@meteora-ag/dynamic-bonding-curve-sdk 1.4.9 → 1.4.10

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 CHANGED
@@ -737,8 +737,17 @@ var getSqrtPriceFromPrice = (price, tokenADecimal, tokenBDecimal) => {
737
737
  const sqrtValueQ64 = sqrtValue.mul(_decimaljs2.default.pow(2, 64));
738
738
  return new (0, _bnjs2.default)(sqrtValueQ64.floor().toFixed());
739
739
  };
740
+ var createSqrtPrices = (prices, tokenBaseDecimal, tokenQuoteDecimal) => {
741
+ return prices.map(
742
+ (price) => getSqrtPriceFromPrice(
743
+ price.toString(),
744
+ tokenBaseDecimal,
745
+ tokenQuoteDecimal
746
+ )
747
+ );
748
+ };
740
749
  var getSqrtPriceFromMarketCap = (marketCap, totalSupply, tokenBaseDecimal, tokenQuoteDecimal) => {
741
- let price = new (0, _decimaljs2.default)(marketCap).div(new (0, _decimaljs2.default)(totalSupply));
750
+ const price = new (0, _decimaljs2.default)(marketCap).div(new (0, _decimaljs2.default)(totalSupply));
742
751
  return getSqrtPriceFromPrice(
743
752
  price.toString(),
744
753
  tokenBaseDecimal,
@@ -924,8 +933,8 @@ var getMigrationThresholdPrice = (migrationThreshold, sqrtStartPrice, curve) =>
924
933
  }
925
934
  }
926
935
  if (!amountLeft.isZero()) {
927
- let migrationThresholdStr = migrationThreshold.toString();
928
- let amountLeftStr = amountLeft.toString();
936
+ const migrationThresholdStr = migrationThreshold.toString();
937
+ const amountLeftStr = amountLeft.toString();
929
938
  throw Error(
930
939
  `Not enough liquidity, migrationThreshold: ${migrationThresholdStr} amountLeft: ${amountLeftStr}`
931
940
  );
@@ -1004,6 +1013,21 @@ var getPercentageSupplyOnMigration = (initialMarketCap, migrationMarketCap, lock
1004
1013
  const denominator = new (0, _decimaljs2.default)(1).add(sqrtRatio);
1005
1014
  return numerator.div(denominator).toNumber();
1006
1015
  };
1016
+ function calculateAdjustedPercentageSupplyOnMigration(initialMarketCap, migrationMarketCap, migrationFee, lockedVesting, totalLeftover, totalTokenSupply) {
1017
+ const D = new (0, _decimaljs2.default)(initialMarketCap);
1018
+ const M = new (0, _decimaljs2.default)(migrationMarketCap);
1019
+ const f = new (0, _decimaljs2.default)(migrationFee.feePercentage).div(100);
1020
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
1021
+ const V = new (0, _decimaljs2.default)(totalVestingAmount.toString()).mul(100).div(new (0, _decimaljs2.default)(totalTokenSupply.toString()));
1022
+ const L = new (0, _decimaljs2.default)(totalLeftover.toString()).mul(100).div(new (0, _decimaljs2.default)(totalTokenSupply.toString()));
1023
+ const requiredRatio = _decimaljs2.default.sqrt(D.div(M));
1024
+ const oneMinusF = new (0, _decimaljs2.default)(1).sub(f);
1025
+ const availablePercentage = new (0, _decimaljs2.default)(100).sub(V).sub(L);
1026
+ const numerator = requiredRatio.mul(oneMinusF).mul(availablePercentage);
1027
+ const denominator = new (0, _decimaljs2.default)(1).add(requiredRatio.mul(oneMinusF));
1028
+ const percentageSupplyOnMigration = numerator.div(denominator).toNumber();
1029
+ return percentageSupplyOnMigration;
1030
+ }
1007
1031
  var getMigrationQuoteAmount = (migrationMarketCap, percentageSupplyOnMigration) => {
1008
1032
  return migrationMarketCap.mul(percentageSupplyOnMigration).div(new (0, _decimaljs2.default)(100));
1009
1033
  };
@@ -1205,19 +1229,19 @@ function getLockedVestingParams(totalLockedVestingAmount, numberOfVestingPeriod,
1205
1229
  };
1206
1230
  }
