@rabby-wallet/rabby-swap 0.0.24 → 0.0.26

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,3 +142,37 @@ 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
+ })[];
package/dist/abi.js CHANGED
@@ -764,3 +764,88 @@ 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
+ ];
package/dist/consts.d.ts CHANGED
@@ -4,7 +4,8 @@ export declare enum DEX_ENUM {
4
4
  PARASWAP = "ParaSwap",
5
5
  ZEROXAPI = "0xAPI",
6
6
  WRAPTOKEN = "WrapToken",
7
- OPENOCEAN = "OpenOcean"
7
+ OPENOCEAN = "OpenOcean",
8
+ UNISWAP = "Uniswap"
8
9
  }
9
10
  export declare const WrapTokenAddressMap: {
10
11
  ETH: string;
@@ -23,6 +24,7 @@ export declare const DEX_SUPPORT_CHAINS: {
23
24
  ParaSwap: CHAINS_ENUM[];
24
25
  "0xAPI": CHAINS_ENUM[];
25
26
  OpenOcean: CHAINS_ENUM[];
27
+ Uniswap: CHAINS_ENUM[];
26
28
  };
27
29
  export declare const DEX_ROUTER_WHITELIST: {
28
30
  "1inch": {
@@ -71,6 +73,13 @@ export declare const DEX_ROUTER_WHITELIST: {
71
73
  KAVA: string;
72
74
  METIS: string;
73
75
  };
76
+ Uniswap: {
77
+ ETH: string;
78
+ POLYGON: string;
79
+ BSC: string;
80
+ OP: string;
81
+ ARBITRUM: string;
82
+ };
74
83
  };
75
84
  export declare const DEX_SPENDER_WHITELIST: {
76
85
  "1inch": {
@@ -119,4 +128,11 @@ export declare const DEX_SPENDER_WHITELIST: {
119
128
  KAVA: string;
120
129
  METIS: string;
121
130
  };
131
+ Uniswap: {
132
+ ETH: string;
133
+ POLYGON: string;
134
+ BSC: string;
135
+ OP: string;
136
+ ARBITRUM: string;
137
+ };
122
138
  };
package/dist/consts.js CHANGED
@@ -4,6 +4,7 @@ import { SUPPORT_CHAINS as zeroXSupportChains } from "./dexs/0xapi";
4
4
  import { SUPPORT_CHAINS as oneInchSupportChains } from "./dexs/1inch";
5
5
  import { SUPPORT_CHAINS as paraswapSupportChains } from "./dexs/paraswap";
6
6
  import { SUPPORT_CHAINS as openOceanSupportChains } from "./dexs/openocean";
7
+ import { SUPPORT_CHAINS as uniswapSupportChains } from "./dexs/uniswap";
7
8
  export var DEX_ENUM;
8
9
  (function (DEX_ENUM) {
9
10
  DEX_ENUM["ONEINCH"] = "1inch";
@@ -11,6 +12,7 @@ export var DEX_ENUM;
11
12
  DEX_ENUM["ZEROXAPI"] = "0xAPI";
12
13
  DEX_ENUM["WRAPTOKEN"] = "WrapToken";
13
14
  DEX_ENUM["OPENOCEAN"] = "OpenOcean";
15
+ DEX_ENUM["UNISWAP"] = "Uniswap";
14
16
  })(DEX_ENUM || (DEX_ENUM = {}));
15
17
  export const WrapTokenAddressMap = {
16
18
  [CHAINS_ENUM.ETH]: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
@@ -29,6 +31,7 @@ export const DEX_SUPPORT_CHAINS = {
29
31
  [DEX_ENUM.PARASWAP]: paraswapSupportChains,
30
32
  [DEX_ENUM.ZEROXAPI]: zeroXSupportChains,
31
33
  [DEX_ENUM.OPENOCEAN]: openOceanSupportChains,
34
+ [DEX_ENUM.UNISWAP]: uniswapSupportChains,
32
35
  };
33
36
  export const DEX_ROUTER_WHITELIST = {
34
37
  [DEX_ENUM.ONEINCH]: {
@@ -77,6 +80,13 @@ export const DEX_ROUTER_WHITELIST = {
77
80
  [CHAINS_ENUM.KAVA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
78
81
  [CHAINS_ENUM.METIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
79
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
+ },
80
90
  };
81
91
  export const DEX_SPENDER_WHITELIST = {
82
92
  [DEX_ENUM.ONEINCH]: {
@@ -125,4 +135,11 @@ export const DEX_SPENDER_WHITELIST = {
125
135
  [CHAINS_ENUM.KAVA]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
126
136
  [CHAINS_ENUM.METIS]: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
127
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
+ },
128
145
  };
@@ -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,28 +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 { ZeroXABI } from "../abi";
15
5
  const NATIVE_TOKEN = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
16
- const API_DOMAINS = {
17
- [CHAINS_ENUM.ETH]: "https://api.0x.org",
18
- [CHAINS_ENUM.POLYGON]: "https://polygon.api.0x.org",
19
- [CHAINS_ENUM.BSC]: "https://bsc.api.0x.org",
20
- [CHAINS_ENUM.OP]: "https://optimism.api.0x.org",
21
- [CHAINS_ENUM.FTM]: "https://fantom.api.0x.org",
22
- [CHAINS_ENUM.CELO]: "https://celo.api.0x.org",
23
- [CHAINS_ENUM.AVAX]: "https://avalanche.api.0x.org",
24
- [CHAINS_ENUM.ARBITRUM]: "https://arbitrum.api.0x.org",
25
- };
26
6
  export const SUPPORT_CHAINS = [
27
7
  CHAINS_ENUM.ETH,
28
8
  CHAINS_ENUM.POLYGON,
@@ -33,70 +13,10 @@ export const SUPPORT_CHAINS = [
33
13
  CHAINS_ENUM.ARBITRUM,
34
14
  CHAINS_ENUM.CELO,
35
15
  ];
36
- export const getQuote = (options) => __awaiter(void 0, void 0, void 0, function* () {
37
- if (!SUPPORT_CHAINS.includes(options.chain)) {
38
- throw new Error(`${CHAINS[options.chain]} is not support on 1inch`);
39
- }
40
- const baseURL = API_DOMAINS[options.chain];
41
- const request = axios.create({
42
- baseURL,
43
- });
44
- request.interceptors.response.use((response) => {
45
- var _a, _b;
46
- const code = (_a = response.data) === null || _a === void 0 ? void 0 : _a.code;
47
- const msg = (_b = response.data) === null || _b === void 0 ? void 0 : _b.reason;
48
- if (code && code !== 200) {
49
- if (msg) {
50
- let err;
51
- try {
52
- err = new Error(JSON.parse(msg));
53
- }
54
- catch (e) {
55
- err = new Error(msg);
56
- }
57
- throw err;
58
- }
59
- throw new Error(response.data);
60
- }
61
- return response;
62
- });
63
- const params = {
64
- sellToken: options.fromToken === CHAINS[options.chain].nativeTokenAddress
65
- ? NATIVE_TOKEN
66
- : options.fromToken,
67
- buyToken: options.toToken === CHAINS[options.chain].nativeTokenAddress
68
- ? NATIVE_TOKEN
69
- : options.toToken,
70
- sellAmount: options.amount,
71
- takerAddress: options.userAddress,
72
- slippagePercentage: options.slippage / 100,
73
- skipValidation: true,
74
- };
75
- if (options.feeRate !== null && options.feeRate !== undefined) {
76
- params.buyTokenPercentageFee = options.feeRate / 100;
77
- params.feeRecipient = options.feeAddress;
78
- params.affiliateAddress = options.feeAddress;
79
- }
80
- const { data } = yield request.get("/swap/v1/quote", {
81
- params,
82
- });
83
- return {
84
- tx: {
85
- data: data.data,
86
- to: data.to,
87
- value: data.value,
88
- from: data.from,
89
- },
90
- fromToken: isSameAddress(data.sellTokenAddress, NATIVE_TOKEN)
91
- ? CHAINS[options.chain].nativeTokenAddress
92
- : data.sellTokenAddress,
93
- spender: data.allowanceTarget,
94
- fromTokenAmount: data.sellAmount,
95
- toToken: isSameAddress(data.buyTokenAddress, NATIVE_TOKEN)
96
- ? CHAINS[options.chain].nativeTokenAddress
97
- : data.buyTokenAddress,
98
- toTokenAmount: data.buyAmount,
99
- };
16
+ export const getQuote = generateGetQuote({
17
+ SUPPORT_CHAINS,
18
+ id: "matcha",
19
+ dex: "0x",
100
20
  });
101
21
  export const decodeCalldata = (tx) => {
102
22
  const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
@@ -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,60 @@
1
+ import { CHAINS_ENUM, CHAINS } from "@debank/common";
2
+ import { Interface } from "@ethersproject/abi";
3
+ import { generateGetQuote } from "../utils";
4
+ import { UniswapABI } from "../abi";
5
+ export const SUPPORT_CHAINS = [
6
+ CHAINS_ENUM.ETH,
7
+ CHAINS_ENUM.POLYGON,
8
+ CHAINS_ENUM.OP,
9
+ CHAINS_ENUM.ARBITRUM,
10
+ ];
11
+ export const getQuote = generateGetQuote({
12
+ SUPPORT_CHAINS,
13
+ id: "uniswap3",
14
+ dex: "Uniswap",
15
+ });
16
+ export const decodeCalldata = (tx) => {
17
+ var _a, _b, _c;
18
+ const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
19
+ if (!chain)
20
+ return null;
21
+ const contractInterface = new Interface(UniswapABI);
22
+ const result = contractInterface.parseTransaction({ data: tx.data });
23
+ 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) {
24
+ const data = (_c = result === null || result === void 0 ? void 0 : result.args) === null || _c === void 0 ? void 0 : _c.data;
25
+ if (data.startsWith("0x49404b7c")) {
26
+ const result = decodeCalldataExactInput(data[0]);
27
+ if (result) {
28
+ return Object.assign(Object.assign({}, result), { toToken: chain.nativeTokenAddress });
29
+ }
30
+ }
31
+ }
32
+ return decodeCalldataExactInput(tx);
33
+ };
34
+ function decodeCalldataExactInput(tx) {
35
+ const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
36
+ if (!chain)
37
+ return null;
38
+ const contractInterface = new Interface(UniswapABI);
39
+ const result = contractInterface.parseTransaction({ data: tx.data });
40
+ if (result.name === "") {
41
+ return null;
42
+ }
43
+ const [path, recipient, dstReceiver, amount, minReturnAmount] = result.args[0];
44
+ let srcToken = "";
45
+ let dstToken = "";
46
+ if (!path) {
47
+ return null;
48
+ }
49
+ srcToken = "0x" + path.slice(2, 42);
50
+ dstToken = "0x" + path.slice(-40);
51
+ if (!srcToken || !dstToken || !recipient || !amount || !minReturnAmount)
52
+ return null;
53
+ return {
54
+ fromToken: srcToken,
55
+ fromTokenAmount: amount.toString(),
56
+ toToken: dstToken,
57
+ minReceiveToTokenAmount: minReturnAmount.toString(),
58
+ toTokenReceiver: dstReceiver,
59
+ };
60
+ }
package/dist/quote.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CHAINS_ENUM } from "@debank/common";
2
+ import { OpenApiService } from "@rabby-wallet/rabby-api";
2
3
  import { DEX_ENUM } from "./consts";
3
4
  export interface QuoteParams {
4
5
  fromToken: string;
@@ -34,7 +35,7 @@ export interface QuoteResult {
34
35
  toTokenAmount: string;
35
36
  spender: string;
36
37
  }
37
- export declare const getQuote: (id: DEX_ENUM, params: QuoteParams) => Promise<QuoteResult>;
38
+ export declare const getQuote: (id: DEX_ENUM, params: QuoteParams, api: OpenApiService) => Promise<QuoteResult>;
38
39
  export interface DecodeCalldataResult {
39
40
  fromToken: string;
40
41
  fromTokenAmount: string;
package/dist/quote.js CHANGED
@@ -13,7 +13,8 @@ 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
- export const getQuote = (id, params) => __awaiter(void 0, void 0, void 0, function* () {
16
+ import { getQuote as uniswapGetQuote, decodeCalldata as uniswapDecodeCalldata, } from "./dexs/uniswap";
17
+ export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, function* () {
17
18
  switch (id) {
18
19
  case DEX_ENUM.WRAPTOKEN:
19
20
  return yield wrapTokenGetQuote(params);
@@ -22,9 +23,11 @@ export const getQuote = (id, params) => __awaiter(void 0, void 0, void 0, functi
22
23
  case DEX_ENUM.PARASWAP:
23
24
  return yield paraSwapGetQuote(params);
24
25
  case DEX_ENUM.ZEROXAPI:
25
- return yield zeroXGetQuote(params);
26
+ return yield zeroXGetQuote(params, api);
26
27
  case DEX_ENUM.OPENOCEAN:
27
28
  return yield openOceanGetQuote(params);
29
+ case DEX_ENUM.UNISWAP:
30
+ return yield uniswapGetQuote(params, api);
28
31
  default:
29
32
  throw new Error(`${id} is not supported!`);
30
33
  }
@@ -39,6 +42,8 @@ export const decodeCalldata = (id, tx) => {
39
42
  return zeroXDecodeCalldata(tx);
40
43
  case DEX_ENUM.OPENOCEAN:
41
44
  return openOceanDecodeCalldata(tx);
45
+ case DEX_ENUM.UNISWAP:
46
+ return uniswapDecodeCalldata(tx);
42
47
  default:
43
48
  throw new Error(`${id} is not supported!`);
44
49
  }
package/dist/utils.d.ts CHANGED
@@ -1 +1,9 @@
1
+ import { OpenApiService } from "@rabby-wallet/rabby-api";
2
+ import { CHAINS_ENUM } from "@debank/common";
3
+ import { QuoteParams, QuoteResult } from "./quote";
1
4
  export declare const isSameAddress: (addr1: string, addr2: string) => boolean;
5
+ export declare const generateGetQuote: ({ SUPPORT_CHAINS, id, dex, }: {
6
+ SUPPORT_CHAINS: CHAINS_ENUM[];
7
+ id: string;
8
+ dex: string;
9
+ }) => (options: QuoteParams, api: OpenApiService) => Promise<QuoteResult>;
package/dist/utils.js CHANGED
@@ -1,5 +1,47 @@
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 { CHAINS, CHAINS_ENUM } from "@debank/common";
1
11
  export const isSameAddress = (addr1, addr2) => {
2
- if (typeof addr1 !== 'string' || typeof addr2 !== 'string')
12
+ if (typeof addr1 !== "string" || typeof addr2 !== "string")
3
13
  return false;
4
14
  return addr1.toLowerCase() === addr2.toLowerCase();
5
15
  };
16
+ export const generateGetQuote = ({ SUPPORT_CHAINS, id, dex, }) => (options, api) => __awaiter(void 0, void 0, void 0, function* () {
17
+ if (!SUPPORT_CHAINS.includes(options.chain)) {
18
+ throw new Error(`${CHAINS[options.chain]} is not support on ${dex}`);
19
+ }
20
+ const data = yield api.getSwapQuote({
21
+ id: options.userAddress,
22
+ chain_id: CHAINS[options.chain].serverId,
23
+ dex_id: options.chain === CHAINS_ENUM.ETH
24
+ ? id
25
+ : `${CHAINS[options.chain].serverId}_${id}`,
26
+ pay_token_id: options.fromToken,
27
+ pay_token_raw_amount: options.amount,
28
+ receive_token_id: options.toToken,
29
+ slippage: options.slippage / 100,
30
+ });
31
+ const isNativeToken = isSameAddress(data.pay_token.id, CHAINS[options.chain].nativeTokenAddress);
32
+ return {
33
+ tx: {
34
+ data: data.dex_swap_calldata,
35
+ value: isNativeToken ? options.amount : "0",
36
+ to: data.dex_swap_to,
37
+ from: options.userAddress,
38
+ },
39
+ fromToken: data.pay_token.id,
40
+ fromTokenAmount: options.amount,
41
+ fromTokenDecimals: data.pay_token.decimals,
42
+ toToken: data.receive_token.id,
43
+ toTokenAmount: data.receive_token_raw_amount + "",
44
+ toTokenDecimals: data.receive_token.decimals,
45
+ spender: data.dex_swap_to,
46
+ };
47
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-swap",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -24,6 +24,8 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@babel/preset-env": "^7.19.1",
27
+ "@debank/common": "^0.3.5",
28
+ "@rabby-wallet/rabby-api": "^0.6.13",
27
29
  "@types/jest": "^29.0.3",
28
30
  "@types/node": "^18.7.18",
29
31
  "axios-mock-adapter": "^1.21.2",
@@ -36,7 +38,8 @@
36
38
  "typescript": "^4.8.3"
37
39
  },
38
40
  "peerDependencies": {
39
- "@debank/common": "^0.3.5"
41
+ "@debank/common": "^0.3.5",
42
+ "@rabby-wallet/rabby-api": "^0.6.13"
40
43
  },
41
44
  "author": "vvvvvv1vvvvvv",
42
45
  "license": "ISC",
@@ -44,4 +47,4 @@
44
47
  "url": "https://github.com/RabbyHub/rabby-swap/issues"
45
48
  },
46
49
  "homepage": "https://github.com/RabbyHub/rabby-swap#readme"
47
- }
50
+ }