Skip to main content

Withdraw from Earn Vault

Withdraw your vault shares to receive the underlying tokens plus accrued interest.
1

Import Dependencies

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

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.
3

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.
4

Build and Sign Transaction

Use Kit’s functional pipe pattern to build and sign the transaction with a fresh blockhash.
5

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.