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
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.Load Keypair and Initialise Connection
Load the signer and create the RPC connection. Set vault ID and amounts for each operation.
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.Build and Sign Transaction
Build a v0 message with the merged instructions and address lookup tables, then sign.
Operate parameters
getOperateIx accepts the following parameters:
| Parameter | Type | Description |
|---|---|---|
vaultId | number | Target vault (market) ID. |
positionId | number | Position NFT ID. Use 0 to create a new position and operate in one transaction. |
colAmount | BN | Signed collateral amount in base units. Positive = deposit. Negative = withdraw. Use new BN(0) for borrow/repay-only. |
debtAmount | BN | Signed debt amount in base units. Positive = borrow. Negative = repay. Use new BN(0) for deposit/withdraw-only. |
connection | Connection | Solana RPC connection. |
signer | PublicKey | Wallet that signs the transaction (position owner). |
colAmount and debtAmount in one call (e.g. deposit + borrow: both positive; repay + withdraw: both negative).
Combining operations
Combining operations
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.Using an existing position
Using an existing position
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.