@paraswap/dex-lib 4.1.4-bal-v3-hooks.0 → 4.1.4

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 (321) hide show
  1. package/build/abi/Aave_GSM.json +751 -0
  2. package/build/abi/Balancer.json +257 -0
  3. package/build/abi/{balancer-v3/stableSurgeHook.json → BalancerV2.json} +732 -529
  4. package/build/abi/{integral/relayer.json → RamsesV2Pool.abi.json} +850 -832
  5. package/build/abi/RamsesV2Quoter.abi.json +274 -0
  6. package/build/abi/USDM.json +807 -0
  7. package/build/abi/UniswapV2Router.json +397 -0
  8. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
  9. package/build/abi/{integral/oracle.json → angle-transmuter/ChainlinkEACAggregatorProxy.json} +247 -239
  10. package/build/abi/curve-v1/CurveBUSDv2.abi.json +1356 -0
  11. package/build/abi/curve-v1/CurveTokenV1.json +305 -0
  12. package/build/abi/curve-v1/CurveTokenV2.json +318 -0
  13. package/build/abi/curve-v1/CurveV1StableNg.json +1452 -0
  14. package/build/abi/curve-v1/CurveV2Swap.json +700 -0
  15. package/build/abi/curve-v1/FactoryCryptoRegistry.json +316 -0
  16. package/build/abi/curve-v1/FactoryRegistry.json +508 -0
  17. package/build/abi/curve-v1/StableSwapAave.json +1152 -0
  18. package/build/abi/curve-v1/StableSwapBUSD.json +814 -0
  19. package/build/abi/curve-v1/StableSwapCompound.json +814 -0
  20. package/build/abi/curve-v1/StableSwapIDLE.json +1253 -0
  21. package/build/abi/curve-v1/StableSwapPax.json +865 -0
  22. package/build/abi/curve-v1/StableSwapSnow.json +900 -0
  23. package/build/abi/{integral/pool.json → curve-v1/StableSwapUSDN.json} +450 -487
  24. package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
  25. package/build/abi/curve-v1/StableSwapY.json +814 -0
  26. package/build/abi/fluid-dex/resolver.abi.json +30 -0
  27. package/build/abi/inception/inception-ineth-pool.json +1062 -0
  28. package/build/abi/inception/inception-ineth.json +609 -0
  29. package/build/abi/inception/inception-ratio-feed.json +329 -0
  30. package/build/abi/inception/inception-vault.json +991 -0
  31. package/build/abi/kyberdmm/kyber-storage.abi.json +824 -0
  32. package/build/abi/kyberdmm.abi.json +1148 -0
  33. package/build/abi/maverick-v2/MaverickV2Quoter.json +278 -0
  34. package/build/abi/nerve/nerve-metapool.json +790 -0
  35. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
  36. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
  37. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  38. package/build/dex/aave-v1/aave-v1.js +22 -0
  39. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  40. package/build/dex/balancer-v1/balancer-pools.json +33333 -0
  41. package/build/dex/balancer-v3/balancer-v3-pool.d.ts +1 -4
  42. package/build/dex/balancer-v3/balancer-v3-pool.js +13 -20
  43. package/build/dex/balancer-v3/balancer-v3-pool.js.map +1 -1
  44. package/build/dex/balancer-v3/balancer-v3.d.ts +0 -4
  45. package/build/dex/balancer-v3/balancer-v3.js +3 -29
  46. package/build/dex/balancer-v3/balancer-v3.js.map +1 -1
  47. package/build/dex/balancer-v3/config.js +0 -39
  48. package/build/dex/balancer-v3/config.js.map +1 -1
  49. package/build/dex/balancer-v3/getOnChainState.d.ts +2 -1
  50. package/build/dex/balancer-v3/getOnChainState.js +2 -0
  51. package/build/dex/balancer-v3/getOnChainState.js.map +1 -1
  52. package/build/dex/balancer-v3/getPoolsApi.d.ts +1 -2
  53. package/build/dex/balancer-v3/getPoolsApi.js +10 -17
  54. package/build/dex/balancer-v3/getPoolsApi.js.map +1 -1
  55. package/build/dex/balancer-v3/getTopPoolsApi.d.ts +1 -5
  56. package/build/dex/balancer-v3/getTopPoolsApi.js +3 -6
  57. package/build/dex/balancer-v3/getTopPoolsApi.js.map +1 -1
  58. package/build/dex/balancer-v3/types.d.ts +1 -4
  59. package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
  60. package/build/dex/bebop/websocket-fetcher.js +87 -0
  61. package/build/dex/bebop/websocket-fetcher.js.map +1 -0
  62. package/build/dex/fluid-dex/config.js +2 -2
  63. package/build/dex/fluid-dex/constants.d.ts +1 -1
  64. package/build/dex/fluid-dex/constants.js +2 -1
  65. package/build/dex/fluid-dex/constants.js.map +1 -1
  66. package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js +3 -1
  67. package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js.map +1 -1
  68. package/build/dex/fluid-dex/fluid-dex.d.ts +4 -5
  69. package/build/dex/fluid-dex/fluid-dex.js +61 -59
  70. package/build/dex/fluid-dex/fluid-dex.js.map +1 -1
  71. package/build/dex/fluid-dex/types.d.ts +3 -0
  72. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  73. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  74. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  75. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  76. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  77. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  78. package/build/dex/idle-dao/scripts.d.ts +9 -0
  79. package/build/dex/idle-dao/scripts.js +552 -0
  80. package/build/dex/idle-dao/scripts.js.map +1 -0
  81. package/build/dex/inception/config.d.ts +4 -0
  82. package/build/dex/inception/config.js +109 -0
  83. package/build/dex/inception/config.js.map +1 -0
  84. package/build/dex/inception/inception-event-pool.d.ts +16 -0
  85. package/build/dex/inception/inception-event-pool.js +51 -0
  86. package/build/dex/inception/inception-event-pool.js.map +1 -0
  87. package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
  88. package/build/dex/inception/inception-native.js +131 -0
  89. package/build/dex/inception/inception-native.js.map +1 -0
  90. package/build/dex/inception/inception-pool.d.ts +18 -0
  91. package/build/dex/inception/inception-pool.js +32 -0
  92. package/build/dex/inception/inception-pool.js.map +1 -0
  93. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  94. package/build/dex/inception/inception-price-feed.js +51 -0
  95. package/build/dex/inception/inception-price-feed.js.map +1 -0
  96. package/build/dex/inception/inception.d.ts +43 -0
  97. package/build/dex/inception/inception.js +204 -0
  98. package/build/dex/inception/inception.js.map +1 -0
  99. package/build/dex/inception/tokens.d.ts +9 -0
  100. package/build/dex/inception/tokens.js +28 -0
  101. package/build/dex/inception/tokens.js.map +1 -0
  102. package/build/dex/inception/types.d.ts +22 -0
  103. package/build/dex/inception/types.js +3 -0
  104. package/build/dex/inception/types.js.map +1 -0
  105. package/build/dex/inception/utils.d.ts +6 -0
  106. package/build/dex/inception/utils.js +37 -0
  107. package/build/dex/inception/utils.js.map +1 -0
  108. package/build/dex/jarvis.d.ts +2 -1
  109. package/build/dex/jarvis.js +58 -0
  110. package/build/dex/jarvis.js.map +1 -1
  111. package/build/dex/platypus/platypus.d.ts +2 -1
  112. package/build/dex/platypus/platypus.js +31 -0
  113. package/build/dex/platypus/platypus.js.map +1 -1
  114. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  115. package/build/dex/swaap-v1/swaap-v1.js +10 -0
  116. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  117. package/build/dex/zerox/index.d.ts +4 -26
  118. package/build/dex/zerox/index.js +50 -42
  119. package/build/dex/zerox/index.js.map +1 -1
  120. package/build/dex/zerox/types.d.ts +29 -0
  121. package/build/dex/zerox/types.js +8 -1
  122. package/build/dex/zerox/types.js.map +1 -1
  123. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
  124. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
  125. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
  126. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
  127. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
  128. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
  129. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
  130. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
  131. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
  132. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
  133. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
  134. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
  135. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
  136. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
  137. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
  138. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
  139. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
  140. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
  141. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
  142. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
  143. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
  144. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
  145. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
  146. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
  147. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
  148. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
  149. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
  150. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
  151. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
  152. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
  153. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
  154. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
  155. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
  156. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
  157. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
  158. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
  159. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
  160. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
  161. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
  162. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
  163. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
  164. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
  165. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
  166. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
  167. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
  168. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
  169. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
  170. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
  171. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
  172. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
  173. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
  174. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
  175. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
  176. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
  177. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
  178. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
  179. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
  180. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
  181. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
  182. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
  183. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
  184. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
  185. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
  186. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
  187. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
  188. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
  189. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
  190. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
  191. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
  192. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
  193. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
  194. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
  195. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
  196. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
  197. package/package.json +2 -2
  198. package/scripts/run-dex-integration-v3.ts +4 -4
  199. package/src/abi/fluid-dex/resolver.abi.json +30 -0
  200. package/src/dex/balancer-v3/balancer-v3-e2e.test.ts +0 -20
  201. package/src/dex/balancer-v3/balancer-v3-integration.test.ts +197 -2
  202. package/src/dex/balancer-v3/balancer-v3-pool.ts +13 -37
  203. package/src/dex/balancer-v3/balancer-v3.ts +1 -42
  204. package/src/dex/balancer-v3/config.ts +0 -39
  205. package/src/dex/balancer-v3/getOnChainState.ts +4 -1
  206. package/src/dex/balancer-v3/getPoolsApi.ts +23 -42
  207. package/src/dex/balancer-v3/getTopPoolsApi.ts +2 -13
  208. package/src/dex/balancer-v3/types.ts +2 -4
  209. package/src/dex/fluid-dex/config.ts +2 -2
  210. package/src/dex/fluid-dex/constants.ts +2 -1
  211. package/src/dex/fluid-dex/fluid-dex-e2e.test.ts +61 -117
  212. package/src/dex/fluid-dex/fluid-dex-liquidity-proxy.ts +3 -0
  213. package/src/dex/fluid-dex/fluid-dex.ts +96 -94
  214. package/src/dex/fluid-dex/types.ts +3 -0
  215. package/tests/constants-e2e.ts +2 -7
  216. package/tests/tenderly-simulation.ts +1 -0
  217. package/.idea/aws.xml +0 -17
  218. package/.idea/codeStyles/Project.xml +0 -19
  219. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  220. package/.idea/misc.xml +0 -6
  221. package/.idea/modules.xml +0 -8
  222. package/.idea/paraswap-dex-lib.iml +0 -9
  223. package/.idea/prettier.xml +0 -7
  224. package/.idea/vcs.xml +0 -6
  225. package/build/abi/balancer-v3/directionalFeeHook.json +0 -684
  226. package/build/abi/integral/factory.json +0 -333
  227. package/build/dex/bProtocol.d.ts +0 -18
  228. package/build/dex/bProtocol.js +0 -39
  229. package/build/dex/bProtocol.js.map +0 -1
  230. package/build/dex/balancer-v3/balancer-test-helpers.d.ts +0 -5
  231. package/build/dex/balancer-v3/balancer-test-helpers.js +0 -122
  232. package/build/dex/balancer-v3/balancer-test-helpers.js.map +0 -1
  233. package/build/dex/balancer-v3/hooks/balancer-hook-event-subscriber.d.ts +0 -54
  234. package/build/dex/balancer-v3/hooks/balancer-hook-event-subscriber.js +0 -153
  235. package/build/dex/balancer-v3/hooks/balancer-hook-event-subscriber.js.map +0 -1
  236. package/build/dex/balancer-v3/hooks/directionalFeeHook.d.ts +0 -26
  237. package/build/dex/balancer-v3/hooks/directionalFeeHook.js +0 -41
  238. package/build/dex/balancer-v3/hooks/directionalFeeHook.js.map +0 -1
  239. package/build/dex/balancer-v3/hooks/loadHooksConfig.d.ts +0 -2
  240. package/build/dex/balancer-v3/hooks/loadHooksConfig.js +0 -11
  241. package/build/dex/balancer-v3/hooks/loadHooksConfig.js.map +0 -1
  242. package/build/dex/balancer-v3/hooks/stableSurgeHook.d.ts +0 -39
  243. package/build/dex/balancer-v3/hooks/stableSurgeHook.js +0 -99
  244. package/build/dex/balancer-v3/hooks/stableSurgeHook.js.map +0 -1
  245. package/build/dex/bancor.d.ts +0 -26
  246. package/build/dex/bancor.js +0 -58
  247. package/build/dex/bancor.js.map +0 -1
  248. package/build/dex/compound.d.ts +0 -18
  249. package/build/dex/compound.js +0 -46
  250. package/build/dex/compound.js.map +0 -1
  251. package/build/dex/curve-v2.d.ts +0 -58
  252. package/build/dex/curve-v2.js +0 -180
  253. package/build/dex/curve-v2.js.map +0 -1
  254. package/build/dex/dodo-v1.d.ts +0 -33
  255. package/build/dex/dodo-v1.js +0 -63
  256. package/build/dex/dodo-v1.js.map +0 -1
  257. package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
  258. package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
  259. package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
  260. package/build/dex/integral/config.d.ts +0 -4
  261. package/build/dex/integral/config.js +0 -20
  262. package/build/dex/integral/config.js.map +0 -1
  263. package/build/dex/integral/context.d.ts +0 -40
  264. package/build/dex/integral/context.js +0 -158
  265. package/build/dex/integral/context.js.map +0 -1
  266. package/build/dex/integral/integral-factory.d.ts +0 -24
  267. package/build/dex/integral/integral-factory.js +0 -95
  268. package/build/dex/integral/integral-factory.js.map +0 -1
  269. package/build/dex/integral/integral-pool.d.ts +0 -50
  270. package/build/dex/integral/integral-pool.js +0 -149
  271. package/build/dex/integral/integral-pool.js.map +0 -1
  272. package/build/dex/integral/integral-pricing.d.ts +0 -18
  273. package/build/dex/integral/integral-pricing.js +0 -114
  274. package/build/dex/integral/integral-pricing.js.map +0 -1
  275. package/build/dex/integral/integral-relayer.d.ts +0 -42
  276. package/build/dex/integral/integral-relayer.js +0 -192
  277. package/build/dex/integral/integral-relayer.js.map +0 -1
  278. package/build/dex/integral/integral-token.d.ts +0 -27
  279. package/build/dex/integral/integral-token.js +0 -59
  280. package/build/dex/integral/integral-token.js.map +0 -1
  281. package/build/dex/integral/integral.js +0 -376
  282. package/build/dex/integral/integral.js.map +0 -1
  283. package/build/dex/integral/types.d.ts +0 -85
  284. package/build/dex/integral/types.js +0 -9
  285. package/build/dex/integral/types.js.map +0 -1
  286. package/build/dex/integral/utils-e2e.d.ts +0 -9
  287. package/build/dex/integral/utils-e2e.js +0 -131
  288. package/build/dex/integral/utils-e2e.js.map +0 -1
  289. package/build/dex/integral/utils.d.ts +0 -17
  290. package/build/dex/integral/utils.js +0 -94
  291. package/build/dex/integral/utils.js.map +0 -1
  292. package/build/dex/lido.d.ts +0 -19
  293. package/build/dex/lido.js +0 -42
  294. package/build/dex/lido.js.map +0 -1
  295. package/build/dex/onebit.d.ts +0 -25
  296. package/build/dex/onebit.js +0 -42
  297. package/build/dex/onebit.js.map +0 -1
  298. package/build/dex/smoothy.d.ts +0 -26
  299. package/build/dex/smoothy.js +0 -48
  300. package/build/dex/smoothy.js.map +0 -1
  301. package/build/dex/stable-pool.d.ts +0 -28
  302. package/build/dex/stable-pool.js +0 -62
  303. package/build/dex/stable-pool.js.map +0 -1
  304. package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
  305. package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
  306. package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
  307. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
  308. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
  309. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
  310. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  311. package/build/dex/trader-joe-v2.1.js +0 -79
  312. package/build/dex/trader-joe-v2.1.js.map +0 -1
  313. package/src/abi/balancer-v3/directionalFeeHook.json +0 -684
  314. package/src/abi/balancer-v3/stableSurgeHook.json +0 -976
  315. package/src/dex/balancer-v3/balancer-hooks-events.test.ts +0 -99
  316. package/src/dex/balancer-v3/balancer-stableSurge.test.ts +0 -110
  317. package/src/dex/balancer-v3/balancer-test-helpers.ts +0 -199
  318. package/src/dex/balancer-v3/hooks/balancer-hook-event-subscriber.ts +0 -226
  319. package/src/dex/balancer-v3/hooks/directionalFeeHook.ts +0 -51
  320. package/src/dex/balancer-v3/hooks/loadHooksConfig.ts +0 -12
  321. package/src/dex/balancer-v3/hooks/stableSurgeHook.ts +0 -163
