Create Position
Import Dependencies
Import the required packages for Solana RPC communication, Jupiter Lend borrow SDK, and transaction building.
@solana/web3.js provides RPC connection and transaction types. @jup-ag/lend/borrow exposes getInitPositionIx for creating a new position in a vault.Load Keypair and Initialise Connection
Load the signer keypair and create the Solana RPC connection.
Set
VAULT_ID to the target vault (market). Vault IDs are protocol-specific; check Jupiter or the vault list for your market.Build Create Position Instruction
Call the SDK to get the instruction that creates a new position and returns the new position ID (nftId).
getInitPositionIx mints a position NFT for the vault. Save nftId; you use it as positionId for Deposit, Borrow, Withdraw, and Repay.What is a position?
What is a position?
A position is an NFT that represents your borrow account in one vault. One position holds collateral (supply) and debt (borrow) in that vault. You need one position per vault before you can deposit or borrow.
Create and deposit in one transaction
Create and deposit in one transaction
You can skip a separate Create Position step by using
getOperateIx with positionId: 0. The SDK batches init position and the first operate (deposit or borrow) in a single transaction. The returned nftId is your new position ID for future operations. See Deposit for an example.Next steps
Next steps
After creating a position, Deposit collateral, then Borrow. Use Withdraw to remove collateral and Repay to reduce debt.
