@meteora-ag/dynamic-bonding-curve-sdk 1.5.2 → 1.5.4
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 +355 -256
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +111 -63
- package/dist/index.d.ts +111 -63
- package/dist/index.js +350 -251
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -18,15 +18,15 @@ var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
|
18
18
|
TokenType2[TokenType2["Token2022"] = 1] = "Token2022";
|
|
19
19
|
return TokenType2;
|
|
20
20
|
})(TokenType || {});
|
|
21
|
-
var CollectFeeMode = /* @__PURE__ */ ((
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
21
|
+
var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode3) => {
|
|
22
|
+
CollectFeeMode3[CollectFeeMode3["QuoteToken"] = 0] = "QuoteToken";
|
|
23
|
+
CollectFeeMode3[CollectFeeMode3["OutputToken"] = 1] = "OutputToken";
|
|
24
|
+
return CollectFeeMode3;
|
|
25
25
|
})(CollectFeeMode || {});
|
|
26
|
-
var DammV2DynamicFeeMode = /* @__PURE__ */ ((
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
26
|
+
var DammV2DynamicFeeMode = /* @__PURE__ */ ((DammV2DynamicFeeMode2) => {
|
|
27
|
+
DammV2DynamicFeeMode2[DammV2DynamicFeeMode2["Disabled"] = 0] = "Disabled";
|
|
28
|
+
DammV2DynamicFeeMode2[DammV2DynamicFeeMode2["Enabled"] = 1] = "Enabled";
|
|
29
|
+
return DammV2DynamicFeeMode2;
|
|
30
30
|
})(DammV2DynamicFeeMode || {});
|
|
31
31
|
var DammV2BaseFeeMode = /* @__PURE__ */ ((DammV2BaseFeeMode2) => {
|
|
32
32
|
DammV2BaseFeeMode2[DammV2BaseFeeMode2["FeeTimeSchedulerLinear"] = 0] = "FeeTimeSchedulerLinear";
|
|
@@ -182,6 +182,11 @@ var DAMM_V2_MIGRATION_FEE_ADDRESS = [
|
|
|
182
182
|
new (0, _web3js.PublicKey)("A8gMrEPJkacWkcb3DGwtJwTe16HktSEfvwtuDh2MCtck")
|
|
183
183
|
// Customizable
|
|
184
184
|
];
|
|
185
|
+
var DEFAULT_MIGRATED_POOL_FEE_PARAMS = {
|
|
186
|
+
collectFeeMode: 0,
|
|
187
|
+
dynamicFee: 0,
|
|
188
|
+
poolFeeBps: 0
|
|
189
|
+
};
|
|
185
190
|
var DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS = {
|
|
186
191
|
vestingPercentage: 0,
|
|
187
192
|
bpsPerPeriod: 0,
|
|
@@ -2820,11 +2825,6 @@ function checkRateLimiterApplied(baseFeeMode, swapBaseForQuote, currentPoint, ac
|
|
|
2820
2825
|
}
|
|
2821
2826
|
function getBaseFeeParams(baseFeeParams, tokenQuoteDecimal, activationType) {
|
|
2822
2827
|
if (baseFeeParams.baseFeeMode === 2 /* RateLimiter */) {
|
|
2823
|
-
if (!baseFeeParams.rateLimiterParam) {
|
|
2824
|
-
throw new Error(
|
|
2825
|
-
"Rate limiter parameters are required for RateLimiter mode"
|
|
2826
|
-
);
|
|
2827
|
-
}
|
|
2828
2828
|
const {
|
|
2829
2829
|
baseFeeBps,
|
|
2830
2830
|
feeIncrementBps,
|
|
@@ -2840,11 +2840,6 @@ function getBaseFeeParams(baseFeeParams, tokenQuoteDecimal, activationType) {
|
|
|
2840
2840
|
activationType
|
|
2841
2841
|
);
|
|
2842
2842
|
} else {
|
|
2843
|
-
if (!baseFeeParams.feeSchedulerParam) {
|
|
2844
|
-
throw new Error(
|
|
2845
|
-
"Fee scheduler parameters are required for FeeScheduler mode"
|
|
2846
|
-
);
|
|
2847
|
-
}
|
|
2848
2843
|
const { startingFeeBps, endingFeeBps, numberOfPeriod, totalDuration } = baseFeeParams.feeSchedulerParam;
|
|
2849
2844
|
return getFeeSchedulerParams(
|
|
2850
2845
|
startingFeeBps,
|
|
@@ -2889,22 +2884,59 @@ var getTokenomics = (initialMarketCap, migrationMarketCap, totalLockedVestingAmo
|
|
|
2889
2884
|
lockedVestingSupply: totalLockedVestingAmount
|
|
2890
2885
|
};
|
|
2891
2886
|
};
|
|
2892
|
-
function getMigratedPoolFeeParams(migrationOption, migrationFeeOption, migratedPoolFee) {
|
|
2893
|
-
const
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2887
|
+
function getMigratedPoolFeeParams(migrationOption, migrationFeeOption, migratedPoolFee, baseFeeParams) {
|
|
2888
|
+
const defaultResult = {
|
|
2889
|
+
migratedPoolFee: DEFAULT_MIGRATED_POOL_FEE_PARAMS,
|
|
2890
|
+
migratedPoolBaseFeeMode: 0 /* FeeTimeSchedulerLinear */,
|
|
2891
|
+
migratedPoolMarketCapFeeSchedulerParams: DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS,
|
|
2892
|
+
migrationFeeOption
|
|
2897
2893
|
};
|
|
2898
2894
|
if (migrationOption === 0 /* MET_DAMM */) {
|
|
2899
|
-
return
|
|
2895
|
+
return defaultResult;
|
|
2900
2896
|
}
|
|
2901
2897
|
if (migrationOption === 1 /* MET_DAMM_V2 */) {
|
|
2898
|
+
const baseFeeMode = _nullishCoalesce(_optionalChain([migratedPoolFee, 'optionalAccess', _3 => _3.baseFeeMode]), () => ( 0)) /* FeeTimeSchedulerLinear */;
|
|
2899
|
+
if (_optionalChain([migratedPoolFee, 'optionalAccess', _4 => _4.marketCapFeeSchedulerParams]) && baseFeeParams) {
|
|
2900
|
+
const schedulerParams = getMigratedPoolMarketCapFeeSchedulerParams(
|
|
2901
|
+
getStartingBaseFeeBpsFromBaseFeeParams(baseFeeParams),
|
|
2902
|
+
migratedPoolFee.marketCapFeeSchedulerParams.endingBaseFeeBps,
|
|
2903
|
+
baseFeeMode,
|
|
2904
|
+
migratedPoolFee.marketCapFeeSchedulerParams.numberOfPeriod,
|
|
2905
|
+
migratedPoolFee.marketCapFeeSchedulerParams.sqrtPriceStepBps,
|
|
2906
|
+
migratedPoolFee.marketCapFeeSchedulerParams.schedulerExpirationDuration
|
|
2907
|
+
);
|
|
2908
|
+
return {
|
|
2909
|
+
migratedPoolFee: {
|
|
2910
|
+
collectFeeMode: migratedPoolFee.collectFeeMode,
|
|
2911
|
+
dynamicFee: migratedPoolFee.dynamicFee,
|
|
2912
|
+
poolFeeBps: migratedPoolFee.poolFeeBps
|
|
2913
|
+
},
|
|
2914
|
+
migratedPoolBaseFeeMode: baseFeeMode,
|
|
2915
|
+
migratedPoolMarketCapFeeSchedulerParams: schedulerParams,
|
|
2916
|
+
// force Customizable when using market cap fee scheduler
|
|
2917
|
+
migrationFeeOption: 6 /* Customizable */
|
|
2918
|
+
};
|
|
2919
|
+
}
|
|
2902
2920
|
if (migrationFeeOption === 6 /* Customizable */) {
|
|
2903
|
-
return
|
|
2921
|
+
return {
|
|
2922
|
+
migratedPoolFee: {
|
|
2923
|
+
collectFeeMode: _nullishCoalesce(_optionalChain([migratedPoolFee, 'optionalAccess', _5 => _5.collectFeeMode]), () => ( DEFAULT_MIGRATED_POOL_FEE_PARAMS.collectFeeMode)),
|
|
2924
|
+
dynamicFee: _nullishCoalesce(_optionalChain([migratedPoolFee, 'optionalAccess', _6 => _6.dynamicFee]), () => ( DEFAULT_MIGRATED_POOL_FEE_PARAMS.dynamicFee)),
|
|
2925
|
+
poolFeeBps: _nullishCoalesce(_optionalChain([migratedPoolFee, 'optionalAccess', _7 => _7.poolFeeBps]), () => ( DEFAULT_MIGRATED_POOL_FEE_PARAMS.poolFeeBps))
|
|
2926
|
+
},
|
|
2927
|
+
migratedPoolBaseFeeMode: baseFeeMode,
|
|
2928
|
+
migratedPoolMarketCapFeeSchedulerParams: DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS,
|
|
2929
|
+
migrationFeeOption: 6 /* Customizable */
|
|
2930
|
+
};
|
|
2904
2931
|
}
|
|
2905
|
-
return
|
|
2932
|
+
return {
|
|
2933
|
+
migratedPoolFee: DEFAULT_MIGRATED_POOL_FEE_PARAMS,
|
|
2934
|
+
migratedPoolBaseFeeMode: baseFeeMode,
|
|
2935
|
+
migratedPoolMarketCapFeeSchedulerParams: DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS,
|
|
2936
|
+
migrationFeeOption
|
|
2937
|
+
};
|
|
2906
2938
|
}
|
|
2907
|
-
return
|
|
2939
|
+
return defaultResult;
|
|
2908
2940
|
}
|
|
2909
2941
|
async function getCurrentPoint(connection, activationType) {
|
|
2910
2942
|
const currentSlot = await connection.getSlot();
|
|
@@ -3395,7 +3427,7 @@ function validateCurve(curve, sqrtStartPrice) {
|
|
|
3395
3427
|
if (!curve || curve.length === 0 || curve.length > MAX_CURVE_POINT) {
|
|
3396
3428
|
return false;
|
|
3397
3429
|
}
|
|
3398
|
-
if (_optionalChain([curve, 'access',
|
|
3430
|
+
if (_optionalChain([curve, 'access', _8 => _8[0], 'optionalAccess', _9 => _9.sqrtPrice, 'access', _10 => _10.lte, 'call', _11 => _11(sqrtStartPrice)]) || _optionalChain([curve, 'access', _12 => _12[0], 'optionalAccess', _13 => _13.liquidity, 'access', _14 => _14.lte, 'call', _15 => _15(new (0, _bnjs2.default)(0))]) || _optionalChain([curve, 'access', _16 => _16[0], 'optionalAccess', _17 => _17.sqrtPrice, 'access', _18 => _18.gt, 'call', _19 => _19(new (0, _bnjs2.default)(MAX_SQRT_PRICE))])) {
|
|
3399
3431
|
return false;
|
|
3400
3432
|
}
|
|
3401
3433
|
for (let i = 1; i < curve.length; i++) {
|
|
@@ -3408,7 +3440,7 @@ function validateCurve(curve, sqrtStartPrice) {
|
|
|
3408
3440
|
return false;
|
|
3409
3441
|
}
|
|
3410
3442
|
}
|
|
3411
|
-
return !_optionalChain([curve, 'access',
|
|
3443
|
+
return !_optionalChain([curve, 'access', _20 => _20[curve.length - 1], 'optionalAccess', _21 => _21.sqrtPrice, 'access', _22 => _22.gt, 'call', _23 => _23(new (0, _bnjs2.default)(MAX_SQRT_PRICE))]);
|
|
3412
3444
|
}
|
|
3413
3445
|
function validateTokenSupply(tokenSupply, leftoverReceiver, swapBaseAmount, migrationBaseAmount, lockedVesting, swapBaseAmountBuffer) {
|
|
3414
3446
|
if (!tokenSupply) return true;
|
|
@@ -3477,17 +3509,25 @@ function validateMinimumLockedLiquidity(partnerPermanentLockedLiquidityPercentag
|
|
|
3477
3509
|
);
|
|
3478
3510
|
return lockedBpsAtDay1 >= MIN_LOCKED_LIQUIDITY_BPS;
|
|
3479
3511
|
}
|
|
3480
|
-
function validateMigratedPoolFee(migratedPoolFee, migrationOption, migrationFeeOption) {
|
|
3512
|
+
function validateMigratedPoolFee(migratedPoolFee, migrationOption, migrationFeeOption, migratedPoolMarketCapFeeSchedulerParams) {
|
|
3481
3513
|
const isEmpty = () => {
|
|
3482
3514
|
return migratedPoolFee.collectFeeMode === 0 && migratedPoolFee.dynamicFee === 0 && migratedPoolFee.poolFeeBps === 0;
|
|
3483
3515
|
};
|
|
3516
|
+
const isMarketCapFeeSchedulerConfigured = () => {
|
|
3517
|
+
if (!migratedPoolMarketCapFeeSchedulerParams) return false;
|
|
3518
|
+
return migratedPoolMarketCapFeeSchedulerParams.numberOfPeriod > 0 || migratedPoolMarketCapFeeSchedulerParams.sqrtPriceStepBps > 0 || migratedPoolMarketCapFeeSchedulerParams.schedulerExpirationDuration > 0 || !migratedPoolMarketCapFeeSchedulerParams.reductionFactor.eq(
|
|
3519
|
+
new (0, _bnjs2.default)(0)
|
|
3520
|
+
);
|
|
3521
|
+
};
|
|
3484
3522
|
if (migrationOption !== void 0 && migrationFeeOption !== void 0) {
|
|
3485
3523
|
if (migrationOption === 0 /* MET_DAMM */) {
|
|
3486
3524
|
return isEmpty();
|
|
3487
3525
|
}
|
|
3488
3526
|
if (migrationOption === 1 /* MET_DAMM_V2 */) {
|
|
3489
3527
|
if (migrationFeeOption !== 6 /* Customizable */) {
|
|
3490
|
-
|
|
3528
|
+
if (!isMarketCapFeeSchedulerConfigured()) {
|
|
3529
|
+
return isEmpty();
|
|
3530
|
+
}
|
|
3491
3531
|
}
|
|
3492
3532
|
}
|
|
3493
3533
|
}
|
|
@@ -3548,8 +3588,8 @@ function validateConfigParameters(configParam) {
|
|
|
3548
3588
|
if (!validateTokenDecimals(configParam.tokenDecimal)) {
|
|
3549
3589
|
throw new Error("Token decimal must be between 6 and 9");
|
|
3550
3590
|
}
|
|
3551
|
-
const partnerVestingPercentage = _nullishCoalesce(_optionalChain([configParam, 'access',
|
|
3552
|
-
const creatorVestingPercentage = _nullishCoalesce(_optionalChain([configParam, 'access',
|
|
3591
|
+
const partnerVestingPercentage = _nullishCoalesce(_optionalChain([configParam, 'access', _24 => _24.partnerLiquidityVestingInfo, 'optionalAccess', _25 => _25.vestingPercentage]), () => ( 0));
|
|
3592
|
+
const creatorVestingPercentage = _nullishCoalesce(_optionalChain([configParam, 'access', _26 => _26.creatorLiquidityVestingInfo, 'optionalAccess', _27 => _27.vestingPercentage]), () => ( 0));
|
|
3553
3593
|
if (!validateLPPercentages(
|
|
3554
3594
|
configParam.partnerLiquidityPercentage,
|
|
3555
3595
|
configParam.partnerPermanentLockedLiquidityPercentage,
|
|
@@ -3624,7 +3664,8 @@ function validateConfigParameters(configParam) {
|
|
|
3624
3664
|
if (!validateMigratedPoolFee(
|
|
3625
3665
|
configParam.migratedPoolFee,
|
|
3626
3666
|
configParam.migrationOption,
|
|
3627
|
-
configParam.migrationFeeOption
|
|
3667
|
+
configParam.migrationFeeOption,
|
|
3668
|
+
configParam.migratedPoolMarketCapFeeSchedulerParams
|
|
3628
3669
|
)) {
|
|
3629
3670
|
throw new Error("Invalid migrated pool fee parameters");
|
|
3630
3671
|
}
|
|
@@ -3635,6 +3676,10 @@ function validateConfigParameters(configParam) {
|
|
|
3635
3676
|
configParam.migratedPoolMarketCapFeeSchedulerParams,
|
|
3636
3677
|
configParam.migrationOption
|
|
3637
3678
|
);
|
|
3679
|
+
validateMarketCapFeeSchedulerRequiresPoolFeeBps(
|
|
3680
|
+
configParam.migratedPoolMarketCapFeeSchedulerParams,
|
|
3681
|
+
configParam.migratedPoolFee
|
|
3682
|
+
);
|
|
3638
3683
|
}
|
|
3639
3684
|
if (!validateCurve(configParam.curve, configParam.sqrtStartPrice)) {
|
|
3640
3685
|
throw new Error("Invalid curve");
|
|
@@ -3760,6 +3805,17 @@ function validateMigratedPoolBaseFeeMode(migratedPoolBaseFeeMode, migratedPoolMa
|
|
|
3760
3805
|
`Unknown migratedPoolBaseFeeMode: ${migratedPoolBaseFeeMode}`
|
|
3761
3806
|
);
|
|
3762
3807
|
}
|
|
3808
|
+
function validateMarketCapFeeSchedulerRequiresPoolFeeBps(migratedPoolMarketCapFeeSchedulerParams, migratedPoolFee) {
|
|
3809
|
+
const isMarketCapFeeSchedulerConfigured = migratedPoolMarketCapFeeSchedulerParams.numberOfPeriod > 0 || migratedPoolMarketCapFeeSchedulerParams.sqrtPriceStepBps > 0 || migratedPoolMarketCapFeeSchedulerParams.schedulerExpirationDuration > 0 || !migratedPoolMarketCapFeeSchedulerParams.reductionFactor.eq(new (0, _bnjs2.default)(0));
|
|
3810
|
+
if (isMarketCapFeeSchedulerConfigured) {
|
|
3811
|
+
if (!migratedPoolFee || migratedPoolFee.poolFeeBps === 0) {
|
|
3812
|
+
throw new Error(
|
|
3813
|
+
"When marketCapFeeSchedulerParams is configured, migratedPoolFee.poolFeeBps is required and must be greater than 0. The poolFeeBps serves as the starting (cliff) fee for the market cap fee scheduler."
|
|
3814
|
+
);
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
return true;
|
|
3818
|
+
}
|
|
3763
3819
|
function validateMigrationFee(migrationFee) {
|
|
3764
3820
|
if (!Number.isInteger(migrationFee.feePercentage) || !Number.isInteger(migrationFee.creatorFeePercentage)) {
|
|
3765
3821
|
throw new Error(
|
|
@@ -3782,37 +3838,47 @@ function validateMigrationFee(migrationFee) {
|
|
|
3782
3838
|
// src/helpers/buildCurve.ts
|
|
3783
3839
|
|
|
3784
3840
|
|
|
3785
|
-
function buildCurve(
|
|
3841
|
+
function buildCurve(params) {
|
|
3842
|
+
const {
|
|
3843
|
+
token,
|
|
3844
|
+
fee,
|
|
3845
|
+
migration,
|
|
3846
|
+
liquidityDistribution,
|
|
3847
|
+
lockedVesting,
|
|
3848
|
+
activationType,
|
|
3849
|
+
percentageSupplyOnMigration,
|
|
3850
|
+
migrationQuoteThreshold
|
|
3851
|
+
} = params;
|
|
3786
3852
|
const {
|
|
3787
|
-
totalTokenSupply,
|
|
3788
3853
|
tokenType,
|
|
3789
3854
|
tokenBaseDecimal,
|
|
3790
3855
|
tokenQuoteDecimal,
|
|
3791
3856
|
tokenUpdateAuthority,
|
|
3792
|
-
|
|
3793
|
-
leftover
|
|
3857
|
+
totalTokenSupply,
|
|
3858
|
+
leftover
|
|
3859
|
+
} = token;
|
|
3860
|
+
const {
|
|
3794
3861
|
baseFeeParams,
|
|
3795
3862
|
dynamicFeeEnabled,
|
|
3796
|
-
activationType,
|
|
3797
3863
|
collectFeeMode,
|
|
3798
3864
|
creatorTradingFeePercentage,
|
|
3799
3865
|
poolCreationFee,
|
|
3866
|
+
enableFirstSwapWithMinFee
|
|
3867
|
+
} = fee;
|
|
3868
|
+
const {
|
|
3800
3869
|
migrationOption,
|
|
3801
3870
|
migrationFeeOption,
|
|
3802
3871
|
migrationFee,
|
|
3872
|
+
migratedPoolFee
|
|
3873
|
+
} = migration;
|
|
3874
|
+
const {
|
|
3803
3875
|
partnerPermanentLockedLiquidityPercentage,
|
|
3804
3876
|
partnerLiquidityPercentage,
|
|
3877
|
+
partnerLiquidityVestingInfoParams,
|
|
3805
3878
|
creatorPermanentLockedLiquidityPercentage,
|
|
3806
3879
|
creatorLiquidityPercentage,
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
migratedPoolFee,
|
|
3810
|
-
migratedPoolBaseFeeMode,
|
|
3811
|
-
migratedPoolMarketCapFeeSchedulerParams,
|
|
3812
|
-
enableFirstSwapWithMinFee,
|
|
3813
|
-
percentageSupplyOnMigration,
|
|
3814
|
-
migrationQuoteThreshold
|
|
3815
|
-
} = buildCurveParam;
|
|
3880
|
+
creatorLiquidityVestingInfoParams
|
|
3881
|
+
} = liquidityDistribution;
|
|
3816
3882
|
const baseFee = getBaseFeeParams(
|
|
3817
3883
|
baseFeeParams,
|
|
3818
3884
|
tokenQuoteDecimal,
|
|
@@ -3824,8 +3890,8 @@ function buildCurve(buildCurveParam) {
|
|
|
3824
3890
|
cliffUnlockAmount,
|
|
3825
3891
|
totalVestingDuration,
|
|
3826
3892
|
cliffDurationFromMigrationTime
|
|
3827
|
-
} =
|
|
3828
|
-
const
|
|
3893
|
+
} = lockedVesting;
|
|
3894
|
+
const lockedVestingParams = getLockedVestingParams(
|
|
3829
3895
|
totalLockedVestingAmount,
|
|
3830
3896
|
numberOfVestingPeriod,
|
|
3831
3897
|
cliffUnlockAmount,
|
|
@@ -3834,43 +3900,30 @@ function buildCurve(buildCurveParam) {
|
|
|
3834
3900
|
tokenBaseDecimal
|
|
3835
3901
|
);
|
|
3836
3902
|
const partnerVestingParams = _nullishCoalesce(partnerLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
|
|
3837
|
-
const {
|
|
3838
|
-
vestingPercentage: partnerVestingPercentage,
|
|
3839
|
-
bpsPerPeriod: partnerBpsPerPeriod,
|
|
3840
|
-
numberOfPeriods: partnerNumberOfPeriods,
|
|
3841
|
-
cliffDurationFromMigrationTime: partnerCliffDurationFromMigrationTime,
|
|
3842
|
-
totalDuration: partnerTotalDuration
|
|
3843
|
-
} = partnerVestingParams;
|
|
3844
3903
|
const partnerLiquidityVestingInfo = getLiquidityVestingInfoParams(
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3904
|
+
partnerVestingParams.vestingPercentage,
|
|
3905
|
+
partnerVestingParams.bpsPerPeriod,
|
|
3906
|
+
partnerVestingParams.numberOfPeriods,
|
|
3907
|
+
partnerVestingParams.cliffDurationFromMigrationTime,
|
|
3908
|
+
partnerVestingParams.totalDuration
|
|
3850
3909
|
);
|
|
3851
3910
|
const creatorVestingParams = _nullishCoalesce(creatorLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
|
|
3852
|
-
const {
|
|
3853
|
-
vestingPercentage: creatorVestingPercentage,
|
|
3854
|
-
bpsPerPeriod: creatorBpsPerPeriod,
|
|
3855
|
-
numberOfPeriods: creatorNumberOfPeriods,
|
|
3856
|
-
cliffDurationFromMigrationTime: creatorCliffDurationFromMigrationTime,
|
|
3857
|
-
totalDuration: creatorTotalDuration
|
|
3858
|
-
} = creatorVestingParams;
|
|
3859
3911
|
const creatorLiquidityVestingInfo = getLiquidityVestingInfoParams(
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3912
|
+
creatorVestingParams.vestingPercentage,
|
|
3913
|
+
creatorVestingParams.bpsPerPeriod,
|
|
3914
|
+
creatorVestingParams.numberOfPeriods,
|
|
3915
|
+
creatorVestingParams.cliffDurationFromMigrationTime,
|
|
3916
|
+
creatorVestingParams.totalDuration
|
|
3865
3917
|
);
|
|
3866
3918
|
const poolCreationFeeInLamports = convertToLamports(
|
|
3867
3919
|
poolCreationFee,
|
|
3868
3920
|
9 /* NINE */
|
|
3869
3921
|
);
|
|
3870
|
-
const
|
|
3922
|
+
const migratedPoolFeeResult = getMigratedPoolFeeParams(
|
|
3871
3923
|
migrationOption,
|
|
3872
3924
|
migrationFeeOption,
|
|
3873
|
-
migratedPoolFee
|
|
3925
|
+
migratedPoolFee,
|
|
3926
|
+
baseFeeParams
|
|
3874
3927
|
);
|
|
3875
3928
|
const migrationBaseSupply = new (0, _decimaljs2.default)(totalTokenSupply).mul(new (0, _decimaljs2.default)(percentageSupplyOnMigration)).div(new (0, _decimaljs2.default)(100));
|
|
3876
3929
|
const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
@@ -3899,7 +3952,7 @@ function buildCurve(buildCurveParam) {
|
|
|
3899
3952
|
migrateSqrtPrice,
|
|
3900
3953
|
migrationOption
|
|
3901
3954
|
);
|
|
3902
|
-
const totalVestingAmount = getTotalVestingAmount(
|
|
3955
|
+
const totalVestingAmount = getTotalVestingAmount(lockedVestingParams);
|
|
3903
3956
|
const swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
|
|
3904
3957
|
const { sqrtStartPrice, curve } = getFirstCurve(
|
|
3905
3958
|
migrateSqrtPrice,
|
|
@@ -3912,7 +3965,7 @@ function buildCurve(buildCurveParam) {
|
|
|
3912
3965
|
migrationQuoteThresholdInLamport,
|
|
3913
3966
|
sqrtStartPrice,
|
|
3914
3967
|
curve,
|
|
3915
|
-
|
|
3968
|
+
lockedVestingParams,
|
|
3916
3969
|
migrationOption,
|
|
3917
3970
|
totalLeftover,
|
|
3918
3971
|
migrationFee.feePercentage
|
|
@@ -3949,8 +4002,8 @@ function buildCurve(buildCurveParam) {
|
|
|
3949
4002
|
creatorPermanentLockedLiquidityPercentage,
|
|
3950
4003
|
migrationQuoteThreshold: migrationQuoteThresholdInLamport,
|
|
3951
4004
|
sqrtStartPrice,
|
|
3952
|
-
lockedVesting,
|
|
3953
|
-
migrationFeeOption,
|
|
4005
|
+
lockedVesting: lockedVestingParams,
|
|
4006
|
+
migrationFeeOption: migratedPoolFeeResult.migrationFeeOption,
|
|
3954
4007
|
tokenSupply: {
|
|
3955
4008
|
preMigrationTokenSupply: totalSupply,
|
|
3956
4009
|
postMigrationTokenSupply: totalSupply
|
|
@@ -3958,47 +4011,36 @@ function buildCurve(buildCurveParam) {
|
|
|
3958
4011
|
creatorTradingFeePercentage,
|
|
3959
4012
|
tokenUpdateAuthority,
|
|
3960
4013
|
migrationFee,
|
|
3961
|
-
migratedPoolFee:
|
|
3962
|
-
collectFeeMode: migratedPoolFeeParams.collectFeeMode,
|
|
3963
|
-
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
3964
|
-
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
3965
|
-
},
|
|
4014
|
+
migratedPoolFee: migratedPoolFeeResult.migratedPoolFee,
|
|
3966
4015
|
poolCreationFee: poolCreationFeeInLamports,
|
|
3967
4016
|
partnerLiquidityVestingInfo,
|
|
3968
4017
|
creatorLiquidityVestingInfo,
|
|
3969
|
-
migratedPoolBaseFeeMode:
|
|
3970
|
-
migratedPoolMarketCapFeeSchedulerParams: migratedPoolMarketCapFeeSchedulerParams
|
|
3971
|
-
getStartingBaseFeeBpsFromBaseFeeParams(baseFeeParams),
|
|
3972
|
-
migratedPoolMarketCapFeeSchedulerParams.endingBaseFeeBps,
|
|
3973
|
-
_nullishCoalesce(migratedPoolBaseFeeMode, () => ( 0)) /* FeeTimeSchedulerLinear */,
|
|
3974
|
-
migratedPoolMarketCapFeeSchedulerParams.numberOfPeriod,
|
|
3975
|
-
migratedPoolMarketCapFeeSchedulerParams.sqrtPriceStepBps,
|
|
3976
|
-
migratedPoolMarketCapFeeSchedulerParams.schedulerExpirationDuration
|
|
3977
|
-
) : DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS,
|
|
4018
|
+
migratedPoolBaseFeeMode: migratedPoolFeeResult.migratedPoolBaseFeeMode,
|
|
4019
|
+
migratedPoolMarketCapFeeSchedulerParams: migratedPoolFeeResult.migratedPoolMarketCapFeeSchedulerParams,
|
|
3978
4020
|
enableFirstSwapWithMinFee,
|
|
3979
4021
|
padding: [],
|
|
3980
4022
|
curve
|
|
3981
4023
|
};
|
|
3982
4024
|
return instructionParams;
|
|
3983
4025
|
}
|
|
3984
|
-
function buildCurveWithMarketCap(
|
|
4026
|
+
function buildCurveWithMarketCap(params) {
|
|
3985
4027
|
const {
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
leftover,
|
|
3990
|
-
migrationFee,
|
|
4028
|
+
token,
|
|
4029
|
+
migration,
|
|
4030
|
+
lockedVesting,
|
|
3991
4031
|
initialMarketCap,
|
|
3992
4032
|
migrationMarketCap
|
|
3993
|
-
} =
|
|
4033
|
+
} = params;
|
|
4034
|
+
const { totalTokenSupply, tokenBaseDecimal, leftover } = token;
|
|
4035
|
+
const { migrationFee } = migration;
|
|
3994
4036
|
const {
|
|
3995
4037
|
totalLockedVestingAmount,
|
|
3996
4038
|
numberOfVestingPeriod,
|
|
3997
4039
|
cliffUnlockAmount,
|
|
3998
4040
|
totalVestingDuration,
|
|
3999
4041
|
cliffDurationFromMigrationTime
|
|
4000
|
-
} =
|
|
4001
|
-
const
|
|
4042
|
+
} = lockedVesting;
|
|
4043
|
+
const lockedVestingParams = getLockedVestingParams(
|
|
4002
4044
|
totalLockedVestingAmount,
|
|
4003
4045
|
numberOfVestingPeriod,
|
|
4004
4046
|
cliffUnlockAmount,
|
|
@@ -4012,13 +4054,13 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
|
|
|
4012
4054
|
initialMarketCap,
|
|
4013
4055
|
migrationMarketCap,
|
|
4014
4056
|
migrationFee,
|
|
4015
|
-
|
|
4057
|
+
lockedVestingParams,
|
|
4016
4058
|
totalLeftover,
|
|
4017
4059
|
totalSupply
|
|
4018
4060
|
) : getPercentageSupplyOnMigration(
|
|
4019
4061
|
new (0, _decimaljs2.default)(initialMarketCap),
|
|
4020
4062
|
new (0, _decimaljs2.default)(migrationMarketCap),
|
|
4021
|
-
|
|
4063
|
+
lockedVestingParams,
|
|
4022
4064
|
totalLeftover,
|
|
4023
4065
|
totalSupply
|
|
4024
4066
|
);
|
|
@@ -4031,43 +4073,53 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
|
|
|
4031
4073
|
new (0, _decimaljs2.default)(migrationFee.feePercentage)
|
|
4032
4074
|
).toNumber();
|
|
4033
4075
|
return buildCurve({
|
|
4034
|
-
...
|
|
4076
|
+
...params,
|
|
4035
4077
|
percentageSupplyOnMigration,
|
|
4036
4078
|
migrationQuoteThreshold
|
|
4037
4079
|
});
|
|
4038
4080
|
}
|
|
4039
|
-
function buildCurveWithTwoSegments(
|
|
4081
|
+
function buildCurveWithTwoSegments(params) {
|
|
4082
|
+
const {
|
|
4083
|
+
token,
|
|
4084
|
+
fee,
|
|
4085
|
+
migration,
|
|
4086
|
+
liquidityDistribution,
|
|
4087
|
+
lockedVesting,
|
|
4088
|
+
activationType,
|
|
4089
|
+
initialMarketCap,
|
|
4090
|
+
migrationMarketCap,
|
|
4091
|
+
percentageSupplyOnMigration
|
|
4092
|
+
} = params;
|
|
4040
4093
|
const {
|
|
4041
|
-
totalTokenSupply,
|
|
4042
4094
|
tokenType,
|
|
4043
4095
|
tokenBaseDecimal,
|
|
4044
4096
|
tokenQuoteDecimal,
|
|
4045
4097
|
tokenUpdateAuthority,
|
|
4046
|
-
|
|
4047
|
-
|
|
4098
|
+
totalTokenSupply,
|
|
4099
|
+
leftover
|
|
4100
|
+
} = token;
|
|
4101
|
+
const {
|
|
4048
4102
|
baseFeeParams,
|
|
4049
4103
|
dynamicFeeEnabled,
|
|
4050
|
-
activationType,
|
|
4051
4104
|
collectFeeMode,
|
|
4052
4105
|
creatorTradingFeePercentage,
|
|
4053
4106
|
poolCreationFee,
|
|
4107
|
+
enableFirstSwapWithMinFee
|
|
4108
|
+
} = fee;
|
|
4109
|
+
const {
|
|
4054
4110
|
migrationOption,
|
|
4055
4111
|
migrationFeeOption,
|
|
4056
4112
|
migrationFee,
|
|
4113
|
+
migratedPoolFee
|
|
4114
|
+
} = migration;
|
|
4115
|
+
const {
|
|
4057
4116
|
partnerPermanentLockedLiquidityPercentage,
|
|
4058
4117
|
partnerLiquidityPercentage,
|
|
4118
|
+
partnerLiquidityVestingInfoParams,
|
|
4059
4119
|
creatorPermanentLockedLiquidityPercentage,
|
|
4060
4120
|
creatorLiquidityPercentage,
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
migratedPoolFee,
|
|
4064
|
-
migratedPoolBaseFeeMode,
|
|
4065
|
-
migratedPoolMarketCapFeeSchedulerParams,
|
|
4066
|
-
enableFirstSwapWithMinFee,
|
|
4067
|
-
initialMarketCap,
|
|
4068
|
-
migrationMarketCap,
|
|
4069
|
-
percentageSupplyOnMigration
|
|
4070
|
-
} = buildCurveWithTwoSegmentsParam;
|
|
4121
|
+
creatorLiquidityVestingInfoParams
|
|
4122
|
+
} = liquidityDistribution;
|
|
4071
4123
|
const baseFee = getBaseFeeParams(
|
|
4072
4124
|
baseFeeParams,
|
|
4073
4125
|
tokenQuoteDecimal,
|
|
@@ -4079,8 +4131,8 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
4079
4131
|
cliffUnlockAmount,
|
|
4080
4132
|
totalVestingDuration,
|
|
4081
4133
|
cliffDurationFromMigrationTime
|
|
4082
|
-
} =
|
|
4083
|
-
const
|
|
4134
|
+
} = lockedVesting;
|
|
4135
|
+
const lockedVestingParams = getLockedVestingParams(
|
|
4084
4136
|
totalLockedVestingAmount,
|
|
4085
4137
|
numberOfVestingPeriod,
|
|
4086
4138
|
cliffUnlockAmount,
|
|
@@ -4122,10 +4174,11 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
4122
4174
|
poolCreationFee,
|
|
4123
4175
|
9 /* NINE */
|
|
4124
4176
|
);
|
|
4125
|
-
const
|
|
4177
|
+
const migratedPoolFeeResult = getMigratedPoolFeeParams(
|
|
4126
4178
|
migrationOption,
|
|
4127
4179
|
migrationFeeOption,
|
|
4128
|
-
migratedPoolFee
|
|
4180
|
+
migratedPoolFee,
|
|
4181
|
+
baseFeeParams
|
|
4129
4182
|
);
|
|
4130
4183
|
const migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
|
|
4131
4184
|
const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
@@ -4156,7 +4209,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
4156
4209
|
migrateSqrtPrice,
|
|
4157
4210
|
migrationOption
|
|
4158
4211
|
);
|
|
4159
|
-
const totalVestingAmount = getTotalVestingAmount(
|
|
4212
|
+
const totalVestingAmount = getTotalVestingAmount(lockedVestingParams);
|
|
4160
4213
|
const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
|
|
4161
4214
|
const swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
|
|
4162
4215
|
const initialSqrtPrice = getSqrtPriceFromMarketCap(
|
|
@@ -4198,7 +4251,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
4198
4251
|
migrationQuoteThresholdInLamport,
|
|
4199
4252
|
sqrtStartPrice,
|
|
4200
4253
|
curve,
|
|
4201
|
-
|
|
4254
|
+
lockedVestingParams,
|
|
4202
4255
|
migrationOption,
|
|
4203
4256
|
totalLeftover,
|
|
4204
4257
|
migrationFee.feePercentage
|
|
@@ -4229,30 +4282,19 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
4229
4282
|
creatorLiquidityPercentage,
|
|
4230
4283
|
creatorPermanentLockedLiquidityPercentage,
|
|
4231
4284
|
sqrtStartPrice,
|
|
4232
|
-
lockedVesting,
|
|
4233
|
-
migrationFeeOption,
|
|
4285
|
+
lockedVesting: lockedVestingParams,
|
|
4286
|
+
migrationFeeOption: migratedPoolFeeResult.migrationFeeOption,
|
|
4234
4287
|
tokenSupply: {
|
|
4235
4288
|
preMigrationTokenSupply: totalSupply,
|
|
4236
4289
|
postMigrationTokenSupply: totalSupply
|
|
4237
4290
|
},
|
|
4238
4291
|
creatorTradingFeePercentage,
|
|
4239
|
-
migratedPoolFee:
|
|
4240
|
-
collectFeeMode: migratedPoolFeeParams.collectFeeMode,
|
|
4241
|
-
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
4242
|
-
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
4243
|
-
},
|
|
4292
|
+
migratedPoolFee: migratedPoolFeeResult.migratedPoolFee,
|
|
4244
4293
|
poolCreationFee: poolCreationFeeInLamports,
|
|
4245
4294
|
partnerLiquidityVestingInfo,
|
|
4246
4295
|
creatorLiquidityVestingInfo,
|
|
4247
|
-
migratedPoolBaseFeeMode:
|
|
4248
|
-
migratedPoolMarketCapFeeSchedulerParams: migratedPoolMarketCapFeeSchedulerParams
|
|
4249
|
-
getStartingBaseFeeBpsFromBaseFeeParams(baseFeeParams),
|
|
4250
|
-
migratedPoolMarketCapFeeSchedulerParams.endingBaseFeeBps,
|
|
4251
|
-
_nullishCoalesce(migratedPoolBaseFeeMode, () => ( 0)) /* FeeTimeSchedulerLinear */,
|
|
4252
|
-
migratedPoolMarketCapFeeSchedulerParams.numberOfPeriod,
|
|
4253
|
-
migratedPoolMarketCapFeeSchedulerParams.sqrtPriceStepBps,
|
|
4254
|
-
migratedPoolMarketCapFeeSchedulerParams.schedulerExpirationDuration
|
|
4255
|
-
) : DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS,
|
|
4296
|
+
migratedPoolBaseFeeMode: migratedPoolFeeResult.migratedPoolBaseFeeMode,
|
|
4297
|
+
migratedPoolMarketCapFeeSchedulerParams: migratedPoolFeeResult.migratedPoolMarketCapFeeSchedulerParams,
|
|
4256
4298
|
enableFirstSwapWithMinFee,
|
|
4257
4299
|
padding: [],
|
|
4258
4300
|
curve,
|
|
@@ -4261,39 +4303,49 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
4261
4303
|
};
|
|
4262
4304
|
return instructionParams;
|
|
4263
4305
|
}
|
|
4264
|
-
function buildCurveWithMidPrice(
|
|
4306
|
+
function buildCurveWithMidPrice(params) {
|
|
4307
|
+
const {
|
|
4308
|
+
token,
|
|
4309
|
+
fee,
|
|
4310
|
+
migration,
|
|
4311
|
+
liquidityDistribution,
|
|
4312
|
+
lockedVesting,
|
|
4313
|
+
activationType,
|
|
4314
|
+
initialMarketCap,
|
|
4315
|
+
migrationMarketCap,
|
|
4316
|
+
midPrice,
|
|
4317
|
+
percentageSupplyOnMigration
|
|
4318
|
+
} = params;
|
|
4265
4319
|
const {
|
|
4266
|
-
totalTokenSupply,
|
|
4267
4320
|
tokenType,
|
|
4268
4321
|
tokenBaseDecimal,
|
|
4269
4322
|
tokenQuoteDecimal,
|
|
4270
4323
|
tokenUpdateAuthority,
|
|
4271
|
-
|
|
4272
|
-
leftover
|
|
4324
|
+
totalTokenSupply,
|
|
4325
|
+
leftover
|
|
4326
|
+
} = token;
|
|
4327
|
+
const {
|
|
4273
4328
|
baseFeeParams,
|
|
4274
4329
|
dynamicFeeEnabled,
|
|
4275
|
-
activationType,
|
|
4276
4330
|
collectFeeMode,
|
|
4277
4331
|
creatorTradingFeePercentage,
|
|
4278
4332
|
poolCreationFee,
|
|
4333
|
+
enableFirstSwapWithMinFee
|
|
4334
|
+
} = fee;
|
|
4335
|
+
const {
|
|
4279
4336
|
migrationOption,
|
|
4280
4337
|
migrationFeeOption,
|
|
4281
4338
|
migrationFee,
|
|
4339
|
+
migratedPoolFee
|
|
4340
|
+
} = migration;
|
|
4341
|
+
const {
|
|
4282
4342
|
partnerPermanentLockedLiquidityPercentage,
|
|
4283
4343
|
partnerLiquidityPercentage,
|
|
4344
|
+
partnerLiquidityVestingInfoParams,
|
|
4284
4345
|
creatorPermanentLockedLiquidityPercentage,
|
|
4285
4346
|
creatorLiquidityPercentage,
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
migratedPoolFee,
|
|
4289
|
-
migratedPoolBaseFeeMode,
|
|
4290
|
-
migratedPoolMarketCapFeeSchedulerParams,
|
|
4291
|
-
enableFirstSwapWithMinFee,
|
|
4292
|
-
initialMarketCap,
|
|
4293
|
-
migrationMarketCap,
|
|
4294
|
-
midPrice,
|
|
4295
|
-
percentageSupplyOnMigration
|
|
4296
|
-
} = buildCurveWithMidPriceParam;
|
|
4347
|
+
creatorLiquidityVestingInfoParams
|
|
4348
|
+
} = liquidityDistribution;
|
|
4297
4349
|
const baseFee = getBaseFeeParams(
|
|
4298
4350
|
baseFeeParams,
|
|
4299
4351
|
tokenQuoteDecimal,
|
|
@@ -4305,8 +4357,8 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
|
|
|
4305
4357
|
cliffUnlockAmount,
|
|
4306
4358
|
totalVestingDuration,
|
|
4307
4359
|
cliffDurationFromMigrationTime
|
|
4308
|
-
} =
|
|
4309
|
-
const
|
|
4360
|
+
} = lockedVesting;
|
|
4361
|
+
const lockedVestingParams = getLockedVestingParams(
|
|
4310
4362
|
totalLockedVestingAmount,
|
|
4311
4363
|
numberOfVestingPeriod,
|
|
4312
4364
|
cliffUnlockAmount,
|
|
@@ -4348,10 +4400,11 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
|
|
|
4348
4400
|
poolCreationFee,
|
|
4349
4401
|
9 /* NINE */
|
|
4350
4402
|
);
|
|
4351
|
-
const
|
|
4403
|
+
const migratedPoolFeeResult = getMigratedPoolFeeParams(
|
|
4352
4404
|
migrationOption,
|
|
4353
4405
|
migrationFeeOption,
|
|
4354
|
-
migratedPoolFee
|
|
4406
|
+
migratedPoolFee,
|
|
4407
|
+
baseFeeParams
|
|
4355
4408
|
);
|
|
4356
4409
|
const migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
|
|
4357
4410
|
const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
@@ -4382,7 +4435,7 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
|
|
|
4382
4435
|
migrateSqrtPrice,
|
|
4383
4436
|
migrationOption
|
|
4384
4437
|
);
|
|
4385
|
-
const totalVestingAmount = getTotalVestingAmount(
|
|
4438
|
+
const totalVestingAmount = getTotalVestingAmount(lockedVestingParams);
|
|
4386
4439
|
const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
|
|
4387
4440
|
const swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
|
|
4388
4441
|
const initialSqrtPrice = getSqrtPriceFromMarketCap(
|
|
@@ -4411,7 +4464,7 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
|
|
|
4411
4464
|
migrationQuoteThresholdInLamport,
|
|
4412
4465
|
sqrtStartPrice,
|
|
4413
4466
|
curve,
|
|
4414
|
-
|
|
4467
|
+
lockedVestingParams,
|
|
4415
4468
|
migrationOption,
|
|
4416
4469
|
totalLeftover,
|
|
4417
4470
|
migrationFee.feePercentage
|
|
@@ -4442,30 +4495,19 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
|
|
|
4442
4495
|
creatorLiquidityPercentage,
|
|
4443
4496
|
creatorPermanentLockedLiquidityPercentage,
|
|
4444
4497
|
sqrtStartPrice,
|
|
4445
|
-
lockedVesting,
|
|
4446
|
-
migrationFeeOption,
|
|
4498
|
+
lockedVesting: lockedVestingParams,
|
|
4499
|
+
migrationFeeOption: migratedPoolFeeResult.migrationFeeOption,
|
|
4447
4500
|
tokenSupply: {
|
|
4448
4501
|
preMigrationTokenSupply: totalSupply,
|
|
4449
4502
|
postMigrationTokenSupply: totalSupply
|
|
4450
4503
|
},
|
|
4451
4504
|
creatorTradingFeePercentage,
|
|
4452
|
-
migratedPoolFee:
|
|
4453
|
-
collectFeeMode: migratedPoolFeeParams.collectFeeMode,
|
|
4454
|
-
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
4455
|
-
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
4456
|
-
},
|
|
4505
|
+
migratedPoolFee: migratedPoolFeeResult.migratedPoolFee,
|
|
4457
4506
|
poolCreationFee: poolCreationFeeInLamports,
|
|
4458
4507
|
partnerLiquidityVestingInfo,
|
|
4459
4508
|
creatorLiquidityVestingInfo,
|
|
4460
|
-
migratedPoolBaseFeeMode:
|
|
4461
|
-
migratedPoolMarketCapFeeSchedulerParams: migratedPoolMarketCapFeeSchedulerParams
|
|
4462
|
-
getStartingBaseFeeBpsFromBaseFeeParams(baseFeeParams),
|
|
4463
|
-
migratedPoolMarketCapFeeSchedulerParams.endingBaseFeeBps,
|
|
4464
|
-
_nullishCoalesce(migratedPoolBaseFeeMode, () => ( 0)) /* FeeTimeSchedulerLinear */,
|
|
4465
|
-
migratedPoolMarketCapFeeSchedulerParams.numberOfPeriod,
|
|
4466
|
-
migratedPoolMarketCapFeeSchedulerParams.sqrtPriceStepBps,
|
|
4467
|
-
migratedPoolMarketCapFeeSchedulerParams.schedulerExpirationDuration
|
|
4468
|
-
) : DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS,
|
|
4509
|
+
migratedPoolBaseFeeMode: migratedPoolFeeResult.migratedPoolBaseFeeMode,
|
|
4510
|
+
migratedPoolMarketCapFeeSchedulerParams: migratedPoolFeeResult.migratedPoolMarketCapFeeSchedulerParams,
|
|
4469
4511
|
enableFirstSwapWithMinFee,
|
|
4470
4512
|
padding: [],
|
|
4471
4513
|
curve,
|
|
@@ -4474,38 +4516,48 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
|
|
|
4474
4516
|
};
|
|
4475
4517
|
return instructionParams;
|
|
4476
4518
|
}
|
|
4477
|
-
function buildCurveWithLiquidityWeights(
|
|
4519
|
+
function buildCurveWithLiquidityWeights(params) {
|
|
4520
|
+
const {
|
|
4521
|
+
token,
|
|
4522
|
+
fee,
|
|
4523
|
+
migration,
|
|
4524
|
+
liquidityDistribution,
|
|
4525
|
+
lockedVesting,
|
|
4526
|
+
activationType,
|
|
4527
|
+
initialMarketCap,
|
|
4528
|
+
migrationMarketCap,
|
|
4529
|
+
liquidityWeights
|
|
4530
|
+
} = params;
|
|
4478
4531
|
const {
|
|
4479
|
-
totalTokenSupply,
|
|
4480
4532
|
tokenType,
|
|
4481
4533
|
tokenBaseDecimal,
|
|
4482
4534
|
tokenQuoteDecimal,
|
|
4483
4535
|
tokenUpdateAuthority,
|
|
4484
|
-
|
|
4485
|
-
leftover
|
|
4536
|
+
totalTokenSupply,
|
|
4537
|
+
leftover
|
|
4538
|
+
} = token;
|
|
4539
|
+
const {
|
|
4486
4540
|
baseFeeParams,
|
|
4487
4541
|
dynamicFeeEnabled,
|
|
4488
|
-
activationType,
|
|
4489
4542
|
collectFeeMode,
|
|
4490
4543
|
creatorTradingFeePercentage,
|
|
4491
4544
|
poolCreationFee,
|
|
4545
|
+
enableFirstSwapWithMinFee
|
|
4546
|
+
} = fee;
|
|
4547
|
+
const {
|
|
4492
4548
|
migrationOption,
|
|
4493
4549
|
migrationFeeOption,
|
|
4494
4550
|
migrationFee,
|
|
4551
|
+
migratedPoolFee
|
|
4552
|
+
} = migration;
|
|
4553
|
+
const {
|
|
4495
4554
|
partnerPermanentLockedLiquidityPercentage,
|
|
4496
4555
|
partnerLiquidityPercentage,
|
|
4556
|
+
partnerLiquidityVestingInfoParams,
|
|
4497
4557
|
creatorPermanentLockedLiquidityPercentage,
|
|
4498
4558
|
creatorLiquidityPercentage,
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
migratedPoolFee,
|
|
4502
|
-
migratedPoolBaseFeeMode,
|
|
4503
|
-
migratedPoolMarketCapFeeSchedulerParams,
|
|
4504
|
-
enableFirstSwapWithMinFee,
|
|
4505
|
-
initialMarketCap,
|
|
4506
|
-
migrationMarketCap,
|
|
4507
|
-
liquidityWeights
|
|
4508
|
-
} = buildCurveWithLiquidityWeightsParam;
|
|
4559
|
+
creatorLiquidityVestingInfoParams
|
|
4560
|
+
} = liquidityDistribution;
|
|
4509
4561
|
const baseFee = getBaseFeeParams(
|
|
4510
4562
|
baseFeeParams,
|
|
4511
4563
|
tokenQuoteDecimal,
|
|
@@ -4517,8 +4569,8 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
4517
4569
|
cliffUnlockAmount,
|
|
4518
4570
|
totalVestingDuration,
|
|
4519
4571
|
cliffDurationFromMigrationTime
|
|
4520
|
-
} =
|
|
4521
|
-
const
|
|
4572
|
+
} = lockedVesting;
|
|
4573
|
+
const lockedVestingParams = getLockedVestingParams(
|
|
4522
4574
|
totalLockedVestingAmount,
|
|
4523
4575
|
numberOfVestingPeriod,
|
|
4524
4576
|
cliffUnlockAmount,
|
|
@@ -4560,10 +4612,11 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
4560
4612
|
poolCreationFee,
|
|
4561
4613
|
9 /* NINE */
|
|
4562
4614
|
);
|
|
4563
|
-
const
|
|
4615
|
+
const migratedPoolFeeResult = getMigratedPoolFeeParams(
|
|
4564
4616
|
migrationOption,
|
|
4565
4617
|
migrationFeeOption,
|
|
4566
|
-
migratedPoolFee
|
|
4618
|
+
migratedPoolFee,
|
|
4619
|
+
baseFeeParams
|
|
4567
4620
|
);
|
|
4568
4621
|
const pMin = getSqrtPriceFromMarketCap(
|
|
4569
4622
|
initialMarketCap,
|
|
@@ -4591,7 +4644,7 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
4591
4644
|
}
|
|
4592
4645
|
const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
4593
4646
|
const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
|
|
4594
|
-
const totalVestingAmount = getTotalVestingAmount(
|
|
4647
|
+
const totalVestingAmount = getTotalVestingAmount(lockedVestingParams);
|
|
4595
4648
|
const totalSwapAndMigrationAmount = totalSupply.sub(totalVestingAmount).sub(totalLeftover);
|
|
4596
4649
|
let sumFactor = new (0, _decimaljs2.default)(0);
|
|
4597
4650
|
const pmaxWeight = new (0, _decimaljs2.default)(pMax.toString());
|
|
@@ -4637,7 +4690,7 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
4637
4690
|
migrationQuoteThresholdInLamport,
|
|
4638
4691
|
pMin,
|
|
4639
4692
|
curve,
|
|
4640
|
-
|
|
4693
|
+
lockedVestingParams,
|
|
4641
4694
|
migrationOption,
|
|
4642
4695
|
totalLeftover,
|
|
4643
4696
|
migrationFee.feePercentage
|
|
@@ -4668,30 +4721,19 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
4668
4721
|
creatorLiquidityPercentage,
|
|
4669
4722
|
creatorPermanentLockedLiquidityPercentage,
|
|
4670
4723
|
sqrtStartPrice: pMin,
|
|
4671
|
-
lockedVesting,
|
|
4672
|
-
migrationFeeOption,
|
|
4724
|
+
lockedVesting: lockedVestingParams,
|
|
4725
|
+
migrationFeeOption: migratedPoolFeeResult.migrationFeeOption,
|
|
4673
4726
|
tokenSupply: {
|
|
4674
4727
|
preMigrationTokenSupply: totalSupply,
|
|
4675
4728
|
postMigrationTokenSupply: totalSupply
|
|
4676
4729
|
},
|
|
4677
4730
|
creatorTradingFeePercentage,
|
|
4678
|
-
migratedPoolFee:
|
|
4679
|
-
collectFeeMode: migratedPoolFeeParams.collectFeeMode,
|
|
4680
|
-
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
4681
|
-
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
4682
|
-
},
|
|
4731
|
+
migratedPoolFee: migratedPoolFeeResult.migratedPoolFee,
|
|
4683
4732
|
poolCreationFee: poolCreationFeeInLamports,
|
|
4684
4733
|
partnerLiquidityVestingInfo,
|
|
4685
4734
|
creatorLiquidityVestingInfo,
|
|
4686
|
-
migratedPoolBaseFeeMode:
|
|
4687
|
-
migratedPoolMarketCapFeeSchedulerParams: migratedPoolMarketCapFeeSchedulerParams
|
|
4688
|
-
getStartingBaseFeeBpsFromBaseFeeParams(baseFeeParams),
|
|
4689
|
-
migratedPoolMarketCapFeeSchedulerParams.endingBaseFeeBps,
|
|
4690
|
-
_nullishCoalesce(migratedPoolBaseFeeMode, () => ( 0)) /* FeeTimeSchedulerLinear */,
|
|
4691
|
-
migratedPoolMarketCapFeeSchedulerParams.numberOfPeriod,
|
|
4692
|
-
migratedPoolMarketCapFeeSchedulerParams.sqrtPriceStepBps,
|
|
4693
|
-
migratedPoolMarketCapFeeSchedulerParams.schedulerExpirationDuration
|
|
4694
|
-
) : DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS,
|
|
4735
|
+
migratedPoolBaseFeeMode: migratedPoolFeeResult.migratedPoolBaseFeeMode,
|
|
4736
|
+
migratedPoolMarketCapFeeSchedulerParams: migratedPoolFeeResult.migratedPoolMarketCapFeeSchedulerParams,
|
|
4695
4737
|
enableFirstSwapWithMinFee,
|
|
4696
4738
|
padding: [],
|
|
4697
4739
|
curve,
|
|
@@ -4700,37 +4742,47 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
4700
4742
|
};
|
|
4701
4743
|
return instructionParams;
|
|
4702
4744
|
}
|
|
4703
|
-
function buildCurveWithCustomSqrtPrices(
|
|
4745
|
+
function buildCurveWithCustomSqrtPrices(params) {
|
|
4746
|
+
const {
|
|
4747
|
+
token,
|
|
4748
|
+
fee,
|
|
4749
|
+
migration,
|
|
4750
|
+
liquidityDistribution,
|
|
4751
|
+
lockedVesting,
|
|
4752
|
+
activationType,
|
|
4753
|
+
sqrtPrices
|
|
4754
|
+
} = params;
|
|
4704
4755
|
const {
|
|
4705
|
-
totalTokenSupply,
|
|
4706
4756
|
tokenType,
|
|
4707
4757
|
tokenBaseDecimal,
|
|
4708
4758
|
tokenQuoteDecimal,
|
|
4709
4759
|
tokenUpdateAuthority,
|
|
4710
|
-
|
|
4711
|
-
leftover
|
|
4760
|
+
totalTokenSupply,
|
|
4761
|
+
leftover
|
|
4762
|
+
} = token;
|
|
4763
|
+
const {
|
|
4712
4764
|
baseFeeParams,
|
|
4713
4765
|
dynamicFeeEnabled,
|
|
4714
|
-
activationType,
|
|
4715
4766
|
collectFeeMode,
|
|
4716
4767
|
creatorTradingFeePercentage,
|
|
4717
4768
|
poolCreationFee,
|
|
4769
|
+
enableFirstSwapWithMinFee
|
|
4770
|
+
} = fee;
|
|
4771
|
+
const {
|
|
4718
4772
|
migrationOption,
|
|
4719
4773
|
migrationFeeOption,
|
|
4720
4774
|
migrationFee,
|
|
4775
|
+
migratedPoolFee
|
|
4776
|
+
} = migration;
|
|
4777
|
+
const {
|
|
4721
4778
|
partnerPermanentLockedLiquidityPercentage,
|
|
4722
4779
|
partnerLiquidityPercentage,
|
|
4780
|
+
partnerLiquidityVestingInfoParams,
|
|
4723
4781
|
creatorPermanentLockedLiquidityPercentage,
|
|
4724
4782
|
creatorLiquidityPercentage,
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
migratedPoolBaseFeeMode,
|
|
4729
|
-
migratedPoolMarketCapFeeSchedulerParams,
|
|
4730
|
-
enableFirstSwapWithMinFee,
|
|
4731
|
-
sqrtPrices
|
|
4732
|
-
} = buildCurveWithCustomSqrtPricesParam;
|
|
4733
|
-
let { liquidityWeights } = buildCurveWithCustomSqrtPricesParam;
|
|
4783
|
+
creatorLiquidityVestingInfoParams
|
|
4784
|
+
} = liquidityDistribution;
|
|
4785
|
+
let { liquidityWeights } = params;
|
|
4734
4786
|
if (sqrtPrices.length < 2) {
|
|
4735
4787
|
throw new Error("sqrtPrices array must have at least 2 elements");
|
|
4736
4788
|
}
|
|
@@ -4758,8 +4810,8 @@ function buildCurveWithCustomSqrtPrices(buildCurveWithCustomSqrtPricesParam) {
|
|
|
4758
4810
|
cliffUnlockAmount,
|
|
4759
4811
|
totalVestingDuration,
|
|
4760
4812
|
cliffDurationFromMigrationTime
|
|
4761
|
-
} =
|
|
4762
|
-
const
|
|
4813
|
+
} = lockedVesting;
|
|
4814
|
+
const lockedVestingParams = getLockedVestingParams(
|
|
4763
4815
|
totalLockedVestingAmount,
|
|
4764
4816
|
numberOfVestingPeriod,
|
|
4765
4817
|
cliffUnlockAmount,
|
|
@@ -4801,16 +4853,17 @@ function buildCurveWithCustomSqrtPrices(buildCurveWithCustomSqrtPricesParam) {
|
|
|
4801
4853
|
poolCreationFee,
|
|
4802
4854
|
9 /* NINE */
|
|
4803
4855
|
);
|
|
4804
|
-
const
|
|
4856
|
+
const migratedPoolFeeResult = getMigratedPoolFeeParams(
|
|
4805
4857
|
migrationOption,
|
|
4806
4858
|
migrationFeeOption,
|
|
4807
|
-
migratedPoolFee
|
|
4859
|
+
migratedPoolFee,
|
|
4860
|
+
baseFeeParams
|
|
4808
4861
|
);
|
|
4809
4862
|
const pMin = sqrtPrices[0];
|
|
4810
4863
|
const pMax = sqrtPrices[sqrtPrices.length - 1];
|
|
4811
4864
|
const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
4812
4865
|
const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
|
|
4813
|
-
const totalVestingAmount = getTotalVestingAmount(
|
|
4866
|
+
const totalVestingAmount = getTotalVestingAmount(lockedVestingParams);
|
|
4814
4867
|
const totalSwapAndMigrationAmount = totalSupply.sub(totalVestingAmount).sub(totalLeftover);
|
|
4815
4868
|
let sumFactor = new (0, _decimaljs2.default)(0);
|
|
4816
4869
|
const pmaxWeight = new (0, _decimaljs2.default)(pMax.toString());
|
|
@@ -4857,7 +4910,7 @@ function buildCurveWithCustomSqrtPrices(buildCurveWithCustomSqrtPricesParam) {
|
|
|
4857
4910
|
migrationQuoteThresholdInLamport,
|
|
4858
4911
|
pMin,
|
|
4859
4912
|
curve,
|
|
4860
|
-
|
|
4913
|
+
lockedVestingParams,
|
|
4861
4914
|
migrationOption,
|
|
4862
4915
|
totalLeftover,
|
|
4863
4916
|
migrationFee.feePercentage
|
|
@@ -4888,30 +4941,19 @@ function buildCurveWithCustomSqrtPrices(buildCurveWithCustomSqrtPricesParam) {
|
|
|
4888
4941
|
creatorLiquidityPercentage,
|
|
4889
4942
|
creatorPermanentLockedLiquidityPercentage,
|
|
4890
4943
|
sqrtStartPrice: pMin,
|
|
4891
|
-
lockedVesting,
|
|
4892
|
-
migrationFeeOption,
|
|
4944
|
+
lockedVesting: lockedVestingParams,
|
|
4945
|
+
migrationFeeOption: migratedPoolFeeResult.migrationFeeOption,
|
|
4893
4946
|
tokenSupply: {
|
|
4894
4947
|
preMigrationTokenSupply: totalSupply,
|
|
4895
4948
|
postMigrationTokenSupply: totalSupply
|
|
4896
4949
|
},
|
|
4897
4950
|
creatorTradingFeePercentage,
|
|
4898
|
-
migratedPoolFee:
|
|
4899
|
-
collectFeeMode: migratedPoolFeeParams.collectFeeMode,
|
|
4900
|
-
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
4901
|
-
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
4902
|
-
},
|
|
4951
|
+
migratedPoolFee: migratedPoolFeeResult.migratedPoolFee,
|
|
4903
4952
|
poolCreationFee: poolCreationFeeInLamports,
|
|
4904
4953
|
partnerLiquidityVestingInfo,
|
|
4905
4954
|
creatorLiquidityVestingInfo,
|
|
4906
|
-
migratedPoolBaseFeeMode:
|
|
4907
|
-
migratedPoolMarketCapFeeSchedulerParams: migratedPoolMarketCapFeeSchedulerParams
|
|
4908
|
-
getStartingBaseFeeBpsFromBaseFeeParams(baseFeeParams),
|
|
4909
|
-
migratedPoolMarketCapFeeSchedulerParams.endingBaseFeeBps,
|
|
4910
|
-
_nullishCoalesce(migratedPoolBaseFeeMode, () => ( 0)) /* FeeTimeSchedulerLinear */,
|
|
4911
|
-
migratedPoolMarketCapFeeSchedulerParams.numberOfPeriod,
|
|
4912
|
-
migratedPoolMarketCapFeeSchedulerParams.sqrtPriceStepBps,
|
|
4913
|
-
migratedPoolMarketCapFeeSchedulerParams.schedulerExpirationDuration
|
|
4914
|
-
) : DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS,
|
|
4955
|
+
migratedPoolBaseFeeMode: migratedPoolFeeResult.migratedPoolBaseFeeMode,
|
|
4956
|
+
migratedPoolMarketCapFeeSchedulerParams: migratedPoolFeeResult.migratedPoolMarketCapFeeSchedulerParams,
|
|
4915
4957
|
enableFirstSwapWithMinFee,
|
|
4916
4958
|
padding: [],
|
|
4917
4959
|
curve,
|
|
@@ -25626,7 +25668,7 @@ var StateService = class extends DynamicBondingCurveProgram {
|
|
|
25626
25668
|
* @param poolAddress - The address of the pool
|
|
25627
25669
|
* @returns The progress as a ratio between 0 and 1
|
|
25628
25670
|
*/
|
|
25629
|
-
async
|
|
25671
|
+
async getPoolQuoteTokenCurveProgress(poolAddress) {
|
|
25630
25672
|
const pool = await this.getPool(poolAddress);
|
|
25631
25673
|
if (!pool) {
|
|
25632
25674
|
throw new Error(`Pool not found: ${poolAddress.toString()}`);
|
|
@@ -25639,6 +25681,61 @@ var StateService = class extends DynamicBondingCurveProgram {
|
|
|
25639
25681
|
const progress = quoteReserveDecimal.div(thresholdDecimal).toNumber();
|
|
25640
25682
|
return Math.min(Math.max(progress, 0), 1);
|
|
25641
25683
|
}
|
|
25684
|
+
/**
|
|
25685
|
+
* Get the progress of the curve based on base tokens sold relative to total base tokens available for trading.
|
|
25686
|
+
*
|
|
25687
|
+
* In CLMMs, the formulas are non-linear.
|
|
25688
|
+
* For a liquidity position with liquidity L between sqrt prices P0 and P1:
|
|
25689
|
+
* - Base delta = L × (1/P0 - 1/P1)
|
|
25690
|
+
* - Quote delta = L × (P1 - P0)
|
|
25691
|
+
* At some intermediate current sqrt price P:
|
|
25692
|
+
* - Base progress: (1/P0 - 1/P) / (1/P0 - 1/P1)
|
|
25693
|
+
* - Quote progress: (P - P0) / (P1 - P0)
|
|
25694
|
+
*
|
|
25695
|
+
* Both metrics equal 0 when the price is at P0, and 1 at P1, but their curves differ in between:
|
|
25696
|
+
* - Base progress depends on 1/P, which means it flattens for high prices.
|
|
25697
|
+
* - Quote progress depends linearly on P.
|
|
25698
|
+
*
|
|
25699
|
+
* As a result, near the end of the curve (at high prices), base progress approaches 1 faster than quote progress.
|
|
25700
|
+
* For example, you might see progress values like 99.87% base vs 99.38% quote, reflecting this mathematical difference.
|
|
25701
|
+
*
|
|
25702
|
+
* @param poolAddress - The address of the pool
|
|
25703
|
+
* @returns The progress as a ratio between 0 and 1
|
|
25704
|
+
*/
|
|
25705
|
+
async getPoolBaseTokenCurveProgress(poolAddress) {
|
|
25706
|
+
const pool = await this.getPool(poolAddress);
|
|
25707
|
+
if (!pool) {
|
|
25708
|
+
throw new Error(`Pool not found: ${poolAddress.toString()}`);
|
|
25709
|
+
}
|
|
25710
|
+
const config = await this.getPoolConfig(pool.config);
|
|
25711
|
+
const swapBaseAmount = new (0, _decimaljs2.default)(config.swapBaseAmount.toString());
|
|
25712
|
+
if (swapBaseAmount.isZero()) {
|
|
25713
|
+
return 0;
|
|
25714
|
+
}
|
|
25715
|
+
const baseReserve = new (0, _decimaljs2.default)(pool.baseReserve.toString());
|
|
25716
|
+
let initialBaseReserve;
|
|
25717
|
+
const isFixedSupply = config.fixedTokenSupplyFlag === 1;
|
|
25718
|
+
if (isFixedSupply) {
|
|
25719
|
+
initialBaseReserve = new (0, _decimaljs2.default)(
|
|
25720
|
+
config.preMigrationTokenSupply.toString()
|
|
25721
|
+
);
|
|
25722
|
+
} else {
|
|
25723
|
+
const swapBaseAmountBuffer = getSwapAmountWithBuffer(
|
|
25724
|
+
config.swapBaseAmount,
|
|
25725
|
+
config.sqrtStartPrice,
|
|
25726
|
+
config.curve
|
|
25727
|
+
);
|
|
25728
|
+
const totalSupply = getTotalTokenSupply(
|
|
25729
|
+
swapBaseAmountBuffer,
|
|
25730
|
+
config.migrationBaseThreshold,
|
|
25731
|
+
config.lockedVestingConfig
|
|
25732
|
+
);
|
|
25733
|
+
initialBaseReserve = new (0, _decimaljs2.default)(totalSupply.toString());
|
|
25734
|
+
}
|
|
25735
|
+
const baseSold = _decimaljs2.default.max(0, initialBaseReserve.sub(baseReserve));
|
|
25736
|
+
const progress = baseSold.div(swapBaseAmount).toNumber();
|
|
25737
|
+
return Math.min(Math.max(progress, 0), 1);
|
|
25738
|
+
}
|
|
25642
25739
|
/**
|
|
25643
25740
|
* Get pool metadata
|
|
25644
25741
|
* @param poolAddress - The address of the pool
|
|
@@ -28474,5 +28571,7 @@ var DynamicBondingCurveClient = class _DynamicBondingCurveClient {
|
|
|
28474
28571
|
|
|
28475
28572
|
|
|
28476
28573
|
|
|
28477
|
-
exports.ActivationType = ActivationType; exports.BASE_ADDRESS = BASE_ADDRESS; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.BaseFeeMode = BaseFeeMode; exports.CollectFeeMode = CollectFeeMode; exports.CreatorService = CreatorService; exports.DAMM_V1_MIGRATION_FEE_ADDRESS = DAMM_V1_MIGRATION_FEE_ADDRESS; exports.DAMM_V1_PROGRAM_ID = DAMM_V1_PROGRAM_ID; exports.DAMM_V2_MIGRATION_FEE_ADDRESS = DAMM_V2_MIGRATION_FEE_ADDRESS; exports.DAMM_V2_PROGRAM_ID = DAMM_V2_PROGRAM_ID; exports.DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS = DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS; exports.DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS = DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS; exports.DYNAMIC_BONDING_CURVE_PROGRAM_ID = DYNAMIC_BONDING_CURVE_PROGRAM_ID; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; exports.DYNAMIC_FEE_ROUNDING_OFFSET = DYNAMIC_FEE_ROUNDING_OFFSET; exports.DYNAMIC_FEE_SCALING_FACTOR = DYNAMIC_FEE_SCALING_FACTOR; exports.DammV2BaseFeeMode = DammV2BaseFeeMode; exports.DammV2DynamicFeeMode = DammV2DynamicFeeMode; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveIdl = idl_default; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeScheduler = FeeScheduler; exports.HOST_FEE_PERCENT = HOST_FEE_PERCENT; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_BASIS_POINT = MAX_BASIS_POINT; exports.MAX_CREATOR_MIGRATION_FEE_PERCENTAGE = MAX_CREATOR_MIGRATION_FEE_PERCENTAGE; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_FEE_BPS = MAX_FEE_BPS; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_LOCK_DURATION_IN_SECONDS = MAX_LOCK_DURATION_IN_SECONDS; exports.MAX_MIGRATED_POOL_FEE_BPS = MAX_MIGRATED_POOL_FEE_BPS; exports.MAX_MIGRATION_FEE_PERCENTAGE = MAX_MIGRATION_FEE_PERCENTAGE; exports.MAX_POOL_CREATION_FEE = MAX_POOL_CREATION_FEE; exports.MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT = MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT; exports.MAX_RATE_LIMITER_DURATION_IN_SECONDS = MAX_RATE_LIMITER_DURATION_IN_SECONDS; exports.MAX_RATE_LIMITER_DURATION_IN_SLOTS = MAX_RATE_LIMITER_DURATION_IN_SLOTS; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.METAPLEX_PROGRAM_ID = METAPLEX_PROGRAM_ID; exports.MIN_FEE_BPS = MIN_FEE_BPS; exports.MIN_FEE_NUMERATOR = MIN_FEE_NUMERATOR; exports.MIN_LOCKED_LIQUIDITY_BPS = MIN_LOCKED_LIQUIDITY_BPS; exports.MIN_MIGRATED_POOL_FEE_BPS = MIN_MIGRATED_POOL_FEE_BPS; exports.MIN_POOL_CREATION_FEE = MIN_POOL_CREATION_FEE; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.MigrationFeeOption = MigrationFeeOption; exports.MigrationOption = MigrationOption; exports.MigrationService = MigrationService; exports.OFFSET = OFFSET; exports.ONE_Q64 = ONE_Q64; exports.PROTOCOL_FEE_PERCENT = PROTOCOL_FEE_PERCENT; exports.PROTOCOL_POOL_CREATION_FEE_PERCENT = PROTOCOL_POOL_CREATION_FEE_PERCENT; exports.PartnerService = PartnerService; exports.PoolService = PoolService; exports.RESOLUTION = RESOLUTION; exports.Rounding = Rounding; exports.SECONDS_PER_DAY = SECONDS_PER_DAY; exports.SWAP_BUFFER_PERCENTAGE = SWAP_BUFFER_PERCENTAGE; exports.SafeMath = SafeMath; exports.StateService = StateService; exports.SwapMode = SwapMode; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TokenUpdateAuthorityOption = TokenUpdateAuthorityOption; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_MAX; exports.U24_MAX = U24_MAX; exports.U64_MAX = U64_MAX; exports.VAULT_PROGRAM_ID = VAULT_PROGRAM_ID; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.buildCurve = buildCurve; exports.buildCurveWithCustomSqrtPrices = buildCurveWithCustomSqrtPrices; exports.buildCurveWithLiquidityWeights = buildCurveWithLiquidityWeights; exports.buildCurveWithMarketCap = buildCurveWithMarketCap; exports.buildCurveWithMidPrice = buildCurveWithMidPrice; exports.buildCurveWithTwoSegments = buildCurveWithTwoSegments; exports.calculateAdjustedPercentageSupplyOnMigration = calculateAdjustedPercentageSupplyOnMigration; exports.calculateBaseToQuoteFromAmountIn = calculateBaseToQuoteFromAmountIn; exports.calculateBaseToQuoteFromAmountOut = calculateBaseToQuoteFromAmountOut; exports.calculateFeeSchedulerEndingBaseFeeBps = calculateFeeSchedulerEndingBaseFeeBps; exports.calculateLockedLiquidityBpsAtTime = calculateLockedLiquidityBpsAtTime; exports.calculateQuoteToBaseFromAmountIn = calculateQuoteToBaseFromAmountIn; exports.calculateQuoteToBaseFromAmountOut = calculateQuoteToBaseFromAmountOut; exports.checkRateLimiterApplied = checkRateLimiterApplied; exports.cleanUpTokenAccountTx = cleanUpTokenAccountTx; exports.convertDecimalToBN = convertDecimalToBN; exports.convertToLamports = convertToLamports; exports.createDammV1Program = createDammV1Program; exports.createDammV2Program = createDammV2Program; exports.createDbcProgram = createDbcProgram; exports.createInitializePermissionlessDynamicVaultIx = createInitializePermissionlessDynamicVaultIx; exports.createLockEscrowIx = createLockEscrowIx; exports.createProgramAccountFilter = createProgramAccountFilter; exports.createSqrtPrices = createSqrtPrices; exports.createVaultProgram = createVaultProgram; exports.deriveBaseKeyForLocker = deriveBaseKeyForLocker; exports.deriveDammV1EventAuthority = deriveDammV1EventAuthority; exports.deriveDammV1LockEscrowAddress = deriveDammV1LockEscrowAddress; exports.deriveDammV1LpMintAddress = deriveDammV1LpMintAddress; exports.deriveDammV1MigrationMetadataAddress = deriveDammV1MigrationMetadataAddress; exports.deriveDammV1PoolAddress = deriveDammV1PoolAddress; exports.deriveDammV1PoolAuthority = deriveDammV1PoolAuthority; exports.deriveDammV1ProtocolFeeAddress = deriveDammV1ProtocolFeeAddress; exports.deriveDammV1VaultLPAddress = deriveDammV1VaultLPAddress; exports.deriveDammV2EventAuthority = deriveDammV2EventAuthority; exports.deriveDammV2LockEscrowAddress = deriveDammV2LockEscrowAddress; exports.deriveDammV2MigrationMetadataAddress = deriveDammV2MigrationMetadataAddress; exports.deriveDammV2PoolAddress = deriveDammV2PoolAddress; exports.deriveDammV2PoolAuthority = deriveDammV2PoolAuthority; exports.deriveDammV2PositionVestingAccount = deriveDammV2PositionVestingAccount; exports.deriveDammV2TokenVaultAddress = deriveDammV2TokenVaultAddress; exports.deriveDbcEventAuthority = deriveDbcEventAuthority; exports.deriveDbcPoolAddress = deriveDbcPoolAddress; exports.deriveDbcPoolAuthority = deriveDbcPoolAuthority; exports.deriveDbcPoolMetadata = deriveDbcPoolMetadata; exports.deriveDbcTokenVaultAddress = deriveDbcTokenVaultAddress; exports.deriveEscrow = deriveEscrow; exports.deriveLockerEventAuthority = deriveLockerEventAuthority; exports.deriveMintMetadata = deriveMintMetadata; exports.derivePartnerMetadata = derivePartnerMetadata; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveTokenVaultKey = deriveTokenVaultKey; exports.deriveVaultAddress = deriveVaultAddress; exports.deriveVaultLpMintAddress = deriveVaultLpMintAddress; exports.deriveVaultPdas = deriveVaultPdas; exports.feeNumeratorToBps = feeNumeratorToBps; exports.findAssociatedTokenAddress = findAssociatedTokenAddress; exports.fromDecimalToBN = fromDecimalToBN; exports.getAccountCreationTimestamp = getAccountCreationTimestamp; exports.getAccountCreationTimestamps = getAccountCreationTimestamps; exports.getAccountData = getAccountData; exports.getBaseFeeHandler = getBaseFeeHandler; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getBaseFeeNumeratorByPeriod = getBaseFeeNumeratorByPeriod; exports.getBaseFeeParams = getBaseFeeParams; exports.getBaseTokenForSwap = getBaseTokenForSwap; exports.getCheckedAmounts = getCheckedAmounts; exports.getCurrentPoint = getCurrentPoint; exports.getCurveBreakdown = getCurveBreakdown; exports.getDeltaAmountBaseUnsigned = getDeltaAmountBaseUnsigned; exports.getDeltaAmountBaseUnsigned256 = getDeltaAmountBaseUnsigned256; exports.getDeltaAmountBaseUnsignedUnchecked = getDeltaAmountBaseUnsignedUnchecked; exports.getDeltaAmountQuoteUnsigned = getDeltaAmountQuoteUnsigned; exports.getDeltaAmountQuoteUnsigned256 = getDeltaAmountQuoteUnsigned256; exports.getDeltaAmountQuoteUnsignedUnchecked = getDeltaAmountQuoteUnsignedUnchecked; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getExcludedFeeAmount = getExcludedFeeAmount; exports.getFeeMode = getFeeMode; exports.getFeeNumeratorFromExcludedAmount = getFeeNumeratorFromExcludedAmount; exports.getFeeNumeratorFromIncludedAmount = getFeeNumeratorFromIncludedAmount; exports.getFeeNumeratorOnExponentialFeeScheduler = getFeeNumeratorOnExponentialFeeScheduler; exports.getFeeNumeratorOnLinearFeeScheduler = getFeeNumeratorOnLinearFeeScheduler; exports.getFeeOnAmount = getFeeOnAmount; exports.getFeeSchedulerMaxBaseFeeNumerator = getFeeSchedulerMaxBaseFeeNumerator; exports.getFeeSchedulerMinBaseFeeNumerator = getFeeSchedulerMinBaseFeeNumerator; exports.getFeeSchedulerParams = getFeeSchedulerParams; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getLiquidity = getLiquidity; exports.getLiquidityVestingInfoParams = getLiquidityVestingInfoParams; exports.getLockedVestingParams = getLockedVestingParams; exports.getMaxIndex = getMaxIndex; exports.getMaxOutAmountWithMinBaseFee = getMaxOutAmountWithMinBaseFee; exports.getMigratedPoolFeeParams = getMigratedPoolFeeParams; exports.getMigratedPoolMarketCapFeeSchedulerParams = getMigratedPoolMarketCapFeeSchedulerParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteAmount = getMigrationQuoteAmount; exports.getMigrationQuoteAmountFromMigrationQuoteThreshold = getMigrationQuoteAmountFromMigrationQuoteThreshold; exports.getMigrationQuoteThresholdFromMigrationQuoteAmount = getMigrationQuoteThresholdFromMigrationQuoteAmount; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getNextSqrtPriceFromBaseAmountInRoundingUp = getNextSqrtPriceFromBaseAmountInRoundingUp; exports.getNextSqrtPriceFromBaseAmountOutRoundingUp = getNextSqrtPriceFromBaseAmountOutRoundingUp; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getNextSqrtPriceFromOutput = getNextSqrtPriceFromOutput; exports.getNextSqrtPriceFromQuoteAmountInRoundingDown = getNextSqrtPriceFromQuoteAmountInRoundingDown; exports.getNextSqrtPriceFromQuoteAmountOutRoundingDown = getNextSqrtPriceFromQuoteAmountOutRoundingDown; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPercentageSupplyOnMigration = getPercentageSupplyOnMigration; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getProtocolMigrationFee = getProtocolMigrationFee; exports.getQuoteReserveFromNextSqrtPrice = getQuoteReserveFromNextSqrtPrice; exports.getRateLimiterExcludedFeeAmount = getRateLimiterExcludedFeeAmount; exports.getRateLimiterMinBaseFeeNumerator = getRateLimiterMinBaseFeeNumerator; exports.getRateLimiterParams = getRateLimiterParams; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getStartingBaseFeeBpsFromBaseFeeParams = getStartingBaseFeeBpsFromBaseFeeParams; exports.getSwapAmountWithBuffer = getSwapAmountWithBuffer; exports.getSwapResult = getSwapResult; exports.getSwapResultFromExactInput = getSwapResultFromExactInput; exports.getSwapResultFromExactOutput = getSwapResultFromExactOutput; exports.getSwapResultFromPartialInput = getSwapResultFromPartialInput; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTokenType = getTokenType; exports.getTokenomics = getTokenomics; exports.getTotalFeeNumerator = getTotalFeeNumerator; exports.getTotalFeeNumeratorFromExcludedFeeAmount = getTotalFeeNumeratorFromExcludedFeeAmount; exports.getTotalFeeNumeratorFromIncludedFeeAmount = getTotalFeeNumeratorFromIncludedFeeAmount; exports.getTotalSupplyFromCurve = getTotalSupplyFromCurve; exports.getTotalTokenSupply = getTotalTokenSupply; exports.getTotalVestingAmount = getTotalVestingAmount; exports.getTwoCurve = getTwoCurve; exports.getVariableFeeNumerator = getVariableFeeNumerator; exports.getVestingLockedLiquidityBpsAtNSeconds = getVestingLockedLiquidityBpsAtNSeconds; exports.isDefaultLockedVesting = isDefaultLockedVesting; exports.isDynamicFeeEnabled = isDynamicFeeEnabled; exports.isNativeSol = isNativeSol; exports.isNonZeroRateLimiter = isNonZeroRateLimiter; exports.isRateLimiterApplied = isRateLimiterApplied; exports.isZeroRateLimiter = isZeroRateLimiter; exports.mulDiv = mulDiv; exports.mulShr = mulShr; exports.pow = pow; exports.prepareSwapAmountParam = prepareSwapAmountParam; exports.prepareTokenAccountTx = prepareTokenAccountTx; exports.splitFees = splitFees; exports.sqrt = sqrt; exports.swapQuote = swapQuote; exports.swapQuoteExactIn = swapQuoteExactIn; exports.swapQuoteExactOut = swapQuoteExactOut; exports.swapQuotePartialFill = swapQuotePartialFill; exports.toNumerator = toNumerator; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateActivationType = validateActivationType; exports.validateBalance = validateBalance; exports.validateBaseTokenType = validateBaseTokenType; exports.validateCollectFeeMode = validateCollectFeeMode; exports.validateConfigParameters = validateConfigParameters; exports.validateCurve = validateCurve; exports.validateDynamicFee = validateDynamicFee; exports.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeScheduler = validateFeeScheduler; exports.validateLPPercentages = validateLPPercentages; exports.validateLiquidityVestingInfo = validateLiquidityVestingInfo; exports.validateMigratedPoolBaseFeeMode = validateMigratedPoolBaseFeeMode; exports.validateMigratedPoolFee = validateMigratedPoolFee; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFee = validateMigrationFee; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validateMinimumLockedLiquidity = validateMinimumLockedLiquidity; exports.validatePoolCreationFee = validatePoolCreationFee; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.validateTokenUpdateAuthorityOptions = validateTokenUpdateAuthorityOptions; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
28574
|
+
|
|
28575
|
+
|
|
28576
|
+
exports.ActivationType = ActivationType; exports.BASE_ADDRESS = BASE_ADDRESS; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.BaseFeeMode = BaseFeeMode; exports.CollectFeeMode = CollectFeeMode; exports.CreatorService = CreatorService; exports.DAMM_V1_MIGRATION_FEE_ADDRESS = DAMM_V1_MIGRATION_FEE_ADDRESS; exports.DAMM_V1_PROGRAM_ID = DAMM_V1_PROGRAM_ID; exports.DAMM_V2_MIGRATION_FEE_ADDRESS = DAMM_V2_MIGRATION_FEE_ADDRESS; exports.DAMM_V2_PROGRAM_ID = DAMM_V2_PROGRAM_ID; exports.DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS = DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS; exports.DEFAULT_MIGRATED_POOL_FEE_PARAMS = DEFAULT_MIGRATED_POOL_FEE_PARAMS; exports.DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS = DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS; exports.DYNAMIC_BONDING_CURVE_PROGRAM_ID = DYNAMIC_BONDING_CURVE_PROGRAM_ID; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; exports.DYNAMIC_FEE_ROUNDING_OFFSET = DYNAMIC_FEE_ROUNDING_OFFSET; exports.DYNAMIC_FEE_SCALING_FACTOR = DYNAMIC_FEE_SCALING_FACTOR; exports.DammV2BaseFeeMode = DammV2BaseFeeMode; exports.DammV2DynamicFeeMode = DammV2DynamicFeeMode; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveIdl = idl_default; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeScheduler = FeeScheduler; exports.HOST_FEE_PERCENT = HOST_FEE_PERCENT; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_BASIS_POINT = MAX_BASIS_POINT; exports.MAX_CREATOR_MIGRATION_FEE_PERCENTAGE = MAX_CREATOR_MIGRATION_FEE_PERCENTAGE; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_FEE_BPS = MAX_FEE_BPS; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_LOCK_DURATION_IN_SECONDS = MAX_LOCK_DURATION_IN_SECONDS; exports.MAX_MIGRATED_POOL_FEE_BPS = MAX_MIGRATED_POOL_FEE_BPS; exports.MAX_MIGRATION_FEE_PERCENTAGE = MAX_MIGRATION_FEE_PERCENTAGE; exports.MAX_POOL_CREATION_FEE = MAX_POOL_CREATION_FEE; exports.MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT = MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT; exports.MAX_RATE_LIMITER_DURATION_IN_SECONDS = MAX_RATE_LIMITER_DURATION_IN_SECONDS; exports.MAX_RATE_LIMITER_DURATION_IN_SLOTS = MAX_RATE_LIMITER_DURATION_IN_SLOTS; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.METAPLEX_PROGRAM_ID = METAPLEX_PROGRAM_ID; exports.MIN_FEE_BPS = MIN_FEE_BPS; exports.MIN_FEE_NUMERATOR = MIN_FEE_NUMERATOR; exports.MIN_LOCKED_LIQUIDITY_BPS = MIN_LOCKED_LIQUIDITY_BPS; exports.MIN_MIGRATED_POOL_FEE_BPS = MIN_MIGRATED_POOL_FEE_BPS; exports.MIN_POOL_CREATION_FEE = MIN_POOL_CREATION_FEE; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.MigrationFeeOption = MigrationFeeOption; exports.MigrationOption = MigrationOption; exports.MigrationService = MigrationService; exports.OFFSET = OFFSET; exports.ONE_Q64 = ONE_Q64; exports.PROTOCOL_FEE_PERCENT = PROTOCOL_FEE_PERCENT; exports.PROTOCOL_POOL_CREATION_FEE_PERCENT = PROTOCOL_POOL_CREATION_FEE_PERCENT; exports.PartnerService = PartnerService; exports.PoolService = PoolService; exports.RESOLUTION = RESOLUTION; exports.Rounding = Rounding; exports.SECONDS_PER_DAY = SECONDS_PER_DAY; exports.SWAP_BUFFER_PERCENTAGE = SWAP_BUFFER_PERCENTAGE; exports.SafeMath = SafeMath; exports.StateService = StateService; exports.SwapMode = SwapMode; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TokenUpdateAuthorityOption = TokenUpdateAuthorityOption; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_MAX; exports.U24_MAX = U24_MAX; exports.U64_MAX = U64_MAX; exports.VAULT_PROGRAM_ID = VAULT_PROGRAM_ID; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.buildCurve = buildCurve; exports.buildCurveWithCustomSqrtPrices = buildCurveWithCustomSqrtPrices; exports.buildCurveWithLiquidityWeights = buildCurveWithLiquidityWeights; exports.buildCurveWithMarketCap = buildCurveWithMarketCap; exports.buildCurveWithMidPrice = buildCurveWithMidPrice; exports.buildCurveWithTwoSegments = buildCurveWithTwoSegments; exports.calculateAdjustedPercentageSupplyOnMigration = calculateAdjustedPercentageSupplyOnMigration; exports.calculateBaseToQuoteFromAmountIn = calculateBaseToQuoteFromAmountIn; exports.calculateBaseToQuoteFromAmountOut = calculateBaseToQuoteFromAmountOut; exports.calculateFeeSchedulerEndingBaseFeeBps = calculateFeeSchedulerEndingBaseFeeBps; exports.calculateLockedLiquidityBpsAtTime = calculateLockedLiquidityBpsAtTime; exports.calculateQuoteToBaseFromAmountIn = calculateQuoteToBaseFromAmountIn; exports.calculateQuoteToBaseFromAmountOut = calculateQuoteToBaseFromAmountOut; exports.checkRateLimiterApplied = checkRateLimiterApplied; exports.cleanUpTokenAccountTx = cleanUpTokenAccountTx; exports.convertDecimalToBN = convertDecimalToBN; exports.convertToLamports = convertToLamports; exports.createDammV1Program = createDammV1Program; exports.createDammV2Program = createDammV2Program; exports.createDbcProgram = createDbcProgram; exports.createInitializePermissionlessDynamicVaultIx = createInitializePermissionlessDynamicVaultIx; exports.createLockEscrowIx = createLockEscrowIx; exports.createProgramAccountFilter = createProgramAccountFilter; exports.createSqrtPrices = createSqrtPrices; exports.createVaultProgram = createVaultProgram; exports.deriveBaseKeyForLocker = deriveBaseKeyForLocker; exports.deriveDammV1EventAuthority = deriveDammV1EventAuthority; exports.deriveDammV1LockEscrowAddress = deriveDammV1LockEscrowAddress; exports.deriveDammV1LpMintAddress = deriveDammV1LpMintAddress; exports.deriveDammV1MigrationMetadataAddress = deriveDammV1MigrationMetadataAddress; exports.deriveDammV1PoolAddress = deriveDammV1PoolAddress; exports.deriveDammV1PoolAuthority = deriveDammV1PoolAuthority; exports.deriveDammV1ProtocolFeeAddress = deriveDammV1ProtocolFeeAddress; exports.deriveDammV1VaultLPAddress = deriveDammV1VaultLPAddress; exports.deriveDammV2EventAuthority = deriveDammV2EventAuthority; exports.deriveDammV2LockEscrowAddress = deriveDammV2LockEscrowAddress; exports.deriveDammV2MigrationMetadataAddress = deriveDammV2MigrationMetadataAddress; exports.deriveDammV2PoolAddress = deriveDammV2PoolAddress; exports.deriveDammV2PoolAuthority = deriveDammV2PoolAuthority; exports.deriveDammV2PositionVestingAccount = deriveDammV2PositionVestingAccount; exports.deriveDammV2TokenVaultAddress = deriveDammV2TokenVaultAddress; exports.deriveDbcEventAuthority = deriveDbcEventAuthority; exports.deriveDbcPoolAddress = deriveDbcPoolAddress; exports.deriveDbcPoolAuthority = deriveDbcPoolAuthority; exports.deriveDbcPoolMetadata = deriveDbcPoolMetadata; exports.deriveDbcTokenVaultAddress = deriveDbcTokenVaultAddress; exports.deriveEscrow = deriveEscrow; exports.deriveLockerEventAuthority = deriveLockerEventAuthority; exports.deriveMintMetadata = deriveMintMetadata; exports.derivePartnerMetadata = derivePartnerMetadata; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveTokenVaultKey = deriveTokenVaultKey; exports.deriveVaultAddress = deriveVaultAddress; exports.deriveVaultLpMintAddress = deriveVaultLpMintAddress; exports.deriveVaultPdas = deriveVaultPdas; exports.feeNumeratorToBps = feeNumeratorToBps; exports.findAssociatedTokenAddress = findAssociatedTokenAddress; exports.fromDecimalToBN = fromDecimalToBN; exports.getAccountCreationTimestamp = getAccountCreationTimestamp; exports.getAccountCreationTimestamps = getAccountCreationTimestamps; exports.getAccountData = getAccountData; exports.getBaseFeeHandler = getBaseFeeHandler; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getBaseFeeNumeratorByPeriod = getBaseFeeNumeratorByPeriod; exports.getBaseFeeParams = getBaseFeeParams; exports.getBaseTokenForSwap = getBaseTokenForSwap; exports.getCheckedAmounts = getCheckedAmounts; exports.getCurrentPoint = getCurrentPoint; exports.getCurveBreakdown = getCurveBreakdown; exports.getDeltaAmountBaseUnsigned = getDeltaAmountBaseUnsigned; exports.getDeltaAmountBaseUnsigned256 = getDeltaAmountBaseUnsigned256; exports.getDeltaAmountBaseUnsignedUnchecked = getDeltaAmountBaseUnsignedUnchecked; exports.getDeltaAmountQuoteUnsigned = getDeltaAmountQuoteUnsigned; exports.getDeltaAmountQuoteUnsigned256 = getDeltaAmountQuoteUnsigned256; exports.getDeltaAmountQuoteUnsignedUnchecked = getDeltaAmountQuoteUnsignedUnchecked; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getExcludedFeeAmount = getExcludedFeeAmount; exports.getFeeMode = getFeeMode; exports.getFeeNumeratorFromExcludedAmount = getFeeNumeratorFromExcludedAmount; exports.getFeeNumeratorFromIncludedAmount = getFeeNumeratorFromIncludedAmount; exports.getFeeNumeratorOnExponentialFeeScheduler = getFeeNumeratorOnExponentialFeeScheduler; exports.getFeeNumeratorOnLinearFeeScheduler = getFeeNumeratorOnLinearFeeScheduler; exports.getFeeOnAmount = getFeeOnAmount; exports.getFeeSchedulerMaxBaseFeeNumerator = getFeeSchedulerMaxBaseFeeNumerator; exports.getFeeSchedulerMinBaseFeeNumerator = getFeeSchedulerMinBaseFeeNumerator; exports.getFeeSchedulerParams = getFeeSchedulerParams; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getLiquidity = getLiquidity; exports.getLiquidityVestingInfoParams = getLiquidityVestingInfoParams; exports.getLockedVestingParams = getLockedVestingParams; exports.getMaxIndex = getMaxIndex; exports.getMaxOutAmountWithMinBaseFee = getMaxOutAmountWithMinBaseFee; exports.getMigratedPoolFeeParams = getMigratedPoolFeeParams; exports.getMigratedPoolMarketCapFeeSchedulerParams = getMigratedPoolMarketCapFeeSchedulerParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteAmount = getMigrationQuoteAmount; exports.getMigrationQuoteAmountFromMigrationQuoteThreshold = getMigrationQuoteAmountFromMigrationQuoteThreshold; exports.getMigrationQuoteThresholdFromMigrationQuoteAmount = getMigrationQuoteThresholdFromMigrationQuoteAmount; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getNextSqrtPriceFromBaseAmountInRoundingUp = getNextSqrtPriceFromBaseAmountInRoundingUp; exports.getNextSqrtPriceFromBaseAmountOutRoundingUp = getNextSqrtPriceFromBaseAmountOutRoundingUp; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getNextSqrtPriceFromOutput = getNextSqrtPriceFromOutput; exports.getNextSqrtPriceFromQuoteAmountInRoundingDown = getNextSqrtPriceFromQuoteAmountInRoundingDown; exports.getNextSqrtPriceFromQuoteAmountOutRoundingDown = getNextSqrtPriceFromQuoteAmountOutRoundingDown; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPercentageSupplyOnMigration = getPercentageSupplyOnMigration; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getProtocolMigrationFee = getProtocolMigrationFee; exports.getQuoteReserveFromNextSqrtPrice = getQuoteReserveFromNextSqrtPrice; exports.getRateLimiterExcludedFeeAmount = getRateLimiterExcludedFeeAmount; exports.getRateLimiterMinBaseFeeNumerator = getRateLimiterMinBaseFeeNumerator; exports.getRateLimiterParams = getRateLimiterParams; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getStartingBaseFeeBpsFromBaseFeeParams = getStartingBaseFeeBpsFromBaseFeeParams; exports.getSwapAmountWithBuffer = getSwapAmountWithBuffer; exports.getSwapResult = getSwapResult; exports.getSwapResultFromExactInput = getSwapResultFromExactInput; exports.getSwapResultFromExactOutput = getSwapResultFromExactOutput; exports.getSwapResultFromPartialInput = getSwapResultFromPartialInput; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTokenType = getTokenType; exports.getTokenomics = getTokenomics; exports.getTotalFeeNumerator = getTotalFeeNumerator; exports.getTotalFeeNumeratorFromExcludedFeeAmount = getTotalFeeNumeratorFromExcludedFeeAmount; exports.getTotalFeeNumeratorFromIncludedFeeAmount = getTotalFeeNumeratorFromIncludedFeeAmount; exports.getTotalSupplyFromCurve = getTotalSupplyFromCurve; exports.getTotalTokenSupply = getTotalTokenSupply; exports.getTotalVestingAmount = getTotalVestingAmount; exports.getTwoCurve = getTwoCurve; exports.getVariableFeeNumerator = getVariableFeeNumerator; exports.getVestingLockedLiquidityBpsAtNSeconds = getVestingLockedLiquidityBpsAtNSeconds; exports.isDefaultLockedVesting = isDefaultLockedVesting; exports.isDynamicFeeEnabled = isDynamicFeeEnabled; exports.isNativeSol = isNativeSol; exports.isNonZeroRateLimiter = isNonZeroRateLimiter; exports.isRateLimiterApplied = isRateLimiterApplied; exports.isZeroRateLimiter = isZeroRateLimiter; exports.mulDiv = mulDiv; exports.mulShr = mulShr; exports.pow = pow; exports.prepareSwapAmountParam = prepareSwapAmountParam; exports.prepareTokenAccountTx = prepareTokenAccountTx; exports.splitFees = splitFees; exports.sqrt = sqrt; exports.swapQuote = swapQuote; exports.swapQuoteExactIn = swapQuoteExactIn; exports.swapQuoteExactOut = swapQuoteExactOut; exports.swapQuotePartialFill = swapQuotePartialFill; exports.toNumerator = toNumerator; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateActivationType = validateActivationType; exports.validateBalance = validateBalance; exports.validateBaseTokenType = validateBaseTokenType; exports.validateCollectFeeMode = validateCollectFeeMode; exports.validateConfigParameters = validateConfigParameters; exports.validateCurve = validateCurve; exports.validateDynamicFee = validateDynamicFee; exports.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeScheduler = validateFeeScheduler; exports.validateLPPercentages = validateLPPercentages; exports.validateLiquidityVestingInfo = validateLiquidityVestingInfo; exports.validateMarketCapFeeSchedulerRequiresPoolFeeBps = validateMarketCapFeeSchedulerRequiresPoolFeeBps; exports.validateMigratedPoolBaseFeeMode = validateMigratedPoolBaseFeeMode; exports.validateMigratedPoolFee = validateMigratedPoolFee; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFee = validateMigrationFee; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validateMinimumLockedLiquidity = validateMinimumLockedLiquidity; exports.validatePoolCreationFee = validatePoolCreationFee; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.validateTokenUpdateAuthorityOptions = validateTokenUpdateAuthorityOptions; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
28478
28577
|
//# sourceMappingURL=index.cjs.map
|