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 for both standard and subscription-based operations.
Replace /path/to/your/keypair.json with the actual path to your keypair file. The rpcSubscriptions enables real-time transaction confirmation.
3

Initialize Manager and Vault

Initialize the Kamino manager with slot timing and create a vault instance.
The getMedianSlotDurationInMsFromLastEpochs function calculates the median slot duration from recent epochs for accurate timing. This vault instance represents a specific Kamino vault you want to claim rewards from.
4

Generate Claim Rewards Instructions

Request all claim reward instructions for the vault from the Kamino manager.
The getClaimAllRewardsForVaultIxs method generates instructions to claim all available rewards for your position in the specified vault. If no instructions are returned, there may be no claimable rewards available.
5

Build and Sign Transaction

Use Kit’s functional pipe pattern to build and sign the transaction with a fresh blockhash.
Kit’s pipe function enables functional composition of transaction building steps. The signed transaction is ready to be sent to the network.
6

Send and Confirm Transaction

Send the transaction to the network and wait for confirmation using the subscription-based confirmation method.