meteora

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Meteora Protocol Development Guide

Meteora协议开发指南

A comprehensive guide for building Solana DeFi applications with Meteora's suite of SDKs - the leading liquidity infrastructure on Solana.
本指南全面介绍如何使用Meteora的SDK套件构建Solana DeFi应用,Meteora是Solana上领先的流动性基础设施。

What is Meteora?

什么是Meteora?

Meteora is Solana's premier liquidity layer, powering the infrastructure that connects liquidity providers (LPs), token launchers, and traders. It offers:
  • $2B+ Total Value Locked across all protocols
  • Multiple AMM Types - DLMM (concentrated), DAMM v2/v1 (constant product)
  • Token Launch Infrastructure - Dynamic Bonding Curves, Alpha Vault anti-bot protection
  • Yield Optimization - Dynamic Vaults, Stake-for-Fee (M3M3)
  • Developer Tools - TypeScript/Go SDKs, CLI tools, Zap for single-token entry
Meteora是Solana上顶级的流动性层,为连接流动性提供者(LP)、代币发行方和交易者的基础设施提供支持。它提供以下功能:
  • 全协议锁定总价值超20亿美元
  • 多种AMM类型 - DLMM(集中流动性)、DAMM v2/v1(恒定乘积)
  • 代币发行基础设施 - 动态绑定曲线、Alpha金库反机器人保护
  • 收益优化 - 动态金库、Stake-for-Fee(M3M3)
  • 开发者工具 - TypeScript/Go SDK、CLI工具、支持单代币准入的Zap

Why Use Meteora?

为什么选择Meteora?

FeatureBenefit
Low Pool Creation Cost0.022 SOL (vs 0.25+ SOL on competitors)
Dynamic FeesVolatility-adjusted fees maximize LP returns
Anti-Snipe ProtectionFee schedulers and Alpha Vault prevent bot exploitation
Token-2022 SupportFull Token Extensions compatibility
PermissionlessCreate pools, farms, and launches without approval
Auto-GraduationBonding curves auto-migrate to AMM pools
特性优势
低池创建成本0.022 SOL(竞品需0.25+ SOL)
动态手续费根据波动率调整手续费,最大化LP收益
防抢跑保护手续费调度器和Alpha金库防止机器人套利
Token-2022支持完全兼容Token Extensions标准
无需许可无需审批即可创建池、农场和代币发行
自动升级绑定曲线自动迁移至AMM池

Overview

概述

Meteora provides a complete DeFi infrastructure stack on Solana:
  • DLMM (Dynamic Liquidity Market Maker): Concentrated liquidity with dynamic fees
  • DAMM v2 (Dynamic AMM): Next-generation constant product AMM with position NFTs
  • DAMM v1 (Legacy AMM): Original constant product AMM with stable/weighted pools
  • Dynamic Bonding Curve: Customizable token launch curves with auto-graduation
  • Dynamic Vault: Yield-optimized token vaults
  • Alpha Vault: Anti-bot protection for token launches
  • Stake-for-Fee (M3M3): Staking rewards from trading fees
  • Zap SDK: Single-token entry/exit for liquidity positions
  • Presale Vault (Beta): Token presale infrastructure
Meteora在Solana上提供完整的DeFi基础设施栈:
  • DLMM(动态流动性做市商):带动态手续费的集中流动性协议
  • DAMM v2(动态AMM):下一代恒定乘积AMM,支持仓位NFT
  • DAMM v1(旧版AMM):原始恒定乘积AMM,支持稳定池/加权池
  • 动态绑定曲线:可定制的代币发行曲线,支持自动升级
  • 动态金库:收益优化型代币金库
  • Alpha金库:代币发行的反机器人保护
  • Stake-for-Fee(M3M3):通过交易手续费获得质押奖励
  • Zap SDK:流动性仓位的单代币准入/退出
  • 预售金库(Beta版):代币预售基础设施

Quick Start

快速开始

Installation

安装

bash
undefined
bash
undefined

DLMM SDK - Concentrated liquidity

DLMM SDK - Concentrated liquidity

npm install @meteora-ag/dlmm @coral-xyz/anchor @solana/web3.js
npm install @meteora-ag/dlmm @coral-xyz/anchor @solana/web3.js

DAMM v2 SDK - Next-gen constant product AMM

DAMM v2 SDK - Next-gen constant product AMM

npm install @meteora-ag/cp-amm-sdk @solana/web3.js
npm install @meteora-ag/cp-amm-sdk @solana/web3.js

DAMM v1 SDK - Legacy AMM (stable pools, weighted pools)

DAMM v1 SDK - Legacy AMM (stable pools, weighted pools)

npm install @meteora-ag/dynamic-amm @solana/web3.js @coral-xyz/anchor
npm install @meteora-ag/dynamic-amm @solana/web3.js @coral-xyz/anchor

Dynamic Bonding Curve SDK - Token launches

Dynamic Bonding Curve SDK - Token launches

npm install @meteora-ag/dynamic-bonding-curve-sdk
npm install @meteora-ag/dynamic-bonding-curve-sdk

Vault SDK - Yield optimization

Vault SDK - Yield optimization

npm install @meteora-ag/vault-sdk @coral-xyz/anchor @solana/web3.js @solana/spl-token
npm install @meteora-ag/vault-sdk @coral-xyz/anchor @solana/web3.js @solana/spl-token

Alpha Vault SDK - Anti-bot protection

Alpha Vault SDK - Anti-bot protection

npm install @meteora-ag/alpha-vault
npm install @meteora-ag/alpha-vault

Stake-for-Fee (M3M3) SDK - Fee staking

Stake-for-Fee (M3M3) SDK - Fee staking

npm install @meteora-ag/m3m3 @coral-xyz/anchor @solana/web3.js @solana/spl-token
npm install @meteora-ag/m3m3 @coral-xyz/anchor @solana/web3.js @solana/spl-token

Zap SDK - Single-token entry/exit (requires Jupiter API key)

Zap SDK - Single-token entry/exit (requires Jupiter API key)

npm install @meteora-ag/zap-sdk
npm install @meteora-ag/zap-sdk

Pool Farms SDK - Farm creation and staking

Pool Farms SDK - Farm creation and staking

npm install @meteora-ag/farming
undefined
npm install @meteora-ag/farming
undefined

Program Addresses

程序地址

ProgramMainnet/Devnet Address
DLMM
LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo
DAMM v2
cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG
DAMM v1
Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB
Dynamic Bonding Curve
dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN
Dynamic Vault
24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi
Stake-for-Fee
FEESngU3neckdwib9X3KWqdL7Mjmqk9XNp3uh5JbP4KP
Zap
zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz

程序主网/测试网地址
DLMM
LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo
DAMM v2
cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG
DAMM v1
Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB
Dynamic Bonding Curve
dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN
Dynamic Vault
24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi
Stake-for-Fee
FEESngU3neckdwib9X3KWqdL7Mjmqk9XNp3uh5JbP4KP
Zap
zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz

DLMM SDK (Dynamic Liquidity Market Maker)

DLMM SDK(动态流动性做市商)

The DLMM SDK provides programmatic access to Meteora's concentrated liquidity protocol with dynamic fees based on volatility.
DLMM SDK提供程序化访问Meteora的集中流动性协议,支持基于波动率的动态手续费。

Basic Setup

基础设置

typescript
import { Connection, PublicKey, Keypair } from '@solana/web3.js';
import DLMM from '@meteora-ag/dlmm';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const poolAddress = new PublicKey('POOL_ADDRESS');

// Create DLMM instance for existing pool
const dlmm = await DLMM.create(connection, poolAddress);

// Create multiple pools
const dlmmPools = await DLMM.createMultiple(connection, [pool1, pool2, pool3]);
typescript
import { Connection, PublicKey, Keypair } from '@solana/web3.js';
import DLMM from '@meteora-ag/dlmm';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const poolAddress = new PublicKey('POOL_ADDRESS');

// Create DLMM instance for existing pool
const dlmm = await DLMM.create(connection, poolAddress);

// Create multiple pools
const dlmmPools = await DLMM.createMultiple(connection, [pool1, pool2, pool3]);

Core Operations

核心操作

Get Active Bin (Current Price)

获取活跃Bin(当前价格)

typescript
const activeBin = await dlmm.getActiveBin();
console.log('Active Bin ID:', activeBin.binId);
console.log('Price:', activeBin.price);
console.log('X Amount:', activeBin.xAmount.toString());
console.log('Y Amount:', activeBin.yAmount.toString());
typescript
const activeBin = await dlmm.getActiveBin();
console.log('Active Bin ID:', activeBin.binId);
console.log('Price:', activeBin.price);
console.log('X Amount:', activeBin.xAmount.toString());
console.log('Y Amount:', activeBin.yAmount.toString());

Price and Bin Conversions

价格与Bin转换

typescript
// Get price from bin ID
const price = dlmm.getPriceOfBinByBinId(binId);

// Get bin ID from price
const binId = dlmm.getBinIdFromPrice(price, true); // true = round down

// Convert to/from lamport representation
const lamportPrice = dlmm.toPricePerLamport(21.23);
const realPrice = dlmm.fromPricePerLamport(lamportPrice);

// Get bins in a range
const bins = await dlmm.getBinsBetweenLowerAndUpperBound(minBinId, maxBinId);

// Get bins around active bin
const surroundingBins = await dlmm.getBinsAroundActiveBin(10); // 10 bins each side
typescript
// Get price from bin ID
const price = dlmm.getPriceOfBinByBinId(binId);

// Get bin ID from price
const binId = dlmm.getBinIdFromPrice(price, true); // true = round down

// Convert to/from lamport representation
const lamportPrice = dlmm.toPricePerLamport(21.23);
const realPrice = dlmm.fromPricePerLamport(lamportPrice);

// Get bins in a range
const bins = await dlmm.getBinsBetweenLowerAndUpperBound(minBinId, maxBinId);

// Get bins around active bin
const surroundingBins = await dlmm.getBinsAroundActiveBin(10); // 10 bins each side

Swap Operations

兑换操作

typescript
import { BN } from '@coral-xyz/anchor';

// Get swap quote
const swapAmount = new BN(1_000_000); // 1 USDC (6 decimals)
const swapForY = true; // Swap X for Y
const slippageBps = 100; // 1% slippage

const binArrays = await dlmm.getBinArrayForSwap(swapForY);
const swapQuote = dlmm.swapQuote(swapAmount, swapForY, slippageBps, binArrays);

console.log('Amount In:', swapQuote.consumedInAmount.toString());
console.log('Amount Out:', swapQuote.outAmount.toString());
console.log('Min Amount Out:', swapQuote.minOutAmount.toString());
console.log('Price Impact:', swapQuote.priceImpact);
console.log('Fee:', swapQuote.fee.toString());

