@paraswap/dex-lib 4.1.9 → 4.1.10-pubsub

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 (363) hide show
  1. package/build/abi/AaveV1_lending_pool.json +27 -0
  2. package/build/abi/Aave_GSM.json +751 -0
  3. package/build/abi/Balancer.json +257 -0
  4. package/build/abi/BalancerV2.json +1179 -0
  5. package/build/abi/RamsesV2Pool.abi.json +1554 -0
  6. package/build/abi/RamsesV2Quoter.abi.json +274 -0
  7. package/build/abi/USDM.json +807 -0
  8. package/build/abi/UniswapV2Router.json +397 -0
  9. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
  10. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +509 -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/ekubo/core.json +1266 -0
  28. package/build/abi/ekubo/data-fetcher.json +161 -0
  29. package/build/abi/ekubo/router.json +803 -0
  30. package/build/abi/inception/inception-ineth-pool.json +1062 -0
  31. package/build/abi/inception/inception-ineth.json +609 -0
  32. package/build/abi/inception/inception-ratio-feed.json +329 -0
  33. package/build/abi/inception/inception-vault.json +991 -0
  34. package/build/abi/kyberdmm/kyber-storage.abi.json +824 -0
  35. package/build/abi/kyberdmm.abi.json +1148 -0
  36. package/build/abi/maverick-v2/MaverickV2Quoter.json +278 -0
  37. package/build/abi/nerve/nerve-metapool.json +790 -0
  38. package/build/abi/platypus/asset.json +490 -0
  39. package/build/abi/platypus/avax-pool.json +820 -0
  40. package/build/abi/platypus/oracle.json +119 -0
  41. package/build/abi/platypus/pool.json +677 -0
  42. package/build/abi/smardex/all/smardex-router.json +648 -0
  43. package/build/abi/smardex/layer-1/smardex-factory.json +242 -0
  44. package/build/abi/smardex/layer-1/smardex-pool.json +506 -0
  45. package/build/abi/smardex/layer-2/smardex-factory.json +185 -0
  46. package/build/abi/smardex/layer-2/smardex-pool.json +578 -0
  47. package/build/abi/swaap-v1/pool.json +1346 -0
  48. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
  49. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
  50. package/build/dex/aave-v1/aave-v1.d.ts +34 -0
  51. package/build/dex/aave-v1/aave-v1.js +180 -0
  52. package/build/dex/aave-v1/aave-v1.js.map +1 -0
  53. package/build/dex/aave-v1/config.d.ts +11 -0
  54. package/build/dex/aave-v1/config.js +20 -0
  55. package/build/dex/aave-v1/config.js.map +1 -0
  56. package/build/dex/aave-v1/tokens-mainnet.json +134 -0
  57. package/build/dex/aave-v1/tokens.d.ts +3 -0
  58. package/build/dex/aave-v1/tokens.js +50 -0
  59. package/build/dex/aave-v1/tokens.js.map +1 -0
  60. package/build/dex/aave-v1/types.d.ts +12 -0
  61. package/build/dex/aave-v1/types.js +3 -0
  62. package/build/dex/aave-v1/types.js.map +1 -0
  63. package/build/dex/aave-v3-stata/config.js +8 -8
  64. package/build/dex/aave-v3-stata/config.js.map +1 -1
  65. package/build/dex/aave-v3-stata-v2/aave-v3-stata-v2.js +2 -2
  66. package/build/dex/aave-v3-stata-v2/aave-v3-stata-v2.js.map +1 -1
  67. package/build/dex/aave-v3-stata-v2/config.js +31 -24
  68. package/build/dex/aave-v3-stata-v2/config.js.map +1 -1
  69. package/build/dex/aave-v3-stata-v2/types.d.ts +3 -2
  70. package/build/dex/aave-v3-stata-v2/types.js.map +1 -1
  71. package/build/dex/aave-v3-stata-v2/utils.d.ts +2 -2
  72. package/build/dex/aave-v3-stata-v2/utils.js +7 -6
  73. package/build/dex/aave-v3-stata-v2/utils.js.map +1 -1
  74. package/build/dex/balancer-v1/balancer-pools.json +33333 -0
  75. package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
  76. package/build/dex/bebop/websocket-fetcher.js +87 -0
  77. package/build/dex/bebop/websocket-fetcher.js.map +1 -0
  78. package/build/dex/ekubo/config.d.ts +3 -0
  79. package/build/dex/ekubo/config.js +23 -0
  80. package/build/dex/ekubo/config.js.map +1 -0
  81. package/build/dex/ekubo/ekubo.d.ts +49 -0
  82. package/build/dex/ekubo/ekubo.js +418 -0
  83. package/build/dex/ekubo/ekubo.js.map +1 -0
  84. package/build/dex/ekubo/pools/base-pool.d.ts +47 -0
  85. package/build/dex/ekubo/pools/base-pool.js +184 -0
  86. package/build/dex/ekubo/pools/base-pool.js.map +1 -0
  87. package/build/dex/ekubo/pools/math/constants.d.ts +3 -0
  88. package/build/dex/ekubo/pools/math/constants.js +7 -0
  89. package/build/dex/ekubo/pools/math/constants.js.map +1 -0
  90. package/build/dex/ekubo/pools/math/delta.d.ts +2 -0
  91. package/build/dex/ekubo/pools/math/delta.js +51 -0
  92. package/build/dex/ekubo/pools/math/delta.js.map +1 -0
  93. package/build/dex/ekubo/pools/math/price.d.ts +7 -0
  94. package/build/dex/ekubo/pools/math/price.js +116 -0
  95. package/build/dex/ekubo/pools/math/price.js.map +1 -0
  96. package/build/dex/ekubo/pools/math/swap.d.ts +18 -0
  97. package/build/dex/ekubo/pools/math/swap.js +128 -0
  98. package/build/dex/ekubo/pools/math/swap.js.map +1 -0
  99. package/build/dex/ekubo/pools/math/tick.d.ts +7 -0
  100. package/build/dex/ekubo/pools/math/tick.js +112 -0
  101. package/build/dex/ekubo/pools/math/tick.js.map +1 -0
  102. package/build/dex/ekubo/pools/oracle-pool.d.ts +10 -0
  103. package/build/dex/ekubo/pools/oracle-pool.js +19 -0
  104. package/build/dex/ekubo/pools/oracle-pool.js.map +1 -0
  105. package/build/dex/ekubo/types.d.ts +88 -0
  106. package/build/dex/ekubo/types.js +238 -0
  107. package/build/dex/ekubo/types.js.map +1 -0
  108. package/build/dex/ekubo/utils.d.ts +6 -0
  109. package/build/dex/ekubo/utils.js +30 -0
  110. package/build/dex/ekubo/utils.js.map +1 -0
  111. package/build/dex/generic-rfq/generic-rfq.js +1 -2
  112. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  113. package/build/dex/generic-rfq/rate-fetcher.d.ts +4 -1
  114. package/build/dex/generic-rfq/rate-fetcher.js +84 -23
  115. package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
  116. package/build/dex/hashflow/hashflow.js +4 -0
  117. package/build/dex/hashflow/hashflow.js.map +1 -1
  118. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  119. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  120. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  121. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  122. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  123. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  124. package/build/dex/idle-dao/scripts.d.ts +9 -0
  125. package/build/dex/idle-dao/scripts.js +552 -0
  126. package/build/dex/idle-dao/scripts.js.map +1 -0
  127. package/build/dex/inception/config.d.ts +4 -0
  128. package/build/dex/inception/config.js +109 -0
  129. package/build/dex/inception/config.js.map +1 -0
  130. package/build/dex/inception/inception-event-pool.d.ts +16 -0
  131. package/build/dex/inception/inception-event-pool.js +51 -0
  132. package/build/dex/inception/inception-event-pool.js.map +1 -0
  133. package/build/dex/inception/inception-native.d.ts +43 -0
  134. package/build/dex/inception/inception-native.js +131 -0
  135. package/build/dex/inception/inception-native.js.map +1 -0
  136. package/build/dex/inception/inception-pool.d.ts +18 -0
  137. package/build/dex/inception/inception-pool.js +32 -0
  138. package/build/dex/inception/inception-pool.js.map +1 -0
  139. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  140. package/build/dex/inception/inception-price-feed.js +51 -0
  141. package/build/dex/inception/inception-price-feed.js.map +1 -0
  142. package/build/dex/inception/inception.d.ts +43 -0
  143. package/build/dex/inception/inception.js +204 -0
  144. package/build/dex/inception/inception.js.map +1 -0
  145. package/build/dex/inception/tokens.d.ts +9 -0
  146. package/build/dex/inception/tokens.js +28 -0
  147. package/build/dex/inception/tokens.js.map +1 -0
  148. package/build/dex/inception/types.d.ts +22 -0
  149. package/build/dex/inception/types.js +3 -0
  150. package/build/dex/inception/types.js.map +1 -0
  151. package/build/dex/inception/utils.d.ts +6 -0
  152. package/build/dex/inception/utils.js +37 -0
  153. package/build/dex/inception/utils.js.map +1 -0
  154. package/build/dex/platypus/asset.d.ts +14 -0
  155. package/build/dex/platypus/asset.js +97 -0
  156. package/build/dex/platypus/asset.js.map +1 -0
  157. package/build/dex/platypus/config.d.ts +11 -0
  158. package/build/dex/platypus/config.js +69 -0
  159. package/build/dex/platypus/config.js.map +1 -0
  160. package/build/dex/platypus/platypus.d.ts +63 -0
  161. package/build/dex/platypus/platypus.js +473 -0
  162. package/build/dex/platypus/platypus.js.map +1 -0
  163. package/build/dex/platypus/pool-avax.d.ts +8 -0
  164. package/build/dex/platypus/pool-avax.js +54 -0
  165. package/build/dex/platypus/pool-avax.js.map +1 -0
  166. package/build/dex/platypus/pool-base.d.ts +19 -0
  167. package/build/dex/platypus/pool-base.js +86 -0
  168. package/build/dex/platypus/pool-base.js.map +1 -0
  169. package/build/dex/platypus/pool-pure.d.ts +8 -0
  170. package/build/dex/platypus/pool-pure.js +37 -0
  171. package/build/dex/platypus/pool-pure.js.map +1 -0
  172. package/build/dex/platypus/pool-subscriber.d.ts +14 -0
  173. package/build/dex/platypus/pool-subscriber.js +167 -0
  174. package/build/dex/platypus/pool-subscriber.js.map +1 -0
  175. package/build/dex/platypus/pool.d.ts +8 -0
  176. package/build/dex/platypus/pool.js +58 -0
  177. package/build/dex/platypus/pool.js.map +1 -0
  178. package/build/dex/platypus/types.d.ts +92 -0
  179. package/build/dex/platypus/types.js +10 -0
  180. package/build/dex/platypus/types.js.map +1 -0
  181. package/build/dex/quickswap/spiritswap-v3.d.ts +6 -0
  182. package/build/dex/quickswap/spiritswap-v3.js +19 -0
  183. package/build/dex/quickswap/spiritswap-v3.js.map +1 -0
  184. package/build/dex/smardex/config.d.ts +4 -0
  185. package/build/dex/smardex/config.js +64 -0
  186. package/build/dex/smardex/config.js.map +1 -0
  187. package/build/dex/smardex/constants.d.ts +18 -0
  188. package/build/dex/smardex/constants.js +33 -0
  189. package/build/dex/smardex/constants.js.map +1 -0
  190. package/build/dex/smardex/sdk/constants.d.ts +6 -0
  191. package/build/dex/smardex/sdk/constants.js +13 -0
  192. package/build/dex/smardex/sdk/constants.js.map +1 -0
  193. package/build/dex/smardex/sdk/core.d.ts +113 -0
  194. package/build/dex/smardex/sdk/core.js +499 -0
  195. package/build/dex/smardex/sdk/core.js.map +1 -0
  196. package/build/dex/smardex/sdk/errors.d.ts +15 -0
  197. package/build/dex/smardex/sdk/errors.js +22 -0
  198. package/build/dex/smardex/sdk/errors.js.map +1 -0
  199. package/build/dex/smardex/sdk/types.d.ts +62 -0
  200. package/build/dex/smardex/sdk/types.js +3 -0
  201. package/build/dex/smardex/sdk/types.js.map +1 -0
  202. package/build/dex/smardex/sdk/utils.d.ts +44 -0
  203. package/build/dex/smardex/sdk/utils.js +133 -0
  204. package/build/dex/smardex/sdk/utils.js.map +1 -0
  205. package/build/dex/smardex/smardex-event-pool.d.ts +28 -0
  206. package/build/dex/smardex/smardex-event-pool.js +119 -0
  207. package/build/dex/smardex/smardex-event-pool.js.map +1 -0
  208. package/build/dex/smardex/smardex.d.ts +65 -0
  209. package/build/dex/smardex/smardex.js +519 -0
  210. package/build/dex/smardex/smardex.js.map +1 -0
  211. package/build/dex/smardex/types.d.ts +55 -0
  212. package/build/dex/smardex/types.js +3 -0
  213. package/build/dex/smardex/types.js.map +1 -0
  214. package/build/dex/solidly/forks-override/cone.d.ts +22 -0
  215. package/build/dex/solidly/forks-override/cone.js +53 -0
  216. package/build/dex/solidly/forks-override/cone.js.map +1 -0
  217. package/build/dex/solidly/forks-override/solisnek.d.ts +8 -0
  218. package/build/dex/solidly/forks-override/solisnek.js +15 -0
  219. package/build/dex/solidly/forks-override/solisnek.js.map +1 -0
  220. package/build/dex/swaap-v1/config.d.ts +17 -0
  221. package/build/dex/swaap-v1/config.js +56 -0
  222. package/build/dex/swaap-v1/config.js.map +1 -0
  223. package/build/dex/swaap-v1/constants.d.ts +6 -0
  224. package/build/dex/swaap-v1/constants.js +17 -0
  225. package/build/dex/swaap-v1/constants.js.map +1 -0
  226. package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +25 -0
  227. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +62 -0
  228. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +1 -0
  229. package/build/dex/swaap-v1/libraries/Const.d.ts +18 -0
  230. package/build/dex/swaap-v1/libraries/Const.js +26 -0
  231. package/build/dex/swaap-v1/libraries/Const.js.map +1 -0
  232. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +77 -0
  233. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +316 -0
  234. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +1 -0
  235. package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +75 -0
  236. package/build/dex/swaap-v1/libraries/LogExpMath.js +418 -0
  237. package/build/dex/swaap-v1/libraries/LogExpMath.js.map +1 -0
  238. package/build/dex/swaap-v1/libraries/MathMMM.d.ts +185 -0
  239. package/build/dex/swaap-v1/libraries/MathMMM.js +453 -0
  240. package/build/dex/swaap-v1/libraries/MathMMM.js.map +1 -0
  241. package/build/dex/swaap-v1/libraries/Num.d.ts +31 -0
  242. package/build/dex/swaap-v1/libraries/Num.js +167 -0
  243. package/build/dex/swaap-v1/libraries/Num.js.map +1 -0
  244. package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +23 -0
  245. package/build/dex/swaap-v1/libraries/PoolQuotations.js +131 -0
  246. package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +1 -0
  247. package/build/dex/swaap-v1/libraries/Struct.d.ts +56 -0
  248. package/build/dex/swaap-v1/libraries/Struct.js +3 -0
  249. package/build/dex/swaap-v1/libraries/Struct.js.map +1 -0
  250. package/build/dex/swaap-v1/swaap-v1-pool.d.ts +45 -0
  251. package/build/dex/swaap-v1/swaap-v1-pool.js +656 -0
  252. package/build/dex/swaap-v1/swaap-v1-pool.js.map +1 -0
  253. package/build/dex/swaap-v1/swaap-v1.d.ts +62 -0
  254. package/build/dex/swaap-v1/swaap-v1.js +379 -0
  255. package/build/dex/swaap-v1/swaap-v1.js.map +1 -0
  256. package/build/dex/swaap-v1/types.d.ts +106 -0
  257. package/build/dex/swaap-v1/types.js +9 -0
  258. package/build/dex/swaap-v1/types.js.map +1 -0
  259. package/build/dex/zerox/index.d.ts +1 -1
  260. package/build/dex/zerox/index.js.map +1 -1
  261. package/build/dex-helper/dummy-dex-helper.js +3 -0
  262. package/build/dex-helper/dummy-dex-helper.js.map +1 -1
  263. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
  264. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
  265. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
  266. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
  267. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
  268. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
  269. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
  270. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
  271. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
  272. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
  273. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
  274. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
  275. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
  276. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
  277. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
  278. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
  279. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
  280. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
  281. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
  282. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
  283. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
  284. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
  285. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
  286. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
  287. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
  288. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
  289. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
  290. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
  291. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
  292. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
  293. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
  294. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
  295. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
  296. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
  297. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
  298. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
  299. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
  300. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
  301. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
  302. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
  303. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
  304. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
  305. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
  306. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
  307. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
  308. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
  309. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
  310. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
  311. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
  312. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
  313. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
  314. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
  315. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
  316. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
  317. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
  318. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
  319. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
  320. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
  321. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
  322. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
  323. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
  324. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
  325. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
  326. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
  327. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
  328. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
  329. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
  330. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
  331. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
  332. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
  333. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
  334. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
  335. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
  336. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
  337. package/build/lib/pub-sub.d.ts +20 -0
  338. package/build/lib/pub-sub.js +112 -4
  339. package/build/lib/pub-sub.js.map +1 -1
  340. package/package.json +2 -2
  341. package/src/abi/balancer-v3/directionalFeeHook.json +677 -677
  342. package/src/abi/balancer-v3/stableSurgeHook.json +975 -975
  343. package/src/dex/aave-v3-stata/config.ts +8 -8
  344. package/src/dex/aave-v3-stata-v2/aave-v3-stata-v2-e2e.test.ts +5 -5
  345. package/src/dex/aave-v3-stata-v2/aave-v3-stata-v2.ts +2 -2
  346. package/src/dex/aave-v3-stata-v2/config.ts +31 -24
  347. package/src/dex/aave-v3-stata-v2/types.ts +3 -2
  348. package/src/dex/aave-v3-stata-v2/utils.ts +18 -10
  349. package/src/dex/generic-rfq/generic-rfq.ts +1 -6
  350. package/src/dex/generic-rfq/rate-fetcher.ts +130 -58
  351. package/src/dex/hashflow/hashflow.ts +12 -0
  352. package/src/dex-helper/dummy-dex-helper.ts +10 -0
  353. package/src/lib/pub-sub.ts +145 -5
  354. package/tests/constants-e2e.ts +10 -0
  355. package/tests/utils-e2e.ts +0 -1
  356. package/.idea/codeStyles/Project.xml +0 -59
  357. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  358. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  359. package/.idea/modules.xml +0 -8
  360. package/.idea/paraswap-dex-lib.iml +0 -12
  361. package/.idea/prettier.xml +0 -7
  362. package/.idea/vcs.xml +0 -6
  363. package/scripts/get-uniswap-v3-dexes.ts +0 -64
