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.

Stake2Earn transactions that touch fees must pass fresh DAMM v1 pool, lock escrow, Dynamic Vault, LP mint, and token vault accounts. The TypeScript SDK builds these account bundles automatically.

Instruction Index

InstructionAccessArgumentsUse
initialize_vaultPermissionless public buildInitializeVaultParamsCreate a vault for a DAMM v1 constant-product pool and initialize list accounts.
initialize_stake_escrowPermissionlessNoneCreate a user’s stake escrow and grow the list accounts when needed.
stakeStake escrow owneramount: u64Claim and distribute lock escrow fees, transfer stake tokens, and sync top/full lists.
claim_feeStake escrow ownermax_fee: u64Claim quote token fees to the user and automatically restake base/stake token fees.
request_unstakeStake escrow ownerunstake_amount: u64Reserve stake for withdrawal and create an Unstake account with a release time.
cancel_unstakeStake escrow ownerNoneClose an Unstake account and return the amount to active stake.
withdrawStake escrow ownerNoneTransfer released unstaked tokens back to the user and close the Unstake account.
claim_fee_crankPermissionlessNoneClaim fees from the DAMM v1 lock escrow and update fee drip state without a user claim.
update_unstake_lock_durationAdmin signerunstake_lock_duration: u64Update the cooldown for future unstake requests.
update_seconds_to_full_unlockAdmin signerseconds_to_full_unlock: u64Update fee drip duration after a preceding claim_fee_crank instruction.
_dummyInternalNoneIDL-generation helper only. Do not call in integrations.
All public user/admin instructions in the source use Anchor Event CPI, so generated clients include event_authority and program accounts.

initialize_vault

Creates the root vault and list accounts for a DAMM v1 pool.
RequirementDetails
Vault PDA["vault", pool]. There can be one Stake2Earn vault per DAMM v1 pool.
Pool typeDAMM v1 constant product only.
Mintsstake_mint and quote_mint must both belong to the pool. quote_mint must be SOL or USDC; stake_mint must not be SOL or USDC.
Lock escrowDAMM v1 lock escrow must have owner == vault and pool == pool.
List lengthPublic builds allow top_list_length from 5 to 1000.
Drip durationPublic builds allow seconds_to_full_unlock from 6 hours to 31 days.
Unstake lockPublic builds allow unstake_lock_duration from 6 hours to 31 days.
Start timestampOptional. If supplied, it must be no more than 31 days after the current on-chain timestamp.
AccountRole
vaultInitialized FeeVault PDA.
stake_token_vaultATA for stake_mint, owned by the vault PDA.
quote_token_vaultATA for quote_mint, owned by the vault PDA.
top_staker_listInitialized TopListMetadata PDA.
full_balance_listInitialized FullBalanceListMetadata PDA.
poolDAMM v1 pool account.
stake_mint, quote_mintPool mints.
lock_escrowDAMM v1 lock escrow owned by the vault PDA.
payerSigner paying account rent.
system_program, token_program, associated_token_programRequired Solana programs.
Emits VaultCreated.

initialize_stake_escrow

Creates a user stake escrow for one vault.
AccountRole
vaultParent FeeVault.
escrowInitialized PDA ["escrow", vault, owner].
full_balance_listReallocated to append the user if under the hard limit.
top_staker_listReallocated while current_length < top_list_length.
ownerWallet that owns the stake escrow.
payerSigner paying rent and realloc costs.
system_programRequired for account creation and realloc.
The handler increments total_stake_escrow_count, initializes an empty stake escrow, and appends a full-balance entry when capacity remains. Emits StakeEscrowCreated.

Fee Claim Account Bundle

These accounts are required by stake, claim_fee, request_unstake, cancel_unstake, and claim_fee_crank because each flow first claims and distributes fees from the DAMM v1 lock escrow.
AccountRequirement
poolDAMM v1 pool; must reference the supplied vaults, LP accounts, and LP mint.
lp_mintDAMM v1 LP mint.
lock_escrowLock escrow stored on the FeeVault.
escrow_vaultToken account for locked LP; validated by the DAMM v1 program.
a_token_vault, b_token_vaultToken vault accounts for Dynamic Vault reserves.
a_vault, b_vaultDynamic Vault accounts from the DAMM v1 pool.
a_vault_lp, b_vault_lpDAMM v1 pool LP token accounts for each Dynamic Vault.
a_vault_lp_mint, b_vault_lp_mintLP mints for the Dynamic Vault accounts.
amm_programDAMM v1 program.
vault_programDynamic Vault program.
token_programSPL Token program.

