@paraswap/dex-lib 4.1.7-mwrappedm.4 → 4.1.7-pub-sub.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 (271) 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/{integral/relayer.json → RamsesV2Pool.abi.json} +850 -832
  5. package/build/abi/RamsesV2Quoter.abi.json +274 -0
  6. package/build/abi/USDM.json +807 -0
  7. package/build/abi/UniswapV2Router.json +397 -0
  8. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
  9. package/build/abi/{integral/oracle.json → angle-transmuter/ChainlinkEACAggregatorProxy.json} +247 -239
  10. package/build/abi/curve-v1/CurveBUSDv2.abi.json +1356 -0
  11. package/build/abi/curve-v1/CurveTokenV1.json +305 -0
  12. package/build/abi/curve-v1/CurveTokenV2.json +318 -0
  13. package/build/abi/curve-v1/CurveV1StableNg.json +1452 -0
  14. package/build/abi/curve-v1/CurveV2Swap.json +700 -0
  15. package/build/abi/curve-v1/FactoryCryptoRegistry.json +316 -0
  16. package/build/abi/curve-v1/FactoryRegistry.json +508 -0
  17. package/build/abi/curve-v1/StableSwapAave.json +1152 -0
  18. package/build/abi/curve-v1/StableSwapBUSD.json +814 -0
  19. package/build/abi/curve-v1/StableSwapCompound.json +814 -0
  20. package/build/abi/curve-v1/StableSwapIDLE.json +1253 -0
  21. package/build/abi/curve-v1/StableSwapPax.json +865 -0
  22. package/build/abi/curve-v1/StableSwapSnow.json +900 -0
  23. package/build/abi/{integral/pool.json → curve-v1/StableSwapUSDN.json} +450 -487
  24. package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
  25. package/build/abi/curve-v1/StableSwapY.json +814 -0
  26. package/build/abi/inception/inception-ineth-pool.json +1062 -0
  27. package/build/abi/inception/inception-ineth.json +609 -0
  28. package/build/abi/inception/inception-ratio-feed.json +329 -0
  29. package/build/abi/inception/inception-vault.json +991 -0
  30. package/build/abi/kyberdmm/kyber-storage.abi.json +824 -0
  31. package/build/abi/kyberdmm.abi.json +1148 -0
  32. package/build/abi/maverick-v2/MaverickV2Quoter.json +278 -0
  33. package/build/abi/nerve/nerve-metapool.json +790 -0
  34. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
  35. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
  36. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  37. package/build/dex/aave-v1/aave-v1.js +22 -0
  38. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  39. package/build/dex/balancer-v1/balancer-pools.json +33333 -0
  40. package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
  41. package/build/dex/bebop/websocket-fetcher.js +87 -0
  42. package/build/dex/bebop/websocket-fetcher.js.map +1 -0
  43. package/build/dex/generic-rfq/generic-rfq.js +1 -2
  44. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  45. package/build/dex/generic-rfq/rate-fetcher.d.ts +4 -1
  46. package/build/dex/generic-rfq/rate-fetcher.js +65 -20
  47. package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
  48. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  49. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  50. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  51. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  52. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  53. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  54. package/build/dex/idle-dao/scripts.d.ts +9 -0
  55. package/build/dex/idle-dao/scripts.js +552 -0
  56. package/build/dex/idle-dao/scripts.js.map +1 -0
  57. package/build/dex/inception/config.d.ts +4 -0
  58. package/build/dex/inception/config.js +109 -0
  59. package/build/dex/inception/config.js.map +1 -0
  60. package/build/dex/inception/inception-event-pool.d.ts +16 -0
  61. package/build/dex/inception/inception-event-pool.js +51 -0
  62. package/build/dex/inception/inception-event-pool.js.map +1 -0
  63. package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
  64. package/build/dex/inception/inception-native.js +131 -0
  65. package/build/dex/inception/inception-native.js.map +1 -0
  66. package/build/dex/inception/inception-pool.d.ts +18 -0
  67. package/build/dex/inception/inception-pool.js +32 -0
  68. package/build/dex/inception/inception-pool.js.map +1 -0
  69. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  70. package/build/dex/inception/inception-price-feed.js +51 -0
  71. package/build/dex/inception/inception-price-feed.js.map +1 -0
  72. package/build/dex/inception/inception.d.ts +43 -0
  73. package/build/dex/inception/inception.js +204 -0
  74. package/build/dex/inception/inception.js.map +1 -0
  75. package/build/dex/inception/tokens.d.ts +9 -0
  76. package/build/dex/inception/tokens.js +28 -0
  77. package/build/dex/inception/tokens.js.map +1 -0
  78. package/build/dex/inception/types.d.ts +22 -0
  79. package/build/dex/{m-token → inception}/types.js.map +1 -1
  80. package/build/dex/inception/utils.d.ts +6 -0
  81. package/build/dex/inception/utils.js +37 -0
  82. package/build/dex/inception/utils.js.map +1 -0
  83. package/build/dex/jarvis.d.ts +2 -1
  84. package/build/dex/jarvis.js +58 -0
  85. package/build/dex/jarvis.js.map +1 -1
  86. package/build/dex/platypus/platypus.d.ts +2 -1
  87. package/build/dex/platypus/platypus.js +31 -0
  88. package/build/dex/platypus/platypus.js.map +1 -1
  89. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  90. package/build/dex/swaap-v1/swaap-v1.js +10 -0
  91. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  92. package/build/dex/zerox/index.d.ts +4 -26
  93. package/build/dex/zerox/index.js +50 -42
  94. package/build/dex/zerox/index.js.map +1 -1
  95. package/build/dex/zerox/types.d.ts +29 -0
  96. package/build/dex/zerox/types.js +8 -1
  97. package/build/dex/zerox/types.js.map +1 -1
  98. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
  99. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
  100. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
  101. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
  102. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
  103. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
  104. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
  105. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
  106. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
  107. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
  108. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
  109. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
  110. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
  111. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
  112. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
  113. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
  114. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
  115. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
  116. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
  117. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
  118. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
  119. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
  120. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
  121. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
  122. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
  123. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
  124. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
  125. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
  126. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
  127. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
  128. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
  129. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
  130. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
  131. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
  132. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
  133. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
  134. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
  135. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
  136. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
  137. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
  138. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
  139. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
  140. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
  141. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
  142. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
  143. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
  144. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
  145. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
  146. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
  147. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
  148. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
  149. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
  150. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
  151. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
  152. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
  153. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
  154. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
  155. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
  156. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
  157. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
  158. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
  159. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
  160. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
  161. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
  162. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
  163. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
  164. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
  165. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
  166. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
  167. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
  168. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
  169. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
  170. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
  171. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
  172. package/build/lib/pub-sub.d.ts +17 -0
  173. package/build/lib/pub-sub.js +84 -4
  174. package/build/lib/pub-sub.js.map +1 -1
  175. package/package.json +1 -1
  176. package/src/abi/balancer-v3/directionalFeeHook.json +677 -677
  177. package/src/abi/balancer-v3/stableSurgeHook.json +975 -975
  178. package/src/dex/generic-rfq/generic-rfq.ts +1 -6
  179. package/src/dex/generic-rfq/rate-fetcher.ts +112 -47
  180. package/src/lib/pub-sub.ts +111 -3
  181. package/.idea/aws.xml +0 -17
  182. package/.idea/codeStyles/Project.xml +0 -19
  183. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  184. package/.idea/misc.xml +0 -6
  185. package/.idea/modules.xml +0 -8
  186. package/.idea/paraswap-dex-lib.iml +0 -9
  187. package/.idea/prettier.xml +0 -7
  188. package/.idea/vcs.xml +0 -6
  189. package/build/abi/integral/factory.json +0 -333
  190. package/build/dex/bProtocol.d.ts +0 -18
  191. package/build/dex/bProtocol.js +0 -39
  192. package/build/dex/bProtocol.js.map +0 -1
  193. package/build/dex/bancor.d.ts +0 -26
  194. package/build/dex/bancor.js +0 -58
  195. package/build/dex/bancor.js.map +0 -1
  196. package/build/dex/compound.d.ts +0 -18
  197. package/build/dex/compound.js +0 -46
  198. package/build/dex/compound.js.map +0 -1
  199. package/build/dex/curve-v2.d.ts +0 -58
  200. package/build/dex/curve-v2.js +0 -180
  201. package/build/dex/curve-v2.js.map +0 -1
  202. package/build/dex/dodo-v1.d.ts +0 -33
  203. package/build/dex/dodo-v1.js +0 -63
  204. package/build/dex/dodo-v1.js.map +0 -1
  205. package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
  206. package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
  207. package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
  208. package/build/dex/integral/config.d.ts +0 -4
  209. package/build/dex/integral/config.js +0 -20
  210. package/build/dex/integral/config.js.map +0 -1
  211. package/build/dex/integral/context.d.ts +0 -40
  212. package/build/dex/integral/context.js +0 -158
  213. package/build/dex/integral/context.js.map +0 -1
  214. package/build/dex/integral/integral-factory.d.ts +0 -24
  215. package/build/dex/integral/integral-factory.js +0 -95
  216. package/build/dex/integral/integral-factory.js.map +0 -1
  217. package/build/dex/integral/integral-pool.d.ts +0 -50
  218. package/build/dex/integral/integral-pool.js +0 -149
  219. package/build/dex/integral/integral-pool.js.map +0 -1
  220. package/build/dex/integral/integral-pricing.d.ts +0 -18
  221. package/build/dex/integral/integral-pricing.js +0 -114
  222. package/build/dex/integral/integral-pricing.js.map +0 -1
  223. package/build/dex/integral/integral-relayer.d.ts +0 -42
  224. package/build/dex/integral/integral-relayer.js +0 -192
  225. package/build/dex/integral/integral-relayer.js.map +0 -1
  226. package/build/dex/integral/integral-token.d.ts +0 -27
  227. package/build/dex/integral/integral-token.js +0 -59
  228. package/build/dex/integral/integral-token.js.map +0 -1
  229. package/build/dex/integral/integral.js +0 -376
  230. package/build/dex/integral/integral.js.map +0 -1
  231. package/build/dex/integral/types.d.ts +0 -85
  232. package/build/dex/integral/types.js +0 -9
  233. package/build/dex/integral/types.js.map +0 -1
  234. package/build/dex/integral/utils-e2e.d.ts +0 -9
  235. package/build/dex/integral/utils-e2e.js +0 -131
  236. package/build/dex/integral/utils-e2e.js.map +0 -1
  237. package/build/dex/integral/utils.d.ts +0 -17
  238. package/build/dex/integral/utils.js +0 -94
  239. package/build/dex/integral/utils.js.map +0 -1
  240. package/build/dex/lido.d.ts +0 -19
  241. package/build/dex/lido.js +0 -42
  242. package/build/dex/lido.js.map +0 -1
  243. package/build/dex/m-token/config.d.ts +0 -3
  244. package/build/dex/m-token/config.js +0 -19
  245. package/build/dex/m-token/config.js.map +0 -1
  246. package/build/dex/m-token/m-token.d.ts +0 -29
  247. package/build/dex/m-token/m-token.js +0 -145
  248. package/build/dex/m-token/m-token.js.map +0 -1
  249. package/build/dex/m-token/m-wrapped-m.d.ts +0 -17
  250. package/build/dex/m-token/m-wrapped-m.js +0 -50
  251. package/build/dex/m-token/m-wrapped-m.js.map +0 -1
  252. package/build/dex/m-token/types.d.ts +0 -12
  253. package/build/dex/onebit.d.ts +0 -25
  254. package/build/dex/onebit.js +0 -42
  255. package/build/dex/onebit.js.map +0 -1
  256. package/build/dex/smoothy.d.ts +0 -26
  257. package/build/dex/smoothy.js +0 -48
  258. package/build/dex/smoothy.js.map +0 -1
  259. package/build/dex/stable-pool.d.ts +0 -28
  260. package/build/dex/stable-pool.js +0 -62
  261. package/build/dex/stable-pool.js.map +0 -1
  262. package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
  263. package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
  264. package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
  265. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
  266. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
  267. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
  268. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  269. package/build/dex/trader-joe-v2.1.js +0 -79
  270. package/build/dex/trader-joe-v2.1.js.map +0 -1
  271. /package/build/dex/{m-token → inception}/types.js +0 -0
