@paraswap/dex-lib 3.11.1 → 3.11.2

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 (280) hide show
  1. package/build/abi/Aave_GSM.json +751 -0
  2. package/build/abi/Balancer.json +257 -0
  3. package/build/abi/BalancerV2.json +1179 -0
  4. package/build/abi/RamsesV2Pool.abi.json +1554 -0
  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/{wombat/pool.json → angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json} +594 -637
  9. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +509 -0
  10. package/build/abi/cables/CablesMainnetRFQ.json +1083 -0
  11. package/build/abi/curve-v1/CurveBUSDv2.abi.json +1356 -0
  12. package/build/abi/curve-v1/CurveTokenV1.json +305 -0
  13. package/build/abi/curve-v1/CurveTokenV2.json +318 -0
  14. package/build/abi/curve-v1/CurveV1StableNg.json +1452 -0
  15. package/build/abi/curve-v1/CurveV2Swap.json +700 -0
  16. package/build/abi/curve-v1/FactoryCryptoRegistry.json +316 -0
  17. package/build/abi/curve-v1/FactoryRegistry.json +508 -0
  18. package/build/abi/curve-v1/StableSwapAave.json +1152 -0
  19. package/build/abi/curve-v1/StableSwapBUSD.json +814 -0
  20. package/build/abi/curve-v1/StableSwapCompound.json +814 -0
  21. package/build/abi/curve-v1/StableSwapIDLE.json +1253 -0
  22. package/build/abi/curve-v1/StableSwapPax.json +865 -0
  23. package/build/abi/curve-v1/StableSwapSnow.json +900 -0
  24. package/build/abi/curve-v1/StableSwapUSDN.json +1004 -0
  25. package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
  26. package/build/abi/curve-v1/StableSwapY.json +814 -0
  27. package/build/abi/inception/inception-ineth.json +609 -0
  28. package/build/abi/kyberdmm/kyber-storage.abi.json +824 -0
  29. package/build/abi/kyberdmm.abi.json +1148 -0
  30. package/build/abi/maverick-v2/MaverickV2Quoter.json +278 -0
  31. package/build/abi/nerve/nerve-metapool.json +790 -0
  32. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
  33. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
  34. package/build/config.js +1 -0
  35. package/build/config.js.map +1 -1
  36. package/build/dex/aave-v1/aave-v1.js +0 -1
  37. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  38. package/build/dex/balancer-v1/balancer-pools.json +33333 -0
  39. package/build/dex/bebop/bebop.js +1 -1
  40. package/build/dex/bebop/bebop.js.map +1 -1
  41. package/build/dex/bebop/config.js +5 -0
  42. package/build/dex/bebop/config.js.map +1 -1
  43. package/build/dex/bebop/rate-fetcher.d.ts +3 -1
  44. package/build/dex/bebop/rate-fetcher.js +42 -2
  45. package/build/dex/bebop/rate-fetcher.js.map +1 -1
  46. package/build/dex/bebop/validators.d.ts +2 -0
  47. package/build/dex/bebop/validators.js +9 -1
  48. package/build/dex/bebop/validators.js.map +1 -1
  49. package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
  50. package/build/dex/bebop/websocket-fetcher.js +87 -0
  51. package/build/dex/bebop/websocket-fetcher.js.map +1 -0
  52. package/build/dex/cables/cables.d.ts +57 -0
  53. package/build/dex/cables/cables.js +471 -0
  54. package/build/dex/cables/cables.js.map +1 -0
  55. package/build/dex/cables/config.d.ts +4 -0
  56. package/build/dex/cables/config.js +15 -0
  57. package/build/dex/cables/config.js.map +1 -0
  58. package/build/dex/cables/constants.d.ts +19 -0
  59. package/build/dex/cables/constants.js +26 -0
  60. package/build/dex/cables/constants.js.map +1 -0
  61. package/build/dex/cables/rate-fetcher.d.ts +34 -0
  62. package/build/dex/cables/rate-fetcher.js +106 -0
  63. package/build/dex/cables/rate-fetcher.js.map +1 -0
  64. package/build/dex/cables/types.d.ts +106 -0
  65. package/build/dex/cables/types.js +12 -0
  66. package/build/dex/cables/types.js.map +1 -0
  67. package/build/dex/cables/validators.d.ts +5 -0
  68. package/build/dex/cables/validators.js +49 -0
  69. package/build/dex/cables/validators.js.map +1 -0
  70. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  71. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  72. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  73. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  74. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  75. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  76. package/build/dex/idle-dao/scripts.d.ts +9 -0
  77. package/build/dex/idle-dao/scripts.js +552 -0
  78. package/build/dex/idle-dao/scripts.js.map +1 -0
  79. package/build/dex/inception/inception-event-pool.d.ts +4 -4
  80. package/build/dex/inception/inception-event-pool.js +9 -7
  81. package/build/dex/inception/inception-event-pool.js.map +1 -1
  82. package/build/dex/inception/inception-native.d.ts +43 -0
  83. package/build/dex/inception/inception-native.js +131 -0
  84. package/build/dex/inception/inception-native.js.map +1 -0
  85. package/build/dex/inception/inception-pool.d.ts +18 -0
  86. package/build/dex/inception/inception-pool.js +32 -0
  87. package/build/dex/inception/inception-pool.js.map +1 -0
  88. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  89. package/build/dex/inception/inception-price-feed.js +51 -0
  90. package/build/dex/inception/inception-price-feed.js.map +1 -0
  91. package/build/dex/inception/inception.d.ts +6 -6
  92. package/build/dex/inception/inception.js +40 -16
  93. package/build/dex/inception/inception.js.map +1 -1
  94. package/build/dex/inception/utils.d.ts +0 -1
  95. package/build/dex/inception/utils.js +1 -22
  96. package/build/dex/inception/utils.js.map +1 -1
  97. package/build/dex/platypus/platypus.js +3 -17
  98. package/build/dex/platypus/platypus.js.map +1 -1
  99. package/build/dex/swaap-v1/swaap-v1.js +0 -4
  100. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  101. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
  102. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
  103. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
  104. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
  105. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
  106. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
  107. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
  108. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
  109. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
  110. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
  111. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
  112. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
  113. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
  114. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
  115. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
  116. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
  117. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
  118. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
  119. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
  120. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
  121. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
  122. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
  123. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
  124. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
  125. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
  126. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
  127. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
  128. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
  129. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
  130. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
  131. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
  132. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
  133. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
  134. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
  135. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
  136. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
  137. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
  138. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
  139. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
  140. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
  141. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
  142. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
  143. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
  144. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
  145. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
  146. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
  147. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
  148. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
  149. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
  150. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
  151. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
  152. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
  153. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
  154. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
  155. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
  156. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
  157. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
  158. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
  159. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
  160. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
  161. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
  162. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
  163. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
  164. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
  165. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
  166. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
  167. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
  168. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
  169. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
  170. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
  171. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
  172. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
  173. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
  174. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
  175. package/build/lib/fetcher/wsFetcher.d.ts +7 -3
  176. package/build/lib/fetcher/wsFetcher.js +64 -51
  177. package/build/lib/fetcher/wsFetcher.js.map +1 -1
  178. package/package.json +4 -2
  179. package/src/config.ts +1 -0
  180. package/src/dex/bebop/bebop-e2e.test.ts +21 -0
  181. package/src/dex/bebop/bebop.json +72 -0
  182. package/src/dex/bebop/bebop.proto +15 -0
  183. package/src/dex/bebop/bebop.ts +1 -1
  184. package/src/dex/bebop/config.ts +5 -0
  185. package/src/dex/bebop/rate-fetcher.ts +51 -6
  186. package/src/dex/bebop/validators.ts +10 -0
  187. package/src/lib/fetcher/wsFetcher.ts +79 -66
  188. package/.vscode/launch.json +0 -53
  189. package/.vscode/settings.json +0 -2
  190. package/.vscode/tasks.json +0 -15
  191. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
  192. package/build/dex/aave-v2/tokens-avalanche.json +0 -44
  193. package/build/dex/aave-v2/tokens-mainnet.json +0 -188
  194. package/build/dex/aave-v2/tokens-polygon.json +0 -44
  195. package/build/dex/bProtocol.d.ts +0 -18
  196. package/build/dex/bProtocol.js +0 -39
  197. package/build/dex/bProtocol.js.map +0 -1
  198. package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +0 -729
  199. package/build/dex/balancer-v3/abi/balancerBatchRouter.js +0 -732
  200. package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +0 -1
  201. package/build/dex/balancer-v3/abi/balancerRouter.d.ts +0 -1406
  202. package/build/dex/balancer-v3/abi/balancerRouter.js +0 -1175
  203. package/build/dex/balancer-v3/abi/balancerRouter.js.map +0 -1
  204. package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +0 -2081
  205. package/build/dex/balancer-v3/abi/vaultExtension.V3.js +0 -1851
  206. package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +0 -1
  207. package/build/dex/balancer-v3/balancer-v3-pool.d.ts +0 -76
  208. package/build/dex/balancer-v3/balancer-v3-pool.js +0 -383
  209. package/build/dex/balancer-v3/balancer-v3-pool.js.map +0 -1
  210. package/build/dex/balancer-v3/balancer-v3.d.ts +0 -57
  211. package/build/dex/balancer-v3/balancer-v3.js +0 -373
  212. package/build/dex/balancer-v3/balancer-v3.js.map +0 -1
  213. package/build/dex/balancer-v3/config.d.ts +0 -8
  214. package/build/dex/balancer-v3/config.js +0 -24
  215. package/build/dex/balancer-v3/config.js.map +0 -1
  216. package/build/dex/balancer-v3/getOnChainState.d.ts +0 -10
  217. package/build/dex/balancer-v3/getOnChainState.js +0 -158
  218. package/build/dex/balancer-v3/getOnChainState.js.map +0 -1
  219. package/build/dex/balancer-v3/getPoolsApi.d.ts +0 -2
  220. package/build/dex/balancer-v3/getPoolsApi.js +0 -81
  221. package/build/dex/balancer-v3/getPoolsApi.js.map +0 -1
  222. package/build/dex/balancer-v3/getTopPoolsApi.d.ts +0 -13
  223. package/build/dex/balancer-v3/getTopPoolsApi.js +0 -62
  224. package/build/dex/balancer-v3/getTopPoolsApi.js.map +0 -1
  225. package/build/dex/balancer-v3/types.d.ts +0 -63
  226. package/build/dex/balancer-v3/types.js +0 -3
  227. package/build/dex/balancer-v3/types.js.map +0 -1
  228. package/build/dex/bancor.d.ts +0 -26
  229. package/build/dex/bancor.js +0 -58
  230. package/build/dex/bancor.js.map +0 -1
  231. package/build/dex/compound.d.ts +0 -18
  232. package/build/dex/compound.js +0 -46
  233. package/build/dex/compound.js.map +0 -1
  234. package/build/dex/curve-v2.d.ts +0 -58
  235. package/build/dex/curve-v2.js +0 -180
  236. package/build/dex/curve-v2.js.map +0 -1
  237. package/build/dex/dodo-v1.d.ts +0 -33
  238. package/build/dex/dodo-v1.js +0 -63
  239. package/build/dex/dodo-v1.js.map +0 -1
  240. package/build/dex/fluid-dex/fluid-dex-pool.d.ts +0 -47
  241. package/build/dex/fluid-dex/fluid-dex-pool.js +0 -119
  242. package/build/dex/fluid-dex/fluid-dex-pool.js.map +0 -1
  243. package/build/dex/lido.d.ts +0 -19
  244. package/build/dex/lido.js +0 -42
  245. package/build/dex/lido.js.map +0 -1
  246. package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
  247. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  248. package/build/dex/maker-psm/scripts/validate-state.js +0 -185
  249. package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
  250. package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
  251. package/build/dex/onebit.d.ts +0 -25
  252. package/build/dex/onebit.js +0 -42
  253. package/build/dex/onebit.js.map +0 -1
  254. package/build/dex/smoothy.d.ts +0 -26
  255. package/build/dex/smoothy.js +0 -48
  256. package/build/dex/smoothy.js.map +0 -1
  257. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
  258. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
  259. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
  260. package/build/dex/stable-pool.d.ts +0 -28
  261. package/build/dex/stable-pool.js +0 -55
  262. package/build/dex/stable-pool.js.map +0 -1
  263. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
  264. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
  265. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
  266. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  267. package/build/dex/trader-joe-v2.1.js +0 -79
  268. package/build/dex/trader-joe-v2.1.js.map +0 -1
  269. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
  270. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
  271. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
  272. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
  273. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
  274. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
  275. package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +0 -4
  276. package/build/dex/uniswap-v3/uniswap-v3-pricing.js +0 -43
  277. package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +0 -1
  278. package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +0 -1
  279. package/build/dex/uniswap-v3/uniswap-v3-worker.js +0 -10
  280. package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +0 -1
