$npx -y skills add jup-ag/agent-skills --skill jupiter-lendInteract with Jupiter Lend Protocol. Read-only SDK (@jup-ag/lend-read) for querying liquidity pools, lending markets (jlTokens), and vaults. Write SDK (@jup-ag/lend) for lending (deposit/withdraw) and vault operations (deposit collateral, borrow, repay, manage positions).
| 1 | # Jupiter Lend Protocol |
| 2 | |
| 3 | Jupiter Lend (powered by Fluid Protocol) is a lending and borrowing protocol on Solana. It offers **Liquidity Pools**, **Lending Markets (jlTokens)**, and **Vaults** for leveraged positions. |
| 4 | |
| 5 | The protocol uses two main SDKs: |
| 6 | |
| 7 | - `@jup-ag/lend-read`: Read-only queries for all programs (Liquidity, Lending, Vaults) |
| 8 | - `@jup-ag/lend`: Write operations (deposit, withdraw, borrow, repay) |
| 9 | |
| 10 | ## Agent usage |
| 11 | |
| 12 | Example prompts you can use to demo Jupiter Lend integrations: |
| 13 | |
| 14 | - Discover all available vaults and list them |
| 15 | - Fetch all vault positions for a user |
| 16 | - Deposit collateral and borrow in a single transaction |
| 17 | - Repay max debt and withdraw max collateral for a position |
| 18 | - Get user Earn (jlToken) positions and underlying balances |
| 19 | - Build a flashloan for arbitrage or liquidation |
| 20 | - Get liquidity rates and APY for a token |
| 21 | - Create a new vault position (positionId 0), deposit collateral, and borrow |
| 22 | |
| 23 | ## SDK Installation |
| 24 | |
| 25 | ```bash |
| 26 | # For read operations (queries, prices, positions) |
| 27 | npm install @jup-ag/lend-read |
| 28 | |
| 29 | # For write operations (transactions) |
| 30 | npm install @jup-ag/lend |
| 31 | ``` |
| 32 | |
| 33 | --- |
| 34 | |
| 35 | # 1. Key Concepts & Protocol Jargon |
| 36 | |
| 37 | Understanding the architecture and terminology of Jupiter Lend will help you build better integrations. |
| 38 | |
| 39 | ### Architecture: The Two-Layer Model |
| 40 | |
| 41 | - **Liquidity Layer (Single Orderbook)**: The foundational layer where all assets reside. It manages token limits, rate curves, and unified liquidity. Users never interact with this directly. |
| 42 | - **Protocol Layer**: User-facing modules (Lending and Vaults) that sit on top of the Liquidity Layer and interact with it via Cross-Program Invocations (CPIs). |
| 43 | |
| 44 | ### Terminology |
| 45 | |
| 46 | - **jlToken (Jupiter Lend Token)**: The yield-bearing asset you receive when supplying tokens to the Lending protocol (e.g., `jlUSDC`). As interest accrues, the exchange rate increases, making your `jlToken` worth more underlying `USDC`. |
| 47 | - **Exchange Price**: The conversion rate used to translate between "raw" stored amounts and actual token amounts. It continuously increases as interest is earned on supply or accrued on debt. |
| 48 | - **Collateral Factor (CF)**: The maximum Loan-to-Value (LTV) ratio allowed when opening or managing a position. |
| 49 | - **Liquidation Threshold (LT)**: The LTV at which a position becomes undercollateralized and eligible for liquidation. |
| 50 | - **Liquidation Max Limit (LML)**: The absolute maximum LTV limit. If a position's risk ratio exceeds this boundary, it is automatically absorbed by the protocol to protect liquidity providers. |
| 51 | - **Liquidation Penalty**: The discount percentage offered to liquidators when they repay debt on behalf of a risky position. |
| 52 | - **Rebalance**: An operation that synchronizes the upper protocol layer's accounting (Vaults/Lending) with its actual position on the Liquidity layer. It also syncs the orderbook to account for any active accrued rewards. |
| 53 | - **Tick-based Architecture**: The Vaults protocol groups positions into "ticks" based on their risk level (debt-to-collateral ratio). This allows the protocol to efficiently manage risk and process liquidations at scale. |
| 54 | - **Dust Borrow**: A tiny residual amount of debt intentionally kept on positions to handle division rounding complexities. |
| 55 | - **Sentinel Values**: Constants like `MAX_WITHDRAW_AMOUNT` and `MAX_REPAY_AMOUNT` that tell the protocol to dynamically calculate and withdraw/repay the maximum mathematically possible amount for a position. |
| 56 | |
| 57 | ### Amounts and units |
| 58 | |
| 59 | All SDK amounts use **base units** (smallest token unit, e.g. `1_000_000` = 1 USDC for 6 decimals). |
| 60 | |
| 61 | --- |
| 62 | |
| 63 | # 2. Jupiter Earn (Lending) |
| 64 | |
| 65 | Jupiter Earn allows users to supply assets to earn yield. In return, users receive yield-bearing `jlTokens` (e.g., `jlUSDC`). |
| 66 | |
| 67 | ### Lending Module (jlTokens) |
| 68 | |
| 69 | Access jlToken (Jupiter Lend token) markets, exchange prices, and user positions. |
| 70 | |
| 71 | ```typescript |
| 72 | // Get all jlToken details at once |
| 73 | const allDetails = await client.lending.getAllJlTokenDetails(); |
| 74 | |
| 75 | // Get user's jlToken balance |
| 76 | const position = await client.lending.getUserPosition(USDC, userPublicKey); |
| 77 | ``` |
| 78 | |
| 79 | ## Lending (Earn) |
| 80 | |
| 81 | Deposit underlying assets to receive yield-bearing tokens, or withdraw them. |
| 82 | |
| 83 | ```typescript |
| 84 | import { getDepositIxs, getWithdrawIxs } from "@jup-ag/lend/earn"; |
| 85 | import BN from "bn.js"; |
| 86 | |
| 87 | // Deposit 1 USDC (base units: 1_000_000 for 6 decimals) |
| 88 | const { ixs: depositIxs } = await getDepositIxs({ |
| 89 | amount: new BN(1_000_000), |
| 90 | asset: USDC_PUBKEY, |
| 91 | signer: userPublicKey, |
| 92 | connection, |
| 93 | }); |
| 94 | |
| 95 | // Withdraw 0.1 USDC (100_000 base units @ 6 decimals) |
| 96 | const { ixs: withdrawIxs } = await getWithdrawIxs({ |
| 97 | amount: new BN |