@meteora-ag/cp-amm-sdk 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -8664,11 +8664,11 @@ import BN8 from "bn.js";
8664
8664
  function getMaxBaseFeeNumerator(cliffFeeNumerator) {
8665
8665
  return cliffFeeNumerator;
8666
8666
  }
8667
- function getMinBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, feeSchedulerMode) {
8667
+ function getMinBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, reductionFactor, feeSchedulerMode) {
8668
8668
  return getBaseFeeNumeratorByPeriod(
8669
8669
  cliffFeeNumerator,
8670
8670
  numberOfPeriod,
8671
- periodFrequency,
8671
+ new BN8(numberOfPeriod),
8672
8672
  reductionFactor,
8673
8673
  feeSchedulerMode
8674
8674
  );
@@ -8718,7 +8718,15 @@ function getBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, periodFrequency,
8718
8718
  if (periodFrequency.isZero()) {
8719
8719
  return cliffFeeNumerator;
8720
8720
  }
8721
- const period = currentPoint.sub(activationPoint).div(periodFrequency);
8721
+ let period;
8722
+ if (currentPoint.lt(activationPoint)) {
8723
+ period = new BN8(numberOfPeriod);
8724
+ } else {
8725
+ period = currentPoint.sub(activationPoint).div(periodFrequency);
8726
+ if (period.gt(new BN8(numberOfPeriod))) {
8727
+ period = new BN8(numberOfPeriod);
8728
+ }
8729
+ }
8722
8730
  return getBaseFeeNumeratorByPeriod(
8723
8731
  cliffFeeNumerator,
8724
8732
  numberOfPeriod,
@@ -9626,7 +9634,6 @@ function validateFeeScheduler(numberOfPeriod, periodFrequency, reductionFactor,
9626
9634
  const minFeeNumerator = getMinBaseFeeNumerator(
9627
9635
  cliffFeeNumerator,
9628
9636
  numberOfPeriod,
9629
- periodFrequency,
9630
9637
  reductionFactor,
9631
9638
  baseFeeMode
9632
9639
  );
@@ -11616,7 +11623,8 @@ var CpAmm = class {
11616
11623
  const closeWrappedSOLIx = yield unwrapSOLInstruction(payer);
11617
11624
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
11618
11625
  }
11619
- const poolState = yield this.fetchPoolState(pool);
11626
+ let { poolState } = params;
11627
+ poolState = poolState != null ? poolState : yield this.fetchPoolState(pool);
11620
11628
  const currentPoint = yield getCurrentPoint(
11621
11629
  this._program.provider.connection,
11622
11630
  poolState.activationType
@@ -11717,7 +11725,8 @@ var CpAmm = class {
11717
11725
  const closeWrappedSOLIx = yield unwrapSOLInstruction(payer);
11718
11726
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
11719
11727
  }
11720
- const poolState = yield this.fetchPoolState(pool);
11728
+ let { poolState } = params;
11729
+ poolState = poolState != null ? poolState : yield this.fetchPoolState(pool);
11721
11730
  const currentPoint = yield getCurrentPoint(
11722
11731
  this._program.provider.connection,
11723
11732
  poolState.activationType