operate endpoint: one call can create a position, deposit collateral, borrow, repay, and withdraw, driven by signed colAmount and debtAmount values. Positions are represented as NFTs.
Prerequisite
Dependencies
Dependencies
RPC
RPC
Set up RPC
NOTESolana provides a default RPC endpoint. As your application grows, provision your own or a 3rd party provider’s RPC endpoint such as Helius or Triton.
Wallet
Wallet
Set up Development Wallet
Markets
All borrow endpoints accept an optionalmarket parameter: main (default) or ethena. Pass it as a query parameter (?market=ethena) on any endpoint, including operate calls. Omitting it uses the main market.
Vault and position IDs are scoped to a market. The same vaultId refers to a different vault in main than in ethena, so always pass the same market to operate that you used to read the vault or position.
Read vault and position data
Use the read endpoints to discover vaults and inspect user positions. Both accept GET requests.Vaults
GET https://api.jup.ag/lend/v1/borrow/vaults returns every borrow vault with its collateral token (supplyToken), borrow token (borrowToken), risk parameters, rates, and available liquidity. The id field is the vaultId you pass to operate calls.
collateralFactor (max LTV, where 800 corresponds to 80%), liquidationThreshold, borrowable and withdrawable (available liquidity in base units), and minimumBorrowing (the smallest non-zero debt a position may hold).
Positions
GET https://api.jup.ag/lend/v1/borrow/positions?users={user1},{user2} returns the borrow positions for one or more wallets (comma-separated). Each position reports its NFT id, vaultId, supply (collateral), borrow (debt), and dustBorrow (residual debt including accrued interest).
Operate
POST https://api.jup.ag/lend/v1/borrow/operate builds a borrow transaction from an OperatePayload. The operation performed is determined by the sign of colAmount (collateral) and debtAmount (debt):
| Action | colAmount | debtAmount | Notes |
|---|---|---|---|
| Create position + deposit | > 0 | "0" | Set positionId: 0 |
| Deposit collateral | > 0 | "0" | |
| Borrow | "0" | > 0 | Debt must be >= minimumBorrowing |
| Repay | "0" | < 0 | |
| Withdraw collateral | < 0 | "0" | |
| Deposit and borrow | > 0 | > 0 | Single transaction |
| Repay all debt | "0" | MIN_I128 | Clears accrued-interest dust |
| Withdraw all collateral | MIN_I128 | "0" |
MIN_I128 is the literal string -170141183460469231731687303715884105728.
The OperatePayload fields:
| Field | Type | Required | Description |
|---|---|---|---|
vaultId | number | Yes | Vault ID from GET /borrow/vaults. |
positionId | number | Yes | Position NFT ID to operate on. Use 0 to create a new position. |
positionOwner | string | No | Owner of the position. Defaults to signer. |
signer | string | Yes | Wallet that signs and pays for the transaction. |
colAmount | string | Yes | Signed collateral amount in supply-token base units. |
debtAmount | string | Yes | Signed debt amount in borrow-token base units. |
nftId (the position NFT ID, newly assigned when positionId was 0) and a base64-encoded unsigned VersionedTransaction.
The API creates the borrow-token associated token account for the signer when it does not already exist, so borrowing to a fresh wallet works without adding a create-account instruction. You do not need to pre-create the output token account.
Native SOL (WSOL) handling
The API does not wrap or unwrap native SOL. This matters whenever a vault’ssupplyToken or borrowToken is So11111111111111111111111111111111111111112 (WSOL):
- Depositing WSOL collateral: wrap SOL into your WSOL token account first. Without a funded WSOL account, the deposit fails with a token-program
insufficient fundserror. Wrap slightly more than you deposit: depositing your exact WSOL balance can fail because the transfer rounds up by a few base units. - Borrowing or withdrawing WSOL: you receive wrapped SOL in your WSOL token account. Close the account yourself if you want native SOL back.
Repaying the exact
borrow amount can leave interest dust below minimumBorrowing, which fails with VaultUserDebtTooLow. Repay with debtAmount: MIN_I128 to clear all debt before closing a position.Build your own transaction
The Borrow API provides two ways to build an operate transaction. Use/operate for a ready-to-sign transaction, or /operate-instructions when you need the raw instructions to compose with other instructions or for CPI.
Transaction
Call/operate (above), deserialize the base64 transaction, sign, and send.
Instructions
POST https://api.jup.ag/lend/v1/borrow/operate-instructions takes the same OperatePayload and returns { nftId, instructions, addressLookupTableAddresses }. Resolve the address lookup tables and compile a v0 transaction.
CPI
- Refer to github.com/jup-ag/jupiter-lend/blob/main/docs/borrow/cpi.md for the CPI example
- Refer to github.com/jup-ag/jupiter-lend/blob/main/target/idl/vaults.json for the IDL
Full code example
Create a position, deposit collateral, then borrow against it. The borrow step uses/operate-instructions to show the address lookup table flow.
Related
Borrow API Reference
Full request and response schemas for vaults, positions, operate, and operate-instructions.
Read SDK
Read vault config, state, and user positions with
@jup-ag/lend-read.Borrow SDK operations
Build operate flows (create, deposit, borrow, repay, withdraw) with
@jup-ag/lend.Borrow CPI
Cross-program invocation for vault operations.
