@paraswap/dex-lib 2.42.4-baseswap.3 → 2.42.5

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.
@@ -0,0 +1,11 @@
1
+ import { DexParams } from '../gmx/types';
2
+ import { DexConfigMap } from '../../types';
3
+ export declare const MorphexConfig: DexConfigMap<DexParams>;
4
+ export declare const Adapters: {
5
+ [chainId: number]: {
6
+ [side: string]: {
7
+ name: string;
8
+ index: number;
9
+ }[] | null;
10
+ };
11
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Adapters = exports.MorphexConfig = void 0;
4
+ const constants_1 = require("../../constants");
5
+ exports.MorphexConfig = {
6
+ Morphex: {
7
+ [constants_1.Network.FANTOM]: {
8
+ vault: '0x245cD6d33578de9aF75a3C0c636c726b1A8cbdAa',
9
+ reader: '0xcA47b9b612a152ece991F31d8D3547D73BaF2Ecc',
10
+ priceFeed: '0x7a451DE877CbB6551AACa671d0458B6f9dF1e29A',
11
+ fastPriceFeed: '0x7f54C35A38D89fcf5Fe516206E6628745ed38CC7',
12
+ fastPriceEvents: '0xDc7C389be5da32e326A261dC0126feCa7AE04d79',
13
+ usdg: '0xe135c7BFfda932b5B862Da442cF4CbC4d43DC3Ad',
14
+ },
15
+ [constants_1.Network.BSC]: {
16
+ vault: '0x46940Dc651bFe3F2CC3E04cf9dC5579B50Cf0765',
17
+ reader: '0x49A97680938B4F1f73816d1B70C3Ab801FAd124B',
18
+ priceFeed: '0x0144b19D1B9338fC7C286d6767bd9b29F0347f27',
19
+ fastPriceFeed: '0x55e6e6A968e485abEC1e1d957f408586e45a4f99',
20
+ fastPriceEvents: '0x491Df61db853761d42C4F38BeD220E9D807143dE',
21
+ usdg: '0x548f93779fBC992010C07467cBaf329DD5F059B7',
22
+ },
23
+ },
24
+ };
25
+ exports.Adapters = {
26
+ [constants_1.Network.FANTOM]: {
27
+ [constants_1.SwapSide.SELL]: [
28
+ {
29
+ name: 'FantomAdapter01',
30
+ index: 6, // TODO: there is no Morphex adapter
31
+ },
32
+ ],
33
+ },
34
+ [constants_1.Network.BSC]: {
35
+ [constants_1.SwapSide.SELL]: [
36
+ {
37
+ name: 'BscAdapter01',
38
+ index: 6, // TODO: there is no Morphex adapter
39
+ },
40
+ ],
41
+ },
42
+ };
43
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/morphex/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,aAAa,GAA4B;IACpD,OAAO,EAAE;QACP,CAAC,mBAAO,CAAC,MAAM,CAAC,EAAE;YAChB,KAAK,EAAE,4CAA4C;YACnD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;YACvD,aAAa,EAAE,4CAA4C;YAC3D,eAAe,EAAE,4CAA4C;YAC7D,IAAI,EAAE,4CAA4C;SACnD;QACD,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE;YACb,KAAK,EAAE,4CAA4C;YACnD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;YACvD,aAAa,EAAE,4CAA4C;YAC3D,eAAe,EAAE,4CAA4C;YAC7D,IAAI,EAAE,4CAA4C;SACnD;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAIjB;IACF,CAAC,mBAAO,CAAC,MAAM,CAAC,EAAE;QAChB,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE;YACf;gBACE,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,CAAC,EAAE,oCAAoC;aAC/C;SACF;KACF;IACD,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE;QACb,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE;YACf;gBACE,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,CAAC,EAAE,oCAAoC;aAC/C;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Network } from '../../constants';
2
+ import { IDexHelper } from '../../dex-helper';
3
+ import { DexParams } from '../gmx/types';
4
+ import { GMX } from '../gmx/gmx';
5
+ export declare class Morphex extends GMX {
6
+ protected network: Network;
7
+ protected dexHelper: IDexHelper;
8
+ protected adapters: {
9
+ [side: string]: {
10
+ name: string;
11
+ index: number;
12
+ }[] | null;
13
+ };
14
+ protected params: DexParams;
15
+ static dexKeysWithNetwork: {
16
+ key: string;
17
+ networks: Network[];
18
+ }[];
19
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: {
20
+ [side: string]: {
21
+ name: string;
22
+ index: number;
23
+ }[] | null;
24
+ }, params?: DexParams);
25
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Morphex = void 0;
4
+ const config_1 = require("./config");
5
+ const gmx_1 = require("../gmx/gmx");
6
+ const utils_1 = require("../../utils");
7
+ class Morphex extends gmx_1.GMX {
8
+ constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network], params = config_1.MorphexConfig[dexKey][network]) {
9
+ super(network, dexKey, dexHelper, adapters, params);
10
+ this.network = network;
11
+ this.dexHelper = dexHelper;
12
+ this.adapters = adapters;
13
+ this.params = params;
14
+ this.logger = dexHelper.getLogger(dexKey);
15
+ }
16
+ }
17
+ exports.Morphex = Morphex;
18
+ Morphex.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.MorphexConfig);
19
+ //# sourceMappingURL=morphex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morphex.js","sourceRoot":"","sources":["../../../src/dex/morphex/morphex.ts"],"names":[],"mappings":";;;AAGA,qCAAmD;AACnD,oCAAiC;AACjC,uCAAoD;AAEpD,MAAa,OAAQ,SAAQ,SAAG;IAI9B,YACY,OAAgB,EAC1B,MAAc,EACJ,SAAqB,EACrB,WAAW,iBAAQ,CAAC,OAAO,CAAC,EAC5B,SAAoB,sBAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;QAE5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAN1C,YAAO,GAAP,OAAO,CAAS;QAEhB,cAAS,GAAT,SAAS,CAAY;QACrB,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,WAAM,GAAN,MAAM,CAA4C;QAG5D,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;;AAbH,0BAcC;AAbe,0BAAkB,GAC9B,IAAA,6BAAqB,EAAC,sBAAa,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraswap/dex-lib",
3
- "version": "2.42.4-baseswap.3",
3
+ "version": "2.42.5",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "repository": "https://github.com/paraswap/paraswap-dex-lib",
@@ -11,7 +11,7 @@ import { checkPoolPrices, checkPoolsLiquidity } from '../../../tests/utils';
11
11
  import { Tokens } from '../../../tests/constants-e2e';
