2.0.0 matches program 0.2.2. Import the client, curve builders, quotes, and PDA helpers from @meteora-ag/dynamic-bonding-curve-sdk. Import curve, fee, transfer-fee, and swap math from @meteora-ag/dynamic-bonding-curve-sdk/math.
import {
DynamicBondingCurveClient,
buildCurveWithMarketCap,
deriveDbcPoolAddress,
getSwapQuoteTransferFees,
} from "@meteora-ag/dynamic-bonding-curve-sdk";
import {
calculateTransferFeeExcludedAmount,
getSwapResult,
} from "@meteora-ag/dynamic-bonding-curve-sdk/math";
DynamicBondingCurveProgram, swapQuoteExactIn, swapQuoteExactOut, swapQuotePartialFill, createDammV1Program, createDammV2Program, and createDynamicVaultProgram are not package exports. Construct services from DynamicBondingCurveClient. The Anchor program is client.program. createDbcProgram returns that Program directly.
Dependencies
| Package | Version |
|---|---|
@coral-xyz/anchor | ^0.31.0 |
@solana/web3.js | ^1.98.0 |
@solana/spl-token | ^0.4.13 |
bn.js | ^5.2.1 |
decimal.js | ^10.5.0 |
Program IDs
| Program | ID |
|---|---|
| DBC | dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN |
| DAMM v1 | Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB |
| DAMM v2 | cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG |
| Locker | LocpQgucEQHbqNABEYvBvwoxCPsSbG91A1QaQhQQqjn |
| Dynamic Vault | 24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi |
| Metaplex metadata | metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s |
Core Exports
| Export | Use |
|---|---|
DynamicBondingCurveClient | Main SDK client. Exposes pool, partner, creator, migration, and state services. |
DynamicBondingCurveIdl | Bundled Anchor IDL JSON for dynamic_bonding_curve. |
DynamicBondingCurveTypes | IDL TypeScript type export. |
DynamicBondingCurveProgram | Base service class with the connection-backed Anchor program. |
types exports | IDL account types, SDK parameter types, enums, and quote result types. |
constants exports | Program IDs, fee constants, curve limits, migration fee config keys, and default parameter structs. |
helpers exports | Curve builders, PDA helpers, validation helpers, token helpers, instruction helpers, and config math helpers. |
services exports | Service classes for partner, pool, creator, migration, program, and state flows. |
math exports | Curve math, swap quote math, fee math, safe math, and pool fee handlers. |
Enums
| Enum | Values |
|---|---|
ActivationType | Slot = 0, Timestamp = 1. |
TokenType | SPLToken = 0, Token2022 = 1. |
CollectFeeMode | QuoteToken = 0, OutputToken = 1. |
MigratedCollectFeeMode | QuoteToken = 0, OutputToken = 1, Compounding = 2. |
DammV2DynamicFeeMode | Disabled = 0, Enabled = 1. |
DammV2BaseFeeMode | FeeTimeSchedulerLinear = 0, FeeTimeSchedulerExponential = 1, RateLimiter = 2, FeeMarketCapSchedulerLinear = 3, FeeMarketCapSchedulerExponential = 4. |
MigrationOption | MET_DAMM = 0 (deprecated for new configs and new pools), MET_DAMM_V2 = 1. |
BaseFeeMode | FeeSchedulerLinear = 0, FeeSchedulerExponential = 1, RateLimiter = 2 (deprecated for new configs and new pools). |
MigrationFeeOption | FixedBps25 = 0, FixedBps30 = 1, FixedBps100 = 2, FixedBps200 = 3, FixedBps400 = 4, FixedBps600 = 5, Customizable = 6. |
TokenDecimal | SIX = 6, SEVEN = 7, EIGHT = 8, NINE = 9. |
TradeDirection | BaseToQuote = 0, QuoteToBase = 1. |
SwapMode | ExactIn = 0, PartialFill = 1, ExactOut = 2. |
TokenAuthorityOption | CreatorUpdateAuthority = 0, Immutable = 1, PartnerUpdateAuthority = 2, CreatorUpdateAndMintAuthority = 3, PartnerUpdateAndMintAuthority = 4. |
Important Constants
| Constant | Value |
|---|---|
MAX_CURVE_POINT | 16 |
FEE_DENOMINATOR | 1_000_000_000 |
MAX_BASIS_POINT | 10_000 |
U16_MAX, U24_MAX, U64_MAX, U128_MAX | Integer bounds used by validation and math helpers. |
MIN_SQRT_PRICE / MAX_SQRT_PRICE | 4295048016 / 79226673521066979257578248091 |
MIN_FEE_BPS / MAX_FEE_BPS | 25 / 9900 |
MIN_FEE_NUMERATOR / MAX_FEE_NUMERATOR | 2_500_000 / 990_000_000 |
MAX_RATE_LIMITER_DURATION_IN_SECONDS | 43_200 |
MAX_RATE_LIMITER_DURATION_IN_SLOTS | 108_000 |
DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT | Default dynamic-fee timing and reduction settings. |
BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, MAX_PRICE_CHANGE_BPS_DEFAULT | Default dynamic-fee bin and price-change settings. |
PROTOCOL_FEE_PERCENT / HOST_FEE_PERCENT | 20 / 20 |
SWAP_BUFFER_PERCENTAGE | 25 |
MAX_MIGRATION_FEE_PERCENTAGE / MAX_CREATOR_MIGRATION_FEE_PERCENTAGE | 99 / 100 |
MIN_LOCKED_LIQUIDITY_BPS | 1000 |
SECONDS_PER_DAY | 86400 |
MAX_LOCK_DURATION_IN_SECONDS | 63_072_000 |
PROTOCOL_POOL_CREATION_FEE_PERCENT | 10 |
MIN_POOL_CREATION_FEE / MAX_POOL_CREATION_FEE | 1_000_000 / 100_000_000_000 lamports |
MIN_MIGRATED_POOL_FEE_BPS / MAX_MIGRATED_POOL_FEE_BPS | 10 / 1000 |
DAMM_V1_MIGRATION_FEE_ADDRESS, DAMM_V2_MIGRATION_FEE_ADDRESS | Published migration fee config addresses used by migrated-pool flows. |
DEFAULT_MIGRATED_POOL_FEE_PARAMS, DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS, DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS | Default config helper structs. |
Creating A Client
import { Connection } from "@solana/web3.js";
import { DynamicBondingCurveClient } from "@meteora-ag/dynamic-bonding-curve-sdk";
const connection = new Connection(process.env.RPC_URL!, "confirmed");
const client = new DynamicBondingCurveClient(connection, "confirmed");
Complete Function Index
Client And Program Helpers
| Function or method | Returns | Use |
|---|---|---|
new DynamicBondingCurveClient(connection, commitment?) | DynamicBondingCurveClient | Construct the client. commitment defaults to confirmed. Read the Anchor program from client.program. |
createDbcProgram(connection, commitment?) | Program<DynamicBondingCurve> | Build an Anchor program for the DBC IDL. The client constructor calls this. |
PartnerService
| Method | Returns | Use |
|---|---|---|
createConfig2(params) | Promise<Transaction> | Create a PoolConfig. Pass transferFeeParameters for a base-mint transfer fee, or null when there is none. createConfigAndPool and createConfigAndPoolWithFirstBuy call this. |
createConfig(params) | Promise<Transaction> | Deprecated. Same as createConfig2 with no base transfer fee. Rejects a quote mint with a non-zero transfer fee or a live transfer fee config authority. |
createConfigWithTransferHook(params) | Promise<Transaction> | Create a ConfigWithTransferHook from CreateConfigWithTransferHookParams. |
createConfigAndPool(params) | Promise<Transaction> | Build one transaction that creates a config and initializes a standard pool. |
createConfigAndPoolWithTransferHook(params) | Promise<Transaction> | Build one transaction that creates a transfer-hook config and initializes a transfer-hook pool. |
createConfigAndPoolWithFirstBuy(params) | Promise<{ createConfigTx; createPoolWithFirstBuyTx }> | Build separate config and pool-with-first-buy transactions for a standard pool. |
createConfigAndPoolWithFirstBuyWithTransferHook(params) | Promise<{ createConfigTx; createPoolWithFirstBuyTx }> | Build separate config and pool-with-first-buy transactions for a transfer-hook pool. |
createPartnerMetadata(params) | Promise<Transaction> | Create partner metadata for a fee claimer. |
claimPartnerTradingFee(params) | Promise<Transaction> | Claim partner trading fees with optional SOL wrapping behavior. |
claimPartnerTradingFeeToReceiver(params) | Promise<Transaction> | Claim standard-pool partner trading fees to an explicit receiver. |
claimPartnerTradingFee2(params) | Promise<Transaction> | Claim transfer-hook pool partner trading fees. |
partnerWithdrawSurplus(params) | Promise<Transaction> | Withdraw partner surplus after migration. |
partnerWithdrawMigrationFee(params) | Promise<Transaction> | Withdraw the partner share of migration fees. |
claimPartnerPoolCreationFee(params) | Promise<Transaction> | Claim the partner share of pool creation fees. |
PoolService
| Method | Returns | Use |
|---|---|---|
swap(params) | Promise<Transaction> | Build the legacy exact-in swap transaction. |
swap2(params) | Promise<Transaction> | Build the preferred swap transaction for exact-in, partial-fill, and exact-out modes. |
swap2WithTransferHook(params) | Promise<Transaction> | Build the transfer-hook swap transaction for exact-in, partial-fill, and exact-out modes. |
swapQuote(params) | SwapQuoteResult | Quote the legacy exact-in swap path. |
swapQuote2(params) | SwapQuote2Result | Quote SwapMode.ExactIn, PartialFill, or ExactOut for an existing pool. Requires currentPoint. Returns includedTransferFeeAmountIn and excludedTransferFeeAmountOut. |
CreatorService
| Method | Returns | Use |
|---|---|---|
createPool(params) | Promise<Transaction> | Create a standard virtual pool from an existing config and base mint. Pass optional tokenBadge on CreatePoolParams when the quote mint is not permissionless-supported. |
createPoolWithTransferHook(params) | Promise<Transaction> | Create a transfer-hook pool from an existing transfer-hook config. |
createPoolWithFirstBuy(params) | Promise<Transaction> | Create a standard pool and include an initial buy. |
createPoolWithFirstBuyWithTransferHook(params) | Promise<Transaction> | Create a transfer-hook pool and include an initial buy. |
createPoolWithPartnerAndCreatorFirstBuy(params) | Promise<Transaction> | Create a standard pool with partner and creator first-buy handling. |
createPoolWithPartnerAndCreatorFirstBuyWithTransferHook(params) | Promise<Transaction> | Create a transfer-hook pool with partner and creator first-buy handling. |
createPoolMetadata(params) | Promise<Transaction> | Create optional metadata for a virtual pool. |
claimCreatorTradingFee(params) | Promise<Transaction> | Claim creator trading fees with optional SOL wrapping behavior. |
claimCreatorTradingFeeToReceiver(params) | Promise<Transaction> | Claim standard-pool creator trading fees to an explicit receiver. |
claimCreatorTradingFee2(params) | Promise<Transaction> | Claim transfer-hook pool creator trading fees. |
creatorWithdrawSurplus(params) | Promise<Transaction> | Withdraw creator surplus after migration. |
transferPoolCreator(params) | Promise<Transaction> | Transfer creator rights to a new creator. |
creatorWithdrawMigrationFee(params) | Promise<Transaction> | Withdraw the creator share of migration fees. |
MigrationService
| Method | Returns | Use |
|---|---|---|
createLocker(params) | Promise<Transaction> | Create a locker escrow when locked vesting is configured. |
withdrawLeftover(params) | Promise<Transaction> | Withdraw leftover base tokens after migration. leftoverReceiver is a signer when the leftover charges a transfer fee. |
createDammV1MigrationMetadata(params) | Promise<Transaction> | Create DAMM v1 migration metadata. |
migrateToDammV1(params) | Promise<Transaction> | Migrate a completed DBC pool to DAMM v1. |
lockDammV1LpToken(params) | Promise<Transaction> | Lock DAMM v1 LP allocation. |
claimDammV1LpToken(params) | Promise<Transaction> | Claim locked DAMM v1 LP allocation. |
migrateToDammV2(params) | Promise<MigrateToDammV2Response> | Migrate a completed DBC pool to DAMM v2 and return position NFT keypairs with the transaction. |
StateService
| Method | Returns | Use |
|---|---|---|
getPoolConfig(configAddress) | Promise<PoolConfig or null> | Fetch one standard or transfer-hook config. Transfer-hook configs return the embedded PoolConfig. |
getPoolConfigs() | Promise<ProgramAccount<PoolConfig>[]> | Fetch all standard and transfer-hook configs. |
getPoolConfigsByOwner(owner) | Promise<ProgramAccount<PoolConfig>[]> | Fetch standard and transfer-hook configs by partner owner or fee claimer. |
getPool(poolAddress) | Promise<VirtualPool or null> | Fetch one standard or transfer-hook pool account. |
getPools() | Promise<ProgramAccount<VirtualPool>[]> | Fetch all standard and transfer-hook pool accounts. |
getPoolsByConfig(configAddress) | Promise<ProgramAccount<VirtualPool>[]> | Fetch standard and transfer-hook pools created from one config. |
getPoolsByCreator(creatorAddress) | Promise<ProgramAccount<VirtualPool>[]> | Fetch standard and transfer-hook pools by creator. |
getPoolByBaseMint(baseMint) | Promise<ProgramAccount<VirtualPool> or null> | Resolve a standard or transfer-hook pool by base mint. |
getPoolMigrationQuoteThreshold(poolAddress) | Promise<BN> | Read the migration quote threshold for a pool. |
getPoolQuoteTokenCurveProgress(poolAddress) | Promise<number> | Calculate quote-side curve progress. |
getPoolBaseTokenCurveProgress(poolAddress) | Promise<number> | Calculate base-side curve progress. |
getPoolMetadata(pool) | Promise<VirtualPoolMetadata[]> | Fetch optional pool metadata accounts. |
getPartnerMetadata(feeClaimer) | Promise<PartnerMetadata[]> | Fetch optional partner metadata accounts. |
getPoolFeeMetrics(poolAddress) | Fee metrics object | Read lifetime fee metrics for one pool. |
getPoolFeeBreakdown(poolAddress) | Fee breakdown object | Read current claimable fee breakdown for partner and creator. |
getPoolsFeesByConfig(configAddress) | Aggregated fee metrics | Aggregate fee metrics across pools for one config. |
getPoolsFeesByCreator(creatorAddress) | Aggregated fee metrics | Aggregate fee metrics across pools for one creator. |
getDammV1MigrationMetadata(poolAddress) | Promise<MeteoraDammMigrationMetadata> | Fetch DAMM v1 migration metadata for existing DAMM v1 pools. |
getTokenBadge(tokenMint) | Promise<TokenBadge or null> | Fetch the DBC token badge for a quote mint. |
Curve Builder Helpers
All curve builders returnConfigParameters.
| Function | Params type | Extra fields beyond BuildCurveBaseParams | Use |
|---|---|---|---|
buildCurve | BuildCurveParams | percentageSupplyOnMigration, migrationQuoteThreshold | Build a config from target migration amount and supply percentage. |
buildCurveWithMarketCap | BuildCurveWithMarketCapParams | initialMarketCap, migrationMarketCap | Build a config from market-cap targets. |
buildCurveWithTwoSegments | BuildCurveWithTwoSegmentsParams | initialMarketCap, migrationMarketCap, percentageSupplyOnMigration | Build a two-segment curve. |
buildCurveWithMidPrice | BuildCurveWithMidPriceParams | initialMarketCap, migrationMarketCap, midPrice, percentageSupplyOnMigration | Build a two-segment curve with a specified midpoint. |
buildCurveWithLiquidityWeights | BuildCurveWithLiquidityWeightsParams | initialMarketCap, migrationMarketCap, liquidityWeights | Shape curve liquidity distribution with weights. |
buildCurveWithCustomSqrtPrices | BuildCurveWithCustomSqrtPricesParams | sqrtPrices, optional liquidityWeights | Build a curve with explicit square-root price checkpoints. |
Config, Curve, And Account Helpers
These names are exported from the package root.| Function | Use |
|---|---|
getCurrentPoint | Return the current slot or timestamp for the config’s activation type. |
prepareSwapAmountParam | Fill the swap amount fields for a swap2 instruction. |
getPriceFromSqrtPrice | Convert a square-root price into a UI price with base and quote decimals. |
getSqrtPriceFromPrice | Convert a UI price into a square-root price. |
createSqrtPrices | Build square-root price checkpoints from UI prices. |
getSqrtPriceFromMarketCap | Convert market cap and supply into a square-root price. |
getBaseTokenForSwap | Compute base-token movement for a swap against the curve. |
getQuoteReserveFromNextSqrtPrice | Calculate the quote reserve from the next square-root price. |
getProtocolMigrationFee | Resolve the protocol migration fee for a migration option and fee option. |
getMigrationBaseToken | Calculate base tokens reserved for migration. |
getMigrationQuoteAmountFromThreshold | Convert a migration quote threshold into a migration quote amount. |
getMigrationThresholdPrice | Calculate the price at the migration threshold. |
getPercentageSupplyOnMigration | Calculate the migration supply percentage from curve parameters. |
getCurveBreakdown | Return per-segment curve supply and quote. |
getTotalSupplyFromCurve | Sum the supply represented by the curve checkpoints. |
getSwapAmountWithBuffer | Add the SDK swap buffer to a swap amount. |
getTokenomics | Calculate the tokenomics breakdown for a configured curve. |
getSurplusBreakdown | Split quote surplus above the migration threshold into partner, creator, and protocol shares. |
getTransferFeeMigrationPositionSplit | Split migrated liquidity after transfer fees, using the compounding deposit rounding. |
getQuoteFromInputAmount, getQuoteFromOutputAmount | Quote a buildCurve result as the pool would be right after initialization. |
getSwapQuoteTransferFees | Load the quote mint when quoteTokenFlag is Token 2022, the base mint when baseMint is passed, and the current epoch. Spread the result into swapQuote or swapQuote2. |
rateLimiterApplied | Check whether the rate limiter applies at a point. |
getFeeSchedulerParams | Convert scheduler inputs into DBC base-fee params. |
calculateFeeSchedulerEndingBaseFeeBps | Calculate the ending scheduler fee in bps. |
getBaseFeeParams | Normalize scheduler fields into program params. Rate limiter inputs are rejected. |
getDynamicFeeParams | Build dynamic-fee params from a base fee and an optional price-change limit. |
getStartingBaseFeeBpsFromBaseFeeParams | Recover the starting base fee in bps from base-fee params. |
getRateLimiterParams | Encode rate-limiter params for quoting an existing pool. getBaseFeeParams, createConfig2, createPool, and buildCurve* reject BaseFeeMode.RateLimiter. |
getMigratedPoolFeeParams | Build migrated-pool fee params. |
getMigratedPoolMarketCapFeeSchedulerParams | Build DAMM v2 market-cap fee scheduler params. The price input is priceMultiple. |
getLockedVestingParams | Convert locked-vesting inputs into program params. |
getLiquidityVestingInfoParams | Convert migrated-liquidity vesting inputs into program params. |
getTotalVestingAmount | Calculate the total locked vesting amount. |
getVestingLockedLiquidityBpsAtNSeconds | Calculate locked-liquidity bps after an elapsed time. |
calculateLockedLiquidityBpsAtTime | Calculate locked-liquidity bps at a timestamp. |
getTokenProgram | Map TokenType to the SPL Token or Token 2022 program id. |
getTokenType | Read mint ownership and return TokenType. |
bpsToFeeNumerator, feeNumeratorToBps | Convert between basis points and the fee numerator. |
convertToLamports | Convert a UI amount into raw units for a decimal count. |
fromDecimalToBN | Convert a Decimal into BN. |
calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount | Convert between a gross transfer amount and the amount after a Token 2022 transfer fee. |
isZeroTransferFee | True when basis points are 0 or the maximum fee is 0. |
resolveSwapTransferFees | Resolve the base and quote EpochTransferFee for a quote. |
PDA Helpers
| Function | Use |
|---|---|
deriveDbcPoolAddress | Derive a virtual pool address from quote mint, base mint, and config. |
deriveDbcPoolAuthority | Derive the pool authority PDA. |
deriveDbcTokenVaultAddress | Derive a DBC token vault PDA. |
deriveDbcEventAuthority | Derive the DBC event authority PDA. |
deriveDbcPoolMetadata | Derive the DBC pool metadata PDA. |
derivePartnerMetadata | Derive partner metadata from the fee claimer. |
deriveTokenBadgeAddress | Derive ["token_badge", quote_mint]. |
getTokenBadgeRemainingAccounts | Return the badge as remaining account index 0 when the quote mint needs one. |
deriveDammV1PoolAddress | Derive a migrated DAMM v1 pool address. |
deriveDammV1MigrationMetadataAddress | Derive DAMM v1 migration metadata. |
deriveDammV2PoolAddress | Derive a migrated DAMM v2 pool address. |
deriveLockerEscrowAddress | Derive the locker escrow PDA. |
deriveBaseKeyForLocker | Derive the base key used in locker escrow seeds. |
Validation Helpers
CallvalidateConfigParameters before createConfig2. It runs the same config checks as the program, including the transfer-fee restrictions.
| Function | Use |
|---|---|
validateConfigParameters | Validate ConfigParameters and optional transferFeeParameters before config creation. |
validateTransferFeeParameters | Check transferFeeParameters the way create_config2 does. |
validateMigratedPoolFee | Validate the migrated-pool fee config. |
validateCompoundingFeeBps | Validate DAMM v2 compounding fee bps. 0 to 10_000 for compounding mode. Must be 0 for every other mode. |
Swap Quote Math
These functions are exported from@meteora-ag/dynamic-bonding-curve-sdk/math, except swapQuote, which stays on the package root. swapQuoteExactIn, swapQuoteExactOut, and swapQuotePartialFill are not exported. Quote an existing pool with client.pool.swapQuote2.
swapQuote and swapQuote2 return includedTransferFeeAmountIn and excludedTransferFeeAmountOut. For a Token 2022 quote mint, pass quoteMint and currentEpoch from getSwapQuoteTransferFees. Omitting them throws quoteMint and currentEpoch are required for a Token-2022 quote mint, use getSwapQuoteTransferFees. A base transfer fee is read from config.transferFeeFlag unless you pass baseMint or baseTransferFeeBasisPoints.
| Function | Use |
|---|---|
swapQuote | Exact-in quote on the package root. Returns includedTransferFeeAmountIn and excludedTransferFeeAmountOut. |
getSwapResult | Legacy SwapResult from an exact-input simulation. |
getSwapResultFromExactInput | Exact-input curve movement. |
getSwapResultFromPartialInput | Partial-fill curve movement. |
getSwapResultFromExactOutput | Exact-output curve movement. |
calculateBaseToQuoteFromAmountIn | Base-to-quote exact-input movement. |
calculateQuoteToBaseFromAmountIn | Quote-to-base exact-input movement. |
calculateBaseToQuoteFromAmountOut | Base-to-quote exact-output movement. |
calculateQuoteToBaseFromAmountOut | Quote-to-base exact-output movement. |
Curve Math
| Function | Use |
|---|---|
getInitialLiquidityFromDeltaQuote | Calculate initial liquidity from quote amount and square-root price range. |
getInitialLiquidityFromDeltaBase | Calculate initial liquidity from base amount and square-root price range. |
getDeltaAmountBaseUnsigned | Unsigned base delta for a liquidity and price range. |
getDeltaAmountBaseUnsigned256 | Same delta with a 256-bit intermediate. This is the unbounded variant. |
getDeltaAmountQuoteUnsigned | Unsigned quote delta for a liquidity and price range. |
getDeltaAmountQuoteUnsigned256 | Same delta with a 256-bit intermediate. This is the unbounded variant. |
getNextSqrtPriceFromInput | Calculate next square-root price from input amount. |
getNextSqrtPriceFromOutput | Calculate next square-root price from output amount. |
getNextSqrtPriceFromQuoteAmountOutRoundingDown | Calculate next price for quote output with rounding down. |
getNextSqrtPriceFromBaseAmountOutRoundingUp | Calculate next price for base output with rounding up. |
getNextSqrtPriceFromBaseAmountInRoundingUp | Calculate next price for base input with rounding up. |
getNextSqrtPriceFromQuoteAmountInRoundingDown | Calculate next price for quote input with rounding down. |
Fee Math
| Function | Use |
|---|---|
toNumerator | Convert bps to fee numerator for a denominator. |
getFeeMode | Resolve fee collection behavior from collect-fee mode, direction, and referral state. |
getTotalFeeNumeratorFromIncludedFeeAmount | Infer total fee numerator from an amount that already includes fee. |
getTotalFeeNumeratorFromExcludedFeeAmount | Infer total fee numerator from an amount before fee. |
getTotalFeeNumerator | Combine base fee, dynamic fee, and fee mode into total fee numerator. |
getFeeOnAmount | Calculate fee charged on an amount. |
getExcludedFeeAmount | Calculate fee amount excluded from input. |
getIncludedFeeAmount | Calculate fee amount included in output. |
splitFees | Split a fee into trading fee, protocol fee, and referral fee. The referral fee is a share of the protocol fee. |
Pool Fee Math
| Function or class | Use |
|---|---|
new FeeRateLimiter(...) | Base-fee handler for rate-limiter mode. |
FeeRateLimiter.getMinBaseFeeNumerator | Minimum base-fee numerator for the rate limiter. |
FeeRateLimiter.getBaseFeeNumeratorFromIncludedFeeAmount | Calculate base fee from an amount that includes fee. |
FeeRateLimiter.getBaseFeeNumeratorFromExcludedFeeAmount | Calculate base fee from an amount before fee. |
new FeeScheduler(...) | Base-fee handler for linear or exponential scheduler mode. |
FeeScheduler.getMinBaseFeeNumerator | Minimum base-fee numerator for the scheduler. |
FeeScheduler.getBaseFeeNumeratorFromIncludedFeeAmount | Calculate scheduled base fee for an included-fee amount. |
FeeScheduler.getBaseFeeNumeratorFromExcludedFeeAmount | Calculate scheduled base fee for an excluded-fee amount. |
getBaseFeeHandler | Instantiate the correct base-fee handler from base-fee mode. |
isDynamicFeeEnabled | Check whether dynamic fee config is active. |
getVariableFeeNumerator | Calculate variable dynamic-fee numerator from volatility state. |
getFeeSchedulerMinBaseFeeNumerator | Minimum base-fee numerator for scheduler mode. |
getBaseFeeNumeratorByPeriod | Calculate scheduler base-fee numerator for a period. |
getFeeNumeratorOnLinearFeeScheduler | Calculate linear scheduler fee numerator. |
getFeeNumeratorOnExponentialFeeScheduler | Calculate exponential scheduler fee numerator. |
getBaseFeeNumerator | Calculate active base-fee numerator for scheduler mode. |
isRateLimiterApplied | Check if rate limiter applies at the current point and trade direction. |
isZeroRateLimiter | Check whether rate-limiter config is effectively zero. |
isNonZeroRateLimiter | Check whether rate-limiter config is nonzero. |
getMaxIndex | Calculate max rate-limiter fee index. |
getMaxOutAmountWithMinBaseFee | Calculate max output amount that can use min base fee. |
getCheckedAmounts | Calculate bounded amount slices for rate-limiter fee math. |
getFeeNumeratorFromExcludedAmount | Calculate rate-limiter fee numerator from excluded amount. |
getRateLimiterExcludedFeeAmount | Calculate excluded fee amount under rate-limiter math. |
getFeeNumeratorFromIncludedAmount | Rate-limiter fee numerator from an included amount. |
Math Utilities
| Function or class method | Use |
|---|---|
SafeMath.add | Add two BN values. |
SafeMath.sub | Subtract two BN values and throw on underflow. |
SafeMath.mul | Multiply two BN values. |
SafeMath.div | Divide two BN values and throw on division by zero. |
SafeMath.shl | Left shift a BN. |
SafeMath.shr | Right shift a BN. |
pow | Q64 power, matching the program. |
mulDiv | Multiply, then divide, with the given rounding. |
sqrt | Integer square root for BN. |
Core Types
| Type group | Types |
|---|---|
| Program and IDL | DynamicCurveProgram, DynamicBondingCurveTypes, DynamicBondingCurveIdl. |
| Account states | PoolConfig, ConfigWithTransferHook, VirtualPool, TransferHookPool, MeteoraDammMigrationMetadata, LockEscrow, PartnerMetadata, VirtualPoolMetadata, TokenBadge. |
| Config structs | ConfigParameters, PoolFeeParameters, DynamicFeeParameters, LiquidityDistributionParameters, LockedVestingParameters, LiquidityVestingInfoParameters, MigratedPoolMarketCapFeeSchedulerParameters, TransferHookAccountsInfo. |
| Builder config inputs | TokenConfig, FeeConfig, BaseFeeParams, FeeSchedulerParams, RateLimiterParams, MigrationConfig, MigrationFee, MigratedPoolFeeConfig, MigratedPoolMarketCapFeeSchedulerParams, LiquidityDistributionConfig, LockedVestingParams. |
| Curve builder params | BuildCurveBaseParams, BuildCurveParams, BuildCurveWithMarketCapParams, BuildCurveWithTwoSegmentsParams, BuildCurveWithMidPriceParams, BuildCurveWithLiquidityWeightsParams, BuildCurveWithCustomSqrtPricesParams. |
| Pool and swap params | CreatePoolParams, CreatePoolWithTransferHookParams, CreateConfigAndPoolParams, CreateConfigAndPoolWithFirstBuyParams, CreateConfigAndPoolWithTransferHookParams, CreateConfigAndPoolWithFirstBuyWithTransferHookParams, CreatePoolWithFirstBuyParams, CreatePoolWithFirstBuyWithTransferHookParams, CreatePoolWithPartnerAndCreatorFirstBuyParams, CreatePoolWithPartnerAndCreatorFirstBuyWithTransferHookParams, FirstBuyWithTransferHookParams, PartnerFirstBuyWithTransferHookParams, CreatorFirstBuyWithTransferHookParams, SwapParams, Swap2Params, SwapQuoteParams, SwapQuote2Params. |
| Migration params | MigrateToDammV1Params, MigrateToDammV2Params, MigrateToDammV2Response, DammLpTokenParams, CreateLockerParams, CreateDammV1MigrationMetadataParams. |
| Claim and withdraw params | ClaimPartnerTradingFeeParams, ClaimPartnerTradingFeeToReceiverParams, ClaimCreatorTradingFeeParams, ClaimCreatorTradingFeeToReceiverParams, PartnerWithdrawSurplusParams, CreatorWithdrawSurplusParams, WithdrawMigrationFeeParams, ClaimPartnerPoolCreationFeeParams. |
| Quote and fee results | SwapResult, SwapResult2, SwapQuoteResult, SwapQuote2Result, QuoteTransferFees, VolatilityTracker, MigratedPoolFee. SwapQuote2Result includes includedTransferFeeAmountIn and excludedTransferFeeAmountOut. |
Config Creation Types
client.partner.createConfig2 accepts CreateConfig2Params. That is CreateConfigParams plus optional transferFeeParameters. createConfig is the deprecated instruction and does not take a base transfer fee.
client.partner.createConfigWithTransferHook accepts CreateConfigWithTransferHookParams, which adds transferHookProgram. It does not take transferFeeParameters, and it rejects a quote mint with a non-zero transfer fee or a live transfer fee config authority.
| Account field | Type | Use |
|---|---|---|
config | PublicKey | Config account address to initialize. |
feeClaimer | PublicKey | Partner authority that can claim partner fees. |
leftoverReceiver | PublicKey | Receiver for leftover base tokens after migration. |
quoteMint | PublicKey | Quote token mint used by pools created from the config. |
payer | PublicKey | Transaction fee payer and account initializer. |
tokenBadge | optional PublicKey | Token badge PDA required when the quote mint is not permissionless-supported. |
transferFeeParameters | TransferFeeParameters or null | Base-mint transfer fee for createConfig2. null means no TransferFeeConfig. |
transferHookProgram | PublicKey | Transfer-hook program for createConfigWithTransferHook; it must be executable and cannot be DBC, SPL Token, Token 2022, or the default pubkey. |
ConfigParameters is usually produced by one of the curve builders. Pass the returned object into createConfig2, createConfigWithTransferHook, createConfigAndPool, or createConfigAndPoolWithFirstBuy.
TransferFeeParameters has transferFeeBasisPoints (0 to 1000), withheldAuthority (TransferFeeWithheldAuthority.Partner or Creator), and migratedTransferFeeAuthorityOption (Immutable, RevokeZeroFee, Creator, or Partner). 0 basis points still creates a TransferFeeConfig and is rejected with Immutable or RevokeZeroFee. The base mint must be Token 2022. A base transfer fee, or a quote mint with a non-zero transfer fee or a live transfer fee config authority, requires constant token supply, no locked vesting, MigrationFeeOption.Customizable, and MigratedCollectFeeMode.Compounding.
| Field | Meaning |
|---|---|
poolFees | Base-fee and optional dynamic-fee parameters for DBC swaps. |
collectFeeMode | Whether trading fees are collected in quote token or output token. |
migrationOption | Destination AMM family. New configs must use MET_DAMM_V2. MET_DAMM is rejected. |
activationType | Activation point unit, either slot or timestamp. |
tokenType | SPL Token or Token-2022 base mint handling. |
tokenDecimal | Base token decimal enum encoded into the config. |
partnerLiquidityPercentage, creatorLiquidityPercentage | Migrated-pool liquidity share for partner and creator. |
partnerPermanentLockedLiquidityPercentage, creatorPermanentLockedLiquidityPercentage | Migrated-pool liquidity share permanently locked for each party. |
migrationQuoteThreshold | Quote amount threshold that completes the bonding curve. |
sqrtStartPrice | Initial square-root price for the virtual curve. |
lockedVesting | Locked base-token vesting schedule after migration. |
migrationFeeOption, migrationFee | Fixed or customizable migration fee settings. |
tokenSupply | Total base-token supply for the launch. |
creatorTradingFeePercentage | Creator share of trading fees. |
tokenAuthorityOption | Base mint update-authority and mint-authority behavior. Mint-authority options are only valid for transfer-hook configs. |
migratedPoolFee | Fee settings applied to the migrated DAMM pool. |
poolCreationFee | Pool creation fee in lamports. |
partnerLiquidityVestingInfo, creatorLiquidityVestingInfo | Optional vesting schedule for migrated liquidity shares. |
migratedPoolBaseFeeMode | Optional DAMM v2 base-fee mode for graduated pools. |
migratedPoolMarketCapFeeSchedulerParams | Optional market-cap fee scheduler for DAMM v2 migration. Current helper inputs use priceMultiple. |
enableFirstSwapWithMinFee | Allows the first eligible swap to use the configured minimum-fee path. |
compoundingFeeBps | DAMM v2 compounding fee bps when migrated collect-fee mode is compounding. |
curve | Up to MAX_CURVE_POINT curve checkpoints. |
Builder Input Groups
All curve builders shareBuildCurveBaseParams, then add builder-specific target fields.
| Group | Fields |
|---|---|
token | tokenType, tokenBaseDecimal, tokenQuoteDecimal, tokenAuthorityOption, totalTokenSupply, leftover. |
fee | baseFeeParams, dynamicFeeEnabled, collectFeeMode, creatorTradingFeePercentage, poolCreationFee, enableFirstSwapWithMinFee. |
migration | migrationOption, migrationFeeOption, migrationFee, optional migratedPoolFee. |
liquidityDistribution | Partner and creator migrated-liquidity percentages, permanent-lock percentages, and optional vesting info for each side. |
lockedVesting | totalLockedVestingAmount, numberOfVestingPeriod, cliffUnlockAmount, totalVestingDuration, cliffDurationFromMigrationTime. |
activationType | Slot-based or timestamp-based activation. |
| Nested type | Key fields | Notes |
|---|---|---|
BaseFeeParams | Fee scheduler params | Use getFeeSchedulerParams for linear or exponential fee decay. createConfig, createPool, and buildCurve* reject BaseFeeMode.RateLimiter. |
FeeSchedulerParams | startingFeeBps, endingFeeBps, numberOfPeriod, totalDuration | Used with FeeSchedulerLinear or FeeSchedulerExponential. |
RateLimiterParams | baseFeeBps, feeIncrementBps, referenceAmount, maxLimiterDuration | Kept for quoting existing rate-limiter pools. getRateLimiterParams still encodes these fields. New config and pool builders reject the mode. |
MigrationFee | feePercentage, creatorFeePercentage | Required only when migrationFeeOption is Customizable. |
MigratedPoolFeeConfig | collectFeeMode, dynamicFee, poolFeeBps, optional compoundingFeeBps, optional graduated fee fields | Applies to the migrated DAMM pool, not to the DBC virtual pool. |
MigratedPoolMarketCapFeeSchedulerParams | endingBaseFeeBps, numberOfPeriod, priceMultiple, schedulerExpirationDuration | Applies when using a DAMM v2 migrated-pool market-cap fee scheduler. |
LiquidityVestingInfoParams | vestingPercentage, bpsPerPeriod, numberOfPeriods, cliffDurationFromMigrationTime, totalDuration | Optional migrated-liquidity vesting schedule. |
LockedVestingParams | totalLockedVestingAmount, numberOfVestingPeriod, cliffUnlockAmount, totalVestingDuration, cliffDurationFromMigrationTime | Base-token vesting locked during migration. |
Common Workflows
Create A Config From A Builder
const configParams = buildCurveWithMarketCap({
token,
fee,
migration,
liquidityDistribution,
lockedVesting,
activationType: ActivationType.Timestamp,
initialMarketCap,
migrationMarketCap,
});
const tx = await client.partner.createConfig2({
...configParams,
config,
feeClaimer,
leftoverReceiver,
quoteMint,
payer,
});
Create A Pool From An Existing Config
const tx = await client.creator.createPool({
baseMint,
config,
name,
symbol,
uri,
payer,
poolCreator,
});
client.creator.createPoolWithTransferHook.
Quote And Build A swap2 Transaction
const quote = client.pool.swapQuote2({
virtualPool,
config,
swapBaseForQuote: false,
hasReferral: false,
eligibleForFirstSwapWithMinFee: false,
currentPoint,
slippageBps,
swapMode: SwapMode.ExactIn,
amountIn,
});
const tx = await client.pool.swap2({
owner,
pool,
swapBaseForQuote: false,
amountIn,
minimumAmountOut: quote.minimumAmountOut,
swapMode: SwapMode.ExactIn,
referralTokenAccount: null,
});
getSwapQuoteTransferFees(connection, config) into swapQuote2. Pass baseMint when you want the quote to read the base mint’s current transfer fee instead of transferFeeFlag.
Integration Notes
| Gotcha | Guidance |
|---|---|
swap2 modes | Use SwapMode.ExactIn, PartialFill, or ExactOut and pass the matching amount fields. |
| Rate limiter pools | The SDK adds the instructions sysvar when the current fee mode requires single-swap validation. |
| First-swap minimum fee | Set eligibleForFirstSwapWithMinFee only when quoting a transaction that satisfies the program’s first-swap validation path. |
| Token 2022 transfer fees | Pass transferFeeParameters on createConfig2 for a base-mint fee. Quote a Token 2022 quote mint with getSwapQuoteTransferFees. |
| Transfer-hook pools | Use createConfigWithTransferHook, createPoolWithTransferHook, swap2WithTransferHook, and transfer-hook fee claim methods. Standard swap and claim paths reject transfer-hook pools. |
| DAMM v2 compounding | compoundingFeeBps is 0 to 10_000 when migrated collect-fee mode is compounding, and 0 otherwise. |
| Market-cap scheduler | Market-cap scheduler params use priceMultiple in current SDK helpers. |

