@meteora-ag/dynamic-bonding-curve-sdk 1.4.7 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +234 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +233 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -5560,6 +5560,12 @@ type BuildCurveWithTwoSegmentsParams = BuildCurveBaseParams & {
|
|
|
5560
5560
|
migrationMarketCap: number;
|
|
5561
5561
|
percentageSupplyOnMigration: number;
|
|
5562
5562
|
};
|
|
5563
|
+
type BuildCurveWithMidPriceParams = BuildCurveBaseParams & {
|
|
5564
|
+
initialMarketCap: number;
|
|
5565
|
+
migrationMarketCap: number;
|
|
5566
|
+
midPrice: number;
|
|
5567
|
+
percentageSupplyOnMigration: number;
|
|
5568
|
+
};
|
|
5563
5569
|
type BuildCurveWithLiquidityWeightsParams = BuildCurveBaseParams & {
|
|
5564
5570
|
initialMarketCap: number;
|
|
5565
5571
|
migrationMarketCap: number;
|
|
@@ -6662,6 +6668,19 @@ declare const getTotalSupplyFromCurve: (migrationQuoteThreshold: BN$1, sqrtStart
|
|
|
6662
6668
|
* @returns The migration threshold price
|
|
6663
6669
|
*/
|
|
6664
6670
|
declare const getMigrationThresholdPrice: (migrationThreshold: BN$1, sqrtStartPrice: BN$1, curve: Array<LiquidityDistributionParameters>) => BN$1;
|
|
6671
|
+
/**
|
|
6672
|
+
* Calculate the quote amount allocated to each curve segment
|
|
6673
|
+
* Formula: Δb = L * (√P_upper - √P_lower) for each segment
|
|
6674
|
+
* @param migrationQuoteThreshold - The total migration quote threshold
|
|
6675
|
+
* @param sqrtStartPrice - The start sqrt price
|
|
6676
|
+
* @param curve - The curve segments with sqrtPrice and liquidity
|
|
6677
|
+
* @returns Array of quote amounts for each segment and the final sqrt price reached
|
|
6678
|
+
*/
|
|
6679
|
+
declare const getCurveBreakdown: (migrationQuoteThreshold: BN$1, sqrtStartPrice: BN$1, curve: Array<LiquidityDistributionParameters>) => {
|
|
6680
|
+
segmentAmounts: BN$1[];
|
|
6681
|
+
finalSqrtPrice: BN$1;
|
|
6682
|
+
totalAmount: BN$1;
|
|
6683
|
+
};
|
|
6665
6684
|
/**
|
|
6666
6685
|
* Get the swap amount with buffer
|
|
6667
6686
|
* @param swapBaseAmount - The swap base amount
|
|
@@ -7244,6 +7263,12 @@ declare function buildCurveWithMarketCap(buildCurveWithMarketCapParam: BuildCurv
|
|
|
7244
7263
|
* @returns The build custom constant product curve by market cap
|
|
7245
7264
|
*/
|
|
7246
7265
|
declare function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam: BuildCurveWithTwoSegmentsParams): ConfigParameters;
|
|
7266
|
+
/**
|
|
7267
|
+
* Build a custom constant product curve with a mid price. This will create a two segment curve with a start price -> mid price, and a mid price -> migration price.
|
|
7268
|
+
* @param buildCurveWithMidPriceParam - The parameters for the custom constant product curve with a mid price
|
|
7269
|
+
* @returns The build custom constant product curve by mid price
|
|
7270
|
+
*/
|
|
7271
|
+
declare function buildCurveWithMidPrice(buildCurveWithMidPriceParam: BuildCurveWithMidPriceParams): ConfigParameters;
|
|
7247
7272
|
/**
|
|
7248
7273
|
* Build a custom curve graph with liquidity weights, changing the curve shape based on the liquidity weights
|
|
7249
7274
|
* @param buildCurveWithLiquidityWeightsParam - The parameters for the custom constant product curve with liquidity weights
|
|
@@ -21662,4 +21687,4 @@ var idl = {
|
|
|
21662
21687
|
types: types
|
|
21663
21688
|
};
|
|
21664
21689
|
|
|
21665
|
-
export { ActivationType, BASE_ADDRESS, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BaseFeeConfig, type BaseFeeHandler, BaseFeeMode, type BaseFeeParams, type BuildCurveBaseParams, type BuildCurveParams, type BuildCurveWithLiquidityWeightsParams, type BuildCurveWithMarketCapParams, type BuildCurveWithTwoSegmentsParams, type ClaimCreatorTradingFee2Params, type ClaimCreatorTradingFeeParams, type ClaimCreatorTradingFeeWithQuoteMintNotSolParams, type ClaimCreatorTradingFeeWithQuoteMintSolParams, type ClaimPartnerTradingFeeWithQuoteMintNotSolParams, type ClaimPartnerTradingFeeWithQuoteMintSolParams, type ClaimTradingFee2Params, type ClaimTradingFeeParams, CollectFeeMode, type ConfigParameters, type CreateConfigAccounts, type CreateConfigAndPoolParams, type CreateConfigAndPoolWithFirstBuyParams, type CreateConfigParams, type CreateDammV1MigrationMetadataParams, type CreateLockerParams, type CreatePartnerMetadataParameters, type CreatePartnerMetadataParams, type CreatePoolParams, type CreatePoolWithFirstBuyParams, type CreatePoolWithPartnerAndCreatorFirstBuyParams, type CreateVirtualPoolMetadataParams, type CreatorFirstBuyParams, CreatorService, type CreatorWithdrawSurplusParams, DAMM_V1_MIGRATION_FEE_ADDRESS, DAMM_V1_PROGRAM_ID, DAMM_V2_MIGRATION_FEE_ADDRESS, DAMM_V2_PROGRAM_ID, DYNAMIC_BONDING_CURVE_PROGRAM_ID, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, DYNAMIC_FEE_ROUNDING_OFFSET, DYNAMIC_FEE_SCALING_FACTOR, type DammLpTokenParams, DammV2DynamicFeeMode, DynamicBondingCurveClient, idl as DynamicBondingCurveIdl, DynamicBondingCurveProgram, type DynamicBondingCurve as DynamicBondingCurveTypes, type DynamicCurveProgram, type DynamicFeeConfig, type DynamicFeeParameters, FEE_DENOMINATOR, type FeeMode, type FeeOnAmountResult, FeeRateLimiter, type FeeResult, FeeScheduler, type FeeSchedulerParams, type FirstBuyParams, type InitializePoolBaseParams, type InitializePoolParameters, LOCKER_PROGRAM_ID, type LiquidityDistributionParameters, type LockEscrow, type LockedVestingParameters, type LockedVestingParams, MAX_CREATOR_MIGRATION_FEE_PERCENTAGE, MAX_CURVE_POINT, MAX_DYNAMIC_FEE_PERCENTAGE, MAX_FEE_BPS, MAX_FEE_NUMERATOR, MAX_MIGRATED_POOL_FEE_BPS, MAX_MIGRATION_FEE_PERCENTAGE, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_RATE_LIMITER_DURATION_IN_SECONDS, MAX_RATE_LIMITER_DURATION_IN_SLOTS, MAX_SQRT_PRICE, METAPLEX_PROGRAM_ID, MIN_FEE_BPS, MIN_FEE_NUMERATOR, MIN_MIGRATED_POOL_FEE_BPS, MIN_SQRT_PRICE, type MeteoraDammMigrationMetadata, type MigrateToDammV1Params, type MigrateToDammV2Params, type MigrateToDammV2Response, type MigratedPoolFee, MigrationFeeOption, MigrationOption, MigrationService, OFFSET, ONE_Q64, PARTNER_SURPLUS_SHARE, type PartnerFirstBuyParams, type PartnerMetadata, PartnerService, type PartnerWithdrawSurplusParams, type PoolConfig, type PoolFeeParameters, type PoolFees, type PoolFeesConfig, PoolService, type PreCreatePoolParams, type PrepareSwapParams, RESOLUTION, type RateLimiterParams, Rounding, SLOT_DURATION, SWAP_BUFFER_PERCENTAGE, SafeMath, StateService, type Swap2Params, type SwapAmount, SwapMode, type SwapParams, type SwapQuote2Params, type SwapQuote2Result, type SwapQuoteParams, type SwapQuoteResult, type SwapResult, type SwapResult2, TIMESTAMP_DURATION, TokenDecimal, TokenType, TokenUpdateAuthorityOption, TradeDirection, type TransferPoolCreatorParams, U128_MAX, U16_MAX, U64_MAX, VAULT_PROGRAM_ID, type VirtualPool, type VirtualPoolMetadata, type VolatilityTracker, type WithdrawLeftoverParams, type WithdrawMigrationFeeParams, bpsToFeeNumerator, buildCurve, buildCurveWithLiquidityWeights, buildCurveWithMarketCap, buildCurveWithTwoSegments, calculateBaseToQuoteFromAmountIn, calculateBaseToQuoteFromAmountOut, calculateFeeSchedulerEndingBaseFeeBps, calculateQuoteToBaseFromAmountIn, calculateQuoteToBaseFromAmountOut, checkRateLimiterApplied, cleanUpTokenAccountTx, convertDecimalToBN, convertToLamports, createDammV1Program, createDammV2Program, createDbcProgram, createInitializePermissionlessDynamicVaultIx, createLockEscrowIx, createProgramAccountFilter, createVaultProgram, deriveBaseKeyForLocker, deriveDammV1EventAuthority, deriveDammV1LockEscrowAddress, deriveDammV1LpMintAddress, deriveDammV1MigrationMetadataAddress, deriveDammV1PoolAddress, deriveDammV1PoolAuthority, deriveDammV1ProtocolFeeAddress, deriveDammV1VaultLPAddress, deriveDammV2EventAuthority, deriveDammV2LockEscrowAddress, deriveDammV2MigrationMetadataAddress, deriveDammV2PoolAddress, deriveDammV2PoolAuthority, deriveDammV2TokenVaultAddress, deriveDbcEventAuthority, deriveDbcPoolAddress, deriveDbcPoolAuthority, deriveDbcPoolMetadata, deriveDbcTokenVaultAddress, deriveEscrow, deriveLockerEventAuthority, deriveMintMetadata, derivePartnerMetadata, derivePositionAddress, derivePositionNftAccount, deriveTokenVaultKey, deriveVaultAddress, deriveVaultLpMintAddress, deriveVaultPdas, feeNumeratorToBps, findAssociatedTokenAddress, fromDecimalToBN, getAccountCreationTimestamp, getAccountCreationTimestamps, getAccountData, getBaseFeeHandler, getBaseFeeNumerator, getBaseFeeNumeratorByPeriod, getBaseFeeParams, getBaseTokenForSwap, getCheckedAmounts, getCurrentPoint, getDeltaAmountBaseUnsigned, getDeltaAmountBaseUnsigned256, getDeltaAmountBaseUnsignedUnchecked, getDeltaAmountQuoteUnsigned, getDeltaAmountQuoteUnsigned256, getDeltaAmountQuoteUnsignedUnchecked, getDynamicFeeParams, getExcludedFeeAmount, getFeeMode, getFeeNumeratorFromExcludedAmount, getFeeNumeratorFromIncludedAmount, getFeeNumeratorOnExponentialFeeScheduler, getFeeNumeratorOnLinearFeeScheduler, getFeeOnAmount, getFeeSchedulerParams, getFirstCurve, getFirstKey, getIncludedFeeAmount, getInitialLiquidityFromDeltaBase, getInitialLiquidityFromDeltaQuote, getLiquidity, getLockedVestingParams, getMaxBaseFeeNumerator, getMaxIndex, getMaxOutAmountWithMinBaseFee, getMigratedPoolFeeParams, getMigrationBaseToken, getMigrationQuoteAmount, getMigrationQuoteAmountFromMigrationQuoteThreshold, getMigrationQuoteThresholdFromMigrationQuoteAmount, getMigrationThresholdPrice, getMinBaseFeeNumerator, getNextSqrtPriceFromBaseAmountInRoundingUp, getNextSqrtPriceFromBaseAmountOutRoundingUp, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getNextSqrtPriceFromQuoteAmountInRoundingDown, getNextSqrtPriceFromQuoteAmountOutRoundingDown, getOrCreateATAInstruction, getPercentageSupplyOnMigration, getPriceFromSqrtPrice, getQuoteReserveFromNextSqrtPrice, getRateLimiterExcludedFeeAmount, getRateLimiterParams, getSecondKey, getSqrtPriceFromMarketCap, getSqrtPriceFromPrice, getSwapAmountWithBuffer, getSwapResult, getSwapResultFromExactInput, getSwapResultFromExactOutput, getSwapResultFromPartialInput, getTokenDecimals, getTokenProgram, getTokenType, getTokenomics, getTotalFeeNumerator, getTotalFeeNumeratorFromExcludedFeeAmount, getTotalFeeNumeratorFromIncludedFeeAmount, getTotalSupplyFromCurve, getTotalTokenSupply, getTotalVestingAmount, getTwoCurve, getVariableFeeNumerator, isDefaultLockedVesting, isDynamicFeeEnabled, isNativeSol, isNonZeroRateLimiter, isRateLimiterApplied, isZeroRateLimiter, mulDiv, mulShr, pow, prepareSwapAmountParam, prepareTokenAccountTx, splitFees, sqrt, swapQuote, swapQuoteExactIn, swapQuoteExactOut, swapQuotePartialFill, toNumerator, unwrapSOLInstruction, validateActivationType, validateBalance, validateBaseTokenType, validateCollectFeeMode, validateConfigParameters, validateCurve, validateFeeRateLimiter, validateFeeScheduler, validateLPPercentages, validateMigratedPoolFee, validateMigrationAndTokenType, validateMigrationFee, validateMigrationFeeOption, validatePoolFees, validateSwapAmount, validateTokenDecimals, validateTokenSupply, validateTokenUpdateAuthorityOptions, wrapSOLInstruction };
|
|
21690
|
+
export { ActivationType, BASE_ADDRESS, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BaseFeeConfig, type BaseFeeHandler, BaseFeeMode, type BaseFeeParams, type BuildCurveBaseParams, type BuildCurveParams, type BuildCurveWithLiquidityWeightsParams, type BuildCurveWithMarketCapParams, type BuildCurveWithMidPriceParams, type BuildCurveWithTwoSegmentsParams, type ClaimCreatorTradingFee2Params, type ClaimCreatorTradingFeeParams, type ClaimCreatorTradingFeeWithQuoteMintNotSolParams, type ClaimCreatorTradingFeeWithQuoteMintSolParams, type ClaimPartnerTradingFeeWithQuoteMintNotSolParams, type ClaimPartnerTradingFeeWithQuoteMintSolParams, type ClaimTradingFee2Params, type ClaimTradingFeeParams, CollectFeeMode, type ConfigParameters, type CreateConfigAccounts, type CreateConfigAndPoolParams, type CreateConfigAndPoolWithFirstBuyParams, type CreateConfigParams, type CreateDammV1MigrationMetadataParams, type CreateLockerParams, type CreatePartnerMetadataParameters, type CreatePartnerMetadataParams, type CreatePoolParams, type CreatePoolWithFirstBuyParams, type CreatePoolWithPartnerAndCreatorFirstBuyParams, type CreateVirtualPoolMetadataParams, type CreatorFirstBuyParams, CreatorService, type CreatorWithdrawSurplusParams, DAMM_V1_MIGRATION_FEE_ADDRESS, DAMM_V1_PROGRAM_ID, DAMM_V2_MIGRATION_FEE_ADDRESS, DAMM_V2_PROGRAM_ID, DYNAMIC_BONDING_CURVE_PROGRAM_ID, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, DYNAMIC_FEE_ROUNDING_OFFSET, DYNAMIC_FEE_SCALING_FACTOR, type DammLpTokenParams, DammV2DynamicFeeMode, DynamicBondingCurveClient, idl as DynamicBondingCurveIdl, DynamicBondingCurveProgram, type DynamicBondingCurve as DynamicBondingCurveTypes, type DynamicCurveProgram, type DynamicFeeConfig, type DynamicFeeParameters, FEE_DENOMINATOR, type FeeMode, type FeeOnAmountResult, FeeRateLimiter, type FeeResult, FeeScheduler, type FeeSchedulerParams, type FirstBuyParams, type InitializePoolBaseParams, type InitializePoolParameters, LOCKER_PROGRAM_ID, type LiquidityDistributionParameters, type LockEscrow, type LockedVestingParameters, type LockedVestingParams, MAX_CREATOR_MIGRATION_FEE_PERCENTAGE, MAX_CURVE_POINT, MAX_DYNAMIC_FEE_PERCENTAGE, MAX_FEE_BPS, MAX_FEE_NUMERATOR, MAX_MIGRATED_POOL_FEE_BPS, MAX_MIGRATION_FEE_PERCENTAGE, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_RATE_LIMITER_DURATION_IN_SECONDS, MAX_RATE_LIMITER_DURATION_IN_SLOTS, MAX_SQRT_PRICE, METAPLEX_PROGRAM_ID, MIN_FEE_BPS, MIN_FEE_NUMERATOR, MIN_MIGRATED_POOL_FEE_BPS, MIN_SQRT_PRICE, type MeteoraDammMigrationMetadata, type MigrateToDammV1Params, type MigrateToDammV2Params, type MigrateToDammV2Response, type MigratedPoolFee, MigrationFeeOption, MigrationOption, MigrationService, OFFSET, ONE_Q64, PARTNER_SURPLUS_SHARE, type PartnerFirstBuyParams, type PartnerMetadata, PartnerService, type PartnerWithdrawSurplusParams, type PoolConfig, type PoolFeeParameters, type PoolFees, type PoolFeesConfig, PoolService, type PreCreatePoolParams, type PrepareSwapParams, RESOLUTION, type RateLimiterParams, Rounding, SLOT_DURATION, SWAP_BUFFER_PERCENTAGE, SafeMath, StateService, type Swap2Params, type SwapAmount, SwapMode, type SwapParams, type SwapQuote2Params, type SwapQuote2Result, type SwapQuoteParams, type SwapQuoteResult, type SwapResult, type SwapResult2, TIMESTAMP_DURATION, TokenDecimal, TokenType, TokenUpdateAuthorityOption, TradeDirection, type TransferPoolCreatorParams, U128_MAX, U16_MAX, U64_MAX, VAULT_PROGRAM_ID, type VirtualPool, type VirtualPoolMetadata, type VolatilityTracker, type WithdrawLeftoverParams, type WithdrawMigrationFeeParams, bpsToFeeNumerator, buildCurve, buildCurveWithLiquidityWeights, buildCurveWithMarketCap, buildCurveWithMidPrice, buildCurveWithTwoSegments, calculateBaseToQuoteFromAmountIn, calculateBaseToQuoteFromAmountOut, calculateFeeSchedulerEndingBaseFeeBps, calculateQuoteToBaseFromAmountIn, calculateQuoteToBaseFromAmountOut, checkRateLimiterApplied, cleanUpTokenAccountTx, convertDecimalToBN, convertToLamports, createDammV1Program, createDammV2Program, createDbcProgram, createInitializePermissionlessDynamicVaultIx, createLockEscrowIx, createProgramAccountFilter, createVaultProgram, deriveBaseKeyForLocker, deriveDammV1EventAuthority, deriveDammV1LockEscrowAddress, deriveDammV1LpMintAddress, deriveDammV1MigrationMetadataAddress, deriveDammV1PoolAddress, deriveDammV1PoolAuthority, deriveDammV1ProtocolFeeAddress, deriveDammV1VaultLPAddress, deriveDammV2EventAuthority, deriveDammV2LockEscrowAddress, deriveDammV2MigrationMetadataAddress, deriveDammV2PoolAddress, deriveDammV2PoolAuthority, deriveDammV2TokenVaultAddress, deriveDbcEventAuthority, deriveDbcPoolAddress, deriveDbcPoolAuthority, deriveDbcPoolMetadata, deriveDbcTokenVaultAddress, deriveEscrow, deriveLockerEventAuthority, deriveMintMetadata, derivePartnerMetadata, derivePositionAddress, derivePositionNftAccount, deriveTokenVaultKey, deriveVaultAddress, deriveVaultLpMintAddress, deriveVaultPdas, feeNumeratorToBps, findAssociatedTokenAddress, fromDecimalToBN, getAccountCreationTimestamp, getAccountCreationTimestamps, getAccountData, getBaseFeeHandler, getBaseFeeNumerator, getBaseFeeNumeratorByPeriod, getBaseFeeParams, getBaseTokenForSwap, getCheckedAmounts, getCurrentPoint, getCurveBreakdown, getDeltaAmountBaseUnsigned, getDeltaAmountBaseUnsigned256, getDeltaAmountBaseUnsignedUnchecked, getDeltaAmountQuoteUnsigned, getDeltaAmountQuoteUnsigned256, getDeltaAmountQuoteUnsignedUnchecked, getDynamicFeeParams, getExcludedFeeAmount, getFeeMode, getFeeNumeratorFromExcludedAmount, getFeeNumeratorFromIncludedAmount, getFeeNumeratorOnExponentialFeeScheduler, getFeeNumeratorOnLinearFeeScheduler, getFeeOnAmount, getFeeSchedulerParams, getFirstCurve, getFirstKey, getIncludedFeeAmount, getInitialLiquidityFromDeltaBase, getInitialLiquidityFromDeltaQuote, getLiquidity, getLockedVestingParams, getMaxBaseFeeNumerator, getMaxIndex, getMaxOutAmountWithMinBaseFee, getMigratedPoolFeeParams, getMigrationBaseToken, getMigrationQuoteAmount, getMigrationQuoteAmountFromMigrationQuoteThreshold, getMigrationQuoteThresholdFromMigrationQuoteAmount, getMigrationThresholdPrice, getMinBaseFeeNumerator, getNextSqrtPriceFromBaseAmountInRoundingUp, getNextSqrtPriceFromBaseAmountOutRoundingUp, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getNextSqrtPriceFromQuoteAmountInRoundingDown, getNextSqrtPriceFromQuoteAmountOutRoundingDown, getOrCreateATAInstruction, getPercentageSupplyOnMigration, getPriceFromSqrtPrice, getQuoteReserveFromNextSqrtPrice, getRateLimiterExcludedFeeAmount, getRateLimiterParams, getSecondKey, getSqrtPriceFromMarketCap, getSqrtPriceFromPrice, getSwapAmountWithBuffer, getSwapResult, getSwapResultFromExactInput, getSwapResultFromExactOutput, getSwapResultFromPartialInput, getTokenDecimals, getTokenProgram, getTokenType, getTokenomics, getTotalFeeNumerator, getTotalFeeNumeratorFromExcludedFeeAmount, getTotalFeeNumeratorFromIncludedFeeAmount, getTotalSupplyFromCurve, getTotalTokenSupply, getTotalVestingAmount, getTwoCurve, getVariableFeeNumerator, isDefaultLockedVesting, isDynamicFeeEnabled, isNativeSol, isNonZeroRateLimiter, isRateLimiterApplied, isZeroRateLimiter, mulDiv, mulShr, pow, prepareSwapAmountParam, prepareTokenAccountTx, splitFees, sqrt, swapQuote, swapQuoteExactIn, swapQuoteExactOut, swapQuotePartialFill, toNumerator, unwrapSOLInstruction, validateActivationType, validateBalance, validateBaseTokenType, validateCollectFeeMode, validateConfigParameters, validateCurve, validateFeeRateLimiter, validateFeeScheduler, validateLPPercentages, validateMigratedPoolFee, validateMigrationAndTokenType, validateMigrationFee, validateMigrationFeeOption, validatePoolFees, validateSwapAmount, validateTokenDecimals, validateTokenSupply, validateTokenUpdateAuthorityOptions, wrapSOLInstruction };
|
package/dist/index.d.ts
CHANGED
|
@@ -5560,6 +5560,12 @@ type BuildCurveWithTwoSegmentsParams = BuildCurveBaseParams & {
|
|
|
5560
5560
|
migrationMarketCap: number;
|
|
5561
5561
|
percentageSupplyOnMigration: number;
|
|
5562
5562
|
};
|
|
5563
|
+
type BuildCurveWithMidPriceParams = BuildCurveBaseParams & {
|
|
5564
|
+
initialMarketCap: number;
|
|
5565
|
+
migrationMarketCap: number;
|
|
5566
|
+
midPrice: number;
|
|
5567
|
+
percentageSupplyOnMigration: number;
|
|
5568
|
+
};
|
|
5563
5569
|
type BuildCurveWithLiquidityWeightsParams = BuildCurveBaseParams & {
|
|
5564
5570
|
initialMarketCap: number;
|
|
5565
5571
|
migrationMarketCap: number;
|
|
@@ -6662,6 +6668,19 @@ declare const getTotalSupplyFromCurve: (migrationQuoteThreshold: BN$1, sqrtStart
|
|
|
6662
6668
|
* @returns The migration threshold price
|
|
6663
6669
|
*/
|
|
6664
6670
|
declare const getMigrationThresholdPrice: (migrationThreshold: BN$1, sqrtStartPrice: BN$1, curve: Array<LiquidityDistributionParameters>) => BN$1;
|
|
6671
|
+
/**
|
|
6672
|
+
* Calculate the quote amount allocated to each curve segment
|
|
6673
|
+
* Formula: Δb = L * (√P_upper - √P_lower) for each segment
|
|
6674
|
+
* @param migrationQuoteThreshold - The total migration quote threshold
|
|
6675
|
+
* @param sqrtStartPrice - The start sqrt price
|
|
6676
|
+
* @param curve - The curve segments with sqrtPrice and liquidity
|
|
6677
|
+
* @returns Array of quote amounts for each segment and the final sqrt price reached
|
|
6678
|
+
*/
|
|
6679
|
+
declare const getCurveBreakdown: (migrationQuoteThreshold: BN$1, sqrtStartPrice: BN$1, curve: Array<LiquidityDistributionParameters>) => {
|
|
6680
|
+
segmentAmounts: BN$1[];
|
|
6681
|
+
finalSqrtPrice: BN$1;
|
|
6682
|
+
totalAmount: BN$1;
|
|
6683
|
+
};
|
|
6665
6684
|
/**
|
|
6666
6685
|
* Get the swap amount with buffer
|
|
6667
6686
|
* @param swapBaseAmount - The swap base amount
|
|
@@ -7244,6 +7263,12 @@ declare function buildCurveWithMarketCap(buildCurveWithMarketCapParam: BuildCurv
|
|
|
7244
7263
|
* @returns The build custom constant product curve by market cap
|
|
7245
7264
|
*/
|
|
7246
7265
|
declare function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam: BuildCurveWithTwoSegmentsParams): ConfigParameters;
|
|
7266
|
+
/**
|
|
7267
|
+
* Build a custom constant product curve with a mid price. This will create a two segment curve with a start price -> mid price, and a mid price -> migration price.
|
|
7268
|
+
* @param buildCurveWithMidPriceParam - The parameters for the custom constant product curve with a mid price
|
|
7269
|
+
* @returns The build custom constant product curve by mid price
|
|
7270
|
+
*/
|
|
7271
|
+
declare function buildCurveWithMidPrice(buildCurveWithMidPriceParam: BuildCurveWithMidPriceParams): ConfigParameters;
|
|
7247
7272
|
/**
|
|
7248
7273
|
* Build a custom curve graph with liquidity weights, changing the curve shape based on the liquidity weights
|
|
7249
7274
|
* @param buildCurveWithLiquidityWeightsParam - The parameters for the custom constant product curve with liquidity weights
|
|
@@ -21662,4 +21687,4 @@ var idl = {
|
|
|
21662
21687
|
types: types
|
|
21663
21688
|
};
|
|
21664
21689
|
|
|
21665
|
-
export { ActivationType, BASE_ADDRESS, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BaseFeeConfig, type BaseFeeHandler, BaseFeeMode, type BaseFeeParams, type BuildCurveBaseParams, type BuildCurveParams, type BuildCurveWithLiquidityWeightsParams, type BuildCurveWithMarketCapParams, type BuildCurveWithTwoSegmentsParams, type ClaimCreatorTradingFee2Params, type ClaimCreatorTradingFeeParams, type ClaimCreatorTradingFeeWithQuoteMintNotSolParams, type ClaimCreatorTradingFeeWithQuoteMintSolParams, type ClaimPartnerTradingFeeWithQuoteMintNotSolParams, type ClaimPartnerTradingFeeWithQuoteMintSolParams, type ClaimTradingFee2Params, type ClaimTradingFeeParams, CollectFeeMode, type ConfigParameters, type CreateConfigAccounts, type CreateConfigAndPoolParams, type CreateConfigAndPoolWithFirstBuyParams, type CreateConfigParams, type CreateDammV1MigrationMetadataParams, type CreateLockerParams, type CreatePartnerMetadataParameters, type CreatePartnerMetadataParams, type CreatePoolParams, type CreatePoolWithFirstBuyParams, type CreatePoolWithPartnerAndCreatorFirstBuyParams, type CreateVirtualPoolMetadataParams, type CreatorFirstBuyParams, CreatorService, type CreatorWithdrawSurplusParams, DAMM_V1_MIGRATION_FEE_ADDRESS, DAMM_V1_PROGRAM_ID, DAMM_V2_MIGRATION_FEE_ADDRESS, DAMM_V2_PROGRAM_ID, DYNAMIC_BONDING_CURVE_PROGRAM_ID, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, DYNAMIC_FEE_ROUNDING_OFFSET, DYNAMIC_FEE_SCALING_FACTOR, type DammLpTokenParams, DammV2DynamicFeeMode, DynamicBondingCurveClient, idl as DynamicBondingCurveIdl, DynamicBondingCurveProgram, type DynamicBondingCurve as DynamicBondingCurveTypes, type DynamicCurveProgram, type DynamicFeeConfig, type DynamicFeeParameters, FEE_DENOMINATOR, type FeeMode, type FeeOnAmountResult, FeeRateLimiter, type FeeResult, FeeScheduler, type FeeSchedulerParams, type FirstBuyParams, type InitializePoolBaseParams, type InitializePoolParameters, LOCKER_PROGRAM_ID, type LiquidityDistributionParameters, type LockEscrow, type LockedVestingParameters, type LockedVestingParams, MAX_CREATOR_MIGRATION_FEE_PERCENTAGE, MAX_CURVE_POINT, MAX_DYNAMIC_FEE_PERCENTAGE, MAX_FEE_BPS, MAX_FEE_NUMERATOR, MAX_MIGRATED_POOL_FEE_BPS, MAX_MIGRATION_FEE_PERCENTAGE, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_RATE_LIMITER_DURATION_IN_SECONDS, MAX_RATE_LIMITER_DURATION_IN_SLOTS, MAX_SQRT_PRICE, METAPLEX_PROGRAM_ID, MIN_FEE_BPS, MIN_FEE_NUMERATOR, MIN_MIGRATED_POOL_FEE_BPS, MIN_SQRT_PRICE, type MeteoraDammMigrationMetadata, type MigrateToDammV1Params, type MigrateToDammV2Params, type MigrateToDammV2Response, type MigratedPoolFee, MigrationFeeOption, MigrationOption, MigrationService, OFFSET, ONE_Q64, PARTNER_SURPLUS_SHARE, type PartnerFirstBuyParams, type PartnerMetadata, PartnerService, type PartnerWithdrawSurplusParams, type PoolConfig, type PoolFeeParameters, type PoolFees, type PoolFeesConfig, PoolService, type PreCreatePoolParams, type PrepareSwapParams, RESOLUTION, type RateLimiterParams, Rounding, SLOT_DURATION, SWAP_BUFFER_PERCENTAGE, SafeMath, StateService, type Swap2Params, type SwapAmount, SwapMode, type SwapParams, type SwapQuote2Params, type SwapQuote2Result, type SwapQuoteParams, type SwapQuoteResult, type SwapResult, type SwapResult2, TIMESTAMP_DURATION, TokenDecimal, TokenType, TokenUpdateAuthorityOption, TradeDirection, type TransferPoolCreatorParams, U128_MAX, U16_MAX, U64_MAX, VAULT_PROGRAM_ID, type VirtualPool, type VirtualPoolMetadata, type VolatilityTracker, type WithdrawLeftoverParams, type WithdrawMigrationFeeParams, bpsToFeeNumerator, buildCurve, buildCurveWithLiquidityWeights, buildCurveWithMarketCap, buildCurveWithTwoSegments, calculateBaseToQuoteFromAmountIn, calculateBaseToQuoteFromAmountOut, calculateFeeSchedulerEndingBaseFeeBps, calculateQuoteToBaseFromAmountIn, calculateQuoteToBaseFromAmountOut, checkRateLimiterApplied, cleanUpTokenAccountTx, convertDecimalToBN, convertToLamports, createDammV1Program, createDammV2Program, createDbcProgram, createInitializePermissionlessDynamicVaultIx, createLockEscrowIx, createProgramAccountFilter, createVaultProgram, deriveBaseKeyForLocker, deriveDammV1EventAuthority, deriveDammV1LockEscrowAddress, deriveDammV1LpMintAddress, deriveDammV1MigrationMetadataAddress, deriveDammV1PoolAddress, deriveDammV1PoolAuthority, deriveDammV1ProtocolFeeAddress, deriveDammV1VaultLPAddress, deriveDammV2EventAuthority, deriveDammV2LockEscrowAddress, deriveDammV2MigrationMetadataAddress, deriveDammV2PoolAddress, deriveDammV2PoolAuthority, deriveDammV2TokenVaultAddress, deriveDbcEventAuthority, deriveDbcPoolAddress, deriveDbcPoolAuthority, deriveDbcPoolMetadata, deriveDbcTokenVaultAddress, deriveEscrow, deriveLockerEventAuthority, deriveMintMetadata, derivePartnerMetadata, derivePositionAddress, derivePositionNftAccount, deriveTokenVaultKey, deriveVaultAddress, deriveVaultLpMintAddress, deriveVaultPdas, feeNumeratorToBps, findAssociatedTokenAddress, fromDecimalToBN, getAccountCreationTimestamp, getAccountCreationTimestamps, getAccountData, getBaseFeeHandler, getBaseFeeNumerator, getBaseFeeNumeratorByPeriod, getBaseFeeParams, getBaseTokenForSwap, getCheckedAmounts, getCurrentPoint, getDeltaAmountBaseUnsigned, getDeltaAmountBaseUnsigned256, getDeltaAmountBaseUnsignedUnchecked, getDeltaAmountQuoteUnsigned, getDeltaAmountQuoteUnsigned256, getDeltaAmountQuoteUnsignedUnchecked, getDynamicFeeParams, getExcludedFeeAmount, getFeeMode, getFeeNumeratorFromExcludedAmount, getFeeNumeratorFromIncludedAmount, getFeeNumeratorOnExponentialFeeScheduler, getFeeNumeratorOnLinearFeeScheduler, getFeeOnAmount, getFeeSchedulerParams, getFirstCurve, getFirstKey, getIncludedFeeAmount, getInitialLiquidityFromDeltaBase, getInitialLiquidityFromDeltaQuote, getLiquidity, getLockedVestingParams, getMaxBaseFeeNumerator, getMaxIndex, getMaxOutAmountWithMinBaseFee, getMigratedPoolFeeParams, getMigrationBaseToken, getMigrationQuoteAmount, getMigrationQuoteAmountFromMigrationQuoteThreshold, getMigrationQuoteThresholdFromMigrationQuoteAmount, getMigrationThresholdPrice, getMinBaseFeeNumerator, getNextSqrtPriceFromBaseAmountInRoundingUp, getNextSqrtPriceFromBaseAmountOutRoundingUp, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getNextSqrtPriceFromQuoteAmountInRoundingDown, getNextSqrtPriceFromQuoteAmountOutRoundingDown, getOrCreateATAInstruction, getPercentageSupplyOnMigration, getPriceFromSqrtPrice, getQuoteReserveFromNextSqrtPrice, getRateLimiterExcludedFeeAmount, getRateLimiterParams, getSecondKey, getSqrtPriceFromMarketCap, getSqrtPriceFromPrice, getSwapAmountWithBuffer, getSwapResult, getSwapResultFromExactInput, getSwapResultFromExactOutput, getSwapResultFromPartialInput, getTokenDecimals, getTokenProgram, getTokenType, getTokenomics, getTotalFeeNumerator, getTotalFeeNumeratorFromExcludedFeeAmount, getTotalFeeNumeratorFromIncludedFeeAmount, getTotalSupplyFromCurve, getTotalTokenSupply, getTotalVestingAmount, getTwoCurve, getVariableFeeNumerator, isDefaultLockedVesting, isDynamicFeeEnabled, isNativeSol, isNonZeroRateLimiter, isRateLimiterApplied, isZeroRateLimiter, mulDiv, mulShr, pow, prepareSwapAmountParam, prepareTokenAccountTx, splitFees, sqrt, swapQuote, swapQuoteExactIn, swapQuoteExactOut, swapQuotePartialFill, toNumerator, unwrapSOLInstruction, validateActivationType, validateBalance, validateBaseTokenType, validateCollectFeeMode, validateConfigParameters, validateCurve, validateFeeRateLimiter, validateFeeScheduler, validateLPPercentages, validateMigratedPoolFee, validateMigrationAndTokenType, validateMigrationFee, validateMigrationFeeOption, validatePoolFees, validateSwapAmount, validateTokenDecimals, validateTokenSupply, validateTokenUpdateAuthorityOptions, wrapSOLInstruction };
|
|
21690
|
+
export { ActivationType, BASE_ADDRESS, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BaseFeeConfig, type BaseFeeHandler, BaseFeeMode, type BaseFeeParams, type BuildCurveBaseParams, type BuildCurveParams, type BuildCurveWithLiquidityWeightsParams, type BuildCurveWithMarketCapParams, type BuildCurveWithMidPriceParams, type BuildCurveWithTwoSegmentsParams, type ClaimCreatorTradingFee2Params, type ClaimCreatorTradingFeeParams, type ClaimCreatorTradingFeeWithQuoteMintNotSolParams, type ClaimCreatorTradingFeeWithQuoteMintSolParams, type ClaimPartnerTradingFeeWithQuoteMintNotSolParams, type ClaimPartnerTradingFeeWithQuoteMintSolParams, type ClaimTradingFee2Params, type ClaimTradingFeeParams, CollectFeeMode, type ConfigParameters, type CreateConfigAccounts, type CreateConfigAndPoolParams, type CreateConfigAndPoolWithFirstBuyParams, type CreateConfigParams, type CreateDammV1MigrationMetadataParams, type CreateLockerParams, type CreatePartnerMetadataParameters, type CreatePartnerMetadataParams, type CreatePoolParams, type CreatePoolWithFirstBuyParams, type CreatePoolWithPartnerAndCreatorFirstBuyParams, type CreateVirtualPoolMetadataParams, type CreatorFirstBuyParams, CreatorService, type CreatorWithdrawSurplusParams, DAMM_V1_MIGRATION_FEE_ADDRESS, DAMM_V1_PROGRAM_ID, DAMM_V2_MIGRATION_FEE_ADDRESS, DAMM_V2_PROGRAM_ID, DYNAMIC_BONDING_CURVE_PROGRAM_ID, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, DYNAMIC_FEE_ROUNDING_OFFSET, DYNAMIC_FEE_SCALING_FACTOR, type DammLpTokenParams, DammV2DynamicFeeMode, DynamicBondingCurveClient, idl as DynamicBondingCurveIdl, DynamicBondingCurveProgram, type DynamicBondingCurve as DynamicBondingCurveTypes, type DynamicCurveProgram, type DynamicFeeConfig, type DynamicFeeParameters, FEE_DENOMINATOR, type FeeMode, type FeeOnAmountResult, FeeRateLimiter, type FeeResult, FeeScheduler, type FeeSchedulerParams, type FirstBuyParams, type InitializePoolBaseParams, type InitializePoolParameters, LOCKER_PROGRAM_ID, type LiquidityDistributionParameters, type LockEscrow, type LockedVestingParameters, type LockedVestingParams, MAX_CREATOR_MIGRATION_FEE_PERCENTAGE, MAX_CURVE_POINT, MAX_DYNAMIC_FEE_PERCENTAGE, MAX_FEE_BPS, MAX_FEE_NUMERATOR, MAX_MIGRATED_POOL_FEE_BPS, MAX_MIGRATION_FEE_PERCENTAGE, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_RATE_LIMITER_DURATION_IN_SECONDS, MAX_RATE_LIMITER_DURATION_IN_SLOTS, MAX_SQRT_PRICE, METAPLEX_PROGRAM_ID, MIN_FEE_BPS, MIN_FEE_NUMERATOR, MIN_MIGRATED_POOL_FEE_BPS, MIN_SQRT_PRICE, type MeteoraDammMigrationMetadata, type MigrateToDammV1Params, type MigrateToDammV2Params, type MigrateToDammV2Response, type MigratedPoolFee, MigrationFeeOption, MigrationOption, MigrationService, OFFSET, ONE_Q64, PARTNER_SURPLUS_SHARE, type PartnerFirstBuyParams, type PartnerMetadata, PartnerService, type PartnerWithdrawSurplusParams, type PoolConfig, type PoolFeeParameters, type PoolFees, type PoolFeesConfig, PoolService, type PreCreatePoolParams, type PrepareSwapParams, RESOLUTION, type RateLimiterParams, Rounding, SLOT_DURATION, SWAP_BUFFER_PERCENTAGE, SafeMath, StateService, type Swap2Params, type SwapAmount, SwapMode, type SwapParams, type SwapQuote2Params, type SwapQuote2Result, type SwapQuoteParams, type SwapQuoteResult, type SwapResult, type SwapResult2, TIMESTAMP_DURATION, TokenDecimal, TokenType, TokenUpdateAuthorityOption, TradeDirection, type TransferPoolCreatorParams, U128_MAX, U16_MAX, U64_MAX, VAULT_PROGRAM_ID, type VirtualPool, type VirtualPoolMetadata, type VolatilityTracker, type WithdrawLeftoverParams, type WithdrawMigrationFeeParams, bpsToFeeNumerator, buildCurve, buildCurveWithLiquidityWeights, buildCurveWithMarketCap, buildCurveWithMidPrice, buildCurveWithTwoSegments, calculateBaseToQuoteFromAmountIn, calculateBaseToQuoteFromAmountOut, calculateFeeSchedulerEndingBaseFeeBps, calculateQuoteToBaseFromAmountIn, calculateQuoteToBaseFromAmountOut, checkRateLimiterApplied, cleanUpTokenAccountTx, convertDecimalToBN, convertToLamports, createDammV1Program, createDammV2Program, createDbcProgram, createInitializePermissionlessDynamicVaultIx, createLockEscrowIx, createProgramAccountFilter, createVaultProgram, deriveBaseKeyForLocker, deriveDammV1EventAuthority, deriveDammV1LockEscrowAddress, deriveDammV1LpMintAddress, deriveDammV1MigrationMetadataAddress, deriveDammV1PoolAddress, deriveDammV1PoolAuthority, deriveDammV1ProtocolFeeAddress, deriveDammV1VaultLPAddress, deriveDammV2EventAuthority, deriveDammV2LockEscrowAddress, deriveDammV2MigrationMetadataAddress, deriveDammV2PoolAddress, deriveDammV2PoolAuthority, deriveDammV2TokenVaultAddress, deriveDbcEventAuthority, deriveDbcPoolAddress, deriveDbcPoolAuthority, deriveDbcPoolMetadata, deriveDbcTokenVaultAddress, deriveEscrow, deriveLockerEventAuthority, deriveMintMetadata, derivePartnerMetadata, derivePositionAddress, derivePositionNftAccount, deriveTokenVaultKey, deriveVaultAddress, deriveVaultLpMintAddress, deriveVaultPdas, feeNumeratorToBps, findAssociatedTokenAddress, fromDecimalToBN, getAccountCreationTimestamp, getAccountCreationTimestamps, getAccountData, getBaseFeeHandler, getBaseFeeNumerator, getBaseFeeNumeratorByPeriod, getBaseFeeParams, getBaseTokenForSwap, getCheckedAmounts, getCurrentPoint, getCurveBreakdown, getDeltaAmountBaseUnsigned, getDeltaAmountBaseUnsigned256, getDeltaAmountBaseUnsignedUnchecked, getDeltaAmountQuoteUnsigned, getDeltaAmountQuoteUnsigned256, getDeltaAmountQuoteUnsignedUnchecked, getDynamicFeeParams, getExcludedFeeAmount, getFeeMode, getFeeNumeratorFromExcludedAmount, getFeeNumeratorFromIncludedAmount, getFeeNumeratorOnExponentialFeeScheduler, getFeeNumeratorOnLinearFeeScheduler, getFeeOnAmount, getFeeSchedulerParams, getFirstCurve, getFirstKey, getIncludedFeeAmount, getInitialLiquidityFromDeltaBase, getInitialLiquidityFromDeltaQuote, getLiquidity, getLockedVestingParams, getMaxBaseFeeNumerator, getMaxIndex, getMaxOutAmountWithMinBaseFee, getMigratedPoolFeeParams, getMigrationBaseToken, getMigrationQuoteAmount, getMigrationQuoteAmountFromMigrationQuoteThreshold, getMigrationQuoteThresholdFromMigrationQuoteAmount, getMigrationThresholdPrice, getMinBaseFeeNumerator, getNextSqrtPriceFromBaseAmountInRoundingUp, getNextSqrtPriceFromBaseAmountOutRoundingUp, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getNextSqrtPriceFromQuoteAmountInRoundingDown, getNextSqrtPriceFromQuoteAmountOutRoundingDown, getOrCreateATAInstruction, getPercentageSupplyOnMigration, getPriceFromSqrtPrice, getQuoteReserveFromNextSqrtPrice, getRateLimiterExcludedFeeAmount, getRateLimiterParams, getSecondKey, getSqrtPriceFromMarketCap, getSqrtPriceFromPrice, getSwapAmountWithBuffer, getSwapResult, getSwapResultFromExactInput, getSwapResultFromExactOutput, getSwapResultFromPartialInput, getTokenDecimals, getTokenProgram, getTokenType, getTokenomics, getTotalFeeNumerator, getTotalFeeNumeratorFromExcludedFeeAmount, getTotalFeeNumeratorFromIncludedFeeAmount, getTotalSupplyFromCurve, getTotalTokenSupply, getTotalVestingAmount, getTwoCurve, getVariableFeeNumerator, isDefaultLockedVesting, isDynamicFeeEnabled, isNativeSol, isNonZeroRateLimiter, isRateLimiterApplied, isZeroRateLimiter, mulDiv, mulShr, pow, prepareSwapAmountParam, prepareTokenAccountTx, splitFees, sqrt, swapQuote, swapQuoteExactIn, swapQuoteExactOut, swapQuotePartialFill, toNumerator, unwrapSOLInstruction, validateActivationType, validateBalance, validateBaseTokenType, validateCollectFeeMode, validateConfigParameters, validateCurve, validateFeeRateLimiter, validateFeeScheduler, validateLPPercentages, validateMigratedPoolFee, validateMigrationAndTokenType, validateMigrationFee, validateMigrationFeeOption, validatePoolFees, validateSwapAmount, validateTokenDecimals, validateTokenSupply, validateTokenUpdateAuthorityOptions, wrapSOLInstruction };
|
package/dist/index.js
CHANGED
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
} from "@solana/web3.js";
|
|
8
8
|
|
|
9
9
|
// src/types.ts
|
|
10
|
-
var ActivationType = /* @__PURE__ */ ((
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
10
|
+
var ActivationType = /* @__PURE__ */ ((ActivationType4) => {
|
|
11
|
+
ActivationType4[ActivationType4["Slot"] = 0] = "Slot";
|
|
12
|
+
ActivationType4[ActivationType4["Timestamp"] = 1] = "Timestamp";
|
|
13
|
+
return ActivationType4;
|
|
14
14
|
})(ActivationType || {});
|
|
15
15
|
var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
16
16
|
TokenType2[TokenType2["SPL"] = 0] = "SPL";
|
|
@@ -933,6 +933,56 @@ var getMigrationThresholdPrice = (migrationThreshold, sqrtStartPrice, curve) =>
|
|
|
933
933
|
}
|
|
934
934
|
return nextSqrtPrice;
|
|
935
935
|
};
|
|
936
|
+
var getCurveBreakdown = (migrationQuoteThreshold, sqrtStartPrice, curve) => {
|
|
937
|
+
if (curve.length === 0) {
|
|
938
|
+
throw Error("Curve is empty");
|
|
939
|
+
}
|
|
940
|
+
const segmentAmounts = [];
|
|
941
|
+
let totalAllocated = new BN6(0);
|
|
942
|
+
let currentSqrtPrice = sqrtStartPrice;
|
|
943
|
+
let finalSqrtPrice = sqrtStartPrice;
|
|
944
|
+
for (let i = 0; i < curve.length; i++) {
|
|
945
|
+
const lowerSqrtPrice = currentSqrtPrice;
|
|
946
|
+
const upperSqrtPrice = curve[i].sqrtPrice;
|
|
947
|
+
const liquidity = curve[i].liquidity;
|
|
948
|
+
const maxSegmentAmount = getDeltaAmountQuoteUnsigned(
|
|
949
|
+
lowerSqrtPrice,
|
|
950
|
+
upperSqrtPrice,
|
|
951
|
+
liquidity,
|
|
952
|
+
0 /* Up */
|
|
953
|
+
);
|
|
954
|
+
if (maxSegmentAmount.gte(migrationQuoteThreshold)) {
|
|
955
|
+
segmentAmounts.push(migrationQuoteThreshold);
|
|
956
|
+
totalAllocated = totalAllocated.add(migrationQuoteThreshold);
|
|
957
|
+
finalSqrtPrice = getNextSqrtPriceFromInput(
|
|
958
|
+
lowerSqrtPrice,
|
|
959
|
+
liquidity,
|
|
960
|
+
migrationQuoteThreshold,
|
|
961
|
+
false
|
|
962
|
+
);
|
|
963
|
+
for (let j = i + 1; j < curve.length; j++) {
|
|
964
|
+
segmentAmounts.push(new BN6(0));
|
|
965
|
+
}
|
|
966
|
+
break;
|
|
967
|
+
} else {
|
|
968
|
+
segmentAmounts.push(maxSegmentAmount);
|
|
969
|
+
totalAllocated = totalAllocated.add(maxSegmentAmount);
|
|
970
|
+
currentSqrtPrice = upperSqrtPrice;
|
|
971
|
+
finalSqrtPrice = upperSqrtPrice;
|
|
972
|
+
if (i === curve.length - 1 && totalAllocated.lt(migrationQuoteThreshold)) {
|
|
973
|
+
const shortfall = migrationQuoteThreshold.sub(totalAllocated);
|
|
974
|
+
throw Error(
|
|
975
|
+
`Not enough liquidity in curve. Total allocated: ${totalAllocated.toString()}, Required: ${migrationQuoteThreshold.toString()}, Shortfall: ${shortfall.toString()}`
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return {
|
|
981
|
+
segmentAmounts,
|
|
982
|
+
finalSqrtPrice,
|
|
983
|
+
totalAmount: totalAllocated
|
|
984
|
+
};
|
|
985
|
+
};
|
|
936
986
|
var getSwapAmountWithBuffer = (swapBaseAmount, sqrtStartPrice, curve) => {
|
|
937
987
|
const swapAmountBuffer = swapBaseAmount.add(
|
|
938
988
|
swapBaseAmount.mul(new BN6(SWAP_BUFFER_PERCENTAGE)).div(new BN6(100))
|
|
@@ -3532,7 +3582,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3532
3582
|
let product2 = numerator3.mul(numerator4);
|
|
3533
3583
|
let midSqrtPriceDecimal3 = Decimal4.pow(product2, 0.25);
|
|
3534
3584
|
let midSqrtPrice3 = new BN14(midSqrtPriceDecimal3.floor().toFixed());
|
|
3535
|
-
let midPrices = [
|
|
3585
|
+
let midPrices = [midSqrtPrice3, midSqrtPrice2, midSqrtPrice1];
|
|
3536
3586
|
let sqrtStartPrice = new BN14(0);
|
|
3537
3587
|
let curve = [];
|
|
3538
3588
|
for (let i = 0; i < midPrices.length; i++) {
|
|
@@ -3603,6 +3653,165 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3603
3653
|
};
|
|
3604
3654
|
return instructionParams;
|
|
3605
3655
|
}
|
|
3656
|
+
function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
|
|
3657
|
+
const {
|
|
3658
|
+
totalTokenSupply,
|
|
3659
|
+
initialMarketCap,
|
|
3660
|
+
migrationMarketCap,
|
|
3661
|
+
midPrice,
|
|
3662
|
+
percentageSupplyOnMigration,
|
|
3663
|
+
migrationOption,
|
|
3664
|
+
tokenBaseDecimal,
|
|
3665
|
+
tokenQuoteDecimal,
|
|
3666
|
+
creatorTradingFeePercentage,
|
|
3667
|
+
collectFeeMode,
|
|
3668
|
+
leftover,
|
|
3669
|
+
tokenType,
|
|
3670
|
+
partnerLpPercentage,
|
|
3671
|
+
creatorLpPercentage,
|
|
3672
|
+
partnerLockedLpPercentage,
|
|
3673
|
+
creatorLockedLpPercentage,
|
|
3674
|
+
activationType,
|
|
3675
|
+
dynamicFeeEnabled,
|
|
3676
|
+
migrationFeeOption,
|
|
3677
|
+
migrationFee,
|
|
3678
|
+
tokenUpdateAuthority,
|
|
3679
|
+
baseFeeParams,
|
|
3680
|
+
migratedPoolFee
|
|
3681
|
+
} = buildCurveWithMidPriceParam;
|
|
3682
|
+
const baseFee = getBaseFeeParams(
|
|
3683
|
+
baseFeeParams,
|
|
3684
|
+
tokenQuoteDecimal,
|
|
3685
|
+
activationType
|
|
3686
|
+
);
|
|
3687
|
+
const {
|
|
3688
|
+
totalLockedVestingAmount,
|
|
3689
|
+
numberOfVestingPeriod,
|
|
3690
|
+
cliffUnlockAmount,
|
|
3691
|
+
totalVestingDuration,
|
|
3692
|
+
cliffDurationFromMigrationTime
|
|
3693
|
+
} = buildCurveWithMidPriceParam.lockedVestingParam;
|
|
3694
|
+
const lockedVesting = getLockedVestingParams(
|
|
3695
|
+
totalLockedVestingAmount,
|
|
3696
|
+
numberOfVestingPeriod,
|
|
3697
|
+
cliffUnlockAmount,
|
|
3698
|
+
totalVestingDuration,
|
|
3699
|
+
cliffDurationFromMigrationTime,
|
|
3700
|
+
tokenBaseDecimal
|
|
3701
|
+
);
|
|
3702
|
+
const migratedPoolFeeParams = getMigratedPoolFeeParams(
|
|
3703
|
+
migrationOption,
|
|
3704
|
+
migrationFeeOption,
|
|
3705
|
+
migratedPoolFee
|
|
3706
|
+
);
|
|
3707
|
+
let migrationBaseSupply = new BN14(totalTokenSupply).mul(new BN14(percentageSupplyOnMigration)).div(new BN14(100));
|
|
3708
|
+
let totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
3709
|
+
let migrationQuoteAmount = getMigrationQuoteAmount(
|
|
3710
|
+
new Decimal4(migrationMarketCap),
|
|
3711
|
+
new Decimal4(percentageSupplyOnMigration)
|
|
3712
|
+
);
|
|
3713
|
+
let migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
|
|
3714
|
+
migrationQuoteAmount,
|
|
3715
|
+
new Decimal4(migrationFee.feePercentage)
|
|
3716
|
+
);
|
|
3717
|
+
let migrationPrice = migrationQuoteAmount.div(
|
|
3718
|
+
new Decimal4(migrationBaseSupply.toString())
|
|
3719
|
+
);
|
|
3720
|
+
let migrationQuoteThresholdInLamport = fromDecimalToBN(
|
|
3721
|
+
migrationQuoteThreshold.mul(new Decimal4(10 ** tokenQuoteDecimal))
|
|
3722
|
+
);
|
|
3723
|
+
let migrationQuoteAmountInLamport = fromDecimalToBN(
|
|
3724
|
+
migrationQuoteAmount.mul(new Decimal4(10 ** tokenQuoteDecimal))
|
|
3725
|
+
);
|
|
3726
|
+
let migrateSqrtPrice = getSqrtPriceFromPrice(
|
|
3727
|
+
migrationPrice.toString(),
|
|
3728
|
+
tokenBaseDecimal,
|
|
3729
|
+
tokenQuoteDecimal
|
|
3730
|
+
);
|
|
3731
|
+
let migrationBaseAmount = getMigrationBaseToken(
|
|
3732
|
+
migrationQuoteAmountInLamport,
|
|
3733
|
+
migrateSqrtPrice,
|
|
3734
|
+
migrationOption
|
|
3735
|
+
);
|
|
3736
|
+
let totalVestingAmount = getTotalVestingAmount(lockedVesting);
|
|
3737
|
+
let totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
|
|
3738
|
+
let swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
|
|
3739
|
+
let initialSqrtPrice = getSqrtPriceFromMarketCap(
|
|
3740
|
+
initialMarketCap,
|
|
3741
|
+
totalTokenSupply,
|
|
3742
|
+
tokenBaseDecimal,
|
|
3743
|
+
tokenQuoteDecimal
|
|
3744
|
+
);
|
|
3745
|
+
const midSqrtPrice = getSqrtPriceFromPrice(
|
|
3746
|
+
midPrice.toString(),
|
|
3747
|
+
tokenBaseDecimal,
|
|
3748
|
+
tokenQuoteDecimal
|
|
3749
|
+
);
|
|
3750
|
+
let sqrtStartPrice = new BN14(0);
|
|
3751
|
+
let curve = [];
|
|
3752
|
+
const result = getTwoCurve(
|
|
3753
|
+
migrateSqrtPrice,
|
|
3754
|
+
midSqrtPrice,
|
|
3755
|
+
initialSqrtPrice,
|
|
3756
|
+
swapAmount,
|
|
3757
|
+
migrationQuoteThresholdInLamport
|
|
3758
|
+
);
|
|
3759
|
+
curve = result.curve;
|
|
3760
|
+
sqrtStartPrice = result.sqrtStartPrice;
|
|
3761
|
+
let totalDynamicSupply = getTotalSupplyFromCurve(
|
|
3762
|
+
migrationQuoteThresholdInLamport,
|
|
3763
|
+
sqrtStartPrice,
|
|
3764
|
+
curve,
|
|
3765
|
+
lockedVesting,
|
|
3766
|
+
migrationOption,
|
|
3767
|
+
totalLeftover,
|
|
3768
|
+
migrationFee.feePercentage
|
|
3769
|
+
);
|
|
3770
|
+
if (totalDynamicSupply.gt(totalSupply)) {
|
|
3771
|
+
let leftOverDelta = totalDynamicSupply.sub(totalSupply);
|
|
3772
|
+
if (!leftOverDelta.lt(totalLeftover)) {
|
|
3773
|
+
throw new Error("leftOverDelta must be less than totalLeftover");
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
const instructionParams = {
|
|
3777
|
+
poolFees: {
|
|
3778
|
+
baseFee: {
|
|
3779
|
+
...baseFee
|
|
3780
|
+
},
|
|
3781
|
+
dynamicFee: dynamicFeeEnabled ? getDynamicFeeParams(
|
|
3782
|
+
baseFeeParams.baseFeeMode === 2 /* RateLimiter */ ? baseFeeParams.rateLimiterParam.baseFeeBps : baseFeeParams.feeSchedulerParam.endingFeeBps
|
|
3783
|
+
) : null
|
|
3784
|
+
},
|
|
3785
|
+
activationType,
|
|
3786
|
+
collectFeeMode,
|
|
3787
|
+
migrationOption,
|
|
3788
|
+
tokenType,
|
|
3789
|
+
tokenDecimal: tokenBaseDecimal,
|
|
3790
|
+
migrationQuoteThreshold: migrationQuoteThresholdInLamport,
|
|
3791
|
+
partnerLpPercentage,
|
|
3792
|
+
creatorLpPercentage,
|
|
3793
|
+
partnerLockedLpPercentage,
|
|
3794
|
+
creatorLockedLpPercentage,
|
|
3795
|
+
sqrtStartPrice,
|
|
3796
|
+
lockedVesting,
|
|
3797
|
+
migrationFeeOption,
|
|
3798
|
+
tokenSupply: {
|
|
3799
|
+
preMigrationTokenSupply: totalSupply,
|
|
3800
|
+
postMigrationTokenSupply: totalSupply
|
|
3801
|
+
},
|
|
3802
|
+
creatorTradingFeePercentage,
|
|
3803
|
+
migratedPoolFee: {
|
|
3804
|
+
collectFeeMode: migratedPoolFeeParams.collectFeeMode,
|
|
3805
|
+
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
3806
|
+
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
3807
|
+
},
|
|
3808
|
+
padding: [],
|
|
3809
|
+
curve,
|
|
3810
|
+
tokenUpdateAuthority,
|
|
3811
|
+
migrationFee
|
|
3812
|
+
};
|
|
3813
|
+
return instructionParams;
|
|
3814
|
+
}
|
|
3606
3815
|
function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
3607
3816
|
let {
|
|
3608
3817
|
totalTokenSupply,
|
|
@@ -25148,7 +25357,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25148
25357
|
* @param quoteMint - The quote mint token
|
|
25149
25358
|
* @returns Instructions for the first buy
|
|
25150
25359
|
*/
|
|
25151
|
-
async swapBuyTx(firstBuyParam, baseMint, config, baseFee, swapBaseForQuote,
|
|
25360
|
+
async swapBuyTx(firstBuyParam, baseMint, config, baseFee, swapBaseForQuote, activationType, tokenType, quoteMint) {
|
|
25152
25361
|
const {
|
|
25153
25362
|
buyer,
|
|
25154
25363
|
receiver,
|
|
@@ -25159,6 +25368,10 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25159
25368
|
validateSwapAmount(buyAmount);
|
|
25160
25369
|
let rateLimiterApplied = false;
|
|
25161
25370
|
if (baseFee.baseFeeMode === 2 /* RateLimiter */) {
|
|
25371
|
+
const currentPoint = await getCurrentPoint(
|
|
25372
|
+
this.connection,
|
|
25373
|
+
activationType
|
|
25374
|
+
);
|
|
25162
25375
|
rateLimiterApplied = isRateLimiterApplied(
|
|
25163
25376
|
currentPoint,
|
|
25164
25377
|
new BN16(0),
|
|
@@ -25380,10 +25593,6 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25380
25593
|
params.tokenType,
|
|
25381
25594
|
quoteMintToken
|
|
25382
25595
|
);
|
|
25383
|
-
const currentPoint = await getCurrentPoint(
|
|
25384
|
-
this.connection,
|
|
25385
|
-
configParam.activationType
|
|
25386
|
-
);
|
|
25387
25596
|
let swapBuyTx;
|
|
25388
25597
|
if (params.firstBuyParam && params.firstBuyParam.buyAmount.gt(new BN16(0))) {
|
|
25389
25598
|
swapBuyTx = await this.swapBuyTx(
|
|
@@ -25392,7 +25601,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25392
25601
|
configKey,
|
|
25393
25602
|
configParam.poolFees.baseFee,
|
|
25394
25603
|
false,
|
|
25395
|
-
|
|
25604
|
+
configParam.activationType,
|
|
25396
25605
|
params.tokenType,
|
|
25397
25606
|
quoteMintToken
|
|
25398
25607
|
);
|
|
@@ -25422,10 +25631,6 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25422
25631
|
tokenType,
|
|
25423
25632
|
quoteMint
|
|
25424
25633
|
);
|
|
25425
|
-
const currentPoint = await getCurrentPoint(
|
|
25426
|
-
this.connection,
|
|
25427
|
-
poolConfigState.activationType
|
|
25428
|
-
);
|
|
25429
25634
|
let swapBuyTx;
|
|
25430
25635
|
if (firstBuyParam && firstBuyParam.buyAmount.gt(new BN16(0))) {
|
|
25431
25636
|
swapBuyTx = await this.swapBuyTx(
|
|
@@ -25434,7 +25639,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25434
25639
|
config,
|
|
25435
25640
|
poolConfigState.poolFees.baseFee,
|
|
25436
25641
|
false,
|
|
25437
|
-
|
|
25642
|
+
poolConfigState.activationType,
|
|
25438
25643
|
tokenType,
|
|
25439
25644
|
quoteMint
|
|
25440
25645
|
);
|
|
@@ -25461,10 +25666,6 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25461
25666
|
tokenType,
|
|
25462
25667
|
quoteMint
|
|
25463
25668
|
);
|
|
25464
|
-
const currentPoint = await getCurrentPoint(
|
|
25465
|
-
this.connection,
|
|
25466
|
-
poolConfigState.activationType
|
|
25467
|
-
);
|
|
25468
25669
|
let partnerSwapBuyTx;
|
|
25469
25670
|
if (partnerFirstBuyParam && partnerFirstBuyParam.buyAmount.gt(new BN16(0))) {
|
|
25470
25671
|
partnerSwapBuyTx = await this.swapBuyTx(
|
|
@@ -25479,7 +25680,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25479
25680
|
config,
|
|
25480
25681
|
poolConfigState.poolFees.baseFee,
|
|
25481
25682
|
false,
|
|
25482
|
-
|
|
25683
|
+
poolConfigState.activationType,
|
|
25483
25684
|
tokenType,
|
|
25484
25685
|
quoteMint
|
|
25485
25686
|
);
|
|
@@ -25498,7 +25699,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25498
25699
|
config,
|
|
25499
25700
|
poolConfigState.poolFees.baseFee,
|
|
25500
25701
|
false,
|
|
25501
|
-
|
|
25702
|
+
poolConfigState.activationType,
|
|
25502
25703
|
tokenType,
|
|
25503
25704
|
quoteMint
|
|
25504
25705
|
);
|
|
@@ -25539,12 +25740,12 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25539
25740
|
throw new Error(`Pool config not found for virtual pool`);
|
|
25540
25741
|
}
|
|
25541
25742
|
validateSwapAmount(amountIn);
|
|
25542
|
-
const currentPoint = await getCurrentPoint(
|
|
25543
|
-
this.connection,
|
|
25544
|
-
poolConfigState.activationType
|
|
25545
|
-
);
|
|
25546
25743
|
let rateLimiterApplied = false;
|
|
25547
25744
|
if (poolConfigState.poolFees.baseFee.baseFeeMode === 2 /* RateLimiter */) {
|
|
25745
|
+
const currentPoint = await getCurrentPoint(
|
|
25746
|
+
this.connection,
|
|
25747
|
+
poolConfigState.activationType
|
|
25748
|
+
);
|
|
25548
25749
|
rateLimiterApplied = isRateLimiterApplied(
|
|
25549
25750
|
currentPoint,
|
|
25550
25751
|
poolState.activationPoint,
|
|
@@ -25650,12 +25851,12 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
25650
25851
|
if (!poolConfigState) {
|
|
25651
25852
|
throw new Error(`Pool config not found for virtual pool`);
|
|
25652
25853
|
}
|
|
25653
|
-
const currentPoint = await getCurrentPoint(
|
|
25654
|
-
this.connection,
|
|
25655
|
-
poolConfigState.activationType
|
|
25656
|
-
);
|
|
25657
25854
|
let rateLimiterApplied = false;
|
|
25658
25855
|
if (poolConfigState.poolFees.baseFee.baseFeeMode === 2 /* RateLimiter */) {
|
|
25856
|
+
const currentPoint = await getCurrentPoint(
|
|
25857
|
+
this.connection,
|
|
25858
|
+
poolConfigState.activationType
|
|
25859
|
+
);
|
|
25659
25860
|
rateLimiterApplied = isRateLimiterApplied(
|
|
25660
25861
|
currentPoint,
|
|
25661
25862
|
poolState.activationPoint,
|
|
@@ -26358,6 +26559,7 @@ export {
|
|
|
26358
26559
|
buildCurve,
|
|
26359
26560
|
buildCurveWithLiquidityWeights,
|
|
26360
26561
|
buildCurveWithMarketCap,
|
|
26562
|
+
buildCurveWithMidPrice,
|
|
26361
26563
|
buildCurveWithTwoSegments,
|
|
26362
26564
|
calculateBaseToQuoteFromAmountIn,
|
|
26363
26565
|
calculateBaseToQuoteFromAmountOut,
|
|
@@ -26418,6 +26620,7 @@ export {
|
|
|
26418
26620
|
getBaseTokenForSwap,
|
|
26419
26621
|
getCheckedAmounts,
|
|
26420
26622
|
getCurrentPoint,
|
|
26623
|
+
getCurveBreakdown,
|
|
26421
26624
|
getDeltaAmountBaseUnsigned,
|
|
26422
26625
|
getDeltaAmountBaseUnsigned256,
|
|
26423
26626
|
getDeltaAmountBaseUnsignedUnchecked,
|