@paraswap/dex-lib 2.47.5 → 2.47.7
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/balancer-v2/gyro-e.abi.json +1595 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +6 -3
- package/build/dex/balancer-v2/balancer-v2.js +56 -35
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.d.ts +32 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js +149 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js.map +1 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.d.ts +37 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js +222 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js.map +1 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.d.ts +2 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js +19 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js.map +1 -0
- package/build/dex/balancer-v2/queryOnChain.d.ts +1 -0
- package/build/dex/balancer-v2/queryOnChain.js +40 -0
- package/build/dex/balancer-v2/queryOnChain.js.map +1 -0
- package/build/dex/balancer-v2/types.d.ts +24 -1
- package/build/dex/balancer-v2/types.js +2 -0
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/balancer-v2/utils.d.ts +8 -0
- package/build/dex/balancer-v2/utils.js +17 -1
- package/build/dex/balancer-v2/utils.js.map +1 -1
- package/package.json +2 -1
- package/src/abi/balancer-v2/gyro-e.abi.json +1595 -0
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +94 -0
- package/src/dex/balancer-v2/balancer-v2-gyro3.test.ts +268 -0
- package/src/dex/balancer-v2/balancer-v2-gyroE.test.ts +401 -0
- package/src/dex/balancer-v2/balancer-v2-integration.test.ts +253 -112
- package/src/dex/balancer-v2/balancer-v2.ts +107 -67
- package/src/dex/balancer-v2/pools/gyro/Gyro3Pool.ts +255 -0
- package/src/dex/balancer-v2/pools/gyro/GyroEPool.ts +403 -0
- package/src/dex/balancer-v2/pools/gyro/gyro-helpers.ts +15 -0
- package/src/dex/balancer-v2/queryOnChain.ts +48 -0
- package/src/dex/balancer-v2/types.ts +26 -0
- package/src/dex/balancer-v2/utils.ts +16 -0
- package/src/dex/synthetix/synthetix-state.ts +2 -2
- package/tests/constants-e2e.ts +26 -0
- package/build/abi/Redstone.json +0 -739
- package/build/abi/angle/stagToken.json +0 -963
- package/build/abi/angle-transmuter/Pyth.json +0 -1534
- package/build/abi/angle-transmuter/Transmuter.json +0 -1719
- package/build/abi/smardex/smardex-factory.json +0 -185
- package/build/abi/smardex/smardex-pool.json +0 -578
- package/build/abi/smardex/smardex-router.json +0 -648
- package/build/abi/trader-joe-v2_1/FactoryABI.json +0 -1208
- package/build/abi/trader-joe-v2_1/PairABI.json +0 -1493
- package/build/abi/trader-joe-v2_1/RouterABI.json +0 -1489
- package/build/abi/trader-joe-v2_1/StateMulticall.json +0 -193
- package/build/abi/wombat/pool.json +0 -1289
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +0 -53
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +0 -175
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +0 -1
- package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +0 -42
- package/build/dex/angle-staked-stable/angle-staked-stable.js +0 -232
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +0 -1
- package/build/dex/angle-staked-stable/config.d.ts +0 -4
- package/build/dex/angle-staked-stable/config.js +0 -26
- package/build/dex/angle-staked-stable/config.js.map +0 -1
- package/build/dex/angle-staked-stable/types.d.ts +0 -15
- package/build/dex/angle-staked-stable/types.js +0 -3
- package/build/dex/angle-staked-stable/types.js.map +0 -1
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +0 -43
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +0 -309
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +0 -1
- package/build/dex/angle-transmuter/angle-transmuter.d.ts +0 -46
- package/build/dex/angle-transmuter/angle-transmuter.js +0 -233
- package/build/dex/angle-transmuter/angle-transmuter.js.map +0 -1
- package/build/dex/angle-transmuter/backedOracle.d.ts +0 -19
- package/build/dex/angle-transmuter/backedOracle.js +0 -56
- package/build/dex/angle-transmuter/backedOracle.js.map +0 -1
- package/build/dex/angle-transmuter/config.d.ts +0 -4
- package/build/dex/angle-transmuter/config.js +0 -20
- package/build/dex/angle-transmuter/config.js.map +0 -1
- package/build/dex/angle-transmuter/constants.d.ts +0 -4
- package/build/dex/angle-transmuter/constants.js +0 -8
- package/build/dex/angle-transmuter/constants.js.map +0 -1
- package/build/dex/angle-transmuter/pyth.d.ts +0 -19
- package/build/dex/angle-transmuter/pyth.js +0 -71
- package/build/dex/angle-transmuter/pyth.js.map +0 -1
- package/build/dex/angle-transmuter/redstone.d.ts +0 -20
- package/build/dex/angle-transmuter/redstone.js +0 -73
- package/build/dex/angle-transmuter/redstone.js.map +0 -1
- package/build/dex/angle-transmuter/transmuter.d.ts +0 -50
- package/build/dex/angle-transmuter/transmuter.js +0 -314
- package/build/dex/angle-transmuter/transmuter.js.map +0 -1
- package/build/dex/angle-transmuter/types.d.ts +0 -144
- package/build/dex/angle-transmuter/types.js +0 -31
- package/build/dex/angle-transmuter/types.js.map +0 -1
- package/build/dex/angle-transmuter/utils.d.ts +0 -9
- package/build/dex/angle-transmuter/utils.js +0 -264
- package/build/dex/angle-transmuter/utils.js.map +0 -1
- package/build/dex/smardex/subgraph-queries.d.ts +0 -1
- package/build/dex/smardex/subgraph-queries.js +0 -17
- package/build/dex/smardex/subgraph-queries.js.map +0 -1
- package/build/dex/smardex/usd-reserves.d.ts +0 -23
- package/build/dex/smardex/usd-reserves.js +0 -86
- package/build/dex/smardex/usd-reserves.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/config.d.ts +0 -4
- package/build/dex/trader-joe-v2-1-2/config.js +0 -47
- package/build/dex/trader-joe-v2-1-2/config.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +0 -20
- package/build/dex/trader-joe-v2-1-2/constants.js +0 -22
- package/build/dex/trader-joe-v2-1-2/constants.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +0 -37
- package/build/dex/trader-joe-v2-1-2/math/index.js +0 -291
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +0 -60
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +0 -248
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +0 -53
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +0 -307
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/types.d.ts +0 -82
- package/build/dex/trader-joe-v2-1-2/types.js +0 -9
- package/build/dex/trader-joe-v2-1-2/types.js.map +0 -1
- package/build/dex/trader-joe-v2_1/config.d.ts +0 -4
- package/build/dex/trader-joe-v2_1/config.js +0 -47
- package/build/dex/trader-joe-v2_1/config.js.map +0 -1
- package/build/dex/trader-joe-v2_1/constants.d.ts +0 -20
- package/build/dex/trader-joe-v2_1/constants.js +0 -22
- package/build/dex/trader-joe-v2_1/constants.js.map +0 -1
- package/build/dex/trader-joe-v2_1/math/index.d.ts +0 -37
- package/build/dex/trader-joe-v2_1/math/index.js +0 -291
- package/build/dex/trader-joe-v2_1/math/index.js.map +0 -1
- 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 +0 -384
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +0 -60
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +0 -247
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +0 -53
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +0 -307
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +0 -1
- package/build/dex/trader-joe-v2_1/types.d.ts +0 -82
- package/build/dex/trader-joe-v2_1/types.js +0 -9
- package/build/dex/trader-joe-v2_1/types.js.map +0 -1
- package/build/dex/wombat/wombat-pool-poller.d.ts +0 -22
- package/build/dex/wombat/wombat-pool-poller.js +0 -164
- package/build/dex/wombat/wombat-pool-poller.js.map +0 -1
|
@@ -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]['MAI'];
|
|
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,96 +366,97 @@ 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
|
-
|
|
369
|
+
// Removed as Linear no-longer supported after vulnerability
|
|
370
|
+
// describe('Linear', () => {
|
|
371
|
+
// it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
372
|
+
// const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
373
|
+
// const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
374
|
+
// const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
|
|
375
|
+
|
|
376
|
+
// await balancerV2.initializePricing(blocknumber);
|
|
377
|
+
|
|
378
|
+
// //daniel: pricing for BPT swaps has been removed for the time being
|
|
379
|
+
// //focus on main tokens swaps
|
|
380
|
+
// /*const pools = await balancerV2.getPoolIdentifiers(
|
|
381
|
+
// DAI,
|
|
382
|
+
// BBADAI,
|
|
383
|
+
// SwapSide.SELL,
|
|
384
|
+
// blocknumber,
|
|
385
|
+
// );
|
|
386
|
+
// console.log('DAI <> BBADAI Pool Identifiers: ', pools);
|
|
387
|
+
|
|
388
|
+
// expect(pools.length).toBeGreaterThan(0);
|
|
389
|
+
|
|
390
|
+
// const poolPrices = await balancerV2.getPricesVolume(
|
|
391
|
+
// DAI,
|
|
392
|
+
// BBADAI,
|
|
393
|
+
// amounts,
|
|
394
|
+
// SwapSide.SELL,
|
|
395
|
+
// blocknumber,
|
|
396
|
+
// pools,
|
|
397
|
+
// );
|
|
398
|
+
// console.log('DAI <> BBADAI Pool Prices: ', poolPrices);
|
|
399
|
+
|
|
400
|
+
// expect(poolPrices).not.toBeNull();
|
|
401
|
+
// checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);*/
|
|
402
|
+
|
|
403
|
+
// await balancerV2.releaseResources();
|
|
404
|
+
// });
|
|
405
|
+
|
|
406
|
+
// it('getTopPoolsForToken', async function () {
|
|
407
|
+
// const BBADAI = Tokens[Network.MAINNET]['BBADAI'];
|
|
408
|
+
// const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
409
|
+
// const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
|
|
410
|
+
|
|
411
|
+
// const poolLiquidity = await balancerV2.getTopPoolsForToken(
|
|
412
|
+
// BBADAI.address,
|
|
413
|
+
// 10,
|
|
414
|
+
// );
|
|
415
|
+
// console.log('BBADAI Top Pools:', poolLiquidity);
|
|
416
|
+
|
|
417
|
+
// checkPoolsLiquidity(poolLiquidity, BBADAI.address, dexKey);
|
|
418
|
+
// });
|
|
419
|
+
|
|
420
|
+
// // it('applies getRate to phantom bpt scaling factor', async function () {
|
|
421
|
+
// // const config = BalancerConfig[dexKey][Network.MAINNET];
|
|
422
|
+
// // const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
423
|
+
// // const tokens = Tokens[Network.MAINNET];
|
|
424
|
+
// // const logger = dexHelper.getLogger(dexKey);
|
|
425
|
+
// // const blocknumber = 15731000;
|
|
426
|
+
// //
|
|
427
|
+
// // const balancerPools = new BalancerV2EventPool(
|
|
428
|
+
// // dexKey,
|
|
429
|
+
// // Network.MAINNET,
|
|
430
|
+
// // config.vaultAddress,
|
|
431
|
+
// // config.subgraphURL,
|
|
432
|
+
// // dexHelper,
|
|
433
|
+
// // logger,
|
|
434
|
+
// // );
|
|
435
|
+
// //
|
|
436
|
+
// // const state = await balancerPools.getOnChainState(
|
|
437
|
+
// // [
|
|
438
|
+
// // {
|
|
439
|
+
// // id: BBAUSDT_PoolId,
|
|
440
|
+
// // address: tokens.BBAUSDT.address,
|
|
441
|
+
// // poolType: BalancerPoolTypes.AaveLinear,
|
|
442
|
+
// // mainIndex: 1,
|
|
443
|
+
// // wrappedIndex: 0,
|
|
444
|
+
// // tokens: [tokens.BBAUSDT, tokens.aUSDT, tokens.USDT],
|
|
445
|
+
// // mainTokens: [],
|
|
446
|
+
// // },
|
|
447
|
+
// // ],
|
|
448
|
+
// // blocknumber,
|
|
449
|
+
// // );
|
|
450
|
+
// //
|
|
451
|
+
// // expect(
|
|
452
|
+
// // state[tokens.BBAUSDT.address].tokens[
|
|
453
|
+
// // tokens.BBAUSDT.address
|
|
454
|
+
// // ].scalingFactor!.toString(),
|
|
455
|
+
// // ).toBe('1015472217207213567');
|
|
456
|
+
// // });
|
|
457
|
+
// });
|
|
458
|
+
|
|
459
|
+
describe.only('PhantomStable', () => {
|
|
459
460
|
/*
|
|
460
461
|
As advised by @shresth this test has been commented out.
|
|
461
462
|
checkPoolPrices expects price to decrease as higher amounts are used. Linear/PhantomStable can sometimes return same or better.
|
|
@@ -467,9 +468,7 @@ describe('BalancerV2', function () {
|
|
|
467
468
|
// const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
468
469
|
// const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
469
470
|
// const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
|
|
470
|
-
|
|
471
471
|
// await balancerV2.initializePricing(blocknumber);
|
|
472
|
-
|
|
473
472
|
// const pools = await balancerV2.getPoolIdentifiers(
|
|
474
473
|
// BBAUSD,
|
|
475
474
|
// BBADAI,
|
|
@@ -477,9 +476,7 @@ describe('BalancerV2', function () {
|
|
|
477
476
|
// blocknumber,
|
|
478
477
|
// );
|
|
479
478
|
// console.log('BBAUSD <> BBADAI Pool Identifiers: ', pools);
|
|
480
|
-
|
|
481
479
|
// expect(pools.length).toBeGreaterThan(0);
|
|
482
|
-
|
|
483
480
|
// const poolPrices = await balancerV2.getPricesVolume(
|
|
484
481
|
// BBAUSD,
|
|
485
482
|
// BBADAI,
|
|
@@ -489,27 +486,22 @@ describe('BalancerV2', function () {
|
|
|
489
486
|
// pools,
|
|
490
487
|
// );
|
|
491
488
|
// console.log('BBAUSD <> BBADAI Pool Prices: ', poolPrices);
|
|
492
|
-
|
|
493
489
|
// expect(poolPrices).not.toBeNull();
|
|
494
490
|
// checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
495
|
-
|
|
496
491
|
// await balancerV2.releaseResources();
|
|
497
492
|
// });
|
|
498
|
-
|
|
499
|
-
it('getTopPoolsForToken', async function () {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
checkPoolsLiquidity(poolLiquidity, BBAUSD.address, dexKey);
|
|
511
|
-
});
|
|
512
|
-
|
|
493
|
+
// bbausd pool disable after vulnerability
|
|
494
|
+
// it('getTopPoolsForToken', async function () {
|
|
495
|
+
// const BBAUSD = Tokens[Network.MAINNET]['BBAUSD'];
|
|
496
|
+
// const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
497
|
+
// const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
|
|
498
|
+
// const poolLiquidity = await balancerV2.getTopPoolsForToken(
|
|
499
|
+
// BBAUSD.address,
|
|
500
|
+
// 10,
|
|
501
|
+
// );
|
|
502
|
+
// console.log('BBAUSD Top Pools:', poolLiquidity);
|
|
503
|
+
// checkPoolsLiquidity(poolLiquidity, BBAUSD.address, dexKey);
|
|
504
|
+
// });
|
|
513
505
|
// it('applies getRate to phantom bpt scaling factor', async function () {
|
|
514
506
|
// const config = BalancerConfig[dexKey][Network.MAINNET];
|
|
515
507
|
// const dexHelper = new DummyDexHelper(Network.MAINNET);
|
|
@@ -551,6 +543,155 @@ describe('BalancerV2', function () {
|
|
|
551
543
|
// ).toBe('1015093119997891367');
|
|
552
544
|
// });
|
|
553
545
|
});
|
|
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
|
+
});
|
|
554
695
|
});
|
|
555
696
|
|
|
556
697
|
describe('BeetsFi', () => {
|