Deposit to Earn Vault
Deposit assets to start earning yield.1
Import Dependencies
Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.2
Load Signer and Initialize RPC
Load your keypair from a file and initialize RPC connections.Replace
/path/to/your/keypair.json with the actual path to your keypair file. parseKeypairFile loads an existing keypair from a JSON file. The rpcSubscriptions enables real-time transaction confirmation.3
Load the Vault
Initialize the vault and load its state, reserves, and farm state once. The deposit instructions need all three.4
Set Slippage Protection
Estimate the shares the deposit will mint, minus a slippage tolerance. The deposit reverts if fewer shares would be minted.The deposit amount is in tokens (
1.0 is 1 USDC), not lamports.5
Build Deposit Instructions
Generate the deposit instructions, plus the instructions that stake the new shares in the vault’s farm.If the vault has a rewards farm,
stakeInFarmIfNeededIxs stakes the minted shares in it so the position earns farm rewards. Shares staked here are unstaked automatically when you withdraw.6
Load the Vault’s Lookup Table
Fetch the vault’s address lookup table to keep the transaction small.Every vault has its own lookup table. Compressing with it cuts the deposit from about 1,021 to 528 bytes, well under Solana’s 1,232-byte transaction limit.
7
Build and Sign Transaction
Use Kit’s functional pipe pattern to build, compress, and sign the transaction with a fresh blockhash.8
Send and Confirm Transaction
Send the deposit transaction and wait for confirmation.Once the deposit transaction is confirmed, your assets are deposited into the vault and you start earning yield. Vault shares are minted to represent your position.