The Jupiter Developer Platform is live. Previous portal users keep their rate limits for free until 30 June 2026 — set up billing on the new platform before then. See the Migration Guide for details.
Use this file to discover all available pages before exploring further.
Withdraw collateral (supply assets) from an existing Jupiter Lend borrow position. The SDK builds operate instructions with a negative collateral amount and zero debt change. You can only withdraw up to the amount that keeps your position within the vault’s LTV limits. Transactions use versioned (v0) format with address lookup tables.
Import the required packages for Solana RPC, Jupiter Lend borrow SDK, and versioned transaction building.
import { Connection, Keypair, TransactionMessage, VersionedTransaction,} from "@solana/web3.js";import BN from "bn.js";import { getOperateIx } from "@jup-ag/lend/borrow";import fs from "fs";import path from "path";
Withdraw uses getOperateIx with negative colAmount and zero debtAmount. The withdrawn collateral is sent back to your wallet.
2
Load Keypair and Initialise Connection
Load the signer and create the RPC connection. Set vault ID, position ID, and withdraw amount (positive number; the script passes it as negative to the SDK).
Withdrawing collateral increases your LTV. Ensure you stay below the liquidation threshold; repay debt first if needed.
3
Build Withdraw Instructions
Build operate instructions with negative collateral amount and no debt change.
const { ixs, addressLookupTableAccounts } = await getOperateIx({ vaultId: VAULT_ID, positionId: POSITION_ID, colAmount: WITHDRAW_AMOUNT.neg(), debtAmount: new BN(0), connection, signer,});if (!ixs?.length) { throw new Error("No withdraw instructions returned by Jupiter Lend SDK.");}
Withdraw is operate with colAmount < 0 and debtAmount = 0. Use .neg() so the SDK receives a negative BN. The vault may reject if the withdrawal would breach LTV limits.
4
Build and Sign Transaction
Build a v0 message with the instructions and address lookup tables, then sign.
Signed collateral amount in base units. Positive = deposit. Negative = withdraw (reduce collateral). Pass a negative BN, e.g. WITHDRAW_AMOUNT.neg().
debtAmount
BN
Signed debt amount in base units. Positive = borrow. Negative = repay. Use new BN(0) for withdraw-only.
connection
Connection
Solana RPC connection.
signer
PublicKey
Wallet that signs the transaction (position owner).
For withdraw: colAmount < 0 (negative), debtAmount = 0.
When can I withdraw?
You can withdraw collateral as long as the resulting position stays within the vault’s LTV rules. If you have outstanding debt, the protocol may limit how much you can withdraw until you repay.
Max withdraw (withdraw all collateral)
To withdraw all collateral in one go, use MAX_WITHDRAW_AMOUNT from the SDK as colAmount. The protocol treats this sentinel as “withdraw all collateral”:
This only succeeds if the resulting position stays within LTV (e.g. you have no debt, or you repay first). Otherwise the vault will reject the transaction.