@magmaprotocol/magma-clmm-sdk 0.5.110 → 0.5.112

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
@@ -10539,8 +10539,7 @@ var AlmmModule = class {
10539
10539
  tx.object(global_config_id),
10540
10540
  tx.pure.u64(params.base_fee),
10541
10541
  tx.pure.u16(params.bin_step),
10542
- tx.pure.u32(storage_id),
10543
- tx.object(CLOCK_ADDRESS)
10542
+ tx.pure.u32(storage_id)
10544
10543
  ];
10545
10544
  tx.moveCall({
10546
10545
  target: `${integrate.published_at}::${AlmmScript}::create_pair`,
@@ -10818,20 +10817,13 @@ var AlmmModule = class {
10818
10817
  async burnPosition(params) {
10819
10818
  const tx = new Transaction12();
10820
10819
  tx.setSender(this.sdk.senderAddress);
10821
- const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
10820
+ const { integrate, clmm_pool } = this.sdk.sdkOptions;
10822
10821
  const clmmConfigs = getPackagerConfigs(clmm_pool);
10823
- const almmConfig = getPackagerConfigs(almm_pool);
10824
10822
  const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
10825
- let args = [tx.object(almmConfig.factory), tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
10823
+ let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
10826
10824
  let target = `${integrate.published_at}::${AlmmScript}::burn_position`;
10827
10825
  if (params.rewards_token.length > 0) {
10828
- args = [
10829
- tx.object(almmConfig.factory),
10830
- tx.object(params.pool_id),
10831
- tx.object(clmmConfigs.global_vault_id),
10832
- tx.object(params.position_id),
10833
- tx.object(CLOCK_ADDRESS)
10834
- ];
10826
+ args = [tx.object(params.pool_id), tx.object(clmmConfigs.global_vault_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
10835
10827
  target = `${integrate.published_at}::${AlmmScript}::burn_position_reward${params.rewards_token.length}`;
10836
10828
  }
10837
10829
  tx.moveCall({
@@ -10844,21 +10836,13 @@ var AlmmModule = class {
10844
10836
  async shrinkPosition(params) {
10845
10837
  const tx = new Transaction12();
10846
10838
  tx.setSender(this.sdk.senderAddress);
10847
- const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
10839
+ const { integrate, clmm_pool } = this.sdk.sdkOptions;
10848
10840
  const clmmConfigs = getPackagerConfigs(clmm_pool);
10849
- const almmConfig = getPackagerConfigs(almm_pool);
10850
10841
  const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
10851
- let args = [
10852
- tx.object(almmConfig.factory),
10853
- tx.object(params.pool_id),
10854
- tx.object(params.position_id),
10855
- tx.pure.u64(params.delta_percentage),
10856
- tx.object(CLOCK_ADDRESS)
10857
- ];
10842
+ let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.pure.u64(params.delta_percentage), tx.object(CLOCK_ADDRESS)];
10858
10843
  let target = `${integrate.published_at}::${AlmmScript}::shrink_position`;
10859
10844
  if (params.rewards_token.length > 0) {
10860
10845
  args = [
10861
- tx.object(almmConfig.factory),
10862
10846
  tx.object(params.pool_id),
10863
10847
  tx.object(clmmConfigs.global_vault_id),
10864
10848
  tx.object(params.position_id),
@@ -10895,12 +10879,10 @@ var AlmmModule = class {
10895
10879
  async collectReward(params, transaction) {
10896
10880
  const tx = transaction || new Transaction12();
10897
10881
  tx.setSender(this.sdk.senderAddress);
10898
- const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
10882
+ const { integrate, clmm_pool } = this.sdk.sdkOptions;
10899
10883
  const clmmConfigs = getPackagerConfigs(clmm_pool);
10900
- const almmConfig = getPackagerConfigs(almm_pool);
10901
10884
  const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
10902
10885
  const args = [
10903
- tx.object(almmConfig.factory),
10904
10886
  tx.object(params.pool_id),
10905
10887
  tx.object(clmmConfigs.global_vault_id),
10906
10888
  tx.object(params.position_id),
@@ -10920,10 +10902,9 @@ var AlmmModule = class {
10920
10902
  async collectFees(params, transaction) {
10921
10903
  const tx = transaction || new Transaction12();
10922
10904
  tx.setSender(this.sdk.senderAddress);
10923
- const { integrate, almm_pool } = this.sdk.sdkOptions;
10924
- const almmConfig = getPackagerConfigs(almm_pool);
10905
+ const { integrate } = this.sdk.sdkOptions;
10925
10906
  const typeArguments = [params.coin_a, params.coin_b];
10926
- const args = [tx.object(almmConfig.factory), tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
10907
+ const args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
10927
10908
  const target = `${integrate.published_at}::${AlmmScript}::collect_fees`;
10928
10909
  tx.moveCall({
10929
10910
  target,
@@ -10973,9 +10954,8 @@ var AlmmModule = class {
10973
10954
  async swap(params) {
10974
10955
  const tx = new Transaction12();
10975
10956
  tx.setSender(this.sdk.senderAddress);
10976
- const { clmm_pool, almm_pool, integrate } = this.sdk.sdkOptions;
10957
+ const { clmm_pool, integrate } = this.sdk.sdkOptions;
10977
10958
  const { global_config_id } = getPackagerConfigs(clmm_pool);
10978
- const almmConfig = getPackagerConfigs(almm_pool);
10979
10959
  const typeArguments = [params.coinTypeA, params.coinTypeB];
10980
10960
  const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
10981
10961
  const primaryCoinInputA = TransactionUtil.buildCoinForAmount(
@@ -10995,7 +10975,6 @@ var AlmmModule = class {
10995
10975
  true
10996
10976
  );
10997
10977
  const args = [
10998
- tx.object(almmConfig.factory),
10999
10978
  tx.object(params.pair),
11000
10979
  tx.object(global_config_id),
11001
10980
  primaryCoinInputA.targetCoin,
@@ -11104,6 +11083,29 @@ var AlmmModule = class {
11104
11083
  // contractPool: pool,
11105
11084
  // }
11106
11085
  // }
11086
+ /**
11087
+ * Gets a list of positions for the given account address.
11088
+ * @param positionId The account address to get positions for.
11089
+ * @param assignPoolIds An array of pool IDs to filter the positions by.
11090
+ * @returns array of Position objects.
11091
+ */
11092
+ async getUserPositionById(positionId, showDisplay = true) {
11093
+ let allPosition = [];
11094
+ const ownerRes = await this._sdk.fullClient.getObject({
11095
+ id: positionId,
11096
+ options: { showContent: true, showType: true, showDisplay, showOwner: true }
11097
+ });
11098
+ for (const item of ownerRes.data) {
11099
+ const type = extractStructTagFromType(item.data.type);
11100
+ if (type.full_address === this.buildPositionType()) {
11101
+ const position = this.buildPosition(item);
11102
+ const cacheKey = `${position.pos_object_id}_getPositionList`;
11103
+ this.updateCache(cacheKey, position, cacheTime24h);
11104
+ allPosition.push(position);
11105
+ }
11106
+ }
11107
+ return await this.getUserPositionInfo(allPosition);
11108
+ }
11107
11109
  /**
11108
11110
  * Gets a list of positions for the given account address.
11109
11111
  * @param accountAddress The account address to get positions for.
@@ -11124,7 +11126,7 @@ var AlmmModule = class {
11124
11126
  const cacheKey = `${position.pos_object_id}_getPositionList`;
11125
11127
  this.updateCache(cacheKey, position, cacheTime24h);
11126
11128
  if (hasAssignPoolIds) {
11127
- if (assignPoolIds.includes(position.pos_object_id)) {
11129
+ if (assignPoolIds.includes(position.pool)) {
11128
11130
  allPosition.push(position);
11129
11131
  }
11130
11132
  } else {
@@ -11132,6 +11134,9 @@ var AlmmModule = class {
11132
11134
  }
11133
11135
  }
11134
11136
  }
11137
+ return this.getUserPositionInfo(allPosition);
11138
+ }
11139
+ async getUserPositionInfo(allPosition) {
11135
11140
  const poolMap = /* @__PURE__ */ new Set();
11136
11141
  for (const item of allPosition) {
11137
11142
  poolMap.add(item.pool);