impermax-sdk 2.1.561 → 2.1.562
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.
|
@@ -55,9 +55,16 @@ function formatPriceSqrtX96(priceSqrtX96, priceAdjustment) {
|
|
|
55
55
|
}
|
|
56
56
|
exports.formatPriceSqrtX96 = formatPriceSqrtX96;
|
|
57
57
|
function formatPriceToSqrtX96(price, priceAdjustment) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
let adjustedPriceSqrt = Math.sqrt(price / priceAdjustment);
|
|
59
|
+
let n = 96;
|
|
60
|
+
while (adjustedPriceSqrt < 1e8 && n > 0) {
|
|
61
|
+
adjustedPriceSqrt *= 2;
|
|
62
|
+
n--;
|
|
63
|
+
}
|
|
64
|
+
console.log(adjustedPriceSqrt);
|
|
65
|
+
const priceSqrt = ethers_1.BigNumber.from(Math.round(adjustedPriceSqrt));
|
|
66
|
+
const _2_n = ethers_1.BigNumber.from(2).pow(n);
|
|
67
|
+
return priceSqrt.mul(_2_n);
|
|
61
68
|
}
|
|
62
69
|
exports.formatPriceToSqrtX96 = formatPriceToSqrtX96;
|
|
63
70
|
function formatCLLiquidity(liquidityMantissa, decimalsA, decimalsB) {
|