@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.d.cts CHANGED
@@ -492,6 +492,46 @@ declare class Positions {
492
492
  tickLower: number;
493
493
  tickUpper: number;
494
494
  }): Promise<GetPositionResult>;
495
+ /**
496
+ * Estimates the token amounts that would be received from removing liquidity from a position.
497
+ * @param args - Parameters for estimating liquidity removal.
498
+ * @param args.ownerAddress - The wallet address that owns the position.
499
+ * @param args.positionId - The position identifier.
500
+ * @param args.token0 - The first token in the pair.
501
+ * @param args.token1 - The second token in the pair.
502
+ * @param args.fee - The pool fee tier.
503
+ * @param args.tickLower - The lower tick of the position range.
504
+ * @param args.tickUpper - The upper tick of the position range.
505
+ * @param args.amount - The amount of liquidity to remove.
506
+ * @returns Estimated token amounts that would be received.
507
+ * @example
508
+ * ```typescript
509
+ * const estimation = await gSwap.positions.estimateRemoveLiquidity({
510
+ * ownerAddress: 'client|635f048ab243d7eb7f5ba044',
511
+ * positionId: '210f8e4dd1bbe1b4af4b977330ee7e4b68bc716f66e39c87a60fff0976ded3ea',
512
+ * token0: 'GALA|Unit|none|none',
513
+ * token1: 'GUSDT|Unit|none|none',
514
+ * fee: 3000,
515
+ * tickLower: -41100,
516
+ * tickUpper: -40080,
517
+ * amount: '1491.973332758921980256'
518
+ * });
519
+ * console.log('Estimated tokens:', estimation);
520
+ * ```
521
+ */
522
+ estimateRemoveLiquidity(args: {
523
+ ownerAddress: string;
524
+ positionId: string;
525
+ token0: GalaChainTokenClassKey | string;
526
+ token1: GalaChainTokenClassKey | string;
527
+ fee: number;
528
+ tickLower: number;
529
+ tickUpper: number;
530
+ amount: NumericAmount;
531
+ }): Promise<{
532
+ amount0: BigNumber;
533
+ amount1: BigNumber;
534
+ }>;
495
535
  /**
496
536
  * Gets detailed information about a liquidity position by its ID.
497
537
  * @param ownerAddress - The wallet address that owns the position.
package/dist/index.d.ts CHANGED
@@ -492,6 +492,46 @@ declare class Positions {
492
492
  tickLower: number;
493
493
  tickUpper: number;
494
494
  }): Promise<GetPositionResult>;
495
+ /**
496
+ * Estimates the token amounts that would be received from removing liquidity from a position.
497
+ * @param args - Parameters for estimating liquidity removal.
498
+ * @param args.ownerAddress - The wallet address that owns the position.
499
+ * @param args.positionId - The position identifier.
500
+ * @param args.token0 - The first token in the pair.
501
+ * @param args.token1 - The second token in the pair.
502
+ * @param args.fee - The pool fee tier.
503
+ * @param args.tickLower - The lower tick of the position range.
504
+ * @param args.tickUpper - The upper tick of the position range.
505
+ * @param args.amount - The amount of liquidity to remove.
506
+ * @returns Estimated token amounts that would be received.
507
+ * @example
508
+ * ```typescript
509
+ * const estimation = await gSwap.positions.estimateRemoveLiquidity({
510
+ * ownerAddress: 'client|635f048ab243d7eb7f5ba044',
511
+ * positionId: '210f8e4dd1bbe1b4af4b977330ee7e4b68bc716f66e39c87a60fff0976ded3ea',
512
+ * token0: 'GALA|Unit|none|none',
513
+ * token1: 'GUSDT|Unit|none|none',
514
+ * fee: 3000,
515
+ * tickLower: -41100,
516
+ * tickUpper: -40080,
517
+ * amount: '1491.973332758921980256'
518
+ * });
519
+ * console.log('Estimated tokens:', estimation);
520
+ * ```
521
+ */
522
+ estimateRemoveLiquidity(args: {
523
+ ownerAddress: string;
524
+ positionId: string;
525
+ token0: GalaChainTokenClassKey | string;
526
+ token1: GalaChainTokenClassKey | string;
527
+ fee: number;
528
+ tickLower: number;
529
+ tickUpper: number;
530
+ amount: NumericAmount;
531
+ }): Promise<{
532
+ amount0: BigNumber;
533
+ amount1: BigNumber;
534
+ }>;
495
535
  /**
496
536
  * Gets detailed information about a liquidity position by its ID.
497
537
  * @param ownerAddress - The wallet address that owns the position.
package/dist/index.mjs CHANGED
@@ -858,6 +858,56 @@ var Positions = class {
858
858
  });
859
859
  return result;
860
860
  }
861
+ /**
862
+ * Estimates the token amounts that would be received from removing liquidity from a position.
863
+ * @param args - Parameters for estimating liquidity removal.
864
+ * @param args.ownerAddress - The wallet address that owns the position.
865
+ * @param args.positionId - The position identifier.
866
+ * @param args.token0 - The first token in the pair.
867
+ * @param args.token1 - The second token in the pair.
868
+ * @param args.fee - The pool fee tier.
869
+ * @param args.tickLower - The lower tick of the position range.
870
+ * @param args.tickUpper - The upper tick of the position range.
871
+ * @param args.amount - The amount of liquidity to remove.
872
+ * @returns Estimated token amounts that would be received.
873
+ * @example
874
+ * ```typescript
875
+ * const estimation = await gSwap.positions.estimateRemoveLiquidity({
876
+ * ownerAddress: 'client|635f048ab243d7eb7f5ba044',
877
+ * positionId: '210f8e4dd1bbe1b4af4b977330ee7e4b68bc716f66e39c87a60fff0976ded3ea',
878
+ * token0: 'GALA|Unit|none|none',
879
+ * token1: 'GUSDT|Unit|none|none',
880
+ * fee: 3000,
881
+ * tickLower: -41100,
882
+ * tickUpper: -40080,
883
+ * amount: '1491.973332758921980256'
884
+ * });
885
+ * console.log('Estimated tokens:', estimation);
886
+ * ```
887
+ */
888
+ async estimateRemoveLiquidity(args) {
889
+ validateWalletAddress(args.ownerAddress);
890
+ validateFee(args.fee);
891
+ validateTickRange(args.tickLower, args.tickUpper);
892
+ validateNumericAmount(args.amount, "amount");
893
+ const token0TokenClassKey = parseTokenClassKey(args.token0);
894
+ const token1TokenClassKey = parseTokenClassKey(args.token1);
895
+ const ordering = getTokenOrdering(token0TokenClassKey, token1TokenClassKey, false);
896
+ const responseBody = await this.httpClient.sendPostRequest(this.gatewayBaseUrl, this.dexContractBasePath, "/GetRemoveLiquidityEstimation", {
897
+ tickLower: args.tickLower,
898
+ tickUpper: args.tickUpper,
899
+ amount: BigNumber3(args.amount).toFixed(),
900
+ token0: ordering.token0,
901
+ token1: ordering.token1,
902
+ fee: args.fee,
903
+ owner: args.ownerAddress,
904
+ positionId: args.positionId
905
+ });
906
+ return {
907
+ amount0: BigNumber3(responseBody.Data.amount0),
908
+ amount1: BigNumber3(responseBody.Data.amount1)
909
+ };
910
+ }
861
911
  /**
862
912
  * Gets detailed information about a liquidity position by its ID.
863
913
  * @param ownerAddress - The wallet address that owns the position.