@orbs-network/twap 1.14.3 → 1.16.0

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,7 +18,9 @@ export declare enum ParaswapOnlyDex {
18
18
  Chronos = "Chronos"
19
19
  }
20
20
  export declare enum OdosOnlyDex {
21
- Chronos = "Chronos Stable,Chronos Volatile,Wrapped Ether"
21
+ Chronos = "Chronos Stable,Chronos Volatile,Wrapped Ether",
22
+ BaseSwap = "BaseSwap,BaseSwapX",
23
+ Arbidex = "Arbidex Classic,Arbidex Quantum"
22
24
  }
23
25
  export declare enum OpenOceanOnlyDex {
24
26
  Thena = "43,47"
@@ -1453,6 +1455,241 @@ export declare const ChainConfigs: {
1453
1455
  logoUrl: string;
1454
1456
  };
1455
1457
  };
1458
+ base: {
1459
+ twapAbi: ({
1460
+ inputs: {
1461
+ internalType: string;
1462
+ name: string;
1463
+ type: string;
1464
+ }[];
1465
+ stateMutability: string;
1466
+ type: string;
1467
+ anonymous?: undefined;
1468
+ name?: undefined;
1469
+ outputs?: undefined;
1470
+ } | {
1471
+ anonymous: boolean;
1472
+ inputs: ({
1473
+ indexed: boolean;
1474
+ internalType: string;
1475
+ name: string;
1476
+ type: string;
1477
+ components?: undefined;
1478
+ } | {
1479
+ components: {
1480
+ internalType: string;
1481
+ name: string;
1482
+ type: string;
1483
+ }[];
1484
+ indexed: boolean;
1485
+ internalType: string;
1486
+ name: string;
1487
+ type: string;
1488
+ })[];
1489
+ name: string;
1490
+ type: string;
1491
+ stateMutability?: undefined;
1492
+ outputs?: undefined;
1493
+ } | {
1494
+ inputs: {
1495
+ components: {
1496
+ internalType: string;
1497
+ name: string;
1498
+ type: string;
1499
+ }[];
1500
+ internalType: string;
1501
+ name: string;
1502
+ type: string;
1503
+ }[];
1504
+ name: string;
1505
+ outputs: {
1506
+ internalType: string;
1507
+ name: string;
1508
+ type: string;
1509
+ }[];
1510
+ stateMutability: string;
1511
+ type: string;
1512
+ anonymous?: undefined;
1513
+ } | {
1514
+ inputs: {
1515
+ internalType: string;
1516
+ name: string;
1517
+ type: string;
1518
+ }[];
1519
+ name: string;
1520
+ outputs: ({
1521
+ internalType: string;
1522
+ name: string;
1523
+ type: string;
1524
+ components?: undefined;
1525
+ } | {
1526
+ components: {
1527
+ internalType: string;
1528
+ name: string;
1529
+ type: string;
1530
+ }[];
1531
+ internalType: string;
1532
+ name: string;
1533
+ type: string;
1534
+ })[];
1535
+ stateMutability: string;
1536
+ type: string;
1537
+ anonymous?: undefined;
1538
+ } | {
1539
+ inputs: {
1540
+ internalType: string;
1541
+ name: string;
1542
+ type: string;
1543
+ }[];
1544
+ name: string;
1545
+ outputs: {
1546
+ components: ({
1547
+ internalType: string;
1548
+ name: string;
1549
+ type: string;
1550
+ components?: undefined;
1551
+ } | {
1552
+ components: {
1553
+ internalType: string;
1554
+ name: string;
1555
+ type: string;
1556
+ }[];
1557
+ internalType: string;
1558
+ name: string;
1559
+ type: string;
1560
+ })[];
1561
+ internalType: string;
1562
+ name: string;
1563
+ type: string;
1564
+ }[];
1565
+ stateMutability: string;
1566
+ type: string;
1567
+ anonymous?: undefined;
1568
+ } | {
1569
+ stateMutability: string;
1570
+ type: string;
1571
+ inputs?: undefined;
1572
+ anonymous?: undefined;
1573
+ name?: undefined;
1574
+ outputs?: undefined;
1575
+ })[];
1576
+ lensAbi: ({
1577
+ inputs: {
1578
+ internalType: string;
1579
+ name: string;
1580
+ type: string;
1581
+ }[];
1582
+ stateMutability: string;
1583
+ type: string;
1584
+ name?: undefined;
1585
+ outputs?: undefined;
1586
+ } | {
1587
+ inputs: never[];
1588
+ name: string;
1589
+ outputs: {
1590
+ internalType: string;
1591
+ name: string;
1592
+ type: string;
1593
+ }[];
1594
+ stateMutability: string;
1595
+ type: string;
1596
+ } | {
1597
+ inputs: {
1598
+ internalType: string;
1599
+ name: string;
1600
+ type: string;
1601
+ }[];
1602
+ name: string;
1603
+ outputs: {
1604
+ components: ({
1605
+ internalType: string;
1606
+ name: string;
1607
+ type: string;
1608
+ components?: undefined;
1609
+ } | {
1610
+ components: {
1611
+ internalType: string;
1612
+ name: string;
1613
+ type: string;
1614
+ }[];
1615
+ internalType: string;
1616
+ name: string;
1617
+ type: string;
1618
+ })[];
1619
+ internalType: string;
1620
+ name: string;
1621
+ type: string;
1622
+ }[];
1623
+ stateMutability: string;
1624
+ type: string;
1625
+ })[];
1626
+ takerAbi: ({
1627
+ inputs: {
1628
+ internalType: string;
1629
+ name: string;
1630
+ type: string;
1631
+ }[];
1632
+ stateMutability: string;
1633
+ type: string;
1634
+ anonymous?: undefined;
1635
+ name?: undefined;
1636
+ outputs?: undefined;
1637
+ } | {
1638
+ anonymous: boolean;
1639
+ inputs: {
1640
+ indexed: boolean;
1641
+ internalType: string;
1642
+ name: string;
1643
+ type: string;
1644
+ }[];
1645
+ name: string;
1646
+ type: string;
1647
+ stateMutability?: undefined;
1648
+ outputs?: undefined;
1649
+ } | {
1650
+ inputs: {
1651
+ internalType: string;
1652
+ name: string;
1653
+ type: string;
1654
+ }[];
1655
+ name: string;
1656
+ outputs: {
1657
+ internalType: string;
1658
+ name: string;
1659
+ type: string;
1660
+ }[];
1661
+ stateMutability: string;
1662
+ type: string;
1663
+ anonymous?: undefined;
1664
+ } | {
1665
+ stateMutability: string;
1666
+ type: string;
1667
+ inputs?: undefined;
1668
+ anonymous?: undefined;
1669
+ name?: undefined;
1670
+ outputs?: undefined;
1671
+ })[];
1672
+ chainName: string;
1673
+ chainId: number;
1674
+ twapVersion: number;
1675
+ twapAddress: string;
1676
+ lensAddress: string;
1677
+ bidDelaySeconds: number;
1678
+ minChunkSizeUsd: number;
1679
+ nativeToken: {
1680
+ address: string;
1681
+ symbol: string;
1682
+ decimals: number;
1683
+ logoUrl: string;
1684
+ };
1685
+ wToken: {
1686
+ symbol: string;
1687
+ address: string;
1688
+ decimals: number;
1689
+ weth: boolean;
1690
+ logoUrl: string;
1691
+ };
1692
+ };
1456
1693
  };