// Execute swap
const swapTx = await dlmm.swap({
  inToken: tokenXMint,
  outToken: tokenYMint,
  inAmount: swapAmount,
  minOutAmount: swapQuote.minOutAmount,
  lbPair: dlmm.pubkey,
  user: wallet.publicKey,
  binArraysPubkey: swapQuote.binArraysPubkey,
});

const txHash = await sendAndConfirmTransaction(connection, swapTx, [wallet]);
typescript
import { BN } from '@coral-xyz/anchor';

// Get swap quote
const swapAmount = new BN(1_000_000); // 1 USDC (6 decimals)
const swapForY = true; // Swap X for Y
const slippageBps = 100; // 1% slippage

const binArrays = await dlmm.getBinArrayForSwap(swapForY);
const swapQuote = dlmm.swapQuote(swapAmount, swapForY, slippageBps, binArrays);

console.log('Amount In:', swapQuote.consumedInAmount.toString());
console.log('Amount Out:', swapQuote.outAmount.toString());
console.log('Min Amount Out:', swapQuote.minOutAmount.toString());
console.log('Price Impact:', swapQuote.priceImpact);
console.log('Fee:', swapQuote.fee.toString());

// Execute swap
const swapTx = await dlmm.swap({
  inToken: tokenXMint,
  outToken: tokenYMint,
  inAmount: swapAmount,
  minOutAmount: swapQuote.minOutAmount,
  lbPair: dlmm.pubkey,
  user: wallet.publicKey,
  binArraysPubkey: swapQuote.binArraysPubkey,
});

const txHash = await sendAndConfirmTransaction(connection, swapTx, [wallet]);

Liquidity Management

流动性管理

typescript
import { StrategyType } from '@meteora-ag/dlmm';

// Get user positions
const positions = await dlmm.getPositionsByUserAndLbPair(wallet.publicKey);

// Initialize position and add liquidity with strategy
const newPositionTx = await dlmm.initializePositionAndAddLiquidityByStrategy({
  positionPubKey: newPositionKeypair.publicKey,
  user: wallet.publicKey,
  totalXAmount: new BN(100_000_000), // 100 tokens
  totalYAmount: new BN(100_000_000),
  strategy: {
    maxBinId: activeBin.binId + 10,
    minBinId: activeBin.binId - 10,
    strategyType: StrategyType.SpotBalanced,
  },
});

// Add liquidity to existing position
const addLiquidityTx = await dlmm.addLiquidityByStrategy({
  positionPubKey: existingPosition.publicKey,
  user: wallet.publicKey,
  totalXAmount: new BN(50_000_000),
  totalYAmount: new BN(50_000_000),
  strategy: {
    maxBinId: activeBin.binId + 5,
    minBinId: activeBin.binId - 5,
    strategyType: StrategyType.SpotBalanced,
  },
});

// Remove liquidity
const removeLiquidityTx = await dlmm.removeLiquidity({
  position: position.publicKey,
  user: wallet.publicKey,
  binIds: position.positionData.positionBinData.map(b => b.binId),
  bps: new BN(10000), // 100% (basis points)
  shouldClaimAndClose: true,
});
typescript
import { StrategyType } from '@meteora-ag/dlmm';

// Get user positions
const positions = await dlmm.getPositionsByUserAndLbPair(wallet.publicKey);

// Initialize position and add liquidity with strategy
const newPositionTx = await dlmm.initializePositionAndAddLiquidityByStrategy({
  positionPubKey: newPositionKeypair.publicKey,
  user: wallet.publicKey,
  totalXAmount: new BN(100_000_000), // 100 tokens
  totalYAmount: new BN(100_000_000),
  strategy: {
    maxBinId: activeBin.binId + 10,
    minBinId: activeBin.binId - 10,
    strategyType: StrategyType.SpotBalanced,
  },
});

// Add liquidity to existing position
const addLiquidityTx = await dlmm.addLiquidityByStrategy({
  positionPubKey: existingPosition.publicKey,
  user: wallet.publicKey,
  totalXAmount: new BN(50_000_000),
  totalYAmount: new BN(50_000_000),
  strategy: {
    maxBinId: activeBin.binId + 5,
    minBinId: activeBin.binId - 5,
    strategyType: StrategyType.SpotBalanced,
  },
});

// Remove liquidity
const removeLiquidityTx = await dlmm.removeLiquidity({
  position: position.publicKey,
  user: wallet.publicKey,
  binIds: position.positionData.positionBinData.map(b => b.binId),
  bps: new BN(10000), // 100% (basis points)
  shouldClaimAndClose: true,
});

Claim Fees and Rewards

领取手续费与奖励

typescript
// Get claimable fees
const claimableFees = await DLMM.getClaimableSwapFee(connection, position.publicKey);
console.log('Claimable Fee X:', claimableFees.feeX.toString());
console.log('Claimable Fee Y:', claimableFees.feeY.toString());

// Get claimable LM rewards
const claimableRewards = await DLMM.getClaimableLMReward(connection, position.publicKey);

// Claim swap fees
const claimFeeTx = await dlmm.claimSwapFee({
  owner: wallet.publicKey,
  position: position.publicKey,
});

// Claim all fees from multiple positions
const claimAllFeesTx = await dlmm.claimAllSwapFee({
  owner: wallet.publicKey,
  positions: positions.map(p => p.publicKey),
});

// Claim LM rewards
const claimRewardTx = await dlmm.claimLMReward({
  owner: wallet.publicKey,
  position: position.publicKey,
});

// Claim all rewards
const claimAllTx = await dlmm.claimAllRewards({
  owner: wallet.publicKey,
  positions: positions.map(p => p.publicKey),
});
typescript
// Get claimable fees
const claimableFees = await DLMM.getClaimableSwapFee(connection, position.publicKey);
console.log('Claimable Fee X:', claimableFees.feeX.toString());
console.log('Claimable Fee Y:', claimableFees.feeY.toString());

// Get claimable LM rewards
const claimableRewards = await DLMM.getClaimableLMReward(connection, position.publicKey);

// Claim swap fees
const claimFeeTx = await dlmm.claimSwapFee({
  owner: wallet.publicKey,
  position: position.publicKey,
});

// Claim all fees from multiple positions
const claimAllFeesTx = await dlmm.claimAllSwapFee({
  owner: wallet.publicKey,
  positions: positions.map(p => p.publicKey),
});

// Claim LM rewards
const claimRewardTx = await dlmm.claimLMReward({
  owner: wallet.publicKey,
  position: position.publicKey,
});

// Claim all rewards
const claimAllTx = await dlmm.claimAllRewards({
  owner: wallet.publicKey,
  positions: positions.map(p => p.publicKey),
});

Position Strategies

仓位策略

typescript
import { StrategyType } from '@meteora-ag/dlmm';

// Available strategies
StrategyType.SpotOneSide      // Single-sided liquidity at current price
StrategyType.CurveOneSide     // Curve distribution on one side
StrategyType.BidAskOneSide    // Bid/ask distribution on one side
StrategyType.SpotBalanced     // Balanced around current price
StrategyType.CurveBalanced    // Curve distribution around current price
StrategyType.BidAskBalanced   // Bid/ask distribution around current price
StrategyType.SpotImBalanced   // Imbalanced spot distribution
StrategyType.CurveImBalanced  // Imbalanced curve distribution
StrategyType.BidAskImBalanced // Imbalanced bid/ask distribution

typescript
import { StrategyType } from '@meteora-ag/dlmm';

// Available strategies
StrategyType.SpotOneSide      // Single-sided liquidity at current price
StrategyType.CurveOneSide     // Curve distribution on one side
StrategyType.BidAskOneSide    // Bid/ask distribution on one side
StrategyType.SpotBalanced     // Balanced around current price
StrategyType.CurveBalanced    // Curve distribution around current price
StrategyType.BidAskBalanced   // Bid/ask distribution around current price
StrategyType.SpotImBalanced   // Imbalanced spot distribution
StrategyType.CurveImBalanced  // Imbalanced curve distribution
StrategyType.BidAskImBalanced // Imbalanced bid/ask distribution

DAMM v2 SDK (CP-AMM)

DAMM v2 SDK(CP-AMM)

The DAMM v2 SDK provides a comprehensive interface for Meteora's next-generation constant product AMM with significant improvements over V1.
DAMM v2 SDK为Meteora的下一代恒定乘积AMM提供全面接口,相比V1有显著改进。

Key DAMM V2 Features (New in 2025)

DAMM V2核心特性(2025年新增)

FeatureDescription
Dynamic FeesOptional fee scheduler with anti-sniper mechanism
Position NFTsLPs receive transferrable NFT instead of LP token
Token2022 SupportFull support for Token Extensions standard
Locked LiquidityBuilt-in liquidity locking options
Permissionless FarmsCreate farms without protocol approval
Lower CostsPool creation costs only 0.022 SOL (vs 0.25 SOL on old DLMM)
特性描述
动态手续费可选的手续费调度器,带防抢跑机制
仓位NFTLP获得可转让的NFT,而非LP代币
Token2022支持完全支持Token Extensions标准
锁定流动性内置流动性锁定选项
无需许可的农场无需协议审批即可创建农场
更低成本池创建成本仅0.022 SOL(旧版DLMM需0.25 SOL)

Fee Scheduler (Anti-Snipe)

手续费调度器(防抢跑)

The fee scheduler starts with high swap fees that taper over time, protecting against sniping:
typescript
// Create pool with fee scheduler
const createPoolTx = await cpAmm.createCustomPool({
  // ... other params
  poolFees: {
    baseFee: {
      cliffFeeNumerator: new BN(10000000), // 1% initial fee
      numberOfPeriod: 10,
      reductionFactor: new BN(500000),     // Reduce by 0.05% each period
      periodFrequency: new BN(300),        // Every 5 minutes
      feeSchedulerMode: 1,                 // Linear reduction
    },
    // ...
  },
});
手续费调度器初始设置高兑换手续费,随时间逐渐降低,防止抢跑:
typescript
// Create pool with fee scheduler
const createPoolTx = await cpAmm.createCustomPool({
  // ... other params
  poolFees: {
    baseFee: {
      cliffFeeNumerator: new BN(10000000), // 1% initial fee
      numberOfPeriod: 10,
      reductionFactor: new BN(500000),     // Reduce by 0.05% each period
      periodFrequency: new BN(300),        // Every 5 minutes
      feeSchedulerMode: 1,                 // Linear reduction
    },
    // ...
  },
});

Basic Setup

基础设置

