Skip to main content
Withdraw liquidity or collateral from the reserve. The SDK handles transaction building, instruction creation, and collateral release calculations.

Withdraw for Lending

Withdraw liquidity from the reserve.
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

Initialize RPC and Load Market

Initialize the RPC connection and load the Kamino market instance.
KaminoMarket.load() fetches the current market state including all reserve data and configuration.
3

Build Withdraw Reserve Liquidity Instructions

Fetch the existing obligation from the blockchain and build withdraw instructions.
4

Build and Sign Transaction

Use Kit’s functional pipe pattern to build and sign the transaction.
Kit’s pipe function enables functional composition of transaction building steps for cleaner, more maintainable code.
5

Send and Confirm Transaction

Send the transaction and confirm it using WebSocket.

Withdraw for Borrowing

Withdraw collateral from an obligation.
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

Initialize RPC and Load Market

Initialize the RPC connection and load the Kamino market instance.
KaminoMarket.load() fetches the current market state including all reserve data and configuration.
3

Build Withdraw Collateral Instructions

Build withdraw instructions for collateral withdrawal.
4

Build and Sign Transaction

Use Kit’s functional pipe pattern to build and sign the transaction.
5

Send and Confirm Transaction

Send the transaction and confirm it using WebSocket.
  1. The collateral amount is removed from your obligation
  2. Your borrowing capacity decreases
  3. Your loan-to-value (LTV) ratio increases