@paraswap/dex-lib 4.0.22-bal-v2-base-subgraph.0 → 4.0.22

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.
Files changed (171) hide show
  1. package/.vscode/launch.json +53 -0
  2. package/.vscode/settings.json +2 -0
  3. package/.vscode/tasks.json +15 -0
  4. package/build/abi/{integral/pool.json → inception/inception-ineth-pool.json} +558 -537
  5. package/build/abi/inception/inception-ratio-feed.json +329 -0
  6. package/build/abi/inception/inception-vault.json +991 -0
  7. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
  8. package/build/abi/usual-m-smart-m/usualM.abi.json +483 -0
  9. package/build/abi/{integral/relayer.json → wombat/pool.json} +474 -721
  10. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  11. package/build/dex/aave-v1/aave-v1.js +23 -0
  12. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  13. package/build/dex/aave-v2/tokens-avalanche.json +44 -0
  14. package/build/dex/aave-v2/tokens-mainnet.json +188 -0
  15. package/build/dex/aave-v2/tokens-polygon.json +44 -0
  16. package/build/dex/balancer-v2/config.js +1 -1
  17. package/build/dex/balancer-v2/config.js.map +1 -1
  18. package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +729 -0
  19. package/build/dex/balancer-v3/abi/balancerBatchRouter.js +732 -0
  20. package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +1 -0
  21. package/build/dex/balancer-v3/abi/balancerRouter.d.ts +1406 -0
  22. package/build/dex/balancer-v3/abi/balancerRouter.js +1175 -0
  23. package/build/dex/balancer-v3/abi/balancerRouter.js.map +1 -0
  24. package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +2081 -0
  25. package/build/dex/balancer-v3/abi/vaultExtension.V3.js +1851 -0
  26. package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +1 -0
  27. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +34 -0
  28. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +406 -0
  29. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +1 -0
  30. package/build/dex/bebop/bebop.d.ts +4 -4
  31. package/build/dex/bebop/bebop.js +11 -10
  32. package/build/dex/bebop/bebop.js.map +1 -1
  33. package/build/dex/bebop/rate-fetcher.js +0 -9
  34. package/build/dex/bebop/rate-fetcher.js.map +1 -1
  35. package/build/dex/inception/config.d.ts +4 -0
  36. package/build/dex/inception/config.js +109 -0
  37. package/build/dex/inception/config.js.map +1 -0
  38. package/build/dex/inception/inception-event-pool.d.ts +16 -0
  39. package/build/dex/inception/inception-event-pool.js +49 -0
  40. package/build/dex/inception/inception-event-pool.js.map +1 -0
  41. package/build/dex/inception/inception.d.ts +43 -0
  42. package/build/dex/inception/inception.js +180 -0
  43. package/build/dex/inception/inception.js.map +1 -0
  44. package/build/dex/inception/tokens.d.ts +9 -0
  45. package/build/dex/inception/tokens.js +28 -0
  46. package/build/dex/inception/tokens.js.map +1 -0
  47. package/build/dex/inception/types.d.ts +22 -0
  48. package/build/dex/inception/types.js +3 -0
  49. package/build/dex/inception/types.js.map +1 -0
  50. package/build/dex/inception/utils.d.ts +7 -0
  51. package/build/dex/inception/utils.js +58 -0
  52. package/build/dex/inception/utils.js.map +1 -0
  53. package/build/dex/jarvis.d.ts +2 -1
  54. package/build/dex/jarvis.js +58 -0
  55. package/build/dex/jarvis.js.map +1 -1
  56. package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
  57. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  58. package/build/dex/maker-psm/scripts/validate-state.js +185 -0
  59. package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
  60. package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
  61. package/build/dex/maverick-v1/config.js +1 -1
  62. package/build/dex/maverick-v1/config.js.map +1 -1
  63. package/build/dex/platypus/platypus.d.ts +2 -1
  64. package/build/dex/platypus/platypus.js +45 -0
  65. package/build/dex/platypus/platypus.js.map +1 -1
  66. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
  67. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
  68. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
  69. package/build/dex/stable-pool.js +1 -8
  70. package/build/dex/stable-pool.js.map +1 -1
  71. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  72. package/build/dex/swaap-v1/swaap-v1.js +14 -0
  73. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  74. package/build/dex/uniswap-v3/config.js +1 -1
  75. package/build/dex/uniswap-v3/config.js.map +1 -1
  76. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
  77. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
  78. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
  79. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
  80. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
  81. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
  82. package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +4 -0
  83. package/build/dex/uniswap-v3/uniswap-v3-pricing.js +43 -0
  84. package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +1 -0
  85. package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +1 -0
  86. package/build/dex/uniswap-v3/uniswap-v3-worker.js +10 -0
  87. package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +1 -0
  88. package/build/dex/usual/usual-m-smart-m.d.ts +17 -0
  89. package/build/dex/usual/usual-m-smart-m.js +50 -0
  90. package/build/dex/usual/usual-m-smart-m.js.map +1 -0
  91. package/build/dex/usual-m-smart-m/config.d.ts +3 -0
  92. package/build/dex/usual-m-smart-m/config.js +13 -0
  93. package/build/dex/usual-m-smart-m/config.js.map +1 -0
  94. package/build/dex/usual-m-smart-m/types.d.ts +7 -0
  95. package/build/dex/usual-m-smart-m/types.js +3 -0
  96. package/build/dex/usual-m-smart-m/types.js.map +1 -0
  97. package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +35 -0
  98. package/build/dex/usual-m-smart-m/usual-m-smart-m.js +161 -0
  99. package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +1 -0
  100. package/build/dex/usual-m-usd0/config.d.ts +3 -0
  101. package/build/dex/usual-m-usd0/config.js +14 -0
  102. package/build/dex/usual-m-usd0/config.js.map +1 -0
  103. package/build/dex/usual-m-usd0/types.d.ts +8 -0
  104. package/build/dex/usual-m-usd0/types.js +3 -0
  105. package/build/dex/usual-m-usd0/types.js.map +1 -0
  106. package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +35 -0
  107. package/build/dex/usual-m-usd0/usual-m-usd0.js +159 -0
  108. package/build/dex/usual-m-usd0/usual-m-usd0.js.map +1 -0
  109. package/build/dex/zerox/index.d.ts +4 -26
  110. package/build/dex/zerox/index.js +50 -42
  111. package/build/dex/zerox/index.js.map +1 -1
  112. package/build/dex/zerox/types.d.ts +29 -0
  113. package/build/dex/zerox/types.js +8 -1
  114. package/build/dex/zerox/types.js.map +1 -1
  115. package/package.json +1 -1
  116. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +102 -165
  117. package/src/dex/balancer-v2/balancer-v2-integration.test.ts +80 -238
  118. package/src/dex/balancer-v2/config.ts +2 -1
  119. package/src/dex/bebop/bebop.ts +18 -14
  120. package/src/dex/bebop/rate-fetcher.ts +2 -17
  121. package/src/dex/maverick-v1/config.ts +2 -1
  122. package/src/dex/uniswap-v3/config.ts +2 -1
  123. package/.idea/aws.xml +0 -17
  124. package/.idea/codeStyles/Project.xml +0 -19
  125. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  126. package/.idea/misc.xml +0 -6
  127. package/.idea/modules.xml +0 -8
  128. package/.idea/paraswap-dex-lib.iml +0 -9
  129. package/.idea/prettier.xml +0 -7
  130. package/.idea/vcs.xml +0 -6
  131. package/build/abi/integral/factory.json +0 -333
  132. package/build/abi/integral/oracle.json +0 -501
  133. package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
  134. package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
  135. package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
  136. package/build/dex/integral/config.d.ts +0 -4
  137. package/build/dex/integral/config.js +0 -20
  138. package/build/dex/integral/config.js.map +0 -1
  139. package/build/dex/integral/context.d.ts +0 -40
  140. package/build/dex/integral/context.js +0 -158
  141. package/build/dex/integral/context.js.map +0 -1
  142. package/build/dex/integral/integral-factory.d.ts +0 -24
  143. package/build/dex/integral/integral-factory.js +0 -95
  144. package/build/dex/integral/integral-factory.js.map +0 -1
  145. package/build/dex/integral/integral-pool.d.ts +0 -50
  146. package/build/dex/integral/integral-pool.js +0 -149
  147. package/build/dex/integral/integral-pool.js.map +0 -1
  148. package/build/dex/integral/integral-pricing.d.ts +0 -18
  149. package/build/dex/integral/integral-pricing.js +0 -114
  150. package/build/dex/integral/integral-pricing.js.map +0 -1
  151. package/build/dex/integral/integral-relayer.d.ts +0 -42
  152. package/build/dex/integral/integral-relayer.js +0 -192
  153. package/build/dex/integral/integral-relayer.js.map +0 -1
  154. package/build/dex/integral/integral-token.d.ts +0 -27
  155. package/build/dex/integral/integral-token.js +0 -59
  156. package/build/dex/integral/integral-token.js.map +0 -1
  157. package/build/dex/integral/integral.d.ts +0 -41
  158. package/build/dex/integral/integral.js +0 -376
  159. package/build/dex/integral/integral.js.map +0 -1
  160. package/build/dex/integral/types.d.ts +0 -85
  161. package/build/dex/integral/types.js +0 -9
  162. package/build/dex/integral/types.js.map +0 -1
  163. package/build/dex/integral/utils-e2e.d.ts +0 -9
  164. package/build/dex/integral/utils-e2e.js +0 -131
  165. package/build/dex/integral/utils-e2e.js.map +0 -1
  166. package/build/dex/integral/utils.d.ts +0 -17
  167. package/build/dex/integral/utils.js +0 -94
  168. package/build/dex/integral/utils.js.map +0 -1
  169. package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
  170. package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
  171. package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