typescript
import { Connection } from '@solana/web3.js';
import { CpAmm } from '@meteora-ag/cp-amm-sdk';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const cpAmm = new CpAmm(connection);
typescript
import { Connection } from '@solana/web3.js';
import { CpAmm } from '@meteora-ag/cp-amm-sdk';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const cpAmm = new CpAmm(connection);

Pool Management

池管理

Create Pool

创建池

typescript
// Create standard pool from config
const createPoolTx = await cpAmm.createPool({
  creator: wallet.publicKey,
  configAddress: configPubkey,
  tokenAMint,
  tokenBMint,
  tokenAAmount: new BN(1_000_000_000),
  tokenBAmount: new BN(1_000_000_000),
});

// Create custom pool with specific parameters
const createCustomPoolTx = await cpAmm.createCustomPool({
  creator: wallet.publicKey,
  tokenAMint,
  tokenBMint,
  tokenAAmount: new BN(1_000_000_000),
  tokenBAmount: new BN(1_000_000_000),
  poolFees: {
    baseFee: {
      cliffFeeNumerator: new BN(2500000), // 0.25%
      numberOfPeriod: 0,
      reductionFactor: new BN(0),
      periodFrequency: new BN(0),
      feeSchedulerMode: 0,
    },
    dynamicFee: null,
    protocolFeePercent: 20,
    partnerFeePercent: 0,
    referralFeePercent: 20,
    dynamicFeeConfig: null,
  },
  hasAlphaVault: false,
  activationType: 0, // 0 = slot, 1 = timestamp
  activationPoint: null, // null = immediate
  collectFeeMode: 0,
});
typescript
// Create standard pool from config
const createPoolTx = await cpAmm.createPool({
  creator: wallet.publicKey,
  configAddress: configPubkey,
  tokenAMint,
  tokenBMint,
  tokenAAmount: new BN(1_000_000_000),
  tokenBAmount: new BN(1_000_000_000),
});

// Create custom pool with specific parameters
const createCustomPoolTx = await cpAmm.createCustomPool({
  creator: wallet.publicKey,
  tokenAMint,
  tokenBMint,
  tokenAAmount: new BN(1_000_000_000),
  tokenBAmount: new BN(1_000_000_000),
  poolFees: {
    baseFee: {
      cliffFeeNumerator: new BN(2500000), // 0.25%
      numberOfPeriod: 0,
      reductionFactor: new BN(0),
      periodFrequency: new BN(0),
      feeSchedulerMode: 0,
    },
    dynamicFee: null,
    protocolFeePercent: 20,
    partnerFeePercent: 0,
    referralFeePercent: 20,
    dynamicFeeConfig: null,
  },
  hasAlphaVault: false,
  activationType: 0, // 0 = slot, 1 = timestamp
  activationPoint: null, // null = immediate
  collectFeeMode: 0,
});

Fetch Pool State

获取池状态

typescript
// Fetch single pool
const poolState = await cpAmm.fetchPoolState(poolAddress);
console.log('Token A Vault:', poolState.tokenAVault.toString());
console.log('Token B Vault:', poolState.tokenBVault.toString());
console.log('Sqrt Price:', poolState.sqrtPrice.toString());
console.log('Liquidity:', poolState.liquidity.toString());

// Fetch all pools
const allPools = await cpAmm.getAllPools();

// Check if pool exists
const exists = await cpAmm.isPoolExist(tokenAMint, tokenBMint);
typescript
// Fetch single pool
const poolState = await cpAmm.fetchPoolState(poolAddress);
console.log('Token A Vault:', poolState.tokenAVault.toString());
console.log('Token B Vault:', poolState.tokenBVault.toString());
console.log('Sqrt Price:', poolState.sqrtPrice.toString());
console.log('Liquidity:', poolState.liquidity.toString());

// Fetch all pools
const allPools = await cpAmm.getAllPools();

// Check if pool exists
const exists = await cpAmm.isPoolExist(tokenAMint, tokenBMint);

Position Operations

仓位操作

Create and Manage Positions

创建与管理仓位

typescript
// Create position
const createPositionTx = await cpAmm.createPosition({
  owner: wallet.publicKey,
  pool: poolAddress,
});

// Add liquidity
const addLiquidityTx = await cpAmm.addLiquidity({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  tokenAAmountIn: new BN(100_000_000),
  tokenBAmountIn: new BN(100_000_000),
  liquidityMin: new BN(0),
});

// Get deposit quote
const depositQuote = cpAmm.getDepositQuote({
  poolState,
  tokenAAmount: new BN(100_000_000),
  tokenBAmount: new BN(100_000_000),
  slippageBps: 100,
});

// Remove liquidity
const removeLiquidityTx = await cpAmm.removeLiquidity({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  liquidityAmount: new BN(50_000_000),
  tokenAAmountMin: new BN(0),
  tokenBAmountMin: new BN(0),
});

// Get withdraw quote
const withdrawQuote = cpAmm.getWithdrawQuote({
  poolState,
  positionState,
  liquidityAmount: new BN(50_000_000),
  slippageBps: 100,
});

// Merge positions
const mergePositionTx = await cpAmm.mergePosition({
  owner: wallet.publicKey,
  pool: poolAddress,
  sourcePositions: [position1, position2],
  destinationPosition: destPosition,
});

// Split position
const splitPositionTx = await cpAmm.splitPosition({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  percentage: 50, // Split 50%
  newPosition: newPositionKeypair.publicKey,
});
typescript
// Create position
const createPositionTx = await cpAmm.createPosition({
  owner: wallet.publicKey,
  pool: poolAddress,
});

// Add liquidity
const addLiquidityTx = await cpAmm.addLiquidity({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  tokenAAmountIn: new BN(100_000_000),
  tokenBAmountIn: new BN(100_000_000),
  liquidityMin: new BN(0),
});

// Get deposit quote
const depositQuote = cpAmm.getDepositQuote({
  poolState,
  tokenAAmount: new BN(100_000_000),
  tokenBAmount: new BN(100_000_000),
  slippageBps: 100,
});

// Remove liquidity
const removeLiquidityTx = await cpAmm.removeLiquidity({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  liquidityAmount: new BN(50_000_000),
  tokenAAmountMin: new BN(0),
  tokenBAmountMin: new BN(0),
});

// Get withdraw quote
const withdrawQuote = cpAmm.getWithdrawQuote({
  poolState,
  positionState,
  liquidityAmount: new BN(50_000_000),
  slippageBps: 100,
});

// Merge positions
const mergePositionTx = await cpAmm.mergePosition({
  owner: wallet.publicKey,
  pool: poolAddress,
  sourcePositions: [position1, position2],
  destinationPosition: destPosition,
});

// Split position
const splitPositionTx = await cpAmm.splitPosition({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  percentage: 50, // Split 50%
  newPosition: newPositionKeypair.publicKey,
});

Swapping

兑换

typescript
import { SwapMode } from '@meteora-ag/cp-amm-sdk';

// Available swap modes
SwapMode.ExactIn     // Specify exact input amount
SwapMode.ExactOut    // Specify exact output amount
SwapMode.PartialFill // Allow partial fills

// Get swap quote
const quote = cpAmm.getQuote({
  poolState,
  inputTokenMint: tokenAMint,
  outputTokenMint: tokenBMint,
  amount: new BN(1_000_000),
  slippageBps: 100,
  swapMode: SwapMode.ExactIn,
});

console.log('Input Amount:', quote.inputAmount.toString());
console.log('Output Amount:', quote.outputAmount.toString());
console.log('Min Output:', quote.minimumOutputAmount.toString());
console.log('Price Impact:', quote.priceImpact);
console.log('Fee:', quote.fee.toString());

// Execute swap
const swapTx = await cpAmm.swap({
  payer: wallet.publicKey,
  pool: poolAddress,
  inputTokenMint: tokenAMint,
  outputTokenMint: tokenBMint,
  amountIn: new BN(1_000_000),
  minimumAmountOut: quote.minimumOutputAmount,
  referralAccount: null,
});
typescript
import { SwapMode } from '@meteora-ag/cp-amm-sdk';

// Available swap modes
SwapMode.ExactIn     // Specify exact input amount
SwapMode.ExactOut    // Specify exact output amount
SwapMode.PartialFill // Allow partial fills

// Get swap quote
const quote = cpAmm.getQuote({
  poolState,
  inputTokenMint: tokenAMint,
  outputTokenMint: tokenBMint,
  amount: new BN(1_000_000),
  slippageBps: 100,
  swapMode: SwapMode.ExactIn,
});

console.log('Input Amount:', quote.inputAmount.toString());
console.log('Output Amount:', quote.outputAmount.toString());
console.log('Min Output:', quote.minimumOutputAmount.toString());
console.log('Price Impact:', quote.priceImpact);
console.log('Fee:', quote.fee.toString());

// Execute swap
const swapTx = await cpAmm.swap({
  payer: wallet.publicKey,
  pool: poolAddress,
  inputTokenMint: tokenAMint,
  outputTokenMint: tokenBMint,
  amountIn: new BN(1_000_000),
  minimumAmountOut: quote.minimumOutputAmount,
  referralAccount: null,
});

Fee and Reward Management

手续费与奖励管理

typescript
// Claim position fees
const claimFeeTx = await cpAmm.claimPositionFee({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
});

// Initialize reward (pool creator only)
const initRewardTx = await cpAmm.initializeReward({
  pool: poolAddress,
  rewardMint,
  rewardDuration: new BN(86400 * 7), // 7 days
  funder: wallet.publicKey,
});

// Fund reward
const fundRewardTx = await cpAmm.fundReward({
  pool: poolAddress,
  rewardMint,
  amount: new BN(1_000_000_000),
  funder: wallet.publicKey,
});

// Claim rewards
const claimRewardTx = await cpAmm.claimReward({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  rewardIndex: 0,
});
typescript
// Claim position fees
const claimFeeTx = await cpAmm.claimPositionFee({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
});

// Initialize reward (pool creator only)
const initRewardTx = await cpAmm.initializeReward({
  pool: poolAddress,
  rewardMint,
  rewardDuration: new BN(86400 * 7), // 7 days
  funder: wallet.publicKey,
});

// Fund reward
const fundRewardTx = await cpAmm.fundReward({
  pool: poolAddress,
  rewardMint,
  amount: new BN(1_000_000_000),
  funder: wallet.publicKey,
});

// Claim rewards
const claimRewardTx = await cpAmm.claimReward({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  rewardIndex: 0,
});

Position Locking and Vesting

仓位锁定与解锁

typescript
// Lock position with vesting schedule
const lockPositionTx = await cpAmm.lockPosition({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  vestingDuration: new BN(86400 * 30), // 30 days
  cliffDuration: new BN(86400 * 7),    // 7 day cliff
});