1457
1694
  export declare const Configs: {
1458
1695
  SpiritSwap: Config;
@@ -1461,6 +1698,8 @@ export declare const Configs: {
1461
1698
  PangolinDaas: Config;
1462
1699
  QuickSwap: Config;
1463
1700
  Chronos: Config;
1701
+ BaseSwap: Config;
1702
+ Arbidex: Config;
1464
1703
  Thena: Config;
1465
1704
  PancakeSwap: Config;
1466
1705
  };
@@ -2868,4 +3107,238 @@ export declare const chainConfig: (chainId: number) => {
2868
3107
  weth: boolean;
2869
3108
  logoUrl: string;
2870
3109
  };
3110
+ } | {
3111
+ twapAbi: ({
3112
+ inputs: {
3113
+ internalType: string;
3114
+ name: string;
3115
+ type: string;
3116
+ }[];
3117
+ stateMutability: string;
3118
+ type: string;
3119
+ anonymous?: undefined;
3120
+ name?: undefined;
3121
+ outputs?: undefined;
3122
+ } | {
3123
+ anonymous: boolean;
3124
+ inputs: ({
3125
+ indexed: boolean;
3126
+ internalType: string;
3127
+ name: string;
3128
+ type: string;
3129
+ components?: undefined;
3130
+ } | {
3131
+ components: {
3132
+ internalType: string;
3133
+ name: string;
3134
+ type: string;
3135
+ }[];
3136
+ indexed: boolean;
3137
+ internalType: string;
3138
+ name: string;
3139
+ type: string;
3140
+ })[];
3141
+ name: string;
3142
+ type: string;
3143
+ stateMutability?: undefined;
3144
+ outputs?: undefined;
3145
+ } | {
3146
+ inputs: {
3147
+ components: {
3148
+ internalType: string;
3149
+ name: string;
3150
+ type: string;
3151
+ }[];
3152
+ internalType: string;
3153
+ name: string;
3154
+ type: string;
3155
+ }[];
3156
+ name: string;
3157
+ outputs: {
3158
+ internalType: string;
3159
+ name: string;
3160
+ type: string;
3161
+ }[];
3162
+ stateMutability: string;
3163
+ type: string;
3164
+ anonymous?: undefined;
3165
+ } | {
3166
+ inputs: {
3167
+ internalType: string;
3168
+ name: string;
3169
+ type: string;
3170
+ }[];
3171
+ name: string;
3172
+ outputs: ({
3173
+ internalType: string;
3174
+ name: string;
3175
+ type: string;
3176
+ components?: undefined;
3177
+ } | {
3178
+ components: {
3179
+ internalType: string;
3180
+ name: string;
3181
+ type: string;
3182
+ }[];
3183
+ internalType: string;
3184
+ name: string;
3185
+ type: string;
3186
+ })[];
3187
+ stateMutability: string;
3188
+ type: string;
3189
+ anonymous?: undefined;
3190
+ } | {
3191
+ inputs: {
3192
+ internalType: string;
3193
+ name: string;
3194
+ type: string;
3195
+ }[];
3196
+ name: string;
3197
+ outputs: {
3198
+ components: ({
3199
+ internalType: string;
3200
+ name: string;
3201
+ type: string;
3202
+ components?: undefined;
3203
+ } | {
3204
+ components: {
3205
+ internalType: string;
3206
+ name: string;
3207
+ type: string;
3208
+ }[];
3209
+ internalType: string;
3210
+ name: string;
3211
+ type: string;
3212
+ })[];
3213
+ internalType: string;
3214
+ name: string;
3215
+ type: string;
3216
+ }[];
3217
+ stateMutability: string;
3218
+ type: string;
3219
+ anonymous?: undefined;
3220
+ } | {
3221
+ stateMutability: string;
3222
+ type: string;
3223
+ inputs?: undefined;
3224
+ anonymous?: undefined;
3225
+ name?: undefined;
3226
+ outputs?: undefined;
3227
+ })[];
3228
+ lensAbi: ({
3229
+ inputs: {
3230
+ internalType: string;
3231
+ name: string;
3232
+ type: string;
3233
+ }[];
3234
+ stateMutability: string;
3235
+ type: string;
3236
+ name?: undefined;
3237
+ outputs?: undefined;
3238
+ } | {
3239
+ inputs: never[];
3240
+ name: string;
3241
+ outputs: {
3242
+ internalType: string;
3243
+ name: string;
3244
+ type: string;
3245
+ }[];
3246
+ stateMutability: string;
3247
+ type: string;
3248
+ } | {
3249
+ inputs: {
3250
+ internalType: string;
3251
+ name: string;
3252
+ type: string;
3253
+ }[];
3254
+ name: string;
3255
+ outputs: {
3256
+ components: ({
3257
+ internalType: string;
3258
+ name: string;
3259
+ type: string;
3260
+ components?: undefined;
3261
+ } | {
3262
+ components: {
3263
+ internalType: string;
3264
+ name: string;
3265
+ type: string;
3266
+ }[];
3267
+ internalType: string;
3268
+ name: string;
3269
+ type: string;
3270
+ })[];
3271
+ internalType: string;
3272
+ name: string;
3273
+ type: string;
3274
+ }[];
3275
+ stateMutability: string;
3276
+ type: string;
3277
+ })[];
3278
+ takerAbi: ({
3279
+ inputs: {
3280
+ internalType: string;
3281
+ name: string;
3282
+ type: string;
3283
+ }[];
3284
+ stateMutability: string;
3285
+ type: string;
3286
+ anonymous?: undefined;
3287
+ name?: undefined;
3288
+ outputs?: undefined;
3289
+ } | {
3290
+ anonymous: boolean;
3291
+ inputs: {
3292
+ indexed: boolean;
3293
+ internalType: string;
3294
+ name: string;
3295
+ type: string;
3296
+ }[];
3297
+ name: string;
3298
+ type: string;
3299
+ stateMutability?: undefined;
3300
+ outputs?: undefined;
3301
+ } | {
3302
+ inputs: {
3303
+ internalType: string;
3304
+ name: string;
3305
+ type: string;
3306
+ }[];
3307
+ name: string;
3308
+ outputs: {
3309
+ internalType: string;
3310
+ name: string;
3311
+ type: string;
3312
+ }[];
3313
+ stateMutability: string;
3314
+ type: string;
3315
+ anonymous?: undefined;
3316
+ } | {
3317
+ stateMutability: string;
3318
+ type: string;
3319
+ inputs?: undefined;
3320
+ anonymous?: undefined;
3321
+ name?: undefined;
3322
+ outputs?: undefined;
3323
+ })[];
3324
+ chainName: string;
3325
+ chainId: number;
3326
+ twapVersion: number;
3327
+ twapAddress: string;
3328
+ lensAddress: string;
3329
+ bidDelaySeconds: number;
3330
+ minChunkSizeUsd: number;
3331
+ nativeToken: {
3332
+ address: string;
3333
+ symbol: string;
3334
+ decimals: number;
3335
+ logoUrl: string;
3336
+ };
3337
+ wToken: {
3338
+ symbol: string;
3339
+ address: string;
3340
+ decimals: number;
3341
+ weth: boolean;
3342
+ logoUrl: string;
3343
+ };
2871
3344
  };
