Skip to main content

Harvest

Claim every pending reward token accrued on a farm to your wallet in one call.
claimForUserForFarmAllRewardsIx walks every reward slot, skips any still under its claim cooldown, and returns one harvest instruction per claimable reward, plus an idempotent ATA-create instruction if the reward token account is missing. It reads on-chain Scope prices itself, so there is nothing to refresh. If the returned array is empty, nothing is past its cooldown to claim.
1

Import Dependencies

Import the packages for Solana RPC communication, Kit transaction building, the keypair loader, and the Farms SDK.
2

Configure Constants and Initialize

Set the keypair path, RPC endpoints, and target farm. Load the signer and initialize the farms client.
3

Build Harvest Instructions

Build one harvest instruction per claimable reward. The payer signs and pays fees; the rewards land in the user’s wallet.
Pass isDelegated: false for a non-delegated farm. For a delegated klend or kvault farm, pass true and the obligation as a delegatee in the optional delegatees argument. See Claim user rewards for the delegated case.
4

Build, Sign, and Send Transaction

Compose the v0 transaction, sign, verify it fits the size limit, then send and confirm.
The harvest is complete. Every reward token past its claim cooldown has been transferred to your wallet.

Full Code Example