// Permanent lock (irreversible)
const permanentLockTx = await cpAmm.permanentLockPosition({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  liquidityAmount: new BN(50_000_000), // Amount to permanently lock
});

// Refresh vesting (unlock available tokens)
const refreshVestingTx = await cpAmm.refreshVesting({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
});

// Check if position is locked
const isLocked = cpAmm.isLockedPosition(positionState);
typescript
// Lock position with vesting schedule
const lockPositionTx = await cpAmm.lockPosition({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  vestingDuration: new BN(86400 * 30), // 30 days
  cliffDuration: new BN(86400 * 7),    // 7 day cliff
});

// Permanent lock (irreversible)
const permanentLockTx = await cpAmm.permanentLockPosition({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
  liquidityAmount: new BN(50_000_000), // Amount to permanently lock
});

// Refresh vesting (unlock available tokens)
const refreshVestingTx = await cpAmm.refreshVesting({
  owner: wallet.publicKey,
  pool: poolAddress,
  position: positionAddress,
});

// Check if position is locked
const isLocked = cpAmm.isLockedPosition(positionState);

Helper Functions

辅助函数

typescript
// Price conversions
const price = cpAmm.getPriceFromSqrtPrice(sqrtPrice, tokenADecimals, tokenBDecimals);
const sqrtPrice = cpAmm.getSqrtPriceFromPrice(price, tokenADecimals, tokenBDecimals);

// Fee conversions
const feeNumerator = cpAmm.bpsToFeeNumerator(25); // 0.25% = 25 bps
const bps = cpAmm.feeNumeratorToBps(feeNumerator);

// Slippage calculations
const minAmount = cpAmm.getAmountWithSlippage(amount, slippageBps, false);
const maxAmount = cpAmm.getMaxAmountWithSlippage(amount, slippageBps);

// Get price impact
const priceImpact = cpAmm.getPriceImpact(amountIn, amountOut, currentPrice);

// Get liquidity delta
const liquidityDelta = cpAmm.getLiquidityDelta({
  poolState,
  tokenAAmount: new BN(100_000_000),
  tokenBAmount: new BN(100_000_000),
});

typescript
// Price conversions
const price = cpAmm.getPriceFromSqrtPrice(sqrtPrice, tokenADecimals, tokenBDecimals);
const sqrtPrice = cpAmm.getSqrtPriceFromPrice(price, tokenADecimals, tokenBDecimals);

// Fee conversions
const feeNumerator = cpAmm.bpsToFeeNumerator(25); // 0.25% = 25 bps
const bps = cpAmm.feeNumeratorToBps(feeNumerator);

// Slippage calculations
const minAmount = cpAmm.getAmountWithSlippage(amount, slippageBps, false);
const maxAmount = cpAmm.getMaxAmountWithSlippage(amount, slippageBps);

// Get price impact
const priceImpact = cpAmm.getPriceImpact(amountIn, amountOut, currentPrice);

// Get liquidity delta
const liquidityDelta = cpAmm.getLiquidityDelta({
  poolState,
  tokenAAmount: new BN(100_000_000),
  tokenBAmount: new BN(100_000_000),
});

Dynamic Bonding Curve SDK

动态绑定曲线SDK

The Dynamic Bonding Curve SDK enables building customizable token launches with automatic graduation to DAMM.
动态绑定曲线SDK支持构建可定制的代币发行,支持自动迁移至DAMM。

Basic Setup

基础设置

typescript
import { Connection } from '@solana/web3.js';
import { DynamicBondingCurve } from '@meteora-ag/dynamic-bonding-curve-sdk';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const dbc = new DynamicBondingCurve(connection, 'confirmed');
typescript
import { Connection } from '@solana/web3.js';
import { DynamicBondingCurve } from '@meteora-ag/dynamic-bonding-curve-sdk';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const dbc = new DynamicBondingCurve(connection, 'confirmed');

Token Launch Flow

代币发行流程

The DBC follows a 5-step progression:
  1. Partner Configuration: Set up pool parameters
  2. Pool Creation: Creator launches the bonding curve
  3. Trading Phase: Users buy/sell on the curve
  4. Graduation: Auto-migrate to DAMM v1 or v2 when threshold is met
  5. Post-Graduation: Trade on the graduated AMM
DBC遵循5个阶段:
  1. 合作伙伴配置:设置池参数
  2. 池创建:发行方启动绑定曲线
  3. 交易阶段:用户在曲线上买卖
  4. 升级:达到阈值后自动迁移至DAMM v1或v2
  5. 升级后:在升级后的AMM上交易

Create Pool with Bonding Curve

创建绑定曲线池

typescript
// Create a new bonding curve pool
const createPoolTx = await dbc.createPool({
  creator: wallet.publicKey,
  baseMint: baseTokenMint,
  quoteMint: quoteTokenMint, // Usually SOL or USDC
  config: configAddress,
  baseAmount: new BN(1_000_000_000_000), // Total supply
  quoteAmount: new BN(0), // Initial quote (usually 0)
  name: 'My Token',
  symbol: 'MTK',
  uri: 'https://arweave.net/metadata.json',
});
typescript
// Create a new bonding curve pool
const createPoolTx = await dbc.createPool({
  creator: wallet.publicKey,
  baseMint: baseTokenMint,
  quoteMint: quoteTokenMint, // Usually SOL or USDC
  config: configAddress,
  baseAmount: new BN(1_000_000_000_000), // Total supply
  quoteAmount: new BN(0), // Initial quote (usually 0)
  name: 'My Token',
  symbol: 'MTK',
  uri: 'https://arweave.net/metadata.json',
});

Trading on Bonding Curve

在绑定曲线上交易

typescript
// Get quote for buying tokens
const buyQuote = await dbc.getBuyQuote({
  pool: poolAddress,
  quoteAmount: new BN(1_000_000_000), // 1 SOL
});

console.log('Tokens to receive:', buyQuote.baseAmount.toString());
console.log('Price per token:', buyQuote.price.toString());

// Execute buy
const buyTx = await dbc.buy({
  payer: wallet.publicKey,
  pool: poolAddress,
  quoteAmount: new BN(1_000_000_000),
  minBaseAmount: buyQuote.minBaseAmount,
});

// Get quote for selling tokens
const sellQuote = await dbc.getSellQuote({
  pool: poolAddress,
  baseAmount: new BN(1_000_000), // Tokens to sell
});

// Execute sell
const sellTx = await dbc.sell({
  payer: wallet.publicKey,
  pool: poolAddress,
  baseAmount: new BN(1_000_000),
  minQuoteAmount: sellQuote.minQuoteAmount,
});
typescript
// Get quote for buying tokens
const buyQuote = await dbc.getBuyQuote({
  pool: poolAddress,
  quoteAmount: new BN(1_000_000_000), // 1 SOL
});

console.log('Tokens to receive:', buyQuote.baseAmount.toString());
console.log('Price per token:', buyQuote.price.toString());

// Execute buy
const buyTx = await dbc.buy({
  payer: wallet.publicKey,
  pool: poolAddress,
  quoteAmount: new BN(1_000_000_000),
  minBaseAmount: buyQuote.minBaseAmount,
});

// Get quote for selling tokens
const sellQuote = await dbc.getSellQuote({
  pool: poolAddress,
  baseAmount: new BN(1_000_000), // Tokens to sell
});

// Execute sell
const sellTx = await dbc.sell({
  payer: wallet.publicKey,
  pool: poolAddress,
  baseAmount: new BN(1_000_000),
  minQuoteAmount: sellQuote.minQuoteAmount,
});

Pool Graduation

池升级

typescript
// Check graduation status
const poolState = await dbc.fetchPoolState(poolAddress);
const isGraduated = poolState.graduated;
const graduationThreshold = poolState.graduationThreshold;
const currentMarketCap = poolState.currentMarketCap;

// Manual migration to DAMM v2 (if auto-graduation not triggered)
const migrateTx = await dbc.migrateToDAMMV2({
  pool: poolAddress,
  payer: wallet.publicKey,
});

// For DAMM v1 migration (more steps required)
// 1. Create metadata
const createMetadataTx = await dbc.createMetadata({
  pool: poolAddress,
  payer: wallet.publicKey,
});

// 2. Execute migration
const migrateToDammV1Tx = await dbc.migrateToDAMMV1({
  pool: poolAddress,
  payer: wallet.publicKey,
});

// 3. Lock LP tokens (optional)
const lockLpTx = await dbc.lockLpTokens({
  pool: poolAddress,
  payer: wallet.publicKey,
  lockDuration: new BN(86400 * 365), // 1 year
});

// 4. Claim LP tokens after lock expires
const claimLpTx = await dbc.claimLpTokens({
  pool: poolAddress,
  payer: wallet.publicKey,
});
typescript
// Check graduation status
const poolState = await dbc.fetchPoolState(poolAddress);
const isGraduated = poolState.graduated;
const graduationThreshold = poolState.graduationThreshold;
const currentMarketCap = poolState.currentMarketCap;

// Manual migration to DAMM v2 (if auto-graduation not triggered)
const migrateTx = await dbc.migrateToDAMMV2({
  pool: poolAddress,
  payer: wallet.publicKey,
});

// For DAMM v1 migration (more steps required)
// 1. Create metadata
const createMetadataTx = await dbc.createMetadata({
  pool: poolAddress,
  payer: wallet.publicKey,
});

// 2. Execute migration
const migrateToDammV1Tx = await dbc.migrateToDAMMV1({
  pool: poolAddress,
  payer: wallet.publicKey,
});

// 3. Lock LP tokens (optional)
const lockLpTx = await dbc.lockLpTokens({
  pool: poolAddress,
  payer: wallet.publicKey,
  lockDuration: new BN(86400 * 365), // 1 year
});

// 4. Claim LP tokens after lock expires
const claimLpTx = await dbc.claimLpTokens({
  pool: poolAddress,
  payer: wallet.publicKey,
});

Fee Configuration Options

手续费配置选项

The DBC supports multiple fee tier configurations:
TierFee (bps)Use Case
125Standard launches
250Community tokens
3100Meme tokens
4200High volatility
5400Experimental
6600Maximum protection

DBC支持多种手续费层级:
层级手续费(bps)使用场景
125标准发行
250社区代币
3100迷因代币
4200高波动率
5400实验性
6600最大保护

Dynamic Vault SDK

动态金库SDK

The Vault SDK provides yield-optimized token storage with automatic strategy management.
金库SDK提供收益优化型代币存储,支持自动策略管理。

Basic Setup

基础设置

typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { VaultImpl } from '@meteora-ag/vault-sdk';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const tokenMint = new PublicKey('TOKEN_MINT_ADDRESS');

