Skip to main content

Claiming Rewards

Retrieve and claim all pending rewards from a vault position.
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 and reserves once. Both the rewards check and the claim instructions use them.
4

Check Pending Rewards

List the rewards your position has earned, per reward token.
A position earns rewards from the vault’s farm, the vault’s delegated farm, and the farms of the reserves the vault allocates to. Amounts are in lamports, so divide by 10^decimals of the reward token. Unused reward slots return 0 and are skipped.
5

Generate Claim Rewards Instructions

Build the instructions that claim every pending reward in one transaction.
6

Load the Vault’s Lookup Table

Fetch the vault’s address lookup table to keep the transaction small.
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 claim transaction and wait for confirmation.
Once the claim transaction is confirmed, the reward tokens are sent to your wallet.