@magmaprotocol/magma-clmm-sdk 0.5.45 → 0.5.48

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
@@ -1598,10 +1598,10 @@ import BN10 from "bn.js";
1598
1598
  // src/math/dlmmWeightToAmounts.ts
1599
1599
  import BN9 from "bn.js";
1600
1600
  import Decimal3 from "decimal.js";
1601
- import { get_price_from_real_id } from "@magmaprotocol/calc_dlmm";
1601
+ import { get_price_x128_from_real_id } from "@magmaprotocol/calc_dlmm";
1602
1602
  function getPriceOfBinByBinId(binId, binStep) {
1603
1603
  const twoDec = new Decimal3(2);
1604
- const price = new Decimal3(get_price_from_real_id(binId, binStep));
1604
+ const price = new Decimal3(get_price_x128_from_real_id(binId, binStep));
1605
1605
  return price.div(twoDec.pow(128));
1606
1606
  }
1607
1607
  function autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, distributions) {
@@ -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_from_real_id as get_price_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
- const price = new Decimal6(get_price_from_real_id2(binId, binStep));
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 - decimalsB)).mul(twoDec.pow(128)).toDecimalPlaces(0).toString(), binStep);
2603
+ return realid;
2604
+ }
2599
2605
  };
2600
2606
 
2601
2607
  // src/utils/objects.ts
@@ -10501,7 +10507,7 @@ var GaugeModule = class {
10501
10507
  // src/modules/dlmm.ts
10502
10508
  import { Transaction as Transaction12 } from "@mysten/sui/transactions";
10503
10509
  import Decimal10 from "decimal.js";
10504
- import { get_real_id_from_price, get_storage_id_from_real_id } from "@magmaprotocol/calc_dlmm";
10510
+ import { get_real_id_from_price_x128 as get_real_id_from_price_x1282, get_storage_id_from_real_id } from "@magmaprotocol/calc_dlmm";
10505
10511
  var DlmmModule = class {
10506
10512
  _sdk;
10507
10513
  constructor(sdk) {
@@ -10577,7 +10583,7 @@ var DlmmModule = class {
10577
10583
  const tenDec = new Decimal10(10);
10578
10584
  const twoDec = new Decimal10(2);
10579
10585
  const price_x128 = priceDec.mul(tenDec.pow(tokenBDecimal)).div(tenDec.pow(tokenADecimal)).mul(twoDec.pow(128));
10580
- const active_id = get_real_id_from_price(price_x128.toFixed(0).toString(), bin_step);
10586
+ const active_id = get_real_id_from_price_x1282(price_x128.toFixed(0).toString(), bin_step);
10581
10587
  return get_storage_id_from_real_id(active_id);
10582
10588
  }
10583
10589
  // NOTE: x, y should be sorted
@@ -10589,7 +10595,13 @@ var DlmmModule = class {
10589
10595
  const { global_config_id } = getPackagerConfigs(clmm_pool);
10590
10596
  const dlmmConfig = getPackagerConfigs(dlmm_pool);
10591
10597
  const typeArguments = [params.coinTypeA, params.coinTypeB];
10592
- const args = [tx.object(dlmmConfig.factory), tx.object(global_config_id), tx.pure.u16(params.bin_step), tx.pure.u32(storage_id)];
10598
+ const args = [
10599
+ tx.object(dlmmConfig.factory),
10600
+ tx.object(global_config_id),
10601
+ tx.pure.u64(params.base_fee),
10602
+ tx.pure.u16(params.bin_step),
10603
+ tx.pure.u32(storage_id)
10604
+ ];
10593
10605
  tx.moveCall({
10594
10606
  target: `${integrate.published_at}::${DlmmScript}::create_pair`,
10595
10607
  typeArguments,
@@ -10597,10 +10609,6 @@ var DlmmModule = class {
10597
10609
  });
10598
10610
  return tx;
10599
10611
  }
10600
- async createAddLiquidityPayload() {
10601
- const tx = new Transaction12();
10602
- return tx;
10603
- }
10604
10612
  // Create a position by percent
10605
10613
  async mintPercent(params) {
10606
10614
  const tx = new Transaction12();