// Create vault instance
const vault = await VaultImpl.create(connection, tokenMint);

// With affiliate ID (for partner integrations)
const vaultWithAffiliate = await VaultImpl.create(connection, tokenMint, {
  affiliateId: new PublicKey('PARTNER_KEY'),
});
typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { VaultImpl } from '@meteora-ag/vault-sdk';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const tokenMint = new PublicKey('TOKEN_MINT_ADDRESS');

// Create vault instance
const vault = await VaultImpl.create(connection, tokenMint);

// With affiliate ID (for partner integrations)
const vaultWithAffiliate = await VaultImpl.create(connection, tokenMint, {
  affiliateId: new PublicKey('PARTNER_KEY'),
});

Vault Operations

金库操作

typescript
// Get vault information
const lpSupply = vault.lpSupply; // Or use vault.getVaultSupply() to refresh
const withdrawableAmount = await vault.getWithdrawableAmount();

console.log('Total LP Supply:', lpSupply.toString());
console.log('Locked Amount:', withdrawableAmount.locked.toString());
console.log('Unlocked Amount:', withdrawableAmount.unlocked.toString());

// Get user balance
const userLpBalance = await vault.getUserBalance(wallet.publicKey);

// Deposit tokens
const depositTx = await vault.deposit(wallet.publicKey, new BN(1_000_000_000));
await sendAndConfirmTransaction(connection, depositTx, [wallet]);

// Withdraw tokens
const withdrawTx = await vault.withdraw(wallet.publicKey, new BN(500_000_000));
await sendAndConfirmTransaction(connection, withdrawTx, [wallet]);
typescript
// Get vault information
const lpSupply = vault.lpSupply; // Or use vault.getVaultSupply() to refresh
const withdrawableAmount = await vault.getWithdrawableAmount();

console.log('Total LP Supply:', lpSupply.toString());
console.log('Locked Amount:', withdrawableAmount.locked.toString());
console.log('Unlocked Amount:', withdrawableAmount.unlocked.toString());

// Get user balance
const userLpBalance = await vault.getUserBalance(wallet.publicKey);

// Deposit tokens
const depositTx = await vault.deposit(wallet.publicKey, new BN(1_000_000_000));
await sendAndConfirmTransaction(connection, depositTx, [wallet]);

// Withdraw tokens
const withdrawTx = await vault.withdraw(wallet.publicKey, new BN(500_000_000));
await sendAndConfirmTransaction(connection, withdrawTx, [wallet]);

Share Calculations

份额计算

typescript
import { getAmountByShare, getUnmintAmount } from '@meteora-ag/vault-sdk';

// Convert LP tokens to underlying amount
const underlyingAmount = getAmountByShare(
  userLpBalance,      // User's LP tokens
  unlockedAmount,     // Vault's unlocked balance
  lpSupply            // Total LP supply
);

// Calculate LP tokens needed for specific withdrawal
const lpNeeded = getUnmintAmount(
  targetWithdrawAmount, // Amount to withdraw
  unlockedAmount,       // Vault's unlocked balance
  lpSupply              // Total LP supply
);
typescript
import { getAmountByShare, getUnmintAmount } from '@meteora-ag/vault-sdk';

// Convert LP tokens to underlying amount
const underlyingAmount = getAmountByShare(
  userLpBalance,      // User's LP tokens
  unlockedAmount,     // Vault's unlocked balance
  lpSupply            // Total LP supply
);

// Calculate LP tokens needed for specific withdrawal
const lpNeeded = getUnmintAmount(
  targetWithdrawAmount, // Amount to withdraw
  unlockedAmount,       // Vault's unlocked balance
  lpSupply              // Total LP supply
);

Affiliate Integration

合作伙伴集成

typescript
// Get affiliate info
const affiliateInfo = await vault.getAffiliateInfo();
console.log('Partner:', affiliateInfo.partner.toString());
console.log('Fee Rate:', affiliateInfo.feeRate);
console.log('Outstanding Fee:', affiliateInfo.outstandingFee.toString());

typescript
// Get affiliate info
const affiliateInfo = await vault.getAffiliateInfo();
console.log('Partner:', affiliateInfo.partner.toString());
console.log('Fee Rate:', affiliateInfo.feeRate);
console.log('Outstanding Fee:', affiliateInfo.outstandingFee.toString());

Alpha Vault SDK

Alpha金库SDK

The Alpha Vault SDK provides anti-bot protection for token launches, ensuring fair distribution.
Alpha金库SDK为代币发行提供反机器人保护,确保公平分配。

Basic Setup

基础设置

typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { AlphaVault } from '@meteora-ag/alpha-vault';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const vaultAddress = new PublicKey('VAULT_ADDRESS');

const alphaVault = await AlphaVault.create(connection, vaultAddress);
typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { AlphaVault } from '@meteora-ag/alpha-vault';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const vaultAddress = new PublicKey('VAULT_ADDRESS');

const alphaVault = await AlphaVault.create(connection, vaultAddress);

Vault Operations

金库操作

typescript
// Get vault state
const vaultState = await alphaVault.getVaultState();
console.log('Total Deposited:', vaultState.totalDeposited.toString());
console.log('Max Deposit:', vaultState.maxDeposit.toString());
console.log('Start Time:', vaultState.startTime.toString());
console.log('End Time:', vaultState.endTime.toString());

// Deposit to vault (during deposit window)
const depositTx = await alphaVault.deposit({
  payer: wallet.publicKey,
  amount: new BN(1_000_000_000), // 1 SOL
});

// Withdraw from vault (if allowed)
const withdrawTx = await alphaVault.withdraw({
  payer: wallet.publicKey,
  amount: new BN(500_000_000),
});

// Claim tokens (after launch)
const claimTx = await alphaVault.claimTokens({
  payer: wallet.publicKey,
});

// Get user allocation
const allocation = await alphaVault.getUserAllocation(wallet.publicKey);
console.log('Deposit Amount:', allocation.depositAmount.toString());
console.log('Token Allocation:', allocation.tokenAllocation.toString());
console.log('Claimed:', allocation.claimed);

typescript
// Get vault state
const vaultState = await alphaVault.getVaultState();
console.log('Total Deposited:', vaultState.totalDeposited.toString());
console.log('Max Deposit:', vaultState.maxDeposit.toString());
console.log('Start Time:', vaultState.startTime.toString());
console.log('End Time:', vaultState.endTime.toString());

// Deposit to vault (during deposit window)
const depositTx = await alphaVault.deposit({
  payer: wallet.publicKey,
  amount: new BN(1_000_000_000), // 1 SOL
});

// Withdraw from vault (if allowed)
const withdrawTx = await alphaVault.withdraw({
  payer: wallet.publicKey,
  amount: new BN(500_000_000),
});

// Claim tokens (after launch)
const claimTx = await alphaVault.claimTokens({
  payer: wallet.publicKey,
});

// Get user allocation
const allocation = await alphaVault.getUserAllocation(wallet.publicKey);
console.log('Deposit Amount:', allocation.depositAmount.toString());
console.log('Token Allocation:', allocation.tokenAllocation.toString());
console.log('Claimed:', allocation.claimed);

Stake-for-Fee SDK (M3M3)

Stake-for-Fee SDK(M3M3)

The M3M3 SDK enables staking tokens to earn fees from trading activity.
M3M3 SDK支持质押代币以赚取交易手续费。

Basic Setup

基础设置

typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { StakeForFee } from '@meteora-ag/m3m3';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const poolAddress = new PublicKey('POOL_ADDRESS');

const m3m3 = await StakeForFee.create(connection, poolAddress);
typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { StakeForFee } from '@meteora-ag/m3m3';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const poolAddress = new PublicKey('POOL_ADDRESS');

const m3m3 = await StakeForFee.create(connection, poolAddress);

Staking Operations

质押操作

typescript
// Get user stake and claimable balance
const userBalance = await m3m3.getUserStakeAndClaimBalance(wallet.publicKey);
console.log('Staked Amount:', userBalance.stakedAmount.toString());
console.log('Claimable Fees:', userBalance.claimableFees.toString());

// Stake tokens
const stakeTx = await m3m3.stake(new BN(1_000_000_000), wallet.publicKey);
await sendAndConfirmTransaction(connection, stakeTx, [wallet]);

// Claim accumulated fees
const claimTx = await m3m3.claimFee(wallet.publicKey, null); // null = claim all
await sendAndConfirmTransaction(connection, claimTx, [wallet]);

// Initiate unstake (starts lock period)
const unstakeTx = await m3m3.unstake(
  new BN(500_000_000),
  destinationTokenAccount,
  wallet.publicKey
);

// Cancel pending unstake
const cancelUnstakeTx = await m3m3.cancelUnstake(escrowAddress, wallet.publicKey);

// Complete withdrawal (after lock period)
const withdrawTx = await m3m3.withdraw(escrowAddress, wallet.publicKey);

// Get unstake period
const unstakePeriod = m3m3.getUnstakePeriod(); // Duration in seconds

// Refresh states
await m3m3.refreshStates();

typescript
// Get user stake and claimable balance
const userBalance = await m3m3.getUserStakeAndClaimBalance(wallet.publicKey);
console.log('Staked Amount:', userBalance.stakedAmount.toString());
console.log('Claimable Fees:', userBalance.claimableFees.toString());

// Stake tokens
const stakeTx = await m3m3.stake(new BN(1_000_000_000), wallet.publicKey);
await sendAndConfirmTransaction(connection, stakeTx, [wallet]);

// Claim accumulated fees
const claimTx = await m3m3.claimFee(wallet.publicKey, null); // null = claim all
await sendAndConfirmTransaction(connection, claimTx, [wallet]);

// Initiate unstake (starts lock period)
const unstakeTx = await m3m3.unstake(
  new BN(500_000_000),
  destinationTokenAccount,
  wallet.publicKey
);

// Cancel pending unstake
const cancelUnstakeTx = await m3m3.cancelUnstake(escrowAddress, wallet.publicKey);

// Complete withdrawal (after lock period)
const withdrawTx = await m3m3.withdraw(escrowAddress, wallet.publicKey);

// Get unstake period
const unstakePeriod = m3m3.getUnstakePeriod(); // Duration in seconds

// Refresh states
await m3m3.refreshStates();

DAMM v1 SDK (Legacy Dynamic AMM)

DAMM v1 SDK(旧版动态AMM)

The DAMM v1 SDK is the original constant product AMM, still widely used for stable pools, weighted pools, and LST pools. While DAMM v2 is recommended for new pools, v1 remains fully supported.
DAMM v1 SDK是原始的恒定乘积AMM,仍广泛用于稳定池、加权池和LST池。虽然推荐新项目使用DAMM v2,但v1仍完全受支持。

