@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.d.ts CHANGED
@@ -3790,6 +3790,13 @@ declare class AlmmModule implements IModule {
3790
3790
  createPairAddLiquidity(params: AlmmCreatePairAddLiquidityParams): Promise<Transaction>;
3791
3791
  swap(params: ALMMSwapParams): Promise<Transaction>;
3792
3792
  fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
3793
+ /**
3794
+ * Gets a list of positions for the given account address.
3795
+ * @param positionId The account address to get positions for.
3796
+ * @param assignPoolIds An array of pool IDs to filter the positions by.
3797
+ * @returns array of Position objects.
3798
+ */
3799
+ getUserPositionById(positionId: string, showDisplay?: boolean): Promise<AlmmPositionInfo[]>;
3793
3800
  /**
3794
3801
  * Gets a list of positions for the given account address.
3795
3802
  * @param accountAddress The account address to get positions for.
@@ -3797,6 +3804,7 @@ declare class AlmmModule implements IModule {
3797
3804
  * @returns array of Position objects.
3798
3805
  */
3799
3806
  getUserPositions(accountAddress: string, assignPoolIds?: string[], showDisplay?: boolean): Promise<AlmmPositionInfo[]>;
3807
+ private getUserPositionInfo;
3800
3808
  private buildPosition;
3801
3809
  private getPoolCoins;
3802
3810
  private buildPositionType;
package/dist/index.js CHANGED
@@ -10752,8 +10752,7 @@ var AlmmModule = class {
10752
10752
  tx.object(global_config_id),
10753
10753
  tx.pure.u64(params.base_fee),
10754
10754
  tx.pure.u16(params.bin_step),
10755
- tx.pure.u32(storage_id),
10756
- tx.object(CLOCK_ADDRESS)
10755
+ tx.pure.u32(storage_id)
10757
10756
  ];
10758
10757
  tx.moveCall({
10759
10758
  target: `${integrate.published_at}::${AlmmScript}::create_pair`,
@@ -11031,20 +11030,13 @@ var AlmmModule = class {
11031
11030
  async burnPosition(params) {
11032
11031
  const tx = new import_transactions12.Transaction();
11033
11032
  tx.setSender(this.sdk.senderAddress);
11034
- const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
11033
+ const { integrate, clmm_pool } = this.sdk.sdkOptions;
11035
11034
  const clmmConfigs = getPackagerConfigs(clmm_pool);
11036
- const almmConfig = getPackagerConfigs(almm_pool);
11037
11035
  const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
11038
- let args = [tx.object(almmConfig.factory), tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
11036
+ let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
11039
11037
  let target = `${integrate.published_at}::${AlmmScript}::burn_position`;
11040
11038
  if (params.rewards_token.length > 0) {
11041
- args = [
11042
- tx.object(almmConfig.factory),
11043
- tx.object(params.pool_id),
11044
- tx.object(clmmConfigs.global_vault_id),
11045
- tx.object(params.position_id),
11046
- tx.object(CLOCK_ADDRESS)
11047
- ];
11039
+ args = [tx.object(params.pool_id), tx.object(clmmConfigs.global_vault_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
11048
11040
  target = `${integrate.published_at}::${AlmmScript}::burn_position_reward${params.rewards_token.length}`;
11049
11041
  }
11050
11042
  tx.moveCall({
@@ -11057,21 +11049,13 @@ var AlmmModule = class {
11057
11049
  async shrinkPosition(params) {
11058
11050
  const tx = new import_transactions12.Transaction();
11059
11051
  tx.setSender(this.sdk.senderAddress);
11060
- const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
11052
+ const { integrate, clmm_pool } = this.sdk.sdkOptions;
11061
11053
  const clmmConfigs = getPackagerConfigs(clmm_pool);
11062
- const almmConfig = getPackagerConfigs(almm_pool);
11063
11054
  const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
11064
- let args = [
11065
- tx.object(almmConfig.factory),
11066
- tx.object(params.pool_id),
11067
- tx.object(params.position_id),
11068
- tx.pure.u64(params.delta_percentage),
11069
- tx.object(CLOCK_ADDRESS)
11070
- ];
11055
+ let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.pure.u64(params.delta_percentage), tx.object(CLOCK_ADDRESS)];
11071
11056
  let target = `${integrate.published_at}::${AlmmScript}::shrink_position`;
11072
11057
  if (params.rewards_token.length > 0) {
11073
11058
  args = [
11074
- tx.object(almmConfig.factory),
11075
11059
  tx.object(params.pool_id),
11076
11060
  tx.object(clmmConfigs.global_vault_id),
11077
11061
  tx.object(params.position_id),
@@ -11108,12 +11092,10 @@ var AlmmModule = class {
11108
11092
  async collectReward(params, transaction) {
11109
11093
  const tx = transaction || new import_transactions12.Transaction();
11110
11094
  tx.setSender(this.sdk.senderAddress);
11111
- const { integrate, clmm_pool, almm_pool } = this.sdk.sdkOptions;
11095
+ const { integrate, clmm_pool } = this.sdk.sdkOptions;
11112
11096
  const clmmConfigs = getPackagerConfigs(clmm_pool);
11113
- const almmConfig = getPackagerConfigs(almm_pool);
11114
11097
  const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
11115
11098
  const args = [
11116
- tx.object(almmConfig.factory),
11117
11099
  tx.object(params.pool_id),
11118
11100
  tx.object(clmmConfigs.global_vault_id),
11119
11101
  tx.object(params.position_id),
@@ -11133,10 +11115,9 @@ var AlmmModule = class {
11133
11115
  async collectFees(params, transaction) {
11134
11116
  const tx = transaction || new import_transactions12.Transaction();
11135
11117
  tx.setSender(this.sdk.senderAddress);
11136
- const { integrate, almm_pool } = this.sdk.sdkOptions;
11137
- const almmConfig = getPackagerConfigs(almm_pool);
11118
+ const { integrate } = this.sdk.sdkOptions;
11138
11119
  const typeArguments = [params.coin_a, params.coin_b];
11139
- const args = [tx.object(almmConfig.factory), tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
11120
+ const args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
11140
11121
  const target = `${integrate.published_at}::${AlmmScript}::collect_fees`;
11141
11122
  tx.moveCall({
11142
11123
  target,
@@ -11186,9 +11167,8 @@ var AlmmModule = class {
11186
11167
  async swap(params) {
11187
11168
  const tx = new import_transactions12.Transaction();
11188
11169
  tx.setSender(this.sdk.senderAddress);
11189
- const { clmm_pool, almm_pool, integrate } = this.sdk.sdkOptions;
11170
+ const { clmm_pool, integrate } = this.sdk.sdkOptions;
11190
11171
  const { global_config_id } = getPackagerConfigs(clmm_pool);
11191
- const almmConfig = getPackagerConfigs(almm_pool);
11192
11172
  const typeArguments = [params.coinTypeA, params.coinTypeB];
11193
11173
  const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
11194
11174
  const primaryCoinInputA = TransactionUtil.buildCoinForAmount(
@@ -11208,7 +11188,6 @@ var AlmmModule = class {
11208
11188
  true
11209
11189
  );
11210
11190
  const args = [
11211
- tx.object(almmConfig.factory),
11212
11191
  tx.object(params.pair),
11213
11192
  tx.object(global_config_id),
11214
11193
  primaryCoinInputA.targetCoin,
@@ -11317,6 +11296,29 @@ var AlmmModule = class {
11317
11296
  // contractPool: pool,
11318
11297
  // }
11319
11298
  // }
11299
+ /**
11300
+ * Gets a list of positions for the given account address.
11301
+ * @param positionId The account address to get positions for.
11302
+ * @param assignPoolIds An array of pool IDs to filter the positions by.
11303
+ * @returns array of Position objects.
11304
+ */
11305
+ async getUserPositionById(positionId, showDisplay = true) {
11306
+ let allPosition = [];
11307
+ const ownerRes = await this._sdk.fullClient.getObject({
11308
+ id: positionId,
11309
+ options: { showContent: true, showType: true, showDisplay, showOwner: true }
11310
+ });
11311
+ for (const item of ownerRes.data) {
11312
+ const type = extractStructTagFromType(item.data.type);
11313
+ if (type.full_address === this.buildPositionType()) {
11314
+ const position = this.buildPosition(item);
11315
+ const cacheKey = `${position.pos_object_id}_getPositionList`;
11316
+ this.updateCache(cacheKey, position, cacheTime24h);
11317
+ allPosition.push(position);
11318
+ }
11319
+ }
11320
+ return await this.getUserPositionInfo(allPosition);
11321
+ }
11320
11322
  /**
11321
11323
  * Gets a list of positions for the given account address.
11322
11324
  * @param accountAddress The account address to get positions for.
@@ -11337,7 +11339,7 @@ var AlmmModule = class {
11337
11339
  const cacheKey = `${position.pos_object_id}_getPositionList`;
11338
11340
  this.updateCache(cacheKey, position, cacheTime24h);
11339
11341
  if (hasAssignPoolIds) {
11340
- if (assignPoolIds.includes(position.pos_object_id)) {
11342
+ if (assignPoolIds.includes(position.pool)) {
11341
11343
  allPosition.push(position);
11342
11344
  }
11343
11345
  } else {
@@ -11345,6 +11347,9 @@ var AlmmModule = class {
11345
11347
  }
11346
11348
  }
11347
11349
  }
11350
+ return this.getUserPositionInfo(allPosition);
11351
+ }
11352
+ async getUserPositionInfo(allPosition) {
11348
11353
  const poolMap = /* @__PURE__ */ new Set();
11349
11354
  for (const item of allPosition) {
11350
11355
  poolMap.add(item.pool);