12
12
  import UniswapV3QuoterV2ABI from '../../abi/uniswap-v3/UniswapV3QuoterV2.abi.json';
13
13
  import { Address } from '@paraswap/core';
14
- import { BaseswapV3 } from '../baseswap-v3/baseswap-v3';
14
+ import { UniswapV3Config } from './config';
15
15
 
16
16
  const network = Network.POLYGON;
17
17
  const TokenASymbol = 'USDC';
@@ -1249,7 +1249,7 @@ describe('BaseswapV3', function () {
1249
1249
  const dexHelper = new DummyDexHelper(network);
1250
1250
 
1251
1251
  let blockNumber: number;
1252
- let retro: UniswapV3;
1252
+ let baseswapV3: UniswapV3;
1253
1253
 
1254
1254
  const TokenASymbol = 'USDC';
1255
1255
  const TokenA = Tokens[network][TokenASymbol];
@@ -1257,15 +1257,69 @@ describe('BaseswapV3', function () {
1257
1257
  const TokenBSymbol = 'WETH';
1258
1258
  const TokenB = Tokens[network][TokenBSymbol];
1259
1259
 
1260
- const QuoterV2 = '0x4fDBD73aD4B1DDde594BF05497C15f76308eFfb9';
1260
+ const QuoterV2 = UniswapV3Config[dexKey][network].quoter;
1261
+
1262
+ const amountsBuy = [
1263
+ 0n,
1264
+ 6000000n,
1265
+ 12000000n,
1266
+ 18000000n,
1267
+ 24000000n,
1268
+ 30000000n,
1269
+ 36000000n,
1270
+ 42000000n,
1271
+ 48000000n,
1272
+ 54000000n,
1273
+ 60000000n,
1274
+ 66000000n,
1275
+ 72000000n,
1276
+ 78000000n,
1277
+ 84000000n,
1278
+ 90000000n,
1279
+ 96000000n,
1280
+ 102000000n,
1281
+ 108000000n,
1282
+ 114000000n,
1283
+ 120000000n,
1284
+ 126000000n,
1285
+ 132000000n,
1286
+ 138000000n,
1287
+ 144000000n,
1288
+ 150000000n,
1289
+ 156000000n,
1290
+ 162000000n,
1291
+ 168000000n,
1292
+ 174000000n,
1293
+ 180000000n,
1294
+ 186000000n,
1295
+ 192000000n,
1296
+ 198000000n,
1297
+ 204000000n,
1298
+ 210000000n,
1299
+ 216000000n,
1300
+ 222000000n,
1301
+ 228000000n,
1302
+ 234000000n,
1303
+ 240000000n,
1304
+ 246000000n,
1305
+ 252000000n,
1306
+ 258000000n,
1307
+ 264000000n,
1308
+ 270000000n,
1309
+ 276000000n,
1310
+ 282000000n,
1311
+ 288000000n,
1312
+ 294000000n,
1313
+ 300000000n,
1314
+ ];
1261
1315
 
1262
1316
  beforeEach(async () => {
1263
1317
  blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
1264
- retro = new UniswapV3(network, dexKey, dexHelper);
1318
+ baseswapV3 = new UniswapV3(network, dexKey, dexHelper);
1265
1319
  });
1266
1320
 
1267
1321
  it('getPoolIdentifiers and getPricesVolume SELL', async function () {
1268
- const pools = await retro.getPoolIdentifiers(
1322
+ const pools = await baseswapV3.getPoolIdentifiers(
1269
1323
  TokenA,
1270
1324
  TokenB,
1271
1325
  SwapSide.SELL,
@@ -1278,7 +1332,7 @@ describe('BaseswapV3', function () {
1278
1332
 
1279
1333
  expect(pools.length).toBeGreaterThan(0);
1280
1334
 
1281
- const poolPrices = await retro.getPricesVolume(
1335
+ const poolPrices = await baseswapV3.getPricesVolume(
1282
1336
  TokenA,
1283
1337
  TokenB,
1284
1338
  amounts,
@@ -1297,10 +1351,10 @@ describe('BaseswapV3', function () {
1297
1351
  let falseChecksCounter = 0;
1298
1352
  await Promise.all(
1299
1353
  poolPrices!.map(async price => {
1300
- const fee = retro.eventPools[price.poolIdentifier!]!.feeCode;
1354
+ const fee = baseswapV3.eventPools[price.poolIdentifier!]!.feeCode;
1301
1355
  const res = await checkOnChainPricing(
1302
1356
  dexHelper,
1303
- retro,
1357
+ baseswapV3,
1304
1358
  'quoteExactInputSingle',
1305
1359
  blockNumber,
1306
1360
  QuoterV2,
@@ -1318,7 +1372,14 @@ describe('BaseswapV3', function () {
1318
1372
  });
1319
1373
 
1320
1374
  it('getPoolIdentifiers and getPricesVolume BUY', async function () {
1321
- const pools = await retro.getPoolIdentifiers(
1375
+ const amountsBuy = [
1376
+ 0n,
1377
+ 1n * BI_POWS[18],
1378
+ 2n * BI_POWS[18],
1379
+ 3n * BI_POWS[18],
1380
+ ];
1381
+
1382
+ const pools = await baseswapV3.getPoolIdentifiers(
1322
1383
  TokenA,
1323
1384
  TokenB,
1324
1385
  SwapSide.BUY,
@@ -1331,7 +1392,7 @@ describe('BaseswapV3', function () {
1331
1392
 
1332
1393
  expect(pools.length).toBeGreaterThan(0);
1333
1394
 
1334
- const poolPrices = await retro.getPricesVolume(
1395
+ const poolPrices = await baseswapV3.getPricesVolume(
1335
1396
  TokenA,
1336
1397
  TokenB,
1337
1398
  amountsBuy,
@@ -1351,10 +1412,10 @@ describe('BaseswapV3', function () {
1351
1412
  let falseChecksCounter = 0;
1352
1413
  await Promise.all(
1353
1414
  poolPrices!.map(async price => {
1354
- const fee = retro.eventPools[price.poolIdentifier!]!.feeCode;
1415
+ const fee = baseswapV3.eventPools[price.poolIdentifier!]!.feeCode;
1355
1416
  const res = await checkOnChainPricing(
1356
1417
  dexHelper,
1357
- retro,
1418
+ baseswapV3,
1358
1419
  'quoteExactOutputSingle',
1359
1420
  blockNumber,
1360
1421
  QuoterV2,
@@ -1377,61 +1438,7 @@ describe('BaseswapV3', function () {
1377
1438
  const TokenBSymbol = 'USDC';
1378
1439
  const TokenB = Tokens[network][TokenBSymbol];
1379
1440
 
1380
- const amounts = [
1381
- 0n,
1382
- 6000000n,
1383
- 12000000n,
1384
- 18000000n,
1385
- 24000000n,
1386
- 30000000n,
1387
- 36000000n,
1388
- 42000000n,
1389
- 48000000n,
1390
- 54000000n,
1391
- 60000000n,
1392
- 66000000n,
1393
- 72000000n,
1394
- 78000000n,
1395
- 84000000n,
1396
- 90000000n,
1397
- 96000000n,
1398
- 102000000n,
1399
- 108000000n,
1400
- 114000000n,
1401
- 120000000n,
1402
- 126000000n,
1403
- 132000000n,
1404
- 138000000n,
1405
- 144000000n,
1406
- 150000000n,
1407
- 156000000n,
1408
- 162000000n,
1409
- 168000000n,
1410
- 174000000n,
1411
- 180000000n,
1412
- 186000000n,
1413
- 192000000n,
1414
- 198000000n,
1415
- 204000000n,
1416
- 210000000n,
1417
- 216000000n,
1418
- 222000000n,
1419
- 228000000n,
1420
- 234000000n,
1421
- 240000000n,
1422
- 246000000n,
1423
- 252000000n,
1424
- 258000000n,
1425
- 264000000n,
1426
- 270000000n,
1427
- 276000000n,
1428
- 282000000n,
1429
- 288000000n,
1430
- 294000000n,
1431
- 300000000n,
1432
- ];
1433
-
1434
- const pools = await retro.getPoolIdentifiers(
1441
+ const pools = await baseswapV3.getPoolIdentifiers(
1435
1442
  TokenA,
1436
1443
  TokenB,
1437
1444
  SwapSide.SELL,
@@ -1444,10 +1451,10 @@ describe('BaseswapV3', function () {
1444
1451
 
1445
1452
  expect(pools.length).toBeGreaterThan(0);
1446
1453
 
1447
- const poolPrices = await retro.getPricesVolume(
1454
+ const poolPrices = await baseswapV3.getPricesVolume(
1448
1455
  TokenA,
1449
1456
  TokenB,
1450
- amounts,
1457
+ amountsBuy,
1451
1458
  SwapSide.SELL,
1452
1459
  blockNumber,
1453
1460
  pools,
@@ -1460,7 +1467,7 @@ describe('BaseswapV3', function () {
1460
1467
  expect(poolPrices).not.toBeNull();
1461
1468
  checkPoolPrices(
1462
1469
  poolPrices!.filter(pp => pp.unit !== 0n),
1463
- amounts,
1470
+ amountsBuy,
1464
1471
  SwapSide.SELL,
1465
1472
  dexKey,
1466
1473
  );
@@ -1469,10 +1476,10 @@ describe('BaseswapV3', function () {
1469
1476
  let falseChecksCounter = 0;
1470
1477
  await Promise.all(
1471
1478
  poolPrices!.map(async price => {
1472
- const fee = retro.eventPools[price.poolIdentifier!]!.feeCode;
1479
+ const fee = baseswapV3.eventPools[price.poolIdentifier!]!.feeCode;
1473
1480
  const res = await checkOnChainPricing(
1474
1481
  dexHelper,
1475
- retro,
1482
+ baseswapV3,
1476
1483
  'quoteExactInputSingle',
1477
1484
  blockNumber,
1478
1485
  QuoterV2,
@@ -1480,7 +1487,7 @@ describe('BaseswapV3', function () {
1480
1487
  TokenA.address,
1481
1488
  TokenB.address,
1482
1489
  fee,
1483
- amounts,
1490
+ amountsBuy,
1484
1491
  );
1485
1492
  if (res === false) falseChecksCounter++;
1486
1493
  }),
@@ -1495,61 +1502,7 @@ describe('BaseswapV3', function () {
1495
1502
  const TokenBSymbol = 'USDC';
1496
1503
  const TokenB = Tokens[network][TokenBSymbol];
1497
1504
 
1498
- const amountsBuy = [
1499
- 0n,
1500
- 6000000n,
1501
- 12000000n,
1502
- 18000000n,
1503
- 24000000n,
1504
- 30000000n,
1505
- 36000000n,
1506
- 42000000n,
1507
- 48000000n,
1508
- 54000000n,
1509
- 60000000n,
1510
- 66000000n,
1511
- 72000000n,
1512
- 78000000n,
1513
- 84000000n,
1514
- 90000000n,
1515
- 96000000n,
1516
- 102000000n,
1517
- 108000000n,
1518
- 114000000n,
1519
- 120000000n,
1520
- 126000000n,
1521
- 132000000n,
1522
- 138000000n,
1523
- 144000000n,
1524
- 150000000n,
1525
- 156000000n,
1526
- 162000000n,
1527
- 168000000n,
1528
- 174000000n,
1529
- 180000000n,
1530
- 186000000n,
1531
- 192000000n,
1532
- 198000000n,
1533
- 204000000n,
1534
- 210000000n,
1535
- 216000000n,
1536
- 222000000n,
1537
- 228000000n,
1538
- 234000000n,
1539
- 240000000n,
1540
- 246000000n,
1541
- 252000000n,
1542
- 258000000n,
1543
- 264000000n,
1544
- 270000000n,
1545
- 276000000n,
1546
- 282000000n,
1547
- 288000000n,
1548
- 294000000n,
1549
- 300000000n,
1550
- ];
1551
-
1552
- const pools = await retro.getPoolIdentifiers(
1505
+ const pools = await baseswapV3.getPoolIdentifiers(
1553
1506
  TokenA,
1554
1507
  TokenB,
1555
1508
  SwapSide.BUY,
@@ -1562,7 +1515,7 @@ describe('BaseswapV3', function () {
1562
1515
 
1563
1516
  expect(pools.length).toBeGreaterThan(0);
1564
1517
 
1565
- const poolPrices = await retro.getPricesVolume(
1518
+ const poolPrices = await baseswapV3.getPricesVolume(
1566
1519
  TokenA,
1567
1520
  TokenB,
1568
1521
  amountsBuy,
@@ -1587,10 +1540,10 @@ describe('BaseswapV3', function () {
1587
1540
  let falseChecksCounter = 0;
1588
1541
  await Promise.all(
1589
1542
  poolPrices!.map(async price => {
1590
- const fee = retro.eventPools[price.poolIdentifier!]!.feeCode;
1543
+ const fee = baseswapV3.eventPools[price.poolIdentifier!]!.feeCode;
1591
1544
  const res = await checkOnChainPricing(
1592
1545
  dexHelper,
1593
- retro,
1546
+ baseswapV3,
1594
1547
  'quoteExactOutputSingle',
1595
1548
  blockNumber,
1596
1549
  QuoterV2,
@@ -1607,7 +1560,10 @@ describe('BaseswapV3', function () {
1607
1560
  });
1608
1561
 
1609
1562
  it('getTopPoolsForToken', async function () {
1610
- const poolLiquidity = await retro.getTopPoolsForToken(TokenB.address, 10);
1563
+ const poolLiquidity = await baseswapV3.getTopPoolsForToken(
1564
+ TokenB.address,
1565
+ 10,
1566
+ );
1611
1567
  console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
1612
1568
 
1613
1569
  checkPoolsLiquidity(poolLiquidity, TokenB.address, dexKey);