@@ -1,373 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.BalancerV3 = void 0;
27
- const constants_1 = require("../../constants");
28
- const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
29
- const utils_1 = require("../../utils");
30
- const simple_exchange_1 = require("../simple-exchange");
31
- const config_1 = require("./config");
32
- const balancer_v3_pool_1 = require("./balancer-v3-pool");
33
- const balancer_maths_1 = require("@balancer-labs/balancer-maths");
34
- const abi_1 = require("@ethersproject/abi");
35
- const balancerRouter_1 = require("./abi/balancerRouter");
36
- const utils_2 = require("../../executor/utils");
37
- const getTopPoolsApi_1 = require("./getTopPoolsApi");
38
- const balancerBatchRouter_1 = require("./abi/balancerBatchRouter");
39
- const MAX_UINT256 = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
40
- const POOL_UPDATE_TTL = 5 * 60; // 5mins
41
- const RATE_UPDATE_TTL = 30 * 60; // 30mins
42
- class BalancerV3 extends simple_exchange_1.SimpleExchange {
43
- constructor(network, dexKey, dexHelper) {
44
- super(dexHelper, dexKey);
45
- this.network = network;
46
- this.dexKey = dexKey;
47
- this.dexHelper = dexHelper;
48
- this.hasConstantPriceLargeAmounts = false;
49
- // TODO: vault can handle native
50
- this.needWrapNative = true;
51
- this.isFeeOnTransferSupported = false;
52
- this.logger = dexHelper.getLogger(dexKey);
53
- this.eventPools = new balancer_v3_pool_1.BalancerV3EventPool(dexKey, network, dexHelper, this.logger);
54
- this.balancerRouter = new abi_1.Interface(balancerRouter_1.balancerRouterAbi);
55
- this.balancerBatchRouter = new abi_1.Interface(balancerBatchRouter_1.balancerBatchRouterAbi);
56
- }
57
- // Initialize pricing is called once in the start of
58
- // pricing service. It is intended to setup the integration
59
- // for pricing requests. It is optional for a DEX to
60
- // implement this function
61
- async initializePricing(blockNumber) {
62
- await this.eventPools.initialize(blockNumber);
63
- // This will periodically query API and add any new pools to pool state
64
- if (!this.updateNewPoolsTimer) {
65
- this.updateNewPoolsTimer = setInterval(async () => {
66
- try {
67
- await this.updatePoolState();
68
- }
69
- catch (e) {
70
- this.logger.error(`${this.dexKey}: Failed to update pool state:`, e);
71
- }
72
- }, POOL_UPDATE_TTL * 1000);
73
- }
74
- // This will periodically refresh tokenRates with onchain state
75
- if (!this.updateRatesTimer) {
76
- this.updateRatesTimer = setInterval(async () => {
77
- try {
78
- await this.updateStatePoolRates();
79
- }
80
- catch (e) {
81
- this.logger.error(`${this.dexKey}: Failed to update pool rates:`, e);
82
- }
83
- }, RATE_UPDATE_TTL * 1000);
84
- }
85
- }
86
- getAdapters(side) {
87
- return null;
88
- }
89
- // Returns list of pool identifiers that can be used
90
- // for a given swap. poolIdentifiers must be unique
91
- // across DEXes. It is recommended to use
92
- // ${dexKey}_${poolAddress} as a poolIdentifier
93
- async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
94
- const _from = this.dexHelper.config.wrapETH(srcToken);
95
- const _to = this.dexHelper.config.wrapETH(destToken);
96
- const poolState = this.eventPools.getState(blockNumber);
97
- if (poolState === null)
98
- return [];
99
- return this.findPoolAddressesWithTokens(poolState, _from.address, _to.address);
100
- }
101
- findPoolAddressesWithTokens(pools, tokenA, tokenB) {
102
- return Object.entries(pools)
103
- .filter(([, poolState]) => {
104
- return this.hasTokens(poolState, [tokenA, tokenB]);
105
- })
106
- .map(([address]) => address);
107
- }
108
- /**
109
- * Filter pools that have tokens from/to and are in limitPool list
110
- * @param pools
111
- * @param from
112
- * @param to
113
- * @param limitPools
114
- * @returns Array of PoolState
115
- */
116
- filterPools(pools, from, to, limitPools) {
117
- return Object.entries(pools)
118
- .filter(([address, poolState]) => {
119
- const hasRequiredTokens = this.hasTokens(poolState, [from, to]);
120
- const isAllowedPool = !limitPools || limitPools.includes(address);
121
- return hasRequiredTokens && isAllowedPool;
122
- })
123
- .map(([_, poolState]) => poolState);
124
- }
125
- hasTokens(pool, tokens) {
126
- return tokens.every(token => pool.tokens.includes(token) || pool.tokensUnderlying.includes(token));
127
- }
128
- // Returns pool prices for amounts.
129
- // If limitPools is defined only pools in limitPools
130
- // should be used. If limitPools is undefined then
131
- // any pools can be used.
132
- async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
133
- try {
134
- const _from = this.dexHelper.config.wrapETH(srcToken);
135
- const _to = this.dexHelper.config.wrapETH(destToken);
136
- if (_from.address === _to.address) {
137
- return null;
138
- }
139
- // get up to date pools and state
140
- const allPoolState = this.eventPools.getState(blockNumber);
141
- if (allPoolState === null) {
142
- this.logger.error(`getState returned null`);
143
- return null;
144
- }
145
- // filter for pools with tokens and to only use limit pools
146
- const allowedPools = this.filterPools(allPoolState, _from.address, _to.address, limitPools);
147
- if (!allowedPools.length)
148
- return null;
149
- const swapKind = side === constants_1.SwapSide.SELL ? balancer_maths_1.SwapKind.GivenIn : balancer_maths_1.SwapKind.GivenOut;
150
- const tokenIn = _from.address;
151
- const tokenOut = _to.address;
152
- // Gets the single unit amount based off token decimals, e.g. for USDC its 1e6
153
- const unitAmount = (0, utils_1.getBigIntPow)((side === constants_1.SwapSide.SELL ? _from : _to).decimals);
154
- const poolPrices = [];
155
- // For each pool we calculate swap result using balancer maths
156
- for (let i = 0; i < allowedPools.length; i++) {
157
- const pool = {
158
- ...allowedPools[i],
159
- };
160
- const tokenInInfo = this.eventPools.getTokenInfo(pool, tokenIn);
161
- const tokenOutInfo = this.eventPools.getTokenInfo(pool, tokenOut);
162
- if (!tokenInInfo || !tokenOutInfo) {
163
- continue;
164
- }
165
- const steps = this.eventPools.getSteps(pool, tokenInInfo, tokenOutInfo);
166
- try {
167
- // This is the max amount the pool can swap
168
- const maxSwapAmount = this.eventPools.getMaxSwapAmount(pool, tokenInInfo, tokenOutInfo, swapKind);
169
- let unit = 0n;
170
- if (unitAmount < maxSwapAmount)
171
- unit = this.eventPools.getSwapResult(steps, unitAmount, swapKind);
172
- const poolExchangePrice = {
173
- prices: new Array(amounts.length).fill(0n),
174
- unit,
175
- data: {
176
- steps: steps,
177
- },
178
- exchange: this.dexKey,
179
- gasCost: 1,
180
- poolAddresses: [pool.address],
181
- poolIdentifier: `${this.dexKey}_${pool.address}`,
182
- };
183
- for (let j = 0; j < amounts.length; j++) {
184
- if (amounts[j] < maxSwapAmount) {
185
- // Uses balancer maths to calculate swap
186
- poolExchangePrice.prices[j] = this.eventPools.getSwapResult(steps, amounts[j], swapKind);
187
- }
188
- }
189
- poolPrices.push(poolExchangePrice);
190
- }
191
- catch (err) {
192
- this.logger.error(`error fetching prices for pool`);
193
- this.logger.error(err);
194
- }
195
- }
196
- return poolPrices;
197
- }
198
- catch (err) { }
199
- return null;
200
- }
201
- // Returns estimated gas cost of calldata for this DEX in multiSwap
202
- getCalldataGasCost(poolPrices) {
203
- // TODO: update if there is any payload in getAdapterParam
204
- return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
205
- }
206
- // Not used for V6
207
- getAdapterParam() {
208
- return {
209
- targetExchange: '0x',
210
- payload: '0x',
211
- networkFee: '0',
212
- };
213
- }
214
- getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
215
- if (side === constants_1.SwapSide.SELL) {
216
- return this.getExactInParam(srcToken, destToken, srcAmount, data);
217
- }
218
- else {
219
- return this.getExactOutParam(srcToken, destToken, destAmount, data);
220
- }
221
- }
222
- getExactInParam(srcToken, destToken, srcAmount, data) {
223
- if (data.steps.length === 1) {
224
- const exchangeData = this.balancerRouter.encodeFunctionData('swapSingleTokenExactIn', [
225
- data.steps[0].pool,
226
- srcToken,
227
- destToken,
228
- srcAmount,
229
- '0',
230
- MAX_UINT256,
231
- this.needWrapNative,
232
- '0x',
233
- ]);
234
- return {
235
- needWrapNative: this.needWrapNative,
236
- dexFuncHasRecipient: false,
237
- exchangeData,
238
- // This router handles single swaps
239
- targetExchange: config_1.BalancerV3Config.BalancerV3[this.network].balancerRouterAddress,
240
- returnAmountPos: (0, utils_2.extractReturnAmountPosition)(this.balancerRouter, 'swapSingleTokenExactIn'),
241
- };
242
- }
243
- else {
244
- // for each step:
245
- // if tokenIn == pool router uses removeLiquidity SINGLE_TOKEN_EXACT_IN
246
- // if tokenOut == pool router uses addLiquidity UNBALANCED
247
- const exchangeData = this.balancerBatchRouter.encodeFunctionResult('swapExactIn', [
248
- [
249
- {
250
- tokenIn: srcToken,
251
- steps: data.steps.map(step => ({
252
- pool: step.pool,
253
- tokenOut: step.tokenOut,
254
- isBuffer: step.isBuffer,
255
- })),
256
- exactAmountIn: srcAmount,
257
- minAmountOut: '0', // This should be limit for min amount out. Assume this is set elsewhere via Paraswap contract.
258
- },
259
- ],
260
- MAX_UINT256,
261
- this.needWrapNative,
262
- '0x',
263
- ]);
264
- return {
265
- needWrapNative: this.needWrapNative,
266
- dexFuncHasRecipient: false,
267
- exchangeData,
268
- // This router handles single swaps
269
- targetExchange: config_1.BalancerV3Config.BalancerV3[this.network].balancerBatchRouterAddress,
270
- returnAmountPos: (0, utils_2.extractReturnAmountPosition)(this.balancerBatchRouter, 'swapExactIn'),
271
- };
272
- }
273
- }
274
- getExactOutParam(srcToken, destToken, destAmount, data) {
275
- if (data.steps.length === 1) {
276
- const exchangeData = this.balancerRouter.encodeFunctionData('swapSingleTokenExactOut', [
277
- data.steps[0].pool,
278
- srcToken,
279
- destToken,
280
- destAmount,
281
- MAX_UINT256,
282
- MAX_UINT256,
283
- this.needWrapNative,
284
- '0x',
285
- ]);
286
- return {
287
- needWrapNative: this.needWrapNative,
288
- dexFuncHasRecipient: false,
289
- exchangeData,
290
- // Single swaps are submitted via Balancer Router
291
- targetExchange: config_1.BalancerV3Config.BalancerV3[this.network].balancerRouterAddress,
292
- returnAmountPos: (0, utils_2.extractReturnAmountPosition)(this.balancerRouter, 'swapSingleTokenExactOut'),
293
- };
294
- }
295
- else {
296
- // for each step:
297
- // if tokenIn == pool use removeLiquidity SINGLE_TOKEN_EXACT_OUT
298
- // if tokenOut == pool use addLiquidity SINGLE_TOKEN_EXACT_OUT
299
- const exchangeData = this.balancerBatchRouter.encodeFunctionResult('swapExactOut', [
300
- [
301
- {
302
- tokenIn: srcToken,
303
- steps: data.steps.map(step => ({
304
- pool: step.pool,
305
- tokenOut: step.tokenOut,
306
- isBuffer: step.isBuffer,
307
- })),
308
- exactAmountOut: destAmount,
309
- maxAmountIn: MAX_UINT256, // This should be limit for min amount out. Assume this is set elsewhere via Paraswap contract.
310
- },
311
- ],
312
- MAX_UINT256,
313
- this.needWrapNative,
314
- '0x',
315
- ]);
316
- return {
317
- needWrapNative: this.needWrapNative,
318
- dexFuncHasRecipient: false,
319
- exchangeData,
320
- // This router handles single swaps
321
- targetExchange: config_1.BalancerV3Config.BalancerV3[this.network].balancerBatchRouterAddress,
322
- returnAmountPos: (0, utils_2.extractReturnAmountPosition)(this.balancerBatchRouter, 'swapExactIn'),
323
- };
324
- }
325
- }
326
- /**
327
- * Uses multicall to get onchain token rate for each pool then updates pool state
328
- */
329
- async updateStatePoolRates() {
330
- await this.eventPools.updateStatePoolRates();
331
- }
332
- // This is called once before getTopPoolsForToken is
333
- // called for multiple tokens. This can be helpful to
334
- // update common state required for calculating
335
- // getTopPoolsForToken. It is optional for a DEX
336
- // to implement this
337
- async updatePoolState() {
338
- await this.eventPools.updateStatePools();
339
- }
340
- // Returns list of top pools based on liquidity. Max
341
- // limit number pools should be returned.
342
- async getTopPoolsForToken(tokenAddress, count) {
343
- const poolsWithToken = Object.entries(this.eventPools.getStaleState() || {})
344
- .filter(([, poolState]) => {
345
- return this.hasTokens(poolState, [tokenAddress]);
346
- })
347
- .map(([address]) => address);
348
- const topPools = await (0, getTopPoolsApi_1.getTopPoolsApi)(this.network, poolsWithToken, count);
349
- return topPools.map(pool => {
350
- return {
351
- exchange: this.dexKey,
352
- address: pool.address,
353
- liquidityUSD: parseFloat(pool.dynamicData.totalLiquidity),
354
- connectorTokens: pool.poolTokens.filter(t => t.address !== tokenAddress),
355
- };
356
- });
357
- }
358
- releaseResources() {
359
- if (this.updateNewPoolsTimer) {
360
- clearInterval(this.updateNewPoolsTimer);
361
- this.updateNewPoolsTimer = undefined;
362
- this.logger.info(`${this.dexKey}: cleared updateNewPoolsTimer before shutting down`);
363
- }
364
- if (this.updateRatesTimer) {
365
- clearInterval(this.updateRatesTimer);
366
- this.updateRatesTimer = undefined;
367
- this.logger.info(`${this.dexKey}: cleared updateRatesTimer before shutting down`);
368
- }
369
- }
370
- }
371
- exports.BalancerV3 = BalancerV3;
372
- BalancerV3.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.BalancerV3Config);
373
- //# sourceMappingURL=balancer-v3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"balancer-v3.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/balancer-v3.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,+CAAoD;AACpD,2EAA6D;AAC7D,uCAAkE;AAIlE,wDAAoD;AACpD,qCAA4C;AAC5C,yDAAyD;AAEzD,kEAAyD;AACzD,4CAA+C;AAC/C,yDAAyD;AACzD,gDAAmE;AACnE,qDAAkD;AAClD,mEAAmE;AAEnE,MAAM,WAAW,GACf,gFAAgF,CAAC;AACnF,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ;AACxC,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS;AAM1C,MAAa,UAAW,SAAQ,gCAAc;IAkB5C,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB;QAE9B,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAJhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QAlBvB,iCAA4B,GAAG,KAAK,CAAC;QAC9C,gCAAgC;QACvB,mBAAc,GAAG,IAAI,CAAC;QAEtB,6BAAwB,GAAG,KAAK,CAAC;QAiBxC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,UAAU,GAAG,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AI,CAAC,gBAAgB,EAAE;YACzB,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACrC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,GAAG,IAAI,CAAC,MAAM,iDAAiD,CAChE,CAAC;SACH;IACH,CAAC;;AA3dH,gCA4dC;AAnde,6BAAkB,GAC9B,IAAA,6BAAqB,EAAC,yBAAgB,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- import { DexParams } from './types';
2
- import { DexConfigMap } from '../../types';
3
- export declare enum SUPPORTED_POOLS {
4
- WEIGHTED = "WEIGHTED",
5
- STABLE = "STABLE"
6
- }
7
- export declare const apiUrl = "https://test-api-v3.balancer.fi/";
8
- export declare const BalancerV3Config: DexConfigMap<DexParams>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BalancerV3Config = exports.apiUrl = exports.SUPPORTED_POOLS = void 0;
4
- const constants_1 = require("../../constants");
5
- // These map to the Balancer API poolType. Only Balancer supported pools will be added
6
- var SUPPORTED_POOLS;
7
- (function (SUPPORTED_POOLS) {
8
- SUPPORTED_POOLS["WEIGHTED"] = "WEIGHTED";
9
- SUPPORTED_POOLS["STABLE"] = "STABLE";
10
- })(SUPPORTED_POOLS = exports.SUPPORTED_POOLS || (exports.SUPPORTED_POOLS = {}));
11
- // Balancer API - aggregatorSpecific query serves all useful static pool data
12
- exports.apiUrl = 'https://test-api-v3.balancer.fi/';
13
- // TODO Full config added after V3 release
14
- exports.BalancerV3Config = {
15
- BalancerV3: {
16
- [constants_1.Network.SEPOLIA]: {
17
- vaultAddress: '0x30AF3689547354f82C70256894B07C9D0f067BB6',
18
- apiNetworkName: 'SEPOLIA',
19
- balancerRouterAddress: '0x77eDc69766409C599F06Ef0B551a0990CBfe13A7',
20
- balancerBatchRouterAddress: '0x16Cf31c5c4f92ad6185D583080C84FEeb6074c78',
21
- },
22
- },
23
- };
24
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEpD,sFAAsF;AACtF,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;AACnB,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B;AAED,6EAA6E;AAChE,QAAA,MAAM,GAAG,kCAAkC,CAAC;AAEzD,0CAA0C;AAC7B,QAAA,gBAAgB,GAA4B;IACvD,UAAU,EAAE;QACV,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,YAAY,EAAE,4CAA4C;YAC1D,cAAc,EAAE,SAAS;YACzB,qBAAqB,EAAE,4CAA4C;YACnE,0BAA0B,EAAE,4CAA4C;SACzE;KACF;CACF,CAAC"}
@@ -1,10 +0,0 @@
1
- import { ImmutablePoolStateMap, PoolStateMap } from './types';
2
- import { Interface, Result } from '@ethersproject/abi';
3
- import { IDexHelper } from '../../dex-helper';
4
- export declare function decodeThrowError(contractInterface: Interface, functionName: string, resultEntry: {
5
- success: boolean;
6
- returnData: any;
7
- }, poolAddress: string): Result;
8
- export declare function getOnChainState(network: number, immutablePoolStateMap: ImmutablePoolStateMap, dexHelper: IDexHelper, interfaces: {
9
- [name: string]: Interface;
10
- }, blockNumber?: number): Promise<PoolStateMap>;
@@ -1,158 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getOnChainState = exports.decodeThrowError = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
- const config_1 = require("./config");
9
- // Encoding & Decoding for onchain calls to fetch mutable pool data
10
- // Each supported pool type should have its own specific calls if needed
11
- const poolOnChain = {
12
- ['COMMON']: {
13
- count: 6,
14
- ['encode']: (network, contractInterface, address) => {
15
- return [
16
- {
17
- target: config_1.BalancerV3Config.BalancerV3[network].vaultAddress,
18
- callData: contractInterface.encodeFunctionData('getPoolTokenRates', [
19
- address,
20
- ]),
21
- },
22
- {
23
- target: config_1.BalancerV3Config.BalancerV3[network].vaultAddress,
24
- callData: contractInterface.encodeFunctionData('getCurrentLiveBalances', [address]),
25
- },
26
- {
27
- target: config_1.BalancerV3Config.BalancerV3[network].vaultAddress,
28
- callData: contractInterface.encodeFunctionData('getPoolConfig', [
29
- address,
30
- ]),
31
- },
32
- {
33
- target: config_1.BalancerV3Config.BalancerV3[network].vaultAddress,
34
- callData: contractInterface.encodeFunctionData('totalSupply', [
35
- address,
36
- ]),
37
- },
38
- {
39
- target: config_1.BalancerV3Config.BalancerV3[network].vaultAddress,
40
- callData: contractInterface.encodeFunctionData('isPoolPaused', [
41
- address,
42
- ]),
43
- },
44
- {
45
- target: config_1.BalancerV3Config.BalancerV3[network].vaultAddress,
46
- callData: contractInterface.encodeFunctionData('getHooksConfig', [
47
- address,
48
- ]),
49
- },
50
- ];
51
- },
52
- ['decode']: (contractInterface, poolAddress, data, startIndex) => {
53
- const resultTokenRates = decodeThrowError(contractInterface, 'getPoolTokenRates', data[startIndex++], poolAddress);
54
- if (!resultTokenRates)
55
- throw new Error(`Failed to get result for getPoolTokenRates for ${poolAddress}`);
56
- const resultLiveBalances = decodeThrowError(contractInterface, 'getCurrentLiveBalances', data[startIndex++], poolAddress);
57
- if (!resultLiveBalances)
58
- throw new Error(`Failed to get result for getCurrentLiveBalances for ${poolAddress}`);
59
- const resultGetPoolConfig = decodeThrowError(contractInterface, 'getPoolConfig', data[startIndex++], poolAddress);
60
- if (!resultGetPoolConfig)
61
- throw new Error(`Failed to get result for getPoolConfig for ${poolAddress}`);
62
- const resultTotalSupply = decodeThrowError(contractInterface, 'totalSupply', data[startIndex++], poolAddress);
63
- if (!resultTotalSupply)
64
- throw new Error(`Failed to get result for totalSupply for ${poolAddress}`);
65
- const resultIsPoolPaused = decodeThrowError(contractInterface, 'isPoolPaused', data[startIndex++], poolAddress);
66
- if (!resultIsPoolPaused)
67
- throw new Error(`Failed to get result for isPoolPaused for ${poolAddress}`);
68
- const resultHooksConfig = decodeThrowError(contractInterface, 'getHooksConfig', data[startIndex++], poolAddress);
69
- if (!resultHooksConfig)
70
- throw new Error(`Failed to get result for resultHooksConfig for ${poolAddress}`);
71
- return {
72
- tokenRates: resultTokenRates.tokenRates.map((r) => BigInt(r)),
73
- balancesLiveScaled18: resultLiveBalances.balancesLiveScaled18.map((b) => BigInt(b)),
74
- swapFee: BigInt(resultGetPoolConfig[0].staticSwapFeePercentage),
75
- aggregateSwapFee: BigInt(resultGetPoolConfig[0].aggregateSwapFeePercentage),
76
- totalSupply: BigInt(resultTotalSupply[0]),
77
- scalingFactors: resultTokenRates.decimalScalingFactors.map((r) => BigInt(r)),
78
- isPoolPaused: resultIsPoolPaused[0],
79
- hasHook: resultHooksConfig[0].hooksContract !==
80
- '0x0000000000000000000000000000000000000000',
81
- };
82
- },
83
- },
84
- ['WEIGHTED']: {
85
- count: 0,
86
- ['encode']: (network, contractInterface, address) => {
87
- return [];
88
- },
89
- ['decode']: (contractInterface, poolAddress, data, startIndex) => {
90
- return {};
91
- },
92
- },
93
- ['STABLE']: {
94
- count: 1,
95
- ['encode']: (network, contractInterface, address) => {
96
- return [
97
- {
98
- target: address,
99
- callData: contractInterface.encodeFunctionData('getAmplificationParameter'),
100
- },
101
- ];
102
- },
103
- ['decode']: (contractInterface, poolAddress, data, startIndex) => {
104
- const resultAmp = decodeThrowError(contractInterface, 'getAmplificationParameter', data[startIndex++], poolAddress);
105
- if (!resultAmp)
106
- throw new Error(`Failed to get result for getAmplificationParameter for ${poolAddress}`);
107
- // TODO requested SC to add view to stable pool to get amp update state if it is currently updating
108
- return {
109
- amp: resultAmp[0].toBigInt(),
110
- ampIsUpdating: !!resultAmp[1],
111
- ampStartTime: 0n,
112
- ampStopTime: 0n,
113
- ampStartValue: 0n,
114
- ampEndValue: 0n,
115
- };
116
- },
117
- },
118
- };
119
- function decodeThrowError(contractInterface, functionName, resultEntry, poolAddress) {
120
- if (!resultEntry.success)
121
- throw new Error(`Failed to execute ${functionName} for ${poolAddress}`);
122
- return contractInterface.decodeFunctionResult(functionName, resultEntry.returnData);
123
- }
124
- exports.decodeThrowError = decodeThrowError;
125
- // Any data from API will be immutable. Mutable data such as balances, etc will be fetched via onchain/event state.
126
- async function getOnChainState(network, immutablePoolStateMap, dexHelper, interfaces, blockNumber) {
127
- const multiCallData = Object.entries(immutablePoolStateMap)
128
- .map(([address, pool]) => {
129
- return [
130
- ...poolOnChain['COMMON'].encode(network, interfaces['VAULT'], address),
131
- ...poolOnChain[pool.poolType].encode(network, interfaces[pool.poolType], address),
132
- ];
133
- })
134
- .flat();
135
- // 500 is an arbitrary number chosen based on the blockGasLimit
136
- const slicedMultiCallData = lodash_1.default.chunk(multiCallData, 500);
137
- const multicallData = (await Promise.all(slicedMultiCallData.map(async (_multiCallData) => dexHelper.multiContract.methods
138
- .tryAggregate(false, _multiCallData)
139
- .call({}, blockNumber)))).flat();
140
- let i = 0;
141
- const poolStateMap = Object.fromEntries(Object.entries(immutablePoolStateMap).map(([address, pool]) => {
142
- const commonMutableData = poolOnChain['COMMON'].decode(interfaces['VAULT'], address, multicallData, i);
143
- i = i + poolOnChain['COMMON'].count;
144
- const poolMutableData = poolOnChain[pool.poolType].decode(interfaces[pool.poolType], address, multicallData, i);
145
- i = i + poolOnChain[pool.poolType].count;
146
- return [
147
- address,
148
- {
149
- ...pool,
150
- ...commonMutableData,
151
- ...poolMutableData,
152
- },
153
- ];
154
- }));
155
- return poolStateMap;
156
- }
157
- exports.getOnChainState = getOnChainState;
158
- //# sourceMappingURL=getOnChainState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getOnChainState.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/getOnChainState.ts"],"names":[],"mappings":";;;;;;AAAA,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AAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CACvD,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EACzB,OAAO,EACP,aAAa,EACb,CAAC,CACF,CAAC;QACF,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;QACzC,OAAO;YACL,OAAO;YACP;gBACE,GAAG,IAAI;gBACP,GAAG,iBAAiB;gBACpB,GAAG,eAAe;aACnB;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,CAAC;AA/DD,0CA+DC"}
@@ -1,2 +0,0 @@
1
- import { ImmutablePoolStateMap } from './types';
2
- export declare function getPoolsApi(network: number, timestamp?: number): Promise<ImmutablePoolStateMap>;