@@ -30,9 +30,11 @@ async function getOnChainPricingForWeightedPool(
30
30
  return 0n;
31
31
  }
32
32
 
33
- const params = balancerV2.getBalancerV2BatchSwapParam(
33
+ const params = balancerV2.getBalancerParam(
34
34
  srcTokenAddress,
35
35
  destTokenAddress,
36
+ '0',
37
+ '0',
36
38
  {
37
39
  swaps: [
38
40
  {
@@ -42,8 +44,6 @@ async function getOnChainPricingForWeightedPool(
42
44
  ],
43
45
  },
44
46
  side,
45
- balancerV2.dexHelper.config.data.augustusV6Address!,
46
- balancerV2.dexHelper.config.data.augustusV6Address!,
47
47
  );
48
48
 
49
49
  const calldata = [
@@ -611,243 +611,85 @@ describe('BalancerV2', function () {
611
611
  });
612
612
 
613
613
  describe('GyroE', () => {
614
- describe('sDAI > GYD', () => {
615
- // sDAI<>GYD - more likely to have continued liqudity
616
- const gyroEAddr = '0x1cce5169bde03f3d5ad0206f6bd057953539dae6';
617
-
618
- it('getPoolIdentifiers and getPricesVolume', async function () {
619
- const network = Network.MAINNET;
620
- const dexHelper = new DummyDexHelper(network);
621
- // const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
622
- const blocknumber = 19425305;
623
- const balancerV2 = new BalancerV2(network, dexKey, dexHelper);
624
- const tokens = Tokens[network];
625
-
626
- await balancerV2.initializePricing(blocknumber);
627
-
628
- const pools = await balancerV2.getPoolIdentifiers(
629
- tokens.GYD,
630
- tokens.sDAI,
631
- SwapSide.SELL,
632
- blocknumber,
633
- );
634
- console.log('GYD <> sDAI Pool Identifiers (Mainnet): ', pools);
635
-
636
- const isPool = pools.find(poolIdentifier =>
637
- poolIdentifier.includes(gyroEAddr),
638
- );
639
-
640
- expect(isPool).toBeDefined();
641
-
642
- const poolPrices = await balancerV2.getPricesVolume(
643
- tokens.GYD,
644
- tokens.sDAI,
645
- amounts,
646
- SwapSide.SELL,
647
- blocknumber,
648
- pools,
649
- );
650
- console.log('GYD <> sDAI Pool Prices (Mainnet): ', poolPrices);
651
-
652
- expect(poolPrices).not.toBeNull();
653
- checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
654
- const isPoolPrice = poolPrices!.find(price =>
655
- price.data.poolId.includes(gyroEAddr),
656
- );
657
- expect(isPoolPrice).toBeDefined();
658
-
659
- const onChainPrices = await getOnChainPricingForWeightedPool(
660
- balancerV2,
661
- blocknumber,
662
- isPoolPrice!,
663
- amounts,
664
- tokens.GYD.address,
665
- tokens.sDAI.address,
666
- SwapSide.SELL,
667
- );
668
-
669
- console.log('GYD <> sDAI on-chain prices: ', onChainPrices);
670
-
671
- expect(onChainPrices).toEqual(isPoolPrice!.prices);
672
-
673
- await balancerV2.releaseResources();
674
- });
675
-
676
- it('getTopPoolsForToken', async function () {
677
- const network = Network.MAINNET;
678
- const dexHelper = new DummyDexHelper(network);
679
- const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
680
- const balancerV2 = new BalancerV2(network, dexKey, dexHelper);
681
- await balancerV2.initializePricing(blocknumber);
682
- const tokens = Tokens[network];
683
-
684
- const poolLiquidity = await balancerV2.getTopPoolsForToken(
685
- tokens.sDAI.address.toLowerCase(),
686
- 10,
687
- );
688
- console.log('sDAI Top Pools (Mainnet):', poolLiquidity);
689
-
690
- checkPoolsLiquidity(poolLiquidity, tokens.sDAI.address, dexKey);
691
- const isTopPool = poolLiquidity.find(
692
- pool => pool.address === gyroEAddr,
693
- );
694
- expect(isTopPool).toBeDefined();
695
- await balancerV2.releaseResources();
696
- });
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();
697
673
  });
698
674
 
699
- describe('WETH / USDC', () => {
700
- const gyroEAddr = '0x4c42b5057a8663e2b1ac21685d1502c937a03817';
701
-
702
- it('SELL WETH -> USDC getPoolIdentifiers and getPricesVolume', async function () {
703
- const network = Network.BASE;
704
-
705
- const dexHelper = new DummyDexHelper(network);
706
- const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
707
- // const blocknumber = 19425305;
708
- const balancerV2 = new BalancerV2(network, dexKey, dexHelper);
709
- const tokens = Tokens[network];
710
-
711
- const amounts = [
712
- 0n,
713
- BI_POWS[18],
714
- 2n * BI_POWS[18],
715
- 3n * BI_POWS[18],
716
- 4n * BI_POWS[18],
717
- 5n * BI_POWS[18],
718
- 6n * BI_POWS[18],
719
- 7n * BI_POWS[18],
720
- 8n * BI_POWS[18],
721
- 9n * BI_POWS[18],
722
- 10n * BI_POWS[18],
723
- ];
724
-
725
- await balancerV2.initializePricing(blocknumber);
726
-
727
- const pools = await balancerV2.getPoolIdentifiers(
728
- tokens.WETH,
729
- tokens.USDC,
730
- SwapSide.SELL,
731
- blocknumber,
732
- );
733
- console.log('WETH <> USDC Pool Identifiers (Mainnet): ', pools);
734
-
735
- const isPool = pools.find(poolIdentifier =>
736
- poolIdentifier.includes(gyroEAddr),
737
- );
738
-
739
- expect(isPool).toBeDefined();
740
-
741
- const poolPrices = await balancerV2.getPricesVolume(
742
- tokens.WETH,
743
- tokens.USDC,
744
- amounts,
745
- SwapSide.SELL,
746
- blocknumber,
747
- pools,
748
- );
749
- console.log('WETH <> USDC Pool Prices (Base): ', poolPrices);
750
-
751
- expect(poolPrices).not.toBeNull();
752
-
753
- // checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
754
- const isPoolPrice = poolPrices!.find(price =>
755
- price.data.poolId.includes(gyroEAddr),
756
- );
757
- expect(isPoolPrice).toBeDefined();
758
-
759
- const onChainPrices = await getOnChainPricingForWeightedPool(
760
- balancerV2,
761
- blocknumber,
762
- isPoolPrice!,
763
- amounts,
764
- tokens.WETH.address,
765
- tokens.USDC.address,
766
- SwapSide.SELL,
767
- );
768
-
769
- console.log('WETH <> USDC on-chain prices: ', onChainPrices);
770
-
771
- expect(onChainPrices).toEqual(isPoolPrice!.prices);
772
-
773
- await balancerV2.releaseResources();
774
- });
775
-
776
- it('SELL USDC -> WETH getPoolIdentifiers and getPricesVolume', async function () {
777
- const network = Network.BASE;
778
- const dexHelper = new DummyDexHelper(network);
779
- // const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
780
- const blocknumber = 24931862;
781
- const balancerV2 = new BalancerV2(network, dexKey, dexHelper);
782
- const tokens = Tokens[network];
783
-
784
- const amounts = [
785
- 0n,
786
- 1000000n,
787
- // BI_POWS[6],
788
- // 2n * BI_POWS[6],
789
- // 3n * BI_POWS[6],
790
- // 4n * BI_POWS[6],
791
- // 5n * BI_POWS[6],
792
- // 6n * BI_POWS[6],
793
- // 7n * BI_POWS[6],
794
- // 8n * BI_POWS[6],
795
- // 9n * BI_POWS[6],
796
- // 10n * BI_POWS[6],
797
- ];
798
-
799
- await balancerV2.initializePricing(blocknumber);
800
-
801
- const pools = await balancerV2.getPoolIdentifiers(
802
- tokens.USDC,
803
- tokens.WETH,
804
- SwapSide.SELL,
805
- blocknumber,
806
- );
807
- console.log('USDC -> WETH Pool Identifiers (Base): ', pools);
808
-
809
- const isPool = pools.find(poolIdentifier =>
810
- poolIdentifier.includes(gyroEAddr),
811
- );
812
-
813
- expect(isPool).toBeDefined();
814
-
815
- const poolPrices = await balancerV2.getPricesVolume(
816
- tokens.USDC,
817
- tokens.WETH,
818
- amounts,
819
- SwapSide.SELL,
820
- blocknumber,
821
- pools,
822
- );
823
- console.log('USDC -> WETH Pool Prices (Base): ', poolPrices);
824
-
825
- expect(poolPrices).not.toBeNull();
826
-
827
- // checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
828
- const isPoolPrice = poolPrices!.find(price =>
829
- price.data.poolId.includes(gyroEAddr),
830
- );
831
- expect(isPoolPrice).toBeDefined();
832
-
833
- console.log('isPoolPrice: ', isPoolPrice);
834
-
835
- const onChainPrices = await getOnChainPricingForWeightedPool(
836
- balancerV2,
837
- blocknumber,
838
- isPoolPrice!,
839
- amounts,
840
- tokens.USDC.address,
841
- tokens.WETH.address,
842
- SwapSide.SELL,
843
- );
844
-
845
- console.log('USDC -> WETH on-chain prices: ', onChainPrices);
846
-
847
- expect(onChainPrices).toEqual(isPoolPrice!.prices);
848
-
849
- await balancerV2.releaseResources();
850
- });
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();
851
693
  });
852
694
  });
853
695
  });
@@ -21,7 +21,8 @@ export const BalancerConfig: DexConfigMap<DexParams> = {
21
21
  vaultAddress: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
22
22
  },
23
23
  [Network.BASE]: {
24
- subgraphURL: 'E7XyutxXVLrp8njmjF16Hh38PCJuHm12RRyMt5ma4ctX',
24
+ subgraphURL:
25
+ 'https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest',
25
26
  vaultAddress: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
26
27
  },
27
28
  [Network.GNOSIS]: {
@@ -13,7 +13,7 @@ import {
13
13
  NumberAsString,
14
14
  DexExchangeParam,
15
15
  } from '../../types';
16
- import { SwapSide, Network, ETHER_ADDRESS } from '../../constants';
16
+ import { SwapSide, Network } from '../../constants';
17
17
  import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
18
18
  import { getDexKeysWithNetwork, Utils } from '../../utils';
19
19
  import { IDex } from '../../dex/idex';
@@ -56,11 +56,10 @@ import BigNumber from 'bignumber.js';
56
56
  import { getBigNumberPow } from '../../bignumber-constants';
57
57
  import { ethers, utils } from 'ethers';
58
58
  import qs from 'qs';
59
- import { isEqual } from 'lodash';
60
59
 
61
60
  export class Bebop extends SimpleExchange implements IDex<BebopData> {
62
61
  readonly hasConstantPriceLargeAmounts = false;
63
- readonly needWrapNative = false;
62
+ readonly needWrapNative = true;
64
63
 
65
64
  readonly isFeeOnTransferSupported = false;
66
65
  readonly isStatePollingDex = true;
@@ -186,11 +185,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
186
185
  srcToken.address.toLowerCase(),
187
186
  destToken.address.toLowerCase(),
188
187
  ]);
189
- const nativeWrappedSet = new Set([
190
- this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase(),
191
- ETHER_ADDRESS.toLowerCase(),
192
- ]);
193
- if (tokensSet.size < 2 || isEqual(tokensSet, nativeWrappedSet)) {
188
+ if (tokensSet.size < 2) {
194
189
  return [];
195
190
  }
196
191
 
@@ -281,11 +276,14 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
281
276
  // across DEXes. It is recommended to use
282
277
  // ${dexKey}_${poolAddress} as a poolIdentifier
283
278
  async getPoolIdentifiers(
284
- srcToken: Token,
285
- destToken: Token,
279
+ _srcToken: Token,
280
+ _destToken: Token,
286
281
  side: SwapSide,
287
282
  blockNumber: number,
288
283
  ): Promise<string[]> {
284
+ const srcToken = this.dexHelper.config.wrapETH(_srcToken);
285
+ const destToken = this.dexHelper.config.wrapETH(_destToken);
286
+
289
287
  if (
290
288
  (await this.calculateInstructions(srcToken, destToken, side)).length > 0
291
289
  ) {
@@ -387,8 +385,8 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
387
385
  // should be used. If limitPools is undefined then
388
386
  // any pools can be used.
389
387
  async getPricesVolume(
390
- srcToken: Token,
391
- destToken: Token,
388
+ _srcToken: Token,
389
+ _destToken: Token,
392
390
  amounts: bigint[],
393
391
  side: SwapSide,
394
392
  blockNumber: number,
@@ -399,6 +397,9 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
399
397
  return null;
400
398
  }
401
399
 
400
+ const srcToken = this.dexHelper.config.wrapETH(_srcToken);
401
+ const destToken = this.dexHelper.config.wrapETH(_destToken);
402
+
402
403
  try {
403
404
  let pools = limitPools
404
405
  ? limitPools.filter(
@@ -696,14 +697,17 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
696
697
 
697
698
  async preProcessTransaction(
698
699
  optimalSwapExchange: OptimalSwapExchange<BebopData>,
699
- srcToken: Token,
700
- destToken: Token,
700
+ _srcToken: Token,
701
+ _destToken: Token,
701
702
  side: SwapSide,
702
703
  options: PreprocessTransactionOptions,
703
704
  ): Promise<[OptimalSwapExchange<BebopData>, ExchangeTxInfo]> {
704
705
  const isSell = side === SwapSide.SELL;
705
706
  const isBuy = side === SwapSide.BUY;
706
707
 
708
+ const srcToken = this.dexHelper.config.wrapETH(_srcToken);
709
+ const destToken = this.dexHelper.config.wrapETH(_destToken);
710
+
707
711
  const params = {
708
712
  sell_tokens: utils.getAddress(srcToken.address),
709
713
  buy_tokens: utils.getAddress(destToken.address),
@@ -1,4 +1,4 @@
1
- import { ETHER_ADDRESS, Network } from '../../constants';
1
+ import { Network } from '../../constants';
2
2
  import { IDexHelper } from '../../dex-helper';
3
3
  import { Fetcher } from '../../lib/fetcher/fetcher';
4
4
  import { validateAndCast, ValidationError } from '../../lib/validators';
@@ -10,11 +10,7 @@ import {
10
10
  BebopRateFetcherConfig,
11
11
  BebopTokensResponse,
12
12
  } from './types';
13
- import {
14
- BebopPricingUpdate,
15
- pricesResponseValidator,
16
- tokensResponseValidator,
17
- } from './validators';
13
+ import { BebopPricingUpdate, tokensResponseValidator } from './validators';
18
14
  import { WebSocketFetcher } from '../../lib/fetcher/wsFetcher';
19
15
  import { utils } from 'ethers';
20
16
 
@@ -156,20 +152,9 @@ export class RateFetcher {
156
152
  }
157
153
 
158
154
  private handlePricesResponse(resp: BebopPricingResponse): void {
159
- const wethAddress =
160
- this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase();
161
155
  const normalizedPrices: BebopPricingResponse = {};
162
156
  for (const [pair, levels] of Object.entries(resp)) {
163
157
  normalizedPrices[pair.toLowerCase()] = levels;
164
- const [base, quote] = pair.split('/');
165
- // Also enter native token prices. Pricing doesn't come with these
166
- if (
167
- base.toLowerCase() === wethAddress ||
168
- quote.toLowerCase() === wethAddress
169
- ) {
170
- const nativePair = pair.replace(base, ETHER_ADDRESS);
171
- normalizedPrices[nativePair.toLowerCase()] = levels;
172
- }
173
158
  }
174
159
 
175
160
  this.dexHelper.cache.setex(
@@ -14,7 +14,8 @@ export const MaverickV1Config: DexConfigMap<DexParams> = {
14
14
  poolInspectorAddress: '0xaA5BF61a664109e959D69C38734d4EA7dF74e456',
15
15
  },
16
16
  [Network.BASE]: {
17
- subgraphURL: 'CSxkHjxpG1TxTBQMn55uG1DWpdD4Lsix4RNX4RTLvK4T',
17
+ subgraphURL:
18
+ 'https://api.studio.thegraph.com/query/42519/maverick-base/version/latest',
18
19
  routerAddress: '0x32AED3Bce901DA12ca8489788F3A99fCe1056e14',
19
20
  poolInspectorAddress: '0x65A3AD03Be97619284bA7AA1E3Ca05638B9d6364',
20
21
  },
@@ -117,7 +117,8 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
117
117
  chunksCount: 10,
118
118
  initRetryFrequency: 10,
119
119
  initHash: `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`,
120
- subgraphURL: 'GqzP4Xaehti8KSfQmv3ZctFSjnSUYZ4En5NRsiTbvZpz',
120
+ subgraphURL:
121
+ 'https://api.studio.thegraph.com/query/48211/uniswap-v3-base/version/latest',
121
122
  },
122
123
  },
123
124
  SushiSwapV3: {
package/.idea/aws.xml DELETED
@@ -1,17 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="accountSettings">
4
- <option name="activeProfile" value="profile:default" />
5
- <option name="activeRegion" value="us-east-1" />
6
- <option name="recentlyUsedProfiles">
7
- <list>
8
- <option value="profile:default" />
9
- </list>
10
- </option>
11
- <option name="recentlyUsedRegions">
12
- <list>
13
- <option value="us-east-1" />
14
- </list>
15
- </option>
16
- </component>
17
- </project>
@@ -1,19 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <ScalaCodeStyleSettings>
4
- <option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
5
- </ScalaCodeStyleSettings>
6
- <TypeScriptCodeStyleSettings version="0">
7
- <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
8
- <option name="USE_DOUBLE_QUOTES" value="false" />
9
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
10
- </TypeScriptCodeStyleSettings>
11
- <codeStyleSettings language="TypeScript">
12
- <indentOptions>
13
- <option name="INDENT_SIZE" value="2" />
14
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
15
- <option name="TAB_SIZE" value="2" />
16
- </indentOptions>
17
- </codeStyleSettings>
18
- </code_scheme>
19
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager">
4
- <output url="file://$PROJECT_DIR$/out" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" filepath="$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="JAVA_MODULE" version="4">
3
- <component name="NewModuleRootManager" inherit-compiler-output="true">
4
- <exclude-output />
5
- <content url="file://$MODULE_DIR$" />
6
- <orderEntry type="inheritedJdk" />
7
- <orderEntry type="sourceFolder" forTests="false" />
8
- </component>
9
- </module>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="PrettierConfiguration">
4
- <option name="myRunOnSave" value="true" />
5
- <option name="myRunOnReformat" value="true" />
6
- </component>
7
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>