@meteora-ag/cp-amm-sdk 1.0.3 → 1.0.4-rc.0

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.d.mts CHANGED
@@ -5692,8 +5692,6 @@ type CreatePositionAndAddLiquidity = {
5692
5692
  tokenBAmountThreshold: BN;
5693
5693
  tokenAMint: PublicKey;
5694
5694
  tokenBMint: PublicKey;
5695
- tokenAVault: PublicKey;
5696
- tokenBVault: PublicKey;
5697
5695
  tokenAProgram: PublicKey;
5698
5696
  tokenBProgram: PublicKey;
5699
5697
  };
package/dist/index.d.ts CHANGED
@@ -5692,8 +5692,6 @@ type CreatePositionAndAddLiquidity = {
5692
5692
  tokenBAmountThreshold: BN;
5693
5693
  tokenAMint: PublicKey;
5694
5694
  tokenBMint: PublicKey;
5695
- tokenAVault: PublicKey;
5696
- tokenBVault: PublicKey;
5697
5695
  tokenAProgram: PublicKey;
5698
5696
  tokenBProgram: PublicKey;
5699
5697
  };
package/dist/index.js CHANGED
@@ -6978,10 +6978,10 @@ var _bytes = require('@coral-xyz/anchor/dist/cjs/utils/bytes');
6978
6978
  function getTokenProgram(flag) {
6979
6979
  return flag == 0 ? _spltoken.TOKEN_PROGRAM_ID : _spltoken.TOKEN_2022_PROGRAM_ID;
6980
6980
  }
6981
- var getTokenDecimals = (connection, mint) => __async(void 0, null, function* () {
6981
+ var getTokenDecimals = (connection, mint) => __async(null, null, function* () {
6982
6982
  return (yield _spltoken.getMint.call(void 0, connection, mint)).decimals;
6983
6983
  });
6984
- var getOrCreateATAInstruction = (_0, _1, _2, ..._3) => __async(void 0, [_0, _1, _2, ..._3], function* (connection, tokenMint, owner, payer = owner, allowOwnerOffCurve = true, tokenProgram) {
6984
+ var getOrCreateATAInstruction = (_0, _1, _2, ..._3) => __async(null, [_0, _1, _2, ..._3], function* (connection, tokenMint, owner, payer = owner, allowOwnerOffCurve = true, tokenProgram) {
6985
6985
  const toAccount = _spltoken.getAssociatedTokenAddressSync.call(void 0,
6986
6986
  tokenMint,
6987
6987
  owner,
@@ -7027,7 +7027,7 @@ var wrapSOLInstruction = (from, to, amount) => {
7027
7027
  })
7028
7028
  ];
7029
7029
  };
7030
- var unwrapSOLInstruction = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (owner, receiver = owner, allowOwnerOffCurve = true) {
7030
+ var unwrapSOLInstruction = (_0, ..._1) => __async(null, [_0, ..._1], function* (owner, receiver = owner, allowOwnerOffCurve = true) {
7031
7031
  const wSolATAAccount = _spltoken.getAssociatedTokenAddressSync.call(void 0,
7032
7032
  _spltoken.NATIVE_MINT,
7033
7033
  owner,
@@ -7288,10 +7288,10 @@ function getDynamicFeeNumerator(volatilityAccumulator, binStep, variableFeeContr
7288
7288
  return vFee.add(new (0, _anchor.BN)(99999999999)).div(new (0, _anchor.BN)(1e11));
7289
7289
  }
7290
7290
  function getFeeNumerator(currentPoint, activationPoint, numberOfPeriod, periodFrequency, feeSchedulerMode, cliffFeeNumerator, reductionFactor, dynamicFeeParams) {
7291
- if (Number(periodFrequency) == 0) {
7291
+ if (Number(periodFrequency) == 0 || new (0, _anchor.BN)(currentPoint).lt(activationPoint)) {
7292
7292
  return cliffFeeNumerator;
7293
7293
  }
7294
- const period = new (0, _anchor.BN)(currentPoint).lt(activationPoint) ? new (0, _anchor.BN)(numberOfPeriod) : _anchor.BN.min(
7294
+ const period = _anchor.BN.min(
7295
7295
  new (0, _anchor.BN)(numberOfPeriod),
7296
7296
  new (0, _anchor.BN)(currentPoint).sub(activationPoint).div(periodFrequency)
7297
7297
  );
@@ -7444,7 +7444,7 @@ function getDynamicFeeParams(baseFeeBps, maxPriceChangeBps = MAX_PRICE_CHANGE_BP
7444
7444
 
7445
7445
 
7446
7446
 
7447
- var getSimulationComputeUnits = (connection, instructions, payer, lookupTables, commitment = "confirmed") => __async(void 0, null, function* () {
7447
+ var getSimulationComputeUnits = (connection, instructions, payer, lookupTables, commitment = "confirmed") => __async(null, null, function* () {
7448
7448
  var _a, _b, _c;
7449
7449
  const testInstructions = [
7450
7450
  // Set an arbitrarily high number in simulation
@@ -7476,7 +7476,7 @@ var getSimulationComputeUnits = (connection, instructions, payer, lookupTables,
7476
7476
  }
7477
7477
  return rpcResponse.value.unitsConsumed || null;
7478
7478
  });
7479
- var getEstimatedComputeUnitUsageWithBuffer = (connection, instructions, feePayer, buffer) => __async(void 0, null, function* () {
7479
+ var getEstimatedComputeUnitUsageWithBuffer = (connection, instructions, feePayer, buffer) => __async(null, null, function* () {
7480
7480
  if (!buffer) {
7481
7481
  buffer = 0.1;
7482
7482
  }
@@ -7499,7 +7499,7 @@ var getEstimatedComputeUnitUsageWithBuffer = (connection, instructions, feePayer
7499
7499
  }
7500
7500
  return estimatedComputeUnitUsage + extraComputeUnitBuffer;
7501
7501
  });
7502
- var getEstimatedComputeUnitIxWithBuffer = (connection, instructions, feePayer, buffer) => __async(void 0, null, function* () {
7502
+ var getEstimatedComputeUnitIxWithBuffer = (connection, instructions, feePayer, buffer) => __async(null, null, function* () {
7503
7503
  const units = yield getEstimatedComputeUnitUsageWithBuffer(
7504
7504
  connection,
7505
7505
  instructions,
@@ -9090,8 +9090,6 @@ var CpAmm = class {
9090
9090
  tokenBAmountThreshold,
9091
9091
  tokenAMint,
9092
9092
  tokenBMint,
9093
- tokenAVault,
9094
- tokenBVault,
9095
9093
  tokenAProgram,
9096
9094
  tokenBProgram
9097
9095
  } = params;
@@ -9108,6 +9106,8 @@ var CpAmm = class {
9108
9106
  tokenAProgram,
9109
9107
  tokenBProgram
9110
9108
  });
9109
+ const tokenAVault = deriveTokenVaultAddress(tokenAMint, pool);
9110
+ const tokenBVault = deriveTokenVaultAddress(tokenBMint, pool);
9111
9111
  if (tokenAMint.equals(_spltoken.NATIVE_MINT)) {
9112
9112
  const wrapSOLIx = wrapSOLInstruction(
9113
9113
  owner,