Basic Usage
Build withdraw instructions that can be added to your own transaction flow.1
Import Dependencies
Import the required packages for Solana RPC communication and Kamino SDK operations.Complete Flow
Build, sign, and send a transaction with full implementation using Solana Kit.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.The withdrawal is complete. Your vault shares have been redeemed for the underlying assets.