@meteora-ag/cp-amm-sdk 1.0.1-rc.10 → 1.0.1-rc.12

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
@@ -1,3 +1,4 @@
1
+ var __pow = Math.pow;
1
2
  var __async = (__this, __arguments, generator) => {
2
3
  return new Promise((resolve, reject) => {
3
4
  var fulfilled = (value) => {
@@ -6730,6 +6731,17 @@ function getLiquidityDeltaFromAmountB(maxAmountB, lowerSqrtPrice, upperSqrtPrice
6730
6731
  const result = maxAmountB.shln(SCALE_OFFSET * 2).div(denominator);
6731
6732
  return result;
6732
6733
  }
6734
+ function getAmountAFromLiquidityDelta(liquidity, currentSqrtPrice) {
6735
+ const prod = liquidity.mul(MAX_SQRT_PRICE.sub(currentSqrtPrice));
6736
+ const denominator = currentSqrtPrice.mul(MAX_SQRT_PRICE);
6737
+ const result = shlDiv(prod, denominator, SCALE_OFFSET, 1 /* Down */);
6738
+ return result.shrn(SCALE_OFFSET);
6739
+ }
6740
+ function getAmountBFromLiquidityDelta(liquidity, currentSqrtPrice) {
6741
+ const delta = currentSqrtPrice.sub(MIN_SQRT_PRICE);
6742
+ const prod = liquidity.mul(delta);
6743
+ return prod.shrn(SCALE_OFFSET * 2);
6744
+ }
6733
6745
 
6734
6746
  // src/utils/computeUnits.ts
6735
6747
  import {
@@ -6809,6 +6821,10 @@ var getEstimatedComputeUnitIxWithBuffer = (connection, instructions, feePayer, b
6809
6821
  // src/utils/utils.ts
6810
6822
  import { BN as BN6 } from "@coral-xyz/anchor";
6811
6823
  import Decimal2 from "decimal.js";
6824
+ var getMaxAmountWithSlippage = (amount, slippageRate) => {
6825
+ const slippage = (100 + slippageRate) / 100 * BASIS_POINT_MAX;
6826
+ return amount.mul(new BN6(slippage)).div(new BN6(BASIS_POINT_MAX));
6827
+ };
6812
6828
  var getMinAmountWithSlippage = (amount, slippageRate) => {
6813
6829
  const slippage = (100 - slippageRate) / 100 * BASIS_POINT_MAX;
6814
6830
  return amount.mul(new BN6(slippage)).div(new BN6(BASIS_POINT_MAX));
@@ -6817,6 +6833,19 @@ var getPriceImpact = (amount, amountWithoutSlippage) => {
6817
6833
  const diff = amountWithoutSlippage.sub(amount);
6818
6834
  return new Decimal2(diff.toString()).div(new Decimal2(amountWithoutSlippage.toString())).mul(100).toNumber();
6819
6835
  };
6836
+ var getCurrentPrice = (sqrtPrice, tokenADecimal, tokenBDecimal) => {
6837
+ const rawSqrtPrice = sqrtPrice.shrn(SCALE_OFFSET);
6838
+ const price = rawSqrtPrice.mul(rawSqrtPrice);
6839
+ const expo = __pow(10, tokenADecimal - tokenBDecimal);
6840
+ return price.muln(expo);
6841
+ };
6842
+ var getUnClaimReward = (positionState) => {
6843
+ return {
6844
+ feeTokenA: positionState.feeAPending,
6845
+ feeTokenB: positionState.feeBPending,
6846
+ rewards: positionState.rewardInfos.length > 0 ? positionState.rewardInfos.map((item) => item.rewardPendings) : []
6847
+ };
6848
+ };
6820
6849
 
6821
6850
  // src/utils/accountFilters.ts
6822
6851
  var positionByPoolFilter = (pool) => {
@@ -7957,7 +7986,10 @@ export {
7957
7986
  deriveRewardVaultAddress,
7958
7987
  deriveTokenBadgeAddress,
7959
7988
  deriveTokenVaultAddress,
7989
+ getAmountAFromLiquidityDelta,
7990
+ getAmountBFromLiquidityDelta,
7960
7991
  getBaseFeeNumerator,
7992
+ getCurrentPrice,
7961
7993
  getDeltaAmountA,
7962
7994
  getDeltaAmountB,
7963
7995
  getDynamicFeeNumerator,
@@ -7967,13 +7999,17 @@ export {
7967
7999
  getFirstKey,
7968
8000
  getLiquidityDeltaFromAmountA,
7969
8001
  getLiquidityDeltaFromAmountB,
8002
+ getMaxAmountWithSlippage,
8003
+ getMinAmountWithSlippage,
7970
8004
  getNextSqrtPrice,
7971
8005
  getNftOwner,
7972
8006
  getOrCreateATAInstruction,
8007
+ getPriceImpact,
7973
8008
  getSecondKey,
7974
8009
  getSimulationComputeUnits,
7975
8010
  getTokenDecimals,
7976
8011
  getTokenProgram,
8012
+ getUnClaimReward,
7977
8013
  unwrapSOLInstruction,
7978
8014
  wrapSOLInstruction
7979
8015
  };