@openocean.finance/openocean-sdk 1.2.2 → 1.2.3
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/lib/api/index.js +139 -0
- package/lib/api/vo/RequestVo.js +411 -0
- package/lib/asset/abi/ERC20_abi.js +119 -0
- package/lib/asset/abi/aggregator.js +391 -0
- package/lib/config/index.js +33 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +50 -2
- package/lib/swapSdk/Approve.js +342 -0
- package/lib/swapSdk/NotoMobile.js +141 -0
- package/lib/swapSdk/RequestVo.js +94 -0
- package/lib/swapSdk/Swap.js +1123 -0
- package/lib/swapSdk/getAllowance.js +97 -0
- package/lib/swapSdk/getBalance.js +280 -0
- package/lib/swapSdk/index.js +257 -0
- package/lib/swapSdk/qrcode.d.ts +6 -0
- package/lib/swapSdk/qrcode.js +969 -0
- package/lib/utils/ajx.js +150 -0
- package/lib/utils/index.js +369 -0
- package/lib/utils/web3.js +9 -0
- package/lib/v1/abis/ERC20.d.ts +16 -0
- package/lib/v1/abis/ERC20.js +22 -0
- package/lib/v1/abis/IUniswapV2Pair.d.ts +83 -0
- package/lib/v1/abis/IUniswapV2Pair.js +1434 -0
- package/lib/v1/constants.d.ts +58 -0
- package/lib/v1/constants.js +71 -0
- package/lib/v1/entities/currency.d.ts +27 -0
- package/lib/v1/entities/currency.js +39 -0
- package/lib/v1/entities/fractions/currencyAmount.d.ts +19 -0
- package/lib/v1/entities/fractions/currencyAmount.js +83 -0
- package/lib/v1/entities/fractions/fraction.d.ts +19 -0
- package/lib/v1/entities/fractions/fraction.js +109 -0
- package/lib/v1/entities/fractions/index.d.ts +5 -0
- package/lib/v1/entities/fractions/index.js +21 -0
- package/lib/v1/entities/fractions/percent.d.ts +6 -0
- package/lib/v1/entities/fractions/percent.js +37 -0
- package/lib/v1/entities/fractions/price.d.ts +18 -0
- package/lib/v1/entities/fractions/price.js +90 -0
- package/lib/v1/entities/fractions/tokenAmount.d.ts +9 -0
- package/lib/v1/entities/fractions/tokenAmount.js +43 -0
- package/lib/v1/entities/index.d.ts +6 -0
- package/lib/v1/entities/index.js +22 -0
- package/lib/v1/entities/pair.d.ts +41 -0
- package/lib/v1/entities/pair.js +210 -0
- package/lib/v1/entities/route.d.ts +14 -0
- package/lib/v1/entities/route.js +43 -0
- package/lib/v1/entities/token.d.ts +27 -0
- package/lib/v1/entities/token.js +87 -0
- package/lib/v1/entities/trade.d.ts +106 -0
- package/lib/v1/entities/trade.js +336 -0
- package/lib/v1/errors.d.ts +16 -0
- package/lib/v1/errors.js +56 -0
- package/lib/v1/fetcher.d.ts +28 -0
- package/lib/v1/fetcher.js +140 -0
- package/lib/v1/router.d.ts +56 -0
- package/lib/v1/router.js +97 -0
- package/lib/v1/utils.d.ts +7 -0
- package/lib/v1/utils.js +87 -0
- package/package.json +4 -1
- package/lib/index.js.LICENSE.txt +0 -279
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.aggregator = void 0;
|
|
4
|
+
exports.aggregator = [
|
|
5
|
+
{
|
|
6
|
+
anonymous: false,
|
|
7
|
+
inputs: [
|
|
8
|
+
{
|
|
9
|
+
indexed: false,
|
|
10
|
+
internalType: "address",
|
|
11
|
+
name: "aggregator",
|
|
12
|
+
type: "address",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
name: "AddAggregator",
|
|
16
|
+
type: "event",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
anonymous: false,
|
|
20
|
+
inputs: [
|
|
21
|
+
{
|
|
22
|
+
indexed: false,
|
|
23
|
+
internalType: "address",
|
|
24
|
+
name: "aggregator",
|
|
25
|
+
type: "address",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
name: "DelAggregator",
|
|
29
|
+
type: "event",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
anonymous: false,
|
|
33
|
+
inputs: [
|
|
34
|
+
{
|
|
35
|
+
indexed: false,
|
|
36
|
+
internalType: "uint8",
|
|
37
|
+
name: "version",
|
|
38
|
+
type: "uint8",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
name: "Initialized",
|
|
42
|
+
type: "event",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
anonymous: false,
|
|
46
|
+
inputs: [
|
|
47
|
+
{
|
|
48
|
+
indexed: true,
|
|
49
|
+
internalType: "address",
|
|
50
|
+
name: "previousOwner",
|
|
51
|
+
type: "address",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
indexed: true,
|
|
55
|
+
internalType: "address",
|
|
56
|
+
name: "newOwner",
|
|
57
|
+
type: "address",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
name: "OwnershipTransferred",
|
|
61
|
+
type: "event",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
anonymous: false,
|
|
65
|
+
inputs: [
|
|
66
|
+
{
|
|
67
|
+
indexed: false,
|
|
68
|
+
internalType: "address",
|
|
69
|
+
name: "account",
|
|
70
|
+
type: "address",
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
name: "Paused",
|
|
74
|
+
type: "event",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
anonymous: false,
|
|
78
|
+
inputs: [
|
|
79
|
+
{
|
|
80
|
+
indexed: false,
|
|
81
|
+
internalType: "uint256",
|
|
82
|
+
name: "oldFeeRate",
|
|
83
|
+
type: "uint256",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
indexed: false,
|
|
87
|
+
internalType: "uint256",
|
|
88
|
+
name: "newFeeRate",
|
|
89
|
+
type: "uint256",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
name: "SetFeeRate",
|
|
93
|
+
type: "event",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
anonymous: false,
|
|
97
|
+
inputs: [
|
|
98
|
+
{
|
|
99
|
+
indexed: false,
|
|
100
|
+
internalType: "address",
|
|
101
|
+
name: "oldFeeReceiver",
|
|
102
|
+
type: "address",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
indexed: false,
|
|
106
|
+
internalType: "address",
|
|
107
|
+
name: "newFeeReceiver",
|
|
108
|
+
type: "address",
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
name: "SetFeeReceiver",
|
|
112
|
+
type: "event",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
anonymous: false,
|
|
116
|
+
inputs: [
|
|
117
|
+
{
|
|
118
|
+
indexed: true,
|
|
119
|
+
internalType: "address",
|
|
120
|
+
name: "user",
|
|
121
|
+
type: "address",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
indexed: true,
|
|
125
|
+
internalType: "address",
|
|
126
|
+
name: "invitee",
|
|
127
|
+
type: "address",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
indexed: false,
|
|
131
|
+
internalType: "address[]",
|
|
132
|
+
name: "path",
|
|
133
|
+
type: "address[]",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
indexed: false,
|
|
137
|
+
internalType: "uint256[]",
|
|
138
|
+
name: "amounts",
|
|
139
|
+
type: "uint256[]",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
indexed: false,
|
|
143
|
+
internalType: "address",
|
|
144
|
+
name: "swapAddr",
|
|
145
|
+
type: "address",
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
indexed: false,
|
|
149
|
+
internalType: "uint256",
|
|
150
|
+
name: "fee",
|
|
151
|
+
type: "uint256",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
indexed: false,
|
|
155
|
+
internalType: "bytes",
|
|
156
|
+
name: "swapExtraData",
|
|
157
|
+
type: "bytes",
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
name: "Swap",
|
|
161
|
+
type: "event",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
anonymous: false,
|
|
165
|
+
inputs: [
|
|
166
|
+
{
|
|
167
|
+
indexed: false,
|
|
168
|
+
internalType: "address",
|
|
169
|
+
name: "account",
|
|
170
|
+
type: "address",
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
name: "Unpaused",
|
|
174
|
+
type: "event",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
inputs: [
|
|
178
|
+
{
|
|
179
|
+
internalType: "address",
|
|
180
|
+
name: "",
|
|
181
|
+
type: "address",
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
name: "_aggregators",
|
|
185
|
+
outputs: [
|
|
186
|
+
{
|
|
187
|
+
internalType: "bool",
|
|
188
|
+
name: "",
|
|
189
|
+
type: "bool",
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
stateMutability: "view",
|
|
193
|
+
type: "function",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
inputs: [],
|
|
197
|
+
name: "_feeRate",
|
|
198
|
+
outputs: [
|
|
199
|
+
{
|
|
200
|
+
internalType: "uint256",
|
|
201
|
+
name: "",
|
|
202
|
+
type: "uint256",
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
stateMutability: "view",
|
|
206
|
+
type: "function",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
inputs: [],
|
|
210
|
+
name: "_feeReceiver",
|
|
211
|
+
outputs: [
|
|
212
|
+
{
|
|
213
|
+
internalType: "address",
|
|
214
|
+
name: "",
|
|
215
|
+
type: "address",
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
stateMutability: "view",
|
|
219
|
+
type: "function",
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
inputs: [
|
|
223
|
+
{
|
|
224
|
+
internalType: "address[]",
|
|
225
|
+
name: "aggregators",
|
|
226
|
+
type: "address[]",
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
name: "addAggregator",
|
|
230
|
+
outputs: [],
|
|
231
|
+
stateMutability: "nonpayable",
|
|
232
|
+
type: "function",
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
inputs: [
|
|
236
|
+
{
|
|
237
|
+
internalType: "address",
|
|
238
|
+
name: "aggregator",
|
|
239
|
+
type: "address",
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
name: "delAggregator",
|
|
243
|
+
outputs: [],
|
|
244
|
+
stateMutability: "nonpayable",
|
|
245
|
+
type: "function",
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
inputs: [],
|
|
249
|
+
name: "initialize",
|
|
250
|
+
outputs: [],
|
|
251
|
+
stateMutability: "nonpayable",
|
|
252
|
+
type: "function",
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
inputs: [],
|
|
256
|
+
name: "owner",
|
|
257
|
+
outputs: [
|
|
258
|
+
{
|
|
259
|
+
internalType: "address",
|
|
260
|
+
name: "",
|
|
261
|
+
type: "address",
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
stateMutability: "view",
|
|
265
|
+
type: "function",
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
inputs: [],
|
|
269
|
+
name: "pause",
|
|
270
|
+
outputs: [],
|
|
271
|
+
stateMutability: "nonpayable",
|
|
272
|
+
type: "function",
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
inputs: [],
|
|
276
|
+
name: "paused",
|
|
277
|
+
outputs: [
|
|
278
|
+
{
|
|
279
|
+
internalType: "bool",
|
|
280
|
+
name: "",
|
|
281
|
+
type: "bool",
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
stateMutability: "view",
|
|
285
|
+
type: "function",
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
inputs: [],
|
|
289
|
+
name: "renounceOwnership",
|
|
290
|
+
outputs: [],
|
|
291
|
+
stateMutability: "nonpayable",
|
|
292
|
+
type: "function",
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
inputs: [
|
|
296
|
+
{
|
|
297
|
+
internalType: "uint256",
|
|
298
|
+
name: "feeRate",
|
|
299
|
+
type: "uint256",
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
name: "setFeeRate",
|
|
303
|
+
outputs: [],
|
|
304
|
+
stateMutability: "nonpayable",
|
|
305
|
+
type: "function",
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
inputs: [
|
|
309
|
+
{
|
|
310
|
+
internalType: "address",
|
|
311
|
+
name: "feeReceiver",
|
|
312
|
+
type: "address",
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
name: "setFeeReceiver",
|
|
316
|
+
outputs: [],
|
|
317
|
+
stateMutability: "nonpayable",
|
|
318
|
+
type: "function",
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
inputs: [
|
|
322
|
+
{
|
|
323
|
+
internalType: "address",
|
|
324
|
+
name: "invitee",
|
|
325
|
+
type: "address",
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
internalType: "address[]",
|
|
329
|
+
name: "path",
|
|
330
|
+
type: "address[]",
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
internalType: "uint256[]",
|
|
334
|
+
name: "amounts",
|
|
335
|
+
type: "uint256[]",
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
internalType: "address",
|
|
339
|
+
name: "swapAddr",
|
|
340
|
+
type: "address",
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
internalType: "bytes",
|
|
344
|
+
name: "swapExtraData",
|
|
345
|
+
type: "bytes",
|
|
346
|
+
},
|
|
347
|
+
],
|
|
348
|
+
name: "swap",
|
|
349
|
+
outputs: [],
|
|
350
|
+
stateMutability: "payable",
|
|
351
|
+
type: "function",
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
inputs: [
|
|
355
|
+
{
|
|
356
|
+
internalType: "address",
|
|
357
|
+
name: "newOwner",
|
|
358
|
+
type: "address",
|
|
359
|
+
},
|
|
360
|
+
],
|
|
361
|
+
name: "transferOwnership",
|
|
362
|
+
outputs: [],
|
|
363
|
+
stateMutability: "nonpayable",
|
|
364
|
+
type: "function",
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
inputs: [],
|
|
368
|
+
name: "unpause",
|
|
369
|
+
outputs: [],
|
|
370
|
+
stateMutability: "nonpayable",
|
|
371
|
+
type: "function",
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
inputs: [
|
|
375
|
+
{
|
|
376
|
+
internalType: "address",
|
|
377
|
+
name: "token",
|
|
378
|
+
type: "address",
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
internalType: "uint256",
|
|
382
|
+
name: "amount",
|
|
383
|
+
type: "uint256",
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
name: "withdraw",
|
|
387
|
+
outputs: [],
|
|
388
|
+
stateMutability: "nonpayable",
|
|
389
|
+
type: "function",
|
|
390
|
+
},
|
|
391
|
+
];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProxyContract = exports.config = exports.ERC20_abi = void 0;
|
|
4
|
+
// import { wallets, Wallets } from "./Wallets";
|
|
5
|
+
// import { chains, Chains } from "./Chains";
|
|
6
|
+
var wallet_1 = require("@openocean.finance/wallet");
|
|
7
|
+
exports.ERC20_abi = [{ "constant": true, "inputs": [], "name": "name", "outputs": [{ "name": "", "type": "string" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "name": "_spender", "type": "address" }, { "name": "_value", "type": "uint256" }], "name": "approve", "outputs": [{ "name": "", "type": "bool" }], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [{ "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "name": "_from", "type": "address" }, { "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" }], "name": "transferFrom", "outputs": [{ "name": "", "type": "bool" }], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [{ "name": "", "type": "uint8" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [{ "name": "_owner", "type": "address" }], "name": "balanceOf", "outputs": [{ "name": "balance", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [{ "name": "", "type": "string" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" }], "name": "transfer", "outputs": [{ "name": "", "type": "bool" }], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [{ "name": "_owner", "type": "address" }, { "name": "_spender", "type": "address" }], "name": "allowance", "outputs": [{ "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "payable": true, "stateMutability": "payable", "type": "fallback" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "owner", "type": "address" }, { "indexed": true, "name": "spender", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" }], "name": "Approval", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "from", "type": "address" }, { "indexed": true, "name": "to", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" }], "name": "Transfer", "type": "event" }];
|
|
8
|
+
exports.config = {
|
|
9
|
+
chains: wallet_1.chainsObj,
|
|
10
|
+
wallets: wallet_1.walletsObj,
|
|
11
|
+
ERC20_abi: exports.ERC20_abi
|
|
12
|
+
};
|
|
13
|
+
function getProxyContract(chainName) {
|
|
14
|
+
return {
|
|
15
|
+
eth: '0x38B7C17E62dcBD1C39f96eFe74848C4A037b3ed3',
|
|
16
|
+
bsc: "0x7aeef1035ba6794c0478718a2330671ec8802af1",
|
|
17
|
+
fantom: "0x38B7C17E62dcBD1C39f96eFe74848C4A037b3ed3",
|
|
18
|
+
avax: "0x38B7C17E62dcBD1C39f96eFe74848C4A037b3ed3",
|
|
19
|
+
polygon: "0x38B7C17E62dcBD1C39f96eFe74848C4A037b3ed3",
|
|
20
|
+
okex: "0x6D5630eC1Ee74C907617a6fb7BCAdC4Bf0EF3fcA",
|
|
21
|
+
optimism: "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
|
|
22
|
+
harmony: "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
|
|
23
|
+
cronos: "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
|
|
24
|
+
moonriver: "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
|
|
25
|
+
arbitrum: "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
|
|
26
|
+
heco: "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
|
|
27
|
+
boba: "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
|
|
28
|
+
xdai: "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
|
|
29
|
+
tron: "TTpcMZbsojNCMhea2a9LFHq9DLCxsgGZVv",
|
|
30
|
+
}[chainName];
|
|
31
|
+
}
|
|
32
|
+
exports.getProxyContract = getProxyContract;
|
|
33
|
+
;
|
package/lib/index.d.ts
CHANGED
|
@@ -14,4 +14,10 @@ export declare class OpenoceanSdk {
|
|
|
14
14
|
swapSdk: SwapSdk;
|
|
15
15
|
constructor(sdkArg: OpenoceanSdkArg);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
import JSBI from 'jsbi';
|
|
18
|
+
export { JSBI };
|
|
19
|
+
export { BigintIsh, ChainId, TradeType, Rounding, FACTORY_ADDRESS, INIT_CODE_HASH, MINIMUM_LIQUIDITY } from './v1/constants';
|
|
20
|
+
export * from './v1/errors';
|
|
21
|
+
export * from './v1/entities';
|
|
22
|
+
export * from './v1/router';
|
|
23
|
+
export * from './v1/fetcher';
|