Learn how to create DLMM and Dynamic AMM pools with Meteora
const signature = await agent.methods.meteoraCreateDlmmPool( tokenAMint, // Token A mint address tokenBMint, // Token B mint address 20, // Bin step 0.25, // Initial price (tokenA/tokenB) true, // Price rounding up 20, // Fee in basis points (0.2%) 1, // Activation type (timestamp) false, // Alpha vault support undefined // Activation point );
const signature = await agent.methods.meteoraCreateDynamicPool( tokenAMint, // Token A mint address tokenBMint, // Token B mint address tokenAAmount, // Token A amount tokenBAmount, // Token B amount 2500, // Trade fee numerator (2.5%) activationPoint, // Optional activation point false, // Alpha vault support 1 // Activation type (timestamp) );
interface DLMMPoolParams { tokenAMint: PublicKey; // Token A mint address tokenBMint: PublicKey; // Token B mint address binStep: number; // Pool bin step initialPrice: number; // Initial price ratio feeBps: number; // Trading fee in basis points priceRoundingUp?: boolean; // Price rounding direction activationType?: number; // 0 for slot, 1 for timestamp activationPoint?: number; // Activation point hasAlphaVault?: boolean; // Alpha vault support }
interface DynamicPoolParams { tokenAMint: PublicKey; // Token A mint address tokenBMint: PublicKey; // Token B mint address tokenAAmount: number; // Token A initial amount tokenBAmount: number; // Token B initial amount tradeFeeNumerator: number; // Trade fee numerator activationType?: number; // 0 for slot, 1 for timestamp activationPoint?: number; // Activation point hasAlphaVault?: boolean; // Alpha vault support }
import { SolanaMeteoraCreateDlmmPool } from 'solana-agent-kit'; const createDlmmPoolTool = new SolanaMeteoraCreateDlmmPool(agent); // Tool input format (JSON string): const input = JSON.stringify({ tokenAMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", tokenBMint: "So11111111111111111111111111111111111111112", binStep: 20, initialPrice: 0.25, feeBps: 20, priceRoundingUp: true, activationType: 1, hasAlphaVault: false });
import { SolanaMeteoraCreateDynamicPool } from 'solana-agent-kit'; const createDynamicPoolTool = new SolanaMeteoraCreateDynamicPool(agent); // Tool input format (JSON string): const input = JSON.stringify({ tokenAMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", tokenBMint: "So11111111111111111111111111111111111111112", tokenAAmount: 1000, tokenBAmount: 250, tradeFeeNumerator: 2500, activationType: 1, hasAlphaVault: false });
"Create a DLMM pool for SOL/USDC with 0.2% fee" "Setup a DLMM pool with 20 bin step and initial price of 0.25"
"Create a Dynamic pool with 1000 USDC and 4 SOL" "Setup a Dynamic AMM pool with 2.5% trading fee"
enum ActivationType { Slot = 0, Timestamp = 1 }
// Always fetch and account for token decimals const tokenAInfo = await getMint(connection, tokenAMint); const tokenBInfo = await getMint(connection, tokenBMint); const decimalsA = tokenAInfo.decimals; const decimalsB = tokenBInfo.decimals;
// Calculate price per lamport for DLMM const pricePerLamport = DLMM.getPricePerLamport( decimalsA, decimalsB, initialPrice );
// Convert human amounts to lamports const amountLamports = new BN( new Decimal(amount) .mul(10 ** decimals) .toString() );
try { const signature = await agent.methods.meteoraCreateDlmmPool(...); } catch (error) { if (error.message.includes("invalid mint")) { // Handle invalid token addresses } else if (error.message.includes("insufficient balance")) { // Handle insufficient funds } }
const DECIMALS = { USDC: 6, SOL: 9 }; const COMMON_BIN_STEPS = { TIGHT: 10, NORMAL: 20, WIDE: 50 };
const BPS_DENOMINATOR = 10000; // For DLMM const FEE_DENOMINATOR = 100000; // For Dynamic AMM // Example: 0.2% fee in DLMM const feeBps = 20; // 20/10000 = 0.2% // Example: 2.5% fee in Dynamic AMM const feeNumerator = 2500; // 2500/100000 = 2.5%
import DLMM from "@meteora-ag/dlmm"; import AmmImpl from "@mercurial-finance/dynamic-amm-sdk";
Was this page helpful?