@paraswap/dex-lib 3.11.0-bebop.3 → 3.11.1-algebra.0

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 (291) hide show
  1. package/.vscode/launch.json +53 -0
  2. package/.vscode/settings.json +2 -0
  3. package/.vscode/tasks.json +15 -0
  4. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
  5. package/build/abi/{angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json → wombat/pool.json} +637 -594
  6. package/build/config.js +0 -1
  7. package/build/config.js.map +1 -1
  8. package/build/dex/aave-v1/aave-v1.js +1 -0
  9. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  10. package/build/dex/aave-v2/tokens-avalanche.json +44 -0
  11. package/build/dex/aave-v2/tokens-mainnet.json +188 -0
  12. package/build/dex/aave-v2/tokens-polygon.json +44 -0
  13. package/build/dex/algebra/algebra-pool-v1_1.js +5 -5
  14. package/build/dex/algebra/algebra-pool-v1_1.js.map +1 -1
  15. package/build/dex/algebra/lib/AlgebraMath.js +1 -4
  16. package/build/dex/algebra/lib/AlgebraMath.js.map +1 -1
  17. package/build/dex/bProtocol.d.ts +18 -0
  18. package/build/dex/bProtocol.js +39 -0
  19. package/build/dex/bProtocol.js.map +1 -0
  20. package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +729 -0
  21. package/build/dex/balancer-v3/abi/balancerBatchRouter.js +732 -0
  22. package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +1 -0
  23. package/build/dex/balancer-v3/abi/balancerRouter.d.ts +1406 -0
  24. package/build/dex/balancer-v3/abi/balancerRouter.js +1175 -0
  25. package/build/dex/balancer-v3/abi/balancerRouter.js.map +1 -0
  26. package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +2081 -0
  27. package/build/dex/balancer-v3/abi/vaultExtension.V3.js +1851 -0
  28. package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +1 -0
  29. package/build/dex/balancer-v3/balancer-v3-pool.d.ts +76 -0
  30. package/build/dex/balancer-v3/balancer-v3-pool.js +383 -0
  31. package/build/dex/balancer-v3/balancer-v3-pool.js.map +1 -0
  32. package/build/dex/balancer-v3/balancer-v3.d.ts +57 -0
  33. package/build/dex/balancer-v3/balancer-v3.js +373 -0
  34. package/build/dex/balancer-v3/balancer-v3.js.map +1 -0
  35. package/build/dex/balancer-v3/config.d.ts +8 -0
  36. package/build/dex/balancer-v3/config.js +24 -0
  37. package/build/dex/balancer-v3/config.js.map +1 -0
  38. package/build/dex/balancer-v3/getOnChainState.d.ts +10 -0
  39. package/build/dex/balancer-v3/getOnChainState.js +158 -0
  40. package/build/dex/balancer-v3/getOnChainState.js.map +1 -0
  41. package/build/dex/balancer-v3/getPoolsApi.d.ts +2 -0
  42. package/build/dex/balancer-v3/getPoolsApi.js +81 -0
  43. package/build/dex/balancer-v3/getPoolsApi.js.map +1 -0
  44. package/build/dex/balancer-v3/getTopPoolsApi.d.ts +13 -0
  45. package/build/dex/balancer-v3/getTopPoolsApi.js +62 -0
  46. package/build/dex/balancer-v3/getTopPoolsApi.js.map +1 -0
  47. package/build/dex/balancer-v3/types.d.ts +63 -0
  48. package/build/dex/balancer-v3/types.js +3 -0
  49. package/build/dex/balancer-v3/types.js.map +1 -0
  50. package/build/dex/bancor.d.ts +26 -0
  51. package/build/dex/bancor.js +58 -0
  52. package/build/dex/bancor.js.map +1 -0
  53. package/build/dex/bebop/bebop.js +1 -1
  54. package/build/dex/bebop/bebop.js.map +1 -1
  55. package/build/dex/bebop/config.js +0 -5
  56. package/build/dex/bebop/config.js.map +1 -1
  57. package/build/dex/bebop/rate-fetcher.d.ts +1 -3
  58. package/build/dex/bebop/rate-fetcher.js +2 -42
  59. package/build/dex/bebop/rate-fetcher.js.map +1 -1
  60. package/build/dex/bebop/validators.d.ts +0 -2
  61. package/build/dex/bebop/validators.js +1 -9
  62. package/build/dex/bebop/validators.js.map +1 -1
  63. package/build/dex/compound.d.ts +18 -0
  64. package/build/dex/compound.js +46 -0
  65. package/build/dex/compound.js.map +1 -0
  66. package/build/dex/curve-v2.d.ts +58 -0
  67. package/build/dex/curve-v2.js +180 -0
  68. package/build/dex/curve-v2.js.map +1 -0
  69. package/build/dex/dodo-v1.d.ts +33 -0
  70. package/build/dex/dodo-v1.js +63 -0
  71. package/build/dex/dodo-v1.js.map +1 -0
  72. package/build/dex/fluid-dex/fluid-dex-pool.d.ts +47 -0
  73. package/build/dex/fluid-dex/fluid-dex-pool.js +119 -0
  74. package/build/dex/fluid-dex/fluid-dex-pool.js.map +1 -0
  75. package/build/dex/fluid-dex/fluid-dex.js +1 -1
  76. package/build/dex/fluid-dex/fluid-dex.js.map +1 -1
  77. package/build/dex/inception/inception-event-pool.d.ts +4 -4
  78. package/build/dex/inception/inception-event-pool.js +7 -9
  79. package/build/dex/inception/inception-event-pool.js.map +1 -1
  80. package/build/dex/inception/inception.d.ts +6 -6
  81. package/build/dex/inception/inception.js +16 -40
  82. package/build/dex/inception/inception.js.map +1 -1
  83. package/build/dex/inception/utils.d.ts +1 -0
  84. package/build/dex/inception/utils.js +22 -1
  85. package/build/dex/inception/utils.js.map +1 -1
  86. package/build/dex/lido.d.ts +19 -0
  87. package/build/dex/lido.js +42 -0
  88. package/build/dex/lido.js.map +1 -0
  89. package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
  90. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  91. package/build/dex/maker-psm/scripts/validate-state.js +185 -0
  92. package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
  93. package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
  94. package/build/dex/onebit.d.ts +25 -0
  95. package/build/dex/onebit.js +42 -0
  96. package/build/dex/onebit.js.map +1 -0
  97. package/build/dex/platypus/platypus.js +17 -3
  98. package/build/dex/platypus/platypus.js.map +1 -1
  99. package/build/dex/smoothy.d.ts +26 -0
  100. package/build/dex/smoothy.js +48 -0
  101. package/build/dex/smoothy.js.map +1 -0
  102. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
  103. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
  104. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
  105. package/build/dex/stable-pool.d.ts +28 -0
  106. package/build/dex/stable-pool.js +55 -0
  107. package/build/dex/stable-pool.js.map +1 -0
  108. package/build/dex/swaap-v1/swaap-v1.js +4 -0
  109. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  110. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +7 -0
  111. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +20 -0
  112. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +1 -0
  113. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  114. package/build/dex/trader-joe-v2.1.js +79 -0
  115. package/build/dex/trader-joe-v2.1.js.map +1 -0
  116. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
  117. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
  118. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
  119. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
  120. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
  121. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
  122. package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +4 -0
  123. package/build/dex/uniswap-v3/uniswap-v3-pricing.js +43 -0
  124. package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +1 -0
  125. package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +1 -0
  126. package/build/dex/uniswap-v3/uniswap-v3-worker.js +10 -0
  127. package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +1 -0
  128. package/build/lib/fetcher/wsFetcher.d.ts +3 -7
  129. package/build/lib/fetcher/wsFetcher.js +51 -64
  130. package/build/lib/fetcher/wsFetcher.js.map +1 -1
  131. package/package.json +2 -4
  132. package/src/config.ts +0 -1
  133. package/src/dex/algebra/algebra-pool-v1_1.ts +5 -5
  134. package/src/dex/algebra/lib/AlgebraMath.ts +1 -5
  135. package/src/dex/algebra/scripts/validate-state.test.ts +384 -0
  136. package/src/dex/bebop/bebop-e2e.test.ts +0 -21
  137. package/src/dex/bebop/bebop.ts +1 -1
  138. package/src/dex/bebop/config.ts +0 -5
  139. package/src/dex/bebop/rate-fetcher.ts +6 -51
  140. package/src/dex/bebop/validators.ts +0 -10
  141. package/src/dex/fluid-dex/fluid-dex.ts +0 -1
  142. package/src/lib/fetcher/wsFetcher.ts +66 -79
  143. package/build/abi/Aave_GSM.json +0 -751
  144. package/build/abi/Balancer.json +0 -257
  145. package/build/abi/BalancerV2.json +0 -1179
  146. package/build/abi/RamsesV2Pool.abi.json +0 -1554
  147. package/build/abi/RamsesV2Quoter.abi.json +0 -274
  148. package/build/abi/USDM.json +0 -807
  149. package/build/abi/UniswapV2Router.json +0 -397
  150. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
  151. package/build/abi/cables/CablesMainnetRFQ.json +0 -1083
  152. package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
  153. package/build/abi/curve-v1/CurveTokenV1.json +0 -305
  154. package/build/abi/curve-v1/CurveTokenV2.json +0 -318
  155. package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
  156. package/build/abi/curve-v1/CurveV2Swap.json +0 -700
  157. package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
  158. package/build/abi/curve-v1/FactoryRegistry.json +0 -508
  159. package/build/abi/curve-v1/StableSwapAave.json +0 -1152
  160. package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
  161. package/build/abi/curve-v1/StableSwapCompound.json +0 -814
  162. package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
  163. package/build/abi/curve-v1/StableSwapPax.json +0 -865
  164. package/build/abi/curve-v1/StableSwapSnow.json +0 -900
  165. package/build/abi/curve-v1/StableSwapUSDN.json +0 -1004
  166. package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
  167. package/build/abi/curve-v1/StableSwapY.json +0 -814
  168. package/build/abi/inception/inception-ineth.json +0 -609
  169. package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
  170. package/build/abi/kyberdmm.abi.json +0 -1148
  171. package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  172. package/build/abi/nerve/nerve-metapool.json +0 -790
  173. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  174. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
  175. package/build/dex/balancer-v1/balancer-pools.json +0 -33333
  176. package/build/dex/bebop/bebop.json +0 -72
  177. package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
  178. package/build/dex/bebop/websocket-fetcher.js +0 -87
  179. package/build/dex/bebop/websocket-fetcher.js.map +0 -1
  180. package/build/dex/cables/cables.d.ts +0 -57
  181. package/build/dex/cables/cables.js +0 -471
  182. package/build/dex/cables/cables.js.map +0 -1
  183. package/build/dex/cables/config.d.ts +0 -4
  184. package/build/dex/cables/config.js +0 -15
  185. package/build/dex/cables/config.js.map +0 -1
  186. package/build/dex/cables/constants.d.ts +0 -19
  187. package/build/dex/cables/constants.js +0 -26
  188. package/build/dex/cables/constants.js.map +0 -1
  189. package/build/dex/cables/rate-fetcher.d.ts +0 -34
  190. package/build/dex/cables/rate-fetcher.js +0 -106
  191. package/build/dex/cables/rate-fetcher.js.map +0 -1
  192. package/build/dex/cables/types.d.ts +0 -106
  193. package/build/dex/cables/types.js +0 -12
  194. package/build/dex/cables/types.js.map +0 -1
  195. package/build/dex/cables/validators.d.ts +0 -5
  196. package/build/dex/cables/validators.js +0 -49
  197. package/build/dex/cables/validators.js.map +0 -1
  198. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  199. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  200. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  201. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  202. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  203. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  204. package/build/dex/idle-dao/scripts.d.ts +0 -9
  205. package/build/dex/idle-dao/scripts.js +0 -552
  206. package/build/dex/idle-dao/scripts.js.map +0 -1
  207. package/build/dex/inception/inception-native.d.ts +0 -43
  208. package/build/dex/inception/inception-native.js +0 -131
  209. package/build/dex/inception/inception-native.js.map +0 -1
  210. package/build/dex/inception/inception-pool.d.ts +0 -18
  211. package/build/dex/inception/inception-pool.js +0 -32
  212. package/build/dex/inception/inception-pool.js.map +0 -1
  213. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  214. package/build/dex/inception/inception-price-feed.js +0 -51
  215. package/build/dex/inception/inception-price-feed.js.map +0 -1
  216. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
  217. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
  218. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
  219. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
  220. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
  221. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
  222. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
  223. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
  224. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
  225. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
  226. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
  227. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
  228. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
  229. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
  230. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
  231. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
  232. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
  233. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
  234. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
  235. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
  236. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
  237. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
  238. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
  239. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
  240. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
  241. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
  242. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
  243. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
  244. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
  245. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
  246. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
  247. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
  248. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
  249. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
  250. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
  251. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
  252. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
  253. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
  254. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
  255. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
  256. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
  257. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
  258. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
  259. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
  260. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
  261. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
  262. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
  263. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
  264. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
  265. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
  266. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
  267. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
  268. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
  269. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
  270. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
  271. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
  272. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
  273. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
  274. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
  275. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
  276. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
  277. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
  278. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
  279. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
  280. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
  281. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
  282. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
  283. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
  284. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
  285. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
  286. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
  287. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
  288. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
  289. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
  290. package/src/dex/bebop/bebop.json +0 -72
  291. package/src/dex/bebop/bebop.proto +0 -15
