@rabby-wallet/rabby-swap 0.0.44 → 0.0.46-alpha.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/consts.d.ts CHANGED
@@ -8,5 +8,6 @@ export declare enum DEX_ENUM {
8
8
  KYBERSWAP = "Kyberswap",
9
9
  PARASWAPV6 = "ParaSwapV6",
10
10
  ODOS = "ODOS",
11
- ZEROXAPIV2 = "0xAPIV2"
11
+ ZEROXAPIV2 = "0xAPIV2",
12
+ MAGPIE = "Magpie"
12
13
  }
package/dist/consts.js CHANGED
@@ -10,4 +10,5 @@ export var DEX_ENUM;
10
10
  DEX_ENUM["PARASWAPV6"] = "ParaSwapV6";
11
11
  DEX_ENUM["ODOS"] = "ODOS";
12
12
  DEX_ENUM["ZEROXAPIV2"] = "0xAPIV2";
13
+ DEX_ENUM["MAGPIE"] = "Magpie";
13
14
  })(DEX_ENUM || (DEX_ENUM = {}));
@@ -0,0 +1,5 @@
1
+ import { CHAINS_ENUM } from "@debank/common";
2
+ import { TxWithChainId, DecodeCalldataResult } from "../quote";
3
+ export declare const SUPPORT_CHAINS: CHAINS_ENUM[];
4
+ export declare const getQuote: (options: import("../quote").QuoteParams, api: import("@rabby-wallet/rabby-api").OpenApiService) => Promise<import("../quote").QuoteResult>;
5
+ export declare const decodeCalldata: (tx: TxWithChainId) => DecodeCalldataResult | null;
@@ -0,0 +1,28 @@
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.ARBITRUM,
8
+ CHAINS_ENUM.BSC,
9
+ CHAINS_ENUM.AVAX,
10
+ CHAINS_ENUM.FTM,
11
+ CHAINS_ENUM.POLYGON,
12
+ CHAINS_ENUM.BASE,
13
+ CHAINS_ENUM.PZE,
14
+ "SONIC",
15
+ CHAINS_ENUM.BLAST,
16
+ CHAINS_ENUM.MANTA,
17
+ CHAINS_ENUM.METIS,
18
+ CHAINS_ENUM.SCRL,
19
+ CHAINS_ENUM.ERA,
20
+ ];
21
+ export const getQuote = generateGetQuote({
22
+ SUPPORT_CHAINS,
23
+ id: "magpie",
24
+ dex: DEX_ENUM.MAGPIE,
25
+ });
26
+ export const decodeCalldata = (tx) => {
27
+ return null;
28
+ };
@@ -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 = [
@@ -28,22 +28,24 @@ export const SUPPORT_CHAINS = [
28
28
  // CHAINS_ENUM.BTT,
29
29
  CHAINS_ENUM.BASE,
30
30
  CHAINS_ENUM.ERA,
31
- // CHAINS_ENUM.PZE,
31
+ CHAINS_ENUM.PZE,
32
32
  // CHAINS_ENUM.ROSE,
33
33
  CHAINS_ENUM.SCRL,
34
34
  CHAINS_ENUM.MODE,
35
35
  CHAINS_ENUM.MANTLE,
36
36
  "SONIC",
37
+ CHAINS_ENUM.BLAST,
38
+ CHAINS_ENUM.METIS,
39
+ CHAINS_ENUM.MANTA,
37
40
  ];
38
41
  export const getQuote = (options) => __awaiter(void 0, void 0, void 0, function* () {
39
- const chain = CHAINS[options.chain];
40
- if (!SUPPORT_CHAINS.includes(options.chain)) {
41
- throw new Error(`${CHAINS[options.chain]} is not support on 1inch`);
42
+ if (!options.chainServerId || !options.nativeTokenAddress) {
43
+ throw new Error(`lack chainServerId or nativeTokenAddress is not support`);
42
44
  }
43
45
  const wrapTokenAddress = WrapTokenAddressMap[options.chain];
44
46
  let calldata = "";
45
47
  let value = "0";
46
- if (options.fromToken === chain.nativeTokenAddress &&
48
+ if (options.fromToken === options.nativeTokenAddress &&
47
49
  isSameAddress(options.toToken, wrapTokenAddress)) {
48
50
  calldata = abiCoder.encodeFunctionCall({
49
51
  constant: false,
package/dist/list.d.ts CHANGED
@@ -15,9 +15,13 @@ export declare const WrapTokenAddressMap: {
15
15
  AURORA: string;
16
16
  BASE: string;
17
17
  ERA: string;
18
+ PZE: string;
18
19
  SCRL: string;
19
20
  MANTLE: string;
20
21
  MODE: string;
22
+ BLAST: string;
23
+ METIS: string;
24
+ MANTA: string;
21
25
  };
22
26
  export declare const DEX_SUPPORT_CHAINS: {
23
27
  WrapToken: CHAINS_ENUM[];
@@ -29,6 +33,7 @@ export declare const DEX_SUPPORT_CHAINS: {
29
33
  ParaSwapV6: CHAINS_ENUM[];
30
34
  ODOS: CHAINS_ENUM[];
31
35
  "0xAPIV2": CHAINS_ENUM[];
36
+ Magpie: CHAINS_ENUM[];
32
37
  };
33
38
  export declare const DEX_ROUTER_WHITELIST: {
34
39
  "1inch": {
@@ -133,6 +138,23 @@ export declare const DEX_ROUTER_WHITELIST: {
133
138
  BSC: string;
134
139
  AVAX: string;
135
140
  };
141
+ Magpie: {
142
+ [x: string]: string;
143
+ ETH: string;
144
+ OP: string;
145
+ ARBITRUM: string;
146
+ BSC: string;
147
+ AVAX: string;
148
+ FTM: string;
149
+ POLYGON: string;
150
+ BASE: string;
151
+ PZE: string;
152
+ BLAST: string;
153
+ MANTA: string;
154
+ METIS: string;
155
+ SCRL: string;
156
+ ERA: string;
157
+ };
136
158
  };
137
159
  export declare const DEX_SPENDER_WHITELIST: {
138
160
  "1inch": {
@@ -238,4 +260,21 @@ export declare const DEX_SPENDER_WHITELIST: {
238
260
  BSC: string;
239
261
  AVAX: string;
240
262
  };
263
+ Magpie: {
264
+ [x: string]: string;
265
+ ETH: string;
266
+ OP: string;
267
+ ARBITRUM: string;
268
+ BSC: string;
269
+ AVAX: string;
270
+ FTM: string;
271
+ POLYGON: string;
272
+ BASE: string;
273
+ PZE: string;
274
+ BLAST: string;
275
+ MANTA: string;
276
+ METIS: string;
277
+ SCRL: string;
278
+ ERA: string;
279
+ };
241
280
  };
package/dist/list.js CHANGED
@@ -8,6 +8,7 @@ import { SUPPORT_CHAINS as kyberswapSupportChains } from "./dexs/kyberswap";
8
8
  import { SUPPORT_CHAINS as openOceanSupportChains } from "./dexs/openocean";
9
9
  import { SUPPORT_CHAINS as odosSupportChains } from "./dexs/odos";
10
10
  import { SUPPORT_CHAINS as zeroXV2SupportChains } from "./dexs/0xapi_v2";
11
+ import { SUPPORT_CHAINS as magpieSupportChains } from "./dexs/magpie";
11
12
  import { DEX_ENUM } from "./consts";
12
13
  export const WrapTokenAddressMap = {
13
14
  [CHAINS_ENUM.ETH]: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
@@ -26,11 +27,14 @@ export const WrapTokenAddressMap = {
26
27
  // [CHAINS_ENUM.ROSE]: "0x21c718c22d52d0f3a789b752d4c2fd5908a8a733",
27
28
  [CHAINS_ENUM.BASE]: "0x4200000000000000000000000000000000000006",
28
29
  [CHAINS_ENUM.ERA]: "0x5aea5775959fbc2557cc8789bc1bf90a239d9a91",
29
- // [CHAINS_ENUM.PZE]: "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
30
+ [CHAINS_ENUM.PZE]: "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
30
31
  [CHAINS_ENUM.SCRL]: "0x5300000000000000000000000000000000000004",
31
32
  [CHAINS_ENUM.MANTLE]: "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8",
32
33
  [CHAINS_ENUM.MODE]: "0x4200000000000000000000000000000000000006",
33
34
  ["SONIC"]: "0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38",
35
+ [CHAINS_ENUM.BLAST]: "0x4300000000000000000000000000000000000004",
36
+ [CHAINS_ENUM.METIS]: "0x75cb093e4d61d2a2e65d8e0bbb01de8d89b53481",
37
+ [CHAINS_ENUM.MANTA]: "0x0dc808adce2099a9f62aa87d9670745aba741746",
34
38
  };
35
39
  export const DEX_SUPPORT_CHAINS = {
36
40
  [DEX_ENUM.WRAPTOKEN]: wrapTokenSupportChains,
@@ -42,6 +46,7 @@ export const DEX_SUPPORT_CHAINS = {
42
46
  [DEX_ENUM.PARASWAPV6]: paraswapV6SupportChains,
43
47
  [DEX_ENUM.ODOS]: odosSupportChains,
44
48
  [DEX_ENUM.ZEROXAPIV2]: zeroXV2SupportChains,
49
+ [DEX_ENUM.MAGPIE]: magpieSupportChains,
45
50
  };
46
51
  export const DEX_ROUTER_WHITELIST = {
47
52
  [DEX_ENUM.ONEINCH]: {
@@ -146,6 +151,23 @@ export const DEX_ROUTER_WHITELIST = {
146
151
  [CHAINS_ENUM.BSC]: "0x0000000000001ff3684f28c67538d4d072c22734",
147
152
  [CHAINS_ENUM.AVAX]: "0x0000000000005e88410ccdfade4a5efae4b49562",
148
153
  },
154
+ [DEX_ENUM.MAGPIE]: {
155
+ [CHAINS_ENUM.ETH]: "0x15392211222b46a0ea85a9a800830486d144848d",
156
+ [CHAINS_ENUM.OP]: "0x7f68ab1d50bd4348173e957bfaf0e68b22d3ad13",
157
+ [CHAINS_ENUM.ARBITRUM]: "0x34cdce58cbdc6c54f2ac808a24561d0ab18ca8be",
158
+ [CHAINS_ENUM.BSC]: "0x15392211222b46a0ea85a9a800830486d144848d",
159
+ [CHAINS_ENUM.AVAX]: "0xf25075d95b5945bcff394588db3df8b1cacfccf6",
160
+ [CHAINS_ENUM.FTM]: "0x2b14763c27b9661182c2503f6c9c4d47ba747dd2",
161
+ [CHAINS_ENUM.POLYGON]: "0x15392211222b46a0ea85a9a800830486d144848d",
162
+ [CHAINS_ENUM.BASE]: "0xef42f78d25f4c681dcad2597fa04877ff802ef4b",
163
+ [CHAINS_ENUM.PZE]: "0xcf32c5bb41f7a302298a2d2072155800871baad3",
164
+ ["SONIC"]: "0xba7bac71a8ee550d89b827fe6d67bc3dca07b104",
165
+ [CHAINS_ENUM.BLAST]: "0x5affa5312ade198d9527acf058fee1c8ed8fe9f3",
166
+ [CHAINS_ENUM.MANTA]: "0x5affa5312ade198d9527acf058fee1c8ed8fe9f3",
167
+ [CHAINS_ENUM.METIS]: "0x2b14763c27b9661182c2503f6c9c4d47ba747dd2",
168
+ [CHAINS_ENUM.SCRL]: "0x52bebb970697476313ae2b3383f40d4afd4ad9d3",
169
+ [CHAINS_ENUM.ERA]: "0x38ae1164ca61ee7aa395bb139b3990e347988ce1",
170
+ },
149
171
  };
150
172
  export const DEX_SPENDER_WHITELIST = {
151
173
  [DEX_ENUM.ONEINCH]: {
@@ -251,4 +273,21 @@ export const DEX_SPENDER_WHITELIST = {
251
273
  [CHAINS_ENUM.BSC]: "0x0000000000001ff3684f28c67538d4d072c22734",
252
274
  [CHAINS_ENUM.AVAX]: "0x0000000000005e88410ccdfade4a5efae4b49562",
253
275
  },
276
+ [DEX_ENUM.MAGPIE]: {
277
+ [CHAINS_ENUM.ETH]: "0x15392211222b46a0ea85a9a800830486d144848d",
278
+ [CHAINS_ENUM.OP]: "0x7f68ab1d50bd4348173e957bfaf0e68b22d3ad13",
279
+ [CHAINS_ENUM.ARBITRUM]: "0x34cdce58cbdc6c54f2ac808a24561d0ab18ca8be",
280
+ [CHAINS_ENUM.BSC]: "0x15392211222b46a0ea85a9a800830486d144848d",
281
+ [CHAINS_ENUM.AVAX]: "0xf25075d95b5945bcff394588db3df8b1cacfccf6",
282
+ [CHAINS_ENUM.FTM]: "0x2b14763c27b9661182c2503f6c9c4d47ba747dd2",
283
+ [CHAINS_ENUM.POLYGON]: "0x15392211222b46a0ea85a9a800830486d144848d",
284
+ [CHAINS_ENUM.BASE]: "0xef42f78d25f4c681dcad2597fa04877ff802ef4b",
285
+ [CHAINS_ENUM.PZE]: "0xcf32c5bb41f7a302298a2d2072155800871baad3",
286
+ ["SONIC"]: "0xba7bac71a8ee550d89b827fe6d67bc3dca07b104",
287
+ [CHAINS_ENUM.BLAST]: "0x5affa5312ade198d9527acf058fee1c8ed8fe9f3",
288
+ [CHAINS_ENUM.MANTA]: "0x5affa5312ade198d9527acf058fee1c8ed8fe9f3",
289
+ [CHAINS_ENUM.METIS]: "0x2b14763c27b9661182c2503f6c9c4d47ba747dd2",
290
+ [CHAINS_ENUM.SCRL]: "0x52bebb970697476313ae2b3383f40d4afd4ad9d3",
291
+ [CHAINS_ENUM.ERA]: "0x38ae1164ca61ee7aa395bb139b3990e347988ce1",
292
+ },
254
293
  };
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/quote.js CHANGED
@@ -18,6 +18,7 @@ import { getQuote as kyberswapGetQuote, decodeCalldata as kyberswapDecodeCalldat
18
18
  import { getQuote as paraSwapV6GetQuote, decodeCalldata as paraSwapV6DecodeCalldata, } from "./dexs/paraswap_v6";
19
19
  import { getQuote as odosGetQuote, decodeCalldata as odosDecodeCalldata, } from "./dexs/odos";
20
20
  import { getQuote as zeroXV2GetQuote, decodeCalldata as zeroXV2DecodeCalldata, } from "./dexs/0xapi_v2";
21
+ import { getQuote as magpieGetQuote, decodeCalldata as magpieDecodeCalldata, } from "./dexs/magpie";
21
22
  export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, function* () {
22
23
  switch (id) {
23
24
  case DEX_ENUM.WRAPTOKEN:
@@ -40,6 +41,8 @@ export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, f
40
41
  return yield odosGetQuote(params, api);
41
42
  case DEX_ENUM.ZEROXAPIV2:
42
43
  return yield zeroXV2GetQuote(params, api);
44
+ case DEX_ENUM.MAGPIE:
45
+ return yield magpieGetQuote(params, api);
43
46
  default:
44
47
  throw new Error(`${id} is not supported!`);
45
48
  }
@@ -64,6 +67,8 @@ export const decodeCalldata = (id, tx) => {
64
67
  return odosDecodeCalldata(tx);
65
68
  case DEX_ENUM.ZEROXAPIV2:
66
69
  return zeroXV2DecodeCalldata(tx);
70
+ case DEX_ENUM.MAGPIE:
71
+ return magpieDecodeCalldata(tx);
67
72
  default:
68
73
  throw new Error(`${id} is not supported!`);
69
74
  }
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";
8
+ id: "uniswap3" | "matcha" | "matcha_v2" | "openocean" | "1inch_v6" | "paraswap" | "kyberswap" | "odos" | "paraswap_v6" | "magpie";
9
9
  dex: DEX_ENUM;
10
10
  }) => (options: QuoteParams, api: OpenApiService) => Promise<QuoteResult>;
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.44",
3
+ "version": "0.0.46-alpha.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {