@paraswap/dex-lib 2.47.4 → 2.47.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.
- package/build/abi/Redstone.json +739 -0
- package/build/abi/angle/stagToken.json +963 -0
- package/build/abi/angle-transmuter/Pyth.json +1534 -0
- package/build/abi/angle-transmuter/Transmuter.json +1719 -0
- package/build/abi/smardex/smardex-factory.json +185 -0
- package/build/abi/smardex/smardex-pool.json +578 -0
- package/build/abi/smardex/smardex-router.json +648 -0
- package/build/abi/trader-joe-v2_1/FactoryABI.json +1208 -0
- package/build/abi/trader-joe-v2_1/PairABI.json +1493 -0
- package/build/abi/trader-joe-v2_1/RouterABI.json +1489 -0
- package/build/abi/trader-joe-v2_1/StateMulticall.json +193 -0
- package/build/abi/wombat/pool.json +1289 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +53 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +175 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +1 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +42 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.js +232 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -0
- package/build/dex/angle-staked-stable/config.d.ts +4 -0
- package/build/dex/angle-staked-stable/config.js +26 -0
- package/build/dex/angle-staked-stable/config.js.map +1 -0
- package/build/dex/angle-staked-stable/types.d.ts +15 -0
- package/build/dex/angle-staked-stable/types.js +3 -0
- package/build/dex/angle-staked-stable/types.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +43 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +309 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter.d.ts +46 -0
- package/build/dex/angle-transmuter/angle-transmuter.js +233 -0
- package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
- package/build/dex/angle-transmuter/backedOracle.js +56 -0
- package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
- package/build/dex/angle-transmuter/config.d.ts +4 -0
- package/build/dex/angle-transmuter/config.js +20 -0
- package/build/dex/angle-transmuter/config.js.map +1 -0
- package/build/dex/angle-transmuter/constants.d.ts +4 -0
- package/build/dex/angle-transmuter/constants.js +8 -0
- package/build/dex/angle-transmuter/constants.js.map +1 -0
- package/build/dex/angle-transmuter/pyth.d.ts +19 -0
- package/build/dex/angle-transmuter/pyth.js +71 -0
- package/build/dex/angle-transmuter/pyth.js.map +1 -0
- package/build/dex/angle-transmuter/redstone.d.ts +20 -0
- package/build/dex/angle-transmuter/redstone.js +73 -0
- package/build/dex/angle-transmuter/redstone.js.map +1 -0
- package/build/dex/angle-transmuter/transmuter.d.ts +50 -0
- package/build/dex/angle-transmuter/transmuter.js +314 -0
- package/build/dex/angle-transmuter/transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/types.d.ts +144 -0
- package/build/dex/angle-transmuter/types.js +31 -0
- package/build/dex/angle-transmuter/types.js.map +1 -0
- package/build/dex/angle-transmuter/utils.d.ts +9 -0
- package/build/dex/angle-transmuter/utils.js +264 -0
- package/build/dex/angle-transmuter/utils.js.map +1 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +3 -6
- package/build/dex/balancer-v2/balancer-v2.js +35 -55
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +1 -24
- package/build/dex/balancer-v2/types.js +0 -2
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/balancer-v2/utils.d.ts +0 -8
- package/build/dex/balancer-v2/utils.js +1 -17
- package/build/dex/balancer-v2/utils.js.map +1 -1
- package/build/dex/hashflow/hashflow.js +2 -1
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/smardex/subgraph-queries.d.ts +1 -0
- package/build/dex/smardex/subgraph-queries.js +17 -0
- package/build/dex/smardex/subgraph-queries.js.map +1 -0
- package/build/dex/smardex/usd-reserves.d.ts +23 -0
- package/build/dex/smardex/usd-reserves.js +86 -0
- package/build/dex/smardex/usd-reserves.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/config.d.ts +4 -0
- package/build/dex/trader-joe-v2-1-2/config.js +47 -0
- package/build/dex/trader-joe-v2-1-2/config.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2-1-2/constants.js +22 -0
- package/build/dex/trader-joe-v2-1-2/constants.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js +291 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +248 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +53 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +307 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/types.d.ts +82 -0
- package/build/dex/trader-joe-v2-1-2/types.js +9 -0
- package/build/dex/trader-joe-v2-1-2/types.js.map +1 -0
- package/build/dex/trader-joe-v2_1/config.d.ts +4 -0
- package/build/dex/trader-joe-v2_1/config.js +47 -0
- package/build/dex/trader-joe-v2_1/config.js.map +1 -0
- package/build/dex/trader-joe-v2_1/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2_1/constants.js +22 -0
- package/build/dex/trader-joe-v2_1/constants.js.map +1 -0
- package/build/dex/trader-joe-v2_1/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2_1/math/index.js +291 -0
- package/build/dex/trader-joe-v2_1/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +384 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +247 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +53 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +307 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/types.d.ts +82 -0
- package/build/dex/trader-joe-v2_1/types.js +9 -0
- package/build/dex/trader-joe-v2_1/types.js.map +1 -0
- package/build/dex/wombat/wombat-pool-poller.d.ts +22 -0
- package/build/dex/wombat/wombat-pool-poller.js +164 -0
- package/build/dex/wombat/wombat-pool-poller.js.map +1 -0
- package/package.json +1 -2
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -94
- package/src/dex/balancer-v2/balancer-v2-integration.test.ts +112 -253
- package/src/dex/balancer-v2/balancer-v2.ts +69 -105
- package/src/dex/balancer-v2/types.ts +0 -26
- package/src/dex/balancer-v2/utils.ts +0 -16
- package/src/dex/hashflow/hashflow.ts +4 -1
- package/src/dex/synthetix/synthetix-state.ts +2 -2
- package/tests/constants-e2e.ts +0 -26
- package/build/abi/balancer-v2/gyro-e.abi.json +0 -1595
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.d.ts +0 -32
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js +0 -149
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js.map +0 -1
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.d.ts +0 -37
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js +0 -222
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js.map +0 -1
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.d.ts +0 -2
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js +0 -19
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js.map +0 -1
- package/build/dex/balancer-v2/queryOnChain.d.ts +0 -1
- package/build/dex/balancer-v2/queryOnChain.js +0 -40
- package/build/dex/balancer-v2/queryOnChain.js.map +0 -1
- package/src/abi/balancer-v2/gyro-e.abi.json +0 -1595
- package/src/dex/balancer-v2/balancer-v2-gyro3.test.ts +0 -268
- package/src/dex/balancer-v2/balancer-v2-gyroE.test.ts +0 -401
- package/src/dex/balancer-v2/pools/gyro/Gyro3Pool.ts +0 -255
- package/src/dex/balancer-v2/pools/gyro/GyroEPool.ts +0 -403
- package/src/dex/balancer-v2/pools/gyro/gyro-helpers.ts +0 -15
- package/src/dex/balancer-v2/queryOnChain.ts +0 -48
|
@@ -117,7 +117,7 @@ describe('BalancerV2', function () {
|
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
it('getPoolIdentifiers and getPricesVolume', async () => {
|
|
120
|
-
const MIMATIC = Tokens[Network.POLYGON]['
|
|
120
|
+
const MIMATIC = Tokens[Network.POLYGON]['MIMATIC'];
|
|
121
121
|
const USDC = Tokens[Network.POLYGON]['USDC'];
|
|
122
122
|
const dexHelper = new DummyDexHelper(Network.POLYGON);
|
|
123
123
|
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
@@ -366,97 +366,96 @@ describe('BalancerV2', function () {
|
|
|
366
366
|
});
|
|
367
367
|
});
|
|
368
368
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
describe.only('PhantomStable', () => {
|
|
369
|
+
describe('Linear', () => {
|
|
370
|
+
it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
371
|
+
const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
372
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
373
|
+
const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
|
|
374
|
+
|
|
375
|
+
await balancerV2.initializePricing(blocknumber);
|
|
376
|
+
|
|
377
|
+
//daniel: pricing for BPT swaps has been removed for the time being
|
|
378
|
+
//focus on main tokens swaps
|
|
379
|
+
/*const pools = await balancerV2.getPoolIdentifiers(
|
|
380
|
+
DAI,
|
|
381
|
+
BBADAI,
|
|
382
|
+
SwapSide.SELL,
|
|
383
|
+
blocknumber,
|
|
384
|
+
);
|
|
385
|
+
console.log('DAI <> BBADAI Pool Identifiers: ', pools);
|
|
386
|
+
|
|
387
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
388
|
+
|
|
389
|
+
const poolPrices = await balancerV2.getPricesVolume(
|
|
390
|
+
DAI,
|
|
391
|
+
BBADAI,
|
|
392
|
+
amounts,
|
|
393
|
+
SwapSide.SELL,
|
|
394
|
+
blocknumber,
|
|
395
|
+
pools,
|
|
396
|
+
);
|
|
397
|
+
console.log('DAI <> BBADAI Pool Prices: ', poolPrices);
|
|
398
|
+
|
|
399
|
+
expect(poolPrices).not.toBeNull();
|
|
400
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);*/
|
|
401
|
+
|
|
402
|
+
await balancerV2.releaseResources();
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
it('getTopPoolsForToken', async function () {
|
|
406
|
+
const BBADAI = Tokens[Network.MAINNET]['BBADAI'];
|
|
407
|
+
const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
408
|
+
const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
|
|
409
|
+
|
|
410
|
+
const poolLiquidity = await balancerV2.getTopPoolsForToken(
|
|
411
|
+
BBADAI.address,
|
|
412
|
+
10,
|
|
413
|
+
);
|
|
414
|
+
console.log('BBADAI Top Pools:', poolLiquidity);
|
|
415
|
+
|
|
416
|
+
checkPoolsLiquidity(poolLiquidity, BBADAI.address, dexKey);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// it('applies getRate to phantom bpt scaling factor', async function () {
|
|
420
|
+
// const config = BalancerConfig[dexKey][Network.MAINNET];
|
|
421
|
+
// const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
422
|
+
// const tokens = Tokens[Network.MAINNET];
|
|
423
|
+
// const logger = dexHelper.getLogger(dexKey);
|
|
424
|
+
// const blocknumber = 15731000;
|
|
425
|
+
//
|
|
426
|
+
// const balancerPools = new BalancerV2EventPool(
|
|
427
|
+
// dexKey,
|
|
428
|
+
// Network.MAINNET,
|
|
429
|
+
// config.vaultAddress,
|
|
430
|
+
// config.subgraphURL,
|
|
431
|
+
// dexHelper,
|
|
432
|
+
// logger,
|
|
433
|
+
// );
|
|
434
|
+
//
|
|
435
|
+
// const state = await balancerPools.getOnChainState(
|
|
436
|
+
// [
|
|
437
|
+
// {
|
|
438
|
+
// id: BBAUSDT_PoolId,
|
|
439
|
+
// address: tokens.BBAUSDT.address,
|
|
440
|
+
// poolType: BalancerPoolTypes.AaveLinear,
|
|
441
|
+
// mainIndex: 1,
|
|
442
|
+
// wrappedIndex: 0,
|
|
443
|
+
// tokens: [tokens.BBAUSDT, tokens.aUSDT, tokens.USDT],
|
|
444
|
+
// mainTokens: [],
|
|
445
|
+
// },
|
|
446
|
+
// ],
|
|
447
|
+
// blocknumber,
|
|
448
|
+
// );
|
|
449
|
+
//
|
|
450
|
+
// expect(
|
|
451
|
+
// state[tokens.BBAUSDT.address].tokens[
|
|
452
|
+
// tokens.BBAUSDT.address
|
|
453
|
+
// ].scalingFactor!.toString(),
|
|
454
|
+
// ).toBe('1015472217207213567');
|
|
455
|
+
// });
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
describe('PhantomStable', () => {
|
|
460
459
|
/*
|
|
461
460
|
As advised by @shresth this test has been commented out.
|
|
462
461
|
checkPoolPrices expects price to decrease as higher amounts are used. Linear/PhantomStable can sometimes return same or better.
|
|
@@ -468,7 +467,9 @@ describe('BalancerV2', function () {
|
|
|
468
467
|
// const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
469
468
|
// const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
470
469
|
// const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
|
|
470
|
+
|
|
471
471
|
// await balancerV2.initializePricing(blocknumber);
|
|
472
|
+
|
|
472
473
|
// const pools = await balancerV2.getPoolIdentifiers(
|
|
473
474
|
// BBAUSD,
|
|
474
475
|
// BBADAI,
|
|
@@ -476,7 +477,9 @@ describe('BalancerV2', function () {
|
|
|
476
477
|
// blocknumber,
|
|
477
478
|
// );
|
|
478
479
|
// console.log('BBAUSD <> BBADAI Pool Identifiers: ', pools);
|
|
480
|
+
|
|
479
481
|
// expect(pools.length).toBeGreaterThan(0);
|
|
482
|
+
|
|
480
483
|
// const poolPrices = await balancerV2.getPricesVolume(
|
|
481
484
|
// BBAUSD,
|
|
482
485
|
// BBADAI,
|
|
@@ -486,22 +489,27 @@ describe('BalancerV2', function () {
|
|
|
486
489
|
// pools,
|
|
487
490
|
// );
|
|
488
491
|
// console.log('BBAUSD <> BBADAI Pool Prices: ', poolPrices);
|
|
492
|
+
|
|
489
493
|
// expect(poolPrices).not.toBeNull();
|
|
490
494
|
// checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
495
|
+
|
|
491
496
|
// await balancerV2.releaseResources();
|
|
492
497
|
// });
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
498
|
+
|
|
499
|
+
it('getTopPoolsForToken', async function () {
|
|
500
|
+
const BBAUSD = Tokens[Network.MAINNET]['BBAUSD'];
|
|
501
|
+
const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
502
|
+
const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
|
|
503
|
+
|
|
504
|
+
const poolLiquidity = await balancerV2.getTopPoolsForToken(
|
|
505
|
+
BBAUSD.address,
|
|
506
|
+
10,
|
|
507
|
+
);
|
|
508
|
+
console.log('BBAUSD Top Pools:', poolLiquidity);
|
|
509
|
+
|
|
510
|
+
checkPoolsLiquidity(poolLiquidity, BBAUSD.address, dexKey);
|
|
511
|
+
});
|
|
512
|
+
|
|
505
513
|
// it('applies getRate to phantom bpt scaling factor', async function () {
|
|
506
514
|
// const config = BalancerConfig[dexKey][Network.MAINNET];
|
|
507
515
|
// const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
@@ -543,155 +551,6 @@ describe('BalancerV2', function () {
|
|
|
543
551
|
// ).toBe('1015093119997891367');
|
|
544
552
|
// });
|
|
545
553
|
});
|
|
546
|
-
|
|
547
|
-
describe('Gyro3', () => {
|
|
548
|
-
const gyro3Addr = '0x17f1ef81707811ea15d9ee7c741179bbe2a63887';
|
|
549
|
-
|
|
550
|
-
it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
551
|
-
const network = Network.POLYGON;
|
|
552
|
-
const dexHelper = new DummyDexHelper(network);
|
|
553
|
-
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
554
|
-
const balancerV2 = new BalancerV2(network, dexKey, dexHelper);
|
|
555
|
-
const tokens = Tokens[network];
|
|
556
|
-
await balancerV2.initializePricing(blocknumber);
|
|
557
|
-
|
|
558
|
-
const pools = await balancerV2.getPoolIdentifiers(
|
|
559
|
-
tokens.BUSD,
|
|
560
|
-
tokens.USDC,
|
|
561
|
-
SwapSide.SELL,
|
|
562
|
-
blocknumber,
|
|
563
|
-
);
|
|
564
|
-
console.log('BUSD <> USDC Pool Identifiers (Polygon): ', pools);
|
|
565
|
-
|
|
566
|
-
const isPool = pools.find(poolIdentifier =>
|
|
567
|
-
poolIdentifier.includes(gyro3Addr),
|
|
568
|
-
);
|
|
569
|
-
|
|
570
|
-
expect(isPool).toBeDefined();
|
|
571
|
-
|
|
572
|
-
const poolPrices = await balancerV2.getPricesVolume(
|
|
573
|
-
tokens.BUSD,
|
|
574
|
-
tokens.USDC,
|
|
575
|
-
amounts,
|
|
576
|
-
SwapSide.SELL,
|
|
577
|
-
blocknumber,
|
|
578
|
-
pools,
|
|
579
|
-
);
|
|
580
|
-
console.log('BUSD <> USDC Pool Prices (Polygon): ', poolPrices);
|
|
581
|
-
|
|
582
|
-
expect(poolPrices).not.toBeNull();
|
|
583
|
-
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
584
|
-
const isPoolPrice = poolPrices!.find(price =>
|
|
585
|
-
price.data.poolId.includes(gyro3Addr),
|
|
586
|
-
);
|
|
587
|
-
expect(isPoolPrice).toBeDefined();
|
|
588
|
-
|
|
589
|
-
await balancerV2.releaseResources();
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
it('getTopPoolsForToken', async function () {
|
|
593
|
-
const network = Network.POLYGON;
|
|
594
|
-
const dexHelper = new DummyDexHelper(network);
|
|
595
|
-
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
596
|
-
const balancerV2 = new BalancerV2(network, dexKey, dexHelper);
|
|
597
|
-
await balancerV2.initializePricing(blocknumber);
|
|
598
|
-
const tokens = Tokens[network];
|
|
599
|
-
|
|
600
|
-
const poolLiquidity = await balancerV2.getTopPoolsForToken(
|
|
601
|
-
tokens.BUSD.address.toLowerCase(),
|
|
602
|
-
10,
|
|
603
|
-
);
|
|
604
|
-
console.log('BUSD Top Pools (Polygon):', poolLiquidity);
|
|
605
|
-
|
|
606
|
-
checkPoolsLiquidity(poolLiquidity, tokens.DAI.address, dexKey);
|
|
607
|
-
const isTopPool = poolLiquidity.find(pool => pool.address === gyro3Addr);
|
|
608
|
-
expect(isTopPool).toBeDefined();
|
|
609
|
-
await balancerV2.releaseResources();
|
|
610
|
-
});
|
|
611
|
-
});
|
|
612
|
-
|
|
613
|
-
describe('GyroE', () => {
|
|
614
|
-
// sDAI<>GYD - more likely to have continued liqudity
|
|
615
|
-
const gyroEAddr = '0x1cce5169bde03f3d5ad0206f6bd057953539dae6';
|
|
616
|
-
|
|
617
|
-
it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
618
|
-
const network = Network.MAINNET;
|
|
619
|
-
const dexHelper = new DummyDexHelper(network);
|
|
620
|
-
// const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
621
|
-
const blocknumber = 19425305;
|
|
622
|
-
const balancerV2 = new BalancerV2(network, dexKey, dexHelper);
|
|
623
|
-
const tokens = Tokens[network];
|
|
624
|
-
|
|
625
|
-
await balancerV2.initializePricing(blocknumber);
|
|
626
|
-
|
|
627
|
-
const pools = await balancerV2.getPoolIdentifiers(
|
|
628
|
-
tokens.GYD,
|
|
629
|
-
tokens.sDAI,
|
|
630
|
-
SwapSide.SELL,
|
|
631
|
-
blocknumber,
|
|
632
|
-
);
|
|
633
|
-
console.log('GYD <> sDAI Pool Identifiers (Mainnet): ', pools);
|
|
634
|
-
|
|
635
|
-
const isPool = pools.find(poolIdentifier =>
|
|
636
|
-
poolIdentifier.includes(gyroEAddr),
|
|
637
|
-
);
|
|
638
|
-
|
|
639
|
-
expect(isPool).toBeDefined();
|
|
640
|
-
|
|
641
|
-
const poolPrices = await balancerV2.getPricesVolume(
|
|
642
|
-
tokens.GYD,
|
|
643
|
-
tokens.sDAI,
|
|
644
|
-
amounts,
|
|
645
|
-
SwapSide.SELL,
|
|
646
|
-
blocknumber,
|
|
647
|
-
pools,
|
|
648
|
-
);
|
|
649
|
-
console.log('GYD <> sDAI Pool Prices (Mainnet): ', poolPrices);
|
|
650
|
-
|
|
651
|
-
expect(poolPrices).not.toBeNull();
|
|
652
|
-
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
653
|
-
const isPoolPrice = poolPrices!.find(price =>
|
|
654
|
-
price.data.poolId.includes(gyroEAddr),
|
|
655
|
-
);
|
|
656
|
-
expect(isPoolPrice).toBeDefined();
|
|
657
|
-
|
|
658
|
-
const onChainPrices = await getOnChainPricingForWeightedPool(
|
|
659
|
-
balancerV2,
|
|
660
|
-
blocknumber,
|
|
661
|
-
isPoolPrice!,
|
|
662
|
-
amounts,
|
|
663
|
-
tokens.GYD.address,
|
|
664
|
-
tokens.sDAI.address,
|
|
665
|
-
SwapSide.SELL,
|
|
666
|
-
);
|
|
667
|
-
|
|
668
|
-
console.log('GYD <> sDAI on-chain prices: ', onChainPrices);
|
|
669
|
-
|
|
670
|
-
expect(onChainPrices).toEqual(isPoolPrice!.prices);
|
|
671
|
-
|
|
672
|
-
await balancerV2.releaseResources();
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
it('getTopPoolsForToken', async function () {
|
|
676
|
-
const network = Network.MAINNET;
|
|
677
|
-
const dexHelper = new DummyDexHelper(network);
|
|
678
|
-
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
679
|
-
const balancerV2 = new BalancerV2(network, dexKey, dexHelper);
|
|
680
|
-
await balancerV2.initializePricing(blocknumber);
|
|
681
|
-
const tokens = Tokens[network];
|
|
682
|
-
|
|
683
|
-
const poolLiquidity = await balancerV2.getTopPoolsForToken(
|
|
684
|
-
tokens.sDAI.address.toLowerCase(),
|
|
685
|
-
10,
|
|
686
|
-
);
|
|
687
|
-
console.log('sDAI Top Pools (Mainnet):', poolLiquidity);
|
|
688
|
-
|
|
689
|
-
checkPoolsLiquidity(poolLiquidity, tokens.sDAI.address, dexKey);
|
|
690
|
-
const isTopPool = poolLiquidity.find(pool => pool.address === gyroEAddr);
|
|
691
|
-
expect(isTopPool).toBeDefined();
|
|
692
|
-
await balancerV2.releaseResources();
|
|
693
|
-
});
|
|
694
|
-
});
|
|
695
554
|
});
|
|
696
555
|
|
|
697
556
|
describe('BeetsFi', () => {
|