Stake2Earn Pools are DAMM v1 Pools that are launched with a Stake2Earn Vault. This page provides code examples to initialize and seed a Stake2Earn Pool together with an Alpha Vault.

Key Components:

  • DAMM v1 Pool: A DAMM v1 Pool created with a fee scheduler and with initial liquidity perma-locked
  • Stake2Earn Vault: Stake-to-earn farming mechanism and vault where top stakers can earn a share of fees from the locked liquidity
  • Stake2Earn Pool: A Memecoin Pool with a Stake2Earn Vault
  • Alpha Vault: Anti-sniper tool that allows depositors to be the first to buy from the pool and be guaranteed a share of tokens at the same average price

Getting Started

API

Dependencies

Install dependencies

# NPM
npm i @meteora-ag/dynamic-amm-sdk @solana/web3.js @solana/spl-token

# YARN
yarn add @meteora-ag/dynamic-amm-sdk @solana/web3.js @solana/spl-token

Initialize AmmImpl instance

import AmmImpl, { MAINNET_POOL } from '@meteora-ag/dynamic-amm-sdk';
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
import { AnchorProvider, Wallet } from '@coral-xyz/anchor';

// Connection, Wallet, and AnchorProvider to interact with the network
const mainnetConnection = new Connection('https://api.mainnet-beta.solana.com');

// Create single instance
const constantProductPool = await AmmImpl.create(mainnetConnection, MAINNET_POOL.USDC_SOL);
const stablePool = await AmmImpl.create(mainnetConnection, MAINNET_POOL.USDT_USDC);

// Or with any other pool address, refer to the pool creation section below
const pool = await AmmImpl.create(mainnetConnection, new PublicKey('...'));

// If you need to create multiple, can consider using `createMultiple`
const pools = [MAINNET_POOL.USDC_SOL, MAINNET_POOL.USDT_USDC];
const [constantProductPool, stablePool] = await AmmImpl.createMultiple(mainnetConnection, pools);

Scripts

1. Choose a suitable Pool and Fee Config

Before creating the pool, you need to choose a suitable pool and fee config. What fee parameters to choose depends on your project’s needs.

Key Requirements:

  • Look at the pool config list and choose a suitable pool_config_key with your preferred fee parameters
  • If you want to create an Alpha Vault, you also need a pool_config_key mapped to a vault_config_key that meets your requirements
  • If none of the existing configs meet your requirements, reach out to Meteora for a custom pool config key

Public Pool Config List

Default Pool Config used by Meteora Frontend

By default, Meteora’s frontend uses this pool config key for Memecoin Pool creation: FiENCCbPi3rFh5pW2AJ59HC53yM32eLaCjMKxRqanKFJ

Note: This config doesn’t allow creation of any Alpha Vault, therefore its vault_config_key field is 1111111...

Custom Pool Config and Fee Curve

Custom Pool Config Key: Integrators such as launchpads may need their own unique custom pool config key for custom pool_creator_authority to prevent front-running.

Important Notes:

  • New dedicated config keys can only be created by Meteora
  • The pool_creator_authority doesn’t work with program address - it needs to be a PDA or normal account
  • Custom fee curves require a dedicated config key from Meteora

Custom Fee Curve for a Specific Pool

If required, Meteora can set a custom fee curve for a single, specific pool. This would override the fee curve used by the pool’s config key.

2. Create the Memecoin Pool

After selecting your preferred pool_config_key, reference this example in the Dynamic AMM SDK:

https://github.com/MeteoraAg/damm-v1-sdk/blob/main/ts-client/src/examples/create_pool_and_lock_liquidity.ts

Update the example with your selected pool config and other parameters to create a Memecoin Pool.

How to assign fee claiming wallets

Refer to the allocations section in the example:

https://github.com/MeteoraAg/damm-v1-sdk/blob/main/ts-client/src/examples/create_pool_and_lock_liquidity.ts#L121

Find your Stake2Earn Vault public key address and allocate the percentage of fees from permanently locked liquidity that you intend to go to the Stake2Earn vault.

How to find the Stake2Earn Vault address

Put your pool public key address in this example to derive the Stake2Earn Vault address before it’s created:

https://github.com/MeteoraAg/stake-for-fee-sdk/blob/3bae081b14c065b88abfbee39e86b6e91cd55a39/ts-client/src/stake-for-fee/helpers/pda.ts#L15

3. Create the Stake2Earn Vault

After creating the Memecoin Pool and setting up fee allocation, use this example to create the Stake2Earn Vault:

https://github.com/MeteoraAg/stake-for-fee-sdk/blob/3bae081b14c065b88abfbee39e86b6e91cd55a39/ts-client/src/stake-for-fee/index.ts#L338

4. Create the Alpha Vault

Use this example to create the Alpha Vault:

https://github.com/MeteoraAg/alpha-vault-sdk/blob/f6a6d0e2113fd94c14d94403b08fe83ff40c4791/ts-client/src/alpha-vault/index.ts#L256

