### Install Dynamic Bonding Curve SDK Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/README.md Install the Dynamic Bonding Curve SDK using npm, pnpm, or yarn. ```bash npm install @meteora-ag/dynamic-bonding-curve-sdk # or pnpm install @meteora-ag/dynamic-bonding-curve-sdk # or yarn add @meteora-ag/dynamic-bonding-curve-sdk ``` -------------------------------- ### Start Solana Localnet Validator Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/README.md Start a local Solana validator for testing purposes. ```bash cd packages/dynamic-bonding-curve pnpm start-validator ``` -------------------------------- ### Prepare Swap Transaction Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md This example demonstrates how to prepare the necessary parameters for a swap transaction, including fetching pool state and calculating the current point. ```typescript const amountIn = await prepareSwapAmountParam(1, NATIVE_MINT, connection) const virtualPoolState = await client.state.getPool(poolAddress) const poolConfigState = await client.state.getPoolConfig( virtualPoolState.config ) const currentPoint = await getCurrentPoint( connection, poolConfigState.activationType ) const quote = await client.pool.swapQuote2({ virtualPool: virtualPoolState.account, config: poolConfigState, swapBaseForQuote: false, amountIn, slippageBps: 50, hasReferral: false, currentPoint, swapMode: SwapMode.PartialFill, }) ``` -------------------------------- ### Create Config and Pool in One Transaction with createConfigAndPool Source: https://context7.com/meteoraag/dynamic-bonding-curve-sdk/llms.txt Atomically creates the configuration key and token pool in a single on-chain transaction. This is useful for launchpads that do not separate partner setup from token creation. It requires parameters for payer, config, feeClaimer, leftoverReceiver, quoteMint, and pre-creation pool details. ```typescript const tx = await client.pool.createConfigAndPool({ // all CreateConfigParams fields... payer: wallet.publicKey, config: configKeypair.publicKey, feeClaimer: wallet.publicKey, leftoverReceiver: wallet.publicKey, quoteMint: NATIVE_MINT, /* ...fee and curve params (same shape as createConfig)... */ preCreatePoolParam: { baseMint: baseMintKeypair.publicKey, name: 'My Token', symbol: 'MTK', uri: 'https://arweave.net/metadata.json', poolCreator: wallet.publicKey, }, }) // sign with wallet + configKeypair + baseMintKeypair ``` -------------------------------- ### Build Curve with Market Cap Fee Scheduler Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Configures a dynamic bonding curve with a customizable market cap fee scheduler. This example demonstrates overriding migration fee options and enabling dynamic fees based on market capitalization. ```typescript const curveConfigWithScheduler = buildCurve({ token: { tokenType: TokenType.Token2022, tokenBaseDecimal: TokenDecimal.SIX, tokenQuoteDecimal: TokenDecimal.NINE, tokenUpdateAuthority: TokenUpdateAuthorityOption.Immutable, totalTokenSupply: 1_000_000_000, leftover: 0, }, fee: { baseFeeParams: { baseFeeMode: BaseFeeMode.FeeSchedulerLinear, feeSchedulerParam: { startingFeeBps: 500, endingFeeBps: 100, numberOfPeriod: 10, totalDuration: 3600, }, }, dynamicFeeEnabled: true, collectFeeMode: CollectFeeMode.QuoteToken, creatorTradingFeePercentage: 0, poolCreationFee: 0, enableFirstSwapWithMinFee: true, }, migration: { migrationOption: MigrationOption.MET_DAMM_V2, migrationFeeOption: MigrationFeeOption.FixedBps100, // Will be auto-overridden to Customizable migrationFee: { feePercentage: 0, creatorFeePercentage: 0 }, migratedPoolFee: { collectFeeMode: MigratedCollectFeeMode.QuoteToken, dynamicFee: DammV2DynamicFeeMode.Enabled, poolFeeBps: 120, baseFeeMode: DammV2BaseFeeMode.FeeMarketCapSchedulerLinear, marketCapFeeSchedulerParams: { endingBaseFeeBps: 25, // Must be less than bonding curve's endingFeeBps (100) numberOfPeriod: 100, startingMarketCap: 20_000, endingMarketCap: 20_000_000, schedulerExpirationDuration: 1000000, }, }, }, liquidityDistribution: { partnerLiquidityPercentage: 55, partnerPermanentLockedLiquidityPercentage: 0, creatorLiquidityPercentage: 0, creatorPermanentLockedLiquidityPercentage: 0, partnerLiquidityVestingInfoParams: { ``` -------------------------------- ### buildCurveWithMidPrice Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Builds a custom constant product curve with a mid price. This function creates a two-segment curve, transitioning from a start price to a mid price, and then from the mid price to a migration price. ```APIDOC ## buildCurveWithMidPrice ### Description Builds a custom constant product curve with a mid price. This will create a two segment curve with a start price -> mid price, and a mid price -> migration price. ### Function Signature ```typescript function buildCurveWithMidPrice( params: BuildCurveWithMidPriceParams ): ConfigParameters ``` ### Parameters #### BuildCurveWithMidPriceParams - **token** (TokenConfig) - Required - Configuration for the token. - **fee** (FeeConfig) - Required - Configuration for fees. - **migration** (MigrationConfig) - Required - Configuration for migration. - **liquidityDistribution** (LiquidityDistributionConfig) - Required - Configuration for liquidity distribution. - **lockedVesting** (LockedVestingParams) - Required - Configuration for locked vesting. - **activationType** (ActivationType) - Required - The type of activation. - **initialMarketCap** (number) - Required - The initial market cap. - **migrationMarketCap** (number) - Required - The migration market cap. - **midPrice** (number) - Required - The mid price where the curve segments. - **percentageSupplyOnMigration** (number) - Required - The percentage of the supply that will be migrated. ### Returns - A `ConfigParameters` object. ### Example ```typescript const curveConfig = buildCurveWithMidPrice({ token: { tokenType: TokenType.Token2022, tokenBaseDecimal: TokenDecimal.SIX, tokenQuoteDecimal: TokenDecimal.NINE, tokenUpdateAuthority: TokenUpdateAuthorityOption.Immutable, totalTokenSupply: 1_000_000_000, leftover: 0, }, fee: { baseFeeParams: { baseFeeMode: BaseFeeMode.FeeSchedulerLinear, feeSchedulerParam: { startingFeeBps: 120, endingFeeBps: 120, numberOfPeriod: 0, totalDuration: 0, }, }, dynamicFeeEnabled: true, collectFeeMode: CollectFeeMode.QuoteToken, creatorTradingFeePercentage: 0, poolCreationFee: 0, enableFirstSwapWithMinFee: true, }, migration: { migrationOption: MigrationOption.MET_DAMM_V2, migrationFeeOption: MigrationFeeOption.Customizable, migrationFee: { feePercentage: 0, creatorFeePercentage: 0 }, migratedPoolFee: { collectFeeMode: MigratedCollectFeeMode.QuoteToken, dynamicFee: DammV2DynamicFeeMode.Enabled, poolFeeBps: 120, }, }, liquidityDistribution: { partnerLiquidityPercentage: 55, partnerPermanentLockedLiquidityPercentage: 0, creatorLiquidityPercentage: 0, creatorPermanentLockedLiquidityPercentage: 0, }, lockedVesting: { totalLockedVestingAmount: 0, numberOfVestingPeriod: 0, cliffUnlockAmount: 0, totalVestingDuration: 0, cliffDurationFromMigrationTime: 0, }, activationType: ActivationType.Timestamp, initialMarketCap: 5000, migrationMarketCap: 1000000, midPrice: 141.75, percentageSupplyOnMigration: 20, }) const transaction = await client.partner.createConfig({ config: configKeypair.publicKey, feeClaimer: wallet.publicKey, leftoverReceiver: wallet.publicKey, payer: wallet.publicKey, quoteMint: NATIVE_MINT, ...curveConfig, }) ``` ### Notes - `buildCurveWithMidPrice` helps you create a curve structure based on initial market cap, migration market cap and mid price. - The `midPrice` is the price at which the curve will be segmented into two parts between the start price and the migration price. - The `percentageSupplyOnMigration` is the percentage of the supply that will be migrated. - If `dynamicFeeEnabled` is true, the dynamic fee will be enabled and capped at 20% of minimum base fee. - `lockedVesting.totalVestingDuration` and `lockedVesting.cliffDurationFromMigrationTime` are in seconds. - `feeSchedulerParam.totalDuration` is based on your `activationType`. Slot is 400ms, Timestamp is 1000ms. - See [buildCurve](#buildCurve) notes for details on migration fee option behavior and `marketCapFeeSchedulerParams` constraints. ``` -------------------------------- ### Build Curve with Mid Price Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Use this function to create a two-segment constant product curve. It segments the curve between a start price and a migration price, using the `midPrice` to define the transition point. Ensure `percentageSupplyOnMigration` is set appropriately. ```typescript const curveConfig = buildCurveWithMidPrice({ token: { tokenType: TokenType.Token2022, tokenBaseDecimal: TokenDecimal.SIX, tokenQuoteDecimal: TokenDecimal.NINE, tokenUpdateAuthority: TokenUpdateAuthorityOption.Immutable, totalTokenSupply: 1_000_000_000, leftover: 0, }, fee: { baseFeeParams: { baseFeeMode: BaseFeeMode.FeeSchedulerLinear, feeSchedulerParam: { startingFeeBps: 120, endingFeeBps: 120, numberOfPeriod: 0, totalDuration: 0, }, }, dynamicFeeEnabled: true, collectFeeMode: CollectFeeMode.QuoteToken, creatorTradingFeePercentage: 0, poolCreationFee: 0, enableFirstSwapWithMinFee: true, }, migration: { migrationOption: MigrationOption.MET_DAMM_V2, migrationFeeOption: MigrationFeeOption.Customizable, migrationFee: { feePercentage: 0, creatorFeePercentage: 0 }, migratedPoolFee: { collectFeeMode: MigratedCollectFeeMode.QuoteToken, dynamicFee: DammV2DynamicFeeMode.Enabled, poolFeeBps: 120, }, }, liquidityDistribution: { partnerLiquidityPercentage: 55, partnerPermanentLockedLiquidityPercentage: 0, creatorLiquidityPercentage: 0, creatorPermanentLockedLiquidityPercentage: 0, }, lockedVesting: { totalLockedVestingAmount: 0, numberOfVestingPeriod: 0, cliffUnlockAmount: 0, totalVestingDuration: 0, cliffDurationFromMigrationTime: 0, }, activationType: ActivationType.Timestamp, initialMarketCap: 5000, migrationMarketCap: 1000000, midPrice: 141.75, percentageSupplyOnMigration: 20, }) const transaction = await client.partner.createConfig({ config: configKeypair.publicKey, feeClaimer: wallet.publicKey, leftoverReceiver: wallet.publicKey, payer: wallet.publicKey, quoteMint: NATIVE_MINT, ...curveConfig, }) ``` -------------------------------- ### Create Config and Pool with First Buy Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Use this function to create a new configuration and pool, optionally including parameters for a first buy. Ensure the payer matches the `CreateConfigAndPoolWithFirstBuyParam` payer. The `createConfigTx` requires payer and config signatures, while `createPoolTx` requires payer, poolCreator, and baseMint signatures. If `firstBuyParam` is included, buyer/payer signatures are also needed for the first-buy instructions. ```typescript createConfigAndPoolWithFirstBuy({ partnerLiquidityVestingInfo: { vestingPercentage: 0, bpsPerPeriod: 0, numberOfPeriods: 0, frequency: 0, cliffDurationFromMigrationTime: 0, }, migratedPoolBaseFeeMode: DammV2BaseFeeMode.FeeTimeSchedulerLinear, migratedPoolMarketCapFeeSchedulerParams: { numberOfPeriod: 0, sqrtPriceStepBps: 0, schedulerExpirationDuration: 0, reductionFactor: new BN('0'), }, padding: [], curve: [ { sqrtPrice: new BN('233334906748540631'), liquidity: new BN('622226417996106429201027821619672729'), }, { sqrtPrice: new BN('79226673521066979257578248091'), liquidity: new BN('1'), }, ], enableFirstSwapWithMinFee: false, migratedPoolFee: { dynamicFee: 0, poolFeeBps: 0, collectFeeMode: 0, }, preCreatePoolParam: { baseMint: new PublicKey('0987654321zyxwvutsrqponmlkjihgfedcba'), name: 'Meteora', symbol: 'MET', uri: 'https://launch.meteora.ag/icons/logo.svg', poolCreator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), }, firstBuyParam: { buyer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), buyAmount: amountIn, minimumAmountOut: new BN(1), referralTokenAccount: null, }, }) ``` -------------------------------- ### Get All Pool Configurations Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves an array of all existing pool configurations. ```typescript async getPoolConfigs(): Promise[]> ``` ```typescript const configs = await client.state.getPoolConfigs() ``` -------------------------------- ### createConfigAndPoolWithFirstBuy Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Creates a configuration and pool, including the initial buy transaction. ```APIDOC ## createConfigAndPoolWithFirstBuy ### Description Creates a configuration and pool with an initial buy. ### Method createConfigAndPoolWithFirstBuy ### Parameters (No parameters explicitly documented in the source) ### Request Example (No request example provided in the source) ### Response (No response details provided in the source) ``` -------------------------------- ### Get Pool Configurations by Owner Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves all pool configurations owned by a specific wallet address. ```typescript async getPoolConfigsByOwner(owner: PublicKey | string): Promise[]> ``` ```typescript owner: PublicKey | string // The owner's wallet address ``` ```typescript const configs = await client.state.getPoolConfigsByOwner(wallet.publicKey) ``` -------------------------------- ### createPoolWithPartnerAndCreatorFirstBuy Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Creates a new pool with the config key and buys the token immediately with partner and creator. A single transaction is returned containing pool creation and optional partner/creator first buy instructions. Partner and creator swap instructions are appended when their corresponding params are provided with `buyAmount > 0`. ```APIDOC ## createPoolWithPartnerAndCreatorFirstBuy ### Description Creates a new pool with the config key and buys the token immediately with partner and creator. ### Function Signature ```typescript async createPoolWithPartnerAndCreatorFirstBuy(params: CreatePoolWithPartnerAndCreatorFirstBuyParams): Promise ``` ### Parameters #### `CreatePoolWithPartnerAndCreatorFirstBuyParams` - **`createPoolParam`** (object) - Required - Parameters for creating the pool. - **`baseMint`** (PublicKey) - The base mint address (generated by you). - **`config`** (PublicKey) - The config account address. - **`name`** (string) - The name of the pool. - **`symbol`** (string) - The symbol of the pool. - **`uri`** (string) - The uri of the pool. - **`payer`** (PublicKey) - The payer of the transaction. - **`poolCreator`** (PublicKey) - The pool creator of the transaction. - **`partnerFirstBuyParam`** (object) - Optional - Parameters for the partner's first buy. - **`partner`** (PublicKey) - The launchpad partner. - **`receiver`** (PublicKey) - The receiver of the transaction. - **`buyAmount`** (BN) - The amount of tokens to buy. - **`minimumAmountOut`** (BN) - The minimum amount of tokens to receive. - **`referralTokenAccount`** (PublicKey | null) - The referral token account (optional). - **`creatorFirstBuyParam`** (object) - Optional - Parameters for the creator's first buy. - **`creator`** (PublicKey) - The pool creator. - **`receiver`** (PublicKey) - The receiver of the transaction. - **`buyAmount`** (BN) - The amount of tokens to buy. - **`minimumAmountOut`** (BN) - The minimum amount of tokens to receive. - **`referralTokenAccount`** (PublicKey | null) - The referral token account (optional). ### Returns A single transaction containing pool creation and optional partner/creator first buy instructions. Partner and creator swap instructions are appended when their corresponding params are provided with `buyAmount > 0`. ### Example ```typescript const creatorAmountIn = await prepareSwapAmountParam( 0.5, NATIVE_MINT, connection ) const partnerAmountIn = await prepareSwapAmountParam( 0.1, NATIVE_MINT, connection ) const transaction = await client.pool.createPoolWithPartnerAndCreatorFirstBuy({ createPoolParam: { baseMint: new PublicKey('0987654321zyxwvutsrqponmlkjihgfedcba'), config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'), name: 'Meteora', symbol: 'MET', uri: 'https://launch.meteora.ag/icons/logo.svg', payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), poolCreator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), }, partnerFirstBuyParam: { partner: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), receiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), buyAmount: partnerAmountIn, minimumAmountOut: new BN(1), referralTokenAccount: null, }, creatorFirstBuyParam: { creator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), receiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), buyAmount: creatorAmountIn, minimumAmountOut: new BN(1), referralTokenAccount: null, }, }) ``` ### Notes - The `poolCreator` is required to sign when creating the pool. - The `partner` is required to sign when `partnerFirstBuyParam` is provided with `buyAmount > 0`. - The `creator` is required to sign when `creatorFirstBuyParam` is provided with `buyAmount > 0`. - The `baseMint` token type must be the same as the config key's token type. - The `minimumAmountOut` parameter protects against slippage. Set it to a value slightly lower than the expected output. - The `referralTokenAccount` parameter is an optional token account. If provided, the referral fee will be applied to the transaction. ``` -------------------------------- ### Get Pool Configuration Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves all details about a specific pool's configuration using its address. ```typescript async getPoolConfig(configAddress: PublicKey | string): Promise ``` ```typescript configAddress: PublicKey | string // The address of the config key ``` ```typescript const config = await client.state.getPoolConfig(configAddress) ``` -------------------------------- ### Create Config and Pool with First Buy Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Use this function to create a configuration key, a token pool, and immediately buy the token. Ensure all required parameters are correctly set. ```typescript async createConfigAndPoolWithFirstBuy(params: CreateConfigAndPoolWithFirstBuyParams): Promise<{ createConfigTx: Transaction createPoolTx: Transaction }> ``` -------------------------------- ### swapQuote2 Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Gets the exact swap out quotation for a given swap. Supports ExactIn, ExactOut, and PartialFill swap modes. ```APIDOC ## swapQuote2 ### Description Gets the exact swap out quotation in between quote and base swaps with specific swap modes (ExactIn, ExactOut, PartialFill). ### Method ```typescript swapQuote2(params: SwapQuote2Params): Promise ``` ### Parameters #### SwapQuote2Params - **virtualPool** (VirtualPool) - Required - The virtual pool address - **config** (PoolConfig) - Required - The pool config address - **swapBaseForQuote** (boolean) - Required - True for base->quote, false for quote->base - **hasReferral** (boolean) - Required - Whether to include a referral fee - **currentPoint** (BN) - Required - The current point - **slippageBps** (number) - Optional - The slippage in bps #### SwapMode Specific Parameters **ExactIn Mode:** - **swapMode** (SwapMode.ExactIn) - Required - Swap exact input amount - **amountIn** (BN) - Required - The exact amount to swap in **PartialFill Mode:** - **swapMode** (SwapMode.PartialFill) - Required - Allow partial fills - **amountIn** (BN) - Required - The amount to swap in **ExactOut Mode:** - **swapMode** (SwapMode.ExactOut) - Required - Swap for exact output amount - **amountOut** (BN) - Required - The exact amount to swap out ### Returns The exact swap out quotation in between quote and base swaps with specific swap modes (ExactIn, ExactOut, PartialFill). ### Example ```typescript const amountIn = await prepareSwapAmountParam(1, NATIVE_MINT, connection) const virtualPoolState = await client.state.getPool(poolAddress) const poolConfigState = await client.state.getPoolConfig( virtualPoolState.config ) const currentPoint = await getCurrentPoint( connection, poolConfigState.activationType ) const quote = await client.pool.swapQuote2({ virtualPool: virtualPoolState.account, config: poolConfigState, swapBaseForQuote: false, amountIn, slippageBps: 50, hasReferral: false, currentPoint, swapMode: SwapMode.PartialFill, }) ``` ### Notes - The `swapMode` parameter determines the type of swap: `SwapMode.ExactIn`, `SwapMode.PartialFill`, or `SwapMode.ExactOut`. - `amountIn` is the amount of tokens to swap, denominated in the smallest unit and token decimals. - `slippageBps` protects against slippage. Set it to a value slightly lower than the expected output. - The `referralTokenAccount` parameter is optional; if provided, a referral fee will be applied. ``` -------------------------------- ### Get Pool and Pool Config States Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves the virtual pool state and its configuration. These are necessary for swap calculations and operations. ```typescript const virtualPoolState = await client.state.getPool(poolAddress) const poolConfigState = await client.state.getPoolConfig( virtualPoolState.config ) ``` -------------------------------- ### Create Config, Pool, and First Buy Transaction Source: https://context7.com/meteoraag/dynamic-bonding-curve-sdk/llms.txt Use this to atomically create a configuration, a liquidity pool, and bundle a first-buy swap. It returns separate transactions for config and pool creation for flexibility. Ensure `enableFirstSwapWithMinFee` is true when bundling a swap. ```typescript import { prepareSwapAmountParam } from '@meteora-ag/dynamic-bonding-curve-sdk' const amountIn = await prepareSwapAmountParam(1 /* SOL */, NATIVE_MINT, connection) const { createConfigTx, createPoolTx } = await client.pool.createConfigAndPoolWithFirstBuy({ payer: wallet.publicKey, config: configKeypair.publicKey, feeClaimer: wallet.publicKey, leftoverReceiver: wallet.publicKey, quoteMint: NATIVE_MINT, enableFirstSwapWithMinFee: true, // required when bundling swap /* ...all curve/fee params... */ preCreatePoolParam: { baseMint: baseMintKeypair.publicKey, name: 'My Token', symbol: 'MTK', uri: 'https://arweave.net/metadata.json', poolCreator: wallet.publicKey, }, firstBuyParam: { buyer: wallet.publicKey, buyAmount: amountIn, minimumAmountOut: new BN(1), referralTokenAccount: null, }, }) // createConfigTx: sign with wallet + configKeypair // createPoolTx: sign with wallet + baseMintKeypair (+ buyer for first-buy instructions) ``` -------------------------------- ### Get DAMM V1 Migration Metadata Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves migration metadata for a DAMM V1 pool. The pool address must be provided. ```typescript async getDammV1MigrationMetadata(poolAddress: PublicKey): Promise ``` ```typescript type meteoraDammMigrationMetadata = { virtualPool: PublicKey padding0: number | number[] partner: PublicKey lpMint: PublicKey partnerLockedLiquidity: BN partnerLiquidity: BN creatorLockedLiquidity: BN creatorLiquidity: BN creatorLockedStatus: number partnerLockedStatus: number creatorClaimStatus: number partnerClaimStatus: number padding: number[] } ``` ```typescript const metadata = await client.state.getDammV1MigrationMetadata(poolAddress) ``` -------------------------------- ### client.partner.createPartnerMetadata Source: https://context7.com/meteoraag/dynamic-bonding-curve-sdk/llms.txt Associates a name, website, and logo URL with the partner's fee-claimer wallet for on-chain branding display on launchpad UIs. ```APIDOC ## client.partner.createPartnerMetadata — register partner branding on-chain ### Description Associates a name, website, and logo URL with the partner's fee-claimer wallet so launchpad UIs can display partner branding. ### Method ```typescript await client.partner.createPartnerMetadata({ name: 'MyLaunchpad', website: 'https://mylaunchpad.io', logo: 'https://mylaunchpad.io/logo.png', feeClaimer: wallet.publicKey, payer: wallet.publicKey, }) ``` ### Request Example ```json { "name": "MyLaunchpad", "website": "https://mylaunchpad.io", "logo": "https://mylaunchpad.io/logo.png", "feeClaimer": "", "payer": "" } ``` ``` -------------------------------- ### Get Partner Metadata Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves metadata for a specific partner using their wallet address. Ensure the wallet address is correctly formatted. ```typescript async getPartnerMetadata(walletAddress: PublicKey | string): Promise ``` ```typescript type partnerMetadata = { feeClaimer: PublicKey padding: BN[] name: string website: string logo: string } ``` ```typescript const metadata = await client.state.getPartnerMetadata(wallet.publicKey) ``` -------------------------------- ### Run Tests Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/README.md Execute the test suite for the dynamic bonding curve SDK. ```bash pnpm test ``` -------------------------------- ### Get Specific Pool Details Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves the details of a specific virtual pool using its address. Returns null if the pool is not found. ```typescript async getPool(poolAddress: PublicKey | string): Promise ``` ```typescript poolAddress: PublicKey | string // The address of the pool ``` ```typescript const pool = await client.state.getPool(poolAddress) ``` ```typescript type VolatilityTracker = { lastUpdateTimestamp: BN padding: number[] sqrtPriceReference: BN volatilityAccumulator: BN volatilityReference: BN } type Metrics = { totalProtocolBaseFee: BN totalProtocolQuoteFee: BN totalTradingBaseFee: BN totalTradingQuoteFee: BN } type VirtualPool = { volatilityTracker: VolatilityTracker config: PublicKey creator: PublicKey baseMint: PublicKey baseVault: PublicKey quoteVault: PublicKey baseReserve: BN quoteReserve: BN protocolBaseFee: BN protocolQuoteFee: BN partnerBaseFee: BN partnerQuoteFee: BN sqrtPrice: BN activationPoint: BN poolType: number isMigrated: number isPartnerWithdrawSurplus: number isProtocolWithdrawSurplus: number migrationProgress: number isWithdrawLeftover: number isCreatorWithdrawSurplus: number migrationFeeWithdrawStatus: number metrics: Metrics finishCurveTimestamp: BN creatorBaseFee: BN creatorQuoteFee: BN padding1: BN[] } ``` -------------------------------- ### Get Pool Fees by Creator Address Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves all fee metrics for pools created by a specific creator address. The client must be initialized. ```typescript const fees = await client.state.getPoolsFeesByCreator(creatorAddress) ``` -------------------------------- ### createPoolWithFirstBuy Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Creates a new liquidity pool and optionally performs an initial token buy. The function includes instructions for the first buy if `firstBuyParam` is provided and `buyAmount` is greater than zero. The `poolCreator` must sign for pool creation, and the `buyer` must sign if `firstBuyParam` is used. ```APIDOC ## createPoolWithFirstBuy ### Description Creates a new pool with the config key and buys the token immediately. ### Function Signature ```typescript async createPoolWithFirstBuy(params: CreatePoolWithFirstBuyParams): Promise<{ createPoolTx: Transaction }> ``` ### Parameters #### `CreatePoolWithFirstBuyParams` Interface ```typescript interface CreatePoolWithFirstBuyParams { createPoolParam: { baseMint: PublicKey // The base mint address (generated by you) config: PublicKey // The config account address name: string // The name of the pool symbol: string // The symbol of the pool uri: string // The uri of the pool payer: PublicKey // The payer of the transaction poolCreator: PublicKey // The pool creator of the transaction } firstBuyParam?: { // Optional first buy param buyer: PublicKey // The buyer of the transaction receiver?: PublicKey // Optional: The receiver of the transaction buyAmount: BN // The amount of tokens to buy minimumAmountOut: BN // The minimum amount of tokens to receive referralTokenAccount: PublicKey | null // The referral token account (optional) } } ``` ### Returns An object containing `createPoolTx`, where first-buy instructions are included when `firstBuyParam` is provided and `buyAmount > 0`. ### Example ```typescript const amountIn = await prepareSwapAmountParam(1, NATIVE_MINT, connection) const transaction = await client.pool.createPoolWithFirstBuy({ createPoolParam: { baseMint: new PublicKey('0987654321zyxwvutsrqponmlkjihgfedcba'), config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'), name: 'Meteora', symbol: 'MET', uri: 'https://launch.meteora.ag/icons/logo.svg', payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), poolCreator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), }, firstBuyParam: { buyer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), buyAmount: amountIn, minimumAmountOut: new BN(1), referralTokenAccount: null, }, }) ``` ### Notes - The `poolCreator` is required to sign when creating the pool. - The `buyer` is required to sign when `firstBuyParam` is provided. - The `baseMint` token type must be the same as the config key's token type. - The `minimumAmountOut` parameter protects against slippage. Set it to a value slightly lower than the expected output. - The `referralTokenAccount` parameter is an optional token account. If provided, the referral fee will be applied to the transaction. - The `receiver` parameter is an optional account. If provided, the token will be sent to the receiver address. ``` -------------------------------- ### Get Pool Fees by Config Address Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves all fee metrics for pools associated with a specific configuration address. Ensure the client is initialized. ```typescript const fees = await client.state.getPoolsFeesByConfig(configAddress) ``` -------------------------------- ### client.pool.createConfigAndPoolWithFirstBuy Source: https://context7.com/meteoraag/dynamic-bonding-curve-sdk/llms.txt Creates a configuration and a liquidity pool, with an optional atomic first-buy swap. It returns separate transactions for configuration and pool creation, offering flexibility. ```APIDOC ## client.pool.createConfigAndPoolWithFirstBuy — config + pool + instant buy Creates a config and pool and optionally bundles a first-buy swap, returning separate `createConfigTx` and `createPoolTx` transactions for flexibility. ### Method ```typescript client.pool.createConfigAndPoolWithFirstBuy({ payer: wallet.publicKey, config: configKeypair.publicKey, feeClaimer: wallet.publicKey, leftoverReceiver: wallet.publicKey, quoteMint: NATIVE_MINT, enableFirstSwapWithMinFee: true, // required when bundling swap /* ...all curve/fee params... */ preCreatePoolParam: { baseMint: baseMintKeypair.publicKey, name: 'My Token', symbol: 'MTK', uri: 'https://arweave.net/metadata.json', poolCreator: wallet.publicKey, }, firstBuyParam: { buyer: wallet.publicKey, buyAmount: amountIn, minimumAmountOut: new BN(1), referralTokenAccount: null, }, }) ``` ### Returns - `createConfigTx`: Transaction for creating the configuration. - `createPoolTx`: Transaction for creating the pool. ``` -------------------------------- ### Retrieve All Pools Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Fetches all virtual pools created through the Dynamic Bonding Curve system. Use this to get a comprehensive list of available pools. ```typescript const pools = await client.state.getPools() ``` -------------------------------- ### createConfigAndPoolWithFirstBuy Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Creates a config key and a token pool and buys the token immediately. This function is useful for initializing a new bonding curve with an initial token purchase. ```APIDOC ## createConfigAndPoolWithFirstBuy ### Description Creates a config key and a token pool and buys the token immediately. ### Method Signature ```typescript async createConfigAndPoolWithFirstBuy(params: CreateConfigAndPoolWithFirstBuyParams): Promise<{ createConfigTx: Transaction createPoolTx: Transaction }>; ``` ### Parameters #### `params` (CreateConfigAndPoolWithFirstBuyParams) - **`payer`** (PublicKey) - Required - The wallet paying for the transaction. - **`config`** (PublicKey) - Required - The config account address (generated by the partner). - **`feeClaimer`** (PublicKey) - Required - The wallet that will be able to claim the fee. - **`leftoverReceiver`** (PublicKey) - Required - The wallet that will receive the bonding curve leftover. - **`quoteMint`** (PublicKey) - Required - The quote mint address. - **`poolFees`** (object) - Required - Configuration for pool fees. - **`baseFee`** (object) - Required - Base fee configuration. - **`cliffFeeNumerator`** (BN) - Required - Initial fee numerator (base fee). - **`firstFactor`** (number) - Required - feeScheduler: numberOfPeriod, rateLimiter: feeIncrementBps. - **`secondFactor`** (BN) - Required - feeScheduler: periodFrequency, rateLimiter: maxLimiterDuration. - **`thirdFactor`** (BN) - Required - feeScheduler: reductionFactor, rateLimiter: referenceAmount. - **`baseFeeMode`** (number) - Required - 0: FeeSchedulerLinear, 1: FeeSchedulerExponential, 2: RateLimiter. - **`dynamicFee`** (object | null) - Optional - Dynamic fee configuration. - **`binStep`** (number) - Required - u16 value representing the bin step in bps. - **`binStepU128`** (BN) - Required - u128 value for a more accurate bin step. - **`filterPeriod`** (number) - Required - Minimum time that must pass between fee updates. - **`decayPeriod`** (number) - Required - Period after the volatility starts decaying (must be > filterPeriod). - **`reductionFactor`** (number) - Required - Controls how quickly volatility decys over time. - **`variableFeeControl`** (number) - Required - Multiplier that determines how much volatility affects fees. - **`maxVolatilityAccumulator`** (number) - Required - Caps the maximum volatility that can be accumulated. - **`collectFeeMode`** (number) - Required - 0: QuoteToken, 1: OutputToken. - **`migrationOption`** (number) - Required - 0: DAMM V1, 1: DAMM v2. - **`activationType`** (number) - Required - 0: Slot, 1: Timestamp. - **`tokenType`** (number) - Required - 0: SPL, 1: Token2022. - **`tokenDecimal`** (number) - Required - The number of decimals for the token. - **`partnerLiquidityPercentage`** (number) - Required - The percentage of the LP that will be allocated to the partner in the graduated pool (0-100). - **`partnerPermanentLockedLiquidityPercentage`** (number) - Required - The percentage of the locked LP that will be allocated to the partner in the graduated pool (0-100). - **`creatorLiquidityPercentage`** (number) - Required - The percentage of the LP that will be allocated to the creator in the graduated pool (0-100). - **`creatorPermanentLockedLiquidityPercentage`** (number) - Required - The percentage of the locked LP that will be allocated to the creator in the graduated pool (0-100). - **`migrationQuoteThreshold`** (BN) - Required - The quote threshold for migration. - **`sqrtStartPrice`** (BN) - Required - The starting price of the pool. - **`lockedVesting`** (object) - Optional - Locked vesting configuration. - **`amountPerPeriod`** (BN) - Required - The amount of tokens that will be vested per period. - **`cliffDurationFromMigrationTime`** (BN) - Required - The duration of the waiting time before the vesting starts. - **`frequency`** (BN) - Required - The frequency of the vesting. - **`numberOfPeriod`** (BN) - Required - The number of periods of the vesting. - **`cliffUnlockAmount`** (BN) - Required - The amount of tokens that will be unlocked when vesting starts. - **`migrationFeeOption`** (number) - Required - 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps, 6: Customizable (only for DAMM v2). - **`tokenSupply`** (object | null) - Optional - Token supply configuration. - **`preMigrationTokenSupply`** (BN) - Required - The token supply before migration. - **`postMigrationTokenSupply`** (BN) - Required - The token supply after migration. - **`creatorTradingFeePercentage`** (number) - Required - The percentage of the trading fee that will be allocated to the creator. - **`tokenUpdateAuthority`** (number) - Required - 0 - CreatorUpdateAuthority, 1 - Immutable, 2 - PartnerUpdateAuthority, 3 - CreatorUpdateAndMintAuthority, 4 - PartnerUpdateAndMintAuthority. - **`migrationFee`** (object) - Optional - Migration fee configuration. - **`feePercentage`** (number) - Required - The percentage of fee taken from migration quote threshold (0-99). - **`creatorFeePercentage`** (number) - Required - The fee share percentage for the creator from the migration fee (0-100). - **`migratedPoolFee`** (object) - Optional - Migrated pool fee configuration (Only when migrationOption = MET_DAMM_V2 (1) and migrationFeeOption = Customizable (6)). - **`collectFeeMode`** (number) - Required - 0: QuoteToken, 1: OutputToken, 2: Compounding. - **`dynamicFee`** (number) - Required - 0: Disabled, 1: Enabled. - **`poolFeeBps`** (number) - Required - The pool fee in basis points. Minimum 10, Maximum 1000 bps. - **`compoundingFeeBps`** (number) - Optional - Required when collectFeeMode = 2 (Compounding), otherwise must be 0. ### Returns - **`createConfigTx`** (Transaction) - The transaction for creating the config. - **`createPoolTx`** (Transaction) - The transaction for creating the pool. ``` -------------------------------- ### Get Pool Migration Quote Threshold Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Retrieves the migration quote threshold for a given pool address. This value is important for understanding migration parameters. ```typescript const threshold = await client.state.getPoolMigrationQuoteThreshold(poolAddress) ``` -------------------------------- ### Create Config and Pool with First Buy Source: https://github.com/meteoraag/dynamic-bonding-curve-sdk/blob/main/packages/dynamic-bonding-curve/docs.md Use this function to create a new pool configuration and initialize a pool. It supports an optional first buy transaction to be included if `firstBuyParam` is provided and `buyAmount` is greater than 0. ```typescript const amountIn = await prepareSwapAmountParam(1, NATIVE_MINT, connection) const transactions = await client.pool.createConfigAndPoolWithFirstBuy({ payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'), feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), leftoverReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'), quoteMint: new PublicKey('So11111111111111111111111111111111111111112'), poolFees: { baseFee: { cliffFeeNumerator: new BN('25000000'), firstFactor: 0, secondFactor: new BN('0'), thirdFactor: new BN('0'), baseFeeMode: BaseFeeMode.FeeSchedulerLinear, }, dynamicFee: { binStep: 1, binStepU128: new BN('1844674407370955'), filterPeriod: 10, decayPeriod: 120, reductionFactor: 1000, variableFeeControl: 100000, maxVolatilityAccumulator: 100000, }, }, activationType: 0, collectFeeMode: 0, migrationOption: 0, tokenType: 0, tokenDecimal: 9, migrationQuoteThreshold: new BN('1000000000'), partnerLiquidityPercentage: 25, creatorLiquidityPercentage: 25, partnerPermanentLockedLiquidityPercentage: 25, creatorPermanentLockedLiquidityPercentage: 25, sqrtStartPrice: new BN('58333726687135158'), lockedVesting: { amountPerPeriod: new BN('0'), cliffDurationFromMigrationTime: new BN('0'), frequency: new BN('0'), numberOfPeriod: new BN('0'), cliffUnlockAmount: new BN('0'), }, migrationFeeOption: 0, tokenSupply: null, creatorTradingFeePercentage: 0, tokenUpdateAuthority: 0, migrationFee: { feePercentage: 25, creatorFeePercentage: 50, }, poolCreationFee: new BN(1000000000), creatorLiquidityVestingInfo: { vestingPercentage: 0, bpsPerPeriod: 0, numberOfPeriods: 0, frequency: 0, cliffDurationFromMigrationTime: 0, }, }); ``` -------------------------------- ### Get Pool Fees by Config Source: https://context7.com/meteoraag/dynamic-bonding-curve-sdk/llms.txt Aggregates fee data across all pools associated with a specific configuration address. Useful for partner analytics dashboards. ```typescript const fees = await client.state.getPoolsFeesByConfig(configAddress) fees.forEach(f => console.log(f.poolAddress.toBase58(), f.partnerQuoteFee.toString())) ```