@@ -0,0 +1,384 @@
1
+ /* eslint-disable no-console */
2
+ import dotenv from 'dotenv';
3
+ dotenv.config();
4
+
5
+ import { Network } from '../../../constants';
6
+ import { DummyDexHelper } from '../../../dex-helper';
7
+ import { Algebra } from '../algebra';
8
+ import { uint256ToBigInt } from '../../../lib/decoders';
9
+ import {
10
+ DecodedStateMultiCallResultWithRelativeBitmapsV1_1,
11
+ DecodedStateMultiCallResultWithRelativeBitmapsV1_9,
12
+ PoolState_v1_9,
13
+ } from '../types';
14
+ import {
15
+ decodeStateMultiCallResultWithRelativeBitmapsV1_1,
16
+ decodeStateMultiCallResultWithRelativeBitmapsV1_9,
17
+ } from '../utils';
18
+ import { MultiCallParams, MultiWrapper } from '../../../lib/multi-wrapper';
19
+ import Web3 from 'web3';
20
+ import multiABIV2 from '../../../abi/multi-v2.json';
21
+ import ERC20ABI from '../../../abi/erc20.json';
22
+ import { getLogger } from '../../../lib/log4js';
23
+ import { Interface } from 'ethers/lib/utils';
24
+ import { AbiItem } from 'web3-utils';
25
+ import AlgebraStateMulticallABI from '../../../abi/algebra/AlgebraStateMulticall.abi.json';
26
+ import { TICK_BITMAP_TO_USE, TICK_BITMAP_BUFFER } from '../constants';
27
+ import { BlockHeader } from 'web3-eth';
28
+ import { ethers } from 'ethers';
29
+ import assert from 'assert';
30
+
31
+ // public RPC, replace to RPC with archive node
32
+ const web3Provider = new Web3(
33
+ 'https://empty-muddy-breeze.xdai.quiknode.pro/f1ccb72e430860bc3be568120bb2d8c028ba2633/',
34
+ );
35
+
36
+ // pool and tokens for specific broken tx - 0x9a296a13f7c5eb8ce838e15ecbe3888e8998a14803a1ec46838611e1ff118d6e
37
+ const factoryAddress = '0xA0864cCA6E114013AB0e27cbd5B6f4c8947da766';
38
+ const poolAddress = '0xfd24c5c19df9f124f385b3c0f38f8c6c72f5a137';
39
+ const srcToken = {
40
+ address: `0xaf204776c7245bF4147c2612BF6e5972Ee483701`,
41
+ decimals: 18,
42
+ };
43
+ const destToken = {
44
+ address: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
45
+ decimals: 6,
46
+ };
47
+ const blockHeaders: Record<number, BlockHeader> = {};
48
+
49
+ const multiContract = new web3Provider.eth.Contract(
50
+ multiABIV2 as any,
51
+ '0xca11bde05977b3631167028862be2a173976ca11',
52
+ );
53
+ const stateMultiContract = new web3Provider.eth.Contract(
54
+ AlgebraStateMulticallABI as AbiItem[],
55
+ '0x49C46f7f88110ccA234ef27Cd664510f7bbF5998',
56
+ );
57
+
58
+ const multiWrapper = new MultiWrapper(multiContract, getLogger(`Ticks`));
59
+ const erc20Interface = new Interface(ERC20ABI);
60
+
61
+ function getBitmapRangeToRequest() {
62
+ return TICK_BITMAP_TO_USE + TICK_BITMAP_BUFFER;
63
+ // return 2n;
64
+ // return 0n;
65
+ }
66
+
67
+ async function _fetchPoolState_v1_9SingleStep(
68
+ blockNumber: number,
69
+ ): Promise<
70
+ [bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmapsV1_9]
71
+ > {
72
+ const callData: MultiCallParams<
73
+ bigint | DecodedStateMultiCallResultWithRelativeBitmapsV1_9
74
+ >[] = [
75
+ {
76
+ target: srcToken.address,
77
+ callData: erc20Interface.encodeFunctionData('balanceOf', [poolAddress]),
78
+ decodeFunction: uint256ToBigInt,
79
+ },
80
+ {
81
+ target: destToken.address,
82
+ callData: erc20Interface.encodeFunctionData('balanceOf', [poolAddress]),
83
+ decodeFunction: uint256ToBigInt,
84
+ },
85
+ {
86
+ target: stateMultiContract.options.address,
87
+ callData: stateMultiContract.methods
88
+ .getFullStateWithRelativeBitmaps(
89
+ factoryAddress,
90
+ srcToken.address,
91
+ destToken.address,
92
+ getBitmapRangeToRequest(),
93
+ getBitmapRangeToRequest(),
94
+ )
95
+ .encodeABI(),
96
+ decodeFunction: decodeStateMultiCallResultWithRelativeBitmapsV1_9,
97
+ },
98
+ ];
99
+
100
+ const [resBalance0, resBalance1, resState] = await multiWrapper.tryAggregate<
101
+ bigint | DecodedStateMultiCallResultWithRelativeBitmapsV1_9
102
+ >(false, callData, blockNumber, multiWrapper.defaultBatchSize, false);
103
+
104
+ const [balance0, balance1, _state] = [
105
+ resBalance0.returnData,
106
+ resBalance1.returnData,
107
+ resState.returnData,
108
+ ] as [bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmapsV1_9];
109
+
110
+ return [balance0, balance1, _state];
111
+ }
112
+
113
+ async function fetchPoolStateSingleStep(
114
+ blockNumber: number,
115
+ ): Promise<
116
+ [bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmapsV1_1]
117
+ > {
118
+ const callData: MultiCallParams<
119
+ bigint | DecodedStateMultiCallResultWithRelativeBitmapsV1_1
120
+ >[] = [
121
+ {
122
+ target: srcToken.address,
123
+ callData: erc20Interface.encodeFunctionData('balanceOf', [poolAddress]),
124
+ decodeFunction: uint256ToBigInt,
125
+ },
126
+ {
127
+ target: destToken.address,
128
+ callData: erc20Interface.encodeFunctionData('balanceOf', [poolAddress]),
129
+ decodeFunction: uint256ToBigInt,
130
+ },
131
+ {
132
+ target: stateMultiContract.options.address,
133
+ callData: stateMultiContract.methods
134
+ .getFullStateWithRelativeBitmaps(
135
+ factoryAddress,
136
+ srcToken.address,
137
+ destToken.address,
138
+ getBitmapRangeToRequest(),
139
+ getBitmapRangeToRequest(),
140
+ )
141
+ .encodeABI(),
142
+ decodeFunction: decodeStateMultiCallResultWithRelativeBitmapsV1_1,
143
+ },
144
+ ];
145
+
146
+ const [resBalance0, resBalance1, resState] = await multiWrapper.tryAggregate<
147
+ bigint | DecodedStateMultiCallResultWithRelativeBitmapsV1_1
148
+ >(false, callData, blockNumber, multiWrapper.defaultBatchSize, false);
149
+
150
+ assert(resState.success, 'Pool does not exist');
151
+
152
+ const [balance0, balance1, _state] = [
153
+ resBalance0.returnData,
154
+ resBalance1.returnData,
155
+ resState.returnData,
156
+ ] as [bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmapsV1_1];
157
+
158
+ return [balance0, balance1, _state];
159
+ }
160
+
161
+ function preprocessField(value: any): string {
162
+ // const _v = ethers.BigNumber.from(value);
163
+ return value.toString();
164
+ // if (
165
+ // typeof value === 'bigint' ||
166
+ // typeof value === 'number' ||
167
+ // ethers.BigNumber.isBigNumber(value)
168
+ // ) {
169
+ // return value.toString();
170
+ // }
171
+ // return value;
172
+ }
173
+
174
+ function compareAndLogDifferences<T extends object, Y extends object>(
175
+ obj1: T,
176
+ obj2: Y,
177
+ keyNames: Array<keyof T & keyof Y>,
178
+ checkEachKey = false,
179
+ ) {
180
+ let isValid = true;
181
+ let keys = keyNames;
182
+
183
+ if (checkEachKey) {
184
+ // find common keys
185
+ const keys1 = Object.keys(obj1);
186
+ const keys2 = new Set(Object.keys(obj2));
187
+ keys = keys1.filter(key => keys2.has(key)) as Array<keyof T & keyof Y>;
188
+ }
189
+
190
+ for (let fieldName of keys) {
191
+ const value1 = preprocessField(obj1[fieldName]);
192
+ const value2 = preprocessField(obj2[fieldName]);
193
+
194
+ if (value1 !== value2) {
195
+ console.log(
196
+ `${fieldName.toString()} mismatch: actual: ${value1} vs pool: ${value2}`,
197
+ );
198
+ isValid = false;
199
+ }
200
+ }
201
+
202
+ return isValid;
203
+ }
204
+
205
+ async function isPoolStateEqualToReal(
206
+ state: PoolState_v1_9,
207
+ blockNumber: number,
208
+ ) {
209
+ // const [balance0, balance1, contractState] =
210
+ // await _fetchPoolState_v1_9SingleStep(blockNumber);
211
+
212
+ const [balance0, balance1, contractState] = await fetchPoolStateSingleStep(
213
+ blockNumber,
214
+ );
215
+
216
+ const isValidBalances = compareAndLogDifferences(
217
+ state,
218
+ { balance0, balance1, ...contractState },
219
+ ['balance0', 'balance1', 'liquidity', 'tickSpacing'],
220
+ );
221
+
222
+ const isValidGlobalState = compareAndLogDifferences(
223
+ state.globalState,
224
+ contractState.globalState,
225
+ // can check only for one of them, because they are directly co-related
226
+ ['price', 'tick'],
227
+ );
228
+
229
+ const isValidTickBitmap = compareAndLogDifferences(
230
+ state.tickBitmap,
231
+ contractState.tickBitmap.reduce((acc, val) => {
232
+ // @ts-ignore
233
+ acc[val.index] = val.value;
234
+ return acc;
235
+ }, {} as Record<string, bigint>),
236
+ [],
237
+ true,
238
+ );
239
+
240
+ let isValidTicks = true;
241
+ for (let tick of contractState.ticks) {
242
+ const stateTick = state?.ticks[tick.index];
243
+ if (stateTick) {
244
+ const isValidTick = compareAndLogDifferences(stateTick, tick.value, [
245
+ 'liquidityGross',
246
+ 'liquidityNet',
247
+ // next fields doesn't affect pricing, so skip checks
248
+ // 'initialized',
249
+ // 'secondsOutside',
250
+ // 'secondsPerLiquidityOutsideX128',
251
+ // 'tickCumulativeOutside'
252
+ ]);
253
+
254
+ if (isValidTicks && !isValidTick) {
255
+ isValidTicks = false;
256
+ }
257
+ }
258
+ }
259
+
260
+ return (
261
+ isValidBalances && isValidGlobalState && isValidTicks && isValidTickBitmap
262
+ );
263
+ }
264
+
265
+ async function checkPoolStateForBlockRange(
266
+ startBlockNumber: number,
267
+ endBlockNumber: number,
268
+ ): Promise<boolean> {
269
+ // const network = Network.ARBITRUM;
270
+ // const dexKey = 'CamelotV3';
271
+ const network = Network.GNOSIS;
272
+ const dexKey = 'SwaprV3';
273
+ const dexHelper = new DummyDexHelper(network);
274
+
275
+ const algebra = new Algebra(network, dexKey, dexHelper);
276
+ const pool = await algebra.getPool(
277
+ srcToken.address,
278
+ destToken.address,
279
+ startBlockNumber,
280
+ );
281
+
282
+ const logsToDispatch = await dexHelper.provider.getLogs({
283
+ fromBlock: startBlockNumber,
284
+ toBlock: endBlockNumber,
285
+ address: poolAddress,
286
+ });
287
+
288
+ console.log(logsToDispatch.length);
289
+
290
+ // group logs by block number
291
+ const logsByBlockNumber: Record<number, any[]> = {};
292
+ for (let log of logsToDispatch) {
293
+ if (!logsByBlockNumber[log.blockNumber]) {
294
+ logsByBlockNumber[log.blockNumber] = [];
295
+ }
296
+ logsByBlockNumber[log.blockNumber].push(log);
297
+ }
298
+
299
+ const sortedBlocks = Object.keys(logsByBlockNumber)
300
+ .map(Number)
301
+ .sort((a, b) => Number(a) - Number(b));
302
+
303
+ for (let blockNumber of sortedBlocks) {
304
+ if (!blockHeaders[blockNumber]) {
305
+ blockHeaders[blockNumber] = await dexHelper.web3Provider.eth.getBlock(
306
+ blockNumber,
307
+ );
308
+ }
309
+
310
+ // await pool?.update(logsByBlockNumber[blockNumber], {
311
+ // [blockNumber]: blockHeaders[blockNumber],
312
+ // });
313
+
314
+ const stateBeforeLog1 = pool?.getState(blockNumber) as PoolState_v1_9;
315
+ await pool?.update([logsByBlockNumber[blockNumber][0]], {
316
+ [blockNumber]: blockHeaders[blockNumber],
317
+ });
318
+
319
+ const stateAfterLog1 = pool?.getState(blockNumber) as PoolState_v1_9;
320
+ await pool?.update([logsByBlockNumber[blockNumber][1]], {
321
+ [blockNumber]: blockHeaders[blockNumber],
322
+ });
323
+
324
+ const stateAfterLog2 = pool?.getState(blockNumber) as PoolState_v1_9;
325
+ }
326
+
327
+ const state = pool?.getState(startBlockNumber) as PoolState_v1_9;
328
+ return isPoolStateEqualToReal(state, endBlockNumber);
329
+ }
330
+
331
+ async function findBreakingBlock(startBlock: number, endBlock: number) {
332
+ let left = startBlock;
333
+ let right = endBlock;
334
+
335
+ // If the state is valid at the start, then there's no breaking block in the range
336
+ if (await checkPoolStateForBlockRange(left, right)) {
337
+ return -1; // Indicates no breaking block found
338
+ }
339
+
340
+ while (left <= right) {
341
+ const mid = left + Math.floor((right - left) / 2);
342
+ const isValid = await checkPoolStateForBlockRange(startBlock, mid);
343
+
344
+ if (isValid) {
345
+ // If the state is valid up to mid, the issue must be in the second half
346
+ left = mid + 1;
347
+ } else {
348
+ // If the state is not valid up to mid, the issue is in the first half
349
+ // But we need to check if mid is the first occurrence of the issue
350
+ if (
351
+ mid === startBlock ||
352
+ (await checkPoolStateForBlockRange(startBlock, mid - 1))
353
+ ) {
354
+ return mid; // Found the breaking block
355
+ }
356
+ right = mid - 1;
357
+ }
358
+ }
359
+
360
+ return -1; // Should not reach here if there's a breaking block
361
+ }
362
+
363
+ // set timeout to 5 min
364
+ jest.setTimeout(300000);
365
+
366
+ describe('Algebra Pool State Validation', () => {
367
+ it('should validate pool state for a block range', async () => {
368
+ const isValid = await checkPoolStateForBlockRange(36886183, 36886186);
369
+ expect(isValid).toBe(true);
370
+ });
371
+ });
372
+
373
+ async function main() {
374
+ // use findBreakingBlock to find the block where the state is broken
375
+ // console.log(await findBreakingBlock(startBlockNumber, endBlockNumber));
376
+ // previously broken block 150502863
377
+ console.log(await checkPoolStateForBlockRange(36886183, 36886186));
378
+ // console.log(await checkPoolStateForBlockRange(152087800, 152287800));
379
+ // console.log(await checkPoolStateForBlockRange(152100945, 152100947));
380
+ }
381
+
382
+ // main()
383
+ // .then(() => console.log('Done'))
384
+ // .catch(e => console.error(e));
@@ -192,25 +192,4 @@ describe('Bebop E2E', () => {
192
192
  nativeTokenAmount,
193
193
  );
194
194
  });