Basic Setup

基础设置

typescript
import { Connection, PublicKey, Keypair } from '@solana/web3.js';
import AmmImpl from '@meteora-ag/dynamic-amm';

const connection = new Connection('https://api.mainnet-beta.solana.com');

// Create pool instance
const pool = await AmmImpl.create(connection, new PublicKey('POOL_ADDRESS'));

// Or create multiple pools
const pools = await AmmImpl.createMultiple(connection, [poolAddress1, poolAddress2]);
typescript
import { Connection, PublicKey, Keypair } from '@solana/web3.js';
import AmmImpl from '@meteora-ag/dynamic-amm';

const connection = new Connection('https://api.mainnet-beta.solana.com');

// Create pool instance
const pool = await AmmImpl.create(connection, new PublicKey('POOL_ADDRESS'));

// Or create multiple pools
const pools = await AmmImpl.createMultiple(connection, [poolAddress1, poolAddress2]);

Pool Creation

池创建

typescript
// Create permissionless constant product pool
const createPoolTx = await AmmImpl.createPermissionlessConstantProductPoolWithConfig(
  connection,
  wallet.publicKey,
  tokenAMint,
  tokenBMint,
  tokenAAmount,
  tokenBAmount,
  configAddress, // Fee configuration
  {
    lockLiquidity: false, // Lock initial liquidity
    activationPoint: null, // Optional delayed activation
  }
);

// Create memecoin pool (optimized for token launches)
const memePoolTx = await AmmImpl.createPermissionlessConstantProductMemecoinPoolWithConfig(
  connection,
  wallet.publicKey,
  tokenAMint,
  tokenBMint,
  tokenAAmount,
  tokenBAmount,
  configAddress,
  {
    lockLiquidity: true, // Lock liquidity for trust
  }
);
typescript
// Create permissionless constant product pool
const createPoolTx = await AmmImpl.createPermissionlessConstantProductPoolWithConfig(
  connection,
  wallet.publicKey,
  tokenAMint,
  tokenBMint,
  tokenAAmount,
  tokenBAmount,
  configAddress, // Fee configuration
  {
    lockLiquidity: false, // Lock initial liquidity
    activationPoint: null, // Optional delayed activation
  }
);

// Create memecoin pool (optimized for token launches)
const memePoolTx = await AmmImpl.createPermissionlessConstantProductMemecoinPoolWithConfig(
  connection,
  wallet.publicKey,
  tokenAMint,
  tokenBMint,
  tokenAAmount,
  tokenBAmount,
  configAddress,
  {
    lockLiquidity: true, // Lock liquidity for trust
  }
);

Pool State Queries

池状态查询

typescript
// Get LP token supply
const lpSupply = await pool.getLpSupply();

// Get user's LP token balance
const userBalance = await pool.getUserBalance(wallet.publicKey);

// Get swap quote
const swapQuote = pool.getSwapQuote(
  inputMint,
  inputAmount,
  slippageBps // 100 = 1%
);
console.log('Output amount:', swapQuote.outAmount.toString());
console.log('Fee:', swapQuote.fee.toString());
console.log('Price impact:', swapQuote.priceImpact);

// Get deposit quote
const depositQuote = pool.getDepositQuote(
  tokenAAmount,
  tokenBAmount,
  true, // balanced deposit
  slippageBps
);
console.log('LP tokens to receive:', depositQuote.lpAmount.toString());

// Get withdraw quote
const withdrawQuote = pool.getWithdrawQuote(
  lpAmount,
  slippageBps
);
console.log('Token A out:', withdrawQuote.tokenAAmount.toString());
console.log('Token B out:', withdrawQuote.tokenBAmount.toString());

// Refresh pool state
await pool.updateState();
typescript
// Get LP token supply
const lpSupply = await pool.getLpSupply();

// Get user's LP token balance
const userBalance = await pool.getUserBalance(wallet.publicKey);

// Get swap quote
const swapQuote = pool.getSwapQuote(
  inputMint,
  inputAmount,
  slippageBps // 100 = 1%
);
console.log('Output amount:', swapQuote.outAmount.toString());
console.log('Fee:', swapQuote.fee.toString());
console.log('Price impact:', swapQuote.priceImpact);

// Get deposit quote
const depositQuote = pool.getDepositQuote(
  tokenAAmount,
  tokenBAmount,
  true, // balanced deposit
  slippageBps
);
console.log('LP tokens to receive:', depositQuote.lpAmount.toString());

// Get withdraw quote
const withdrawQuote = pool.getWithdrawQuote(
  lpAmount,
  slippageBps
);
console.log('Token A out:', withdrawQuote.tokenAAmount.toString());
console.log('Token B out:', withdrawQuote.tokenBAmount.toString());

// Refresh pool state
await pool.updateState();

Liquidity Operations

流动性操作

typescript
// Deposit liquidity
const depositTx = await pool.deposit(
  wallet.publicKey,
  tokenAAmount,
  tokenBAmount,
  lpAmountMin // Minimum LP tokens to receive
);

// Withdraw liquidity
const withdrawTx = await pool.withdraw(
  wallet.publicKey,
  lpAmount,
  tokenAMin, // Minimum token A to receive
  tokenBMin  // Minimum token B to receive
);
typescript
// Deposit liquidity
const depositTx = await pool.deposit(
  wallet.publicKey,
  tokenAAmount,
  tokenBAmount,
  lpAmountMin // Minimum LP tokens to receive
);

// Withdraw liquidity
const withdrawTx = await pool.withdraw(
  wallet.publicKey,
  lpAmount,
  tokenAMin, // Minimum token A to receive
  tokenBMin  // Minimum token B to receive
);

Swapping

兑换

typescript
// Execute swap
const swapTx = await pool.swap(
  wallet.publicKey,
  inputMint,
  inputAmount,
  minOutputAmount
);
typescript
// Execute swap
const swapTx = await pool.swap(
  wallet.publicKey,
  inputMint,
  inputAmount,
  minOutputAmount
);

Pool Types

池类型

Pool TypeUse CaseFeatures
Constant ProductGeneral trading pairsStandard x*y=k AMM
StableStablecoin pairs (USDC/USDT)Lower slippage for pegged assets
WeightedUnbalanced pools (80/20)Custom token weights
LSTLiquid staking tokensOptimized for staking derivatives

池类型使用场景特性
恒定乘积通用交易对标准x*y=k AMM
稳定池稳定币对(USDC/USDT)锚定资产的低滑点
加权池非平衡池(80/20)自定义代币权重
LST池流动性质押代币针对质押衍生品优化

Zap SDK

Zap SDK

The Zap SDK enables single-token entry and exit for liquidity positions, automatically handling swaps through Jupiter or the pool's built-in routing.
Zap SDK支持流动性仓位的单代币准入/退出,自动通过Jupiter或池内置路由处理兑换。

Basic Setup

基础设置

typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { Zap } from '@meteora-ag/zap-sdk';

const connection = new Connection('https://api.mainnet-beta.solana.com');

// Jupiter API key is required (get from Jupiter Portal)
const JUPITER_API_URL = 'https://quote-api.jup.ag/v6';
const JUPITER_API_KEY = 'your-api-key';

const zap = new Zap(connection, JUPITER_API_URL, JUPITER_API_KEY);
typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { Zap } from '@meteora-ag/zap-sdk';

const connection = new Connection('https://api.mainnet-beta.solana.com');

// Jupiter API key is required (get from Jupiter Portal)
const JUPITER_API_URL = 'https://quote-api.jup.ag/v6';
const JUPITER_API_KEY = 'your-api-key';

const zap = new Zap(connection, JUPITER_API_URL, JUPITER_API_KEY);

Zap Into DLMM Position

单代币准入DLMM仓位

typescript
// Zap single token into DLMM concentrated liquidity position
const zapInDlmmTx = await zap.zapInDlmm({
  user: wallet.publicKey,
  lbPairAddress: dlmmPoolAddress,
  inputMint: SOL_MINT,
  inputAmount: new BN(1_000_000_000), // 1 SOL
  slippageBps: 100, // 1%
  positionPubkey: positionAddress, // Existing or new position
  strategyType: 'SpotBalanced', // Distribution strategy
  minBinId: activeBinId - 10,
  maxBinId: activeBinId + 10,
});

await sendAndConfirmTransaction(connection, zapInDlmmTx, [wallet]);
typescript
// Zap single token into DLMM concentrated liquidity position
const zapInDlmmTx = await zap.zapInDlmm({
  user: wallet.publicKey,
  lbPairAddress: dlmmPoolAddress,
  inputMint: SOL_MINT,
  inputAmount: new BN(1_000_000_000), // 1 SOL
  slippageBps: 100, // 1%
  positionPubkey: positionAddress, // Existing or new position
  strategyType: 'SpotBalanced', // Distribution strategy
  minBinId: activeBinId - 10,
  maxBinId: activeBinId + 10,
});

await sendAndConfirmTransaction(connection, zapInDlmmTx, [wallet]);

Zap Into DAMM v2 Position

单代币准入DAMM v2仓位

typescript
// Zap single token into DAMM v2 pool
const zapInDammV2Tx = await zap.zapInDammV2({
  user: wallet.publicKey,
  poolAddress: dammV2PoolAddress,
  inputMint: USDC_MINT,
  inputAmount: new BN(100_000_000), // 100 USDC
  slippageBps: 100,
  positionPubkey: positionAddress,
});

await sendAndConfirmTransaction(connection, zapInDammV2Tx, [wallet]);
typescript
// Zap single token into DAMM v2 pool
const zapInDammV2Tx = await zap.zapInDammV2({
  user: wallet.publicKey,
  poolAddress: dammV2PoolAddress,
  inputMint: USDC_MINT,
  inputAmount: new BN(100_000_000), // 100 USDC
  slippageBps: 100,
  positionPubkey: positionAddress,
});

await sendAndConfirmTransaction(connection, zapInDammV2Tx, [wallet]);

Zap Out Operations

单代币退出操作

typescript
// Zap out from DLMM to single token
const zapOutDlmmTx = await zap.zapOutDlmm({
  user: wallet.publicKey,
  lbPairAddress: dlmmPoolAddress,
  outputMint: SOL_MINT, // Receive everything as SOL
  positionPubkey: positionAddress,
  percentageToZap: 100, // 100% of position
  slippageBps: 100,
});

