@jimmygu/sfa-sdk-test 1.0.11 → 1.0.13

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.mts CHANGED
@@ -776,7 +776,7 @@ declare class HyperliquidService {
776
776
  spender: string;
777
777
  token: string;
778
778
  v: 28 | 27;
779
- nonce: any;
779
+ nonce: number;
780
780
  }>;
781
781
  }
782
782
  declare const Hyperliquid: HyperliquidService;
package/dist/index.d.ts CHANGED
@@ -776,7 +776,7 @@ declare class HyperliquidService {
776
776
  spender: string;
777
777
  token: string;
778
778
  v: 28 | 27;
779
- nonce: any;
779
+ nonce: number;
780
780
  }>;
781
781
  }
782
782
  declare const Hyperliquid: HyperliquidService;
package/dist/index.js CHANGED
@@ -659,6 +659,7 @@ var OneClickService = class {
659
659
  swapType = "EXACT_INPUT",
660
660
  ...restParams
661
661
  } = params;
662
+ const isExactOutput = swapType === "EXACT_OUTPUT";
662
663
  const response = await request(OpenAPI, {
663
664
  method: "POST",
664
665
  url: "/v0/quote",
@@ -690,7 +691,7 @@ var OneClickService = class {
690
691
  res.data.outputAmount = numberRemoveEndZero((0, import_big.default)(res.data?.quote?.amountOut || 0).div(10 ** params.toToken.decimals).toFixed(params.toToken.decimals, 0));
691
692
  try {
692
693
  let netFee = (0, import_big.default)(params.amount).div(10 ** params.fromToken.decimals).minus((0, import_big.default)(res.data?.quote?.amountOut || 0).div(10 ** params.toToken.decimals));
693
- if (swapType === "EXACT_OUTPUT") {
694
+ if (isExactOutput) {
694
695
  netFee = (0, import_big.default)(res.data?.quote?.amountIn || 0).div(10 ** params.toToken.decimals).minus((0, import_big.default)(params.amount).div(10 ** params.fromToken.decimals));
695
696
  }
696
697
  const bridgeFeeValue = BridgeFee.reduce((acc, item) => {
@@ -732,7 +733,7 @@ var OneClickService = class {
732
733
  fromToken: params.fromToken,
733
734
  refundTo: params.refundTo,
734
735
  recipient: params.recipient,
735
- amountWei: params.amount,
736
+ amountWei: isExactOutput ? res.data?.quote?.amountIn : params.amount,
736
737
  prices: params.prices,
737
738
  depositAddress: res.data?.quote?.depositAddress || DefaultAddresses[params.fromToken.chainType]
738
739
  });
@@ -4928,7 +4929,7 @@ var HyperliquidService = class {
4928
4929
  provider
4929
4930
  );
4930
4931
  const deadline = Math.floor(Date.now() / 1e3) + 86400;
4931
- const nonce = (await erc20.nonces(address)).toString();
4932
+ const nonce = await erc20.nonces(address);
4932
4933
  const value = amountWei;
4933
4934
  const domain = {
4934
4935
  name,
@@ -4949,7 +4950,7 @@ var HyperliquidService = class {
4949
4950
  owner: address,
4950
4951
  spender: SPENDER,
4951
4952
  value,
4952
- nonce,
4953
+ nonce: nonce.toString(),
4953
4954
  deadline
4954
4955
  };
4955
4956
  const signature = await evmWallet.signTypedData({
@@ -4967,7 +4968,7 @@ var HyperliquidService = class {
4967
4968
  spender: SPENDER,
4968
4969
  token: tokenAddress,
4969
4970
  v,
4970
- nonce
4971
+ nonce: Number(nonce)
4971
4972
  };
4972
4973
  console.log("permitParams: %o", permitParams);
4973
4974
  return permitParams;
package/dist/index.mjs CHANGED
@@ -597,6 +597,7 @@ var OneClickService = class {
597
597
  swapType = "EXACT_INPUT",
598
598
  ...restParams
599
599
  } = params;
600
+ const isExactOutput = swapType === "EXACT_OUTPUT";
600
601
  const response = await request(OpenAPI, {
601
602
  method: "POST",
602
603
  url: "/v0/quote",
@@ -628,7 +629,7 @@ var OneClickService = class {
628
629
  res.data.outputAmount = numberRemoveEndZero(Big(res.data?.quote?.amountOut || 0).div(10 ** params.toToken.decimals).toFixed(params.toToken.decimals, 0));
629
630
  try {
630
631
  let netFee = Big(params.amount).div(10 ** params.fromToken.decimals).minus(Big(res.data?.quote?.amountOut || 0).div(10 ** params.toToken.decimals));
631
- if (swapType === "EXACT_OUTPUT") {
632
+ if (isExactOutput) {
632
633
  netFee = Big(res.data?.quote?.amountIn || 0).div(10 ** params.toToken.decimals).minus(Big(params.amount).div(10 ** params.fromToken.decimals));
633
634
  }
634
635
  const bridgeFeeValue = BridgeFee.reduce((acc, item) => {
@@ -670,7 +671,7 @@ var OneClickService = class {
670
671
  fromToken: params.fromToken,
671
672
  refundTo: params.refundTo,
672
673
  recipient: params.recipient,
673
- amountWei: params.amount,
674
+ amountWei: isExactOutput ? res.data?.quote?.amountIn : params.amount,
674
675
  prices: params.prices,
675
676
  depositAddress: res.data?.quote?.depositAddress || DefaultAddresses[params.fromToken.chainType]
676
677
  });
@@ -4866,7 +4867,7 @@ var HyperliquidService = class {
4866
4867
  provider
4867
4868
  );
4868
4869
  const deadline = Math.floor(Date.now() / 1e3) + 86400;
4869
- const nonce = (await erc20.nonces(address)).toString();
4870
+ const nonce = await erc20.nonces(address);
4870
4871
  const value = amountWei;
4871
4872
  const domain = {
4872
4873
  name,
@@ -4887,7 +4888,7 @@ var HyperliquidService = class {
4887
4888
  owner: address,
4888
4889
  spender: SPENDER,
4889
4890
  value,
4890
- nonce,
4891
+ nonce: nonce.toString(),
4891
4892
  deadline
4892
4893
  };
4893
4894
  const signature = await evmWallet.signTypedData({
@@ -4905,7 +4906,7 @@ var HyperliquidService = class {
4905
4906
  spender: SPENDER,
4906
4907
  token: tokenAddress,
4907
4908
  v,
4908
- nonce
4909
+ nonce: Number(nonce)
4909
4910
  };
4910
4911
  console.log("permitParams: %o", permitParams);
4911
4912
  return permitParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jimmygu/sfa-sdk-test",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "TypeScript SDK for StableFlow AI API - Cross-chain token swap solution",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",