@magmaprotocol/magma-clmm-sdk 0.5.47 → 0.5.49
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.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2589,13 +2589,19 @@ var SplitSwap = class {
|
|
|
2589
2589
|
|
|
2590
2590
|
// src/math/bin.ts
|
|
2591
2591
|
import Decimal6 from "decimal.js";
|
|
2592
|
-
import { get_price_x128_from_real_id as get_price_x128_from_real_id2 } from "@magmaprotocol/calc_dlmm";
|
|
2592
|
+
import { get_price_x128_from_real_id as get_price_x128_from_real_id2, get_real_id_from_price_x128 } from "@magmaprotocol/calc_dlmm";
|
|
2593
2593
|
var BinMath = class {
|
|
2594
2594
|
static getPriceOfBinByBinId(binId, binStep, decimalsA, decimalsB) {
|
|
2595
2595
|
const twoDec = new Decimal6(2);
|
|
2596
2596
|
const price = new Decimal6(get_price_x128_from_real_id2(binId, binStep));
|
|
2597
2597
|
return price.div(twoDec.pow(128)).mul(Decimal6.pow(10, decimalsA - decimalsB));
|
|
2598
2598
|
}
|
|
2599
|
+
static getBinIdFromPrice(price, binStep, decimalsA, decimalsB) {
|
|
2600
|
+
const twoDec = new Decimal6(2);
|
|
2601
|
+
const tenDec = new Decimal6(10);
|
|
2602
|
+
const realid = get_real_id_from_price_x128(new Decimal6(price).mul(tenDec.pow(decimalsB - decimalsA)).mul(twoDec.pow(128)).toDecimalPlaces(0).toString(), binStep);
|
|
2603
|
+
return realid;
|
|
2604
|
+
}
|
|
2599
2605
|
};
|
|
2600
2606
|
|
|
2601
2607
|
// src/utils/objects.ts
|