@@ -1,99 +0,0 @@
1
- // npx jest src/dex/balancer-v3/balancer-hooks-events.test.ts
2
- /* eslint-disable no-console */
3
- import dotenv from 'dotenv';
4
- dotenv.config();
5
- import _ from 'lodash';
6
- import { Network } from '../../constants';
7
- import { Address } from '../../types';
8
- import { DummyDexHelper } from '../../dex-helper/index';
9
- import { testEventSubscriber } from '../../../tests/utils-events';
10
- import {
11
- BalancerEventHook,
12
- HookStateMap,
13
- } from './hooks/balancer-hook-event-subscriber';
14
-
15
- jest.setTimeout(50 * 1000);
16
-
17
- async function fetchHookState(
18
- balancerEventHook: BalancerEventHook,
19
- blockNumber: number,
20
- hookAddress: string,
21
- ): Promise<HookStateMap> {
22
- const hookStateMap = await balancerEventHook.generateState(blockNumber);
23
- // Filter to hook of interest
24
- return Object.entries(_.cloneDeep(hookStateMap) as HookStateMap)
25
- .filter(([address]) => {
26
- return address.toLowerCase() === hookAddress.toLowerCase();
27
- })
28
- .reduce((acc, [address, pool]) => {
29
- acc[address] = pool;
30
- return acc;
31
- }, {} as HookStateMap);
32
- }
33
-
34
- // eventName -> blockNumbers
35
- type EventMappings = Record<string, EventData>;
36
- type EventData = { blockNumbers: number[]; hookAddress: string[] };
37
-
38
- describe('BalancerEventHook', function () {
39
- const dexKey = 'BalancerV3';
40
- const network = Network.SEPOLIA;
41
- const dexHelper = new DummyDexHelper(network);
42
- const logger = dexHelper.getLogger(dexKey);
43
- let balancerEventHook: BalancerEventHook;
44
-
45
- // hook -> EventMappings
46
- const eventsToTest: Record<Address, EventMappings> = {
47
- ['StableSurgeHook']: {
48
- // https://sepolia.etherscan.io/tx/0xa8d363d9c78b7b66e6f93c4417de67e636c13691437aecf85a631987b200abd8
49
- ThresholdSurgePercentageChanged: {
50
- blockNumbers: [7596856],
51
- hookAddress: ['0xC0cbcdD6b823A4f22aA6BbDDe44C17e754266AEF'],
52
- },
53
- // https://sepolia.etherscan.io/tx/0xd1a9e40ed3c3d32bf8f2264daa4c66879ac5eae1f4029ae9993badd653b26bad
54
- MaxSurgeFeePercentageChanged: {
55
- blockNumbers: [7596855],
56
- hookAddress: ['0xC0cbcdD6b823A4f22aA6BbDDe44C17e754266AEF'],
57
- },
58
- },
59
- };
60
-
61
- beforeEach(async () => {
62
- balancerEventHook = new BalancerEventHook(
63
- dexKey,
64
- network,
65
- dexHelper,
66
- logger,
67
- );
68
- });
69
-
70
- Object.entries(eventsToTest).forEach(
71
- ([hookAddress, events]: [string, EventMappings]) => {
72
- describe(`Events for Hook: ${hookAddress}`, () => {
73
- Object.entries(events).forEach(
74
- ([eventName, eventData]: [string, EventData]) => {
75
- describe(`${eventName}`, () => {
76
- eventData.blockNumbers.forEach((blockNumber: number, i) => {
77
- it(`Hook: ${eventData.hookAddress[i]} State after ${blockNumber}`, async function () {
78
- await testEventSubscriber(
79
- balancerEventHook,
80
- balancerEventHook.addressesSubscribed,
81
- (_blockNumber: number) =>
82
- fetchHookState(
83
- balancerEventHook,
84
- _blockNumber,
85
- eventData.hookAddress[i],
86
- ),
87
- blockNumber,
88
- `${dexKey}_${hookAddress}`,
89
- dexHelper.provider,
90
- );
91
- });
92
- });
93
- });
94
- },
95
- );
96
- });
97
- },
98
- );
99
- });
@@ -1,110 +0,0 @@
1
- // npx jest src/dex/balancer-v3/balancer-stableSurge.test.ts
2
- import dotenv from 'dotenv';
3
- dotenv.config();
4
- import { Tokens } from '../../../tests/constants-e2e';
5
- import { Network, SwapSide } from '../../constants';
6
- import { DummyDexHelper } from '../../dex-helper';
7
- import { BalancerV3 } from './balancer-v3';
8
- import { checkOnChainPricingNonMulti } from './balancer-test-helpers';
9
- import { ExchangePrices, Token } from '../../types';
10
- import { BalancerV3Data } from './types';
11
-
12
- const dexKey = 'BalancerV3';
13
- const blockNumber = 7651340;
14
- let balancerV3: BalancerV3;
15
- const network = Network.SEPOLIA;
16
- const dexHelper = new DummyDexHelper(network);
17
- const tokens = Tokens[network];
18
- const bal = tokens['bal'];
19
- const weth = tokens['WETH'];
20
- // https://sepolia.etherscan.io/address/0x132F4bAa39330d9062fC52d81dF72F601DF8C01f
21
- const stableSurgePool =
22
- '0x132F4bAa39330d9062fC52d81dF72F601DF8C01f'.toLowerCase();
23
-
24
- describe('BalancerV3 stableSurge hook tests', function () {
25
- beforeAll(async () => {
26
- balancerV3 = new BalancerV3(network, dexKey, dexHelper);
27
- if (balancerV3.initializePricing) {
28
- await balancerV3.initializePricing(blockNumber);
29
- }
30
- });
31
-
32
- describe('pool with stableSurge hook should be returned', function () {
33
- it('getPoolIdentifiers', async function () {
34
- const pools = await balancerV3.getPoolIdentifiers(
35
- bal,
36
- weth,
37
- SwapSide.SELL,
38
- blockNumber,
39
- );
40
- expect(pools.some(pool => pool === stableSurgePool)).toBe(true);
41
- });
42
-
43
- it('getTopPoolsForToken', async function () {
44
- const pools = await balancerV3.getTopPoolsForToken(weth.address, 10);
45
- expect(pools.some(pool => pool.address === stableSurgePool)).toBe(true);
46
- });
47
- });
48
-
49
- describe('should match onchain pricing', function () {
50
- describe('using staticFee', function () {
51
- it('SELL', async function () {
52
- const amounts = [0n, 10000000000000000n];
53
- const side = SwapSide.SELL;
54
- await testPricesVsOnchain(amounts, weth, bal, side, blockNumber, [
55
- stableSurgePool,
56
- ]);
57
- });
58
- it('BUY', async function () {
59
- const amounts = [0n, 500000000000000000n];
60
- const side = SwapSide.BUY;
61
- await testPricesVsOnchain(amounts, weth, bal, side, blockNumber, [
62
- stableSurgePool,
63
- ]);
64
- });
65
- });
66
- describe('using surge fee', function () {
67
- it('SELL', async function () {
68
- const amounts = [0n, 8000000000000000000n];
69
- const side = SwapSide.SELL;
70
- await testPricesVsOnchain(amounts, bal, weth, side, blockNumber, [
71
- stableSurgePool,
72
- ]);
73
- });
74
- it('BUY', async function () {
75
- const amounts = [0n, 4000000000000000n];
76
- const side = SwapSide.BUY;
77
- await testPricesVsOnchain(amounts, bal, weth, side, blockNumber, [
78
- stableSurgePool,
79
- ]);
80
- });
81
- });
82
- });
83
- });
84
-
85
- async function testPricesVsOnchain(
86
- amounts: bigint[],
87
- srcToken: Token,
88
- dstToken: Token,
89
- side: SwapSide,
90
- blockNumber: number,
91
- limitPools: string[],
92
- ) {
93
- const prices = await balancerV3.getPricesVolume(
94
- srcToken,
95
- dstToken,
96
- amounts,
97
- side,
98
- blockNumber,
99
- limitPools,
100
- );
101
- expect(prices).not.toBeNull();
102
- await checkOnChainPricingNonMulti(
103
- network,
104
- side,
105
- balancerV3,
106
- blockNumber,
107
- prices as ExchangePrices<BalancerV3Data>,
108
- amounts,
109
- );
110
- }
@@ -1,199 +0,0 @@
1
- /* eslint-disable no-console */
2
- // Note - this is currently needed because queries won't work with multicall but should be updated in future
3
- export async function checkOnChainPricingNonMulti(
4
- network: number,
5
- side: SwapSide,
6
- balancerV3: BalancerV3,
7
- blockNumber: number,
8
- prices: ExchangePrices<BalancerV3Data>,
9
- amounts: bigint[],
10
- ) {
11
- // test match for each returned price
12
- for (const price of prices) {
13
- let expectedPrices: bigint[] = [];
14
- if (price.data.steps.length === 1 && !price.data.steps[0].isBuffer)
15
- expectedPrices = await querySinglePathPrices(
16
- network,
17
- side,
18
- balancerV3,
19
- blockNumber,
20
- price,
21
- amounts,
22
- );
23
- else
24
- expectedPrices = await queryMultiPathPrices(
25
- network,
26
- side,
27
- balancerV3,
28
- blockNumber,
29
- price,
30
- amounts,
31
- );
32
- expect(price.prices).toEqual(expectedPrices);
33
- }
34
- }
35
-
36
- async function querySinglePathPrices(
37
- network: number,
38
- side: SwapSide,
39
- balancerV3: BalancerV3,
40
- blockNumber: number,
41
- price: PoolPrices<BalancerV3Data>,
42
- amounts: bigint[],
43
- ) {
44
- const balancerRouter = new Interface(balancerRouterAbi);
45
- const readerCallData = getQuerySwapSingleTokenCalldata(
46
- BalancerV3Config.BalancerV3[network].balancerRouterAddress,
47
- balancerRouter,
48
- amounts,
49
- price.data.steps[0],
50
- side,
51
- );
52
-
53
- const expectedPrices = [0n];
54
- for (const call of readerCallData) {
55
- try {
56
- const result = await balancerV3.dexHelper.provider.call(
57
- {
58
- to: call.target,
59
- data: call.callData,
60
- },
61
- blockNumber,
62
- );
63
- const parsed = balancerRouter.decodeFunctionResult(
64
- side === SwapSide.SELL
65
- ? `querySwapSingleTokenExactIn`
66
- : `querySwapSingleTokenExactOut`,
67
- result,
68
- );
69
- expectedPrices.push(BigInt(parsed[0]._hex));
70
- } catch (error) {
71
- console.log('Error in querySinglePathPrices', error);
72
- expectedPrices.push(0n);
73
- }
74
- }
75
- return expectedPrices;
76
- }
77
-
78
- async function queryMultiPathPrices(
79
- network: number,
80
- side: SwapSide,
81
- balancerV3: BalancerV3,
82
- blockNumber: number,
83
- price: PoolPrices<BalancerV3Data>,
84
- amounts: bigint[],
85
- ) {
86
- const balancerBatchRouter = new Interface(balancerBatchRouterAbi);
87
- const readerCallData = getQuerySwapMultiTokenCalldata(
88
- BalancerV3Config.BalancerV3[network].balancerBatchRouterAddress,
89
- balancerBatchRouter,
90
- amounts,
91
- price.data.steps,
92
- side,
93
- );
94
-
95
- const expectedPrices = [0n];
96
- for (const call of readerCallData) {
97
- try {
98
- const result = await balancerV3.dexHelper.provider.call(
99
- {
100
- to: call.target,
101
- data: call.callData,
102
- },
103
- blockNumber,
104
- );
105
- const parsed = balancerBatchRouter.decodeFunctionResult(
106
- side === SwapSide.SELL ? `querySwapExactIn` : `querySwapExactOut`,
107
- result,
108
- );
109
- expectedPrices.push(BigInt(parsed[2][0]._hex));
110
- } catch (error) {
111
- console.log('Error in queryMultiPathPrices', error);
112
- expectedPrices.push(0n);
113
- }
114
- }
115
- return expectedPrices;
116
- }
117
-
118
- function getQuerySwapSingleTokenCalldata(
119
- routerAddress: Address,
120
- routerInterface: Interface,
121
- amounts: bigint[],
122
- step: Step,
123
- side: SwapSide,
124
- ) {
125
- return amounts
126
- .filter(amount => amount !== 0n)
127
- .map(amount => {
128
- return {
129
- target: routerAddress,
130
- callData: routerInterface.encodeFunctionData(
131
- side === SwapSide.SELL
132
- ? `querySwapSingleTokenExactIn`
133
- : `querySwapSingleTokenExactOut`,
134
- [
135
- step.pool,
136
- step.swapInput.tokenIn,
137
- step.swapInput.tokenOut,
138
- amount,
139
- NULL_ADDRESS,
140
- '0x',
141
- ],
142
- ),
143
- };
144
- });
145
- }
146
- /* eslint-disable no-console */
147
- import { Interface } from '@ethersproject/abi';
148
- import { NULL_ADDRESS, SwapSide } from '../../constants';
149
- import { BalancerV3 } from './balancer-v3';
150
- import { BalancerV3Config } from './config';
151
- import { BalancerV3Data, Step } from './types';
152
- import { Address, ExchangePrices, PoolPrices } from '../../types';
153
- import balancerBatchRouterAbi from '../../abi/balancer-v3/batch-router.json';
154
- import balancerRouterAbi from '../../abi/balancer-v3/router.json';
155
-
156
- function getQuerySwapMultiTokenCalldata(
157
- routerAddress: Address,
158
- routerInterface: Interface,
159
- amounts: bigint[],
160
- steps: Step[],
161
- side: SwapSide,
162
- ) {
163
- const tokenIn = steps[0].swapInput.tokenIn;
164
- const stepsNew = steps.map(s => ({
165
- pool: s.pool,
166
- tokenOut: s.swapInput.tokenOut,
167
- isBuffer: s.isBuffer,
168
- }));
169
- return amounts
170
- .filter(amount => amount !== 0n)
171
- .map(amount => {
172
- let args: any[] = [];
173
- if (side === SwapSide.SELL)
174
- args = [
175
- {
176
- tokenIn,
177
- steps: stepsNew,
178
- exactAmountIn: amount,
179
- minAmountOut: 0n,
180
- },
181
- ];
182
- else
183
- args = [
184
- {
185
- tokenIn,
186
- steps: stepsNew,
187
- exactAmountOut: amount,
188
- maxAmountIn: 0n,
189
- },
190
- ];
191
- return {
192
- target: routerAddress,
193
- callData: routerInterface.encodeFunctionData(
194
- side === SwapSide.SELL ? `querySwapExactIn` : `querySwapExactOut`,
195
- [args, NULL_ADDRESS, '0x'],
196
- ),
197
- };
198
- });
199
- }
@@ -1,226 +0,0 @@
1
- import {
2
- EventFragment,
3
- Fragment,
4
- FunctionFragment,
5
- Interface,
6
- } from '@ethersproject/abi';
7
- import _ from 'lodash';
8
- import { DeepReadonly } from 'ts-essentials';
9
- import { Log, Logger } from '../../../types';
10
- import { catchParseLogError } from '../../../utils';
11
- import { StatefulEventSubscriber } from '../../../stateful-event-subscriber';
12
- import { IDexHelper } from '../../../dex-helper/idex-helper';
13
- import { loadHooksConfig } from './loadHooksConfig';
14
- import {
15
- DirectionalFee,
16
- DirectionalFeeConfig,
17
- DirectionalFeeHookState,
18
- getDirectionalFeeHookState,
19
- } from './directionalFeeHook';
20
- import exitFeeHookAbi from '../../../abi/balancer-v3/directionalFeeHook.json';
21
- import {
22
- getStableSurgeHookState,
23
- maxSurgeFeePercentageChangedEvent,
24
- StableSurge,
25
- StableSurgeConfig,
26
- StableSurgeHookState,
27
- thresholdSurgePercentageChangedEvent,
28
- } from './stableSurgeHook';
29
- import stableSurgeHookAbi from '../../../abi/balancer-v3/stableSurgeHook.json';
30
-
31
- // Add each supported hook state here
32
- export type HookState = DirectionalFeeHookState | StableSurgeHookState;
33
-
34
- export type HookStateMap = {
35
- [address: string]: HookState;
36
- };
37
-
38
- export type HookConfig = DirectionalFeeConfig | StableSurgeConfig;
39
-
40
- export type HooksConfigMap = {
41
- [hookAddress: string]: HookConfig;
42
- };
43
-
44
- /**
45
- * This will handle events/state for each supported hook contract. State is used during swap calculations.
46
- * Each hook should have its own implementation file for state typing, fetching state and handling events.
47
- */
48
- export class BalancerEventHook extends StatefulEventSubscriber<HookStateMap> {
49
- handlers: {
50
- [event: string]: (
51
- event: any,
52
- state: DeepReadonly<HookStateMap>,
53
- log: Readonly<Log>,
54
- ) => DeepReadonly<HookStateMap> | null;
55
- } = {};
56
-
57
- interfaces: Interface[];
58
- logDecoder: (log: Log) => any;
59
-
60
- addressesSubscribed: string[];
61
-
62
- hooksConfigMap: HooksConfigMap;
63
-
64
- constructor(
65
- readonly parentName: string,
66
- protected network: number,
67
- protected dexHelper: IDexHelper,
68
- logger: Logger,
69
- ) {
70
- super(parentName, 'Balancer_Hooks', dexHelper, logger);
71
-
72
- // Load supported hooks from config file
73
- this.hooksConfigMap = loadHooksConfig(network);
74
-
75
- // Add each hook ABI here
76
- this.interfaces = [
77
- new Interface(exitFeeHookAbi),
78
- new Interface(stableSurgeHookAbi),
79
- ];
80
- this.logDecoder = (log: Log) =>
81
- this.combineInterfaces(this.interfaces).parseLog(log);
82
-
83
- // Subscribe to all hooks
84
- this.addressesSubscribed = Object.keys(this.hooksConfigMap);
85
-
86
- // StableSurgeHook events
87
- this.handlers['ThresholdSurgePercentageChanged'] =
88
- thresholdSurgePercentageChangedEvent.bind(this);
89
- this.handlers['MaxSurgeFeePercentageChanged'] =
90
- maxSurgeFeePercentageChangedEvent.bind(this);
91
- }
92
-
93
- /**
94
- * The function is called every time any of the subscribed
95
- * addresses release log. The function accepts the current
96
- * state, updates the state according to the log, and returns
97
- * the updated state.
98
- * @param state - Current state of event subscriber
99
- * @param log - Log released by one of the subscribed addresses
100
- * @returns Updates state of the event subscriber after the log
101
- */
102
- protected processLog(
103
- state: DeepReadonly<HookStateMap>,
104
- log: Readonly<Log>,
105
- ): DeepReadonly<HookStateMap> | null {
106
- try {
107
- const event = this.logDecoder(log);
108
- if (event.name in this.handlers) {
109
- return this.handlers[event.name](event, state, log);
110
- }
111
- } catch (e) {
112
- catchParseLogError(e, this.logger);
113
- }
114
-
115
- return null;
116
- }
117
-
118
- /**
119
- * The function generates state using on-chain calls. This
120
- * function is called to regenerate state if the event based
121
- * system fails to fetch events and the local state is no
122
- * more correct.
123
- * @param blockNumber - Blocknumber for which the state should
124
- * should be generated
125
- * @returns state of the event subscriber at blocknumber
126
- */
127
- async generateState(
128
- blockNumber: number,
129
- ): Promise<DeepReadonly<HookStateMap>> {
130
- // Only hooks that are supported will be called
131
- const hookState: HookStateMap = {};
132
-
133
- await Promise.all(
134
- Object.keys(this.hooksConfigMap).map(async hookAddress => {
135
- const hookConfig = this.hooksConfigMap[hookAddress];
136
- if (hookConfig.type === DirectionalFee.type) {
137
- hookState[hookAddress] = await getDirectionalFeeHookState();
138
- } else if (hookConfig.type === StableSurge.type) {
139
- hookState[hookAddress] = await getStableSurgeHookState(
140
- this.interfaces[1],
141
- hookAddress,
142
- hookConfig.factory,
143
- this.dexHelper,
144
- blockNumber,
145
- );
146
- }
147
- }),
148
- );
149
-
150
- // for (const hookAddress in this.hooksConfigMap) {
151
- // const hookConfig = this.hooksConfigMap[hookAddress];
152
- // if (hookConfig.type === DirectionalFee.type) {
153
- // hookState[hookAddress] = await getDirectionalFeeHookState();
154
- // } else if (hookConfig.type === StableSurge.type) {
155
- // hookState[hookAddress] = await getStableSurgeHookState(
156
- // this.interfaces[1],
157
- // hookAddress,
158
- // hookConfig.factory,
159
- // this.dexHelper,
160
- // blockNumber,
161
- // );
162
- // }
163
- // }
164
-
165
- return hookState;
166
- }
167
-
168
- async updateHookState() {
169
- // Not all hooks need updated, only ones with settings/state that can't be handled by events
170
- const blockNumber = await this.dexHelper.provider.getBlockNumber();
171
- const currentState =
172
- (_.cloneDeep(this.getStaleState()) as HookStateMap) || {};
173
-
174
- await Promise.all(
175
- Object.keys(this.hooksConfigMap).map(async hookAddress => {
176
- const hookConfig = this.hooksConfigMap[hookAddress];
177
- // StableSurge can have new registered pools with associated hook state
178
- if (hookConfig.type === StableSurge.type) {
179
- currentState[hookAddress] = await getStableSurgeHookState(
180
- this.interfaces[1],
181
- hookAddress,
182
- hookConfig.factory,
183
- this.dexHelper,
184
- blockNumber,
185
- );
186
- }
187
- }),
188
- );
189
-
190
- this.setState(currentState, blockNumber);
191
- }
192
-
193
- combineInterfaces = (interfaces: Interface[]): Interface => {
194
- // Use a Map to store unique fragments, keyed by their string representation
195
- const uniqueFragments = new Map<string, Fragment>();
196
-
197
- interfaces.forEach((interfaceInstance: Interface) => {
198
- interfaceInstance.fragments.forEach((fragment: Fragment) => {
199
- let key: string;
200
-
201
- if (fragment instanceof FunctionFragment) {
202
- // For functions, use the signature as the key
203
- // This includes name and parameter types
204
- key = fragment.format();
205
- } else if (fragment instanceof EventFragment) {
206
- // For events, use the signature as the key
207
- key = fragment.format();
208
- } else {
209
- // For other fragment types (like errors), use their string representation
210
- key = fragment.toString();
211
- }
212
-
213
- // Only add if we haven't seen this signature before
214
- if (!uniqueFragments.has(key)) {
215
- uniqueFragments.set(key, fragment);
216
- }
217
- });
218
- });
219
-
220
- // Convert the Map values back to an array
221
- const dedupedFragments = Array.from(uniqueFragments.values());
222
-
223
- // Create a new interface with the deduped fragments
224
- return new Interface(dedupedFragments);
225
- };
226
- }
@@ -1,51 +0,0 @@
1
- /**
2
- * Each supported hook should implement its own version of this file making it easy to retrieve required onchain state.
3
- */
4
- import _ from 'lodash';
5
- import { Log } from '../../../types';
6
- import { DeepReadonly } from 'ts-essentials';
7
- import { HookStateMap } from './balancer-hook-event-subscriber';
8
-
9
- export const DirectionalFee = {
10
- type: 'DirectionalFee' as const,
11
- };
12
-
13
- export type DirectionalFeeConfig = {
14
- type: typeof DirectionalFee.type;
15
- address: string;
16
- };
17
-
18
- export type DirectionalFeeHookState = {
19
- test: string; // Note - this is just a dummy example as this specific test hook doesn't have any required state but is used to prove concept
20
- };
21
-
22
- /**
23
- * Retrieve any initial hook state required.
24
- * @returns
25
- */
26
- export async function getDirectionalFeeHookState(): Promise<DirectionalFeeHookState> {
27
- // Note - for other hooks this function would retrieve any initial state using onchain calls
28
- return { test: 'initial' };
29
- }
30
-
31
- /**
32
- * Handles the event emitted when a new hook is registered.
33
- * @param event
34
- * @param state
35
- * @param log
36
- * @returns
37
- */
38
- export function exitFeeHookExampleRegisteredEvent(
39
- event: any,
40
- state: DeepReadonly<HookStateMap>,
41
- log: Readonly<Log>,
42
- ): DeepReadonly<HookStateMap> | null {
43
- // Note - This is a non-important event but demos the use case. Other hooks would implement this for any state changes required for swap maths.
44
- const hookAddress = event.args.hooksContract.toLowerCase();
45
- if (!state[hookAddress]) {
46
- return null;
47
- }
48
- const newState = _.cloneDeep(state) as HookStateMap;
49
- newState[hookAddress] = { test: event.args.pool };
50
- return newState;
51
- }
@@ -1,12 +0,0 @@
1
- import { BalancerV3Config } from './../config';
2
- import { HooksConfigMap } from './balancer-hook-event-subscriber';
3
-
4
- export function loadHooksConfig(network: number): HooksConfigMap {
5
- const hooks = BalancerV3Config.BalancerV3[network].hooks;
6
-
7
- if (!hooks) return {};
8
-
9
- return Object.fromEntries(
10
- hooks.map(hook => [hook.address.toLowerCase(), hook]),
11
- );
12
- }