// Zap out from DAMM v2 to single token
const zapOutDammV2Tx = await zap.zapOutDammV2({
  user: wallet.publicKey,
  poolAddress: dammV2PoolAddress,
  outputMint: USDC_MINT,
  positionPubkey: positionAddress,
  percentageToZap: 50, // 50% of position
  slippageBps: 100,
});
typescript
// Zap out from DLMM to single token
const zapOutDlmmTx = await zap.zapOutDlmm({
  user: wallet.publicKey,
  lbPairAddress: dlmmPoolAddress,
  outputMint: SOL_MINT, // Receive everything as SOL
  positionPubkey: positionAddress,
  percentageToZap: 100, // 100% of position
  slippageBps: 100,
});

// Zap out from DAMM v2 to single token
const zapOutDammV2Tx = await zap.zapOutDammV2({
  user: wallet.publicKey,
  poolAddress: dammV2PoolAddress,
  outputMint: USDC_MINT,
  positionPubkey: positionAddress,
  percentageToZap: 50, // 50% of position
  slippageBps: 100,
});

Zap Through Jupiter

通过Jupiter路由

typescript
// Get Jupiter quote for optimal routing
const jupiterQuote = await zap.getJupiterQuote({
  inputMint: SOL_MINT,
  outputMint: USDC_MINT,
  amount: new BN(1_000_000_000),
  slippageBps: 50,
});

// Zap out through Jupiter aggregator
const zapOutJupiterTx = await zap.zapOutThroughJupiter({
  user: wallet.publicKey,
  inputMint: tokenMint,
  outputMint: SOL_MINT,
  jupiterSwapResponse: jupiterQuote,
  maxSwapAmount: new BN(1_000_000_000),
  percentageToZap: 100,
});
typescript
// Get Jupiter quote for optimal routing
const jupiterQuote = await zap.getJupiterQuote({
  inputMint: SOL_MINT,
  outputMint: USDC_MINT,
  amount: new BN(1_000_000_000),
  slippageBps: 50,
});

// Zap out through Jupiter aggregator
const zapOutJupiterTx = await zap.zapOutThroughJupiter({
  user: wallet.publicKey,
  inputMint: tokenMint,
  outputMint: SOL_MINT,
  jupiterSwapResponse: jupiterQuote,
  maxSwapAmount: new BN(1_000_000_000),
  percentageToZap: 100,
});

Helper Functions

辅助函数

typescript
// Get token program from mint
const tokenProgram = await zap.getTokenProgramFromMint(connection, mintAddress);

// Get Jupiter swap instruction
const swapIx = await zap.getJupiterSwapInstruction(jupiterQuote, wallet.publicKey);

typescript
// Get token program from mint
const tokenProgram = await zap.getTokenProgramFromMint(connection, mintAddress);

// Get Jupiter swap instruction
const swapIx = await zap.getJupiterSwapInstruction(jupiterQuote, wallet.publicKey);

Pool Farms SDK

池农场SDK

The Pool Farms SDK enables creating and managing liquidity mining farms on DAMM v1 pools.
池农场SDK支持在DAMM v1池上创建和管理流动性挖矿农场。

Basic Setup

基础设置

typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { FarmImpl } from '@meteora-ag/farming';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const farmAddress = new PublicKey('FARM_ADDRESS');

const farm = await FarmImpl.create(connection, farmAddress);
typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { FarmImpl } from '@meteora-ag/farming';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const farmAddress = new PublicKey('FARM_ADDRESS');

const farm = await FarmImpl.create(connection, farmAddress);

Farm Operations

农场操作

typescript
// Deposit LP tokens to farm
const depositTx = await farm.deposit(
  wallet.publicKey,
  lpAmount
);

// Withdraw LP tokens from farm
const withdrawTx = await farm.withdraw(
  wallet.publicKey,
  lpAmount
);

// Claim farming rewards
const claimTx = await farm.claim(wallet.publicKey);

// Get pending rewards
const pendingRewards = await farm.getPendingRewards(wallet.publicKey);
console.log('Pending rewards:', pendingRewards.toString());

// Get user stake info
const stakeInfo = await farm.getUserStakeInfo(wallet.publicKey);
console.log('Staked amount:', stakeInfo.amount.toString());

typescript
// Deposit LP tokens to farm
const depositTx = await farm.deposit(
  wallet.publicKey,
  lpAmount
);

// Withdraw LP tokens from farm
const withdrawTx = await farm.withdraw(
  wallet.publicKey,
  lpAmount
);

// Claim farming rewards
const claimTx = await farm.claim(wallet.publicKey);

// Get pending rewards
const pendingRewards = await farm.getPendingRewards(wallet.publicKey);
console.log('Pending rewards:', pendingRewards.toString());

// Get user stake info
const stakeInfo = await farm.getUserStakeInfo(wallet.publicKey);
console.log('Staked amount:', stakeInfo.amount.toString());

Common Patterns

常见模式

Pattern 1: Initialize with Wallet

模式1:使用钱包初始化

typescript
import { Connection, Keypair } from '@solana/web3.js';
import { Wallet, AnchorProvider } from '@coral-xyz/anchor';
import DLMM from '@meteora-ag/dlmm';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const keypair = Keypair.fromSecretKey(/* your secret key */);
const wallet = new Wallet(keypair);

const provider = new AnchorProvider(connection, wallet, {
  commitment: 'confirmed',
});

// Now use provider.wallet.publicKey for transactions
const dlmm = await DLMM.create(connection, poolAddress);
typescript
import { Connection, Keypair } from '@solana/web3.js';
import { Wallet, AnchorProvider } from '@coral-xyz/anchor';
import DLMM from '@meteora-ag/dlmm';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const keypair = Keypair.fromSecretKey(/* your secret key */);
const wallet = new Wallet(keypair);

const provider = new AnchorProvider(connection, wallet, {
  commitment: 'confirmed',
});

// Now use provider.wallet.publicKey for transactions
const dlmm = await DLMM.create(connection, poolAddress);

Pattern 2: Error Handling

模式2:错误处理

typescript
try {
  const swapTx = await dlmm.swap(swapParams);
  const txHash = await sendAndConfirmTransaction(connection, swapTx, [wallet]);
  console.log('Success:', txHash);
} catch (error) {
  if (error.message.includes('Slippage')) {
    console.error('Slippage exceeded - try increasing tolerance');
  } else if (error.message.includes('InsufficientFunds')) {
    console.error('Not enough balance for this trade');
  } else if (error.message.includes('PoolNotFound')) {
    console.error('Pool does not exist');
  } else {
    throw error;
  }
}
typescript
try {
  const swapTx = await dlmm.swap(swapParams);
  const txHash = await sendAndConfirmTransaction(connection, swapTx, [wallet]);
  console.log('Success:', txHash);
} catch (error) {
  if (error.message.includes('Slippage')) {
    console.error('Slippage exceeded - try increasing tolerance');
  } else if (error.message.includes('InsufficientFunds')) {
    console.error('Not enough balance for this trade');
  } else if (error.message.includes('PoolNotFound')) {
    console.error('Pool does not exist');
  } else {
    throw error;
  }
}

Pattern 3: Batch Operations

模式3:批量操作

typescript
import { Transaction } from '@solana/web3.js';

// Combine multiple instructions in one transaction
const transaction = new Transaction();

const claimFeeIx = await dlmm.claimSwapFee({ owner: wallet.publicKey, position: pos1 });
const claimRewardIx = await dlmm.claimLMReward({ owner: wallet.publicKey, position: pos1 });

transaction.add(...claimFeeIx.instructions);
transaction.add(...claimRewardIx.instructions);

const txHash = await sendAndConfirmTransaction(connection, transaction, [wallet]);
typescript
import { Transaction } from '@solana/web3.js';

// Combine multiple instructions in one transaction
const transaction = new Transaction();

const claimFeeIx = await dlmm.claimSwapFee({ owner: wallet.publicKey, position: pos1 });
const claimRewardIx = await dlmm.claimLMReward({ owner: wallet.publicKey, position: pos1 });

transaction.add(...claimFeeIx.instructions);
transaction.add(...claimRewardIx.instructions);

const txHash = await sendAndConfirmTransaction(connection, transaction, [wallet]);

Pattern 4: Monitor Pool State

模式4:监控池状态

typescript
// Periodically refresh pool state
async function monitorPool(dlmm: DLMM, interval: number = 5000) {
  setInterval(async () => {
    await dlmm.refetchStates();
    const activeBin = await dlmm.getActiveBin();
    console.log(`Current price: ${activeBin.price}`);

    const feeInfo = dlmm.getFeeInfo();
    console.log(`Current fee rate: ${feeInfo.baseFeeRate}%`);
  }, interval);
}

typescript
// Periodically refresh pool state
async function monitorPool(dlmm: DLMM, interval: number = 5000) {
  setInterval(async () => {
    await dlmm.refetchStates();
    const activeBin = await dlmm.getActiveBin();
    console.log(`Current price: ${activeBin.price}`);

    const feeInfo = dlmm.getFeeInfo();
    console.log(`Current fee rate: ${feeInfo.baseFeeRate}%`);
  }, interval);
}

New Features (2025-2026)

新特性(2025-2026年)

DLMM Limit Orders

DLMM限价订单

DLMM now supports fee-free on-chain limit orders:
typescript
// Place limit order on DLMM
const limitOrderTx = await dlmm.placeLimitOrder({
  user: wallet.publicKey,
  binId: targetBinId,
  amount: new BN(1_000_000),
  side: "buy", // or "sell"
});
DLMM现在支持免费链上限价订单:
typescript
// Place limit order on DLMM
const limitOrderTx = await dlmm.placeLimitOrder({
  user: wallet.publicKey,
  binId: targetBinId,
  amount: new BN(1_000_000),
  side: "buy", // or "sell"
});

Auto Vaults (Coming Q1 2026)

自动金库(2026年第一季度推出)

Auto vaults automatically compound fees and support custom market-making strategies through APIs. These vaults help users earn more with less effort.
自动金库自动复利手续费,并通过API支持自定义做市策略。这些金库帮助用户以更少的操作赚取更多收益。

Universal Curve (DBC)

通用曲线(DBC)

The Dynamic Bonding Curve now supports programmable 16-point curves, giving LPs precise control over price trajectories:
typescript
// Create pool with custom curve
const createPoolTx = await dbc.createPoolWithCurve({
  creator: wallet.publicKey,
  baseMint,
  quoteMint,
  curvePoints: [
    { price: 0.001, supply: 0 },
    { price: 0.01, supply: 100_000_000 },
    { price: 0.1, supply: 500_000_000 },
    // ... up to 16 points
  ],
});
动态绑定曲线现在支持可编程的16点曲线,让LP可以精确控制价格轨迹:
typescript
// Create pool with custom curve
const createPoolTx = await dbc.createPoolWithCurve({
  creator: wallet.publicKey,
  baseMint,
  quoteMint,
  curvePoints: [
    { price: 0.001, supply: 0 },
    { price: 0.01, supply: 100_000_000 },
    { price: 0.1, supply: 500_000_000 },
    // ... up to 16 points
  ],
});