@@ -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) =>
@@ -45,6 +46,7 @@ export const reversePrice = (price: PriceAndAmountBigNumber) =>
45
46
  price[1].times(price[0]),
46
47
  ] as PriceAndAmountBigNumber;
47
48
 
49
+ const logPrefix = 'RateFetched[pub_sub]';
48
50
  export class RateFetcher {
49
51
  private tokensFetcher: Fetcher<TokensResponse>;
50
52
  private pairsFetcher: Fetcher<PairsResponse>;
@@ -55,6 +57,9 @@ export class RateFetcher {
55
57
  private addressToTokenMap: Record<string, TokenWithInfo> = {};
56
58
  private pairs: PairMap = {};
57
59
 
60
+ private pricesPubSub: ExpKeyValuePubSub;
61
+ private blacklistPubSub?: NonExpSetPubSub;
62
+
58
63
  private firmRateAuth?: (options: RequestConfig) => void;
59
64
 
60
65
  public blackListCacheKey: string;
@@ -123,6 +128,13 @@ export class RateFetcher {
123
128
  logger,
124
129
  );
125
130
 
131
+ this.pricesPubSub = new ExpKeyValuePubSub(
132
+ this.dexHelper,
133
+ this.dexKey,
134
+ 'prices',
135
+ );
136
+
137
+ this.blackListCacheKey = `${this.dexHelper.config.data.network}_${this.dexKey}_blacklist`;
126
138
  if (config.blacklistConfig) {
127
139
  this.blackListFetcher = new Fetcher<BlackListResponse>(
128
140
  dexHelper.httpRequest,
@@ -142,15 +154,21 @@ export class RateFetcher {
142
154
  config.blacklistConfig.intervalMs,
143
155
  logger,
144
156
  );
157
+
158
+ this.blacklistPubSub = new NonExpSetPubSub(
159
+ this.dexHelper,
160
+ this.dexKey,
161
+ 'blacklist',
162
+ );
145
163
  }
146
164
 
147
- this.blackListCacheKey = `${this.dexHelper.config.data.network}_${this.dexKey}_blacklist`;
148
165
  if (this.config.firmRateConfig.secret) {
149
166
  this.firmRateAuth = this.authHttp(this.config.firmRateConfig.secret);
150
167
  }
151
168
  }
152
169
 
153
170
  async initialize() {
171
+ this.logger.info(`${logPrefix} Initializing rate fetcher`);
154
172
  const isContract = await isContractAddress(
155
173
  this.dexHelper.web3Provider,
156
174
  this.config.maker,
@@ -161,9 +179,22 @@ export class RateFetcher {
161
179
  this.config.maker,
162
180
  );
163
181
  }
182
+
183
+ if (this.dexHelper.config.isSlave) {
184
+ this.logger.info(`${logPrefix} Subscribing to prices pubsub`);
185
+ this.pricesPubSub.subscribe();
186
+ if (this.blacklistPubSub) {
187
+ this.logger.info(`${logPrefix} Subscribing to blacklist pubsub`);
188
+ const initSet = await this.dexHelper.cache.smembers(
189
+ this.blackListCacheKey,
190
+ );
191
+ this.blacklistPubSub.initializeAndSubscribe(initSet);
192
+ }
193
+ }
164
194
  }
165
195
 
166
196
  start() {
197
+ this.logger.info(`${logPrefix} Starting rate fetcher`);
167
198
  this.tokensFetcher.startPolling();
168
199
  this.rateFetcher.startPolling();
169
200
  this.pairsFetcher.startPolling();
@@ -173,6 +204,7 @@ export class RateFetcher {
173
204
  }
174
205
 
175
206
  stop() {
207
+ this.logger.info(`${logPrefix} Stopping rate fetcher`);
176
208
  this.tokensFetcher.stopPolling();
177
209
  this.pairsFetcher.stopPolling();
178
210
  this.rateFetcher.stopPolling();
@@ -183,6 +215,10 @@ export class RateFetcher {
183
215
  }
184
216
 
185
217
  private handleTokensResponse(data: TokensResponse) {
218
+ this.logger.info(
219
+ `${logPrefix} Handling tokens response, tokens: `,
220
+ Object.keys(data.tokens).length,
221
+ );
186
222
  for (const tokenName of Object.keys(data.tokens)) {
187
223
  const token = data.tokens[tokenName];
188
224
  token.address = token.address.toLowerCase();
@@ -200,6 +236,10 @@ export class RateFetcher {
200
236
  }
201
237
 
202
238
  private handlePairsResponse(resp: PairsResponse) {
239
+ this.logger.info(
240
+ `${logPrefix} Handling pairs response, pairs: `,
241
+ Object.keys(resp.pairs).length,
242
+ );
203
243
  this.pairs = {};
204
244
 
205
245
  const pairs: PairMap = {};
@@ -211,19 +251,37 @@ export class RateFetcher {
211
251
  }
212
252
 
213
253
  private handleBlackListResponse(resp: BlackListResponse) {
254
+ this.logger.info(
255
+ `${logPrefix} Handling blacklist response, blacklist length: `,
256
+ resp.blacklist.length,
257
+ );
214
258
  for (const address of resp.blacklist) {
215
259
  this.dexHelper.cache.sadd(this.blackListCacheKey, address.toLowerCase());
216
260
  }
261
+
262
+ if (this.blacklistPubSub) {
263
+ this.logger.info(
264
+ `${logPrefix} Publishing blacklist to pubsub, blacklist length: `,
265
+ resp.blacklist.length,
266
+ );
267
+ this.blacklistPubSub.publish(resp.blacklist);
268
+ }
217
269
  }
218
270
 
219
271
  public isBlackListed(userAddress: string) {
220
- return this.dexHelper.cache.sismember(
221
- this.blackListCacheKey,
222
- userAddress.toLowerCase(),
223
- );
272
+ if (this.blacklistPubSub) {
273
+ return this.blacklistPubSub.has(userAddress.toLowerCase());
274
+ }
275
+ return false;
224
276
  }
225
277
 
226
278
  private handleRatesResponse(resp: RatesResponse) {
279
+ this.logger.info(
280
+ `${logPrefix} Handling rates response, prices length: `,
281
+ Object.keys(resp.prices).length,
282
+ );
283
+ const pubSubData: Record<string, unknown> = {};
284
+ const ttl = this.config.rateConfig.dataTTLS;
227
285
  const pairs = this.pairs;
228
286
 
229
287
  if (isEmpty(pairs)) return;
@@ -252,37 +310,51 @@ export class RateFetcher {
252
310
  }
253
311
 
254
312
  if (prices.bids.length) {
313
+ const key = `${baseToken.address}_${quoteToken.address}_bids`;
314
+ const value = prices.bids;
315
+ pubSubData[key] = value;
316
+
255
317
  this.dexHelper.cache.setex(
256
318
  this.dexKey,
257
319
  this.dexHelper.config.data.network,
258
- `${baseToken.address}_${quoteToken.address}_bids`,
259
- this.config.rateConfig.dataTTLS,
260
- JSON.stringify(prices.bids),
320
+ key,
321
+ ttl,
322
+ JSON.stringify(value),
261
323
  );
262
324
  currentPricePairs.add(`${baseToken.address}_${quoteToken.address}`);
263
325
  }
264
326
 
265
327
  if (prices.asks.length) {
328
+ const key = `${baseToken.address}_${quoteToken.address}_asks`;
329
+ const value = prices.asks;
330
+ pubSubData[key] = value;
331
+
266
332
  this.dexHelper.cache.setex(
267
333
  this.dexKey,
268
334
  this.dexHelper.config.data.network,
269
- `${baseToken.address}_${quoteToken.address}_asks`,
270
- this.config.rateConfig.dataTTLS,
271
- JSON.stringify(prices.asks),
335
+ key,
336
+ ttl,
337
+ JSON.stringify(value),
272
338
  );
273
339
  currentPricePairs.add(`${quoteToken.address}_${baseToken.address}`);
274
340
  }
275
341
  });
276
342
 
277
343
  if (currentPricePairs.size > 0) {
344
+ const key = `pairs`;
345
+ const value = Array.from(currentPricePairs);
346
+ pubSubData[key] = value;
347
+
278
348
  this.dexHelper.cache.setex(
279
349
  this.dexKey,
280
350
  this.dexHelper.config.data.network,
281
- `pairs`,
282
- this.config.rateConfig.dataTTLS,
283
- JSON.stringify(Array.from(currentPricePairs)),
351
+ key,
352
+ ttl,
353
+ JSON.stringify(value),
284
354
  );
285
355
  }
356
+
357
+ this.pricesPubSub.publish(pubSubData, ttl);
286
358
  }
287
359
 
288
360
  checkHealth(): boolean {
@@ -322,18 +394,16 @@ export class RateFetcher {
322
394
  }
323
395
 
324
396
  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,
397
+ const pairs = await this.pricesPubSub.getAndCache<string[]>(`pairs`);
398
+ this.logger.info(
399
+ `${logPrefix} Getting available pairs, pairs: `,
400
+ pairs?.length,
330
401
  );
331
-
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(
@@ -343,53 +413,36 @@ export class RateFetcher {
343
413
  ): Promise<PriceAndAmountBigNumber[] | null> {
344
414
  let reversed = false;
345
415
 
346
- let pricesAsString: string | null = null;
416
+ let prices: PriceAndAmount[] | null = null;
347
417
  if (side === SwapSide.SELL) {
348
- pricesAsString = await this.dexHelper.cache.getAndCacheLocally(
349
- this.dexKey,
350
- this.dexHelper.config.data.network,
418
+ prices = await this.pricesPubSub.getAndCache(
351
419
  `${srcToken.address}_${destToken.address}_bids`,
352
- this.config.rateConfig.intervalMs / 1000,
353
420
  );
354
421
 
355
- if (!pricesAsString) {
356
- pricesAsString = await this.dexHelper.cache.getAndCacheLocally(
357
- this.dexKey,
358
- this.dexHelper.config.data.network,
422
+ if (!prices) {
423
+ prices = await this.pricesPubSub.getAndCache(
359
424
  `${destToken.address}_${srcToken.address}_asks`,
360
- this.config.rateConfig.intervalMs / 1000,
361
425
  );
362
426
  reversed = true;
363
427
  }
364
428
  } else {
365
- pricesAsString = await this.dexHelper.cache.getAndCacheLocally(
366
- this.dexKey,
367
- this.dexHelper.config.data.network,
429
+ prices = await this.pricesPubSub.getAndCache(
368
430
  `${destToken.address}_${srcToken.address}_asks`,
369
- this.config.rateConfig.intervalMs / 1000,
370
431
  );
371
432
 
372
- if (!pricesAsString) {
373
- pricesAsString = await this.dexHelper.cache.getAndCacheLocally(
374
- this.dexKey,
375
- this.dexHelper.config.data.network,
433
+ if (!prices) {
434
+ prices = await this.pricesPubSub.getAndCache(
376
435
  `${srcToken.address}_${destToken.address}_bids`,
377
- this.config.rateConfig.intervalMs / 1000,
378
436
  );
379
437
  reversed = true;
380
438
  }
381
439
  }
382
440
 
383
- if (!pricesAsString) {
384
- return null;
385
- }
386
-
387
- const orderPricesAsString: PriceAndAmount[] = JSON.parse(pricesAsString);
388
- if (!orderPricesAsString) {
441
+ if (!prices) {
389
442
  return null;
390
443
  }
391
444
 
392
- let orderPrices = orderPricesAsString.map(price => [
445
+ let orderPrices = prices.map(price => [
393
446
  new BigNumber(price[0]),
394
447
  new BigNumber(price[1]),
395
448
  ]);
@@ -488,4 +541,16 @@ export class RateFetcher {
488
541
  throw e;
489
542
  }
490
543
  }
544
+
545
+ async setBlacklist(userAddress: string): Promise<boolean> {
546
+ await this.dexHelper.cache.hset(
547
+ this.blackListCacheKey,
548
+ userAddress.toLowerCase(),
549
+ 'true',
550
+ );
551
+ if (this.blacklistPubSub) {
552
+ this.blacklistPubSub.publish([userAddress.toLowerCase()]);
553
+ }
554
+ return true;
555
+ }
491
556
  }
@@ -11,6 +11,108 @@ type KeyValuePubSubMsg = {
11
11
 
12
12
  type SetPubSubMsg = string[];
13
13
 
14
+ export class ExpKeyValuePubSub {
15
+ channel: string;
16
+ network: Network;
17
+ localCache: NodeCache = new NodeCache();
18
+ logPrefix = 'ExpKeyValuePubSub';
19
+
20
+ logger: Logger;
21
+
22
+ constructor(
23
+ private dexHelper: IDexHelper,
24
+ private dexKey: string,
25
+ channel: string,
26
+ private defaultValue?: any,
27
+ private defaultTTL?: number,
28
+ ) {
29
+ this.network = this.dexHelper.config.data.network;
30
+ this.channel = `${this.network}_${this.dexKey}_${channel}`;
31
+
32
+ this.logger = this.dexHelper.getLogger(`ExpKeyValuePubSub_${this.channel}`);
33
+ }
34
+
35
+ subscribe() {
36
+ this.logger.info(`Subscribing to ${this.channel}`);
37
+
38
+ this.dexHelper.cache.subscribe(this.channel, (_, msg) => {
39
+ const decodedMsg = JSON.parse(msg) as KeyValuePubSubMsg;
40
+ this.logger.info(
41
+ `${this.logPrefix} Received msg: '${Object.keys(decodedMsg).length}'`,
42
+ );
43
+ this.handleSubscription(decodedMsg);
44
+ });
45
+ }
46
+
47
+ publish(data: Record<string, unknown>, ttl: number) {
48
+ const expiresAt = Math.round(Date.now() / 1000) + ttl;
49
+ this.logger.info(
50
+ `${this.logPrefix} Publishing msg: '${JSON.stringify({
51
+ expiresAt,
52
+ data: Object.keys(data).length,
53
+ })}'`,
54
+ );
55
+ this.dexHelper.cache.publish(
56
+ this.channel,
57
+ JSON.stringify({ expiresAt, data }),
58
+ );
59
+ }
60
+
61
+ handleSubscription(msg: KeyValuePubSubMsg) {
62
+ const { expiresAt, data } = msg;
63
+
64
+ const now = Math.round(Date.now() / 1000);
65
+ // calculating ttl as message might come with the delay
66
+ const ttl = expiresAt - now;
67
+
68
+ if (ttl > 0) {
69
+ const keys = Object.keys(data);
70
+ for (const key of keys) {
71
+ this.localCache.set(key, data[key], ttl);
72
+ }
73
+ } else {
74
+ this.logger.error('Message has expired', {
75
+ now,
76
+ expiresAt,
77
+ diffInSeconds: now - expiresAt,
78
+ keys: Object.keys(data),
79
+ });
80
+ }
81
+ }
82
+
83
+ async getAndCache<T>(key: string): Promise<T | null> {
84
+ const localValue = this.localCache.get<T>(key);
85
+
86
+ this.logger.info(
87
+ `${this.logPrefix} Getting and caching key: ${key}, localValue length: ${
88
+ localValue ? Object.keys(localValue).length : 0
89
+ }`,
90
+ );
91
+
92
+ if (localValue) {
93
+ return localValue;
94
+ }
95
+
96
+ const [value, ttl] = await Promise.all([
97
+ this.dexHelper.cache.get(this.dexKey, this.network, key),
98
+ this.dexHelper.cache.ttl(this.dexKey, this.network, key),
99
+ ]);
100
+
101
+ if (value && ttl > 0) {
102
+ const parsedValue = JSON.parse(value);
103
+ this.localCache.set(key, parsedValue, ttl);
104
+ return parsedValue;
105
+ }
106
+
107
+ if (this.defaultValue && this.defaultTTL && this.defaultTTL > 0) {
108
+ this.localCache.set(key, this.defaultValue, this.defaultTTL);
109
+ return this.defaultValue;
110
+ }
111
+
112
+ return null;
113
+ }
114
+ }
115
+
14
116
  export class ExpStringPubSub {
15
117
  channel: string;
16
118
  network: Network;
@@ -178,6 +280,7 @@ export class NonExpSetPubSub {
178
280
  channel: string;
179
281
  network: Network;
180
282
  set = new Set<string>();
283
+ logPrefix = 'NonExpSetPubSub';
181
284
 
182
285
  logger: Logger;
183
286
 
@@ -193,7 +296,9 @@ export class NonExpSetPubSub {
193
296
  }
194
297
 
195
298
  async initializeAndSubscribe(initialSet: string[]) {
196
- this.logger.info(`initializeAndSubscribe with ${initialSet}`);
299
+ this.logger.info(
300
+ `${this.logPrefix} initializeAndSubscribe with ${initialSet}`,
301
+ );
197
302
 
198
303
  for (const member of initialSet) {
199
304
  this.set.add(member);
@@ -207,19 +312,22 @@ export class NonExpSetPubSub {
207
312
 
208
313
  this.dexHelper.cache.subscribe(this.channel, (_, msg) => {
209
314
  const decodedMsg = JSON.parse(msg) as SetPubSubMsg;
315
+ this.logger.info(
316
+ `${this.logPrefix} Received subscription msg: '${decodedMsg.length}'`,
317
+ );
210
318
  this.handleSubscription(decodedMsg);
211
319
  });
212
320
  }
213
321
 
214
322
  publish(msg: SetPubSubMsg) {
215
323
  if (msg.length > 0) {
216
- this.logger.info(`Publishing msg: '${msg}'`);
324
+ this.logger.info(`${this.logPrefix} Publishing msg: '${msg.length}'`);
217
325
  this.dexHelper.cache.publish(this.channel, JSON.stringify(msg));
218
326
  }
219
327
  }
220
328
 
221
329
  handleSubscription(set: SetPubSubMsg) {
222
- this.logger.info(`Received subscription msg: '${set}'`);
330
+ this.logger.info(`${this.logPrefix} Received subscription msg: '${set}'`);
223
331
 
224
332
  for (const key of set) {
225
333
  this.set.add(key);
package/.idea/aws.xml DELETED
@@ -1,17 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="accountSettings">
4
- <option name="activeProfile" value="profile:default" />
5
- <option name="activeRegion" value="us-east-1" />
6
- <option name="recentlyUsedProfiles">
7
- <list>
8
- <option value="profile:default" />
9
- </list>
10
- </option>
11
- <option name="recentlyUsedRegions">
12
- <list>
13
- <option value="us-east-1" />
14
- </list>
15
- </option>
16
- </component>
17
- </project>
@@ -1,19 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <ScalaCodeStyleSettings>
4
- <option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
5
- </ScalaCodeStyleSettings>
6
- <TypeScriptCodeStyleSettings version="0">
7
- <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
8
- <option name="USE_DOUBLE_QUOTES" value="false" />
9
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
10
- </TypeScriptCodeStyleSettings>
11
- <codeStyleSettings language="TypeScript">
12
- <indentOptions>
13
- <option name="INDENT_SIZE" value="2" />
14
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
15
- <option name="TAB_SIZE" value="2" />
16
- </indentOptions>
17
- </codeStyleSettings>
18
- </code_scheme>
19
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager">
4
- <output url="file://$PROJECT_DIR$/out" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" filepath="$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="JAVA_MODULE" version="4">
3
- <component name="NewModuleRootManager" inherit-compiler-output="true">
4
- <exclude-output />
5
- <content url="file://$MODULE_DIR$" />
6
- <orderEntry type="inheritedJdk" />
7
- <orderEntry type="sourceFolder" forTests="false" />
8
- </component>
9
- </module>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="PrettierConfiguration">
4
- <option name="myRunOnSave" value="true" />
5
- <option name="myRunOnReformat" value="true" />
6
- </component>
7
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>