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 debt asset (USDC) from Jupiter Lend
- Repay full debt and withdraw full collateral
- Swap collateral → debt (enough to cover the flashloan)
- Pay back the flashloan
Repay with Collateral and Max Withdraw
Set Parameters
Hardcode
VAULT_ID, positionId (NFT ID of your position), debtAmount, and collateralSupply (collateral to swap, in base units).Get Vault Operations (Repay + Withdraw)
Use
getOperateIx with MAX_REPAY_AMOUNT and MAX_WITHDRAW_AMOUNT to fully close the position.Get Quote and Swap Instructions (Jupiter Lite API)
Fetch a quote (swap collateral → debt). Ensure the swap output yields at least The
debtAmount of the debt token (account for slippage).jupIxToTransactionInstruction helper converts the JSON instruction from the API into a Solana TransactionInstruction: