For an overview on how Dynamic Bonding Curve works, please .
This SDK provides a set of tools and methods to interact with the . It enables developers to easily create and manage dynamic bonding curves, with support for custom configurations and fee structures.
Program Repo:
SDK on Github:
NPM:
DBC Migrator Keeper docs:
Installation
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
Initialization
import { Connection } from '@solana/web3.js'
import { DynamicBondingCurveClient } from '@meteora-ag/dynamic-bonding-curve-sdk'
const connection = new Connection('https://api.mainnet-beta.solana.com')
const client = new DynamicBondingCurveClient(connection, 'confirmed')
Partner will create a unique config key, that includes all configuration for their Dynamic Bonding Curve (DBC) on their platform (e.g. a launchpad).
Creators (users of the platform) can create a token and create a Dynamic Bonding Curve pool using this unique partner config key
Trading platforms (e.g. Jupiter, trading bots) can swap with the Dynamic Bonding Curve pool
When the DBC pool reaches a pre-defined minimum quote threshold, no one can swap with that pool anymore
Meteora's migrator keeper service then migrates the DBC pool by sending a crank to create a new Meteora Dynamic AMM v1 or v2 pool
Upon migration LP tokens are locked by the launchpad, with fees claimable by the partner or creator. This is optional and can be configured as part of the config key.
Key Parameters for configuration
Partner can specify these parameters when they create a configuration on all their pools:
pool_fees: include base_fee and dynamic_fee (optional). Partner can add fee scheduler in base_fee or just a fixed fee. pool_fees defines the trading fee for any pool that is created from this configuration.
collect_fee_mode (0 | 1): 0 means the virtual pool will only collect fee in quote token, 1 means virtual pool will collect fee in both tokens.
migration_option: right now we only support migration to Meteora DAMM, so partner must set the value as 0 for this field.
activation_type (0 | 1): 0 means slot, 1 means timestamp, this field indicates the time unit that pool will work with, mostly in calculating fee scheduler and dynamic fee.
token_type (0 | 1): 0 means SPL Token, 1 means Token2022.
token_decimal: the token decimals that the token will use when user creates the virtual pool with this configuration, we only support token decimals from 6 to 9.
partner_lp_percentage: the percentage of LP that partner can claim after token is migrated.
partner_locked_lp_percentage: the percentage of LP that partner will locked permanently after token is migrated.
creator_lp_percentage: the percentage of LP that creator can claim after token is migrated.
creator_locked_lp_percentage: the percentage of LP that creator will be locked permanently after token is migrated.
migration_quote_threshold: the threhold for quote token, that after virtual pool reserve get such quote token amount, the token will graduate from the launch pool and will be migrated.
fee_claimer: the address of partner that can claim trading fees from the virtual pools as well as fees from the locked LPs.
owner: owner of the configuration.
quote_mint: the quote mint address that virtual pool will support.
migration_fee_option: allow partner to choose a fee option on graduated pool (currently support 0.25% | 0.3% | 1% | 2% | 4% | 6%)
token_supply: when the fields are specified, token will have fixed supply in pre and post migration, leftover will be returned to leftover_receiver (configured in config key)
sqrt_start_price: square root of min price in the bonding curve for the virtual pools.
curve: an array of square price and liquidity, that defines the liquidity distribution for the virtual pools.
Example math to build a simple curve (constant-product) from your parameters
initial base reserve: x tokens (a decimals)
initial quote reserve: y tokens (b decimals) (SOL)
migration threshold: z tokens (SOL)
Calculate price = y * (10^(b-a)) / x (pls keep floating point)
Calculate sqrtStartPrice = floor(sqrt(price) * 2^64) (cut all floating point)
interface CreateConfigParam {
payer: PublicKey // The wallet paying for the transaction
config: PublicKey // The config account address (generated by the partner)
feeClaimer: PublicKey // The wallet that will be able to claim the fee
leftoverReceiver: PublicKey // The wallet that will receive the bonding curve leftover
quoteMint: PublicKey // The quote mint address
poolFees: {
// The pool fees
baseFee: {
cliffFeeNumerator: BN // Initial fee numerator (base fee)
numberOfPeriod: number // The number of reduction periods
reductionFactor: BN // How much fee reduces in each period
periodFrequency: BN // How often fees change
feeSchedulerMode: number // 0: Linear, 1: Exponential
}
dynamicFee: {
// Optional dynamic fee
binStep: number // u16 value representing the bin step in bps
binStepU128: BN // u128 value for a more accurate bin step
filterPeriod: number // Minimum time that must pass between fee updates
decayPeriod: number // Period after the volatility starts decaying (must be > filterPeriod)
reductionFactor: number // Controls how quickly volatility decys over time
variableFeeControl: number // Multiplier that determines how much volatility affects fees
maxVolatilityAccumulator: number // Caps the maximum volatility that can be accumulated
} | null
}
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Only Quote, 1: Both
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenType: number // 0: SPL, 1: Token2022
tokenDecimal: number // The number of decimals for the token
migrationQuoteThreshold: BN // The quote threshold for migration
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner (0-100)
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator (0-100)
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked (0-100)
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked (0-100)
sqrtStartPrice: BN // The starting price of the pool
lockedVesting: {
// Optional locked vesting (BN (0) for all fields for no vesting)
amountPerPeriod: BN // The amount of tokens that will be vested per period
cliffDurationFromMigrationTime: BN // The duration of the cliff period
frequency: BN // The frequency of the vesting
numberOfPeriod: BN // The number of periods
cliffUnlockAmount: BN // The amount of tokens that will be unlocked at the cliff
}
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenSupply: {
// Optional token supply
preMigrationTokenSupply: BN // The token supply before migration
postMigrationTokenSupply: BN // The token supply after migration
} | null
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
padding0: []
padding1: []
curve: {
// The curve of the pool
sqrtPrice: BN // The square root of the curve point price
liquidity: BN // The liquidity of the curve point
}[]
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.createConfig({
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('2500000'),
numberOfPeriod: 0,
reductionFactor: new BN('0'),
periodFrequency: new BN('0'),
feeSchedulerMode: FeeSchedulerMode.Linear,
},
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'),
partnerLpPercentage: 25,
creatorLpPercentage: 25,
partnerLockedLpPercentage: 25,
creatorLockedLpPercentage: 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: {
preMigrationTokenSupply: new BN('10000000000000000000'),
postMigrationTokenSupply: new BN('10000000000000000000'),
},
creatorTradingFeePercentage: 0,
padding0: [],
padding1: [],
curve: [
{
sqrtPrice: new BN('233334906748540631'),
liquidity: new BN('622226417996106429201027821619672729'),
},
{
sqrtPrice: new BN('79226673521066979257578248091'),
liquidity: new BN('1'),
},
],
})
Notes
When creating a new configuration for a dynamic bonding curve, several validations are performed to ensure the parameters are valid:
Pool Fees
Pool fees are required and must be valid
Base fee must have a positive cliff fee numerator
Fee Scheduler
when in linear feeSchedulerMode:
fee = cliff_fee_numerator - (period * reduction_factor)
when in exponential feeSchedulerMode:
fee = cliff_fee_numerator * (1 - reduction_factor/10_000)^period
Fee Mode
Collect fee mode must be either OnlyQuote (0) or Both (1)
Migration and Token Type
For migration to DAMM v1 (MigrationOption: 0), token type must be type SPL (TokenType: 0)
Activation Type
Must be either Slot (0) or Timestamp (1)
Migration Fee
Must be a valid option: FixedBps25 (0), FixedBps30 (1), FixedBps100 (2), FixedBps200 (3), FixedBps400 (4), FixedBps600 (5)
Token Decimals
Must be between 6 and 9
LP Percentages
The sum of partner LP, creator LP, partner locked LP, and creator locked LP percentages must equal 100
Migration Quote Threshold
Must be greater than 0
Price
Square root start price must be within valid range (MIN_SQRT_PRICE to MAX_SQRT_PRICE)
Curve
Must have at least one point and not exceed MAX_CURVE_POINT
First curve point must have sqrt price greater than start price and positive liquidity
Curve points must be in ascending order by sqrt price
All points must have positive liquidity
Last point's sqrt price must not exceed MAX_SQRT_PRICE
Locked Vesting
If not default (all zeros), must have valid frequency and total amount greater than 0
Token Supply
Must be valid in relation to swap base amount, migration base amount, and locked vesting
Post-migration supply must not exceed pre-migration supply
Total required tokens (swap + migration + vesting) must not exceed pre-migration supply
Leftover receiver must be a valid PublicKey (not default/zero address)
buildCurveAndCreateConfig
Builds a new constant product config with customisable parameters based on percentage of supply on migration and migration quote threshold. This creates a new configuration key that will dictate the behavior of all pools created with this key.
interface BuildCurveAndCreateConfigParam {
buildCurveParam: {
totalTokenSupply: number // The total token supply
percentageSupplyOnMigration: number // The percentage of the supply that will be migrated
migrationQuoteThreshold: number // The quote threshold for migration
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenBaseDecimal: number // The number of decimals for the base token
tokenQuoteDecimal: number // The number of decimals for the quote token
lockedVesting: {
// Optional locked vesting (BN (0) for all fields for no vesting)
amountPerPeriod: BN // The amount of tokens that will be vested per period
cliffDurationFromMigrationTime: BN // The duration of the cliff period
frequency: BN // The frequency of the vesting
numberOfPeriod: BN // The number of periods
cliffUnlockAmount: BN // The amount of tokens that will be unlocked at the cliff
}
feeSchedulerParam: {
// Optional fee scheduler (BN (0) for all fields for no fee scheduler)
numberOfPeriod: number // The number of periods
reductionFactor: number // The reduction factor
periodFrequency: number // The frequency of the fee reduction
feeSchedulerMode: number // 0: Linear, 1: Exponential
}
baseFeeBps: number // The base fee in bps
dynamicFeeEnabled: boolean // Whether dynamic fee is enabled (true: enabled, false: disabled)
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Only Quote, 1: Both
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenType: number // 0: SPL, 1: Token2022
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
}
feeClaimer: PublicKey // The wallet that will be able to claim the fee
leftoverReceiver: PublicKey // The wallet that will receive the bonding curve leftover
payer: PublicKey // The wallet that will pay for the transaction
quoteMint: PublicKey // The quote mint address
config: PublicKey // The config account address (generated by the partner)
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.buildCurveAndCreateConfig({
buildCurveParam: {
totalTokenSupply: 1000000000,
percentageSupplyOnMigration: 3,
migrationQuoteThreshold: 0.5,
migrationOption: 0,
tokenBaseDecimal: 9,
tokenQuoteDecimal: 9,
lockedVesting: {
amountPerPeriod: new BN(1000000),
cliffDurationFromMigrationTime: new BN(0),
frequency: new BN(30 * 24 * 60 * 60),
numberOfPeriod: new BN(12),
cliffUnlockAmount: new BN(5000000),
},
feeSchedulerParam: {
numberOfPeriod: 0,
reductionFactor: 0,
periodFrequency: 0,
feeSchedulerMode: 0,
},
baseFeeBps: 100,
dynamicFeeEnabled: true,
activationType: 0,
collectFeeMode: 0,
migrationFeeOption: 0,
tokenType: 0,
partnerLpPercentage: 25,
creatorLpPercentage: 25,
partnerLockedLpPercentage: 25,
creatorLockedLpPercentage: 25,
creatorTradingFeePercentage: 0,
},
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
leftoverReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
Use createConfig when you understand the bonding curve math and want more customization to the curve structure
Use buildCurveAndCreateConfig when you want to create a curve structure based on percentage of supply on migration and migration quote threshold. We handle the math for you.
buildCurveAndCreateConfigByMarketCap
Builds a new constant product config with customisable parameters based on market cap. This creates a new configuration key that will dictate the behavior of all pools created with this key.
interface BuildCurveAndCreateConfigByMarketCapParam {
buildCurveByMarketCapParam: {
totalTokenSupply: number // The total token supply
initialMarketCap: number // The initial market cap
migrationMarketCap: number // The migration market cap
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenBaseDecimal: number // The number of decimals for the base token
tokenQuoteDecimal: number // The number of decimals for the quote token
lockedVesting: {
// Optional locked vesting (BN (0) for all fields for no vesting)
amountPerPeriod: BN // The amount of tokens that will be vested per period
cliffDurationFromMigrationTime: BN // The duration of the cliff period
frequency: BN // The frequency of the vesting
numberOfPeriod: BN // The number of periods
cliffUnlockAmount: BN // The amount of tokens that will be unlocked at the cliff
}
feeSchedulerParam: {
// Optional fee scheduler (BN (0) for all fields for no fee scheduler)
numberOfPeriod: number // The number of periods
reductionFactor: number // The reduction factor
periodFrequency: number // The frequency of the fee reduction
feeSchedulerMode: number // 0: Linear, 1: Exponential
}
baseFeeBps: number // The base fee in bps
dynamicFeeEnabled: boolean // Whether dynamic fee is enabled (true: enabled, false: disabled)
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Only Quote, 1: Both
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenType: number // 0: SPL, 1: Token2022
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
}
feeClaimer: PublicKey // The wallet that will be able to claim the fee
leftoverReceiver: PublicKey // The wallet that will receive the bonding curve leftover
payer: PublicKey // The wallet that will pay for the transaction
quoteMint: PublicKey // The quote mint address
config: PublicKey // The config account address (generated by the partner)
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.buildCurveAndCreateConfigByMarketCap({
buildCurveByMarketCapParam: {
totalTokenSupply: 1000000000,
initialMarketCap: 98.58,
migrationMarketCap: 3187.61,
migrationOption: 0,
tokenBaseDecimal: 9,
tokenQuoteDecimal: 9,
lockedVesting: {
amountPerPeriod: new BN(0),
cliffDurationFromMigrationTime: new BN(0),
frequency: new BN(0),
numberOfPeriod: new BN(0),
cliffUnlockAmount: new BN(0),
},
feeSchedulerParam: {
numberOfPeriod: 0,
reductionFactor: 0,
periodFrequency: 0,
feeSchedulerMode: 0,
},
baseFeeBps: 100,
dynamicFeeEnabled: true,
activationType: 0,
collectFeeMode: 0,
migrationFeeOption: 0,
tokenType: TokenType.SPL,
partnerLpPercentage: 25,
creatorLpPercentage: 25,
partnerLockedLpPercentage: 25,
creatorLockedLpPercentage: 25,
creatorTradingFeePercentage: 0,
},
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
leftoverReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
Use createConfig when you understand the bonding curve math and want more customization to the curve structure
Use buildCurveAndCreateConfigByMarketCap when you want to create a curve structure based on market cap. We handle the math for you.
createPartnerMetadata
Creates a new partner metadata account. This partner metadata will be tagged to a wallet address that holds the config keys.
interface CreatePartnerMetadataParam {
name: string // The name of the partner
website: string // The website of the partner
logo: string // The logo of the partner
feeClaimer: PublicKey // The wallet that will be able to claim the fee
payer: PublicKey // The wallet that will pay for the transaction
}
Returns
A transaction that can be signed and sent to the network.
interface ClaimTradingFeeParam {
pool: PublicKey // The pool address
feeClaimer: PublicKey // The wallet that will claim the fee
maxBaseAmount: BN // The maximum base amount to claim (use 0 to not claim base tokens)
maxQuoteAmount: BN // The maximum quote amount to claim (use 0 to not claim quote tokens)
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.claimPartnerTradingFee({
pool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
maxBaseAmount: new BN(1000000),
maxQuoteAmount: new BN(1000000),
})
Notes
The feeClaimer of the pool must be the same as the feeClaimer in the ClaimTradingFeeParam params.
You can indicate maxBaseAmount or maxQuoteAmount to be 0 to not claim Base or Quote tokens respectively.
interface PartnerWithdrawSurplusParam {
feeClaimer: PublicKey // The wallet that will claim the fee
virtualPool: PublicKey // The virtual pool address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.partnerWithdrawSurplus({
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
})
Notes
The feeClaimer of the pool must be the same as the feeClaimer in the PartnerWithdrawSurplusParam params.
interface CreatePoolParam {
quoteMint: PublicKey // The quote mint address
baseMint: PublicKey // The base mint address (generated by you)
config: PublicKey // The config account address
baseTokenType: number // The base token type
quoteTokenType: number // The quote token type
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
}
Returns
A transaction that requires signatures from the payer, the baseMint keypair, and the poolCreator before being submitted to the network.
Example
const transaction = await client.pool.createPool({
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
baseMint: new PublicKey('0987654321zyxwvutsrqponmlkjihgfedcba'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
baseTokenType: 0,
quoteTokenType: 0,
name: 'Meteora',
website: 'https://launch.meteora.ag',
logo: 'https://launch.meteora.ag/icons/logo.svg',
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
poolCreator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
The payer must be the same as the payer in the CreatePoolParam params.
The poolCreator is required to sign when creating the pool.
The baseMint token type must be the same as the config key's token type.
The quoteMint must be the same as the config key's quoteMint.
createPoolAndBuy
Creates a new pool with the configuration key and buys the token immediately.
interface CreatePoolAndBuyParam {
createPoolParam: CreatePoolParam // The create pool parameters
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 transaction that requires signatures from the payer, the baseMint keypair, and the poolCreator before being submitted to the network.
Example
const transaction = await client.pool.createPoolAndBuy({
createPoolParam: {
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
baseMint: new PublicKey('0987654321zyxwvutsrqponmlkjihgfedcba'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
baseTokenType: 0,
quoteTokenType: 0,
name: 'Meteora',
website: 'https://launch.meteora.ag',
logo: 'https://launch.meteora.ag/icons/logo.svg',
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
poolCreator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
},
buyAmount: new BN(0.1 * 1e9),
minimumAmountOut: new BN(1),
referralTokenAccount: null,
})
Notes
The payer must be the same as the payer in the CreatePoolParam params.
The poolCreator is required to sign when creating the pool.
The baseMint token type must be the same as the config key's token type.
The quoteMint must be the same as the config key's quoteMint.
The buyAmount must be greater than 0.
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.
swap
Swaps between base and quote or quote and base on the Dynamic Bonding Curve.
interface SwapParam {
owner: PublicKey // The person swapping the tokens
amountIn: BN // The amount of quote or base tokens to swap
minimumAmountOut: BN // The minimum amount of quote or base tokens to receive
swapBaseForQuote: boolean // Whether to swap base for quote. true = swap base for quote, false = swap quote for base
poolAddress: PublicKey // The pool address
referralTokenAccount: PublicKey | null // The referral token account (optional)
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.pool.swap({
owner: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
amountIn: new BN(1000000000),
minimumAmountOut: new BN(0),
swapBaseForQuote: false,
poolAddress: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
referralTokenAccount: null,
})
Notes
The owner must have sufficient balance for the swap.
For SOL swaps, the owner needs additional SOL for transaction fees (approximately 0.01 SOL).
When swapping quote for base (buying tokens), set swapBaseForQuote to false.
When swapping base for quote (selling tokens), set swapBaseForQuote to true.
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.
If the transaction fails with "insufficient balance", check that you have enough tokens plus fees for the transaction.
The pool address can be derived using client.getDbcPoolAddress(quoteMint, baseMint, config).
swapQuote
Gets the swap quotation between base and quote swaps or quote and base swaps.
const virtualPoolState = await client.getPool(poolAddress)
const poolConfigState = await client.getPoolConfig(virtualPoolState.config)
const quote = await client.pool.swapQuote({
virtualPool: virtualPoolState, // The virtual pool state
config: poolConfigState, // The pool config state
swapBaseForQuote: false, // Whether to swap base for quote
amountIn: new BN(100000000), // The amount of tokens to swap
slippageBps: 100, // The slippage in basis points (optional)
hasReferral: false, // Whether to include a referral fee
currentPoint: new BN(0), // The current point
})
Notes
The swapBaseForQuote parameter determines the direction of the swap:
true: Swap base tokens for quote tokens
false: Swap quote tokens for base tokens
The amountIn is the amount of tokens you want to swap, denominated in the smallest unit and token decimals. (e.g., lamports for SOL).
The slippageBps parameter is the slippage in basis points (optional). This will calculate the minimum amount out based on the slippage.
The hasReferral parameter indicates whether a referral fee should be included in the calculation.
The currentPoint parameter is typically used in cases where the config has applied a fee scheduler. If activationType == 0, then it is current slot. If activationType == 1, then it is the current block timestamp. You can fill in accordingly based on slot or timestamp.
Migration Functions
createLocker
Creates a new locker account when migrating from Dynamic Bonding Curve to DAMM V1 or DAMM V2.
interface CreateDammV1MigrationMetadataParam {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
config: PublicKey // The config address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.createDammV1MigrationMetadata({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
When migrating to DAMM V1, the createDammV1MigrationMetadata function must be the first function called.
migrateToDammV1
Migrates the Dynamic Bonding Curve pool to DAMM V1.
interface MigrateToDammV1Param {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
dammConfig: PublicKey // The damm graduation fee config address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.migrateToDammV1({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
dammConfig: new PublicKey('8f848CEy8eY6PhJ3VcemtBDzPPSD4Vq7aJczLZ3o8MmX'),
})
Notes
When migrating to DAMM V1, the flow would be the following:
createDammV1MigrationMetadata
createLocker (if the token has locked vesting)
migrateToDammV1
lockDammV1LpToken (if creatorLp or partnerLp is >0)
claimDammV1LpToken (if creatorLp or partnerLp is >0)
Ensure that when attempting to migrate the virtual pool, all these validation checks pass:
The MigrationFeeOption must be a valid enum value with a valid base fee in basis points
The pool's config account must have:
pool_creator_authority matching the pool_authority key
activation_duration set to 0
partner_fee_numerator set to 0
vault_config_key set to the default Pubkey (all zeros)
The virtual pool's migration progress must be in the LockedVesting state
The pool must be "complete" based on the migration_quote_threshold (checked via is_curve_complete)
The migration option must be valid and specifically set to MeteoraDamm
The account relationships must be valid:
virtual_pool must have matching base_vault and quote_vault
virtual_pool must have a matching config
migration_metadata must have a matching virtual_pool
lockDammV1LpToken
Locks a DAMM V1 LP token for a partner or creator.
interface DammLpTokenParam {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
dammConfig: PublicKey // The damm graduation fee config address
isPartner: boolean // Whether the LP token is a partner
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.lockDammV1LpToken({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
dammConfig: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
isPartner: true,
})
Notes
This function is called when the creator or partner would like to lock their LP tokens.
claimDammV1LpToken
Claims a DAMM V1 LP token for a partner or creator.
interface DammLpTokenParam {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
dammConfig: PublicKey // The damm graduation fee config address
isPartner: boolean // Whether the LP token is a partner
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.claimDammV1LpToken({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
dammConfig: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
isPartner: true,
})
Notes
This function is called when the creator or partner would like to claim their LP tokens.
interface CreateDammV2MigrationMetadataParam {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
config: PublicKey // The config address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.createDammV2MigrationMetadata({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
When migrating to DAMM V2, the createDammV2MigrationMetadata function must be the first function called.
migrateToDammV2
Migrates the Dynamic Bonding Curve pool to DAMM V2.
interface MigrateToDammV2Param {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
dammConfig: PublicKey // The damm graduation fee config address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.migrateToDammV2({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
dammConfig: new PublicKey('7F6dnUcRuyM2TwR8myT1dYypFXpPSxqwKNSFNkxyNESd'),
})
Notes
When migrating to DAMM V2, the flow would be the following:
createDammV2MigrationMetadata
createLocker (if the token has locked vesting)
migrateToDammV2
Ensure that when attempting to migrate the virtual pool, all these validation checks pass:
The MigrationFeeOption must be a valid enum value with a valid base fee in basis points
For fixed BPS fee options (25, 30, 100, 200, 400, 600), the pool_fees.base_fee.period_frequency must be 0
The pool's config account must have:
pool_creator_authority matching the pool_authority key
partner_fee_percent set to 0
sqrt_min_price equal to MIN_SQRT_PRICE
sqrt_max_price equal to MAX_SQRT_PRICE
vault_config_key set to the default Pubkey (all zeros)
The virtual pool's migration progress must be in the LockedVesting state
The pool must be "complete" based on the migration_quote_threshold (checked via is_curve_complete)
The migration option must be valid and specifically set to DammV2
The account relationships must be valid:
virtual_pool must have matching base_vault and quote_vault
virtual_pool must have a matching config
migration_metadata must have a matching virtual_pool
first_position_nft_mint must not equal second_position_nft_mint
Exactly one remaining account must be provided (for the DAMM V2 config)
interface CreatePoolMetadataParam {
virtualPool: PublicKey // The virtual pool address
name: string // The name of the pool
website: string // The website of the pool
logo: string // The logo of the pool
creator: PublicKey // The creator of the pool
payer: PublicKey // The payer of the transaction
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.creator.createPoolMetadata({
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
creator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
name: 'Meteora',
website: 'https://launch.meteora.ag',
logo: 'https://launch.meteora.ag/icons/logo.svg',
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
})
interface ClaimCreatorTradingFeeParam {
creator: PublicKey // The creator of the pool
pool: PublicKey // The pool address
maxBaseAmount: BN // The maximum amount of base tokens to claim
maxQuoteAmount: BN // The maximum amount of quote tokens to claim
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.creator.claimCreatorTradingFee({
creator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
pool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
maxBaseAmount: new BN(1000000000),
maxQuoteAmount: new BN(1000000000),
})
Notes
The creator of the pool must be the same as the creator in the ClaimTradingFeeParam params.
You can indicate maxBaseAmount or maxQuoteAmount to be 0 to not claim Base or Quote tokens respectively.
Derives the address of a Dynamic Bonding Curve pool.
Function
function deriveDbcPoolAddress(
quoteMint: PublicKey,
baseMint: PublicKey,
config: PublicKey
): PublicKey
Parameters
quoteMint: PublicKey // The quote mint
baseMint: PublicKey // The base mint
config: PublicKey // The config
Returns
The address of the Dynamic Bonding Curve pool.
Example
const dbcPoolAddress = deriveDbcPoolAddress(
quoteMint: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
baseMint: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
config: new PublicKey('config1234567890abcdefghijklmnopqrstuvwxyz')
)
deriveDammV1PoolAddress
Derives the address of a DAMM V1 pool.
Function
function deriveDammV1PoolAddress(
dammConfig: PublicKey,
tokenAMint: PublicKey,
tokenBMint: PublicKey
): PublicKey
Parameters
dammConfig: PublicKey // The DAMM V1 graduation config key (retrievable from the README.md)
tokenAMint: PublicKey // The A token mint
tokenBMint: PublicKey // The B token mint
Returns
The address of the DAMM V1 pool.
Example
const dammV1PoolAddress = deriveDammV1PoolAddress(
dammConfig: new PublicKey('8f848CEy8eY6PhJ3VcemtBDzPPSD4Vq7aJczLZ3o8MmX'),
tokenAMint: new PublicKey('tokenA1234567890abcdefghijklmnopqrstuvwxyz'),
tokenBMint: new PublicKey('tokenB1234567890abcdefghijklmnopqrstuvwxyz')
)
deriveDammV2PoolAddress
Derives the address of a DAMM V2 pool.
Function
function deriveDammV2PoolAddress(
dammConfig: PublicKey,
tokenAMint: PublicKey,
tokenBMint: PublicKey
): PublicKey
Parameters
dammConfig: PublicKey // The DAMM V2 graduation config key (retrievable from the README.md)
tokenAMint: PublicKey // The A token mint
tokenBMint: PublicKey // The B token mint
Returns
The address of the DAMM V2 pool.
Example
const dammV2PoolAddress = deriveDammV2PoolAddress(
dammConfig: new PublicKey('7F6dnUcRuyM2TwR8myT1dYypFXpPSxqwKNSFNkxyNESd'),
tokenAMint: new PublicKey('tokenA1234567890abcdefghijklmnopqrstuvwxyz'),
tokenBMint: new PublicKey('tokenB1234567890abcdefghijklmnopqrstuvwxyz')
)
This can be done using the
Or via the
locked_vesting: locked vesting for creator after token is migrated (token will be migrated to )