195
-
196
- describe('BSC', () => {
197
- const network = Network.BSC;
198
-
199
- const tokenASymbol: string = 'USDT';
200
- const tokenBSymbol: string = 'ETH';
201
-
202
- const tokenAAmount: string = '100000000000000000000';
203
- const tokenBAmount: string = '100000000000000000';
204
- const nativeTokenAmount = '1000000000000000000';
205
-
206
- testForNetwork(
207
- network,
208
- dexKey,
209
- tokenASymbol,
210
- tokenBSymbol,
211
- tokenAAmount,
212
- tokenBAmount,
213
- nativeTokenAmount,
214
- );
215
- });
216
195
  });
@@ -120,7 +120,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
120
120
  pricesReqParams: {
121
121
  url:
122
122
  BEBOP_WS_API_URL +
123
- `/pmm/${BebopConfig['Bebop'][network].chainName}/v3/pricing?format=protobuf`,
123
+ `/pmm/${BebopConfig['Bebop'][network].chainName}/v3/pricing`,
124
124
  headers: {
125
125
  name: BEBOP_AUTH_NAME,
126
126
  authorization: this.bebopAuthToken,
@@ -33,10 +33,5 @@ export const BebopConfig: DexConfigMap<DexParams> = {
33
33
  chainName: 'optimism',
34
34
  middleTokens: ['0x7F5c764cBc14f9669B88837ca1490cCa17c31607'],
35
35
  },
36
- [Network.BSC]: {
37
- settlementAddress: '0xbbbbbBB520d69a9775E85b458C58c648259FAD5F',
38
- chainName: 'bsc',
39
- middleTokens: ['0x55d398326f99059fF775485246999027B3197955'],
40
- },
41
36
  },
42
37
  };
