Skip to main content

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.

Rust CPI integrations should prefer the generated stake_for_fee_interface invoke helpers over hand-built discriminators. The helpers expose both *_invoke and *_invoke_signed variants for every instruction.
Stake2Earn instructions use Anchor Event CPI. CPI callers must include the generated event_authority account and the Stake2Earn program account where the generated key structs require them.

CPI Helper Families

FlowGenerated helper
Initialize vaultinitialize_vault_invoke / initialize_vault_invoke_signed
Initialize stake escrowinitialize_stake_escrow_invoke / initialize_stake_escrow_invoke_signed
Stakestake_invoke / stake_invoke_signed
Claim feeclaim_fee_invoke / claim_fee_invoke_signed
Request unstakerequest_unstake_invoke / request_unstake_invoke_signed
Cancel unstakecancel_unstake_invoke / cancel_unstake_invoke_signed
Withdrawwithdraw_invoke / withdraw_invoke_signed
Claim fee crankclaim_fee_crank_invoke / claim_fee_crank_invoke_signed
Admin updatesupdate_unstake_lock_duration_invoke, update_seconds_to_full_unlock_invoke

Initialize Vault CPI

initialize_vault creates the Stake2Earn vault and two list accounts.
AccountRequirement
vaultPDA ["vault", pool], initialized by the instruction.
stake_token_vaultATA for stake_mint, authority vault.
quote_token_vaultATA for quote_mint, authority vault.
top_staker_listPDA ["list", vault], initialized by the instruction.
full_balance_listPDA ["balance", vault], initialized by the instruction.
poolDAMM v1 constant-product pool containing the stake and quote mints.
stake_mint, quote_mintPool mints; quote must be SOL or USDC.
lock_escrowDAMM v1 lock escrow owned by vault.
payerRent payer signer.
event_authority, programAnchor Event CPI accounts.
ParameterConstraint
top_list_lengthPublic range 5 to 1000.
seconds_to_full_unlockPublic range 6 hours to 31 days.
unstake_lock_durationPublic range 6 hours to 31 days.
start_fee_distribute_timestampOptional; max join window is 31 days.
padding[0; 64] in current clients.

Stake And Claim CPI

stake and claim_fee are not isolated stake-account mutations. They first claim and distribute pending DAMM v1 lock escrow fees, so callers must include the full DAMM v1 and Dynamic Vault account bundle.
Account groupAccounts
Stake2Earn statevault, stake_token_vault, quote_token_vault, top_staker_list, full_balance_list, stake_escrow, optional smallest_stake_escrow
User accountsowner, user_stake_token for stake, user_quote_token for claim_fee
DAMM v1 lock escrowpool, lp_mint, lock_escrow, escrow_vault
Dynamic Vault accountsa_token_vault, b_token_vault, a_vault, b_vault, a_vault_lp, b_vault_lp, a_vault_lp_mint, b_vault_lp_mint
ProgramsDAMM v1 program, Dynamic Vault program, SPL Token program, Event CPI accounts
Top-list synchronization may require additional stake escrow accounts in remaining_accounts. If the full balance list index must be reclaimed, pass the expected smallest_stake_escrow.

Unstake CPI

InstructionCPI notes
request_unstakeInitializes a caller-provided Unstake account, claims/distributes lock escrow fees, decreases active stake, updates list state, and sets release_at.
cancel_unstakeCloses Unstake to the owner, claims/distributes fees, returns the amount to active stake, and syncs list state.
withdrawDoes not need the DAMM v1 fee-claim bundle. It checks release_at, transfers stake tokens from stake_token_vault to user_stake_token, updates ongoing unstake counters, and closes Unstake.

Vault PDA Signer Seeds

When the Stake2Earn program signs for its token vaults internally, it uses:
PDASeeds
FeeVault signer["vault", pool, bump]
External CPI callers do not sign as the Stake2Earn vault PDA unless they are invoking another program directly. If your program composes DAMM v1 lock escrow setup before calling Stake2Earn, ensure the lock escrow owner is the Stake2Earn vault PDA.

Crank And Admin CPI

InstructionNotes
claim_fee_crankPermissionless. Requires the same DAMM v1 and Dynamic Vault fee-claim bundle but no user stake escrow.
update_unstake_lock_durationAdmin signer only. New value affects future unstake requests.
update_seconds_to_full_unlockAdmin signer only. The immediately preceding instruction in the same transaction must be claim_fee_crank for the same vault and program.

CPI Gotchas

GotchaResolution
Missing Event CPI accountsDerive ["__event_authority"] and include the stake_for_fee program account when the generated key struct requires them.
Stale DAMM v1 or Dynamic Vault accountsRe-read account state before building fee-claim flows.
Wrong quote mintOnly SOL and USDC quote mints are accepted on public builds.
Missing replacement stake escrowsSupply remaining accounts for top-list promotion/removal when stake changes can affect rankings.
Withdraw before releaseRead the Unstake account and compare release_at with the current clock before sending.