Skip to main content
Combine multiple borrow operations into one transaction. Pass both colAmount and debtAmount in a single getOperateIx call to batch operations (e.g. deposit + borrow, or repay + withdraw). When positionId is 0, the first call creates a new position and returns positionId for use in the second call. Transactions use versioned (v0) format with address lookup tables.

Combined operations

1

Import Dependencies

Import the required packages for Solana RPC, Jupiter Lend borrow SDK, and versioned transaction building.
Combined operations use multiple getOperateIx calls. Pass both colAmount and debtAmount in one call to batch deposit + borrow or repay + withdraw.
2

Load Keypair and Initialise Connection

Load the signer and create the RPC connection. Set vault ID and amounts for each operation.
3

Build Operate Instructions

Call getOperateIx twice: once with positionId: 0 to create a position and deposit + borrow; once with the returned positionId to repay + withdraw. Then merge instructions and address lookup tables.
When positionId is 0, the SDK creates a new position and returns positionId. Use that positionId in the second call. Deduplicate address lookup tables by key when merging.
4

Build and Sign Transaction

Build a v0 message with the merged instructions and address lookup tables, then sign.
5

Send and Confirm Transaction

Send the transaction and confirm.

Operate parameters

getOperateIx accepts the following parameters: Combine operations by passing both colAmount and debtAmount in one call (e.g. deposit + borrow: both positive; repay + withdraw: both negative).
Pass both colAmount and debtAmount in a single getOperateIx call to batch two operations. Deposit + borrow: colAmount > 0, debtAmount > 0. Repay + withdraw: colAmount < 0, debtAmount < 0.
If you already have a position, use its positionId instead of 0 in the first call and skip the create step. Or use positionId: positionId for both calls when doing repay + withdraw only.

Full code example