stake

Transfers stake tokens from the user into the vault and syncs list state.
BehaviorDetails
AmountThe handler stakes min(amount, user_stake_token.amount).
Auto-create helperThe TypeScript SDK includes initialize_stake_escrow as a pre-instruction when the stake escrow does not exist.
Top list syncProvide replaceable top staker accounts in remaining_accounts when the new stake can affect rankings.
Full list reclaimProvide smallest_stake_escrow when reclaiming a full-balance index from the smallest tracked staker.
EventsEmits FeeEmission, optional list movement events, and UserStake.

claim_fee

Claims fees from a stake escrow.
BehaviorDetails
Fee updateClaims from the DAMM v1 lock escrow, releases dripped fees, updates the caller’s stake escrow, then claims user fees.
Quote transferOnly quote token fees are transferred to user_quote_token.
Base restakeBase/stake token fees are kept in the vault and added to the user’s active stake_amount.
max_feeCaps the quote token amount the user receives. The stake/base side is fully restaked.
SOL handlingThe TypeScript SDK adds a post-instruction to close the user’s wrapped SOL ATA after claiming.
EventsEmits FeeEmission, ClaimFeeSucceed, optional list movement events, and UserStake.

request_unstake

Creates a pending unstake request.
Account or argumentDetails
unstakeNew arbitrary account keypair initialized by the instruction.
unstake_amountMust be less than or equal to the active stake_amount.
Release timeClock::unix_timestamp + vault.configuration.unstake_lock_duration.
List syncRemoves stake from active balances and updates top/full lists.
EventsEmits FeeEmission, optional top list movement events, and UnstakeCreated.

cancel_unstake

Closes an open Unstake account and returns the amount to active stake.
BehaviorDetails
Fee updateClaims and distributes pending lock escrow fees before mutating stake.
Stake updateIncreases stake_amount and decreases ongoing unstake counters.
List syncRe-ranks the user and replacement candidates.
EventsEmits FeeEmission, optional list movement events, and CancelUnstakeSucceed.

withdraw

Transfers stake tokens from the vault back to the owner after the release time.
RequirementDetails
Release checkFails until Clock::unix_timestamp >= unstake.release_at.
Transfer authorityThe vault PDA signs for stake_token_vault with ["vault", pool, bump].
Close behaviorCloses the Unstake account to the owner.
EventsEmits WithdrawSucceed.

claim_fee_crank

Permissionlessly claims fees from the DAMM v1 lock escrow and updates drip accounting without a user claim.
BehaviorDetails
Minimum intervalPublic builds require at least 5 minutes between lock escrow fee claims.
User accountNo stake escrow is required.
EventsEmits FeeEmission when fees are claimed/released.
Admin dependencyupdate_seconds_to_full_unlock requires the immediately preceding instruction to be claim_fee_crank for the same vault.

Admin Updates

InstructionConstraintsEvent
update_unstake_lock_durationAdmin signer; value from 6 hours to 31 days; must differ from current value.UpdateUnstakeLockDuration
update_seconds_to_full_unlockAdmin signer; value from 6 hours to 31 days; immediately preceding instruction must be claim_fee_crank for the same vault.UpdateSecondsToFullUnlock
Admin public keys are hardcoded in the program source for public builds.

Gotchas

GotchaIntegration impact
Event CPI accountsInclude event_authority and program when using low-level clients.
DAMM v1 onlyDAMM v2 and DLMM pools are not accepted by initialize_vault.
Quote mint restrictionOnly SOL and USDC quote mints pass validation on public builds.
Remaining accountsTop list replacements require candidate stake escrow accounts in remaining_accounts.
Open unstake keypairrequest_unstake initializes a caller-provided account; it must sign the transaction.
Fee crank orderingAdmin update_seconds_to_full_unlock must be placed immediately after claim_fee_crank in the same transaction.