@gala-chain/gswap-sdk 0.0.4 → 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.
@@ -982,8 +1032,8 @@ var Positions = class {
982
1032
  validateWalletAddress(walletAddress);
983
1033
  validateFee(args.fee);
984
1034
  validateTickRange(args.tickLower, args.tickUpper);
985
- validateNumericAmount(args.amount0Desired, "amount0Desired");
986
- validateNumericAmount(args.amount1Desired, "amount1Desired");
1035
+ validateNumericAmount(args.amount0Desired, "amount0Desired", true);
1036
+ validateNumericAmount(args.amount1Desired, "amount1Desired", true);
987
1037
  validateNumericAmount(args.amount0Min, "amount0Min", true);
988
1038
  validateNumericAmount(args.amount1Min, "amount1Min", true);
989
1039
  const token0TokenClassKey = parseTokenClassKey(args.token0);
@@ -1069,8 +1119,8 @@ var Positions = class {
1069
1119
  validateTickSpacing(args.tickSpacing);
1070
1120
  validateNumericAmount(args.minPrice, "minPrice", true);
1071
1121
  validateNumericAmount(args.maxPrice, "maxPrice");
1072
- validateNumericAmount(args.amount0Desired, "amount0Desired");
1073
- validateNumericAmount(args.amount1Desired, "amount1Desired");
1122
+ validateNumericAmount(args.amount0Desired, "amount0Desired", true);
1123
+ validateNumericAmount(args.amount1Desired, "amount1Desired", true);
1074
1124
  validateNumericAmount(args.amount0Min, "amount0Min", true);
1075
1125
  validateNumericAmount(args.amount1Min, "amount1Min", true);
1076
1126
  if ((0, import_bignumber3.default)(args.minPrice).isGreaterThan((0, import_bignumber3.default)(args.maxPrice))) {