Presale Vault (Beta)

预售金库(Beta版)

Presale Vault is Meteora's token presale infrastructure, currently in beta. It enables projects to run presales with built-in protection mechanisms.
Note: Presale Vault is in active development. Check the Meteora documentation for the latest information.

预售金库是Meteora的代币预售基础设施,目前处于Beta版。它支持项目运行带有内置保护机制的预售。
注意: 预售金库正在积极开发中。请查看Meteora文档获取最新信息。

GitHub Repositories

GitHub仓库

TypeScript SDKs

TypeScript SDK

RepositoryDescriptionStars
dlmm-sdkDLMM concentrated liquidity SDK280+
damm-v2-sdkDAMM v2 constant product AMM SDK44+
damm-v1-sdkLegacy DAMM v1 SDK126+
dynamic-bonding-curve-sdkToken launch bonding curves35+
zap-sdkSingle-token entry/exit2+
vault-sdkDynamic vault SDK-
alpha-vault-sdkAnti-bot launch protection-
m3m3Stake-for-fee SDK-
仓库描述星标数
dlmm-sdkDLMM集中流动性SDK280+
damm-v2-sdkDAMM v2恒定乘积AMM SDK44+
damm-v1-sdk旧版DAMM v1 SDK126+
dynamic-bonding-curve-sdk代币发行绑定曲线SDK35+
zap-sdk单代币准入/退出SDK2+
vault-sdk动态金库SDK-
alpha-vault-sdk反机器人发行保护SDK-
m3m3Stake-for-Fee SDK-

Go SDKs

Go SDK

RepositoryDescription
damm-v2-goDAMM v2 Go implementation
dbc-goDynamic Bonding Curve Go SDK
仓库描述
damm-v2-goDAMM v2 Go实现
dbc-go动态绑定曲线Go SDK

Core Programs (Rust)

核心程序(Rust)

RepositoryDescriptionStars
damm-v2DAMM v2 program98+
dynamic-bonding-curveDBC program86+
zap-programZap on-chain program-

仓库描述星标数
damm-v2DAMM v2程序98+
dynamic-bonding-curveDBC程序86+
zap-programZap链上程序-

Meteora Invent (CLI Tool)

Meteora Invent(CLI工具)

Metsumi is Meteora's CLI tool for launching tokens and executing on-chain actions with minimal configuration.
Metsumi是Meteora的CLI工具,用于以最少的配置发行代币和执行链上操作。

Installation

安装

bash
undefined
bash
undefined

Prerequisites: Node.js ≥ 18.0.0, pnpm ≥ 10.0.0

Prerequisites: Node.js ≥ 18.0.0, pnpm ≥ 10.0.0

git clone https://github.com/MeteoraAg/meteora-invent.git cd meteora-invent npm install -g pnpm pnpm install
undefined
git clone https://github.com/MeteoraAg/meteora-invent.git cd meteora-invent npm install -g pnpm pnpm install
undefined

Available Commands

可用命令

DLMM Operations

DLMM操作

bash
undefined
bash
undefined

Create permissionless pool

Create permissionless pool

pnpm dlmm-create-pool
pnpm dlmm-create-pool

Seed liquidity

Seed liquidity

pnpm dlmm-seed-liquidity-lfg pnpm dlmm-seed-liquidity-single-bin
pnpm dlmm-seed-liquidity-lfg pnpm dlmm-seed-liquidity-single-bin

Control pool trading

Control pool trading

pnpm dlmm-set-pool-status
undefined
pnpm dlmm-set-pool-status
undefined

DAMM v2 Operations

DAMM v2操作

bash
undefined
bash
undefined

Create pools

Create pools

pnpm damm-v2-create-balanced-pool pnpm damm-v2-create-one-sided-pool
pnpm damm-v2-create-balanced-pool pnpm damm-v2-create-one-sided-pool

Manage liquidity

Manage liquidity

pnpm damm-v2-add-liquidity pnpm damm-v2-remove-liquidity pnpm damm-v2-split-position
pnpm damm-v2-add-liquidity pnpm damm-v2-remove-liquidity pnpm damm-v2-split-position

Claim fees

Claim fees

pnpm damm-v2-claim-position-fee
undefined
pnpm damm-v2-claim-position-fee
undefined

Dynamic Bonding Curve Operations

动态绑定曲线操作

bash
undefined
bash
undefined

Create bonding curve

Create bonding curve

pnpm dbc-create-config pnpm dbc-create-pool
pnpm dbc-create-config pnpm dbc-create-pool

Trade on curve

Trade on curve

pnpm dbc-swap
pnpm dbc-swap

Graduate to AMM

Graduate to AMM

pnpm dbc-migrate-to-damm-v1 pnpm dbc-migrate-to-damm-v2
undefined
pnpm dbc-migrate-to-damm-v1 pnpm dbc-migrate-to-damm-v2
undefined

Vault Operations

金库操作

bash
undefined
bash
undefined

Alpha Vault for anti-bot launches

Alpha Vault for anti-bot launches

pnpm alpha-vault-create
pnpm alpha-vault-create

Presale Vault (beta)

Presale Vault (beta)

pnpm presale-vault-create
undefined
pnpm presale-vault-create
undefined

Configuration Files

配置文件

Configurations are stored in
studio/config/
:
  • dlmm_config.jsonc
    - DLMM pool settings
  • damm_v1_config.jsonc
    - DAMM v1 settings
  • damm_v2_config.jsonc
    - DAMM v2 settings
  • dbc_config.jsonc
    - Bonding curve settings
  • alpha_vault_config.jsonc
    - Alpha vault settings

配置文件存储在
studio/config/
  • dlmm_config.jsonc
    - DLMM池设置
  • damm_v1_config.jsonc
    - DAMM v1设置
  • damm_v2_config.jsonc
    - DAMM v2设置
  • dbc_config.jsonc
    - 绑定曲线设置
  • alpha_vault_config.jsonc
    - Alpha金库设置

Resources

资源

Skill Structure

技能结构

meteora/
├── SKILL.md                          # This file
├── resources/
│   ├── dlmm-api-reference.md         # DLMM SDK complete API
│   ├── damm-v2-api-reference.md      # DAMM v2 SDK complete API
│   ├── damm-v1-api-reference.md      # DAMM v1 SDK complete API
│   ├── zap-api-reference.md          # Zap SDK API reference
│   ├── pool-farms-reference.md       # Pool Farms SDK reference
│   ├── bonding-curve-reference.md    # DBC SDK reference
│   ├── vault-api-reference.md        # Vault SDK reference
│   ├── alpha-vault-reference.md      # Alpha Vault SDK reference
│   ├── m3m3-api-reference.md         # Stake-for-Fee SDK reference
│   ├── github-repos.md               # All GitHub repositories
│   └── program-addresses.md          # All program addresses
├── examples/
│   ├── dlmm/
│   │   ├── swap.ts                   # Basic swap example
│   │   ├── add-liquidity.ts          # Adding liquidity
│   │   └── claim-fees.ts             # Claiming fees/rewards
│   ├── damm-v2/
│   │   ├── create-pool.ts            # Pool creation
│   │   ├── swap.ts                   # Swapping tokens
│   │   └── manage-position.ts        # Position management
│   ├── damm-v1/
│   │   └── basic-operations.ts       # DAMM v1 pool operations
│   ├── zap/
│   │   └── zap-operations.ts         # Zap in/out examples
│   ├── bonding-curve/
│   │   ├── create-token.ts           # Launch token on curve
│   │   ├── trade.ts                  # Buy/sell on curve
│   │   └── graduation.ts             # Pool graduation
│   ├── vault/
│   │   └── deposit-withdraw.ts       # Vault operations
│   ├── alpha-vault/
│   │   └── participation.ts          # Alpha vault participation
│   └── stake-for-fee/
│       └── staking.ts                # Staking operations
├── templates/
│   ├── trading-bot.ts                # Market making template
│   ├── token-launch.ts               # Token launch template
│   └── liquidity-manager.ts          # LP management template
└── docs/
    ├── fee-structures.md             # Fee configuration guide
    ├── migration-guide.md            # DBC to DAMM migration
    ├── strategy-guide.md             # Liquidity strategies
    └── troubleshooting.md            # Common issues
meteora/
├── SKILL.md                          # This file
├── resources/
│   ├── dlmm-api-reference.md         # DLMM SDK complete API
│   ├── damm-v2-api-reference.md      # DAMM v2 SDK complete API
│   ├── damm-v1-api-reference.md      # DAMM v1 SDK complete API
│   ├── zap-api-reference.md          # Zap SDK API reference
│   ├── pool-farms-reference.md       # Pool Farms SDK reference
│   ├── bonding-curve-reference.md    # DBC SDK reference
│   ├── vault-api-reference.md        # Vault SDK reference
│   ├── alpha-vault-reference.md      # Alpha Vault SDK reference
│   ├── m3m3-api-reference.md         # Stake-for-Fee SDK reference
│   ├── github-repos.md               # All GitHub repositories
│   └── program-addresses.md          # All program addresses
├── examples/
│   ├── dlmm/
│   │   ├── swap.ts                   # Basic swap example
│   │   ├── add-liquidity.ts          # Adding liquidity
│   │   └── claim-fees.ts             # Claiming fees/rewards
│   ├── damm-v2/
│   │   ├── create-pool.ts            # Pool creation
│   │   ├── swap.ts                   # Swapping tokens
│   │   └── manage-position.ts        # Position management
│   ├── damm-v1/
│   │   └── basic-operations.ts       # DAMM v1 pool operations
│   ├── zap/
│   │   └── zap-operations.ts         # Zap in/out examples
│   ├── bonding-curve/
│   │   ├── create-token.ts           # Launch token on curve
│   │   ├── trade.ts                  # Buy/sell on curve
│   │   └── graduation.ts             # Pool graduation
│   ├── vault/
│   │   └── deposit-withdraw.ts       # Vault operations
│   ├── alpha-vault/
│   │   └── participation.ts          # Alpha vault participation
│   └── stake-for-fee/
│       └── staking.ts                # Staking operations
├── templates/
│   ├── trading-bot.ts                # Market making template
│   ├── token-launch.ts               # Token launch template
│   └── liquidity-manager.ts          # LP management template
└── docs/
    ├── fee-structures.md             # Fee configuration guide
    ├── migration-guide.md            # DBC to DAMM migration
    ├── strategy-guide.md             # Liquidity strategies
    └── troubleshooting.md            # Common issues