@rabby-wallet/rabby-swap 0.0.74 → 0.0.75-beta.1

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/abi.d.ts CHANGED
@@ -142,40 +142,6 @@ export declare const OpenOceanABI: ({
142
142
  type: string;
143
143
  anonymous?: undefined;
144
144
  })[];
145
- export declare const UniswapABI: ({
146
- inputs: {
147
- components: {
148
- internalType: string;
149
- name: string;
150
- type: string;
151
- }[];
152
- internalType: string;
153
- name: string;
154
- type: string;
155
- }[];
156
- name: string;
157
- outputs: {
158
- internalType: string;
159
- name: string;
160
- type: string;
161
- }[];
162
- stateMutability: string;
163
- type: string;
164
- } | {
165
- inputs: {
166
- internalType: string;
167
- name: string;
168
- type: string;
169
- }[];
170
- name: string;
171
- outputs: {
172
- internalType: string;
173
- name: string;
174
- type: string;
175
- }[];
176
- stateMutability: string;
177
- type: string;
178
- })[];
179
145
  export declare const KyberswapABI: ({
180
146
  inputs: {
181
147
  internalType: string;
package/dist/abi.js CHANGED
@@ -764,91 +764,6 @@ export const OpenOceanABI = [
764
764
  type: "function",
765
765
  },
766
766
  ];
767
- export const UniswapABI = [
768
- {
769
- inputs: [
770
- {
771
- components: [
772
- {
773
- internalType: "bytes",
774
- name: "path",
775
- type: "bytes",
776
- },
777
- {
778
- internalType: "address",
779
- name: "recipient",
780
- type: "address",
781
- },
782
- {
783
- internalType: "uint256",
784
- name: "deadline",
785
- type: "uint256",
786
- },
787
- {
788
- internalType: "uint256",
789
- name: "amountIn",
790
- type: "uint256",
791
- },
792
- {
793
- internalType: "uint256",
794
- name: "amountOutMinimum",
795
- type: "uint256",
796
- },
797
- ],
798
- internalType: "struct ISwapRouter.ExactInputParams",
799
- name: "params",
800
- type: "tuple",
801
- },
802
- ],
803
- name: "exactInput",
804
- outputs: [
805
- {
806
- internalType: "uint256",
807
- name: "amountOut",
808
- type: "uint256",
809
- },
810
- ],
811
- stateMutability: "payable",
812
- type: "function",
813
- },
814
- {
815
- inputs: [
816
- {
817
- internalType: "bytes[]",
818
- name: "data",
819
- type: "bytes[]",
820
- },
821
- ],
822
- name: "multicall",
823
- outputs: [
824
- {
825
- internalType: "bytes[]",
826
- name: "results",
827
- type: "bytes[]",
828
- },
829
- ],
830
- stateMutability: "payable",
831
- type: "function",
832
- },
833
- {
834
- inputs: [
835
- {
836
- internalType: "uint256",
837
- name: "amountMinimum",
838
- type: "uint256",
839
- },
840
- {
841
- internalType: "address",
842
- name: "recipient",
843
- type: "address",
844
- },
845
- ],
846
- name: "unwrapWETH9",
847
- outputs: [],
848
- stateMutability: "payable",
849
- type: "function",
850
- },
851
- ];
852
767
  export const KyberswapABI = [
853
768
  {
854
769
  inputs: [{ internalType: "address", name: "_WETH", type: "address" }],
package/dist/consts.d.ts CHANGED
@@ -4,11 +4,11 @@ export declare enum DEX_ENUM {
4
4
  ZEROXAPI = "0xAPI",
5
5
  WRAPTOKEN = "WrapToken",
6
6
  OPENOCEAN = "OpenOcean",
7
- UNISWAP = "Uniswap",
8
7
  KYBERSWAP = "Kyberswap",
9
8
  PARASWAPV6 = "ParaSwapV6",
10
9
  ODOS = "ODOS",
11
10
  ZEROXAPIV2 = "0xAPIV2",
12
11
  MAGPIE = "Magpie",
13
- RABBY = "Rabby"
12
+ RABBY = "Rabby",
13
+ UNI = "Uniswap"
14
14
  }
package/dist/consts.js CHANGED
@@ -5,11 +5,11 @@ export var DEX_ENUM;
5
5
  DEX_ENUM["ZEROXAPI"] = "0xAPI";
6
6
  DEX_ENUM["WRAPTOKEN"] = "WrapToken";
7
7
  DEX_ENUM["OPENOCEAN"] = "OpenOcean";
8
- DEX_ENUM["UNISWAP"] = "Uniswap";
9
8
  DEX_ENUM["KYBERSWAP"] = "Kyberswap";
10
9
  DEX_ENUM["PARASWAPV6"] = "ParaSwapV6";
11
10
  DEX_ENUM["ODOS"] = "ODOS";
12
11
  DEX_ENUM["ZEROXAPIV2"] = "0xAPIV2";
13
12
  DEX_ENUM["MAGPIE"] = "Magpie";
14
13
  DEX_ENUM["RABBY"] = "Rabby";
14
+ DEX_ENUM["UNI"] = "Uniswap";
15
15
  })(DEX_ENUM || (DEX_ENUM = {}));
@@ -1,7 +1,6 @@
1
+ import { CHAINS_ENUM } from "@debank/common";
1
2
  import { TxWithChainId, DecodeCalldataResult } from "../quote";
2
- /**
3
- * @deprecated
4
- */
5
- export declare const SUPPORT_CHAINS: never[];
3
+ export declare const SUPPORT_CHAINS: CHAINS_ENUM[];
4
+ export declare const UNI_NATIVE_TO_ADDRESSES: Record<CHAINS_ENUM, string>;
6
5
  export declare const getQuote: (options: import("../quote").QuoteParams, api: import("@rabby-wallet/rabby-api").OpenApiService) => Promise<import("../quote").QuoteResult>;
7
6
  export declare const decodeCalldata: (tx: TxWithChainId) => DecodeCalldataResult | null;
@@ -0,0 +1,41 @@
1
+ import { CHAINS_ENUM } from "@debank/common";
2
+ import { generateGetQuote } from "../utils";
3
+ import { DEX_ENUM } from "../consts";
4
+ export const SUPPORT_CHAINS = [
5
+ CHAINS_ENUM.ETH,
6
+ CHAINS_ENUM.OP,
7
+ CHAINS_ENUM.BSC,
8
+ CHAINS_ENUM.POLYGON,
9
+ CHAINS_ENUM.ARBITRUM,
10
+ CHAINS_ENUM.AVAX,
11
+ CHAINS_ENUM.BASE,
12
+ CHAINS_ENUM.BLAST,
13
+ CHAINS_ENUM.CELO,
14
+ CHAINS_ENUM.ERA,
15
+ "UNI",
16
+ "TEMPO",
17
+ "MONAD",
18
+ ];
19
+ export const UNI_NATIVE_TO_ADDRESSES = {
20
+ [CHAINS_ENUM.ETH]: "0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af",
21
+ [CHAINS_ENUM.OP]: "0x851116D9223fabED8E56C0E6b8Ad0c31d98B3507",
22
+ [CHAINS_ENUM.BSC]: "0x1906c1d672b88cD1B9aC7593301cA990F94Eae07",
23
+ [CHAINS_ENUM.POLYGON]: "0x1095692A6237d83C6a72F3F5eFEdb9A670C49223",
24
+ [CHAINS_ENUM.ARBITRUM]: "0xA51afAFe0263b40EdaEf0Df8781eA9aa03E381a3",
25
+ [CHAINS_ENUM.AVAX]: "0x94b75331AE8d42C1b61065089B7d48FE14aA73b7",
26
+ [CHAINS_ENUM.BASE]: "0x6fF5693b99212Da76ad316178A184AB56D299b43",
27
+ [CHAINS_ENUM.BLAST]: "0xeAbBcB3E8E415306207ef514f660A3F820025BE3",
28
+ [CHAINS_ENUM.CELO]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
29
+ [CHAINS_ENUM.ERA]: "0x28731BCC616B5f51dD52CF2e4dF0E78dD1136C06",
30
+ ["UNI"]: "0xEf740bf23aCaE26f6492B10de645D6B98dC8Eaf3",
31
+ ["TEMPO"]: "0xa2dc7d0266f0cc50b3eeaf36c9bfcecff1beea91",
32
+ ["MONAD"]: "0x0d97dc33264bfc1c226207428a79b26757fb9dc3",
33
+ };
34
+ export const getQuote = generateGetQuote({
35
+ SUPPORT_CHAINS,
36
+ id: "uni",
37
+ dex: DEX_ENUM.UNI,
38
+ });
39
+ export const decodeCalldata = (tx) => {
40
+ return null;
41
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { WrapTokenAddressMap, DEX_SUPPORT_CHAINS, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST } from "./list";
2
2
  import { getQuote } from "./quote";
3
3
  import { DEX_ENUM } from "./consts";
4
- export { WrapTokenAddressMap, DEX_ENUM, DEX_SUPPORT_CHAINS, getQuote, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, };
4
+ import { UNI_NATIVE_TO_ADDRESSES } from "./dexs/uni";
5
+ export { WrapTokenAddressMap, DEX_ENUM, DEX_SUPPORT_CHAINS, getQuote, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, UNI_NATIVE_TO_ADDRESSES, };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { WrapTokenAddressMap, DEX_SUPPORT_CHAINS, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, } from "./list";
2
2
  import { getQuote } from "./quote";
3
3
  import { DEX_ENUM } from "./consts";
4
- export { WrapTokenAddressMap, DEX_ENUM, DEX_SUPPORT_CHAINS, getQuote, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, };
4
+ import { UNI_NATIVE_TO_ADDRESSES } from "./dexs/uni";
5
+ export { WrapTokenAddressMap, DEX_ENUM, DEX_SUPPORT_CHAINS, getQuote, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, UNI_NATIVE_TO_ADDRESSES, };
package/dist/list.d.ts CHANGED
@@ -37,6 +37,7 @@ export declare const DEX_SUPPORT_CHAINS: {
37
37
  "0xAPIV2": CHAINS_ENUM[];
38
38
  Magpie: CHAINS_ENUM[];
39
39
  Rabby: CHAINS_ENUM[];
40
+ Uniswap: CHAINS_ENUM[];
40
41
  };
41
42
  export declare const DEX_ROUTER_WHITELIST: {
42
43
  "1inch": {
@@ -176,6 +177,19 @@ export declare const DEX_ROUTER_WHITELIST: {
176
177
  Rabby: {
177
178
  ETH: string;
178
179
  };
180
+ Uniswap: {
181
+ [x: string]: string;
182
+ ETH: string;
183
+ OP: string;
184
+ BSC: string;
185
+ POLYGON: string;
186
+ ARBITRUM: string;
187
+ AVAX: string;
188
+ BASE: string;
189
+ BLAST: string;
190
+ CELO: string;
191
+ ERA: string;
192
+ };
179
193
  };
180
194
  export declare const DEX_SPENDER_WHITELIST: {
181
195
  "1inch": {
@@ -316,4 +330,17 @@ export declare const DEX_SPENDER_WHITELIST: {
316
330
  Rabby: {
317
331
  ETH: string;
318
332
  };
333
+ Uniswap: {
334
+ [x: string]: string;
335
+ ETH: string;
336
+ OP: string;
337
+ BSC: string;
338
+ POLYGON: string;
339
+ ARBITRUM: string;
340
+ AVAX: string;
341
+ BASE: string;
342
+ BLAST: string;
343
+ CELO: string;
344
+ ERA: string;
345
+ };
319
346
  };
package/dist/list.js CHANGED
@@ -10,6 +10,7 @@ import { SUPPORT_CHAINS as odosSupportChains } from "./dexs/odos";
10
10
  import { SUPPORT_CHAINS as zeroXV2SupportChains } from "./dexs/0xapi_v2";
11
11
  import { SUPPORT_CHAINS as magpieSupportChains } from "./dexs/magpie";
12
12
  import { SUPPORT_CHAINS as rabbySupportChains } from "./dexs/rabby";
13
+ import { SUPPORT_CHAINS as uniSupportChains } from "./dexs/uni";
13
14
  import { DEX_ENUM } from "./consts";
14
15
  export const WrapTokenAddressMap = {
15
16
  [CHAINS_ENUM.ETH]: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
@@ -64,6 +65,7 @@ export const DEX_SUPPORT_CHAINS = {
64
65
  [DEX_ENUM.ZEROXAPIV2]: zeroXV2SupportChains,
65
66
  [DEX_ENUM.MAGPIE]: magpieSupportChains,
66
67
  [DEX_ENUM.RABBY]: rabbySupportChains,
68
+ [DEX_ENUM.UNI]: uniSupportChains,
67
69
  };
68
70
  export const DEX_ROUTER_WHITELIST = {
69
71
  [DEX_ENUM.ONEINCH]: {
@@ -231,6 +233,21 @@ export const DEX_ROUTER_WHITELIST = {
231
233
  [DEX_ENUM.RABBY]: {
232
234
  [CHAINS_ENUM.ETH]: "0x7fd9cfeef127451918c688c49e9905e47da3e985",
233
235
  },
236
+ [DEX_ENUM.UNI]: {
237
+ [CHAINS_ENUM.ETH]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
238
+ [CHAINS_ENUM.OP]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
239
+ [CHAINS_ENUM.BSC]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
240
+ [CHAINS_ENUM.POLYGON]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
241
+ [CHAINS_ENUM.ARBITRUM]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
242
+ [CHAINS_ENUM.AVAX]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
243
+ [CHAINS_ENUM.BASE]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
244
+ [CHAINS_ENUM.BLAST]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
245
+ [CHAINS_ENUM.CELO]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
246
+ [CHAINS_ENUM.ERA]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
247
+ ["UNI"]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
248
+ ["TEMPO"]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
249
+ ["MONAD"]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
250
+ },
234
251
  };
235
252
  export const DEX_SPENDER_WHITELIST = {
236
253
  [DEX_ENUM.ONEINCH]: {
@@ -399,4 +416,19 @@ export const DEX_SPENDER_WHITELIST = {
399
416
  [DEX_ENUM.RABBY]: {
400
417
  [CHAINS_ENUM.ETH]: "0x7fd9cfeef127451918c688c49e9905e47da3e985",
401
418
  },
419
+ [DEX_ENUM.UNI]: {
420
+ [CHAINS_ENUM.ETH]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
421
+ [CHAINS_ENUM.OP]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
422
+ [CHAINS_ENUM.BSC]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
423
+ [CHAINS_ENUM.POLYGON]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
424
+ [CHAINS_ENUM.ARBITRUM]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
425
+ [CHAINS_ENUM.AVAX]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
426
+ [CHAINS_ENUM.BASE]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
427
+ [CHAINS_ENUM.BLAST]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
428
+ [CHAINS_ENUM.CELO]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
429
+ [CHAINS_ENUM.ERA]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
430
+ ["UNI"]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
431
+ ["TEMPO"]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
432
+ ["MONAD"]: "0x02E5be68D46DAc0B524905bfF209cf47EE6dB2a9",
433
+ },
402
434
  };
package/dist/quote.js CHANGED
@@ -13,13 +13,13 @@ import { getQuote as oneInchGetQuote, decodeCalldata as oneInchDecodeCalldata, }
13
13
  import { getQuote as zeroXGetQuote, decodeCalldata as zeroXDecodeCalldata, } from "./dexs/0xapi";
14
14
  import { getQuote as paraSwapGetQuote, decodeCalldata as paraSwapDecodeCalldata, } from "./dexs/paraswap";
15
15
  import { getQuote as openOceanGetQuote, decodeCalldata as openOceanDecodeCalldata, } from "./dexs/openocean";
16
- import { getQuote as uniswapGetQuote, decodeCalldata as uniswapDecodeCalldata, } from "./dexs/uniswap";
17
16
  import { getQuote as kyberswapGetQuote, decodeCalldata as kyberswapDecodeCalldata, } from "./dexs/kyberswap";
18
17
  import { getQuote as paraSwapV6GetQuote, decodeCalldata as paraSwapV6DecodeCalldata, } from "./dexs/paraswap_v6";
19
18
  import { getQuote as odosGetQuote, decodeCalldata as odosDecodeCalldata, } from "./dexs/odos";
20
19
  import { getQuote as zeroXV2GetQuote, decodeCalldata as zeroXV2DecodeCalldata, } from "./dexs/0xapi_v2";
21
20
  import { getQuote as magpieGetQuote, decodeCalldata as magpieDecodeCalldata, } from "./dexs/magpie";
22
21
  import { getQuote as rabbyGetQuote, decodeCalldata as rabbyDecodeCalldata, } from "./dexs/rabby";
22
+ import { getQuote as uniGetQuote, decodeCalldata as uniDecodeCalldata, } from "./dexs/uni";
23
23
  export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, function* () {
24
24
  switch (id) {
25
25
  case DEX_ENUM.WRAPTOKEN:
@@ -32,8 +32,6 @@ export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, f
32
32
  return yield zeroXGetQuote(params, api);
33
33
  case DEX_ENUM.OPENOCEAN:
34
34
  return yield openOceanGetQuote(params, api);
35
- case DEX_ENUM.UNISWAP:
36
- return yield uniswapGetQuote(params, api);
37
35
  case DEX_ENUM.KYBERSWAP:
38
36
  return yield kyberswapGetQuote(params, api);
39
37
  case DEX_ENUM.PARASWAPV6:
@@ -46,6 +44,8 @@ export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, f
46
44
  return yield magpieGetQuote(params, api);
47
45
  case DEX_ENUM.RABBY:
48
46
  return yield rabbyGetQuote(params, api);
47
+ case DEX_ENUM.UNI:
48
+ return yield uniGetQuote(params, api);
49
49
  default:
50
50
  throw new Error(`${id} is not supported!`);
51
51
  }
@@ -60,8 +60,6 @@ export const decodeCalldata = (id, tx) => {
60
60
  return zeroXDecodeCalldata(tx);
61
61
  case DEX_ENUM.OPENOCEAN:
62
62
  return openOceanDecodeCalldata(tx);
63
- case DEX_ENUM.UNISWAP:
64
- return uniswapDecodeCalldata(tx);
65
63
  case DEX_ENUM.KYBERSWAP:
66
64
  return kyberswapDecodeCalldata(tx);
67
65
  case DEX_ENUM.PARASWAPV6:
@@ -74,6 +72,8 @@ export const decodeCalldata = (id, tx) => {
74
72
  return magpieDecodeCalldata(tx);
75
73
  case DEX_ENUM.RABBY:
76
74
  return rabbyDecodeCalldata(tx);
75
+ case DEX_ENUM.UNI:
76
+ return uniDecodeCalldata(tx);
77
77
  default:
78
78
  throw new Error(`${id} is not supported!`);
79
79
  }
package/dist/utils.d.ts CHANGED
@@ -5,6 +5,6 @@ import { DEX_ENUM } from "./consts";
5
5
  export declare const isSameAddress: (addr1: string, addr2: string) => boolean;
6
6
  export declare const generateGetQuote: ({ SUPPORT_CHAINS, id, dex, }: {
7
7
  SUPPORT_CHAINS: CHAINS_ENUM[];
8
- id: "uniswap3" | "matcha" | "matcha_v2" | "openocean" | "1inch_v6" | "paraswap" | "kyberswap" | "odos" | "paraswap_v6" | "magpie" | "rabby";
8
+ id: "matcha" | "matcha_v2" | "openocean" | "1inch_v6" | "paraswap" | "kyberswap" | "odos" | "paraswap_v6" | "magpie" | "rabby" | "uni";
9
9
  dex: DEX_ENUM;
10
10
  }) => (options: QuoteParams, api: OpenApiService) => Promise<QuoteResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-swap",
3
- "version": "0.0.74",
3
+ "version": "0.0.75-beta.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,64 +0,0 @@
1
- import { CHAINS } from "@debank/common";
2
- import { Interface } from "@ethersproject/abi";
3
- import { generateGetQuote } from "../utils";
4
- import { UniswapABI } from "../abi";
5
- import { DEX_ENUM } from "../consts";
6
- /**
7
- * @deprecated
8
- */
9
- export const SUPPORT_CHAINS = [
10
- // CHAINS_ENUM.ETH,
11
- // CHAINS_ENUM.POLYGON,
12
- // CHAINS_ENUM.OP,
13
- // CHAINS_ENUM.ARBITRUM,
14
- ];
15
- export const getQuote = generateGetQuote({
16
- SUPPORT_CHAINS,
17
- id: "uniswap3",
18
- dex: DEX_ENUM.UNISWAP,
19
- });
20
- export const decodeCalldata = (tx) => {
21
- var _a, _b, _c;
22
- const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
23
- if (!chain)
24
- return null;
25
- const contractInterface = new Interface(UniswapABI);
26
- const result = contractInterface.parseTransaction({ data: tx.data });
27
- if (result.name === "multicall" && ((_b = (_a = result === null || result === void 0 ? void 0 : result.args) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length) === 2) {
28
- const data = (_c = result === null || result === void 0 ? void 0 : result.args) === null || _c === void 0 ? void 0 : _c.data;
29
- if (data.startsWith("0x49404b7c")) {
30
- const result = decodeCalldataExactInput(data[0]);
31
- if (result) {
32
- return Object.assign(Object.assign({}, result), { toToken: chain.nativeTokenAddress });
33
- }
34
- }
35
- }
36
- return decodeCalldataExactInput(tx);
37
- };
38
- function decodeCalldataExactInput(tx) {
39
- const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
40
- if (!chain)
41
- return null;
42
- const contractInterface = new Interface(UniswapABI);
43
- const result = contractInterface.parseTransaction({ data: tx.data });
44
- if (result.name === "") {
45
- return null;
46
- }
47
- const [path, recipient, dstReceiver, amount, minReturnAmount] = result.args[0];
48
- let srcToken = "";
49
- let dstToken = "";
50
- if (!path) {
51
- return null;
52
- }
53
- srcToken = "0x" + path.slice(2, 42);
54
- dstToken = "0x" + path.slice(-40);
55
- if (!srcToken || !dstToken || !recipient || !amount || !minReturnAmount)
56
- return null;
57
- return {
58
- fromToken: srcToken,
59
- fromTokenAmount: amount.toString(),
60
- toToken: dstToken,
61
- minReceiveToTokenAmount: minReturnAmount.toString(),
62
- toTokenReceiver: dstReceiver,
63
- };
64
- }