@meteora-ag/cp-amm-sdk 1.0.1-rc.11 → 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.d.mts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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) => {
|
|
@@ -6820,6 +6821,10 @@ var getEstimatedComputeUnitIxWithBuffer = (connection, instructions, feePayer, b
|
|
|
6820
6821
|
// src/utils/utils.ts
|
|
6821
6822
|
import { BN as BN6 } from "@coral-xyz/anchor";
|
|
6822
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
|
+
};
|
|
6823
6828
|
var getMinAmountWithSlippage = (amount, slippageRate) => {
|
|
6824
6829
|
const slippage = (100 - slippageRate) / 100 * BASIS_POINT_MAX;
|
|
6825
6830
|
return amount.mul(new BN6(slippage)).div(new BN6(BASIS_POINT_MAX));
|
|
@@ -6828,6 +6833,19 @@ var getPriceImpact = (amount, amountWithoutSlippage) => {
|
|
|
6828
6833
|
const diff = amountWithoutSlippage.sub(amount);
|
|
6829
6834
|
return new Decimal2(diff.toString()).div(new Decimal2(amountWithoutSlippage.toString())).mul(100).toNumber();
|
|
6830
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
|
+
};
|
|
6831
6849
|
|
|
6832
6850
|
// src/utils/accountFilters.ts
|
|
6833
6851
|
var positionByPoolFilter = (pool) => {
|
|
@@ -7971,6 +7989,7 @@ export {
|
|
|
7971
7989
|
getAmountAFromLiquidityDelta,
|
|
7972
7990
|
getAmountBFromLiquidityDelta,
|
|
7973
7991
|
getBaseFeeNumerator,
|
|
7992
|
+
getCurrentPrice,
|
|
7974
7993
|
getDeltaAmountA,
|
|
7975
7994
|
getDeltaAmountB,
|
|
7976
7995
|
getDynamicFeeNumerator,
|
|
@@ -7980,13 +7999,17 @@ export {
|
|
|
7980
7999
|
getFirstKey,
|
|
7981
8000
|
getLiquidityDeltaFromAmountA,
|
|
7982
8001
|
getLiquidityDeltaFromAmountB,
|
|
8002
|
+
getMaxAmountWithSlippage,
|
|
8003
|
+
getMinAmountWithSlippage,
|
|
7983
8004
|
getNextSqrtPrice,
|
|
7984
8005
|
getNftOwner,
|
|
7985
8006
|
getOrCreateATAInstruction,
|
|
8007
|
+
getPriceImpact,
|
|
7986
8008
|
getSecondKey,
|
|
7987
8009
|
getSimulationComputeUnits,
|
|
7988
8010
|
getTokenDecimals,
|
|
7989
8011
|
getTokenProgram,
|
|
8012
|
+
getUnClaimReward,
|
|
7990
8013
|
unwrapSOLInstruction,
|
|
7991
8014
|
wrapSOLInstruction
|
|
7992
8015
|
};
|