Skip to main content

Partner Functions

createConfig

Creates a new config key that will dictate the behavior of all pools created with this key. This is where you set the pool fees, migration options, the bonding curve shape, and more. Function
async createConfig(params: CreateConfigParams): Promise<Transaction>
Parameters
interface CreateConfigParams {
    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: {
        baseFee: {
            cliffFeeNumerator: BN // Initial fee numerator (base fee)
            firstFactor: number // feeScheduler: numberOfPeriod, rateLimiter: feeIncrementBps
            secondFactor: BN // feeScheduler: periodFrequency, rateLimiter: maxLimiterDuration
            thirdFactor: BN // feeScheduler: reductionFactor, rateLimiter: referenceAmount
            baseFeeMode: number // 0: FeeSchedulerLinear, 1: FeeSchedulerExponential, 2: RateLimiter
        }
        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
    }
    collectFeeMode: number // 0: QuoteToken, 1: OutputToken
    migrationOption: number // 0: DAMM V1, 1: DAMM v2
    activationType: number // 0: Slot, 1: Timestamp
    tokenType: number // 0: SPL, 1: Token2022
    tokenDecimal: number // The number of decimals for the token
    partnerLiquidityPercentage: number // The percentage of the LP that will be allocated to the partner in the graduated pool (0-100)
    partnerPermanentLockedLiquidityPercentage: number // The percentage of the locked LP that will be allocated to the partner in the graduated pool (0-100)
    creatorLiquidityPercentage: number // The percentage of the LP that will be allocated to the creator in the graduated pool (0-100)
    creatorPermanentLockedLiquidityPercentage: number // The percentage of the locked LP that will be allocated to the creator in the graduated pool (0-100)
    migrationQuoteThreshold: BN // The quote threshold for migration
    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 waiting time before the vesting starts
        frequency: BN // The frequency of the vesting
        numberOfPeriod: BN // The number of periods of the vesting
        cliffUnlockAmount: BN // The amount of tokens that will be unlocked when vesting starts
    }
    migrationFeeOption: number // 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: {
        // 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
    tokenUpdateAuthority: number // 0 - CreatorUpdateAuthority, 1 - Immutable, 2 - PartnerUpdateAuthority, 3 - CreatorUpdateAndMintAuthority, 4 - PartnerUpdateAndMintAuthority
    migrationFee: {
        // Optional migration fee (set as 0 for feePercentage and creatorFeePercentage for no migration fee)
        feePercentage: number // The percentage of fee taken from migration quote threshold (0-99)
        creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
    }
    migratedPoolFee: {
        // Only when migrationOption = MET_DAMM_V2 (1) and migrationFeeOption = Customizable (6)
        collectFeeMode: number // 0: QuoteToken, 1: OutputToken
        dynamicFee: number // 0: Disabled, 1: Enabled
        poolFeeBps: number // The pool fee in basis points. Minimum 10, Maximum 1000 bps.
    }
    poolCreationFee: BN // The pool creation fee
    partnerLiquidityVestingInfo: {
        vestingPercentage: number // The percentage of the liquidity that will be vested
        bpsPerPeriod: number // The basis points per period
        numberOfPeriods: number // The number of periods
        cliffDurationFromMigrationTime: number // The duration of the waiting time before the vesting starts
        frequency: number // The frequency of the vesting
    }
    creatorLiquidityVestingInfo: {
        vestingPercentage: number // The percentage of the liquidity that will be vested
        bpsPerPeriod: number // The basis points per period
        numberOfPeriods: number // The number of periods
        cliffDurationFromMigrationTime: number // The duration of the waiting time before the vesting starts
        frequency: number // The frequency of the vesting
    }
    migratedPoolBaseFeeMode: number // 0: FeeTimeSchedulerLinear, 1: FeeTimeSchedulerExponential, 3: FeeMarketCapSchedulerLinear, 4: FeeMarketCapSchedulerExponential (defaults to FeeTimeSchedulerLinear)
    migratedPoolMarketCapFeeSchedulerParams: {
        // Defaults to all 0. Configure only when migratedPoolBaseFeeMode = FeeMarketCapSchedulerLinear or FeeMarketCapSchedulerExponential
        numberOfPeriod: number // The number of periods
        sqrtPriceStepBps: number // The square root price step in basis points
        schedulerExpirationDuration: number // The scheduler expiration duration in seconds
        reductionFactor: BN // The reduction factor
    }
    enableFirstSwapWithMinFee: boolean // Whether to enable first swap with minimum fee (defaults to false)
    padding: []
    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('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(1_000_000_000),
    creatorLiquidityVestingInfo: {
        vestingPercentage: 0,
        bpsPerPeriod: 0,
        numberOfPeriods: 0,
        frequency: 0,
        cliffDurationFromMigrationTime: 0,
    },
    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,
    },
})
Notes When creating a new configuration for a dynamic bonding curve, several validations are performed to ensure the parameters are valid: Pool Fees
  • Base fee must have a positive cliff fee numerator
  • If using Fee Scheduler (Linear or Exponential):
    • All parameters (firstFactor, secondFactor, thirdFactor) must be set if any are set
    • Cliff fee numerator must be positive
    • For Linear mode, final fee must not be negative
    • Min and max fee numerators must be within valid range (MIN_FEE_NUMERATOR to MAX_FEE_NUMERATOR)
    • Fee numerators must be less than FEE_DENOMINATOR
  • If using Rate Limiter:
    • Can only be used with QuoteToken collect fee mode
    • All parameters must be set for non-zero rate limiter
    • Max limiter duration must be within limits based on activation type
    • Fee increment numerator must be less than FEE_DENOMINATOR
    • Cliff fee numerator must be within valid range
    • Min and max fee numerators must be within valid range
Fee Mode
  • Collect fee mode must be either QuoteToken (0) or OutputToken (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)
Graduated DAMM V1/V2 Pool Fee (migrationFeeOption)
  • Must be a valid option: FixedBps25 (0), FixedBps30 (1), FixedBps100 (2), FixedBps200 (3), FixedBps400 (4), FixedBps600 (5), Customizable (6)
  • Customizable (6) is only allowed for DAMM V2 migration
  • When marketCapFeeSchedulerParams is configured in migratedPoolFee, the on-chain program requires migrationFeeOption to be Customizable (6). The SDK’s buildCurve* functions handle this automatically by overriding migrationFeeOption to Customizable when marketCapFeeSchedulerParams is present.
  • For fixed options (0-5), all migratedPoolFee fields must be zero (defaults). Custom values are ignored.
Migration Fee
  • Migration fee percentage must be between 0 and 99
  • Creator fee percentage must be between 0 and 100
Token Decimals
  • Must be between 6 and 9
Liquidity Percentages (Graduated pool)
  • The sum of partner liquidity LP, creator liquidity LP, partner locked liquidity LP, creator locked liquidity LP, partner vested liquidity LP and creator vested liquidity LP percentages must equal 100(%).
  • Must ensure that there is minimum 1000 bps of locked liquidity after 1 day duration (86400 seconds). The locked liquidity can be vested liquidity or permanently locked liquidity.
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 sqrt 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 the values are not all zeros (no Locked Vesting), then:
    • Frequency must be greater than 0
    • Total amount of tokens vested (cliffUnlockAmount + amountPerPeriod * numberOfPeriod) must be greater than 0
Token Supply
  • If specified:
    • Leftover receiver must be a valid non-default PublicKey
    • Post-migration supply must not exceed pre-migration supply
    • Pre-migration supply must be sufficient to cover minimum base supply with buffer
    • Post-migration supply must be sufficient to cover minimum base supply without buffer
Token Update Authority
  • Must be either CreatorUpdateAuthority (0), Immutable (1), PartnerUpdateAuthority (2), CreatorUpdateAndMintAuthority (3), PartnerUpdateAndMintAuthority (4)
Pool Creation Fee
  • Can be 0.
  • If non-zero, must be between 1_000_000 and 100_000_000_000 lamports of SOL
Migrated Pool Base Fee Mode
  • Must be either FeeTimeSchedulerLinear (0), FeeTimeSchedulerExponential (1), FeeMarketCapSchedulerLinear (3), FeeMarketCapSchedulerExponential (4)
  • FeeTimeSchedulerLinear (0) and FeeTimeSchedulerExponential (1) required migratedPoolMarketCapFeeSchedulerParams to be all set to 0.
  • FeeMarketCapSchedulerLinear (3) and FeeMarketCapSchedulerExponential (4) required migratedPoolMarketCapFeeSchedulerParams to be provided.
  • Migrated Pool MarketCap Fee Scheduler Params
  • If migratedPoolBaseFeeMode is FeeMarketCapSchedulerLinear or FeeMarketCapSchedulerExponential, then migratedPoolMarketCapFeeSchedulerParams must be provided. Else set all parameter to 0.
  • Enable First Swap With Minimum Fee
  • Enable only when you want to concatenate a swap instruction with create pool instruction in a single transaction.
Migrated Pool Fee
  • Configures the graduated pool fee parameters for the migrated DAMM V2 pool.
  • Only applies when migrationOption = MET_DAMM_V2 (1).
  • When using migrationFeeOption = Customizable (6), you can configure: collectFeeMode, dynamicFee, and poolFeeBps.
  • When marketCapFeeSchedulerParams is configured:
    • poolFeeBps must be greater than 0 (serves as the starting/cliff fee for the market cap scheduler).
    • baseFeeMode must be FeeMarketCapSchedulerLinear (3) or FeeMarketCapSchedulerExponential (4).
    • endingBaseFeeBps must be strictly less than the bonding curve’s endingFeeBps.
  • For DAMM V1 migration, all migrated pool fee parameters are ignored.

createPartnerMetadata

Creates a new partner metadata account. This partner metadata will be tagged to a wallet address that holds the config keys. Function
async createPartnerMetadata(params: CreatePartnerMetadataParams): Promise<Transaction>
Parameters
interface CreatePartnerMetadataParams {
    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.
Example
const transaction = await client.partner.createPartnerMetadata({
    name: 'Meteora',
    website: 'https://meteora.ag',
    logo: 'https://launch.meteora.ag',
    feeClaimer: wallet.publicKey,
    payer: wallet.publicKey,
})

claimPartnerTradingFee

Claims the trading fee for the partner. A partner is the feeClaimer in the config key. Function
async claimPartnerTradingFee(params: ClaimTradingFeeParams): Promise<Transaction>
Parameters
interface ClaimTradingFeeParams {
    pool: PublicKey // The pool address
    feeClaimer: PublicKey // The wallet that will claim the fee
    payer: PublicKey // The wallet that will pay for the transaction
    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)
    receiver?: PublicKey | null // The wallet that will receive the tokens (optional)
    tempWSolAcc?: PublicKey | null // The temporary wallet that will receive the tokens (optional)
}
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'),
    payer: new PublicKey('payer1234567890abcdefghijklmnopqrstuvwxyz'),
    maxBaseAmount: new BN(1000000),
    maxQuoteAmount: new BN(1000000),
    receiver: new PublicKey('receiver1234567890abcdefghijklmnopqrstuvwxyz'),
    tempWSolAcc: new PublicKey(
        'tempWSolAcc1234567890abcdefghijklmnopqrstuvwxyz'
    ),
})
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.
  • If you indicated a receiver, the receiver is not required to sign the transaction, however, you must provide a tempWSolAcc if the receiver != creato and if the quote mint is SOL.

claimPartnerTradingFee2

Claims the trading fee for the partner. A partner is the feeClaimer in the config key. Function
async claimPartnerTradingFee2(params: ClaimTradingFee2Params): Promise<Transaction>
Parameters
interface ClaimTradingFee2Params {
    pool: PublicKey // The pool address
    feeClaimer: PublicKey // The wallet that will claim the fee
    payer: PublicKey // The wallet that will pay for the transaction
    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)
    receiver?: PublicKey | null // The wallet that will receive the tokens
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.claimPartnerTradingFee2({
    pool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
    feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
    payer: new PublicKey('payer1234567890abcdefghijklmnopqrstuvwxyz'),
    maxBaseAmount: new BN(1000000),
    maxQuoteAmount: new BN(1000000),
    receiver: new PublicKey('receiver1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
  • The feeClaimer of the pool must be the same as the feeClaimer in the ClaimTradingFee2Param params.
  • You can indicate maxBaseAmount or maxQuoteAmount to be 0 to not claim Base or Quote tokens respectively.
  • Can be used in case the partner is a squad multisig account.

partnerWithdrawMigrationFee

Withdraws the partner’s migration fee from the pool. Function
async partnerWithdrawMigrationFee(params: WithdrawMigrationFeeParams): Promise<Transaction>
Parameters
interface WithdrawMigrationFeeParams {
    virtualPool: PublicKey // The virtual pool address
    sender: PublicKey // The wallet that will claim the fee
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.partnerWithdrawMigrationFee({
    virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
    sender: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
  • The sender of the pool must be the same as the partner (feeClaimer) in the config key.

partnerWithdrawSurplus

Withdraws the partner’s surplus from the pool. Function
async partnerWithdrawSurplus(params: PartnerWithdrawSurplusParams): Promise<Transaction>
Parameters
interface PartnerWithdrawSurplusParams {
    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.

claimPartnerPoolCreationFee

Claims the partner’s pool creation fee from the pool. (The pool creation fee is paid by the user) Function
async claimPartnerPoolCreationFee(params: ClaimPartnerPoolCreationFeeParams): Promise<Transaction>
Parameters
interface ClaimPartnerPoolCreationFeeParams {
    virtualPool: PublicKey // The virtual pool address
    feeReceiver: PublicKey // The wallet that will claim the fee
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.claimPartnerPoolCreationFee({
    virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
    feeReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
  • The signer of the transaction must be the same as the feeClaimer in the virtualPool’s config.

Build Curve Functions

buildCurve

Builds a new constant product curve. This function does the math for you to create a curve structure based on percentage of supply on migration and migration quote threshold. Function
function buildCurve(params: BuildCurveParams): ConfigParameters
Parameters All buildCurve* functions share the same base parameters (BuildCurveBaseParams), organized into nested groups:
interface BuildCurveParams {
    // Token configuration
    token: {
        tokenType: TokenType // 0: SPL, 1: Token2022
        tokenBaseDecimal: TokenDecimal // 6, 7, 8, or 9
        tokenQuoteDecimal: TokenDecimal // 6, 7, 8, or 9
        tokenUpdateAuthority: TokenUpdateAuthorityOption // 0: CreatorUpdateAuthority, 1: Immutable, 2: PartnerUpdateAuthority, 3: CreatorUpdateAndMintAuthority, 4: PartnerUpdateAndMintAuthority
        totalTokenSupply: number // The total token supply
        leftover: number // The leftover amount that can be withdrawn by leftover receiver
    }
    // Fee configuration
    fee: {
        baseFeeParams: BaseFeeParams // Either FeeScheduler or RateLimiter (see below)
        dynamicFeeEnabled: boolean // Whether dynamic fee is enabled
        collectFeeMode: CollectFeeMode // 0: QuoteToken, 1: OutputToken
        creatorTradingFeePercentage: number // The percentage of the trading fee allocated to the creator
        poolCreationFee: number // The pool creation fee paid by the token pool creator (in SOL)
        enableFirstSwapWithMinFee: boolean // Enable only when bundling swap with create pool instruction
    }
    // Migration configuration
    migration: {
        migrationOption: MigrationOption // 0: DAMM V1, 1: DAMM V2
        migrationFeeOption: MigrationFeeOption // 0-5: Fixed fee options, 6: Customizable (DAMM V2 only)
        migrationFee: {
            feePercentage: number // Percentage of fee taken from migration quote threshold (0-99)
            creatorFeePercentage: number // Fee share percentage for the creator from the migration fee (0-100)
        }
        migratedPoolFee?: {
            // Optional. Configure only for DAMM V2 migration.
            collectFeeMode: CollectFeeMode // 0: QuoteToken, 1: OutputToken
            dynamicFee: DammV2DynamicFeeMode // 0: Disabled, 1: Enabled
            poolFeeBps: number // The pool fee in basis points
            baseFeeMode?: DammV2BaseFeeMode // 0: FeeTimeSchedulerLinear, 1: FeeTimeSchedulerExponential, 3: FeeMarketCapSchedulerLinear, 4: FeeMarketCapSchedulerExponential
            marketCapFeeSchedulerParams?: {
                // Configure for market cap-based fee scheduling
                endingBaseFeeBps: number // The ending base fee in basis points (must be < bonding curve's endingFeeBps)
                numberOfPeriod: number // The number of periods
                sqrtPriceStepBps: number // The square root price step in basis points
                schedulerExpirationDuration: number // The scheduler expiration duration in seconds
            }
        }
    }
    // Liquidity distribution for the graduated pool
    liquidityDistribution: {
        partnerLiquidityPercentage: number // Partner LP percentage (0-100)
        partnerPermanentLockedLiquidityPercentage: number // Partner permanent locked LP percentage (0-100)
        partnerLiquidityVestingInfoParams?: {
            // Optional partner liquidity vesting (DAMM V2 only)
            vestingPercentage: number
            bpsPerPeriod: number
            numberOfPeriods: number
            cliffDurationFromMigrationTime: number
            totalDuration: number
        }
        creatorLiquidityPercentage: number // Creator LP percentage (0-100)
        creatorPermanentLockedLiquidityPercentage: number // Creator permanent locked LP percentage (0-100)
        creatorLiquidityVestingInfoParams?: {
            // Optional creator liquidity vesting (DAMM V2 only)
            vestingPercentage: number
            bpsPerPeriod: number
            numberOfPeriods: number
            cliffDurationFromMigrationTime: number
            totalDuration: number
        }
    }
    // Locked vesting configuration (set all to 0 for no vesting)
    lockedVesting: {
        totalLockedVestingAmount: number // The total locked vesting amount
        numberOfVestingPeriod: number // The number of vesting periods
        cliffUnlockAmount: number // Tokens unlocked when vesting starts
        totalVestingDuration: number // Total vesting duration in seconds
        cliffDurationFromMigrationTime: number // Wait time before vesting starts in seconds
    }
    activationType: ActivationType // 0: Slot, 1: Timestamp
    // buildCurve-specific parameters:
    percentageSupplyOnMigration: number // The percentage of the supply that will be migrated
    migrationQuoteThreshold: number // The quote threshold for migration (in quote token units)
}
BaseFeeParams (used by all buildCurve* functions):
// Either FeeSchedulerLinear/FeeSchedulerExponential mode:
type BaseFeeParams =
    | {
          baseFeeMode:
              | BaseFeeMode.FeeSchedulerLinear
              | BaseFeeMode.FeeSchedulerExponential
          feeSchedulerParam: {
              startingFeeBps: number // The starting fee in basis points
              endingFeeBps: number // The ending fee in basis points
              numberOfPeriod: number // The number of periods
              totalDuration: number // The total duration of the fee scheduler
          }
      }
    // OR RateLimiter mode:
    | {
          baseFeeMode: BaseFeeMode.RateLimiter
          rateLimiterParam: {
              baseFeeBps: number // The base fee in basis points
              feeIncrementBps: number // The fee increment in basis points
              referenceAmount: number // The reference amount for rate limiting
              maxLimiterDuration: number // The maximum duration for rate limiting
          }
      }
Returns
  • A ConfigParameters object that can be spread into createConfig.
Example
// Example 1: Simple fixed fee option (no custom migrated pool fee needed)
const curveConfig = buildCurve({
    token: {
        tokenType: TokenType.SPL,
        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: false,
    },
    migration: {
        migrationOption: MigrationOption.MET_DAMM_V2,
        migrationFeeOption: MigrationFeeOption.FixedBps100,
        migrationFee: { feePercentage: 0, creatorFeePercentage: 0 },
    },
    liquidityDistribution: {
        partnerLiquidityPercentage: 0,
        partnerPermanentLockedLiquidityPercentage: 100,
        creatorLiquidityPercentage: 0,
        creatorPermanentLockedLiquidityPercentage: 0,
    },
    lockedVesting: {
        totalLockedVestingAmount: 0,
        numberOfVestingPeriod: 0,
        cliffUnlockAmount: 0,
        totalVestingDuration: 0,
        cliffDurationFromMigrationTime: 0,
    },
    activationType: ActivationType.Timestamp,
    percentageSupplyOnMigration: 25,
    migrationQuoteThreshold: 1,
})

// Example 2: Customizable with market cap fee scheduler
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: CollectFeeMode.QuoteToken,
            dynamicFee: DammV2DynamicFeeMode.Enabled,
            poolFeeBps: 120,
            baseFeeMode: DammV2BaseFeeMode.FeeMarketCapSchedulerLinear,
            marketCapFeeSchedulerParams: {
                endingBaseFeeBps: 25, // Must be less than bonding curve's endingFeeBps (100)
                numberOfPeriod: 100,
                sqrtPriceStepBps: 10,
                schedulerExpirationDuration: 1000000,
            },
        },
    },
    liquidityDistribution: {
        partnerLiquidityPercentage: 55,
        partnerPermanentLockedLiquidityPercentage: 0,
        creatorLiquidityPercentage: 0,
        creatorPermanentLockedLiquidityPercentage: 0,
        partnerLiquidityVestingInfoParams: {
            vestingPercentage: 30,
            bpsPerPeriod: 1000,
            cliffDurationFromMigrationTime: 86400,
            numberOfPeriods: 10,
            totalDuration: 100,
        },
        creatorLiquidityVestingInfoParams: {
            vestingPercentage: 15,
            bpsPerPeriod: 1,
            cliffDurationFromMigrationTime: 86400,
            numberOfPeriods: 10000,
            totalDuration: 333333,
        },
    },
    lockedVesting: {
        totalLockedVestingAmount: 1000000,
        numberOfVestingPeriod: 10,
        cliffUnlockAmount: 0,
        totalVestingDuration: 10000,
        cliffDurationFromMigrationTime: 0,
    },
    activationType: ActivationType.Timestamp,
    percentageSupplyOnMigration: 10,
    migrationQuoteThreshold: 300,
})

// Use the curve config in createConfig
const transaction = await client.partner.createConfig({
    config: configKeypair.publicKey,
    feeClaimer: wallet.publicKey,
    leftoverReceiver: wallet.publicKey,
    payer: wallet.publicKey,
    quoteMint: NATIVE_MINT,
    ...curveConfig,
})
Notes
  • buildCurve helps you create a curve structure based on percentage of supply on migration and migration quote threshold.
  • If dynamicFeeEnabled is true, the dynamic fee will be enabled and capped at 20% of minimum base fee.
  • lockedVesting.totalVestingDuration and lockedVesting.cliffDurationFromMigrationTime are calculated in terms of seconds.
  • feeSchedulerParam.totalDuration is calculated based on your activationType and activationTime. Slot is 400ms, Timestamp is 1000ms.
  • Migration Fee Option behavior:
    • Fixed options (0-5): Uses default migrated pool fee parameters. Any custom migratedPoolFee values are ignored.
    • Customizable (6): Uses your custom migratedPoolFee values. Falls back to defaults for any omitted fields.
    • Auto-override: When marketCapFeeSchedulerParams is configured inside migratedPoolFee, the SDK automatically overrides migrationFeeOption to Customizable regardless of what you set. This is required by the on-chain program.
  • When using marketCapFeeSchedulerParams:
    • baseFeeMode must be DammV2BaseFeeMode.FeeMarketCapSchedulerLinear (3) or FeeMarketCapSchedulerExponential (4).
    • endingBaseFeeBps must be strictly less than the bonding curve’s baseFeeParams.feeSchedulerParam.endingFeeBps.
    • poolFeeBps must be greater than 0.
  • For DAMM V1 migration, all migratedPoolFee parameters are ignored and defaults are used.

buildCurveWithMarketCap

Builds a new constant product curve with customisable parameters based on market cap. This function does the math for you to create a curve structure based on initial market cap and migration market cap. Function
function buildCurveWithMarketCap(
    params: BuildCurveWithMarketCapParams
): ConfigParameters
Parameters
interface BuildCurveWithMarketCapParams {
    // Inherits all fields from BuildCurveBaseParams (token, fee, migration, liquidityDistribution, lockedVesting, activationType)
    // See buildCurve for the full BuildCurveBaseParams definition.
    token: TokenConfig
    fee: FeeConfig
    migration: MigrationConfig
    liquidityDistribution: LiquidityDistributionConfig
    lockedVesting: LockedVestingParams
    activationType: ActivationType
    // buildCurveWithMarketCap-specific parameters:
    initialMarketCap: number // The initial market cap that your token will start with
    migrationMarketCap: number // The migration market cap that your token will be at migration
}
Returns
  • A ConfigParameters object.
Example
const curveConfig = buildCurveWithMarketCap({
    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: CollectFeeMode.QuoteToken,
            dynamicFee: DammV2DynamicFeeMode.Enabled,
            poolFeeBps: 120,
        },
    },
    liquidityDistribution: {
        partnerLiquidityPercentage: 55,
        partnerPermanentLockedLiquidityPercentage: 0,
        creatorLiquidityPercentage: 0,
        creatorPermanentLockedLiquidityPercentage: 0,
        partnerLiquidityVestingInfoParams: {
            vestingPercentage: 30,
            bpsPerPeriod: 1000,
            cliffDurationFromMigrationTime: 86400,
            numberOfPeriods: 10,
            totalDuration: 100,
        },
        creatorLiquidityVestingInfoParams: {
            vestingPercentage: 15,
            bpsPerPeriod: 1,
            cliffDurationFromMigrationTime: 86400,
            numberOfPeriods: 10000,
            totalDuration: 333333,
        },
    },
    lockedVesting: {
        totalLockedVestingAmount: 1000000,
        numberOfVestingPeriod: 10,
        cliffUnlockAmount: 0,
        totalVestingDuration: 10000,
        cliffDurationFromMigrationTime: 0,
    },
    activationType: ActivationType.Timestamp,
    initialMarketCap: 100,
    migrationMarketCap: 3000,
})

const transaction = await client.partner.createConfig({
    config: configKeypair.publicKey,
    feeClaimer: wallet.publicKey,
    leftoverReceiver: wallet.publicKey,
    payer: wallet.publicKey,
    quoteMint: NATIVE_MINT,
    ...curveConfig,
})
Notes
  • buildCurveWithMarketCap helps you create a curve structure based on initial market cap and migration market cap.
  • 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 notes for details on migration fee option behavior and marketCapFeeSchedulerParams constraints.

buildCurveWithTwoSegments

Builds a new constant product curve with two segments. This function does the math for you to create a curve structure based on initial market cap, migration market cap and percentage of supply on migration. Function
function buildCurveWithTwoSegments(
    params: BuildCurveWithTwoSegmentsParams
): ConfigParameters
Parameters
interface BuildCurveWithTwoSegmentsParams {
    // Inherits all fields from BuildCurveBaseParams (token, fee, migration, liquidityDistribution, lockedVesting, activationType)
    // See buildCurve for the full BuildCurveBaseParams definition.
    token: TokenConfig
    fee: FeeConfig
    migration: MigrationConfig
    liquidityDistribution: LiquidityDistributionConfig
    lockedVesting: LockedVestingParams
    activationType: ActivationType
    // buildCurveWithTwoSegments-specific parameters:
    initialMarketCap: number // The initial market cap that your token will start with
    migrationMarketCap: number // The migration market cap that your token will be at migration
    percentageSupplyOnMigration: number // The percentage of the supply that will be migrated
}
Returns
  • A ConfigParameters object.
Example
const curveConfig = buildCurveWithTwoSegments({
    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: CollectFeeMode.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,
    percentageSupplyOnMigration: 10,
})

const transaction = await client.partner.createConfig({
    config: configKeypair.publicKey,
    feeClaimer: wallet.publicKey,
    leftoverReceiver: wallet.publicKey,
    payer: wallet.publicKey,
    quoteMint: NATIVE_MINT,
    ...curveConfig,
})
Notes
  • buildCurveWithTwoSegments helps you create a curve structure based on initial market cap, migration market cap and percentage of supply on migration.
  • 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 notes for details on migration fee option behavior and marketCapFeeSchedulerParams constraints.

buildCurveWithMidPrice

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
function buildCurveWithMidPrice(
    params: BuildCurveWithMidPriceParams
): ConfigParameters
Parameters
interface BuildCurveWithMidPriceParams {
    // Inherits all fields from BuildCurveBaseParams (token, fee, migration, liquidityDistribution, lockedVesting, activationType)
    // See buildCurve for the full BuildCurveBaseParams definition.
    token: TokenConfig
    fee: FeeConfig
    migration: MigrationConfig
    liquidityDistribution: LiquidityDistributionConfig
    lockedVesting: LockedVestingParams
    activationType: ActivationType
    // buildCurveWithMidPrice-specific parameters:
    initialMarketCap: number // The initial market cap
    migrationMarketCap: number // The migration market cap
    midPrice: number // The mid price where the curve segments
    percentageSupplyOnMigration: number // The percentage of the supply that will be migrated
}
Returns
  • A ConfigParameters object.
Example
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: CollectFeeMode.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.
  • What does mid price do?
    • 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 notes for details on migration fee option behavior and marketCapFeeSchedulerParams constraints.

buildCurveWithLiquidityWeights

Builds a super customizable constant product curve graph configuration based on different liquidity weights. This function does the math for you to create a curve structure based on initial market cap, migration market cap and liquidity weights. Function
function buildCurveWithLiquidityWeights(
    params: BuildCurveWithLiquidityWeightsParams
): ConfigParameters
Parameters
interface BuildCurveWithLiquidityWeightsParams {
    // Inherits all fields from BuildCurveBaseParams (token, fee, migration, liquidityDistribution, lockedVesting, activationType)
    // See buildCurve for the full BuildCurveBaseParams definition.
    token: TokenConfig
    fee: FeeConfig
    migration: MigrationConfig
    liquidityDistribution: LiquidityDistributionConfig
    lockedVesting: LockedVestingParams
    activationType: ActivationType
    // buildCurveWithLiquidityWeights-specific parameters:
    initialMarketCap: number // The initial market cap
    migrationMarketCap: number // The migration market cap
    liquidityWeights: number[] // The liquidity weights for each segment (max 16 elements)
}
Returns
  • A ConfigParameters object.
Example
let liquidityWeights: number[] = []
for (let i = 0; i < 16; i++) {
    liquidityWeights[i] = new Decimal(1.2).pow(new Decimal(i)).toNumber()
}

const curveConfig = buildCurveWithLiquidityWeights({
    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: CollectFeeMode.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,
    liquidityWeights,
})

const transaction = await client.partner.createConfig({
    config: configKeypair.publicKey,
    feeClaimer: wallet.publicKey,
    leftoverReceiver: wallet.publicKey,
    payer: wallet.publicKey,
    quoteMint: NATIVE_MINT,
    ...curveConfig,
})
Notes
  • buildCurveWithLiquidityWeights helps you create a curve structure based on initial market cap, migration market cap and liquidity weights.
  • What does liquidity weights do?
    • The liquidityWeights is an array of numbers that determines how liquidity is distributed across the curve’s price ranges.
    • The maximum number of liquidity weights[i] is 16.
    • Each element in the array represents the liquidity weight for a specific curve segment (total 16 curve segments).
    • For each segment of the curve, the liquidity is scaled by liquidityWeights[i] (where i is the liquidityWeight index).
    • This means that as you move along the curve (from lower to higher price ranges), the liquidity in each curve segment can be controlled.
  • Effects of changing liquidity weights
    1. All liquidityWeights[i] === 1: All segments have the same liquidity. The curve is linear.
    2. liquidityWeights[i] < liquidityWeights[i+1]: Lower liquidity at lower prices. Price moves more at lower prices and less at higher prices.
    3. liquidityWeights[i] > liquidityWeights[i+1]: Higher liquidity at lower prices. Price moves less at lower prices and more at higher prices.
  • 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 notes for details on migration fee option behavior and marketCapFeeSchedulerParams constraints.

buildCurveWithCustomSqrtPrices

Builds a super customizable constant product curve graph configuration based on custom sqrt prices. This function does the math for you to create a curve structure based on custom sqrt prices and optional liquidity weights. Function
function buildCurveWithCustomSqrtPrices(
    params: BuildCurveWithCustomSqrtPricesParams
): ConfigParameters
Parameters
interface BuildCurveWithCustomSqrtPricesParams {
    // Inherits all fields from BuildCurveBaseParams (token, fee, migration, liquidityDistribution, lockedVesting, activationType)
    // See buildCurve for the full BuildCurveBaseParams definition.
    token: TokenConfig
    fee: FeeConfig
    migration: MigrationConfig
    liquidityDistribution: LiquidityDistributionConfig
    lockedVesting: LockedVestingParams
    activationType: ActivationType
    // buildCurveWithCustomSqrtPrices-specific parameters:
    sqrtPrices: BN[] // Array of custom sqrt prices (must be in ascending order, min 2 elements)
    liquidityWeights?: number[] // Optional weights for each segment. Length must be sqrtPrices.length - 1. If not provided, liquidity is distributed evenly.
}
Returns
  • A ConfigParameters object.
Example
const customPrices = [0.000001, 0.00000105, 0.000002, 0.001]
const tokenBaseDecimal = TokenDecimal.SIX
const tokenQuoteDecimal = TokenDecimal.SIX

// convert prices to sqrtPrices
const sqrtPrices = createSqrtPrices(
    customPrices,
    tokenBaseDecimal,
    tokenQuoteDecimal
)

// define custom liquidity weights for custom segments (optional)
// length must be sqrtPrices.length - 1, or leave undefined for even distribution
const liquidityWeights = [2, 1, 1]

const curveConfig = buildCurveWithCustomSqrtPrices({
    token: {
        tokenType: TokenType.Token2022,
        tokenBaseDecimal: TokenDecimal.SIX,
        tokenQuoteDecimal: TokenDecimal.SIX,
        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: CollectFeeMode.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,
    sqrtPrices,
    liquidityWeights,
})

const transaction = await client.partner.createConfig({
    config: configKeypair.publicKey,
    feeClaimer: wallet.publicKey,
    leftoverReceiver: wallet.publicKey,
    payer: wallet.publicKey,
    quoteMint: NATIVE_MINT,
    ...curveConfig,
})
Notes
  • buildCurveWithCustomSqrtPrices helps you create a curve structure based on custom sqrt prices and optional liquidity weights.
  • What does sqrt prices do?
    • The sqrtPrices is an array of BN values representing the sqrt prices of the curve segments.
    • The length of the sqrtPrices array must be at least 2.
    • The first price will be the starting price (pMin) and the last price will be the migration price (pMax).
    • The prices must be in ascending order.
    • Use createSqrtPrices() helper to convert regular prices to sqrt prices.
  • What does liquidity weights do?
    • The liquidityWeights is an array of numbers that determines how liquidity is distributed across the curve’s price ranges.
    • The maximum number of liquidity weights[i] is 16.
    • Each element in the array represents the liquidity weight for a specific curve segment.
    • If not provided, liquidity is distributed evenly across all segments.
    • The length of the liquidityWeights array must be sqrtPrices.length - 1.
  • Effects of changing liquidity weights
    1. All liquidityWeights[i] === 1: All segments have the same liquidity. The curve is linear.
    2. liquidityWeights[i] < liquidityWeights[i+1]: Lower liquidity at lower prices. Price moves more at lower prices and less at higher prices.
    3. liquidityWeights[i] > liquidityWeights[i+1]: Higher liquidity at lower prices. Price moves less at lower prices and more at higher prices.
  • 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 notes for details on migration fee option behavior and marketCapFeeSchedulerParams constraints.

Pool Functions

createPool

Creates a new pool with the config key. Function
async createPool(params: CreatePoolParams): Promise<Transaction>
Parameters
interface CreatePoolParams {
    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
}
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({
    baseMint: new PublicKey('0987654321zyxwvutsrqponmlkjihgfedcba'),
    config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
    name: 'Meteora',
    symbol: 'MET',
    uri: 'https://launch.meteora.ag',
    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.

createConfigAndPool

Creates a config key and a token pool in a single transaction. Function
async createConfigAndPool(params: CreateConfigAndPoolParams): Promise<Transaction>
Parameters
interface CreateConfigAndPoolParams {
    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: {
        baseFee: {
            cliffFeeNumerator: BN // Initial fee numerator (base fee)
            firstFactor: number // feeScheduler: numberOfPeriod, rateLimiter: feeIncrementBps
            secondFactor: BN // feeScheduler: periodFrequency, rateLimiter: maxLimiterDuration
            thirdFactor: BN // feeScheduler: reductionFactor, rateLimiter: referenceAmount
            baseFeeMode: number // 0: FeeSchedulerLinear, 1: FeeSchedulerExponential, 2: RateLimiter
        }
        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
    }
    collectFeeMode: number // 0: QuoteToken, 1: OutputToken
    migrationOption: number // 0: DAMM V1, 1: DAMM v2
    activationType: number // 0: Slot, 1: Timestamp
    tokenType: number // 0: SPL, 1: Token2022
    tokenDecimal: number // The number of decimals for the token
    partnerLiquidityPercentage: number // The percentage of the LP that will be allocated to the partner in the graduated pool (0-100)
    partnerPermanentLockedLiquidityPercentage: number // The percentage of the locked LP that will be allocated to the partner in the graduated pool (0-100)
    creatorLiquidityPercentage: number // The percentage of the LP that will be allocated to the creator in the graduated pool (0-100)
    creatorPermanentLockedLiquidityPercentage: number // The percentage of the locked LP that will be allocated to the creator in the graduated pool (0-100)
    migrationQuoteThreshold: BN // The quote threshold for migration
    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 waiting time before the vesting starts
        frequency: BN // The frequency of the vesting
        numberOfPeriod: BN // The number of periods of the vesting
        cliffUnlockAmount: BN // The amount of tokens that will be unlocked when vesting starts
    }
    migrationFeeOption: number // 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: {
        // 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
    tokenUpdateAuthority: number // 0 - CreatorUpdateAuthority, 1 - Immutable, 2 - PartnerUpdateAuthority, 3 - CreatorUpdateAndMintAuthority, 4 - PartnerUpdateAndMintAuthority
    migrationFee: {
        // Optional migration fee (set as 0 for feePercentage and creatorFeePercentage for no migration fee)
        feePercentage: number // The percentage of fee taken from migration quote threshold (0-99)
        creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
    }
    migratedPoolFee: {
        // Only when migrationOption = MET_DAMM_V2 (1) and migrationFeeOption = Customizable (6)
        collectFeeMode: number // 0: QuoteToken, 1: OutputToken
        dynamicFee: number // 0: Disabled, 1: Enabled
        poolFeeBps: number // The pool fee in basis points. Minimum 10, Maximum 1000 bps.
    }
    migratedPoolBaseFeeMode: number // 0: FeeTimeSchedulerLinear, 1: FeeTimeSchedulerExponential, 3: FeeMarketCapSchedulerLinear, 4: FeeMarketCapSchedulerExponential (defaults to FeeTimeSchedulerLinear)
    migratedPoolMarketCapFeeSchedulerParams: {
        // Defaults to all 0. Configure only when migratedPoolBaseFeeMode = FeeMarketCapSchedulerLinear or FeeMarketCapSchedulerExponential
        numberOfPeriod: number // The number of periods
        sqrtPriceStepBps: number // The square root price step in basis points
        schedulerExpirationDuration: number // The scheduler expiration duration in seconds
        reductionFactor: BN // The reduction factor
    }
    enableFirstSwapWithMinFee: boolean // Whether to enable first swap with minimum fee (defaults to false)
    poolCreationFee: BN // The pool creation fee
    partnerLiquidityVestingInfo: {
        vestingPercentage: number // The percentage of the liquidity that will be vested
        bpsPerPeriod: number // The basis points per period
        numberOfPeriods: number // The number of periods
        cliffDurationFromMigrationTime: number // The duration of the waiting time before the vesting starts
        frequency: number // The frequency of the vesting
    }
    creatorLiquidityVestingInfo: {
        vestingPercentage: number // The percentage of the liquidity that will be vested
        bpsPerPeriod: number // The basis points per period
        numberOfPeriods: number // The number of periods
        cliffDurationFromMigrationTime: number // The duration of the waiting time before the vesting starts
        frequency: number // The frequency of the vesting
    }
    padding: []
    curve: {
        // The curve of the pool
        sqrtPrice: BN // The square root of the curve point price
        liquidity: BN // The liquidity of the curve point
    }[]
    preCreatePoolParam: {
        baseMint: PublicKey // The base mint address (generated by you)
        name: string // The name of the pool
        symbol: string // The symbol of the pool
        uri: string // The uri of the pool
        poolCreator: PublicKey // The pool creator of the transaction
    }
}
Returns
  • A transaction that requires signatures from the payer, the baseMint keypair, and the config keypair before being submitted to the network.
Example
const transaction = await client.pool.createConfigAndPool({
    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(1_000_000_000),
    creatorLiquidityVestingInfo: {
        vestingPercentage: 0,
        bpsPerPeriod: 0,
        numberOfPeriods: 0,
        frequency: 0,
        cliffDurationFromMigrationTime: 0,
    },
    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'),
    },
})
Notes
  • The payer must be the same as the payer in the CreateConfigAndPoolParam 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.
  • You can use any of the build curve functions to create the curve configuration.

createConfigAndPoolWithFirstBuy

Creates a config key and a token pool and buys the token immediately. Function
async createConfigAndPoolWithFirstBuy(params: CreateConfigAndPoolWithFirstBuyParams): Promise<{
    createConfigTx: Transaction
    createPoolTx: Transaction
}>
Parameters
interface CreateConfigAndPoolWithFirstBuyParams {
    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: {
        baseFee: {
            cliffFeeNumerator: BN // Initial fee numerator (base fee)
            firstFactor: number // feeScheduler: numberOfPeriod, rateLimiter: feeIncrementBps
            secondFactor: BN // feeScheduler: periodFrequency, rateLimiter: maxLimiterDuration
            thirdFactor: BN // feeScheduler: reductionFactor, rateLimiter: referenceAmount
            baseFeeMode: number // 0: FeeSchedulerLinear, 1: FeeSchedulerExponential, 2: RateLimiter
        }
        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
    }
    collectFeeMode: number // 0: QuoteToken, 1: OutputToken
    migrationOption: number // 0: DAMM V1, 1: DAMM v2
    activationType: number // 0: Slot, 1: Timestamp
    tokenType: number // 0: SPL, 1: Token2022
    tokenDecimal: number // The number of decimals for the token
    partnerLiquidityPercentage: number // The percentage of the LP that will be allocated to the partner in the graduated pool (0-100)
    partnerPermanentLockedLiquidityPercentage: number // The percentage of the locked LP that will be allocated to the partner in the graduated pool (0-100)
    creatorLiquidityPercentage: number // The percentage of the LP that will be allocated to the creator in the graduated pool (0-100)
    creatorPermanentLockedLiquidityPercentage: number // The percentage of the locked LP that will be allocated to the creator in the graduated pool (0-100)
    migrationQuoteThreshold: BN // The quote threshold for migration
    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 waiting time before the vesting starts
        frequency: BN // The frequency of the vesting
        numberOfPeriod: BN // The number of periods of the vesting
        cliffUnlockAmount: BN // The amount of tokens that will be unlocked when vesting starts
    }
    migrationFeeOption: number // 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: {
        // 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
    tokenUpdateAuthority: number // 0 - CreatorUpdateAuthority, 1 - Immutable, 2 - PartnerUpdateAuthority, 3 - CreatorUpdateAndMintAuthority, 4 - PartnerUpdateAndMintAuthority
    migrationFee: {
        // Optional migration fee (set as 0 for feePercentage and creatorFeePercentage for no migration fee)
        feePercentage: number // The percentage of fee taken from migration quote threshold (0-99)
        creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
    }
    migratedPoolFee: {
        // Only when migrationOption = MET_DAMM_V2 (1) and migrationFeeOption = Customizable (6)
        collectFeeMode: number // 0: QuoteToken, 1: OutputToken
        dynamicFee: number // 0: Disabled, 1: Enabled
        poolFeeBps: number // The pool fee in basis points. Minimum 10, Maximum 1000 bps.
    }
    migratedPoolBaseFeeMode: number // 0: FeeTimeSchedulerLinear, 1: FeeTimeSchedulerExponential, 3: FeeMarketCapSchedulerLinear, 4: FeeMarketCapSchedulerExponential (defaults to FeeTimeSchedulerLinear)
    migratedPoolMarketCapFeeSchedulerParams: {
        // Defaults to all 0. Configure only when migratedPoolBaseFeeMode = FeeMarketCapSchedulerLinear or FeeMarketCapSchedulerExponential
        numberOfPeriod: number // The number of periods
        sqrtPriceStepBps: number // The square root price step in basis points
        schedulerExpirationDuration: number // The scheduler expiration duration in seconds
        reductionFactor: BN // The reduction factor
    }
    enableFirstSwapWithMinFee: boolean // Whether to enable first swap with minimum fee (defaults to false)
    poolCreationFee: BN // The pool creation fee
    partnerLiquidityVestingInfo: {
        vestingPercentage: number // The percentage of the liquidity that will be vested
        bpsPerPeriod: number // The basis points per period
        numberOfPeriods: number // The number of periods
        cliffDurationFromMigrationTime: number // The duration of the waiting time before the vesting starts
        frequency: number // The frequency of the vesting
    }
    creatorLiquidityVestingInfo: {
        vestingPercentage: number // The percentage of the liquidity that will be vested
        bpsPerPeriod: number // The basis points per period
        numberOfPeriods: number // The number of periods
        cliffDurationFromMigrationTime: number // The duration of the waiting time before the vesting starts
        frequency: number // The frequency of the vesting
    }
    padding: []
    curve: {
        // The curve of the pool
        sqrtPrice: BN // The square root of the curve point price
        liquidity: BN // The liquidity of the curve point
    }[]
    preCreatePoolParam: {
        baseMint: PublicKey // The base mint address (generated by you)
        name: string // The name of the pool
        symbol: string // The symbol of the pool
        uri: string // The uri of the pool
        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 of transactions containing:
  • createConfigTx: config creation transaction
  • createPoolTx: pool creation transaction, with first-buy instructions included when firstBuyParam is provided and buyAmount > 0
Example
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(1_000_000_000),
    creatorLiquidityVestingInfo: {
        vestingPercentage: 0,
        bpsPerPeriod: 0,
        numberOfPeriods: 0,
        frequency: 0,
        cliffDurationFromMigrationTime: 0,
    },
    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,
    },
})
Notes
  • The payer must be the same as the payer in the CreateConfigAndPoolWithFirstBuyParam params.
  • The createConfigTx requires the payer and config to sign the transaction.
  • The createPoolTx requires the payer, poolCreator, and baseMint to sign the transaction. If firstBuyParam is provided, it also requires buyer/payer signatures for the appended first-buy instructions.
  • If the firstBuyParam is not provided, createPoolTx includes only pool-creation instructions.
  • The receiver parameter is an optional account. If provided, the token will be sent to the receiver address.

createPoolWithFirstBuy

Creates a new pool with the config key and buys the token immediately. Function
async createPoolWithFirstBuy(params: CreatePoolWithFirstBuyParams): Promise<{
    createPoolTx: Transaction
}>
Parameters
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
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.

createPoolWithPartnerAndCreatorFirstBuy

Creates a new pool with the config key and buys the token immediately with partner and creator. Function
async createPoolWithPartnerAndCreatorFirstBuy(params: CreatePoolWithPartnerAndCreatorFirstBuyParams): Promise<Transaction>
Parameters
interface CreatePoolWithPartnerAndCreatorFirstBuyParams {
    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
    }
    partnerFirstBuyParam?: {
        // Optional partner first buy param
        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?: {
        // Optional creator first buy param
        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
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.

swap

Swaps between base and quote or quote and base on the Dynamic Bonding Curve. Function
async swap(params: SwapParams): Promise<Transaction>
Parameters
interface SwapParams {
    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)
    payer?: PublicKey // The payer of the transaction (optional)
}
Returns
  • A transaction that can be signed and sent to the network.
Example
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.swapQuote({
    virtualPool: virtualPoolState.account,
    config: poolConfigState,
    swapBaseForQuote: false,
    amountIn,
    slippageBps: 50,
    hasReferral: false,
    currentPoint,
    swapMode: SwapMode.PartialFill,
})

const transaction = await client.pool.swap({
    owner: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
    amountIn: new BN(1000000000),
    minimumAmountOut: new BN(0),
    swapBaseForQuote: false,
    pool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
    referralTokenAccount: null,
    payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
})
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 deriveDbcPoolAddress.
  • The payer parameter is optional. If not provided, the owner will be used as the payer to fund ATA creation.

swapQuote

Gets the exact swap out quotation in between quote and base swaps (only ExactIn). Function
swapQuote(params: SwapQuoteParams): Promise<SwapResult>
Parameters
interface SwapQuoteParams {
    virtualPool: VirtualPool // The virtual pool address
    config: PoolConfig // The pool config address
    swapBaseForQuote: boolean // True for base->quote, false for quote->base
    amountIn: BN // The amount of tokens to swap in
    slippageBps?: number // The slippage in bps
    hasReferral: boolean // Whether to include a referral fee
    currentPoint: BN // The current point
}
Returns The exact swap out quotation in between quote and base swaps (only ExactIn). Example
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.swapQuote({
    virtualPool: virtualPoolState,
    config: poolConfigState,
    swapBaseForQuote: false,
    amountIn,
    slippageBps: 50,
    hasReferral: false,
    currentPoint,
})
Notes
  • The swapMode parameter determines the type of swap:
    • SwapMode.ExactIn: Swap exact input amount
    • SwapMode.PartialFill: Allow partial fills
    • SwapMode.ExactOut: Swap for exact output amount
  • 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 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.


swap2

Swaps between base and quote or quote and base on the Dynamic Bonding Curve with specific swap modes (ExactIn, ExactOut, PartialFill). Function
swap2(params: Swap2Params): Promise<Transaction>
Parameters
interface Swap2Params {
    owner: PublicKey // The wallet performing the swap
    pool: PublicKey // The pool address to swap on
    swapBaseForQuote: boolean // True for base->quote, false for quote->base
    referralTokenAccount: PublicKey | null // The referral token account (optional)
    payer?: PublicKey // The payer of the transaction (optional)
} & (
    | {
          swapMode: SwapMode.ExactIn // Swap exact input amount
          amountIn: BN // The exact amount to swap in
          minimumAmountOut: BN // Minimum amount expected out (slippage protection)
      }
    | {
          swapMode: SwapMode.PartialFill // Allow partial fills
          amountIn: BN // The amount to swap in
          minimumAmountOut: BN // Minimum amount expected out (slippage protection)
      }
    | {
          swapMode: SwapMode.ExactOut // Swap for exact output amount
          amountOut: BN // The exact amount desired out
          maximumAmountIn: BN // Maximum amount willing to pay in (slippage protection)
      }
)
Returns
  • A transaction that can be signed and sent to the network.
Example
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,
})

const transaction = await client.pool.swap2({
    amountIn,
    minimumAmountOut: quote.minimumAmountOut,
    swapMode: SwapMode.PartialFill,
    swapBaseForQuote: false,
    owner: wallet.publicKey,
    pool: poolAddress,
    referralTokenAccount: null,
    payer: payer.publicKey,
})
Notes
  • The swapMode parameter determines the type of swap:
    • SwapMode.ExactIn: Swap exact input amount
    • SwapMode.PartialFill: Allow partial fills
    • SwapMode.ExactOut: Swap for exact output amount
  • 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 minimumAmountOut parameter protects against slippage. Set it to a value slightly lower than the expected output.
  • The maximumAmountIn parameter protects against slippage. Set it to a value slightly higher than the expected input.
  • The referralTokenAccount parameter is an optional token account. If provided, the referral fee will be applied to the transaction.
  • The payer parameter is optional. If not provided, the owner will be used as the payer to fund ATA creation.

swapQuote2

Gets the exact swap out quotation in between quote and base swaps with specific swap modes (ExactIn, ExactOut, PartialFill). Function
swapQuote2(params: SwapQuote2Params): Promise<SwapResult2>
Parameters
interface SwapQuote2Params {
    virtualPool: VirtualPool // The virtual pool address
    config: PoolConfig // The pool config address
    swapBaseForQuote: boolean // True for base->quote, false for quote->base
    hasReferral: boolean // Whether to include a referral fee
    currentPoint: BN // The current point
    slippageBps?: number // The slippage in bps
} & (
    | {
          swapMode: SwapMode.ExactIn // Swap exact input amount
          amountIn: BN // The exact amount to swap in
      }
    | {
          swapMode: SwapMode.PartialFill // Allow partial fills
          amountIn: BN // The amount to swap in
      }
    | {
          swapMode: SwapMode.ExactOut // Swap for exact output amount
          amountOut: BN // 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
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: Swap exact input amount
    • SwapMode.PartialFill: Allow partial fills
    • SwapMode.ExactOut: Swap for exact output amount
  • 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 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.

Migration Functions

createLocker

Creates a new locker account when migrating from Dynamic Bonding Curve to DAMM V1 or DAMM V2. This function is called when lockedVestingParam is enabled in the config key. Function
async createLocker(params: CreateLockerParams): Promise<Transaction>
Parameters
interface CreateLockerParams {
    payer: PublicKey // The payer of the transaction
    virtualPool: PublicKey // The virtual pool address
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.createLocker({
    payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
    virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
})
Notes
  • This function is called when lockedVesting is enabled in the config key.

withdrawLeftover

Withdraws leftover tokens from the Dynamic Bonding Curve pool. Function
async withdrawLeftover(params: WithdrawLeftoverParams): Promise<Transaction>
Parameters
interface WithdrawLeftoverParams {
    payer: PublicKey // The payer of the transaction
    virtualPool: PublicKey // The virtual pool address
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.withdrawLeftover({
    payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
    virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
})
Notes
  • This function is called when there are leftover tokens in the Dynamic Bonding Curve pool after migration.
  • The leftover tokens will be sent to the leftoverReceiver that was specified in the config key.

createDammV1MigrationMetadata

Creates a new DAMM V1 migration metadata account. Function
async createDammV1MigrationMetadata(params: CreateDammV1MigrationMetadataParams): Promise<Transaction>
Parameters
interface CreateDammV1MigrationMetadataParams {
    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
  • This function must be called before migrateToDammV1.

migrateToDammV1

Migrates the Dynamic Bonding Curve pool to DAMM V1. Function
async migrateToDammV1(params: MigrateToDammV1Params): Promise<Transaction>
Parameters
interface MigrateToDammV1Params {
    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
  • Ensure that when attempting to migrate the virtual pool, all these validation checks have already been met:
    1. The MigrationFeeOption must be a valid enum value with a valid base fee in basis points
    2. 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)
    3. The virtual pool’s migration progress must be in the LockedVesting state
    4. The pool must be “complete” based on the migration_quote_threshold (checked via is_curve_complete)
    5. The migration option must be valid and specifically set to MeteoraDamm
    6. 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
  • You can get the dammConfig key from the README.md, or you can use DAMM_V1_MIGRATION_FEE_ADDRESS[i] to get the dammConfig key address.

lockDammV1LpToken

Locks a DAMM V1 LP token for a partner or creator. Function
async lockDammV1LpToken(params: DammLpTokenParams): Promise<Transaction>
Parameters
interface DammLpTokenParams {
    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 creatorPermanentLockedLiquidityPercentage or partnerPermanentLockedLiquidityPercentage is > 0.
  • You can get the dammConfig key from the README.md, or you can use DAMM_V1_MIGRATION_FEE_ADDRESS[i] to get the dammConfig key address.

claimDammV1LpToken

Claims a DAMM V1 LP token for a partner or creator. Function
async claimDammV1LpToken(params: DammLpTokenParams): Promise<Transaction>
Parameters
interface DammLpTokenParams {
    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 creatorLiquidityPercentage or partnerLiquiditypercentage is > 0.
  • You can get the dammConfig key from the README.md, or you can use DAMM_V1_MIGRATION_FEE_ADDRESS[i] to get the dammConfig key address.

migrateToDammV2

Migrates the Dynamic Bonding Curve pool to DAMM V2. Function
async migrateToDammV2(params: MigrateToDammV2Params): Promise<Transaction>
Parameters
interface MigrateToDammV2Params {
    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
  • Ensure that when attempting to migrate the virtual pool, all these validation checks have already been met:
    1. The MigrationFeeOption must be a valid enum value with a valid base fee in basis points
    2. 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)
    3. The virtual pool’s migration progress must be in the LockedVesting state
    4. The pool must be “complete” based on the migration_quote_threshold (checked via is_curve_complete)
    5. The migration option must be valid and specifically set to DammV2
    6. 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
    7. Exactly one remaining account must be provided (for the DAMM V2 config)
  • You can get the dammConfig key from the README.md, or you can use DAMM_V2_MIGRATION_FEE_ADDRESS[i] to get the dammConfig key address.

Creator Functions

createPoolMetadata

Creates a new pool metadata account. Function
async createPoolMetadata(params: CreateVirtualPoolMetadataParams): Promise<Transaction>
Parameters
interface CreateVirtualPoolMetadataParams {
    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'),
})

claimCreatorTradingFee

Claims a creator trading fee. If your pool’s config key has creatorTradingFeePercentage > 0, you can use this function to claim the trading fee for the pool creator. Function
async claimCreatorTradingFee(params: ClaimCreatorTradingFeeParams): Promise<Transaction>
Parameters
interface ClaimCreatorTradingFeeParams {
    creator: PublicKey // The creator of the pool
    payer: PublicKey // The payer of the transaction
    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
    receiver?: PublicKey | null // The wallet that will receive the tokens (optional)
    tempWSolAcc?: PublicKey | null // The temporary wallet that will receive the tokens (optional)
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.creator.claimCreatorTradingFee({
    creator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
    payer: new PublicKey('payer1234567890abcdefghijklmnopqrstuvwxyz'),
    pool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
    maxBaseAmount: new BN(1000000000),
    maxQuoteAmount: new BN(1000000000),
    receiver: new PublicKey('receiver1234567890abcdefghijklmnopqrstuvwxyz'),
    tempWSolAcc: new PublicKey(
        'tempWSolAcc1234567890abcdefghijklmnopqrstuvwxyz'
    ),
})
Notes
  • The creator of the pool must be the same as the creator in the ClaimCreatorTradingFeeParams params.
  • You can indicate maxBaseAmount or maxQuoteAmount to be 0 to not claim Base or Quote tokens respectively.
  • If you indicated a receiver, the receiver is not required to sign the transaction, however, you must provide a tempWSolAcc if the receiver != creator and if the quote mint is SOL.

claimCreatorTradingFee2

Claims a creator trading fee. If your pool’s config key has creatorTradingFeePercentage > 0, you can use this function to claim the trading fee for the pool creator. Function
async claimCreatorTradingFee2(params: ClaimCreatorTradingFee2Params): Promise<Transaction>
Parameters
interface ClaimCreatorTradingFee2Params {
    creator: PublicKey // The creator of the pool
    payer: PublicKey // The payer of the transaction
    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
    receiver?: PublicKey | null // The wallet that will receive the tokens
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.creator.claimCreatorTradingFee2({
    creator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
    payer: new PublicKey('payer1234567890abcdefghijklmnopqrstuvwxyz'),
    pool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
    maxBaseAmount: new BN(1000000000),
    maxQuoteAmount: new BN(1000000000),
    receiver: new PublicKey('receiver1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
  • The creator of the pool must be the same as the creator in the ClaimCreatorTradingFee2Params params.
  • You can indicate maxBaseAmount or maxQuoteAmount to be 0 to not claim Base or Quote tokens respectively.
  • Can be used in case the creator is a squad multisig account.

creatorWithdrawSurplus

Withdraws surplus tokens from the pool. Function
async creatorWithdrawSurplus(params: CreatorWithdrawSurplusParams): Promise<Transaction>
Parameters
interface CreatorWithdrawSurplusParams {
    creator: PublicKey // The creator of the pool
    virtualPool: PublicKey // The virtual pool address
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.creator.creatorWithdrawSurplus({
    creator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
    virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
})
Notes
  • The creator of the pool must be the same as the creator in the CreatorWithdrawSurplusParams params.

creatorWithdrawMigrationFee

Withdraws the creator’s migration fee from the pool. Function
async creatorWithdrawMigrationFee(params: WithdrawMigrationFeeParams): Promise<Transaction>
Parameters
interface WithdrawMigrationFeeParams {
    virtualPool: PublicKey // The virtual pool address
    sender: PublicKey // The wallet that will claim the fee
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.creator.creatorWithdrawMigrationFee({
    virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
    sender: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
  • The sender of the pool must be the same as the creator (poolCreator) in the virtual pool.

transferPoolCreator

Transfers the pool creator to a new wallet. Function
async transferPoolCreator(params: TransferPoolCreatorParams): Promise<Transaction>
Parameters
interface TransferPoolCreatorParams {
    virtualPool: PublicKey // The virtual pool address
    creator: PublicKey // The current creator of the pool
    newCreator: PublicKey // The new creator of the pool
}
Returns
  • A transaction that can be signed and sent to the network.
Example
const transaction = await client.creator.transferPoolCreator({
    virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
    creator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
    newCreator: new PublicKey('newCreator1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
  • The creator of the pool must be the signer of the transaction.

State Functions

getPoolConfig

Gets all details about the config. Function
async getPoolConfig(configAddress: PublicKey | string): Promise<PoolConfig>
Parameters
configAddress: PublicKey | string // The address of the config key
Returns
  • A PoolConfig object containing the config key details.
Example
const config = await client.state.getPoolConfig(configAddress)

getPoolConfigs

Retrieves all configs. Function
async getPoolConfigs(): Promise<ProgramAccount<PoolConfig>[]>
Returns
  • An array of configs created by various users.
  • Check return type here.
Example
const configs = await client.state.getPoolConfigs()

getPoolConfigsByOwner

Retrieves all configs owned by a specific wallet. Function
async getPoolConfigsByOwner(owner: PublicKey | string): Promise<ProgramAccount<PoolConfig>[]>
Parameters
owner: PublicKey | string // The owner's wallet address
Returns
  • An array of configs owned by the specified wallet.
  • Check return type here.
Example
const configs = await client.state.getPoolConfigsByOwner(wallet.publicKey)

getPool

Gets the details of a specific pool. Function
async getPool(poolAddress: PublicKey | string): Promise<VirtualPool | null>
Parameters
poolAddress: PublicKey | string // The address of the pool
Returns
  • A VirtualPool object containing the pool’s details, or null if not found.
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[]
}
Example
const pool = await client.state.getPool(poolAddress)

getPools

Retrieves all pools. Function
async getPools(): Promise<ProgramAccount<VirtualPool>[]>
Returns
  • An array of all virtual pools created through DBC.
  • Check return type of VirtualPool here.
Example
const pools = await client.state.getPools()

getPoolsByConfig

Retrieves all pools by config key address. Function
async getPoolsByConfig(configAddress: PublicKey | string): Promise<ProgramAccount<VirtualPool>[]>
Parameters
configAddress: PublicKey | string // The address of the config key
Returns
  • It give all virtual pools created with a specific config key.
  • Check return type of VirtualPool here.
Example
const pools = await client.state.getPoolsByConfig(configAddress)

getPoolsByCreator

Retrieves all pools by creator address. Function
async getPoolsByCreator(creatorAddress: PublicKey | string): Promise<ProgramAccount<VirtualPool>[]>
Parameters
creatorAddress: PublicKey | string // The address of the creator
Returns
  • It give all virtual pools created with a specific wallet address.
  • Check return type of VirtualPool here.
Example
const pools = await client.state.getPoolsByCreator(creatorAddress)

getPoolByBaseMint

Gets the pool by base mint. Function
async getPoolByBaseMint(baseMint: PublicKey | string): Promise<ProgramAccount<VirtualPool> | null>
Parameters
baseMint: PublicKey | string // The address of the base mint
Returns
  • A VirtualPool object containing the pool’s details, or null if not found.
  • Check return type of VirtualPool here.
Example
const pool = await client.state.getPoolByBaseMint(baseMint)

getPoolMigrationQuoteThreshold

Gets the migration quote threshold for a specific pool. Function
async getPoolMigrationQuoteThreshold(poolAddress: PublicKey | string): Promise<BN>
Parameters
poolAddress: PublicKey | string // The address of the pool
Returns
  • A BN object representing the migration quote threshold.
Example
const threshold = await client.state.getPoolMigrationQuoteThreshold(poolAddress)

getPoolQuoteTokenCurveProgress

Gets the progress of the curve by comparing current quote reserve to migration threshold. Function
async getPoolQuoteTokenCurveProgress(poolAddress: PublicKey | string): Promise<number>
Parameters
poolAddress: PublicKey | string // The address of the pool
Returns
  • A number between 0 and 1 representing the curve progress.
Example
const progress = await client.state.getPoolQuoteTokenCurveProgress(poolAddress)

getPoolBaseTokenCurveProgress

Gets the progress of the curve based on base tokens sold relative to total base tokens available for trading. Function
async getPoolBaseTokenCurveProgress(poolAddress: PublicKey | string): Promise<number>
Parameters
poolAddress: PublicKey | string // The address of the pool
Returns
  • A number between 0 and 1 representing the curve progress.
Example
const progress = await client.state.getPoolBaseTokenCurveProgress(poolAddress)

getPoolMetadata

  • Gets the metadata for a specific pool.
  • Can only be used if metadata is set using createPoolMetadata function.
Function
async getPoolMetadata(poolAddress: PublicKey | string): Promise<VirtualPoolMetadata[]>
Parameters
poolAddress: PublicKey | string // The address of the pool
Returns
  • An array of VirtualPoolMetadata objects containing the pool’s metadata.
type VirtualPoolMetadata = {
    virtualPool: PublicKey
    padding: BN[]
    name: string
    website: string
    logo: string
}
Example
const metadata = await client.state.getPoolMetadata(poolAddress)

getPartnerMetadata

Gets the metadata for a specific partner. Function
async getPartnerMetadata(walletAddress: PublicKey | string): Promise<PartnerMetadata[]>
Parameters
walletAddress: PublicKey | string // The partner's wallet address
Returns
  • An array of PartnerMetadata objects containing the partner’s metadata.
type partnerMetadata = {
    feeClaimer: PublicKey
    padding: BN[]
    name: string
    website: string
    logo: string
}
Example
const metadata = await client.state.getPartnerMetadata(wallet.publicKey)

getDammV1LockEscrow

Gets the lock escrow details for a DAMM V1 pool. Function
async getDammV1LockEscrow(lockEscrowAddress: PublicKey | string): Promise<LockEscrow>
Parameters
lockEscrowAddress: PublicKey | string // The address of the lock escrow
Returns
  • A LockEscrow object containing the lock escrow details.
type lockEscrow = {
    pool: PublicKey
    owner: PublicKey
    escrowVault: PublicKey
    bump: number
    totalLockedAmount: BN
    lpPerToken: BN
    unclaimedFeePending: BN
    aFee: BN
    bFee: BN
}
Example
const escrow = await client.state.getDammV1LockEscrow(escrowAddress)

getDammV1MigrationMetadata

Gets the DAMM V1 migration metadata for a specific pool. Function
async getDammV1MigrationMetadata(poolAddress: PublicKey): Promise<MeteoraDammMigrationMetadata>
Parameters
poolAddress: PublicKey // The address of the DBC pool
Returns A MeteoraDammMigrationMetadata object containing the DAMM V1 migration metadata.
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[]
}
Example
const metadata = await client.state.getDammV1MigrationMetadata(poolAddress)

getPoolFeeMetrics

Gets the fee metrics for a specific pool. Function
async getPoolFeeMetrics(poolAddress: PublicKey): Promise<{
    current: {
        partnerBaseFee: BN
        partnerQuoteFee: BN
        creatorBaseFee: BN
        creatorQuoteFee: BN
    }
    total: {
        totalTradingBaseFee: BN
        totalTradingQuoteFee: BN
    }
}>
Parameters
poolAddress: PublicKey // The address of the pool
Returns
  • An object containing current and total fee metrics for the pool.
{
    current: {
        partnerBaseFee: BN
        partnerQuoteFee: BN
        creatorBaseFee: BN
        creatorQuoteFee: BN
    }
    total: {
        totalTradingBaseFee: BN
        totalTradingQuoteFee: BN
    }
}
Example
const metrics = await client.state.getPoolFeeMetrics(poolAddress)

getPoolFeeBreakdown

Gets the fee breakdown for a specific pool. Function
async getPoolFeeBreakdown(poolAddress: PublicKey): Promise<
{
    creator: {
        unclaimedBaseFee: BN
        unclaimedQuoteFee: BN
        claimedBaseFee: BN
        claimedQuoteFee: BN
        totalBaseFee: BN
        totalQuoteFee: BN
    }
    partner: {
        unclaimedBaseFee: BN
        unclaimedQuoteFee: BN
        claimedBaseFee: BN
        claimedQuoteFee: BN
        totalBaseFee: BN
        totalQuoteFee: BN
    }
}>
Parameters
poolAddress: PublicKey // The address of the pool
Returns
  • An object containing current and total fee breakdown for the pool.
{
    creator: {
        unclaimedBaseFee: BN
        unclaimedQuoteFee: BN
        claimedBaseFee: BN
        claimedQuoteFee: BN
        totalBaseFee: BN
        totalQuoteFee: BN
    }
    partner: {
        unclaimedBaseFee: BN
        unclaimedQuoteFee: BN
        claimedBaseFee: BN
        claimedQuoteFee: BN
        totalBaseFee: BN
        totalQuoteFee: BN
    }
}
Example
const breakdown = await client.state.getPoolFeeBreakdown(poolAddress)

getPoolsFeesByConfig

Gets all fees for pools linked to a specific config key. Function
async getPoolsFeesByConfig(configAddress: PublicKey): Promise<Array<FeeMetrics>>
Parameters
configAddress: PublicKey // The address of the pool config
Returns
  • An array of objects containing quote fee metrics for each pool.
type FeeMetrics = {
    poolAddress: PublicKey
    partnerBaseFee: BN
    partnerQuoteFee: BN
    creatorBaseFee: BN
    creatorQuoteFee: BN
    totalTradingBaseFee: BN
    totalTradingQuoteFee: BN
}
Example
const fees = await client.state.getPoolsFeesByConfig(configAddress)

getPoolsFeesByCreator

Gets all fees for pools linked to a specific creator. Function
async getPoolsFeesByCreator(creatorAddress: PublicKey): Promise<Array<FeeMetrics>>
Parameters
creatorAddress: PublicKey // The address of the creator
Returns
  • An array of objects containing quote fee metrics for each pool.
type FeeMetrics = {
    poolAddress: PublicKey
    partnerBaseFee: BN
    partnerQuoteFee: BN
    creatorBaseFee: BN
    creatorQuoteFee: BN
    totalTradingBaseFee: BN
    totalTradingQuoteFee: BN
}
Example
const fees = await client.state.getPoolsFeesByCreator(creatorAddress)

Helper Functions

deriveDbcPoolAddress

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 poolConfig = await client.state.getPoolConfig(configAddress)

const dammV1PoolAddress = deriveDammV1PoolAddress(
    dammConfig: DAMM_V1_MIGRATION_FEE_ADDRESS[poolConfig.migrationFeeOption],
    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 poolConfig = await client.state.getPoolConfig(configAddress)

const dammV2PoolAddress = deriveDammV2PoolAddress(
    dammConfig: DAMM_V2_MIGRATION_FEE_ADDRESS[poolConfig.migrationFeeOption],
    tokenAMint: new PublicKey('tokenA1234567890abcdefghijklmnopqrstuvwxyz'),
    tokenBMint: new PublicKey('tokenB1234567890abcdefghijklmnopqrstuvwxyz')
)

deriveDbcTokenVaultAddress

Derives the address of a DBC token vault. Function
function deriveDbcTokenVaultAddress(pool: PublicKey, mint: PublicKey): PublicKey
Parameters
pool: PublicKey // The pool address
mint: PublicKey // The mint address
Returns
  • The address of the DBC token vault.
Example
const dbcTokenVaultAddress = deriveDbcTokenVaultAddress(
    pool: new PublicKey('pool1234567890abcdefghijklmnopqrstuvwxyz'),
    mint: new PublicKey('token1234567890abcdefghijklmnopqrstuvwxyz')
)

Calculation Functions

getFeeSchedulerParams

Gets the fee scheduler parameters for a specific pool config. Function
function getFeeSchedulerParams(
    startingFeeBps: number,
    endingFeeBps: number,
    feeSchedulerMode: number,
    numberOfPeriod: number,
    totalDuration: number
): BaseFeeParams
Parameters
startingFeeBps: number // The starting fee in basis points
endingFeeBps: number // The ending fee in basis points
feeSchedulerMode: number // 0: Linear, 1: Exponential
numberOfPeriod: number // The number of periods
totalDuration: number // The total duration of the fee scheduler
Returns
  • A BaseFee object containing the calculated fee scheduler parameters.
type BaseFee = {
    cliffFeeNumerator: BN
    firstFactor: number
    secondFactor: BN
    thirdFactor: BN
    baseFeeMode: BaseFeeMode
}
Example
const baseFeeParams = getFeeSchedulerParams(
    startingFeeBps: 5000,
    endingFeeBps: 100,
    feeSchedulerMode: 1,
    numberOfPeriod: 600,
    totalDuration: 600
)
Notes
  • The totalDuration is the total duration of the fee scheduler. It must be calculated based on your activationType. If you use ActivationType.Slot, the totalDuration is denominated in terms of 400ms (slot). If you use ActivationType.Timestamp, the totalDuration is denominated in terms of 1000ms (timestamp).
  • startingFeeBps must always be greater than or equal to endingFeeBps.
  • totalDuration must always be greater than or equal to numberOfPeriod.

getRateLimiterParams

Gets the fee scheduler parameters for a specific pool config. Function
function getRateLimiterParams(
    baseFeeBps: number,
    feeIncrementBps: number,
    referenceAmount: number,
    maxLimiterDuration: number,
    tokenQuoteDecimal: TokenDecimal,
    activationType: ActivationType
): BaseFeeParams
Parameters
baseFeeBps: number // The base fee in basis points
feeIncrementBps: number // The fee increment in basis points
referenceAmount: number // The reference amount (in terms of quote token)
maxLimiterDuration: number // The max rate limiter duration
tokenQuoteDecimal: TokenDecimal // The token quote decimal
activationType: ActivationType // The activation type
Returns
  • A BaseFee object containing the calculated rate limiter parameters.
type BaseFeeParams = {
    cliffFeeNumerator: BN
    firstFactor: number
    secondFactor: BN
    thirdFactor: BN
    baseFeeMode: BaseFeeMode
}
Example
const baseFeeParams = getRateLimiterParams(
    baseFeeBps: 100,
    feeIncrementBps: 100,
    referenceAmount: 1, // 1 SOL
    maxLimiterDuration: 600, // 600 slots
    tokenQuoteDecimal: TokenDecimal.NINE,
    activationType: ActivationType.Slot
)
Notes
  • The maxLimiterDuration is the max duration of the rate limiter. It must be calculated based on your activationType. If you use ActivationType.Slot, the maxLimiterDuration is denominated in terms of 400ms (slot). If you use ActivationType.Timestamp, the maxLimiterDuration is denominated in terms of 1000ms (timestamp).
  • referenceAmount must always be greater than 0. This parameter takes into account the quoteMint decimals. For example, if you use TokenDecimal.NINE, the referenceAmount must be 1 (1 SOL).
  • maxLimiterDuration must always be greater than 0.
  • tokenQuoteDecimal must always be greater than 0.
  • activationType must always be greater than 0.
  • baseFeeBps must always be greater than 0.

getDynamicFeeParams

Gets the dynamic fee parameters for a specific pool. Calculated the fee based on the minimum base fee (capped at 20% of base fee). Please note that the maxPriceChangeBps must be less than or equal to 1500 (15%). Function
function getDynamicFeeParams(
    baseFeeBps: number,
    maxPriceChangeBps: number
): DynamicFeeParams
Parameters
baseFeeBps: number // The base fee in basis points
maxPriceChangeBps: number // The maximum price change in basis points
Returns
  • A DynamicFeeParams object containing the calculated dynamic fee parameters.
type dynamicFeeParameters = {
    binStep: number
    binStepU128: BN
    filterPeriod: number
    decayPeriod: number
    reductionFactor: number
    maxVolatilityAccumulator: number
    variableFeeControl: number
}
Example
const dynamicFeeParams = getDynamicFeeParams(
    baseFeeBps: 5000,
    maxPriceChangeBps: 1500
)

getLockedVestingParams

Gets the locked vesting parameters for a specific pool. Function
function getLockedVestingParams(
    totalLockedVestingAmount: number,
    numberOfVestingPeriod: number,
    cliffUnlockAmount: number,
    totalVestingDuration: number,
    cliffDurationFromMigrationTime: number,
    tokenBaseDecimal: TokenDecimal
): LockedVestingParams
Parameters
totalLockedVestingAmount: number // The total locked vesting amount
numberOfVestingPeriod: number // The number of vesting periods
cliffUnlockAmount: number // The amount of tokens that will be unlocked when vesting starts
totalVestingDuration: number // The total vesting duration in seconds
cliffDurationFromMigrationTime: number // The duration of the waiting time before the vesting starts
tokenBaseDecimal: TokenDecimal // The number of decimals for the base token
Returns
  • A LockedVestingParams object containing the calculated locked vesting parameters.
type LockedVestingParams = {
    amountPerPeriod: BN
    cliffDurationFromMigrationTime: BN
    frequency: BN
    numberOfPeriod: BN
    cliffUnlockAmount: BN
}
Example
const lockedVestingParams = getLockedVestingParams(
    totalLockedVestingAmount: 100000000,
    numberOfVestingPeriod: 600,
    cliffUnlockAmount: 1000,
    totalVestingDuration: 600,
    cliffDurationFromMigrationTime: 600,
    tokenBaseDecimal: 6,
)
Notes
  • The totalVestingDuration is the total duration of the vesting. It must be calculated in terms of seconds => 1000ms (timestamp).

getQuoteReserveFromNextSqrtPrice

Gets the quote reserve from the next sqrt price instead of getting from the pool state. Function
function getQuoteReserveFromNextSqrtPrice(
    nextSqrtPrice: BN,
    config: PoolConfig
): BN
Parameters
nextSqrtPrice: BN // The next sqrt price that you can fetch from swap cpi logs
config: PoolConfig // The pool config
Returns
  • A BN object containing the calculated quote reserve.
Example
const poolConfig = await client.state.getPoolConfig(configAddress)

const quoteReserve = getQuoteReserveFromNextSqrtPrice(
    nextSqrtPrice: new BN('13663931917038696),
    config: poolConfig
)
Notes
  • The nextSqrtPrice is the next sqrt price that you can fetch from swap cpi logs.
  • The config is the pool config that the token pool used to launch.