Documentation Index
Fetch the complete documentation index at: https://docs.raydium.io/llms.txt
Use this file to discover all available pages before exploring further.
Three programs, three schemas. Farm v3, v5, and v6 are separate programs with separate state layouts. This page documents each side by side. In practice most new integrations target v6; v3 and v5 are read-only for most integrators (staking already happened there long ago and the pools are in wind-down).
Account inventory (per farm, any version)
| Account | Owner | Purpose |
|---|---|---|
FarmState | Farm program (v3/v5/v6) | Root state: staking mint, total staked, reward streams. |
farm_authority | Farm program | PDA that owns the staking vault and the reward vaults. |
staking_vault | SPL Token | Holds staked LP (or whatever the staking mint is). |
reward_vault_{i} | SPL Token | Holds the undistributed budget for reward stream i. One per stream. |
UserStake (v3/v5) / UserLedger (v6) | Farm program | Per-(farm, user) ledger: staked amount + snapshot of reward-per-share per stream. |
raydium.farm.getFarmById. For arbitrary third-party farms, the API endpoint GET https://api-v3.raydium.io/main/farms/info?ids=<FARM_ID> also returns them.
FarmState layout — v6
v6 is the current version. Its account structure is the most general.
staking_mint,staking_vault— what gets staked and where it sits.total_staked— current total. Required to compute APR:reward_per_second × 86400 / total_staked.reward_infos[i].emission_per_second_x64— the Q64.64 rate. Divide by2^64for the true per-second token count.reward_infos[i].open_time/end_time— for UI “X days left” displays.reward_infos[i].reward_per_share_x64— the counter theUserLedgerdebts off.
FarmState layout — v5
- Per-slot, not per-second. v5’s update loop runs on slots rather than on the wall clock. The SDK normalizes this into “per-second” for the UI but on-chain the unit is slots.
- Integer emission rate.
reward_per_secondisu64. This caps the minimum expressible rate at 1 unit per second, which is too coarse for low-emission streams on 9-decimal mints. v6 fixed this with the Q64.64 rate. - No
reward_sender. On v5 the owner is the implicit sender; onlyownercan top up.
FarmState layout — v3
UserLedger (v6) / UserStake (v5/v3)
Per-user state, one account per (farm, user) pair. Seeded PDA:
Deposit, Withdraw, or Harvest, the debt is reset to the current deposited × reward_per_share_x64[i] / 2^64.
Authority PDAs
Vaults
Staking and reward vaults are standard SPL Token accounts whoseowner is the farm authority PDA. Addresses are stored on FarmState — do not re-derive; read from state. Freeze authorities must be disabled on the staking mint for v5/v6 (the program checks).
Token-2022 notes:
- v3: SPL Token only.
- v5: SPL Token only.
- v6: Supports Token-2022 on both staking and reward mints, gated on
staking_token_program/reward_token_programfields. Transfer fees on Token-2022 reward mints are charged on emit (vault → user).
Observation and APR
Farms do not store APR on-chain. To compute:staking_mint_usd_price from the pool the LP belongs to (via api-v3.raydium.io/pools/info/ids) and reward_usd_price from any price oracle.
Where to go next
products/farm-staking/instructions— per-version instruction reference.products/farm-staking/code-demos— staking, harvesting, and creating farms via the SDK.reference/program-addresses— all three program IDs.
- Raydium SDK v2
Farmmodule - Farm v6 program source is not currently published as a standalone repo; the IDL is bundled in the SDK at
raydium-io/raydium-sdk-V2undersrc/raydium/farm/.


