Skip to main content
Withdraw assets from Kamino Earn vaults to redeem your shares for underlying tokens. The SDK handles transaction building and vault interaction.

Complete Flow

Implement the full withdrawal flow either in an off-chain TypeScript client or via on-chain Rust CPI within your Anchor program.
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 vault operation methods.
2

Load Keypair and Initialize Vault

Load the keypair from file, initialize RPC connections, and create the vault instance.
parseKeypairFile loads an existing keypair from a JSON file.
3

Build Withdraw Instructions

Generate withdraw instructions including optional unstaking instructions.
The withdrawIxs method returns both unstaking and withdraw instructions. The bundle ensures optimal handling by automatically unstaking deposited assets when needed. The amount represents vault shares to redeem.
4

Build and Send Transaction

Fetch the latest blockhash and construct the transaction message.
Kit’s pipe function enables functional composition of transaction building steps for cleaner, more maintainable code.
Sign and send the transaction with built-in confirmation.
The withdrawal is complete. Your vault shares have been redeemed for the underlying assets.

Full Code Example