Documentation Index
Fetch the complete documentation index at: https://docs.meteora.ag/llms.txt
Use this file to discover all available pages before exploring further.
Stake2Earn uses cumulative stake-weighted accounting. Fees released during an update are shared across the current top-staker list according to active stake amount.
All token amounts are integer raw token units. UI values should apply the relevant token decimals.
Key Terms
| Term | Meaning |
|---|
stake_amount | A user’s active staked amount in raw project-token units. |
top_list_length | Number of stakers eligible for newly released fees. Production range: 5 to 1,000. |
effective_stake_amount | Sum of active stake amounts in the current top-staker list. |
locked_fee_a, locked_fee_b | Collected token A and token B fees that have not fully released yet. |
seconds_to_full_unlock | Duration used to drip locked fees. Production range: 6 hours to 31 days. |
cumulative_fee_per_liquidity | Cumulative released fee per unit of eligible stake, scaled by 2^64. |
checkpoint | User’s last accounted cumulative fee-per-stake value. |
fee_pending | User rewards already accounted but not fully claimed. |
unstake_lock_duration | Cooldown duration before a requested unstake can be withdrawn. |
Top-Staker Eligibility
Only active stake in the top-staker list earns newly released fees.
Eligible Stakers=Top N stakers by active stake
N=top_list_length
Production deployments enforce:
5≤N≤1,000
If two active stake amounts are equal, the earlier full-balance-list index ranks higher.
Effective Stake Amount
The effective stake amount is the denominator for reward splitting.
Effective Stake Amount=i∈Top Stakers∑Stake Amounti
If the effective stake amount is zero, released-fee accounting does not advance. The program preserves locked fees for future stakers and updates last_updated_at to the current time.
Fee Collection Gate
When fee accounting runs, the program may claim new fees from the DAMM v1 lock escrow.
After the first claim, production deployments require:
Current Time−Last Claim Fee At≥300 seconds
The program also skips the lock-escrow claim if either pending token fee is zero:
Pending Fee A=0orPending Fee B=0
Even when no new lock-escrow fee is claimed, existing locked fees can still drip during the update.
Fee Distribution Start
Fees are not released until after the configured start timestamp.
Current Time>Start Fee Distribute Timestamp
At initialization, last_updated_at is set to the start timestamp. If the current time is less than or equal to the start timestamp, newly claimed fees are added to locked fees but released amount is zero.
Fee Drip Release
Each token side is released separately. For one token:
Locked Feenew=Locked Feeold+Newly Claimed Fee
Seconds Elapsed=Current Time−Last Updated At
If elapsed time is greater than or equal to the full unlock duration:
Released Fee=Locked Feenew
Otherwise:
Released Fee=⌊Seconds To Full UnlockLocked Feenew×Seconds Elapsed⌋
The program then subtracts the released amount:
Remaining Locked Fee=Locked Feenew−Released Fee
Fee Per Stake
Released fees increase a cumulative fee-per-stake value for the current top-staker list. The program uses SCALE_OFFSET = 64.
Delta Fee Per Stake=⌊Effective Stake AmountReleased Fee×264⌋
Cumulative Fee Per Stakenew=Cumulative Fee Per Stakeold+Delta Fee Per Stake
Token A and token B have separate cumulative values.
Pending User Rewards
A user accrues new pending rewards only while their stake escrow is marked as in the top list.
Unaccounted Fee Per Stake=Current Cumulative Fee Per Stake−User Checkpoint
New Pending Fee=⌊264User Active Stake×Unaccounted Fee Per Stake⌋
User Pending Feenew=User Pending Feeold+New Pending Fee
User Checkpointnew=Current Cumulative Fee Per Stake
When a user enters the top-staker list, their checkpoints are set to the current cumulative values. When a user leaves the top-staker list, their pending rewards are updated before they are marked out.
Claim and Restake
The vault knows which pool token is the stake mint. The stake-mint side is restaked; the quote-mint side is transferred to the user.
If token A is the stake mint:
Restake Amount=Pending Fee A
Quote Claim Amount=min(Pending Fee B,max_fee)
If token B is the stake mint:
Restake Amount=Pending Fee B
Quote Claim Amount=min(Pending Fee A,max_fee)
After claim:
Active Stakenew=Active Stakeold+Restake Amount
The quote side can remain partially pending when max_fee is lower than the available quote reward. The stake-mint side is claimed in full and restaked.
Total Active Stake
The vault’s total active stake changes when users stake, claim restaked base rewards, request unstake, or cancel unstake.
Total Active Stakenew=Total Active Stakeold+Stake Amount
Total Active Stakenew=Total Active Stakeold+Restake Amount
Total Active Stakenew=Total Active Stakeold−Unstake Amount
Total Active Stakenew=Total Active Stakeold+Canceled Unstake Amount
Unstake Cooldown
A requested unstake records a release time:
Release Time=Request Time+Unstake Lock Duration
Withdrawal is allowed only when:
Current Time≥Release Time
Production deployments enforce:
6 hours≤Unstake Lock Duration≤31 days
Requested unstake amounts stop counting as active stake immediately. They do not earn rewards, do not help leaderboard rank, and cannot be withdrawn until the release time is reached.
Rounding and Precision
Stake2Earn uses 2^64 scaling for fee-per-stake accounting, but all transfers and stored pending rewards are integer token amounts. Division rounds down. Small residual value can remain in cumulative accounting or locked-fee balances when released fees do not divide evenly across active top-list stake.
For interfaces, display rewards as estimates until claimed. Exact values depend on fee collection timing, drip timing, leaderboard state, active stake, token decimals, max_fee, and integer rounding.