@magmaprotocol/magma-clmm-sdk 0.5.63 → 0.5.65

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
@@ -10506,8 +10506,7 @@ var GaugeModule = class {
10506
10506
 
10507
10507
  // src/modules/dlmm.ts
10508
10508
  import { Transaction as Transaction12 } from "@mysten/sui/transactions";
10509
- import { get_real_id, get_real_id_from_price_x128 as get_real_id_from_price_x1282, get_storage_id_from_real_id } from "@magmaprotocol/calc_dlmm";
10510
- import Decimal10 from "decimal.js";
10509
+ import { get_real_id, get_storage_id_from_real_id } from "@magmaprotocol/calc_dlmm";
10511
10510
  var DlmmModule = class {
10512
10511
  _sdk;
10513
10512
  _cache = {};
@@ -10532,7 +10531,9 @@ var DlmmModule = class {
10532
10531
  coin_b: fields.y.fields.name,
10533
10532
  base_factor: fields.params.fields.base_factor,
10534
10533
  base_fee: fields.params.fields.base_factor / 1e4 * (fields.bin_step / 1e4),
10535
- active_index: fields.params.fields.active_index
10534
+ active_index: fields.params.fields.active_index,
10535
+ coinAmountA: fields.reserve_x,
10536
+ coinAmountB: fields.reserve_y
10536
10537
  });
10537
10538
  });
10538
10539
  return poolList;
@@ -10578,18 +10579,9 @@ var DlmmModule = class {
10578
10579
  });
10579
10580
  return res;
10580
10581
  }
10581
- // params price: input (b/(10^b_decimal))/(a/(10^a_decimal))
10582
- price_to_storage_id(price, bin_step, tokenADecimal, tokenBDecimal) {
10583
- const priceDec = new Decimal10(price);
10584
- const tenDec = new Decimal10(10);
10585
- const twoDec = new Decimal10(2);
10586
- const price_x128 = priceDec.mul(tenDec.pow(tokenBDecimal)).div(tenDec.pow(tokenADecimal)).mul(twoDec.pow(128));
10587
- const active_id = get_real_id_from_price_x1282(price_x128.toFixed(0).toString(), bin_step);
10588
- return get_storage_id_from_real_id(active_id);
10589
- }
10590
10582
  // NOTE: x, y should be sorted
10591
10583
  async createPairPayload(params) {
10592
- const storage_id = this.price_to_storage_id(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal);
10584
+ const storage_id = get_storage_id_from_real_id(BinMath.getBinIdFromPrice(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal));
10593
10585
  const tx = new Transaction12();
10594
10586
  tx.setSender(this.sdk.senderAddress);
10595
10587
  const { clmm_pool, dlmm_pool, integrate } = this.sdk.sdkOptions;
@@ -10778,8 +10770,16 @@ var DlmmModule = class {
10778
10770
  });
10779
10771
  return tx;
10780
10772
  }
10781
- async collectReward(params) {
10782
- const tx = new Transaction12();
10773
+ async collectFeeAndReward(params) {
10774
+ let tx = new Transaction12();
10775
+ tx = await this.collectFees(params);
10776
+ if (params.rewards_token.length > 0) {
10777
+ tx = await this.collectReward(params);
10778
+ }
10779
+ return tx;
10780
+ }
10781
+ async collectReward(params, transaction) {
10782
+ const tx = transaction || new Transaction12();
10783
10783
  tx.setSender(this.sdk.senderAddress);
10784
10784
  const { integrate, clmm_pool } = this.sdk.sdkOptions;
10785
10785
  const clmmConfigs = getPackagerConfigs(clmm_pool);
@@ -10801,8 +10801,8 @@ var DlmmModule = class {
10801
10801
  });
10802
10802
  return tx;
10803
10803
  }
10804
- async collectFees(params) {
10805
- const tx = new Transaction12();
10804
+ async collectFees(params, transaction) {
10805
+ const tx = transaction || new Transaction12();
10806
10806
  tx.setSender(this.sdk.senderAddress);
10807
10807
  const { integrate } = this.sdk.sdkOptions;
10808
10808
  const typeArguments = [params.coin_a, params.coin_b];
@@ -10911,7 +10911,7 @@ var DlmmModule = class {
10911
10911
  });
10912
10912
  const type = extractStructTagFromType(ownerRes.data.type);
10913
10913
  if (type.full_address === this.buildPositionType()) {
10914
- position = this.buildPosition(ownerRes.data);
10914
+ position = this.buildPosition(ownerRes);
10915
10915
  } else {
10916
10916
  throw new ClmmpoolsError(`Dlmm Position not exists. Get Position error:${ownerRes.error}`, "InvalidPositionObject" /* InvalidPositionObject */);
10917
10917
  }