@rabby-wallet/rabby-swap 0.0.43 → 0.0.45

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.
@@ -18,6 +18,7 @@ export const SUPPORT_CHAINS = [
18
18
  CHAINS_ENUM.LINEA,
19
19
  // CHAINS_ENUM.BTT,
20
20
  CHAINS_ENUM.BASE,
21
+ "SONIC",
21
22
  // No prev2 support
22
23
  // CHAINS_ENUM.ROSE,
23
24
  ];
@@ -18,6 +18,7 @@ const NATIVE_TOKENS = {
18
18
  [CHAINS_ENUM.KAVA]: "0x0000000000000000000000000000000000000000",
19
19
  [CHAINS_ENUM.METIS]: "0x0000000000000000000000000000000000000000",
20
20
  [CHAINS_ENUM.BASE]: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
21
+ ["SONIC"]: "0x0000000000000000000000000000000000000000",
21
22
  };
22
23
  export const SUPPORT_CHAINS = [
23
24
  CHAINS_ENUM.ETH,
@@ -29,6 +30,7 @@ export const SUPPORT_CHAINS = [
29
30
  CHAINS_ENUM.ARBITRUM,
30
31
  CHAINS_ENUM.CRO,
31
32
  CHAINS_ENUM.BASE,
33
+ "SONIC",
32
34
  /**
33
35
  * 接口返回 swap error
34
36
  */
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import abiCoder from "web3-eth-abi";
11
- import { CHAINS_ENUM, CHAINS } from "@debank/common";
11
+ import { CHAINS_ENUM } from "@debank/common";
12
12
  import { WrapTokenAddressMap } from "../list";
13
13
  import { isSameAddress } from "../utils";
14
14
  export const SUPPORT_CHAINS = [
@@ -33,16 +33,16 @@ export const SUPPORT_CHAINS = [
33
33
  CHAINS_ENUM.SCRL,
34
34
  CHAINS_ENUM.MODE,
35
35
  CHAINS_ENUM.MANTLE,
36
+ "SONIC",
36
37
  ];
37
38
  export const getQuote = (options) => __awaiter(void 0, void 0, void 0, function* () {
38
- const chain = CHAINS[options.chain];
39
- if (!SUPPORT_CHAINS.includes(options.chain)) {
40
- throw new Error(`${CHAINS[options.chain]} is not support on 1inch`);
39
+ if (!options.chainServerId || !options.nativeTokenAddress) {
40
+ throw new Error(`lack chainServerId or nativeTokenAddress is not support`);
41
41
  }
42
42
  const wrapTokenAddress = WrapTokenAddressMap[options.chain];
43
43
  let calldata = "";
44
44
  let value = "0";
45
- if (options.fromToken === chain.nativeTokenAddress &&
45
+ if (options.fromToken === options.nativeTokenAddress &&
46
46
  isSameAddress(options.toToken, wrapTokenAddress)) {
47
47
  calldata = abiCoder.encodeFunctionCall({
48
48
  constant: false,
package/dist/list.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { CHAINS_ENUM } from "@debank/common";
2
2
  export declare const WrapTokenAddressMap: {
3
+ [x: string]: string;
3
4
  ETH: string;
4
5
  BSC: string;
5
6
  POLYGON: string;
@@ -65,6 +66,7 @@ export declare const DEX_ROUTER_WHITELIST: {
65
66
  BASE: string;
66
67
  };
67
68
  OpenOcean: {
69
+ [x: string]: string;
68
70
  ETH: string;
69
71
  POLYGON: string;
70
72
  BSC: string;
@@ -81,6 +83,7 @@ export declare const DEX_ROUTER_WHITELIST: {
81
83
  BASE: string;
82
84
  };
83
85
  Kyberswap: {
86
+ [x: string]: string;
84
87
  ETH: string;
85
88
  POLYGON: string;
86
89
  OP: string;
@@ -168,6 +171,7 @@ export declare const DEX_SPENDER_WHITELIST: {
168
171
  BASE: string;
169
172
  };
170
173
  OpenOcean: {
174
+ [x: string]: string;
171
175
  ETH: string;
172
176
  POLYGON: string;
173
177
  BSC: string;
@@ -184,6 +188,7 @@ export declare const DEX_SPENDER_WHITELIST: {
184
188
  BASE: string;
185
189
  };
186
190
  Kyberswap: {
191
+ [x: string]: string;
187
192
  ETH: string;
188
193
  POLYGON: string;
189
194
  OP: string;
package/dist/list.js CHANGED
@@ -30,6 +30,7 @@ export const WrapTokenAddressMap = {
30
30
  [CHAINS_ENUM.SCRL]: "0x5300000000000000000000000000000000000004",
31
31
  [CHAINS_ENUM.MANTLE]: "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8",
32
32
  [CHAINS_ENUM.MODE]: "0x4200000000000000000000000000000000000006",
33
+ ["SONIC"]: "0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38",
33
34
  };
34
35
  export const DEX_SUPPORT_CHAINS = {
35
36
  [DEX_ENUM.WRAPTOKEN]: wrapTokenSupportChains,
@@ -92,6 +93,7 @@ export const DEX_ROUTER_WHITELIST = {
92
93
  [CHAINS_ENUM.KAVA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
93
94
  [CHAINS_ENUM.METIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
94
95
  [CHAINS_ENUM.BASE]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
96
+ ["SONIC"]: "0x6352a56caadc4f1e25cd6c75970fa768a3304e64",
95
97
  },
96
98
  [DEX_ENUM.KYBERSWAP]: {
97
99
  [CHAINS_ENUM.ETH]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
@@ -107,6 +109,7 @@ export const DEX_ROUTER_WHITELIST = {
107
109
  [CHAINS_ENUM.ROSE]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
108
110
  [CHAINS_ENUM.LINEA]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
109
111
  [CHAINS_ENUM.BASE]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
112
+ ["SONIC"]: "0x6131b5fae19ea4f9d964eac0408e4408b66337b5",
110
113
  },
111
114
  [DEX_ENUM.PARASWAPV6]: {
112
115
  [CHAINS_ENUM.ETH]: "0x6A000F20005980200259B80c5102003040001068",
@@ -195,6 +198,7 @@ export const DEX_SPENDER_WHITELIST = {
195
198
  [CHAINS_ENUM.KAVA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
196
199
  [CHAINS_ENUM.METIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
197
200
  [CHAINS_ENUM.BASE]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
201
+ ["SONIC"]: "0x6352a56caadc4f1e25cd6c75970fa768a3304e64",
198
202
  },
199
203
  [DEX_ENUM.KYBERSWAP]: {
200
204
  [CHAINS_ENUM.ETH]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
@@ -210,6 +214,7 @@ export const DEX_SPENDER_WHITELIST = {
210
214
  [CHAINS_ENUM.ROSE]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
211
215
  [CHAINS_ENUM.LINEA]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
212
216
  [CHAINS_ENUM.BASE]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
217
+ ["SONIC"]: "0x6131b5fae19ea4f9d964eac0408e4408b66337b5",
213
218
  },
214
219
  [DEX_ENUM.PARASWAPV6]: {
215
220
  [CHAINS_ENUM.ETH]: "0x6A000F20005980200259B80c5102003040001068",
package/dist/quote.d.ts CHANGED
@@ -11,8 +11,10 @@ export interface QuoteParams {
11
11
  feeRate?: number;
12
12
  feeAddress?: string;
13
13
  gasPrice?: number;
14
- chain: CHAINS_ENUM;
14
+ chain?: CHAINS_ENUM;
15
15
  fee?: boolean;
16
+ chainServerId: string;
17
+ nativeTokenAddress: string;
16
18
  }
17
19
  export interface Tx {
18
20
  from: string;
package/dist/utils.js CHANGED
@@ -7,7 +7,7 @@ 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 { CHAINS, CHAINS_ENUM } from "@debank/common";
10
+ import { CHAINS_ENUM } from "@debank/common";
11
11
  import { DEX_ENUM } from "./consts";
12
12
  import { DEX_SPENDER_WHITELIST } from "./list";
13
13
  export const isSameAddress = (addr1, addr2) => {
@@ -16,15 +16,15 @@ export const isSameAddress = (addr1, addr2) => {
16
16
  return addr1.toLowerCase() === addr2.toLowerCase();
17
17
  };
18
18
  export const generateGetQuote = ({ SUPPORT_CHAINS, id, dex, }) => (options, api) => __awaiter(void 0, void 0, void 0, function* () {
19
- if (!SUPPORT_CHAINS.includes(options.chain)) {
20
- throw new Error(`${CHAINS[options.chain]} is not support on ${dex}`);
19
+ if (!options.chainServerId || !options.nativeTokenAddress) {
20
+ throw new Error(`lack chainServerId or nativeTokenAddress is not support}`);
21
21
  }
22
22
  const params = {
23
23
  id: options.userAddress,
24
- chain_id: CHAINS[options.chain].serverId,
24
+ chain_id: options.chainServerId,
25
25
  dex_id: options.chain === CHAINS_ENUM.ETH
26
26
  ? id
27
- : `${CHAINS[options.chain].serverId}_${id}`,
27
+ : `${options.chainServerId}_${id}`,
28
28
  pay_token_id: options.fromToken,
29
29
  pay_token_raw_amount: options.amount,
30
30
  receive_token_id: options.toToken,
@@ -34,7 +34,7 @@ export const generateGetQuote = ({ SUPPORT_CHAINS, id, dex, }) => (options, api)
34
34
  params.fee = true;
35
35
  }
36
36
  const data = yield api.getSwapQuote(params);
37
- const isNativeToken = isSameAddress(data.pay_token.id, CHAINS[options.chain].nativeTokenAddress);
37
+ const isNativeToken = isSameAddress(data.pay_token.id, options.nativeTokenAddress);
38
38
  return {
39
39
  dexFeeDesc: data.dex_fee_desc,
40
40
  tx: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-swap",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {