@orbs-network/twap 1.10.2 → 1.10.4
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/src/configs.d.ts +441 -2
- package/dist/src/configs.js +13 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/lib.d.ts +8 -3
- package/dist/src/lib.js +29 -5
- package/dist/src/odos.d.ts +15 -0
- package/dist/src/odos.js +81 -0
- package/dist/src/paraswap.js +1 -1
- package/dist/typechain-hardhat/contracts/exchange/OdosExchange.d.ts +23 -0
- package/dist/typechain-hardhat/contracts/exchange/OdosExchange.js +5 -0
- package/dist/typechain-hardhat/contracts/exchange/index.d.ts +1 -0
- package/package.json +5 -4
package/dist/src/configs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Paraswap } from "./paraswap";
|
|
2
|
+
import { Odos } from "./odos";
|
|
2
3
|
export interface TokenData {
|
|
3
4
|
address: string;
|
|
4
5
|
decimals: number;
|
|
@@ -20,8 +21,8 @@ export interface Config {
|
|
|
20
21
|
takerAbi: any;
|
|
21
22
|
partner: string;
|
|
22
23
|
exchangeAddress: string;
|
|
23
|
-
exchangeType: "UniswapV2Exchange" | "ParaswapExchange" | "PangolinDaasExchange";
|
|
24
|
-
pathfinderKey: Paraswap.OnlyDex;
|
|
24
|
+
exchangeType: "UniswapV2Exchange" | "ParaswapExchange" | "PangolinDaasExchange" | "OdosExchange";
|
|
25
|
+
pathfinderKey: Paraswap.OnlyDex | Odos.OnlyDex;
|
|
25
26
|
}
|
|
26
27
|
export declare const ChainConfigs: {
|
|
27
28
|
eth: {
|
|
@@ -243,6 +244,225 @@ export declare const ChainConfigs: {
|
|
|
243
244
|
logoUrl: string;
|
|
244
245
|
};
|
|
245
246
|
};
|
|
247
|
+
arb: {
|
|
248
|
+
twapAbi: ({
|
|
249
|
+
inputs: {
|
|
250
|
+
internalType: string;
|
|
251
|
+
name: string;
|
|
252
|
+
type: string;
|
|
253
|
+
}[];
|
|
254
|
+
stateMutability: string;
|
|
255
|
+
type: string;
|
|
256
|
+
anonymous?: undefined;
|
|
257
|
+
name?: undefined;
|
|
258
|
+
outputs?: undefined;
|
|
259
|
+
} | {
|
|
260
|
+
anonymous: boolean;
|
|
261
|
+
inputs: ({
|
|
262
|
+
indexed: boolean;
|
|
263
|
+
internalType: string;
|
|
264
|
+
name: string;
|
|
265
|
+
type: string;
|
|
266
|
+
components?: undefined;
|
|
267
|
+
} | {
|
|
268
|
+
components: {
|
|
269
|
+
internalType: string;
|
|
270
|
+
name: string;
|
|
271
|
+
type: string;
|
|
272
|
+
}[];
|
|
273
|
+
indexed: boolean;
|
|
274
|
+
internalType: string;
|
|
275
|
+
name: string;
|
|
276
|
+
type: string;
|
|
277
|
+
})[];
|
|
278
|
+
name: string;
|
|
279
|
+
type: string;
|
|
280
|
+
stateMutability?: undefined;
|
|
281
|
+
outputs?: undefined;
|
|
282
|
+
} | {
|
|
283
|
+
inputs: {
|
|
284
|
+
components: {
|
|
285
|
+
internalType: string;
|
|
286
|
+
name: string;
|
|
287
|
+
type: string;
|
|
288
|
+
}[];
|
|
289
|
+
internalType: string;
|
|
290
|
+
name: string;
|
|
291
|
+
type: string;
|
|
292
|
+
}[];
|
|
293
|
+
name: string;
|
|
294
|
+
outputs: {
|
|
295
|
+
internalType: string;
|
|
296
|
+
name: string;
|
|
297
|
+
type: string;
|
|
298
|
+
}[];
|
|
299
|
+
stateMutability: string;
|
|
300
|
+
type: string;
|
|
301
|
+
anonymous?: undefined;
|
|
302
|
+
} | {
|
|
303
|
+
inputs: {
|
|
304
|
+
internalType: string;
|
|
305
|
+
name: string;
|
|
306
|
+
type: string;
|
|
307
|
+
}[];
|
|
308
|
+
name: string;
|
|
309
|
+
outputs: ({
|
|
310
|
+
internalType: string;
|
|
311
|
+
name: string;
|
|
312
|
+
type: string;
|
|
313
|
+
components?: undefined;
|
|
314
|
+
} | {
|
|
315
|
+
components: {
|
|
316
|
+
internalType: string;
|
|
317
|
+
name: string;
|
|
318
|
+
type: string;
|
|
319
|
+
}[];
|
|
320
|
+
internalType: string;
|
|
321
|
+
name: string;
|
|
322
|
+
type: string;
|
|
323
|
+
})[];
|
|
324
|
+
stateMutability: string;
|
|
325
|
+
type: string;
|
|
326
|
+
anonymous?: undefined;
|
|
327
|
+
} | {
|
|
328
|
+
inputs: {
|
|
329
|
+
internalType: string;
|
|
330
|
+
name: string;
|
|
331
|
+
type: string;
|
|
332
|
+
}[];
|
|
333
|
+
name: string;
|
|
334
|
+
outputs: {
|
|
335
|
+
components: ({
|
|
336
|
+
internalType: string;
|
|
337
|
+
name: string;
|
|
338
|
+
type: string;
|
|
339
|
+
components?: undefined;
|
|
340
|
+
} | {
|
|
341
|
+
components: {
|
|
342
|
+
internalType: string;
|
|
343
|
+
name: string;
|
|
344
|
+
type: string;
|
|
345
|
+
}[];
|
|
346
|
+
internalType: string;
|
|
347
|
+
name: string;
|
|
348
|
+
type: string;
|
|
349
|
+
})[];
|
|
350
|
+
internalType: string;
|
|
351
|
+
name: string;
|
|
352
|
+
type: string;
|
|
353
|
+
}[];
|
|
354
|
+
stateMutability: string;
|
|
355
|
+
type: string;
|
|
356
|
+
anonymous?: undefined;
|
|
357
|
+
} | {
|
|
358
|
+
stateMutability: string;
|
|
359
|
+
type: string;
|
|
360
|
+
inputs?: undefined;
|
|
361
|
+
anonymous?: undefined;
|
|
362
|
+
name?: undefined;
|
|
363
|
+
outputs?: undefined;
|
|
364
|
+
})[];
|
|
365
|
+
lensAbi: ({
|
|
366
|
+
inputs: {
|
|
367
|
+
internalType: string;
|
|
368
|
+
name: string;
|
|
369
|
+
type: string;
|
|
370
|
+
}[];
|
|
371
|
+
stateMutability: string;
|
|
372
|
+
type: string;
|
|
373
|
+
name?: undefined;
|
|
374
|
+
outputs?: undefined;
|
|
375
|
+
} | {
|
|
376
|
+
inputs: never[];
|
|
377
|
+
name: string;
|
|
378
|
+
outputs: {
|
|
379
|
+
internalType: string;
|
|
380
|
+
name: string;
|
|
381
|
+
type: string;
|
|
382
|
+
}[];
|
|
383
|
+
stateMutability: string;
|
|
384
|
+
type: string;
|
|
385
|
+
} | {
|
|
386
|
+
inputs: {
|
|
387
|
+
internalType: string;
|
|
388
|
+
name: string;
|
|
389
|
+
type: string;
|
|
390
|
+
}[];
|
|
391
|
+
name: string;
|
|
392
|
+
outputs: {
|
|
393
|
+
components: ({
|
|
394
|
+
internalType: string;
|
|
395
|
+
name: string;
|
|
396
|
+
type: string;
|
|
397
|
+
components?: undefined;
|
|
398
|
+
} | {
|
|
399
|
+
components: {
|
|
400
|
+
internalType: string;
|
|
401
|
+
name: string;
|
|
402
|
+
type: string;
|
|
403
|
+
}[];
|
|
404
|
+
internalType: string;
|
|
405
|
+
name: string;
|
|
406
|
+
type: string;
|
|
407
|
+
})[];
|
|
408
|
+
internalType: string;
|
|
409
|
+
name: string;
|
|
410
|
+
type: string;
|
|
411
|
+
}[];
|
|
412
|
+
stateMutability: string;
|
|
413
|
+
type: string;
|
|
414
|
+
})[];
|
|
415
|
+
takerAbi: ({
|
|
416
|
+
inputs: {
|
|
417
|
+
internalType: string;
|
|
418
|
+
name: string;
|
|
419
|
+
type: string;
|
|
420
|
+
}[];
|
|
421
|
+
stateMutability: string;
|
|
422
|
+
type: string;
|
|
423
|
+
name?: undefined;
|
|
424
|
+
outputs?: undefined;
|
|
425
|
+
} | {
|
|
426
|
+
inputs: {
|
|
427
|
+
internalType: string;
|
|
428
|
+
name: string;
|
|
429
|
+
type: string;
|
|
430
|
+
}[];
|
|
431
|
+
name: string;
|
|
432
|
+
outputs: {
|
|
433
|
+
internalType: string;
|
|
434
|
+
name: string;
|
|
435
|
+
type: string;
|
|
436
|
+
}[];
|
|
437
|
+
stateMutability: string;
|
|
438
|
+
type: string;
|
|
439
|
+
} | {
|
|
440
|
+
stateMutability: string;
|
|
441
|
+
type: string;
|
|
442
|
+
inputs?: undefined;
|
|
443
|
+
name?: undefined;
|
|
444
|
+
outputs?: undefined;
|
|
445
|
+
})[];
|
|
446
|
+
chainName: string;
|
|
447
|
+
chainId: number;
|
|
448
|
+
twapVersion: number;
|
|
449
|
+
twapAddress: string;
|
|
450
|
+
lensAddress: string;
|
|
451
|
+
bidDelaySeconds: number;
|
|
452
|
+
minChunkSizeUsd: number;
|
|
453
|
+
nativeToken: {
|
|
454
|
+
address: string;
|
|
455
|
+
decimals: number;
|
|
456
|
+
symbol: string;
|
|
457
|
+
logoUrl: string;
|
|
458
|
+
};
|
|
459
|
+
wToken: {
|
|
460
|
+
address: string;
|
|
461
|
+
decimals: number;
|
|
462
|
+
symbol: string;
|
|
463
|
+
logoUrl: string;
|
|
464
|
+
};
|
|
465
|
+
};
|
|
246
466
|
ftm: {
|
|
247
467
|
chainName: string;
|
|
248
468
|
chainId: number;
|
|
@@ -887,6 +1107,7 @@ export declare const Configs: {
|
|
|
887
1107
|
Pangolin: Config;
|
|
888
1108
|
PangolinDaas: Config;
|
|
889
1109
|
QuickSwap: Config;
|
|
1110
|
+
Chronos: Config;
|
|
890
1111
|
};
|
|
891
1112
|
export declare const nativeTokenAddresses: string[];
|
|
892
1113
|
export declare const isNativeAddress: (address: string) => boolean;
|
|
@@ -1108,6 +1329,224 @@ export declare const chainConfig: (chainId: number) => {
|
|
|
1108
1329
|
symbol: string;
|
|
1109
1330
|
logoUrl: string;
|
|
1110
1331
|
};
|
|
1332
|
+
} | {
|
|
1333
|
+
twapAbi: ({
|
|
1334
|
+
inputs: {
|
|
1335
|
+
internalType: string;
|
|
1336
|
+
name: string;
|
|
1337
|
+
type: string;
|
|
1338
|
+
}[];
|
|
1339
|
+
stateMutability: string;
|
|
1340
|
+
type: string;
|
|
1341
|
+
anonymous?: undefined;
|
|
1342
|
+
name?: undefined;
|
|
1343
|
+
outputs?: undefined;
|
|
1344
|
+
} | {
|
|
1345
|
+
anonymous: boolean;
|
|
1346
|
+
inputs: ({
|
|
1347
|
+
indexed: boolean;
|
|
1348
|
+
internalType: string;
|
|
1349
|
+
name: string;
|
|
1350
|
+
type: string;
|
|
1351
|
+
components?: undefined;
|
|
1352
|
+
} | {
|
|
1353
|
+
components: {
|
|
1354
|
+
internalType: string;
|
|
1355
|
+
name: string;
|
|
1356
|
+
type: string;
|
|
1357
|
+
}[];
|
|
1358
|
+
indexed: boolean;
|
|
1359
|
+
internalType: string;
|
|
1360
|
+
name: string;
|
|
1361
|
+
type: string;
|
|
1362
|
+
})[];
|
|
1363
|
+
name: string;
|
|
1364
|
+
type: string;
|
|
1365
|
+
stateMutability?: undefined;
|
|
1366
|
+
outputs?: undefined;
|
|
1367
|
+
} | {
|
|
1368
|
+
inputs: {
|
|
1369
|
+
components: {
|
|
1370
|
+
internalType: string;
|
|
1371
|
+
name: string;
|
|
1372
|
+
type: string;
|
|
1373
|
+
}[];
|
|
1374
|
+
internalType: string;
|
|
1375
|
+
name: string;
|
|
1376
|
+
type: string;
|
|
1377
|
+
}[];
|
|
1378
|
+
name: string;
|
|
1379
|
+
outputs: {
|
|
1380
|
+
internalType: string;
|
|
1381
|
+
name: string;
|
|
1382
|
+
type: string;
|
|
1383
|
+
}[];
|
|
1384
|
+
stateMutability: string;
|
|
1385
|
+
type: string;
|
|
1386
|
+
anonymous?: undefined;
|
|
1387
|
+
} | {
|
|
1388
|
+
inputs: {
|
|
1389
|
+
internalType: string;
|
|
1390
|
+
name: string;
|
|
1391
|
+
type: string;
|
|
1392
|
+
}[];
|
|
1393
|
+
name: string;
|
|
1394
|
+
outputs: ({
|
|
1395
|
+
internalType: string;
|
|
1396
|
+
name: string;
|
|
1397
|
+
type: string;
|
|
1398
|
+
components?: undefined;
|
|
1399
|
+
} | {
|
|
1400
|
+
components: {
|
|
1401
|
+
internalType: string;
|
|
1402
|
+
name: string;
|
|
1403
|
+
type: string;
|
|
1404
|
+
}[];
|
|
1405
|
+
internalType: string;
|
|
1406
|
+
name: string;
|
|
1407
|
+
type: string;
|
|
1408
|
+
})[];
|
|
1409
|
+
stateMutability: string;
|
|
1410
|
+
type: string;
|
|
1411
|
+
anonymous?: undefined;
|
|
1412
|
+
} | {
|
|
1413
|
+
inputs: {
|
|
1414
|
+
internalType: string;
|
|
1415
|
+
name: string;
|
|
1416
|
+
type: string;
|
|
1417
|
+
}[];
|
|
1418
|
+
name: string;
|
|
1419
|
+
outputs: {
|
|
1420
|
+
components: ({
|
|
1421
|
+
internalType: string;
|
|
1422
|
+
name: string;
|
|
1423
|
+
type: string;
|
|
1424
|
+
components?: undefined;
|
|
1425
|
+
} | {
|
|
1426
|
+
components: {
|
|
1427
|
+
internalType: string;
|
|
1428
|
+
name: string;
|
|
1429
|
+
type: string;
|
|
1430
|
+
}[];
|
|
1431
|
+
internalType: string;
|
|
1432
|
+
name: string;
|
|
1433
|
+
type: string;
|
|
1434
|
+
})[];
|
|
1435
|
+
internalType: string;
|
|
1436
|
+
name: string;
|
|
1437
|
+
type: string;
|
|
1438
|
+
}[];
|
|
1439
|
+
stateMutability: string;
|
|
1440
|
+
type: string;
|
|
1441
|
+
anonymous?: undefined;
|
|
1442
|
+
} | {
|
|
1443
|
+
stateMutability: string;
|
|
1444
|
+
type: string;
|
|
1445
|
+
inputs?: undefined;
|
|
1446
|
+
anonymous?: undefined;
|
|
1447
|
+
name?: undefined;
|
|
1448
|
+
outputs?: undefined;
|
|
1449
|
+
})[];
|
|
1450
|
+
lensAbi: ({
|
|
1451
|
+
inputs: {
|
|
1452
|
+
internalType: string;
|
|
1453
|
+
name: string;
|
|
1454
|
+
type: string;
|
|
1455
|
+
}[];
|
|
1456
|
+
stateMutability: string;
|
|
1457
|
+
type: string;
|
|
1458
|
+
name?: undefined;
|
|
1459
|
+
outputs?: undefined;
|
|
1460
|
+
} | {
|
|
1461
|
+
inputs: never[];
|
|
1462
|
+
name: string;
|
|
1463
|
+
outputs: {
|
|
1464
|
+
internalType: string;
|
|
1465
|
+
name: string;
|
|
1466
|
+
type: string;
|
|
1467
|
+
}[];
|
|
1468
|
+
stateMutability: string;
|
|
1469
|
+
type: string;
|
|
1470
|
+
} | {
|
|
1471
|
+
inputs: {
|
|
1472
|
+
internalType: string;
|
|
1473
|
+
name: string;
|
|
1474
|
+
type: string;
|
|
1475
|
+
}[];
|
|
1476
|
+
name: string;
|
|
1477
|
+
outputs: {
|
|
1478
|
+
components: ({
|
|
1479
|
+
internalType: string;
|
|
1480
|
+
name: string;
|
|
1481
|
+
type: string;
|
|
1482
|
+
components?: undefined;
|
|
1483
|
+
} | {
|
|
1484
|
+
components: {
|
|
1485
|
+
internalType: string;
|
|
1486
|
+
name: string;
|
|
1487
|
+
type: string;
|
|
1488
|
+
}[];
|
|
1489
|
+
internalType: string;
|
|
1490
|
+
name: string;
|
|
1491
|
+
type: string;
|
|
1492
|
+
})[];
|
|
1493
|
+
internalType: string;
|
|
1494
|
+
name: string;
|
|
1495
|
+
type: string;
|
|
1496
|
+
}[];
|
|
1497
|
+
stateMutability: string;
|
|
1498
|
+
type: string;
|
|
1499
|
+
})[];
|
|
1500
|
+
takerAbi: ({
|
|
1501
|
+
inputs: {
|
|
1502
|
+
internalType: string;
|
|
1503
|
+
name: string;
|
|
1504
|
+
type: string;
|
|
1505
|
+
}[];
|
|
1506
|
+
stateMutability: string;
|
|
1507
|
+
type: string;
|
|
1508
|
+
name?: undefined;
|
|
1509
|
+
outputs?: undefined;
|
|
1510
|
+
} | {
|
|
1511
|
+
inputs: {
|
|
1512
|
+
internalType: string;
|
|
1513
|
+
name: string;
|
|
1514
|
+
type: string;
|
|
1515
|
+
}[];
|
|
1516
|
+
name: string;
|
|
1517
|
+
outputs: {
|
|
1518
|
+
internalType: string;
|
|
1519
|
+
name: string;
|
|
1520
|
+
type: string;
|
|
1521
|
+
}[];
|
|
1522
|
+
stateMutability: string;
|
|
1523
|
+
type: string;
|
|
1524
|
+
} | {
|
|
1525
|
+
stateMutability: string;
|
|
1526
|
+
type: string;
|
|
1527
|
+
inputs?: undefined;
|
|
1528
|
+
name?: undefined;
|
|
1529
|
+
outputs?: undefined;
|
|
1530
|
+
})[];
|
|
1531
|
+
chainName: string;
|
|
1532
|
+
chainId: number;
|
|
1533
|
+
twapVersion: number;
|
|
1534
|
+
twapAddress: string;
|
|
1535
|
+
lensAddress: string;
|
|
1536
|
+
bidDelaySeconds: number;
|
|
1537
|
+
minChunkSizeUsd: number;
|
|
1538
|
+
nativeToken: {
|
|
1539
|
+
address: string;
|
|
1540
|
+
decimals: number;
|
|
1541
|
+
symbol: string;
|
|
1542
|
+
logoUrl: string;
|
|
1543
|
+
};
|
|
1544
|
+
wToken: {
|
|
1545
|
+
address: string;
|
|
1546
|
+
decimals: number;
|
|
1547
|
+
symbol: string;
|
|
1548
|
+
logoUrl: string;
|
|
1549
|
+
};
|
|
1111
1550
|
} | {
|
|
1112
1551
|
chainName: string;
|
|
1113
1552
|
chainId: number;
|
package/dist/src/configs.js
CHANGED
|
@@ -11,6 +11,7 @@ const TWAP_json_1 = __importDefault(require("../artifacts/contracts/TWAP.sol/TWA
|
|
|
11
11
|
const Lens_json_1 = __importDefault(require("../artifacts/contracts/periphery/Lens.sol/Lens.json"));
|
|
12
12
|
const Taker_json_1 = __importDefault(require("../artifacts/contracts/periphery/Taker.sol/Taker.json"));
|
|
13
13
|
const legacy_abi_1 = require("./legacy-abi");
|
|
14
|
+
const odos_1 = require("./odos");
|
|
14
15
|
const defaultAbis = {
|
|
15
16
|
twapAbi: TWAP_json_1.default.abi,
|
|
16
17
|
lensAbi: Lens_json_1.default.abi,
|
|
@@ -28,6 +29,17 @@ exports.ChainConfigs = {
|
|
|
28
29
|
symbol: "WETH",
|
|
29
30
|
logoUrl: "https://tokens.1inch.io/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png",
|
|
30
31
|
} }, defaultAbis),
|
|
32
|
+
arb: Object.assign({ chainName: "arb", chainId: 42161, twapVersion: 4, twapAddress: "0xD63430c74C8E70D9dbdCA04C6a9E6E9E929028DA", lensAddress: "0xD13609A8ace04D11Ea2FFE176B69dF77C6d9375E", bidDelaySeconds: 60, minChunkSizeUsd: 10, nativeToken: {
|
|
33
|
+
address: web3_candies_1.zeroAddress,
|
|
34
|
+
decimals: 18,
|
|
35
|
+
symbol: "ETH",
|
|
36
|
+
logoUrl: "https://app.1inch.io/assets/images/network-logos/arbitrum.svg",
|
|
37
|
+
}, wToken: {
|
|
38
|
+
address: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
39
|
+
decimals: 18,
|
|
40
|
+
symbol: "WETH",
|
|
41
|
+
logoUrl: "https://tokens.1inch.io/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png",
|
|
42
|
+
} }, defaultAbis),
|
|
31
43
|
ftm: {
|
|
32
44
|
chainName: "ftm",
|
|
33
45
|
chainId: 250,
|
|
@@ -81,6 +93,7 @@ exports.Configs = {
|
|
|
81
93
|
Pangolin: Object.assign(Object.assign({}, exports.ChainConfigs.avax), { partner: "Pangolin", exchangeAddress: "0xf2d96E7BE676153d202e1453804E2749923C7c5b", exchangeType: "UniswapV2Exchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.Pangolin }),
|
|
82
94
|
PangolinDaas: Object.assign(Object.assign({}, exports.ChainConfigs.avax), { partner: "PangolinDaas", exchangeAddress: "0x1579EED0527781B1A748043AA1f59a3858Ace4a7", exchangeType: "PangolinDaasExchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.Pangolin }),
|
|
83
95
|
QuickSwap: Object.assign(Object.assign({}, exports.ChainConfigs.poly), { partner: "QuickSwap", exchangeAddress: "0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF", exchangeType: "ParaswapExchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.QuickSwap }),
|
|
96
|
+
Chronos: Object.assign(Object.assign({}, exports.ChainConfigs.arb), { partner: "Chronos", exchangeAddress: "0xA0b07F9a11dFb01388149abBdbc5B4f2196600AB", exchangeType: "OdosExchange", pathfinderKey: odos_1.Odos.OnlyDex.Chronos }),
|
|
84
97
|
};
|
|
85
98
|
exports.nativeTokenAddresses = [
|
|
86
99
|
web3_candies_1.zeroAddress,
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
package/dist/src/lib.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import BN from "bignumber.js";
|
|
|
3
3
|
import type { TWAP } from "../typechain-hardhat/contracts";
|
|
4
4
|
import type { Lens } from "../typechain-hardhat/contracts/periphery";
|
|
5
5
|
import { Paraswap } from "./paraswap";
|
|
6
|
+
import { Odos } from "./odos";
|
|
6
7
|
export declare class TWAPLib {
|
|
7
8
|
config: Config;
|
|
8
9
|
maker: string;
|
|
@@ -41,6 +42,10 @@ export declare class TWAPLib {
|
|
|
41
42
|
getOrder(id: number): Promise<Order>;
|
|
42
43
|
cancelOrder(id: number, maxPriorityFeePerGas?: BN.Value, maxFeePerGas?: BN.Value): Promise<void>;
|
|
43
44
|
getAllOrders(): Promise<Order[]>;
|
|
45
|
+
getAllOrdersWithTokens(): Promise<(Order & {
|
|
46
|
+
srcToken: TokenData;
|
|
47
|
+
dstToken: TokenData;
|
|
48
|
+
})[]>;
|
|
44
49
|
parseOrder(r: any): Order;
|
|
45
50
|
getToken(address: string): Promise<TokenData>;
|
|
46
51
|
findSwapDataForBid(order: Order): Promise<{
|
|
@@ -48,14 +53,14 @@ export declare class TWAPLib {
|
|
|
48
53
|
dstToken: TokenData;
|
|
49
54
|
srcNextChunkAmountIn: BN;
|
|
50
55
|
dstNextChunkAmountOut: BN;
|
|
51
|
-
raw: string[] | Paraswap.ParaswapRoute;
|
|
56
|
+
raw: string[] | Paraswap.ParaswapRoute | Odos.OdosRoute;
|
|
52
57
|
data: string;
|
|
53
58
|
}>;
|
|
54
|
-
convertRouteToSwapData(route: Paraswap.ParaswapRoute): Promise<{
|
|
59
|
+
convertRouteToSwapData(route: Paraswap.ParaswapRoute | Odos.OdosRoute): Promise<{
|
|
55
60
|
raw: string[];
|
|
56
61
|
data: string;
|
|
57
62
|
} | {
|
|
58
|
-
raw: Paraswap.ParaswapRoute;
|
|
63
|
+
raw: Paraswap.ParaswapRoute | Odos.OdosRoute;
|
|
59
64
|
data: string;
|
|
60
65
|
}>;
|
|
61
66
|
}
|
package/dist/src/lib.js
CHANGED
|
@@ -19,6 +19,7 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
|
19
19
|
const web3_candies_1 = require("@defi.org/web3-candies");
|
|
20
20
|
const paraswap_1 = require("./paraswap");
|
|
21
21
|
const lodash_1 = __importDefault(require("lodash"));
|
|
22
|
+
const odos_1 = require("./odos");
|
|
22
23
|
class TWAPLib {
|
|
23
24
|
constructor(config, maker, provider) {
|
|
24
25
|
this.config = config;
|
|
@@ -185,7 +186,17 @@ class TWAPLib {
|
|
|
185
186
|
}
|
|
186
187
|
getAllOrders() {
|
|
187
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
return lodash_1.default.map(yield this.lens.methods.makerOrders(this.maker).call(), (o) => this.parseOrder(o));
|
|
189
|
+
return lodash_1.default.filter(lodash_1.default.map(yield this.lens.methods.makerOrders(this.maker).call(), (o) => this.parseOrder(o)), (o) => (0, web3_candies_1.eqIgnoreCase)(o.ask.exchange, this.config.exchangeAddress));
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
getAllOrdersWithTokens() {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
const orders = yield this.getAllOrders();
|
|
195
|
+
const tokens = yield Promise.all(lodash_1.default.map(lodash_1.default.uniq(lodash_1.default.concat(lodash_1.default.map(orders, (o) => o.ask.srcToken), lodash_1.default.map(orders, (o) => o.ask.dstToken))), (a) => this.getToken(a)));
|
|
196
|
+
return lodash_1.default.map(orders, (o) => lodash_1.default.merge(o, {
|
|
197
|
+
srcToken: lodash_1.default.find(tokens, (t) => (0, web3_candies_1.eqIgnoreCase)(t.address, o.ask.srcToken)),
|
|
198
|
+
dstToken: lodash_1.default.find(tokens, (t) => (0, web3_candies_1.eqIgnoreCase)(t.address, o.ask.dstToken)),
|
|
199
|
+
}));
|
|
189
200
|
});
|
|
190
201
|
}
|
|
191
202
|
parseOrder(r) {
|
|
@@ -239,10 +250,18 @@ class TWAPLib {
|
|
|
239
250
|
this.getToken(order.ask.srcToken),
|
|
240
251
|
this.getToken(order.ask.dstToken),
|
|
241
252
|
]);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
253
|
+
if (this.config.exchangeType === "OdosExchange") {
|
|
254
|
+
const route = yield odos_1.Odos.findRoute(this.config.chainId, srcToken, dstToken, srcNextChunkAmountIn, this.config.exchangeAddress, this.config.pathfinderKey);
|
|
255
|
+
const dstNextChunkAmountOut = route.dstAmountOut;
|
|
256
|
+
const { raw, data } = yield this.convertRouteToSwapData(route);
|
|
257
|
+
return { srcToken, dstToken, srcNextChunkAmountIn, dstNextChunkAmountOut, raw, data };
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const route = yield paraswap_1.Paraswap.findRoute(this.config.chainId, srcToken, dstToken, srcNextChunkAmountIn, this.config.pathfinderKey);
|
|
261
|
+
const dstNextChunkAmountOut = (0, bignumber_js_1.default)(route.destAmount);
|
|
262
|
+
const { raw, data } = yield this.convertRouteToSwapData(route);
|
|
263
|
+
return { srcToken, dstToken, srcNextChunkAmountIn, dstNextChunkAmountOut, raw, data };
|
|
264
|
+
}
|
|
246
265
|
});
|
|
247
266
|
}
|
|
248
267
|
convertRouteToSwapData(route) {
|
|
@@ -260,6 +279,11 @@ class TWAPLib {
|
|
|
260
279
|
raw: route,
|
|
261
280
|
data: yield paraswap_1.Paraswap.buildSwapData(route, this.config.twapAddress),
|
|
262
281
|
};
|
|
282
|
+
case "OdosExchange":
|
|
283
|
+
return {
|
|
284
|
+
raw: route,
|
|
285
|
+
data: route.data,
|
|
286
|
+
};
|
|
263
287
|
default:
|
|
264
288
|
throw new Error(`unhandled exchange ${this.config.exchangeType}`);
|
|
265
289
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BN } from "@defi.org/web3-candies";
|
|
2
|
+
import { TokenData } from "./configs";
|
|
3
|
+
export declare namespace Odos {
|
|
4
|
+
enum OnlyDex {
|
|
5
|
+
Chronos = "Chronos Stable,Chronos Volatile,Wrapped Ether"
|
|
6
|
+
}
|
|
7
|
+
interface OdosRoute {
|
|
8
|
+
pathId: string;
|
|
9
|
+
dstAmountOut: BN;
|
|
10
|
+
srcUsd: BN;
|
|
11
|
+
data: string;
|
|
12
|
+
}
|
|
13
|
+
function priceUsd(chainId: number, token: TokenData): Promise<BN>;
|
|
14
|
+
function findRoute(chainId: number, src: TokenData, dst: TokenData, amountIn: BN.Value, exchangeAdapter: string, onlyDex?: OnlyDex): Promise<OdosRoute>;
|
|
15
|
+
}
|
package/dist/src/odos.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Odos = void 0;
|
|
13
|
+
const web3_candies_1 = require("@defi.org/web3-candies");
|
|
14
|
+
const configs_1 = require("./configs");
|
|
15
|
+
var Odos;
|
|
16
|
+
(function (Odos) {
|
|
17
|
+
const URL = "https://api.odos.xyz";
|
|
18
|
+
let OnlyDex;
|
|
19
|
+
(function (OnlyDex) {
|
|
20
|
+
OnlyDex["Chronos"] = "Chronos Stable,Chronos Volatile,Wrapped Ether";
|
|
21
|
+
})(OnlyDex = Odos.OnlyDex || (Odos.OnlyDex = {}));
|
|
22
|
+
function priceUsd(chainId, token) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
token = (0, configs_1.isNativeAddress)(token.address) ? (0, configs_1.chainConfig)(chainId).wToken : token;
|
|
25
|
+
const r = yield findRoute(chainId, token, (0, configs_1.chainConfig)(chainId).nativeToken, (0, web3_candies_1.BN)(10).pow(token.decimals), web3_candies_1.zeroAddress);
|
|
26
|
+
return r.srcUsd;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
Odos.priceUsd = priceUsd;
|
|
30
|
+
function findRoute(chainId, src, dst, amountIn, exchangeAdapter, onlyDex) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const response = yield fetch(`${URL}/sor/quote`, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: { "Content-Type": "application/json", accept: "application/json" },
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
chainId,
|
|
37
|
+
inputTokens: [{ tokenAddress: src.address, amount: amountIn.toString() }],
|
|
38
|
+
outputTokens: [{ tokenAddress: dst.address, proportion: 1 }],
|
|
39
|
+
slippageLimitPercent: 50,
|
|
40
|
+
userAddr: exchangeAdapter,
|
|
41
|
+
sourceWhitelist: (onlyDex === null || onlyDex === void 0 ? void 0 : onlyDex.split(",")) || [],
|
|
42
|
+
simulate: false,
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
if (response.status < 200 || response.status >= 400)
|
|
46
|
+
throw new Error(`${response.statusText}`);
|
|
47
|
+
const j = yield response.json();
|
|
48
|
+
const pathId = j.pathId;
|
|
49
|
+
const srcUsd = (0, web3_candies_1.bn)(j.inValues[0]);
|
|
50
|
+
const dstAmountOut = (0, web3_candies_1.bn)(j.outAmounts[0]);
|
|
51
|
+
const data = yield buildSwapData(pathId, dstAmountOut, exchangeAdapter);
|
|
52
|
+
return {
|
|
53
|
+
pathId,
|
|
54
|
+
dstAmountOut,
|
|
55
|
+
srcUsd,
|
|
56
|
+
data,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
Odos.findRoute = findRoute;
|
|
61
|
+
function buildSwapData(pathId, dstAmountOut, exchangeAdapter) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const response = yield fetch(`${URL}/sor/assemble`, {
|
|
65
|
+
method: "POST",
|
|
66
|
+
headers: { accept: "application/json", "Content-Type": "application/json" },
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
pathId,
|
|
69
|
+
userAddr: exchangeAdapter,
|
|
70
|
+
simulate: false,
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
if (response.status < 200 || response.status >= 400)
|
|
74
|
+
throw new Error(`${response.statusText}`);
|
|
75
|
+
const swapData = (_b = (_a = (yield response.json())) === null || _a === void 0 ? void 0 : _a.transaction) === null || _b === void 0 ? void 0 : _b.data;
|
|
76
|
+
if (!swapData)
|
|
77
|
+
throw new Error(`invalid swap data from Odos`);
|
|
78
|
+
return (0, web3_candies_1.web3)().eth.abi.encodeParameters(["uint256", "bytes"], [dstAmountOut.toFixed(0), swapData]);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
})(Odos = exports.Odos || (exports.Odos = {}));
|
package/dist/src/paraswap.js
CHANGED
|
@@ -64,7 +64,7 @@ var Paraswap;
|
|
|
64
64
|
amount: amountIn.toString(),
|
|
65
65
|
network: chainId.toString(),
|
|
66
66
|
side: "SELL",
|
|
67
|
-
maxImpact: "
|
|
67
|
+
maxImpact: "50",
|
|
68
68
|
includeDEXS: onlyDex || "",
|
|
69
69
|
partner: ((_b = (_a = onlyDex === null || onlyDex === void 0 ? void 0 : onlyDex.toLowerCase()) === null || _a === void 0 ? void 0 : _a.split(",")) === null || _b === void 0 ? void 0 : _b[0]) || "",
|
|
70
70
|
otherExchangePrices: otherExchanges.toString(),
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type BigNumber from "bignumber.js";
|
|
3
|
+
import type { ContractOptions } from "web3-eth-contract";
|
|
4
|
+
import type { EventLog } from "web3-core";
|
|
5
|
+
import type { EventEmitter } from "events";
|
|
6
|
+
import type { Callback, NonPayableTransactionObject, BlockType, BaseContract } from "../../types";
|
|
7
|
+
export interface EventOptions {
|
|
8
|
+
filter?: object;
|
|
9
|
+
fromBlock?: BlockType;
|
|
10
|
+
topics?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface OdosExchange extends BaseContract {
|
|
13
|
+
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): OdosExchange;
|
|
14
|
+
clone(): OdosExchange;
|
|
15
|
+
methods: {
|
|
16
|
+
getAmountOut(arg0: string, arg1: string, arg2: number | string | BigNumber, arg3: string | number[], bidData: string | number[]): NonPayableTransactionObject<string>;
|
|
17
|
+
odos(): NonPayableTransactionObject<string>;
|
|
18
|
+
swap(_srcToken: string, _dstToken: string, amountIn: number | string | BigNumber, amountOutMin: number | string | BigNumber, arg4: string | number[], bidData: string | number[]): NonPayableTransactionObject<void>;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
22
|
+
};
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbs-network/twap",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/orbs-network/twap.git"
|
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"prebuild": "npm run prettier && npm run typechain",
|
|
26
26
|
"build": "hardhat compile && solhint 'contracts/**/*.sol' && tsc && hardhat github-pages",
|
|
27
27
|
"prepublishOnly": "npm run build",
|
|
28
|
-
"test:logs": "for t in eth ftm poly avax; do DEBUG=web3-candies npm run test:$t -- --logs; done",
|
|
29
|
-
"test": "for t in eth ftm poly avax; do npm run test:$t; done",
|
|
28
|
+
"test:logs": "for t in eth ftm poly avax arb; do DEBUG=web3-candies npm run test:$t -- --logs; done",
|
|
29
|
+
"test": "for t in eth ftm poly avax arb; do npm run test:$t; done",
|
|
30
30
|
"test:eth": "NETWORK=ETH BLOCK=14905987 hardhat test",
|
|
31
31
|
"test:ftm": "NETWORK=FTM BLOCK=39800909 hardhat test",
|
|
32
32
|
"test:poly": "NETWORK=POLY BLOCK=29174252 hardhat test",
|
|
33
|
-
"test:avax": "NETWORK=AVAX BLOCK=15609313 hardhat test"
|
|
33
|
+
"test:avax": "NETWORK=AVAX BLOCK=15609313 hardhat test",
|
|
34
|
+
"test:arb": "NETWORK=ARB hardhat test"
|
|
34
35
|
},
|
|
35
36
|
"prettier": {
|
|
36
37
|
"printWidth": 120
|