@gala-chain/gswap-sdk 0.0.5 → 0.0.6

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.cjs CHANGED
@@ -919,6 +919,56 @@ var Positions = class {
919
919
  });
920
920
  return result;
921
921
  }
922
+ /**
923
+ * Estimates the token amounts that would be received from removing liquidity from a position.
924
+ * @param args - Parameters for estimating liquidity removal.
925
+ * @param args.ownerAddress - The wallet address that owns the position.
926
+ * @param args.positionId - The position identifier.
927
+ * @param args.token0 - The first token in the pair.
928
+ * @param args.token1 - The second token in the pair.
929
+ * @param args.fee - The pool fee tier.
930
+ * @param args.tickLower - The lower tick of the position range.
931
+ * @param args.tickUpper - The upper tick of the position range.
932
+ * @param args.amount - The amount of liquidity to remove.
933
+ * @returns Estimated token amounts that would be received.
934
+ * @example
935
+ * ```typescript
936
+ * const estimation = await gSwap.positions.estimateRemoveLiquidity({
937
+ * ownerAddress: 'client|635f048ab243d7eb7f5ba044',
938
+ * positionId: '210f8e4dd1bbe1b4af4b977330ee7e4b68bc716f66e39c87a60fff0976ded3ea',
939
+ * token0: 'GALA|Unit|none|none',
940
+ * token1: 'GUSDT|Unit|none|none',
941
+ * fee: 3000,
942
+ * tickLower: -41100,
943
+ * tickUpper: -40080,
944
+ * amount: '1491.973332758921980256'
945
+ * });
946
+ * console.log('Estimated tokens:', estimation);
947
+ * ```
948
+ */
949
+ async estimateRemoveLiquidity(args) {
950
+ validateWalletAddress(args.ownerAddress);
951
+ validateFee(args.fee);
952
+ validateTickRange(args.tickLower, args.tickUpper);
953
+ validateNumericAmount(args.amount, "amount");
954
+ const token0TokenClassKey = parseTokenClassKey(args.token0);
955
+ const token1TokenClassKey = parseTokenClassKey(args.token1);
956
+ const ordering = getTokenOrdering(token0TokenClassKey, token1TokenClassKey, false);
957
+ const responseBody = await this.httpClient.sendPostRequest(this.gatewayBaseUrl, this.dexContractBasePath, "/GetRemoveLiquidityEstimation", {
958
+ tickLower: args.tickLower,
959
+ tickUpper: args.tickUpper,
960
+ amount: (0, import_bignumber3.default)(args.amount).toFixed(),
961
+ token0: ordering.token0,
962
+ token1: ordering.token1,
963
+ fee: args.fee,
964
+ owner: args.ownerAddress,
965
+ positionId: args.positionId
966
+ });
967
+ return {
968
+ amount0: (0, import_bignumber3.default)(responseBody.Data.amount0),
969
+ amount1: (0, import_bignumber3.default)(responseBody.Data.amount1)
970
+ };
971
+ }
922
972
  /**
923
973
  * Gets detailed information about a liquidity position by its ID.
924
974
  * @param ownerAddress - The wallet address that owns the position.