Skip to main content
Deposit assets as collateral or supply liquidity into Kamino lending reserves. The SDK handles transaction building, instruction creation, and obligation management for deposit operations.

Deposit for Lending

Supply liquidity to the reserve and earn interest.
1

Import Dependencies

Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.
@solana/kit provides modern utilities for RPC, transaction building, and signing. @kamino-finance/klend-sdk contains market operation methods.
2

Load Market and Initialize RPC

Load the keypair, initialize RPC connections, and load the Kamino market.
KaminoMarket.load() fetches the current market state including all reserve data and configuration.
3

Build Deposit Instructions

Generate deposit reserve liquidity instructions for the specified token and amount.
buildDepositReserveLiquidityTxns creates a lending obligation for earning interest on deposited assets. The obligation parameter specifies the deposit configuration.
4

Send Setup Transaction (If Needed)

If setup instructions are present, send the setup transaction first and wait for confirmation.
Setup transactions must be confirmed and Address Lookup Tables (ALTs) must be activated before sending the main deposit transaction. Waiting 2 seconds ensures account settlement.
5

Build and Send Deposit Transaction

Gather all instructions from the action.
Fetch the latest blockhash and construct the transaction message.
A fresh blockhash is fetched for the main transaction to ensure it remains valid after the setup transaction completes.
Sign and send the transaction.
The deposit is complete. The assets are now supplied to the reserve and earning interest.

Deposit for Borrowing

Deposit USDC as collateral to borrow other assets.
1

Import Dependencies

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

Load Market and Initialize RPC

Load the keypair, initialize RPC connections, and load the Kamino market.
3

Build Deposit Instructions

Build deposit instructions for depositing collateral to enable borrowing.
4

Send Initial Transaction

Fetch the latest blockhash and build the transaction message.
Sign and send the transaction.
5

Handle Retry Logic

Detect and handle setup-related errors that may occur.
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.
Wait for blockchain state to settle and reload the market.
Rebuild the deposit instructions with the reloaded market state.
Fetch a fresh blockhash and build the retry transaction.
Sign and send the retry transaction.
The deposit is complete. The collateral is now deposited and can be used for borrowing other assets.