Prerequisites
Create Position and Deposit Collateral
Import Dependencies
Configure Privy and Initialise Client
Set up your Privy credentials, Solana connection, and borrow parameters.AUTH_KEY_ID identifies the authorization key (from dashboard/API), AUTH_KEY_PRIVATE is the P-256 private key used for signing. See the Privy authorization keys docs for setup.Get Wallet Address
Build Create Position + Deposit Instructions
PasspositionId: 0 to create a new position and deposit collateral in a single transaction. The SDK returns nftId for future operations.nftId for subsequent operations (borrow, repay, withdraw). With positionId: 0, the SDK batches position creation and collateral deposit into one transaction.Build and Sign Transaction
Borrow transactions use versioned (v0) format with address lookup tables.Send Transaction
Borrow Against Collateral
Once you have a position with deposited collateral, borrow assets against it.Build Borrow Instructions
Use thenftId from the previous step as positionId. Set colAmount to 0 and debtAmount to the borrow amount.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 deposit 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). |
