These flows use many instructions. If you hit compute limits, add
ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }) (or higher) as the first instruction in your transaction.- Flashloan collateral (SOL) from Jupiter Lend.
- Swap SOL → USDC using Jupiter Lite API (you need USDC to repay debt).
- Use
getOperateIxto repay debt and withdraw collateral. - Pay back the flashloan with the withdrawn SOL.
Unwind
Load Keypair and Initialise Connection
Set
positionId (NFT ID from your multiply position) and withdrawAmount (collateral to unwind in base units). For full unwind, use MAX_REPAY_AMOUNT and MAX_WITHDRAW_AMOUNT.Get Flashloan Instructions
Use
getFlashBorrowIx and getFlashPaybackIx to flashloan the collateral asset (e.g. SOL).Get Quote and Swap Instructions (Jupiter Lite API)
Fetch a quote from Jupiter Lite API (swap collateral → debt), then POST to The
swap-instructions. Use otherAmountThreshold from the quote as the repay amount for partial unwind.jupIxToTransactionInstruction helper converts the JSON instruction from the API into a Solana TransactionInstruction:Get Vault Operations (Repay + Withdraw)
Use
getOperateIx with negative amounts. For full unwind use MAX_WITHDRAW_AMOUNT and MAX_REPAY_AMOUNT. For partial, use withdrawAmount.neg() and repayAmount.neg() where repayAmount = new BN(quoteResponse.otherAmountThreshold).