@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.mjs CHANGED
@@ -6978,10 +6978,10 @@ import {
6978
6978
  function getTokenProgram(flag) {
6979
6979
  return flag == 0 ? TOKEN_PROGRAM_ID : 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 getMint(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 = getAssociatedTokenAddressSync(
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 = getAssociatedTokenAddressSync(
7032
7032
  NATIVE_MINT,
7033
7033
  owner,
@@ -7288,10 +7288,10 @@ function getDynamicFeeNumerator(volatilityAccumulator, binStep, variableFeeContr
7288
7288
  return vFee.add(new BN5(99999999999)).div(new BN5(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 BN5(currentPoint).lt(activationPoint)) {
7292
7292
  return cliffFeeNumerator;
7293
7293
  }
7294
- const period = new BN5(currentPoint).lt(activationPoint) ? new BN5(numberOfPeriod) : BN5.min(
7294
+ const period = BN5.min(
7295
7295
  new BN5(numberOfPeriod),
7296
7296
  new BN5(currentPoint).sub(activationPoint).div(periodFrequency)
7297
7297
  );
@@ -7444,7 +7444,7 @@ import {
7444
7444
  TransactionMessage,
7445
7445
  VersionedTransaction
7446
7446
  } from "@solana/web3.js";
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(NATIVE_MINT2)) {
9112
9112
  const wrapSOLIx = wrapSOLInstruction(
9113
9113
  owner,