Withdraw from Earn Vault
Withdraw your vault shares to receive the underlying tokens plus accrued interest.Import Dependencies
Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.Load Signer and Initialize Vault
Load your keypair from a file and initialize RPC connections and the vault instance.Replace
/path/to/your/keypair.json with the actual path to your keypair file. The rpcSubscriptions enables real-time transaction confirmation.Build Withdraw Instructions
Generate withdraw instructions including optional unstaking instructions.The
withdrawIxs method returns both unstaking and withdraw instructions. The amount represents vault shares to redeem, not the underlying token amount.Build and Sign Transaction
Use Kit’s functional pipe pattern to build and sign the transaction with a fresh blockhash.Send and Confirm Transaction
Send the withdraw transaction and wait for confirmation.Once the withdraw transaction is confirmed, your vault shares are burned and you receive the underlying tokens plus any accrued interest.