Skip to main content

Deposit Collateral

Deposit assets as collateral to enable borrowing.
1

Import Dependencies

Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.
2

Load Signer and Initialize Market

Load your keypair from a file and initialize RPC connections and the Kamino market.
Replace /path/to/your/keypair.json with the actual path to your keypair file. The KaminoMarket.load() method fetches the current market state including all reserve data.
3

Build Deposit Instructions

Build deposit instructions for depositing collateral to enable borrowing.
The buildDepositTxns method creates instructions to deposit collateral. This enables you to borrow other assets against your deposit.
4

Send Deposit Transaction with Error Handling

Send the deposit transaction with automatic retry logic for setup-related errors.
When setup instructions are included, the first transaction may fail with error 0x17a3. The retry logic handles this by waiting for blockchain state to settle, reloading the market, and rebuilding instructions.
Once the deposit transaction is confirmed, your collateral is deposited and you can now borrow assets against it. An obligation is created to track your position.

Borrow Assets

Borrow assets against your deposited collateral.
1

Import Dependencies

Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.
2

Load Signer and Initialize Market

Load your keypair from a file and initialize RPC connections and the Kamino market.
Replace /path/to/your/keypair.json with the actual path to your keypair file. The KaminoMarket.load() method fetches the current market state including all reserve data.
3

Check for Existing Obligation

Verify that an obligation exists before attempting to borrow.
You must have an existing obligation with deposited collateral before you can borrow. If you haven’t deposited collateral yet, do that first.
4

Build Borrow Instructions

Generate borrow instructions for the specified token and amount.
The buildBorrowTxns method creates borrow instructions that withdraw assets from the reserve pool to your wallet. The amount borrowed is added to your debt obligation.
5

Build and Sign Transaction

Use Kit’s functional pipe pattern to build and sign the transaction with a fresh blockhash.
6

Send and Confirm Transaction

Send the borrow transaction and wait for confirmation.
Once the borrow transaction is confirmed, the borrowed assets are transferred to your wallet. You now have a debt obligation that accrues interest. Monitor your loan-to-value ratio to avoid liquidation.