@@ -1,30 +1,15 @@
1
1
  import { ETHER_ADDRESS, Network } from '../../constants';
2
2
  import { IDexHelper } from '../../dex-helper';
3
3
  import { Fetcher } from '../../lib/fetcher/fetcher';
4
- import { validateAndCast, ValidationError } from '../../lib/validators';
4
+ import { validateAndCast } from '../../lib/validators';
5
5
  import { Logger, Token } from '../../types';
6
6
  import {
7
- BebopLevel,
8
- BebopPair,
9
7
  BebopPricingResponse,
10
8
  BebopRateFetcherConfig,
11
9
  BebopTokensResponse,
12
10
  } from './types';
13
- import {
14
- BebopPricingUpdate,
15
- pricesResponseValidator,
16
- tokensResponseValidator,
17
- } from './validators';
11
+ import { pricesResponseValidator, tokensResponseValidator } from './validators';
18
12
  import { WebSocketFetcher } from '../../lib/fetcher/wsFetcher';
19
- import { utils } from 'ethers';
20
-
21
- export function levels_from_flat_array(values: number[]): BebopLevel[] {
22
- const levels: BebopLevel[] = [];
23
- for (let i = 0; i < values.length; i += 2) {
24
- levels.push([values[i], values[i + 1]]);
25
- }
26
- return levels;
27
- }
28
13
 