1207
1231
  var getTwoCurve = (migrationSqrtPrice, midSqrtPrice, initialSqrtPrice, swapAmount, migrationQuoteThreshold) => {
1208
- let p0 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
1209
- let p1 = new (0, _decimaljs2.default)(midSqrtPrice.toString());
1210
- let p2 = new (0, _decimaljs2.default)(migrationSqrtPrice.toString());
1211
- let a1 = new (0, _decimaljs2.default)(1).div(p0).sub(new (0, _decimaljs2.default)(1).div(p1));
1212
- let b1 = new (0, _decimaljs2.default)(1).div(p1).sub(new (0, _decimaljs2.default)(1).div(p2));
1213
- let c1 = new (0, _decimaljs2.default)(swapAmount.toString());
1214
- let a2 = p1.sub(p0);
1215
- let b2 = p2.sub(p1);
1216
- let c2 = new (0, _decimaljs2.default)(migrationQuoteThreshold.toString()).mul(
1232
+ const p0 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
1233
+ const p1 = new (0, _decimaljs2.default)(midSqrtPrice.toString());
1234
+ const p2 = new (0, _decimaljs2.default)(migrationSqrtPrice.toString());
1235
+ const a1 = new (0, _decimaljs2.default)(1).div(p0).sub(new (0, _decimaljs2.default)(1).div(p1));
1236
+ const b1 = new (0, _decimaljs2.default)(1).div(p1).sub(new (0, _decimaljs2.default)(1).div(p2));
1237
+ const c1 = new (0, _decimaljs2.default)(swapAmount.toString());
1238
+ const a2 = p1.sub(p0);
1239
+ const b2 = p2.sub(p1);
1240
+ const c2 = new (0, _decimaljs2.default)(migrationQuoteThreshold.toString()).mul(
1217
1241
  _decimaljs2.default.pow(2, 128)
1218
1242
  );
1219
- let l0 = c1.mul(b2).sub(c2.mul(b1)).div(a1.mul(b2).sub(a2.mul(b1)));
1220
- let l1 = c1.mul(a2).sub(c2.mul(a1)).div(b1.mul(a2).sub(b2.mul(a1)));
1243
+ const l0 = c1.mul(b2).sub(c2.mul(b1)).div(a1.mul(b2).sub(a2.mul(b1)));
1244
+ const l1 = c1.mul(a2).sub(c2.mul(a1)).div(b1.mul(a2).sub(b2.mul(a1)));
1221
1245
  if (l0.isNeg() || l1.isNeg()) {
1222
1246
  return {
1223
1247
  isOk: false,
@@ -3291,7 +3315,7 @@ function validateMigrationFee(migrationFee) {
3291
3315
 
3292
3316
 
3293
3317
  function buildCurve(buildCurveParam) {
3294
- let {
3318
+ const {
3295
3319
  totalTokenSupply,
3296
3320
  percentageSupplyOnMigration,
3297
3321
  migrationQuoteThreshold,
@@ -3348,7 +3372,7 @@ function buildCurve(buildCurveParam) {
3348
3372
  const migrationPrice = new (0, _decimaljs2.default)(migrationQuoteAmount.toString()).div(
3349
3373
  new (0, _decimaljs2.default)(migrationBaseSupply.toString())
3350
3374
  );
3351
- let migrationQuoteThresholdInLamport = convertToLamports(
3375
+ const migrationQuoteThresholdInLamport = convertToLamports(
3352
3376
  migrationQuoteThreshold,
3353
3377
  tokenQuoteDecimal
3354
3378
  );
@@ -3358,7 +3382,7 @@ function buildCurve(buildCurveParam) {
3358
3382
  tokenBaseDecimal,
3359
3383
  tokenQuoteDecimal
3360
3384
  );
3361
- let migrationQuoteAmountInLamport = fromDecimalToBN(
3385
+ const migrationQuoteAmountInLamport = fromDecimalToBN(
3362
3386
  migrationQuoteAmount.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3363
3387
  );
3364
3388
  const migrationBaseAmount = getMigrationBaseToken(
@@ -3461,7 +3485,14 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
3461
3485
  );
3462
3486
  const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3463
3487
  const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3464
- const percentageSupplyOnMigration = getPercentageSupplyOnMigration(
3488
+ const percentageSupplyOnMigration = migrationFee.feePercentage > 0 ? calculateAdjustedPercentageSupplyOnMigration(
3489
+ initialMarketCap,
3490
+ migrationMarketCap,
3491
+ migrationFee,
3492
+ lockedVesting,
3493
+ totalLeftover,
3494
+ totalSupply
3495
+ ) : getPercentageSupplyOnMigration(
3465
3496
  new (0, _decimaljs2.default)(initialMarketCap),
3466
3497
  new (0, _decimaljs2.default)(migrationMarketCap),
3467
3498
  lockedVesting,
@@ -3532,57 +3563,57 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3532
3563
  migrationFeeOption,
3533
3564
  migratedPoolFee
3534
3565
  );
3535
- let migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
3536
- let totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3537
- let migrationQuoteAmount = getMigrationQuoteAmount(
3566
+ const migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
3567
+ const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3568
+ const migrationQuoteAmount = getMigrationQuoteAmount(
3538
3569
  new (0, _decimaljs2.default)(migrationMarketCap),
3539
3570
  new (0, _decimaljs2.default)(percentageSupplyOnMigration)
3540
3571
  );
3541
- let migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3572
+ const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3542
3573
  migrationQuoteAmount,
3543
3574
  new (0, _decimaljs2.default)(migrationFee.feePercentage)
3544
3575
  );
3545
- let migrationPrice = migrationQuoteAmount.div(
3576
+ const migrationPrice = migrationQuoteAmount.div(
3546
3577
  new (0, _decimaljs2.default)(migrationBaseSupply.toString())
3547
3578
  );
3548
- let migrationQuoteThresholdInLamport = fromDecimalToBN(
3579
+ const migrationQuoteThresholdInLamport = fromDecimalToBN(
3549
3580
  migrationQuoteThreshold.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3550
3581
  );
3551
- let migrationQuoteAmountInLamport = fromDecimalToBN(
3582
+ const migrationQuoteAmountInLamport = fromDecimalToBN(
3552
3583
  migrationQuoteAmount.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3553
3584
  );
3554
- let migrateSqrtPrice = getSqrtPriceFromPrice(
3585
+ const migrateSqrtPrice = getSqrtPriceFromPrice(
3555
3586
  migrationPrice.toString(),
3556
3587
  tokenBaseDecimal,
3557
3588
  tokenQuoteDecimal
3558
3589
  );
3559
- let migrationBaseAmount = getMigrationBaseToken(
3590
+ const migrationBaseAmount = getMigrationBaseToken(
3560
3591
  migrationQuoteAmountInLamport,
3561
3592
  migrateSqrtPrice,
3562
3593
  migrationOption
3563
3594
  );
3564
- let totalVestingAmount = getTotalVestingAmount(lockedVesting);
3565
- let totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3566
- let swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
3567
- let initialSqrtPrice = getSqrtPriceFromMarketCap(
3595
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
3596
+ const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3597
+ const swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
3598
+ const initialSqrtPrice = getSqrtPriceFromMarketCap(
3568
3599
  initialMarketCap,
3569
3600
  totalTokenSupply,
3570
3601
  tokenBaseDecimal,
3571
3602
  tokenQuoteDecimal
3572
3603
  );
3573
- let midSqrtPriceDecimal1 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString()).mul(new (0, _decimaljs2.default)(initialSqrtPrice.toString())).sqrt();
3574
- let midSqrtPrice1 = new (0, _bnjs2.default)(midSqrtPriceDecimal1.floor().toFixed());
3575
- let numerator1 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
3576
- let numerator2 = _decimaljs2.default.pow(migrateSqrtPrice.toString(), 3);
3577
- let product1 = numerator1.mul(numerator2);
3578
- let midSqrtPriceDecimal2 = _decimaljs2.default.pow(product1, 0.25);
3579
- let midSqrtPrice2 = new (0, _bnjs2.default)(midSqrtPriceDecimal2.floor().toFixed());
3580
- let numerator3 = _decimaljs2.default.pow(initialSqrtPrice.toString(), 3);
3581
- let numerator4 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString());
3582
- let product2 = numerator3.mul(numerator4);
3583
- let midSqrtPriceDecimal3 = _decimaljs2.default.pow(product2, 0.25);
3584
- let midSqrtPrice3 = new (0, _bnjs2.default)(midSqrtPriceDecimal3.floor().toFixed());
3585
- let midPrices = [midSqrtPrice3, midSqrtPrice2, midSqrtPrice1];
3604
+ const midSqrtPriceDecimal1 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString()).mul(new (0, _decimaljs2.default)(initialSqrtPrice.toString())).sqrt();
3605
+ const midSqrtPrice1 = new (0, _bnjs2.default)(midSqrtPriceDecimal1.floor().toFixed());
3606
+ const numerator1 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
3607
+ const numerator2 = _decimaljs2.default.pow(migrateSqrtPrice.toString(), 3);
3608
+ const product1 = numerator1.mul(numerator2);
3609
+ const midSqrtPriceDecimal2 = _decimaljs2.default.pow(product1, 0.25);
3610
+ const midSqrtPrice2 = new (0, _bnjs2.default)(midSqrtPriceDecimal2.floor().toFixed());
3611
+ const numerator3 = _decimaljs2.default.pow(initialSqrtPrice.toString(), 3);
3612
+ const numerator4 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString());
3613
+ const product2 = numerator3.mul(numerator4);
3614
+ const midSqrtPriceDecimal3 = _decimaljs2.default.pow(product2, 0.25);
3615
+ const midSqrtPrice3 = new (0, _bnjs2.default)(midSqrtPriceDecimal3.floor().toFixed());
3616
+ const midPrices = [midSqrtPrice3, midSqrtPrice2, midSqrtPrice1];
3586
3617
  let sqrtStartPrice = new (0, _bnjs2.default)(0);
3587
3618
  let curve = [];
3588
3619
  for (let i = 0; i < midPrices.length; i++) {
@@ -3599,7 +3630,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3599
3630
  break;
3600
3631
  }
3601
3632
  }
3602
- let totalDynamicSupply = getTotalSupplyFromCurve(
3633
+ const totalDynamicSupply = getTotalSupplyFromCurve(
3603
3634
  migrationQuoteThresholdInLamport,
3604
3635
  sqrtStartPrice,
3605
3636
  curve,
@@ -3609,7 +3640,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3609
3640
  migrationFee.feePercentage
3610
3641
  );
3611
3642
  if (totalDynamicSupply.gt(totalSupply)) {
3612
- let leftOverDelta = totalDynamicSupply.sub(totalSupply);
3643
+ const leftOverDelta = totalDynamicSupply.sub(totalSupply);
3613
3644
  if (!leftOverDelta.lt(totalLeftover)) {
3614
3645
  throw new Error("leftOverDelta must be less than totalLeftover");
3615
3646
  }
@@ -3704,39 +3735,39 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3704
3735
  migrationFeeOption,
3705
3736
  migratedPoolFee
3706
3737
  );
3707
- let migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
3708
- let totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3709
- let migrationQuoteAmount = getMigrationQuoteAmount(
3738
+ const migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
3739
+ const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3740
+ const migrationQuoteAmount = getMigrationQuoteAmount(
3710
3741
  new (0, _decimaljs2.default)(migrationMarketCap),
3711
3742
  new (0, _decimaljs2.default)(percentageSupplyOnMigration)
3712
3743
  );
3713
- let migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3744
+ const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3714
3745
  migrationQuoteAmount,
3715
3746
  new (0, _decimaljs2.default)(migrationFee.feePercentage)
3716
3747
  );
3717
- let migrationPrice = migrationQuoteAmount.div(
3748
+ const migrationPrice = migrationQuoteAmount.div(
3718
3749
  new (0, _decimaljs2.default)(migrationBaseSupply.toString())
3719
3750
  );
3720
- let migrationQuoteThresholdInLamport = fromDecimalToBN(
3751
+ const migrationQuoteThresholdInLamport = fromDecimalToBN(
3721
3752
  migrationQuoteThreshold.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3722
3753
  );
3723
- let migrationQuoteAmountInLamport = fromDecimalToBN(
3754
+ const migrationQuoteAmountInLamport = fromDecimalToBN(
3724
3755
  migrationQuoteAmount.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3725
3756
  );
3726
- let migrateSqrtPrice = getSqrtPriceFromPrice(
3757
+ const migrateSqrtPrice = getSqrtPriceFromPrice(
3727
3758
  migrationPrice.toString(),
3728
3759
  tokenBaseDecimal,
3729
3760
  tokenQuoteDecimal
3730
3761
  );
3731
- let migrationBaseAmount = getMigrationBaseToken(
3762
+ const migrationBaseAmount = getMigrationBaseToken(
3732
3763
  migrationQuoteAmountInLamport,
3733
3764
  migrateSqrtPrice,
3734
3765
  migrationOption
3735
3766
  );
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(
3767
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
3768
+ const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3769
+ const swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
3770
+ const initialSqrtPrice = getSqrtPriceFromMarketCap(
3740
3771
  initialMarketCap,
3741
3772
  totalTokenSupply,
3742
3773
  tokenBaseDecimal,
@@ -3758,7 +3789,7 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3758
3789
  );
3759
3790
  curve = result.curve;
3760
3791
  sqrtStartPrice = result.sqrtStartPrice;
3761
- let totalDynamicSupply = getTotalSupplyFromCurve(
3792
+ const totalDynamicSupply = getTotalSupplyFromCurve(
3762
3793
  migrationQuoteThresholdInLamport,
3763
3794
  sqrtStartPrice,
3764
3795
  curve,
@@ -3768,7 +3799,7 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3768
3799
  migrationFee.feePercentage
3769
3800
  );
3770
3801
  if (totalDynamicSupply.gt(totalSupply)) {
3771
- let leftOverDelta = totalDynamicSupply.sub(totalSupply);
3802
+ const leftOverDelta = totalDynamicSupply.sub(totalSupply);
3772
3803
  if (!leftOverDelta.lt(totalLeftover)) {
3773
3804
  throw new Error("leftOverDelta must be less than totalLeftover");
3774
3805
  }
@@ -3813,7 +3844,7 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3813
3844
  return instructionParams;
3814
3845
  }
3815
3846
  function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3816
- let {
3847
+ const {
3817
3848
  totalTokenSupply,
3818
3849
  migrationOption,
3819
3850
  tokenBaseDecimal,
@@ -3862,23 +3893,23 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3862
3893
  migrationFeeOption,
3863
3894
  migratedPoolFee
3864
3895
  );
3865
- let pMin = getSqrtPriceFromMarketCap(
3896
+ const pMin = getSqrtPriceFromMarketCap(
3866
3897
  initialMarketCap,
3867
3898
  totalTokenSupply,
3868
3899
  tokenBaseDecimal,
3869
3900
  tokenQuoteDecimal
3870
3901
  );
3871
- let pMax = getSqrtPriceFromMarketCap(
3902
+ const pMax = getSqrtPriceFromMarketCap(
3872
3903
  migrationMarketCap,
3873
3904
  totalTokenSupply,
3874
3905
  tokenBaseDecimal,
3875
3906
  tokenQuoteDecimal
3876
3907
  );
3877
- let priceRatio = new (0, _decimaljs2.default)(pMax.toString()).div(
3908
+ const priceRatio = new (0, _decimaljs2.default)(pMax.toString()).div(
3878
3909
  new (0, _decimaljs2.default)(pMin.toString())
3879
3910
  );
3880
- let qDecimal = priceRatio.pow(new (0, _decimaljs2.default)(1).div(new (0, _decimaljs2.default)(16)));
3881
- let sqrtPrices = [];
3911
+ const qDecimal = priceRatio.pow(new (0, _decimaljs2.default)(1).div(new (0, _decimaljs2.default)(16)));
3912
+ const sqrtPrices = [];
3882
3913
  let currentPrice = pMin;
3883
3914
  for (let i = 0; i < 17; i++) {
3884
3915
  sqrtPrices.push(currentPrice);
@@ -3886,49 +3917,217 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3886
3917
  qDecimal.mul(new (0, _decimaljs2.default)(currentPrice.toString()))
3887
3918
  );
3888
3919
  }
3889
- let totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3890
- let totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3891
- let totalVestingAmount = getTotalVestingAmount(lockedVesting);
3892
- let totalSwapAndMigrationAmount = totalSupply.sub(totalVestingAmount).sub(totalLeftover);
3920
+ const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3921
+ const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3922
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
3923
+ const totalSwapAndMigrationAmount = totalSupply.sub(totalVestingAmount).sub(totalLeftover);
3893
3924
  let sumFactor = new (0, _decimaljs2.default)(0);
3894
- let pmaxWeight = new (0, _decimaljs2.default)(pMax.toString());
3895
- let migrationFeeFactor = new (0, _decimaljs2.default)(100).sub(new (0, _decimaljs2.default)(migrationFee.feePercentage)).div(new (0, _decimaljs2.default)(100));
3925
+ const pmaxWeight = new (0, _decimaljs2.default)(pMax.toString());
3926
+ const migrationFeeFactor = new (0, _decimaljs2.default)(100).sub(new (0, _decimaljs2.default)(migrationFee.feePercentage)).div(new (0, _decimaljs2.default)(100));
3896
3927
  for (let i = 1; i < 17; i++) {
3897
- let pi = new (0, _decimaljs2.default)(sqrtPrices[i].toString());
3898
- let piMinus = new (0, _decimaljs2.default)(sqrtPrices[i - 1].toString());
3899
- let k = new (0, _decimaljs2.default)(liquidityWeights[i - 1]);
3900
- let w1 = pi.sub(piMinus).div(pi.mul(piMinus));
3901
- let w2 = pi.sub(piMinus).mul(migrationFeeFactor).div(pmaxWeight.mul(pmaxWeight));
3902
- let weight = k.mul(w1.add(w2));
3928
+ const pi = new (0, _decimaljs2.default)(sqrtPrices[i].toString());
3929
+ const piMinus = new (0, _decimaljs2.default)(sqrtPrices[i - 1].toString());
3930
+ const k = new (0, _decimaljs2.default)(liquidityWeights[i - 1]);
3931
+ const w1 = pi.sub(piMinus).div(pi.mul(piMinus));
3932
+ const w2 = pi.sub(piMinus).mul(migrationFeeFactor).div(pmaxWeight.mul(pmaxWeight));
3933
+ const weight = k.mul(w1.add(w2));
3903
3934
  sumFactor = sumFactor.add(weight);
3904
3935
  }
3905
- let l1 = new (0, _decimaljs2.default)(totalSwapAndMigrationAmount.toString()).div(sumFactor);
3906
- let curve = [];
3936
+ const l1 = new (0, _decimaljs2.default)(totalSwapAndMigrationAmount.toString()).div(
3937
+ sumFactor
3938
+ );
3939
+ const curve = [];
3907
3940
  for (let i = 0; i < 16; i++) {
3908
- let k = new (0, _decimaljs2.default)(liquidityWeights[i]);
3909
- let liquidity = convertDecimalToBN(l1.mul(k));
3910
- let sqrtPrice = i < 15 ? sqrtPrices[i + 1] : pMax;
3941
+ const k = new (0, _decimaljs2.default)(liquidityWeights[i]);
3942
+ const liquidity = convertDecimalToBN(l1.mul(k));
3943
+ const sqrtPrice = i < 15 ? sqrtPrices[i + 1] : pMax;
3944
+ curve.push({
3945
+ sqrtPrice,
3946
+ liquidity
3947
+ });
3948
+ }
3949
+ const swapBaseAmount = getBaseTokenForSwap(pMin, pMax, curve);
3950
+ const swapBaseAmountBuffer = getSwapAmountWithBuffer(
3951
+ swapBaseAmount,
3952
+ pMin,
3953
+ curve
3954
+ );
3955
+ const migrationAmount = totalSwapAndMigrationAmount.sub(swapBaseAmountBuffer);
3956
+ const migrationQuoteAmount = migrationAmount.mul(pMax).mul(pMax).shrn(128);
3957
+ const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3958
+ new (0, _decimaljs2.default)(migrationQuoteAmount.toString()),
3959
+ new (0, _decimaljs2.default)(migrationFee.feePercentage)
3960
+ );
3961
+ const migrationQuoteThresholdInLamport = fromDecimalToBN(
3962
+ migrationQuoteThreshold
3963
+ );
3964
+ const totalDynamicSupply = getTotalSupplyFromCurve(
3965
+ migrationQuoteThresholdInLamport,
3966
+ pMin,
3967
+ curve,
3968
+ lockedVesting,
3969
+ migrationOption,
3970
+ totalLeftover,
3971
+ migrationFee.feePercentage
3972
+ );
3973
+ if (totalDynamicSupply.gt(totalSupply)) {
3974
+ const leftOverDelta = totalDynamicSupply.sub(totalSupply);
3975
+ if (!leftOverDelta.lt(totalLeftover)) {
3976
+ throw new Error("leftOverDelta must be less than totalLeftover");
3977
+ }
3978
+ }
3979
+ const instructionParams = {
3980
+ poolFees: {
3981
+ baseFee: {
3982
+ ...baseFee
3983
+ },
3984
+ dynamicFee: dynamicFeeEnabled ? getDynamicFeeParams(
3985
+ baseFeeParams.baseFeeMode === 2 /* RateLimiter */ ? baseFeeParams.rateLimiterParam.baseFeeBps : baseFeeParams.feeSchedulerParam.endingFeeBps
3986
+ ) : null
3987
+ },
3988
+ activationType,
3989
+ collectFeeMode,
3990
+ migrationOption,
3991
+ tokenType,
3992
+ tokenDecimal: tokenBaseDecimal,
3993
+ migrationQuoteThreshold: migrationQuoteThresholdInLamport,
3994
+ partnerLpPercentage,
3995
+ creatorLpPercentage,
3996
+ partnerLockedLpPercentage,
3997
+ creatorLockedLpPercentage,
3998
+ sqrtStartPrice: pMin,
3999
+ lockedVesting,
4000
+ migrationFeeOption,
4001
+ tokenSupply: {
4002
+ preMigrationTokenSupply: totalSupply,
4003
+ postMigrationTokenSupply: totalSupply
4004
+ },
4005
+ creatorTradingFeePercentage,
4006
+ migratedPoolFee: {
4007
+ collectFeeMode: migratedPoolFeeParams.collectFeeMode,
4008
+ dynamicFee: migratedPoolFeeParams.dynamicFee,
4009
+ poolFeeBps: migratedPoolFeeParams.poolFeeBps
4010
+ },
4011
+ padding: [],
4012
+ curve,
4013
+ migrationFee,
4014
+ tokenUpdateAuthority
4015
+ };
4016
+ return instructionParams;
4017
+ }
4018
+ function buildCurveWithCustomSqrtPrices(buildCurveWithCustomSqrtPricesParam) {
4019
+ const {
4020
+ totalTokenSupply,
4021
+ migrationOption,
4022
+ tokenBaseDecimal,
4023
+ tokenQuoteDecimal,
4024
+ dynamicFeeEnabled,
4025
+ activationType,
4026
+ collectFeeMode,
4027
+ migrationFeeOption,
4028
+ tokenType,
4029
+ partnerLpPercentage,
4030
+ creatorLpPercentage,
4031
+ partnerLockedLpPercentage,
4032
+ creatorLockedLpPercentage,
4033
+ creatorTradingFeePercentage,
4034
+ leftover,
4035
+ sqrtPrices,
4036
+ migrationFee,
4037
+ tokenUpdateAuthority,
4038
+ baseFeeParams,
4039
+ migratedPoolFee
4040
+ } = buildCurveWithCustomSqrtPricesParam;
4041
+ let { liquidityWeights } = buildCurveWithCustomSqrtPricesParam;
4042
+ if (sqrtPrices.length < 2) {
4043
+ throw new Error("sqrtPrices array must have at least 2 elements");
4044
+ }
4045
+ for (let i = 1; i < sqrtPrices.length; i++) {
4046
+ if (sqrtPrices[i].lte(sqrtPrices[i - 1])) {
4047
+ throw new Error("sqrtPrices must be in ascending order");
4048
+ }
4049
+ }
4050
+ if (!liquidityWeights) {
4051
+ const numSegments2 = sqrtPrices.length - 1;
4052
+ liquidityWeights = Array(numSegments2).fill(1);
4053
+ } else if (liquidityWeights.length !== sqrtPrices.length - 1) {
4054
+ throw new Error(
4055
+ "liquidityWeights length must equal sqrtPrices.length - 1"
4056
+ );
4057
+ }
4058
+ const baseFee = getBaseFeeParams(
4059
+ baseFeeParams,
4060
+ tokenQuoteDecimal,
4061
+ activationType
4062
+ );
4063
+ const {
4064
+ totalLockedVestingAmount,
4065
+ numberOfVestingPeriod,
4066
+ cliffUnlockAmount,
4067
+ totalVestingDuration,
4068
+ cliffDurationFromMigrationTime
4069
+ } = buildCurveWithCustomSqrtPricesParam.lockedVestingParam;
4070
+ const lockedVesting = getLockedVestingParams(
4071
+ totalLockedVestingAmount,
4072
+ numberOfVestingPeriod,
4073
+ cliffUnlockAmount,
4074
+ totalVestingDuration,
4075
+ cliffDurationFromMigrationTime,
4076
+ tokenBaseDecimal
4077
+ );
4078
+ const migratedPoolFeeParams = getMigratedPoolFeeParams(
4079
+ migrationOption,
4080
+ migrationFeeOption,
4081
+ migratedPoolFee
4082
+ );
4083
+ const pMin = sqrtPrices[0];
4084
+ const pMax = sqrtPrices[sqrtPrices.length - 1];
4085
+ const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
4086
+ const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
4087
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
4088
+ const totalSwapAndMigrationAmount = totalSupply.sub(totalVestingAmount).sub(totalLeftover);
4089
+ let sumFactor = new (0, _decimaljs2.default)(0);
4090
+ const pmaxWeight = new (0, _decimaljs2.default)(pMax.toString());
4091
+ const migrationFeeFactor = new (0, _decimaljs2.default)(100).sub(new (0, _decimaljs2.default)(migrationFee.feePercentage)).div(new (0, _decimaljs2.default)(100));
4092
+ const numSegments = sqrtPrices.length - 1;
4093
+ for (let i = 0; i < numSegments; i++) {
4094
+ const pi = new (0, _decimaljs2.default)(sqrtPrices[i + 1].toString());
4095
+ const piMinus = new (0, _decimaljs2.default)(sqrtPrices[i].toString());
4096
+ const k = new (0, _decimaljs2.default)(liquidityWeights[i]);
4097
+ const w1 = pi.sub(piMinus).div(pi.mul(piMinus));
4098
+ const w2 = pi.sub(piMinus).mul(migrationFeeFactor).div(pmaxWeight.mul(pmaxWeight));
4099
+ const weight = k.mul(w1.add(w2));
4100
+ sumFactor = sumFactor.add(weight);
4101
+ }
4102
+ const l1 = new (0, _decimaljs2.default)(totalSwapAndMigrationAmount.toString()).div(
4103
+ sumFactor
4104
+ );
4105
+ const curve = [];
4106
+ for (let i = 0; i < numSegments; i++) {
4107
+ const k = new (0, _decimaljs2.default)(liquidityWeights[i]);
4108
+ const liquidity = convertDecimalToBN(l1.mul(k));
4109
+ const sqrtPrice = sqrtPrices[i + 1];
3911
4110
  curve.push({
3912
4111
  sqrtPrice,
3913
4112
  liquidity
3914
4113
  });
3915
4114
  }
3916
- let swapBaseAmount = getBaseTokenForSwap(pMin, pMax, curve);
3917
- let swapBaseAmountBuffer = getSwapAmountWithBuffer(
4115
+ const swapBaseAmount = getBaseTokenForSwap(pMin, pMax, curve);
4116
+ const swapBaseAmountBuffer = getSwapAmountWithBuffer(
3918
4117
  swapBaseAmount,
3919
4118
  pMin,
3920
4119
  curve
3921
4120
  );
3922
- let migrationAmount = totalSwapAndMigrationAmount.sub(swapBaseAmountBuffer);
3923
- let migrationQuoteAmount = migrationAmount.mul(pMax).mul(pMax).shrn(128);
3924
- let migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
4121
+ const migrationAmount = totalSwapAndMigrationAmount.sub(swapBaseAmountBuffer);
4122
+ const migrationQuoteAmount = migrationAmount.mul(pMax).mul(pMax).shrn(128);
4123
+ const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3925
4124
  new (0, _decimaljs2.default)(migrationQuoteAmount.toString()),
3926
4125
  new (0, _decimaljs2.default)(migrationFee.feePercentage)
3927
4126
  );
3928
- let migrationQuoteThresholdInLamport = fromDecimalToBN(
4127
+ const migrationQuoteThresholdInLamport = fromDecimalToBN(
3929
4128
  migrationQuoteThreshold
3930
4129
  );
3931
- let totalDynamicSupply = getTotalSupplyFromCurve(
4130
+ const totalDynamicSupply = getTotalSupplyFromCurve(
3932
4131
  migrationQuoteThresholdInLamport,
3933
4132
  pMin,
3934
4133
  curve,
@@ -3938,7 +4137,7 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3938
4137
  migrationFee.feePercentage
3939
4138
  );
3940
4139
  if (totalDynamicSupply.gt(totalSupply)) {
3941
- let leftOverDelta = totalDynamicSupply.sub(totalSupply);
4140
+ const leftOverDelta = totalDynamicSupply.sub(totalSupply);
3942
4141
  if (!leftOverDelta.lt(totalLeftover)) {
3943
4142
  throw new Error("leftOverDelta must be less than totalLeftover");
3944
4143
  }
@@ -26723,5 +26922,8 @@ var DynamicBondingCurveClient = class _DynamicBondingCurveClient {
26723
26922
 
26724
26923
 
26725
26924
 
26726
- exports.ActivationType = ActivationType; exports.BASE_ADDRESS = BASE_ADDRESS; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; 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.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.DammV2DynamicFeeMode = DammV2DynamicFeeMode; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveIdl = idl_default; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeScheduler = FeeScheduler; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_CREATOR_MIGRATION_FEE_PERCENTAGE = MAX_CREATOR_MIGRATION_FEE_PERCENTAGE; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_DYNAMIC_FEE_PERCENTAGE = MAX_DYNAMIC_FEE_PERCENTAGE; exports.MAX_FEE_BPS = MAX_FEE_BPS; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_MIGRATED_POOL_FEE_BPS = MAX_MIGRATED_POOL_FEE_BPS; exports.MAX_MIGRATION_FEE_PERCENTAGE = MAX_MIGRATION_FEE_PERCENTAGE; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_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_MIGRATED_POOL_FEE_BPS = MIN_MIGRATED_POOL_FEE_BPS; 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.PARTNER_SURPLUS_SHARE = PARTNER_SURPLUS_SHARE; exports.PartnerService = PartnerService; exports.PoolService = PoolService; exports.RESOLUTION = RESOLUTION; exports.Rounding = Rounding; exports.SLOT_DURATION = SLOT_DURATION; exports.SWAP_BUFFER_PERCENTAGE = SWAP_BUFFER_PERCENTAGE; exports.SafeMath = SafeMath; exports.StateService = StateService; exports.SwapMode = SwapMode; exports.TIMESTAMP_DURATION = TIMESTAMP_DURATION; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TokenUpdateAuthorityOption = TokenUpdateAuthorityOption; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_MAX; exports.U64_MAX = U64_MAX; exports.VAULT_PROGRAM_ID = VAULT_PROGRAM_ID; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.buildCurve = buildCurve; exports.buildCurveWithLiquidityWeights = buildCurveWithLiquidityWeights; exports.buildCurveWithMarketCap = buildCurveWithMarketCap; exports.buildCurveWithMidPrice = buildCurveWithMidPrice; exports.buildCurveWithTwoSegments = buildCurveWithTwoSegments; exports.calculateBaseToQuoteFromAmountIn = calculateBaseToQuoteFromAmountIn; exports.calculateBaseToQuoteFromAmountOut = calculateBaseToQuoteFromAmountOut; exports.calculateFeeSchedulerEndingBaseFeeBps = calculateFeeSchedulerEndingBaseFeeBps; 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.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.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.getFeeSchedulerParams = getFeeSchedulerParams; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getLiquidity = getLiquidity; exports.getLockedVestingParams = getLockedVestingParams; exports.getMaxBaseFeeNumerator = getMaxBaseFeeNumerator; exports.getMaxIndex = getMaxIndex; exports.getMaxOutAmountWithMinBaseFee = getMaxOutAmountWithMinBaseFee; exports.getMigratedPoolFeeParams = getMigratedPoolFeeParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteAmount = getMigrationQuoteAmount; exports.getMigrationQuoteAmountFromMigrationQuoteThreshold = getMigrationQuoteAmountFromMigrationQuoteThreshold; exports.getMigrationQuoteThresholdFromMigrationQuoteAmount = getMigrationQuoteThresholdFromMigrationQuoteAmount; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getMinBaseFeeNumerator = getMinBaseFeeNumerator; 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.getQuoteReserveFromNextSqrtPrice = getQuoteReserveFromNextSqrtPrice; exports.getRateLimiterExcludedFeeAmount = getRateLimiterExcludedFeeAmount; exports.getRateLimiterParams = getRateLimiterParams; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; 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.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.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeScheduler = validateFeeScheduler; exports.validateLPPercentages = validateLPPercentages; exports.validateMigratedPoolFee = validateMigratedPoolFee; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFee = validateMigrationFee; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.validateTokenUpdateAuthorityOptions = validateTokenUpdateAuthorityOptions; exports.wrapSOLInstruction = wrapSOLInstruction;
26925
+
26926
+
26927
+
26928
+ exports.ActivationType = ActivationType; exports.BASE_ADDRESS = BASE_ADDRESS; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; 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.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.DammV2DynamicFeeMode = DammV2DynamicFeeMode; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveIdl = idl_default; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeScheduler = FeeScheduler; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_CREATOR_MIGRATION_FEE_PERCENTAGE = MAX_CREATOR_MIGRATION_FEE_PERCENTAGE; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_DYNAMIC_FEE_PERCENTAGE = MAX_DYNAMIC_FEE_PERCENTAGE; exports.MAX_FEE_BPS = MAX_FEE_BPS; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_MIGRATED_POOL_FEE_BPS = MAX_MIGRATED_POOL_FEE_BPS; exports.MAX_MIGRATION_FEE_PERCENTAGE = MAX_MIGRATION_FEE_PERCENTAGE; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_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_MIGRATED_POOL_FEE_BPS = MIN_MIGRATED_POOL_FEE_BPS; 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.PARTNER_SURPLUS_SHARE = PARTNER_SURPLUS_SHARE; exports.PartnerService = PartnerService; exports.PoolService = PoolService; exports.RESOLUTION = RESOLUTION; exports.Rounding = Rounding; exports.SLOT_DURATION = SLOT_DURATION; exports.SWAP_BUFFER_PERCENTAGE = SWAP_BUFFER_PERCENTAGE; exports.SafeMath = SafeMath; exports.StateService = StateService; exports.SwapMode = SwapMode; exports.TIMESTAMP_DURATION = TIMESTAMP_DURATION; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TokenUpdateAuthorityOption = TokenUpdateAuthorityOption; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_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.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.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.getFeeSchedulerParams = getFeeSchedulerParams; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getLiquidity = getLiquidity; exports.getLockedVestingParams = getLockedVestingParams; exports.getMaxBaseFeeNumerator = getMaxBaseFeeNumerator; exports.getMaxIndex = getMaxIndex; exports.getMaxOutAmountWithMinBaseFee = getMaxOutAmountWithMinBaseFee; exports.getMigratedPoolFeeParams = getMigratedPoolFeeParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteAmount = getMigrationQuoteAmount; exports.getMigrationQuoteAmountFromMigrationQuoteThreshold = getMigrationQuoteAmountFromMigrationQuoteThreshold; exports.getMigrationQuoteThresholdFromMigrationQuoteAmount = getMigrationQuoteThresholdFromMigrationQuoteAmount; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getMinBaseFeeNumerator = getMinBaseFeeNumerator; 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.getQuoteReserveFromNextSqrtPrice = getQuoteReserveFromNextSqrtPrice; exports.getRateLimiterExcludedFeeAmount = getRateLimiterExcludedFeeAmount; exports.getRateLimiterParams = getRateLimiterParams; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; 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.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.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeScheduler = validateFeeScheduler; exports.validateLPPercentages = validateLPPercentages; exports.validateMigratedPoolFee = validateMigratedPoolFee; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFee = validateMigrationFee; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.validateTokenUpdateAuthorityOptions = validateTokenUpdateAuthorityOptions; exports.wrapSOLInstruction = wrapSOLInstruction;
26727
26929
  //# sourceMappingURL=index.cjs.map