Skip to main content

Documentation Index

Fetch the complete documentation index at: https://kamino.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Each reserve in a market can run two independent farms — one for depositors (collateral side) and one for borrowers (debt side). Farms distribute reward emissions over time to position holders, denominated in any token. They’re the curator’s primary lever for attracting deposits or driving borrow demand. Farms are managed by the kfarms program. The klend Reserve account holds two Pubkey fields — farm_collateral and farm_debt — that link the reserve to its farm accounts on kfarms. Once linked, klend automatically updates the farm whenever a depositor or borrower’s balance changes.

Two farms per reserve

struct Reserve {
    // ...
    farm_collateral: Pubkey,   // Pubkey::default() if no farm
    farm_debt: Pubkey,
    // ...
}
FarmWho earnsUse case
Collateral farmDepositors / suppliersAttract liquidity to a reserve. Most common
Debt farmBorrowersSubsidize borrowing. Used to bootstrap utilization or reward leveraged-yield strategies
Each farm can distribute multiple reward tokens simultaneously, with independent emission rates and start/end times.

Initialize a reserve farm via SDK

The klend initFarmsForReserve instruction creates a kfarms FarmState account and links it to the reserve’s farm_collateral or farm_debt slot. The instruction is exposed in the SDK codegen.
import { initFarmsForReserve } from '@kamino-finance/klend-sdk/dist/@codegen/klend/instructions';
import { PROGRAM_ID } from '@kamino-finance/klend-sdk';

// Build args and accounts per the instruction's signature, then:
const ix = initFarmsForReserve(
  { mode: 0 },  // 0 = collateral, 1 = debt
  accounts,
  PROGRAM_ID,
);
// Sign with the curator's wallet and submit
For full args / accounts shapes, see the auto-generated source at klend-sdk/src/@codegen/klend/instructions/initFarmsForReserve.ts.After the farm is created, configure emission rates and reward mints via the kfarms admin tooling — see the farms-sdk repository.

Read farm state

import { createSolanaRpc, address } from '@solana/kit';
import { KaminoMarket, getMedianSlotDurationInMsFromLastEpochs } from '@kamino-finance/klend-sdk';
import { FarmState } from '@kamino-finance/farms-sdk';

const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
const market = await KaminoMarket.load(rpc, address('<MARKET_ADDRESS>'), slotDuration);

for (const reserve of market!.getReserves()) {
  const collFarm = reserve.getCollateralFarmAddress();
  const debtFarm = reserve.getDebtFarmAddress();

  if (collFarm) {
    const farmState = await FarmState.fetch(rpc, collFarm);
    console.log(`${reserve.symbol} collateral farm:`, farmState);
  }
  if (debtFarm) {
    const farmState = await FarmState.fetch(rpc, debtFarm);
    console.log(`${reserve.symbol} debt farm:`, farmState);
  }
}

Claim rewards

import { Farms } from '@kamino-finance/farms-sdk';

const farms = new Farms(rpc);

const claimIxs = await farms.claimForUserForFarmAllRewardsIx(
  payer,                          // TransactionSigner
  address('<USER_WALLET>'),
  address('<FARM_ADDRESS>'),
  false,                          // isDelegated
);
// Bundle into a transaction and submit
For a step-by-step claiming walkthrough, see Claim user rewards.

Initialization workflow

1

Decide collateral side, debt side, or both

Most markets initialize the collateral farm only. Initialize the debt farm only if you plan to incentivize borrowers.
2

Generate the farm state keypair

Each farm is its own on-chain account. Generate a fresh keypair to use as the farm address.
3

Call init-farms-for-reserve

The klend program initializes the farm via CPI to kfarms and stores the farm address on the reserve. After this, klend automatically refreshes the farm on every deposit / withdraw / borrow / repay touching the reserve.
4

Configure emissions

Use kfarms admin tooling to set reward tokens, emission rates, and start/end timestamps. The standard pattern is one reward mint per active campaign; multiple mints can run in parallel.
5

Fund the farm

Transfer the reward tokens to the farm’s reward vault. Without funding, emissions accrue notionally but cannot be claimed.

How emissions accrue

Once a farm is active and funded:
  • klend auto-refreshes the farm on every position-changing operation (deposit, withdraw, borrow, repay)
  • Each user’s pending rewards accumulate proportionally to their share of the farm’s total weight (collateral side: their share of total deposits; debt side: their share of total borrows)
  • Rewards are claimable at any time via the kfarms claim-rewards instruction
  • Emission rates are tokens-per-unit-time set on the kfarms FarmState

Operating a farm

Common adjustments after launch:
ActionHow
Add a new reward tokenAdd the mint to the farm’s reward set via kfarms admin instructions
Change emission rateUpdate the rate via kfarms; the change applies prospectively
End a campaignSet the campaign’s end timestamp via kfarms; emissions stop accruing after that point
Top up reward fundsTransfer more tokens to the farm’s reward vault
Drain unused rewardsUse kfarms admin to withdraw remaining unclaimed funds (subject to kfarms admin rules)
Most curators operate the farm via Squads multisig once it’s live. The kfarms admin authority should match the operational posture of the market itself.

When to use a debt farm

Debt farms (rewards for borrowers) are less common than collateral farms but valuable in specific scenarios:
ScenarioWhy a debt farm makes sense
Bootstrapping a new fixed-term reserveSubsidize borrowers until natural demand develops
Yield-leverage strategies (looping)Rewards on the debt side compound the strategy’s effective APY
Cross-incentive programReward both depositors (collateral) and borrowers (debt) on the same reserve to drive utilization toward a target
Debt farms have the same mechanical structure as collateral farms (emission rates, reward mints, claim flow); only the underlying weight (borrow balances vs deposit balances) changes.

Reference