@@ -52,6 +52,8 @@ var ParaswapOnlyDex;
52
52
  var OdosOnlyDex;
53
53
  (function (OdosOnlyDex) {
54
54
  OdosOnlyDex["Chronos"] = "Chronos Stable,Chronos Volatile,Wrapped Ether";
55
+ OdosOnlyDex["BaseSwap"] = "BaseSwap,BaseSwapX";
56
+ OdosOnlyDex["Arbidex"] = "Arbidex Classic,Arbidex Quantum";
55
57
  })(OdosOnlyDex = exports.OdosOnlyDex || (exports.OdosOnlyDex = {}));
56
58
  var OpenOceanOnlyDex;
57
59
  (function (OpenOceanOnlyDex) {
@@ -69,6 +71,7 @@ exports.ChainConfigs = {
69
71
  ftm: Object.assign({ chainName: "ftm", chainId: 250, twapVersion: 4, twapAddress: "0xdb55107c17Cb433D322052BFA36069fDf7Cb1031", lensAddress: "0x6E78fA5d48aedF302e48ef3fbD97FD11b4e98d8B", bidDelaySeconds: 60, minChunkSizeUsd: 10, nativeToken: web3_candies_1.networks.ftm.native, wToken: web3_candies_1.networks.ftm.wToken }, defaultAbis),
70
72
  poly: Object.assign({ chainName: "poly", chainId: 137, twapVersion: 4, twapAddress: "0xceFf098C9199c5d9cf24078dc14Eb8F787631cC0", lensAddress: "0x8ffde23Fba2d7Aea9C3CBf2d5B7B533BB46754a8", bidDelaySeconds: 60, minChunkSizeUsd: 10, nativeToken: web3_candies_1.networks.poly.native, wToken: web3_candies_1.networks.poly.wToken }, defaultAbis),
71
73
  avax: Object.assign({ chainName: "avax", chainId: 43114, twapVersion: 4, twapAddress: "0xF2687e119B0A4aB00bED9c9F425403566D605020", lensAddress: "0xfA1e5Da0Cbb780b891Cd635264354a9F4d3A726E", bidDelaySeconds: 60, minChunkSizeUsd: 10, nativeToken: web3_candies_1.networks.avax.native, wToken: web3_candies_1.networks.avax.wToken }, defaultAbis),
74
+ base: Object.assign({ chainName: "base", chainId: 8453, twapVersion: 4, twapAddress: "0x25a0A78f5ad07b2474D3D42F1c1432178465936d", lensAddress: "0x3b7C090857a4068e16396550423ebadae502768F", bidDelaySeconds: 60, minChunkSizeUsd: 10, nativeToken: web3_candies_1.networks.base.native, wToken: web3_candies_1.networks.base.wToken }, defaultAbis),
72
75
  };
73
76
  exports.Configs = {
74
77
  SpiritSwap: Object.assign(Object.assign({}, exports.ChainConfigs.ftm), { twapVersion: 3, twapAddress: "0xBb9F828E34A1327607c3e4eA3dD35891398DD5EE", lensAddress: "0x042799657E971855eD619046aeDf7F30DB56d2D6", twapAbi: legacyAbis.twapAbiV3, lensAbi: legacyAbis.lensAbiV3, takerAbi: legacyAbis.takerAbiV3, name: "SpiritSwap", partner: "Orbs:TWAP:SpiritSwap", exchangeAddress: "0xAd19179201be5A51D1cBd3bB2fC651BB05822404", exchangeType: "ParaswapExchange", pathfinderKey: ParaswapOnlyDex.SpiritSwap }),
@@ -77,6 +80,8 @@ exports.Configs = {
77
80
  PangolinDaas: Object.assign(Object.assign({}, exports.ChainConfigs.avax), { name: "PangolinDaas", partner: "Orbs:TWAP:PangolinDaas", exchangeAddress: "0x1579EED0527781B1A748043AA1f59a3858Ace4a7", exchangeType: "PangolinDaasExchange", pathfinderKey: ParaswapOnlyDex.Pangolin }),
78
81
  QuickSwap: Object.assign(Object.assign({}, exports.ChainConfigs.poly), { name: "QuickSwap", partner: "Orbs:TWAP:QuickSwap", exchangeAddress: "0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF", exchangeType: "ParaswapExchange", pathfinderKey: ParaswapOnlyDex.QuickSwap }),
79
82
  Chronos: Object.assign(Object.assign({}, exports.ChainConfigs.arb), { name: "Chronos", partner: "Orbs:TWAP:Chronos", exchangeAddress: "0xA0b07F9a11dFb01388149abBdbc5B4f2196600AB", exchangeType: "OdosExchange", pathfinderKey: OdosOnlyDex.Chronos }),
83
+ BaseSwap: Object.assign(Object.assign({}, exports.ChainConfigs.base), { name: "BaseSwap", partner: "Orbs:TWAP:BaseSwap", exchangeAddress: "0xD13609A8ace04D11Ea2FFE176B69dF77C6d9375E", exchangeType: "OdosExchange", pathfinderKey: OdosOnlyDex.BaseSwap }),
84
+ Arbidex: Object.assign(Object.assign({}, exports.ChainConfigs.arb), { name: "Arbidex", partner: "Orbs:TWAP:Arbidex", exchangeAddress: "0x7D73DEa3e1b8115fA2f0814B4960cBF3B38eF04a", exchangeType: "OdosExchange", pathfinderKey: OdosOnlyDex.Arbidex }),
80
85
  Thena: Object.assign(Object.assign({}, exports.ChainConfigs.bsc), { name: "Thena", partner: "Orbs:TWAP:Thena", exchangeAddress: "0xD63430c74C8E70D9dbdCA04C6a9E6E9E929028DA", exchangeType: "ParaswapExchange", pathfinderKey: ParaswapOnlyDex.Thena }),
81
86
  PancakeSwap: Object.assign(Object.assign({}, exports.ChainConfigs.bsc), { name: "PancakeSwap", partner: "Orbs:TWAP:PancakeSwap", exchangeAddress: "0x3dD428151c697Aa1a3E5d0ee6A52768E70D85daE", exchangeType: "ParaswapExchange", pathfinderKey: ParaswapOnlyDex.PancakeSwap }),
82
87
  };
package/dist/src/lib.js CHANGED
@@ -244,8 +244,14 @@ class TWAPLib {
244
244
  priceUsd(token) {
245
245
  return __awaiter(this, void 0, void 0, function* () {
246
246
  token = (0, web3_candies_1.isNativeAddress)(token.address) ? this.config.wToken : token;
247
- const r = yield paraswap_1.Paraswap.findRoute(this.config.chainId, token, { address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", symbol: "NATIVE", decimals: 18 }, (0, bignumber_js_1.default)(10).pow(token.decimals));
248
- return r.srcUsd.toNumber();
247
+ try {
248
+ const r = yield paraswap_1.Paraswap.findRoute(this.config.chainId, token, { address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", symbol: "NATIVE", decimals: 18 }, (0, bignumber_js_1.default)(10).pow(token.decimals));
249
+ return r.srcUsd.toNumber();
250
+ }
251
+ catch (e) {
252
+ const r = yield odos_1.Odos.findRoute(this.config.chainId, token, this.config.nativeToken, (0, bignumber_js_1.default)(10).pow(token.decimals));
253
+ return r.srcUsd.toNumber();
254
+ }
249
255
  });
250
256
  }
251
257
  findRoute(srcToken, dstToken, srcAmount) {
package/dist/src/odos.js CHANGED
@@ -16,7 +16,7 @@ var Odos;
16
16
  const URL = "https://api.odos.xyz";
17
17
  function findRoute(chainId, src, dst, amountIn, exchangeAdapter = web3_candies_1.zeroAddress, onlyDex, partner) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
- const response = yield fetch(`${URL}/sor/quote`, {
19
+ const response = yield fetch(`${URL}/sor/quote/v2`, {
20
20
  method: "POST",
21
21
  headers: { "Content-Type": "application/json", accept: "application/json" },
22
22
  body: JSON.stringify({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbs-network/twap",
3
- "version": "1.14.3",
3
+ "version": "1.16.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/orbs-network/twap.git"
@@ -33,7 +33,8 @@
33
33
  "test:avax": "NETWORK=AVAX hardhat test",
34
34
  "test:arb": "NETWORK=ARB hardhat test",
35
35
  "test:bsc": "NETWORK=BSC hardhat test",
36
- "test:glmr": "NETWORK=GLMR hardhat test"
36
+ "test:glmr": "NETWORK=GLMR hardhat test",
37
+ "test:base": "NETWORK=BASE hardhat test"
37
38
  },
38
39
  "prettier": {
39
40
  "printWidth": 120