@meteora-ag/cp-amm-sdk 1.0.1-rc.14 → 1.0.1-rc.15
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 +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6526,6 +6526,10 @@ function pow(base, exp) {
|
|
|
6526
6526
|
// src/math/index.ts
|
|
6527
6527
|
import { BN as BN3 } from "@coral-xyz/anchor";
|
|
6528
6528
|
import Decimal from "decimal.js";
|
|
6529
|
+
function mulShr(x, y, offset, rounding) {
|
|
6530
|
+
const denominator = new BN3(1).shln(offset);
|
|
6531
|
+
return mulDiv(x, y, denominator, rounding);
|
|
6532
|
+
}
|
|
6529
6533
|
function shlDiv(x, y, offset, rounding) {
|
|
6530
6534
|
const scale = new BN3(1).shln(offset);
|
|
6531
6535
|
return mulDiv(x, scale, y, rounding);
|
|
@@ -6543,6 +6547,12 @@ function divCeil(a, b) {
|
|
|
6543
6547
|
}
|
|
6544
6548
|
return a.add(b.sub(new BN3(1))).div(b);
|
|
6545
6549
|
}
|
|
6550
|
+
function q64ToDecimal(num, decimalPlaces) {
|
|
6551
|
+
return new Decimal(num.toString()).div(Decimal.pow(2, 64)).toDecimalPlaces(decimalPlaces);
|
|
6552
|
+
}
|
|
6553
|
+
function decimalToQ64(num) {
|
|
6554
|
+
return new BN3(num.mul(Decimal.pow(2, 64)).floor().toFixed());
|
|
6555
|
+
}
|
|
6546
6556
|
function getInitPriceQ64(tokenAAmount, tokenBAmount) {
|
|
6547
6557
|
const sqrtInitPrice = new Decimal(tokenBAmount.toString()).div(new Decimal(tokenAAmount.toString())).sqrt();
|
|
6548
6558
|
return new BN3(sqrtInitPrice.mul(Decimal.pow(2, 64)).floor().toFixed());
|
|
@@ -8031,6 +8041,7 @@ export {
|
|
|
8031
8041
|
Rounding,
|
|
8032
8042
|
SCALE_OFFSET,
|
|
8033
8043
|
TradeDirection,
|
|
8044
|
+
decimalToQ64,
|
|
8034
8045
|
index_default as default,
|
|
8035
8046
|
deriveClaimFeeOperatorAddress,
|
|
8036
8047
|
deriveConfigAddress,
|
|
@@ -8043,6 +8054,7 @@ export {
|
|
|
8043
8054
|
deriveRewardVaultAddress,
|
|
8044
8055
|
deriveTokenBadgeAddress,
|
|
8045
8056
|
deriveTokenVaultAddress,
|
|
8057
|
+
divCeil,
|
|
8046
8058
|
getAmountAFromLiquidityDelta,
|
|
8047
8059
|
getAmountBFromLiquidityDelta,
|
|
8048
8060
|
getBaseFeeNumerator,
|
|
@@ -8054,6 +8066,7 @@ export {
|
|
|
8054
8066
|
getEstimatedComputeUnitUsageWithBuffer,
|
|
8055
8067
|
getFeeNumerator,
|
|
8056
8068
|
getFirstKey,
|
|
8069
|
+
getInitPriceQ64,
|
|
8057
8070
|
getLiquidityDeltaFromAmountA,
|
|
8058
8071
|
getLiquidityDeltaFromAmountB,
|
|
8059
8072
|
getMaxAmountWithSlippage,
|
|
@@ -8068,7 +8081,11 @@ export {
|
|
|
8068
8081
|
getTokenDecimals,
|
|
8069
8082
|
getTokenProgram,
|
|
8070
8083
|
getUnClaimReward,
|
|
8084
|
+
mulDiv,
|
|
8085
|
+
mulShr,
|
|
8071
8086
|
positionByPoolFilter,
|
|
8087
|
+
q64ToDecimal,
|
|
8088
|
+
shlDiv,
|
|
8072
8089
|
unwrapSOLInstruction,
|
|
8073
8090
|
wrapSOLInstruction
|
|
8074
8091
|
};
|