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 USDC
- Repay all USDC debt and withdraw all SOL from vault 1
- Deposit SOL into vault 2 and borrow USDT with a 1-2 USD buffer for slippage
- Swap the new debt token → USDC
- Pay back the flashloan
Vault Swap
Set Parameters
Hardcode vault IDs,
positionId (NFT ID in vault 1), debtAmount, collateralSupply, and a borrow buffer (e.g. 2 USDC) for slippage.Open Position in Vault 2 (Deposit + Borrow)
Use
positionId: 0 for a new position. Deposit the withdrawn collateral and borrow the new debt token plus buffer.Get Quote and Swap Instructions
Fetch a quote to swap the new debt token (e.g. USDT) → USDC. Ensure output is at least The
debtAmount to cover the flashloan.jupIxToTransactionInstruction helper converts the JSON instruction from the API into a Solana TransactionInstruction: