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(createConfigParam: CreateConfigParam): Promise<Transaction>
Parameters
interface CreateConfigParam {
payer: PublicKey // The wallet paying for the transaction
config: PublicKey // The config account address (generated by the partner)
feeClaimer: PublicKey // The wallet that will be able to claim the fee
leftoverReceiver: PublicKey // The wallet that will receive the bonding curve leftover
quoteMint: PublicKey // The quote mint address
poolFees: {
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
}
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Quote Token, 1: Output Token
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenType: number // 0: SPL, 1: Token2022
tokenDecimal: number // The number of decimals for the token
migrationQuoteThreshold: BN // The quote threshold for migration
partnerLpPercentage: number // The percentage of the LP that will be allocated to the partner in the graduated pool (0-100)
creatorLpPercentage: number // The percentage of the LP that will be allocated to the creator in the graduated pool (0-100)
partnerLockedLpPercentage: number // The percentage of the locked LP that will be allocated to the partner in the graduated pool (0-100)
creatorLockedLpPercentage: number // The percentage of the locked LP that will be allocated to the creator in the graduated pool (0-100)
sqrtStartPrice: BN // The starting price of the pool
lockedVesting: {
// Optional locked vesting (BN (0) for all fields for no vesting)
amountPerPeriod: BN // The amount of tokens that will be vested per period
cliffDurationFromMigrationTime: BN // The duration of the 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
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-50)
creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
}
padding0: []
padding1: []
curve: {
// The curve of the pool
sqrtPrice: BN // The square root of the curve point price
liquidity: BN // The liquidity of the curve point
}[]
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.createConfig({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
leftoverReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
poolFees: {
baseFee: {
cliffFeeNumerator: new BN('2500000'),
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'),
partnerLpPercentage: 25,
creatorLpPercentage: 25,
partnerLockedLpPercentage: 25,
creatorLockedLpPercentage: 25,
sqrtStartPrice: new BN('58333726687135158'),
lockedVesting: {
amountPerPeriod: new BN('0'),
cliffDurationFromMigrationTime: new BN('0'),
frequency: new BN('0'),
numberOfPeriod: new BN('0'),
cliffUnlockAmount: new BN('0'),
},
migrationFeeOption: 0,
tokenSupply: {
preMigrationTokenSupply: new BN('10000000000000000000'),
postMigrationTokenSupply: new BN('10000000000000000000'),
},
creatorTradingFeePercentage: 0,
tokenUpdateAuthority: 1,
migrationFee: {
feePercentage: 25,
creatorFeePercentage: 50,
},
padding0: [],
padding1: [],
curve: [
{
sqrtPrice: new BN('233334906748540631'),
liquidity: new BN('622226417996106429201027821619672729'),
},
{
sqrtPrice: new BN('79226673521066979257578248091'),
liquidity: new BN('1'),
},
],
})
Notes
When creating a new configuration for a dynamic bonding curve, several validations are performed to ensure the parameters are valid:
Pool Fees
- 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 Quote Token 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
Quote Token
(0) or Output Token
(1)
Migration and Token Type
- For migration to DAMM v1 (MigrationOption: 0), token type must be type SPL (TokenType: 0)
Activation Type
- Must be either Slot (0) or Timestamp (1)
Migration Fee
- Must be a valid option: FixedBps25 (0), FixedBps30 (1), FixedBps100 (2), FixedBps200 (3), FixedBps400 (4), FixedBps600 (5)
- Migration fee percentage must be between 0 and 50
- Creator fee percentage must be between 0 and 100
Token Decimals
LP Percentages
- The sum of partner LP, creator LP, partner locked LP, and creator locked LP percentages must equal 100(%)
Migration Quote Threshold
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)
Creates a new partner metadata account. This partner metadata will be tagged to a wallet address that holds the config keys.
Function
async createPartnerMetadata(createPartnerMetadataParam: CreatePartnerMetadataParam): Promise<Transaction>
Parameters
interface CreatePartnerMetadataParam {
name: string // The name of the partner
website: string // The website of the partner
logo: string // The logo of the partner
feeClaimer: PublicKey // The wallet that will be able to claim the fee
payer: PublicKey // The wallet that will pay for the transaction
}
Returns
A transaction that can be signed and sent to the network.
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(claimTradingFeeParam: ClaimTradingFeeParam): Promise<Transaction>
Parameters
interface ClaimTradingFeeParam {
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(claimTradingFee2Param: ClaimTradingFee2Param): Promise<Transaction>
Parameters
interface ClaimTradingFeeParam {
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(withdrawMigrationFeeParam: WithdrawMigrationFeeParam): Promise<Transaction>
Parameters
interface WithdrawMigrationFeeParam {
virtualPool: PublicKey // The virtual pool address
sender: PublicKey // The wallet that will claim the fee
feePayer?: 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.partnerWithdrawMigrationFee({
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
sender: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
feePayer: 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(partnerWithdrawSurplusParam: PartnerWithdrawSurplusParam): Promise<Transaction>
Parameters
interface PartnerWithdrawSurplusParam {
feeClaimer: PublicKey // The wallet that will claim the fee
virtualPool: PublicKey // The virtual pool address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.partner.partnerWithdrawSurplus({
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
})
Notes
- The feeClaimer of the pool must be the same as the feeClaimer in the
PartnerWithdrawSurplusParam
params.
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
async buildCurve(buildCurveParam: BuildCurveParam): Promise<ConfigParameters>
Parameters
interface BuildCurveParam {
totalTokenSupply: number // The total token supply
percentageSupplyOnMigration: number // The percentage of the supply that will be migrated
migrationQuoteThreshold: number // The quote threshold for migration
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenBaseDecimal: number // The number of decimals for the base token
tokenQuoteDecimal: number // The number of decimals for the quote token
lockedVestingParam: {
// Optional locked vesting (0 for all fields for no vesting)
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
}
// Either FeeSchedulerLinear/FeeSchedulerExponential mode
baseFeeParams: {
baseFeeMode: 0 | 1 // 0: FeeSchedulerLinear, 1: 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
baseFeeParams: {
baseFeeMode: 2 // 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
}
}
dynamicFeeEnabled: boolean // Whether dynamic fee is enabled (true: enabled, false: disabled)
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Quote Token, 1: Output Token
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenType: number // 0: SPL, 1: Token2022
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
leftover: number // The leftover amount that can be withdrawn by leftover receiver
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-50)
creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
}
}
Returns
A ConfigParameters
object.
Example
const curveConfig = buildCurve({
totalTokenSupply: 1000000000,
percentageSupplyOnMigration: 10,
migrationQuoteThreshold: 300,
migrationOption: MigrationOption.MET_DAMM_V2,
tokenBaseDecimal: TokenDecimal.SIX,
tokenQuoteDecimal: TokenDecimal.NINE,
lockedVestingParam: {
totalLockedVestingAmount: 0,
numberOfVestingPeriod: 0,
cliffUnlockAmount: 0,
totalVestingDuration: 0,
cliffDurationFromMigrationTime: 0,
},
baseFeeParams: {
baseFeeMode: BaseFeeMode.FeeSchedulerLinear,
feeSchedulerParam: {
startingFeeBps: 100,
endingFeeBps: 100,
numberOfPeriod: 0,
totalDuration: 0,
},
},
dynamicFeeEnabled: true,
activationType: ActivationType.Slot,
collectFeeMode: CollectFeeMode.QuoteToken,
migrationFeeOption: MigrationFeeOption.FixedBps100,
tokenType: TokenType.SPL,
partnerLpPercentage: 0,
creatorLpPercentage: 0,
partnerLockedLpPercentage: 100,
creatorLockedLpPercentage: 0,
creatorTradingFeePercentage: 0,
leftover: 10000,
tokenUpdateAuthority: 1,
migrationFee: {
feePercentage: 0,
creatorFeePercentage: 0,
},
})
const transaction = await client.partner.createConfig({
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
leftoverReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
...curveConfig,
})
Notes
buildCurve
helps you to 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.
lockedVestingParam.totalVestingDuration
and lockedVestingParam.cliffDurationFromMigrationTime
are calculated in terms of seconds.
feeSchedulerParam.totalDuration
is calculated based on your activationType
and activationTime
.
- Slot is 400ms, Timestamp is 1000ms.
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
async buildCurveWithMarketCap(buildCurveWithMarketCapParam: BuildCurveWithMarketCapParam): Promise<ConfigParameters>
Parameters
interface BuildCurveWithMarketCapParam {
totalTokenSupply: number // The total token supply
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
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenBaseDecimal: number // The number of decimals for the base token
tokenQuoteDecimal: number // The number of decimals for the quote token
lockedVestingParam: {
// Optional locked vesting (0 for all fields for no vesting)
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
}
// Either FeeSchedulerLinear/FeeSchedulerExponential mode
baseFeeParams: {
baseFeeMode: 0 | 1 // 0: FeeSchedulerLinear, 1: 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
baseFeeParams: {
baseFeeMode: 2 // 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
}
}
dynamicFeeEnabled: boolean // Whether dynamic fee is enabled (true: enabled, false: disabled)
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Quote Token, 1: Output Token
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenType: number // 0: SPL, 1: Token2022
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
leftover: number // The leftover amount that can be withdrawn by leftover receiver
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-50)
creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
}
}
Returns
A ConfigParameters
object.
Example
const curveConfig = buildCurveWithMarketCap({
totalTokenSupply: 1000000000,
initialMarketCap: 100,
migrationMarketCap: 3000,
migrationOption: MigrationOption.MET_DAMM_V2,
tokenBaseDecimal: TokenDecimal.SIX,
tokenQuoteDecimal: TokenDecimal.NINE,
lockedVestingParam: {
totalLockedVestingAmount: 0,
numberOfVestingPeriod: 0,
cliffUnlockAmount: 0,
totalVestingDuration: 0,
cliffDurationFromMigrationTime: 0,
},
baseFeeParams: {
baseFeeMode: BaseFeeMode.FeeSchedulerLinear,
feeSchedulerParam: {
startingFeeBps: 100,
endingFeeBps: 100,
numberOfPeriod: 0,
totalDuration: 0,
},
},
dynamicFeeEnabled: true,
activationType: ActivationType.Slot,
collectFeeMode: CollectFeeMode.QuoteToken,
migrationFeeOption: MigrationFeeOption.FixedBps100,
tokenType: TokenType.SPL,
partnerLpPercentage: 0,
creatorLpPercentage: 0,
partnerLockedLpPercentage: 100,
creatorLockedLpPercentage: 0,
creatorTradingFeePercentage: 0,
leftover: 0,
tokenUpdateAuthority: 1,
migrationFee: {
feePercentage: 0,
creatorFeePercentage: 0,
},
})
const transaction = await client.partner.createConfig({
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
leftoverReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
...curveConfig,
})
Notes
buildCurveWithMarketCap
helps you to 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.
lockedVestingParam.totalVestingDuration
and lockedVestingParam.cliffDurationFromMigrationTime
are calculated in terms of seconds.
feeSchedulerParam.totalDuration
is calculated based on your activationType
and activationTime
.
- Slot is 400ms, Timestamp is 1000ms.
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
async buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam: BuildCurveWithTwoSegmentsParam): Promise<ConfigParameters>
Parameters
interface BuildCurveWithTwoSegmentsParam {
totalTokenSupply: number // The total token supply
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
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenBaseDecimal: number // The number of decimals for the base token
tokenQuoteDecimal: number // The number of decimals for the quote token
lockedVestingParam: {
// Optional locked vesting (0 for all fields for no vesting)
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
}
// Either FeeSchedulerLinear/FeeSchedulerExponential mode
baseFeeParams: {
baseFeeMode: 0 | 1 // 0: FeeSchedulerLinear, 1: 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
baseFeeParams: {
baseFeeMode: 2 // 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
}
}
dynamicFeeEnabled: boolean // Whether dynamic fee is enabled (true: enabled, false: disabled)
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Quote Token, 1: Output Token
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenType: number // 0: SPL, 1: Token2022
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
leftover: number // The leftover amount that can be withdrawn by leftover receiver
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-50)
creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
}
}
Returns
A ConfigParameters
object.
Example
const curveConfig = buildCurveWithTwoSegments({
totalTokenSupply: 1000000000,
initialMarketCap: 5000,
migrationMarketCap: 1000000,
percentageSupplyOnMigration: 10,
migrationOption: MigrationOption.MET_DAMM_V2,
tokenBaseDecimal: TokenDecimal.SIX,
tokenQuoteDecimal: TokenDecimal.SIX,
lockedVestingParam: {
totalLockedVestingAmount: 0,
numberOfVestingPeriod: 0,
cliffUnlockAmount: 0,
totalVestingDuration: 0,
cliffDurationFromMigrationTime: 0,
},
baseFeeParams: {
baseFeeMode: BaseFeeMode.FeeSchedulerLinear,
feeSchedulerParam: {
startingFeeBps: 100,
endingFeeBps: 100,
numberOfPeriod: 0,
totalDuration: 0,
},
},
dynamicFeeEnabled: true,
activationType: ActivationType.Slot,
collectFeeMode: CollectFeeMode.QuoteToken,
migrationFeeOption: MigrationFeeOption.FixedBps100,
tokenType: TokenType.SPL,
partnerLpPercentage: 100,
creatorLpPercentage: 0,
partnerLockedLpPercentage: 0,
creatorLockedLpPercentage: 0,
creatorTradingFeePercentage: 0,
leftover: 1000,
tokenUpdateAuthority: 1,
migrationFee: {
feePercentage: 0,
creatorFeePercentage: 0,
},
})
const transaction = await client.partner.createConfig({
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
leftoverReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
...curveConfig,
})
Notes
buildCurveWithTwoSegments
helps you to 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.
lockedVestingParam.totalVestingDuration
and lockedVestingParam.cliffDurationFromMigrationTime
are calculated in terms of seconds.
feeSchedulerParam.totalDuration
is calculated based on your activationType
and activationTime
.
- Slot is 400ms, Timestamp is 1000ms.
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
async buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam: BuildCurveWithLiquidityWeightsParam): Promise<ConfigParameters>
Parameters
interface BuildCurveWithLiquidityWeightsParam {
totalTokenSupply: number // The total token supply
initialMarketCap: number // The initial market cap
migrationMarketCap: number // The migration market cap
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenBaseDecimal: number // The number of decimals for the base token
tokenQuoteDecimal: number // The number of decimals for the quote token
lockedVestingParam: {
// Optional locked vesting (0 for all fields for no vesting)
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
}
// Either FeeSchedulerLinear/FeeSchedulerExponential mode
baseFeeParams: {
baseFeeMode: 0 | 1 // 0: FeeSchedulerLinear, 1: 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
baseFeeParams: {
baseFeeMode: 2 // 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
}
}
dynamicFeeEnabled: boolean // Whether dynamic fee is enabled (true: enabled, false: disabled)
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Quote Token, 1: Output Token
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenType: number // 0: SPL, 1: Token2022
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
leftover: number // The leftover amount that can be withdrawn by leftover receiver
liquidityWeights: number[] // The liquidity weights for each liquidity segment in the curve
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-50)
creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
}
}
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({
totalTokenSupply: 1000000000,
initialMarketCap: 5000,
migrationMarketCap: 1000000,
migrationOption: MigrationOption.MET_DAMM_V2,
tokenBaseDecimal: TokenDecimal.SIX,
tokenQuoteDecimal: TokenDecimal.SIX,
lockedVestingParam: {
totalLockedVestingAmount: 0,
numberOfVestingPeriod: 0,
cliffUnlockAmount: 0,
totalVestingDuration: 0,
cliffDurationFromMigrationTime: 0,
},
baseFeeParams: {
baseFeeMode: BaseFeeMode.FeeSchedulerLinear,
feeSchedulerParam: {
startingFeeBps: 100,
endingFeeBps: 100,
numberOfPeriod: 0,
totalDuration: 0,
},
},
dynamicFeeEnabled: true,
activationType: ActivationType.Slot,
collectFeeMode: CollectFeeMode.QuoteToken,
migrationFeeOption: MigrationFeeOption.FixedBps100,
tokenType: TokenType.SPL,
partnerLpPercentage: 100,
creatorLpPercentage: 0,
partnerLockedLpPercentage: 0,
creatorLockedLpPercentage: 0,
creatorTradingFeePercentage: 0,
leftover: 1000,
liquidityWeights,
tokenUpdateAuthority: 1,
migrationFee: {
feePercentage: 0,
creatorFeePercentage: 0,
},
})
const transaction = await client.partner.createConfig({
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
feeClaimer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
leftoverReceiver: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
...curveConfig,
})
Notes
buildCurveWithLiquidityWeights
helps you to 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
All liquidityWeights[i] === 1
: All segments have the same liquidity. The curve is linear.
liquidityWeights[i] < liquidityWeights[i+1]
: Lower liquidity at lower prices.
- This means that the price will move more for a given trade at lower prices (less resistance), and price will move less for a given trade at higher prices (more resistance).
liquidityWeights[i] > liquidityWeights[i+1]
: Higher liquidity at lower prices.
- This means that the price will move less for a given trade at lower prices (more resistance), and price will move more for a given trade at higher prices (less resistance).
- If
dynamicFeeEnabled
is true, the dynamic fee will be enabled and capped at 20% of minimum base fee.
lockedVestingParam.totalVestingDuration
and lockedVestingParam.cliffDurationFromMigrationTime
are calculated in terms of seconds.
feeSchedulerParam.totalDuration
is calculated based on your activationType
and activationTime
.
- Slot is 400ms, Timestamp is 1000ms.
Pool Functions
createPool
Creates a new pool with the config key.
Function
async createPool(createPoolParam: CreatePoolParam): Promise<Transaction>
Parameters
interface 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
}
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(createConfigAndPoolParam: CreateConfigAndPoolParam): Promise<Transaction>
Parameters
interface CreateConfigAndPoolParam {
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, put null if you don't want to use dynamic fee
binStep: number // u16 value representing the bin step in bps
binStepU128: BN // u128 value for a more accurate bin step
filterPeriod: number // Minimum time that must pass between fee updates
decayPeriod: number // Period after the volatility starts decaying (must be > filterPeriod)
reductionFactor: number // Controls how quickly volatility decys over time
variableFeeControl: number // Multiplier that determines how much volatility affects fees
maxVolatilityAccumulator: number // Caps the maximum volatility that can be accumulated
} | null
}
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Quote Token, 1: Output Token
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenType: number // 0: SPL, 1: Token2022
tokenDecimal: number // The number of decimals for the token
migrationQuoteThreshold: BN // The quote threshold for migration
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner (0-100)
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator (0-100)
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked (0-100)
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked (0-100)
sqrtStartPrice: BN // The starting price of the pool
lockedVesting: {
// Optional locked vesting (BN (0) for all fields for no vesting)
amountPerPeriod: BN // The amount of tokens that will be vested per period
cliffDurationFromMigrationTime: BN // The duration of the cliff period
frequency: BN // The frequency of the vesting
numberOfPeriod: BN // The number of periods
cliffUnlockAmount: BN // The amount of tokens that will be unlocked at the cliff
}
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenSupply: {
// Optional token supply
preMigrationTokenSupply: BN // The token supply before migration
postMigrationTokenSupply: BN // The token supply after migration
} | null
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
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-50)
creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
}
padding0: []
padding1: []
curve: {
// The curve of the pool
sqrtPrice: BN // The square root of the curve point price
liquidity: BN // The liquidity of the curve point
}[]
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('2500000'),
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'),
partnerLpPercentage: 25,
creatorLpPercentage: 25,
partnerLockedLpPercentage: 25,
creatorLockedLpPercentage: 25,
sqrtStartPrice: new BN('58333726687135158'),
lockedVesting: {
amountPerPeriod: new BN('0'),
cliffDurationFromMigrationTime: new BN('0'),
frequency: new BN('0'),
numberOfPeriod: new BN('0'),
cliffUnlockAmount: new BN('0'),
},
migrationFeeOption: 0,
tokenSupply: {
preMigrationTokenSupply: new BN('10000000000000000000'),
postMigrationTokenSupply: new BN('10000000000000000000'),
},
creatorTradingFeePercentage: 0,
tokenUpdateAuthority: 1,
migrationFee: {
feePercentage: 25,
creatorFeePercentage: 50,
},
padding0: [],
padding1: [],
curve: [
{
sqrtPrice: new BN('233334906748540631'),
liquidity: new BN('622226417996106429201027821619672729'),
},
{
sqrtPrice: new BN('79226673521066979257578248091'),
liquidity: new BN('1'),
},
],
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 in a single transaction.
Function
async createConfigAndPoolWithFirstBuy(createConfigAndPoolWithFirstBuyParam: CreateConfigAndPoolWithFirstBuyParam): Promise<{
createConfigTx: Transaction
createPoolTx: Transaction
swapBuyTx: Transaction | undefined
}>
Parameters
interface CreateConfigAndPoolWithFirstBuyParam {
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
}
activationType: number // 0: Slot, 1: Timestamp
collectFeeMode: number // 0: Quote Token, 1: Output Token
migrationOption: number // 0: DAMM V1, 1: DAMM v2
tokenType: number // 0: SPL, 1: Token2022
tokenDecimal: number // The number of decimals for the token
migrationQuoteThreshold: BN // The quote threshold for migration
partnerLpPercentage: number // The percentage of the pool that will be allocated to the partner (0-100)
creatorLpPercentage: number // The percentage of the pool that will be allocated to the creator (0-100)
partnerLockedLpPercentage: number // The percentage of the pool that will be allocated to the partner locked (0-100)
creatorLockedLpPercentage: number // The percentage of the pool that will be allocated to the creator locked (0-100)
sqrtStartPrice: BN // The starting price of the pool
lockedVesting: {
// Optional locked vesting (BN (0) for all fields for no vesting)
amountPerPeriod: BN // The amount of tokens that will be vested per period
cliffDurationFromMigrationTime: BN // The duration of the cliff period
frequency: BN // The frequency of the vesting
numberOfPeriod: BN // The number of periods
cliffUnlockAmount: BN // The amount of tokens that will be unlocked at the cliff
}
migrationFeeOption: number // 0: Fixed 25bps, 1: Fixed 30bps, 2: Fixed 100bps, 3: Fixed 200bps, 4: Fixed 400bps, 5: Fixed 600bps
tokenSupply: {
// Optional token supply
preMigrationTokenSupply: BN // The token supply before migration
postMigrationTokenSupply: BN // The token supply after migration
} | null
creatorTradingFeePercentage: number // The percentage of the trading fee that will be allocated to the creator
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-50)
creatorFeePercentage: number // The fee share percentage for the creator from the migration fee (0-100)
}
padding0: []
padding1: []
curve: {
// The curve of the pool
sqrtPrice: BN // The square root of the curve point price
liquidity: BN // The liquidity of the curve point
}[]
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
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, createPoolTx, and swapBuyTx) that requires signatures before being submitted to the network. Can be bundled together.
Example
const transaction = 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('2500000'),
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'),
partnerLpPercentage: 25,
creatorLpPercentage: 25,
partnerLockedLpPercentage: 25,
creatorLockedLpPercentage: 25,
sqrtStartPrice: new BN('58333726687135158'),
lockedVesting: {
amountPerPeriod: new BN('0'),
cliffDurationFromMigrationTime: new BN('0'),
frequency: new BN('0'),
numberOfPeriod: new BN('0'),
cliffUnlockAmount: new BN('0'),
},
migrationFeeOption: 0,
tokenSupply: {
preMigrationTokenSupply: new BN('10000000000000000000'),
postMigrationTokenSupply: new BN('10000000000000000000'),
},
creatorTradingFeePercentage: 0,
tokenUpdateAuthority: 1,
migrationFee: {
feePercentage: 25,
creatorFeePercentage: 50,
},
padding0: [],
padding1: [],
curve: [
{
sqrtPrice: new BN('233334906748540631'),
liquidity: new BN('622226417996106429201027821619672729'),
},
{
sqrtPrice: new BN('79226673521066979257578248091'),
liquidity: new BN('1'),
},
],
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: new BN(0.1 * 1e9),
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 the
firstBuyParam
is not provided, the swapBuyTx
will be undefined.
- The
swapBuyTx
requires the buyer and payer to sign the transaction.
createPoolWithFirstBuy
Creates a new pool with the config key and buys the token immediately.
Function
async createPoolWithFirstBuy(createPoolWithFirstBuyParam: CreatePoolWithFirstBuyParam): Promise<{
createPoolTx: Transaction
swapBuyTx: Transaction | undefined
}>
Parameters
interface CreatePoolWithFirstBuyParam {
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
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 createPoolTx and swapBuyTx) that requires signatures before being submitted to the network. Can be bundled together.
Example
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: new BN(0.1 * 1e9),
minimumAmountOut: new BN(1),
referralTokenAccount: null,
},
})
Notes
- The
poolCreator
is required to sign when creating the pool.
- The
buyer
is required to sign when buying the token.
- 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.
createPoolWithPartnerAndCreatorFirstBuy
Creates a new pool with the config key and buys the token immediately with partner and creator.
Function
async createPoolWithPartnerAndCreatorFirstBuy(createPoolWithPartnerAndCreatorFirstBuyParam: CreatePoolWithPartnerAndCreatorFirstBuyParam): Promise<{
createPoolTx: Transaction
partnerSwapBuyTx: Transaction | undefined
creatorSwapBuyTx: Transaction | undefined
}>
Parameters
interface CreatePoolWithPartnerAndCreatorFirstBuyParam {
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
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
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 createPoolTx, partnerSwapBuyTx, and creatorSwapBuyTx) that requires signatures before being submitted to the network. Can be bundled together.
Example
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'),
buyAmount: new BN(0.1 * 1e9),
minimumAmountOut: new BN(1),
referralTokenAccount: null,
},
creatorFirstBuyParam: {
creator: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
buyAmount: new BN(0.1 * 1e9),
minimumAmountOut: new BN(1),
referralTokenAccount: null,
},
})
Notes
- The
poolCreator
is required to sign when creating the pool.
- The
partner
is required to sign when buying the token.
- The
creator
is required to sign when buying the token.
- 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(swapParam: SwapParam): Promise<Transaction>
Parameters
interface SwapParam {
owner: PublicKey // The person swapping the tokens
amountIn: BN // The amount of quote or base tokens to swap
minimumAmountOut: BN // The minimum amount of quote or base tokens to receive
swapBaseForQuote: boolean // Whether to swap base for quote. true = swap base for quote, false = swap quote for base
poolAddress: PublicKey // The pool address
referralTokenAccount: PublicKey | null // The referral token account (optional)
payer?: PublicKey // The payer of the transaction (optional)
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.pool.swap({
owner: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
amountIn: new BN(1000000000),
minimumAmountOut: new BN(0),
swapBaseForQuote: false,
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 swap quotation between base and quote swaps or quote and base swaps.
Function
swapQuote(swapQuoteParam: SwapQuoteParam): Promise<QuoteResult>
Parameters
interface SwapQuoteParam {
virtualPool: VirtualPool
config: PoolConfig
swapBaseForQuote: boolean
amountIn: BN
slippageBps?: number
hasReferral: boolean
currentPoint: BN
}
Returns
The quote result of the swap.
Example
const virtualPoolState = await client.state.getPool(poolAddress)
const poolConfigState = await client.state.getPoolConfig(
virtualPoolState.config
)
const currentSlot = await connection.getSlot()
const quote = await client.pool.swapQuote({
virtualPool: virtualPoolState, // The virtual pool state
config: poolConfigState, // The pool config state
swapBaseForQuote: false, // Whether to swap base for quote
amountIn: new BN(100000000), // The amount of tokens to swap
slippageBps: 100, // The slippage in basis points (optional)
hasReferral: false, // Whether to include a referral fee
currentPoint: new BN(currentSlot), // The current point
})
Notes
- The
swapBaseForQuote
parameter determines the direction of the swap:
true
: Swap base tokens for quote tokens
false
: Swap quote tokens for base tokens
- The
amountIn
is the amount of tokens you want to swap, denominated in the smallest unit and token decimals. (e.g., lamports for SOL).
- The
slippageBps
parameter is the slippage in basis points (optional). This will calculate the minimum amount out based on the slippage.
- The
hasReferral
parameter indicates whether a referral fee should be included in the calculation.
- The
currentPoint
parameter is typically used in cases where the config has applied a fee scheduler. If activationType == 0, then it is current slot. If activationType == 1, then it is the current block timestamp. You can fill in accordingly based on slot or timestamp.
swapQuoteExactIn
Gets the exact swap quotation in between quote and base swaps.
Function
swapQuoteExactIn(swapQuoteExactInParam: SwapQuoteExactInParam): Promise<QuoteResult>
Parameters
interface SwapQuoteExactInParam {
virtualPool: VirtualPool
config: PoolConfig
currentPoint: BN
}
Returns
The exact quote in result of the swap.
Example
const virtualPoolState = await client.state.getPool(poolAddress)
const poolConfigState = await client.state.getPoolConfig(
virtualPoolState.config
)
const currentSlot = await connection.getSlot()
const quote = await client.pool.swapQuoteExactIn({
virtualPool: virtualPoolState, // The virtual pool state
config: poolConfigState, // The pool config state
currentPoint: new BN(currentSlot), // The current point
})
Notes
- This function helps to get the exact number of quote tokens to swap to hit the
migrationQuoteThreshold
in the config key.
- The
currentPoint
parameter is typically used in cases where the config has applied a fee scheduler. If activationType == 0, then it is current slot. If activationType == 1, then it is the current block timestamp. You can fill in accordingly based on slot or timestamp.
swapQuoteExactOut
Gets the exact swap out quotation in between quote and base swaps.
Function
swapQuoteExactOut(swapQuoteExactOutParam: SwapQuoteExactOutParam): Promise<QuoteResult>
Parameters
interface SwapQuoteExactOutParam {
virtualPool: VirtualPool
config: PoolConfig
swapBaseForQuote: boolean
outAmount: BN
slippageBps?: number
hasReferral: boolean
currentPoint: BN
}
Returns
The exact quote out result of the swap.
Example
const virtualPoolState = await client.state.getPool(poolAddress)
const poolConfigState = await client.state.getPoolConfig(
virtualPoolState.config
)
let currentPoint: BN
if (poolConfigState.activationType === 0) {
// Slot
const currentSlot = await connection.getSlot()
currentPoint = new BN(currentSlot)
} else {
// Timestamp
const currentSlot = await connection.getSlot()
const currentTime = await connection.getBlockTime(currentSlot)
currentPoint = new BN(currentTime || 0)
}
const quote = await client.pool.swapQuoteExactOut({
virtualPool: virtualPoolState,
config: poolConfigState,
swapBaseForQuote: false,
outAmount: new BN(100000000),
slippageBps: 0,
hasReferral: false,
currentPoint,
})
Notes
- This function helps to get the exact number of input tokens to swap to get the exact output amount.
- The
currentPoint
parameter is typically used in cases where the config has applied a fee scheduler. If activationType == 0, then it is current slot. If activationType == 1, then it is the current block timestamp. You can fill in accordingly based on slot or timestamp.
Migration Functions
Flow of migration
DAMM V1
createDammV1MigrationMetadata
createLocker
(if the token has locked vesting)
migrateToDammV1
lockDammV1LpToken
(if creatorLockedLpPercentage
or partnerLockedLpPercentage
is >0)
claimDammV1LpToken
(if creatorLpPercentage
or partnerLpPercentage
is >0)
DAMM V2
createDammV2MigrationMetadata
createLocker
(if the token has locked vesting)
migrateToDammV2
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(createLockerParam: CreateLockerParam): Promise<Transaction>
Parameters
interface CreateLockerParam {
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(withdrawLeftoverParam: WithdrawLeftoverParam): Promise<Transaction>
Parameters
interface WithdrawLeftoverParam {
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.
Creates a new DAMM V1 migration metadata account.
Function
async createDammV1MigrationMetadata(createDammV1MigrationMetadataParam: CreateDammV1MigrationMetadataParam): Promise<Transaction>
Parameters
interface CreateDammV1MigrationMetadataParam {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
config: PublicKey // The config address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.createDammV1MigrationMetadata({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
- This function must be called before
migrateToDammV1
.
migrateToDammV1
Migrates the Dynamic Bonding Curve pool to DAMM V1.
Function
async migrateToDammV1(migrateToDammV1Param: MigrateToDammV1Param): Promise<Transaction>
Parameters
interface MigrateToDammV1Param {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
dammConfig: PublicKey // The damm graduation fee config address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.migrateToDammV1({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
dammConfig: new PublicKey('8f848CEy8eY6PhJ3VcemtBDzPPSD4Vq7aJczLZ3o8MmX'),
})
Notes
- Ensure that when attempting to migrate the virtual pool, all these validation checks have already been met:
- The
MigrationFeeOption
must be a valid enum value with a valid base fee in basis points
- The pool’s config account must have:
- pool_creator_authority matching the pool_authority key
- activation_duration set to 0
- partner_fee_numerator set to 0
- vault_config_key set to the default Pubkey (all zeros)
- The virtual pool’s migration progress must be in the LockedVesting state
- The pool must be “complete” based on the migration_quote_threshold (checked via is_curve_complete)
- The migration option must be valid and specifically set to MeteoraDamm
- The account relationships must be valid:
- virtual_pool must have matching base_vault and quote_vault
- virtual_pool must have a matching config
- migration_metadata must have a matching virtual_pool
- 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(lockDammV1LpTokenParam: DammLpTokenParam): Promise<Transaction>
Parameters
interface DammLpTokenParam {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
dammConfig: PublicKey // The damm graduation fee config address
isPartner: boolean // Whether the LP token is a partner
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.lockDammV1LpToken({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
dammConfig: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
isPartner: true,
})
Notes
- This function is called when the
creatorLockedLpPercentage
or partnerLockedLpPercentage
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(claimDammV1LpTokenParam: DammLpTokenParam): Promise<Transaction>
Parameters
interface DammLpTokenParam {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
dammConfig: PublicKey // The damm graduation fee config address
isPartner: boolean // Whether the LP token is a partner
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.claimDammV1LpToken({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
dammConfig: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
isPartner: true,
})
Notes
- This function is called when the
creatorLpPercentage
or partnerLpPercentage
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.
Creates a new DAMM V2 migration metadata account.
Function
async createDammV2MigrationMetadata(createDammV2MigrationMetadataParam: CreateDammV2MigrationMetadataParam): Promise<Transaction>
Parameters
interface CreateDammV2MigrationMetadataParam {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
config: PublicKey // The config address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.createDammV2MigrationMetadata({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
config: new PublicKey('1234567890abcdefghijklmnopqrstuvwxyz'),
})
Notes
- This function must be called before
migrateToDammV2
.
migrateToDammV2
Migrates the Dynamic Bonding Curve pool to DAMM V2.
Function
async migrateToDammV2(migrateToDammV2Param: MigrateToDammV2Param): Promise<Transaction>
Parameters
interface MigrateToDammV2Param {
payer: PublicKey // The payer of the transaction
virtualPool: PublicKey // The virtual pool address
dammConfig: PublicKey // The damm graduation fee config address
}
Returns
A transaction that can be signed and sent to the network.
Example
const transaction = await client.migration.migrateToDammV2({
payer: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
dammConfig: new PublicKey('7F6dnUcRuyM2TwR8myT1dYypFXpPSxqwKNSFNkxyNESd'),
})
Notes
- Ensure that when attempting to migrate the virtual pool, all these validation checks have already been met:
- The
MigrationFeeOption
must be a valid enum value with a valid base fee in basis points
- The pool’s config account must have:
- pool_creator_authority matching the pool_authority key
- partner_fee_percent set to 0
- sqrt_min_price equal to MIN_SQRT_PRICE
- sqrt_max_price equal to MAX_SQRT_PRICE
- vault_config_key set to the default Pubkey (all zeros)
- The virtual pool’s migration progress must be in the LockedVesting state
- The pool must be “complete” based on the migration_quote_threshold (checked via is_curve_complete)
- The migration option must be valid and specifically set to DammV2
- The account relationships must be valid:
- virtual_pool must have matching base_vault and quote_vault
- virtual_pool must have a matching config
- migration_metadata must have a matching virtual_pool
- first_position_nft_mint must not equal second_position_nft_mint
- Exactly one remaining account must be provided (for the DAMM V2 config)
- 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
Creates a new pool metadata account.
Function
async createPoolMetadata(createVirtualPoolMetadataParam: CreateVirtualPoolMetadataParam): Promise<Transaction>
Parameters
interface CreateVirtualPoolMetadataParam {
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(claimCreatorTradingFeeParam: ClaimCreatorTradingFeeParam): Promise<Transaction>
Parameters
interface ClaimCreatorTradingFeeParam {
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
ClaimCreatorTradingFeeParam
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(claimCreatorTradingFee2Param: ClaimCreatorTradingFee2Param): Promise<Transaction>
Parameters
interface ClaimCreatorTradingFeeParam {
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.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'),
})
Notes
- The creator of the pool must be the same as the creator in the
ClaimCreatorTradingFee2Param
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(creatorWithdrawSurplusParam: CreatorWithdrawSurplusParam): Promise<Transaction>
Parameters
interface CreatorWithdrawSurplusParam {
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
CreatorWithdrawSurplusParam
params.
creatorWithdrawMigrationFee
Withdraws the creator’s migration fee from the pool.
Function
async creatorWithdrawMigrationFee(withdrawMigrationFeeParam: WithdrawMigrationFeeParam): Promise<Transaction>
Parameters
interface WithdrawMigrationFeeParam {
virtualPool: PublicKey // The virtual pool address
sender: PublicKey // The wallet that will claim the fee
feePayer?: 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.creator.creatorWithdrawMigrationFee({
virtualPool: new PublicKey('abcdefghijklmnopqrstuvwxyz1234567890'),
sender: new PublicKey('boss1234567890abcdefghijklmnopqrstuvwxyz'),
feePayer: 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(transferPoolCreatorParam: TransferPoolCreatorParam): Promise<Transaction>
Parameters
interface TransferPoolCreatorParam {
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 the config key details.
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 config keys.
Function
async getPoolConfigs(): Promise<ProgramAccount<PoolConfig>[]>
Returns
An array of config keys.
Example
const configs = await client.state.getPoolConfigs()
getPoolConfigsByOwner
Retrieves all config keys 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 config keys owned by the specified wallet.
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.
Example
const pool = await client.state.getPool(poolAddress)
getPools
Retrieves all pools.
Function
async getPools(): Promise<ProgramAccount<VirtualPool>[]>
Returns
An array of all pools.
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
An array of pools.
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
An array of pools.
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.
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)
getPoolCurveProgress
Gets the progress of the curve by comparing current quote reserve to migration threshold.
Function
async getPoolCurveProgress(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.getPoolCurveProgress(poolAddress)
Gets the metadata for a specific pool.
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.
Example
const metadata = await client.state.getPoolMetadata(poolAddress)
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.
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.
Example
const escrow = await client.state.getDammV1LockEscrow(escrowAddress)
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.
Example
const metrics = await client.state.getPoolFeeMetrics(poolAddress)
getPoolsFeesByConfig
Gets all fees for pools linked to a specific config key.
Function
async getPoolsFeesByConfig(configAddress: PublicKey): Promise<Array<{
poolAddress: PublicKey
partnerBaseFee: BN
partnerQuoteFee: BN
creatorBaseFee: BN
creatorQuoteFee: BN
totalTradingBaseFee: BN
totalTradingQuoteFee: BN
}>>
Parameters
configAddress: PublicKey // The address of the pool config
Returns
An array of objects containing quote fee metrics for each pool.
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<{
poolAddress: PublicKey
partnerBaseFee: BN
partnerQuoteFee: BN
creatorBaseFee: BN
creatorQuoteFee: BN
totalTradingBaseFee: BN
totalTradingQuoteFee: BN
}>>
Parameters
creatorAddress: PublicKey // The address of the creator
Returns
An array of objects containing quote fee metrics for each pool.
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.
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.
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.
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.
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.