Read the Alpha Vault SDK and code examples for more information.

Alpha Vault with Whitelist

For launches that want to restrict wallet addresses allowed to deposit into the Alpha Vault, specify the whitelistMode in the config:

  • permissionless: No whitelist, anyone can deposit
  • permission_with_authority: Only the Alpha Vault creator can create escrow accounts with max_cap (suitable for ≤100 addresses)
  • permission_with_merkle_proof: Only whitelisted wallets can deposit (requires CSV file of whitelisted addresses)

After deployment

To view pool on the UI, access the link below:

For Dynamic AMM and Memecoin Pool: https://app.meteora.ag/pools/`POOL_ADDRESS`

When can you withdraw tokens from the pool?

CustomizablePermissionless Dynamic AMM: After pool activation point (trading starts)

Important Notes

  • Configure your Stake2Earn staking rewards distribution start time approximately 48 hours after launch to allow more fee accumulation
  • Currently, only SOL or USDC is accepted as the quote token when initializing pools with Alpha Vault in permissionless setup
  • If using a multisig on the Meteora website, ensure it’s the SquadsX multisig (only supported type)
  • There must be a ~1 hour 5 minutes period between deposit close time and pool activation time

Timing Requirements:

  • Crank start point: activationPoint - 3600 (timestamp) or activationPoint - 9000 (slot)
  • Vault deposit close point: Crank start point - 5 min (timestamp) or Crank start point - 750 (slot)

Configuration Details

There are various config files in the config directory containing all configurations required to run the scripts. You also need to provide the keypair for the payer wallet in keypair.json file.

General configuration

  • rpcUrl: Solana RPC URL to get data and send transactions
  • keypairFilePath: Keypair file path to send transactions
  • dryRun: Set to true to send transactions
  • computeUnitPriceMicroLamports: CU price in micro lamports unit (e.g., 100000)
  • createBaseToken: Configuration to create base token
  • baseMint: Base token address if the createBaseToken field is not set
  • quoteSymbol: Quote token symbol, only SOL or USDC is supported
  • quoteMint: Quote token mint for tokens other than SOL or USDC
  • dynamicAmm: Dynamic AMM pool configuration
  • alphaVault: FCFS or Pro-rata Alpha Vault configuration

Configuration constraints:

  • createBaseToken and baseMint cannot be used together
  • dynamicAmm and dlmm cannot be used together

Create Base Token configuration

  • mintBaseTokenAmount: Base token amount to be minted

Dynamic AMM configuration

  • baseAmount: Base token amount
  • quoteAmount: Quote token amount
  • tradeFeeNumerator: Trade fee numerator (fee denominator is 100,000)
  • activationType: Activate pool trading based on slot or timestamp
  • activationPoint: Pool activation point (slot or timestamp value)
  • hasAlphaVault: Whether alpha vault is enabled for this pool

Alpha Vault configuration

  • poolType: Dynamic or DLMM pool type
  • alphaVaultType: Alpha Vault type (fcfs or prorata)
  • depositingPoint: Slot or timestamp that allows deposit
  • startVestingPoint: Slot or timestamp that starts vesting
  • endVestingPoint: Slot or timestamp that ends vesting
  • maxDepositCap: Maximum deposit cap
  • individualDepositingCap: Individual deposit cap
  • escrowFee: Fee to create stake escrow account (charged in native SOL)
  • whitelistMode: permissionless, permission_with_merkle_proof, or permission_with_authority

Alpha Vault Pro-rata configuration

  • depositingPoint: Slot or timestamp that allows deposit
  • startVestingPoint: Slot or timestamp that starts vesting
  • endVestingPoint: Slot or timestamp that ends vesting
  • maxBuyingCap: Maximum buying cap
  • escrowFee: Fee to create stake escrow account
  • whitelistMode: permissionless, permission_with_merkle_proof, or permission_with_authority

Alpha Vault Key Components

Vault Types: Supports both permissionless (without whitelist) and permissioned (with whitelist) Alpha Vaults

Whitelist Modes:

  • Without whitelist: Permissionless
  • With whitelist: PermissionWithMerkleProof, PermissionWithAuthority

alphaVaultType (Vault Mode):

  • Pro-rata
  • FCFS (First-Come, First-Served)

Individual Deposit Cap: Global individual deposit cap without whitelist only possible on FCFS vault mode

Create Stake2Earn Vault configuration

  • topListLength: Length of the top list
  • unstakeLockDurationSecs: Duration to wait before withdraw (from unstake action timestamp)
  • secondsToFullUnlock: Time required for locked claim fee to be fully dripped
  • startFeeDistributeTimestamp: When fee distribution starts (should be 48h after pool activation)

Alpha Vault TypeScript SDK

After creating the Alpha Vault for your pool, check out the Alpha Vault SDK for different ways to interact with it, including depositing funds, cranking the vault to buy tokens, or claiming purchased tokens.