29
14
  export class RateFetcher {
30
15
  private pricesFetcher: WebSocketFetcher<BebopPricingResponse>;
@@ -50,16 +35,10 @@ export class RateFetcher {
50
35
  info: {
51
36
  requestOptions: config.rateConfig.pricesReqParams,
52
37
  caster: (data: unknown) => {
53
- const dataBuffer = data as any;
54
- const invalid = BebopPricingUpdate.verify(dataBuffer);
55
- if (invalid) {
56
- throw new ValidationError(invalid);
57
- }
58
- const update = BebopPricingUpdate.decode(dataBuffer);
59
- const updateObject = BebopPricingUpdate.toObject(update, {
60
- longs: Number,
61
- });
62
- return this.parsePricingUpdate(updateObject);
38
+ return validateAndCast<BebopPricingResponse>(
39
+ data,
40
+ pricesResponseValidator,
41
+ );
63
42
  },
64
43
  },
65
44
  handler: this.handlePricesResponse.bind(this),
@@ -89,30 +68,6 @@ export class RateFetcher {
89
68
  );
90
69
  }
91
70
 
92
- parsePricingUpdate(updateObject: any): BebopPricingResponse {
93
- const pricingResponse: BebopPricingResponse = {};
94
- if (!updateObject.pairs || !updateObject.pairs.length) {
95
- this.logger.warn('Update message did not include pairs', updateObject);
96
- return pricingResponse;
97
- }
98
- for (const pairBook of updateObject.pairs) {
99
- const pair =
100
- utils.getAddress('0x' + pairBook.base.toString('hex')) +
101
- '/' +
102
- utils.getAddress('0x' + pairBook.quote.toString('hex'));
103
- const lastUpdateTs = pairBook.lastUpdateTs;
104
- const bids = pairBook.bids ? levels_from_flat_array(pairBook.bids) : [];
105
- const asks = pairBook.asks ? levels_from_flat_array(pairBook.asks) : [];
106
- const bebopPair: BebopPair = {
107
- bids,
108
- asks,
109
- last_update_ts: lastUpdateTs,
110
- };
111
- pricingResponse[pair] = bebopPair;
112
- }
113
- return pricingResponse;
114
- }
115
-
116
71
  start() {
117
72
  this.pricesFetcher.startPolling();
118
73
  this.tokensFetcher.startPolling();
@@ -1,6 +1,4 @@
1
1
  import joi from 'joi';
2
- import protobuf from 'protobufjs';
3
- import JSONDescriptor from './bebop.json';
4
2
 
5
3
  const levelValidator = joi.array().items(joi.number()).length(2);
6
4
 
@@ -29,11 +27,3 @@ export const tokensResponseValidator = joi.object({
29
27
  export const blacklistResponseValidator = joi.object({
30
28
  blacklist: joi.array().items(joi.string().min(1)).required(),
31
29
  });
32
-
33
- // Original .proto def
34
- // const root = protobuf.loadSync(__dirname + '/bebop.proto');
35
- // Use .json to not change build step to include .proto files
36
- // console.log(JSON.stringify(root.toJSON(), null, 4));
37
-
38
- const root = protobuf.Root.fromJSON(JSONDescriptor);
39
- export const BebopPricingUpdate = root.lookupType('bebop.BebopPricingUpdate');
@@ -314,7 +314,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
314
314
  this.fluidDexPoolIface,
315
315
  method,
316
316
  'amountOut_',
317
- 1,
318
317
  );
319
318
 
320
319
  const pool = await this.getPoolByTokenPair(srcToken, destToken);