@meteora-ag/cp-amm-sdk 1.0.0-rc.7 → 1.0.0-rc.8

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
@@ -6886,57 +6886,6 @@ function getSwapAmount(inAmount, sqrtPrice, liquidity, tradeFeeNumerator, aToB,
6886
6886
  const amountOut = feeMode.feeOnInput ? outAmount : (totalFee = getTotalFeeOnAmount(outAmount, tradeFeeNumerator), outAmount.sub(totalFee));
6887
6887
  return { amountOut, totalFee };
6888
6888
  }
6889
- function bpsToFeeNumerator(bps) {
6890
- return bps * FEE_DENOMINATOR / BASIS_POINT_MAX;
6891
- }
6892
- function feeNumeratorToBps(feeNumerator) {
6893
- return feeNumerator * BASIS_POINT_MAX / FEE_DENOMINATOR;
6894
- }
6895
- function estimateLinearReductionFactor(cliffFeeBps, targetFeeBps, totalPeriods) {
6896
- if (totalPeriods <= 0) {
6897
- throw new Error("Total periods must be greater than zero");
6898
- }
6899
- if (cliffFeeBps > feeNumeratorToBps(MAX_FEE_NUMERATOR)) {
6900
- throw new Error(
6901
- `Cliff fee (${cliffFeeBps} bps) exceeds maximum allowed value of ${feeNumeratorToBps(
6902
- MAX_FEE_NUMERATOR
6903
- )} bps`
6904
- );
6905
- }
6906
- if (targetFeeBps > cliffFeeBps) {
6907
- throw new Error(
6908
- "Target fee must be less than or equal to cliff fee for reduction"
6909
- );
6910
- }
6911
- const cliffFeeNumerator = bpsToFeeNumerator(cliffFeeBps);
6912
- const targetFeeNumerator = bpsToFeeNumerator(targetFeeBps);
6913
- const totalReduction = cliffFeeNumerator - targetFeeNumerator;
6914
- const reductionFactor = totalReduction / totalPeriods;
6915
- return Math.floor(reductionFactor);
6916
- }
6917
- function estimateExponentialReductionFactor(cliffFeeBps, targetFeeBps, totalPeriods) {
6918
- if (totalPeriods <= 0) {
6919
- throw new Error("Total periods must be greater than zero");
6920
- }
6921
- if (cliffFeeBps > feeNumeratorToBps(MAX_FEE_NUMERATOR)) {
6922
- throw new Error(
6923
- `Cliff fee (${cliffFeeBps} bps) exceeds maximum allowed value of ${feeNumeratorToBps(
6924
- MAX_FEE_NUMERATOR
6925
- )} bps`
6926
- );
6927
- }
6928
- if (targetFeeBps > cliffFeeBps) {
6929
- throw new Error(
6930
- "Target fee bps must be less than or equal to cliff fee bps for reduction"
6931
- );
6932
- }
6933
- const cliffFeeNumerator = bpsToFeeNumerator(cliffFeeBps);
6934
- const targetFeeNumerator = bpsToFeeNumerator(targetFeeBps);
6935
- const ratio = targetFeeNumerator / cliffFeeNumerator;
6936
- const decayBase = Math.pow(ratio, 1 / totalPeriods);
6937
- const reductionFactor = BASIS_POINT_MAX * (1 - decayBase);
6938
- return Math.floor(reductionFactor);
6939
- }
6940
6889
 
6941
6890
  // src/helpers/computeUnits.ts
6942
6891
  import {
@@ -7236,6 +7185,13 @@ var CpAmm = class {
7236
7185
  });
7237
7186
  this.poolAuthority = derivePoolAuthority();
7238
7187
  }
7188
+ /**
7189
+ * Returns the Anchor program instance.
7190
+ * @returns The AmmProgram instance.
7191
+ */
7192
+ getProgram() {
7193
+ return this._program;
7194
+ }
7239
7195
  /**
7240
7196
  * Prepares token accounts for a transaction by retrieving or creating associated token accounts.
7241
7197
  * @private
@@ -8950,13 +8906,6 @@ var CpAmm = class {
8950
8906
  tokenAProgram,
8951
8907
  tokenBProgram
8952
8908
  );
8953
- const postInstructions = [];
8954
- if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
8955
- NATIVE_MINT2.toBase58()
8956
- )) {
8957
- const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
8958
- closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
8959
- }
8960
8909
  let positionBLiquidityDelta = positionBState.unlockedLiquidity;
8961
8910
  if (positionBVestings.length > 0) {
8962
8911
  const totalAvailableVestingLiquidity = positionBVestings.reduce(
@@ -8982,6 +8931,14 @@ var CpAmm = class {
8982
8931
  refreshVestingInstruction && preInstructions.push(refreshVestingInstruction);
8983
8932
  }
8984
8933
  const transaction = new Transaction();
8934
+ if (poolState.tokenAMint.equals(NATIVE_MINT2)) {
8935
+ const wrapSOLIx = wrapSOLInstruction(owner, tokenAAccount, BigInt(1));
8936
+ preInstructions.push(...wrapSOLIx);
8937
+ }
8938
+ if (poolState.tokenBMint.equals(NATIVE_MINT2)) {
8939
+ const wrapSOLIx = wrapSOLInstruction(owner, tokenBAccount, BigInt(1));
8940
+ preInstructions.push(...wrapSOLIx);
8941
+ }
8985
8942
  if (preInstructions.length > 0) {
8986
8943
  transaction.add(...preInstructions);
8987
8944
  }
@@ -9015,8 +8972,11 @@ var CpAmm = class {
9015
8972
  tokenBAmountThreshold: tokenBAmountAddLiquidityThreshold
9016
8973
  });
9017
8974
  transaction.add(addLiquidityInstruction);
9018
- if (postInstructions.length > 0) {
9019
- transaction.add(...postInstructions);
8975
+ if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
8976
+ NATIVE_MINT2.toBase58()
8977
+ )) {
8978
+ const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
8979
+ closeWrappedSOLIx && transaction.add(closeWrappedSOLIx);
9020
8980
  }
9021
8981
  return transaction;
9022
8982
  });
@@ -9248,7 +9208,6 @@ export {
9248
9208
  Rounding,
9249
9209
  SCALE_OFFSET,
9250
9210
  TradeDirection,
9251
- bpsToFeeNumerator,
9252
9211
  calculateInitSqrtPrice,
9253
9212
  calculateTransferFeeExcludedAmount,
9254
9213
  calculateTransferFeeIncludedAmount,
@@ -9264,9 +9223,6 @@ export {
9264
9223
  deriveRewardVaultAddress,
9265
9224
  deriveTokenBadgeAddress,
9266
9225
  deriveTokenVaultAddress,
9267
- estimateExponentialReductionFactor,
9268
- estimateLinearReductionFactor,
9269
- feeNumeratorToBps,
9270
9226
  getAllPositionNftAccountByOwner,
9271
9227
  getAllUserPositionNftAccount,
9272
9228
  getAmountAFromLiquidityDelta,