@rabby-wallet/rabby-swap 0.0.26 → 0.0.27-alpha.0

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/consts.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { CHAINS_ENUM } from "@debank/common";
2
- export declare enum DEX_ENUM {
1
+ export declare const enum DEX_ENUM {
3
2
  ONEINCH = "1inch",
4
3
  PARASWAP = "ParaSwap",
5
4
  ZEROXAPI = "0xAPI",
@@ -7,132 +6,3 @@ export declare enum DEX_ENUM {
7
6
  OPENOCEAN = "OpenOcean",
8
7
  UNISWAP = "Uniswap"
9
8
  }
10
- export declare const WrapTokenAddressMap: {
11
- ETH: string;
12
- BSC: string;
13
- POLYGON: string;
14
- OP: string;
15
- FTM: string;
16
- AVAX: string;
17
- ARBITRUM: string;
18
- KLAY: string;
19
- GNOSIS: string;
20
- };
21
- export declare const DEX_SUPPORT_CHAINS: {
22
- WrapToken: CHAINS_ENUM[];
23
- "1inch": CHAINS_ENUM[];
24
- ParaSwap: CHAINS_ENUM[];
25
- "0xAPI": CHAINS_ENUM[];
26
- OpenOcean: CHAINS_ENUM[];
27
- Uniswap: CHAINS_ENUM[];
28
- };
29
- export declare const DEX_ROUTER_WHITELIST: {
30
- "1inch": {
31
- ETH: string;
32
- POLYGON: string;
33
- BSC: string;
34
- OP: string;
35
- FTM: string;
36
- AVAX: string;
37
- ARBITRUM: string;
38
- KLAY: string;
39
- GNOSIS: string;
40
- CELO: string;
41
- };
42
- ParaSwap: {
43
- ETH: string;
44
- POLYGON: string;
45
- BSC: string;
46
- AVAX: string;
47
- FTM: string;
48
- ARBITRUM: string;
49
- OP: string;
50
- };
51
- "0xAPI": {
52
- ETH: string;
53
- POLYGON: string;
54
- BSC: string;
55
- OP: string;
56
- FTM: string;
57
- CELO: string;
58
- AVAX: string;
59
- ARBITRUM: string;
60
- };
61
- OpenOcean: {
62
- ETH: string;
63
- POLYGON: string;
64
- BSC: string;
65
- OP: string;
66
- FTM: string;
67
- AVAX: string;
68
- ARBITRUM: string;
69
- CRO: string;
70
- GNOSIS: string;
71
- AURORA: string;
72
- BOBA: string;
73
- KAVA: string;
74
- METIS: string;
75
- };
76
- Uniswap: {
77
- ETH: string;
78
- POLYGON: string;
79
- BSC: string;
80
- OP: string;
81
- ARBITRUM: string;
82
- };
83
- };
84
- export declare const DEX_SPENDER_WHITELIST: {
85
- "1inch": {
86
- ETH: string;
87
- POLYGON: string;
88
- BSC: string;
89
- OP: string;
90
- FTM: string;
91
- AVAX: string;
92
- ARBITRUM: string;
93
- KLAY: string;
94
- GNOSIS: string;
95
- CELO: string;
96
- };
97
- ParaSwap: {
98
- ETH: string;
99
- POLYGON: string;
100
- BSC: string;
101
- AVAX: string;
102
- FTM: string;
103
- OP: string;
104
- ARBITRUM: string;
105
- };
106
- "0xAPI": {
107
- ETH: string;
108
- POLYGON: string;
109
- BSC: string;
110
- OP: string;
111
- FTM: string;
112
- CELO: string;
113
- AVAX: string;
114
- ARBITRUM: string;
115
- };
116
- OpenOcean: {
117
- ETH: string;
118
- POLYGON: string;
119
- BSC: string;
120
- OP: string;
121
- FTM: string;
122
- AVAX: string;
123
- ARBITRUM: string;
124
- CRO: string;
125
- GNOSIS: string;
126
- AURORA: string;
127
- BOBA: string;
128
- KAVA: string;
129
- METIS: string;
130
- };
131
- Uniswap: {
132
- ETH: string;
133
- POLYGON: string;
134
- BSC: string;
135
- OP: string;
136
- ARBITRUM: string;
137
- };
138
- };
package/dist/consts.js CHANGED
@@ -1,145 +1 @@
1
- import { CHAINS_ENUM } from "@debank/common";
2
- import { SUPPORT_CHAINS as wrapTokenSupportChains } from "./dexs/wrapToken";
3
- import { SUPPORT_CHAINS as zeroXSupportChains } from "./dexs/0xapi";
4
- import { SUPPORT_CHAINS as oneInchSupportChains } from "./dexs/1inch";
5
- import { SUPPORT_CHAINS as paraswapSupportChains } from "./dexs/paraswap";
6
- import { SUPPORT_CHAINS as openOceanSupportChains } from "./dexs/openocean";
7
- import { SUPPORT_CHAINS as uniswapSupportChains } from "./dexs/uniswap";
8
- export var DEX_ENUM;
9
- (function (DEX_ENUM) {
10
- DEX_ENUM["ONEINCH"] = "1inch";
11
- DEX_ENUM["PARASWAP"] = "ParaSwap";
12
- DEX_ENUM["ZEROXAPI"] = "0xAPI";
13
- DEX_ENUM["WRAPTOKEN"] = "WrapToken";
14
- DEX_ENUM["OPENOCEAN"] = "OpenOcean";
15
- DEX_ENUM["UNISWAP"] = "Uniswap";
16
- })(DEX_ENUM || (DEX_ENUM = {}));
17
- export const WrapTokenAddressMap = {
18
- [CHAINS_ENUM.ETH]: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
19
- [CHAINS_ENUM.BSC]: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
20
- [CHAINS_ENUM.POLYGON]: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
21
- [CHAINS_ENUM.OP]: "0x4200000000000000000000000000000000000006",
22
- [CHAINS_ENUM.FTM]: "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83",
23
- [CHAINS_ENUM.AVAX]: "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
24
- [CHAINS_ENUM.ARBITRUM]: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
25
- [CHAINS_ENUM.KLAY]: "0xe4f05a66ec68b54a58b17c22107b02e0232cc817",
26
- [CHAINS_ENUM.GNOSIS]: "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d",
27
- };
28
- export const DEX_SUPPORT_CHAINS = {
29
- [DEX_ENUM.WRAPTOKEN]: wrapTokenSupportChains,
30
- [DEX_ENUM.ONEINCH]: oneInchSupportChains,
31
- [DEX_ENUM.PARASWAP]: paraswapSupportChains,
32
- [DEX_ENUM.ZEROXAPI]: zeroXSupportChains,
33
- [DEX_ENUM.OPENOCEAN]: openOceanSupportChains,
34
- [DEX_ENUM.UNISWAP]: uniswapSupportChains,
35
- };
36
- export const DEX_ROUTER_WHITELIST = {
37
- [DEX_ENUM.ONEINCH]: {
38
- [CHAINS_ENUM.ETH]: "0x1111111254eeb25477b68fb85ed929f73a960582",
39
- [CHAINS_ENUM.POLYGON]: "0x1111111254eeb25477b68fb85ed929f73a960582",
40
- [CHAINS_ENUM.BSC]: "0x1111111254eeb25477b68fb85ed929f73a960582",
41
- [CHAINS_ENUM.OP]: "0x1111111254eeb25477b68fb85ed929f73a960582",
42
- [CHAINS_ENUM.FTM]: "0x1111111254eeb25477b68fb85ed929f73a960582",
43
- [CHAINS_ENUM.AVAX]: "0x1111111254eeb25477b68fb85ed929f73a960582",
44
- [CHAINS_ENUM.ARBITRUM]: "0x1111111254eeb25477b68fb85ed929f73a960582",
45
- [CHAINS_ENUM.KLAY]: "0x1111111254eeb25477b68fb85ed929f73a960582",
46
- [CHAINS_ENUM.GNOSIS]: "0x1111111254eeb25477b68fb85ed929f73a960582",
47
- [CHAINS_ENUM.CELO]: "0x1111111254eeb25477b68fb85ed929f73a960582",
48
- },
49
- [DEX_ENUM.PARASWAP]: {
50
- [CHAINS_ENUM.ETH]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
51
- [CHAINS_ENUM.POLYGON]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
52
- [CHAINS_ENUM.BSC]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
53
- [CHAINS_ENUM.AVAX]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
54
- [CHAINS_ENUM.FTM]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
55
- [CHAINS_ENUM.ARBITRUM]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
56
- [CHAINS_ENUM.OP]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
57
- },
58
- [DEX_ENUM.ZEROXAPI]: {
59
- [CHAINS_ENUM.ETH]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
60
- [CHAINS_ENUM.POLYGON]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
61
- [CHAINS_ENUM.BSC]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
62
- [CHAINS_ENUM.OP]: "0xdef1abe32c034e558cdd535791643c58a13acc10",
63
- [CHAINS_ENUM.FTM]: "0xdef189deaef76e379df891899eb5a00a94cbc250",
64
- [CHAINS_ENUM.CELO]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
65
- [CHAINS_ENUM.AVAX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
66
- [CHAINS_ENUM.ARBITRUM]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
67
- },
68
- [DEX_ENUM.OPENOCEAN]: {
69
- [CHAINS_ENUM.ETH]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
70
- [CHAINS_ENUM.POLYGON]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
71
- [CHAINS_ENUM.BSC]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
72
- [CHAINS_ENUM.OP]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
73
- [CHAINS_ENUM.FTM]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
74
- [CHAINS_ENUM.AVAX]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
75
- [CHAINS_ENUM.ARBITRUM]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
76
- [CHAINS_ENUM.CRO]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
77
- [CHAINS_ENUM.GNOSIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
78
- [CHAINS_ENUM.AURORA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
79
- [CHAINS_ENUM.BOBA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
80
- [CHAINS_ENUM.KAVA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
81
- [CHAINS_ENUM.METIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
82
- },
83
- [DEX_ENUM.UNISWAP]: {
84
- [CHAINS_ENUM.ETH]: "0xe592427a0aece92de3edee1f18e0157c05861564",
85
- [CHAINS_ENUM.POLYGON]: "0xe592427a0aece92de3edee1f18e0157c05861564",
86
- [CHAINS_ENUM.BSC]: "0xe592427a0aece92de3edee1f18e0157c05861564",
87
- [CHAINS_ENUM.OP]: "0xe592427a0aece92de3edee1f18e0157c05861564",
88
- [CHAINS_ENUM.ARBITRUM]: "0xe592427a0aece92de3edee1f18e0157c05861564",
89
- },
90
- };
91
- export const DEX_SPENDER_WHITELIST = {
92
- [DEX_ENUM.ONEINCH]: {
93
- [CHAINS_ENUM.ETH]: "0x1111111254eeb25477b68fb85ed929f73a960582",
94
- [CHAINS_ENUM.POLYGON]: "0x1111111254eeb25477b68fb85ed929f73a960582",
95
- [CHAINS_ENUM.BSC]: "0x1111111254eeb25477b68fb85ed929f73a960582",
96
- [CHAINS_ENUM.OP]: "0x1111111254eeb25477b68fb85ed929f73a960582",
97
- [CHAINS_ENUM.FTM]: "0x1111111254eeb25477b68fb85ed929f73a960582",
98
- [CHAINS_ENUM.AVAX]: "0x1111111254eeb25477b68fb85ed929f73a960582",
99
- [CHAINS_ENUM.ARBITRUM]: "0x1111111254eeb25477b68fb85ed929f73a960582",
100
- [CHAINS_ENUM.KLAY]: "0x1111111254eeb25477b68fb85ed929f73a960582",
101
- [CHAINS_ENUM.GNOSIS]: "0x1111111254eeb25477b68fb85ed929f73a960582",
102
- [CHAINS_ENUM.CELO]: "0x1111111254eeb25477b68fb85ed929f73a960582",
103
- },
104
- [DEX_ENUM.PARASWAP]: {
105
- [CHAINS_ENUM.ETH]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
106
- [CHAINS_ENUM.POLYGON]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
107
- [CHAINS_ENUM.BSC]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
108
- [CHAINS_ENUM.AVAX]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
109
- [CHAINS_ENUM.FTM]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
110
- [CHAINS_ENUM.OP]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
111
- [CHAINS_ENUM.ARBITRUM]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
112
- },
113
- [DEX_ENUM.ZEROXAPI]: {
114
- [CHAINS_ENUM.ETH]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
115
- [CHAINS_ENUM.POLYGON]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
116
- [CHAINS_ENUM.BSC]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
117
- [CHAINS_ENUM.OP]: "0xdef1abe32c034e558cdd535791643c58a13acc10",
118
- [CHAINS_ENUM.FTM]: "0xdef189deaef76e379df891899eb5a00a94cbc250",
119
- [CHAINS_ENUM.CELO]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
120
- [CHAINS_ENUM.AVAX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
121
- [CHAINS_ENUM.ARBITRUM]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
122
- },
123
- [DEX_ENUM.OPENOCEAN]: {
124
- [CHAINS_ENUM.ETH]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
125
- [CHAINS_ENUM.POLYGON]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
126
- [CHAINS_ENUM.BSC]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
127
- [CHAINS_ENUM.OP]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
128
- [CHAINS_ENUM.FTM]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
129
- [CHAINS_ENUM.AVAX]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
130
- [CHAINS_ENUM.ARBITRUM]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
131
- [CHAINS_ENUM.CRO]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
132
- [CHAINS_ENUM.GNOSIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
133
- [CHAINS_ENUM.AURORA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
134
- [CHAINS_ENUM.BOBA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
135
- [CHAINS_ENUM.KAVA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
136
- [CHAINS_ENUM.METIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
137
- },
138
- [DEX_ENUM.UNISWAP]: {
139
- [CHAINS_ENUM.ETH]: "0xe592427a0aece92de3edee1f18e0157c05861564",
140
- [CHAINS_ENUM.POLYGON]: "0xe592427a0aece92de3edee1f18e0157c05861564",
141
- [CHAINS_ENUM.BSC]: "0xe592427a0aece92de3edee1f18e0157c05861564",
142
- [CHAINS_ENUM.OP]: "0xe592427a0aece92de3edee1f18e0157c05861564",
143
- [CHAINS_ENUM.ARBITRUM]: "0xe592427a0aece92de3edee1f18e0157c05861564",
144
- },
145
- };
1
+ export {};
@@ -16,7 +16,7 @@ export const SUPPORT_CHAINS = [
16
16
  export const getQuote = generateGetQuote({
17
17
  SUPPORT_CHAINS,
18
18
  id: "matcha",
19
- dex: "0x",
19
+ dex: "0xAPI" /* DEX_ENUM.ZEROXAPI */,
20
20
  });
21
21
  export const decodeCalldata = (tx) => {
22
22
  const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
@@ -1,5 +1,5 @@
1
1
  import { CHAINS_ENUM } from "@debank/common";
2
- import { QuoteParams, QuoteResult, TxWithChainId, DecodeCalldataResult } from "../quote";
2
+ import { TxWithChainId, DecodeCalldataResult } from "../quote";
3
3
  export declare const SUPPORT_CHAINS: CHAINS_ENUM[];
4
- export declare const getQuote: (options: QuoteParams) => Promise<QuoteResult>;
4
+ export declare const getQuote: (options: import("../quote").QuoteParams, api: import("@rabby-wallet/rabby-api").OpenApiService) => Promise<import("../quote").QuoteResult>;
5
5
  export declare const decodeCalldata: (tx: TxWithChainId) => DecodeCalldataResult | null;
@@ -1,40 +1,8 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import axios from "axios";
11
1
  import { CHAINS_ENUM, CHAINS } from "@debank/common";
12
2
  import { Interface } from "@ethersproject/abi";
13
- import { isSameAddress } from "../utils";
3
+ import { generateGetQuote, isSameAddress } from "../utils";
14
4
  import { OneInchABI } from "../abi";
15
5
  const NATIVE_TOKEN = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
16
- const request = axios.create({
17
- baseURL: "https://api-rabby.1inch.io/v5.0",
18
- });
19
- request.interceptors.response.use((response) => {
20
- var _a, _b, _c;
21
- const code = (_a = response.data) === null || _a === void 0 ? void 0 : _a.statusCode;
22
- const msg = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.description) || ((_c = response.data) === null || _c === void 0 ? void 0 : _c.error);
23
- if (code && code !== 200) {
24
- if (msg) {
25
- let err;
26
- try {
27
- err = new Error(JSON.parse(msg));
28
- }
29
- catch (e) {
30
- err = new Error(msg);
31
- }
32
- throw err;
33
- }
34
- throw new Error(response.data);
35
- }
36
- return response;
37
- });
38
6
  export const SUPPORT_CHAINS = [
39
7
  CHAINS_ENUM.ETH,
40
8
  CHAINS_ENUM.POLYGON,
@@ -46,45 +14,10 @@ export const SUPPORT_CHAINS = [
46
14
  CHAINS_ENUM.KLAY,
47
15
  CHAINS_ENUM.GNOSIS,
48
16
  ];
49
- export const getQuote = (options) => __awaiter(void 0, void 0, void 0, function* () {
50
- const chainId = CHAINS[options.chain].id;
51
- if (!SUPPORT_CHAINS.includes(options.chain)) {
52
- throw new Error(`${CHAINS[options.chain]} is not support on 1inch`);
53
- }
54
- const params = {
55
- fromTokenAddress: options.fromToken === CHAINS[options.chain].nativeTokenAddress
56
- ? NATIVE_TOKEN
57
- : options.fromToken,
58
- toTokenAddress: options.toToken === CHAINS[options.chain].nativeTokenAddress
59
- ? NATIVE_TOKEN
60
- : options.toToken,
61
- amount: options.amount,
62
- fromAddress: options.userAddress,
63
- slippage: options.slippage,
64
- disableEstimate: true,
65
- };
66
- if (options.feeRate !== null && options.feeRate !== undefined) {
67
- params.fee = options.feeRate;
68
- params.referrerAddress = options.feeAddress;
69
- }
70
- const { data } = yield request.get(`/${chainId}/swap`, {
71
- params,
72
- });
73
- return {
74
- tx: Object.assign(Object.assign({}, data.tx), { data: `${data.tx.data}5257` // add specific 4 bytes for identify rabby swap
75
- }),
76
- fromToken: data.fromToken.address === NATIVE_TOKEN
77
- ? CHAINS[options.chain].nativeTokenAddress
78
- : data.fromToken.address,
79
- fromTokenAmount: data.fromTokenAmount,
80
- fromTokenDecimals: data.fromToken.decimals,
81
- toToken: data.toToken.address === NATIVE_TOKEN
82
- ? CHAINS[options.chain].nativeTokenAddress
83
- : data.toToken.address,
84
- toTokenAmount: data.toTokenAmount,
85
- toTokenDecimals: data.toToken.decimals,
86
- spender: data.tx.to,
87
- };
17
+ export const getQuote = generateGetQuote({
18
+ SUPPORT_CHAINS,
19
+ id: "1inch",
20
+ dex: "1inch" /* DEX_ENUM.ONEINCH */,
88
21
  });
89
22
  export const decodeCalldata = (tx) => {
90
23
  const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
@@ -1,5 +1,5 @@
1
1
  import { CHAINS_ENUM } from "@debank/common";
2
- import { QuoteParams, QuoteResult, TxWithChainId, DecodeCalldataResult } from "../quote";
2
+ import { TxWithChainId, DecodeCalldataResult } from "../quote";
3
3
  export declare const SUPPORT_CHAINS: CHAINS_ENUM[];
4
- export declare const getQuote: (options: QuoteParams) => Promise<QuoteResult>;
4
+ export declare const getQuote: (options: import("../quote").QuoteParams, api: import("@rabby-wallet/rabby-api").OpenApiService) => Promise<import("../quote").QuoteResult>;
5
5
  export declare const decodeCalldata: (tx: TxWithChainId) => DecodeCalldataResult | null;
@@ -1,17 +1,6 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import axios from "axios";
11
1
  import { Interface } from "@ethersproject/abi";
12
2
  import { CHAINS_ENUM, CHAINS } from "@debank/common";
13
- import BigNumber from "bignumber.js";
14
- import { isSameAddress } from "../utils";
3
+ import { generateGetQuote, isSameAddress } from "../utils";
15
4
  import { OpenOceanABI } from "../abi";
16
5
  const NATIVE_TOKENS = {
17
6
  [CHAINS_ENUM.ETH]: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
@@ -28,21 +17,6 @@ const NATIVE_TOKENS = {
28
17
  [CHAINS_ENUM.KAVA]: "0x0000000000000000000000000000000000000000",
29
18
  [CHAINS_ENUM.METIS]: "0x0000000000000000000000000000000000000000",
30
19
  };
31
- const chainCode = {
32
- [CHAINS_ENUM.ETH]: "eth",
33
- [CHAINS_ENUM.POLYGON]: "polygon",
34
- [CHAINS_ENUM.BSC]: "bsc",
35
- [CHAINS_ENUM.OP]: "optimism",
36
- [CHAINS_ENUM.FTM]: "fantom",
37
- [CHAINS_ENUM.AVAX]: "avax",
38
- [CHAINS_ENUM.ARBITRUM]: "arbitrum",
39
- [CHAINS_ENUM.CRO]: "cronos",
40
- [CHAINS_ENUM.GNOSIS]: "xdai",
41
- [CHAINS_ENUM.AURORA]: "aurora",
42
- [CHAINS_ENUM.BOBA]: "boba",
43
- [CHAINS_ENUM.KAVA]: "kava",
44
- [CHAINS_ENUM.METIS]: "metis",
45
- };
46
20
  export const SUPPORT_CHAINS = [
47
21
  CHAINS_ENUM.ETH,
48
22
  CHAINS_ENUM.POLYGON,
@@ -67,77 +41,10 @@ export const SUPPORT_CHAINS = [
67
41
  // CHAINS_ENUM.BOBA,
68
42
  // CHAINS_ENUM.KAVA, //pre api v1
69
43
  ];
70
- export const getQuote = (options) => __awaiter(void 0, void 0, void 0, function* () {
71
- if (!SUPPORT_CHAINS.includes(options.chain)) {
72
- throw new Error(`${CHAINS[options.chain]} is not support on OpenOcean`);
73
- }
74
- const swapChainCode = chainCode[options.chain];
75
- const baseURL = `https://open-api.openocean.finance/v3/${swapChainCode}`;
76
- const request = axios.create({
77
- baseURL,
78
- });
79
- request.interceptors.response.use((response) => {
80
- var _a, _b;
81
- const code = (_a = response.data) === null || _a === void 0 ? void 0 : _a.code;
82
- const msg = (_b = response.data) === null || _b === void 0 ? void 0 : _b.reason;
83
- if (code === 200)
84
- return response.data;
85
- if (code && code !== 200) {
86
- if (msg) {
87
- let err;
88
- try {
89
- err = new Error(JSON.parse(msg));
90
- }
91
- catch (e) {
92
- err = new Error(msg);
93
- }
94
- throw err;
95
- }
96
- throw new Error(response.data);
97
- }
98
- return response;
99
- });
100
- const NATIVE_TOKEN = NATIVE_TOKENS[options.chain];
101
- const params = {
102
- inTokenAddress: options.fromToken === CHAINS[options.chain].nativeTokenAddress
103
- ? NATIVE_TOKEN
104
- : options.fromToken,
105
- outTokenAddress: options.toToken === CHAINS[options.chain].nativeTokenAddress
106
- ? NATIVE_TOKEN
107
- : options.toToken,
108
- amount: new BigNumber(options.amount)
109
- .div(10 ** options.fromTokenDecimals)
110
- .toFixed(),
111
- slippage: options.slippage,
112
- gasPrice: options.gasPrice || 1,
113
- account: options.userAddress,
114
- };
115
- if (options.feeAddress) {
116
- params.referrer = options.feeAddress;
117
- }
118
- if (options.feeRate !== null && options.feeRate !== undefined) {
119
- params.referrerFee = options.feeRate;
120
- }
121
- const { data } = yield request.get("/swap_quote", {
122
- params,
123
- });
124
- return {
125
- tx: {
126
- data: data.data,
127
- to: data.to,
128
- value: data.value,
129
- from: data.from,
130
- },
131
- fromToken: isSameAddress(data.inToken.address, NATIVE_TOKEN)
132
- ? CHAINS[options.chain].nativeTokenAddress
133
- : data.inToken.address,
134
- spender: data.to,
135
- fromTokenAmount: data.inAmount,
136
- toToken: isSameAddress(data.outToken.address, NATIVE_TOKEN)
137
- ? CHAINS[options.chain].nativeTokenAddress
138
- : data.outToken.address,
139
- toTokenAmount: data.outAmount,
140
- };
44
+ export const getQuote = generateGetQuote({
45
+ SUPPORT_CHAINS,
46
+ id: "openocean",
47
+ dex: "OpenOcean" /* DEX_ENUM.OPENOCEAN */,
141
48
  });
142
49
  export const decodeCalldata = (tx) => {
143
50
  const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
@@ -1,5 +1,5 @@
1
1
  import { CHAINS_ENUM } from "@debank/common";
2
- import { QuoteParams, QuoteResult, TxWithChainId, DecodeCalldataResult } from "../quote";
2
+ import { TxWithChainId, DecodeCalldataResult } from "../quote";
3
3
  export declare const SUPPORT_CHAINS: CHAINS_ENUM[];
4
- export declare const getQuote: (options: QuoteParams) => Promise<QuoteResult>;
4
+ export declare const getQuote: (options: import("../quote").QuoteParams, api: import("@rabby-wallet/rabby-api").OpenApiService) => Promise<import("../quote").QuoteResult>;
5
5
  export declare const decodeCalldata: (tx: TxWithChainId) => DecodeCalldataResult | null;
@@ -1,41 +1,8 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import axios from "axios";
11
1
  import { Interface } from "@ethersproject/abi";
12
2
  import { CHAINS_ENUM, CHAINS } from "@debank/common";
13
- import { isSameAddress } from "../utils";
3
+ import { generateGetQuote, isSameAddress } from "../utils";
14
4
  import { ParaSwapABI } from "../abi";
15
- import { DEX_ENUM, DEX_SPENDER_WHITELIST } from "../consts";
16
5
  const NATIVE_TOKEN = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
17
- const request = axios.create({
18
- baseURL: "https://apiv5.paraswap.io",
19
- });
20
- request.interceptors.response.use((response) => {
21
- var _a, _b, _c;
22
- const code = (_a = response.data) === null || _a === void 0 ? void 0 : _a.statusCode;
23
- const msg = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.description) || ((_c = response.data) === null || _c === void 0 ? void 0 : _c.error);
24
- if (code && code !== 200) {
25
- if (msg) {
26
- let err;
27
- try {
28
- err = new Error(JSON.parse(msg));
29
- }
30
- catch (e) {
31
- err = new Error(msg);
32
- }
33
- throw err;
34
- }
35
- throw new Error(response.data);
36
- }
37
- return response;
38
- });
39
6
  export const SUPPORT_CHAINS = [
40
7
  CHAINS_ENUM.ETH,
41
8
  CHAINS_ENUM.POLYGON,
@@ -45,71 +12,10 @@ export const SUPPORT_CHAINS = [
45
12
  CHAINS_ENUM.ARBITRUM,
46
13
  CHAINS_ENUM.FTM,
47
14
  ];
48
- const getPriceRoute = (params) => __awaiter(void 0, void 0, void 0, function* () {
49
- const { data } = yield request.get("/prices", {
50
- params,
51
- });
52
- return data;
53
- });
54
- export const getQuote = (options) => __awaiter(void 0, void 0, void 0, function* () {
55
- const chainId = CHAINS[options.chain].id;
56
- if (!SUPPORT_CHAINS.includes(options.chain)) {
57
- throw new Error(`${CHAINS[options.chain]} is not support on 1inch`);
58
- }
59
- const { priceRoute } = yield getPriceRoute({
60
- srcDecimals: options.fromTokenDecimals,
61
- srcToken: options.fromToken === CHAINS[options.chain].nativeTokenAddress
62
- ? NATIVE_TOKEN
63
- : options.fromToken,
64
- destToken: options.toToken === CHAINS[options.chain].nativeTokenAddress
65
- ? NATIVE_TOKEN
66
- : options.toToken,
67
- amount: options.amount,
68
- userAddress: options.userAddress,
69
- network: chainId,
70
- includeContractMethods: "simpleSwap,multiSwap,megaSwap",
71
- excludeDEXS: "ParaSwapPool,ParaSwapLimitOrders,Hashflow",
72
- partner: "Rabby",
73
- });
74
- const params = {
75
- srcToken: options.fromToken === CHAINS[options.chain].nativeTokenAddress
76
- ? NATIVE_TOKEN
77
- : options.fromToken,
78
- srcDecimals: options.fromTokenDecimals,
79
- destToken: options.toToken === CHAINS[options.chain].nativeTokenAddress
80
- ? NATIVE_TOKEN
81
- : options.toToken,
82
- srcAmount: options.amount,
83
- userAddress: options.userAddress,
84
- slippage: Math.floor(options.slippage * 100),
85
- priceRoute: priceRoute,
86
- partner: "Rabby",
87
- deadline: Math.floor(Date.now() / 1000) + 21600,
88
- };
89
- if (options.feeRate !== null && options.feeRate !== undefined) {
90
- params.partnerFeeBps = (options.feeRate * 100).toString();
91
- params.partnerAddress = options.feeAddress;
92
- }
93
- const { data } = yield request.post(`/transactions/${chainId}`, params, {
94
- params: {
95
- ignoreChecks: true,
96
- ignoreGasEstimate: true,
97
- },
98
- });
99
- return {
100
- tx: data,
101
- fromToken: priceRoute.srcToken === NATIVE_TOKEN
102
- ? CHAINS[options.chain].nativeTokenAddress
103
- : priceRoute.srcToken,
104
- fromTokenAmount: priceRoute.srcAmount,
105
- fromTokenDecimals: priceRoute.srcDecimals,
106
- toToken: priceRoute.destToken === NATIVE_TOKEN
107
- ? CHAINS[options.chain].nativeTokenAddress
108
- : priceRoute.destToken,
109
- toTokenAmount: priceRoute.destAmount,
110
- toTokenDecimals: priceRoute.destDecimals,
111
- spender: DEX_SPENDER_WHITELIST[DEX_ENUM.PARASWAP][options.chain],
112
- };
15
+ export const getQuote = generateGetQuote({
16
+ SUPPORT_CHAINS,
17
+ id: "paraswap",
18
+ dex: "ParaSwap" /* DEX_ENUM.PARASWAP */,
113
19
  });
114
20
  export const decodeCalldata = (tx) => {
115
21
  const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
@@ -11,7 +11,7 @@ export const SUPPORT_CHAINS = [
11
11
  export const getQuote = generateGetQuote({
12
12
  SUPPORT_CHAINS,
13
13
  id: "uniswap3",
14
- dex: "Uniswap",
14
+ dex: "Uniswap" /* DEX_ENUM.UNISWAP */,
15
15
  });
16
16
  export const decodeCalldata = (tx) => {
17
17
  var _a, _b, _c;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import abiCoder from "web3-eth-abi";
11
11
  import { CHAINS_ENUM, CHAINS } from "@debank/common";
12
- import { WrapTokenAddressMap } from "../consts";
12
+ import { WrapTokenAddressMap } from "../list";
13
13
  import { isSameAddress } from "../utils";
14
14
  export const SUPPORT_CHAINS = [
15
15
  CHAINS_ENUM.ETH,
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import { WrapTokenAddressMap, DEX_ENUM, DEX_SUPPORT_CHAINS, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST } from "./consts";
1
+ import { WrapTokenAddressMap, DEX_SUPPORT_CHAINS, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST } from "./list";
2
2
  import { getQuote } from "./quote";
3
+ import { DEX_ENUM } from "./consts";
3
4
  export { WrapTokenAddressMap, DEX_ENUM, DEX_SUPPORT_CHAINS, getQuote, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { WrapTokenAddressMap, DEX_ENUM, DEX_SUPPORT_CHAINS, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, } from "./consts";
1
+ import { WrapTokenAddressMap, DEX_SUPPORT_CHAINS, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, } from "./list";
2
2
  import { getQuote } from "./quote";
3
- export { WrapTokenAddressMap, DEX_ENUM, DEX_SUPPORT_CHAINS, getQuote, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, };
3
+ export { WrapTokenAddressMap, DEX_SUPPORT_CHAINS, getQuote, DEX_ROUTER_WHITELIST, DEX_SPENDER_WHITELIST, };
package/dist/list.d.ts ADDED
@@ -0,0 +1,130 @@
1
+ import { CHAINS_ENUM } from "@debank/common";
2
+ export declare const WrapTokenAddressMap: {
3
+ ETH: string;
4
+ BSC: string;
5
+ POLYGON: string;
6
+ OP: string;
7
+ FTM: string;
8
+ AVAX: string;
9
+ ARBITRUM: string;
10
+ KLAY: string;
11
+ GNOSIS: string;
12
+ };
13
+ export declare const DEX_SUPPORT_CHAINS: {
14
+ WrapToken: CHAINS_ENUM[];
15
+ "1inch": CHAINS_ENUM[];
16
+ ParaSwap: CHAINS_ENUM[];
17
+ "0xAPI": CHAINS_ENUM[];
18
+ OpenOcean: CHAINS_ENUM[];
19
+ Uniswap: CHAINS_ENUM[];
20
+ };
21
+ export declare const DEX_ROUTER_WHITELIST: {
22
+ "1inch": {
23
+ ETH: string;
24
+ POLYGON: string;
25
+ BSC: string;
26
+ OP: string;
27
+ FTM: string;
28
+ AVAX: string;
29
+ ARBITRUM: string;
30
+ KLAY: string;
31
+ GNOSIS: string;
32
+ CELO: string;
33
+ };
34
+ ParaSwap: {
35
+ ETH: string;
36
+ POLYGON: string;
37
+ BSC: string;
38
+ AVAX: string;
39
+ FTM: string;
40
+ ARBITRUM: string;
41
+ OP: string;
42
+ };
43
+ "0xAPI": {
44
+ ETH: string;
45
+ POLYGON: string;
46
+ BSC: string;
47
+ OP: string;
48
+ FTM: string;
49
+ CELO: string;
50
+ AVAX: string;
51
+ ARBITRUM: string;
52
+ };
53
+ OpenOcean: {
54
+ ETH: string;
55
+ POLYGON: string;
56
+ BSC: string;
57
+ OP: string;
58
+ FTM: string;
59
+ AVAX: string;
60
+ ARBITRUM: string;
61
+ CRO: string;
62
+ GNOSIS: string;
63
+ AURORA: string;
64
+ BOBA: string;
65
+ KAVA: string;
66
+ METIS: string;
67
+ };
68
+ Uniswap: {
69
+ ETH: string;
70
+ POLYGON: string;
71
+ BSC: string;
72
+ OP: string;
73
+ ARBITRUM: string;
74
+ };
75
+ };
76
+ export declare const DEX_SPENDER_WHITELIST: {
77
+ "1inch": {
78
+ ETH: string;
79
+ POLYGON: string;
80
+ BSC: string;
81
+ OP: string;
82
+ FTM: string;
83
+ AVAX: string;
84
+ ARBITRUM: string;
85
+ KLAY: string;
86
+ GNOSIS: string;
87
+ CELO: string;
88
+ };
89
+ ParaSwap: {
90
+ ETH: string;
91
+ POLYGON: string;
92
+ BSC: string;
93
+ AVAX: string;
94
+ FTM: string;
95
+ OP: string;
96
+ ARBITRUM: string;
97
+ };
98
+ "0xAPI": {
99
+ ETH: string;
100
+ POLYGON: string;
101
+ BSC: string;
102
+ OP: string;
103
+ FTM: string;
104
+ CELO: string;
105
+ AVAX: string;
106
+ ARBITRUM: string;
107
+ };
108
+ OpenOcean: {
109
+ ETH: string;
110
+ POLYGON: string;
111
+ BSC: string;
112
+ OP: string;
113
+ FTM: string;
114
+ AVAX: string;
115
+ ARBITRUM: string;
116
+ CRO: string;
117
+ GNOSIS: string;
118
+ AURORA: string;
119
+ BOBA: string;
120
+ KAVA: string;
121
+ METIS: string;
122
+ };
123
+ Uniswap: {
124
+ ETH: string;
125
+ POLYGON: string;
126
+ BSC: string;
127
+ OP: string;
128
+ ARBITRUM: string;
129
+ };
130
+ };
package/dist/list.js ADDED
@@ -0,0 +1,136 @@
1
+ import { CHAINS_ENUM } from "@debank/common";
2
+ import { SUPPORT_CHAINS as wrapTokenSupportChains } from "./dexs/wrapToken";
3
+ import { SUPPORT_CHAINS as zeroXSupportChains } from "./dexs/0xapi";
4
+ import { SUPPORT_CHAINS as oneInchSupportChains } from "./dexs/1inch";
5
+ import { SUPPORT_CHAINS as paraswapSupportChains } from "./dexs/paraswap";
6
+ import { SUPPORT_CHAINS as openOceanSupportChains } from "./dexs/openocean";
7
+ import { SUPPORT_CHAINS as uniswapSupportChains } from "./dexs/uniswap";
8
+ export const WrapTokenAddressMap = {
9
+ [CHAINS_ENUM.ETH]: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
10
+ [CHAINS_ENUM.BSC]: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
11
+ [CHAINS_ENUM.POLYGON]: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
12
+ [CHAINS_ENUM.OP]: "0x4200000000000000000000000000000000000006",
13
+ [CHAINS_ENUM.FTM]: "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83",
14
+ [CHAINS_ENUM.AVAX]: "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
15
+ [CHAINS_ENUM.ARBITRUM]: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
16
+ [CHAINS_ENUM.KLAY]: "0xe4f05a66ec68b54a58b17c22107b02e0232cc817",
17
+ [CHAINS_ENUM.GNOSIS]: "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d",
18
+ };
19
+ export const DEX_SUPPORT_CHAINS = {
20
+ ["WrapToken" /* DEX_ENUM.WRAPTOKEN */]: wrapTokenSupportChains,
21
+ ["1inch" /* DEX_ENUM.ONEINCH */]: oneInchSupportChains,
22
+ ["ParaSwap" /* DEX_ENUM.PARASWAP */]: paraswapSupportChains,
23
+ ["0xAPI" /* DEX_ENUM.ZEROXAPI */]: zeroXSupportChains,
24
+ ["OpenOcean" /* DEX_ENUM.OPENOCEAN */]: openOceanSupportChains,
25
+ ["Uniswap" /* DEX_ENUM.UNISWAP */]: uniswapSupportChains,
26
+ };
27
+ export const DEX_ROUTER_WHITELIST = {
28
+ ["1inch" /* DEX_ENUM.ONEINCH */]: {
29
+ [CHAINS_ENUM.ETH]: "0x1111111254eeb25477b68fb85ed929f73a960582",
30
+ [CHAINS_ENUM.POLYGON]: "0x1111111254eeb25477b68fb85ed929f73a960582",
31
+ [CHAINS_ENUM.BSC]: "0x1111111254eeb25477b68fb85ed929f73a960582",
32
+ [CHAINS_ENUM.OP]: "0x1111111254eeb25477b68fb85ed929f73a960582",
33
+ [CHAINS_ENUM.FTM]: "0x1111111254eeb25477b68fb85ed929f73a960582",
34
+ [CHAINS_ENUM.AVAX]: "0x1111111254eeb25477b68fb85ed929f73a960582",
35
+ [CHAINS_ENUM.ARBITRUM]: "0x1111111254eeb25477b68fb85ed929f73a960582",
36
+ [CHAINS_ENUM.KLAY]: "0x1111111254eeb25477b68fb85ed929f73a960582",
37
+ [CHAINS_ENUM.GNOSIS]: "0x1111111254eeb25477b68fb85ed929f73a960582",
38
+ [CHAINS_ENUM.CELO]: "0x1111111254eeb25477b68fb85ed929f73a960582",
39
+ },
40
+ ["ParaSwap" /* DEX_ENUM.PARASWAP */]: {
41
+ [CHAINS_ENUM.ETH]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
42
+ [CHAINS_ENUM.POLYGON]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
43
+ [CHAINS_ENUM.BSC]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
44
+ [CHAINS_ENUM.AVAX]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
45
+ [CHAINS_ENUM.FTM]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
46
+ [CHAINS_ENUM.ARBITRUM]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
47
+ [CHAINS_ENUM.OP]: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
48
+ },
49
+ ["0xAPI" /* DEX_ENUM.ZEROXAPI */]: {
50
+ [CHAINS_ENUM.ETH]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
51
+ [CHAINS_ENUM.POLYGON]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
52
+ [CHAINS_ENUM.BSC]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
53
+ [CHAINS_ENUM.OP]: "0xdef1abe32c034e558cdd535791643c58a13acc10",
54
+ [CHAINS_ENUM.FTM]: "0xdef189deaef76e379df891899eb5a00a94cbc250",
55
+ [CHAINS_ENUM.CELO]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
56
+ [CHAINS_ENUM.AVAX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
57
+ [CHAINS_ENUM.ARBITRUM]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
58
+ },
59
+ ["OpenOcean" /* DEX_ENUM.OPENOCEAN */]: {
60
+ [CHAINS_ENUM.ETH]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
61
+ [CHAINS_ENUM.POLYGON]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
62
+ [CHAINS_ENUM.BSC]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
63
+ [CHAINS_ENUM.OP]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
64
+ [CHAINS_ENUM.FTM]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
65
+ [CHAINS_ENUM.AVAX]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
66
+ [CHAINS_ENUM.ARBITRUM]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
67
+ [CHAINS_ENUM.CRO]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
68
+ [CHAINS_ENUM.GNOSIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
69
+ [CHAINS_ENUM.AURORA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
70
+ [CHAINS_ENUM.BOBA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
71
+ [CHAINS_ENUM.KAVA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
72
+ [CHAINS_ENUM.METIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
73
+ },
74
+ ["Uniswap" /* DEX_ENUM.UNISWAP */]: {
75
+ [CHAINS_ENUM.ETH]: "0xe592427a0aece92de3edee1f18e0157c05861564",
76
+ [CHAINS_ENUM.POLYGON]: "0xe592427a0aece92de3edee1f18e0157c05861564",
77
+ [CHAINS_ENUM.BSC]: "0xe592427a0aece92de3edee1f18e0157c05861564",
78
+ [CHAINS_ENUM.OP]: "0xe592427a0aece92de3edee1f18e0157c05861564",
79
+ [CHAINS_ENUM.ARBITRUM]: "0xe592427a0aece92de3edee1f18e0157c05861564",
80
+ },
81
+ };
82
+ export const DEX_SPENDER_WHITELIST = {
83
+ ["1inch" /* DEX_ENUM.ONEINCH */]: {
84
+ [CHAINS_ENUM.ETH]: "0x1111111254eeb25477b68fb85ed929f73a960582",
85
+ [CHAINS_ENUM.POLYGON]: "0x1111111254eeb25477b68fb85ed929f73a960582",
86
+ [CHAINS_ENUM.BSC]: "0x1111111254eeb25477b68fb85ed929f73a960582",
87
+ [CHAINS_ENUM.OP]: "0x1111111254eeb25477b68fb85ed929f73a960582",
88
+ [CHAINS_ENUM.FTM]: "0x1111111254eeb25477b68fb85ed929f73a960582",
89
+ [CHAINS_ENUM.AVAX]: "0x1111111254eeb25477b68fb85ed929f73a960582",
90
+ [CHAINS_ENUM.ARBITRUM]: "0x1111111254eeb25477b68fb85ed929f73a960582",
91
+ [CHAINS_ENUM.KLAY]: "0x1111111254eeb25477b68fb85ed929f73a960582",
92
+ [CHAINS_ENUM.GNOSIS]: "0x1111111254eeb25477b68fb85ed929f73a960582",
93
+ [CHAINS_ENUM.CELO]: "0x1111111254eeb25477b68fb85ed929f73a960582",
94
+ },
95
+ ["ParaSwap" /* DEX_ENUM.PARASWAP */]: {
96
+ [CHAINS_ENUM.ETH]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
97
+ [CHAINS_ENUM.POLYGON]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
98
+ [CHAINS_ENUM.BSC]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
99
+ [CHAINS_ENUM.AVAX]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
100
+ [CHAINS_ENUM.FTM]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
101
+ [CHAINS_ENUM.OP]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
102
+ [CHAINS_ENUM.ARBITRUM]: "0x216b4b4ba9f3e719726886d34a177484278bfcae",
103
+ },
104
+ ["0xAPI" /* DEX_ENUM.ZEROXAPI */]: {
105
+ [CHAINS_ENUM.ETH]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
106
+ [CHAINS_ENUM.POLYGON]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
107
+ [CHAINS_ENUM.BSC]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
108
+ [CHAINS_ENUM.OP]: "0xdef1abe32c034e558cdd535791643c58a13acc10",
109
+ [CHAINS_ENUM.FTM]: "0xdef189deaef76e379df891899eb5a00a94cbc250",
110
+ [CHAINS_ENUM.CELO]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
111
+ [CHAINS_ENUM.AVAX]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
112
+ [CHAINS_ENUM.ARBITRUM]: "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
113
+ },
114
+ ["OpenOcean" /* DEX_ENUM.OPENOCEAN */]: {
115
+ [CHAINS_ENUM.ETH]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
116
+ [CHAINS_ENUM.POLYGON]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
117
+ [CHAINS_ENUM.BSC]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
118
+ [CHAINS_ENUM.OP]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
119
+ [CHAINS_ENUM.FTM]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
120
+ [CHAINS_ENUM.AVAX]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
121
+ [CHAINS_ENUM.ARBITRUM]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
122
+ [CHAINS_ENUM.CRO]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
123
+ [CHAINS_ENUM.GNOSIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
124
+ [CHAINS_ENUM.AURORA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
125
+ [CHAINS_ENUM.BOBA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
126
+ [CHAINS_ENUM.KAVA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
127
+ [CHAINS_ENUM.METIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
128
+ },
129
+ ["Uniswap" /* DEX_ENUM.UNISWAP */]: {
130
+ [CHAINS_ENUM.ETH]: "0xe592427a0aece92de3edee1f18e0157c05861564",
131
+ [CHAINS_ENUM.POLYGON]: "0xe592427a0aece92de3edee1f18e0157c05861564",
132
+ [CHAINS_ENUM.BSC]: "0xe592427a0aece92de3edee1f18e0157c05861564",
133
+ [CHAINS_ENUM.OP]: "0xe592427a0aece92de3edee1f18e0157c05861564",
134
+ [CHAINS_ENUM.ARBITRUM]: "0xe592427a0aece92de3edee1f18e0157c05861564",
135
+ },
136
+ };
package/dist/quote.js CHANGED
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { DEX_ENUM } from "./consts";
11
10
  import { getQuote as wrapTokenGetQuote } from "./dexs/wrapToken";
12
11
  import { getQuote as oneInchGetQuote, decodeCalldata as oneInchDecodeCalldata, } from "./dexs/1inch";
13
12
  import { getQuote as zeroXGetQuote, decodeCalldata as zeroXDecodeCalldata, } from "./dexs/0xapi";
@@ -16,17 +15,17 @@ import { getQuote as openOceanGetQuote, decodeCalldata as openOceanDecodeCalldat
16
15
  import { getQuote as uniswapGetQuote, decodeCalldata as uniswapDecodeCalldata, } from "./dexs/uniswap";
17
16
  export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, function* () {
18
17
  switch (id) {
19
- case DEX_ENUM.WRAPTOKEN:
18
+ case "WrapToken" /* DEX_ENUM.WRAPTOKEN */:
20
19
  return yield wrapTokenGetQuote(params);
21
- case DEX_ENUM.ONEINCH:
22
- return yield oneInchGetQuote(params);
23
- case DEX_ENUM.PARASWAP:
24
- return yield paraSwapGetQuote(params);
25
- case DEX_ENUM.ZEROXAPI:
20
+ case "1inch" /* DEX_ENUM.ONEINCH */:
21
+ return yield oneInchGetQuote(params, api);
22
+ case "ParaSwap" /* DEX_ENUM.PARASWAP */:
23
+ return yield paraSwapGetQuote(params, api);
24
+ case "0xAPI" /* DEX_ENUM.ZEROXAPI */:
26
25
  return yield zeroXGetQuote(params, api);
27
- case DEX_ENUM.OPENOCEAN:
28
- return yield openOceanGetQuote(params);
29
- case DEX_ENUM.UNISWAP:
26
+ case "OpenOcean" /* DEX_ENUM.OPENOCEAN */:
27
+ return yield openOceanGetQuote(params, api);
28
+ case "Uniswap" /* DEX_ENUM.UNISWAP */:
30
29
  return yield uniswapGetQuote(params, api);
31
30
  default:
32
31
  throw new Error(`${id} is not supported!`);
@@ -34,15 +33,15 @@ export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, f
34
33
  });
35
34
  export const decodeCalldata = (id, tx) => {
36
35
  switch (id) {
37
- case DEX_ENUM.ONEINCH:
36
+ case "1inch" /* DEX_ENUM.ONEINCH */:
38
37
  return oneInchDecodeCalldata(tx);
39
- case DEX_ENUM.PARASWAP:
38
+ case "ParaSwap" /* DEX_ENUM.PARASWAP */:
40
39
  return paraSwapDecodeCalldata(tx);
41
- case DEX_ENUM.ZEROXAPI:
40
+ case "0xAPI" /* DEX_ENUM.ZEROXAPI */:
42
41
  return zeroXDecodeCalldata(tx);
43
- case DEX_ENUM.OPENOCEAN:
42
+ case "OpenOcean" /* DEX_ENUM.OPENOCEAN */:
44
43
  return openOceanDecodeCalldata(tx);
45
- case DEX_ENUM.UNISWAP:
44
+ case "Uniswap" /* DEX_ENUM.UNISWAP */:
46
45
  return uniswapDecodeCalldata(tx);
47
46
  default:
48
47
  throw new Error(`${id} is not supported!`);
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { OpenApiService } from "@rabby-wallet/rabby-api";
2
2
  import { CHAINS_ENUM } from "@debank/common";
3
3
  import { QuoteParams, QuoteResult } from "./quote";
4
+ import { DEX_ENUM } from "./consts";
4
5
  export declare const isSameAddress: (addr1: string, addr2: string) => boolean;
5
6
  export declare const generateGetQuote: ({ SUPPORT_CHAINS, id, dex, }: {
6
7
  SUPPORT_CHAINS: CHAINS_ENUM[];
7
- id: string;
8
- dex: string;
8
+ id: "uniswap3" | "matcha" | "openocean" | "1inch" | "paraswap";
9
+ dex: DEX_ENUM;
9
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.26",
3
+ "version": "0.0.27-alpha.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {