Stake2Earn
Introduction
Stake2Earn is a hassle-free solution that creators can use immediately to implement an automated staking mechanism for their memecoins.
Program Address
- Mainnet-beta:
FEESngU3neckdwib9X3KWqdL7Mjmqk9XNp3uh5JbP4KP
- Devnet:
FEESngU3neckdwib9X3KWqdL7Mjmqk9XNp3uh5JbP4KP
Resources
Features
Staking System for Fee Distribution
Users can stake meme tokens to earn trading fees from a DAMM v1 pool. Only the top stakers (configurable number) receive fee distributions. The program maintains a top staker list and a full balance list to track all participants.
Vault Initialization
Creates a vault associated with a specific AMM pool (Dynamic AMM) with configurable parameters:
top_list_length
: Number of top holders who receive fees (min: 10, max: 300)seconds_to_full_unlock
: Time for locked fees to be fully distributed (min: 60s, max: 30 days)unstake_lock_duration
: Lock period for unstaking (min: 1 hour, max: 30 days)start_fee_distribute_timestamp
: When fee distribution begins
Staking Operations
- Stake: Users deposit meme tokens to participate in fee sharing
- Initialize Stake Escrow: Creates an escrow account for each staker
- Automatic tracking of stake amounts and positions in the top holder list
Fee Claiming Mechanism
Claims fees from the associated DAMM v1 pool with:
- Dual token fees: Supports both base (meme) and quote (SOL/USDC) tokens
- Auto-restaking: Claimed meme tokens are automatically restaked
- Quote token withdrawal: Only quote tokens (SOL/USDC) are sent to users
- Fees distributed proportionally based on stake amount among top holders
- Time-locked fee release mechanism for gradual distribution
Unstaking Process
- Request Unstake: Initiates unstaking with a lock period
- Cancel Unstake: Allows cancellation before the lock period ends
- Withdraw: Complete withdrawal after the lock period expires
- Maintains
ongoing_total_partial_unstake_amount
to track pending unstakes
Dynamic Top Holder Management
- Automatically updates the top staker list when stakes change
- Tracks whether a staker is in the top list (in_top_list flag)
- Adjusts fee distribution checkpoints when users enter/exit the top list
Fee Distribution Algorithm
- Uses a checkpoint system with cumulative fee per liquidity
- Calculates pending fees based on stake amount and time in the top list
- Supports gradual fee release over
seconds_to_full_unlock
period
Permissionless
- Claim Fee Crank: Anyone can trigger fee claims from the AMM pool
- Helps ensure regular fee collection even if users don’t claim