@@ -17,28 +17,28 @@ import {
17
17
  export const AaveV3StataConfig: DexConfigMap<DexParams> = {
18
18
  AaveV3Stata: {
19
19
  [Network.MAINNET]: {
20
- factoryAddress: AaveV3Ethereum.STATIC_A_TOKEN_FACTORY,
20
+ factoryAddress: AaveV3Ethereum.LEGACY_STATIC_A_TOKEN_FACTORY,
21
21
  },
22
22
  [Network.POLYGON]: {
23
- factoryAddress: AaveV3Polygon.STATIC_A_TOKEN_FACTORY,
23
+ factoryAddress: AaveV3Polygon.LEGACY_STATIC_A_TOKEN_FACTORY,
24
24
  },
25
25
  [Network.AVALANCHE]: {
26
- factoryAddress: AaveV3Avalanche.STATIC_A_TOKEN_FACTORY,
26
+ factoryAddress: AaveV3Avalanche.LEGACY_STATIC_A_TOKEN_FACTORY,
27
27
  },
28
28
  [Network.ARBITRUM]: {
29
- factoryAddress: AaveV3Arbitrum.STATIC_A_TOKEN_FACTORY,
29
+ factoryAddress: AaveV3Arbitrum.LEGACY_STATIC_A_TOKEN_FACTORY,
30
30
  },
31
31
  [Network.OPTIMISM]: {
32
- factoryAddress: AaveV3Optimism.STATIC_A_TOKEN_FACTORY,
32
+ factoryAddress: AaveV3Optimism.LEGACY_STATIC_A_TOKEN_FACTORY,
33
33
  },
34
34
  [Network.BASE]: {
35
- factoryAddress: AaveV3Base.STATIC_A_TOKEN_FACTORY,
35
+ factoryAddress: AaveV3Base.LEGACY_STATIC_A_TOKEN_FACTORY,
36
36
  },
37
37
  [Network.BSC]: {
38
- factoryAddress: AaveV3BNB.STATIC_A_TOKEN_FACTORY,
38
+ factoryAddress: AaveV3BNB.LEGACY_STATIC_A_TOKEN_FACTORY,
39
39
  },
40
40
  [Network.GNOSIS]: {
41
- factoryAddress: AaveV3Gnosis.STATIC_A_TOKEN_FACTORY,
41
+ factoryAddress: AaveV3Gnosis.LEGACY_STATIC_A_TOKEN_FACTORY,
42
42
  },
43
43
  // [Network.Scroll]: {
44
44
  // factoryAddress: AaveV3Scroll.STATIC_A_TOKEN_FACTORY,
@@ -264,28 +264,28 @@ describe('AaveV3Stata E2E', () => {
264
264
  });
265
265
 
266
266
  // no tokens yet deployed
267
- describe.skip('Optimism', () => {
267
+ describe('Optimism', () => {
268
268
  const network = Network.OPTIMISM;
269
269
 
270
270
  const pairs: { name: string; amount: string; skipBuy?: boolean }[][] = [
271
271
  [
272
272
  {
273
- name: 'USDT',
273
+ name: 'USDC',
274
274
  amount: '100000',
275
275
  },
276
276
  {
277
- name: 'stataUSDT',
277
+ name: 'stataUSDC',
278
278
  amount: '100000',
279
279
  },
280
280
  ],
281
281
  [
282
282
  {
283
- name: 'aaveUSDT',
283
+ name: 'aOptUSDCn',
284
284
  amount: '100000',
285
285
  skipBuy: true,
286
286
  },
287
287
  {
288
- name: 'stataUSDT',
288
+ name: 'stataUSDC', // no holders
289
289
  amount: '100000',
290
290
  },
291
291
  ],
@@ -103,7 +103,7 @@ export class AaveV3StataV2
103
103
 
104
104
  let tokenList = await fetchTokenList(
105
105
  this.dexHelper.web3Provider,
106
- this.config.factoryAddresses,
106
+ this.config,
107
107
  this.dexHelper.multiWrapper,
108
108
  blockNumber,
109
109
  );
@@ -216,7 +216,7 @@ export class AaveV3StataV2
216
216
  true,
217
217
  [
218
218
  {
219
- target: this.config.pool,
219
+ target: stataToken.pool,
220
220
  callData: AaveV3StataV2.pool.encodeFunctionData(
221
221
  'getReserveNormalizedIncome',
222
222
  [stataToken.underlying],
@@ -12,29 +12,36 @@ import {
12
12
 
13
13
  export const AaveV3StataConfig: DexConfigMap<DexParams> = {
14
14
  AaveV3StataV2: {
15
- [Network.MAINNET]: {
16
- factoryAddresses: [
17
- AaveV3Ethereum.STATA_FACTORY,
18
- AaveV3EthereumLido.STATA_FACTORY,
19
- ],
20
- pool: AaveV3Ethereum.POOL,
21
- },
22
- [Network.GNOSIS]: {
23
- factoryAddresses: [AaveV3Gnosis.STATA_FACTORY],
24
- pool: AaveV3Gnosis.POOL,
25
- },
26
- // Waiting for BalancerV3 to get released on Optimism
27
- // [Network.OPTIMISM]: {
28
- // factoryAddresses: [AaveV3Optimism.STATA_FACTORY],
29
- // pool: AaveV3Optimism.POOL,
30
- // },
31
- [Network.ARBITRUM]: {
32
- factoryAddresses: [AaveV3Arbitrum.STATA_FACTORY],
33
- pool: AaveV3Arbitrum.POOL,
34
- },
35
- [Network.BASE]: {
36
- factoryAddresses: [AaveV3Base.STATA_FACTORY],
37
- pool: AaveV3Base.POOL,
38
- },
15
+ [Network.MAINNET]: [
16
+ { factory: AaveV3Ethereum.STATA_FACTORY, pool: AaveV3Ethereum.POOL },
17
+ {
18
+ factory: AaveV3EthereumLido.STATA_FACTORY,
19
+ pool: AaveV3EthereumLido.POOL,
20
+ },
21
+ ],
22
+ [Network.GNOSIS]: [
23
+ {
24
+ factory: AaveV3Gnosis.STATA_FACTORY,
25
+ pool: AaveV3Gnosis.POOL,
26
+ },
27
+ ],
28
+ [Network.OPTIMISM]: [
29
+ {
30
+ factory: AaveV3Optimism.STATA_FACTORY,
31
+ pool: AaveV3Optimism.POOL,
32
+ },
33
+ ],
34
+ [Network.ARBITRUM]: [
35
+ {
36
+ factory: AaveV3Arbitrum.STATA_FACTORY,
37
+ pool: AaveV3Arbitrum.POOL,
38
+ },
39
+ ],
40
+ [Network.BASE]: [
41
+ {
42
+ factory: AaveV3Base.STATA_FACTORY,
43
+ pool: AaveV3Base.POOL,
44
+ },
45
+ ],
39
46
  },
40
47
  };
@@ -8,9 +8,9 @@ export enum TokenType {
8
8
  }
9
9
 
10
10
  export type DexParams = {
11
- factoryAddresses: string[];
11
+ factory: string;
12
12
  pool: string;
13
- };
13
+ }[];
14
14
 
15
15
  export type AaveV3StataV2Data = {
16
16
  exchange: Address;
@@ -24,6 +24,7 @@ export type StataToken = {
24
24
  underlyingAToken: string;
25
25
  stataSymbol: string;
26
26
  decimals: number;
27
+ pool: string;
27
28
  };
28
29
 
29
30
  export enum StataFunctions {
@@ -6,21 +6,26 @@ import { Interface } from '@ethersproject/abi';
6
6
  import Web3 from 'web3';
7
7
  import { MultiCallParams, MultiWrapper } from '../../lib/multi-wrapper';
8
8
  import { stringDecode, uint8ToNumber, addressDecode } from '../../lib/decoders';
9
- import { StataToken } from './types';
9
+ import { StataToken, DexParams } from './types';
10
10
  import FactoryABI from '../../abi/aavev3statav2/Factory.json';
11
11
  import TokenABI from '../../abi/aavev3statav2/Token.json';
12
12
  import { AbiItem } from 'web3-utils';
13
13
 
14
+ type PoolAndToken = {
15
+ token: string;
16
+ pool: string;
17
+ };
18
+
14
19
  // const stataInterface = new Interface(IStaticATokenLM_ABI);
15
20
  const statav2Interface = new Interface(TokenABI);
16
21
 
17
22
  async function getTokenMetaData(
18
- stataTokens: string[],
23
+ stataTokens: PoolAndToken[],
19
24
  multiWrapper: MultiWrapper,
20
25
  blockNumber?: number,
21
26
  ): Promise<StataToken[]> {
22
27
  const calls: MultiCallParams<any>[] = stataTokens
23
- .map(token => {
28
+ .map(({ token }) => {
24
29
  return [
25
30
  {
26
31
  target: token,
@@ -54,7 +59,8 @@ async function getTokenMetaData(
54
59
  let tokenList: StataToken[] = [];
55
60
  for (let i = 0, x = 0; i < stataTokens.length; ++i, x += 4) {
56
61
  tokenList.push({
57
- address: stataTokens[i].toLowerCase(),
62
+ address: stataTokens[i].token.toLowerCase(),
63
+ pool: stataTokens[i].pool.toLowerCase(),
58
64
  stataSymbol: results[x] as string,
59
65
  decimals: results[x + 1] as number,
60
66
  underlying: (results[x + 2] as string).toLowerCase(),
@@ -66,22 +72,24 @@ async function getTokenMetaData(
66
72
 
67
73
  export const fetchTokenList = async (
68
74
  web3Provider: Web3,
69
- factoryAddresses: string[],
75
+ config: DexParams,
70
76
  multiWrapper: MultiWrapper,
71
77
  blockNumber?: number,
72
78
  ): Promise<StataToken[]> => {
73
- let stataList: string[] = (
79
+ let stataList: PoolAndToken[] = (
74
80
  (await Promise.all(
75
- factoryAddresses.map(async factoryAddress => {
81
+ config.map(async ({ factory, pool }) => {
76
82
  let factoryContract = new web3Provider.eth.Contract(
77
83
  FactoryABI as AbiItem[],
78
84
  // IStaticATokenFactory_ABI as any,
79
- factoryAddress,
85
+ factory,
80
86
  );
81
87
 
82
- return await factoryContract.methods.getStataTokens().call();
88
+ return (
89
+ (await factoryContract.methods.getStataTokens().call()) as string[]
90
+ ).map(address => ({ token: address, pool }));
83
91
  }),
84
- )) as string[][]
92
+ )) as PoolAndToken[][]
85
93
  ).flat();
86
94
 
87
95
  return getTokenMetaData(stataList, multiWrapper, blockNumber);
@@ -447,12 +447,7 @@ export class GenericRFQ extends ParaSwapLimitOrders {
447
447
  }
448
448
 
449
449
  async setBlacklist(userAddress: string): Promise<boolean> {
450
- await this.dexHelper.cache.hset(
451
- this.rateFetcher.blackListCacheKey,
452
- userAddress.toLowerCase(),
453
- 'true',
454
- );
455
- return true;
450
+ return this.rateFetcher.setBlacklist(userAddress);
456
451
  }
457
452
 
458
453
  releaseResources(): void {
@@ -37,6 +37,7 @@ import {
37
37
  ERC1271Contract,
38
38
  } from '../../lib/erc1271-utils';
39
39
  import { isContractAddress } from '../../utils';
40
+ import { ExpKeyValuePubSub, NonExpSetPubSub } from '../../lib/pub-sub';
40
41
 
41
42
  const GET_FIRM_RATE_TIMEOUT_MS = 2000;
42
43
  export const reversePrice = (price: PriceAndAmountBigNumber) =>
@@ -55,6 +56,9 @@ export class RateFetcher {
55
56
  private addressToTokenMap: Record<string, TokenWithInfo> = {};
56
57
  private pairs: PairMap = {};
57
58
 
59
+ private pricesPubSub: ExpKeyValuePubSub;
60
+ private blacklistPubSub?: NonExpSetPubSub;
61
+
58
62
  private firmRateAuth?: (options: RequestConfig) => void;
59
63
 
60
64
  public blackListCacheKey: string;
@@ -123,6 +127,13 @@ export class RateFetcher {
123
127
  logger,
124
128
  );
125
129
 
130
+ this.pricesPubSub = new ExpKeyValuePubSub(
131
+ this.dexHelper,
132
+ this.dexKey,
133
+ 'prices',
134
+ );
135
+
136
+ this.blackListCacheKey = `${this.dexHelper.config.data.network}_${this.dexKey}_blacklist`;
126
137
  if (config.blacklistConfig) {
127
138
  this.blackListFetcher = new Fetcher<BlackListResponse>(
128
139
  dexHelper.httpRequest,
@@ -142,9 +153,14 @@ export class RateFetcher {
142
153
  config.blacklistConfig.intervalMs,
143
154
  logger,
144
155
  );
156
+
157
+ this.blacklistPubSub = new NonExpSetPubSub(
158
+ this.dexHelper,
159
+ this.dexKey,
160
+ 'blacklist',
161
+ );
145
162
  }
146
163
 
147
- this.blackListCacheKey = `${this.dexHelper.config.data.network}_${this.dexKey}_blacklist`;
148
164
  if (this.config.firmRateConfig.secret) {
149
165
  this.firmRateAuth = this.authHttp(this.config.firmRateConfig.secret);
150
166
  }
@@ -161,6 +177,30 @@ export class RateFetcher {
161
177
  this.config.maker,
162
178
  );
163
179
  }
180
+
181
+ this.logger.info(
182
+ `Initializing RateFetcher for ${this.dexKey}, isSlave=${this.dexHelper.config.isSlave}`,
183
+ );
184
+
185
+ if (this.dexHelper.config.isSlave) {
186
+ this.logger.info(
187
+ `Subscribing to price updates as slave for ${this.dexKey}`,
188
+ );
189
+ this.pricesPubSub.subscribe();
190
+ if (this.blacklistPubSub) {
191
+ const initSet = await this.dexHelper.cache.smembers(
192
+ this.blackListCacheKey,
193
+ );
194
+ this.logger.info(
195
+ `Initializing blacklist with ${initSet.length} entries`,
196
+ );
197
+ this.blacklistPubSub.initializeAndSubscribe(initSet);
198
+ }
199
+ } else {
200
+ this.logger.info(
201
+ `Not subscribing to price updates as master for ${this.dexKey}`,
202
+ );
203
+ }
164
204
  }
165
205
 
166
206
  start() {
@@ -214,74 +254,110 @@ export class RateFetcher {
214
254
  for (const address of resp.blacklist) {
215
255
  this.dexHelper.cache.sadd(this.blackListCacheKey, address.toLowerCase());
216
256
  }
257
+
258
+ if (this.blacklistPubSub) {
259
+ this.blacklistPubSub.publish(resp.blacklist);
260
+ }
217
261
  }
218
262
 
219
263
  public isBlackListed(userAddress: string) {
220
- return this.dexHelper.cache.sismember(
221
- this.blackListCacheKey,
222
- userAddress.toLowerCase(),
223
- );
264
+ if (this.blacklistPubSub) {
265
+ return this.blacklistPubSub.has(userAddress.toLowerCase());
266
+ }
267
+ return false;
224
268
  }
225
269
 
226
270
  private handleRatesResponse(resp: RatesResponse) {
271
+ const pubSubData: Record<string, unknown> = {};
272
+ const ttl = this.config.rateConfig.dataTTLS;
227
273
  const pairs = this.pairs;
228
274
 
229
- if (isEmpty(pairs)) return;
275
+ if (isEmpty(pairs)) {
276
+ this.logger.debug(`No pairs available for ${this.dexKey}`);
277
+ return;
278
+ }
230
279
 
231
280
  const currentPricePairs = new Set();
281
+ let updatedPairsCount = 0;
232
282
 
233
283
  Object.keys(resp.prices).forEach(pairName => {
234
284
  const pair = pairs[pairName];
235
285
  if (!pair) {
286
+ this.logger.debug(`Pair ${pairName} not found in available pairs`);
236
287
  return;
237
288
  }
238
289
  const prices = resp.prices[pairName];
239
290
 
240
291
  if (!prices.asks || !prices.bids) {
292
+ this.logger.debug(`No asks or bids for pair ${pairName}`);
241
293
  return;
242
294
  }
243
295
 
244
- if (isEmpty(this.tokens)) return;
296
+ if (isEmpty(this.tokens)) {
297
+ this.logger.debug(`No tokens available for ${this.dexKey}`);
298
+ return;
299
+ }
245
300
 
246
301
  const baseToken = this.tokens[pair.base];
247
302
  const quoteToken = this.tokens[pair.quote];
248
303
 
249
304
  if (!baseToken || !quoteToken) {
250
- this.logger.warn(`missing base or quote token`);
305
+ this.logger.warn(`Missing base or quote token for pair ${pairName}`);
251
306
  return;
252
307
  }
253
308
 
254
309
  if (prices.bids.length) {
310
+ const key = `${baseToken.address}_${quoteToken.address}_bids`;
311
+ const value = prices.bids;
312
+ pubSubData[key] = value;
313
+ updatedPairsCount++;
314
+
255
315
  this.dexHelper.cache.setex(
256
316
  this.dexKey,
257
317
  this.dexHelper.config.data.network,
258
- `${baseToken.address}_${quoteToken.address}_bids`,
259
- this.config.rateConfig.dataTTLS,
260
- JSON.stringify(prices.bids),
318
+ key,
319
+ ttl,
320
+ JSON.stringify(value),
261
321
  );
262
322
  currentPricePairs.add(`${baseToken.address}_${quoteToken.address}`);
263
323
  }
264
324
 
265
325
  if (prices.asks.length) {
326
+ const key = `${baseToken.address}_${quoteToken.address}_asks`;
327
+ const value = prices.asks;
328
+ pubSubData[key] = value;
329
+ updatedPairsCount++;
330
+
266
331
  this.dexHelper.cache.setex(
267
332
  this.dexKey,
268
333
  this.dexHelper.config.data.network,
269
- `${baseToken.address}_${quoteToken.address}_asks`,
270
- this.config.rateConfig.dataTTLS,
271
- JSON.stringify(prices.asks),
334
+ key,
335
+ ttl,
336
+ JSON.stringify(value),
272
337
  );
273
338
  currentPricePairs.add(`${quoteToken.address}_${baseToken.address}`);
274
339
  }
275
340
  });
276
341
 
277
342
  if (currentPricePairs.size > 0) {
343
+ const key = `pairs`;
344
+ const value = Array.from(currentPricePairs);
345
+ pubSubData[key] = value;
346
+
278
347
  this.dexHelper.cache.setex(
279
348
  this.dexKey,
280
349
  this.dexHelper.config.data.network,
281
- `pairs`,
282
- this.config.rateConfig.dataTTLS,
283
- JSON.stringify(Array.from(currentPricePairs)),
350
+ key,
351
+ ttl,
352
+ JSON.stringify(value),
353
+ );
354
+
355
+ this.logger.info(
356
+ `Updated ${updatedPairsCount} price entries for ${currentPricePairs.size} pairs`,
284
357
  );
358
+ this.pricesPubSub.publish(pubSubData, ttl);
359
+ } else {
360
+ this.logger.warn(`No price pairs were updated for ${this.dexKey}`);
285
361
  }
286
362
  }
287
363
 
@@ -322,18 +398,12 @@ export class RateFetcher {
322
398
  }
323
399
 
324
400
  public async getAvailablePairs(): Promise<string[]> {
325
- const pairs = await this.dexHelper.cache.getAndCacheLocally(
326
- this.dexKey,
327
- this.dexHelper.config.data.network,
328
- `pairs`,
329
- this.config.rateConfig.intervalMs / 1000,
330
- );
331
-
401
+ const pairs = await this.pricesPubSub.getAndCache<string[]>(`pairs`);
332
402
  if (!pairs) {
333
403
  return [];
334
404
  }
335
405
 
336
- return JSON.parse(pairs) as string[];
406
+ return pairs;
337
407
  }
338
408
 
339
409
  public async getOrderPrice(
@@ -342,54 +412,44 @@ export class RateFetcher {
342
412
  side: SwapSide,
343
413
  ): Promise<PriceAndAmountBigNumber[] | null> {
344
414
  let reversed = false;
415
+ const srcAddress = srcToken.address.toLowerCase();
416
+ const destAddress = destToken.address.toLowerCase();
417
+
418
+ let prices: PriceAndAmount[] | null = null;
419
+ let cacheKey = '';
345
420
 
346
- let pricesAsString: string | null = null;
347
421
  if (side === SwapSide.SELL) {
348
- pricesAsString = await this.dexHelper.cache.getAndCacheLocally(
349
- this.dexKey,
350
- this.dexHelper.config.data.network,
351
- `${srcToken.address}_${destToken.address}_bids`,
352
- this.config.rateConfig.intervalMs / 1000,
353
- );
422
+ cacheKey = `${srcAddress}_${destAddress}_bids`;
423
+ prices = await this.pricesPubSub.getAndCache(cacheKey);
354
424
 
355
- if (!pricesAsString) {
356
- pricesAsString = await this.dexHelper.cache.getAndCacheLocally(
357
- this.dexKey,
358
- this.dexHelper.config.data.network,
359
- `${destToken.address}_${srcToken.address}_asks`,
360
- this.config.rateConfig.intervalMs / 1000,
361
- );
425
+ if (!prices) {
426
+ cacheKey = `${destAddress}_${srcAddress}_asks`;
427
+ prices = await this.pricesPubSub.getAndCache(cacheKey);
362
428
  reversed = true;
363
429
  }
364
430
  } else {
365
- pricesAsString = await this.dexHelper.cache.getAndCacheLocally(
366
- this.dexKey,
367
- this.dexHelper.config.data.network,
368
- `${destToken.address}_${srcToken.address}_asks`,
369
- this.config.rateConfig.intervalMs / 1000,
370
- );
431
+ cacheKey = `${destAddress}_${srcAddress}_asks`;
432
+ prices = await this.pricesPubSub.getAndCache(cacheKey);
371
433
 
372
- if (!pricesAsString) {
373
- pricesAsString = await this.dexHelper.cache.getAndCacheLocally(
374
- this.dexKey,
375
- this.dexHelper.config.data.network,
376
- `${srcToken.address}_${destToken.address}_bids`,
377
- this.config.rateConfig.intervalMs / 1000,
378
- );
434
+ if (!prices) {
435
+ cacheKey = `${srcAddress}_${destAddress}_bids`;
436
+ prices = await this.pricesPubSub.getAndCache(cacheKey);
379
437
  reversed = true;
380
438
  }
381
439
  }
382
440
 
383
- if (!pricesAsString) {
441
+ if (!prices) {
442
+ this.logger.debug(
443
+ `No prices found for ${srcAddress} to ${destAddress} (${side}) using key ${cacheKey}`,
444
+ );
384
445
  return null;
385
446
  }
386
447
 
387
- const orderPricesAsString: PriceAndAmount[] = JSON.parse(pricesAsString);
388
- if (!orderPricesAsString) {
389
- return null;
390
- }
448
+ this.logger.debug(
449
+ `Found ${prices.length} prices for ${srcAddress} to ${destAddress} (${side}), reversed=${reversed}`,
450
+ );
391
451
 
392
- let orderPrices = orderPricesAsString.map(price => [
452
+ let orderPrices = prices.map(price => [
393
453
  new BigNumber(price[0]),
394
454
  new BigNumber(price[1]),
395
455
  ]);
@@ -488,4 +548,16 @@ export class RateFetcher {
488
548
  throw e;
489
549
  }
490
550
  }
551
+
552
+ async setBlacklist(userAddress: string): Promise<boolean> {
553
+ await this.dexHelper.cache.hset(
554
+ this.blackListCacheKey,
555
+ userAddress.toLowerCase(),
556
+ 'true',
557
+ );
558
+ if (this.blacklistPubSub) {
559
+ this.blacklistPubSub.publish([userAddress.toLowerCase()]);
560
+ }
561
+ return true;
562
+ }
491
563
  }
@@ -191,6 +191,9 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
191
191
  side: SwapSide,
192
192
  blockNumber: number,
193
193
  ): Promise<string[]> {
194
+ this.logger.debug(
195
+ `Getting pool identifiers for ${srcToken.address} to ${destToken.address} (${side}) for ${this.dexKey}-${this.network}`,
196
+ );
194
197
  const _srcToken = this.dexHelper.config.wrapETH(srcToken);
195
198
  const _destToken = this.dexHelper.config.wrapETH(destToken);
196
199
 
@@ -398,6 +401,9 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
398
401
  }
399
402
 
400
403
  async getCachedLevels(): Promise<PriceLevelsResponse['levels'] | null> {
404
+ this.logger.debug(
405
+ `Getting cached levels for ${this.pricesCacheKey} for ${this.dexKey}-${this.network}`,
406
+ );
401
407
  const cachedLevels = await this.dexHelper.cache.rawget(this.pricesCacheKey);
402
408
 
403
409
  if (cachedLevels) {
@@ -416,6 +422,11 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
416
422
  limitPools?: string[],
417
423
  ): Promise<null | ExchangePrices<HashflowData>> {
418
424
  try {
425
+ this.logger.debug(
426
+ `Getting prices volume for ${srcToken.symbol || srcToken.address}, ${
427
+ destToken.symbol || destToken.address
428
+ }, ${side} for ${this.dexKey}-${this.network}`,
429
+ );
419
430
  const _srcToken = this.dexHelper.config.wrapETH(srcToken);
420
431
  const _destToken = this.dexHelper.config.wrapETH(destToken);
421
432
 
@@ -916,6 +927,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
916
927
  }
917
928
 
918
929
  async isBlacklisted(txOrigin: Address): Promise<boolean> {
930
+ this.logger.debug(`Checking if ${txOrigin} is blacklisted for Hashflow`);
919
931
  const result = await this.dexHelper.cache.get(
920
932
  this.dexKey,
921
933
  this.network,
@@ -329,6 +329,7 @@ export class DummyDexHelper implements IDexHelper {
329
329
  rpcUrl ? rpcUrl : this.config.data.privateHttpProvider,
330
330
  network,
331
331
  );
332
+
332
333
  this.web3Provider = new Web3(
333
334
  rpcUrl ? rpcUrl : this.config.data.privateHttpProvider,
334
335
  );
@@ -365,5 +366,14 @@ export class DummyDexHelper implements IDexHelper {
365
366
 
366
367
  replaceProviderWithRPC(rpcUrl: string) {
367
368
  this.provider = new StaticJsonRpcProvider(rpcUrl, this.config.data.network);
369
+ this.web3Provider = new Web3(rpcUrl);
370
+ this.multiContract = new this.web3Provider.eth.Contract(
371
+ multiABIV2 as any,
372
+ this.config.data.multicallV2Address,
373
+ );
374
+ this.multiWrapper = new MultiWrapper(
375
+ this.multiContract,
376
+ this.getLogger(`MultiWrapper-${this.config.data.network}`),
377
+ );
368
378
  }
369
379
  }