@paraswap/dex-lib 2.48.0 → 2.48.1-hashflow-impr

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 (323) hide show
  1. package/build/abi/Redstone.json +739 -0
  2. package/build/abi/angle/stagToken.json +963 -0
  3. package/build/abi/angle-transmuter/Pyth.json +1534 -0
  4. package/build/abi/angle-transmuter/Transmuter.json +1719 -0
  5. package/build/abi/smardex/smardex-factory.json +185 -0
  6. package/build/abi/smardex/smardex-pool.json +578 -0
  7. package/build/abi/smardex/smardex-router.json +648 -0
  8. package/build/abi/trader-joe-v2_1/FactoryABI.json +1208 -0
  9. package/build/abi/trader-joe-v2_1/PairABI.json +1493 -0
  10. package/build/abi/trader-joe-v2_1/RouterABI.json +1489 -0
  11. package/build/abi/trader-joe-v2_1/StateMulticall.json +193 -0
  12. package/build/abi/wombat/pool.json +1289 -0
  13. package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +53 -0
  14. package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +175 -0
  15. package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +1 -0
  16. package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +42 -0
  17. package/build/dex/angle-staked-stable/angle-staked-stable.js +232 -0
  18. package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -0
  19. package/build/dex/{sushiswap-v3 → angle-staked-stable}/config.d.ts +2 -2
  20. package/build/dex/angle-staked-stable/config.js +26 -0
  21. package/build/dex/angle-staked-stable/config.js.map +1 -0
  22. package/build/dex/angle-staked-stable/types.d.ts +15 -0
  23. package/build/dex/angle-staked-stable/types.js.map +1 -0
  24. package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +43 -0
  25. package/build/dex/angle-transmuter/angle-transmuter-pool.js +309 -0
  26. package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
  27. package/build/dex/{lighter-v1/lighter-v1.d.ts → angle-transmuter/angle-transmuter.d.ts} +18 -17
  28. package/build/dex/angle-transmuter/angle-transmuter.js +233 -0
  29. package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
  30. package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
  31. package/build/dex/angle-transmuter/backedOracle.js +56 -0
  32. package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
  33. package/build/dex/{woo-fi → angle-transmuter}/config.d.ts +1 -1
  34. package/build/dex/angle-transmuter/config.js +20 -0
  35. package/build/dex/angle-transmuter/config.js.map +1 -0
  36. package/build/dex/angle-transmuter/constants.d.ts +4 -0
  37. package/build/dex/angle-transmuter/constants.js +8 -0
  38. package/build/dex/angle-transmuter/constants.js.map +1 -0
  39. package/build/dex/angle-transmuter/pyth.d.ts +19 -0
  40. package/build/dex/angle-transmuter/pyth.js +71 -0
  41. package/build/dex/angle-transmuter/pyth.js.map +1 -0
  42. package/build/dex/angle-transmuter/redstone.d.ts +20 -0
  43. package/build/dex/angle-transmuter/redstone.js +73 -0
  44. package/build/dex/angle-transmuter/redstone.js.map +1 -0
  45. package/build/dex/angle-transmuter/transmuter.d.ts +50 -0
  46. package/build/dex/angle-transmuter/transmuter.js +314 -0
  47. package/build/dex/angle-transmuter/transmuter.js.map +1 -0
  48. package/build/dex/angle-transmuter/types.d.ts +144 -0
  49. package/build/dex/angle-transmuter/types.js +31 -0
  50. package/build/dex/angle-transmuter/types.js.map +1 -0
  51. package/build/dex/angle-transmuter/utils.d.ts +9 -0
  52. package/build/dex/angle-transmuter/utils.js +264 -0
  53. package/build/dex/angle-transmuter/utils.js.map +1 -0
  54. package/build/dex/hashflow/constants.d.ts +28 -0
  55. package/build/dex/hashflow/constants.js +31 -1
  56. package/build/dex/hashflow/constants.js.map +1 -1
  57. package/build/dex/hashflow/hashflow.d.ts +3 -2
  58. package/build/dex/hashflow/hashflow.js +87 -12
  59. package/build/dex/hashflow/hashflow.js.map +1 -1
  60. package/build/dex/hashflow/types.d.ts +11 -0
  61. package/build/dex/hashflow/types.js +9 -0
  62. package/build/dex/hashflow/types.js.map +1 -1
  63. package/build/dex/smardex/subgraph-queries.d.ts +1 -0
  64. package/build/dex/smardex/subgraph-queries.js +17 -0
  65. package/build/dex/smardex/subgraph-queries.js.map +1 -0
  66. package/build/dex/smardex/usd-reserves.d.ts +23 -0
  67. package/build/dex/smardex/usd-reserves.js +86 -0
  68. package/build/dex/smardex/usd-reserves.js.map +1 -0
  69. package/build/dex/{lighter-v1 → trader-joe-v2-1-2}/config.d.ts +1 -1
  70. package/build/dex/trader-joe-v2-1-2/config.js +47 -0
  71. package/build/dex/trader-joe-v2-1-2/config.js.map +1 -0
  72. package/build/dex/trader-joe-v2-1-2/constants.d.ts +20 -0
  73. package/build/dex/trader-joe-v2-1-2/constants.js +22 -0
  74. package/build/dex/trader-joe-v2-1-2/constants.js.map +1 -0
  75. package/build/dex/trader-joe-v2-1-2/math/index.d.ts +37 -0
  76. package/build/dex/trader-joe-v2-1-2/math/index.js +291 -0
  77. package/build/dex/trader-joe-v2-1-2/math/index.js.map +1 -0
  78. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +60 -0
  79. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +248 -0
  80. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +1 -0
  81. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +53 -0
  82. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +307 -0
  83. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +1 -0
  84. package/build/dex/trader-joe-v2-1-2/types.d.ts +82 -0
  85. package/build/dex/trader-joe-v2-1-2/types.js +9 -0
  86. package/build/dex/trader-joe-v2-1-2/types.js.map +1 -0
  87. package/build/dex/{ramses-v2 → trader-joe-v2_1}/config.d.ts +1 -1
  88. package/build/dex/trader-joe-v2_1/config.js +47 -0
  89. package/build/dex/trader-joe-v2_1/config.js.map +1 -0
  90. package/build/dex/trader-joe-v2_1/constants.d.ts +20 -0
  91. package/build/dex/trader-joe-v2_1/constants.js +22 -0
  92. package/build/dex/trader-joe-v2_1/constants.js.map +1 -0
  93. package/build/dex/trader-joe-v2_1/math/index.d.ts +37 -0
  94. package/build/dex/trader-joe-v2_1/math/index.js +291 -0
  95. package/build/dex/trader-joe-v2_1/math/index.js.map +1 -0
  96. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
  97. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +384 -0
  98. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +1 -0
  99. package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +60 -0
  100. package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +247 -0
  101. package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +1 -0
  102. package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +53 -0
  103. package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +307 -0
  104. package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +1 -0
  105. package/build/dex/trader-joe-v2_1/types.d.ts +82 -0
  106. package/build/dex/trader-joe-v2_1/types.js +9 -0
  107. package/build/dex/trader-joe-v2_1/types.js.map +1 -0
  108. package/build/dex/uniswap-v3/config.js +14 -0
  109. package/build/dex/uniswap-v3/config.js.map +1 -1
  110. package/build/dex/uniswap-v3/uniswap-v3.js +1 -0
  111. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  112. package/build/dex/wombat/wombat-pool-poller.d.ts +22 -0
  113. package/build/dex/wombat/wombat-pool-poller.js +164 -0
  114. package/build/dex/wombat/wombat-pool-poller.js.map +1 -0
  115. package/package.json +1 -1
  116. package/src/dex/hashflow/constants.ts +34 -0
  117. package/src/dex/hashflow/hashflow.ts +146 -19
  118. package/src/dex/hashflow/types.ts +20 -2
  119. package/src/dex/uniswap-v3/config.ts +16 -0
  120. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +27 -3
  121. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +296 -3
  122. package/src/dex/uniswap-v3/uniswap-v3.ts +1 -0
  123. package/tests/constants-e2e.ts +5 -0
  124. package/.idea/aws.xml +0 -17
  125. package/.idea/codeStyles/Project.xml +0 -19
  126. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  127. package/.idea/misc.xml +0 -6
  128. package/.idea/modules.xml +0 -8
  129. package/.idea/paraswap-dex-lib.iml +0 -9
  130. package/.idea/prettier.xml +0 -7
  131. package/.idea/vcs.xml +0 -6
  132. package/build/abi/AugustusV6.abi.json +0 -395
  133. package/build/abi/algebra/AlgebraPool.abi.json +0 -727
  134. package/build/abi/curve-v1/StableSwapFRXETH.json +0 -889
  135. package/build/abi/curve-v1/StableSwapWBETH.json +0 -1223
  136. package/build/abi/sushiswap-v3/QuoterV2.json +0 -267
  137. package/build/abi/sushiswap-v3/RouterProcessor3.json +0 -289
  138. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  139. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +0 -285
  140. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +0 -583
  141. package/build/abi/wBETH.json +0 -1527
  142. package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
  143. package/build/abi/woo-fi/WooPP.abi.json +0 -548
  144. package/build/abi/woo-fi/Wooracle.abi.json +0 -260
  145. package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
  146. package/build/dex/aave-v3/tokens/avalanche.json +0 -74
  147. package/build/dex/aave-v3/tokens/fantom.json +0 -62
  148. package/build/dex/aave-v3/tokens/optimism.json +0 -50
  149. package/build/dex/aave-v3/tokens/polygon.json +0 -116
  150. package/build/dex/algebra/algebra-pool.d.ts +0 -114
  151. package/build/dex/algebra/algebra-pool.js +0 -448
  152. package/build/dex/algebra/algebra-pool.js.map +0 -1
  153. package/build/dex/balancer-v2/Gyro3Pool.d.ts +0 -43
  154. package/build/dex/balancer-v2/Gyro3Pool.js +0 -160
  155. package/build/dex/balancer-v2/Gyro3Pool.js.map +0 -1
  156. package/build/dex/balancer-v2/LinearMath.d.ts +0 -88
  157. package/build/dex/balancer-v2/LinearMath.js +0 -285
  158. package/build/dex/balancer-v2/LinearMath.js.map +0 -1
  159. package/build/dex/balancer-v2/LinearPool.d.ts +0 -81
  160. package/build/dex/balancer-v2/LinearPool.js +0 -444
  161. package/build/dex/balancer-v2/LinearPool.js.map +0 -1
  162. package/build/dex/balancer-v2/PhantomStablePool.d.ts +0 -90
  163. package/build/dex/balancer-v2/PhantomStablePool.js +0 -418
  164. package/build/dex/balancer-v2/PhantomStablePool.js.map +0 -1
  165. package/build/dex/balancer-v2/StableMath.d.ts +0 -9
  166. package/build/dex/balancer-v2/StableMath.js +0 -272
  167. package/build/dex/balancer-v2/StableMath.js.map +0 -1
  168. package/build/dex/balancer-v2/balancer-v2-pool.d.ts +0 -140
  169. package/build/dex/balancer-v2/balancer-v2-pool.js +0 -647
  170. package/build/dex/balancer-v2/balancer-v2-pool.js.map +0 -1
  171. package/build/dex/curve-v1/pools/frxETHpool.d.ts +0 -7
  172. package/build/dex/curve-v1/pools/frxETHpool.js +0 -27
  173. package/build/dex/curve-v1/pools/frxETHpool.js.map +0 -1
  174. package/build/dex/curve-v1/pools/wbETHpool.d.ts +0 -29
  175. package/build/dex/curve-v1/pools/wbETHpool.js +0 -408
  176. package/build/dex/curve-v1/pools/wbETHpool.js.map +0 -1
  177. package/build/dex/lighter-v1/abi/erc20.json +0 -222
  178. package/build/dex/lighter-v1/abi/factory.json +0 -291
  179. package/build/dex/lighter-v1/abi/order_book.json +0 -594
  180. package/build/dex/lighter-v1/abi/order_book_helper.json +0 -176
  181. package/build/dex/lighter-v1/abi/router.json +0 -488
  182. package/build/dex/lighter-v1/config.js +0 -17
  183. package/build/dex/lighter-v1/config.js.map +0 -1
  184. package/build/dex/lighter-v1/constants.d.ts +0 -2
  185. package/build/dex/lighter-v1/constants.js +0 -13
  186. package/build/dex/lighter-v1/constants.js.map +0 -1
  187. package/build/dex/lighter-v1/lighter-v1-pool.d.ts +0 -57
  188. package/build/dex/lighter-v1/lighter-v1-pool.js +0 -310
  189. package/build/dex/lighter-v1/lighter-v1-pool.js.map +0 -1
  190. package/build/dex/lighter-v1/lighter-v1.js +0 -331
  191. package/build/dex/lighter-v1/lighter-v1.js.map +0 -1
  192. package/build/dex/lighter-v1/types.d.ts +0 -40
  193. package/build/dex/lighter-v1/types.js +0 -3
  194. package/build/dex/lighter-v1/types.js.map +0 -1
  195. package/build/dex/pancakeswap-v3/types.d.ts +0 -14
  196. package/build/dex/pancakeswap-v3/types.js +0 -3
  197. package/build/dex/pancakeswap-v3/types.js.map +0 -1
  198. package/build/dex/quickswap/camelot-v3.d.ts +0 -6
  199. package/build/dex/quickswap/camelot-v3.js +0 -19
  200. package/build/dex/quickswap/camelot-v3.js.map +0 -1
  201. package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
  202. package/build/dex/quickswap/zyberswap-v3.js +0 -19
  203. package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
  204. package/build/dex/quickswap-v3.d.ts +0 -21
  205. package/build/dex/quickswap-v3.js +0 -40
  206. package/build/dex/quickswap-v3.js.map +0 -1
  207. package/build/dex/ramses-v2/config.js +0 -28
  208. package/build/dex/ramses-v2/config.js.map +0 -1
  209. package/build/dex/ramses-v2/constants.d.ts +0 -28
  210. package/build/dex/ramses-v2/constants.js +0 -35
  211. package/build/dex/ramses-v2/constants.js.map +0 -1
  212. package/build/dex/ramses-v2/contract-math/BitMath.d.ts +0 -4
  213. package/build/dex/ramses-v2/contract-math/BitMath.js +0 -93
  214. package/build/dex/ramses-v2/contract-math/BitMath.js.map +0 -1
  215. package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +0 -3
  216. package/build/dex/ramses-v2/contract-math/FixedPoint128.js +0 -8
  217. package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +0 -1
  218. package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +0 -4
  219. package/build/dex/ramses-v2/contract-math/FixedPoint96.js +0 -9
  220. package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +0 -1
  221. package/build/dex/ramses-v2/contract-math/FullMath.d.ts +0 -4
  222. package/build/dex/ramses-v2/contract-math/FullMath.js +0 -19
  223. package/build/dex/ramses-v2/contract-math/FullMath.js.map +0 -1
  224. package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +0 -3
  225. package/build/dex/ramses-v2/contract-math/LiquidityMath.js +0 -22
  226. package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +0 -1
  227. package/build/dex/ramses-v2/contract-math/Oracle.d.ts +0 -10
  228. package/build/dex/ramses-v2/contract-math/Oracle.js +0 -133
  229. package/build/dex/ramses-v2/contract-math/Oracle.js.map +0 -1
  230. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +0 -10
  231. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +0 -91
  232. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +0 -1
  233. package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +0 -8
  234. package/build/dex/ramses-v2/contract-math/SwapMath.js +0 -70
  235. package/build/dex/ramses-v2/contract-math/SwapMath.js.map +0 -1
  236. package/build/dex/ramses-v2/contract-math/Tick.d.ts +0 -7
  237. package/build/dex/ramses-v2/contract-math/Tick.js +0 -45
  238. package/build/dex/ramses-v2/contract-math/Tick.js.map +0 -1
  239. package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +0 -8
  240. package/build/dex/ramses-v2/contract-math/TickBitMap.js +0 -87
  241. package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +0 -1
  242. package/build/dex/ramses-v2/contract-math/TickMath.d.ts +0 -8
  243. package/build/dex/ramses-v2/contract-math/TickMath.js +0 -162
  244. package/build/dex/ramses-v2/contract-math/TickMath.js.map +0 -1
  245. package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +0 -3
  246. package/build/dex/ramses-v2/contract-math/UnsafeMath.js +0 -10
  247. package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +0 -1
  248. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +0 -18
  249. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +0 -392
  250. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +0 -1
  251. package/build/dex/ramses-v2/contract-math/utils.d.ts +0 -3
  252. package/build/dex/ramses-v2/contract-math/utils.js +0 -16
  253. package/build/dex/ramses-v2/contract-math/utils.js.map +0 -1
  254. package/build/dex/ramses-v2/ramses-v2-pool.d.ts +0 -42
  255. package/build/dex/ramses-v2/ramses-v2-pool.js +0 -307
  256. package/build/dex/ramses-v2/ramses-v2-pool.js.map +0 -1
  257. package/build/dex/ramses-v2/ramses-v2.d.ts +0 -61
  258. package/build/dex/ramses-v2/ramses-v2.js +0 -690
  259. package/build/dex/ramses-v2/ramses-v2.js.map +0 -1
  260. package/build/dex/ramses-v2/types.d.ts +0 -154
  261. package/build/dex/ramses-v2/types.js +0 -9
  262. package/build/dex/ramses-v2/types.js.map +0 -1
  263. package/build/dex/ramses-v2/utils.d.ts +0 -6
  264. package/build/dex/ramses-v2/utils.js +0 -71
  265. package/build/dex/ramses-v2/utils.js.map +0 -1
  266. package/build/dex/solidly/forks-override/fvm.d.ts +0 -20
  267. package/build/dex/solidly/forks-override/fvm.js +0 -42
  268. package/build/dex/solidly/forks-override/fvm.js.map +0 -1
  269. package/build/dex/sushiswap-v3/config.js +0 -132
  270. package/build/dex/sushiswap-v3/config.js.map +0 -1
  271. package/build/dex/sushiswap-v3/constants.d.ts +0 -4
  272. package/build/dex/sushiswap-v3/constants.js +0 -32
  273. package/build/dex/sushiswap-v3/constants.js.map +0 -1
  274. package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +0 -56
  275. package/build/dex/sushiswap-v3/sushiswap-v3-original.js +0 -598
  276. package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +0 -1
  277. package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +0 -1
  278. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +0 -6
  279. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +0 -1
  280. package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +0 -21
  281. package/build/dex/sushiswap-v3/sushiswap-v3.js +0 -58
  282. package/build/dex/sushiswap-v3/sushiswap-v3.js.map +0 -1
  283. package/build/dex/sushiswap-v3/token.d.ts +0 -6
  284. package/build/dex/sushiswap-v3/token.js +0 -23
  285. package/build/dex/sushiswap-v3/token.js.map +0 -1
  286. package/build/dex/sushiswap-v3/types.d.ts +0 -15
  287. package/build/dex/sushiswap-v3/types.js +0 -18
  288. package/build/dex/sushiswap-v3/types.js.map +0 -1
  289. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +0 -12
  290. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +0 -23
  291. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +0 -1
  292. package/build/dex/woo-fi/config.js +0 -141
  293. package/build/dex/woo-fi/config.js.map +0 -1
  294. package/build/dex/woo-fi/constants.d.ts +0 -5
  295. package/build/dex/woo-fi/constants.js +0 -20
  296. package/build/dex/woo-fi/constants.js.map +0 -1
  297. package/build/dex/woo-fi/types.d.ts +0 -48
  298. package/build/dex/woo-fi/types.js.map +0 -1
  299. package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
  300. package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
  301. package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
  302. package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
  303. package/build/dex/woo-fi/woo-fi-math.js +0 -300
  304. package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
  305. package/build/dex/woo-fi/woo-fi.d.ts +0 -65
  306. package/build/dex/woo-fi/woo-fi.js +0 -480
  307. package/build/dex/woo-fi/woo-fi.js.map +0 -1
  308. package/build/executor/Executor01BytecodeBuilder.d.ts +0 -77
  309. package/build/executor/Executor01BytecodeBuilder.js +0 -359
  310. package/build/executor/Executor01BytecodeBuilder.js.map +0 -1
  311. package/build/executor/Executor02BytecodeBuilder.d.ts +0 -12
  312. package/build/executor/Executor02BytecodeBuilder.js +0 -14
  313. package/build/executor/Executor02BytecodeBuilder.js.map +0 -1
  314. package/build/executor/ExecutorDetector.d.ts +0 -28
  315. package/build/executor/ExecutorDetector.js +0 -89
  316. package/build/executor/ExecutorDetector.js.map +0 -1
  317. package/build/executor/IExecutorBytecodeBuilder.d.ts +0 -6
  318. package/build/executor/IExecutorBytecodeBuilder.js +0 -3
  319. package/build/executor/IExecutorBytecodeBuilder.js.map +0 -1
  320. package/build/generic-swap-transaction-builder.d.ts +0 -39
  321. package/build/generic-swap-transaction-builder.js +0 -156
  322. package/build/generic-swap-transaction-builder.js.map +0 -1
  323. /package/build/dex/{woo-fi → angle-staked-stable}/types.js +0 -0
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterDictionaryOnly = exports._quoteFees = exports._quoteBurnExactInput = exports._quoteBurnExactOutput = exports._quoteMintExactOutput = exports._quoteMintExactInput = void 0;
4
+ const types_1 = require("./types");
5
+ /// @notice Computes the `amountOut` of stablecoins to mint from `tokenIn` of a collateral with data `collatInfo`
6
+ function _quoteMintExactInput(oracleValue, amountIn, fees, stablecoinsIssued, otherStablecoinSupply) {
7
+ const amountOut = oracleValue * amountIn;
8
+ return _quoteFees(fees, types_1.QuoteType.MintExactInput, amountOut, stablecoinsIssued, otherStablecoinSupply);
9
+ }
10
+ exports._quoteMintExactInput = _quoteMintExactInput;
11
+ /// @notice Computes the `amountIn` of collateral to get during a mint of `amountOut` of stablecoins
12
+ function _quoteMintExactOutput(oracleValue, amountOut, fees, stablecoinsIssued, otherStablecoinSupply) {
13
+ const amountIn = _quoteFees(fees, types_1.QuoteType.MintExactOutput, amountOut, stablecoinsIssued, otherStablecoinSupply);
14
+ return amountIn / oracleValue;
15
+ }
16
+ exports._quoteMintExactOutput = _quoteMintExactOutput;
17
+ /// @notice Computes the `amountIn` of stablecoins to burn to release `amountOut` of `collateral`
18
+ function _quoteBurnExactOutput(oracleValue, ratio, amountOut, fees, stablecoinsIssued, otherStablecoinSupply) {
19
+ const amountIn = (amountOut * oracleValue) / ratio;
20
+ return _quoteFees(fees, types_1.QuoteType.BurnExactOutput, amountIn, stablecoinsIssued, otherStablecoinSupply);
21
+ }
22
+ exports._quoteBurnExactOutput = _quoteBurnExactOutput;
23
+ /// @notice Computes the `amountOut` of `collateral` to give during a burn operation of `amountIn` of stablecoins
24
+ function _quoteBurnExactInput(oracleValue, ratio, amountIn, fees, stablecoinsIssued, otherStablecoinSupply) {
25
+ const amountOut = _quoteFees(fees, types_1.QuoteType.BurnExactInput, amountIn, stablecoinsIssued, otherStablecoinSupply);
26
+ return (amountOut * ratio) / oracleValue;
27
+ }
28
+ exports._quoteBurnExactInput = _quoteBurnExactInput;
29
+ function _quoteFees(fees, quoteType, amountStable, stablecoinsIssued, otherStablecoinSupply) {
30
+ const isMint = _isMint(quoteType);
31
+ const isExact = _isExact(quoteType);
32
+ const n = isMint ? fees.xFeeMint.length : fees.xFeeBurn.length;
33
+ let currentExposure = (stablecoinsIssued * types_1.BASE_9) / (otherStablecoinSupply + stablecoinsIssued);
34
+ let amount = 0;
35
+ // Finding in which segment the current exposure to the collateral is
36
+ let i = findLowerBound(isMint, isMint ? fees.xFeeMint : fees.xFeeBurn, types_1.BASE_9, currentExposure);
37
+ let lowerExposure;
38
+ let upperExposure;
39
+ let lowerFees;
40
+ let upperFees;
41
+ let amountToNextBreakPoint;
42
+ while (i < n - 1) {
43
+ // We compute a linear by part function on the amount swapped
44
+ // The `amountToNextBreakPoint` variable is the `b_{i+1}` value from the whitepaper
45
+ if (isMint) {
46
+ lowerExposure = fees.xFeeMint[i];
47
+ upperExposure = fees.xFeeMint[i + 1];
48
+ lowerFees = fees.yFeeMint[i];
49
+ upperFees = fees.yFeeMint[i + 1];
50
+ amountToNextBreakPoint =
51
+ (otherStablecoinSupply * upperExposure) / (types_1.BASE_9 - upperExposure) -
52
+ stablecoinsIssued;
53
+ }
54
+ else {
55
+ // The exposures in the burn case are decreasing
56
+ lowerExposure = fees.xFeeBurn[i];
57
+ upperExposure = fees.xFeeBurn[i + 1];
58
+ lowerFees = fees.yFeeBurn[i];
59
+ upperFees = fees.yFeeBurn[i + 1];
60
+ // The `b_{i+1}` value in the burn case is the opposite value of the mint case
61
+ amountToNextBreakPoint =
62
+ stablecoinsIssued -
63
+ (otherStablecoinSupply * upperExposure) / (types_1.BASE_9 - upperExposure);
64
+ }
65
+ let currentFees;
66
+ if (lowerExposure * types_1.BASE_9 === currentExposure) {
67
+ currentFees = lowerFees;
68
+ }
69
+ else if (lowerFees === upperFees) {
70
+ currentFees = lowerFees;
71
+ }
72
+ else {
73
+ // This is the opposite of the `b_i` value from the whitepaper.
74
+ const amountFromPrevBreakPoint = isMint
75
+ ? stablecoinsIssued -
76
+ (otherStablecoinSupply * lowerExposure) / (types_1.BASE_9 - lowerExposure)
77
+ : (otherStablecoinSupply * lowerExposure) / (types_1.BASE_9 - lowerExposure) -
78
+ stablecoinsIssued;
79
+ // slope = (upperFees - lowerFees) / (amountToNextBreakPoint + amountFromPrevBreakPoint)
80
+ // `currentFees` is the `g(0)` value from the whitepaper
81
+ currentFees =
82
+ lowerFees +
83
+ ((upperFees - lowerFees) * amountFromPrevBreakPoint) /
84
+ (amountToNextBreakPoint + amountFromPrevBreakPoint);
85
+ }
86
+ {
87
+ let amountToNextBreakPointNormalizer = isExact
88
+ ? amountToNextBreakPoint
89
+ : isMint
90
+ ? _invertFeeMint(amountToNextBreakPoint, (upperFees + currentFees) / 2)
91
+ : _applyFeeBurn(amountToNextBreakPoint, (upperFees + currentFees) / 2);
92
+ if (amountToNextBreakPointNormalizer >= amountStable) {
93
+ let midFee;
94
+ if (isExact) {
95
+ // `(g_i(0) + g_i(M)) / 2 = g(0) + (f_{i+1} - g(0)) * M / (2 * b_{i+1})`
96
+ midFee =
97
+ currentFees +
98
+ (amountStable * (upperFees - currentFees)) /
99
+ (2 * amountToNextBreakPointNormalizer);
100
+ }
101
+ else {
102
+ // Here instead of computing the closed form expression for `m_t` derived in the whitepaper,
103
+ // we are computing: `(g(0)+g_i(m_t))/2 = g(0)+(f_{i+1}-f_i)/(b_{i+1}-b_i)m_t/2
104
+ // ac4 is the value of `2M(f_{i+1}-f_i)/(b_{i+1}-b_i) = 2M(f_{i+1}-g(0))/b_{i+1}` used
105
+ // in the computation of `m_t` in both the mint and burn case
106
+ const ac4 = (types_1.BASE_9 * (2 * amountStable * (upperFees - currentFees))) /
107
+ amountToNextBreakPoint;
108
+ if (isMint) {
109
+ // In the mint case:
110
+ // `m_t = (-1-g(0)+sqrt[(1+g(0))**2+2M(f_{i+1}-g(0))/b_{i+1})]/((f_{i+1}-g(0))/b_{i+1})`
111
+ // And so: g(0)+(f_{i+1}-f_i)/(b_{i+1}-b_i)m_t/2
112
+ // = (g(0)-1+sqrt[(1+g(0))**2+2M(f_{i+1}-g(0))/b_{i+1})])
113
+ midFee = Number((Math.sqrt((types_1.BASE_9 + currentFees) ** 2 + ac4) +
114
+ currentFees -
115
+ types_1.BASE_9) /
116
+ 2);
117
+ }
118
+ else {
119
+ // In the burn case:
120
+ // `m_t = (1-g(0)+sqrt[(1-g(0))**2-2M(f_{i+1}-g(0))/b_{i+1})]/((f_{i+1}-g(0))/b_{i+1})`
121
+ // And so: g(0)+(f_{i+1}-f_i)/(b_{i+1}-b_i)m_t/2
122
+ // = (g(0)+1-sqrt[(1-g(0))**2-2M(f_{i+1}-g(0))/b_{i+1})])
123
+ const baseMinusCurrentSquared = (types_1.BASE_9 - currentFees) ** 2;
124
+ // Mathematically, this condition is always verified, but rounding errors may make this
125
+ // mathematical invariant break, in which case we consider that the square root is null
126
+ if (baseMinusCurrentSquared < ac4) {
127
+ midFee = (currentFees + types_1.BASE_9) / 2;
128
+ }
129
+ else {
130
+ midFee =
131
+ (currentFees +
132
+ types_1.BASE_9 -
133
+ Math.sqrt(baseMinusCurrentSquared - ac4)) /
134
+ 2;
135
+ }
136
+ }
137
+ }
138
+ return amount + _computeFee(quoteType, amountStable, midFee);
139
+ }
140
+ else {
141
+ amountStable -= amountToNextBreakPointNormalizer;
142
+ amount += !isExact
143
+ ? amountToNextBreakPoint
144
+ : isMint
145
+ ? _invertFeeMint(amountToNextBreakPoint, (upperFees + currentFees) / 2)
146
+ : _applyFeeBurn(amountToNextBreakPoint, (upperFees + currentFees) / 2);
147
+ currentExposure = upperExposure * types_1.BASE_9;
148
+ ++i;
149
+ // Update for the rest of the swaps the stablecoins issued from the asset
150
+ stablecoinsIssued = isMint
151
+ ? stablecoinsIssued + amountToNextBreakPoint
152
+ : stablecoinsIssued - amountToNextBreakPoint;
153
+ }
154
+ }
155
+ }
156
+ return (amount +
157
+ _computeFee(quoteType, amountStable, isMint ? fees.yFeeMint[n - 1] : fees.yFeeBurn[n - 1]));
158
+ }
159
+ exports._quoteFees = _quoteFees;
160
+ function findLowerBound(increasingArray, array, normalizerArray, element) {
161
+ if (array.length === 0) {
162
+ return 0;
163
+ }
164
+ let low = 1;
165
+ let high = array.length;
166
+ if ((increasingArray && array[high - 1] * normalizerArray <= element) ||
167
+ (!increasingArray && array[high - 1] * normalizerArray >= element)) {
168
+ return high - 1;
169
+ }
170
+ while (low < high) {
171
+ const mid = Math.floor((low + high) / 2);
172
+ if (increasingArray
173
+ ? array[mid] * normalizerArray > element
174
+ : array[mid] * normalizerArray < element) {
175
+ high = mid;
176
+ }
177
+ else {
178
+ low = mid + 1;
179
+ }
180
+ }
181
+ return low - 1;
182
+ }
183
+ function _isMint(quoteType) {
184
+ return (quoteType === types_1.QuoteType.MintExactInput ||
185
+ quoteType === types_1.QuoteType.MintExactOutput);
186
+ }
187
+ function _isExact(quoteType) {
188
+ return (quoteType === types_1.QuoteType.MintExactOutput ||
189
+ quoteType === types_1.QuoteType.BurnExactInput);
190
+ }
191
+ function _applyFeeMint(amountIn, fees) {
192
+ if (fees >= 0) {
193
+ const castedFees = fees;
194
+ // Consider that if fees are above `BASE_12` this is equivalent to infinite fees
195
+ if (castedFees >= types_1.BASE_12)
196
+ throw new Error('InvalidSwap');
197
+ return (amountIn * types_1.BASE_9) / (types_1.BASE_9 + castedFees);
198
+ }
199
+ else {
200
+ return (amountIn * types_1.BASE_9) / (types_1.BASE_9 - Math.abs(-fees));
201
+ }
202
+ }
203
+ function _invertFeeMint(amountOut, fees) {
204
+ if (fees >= 0) {
205
+ const castedFees = fees;
206
+ // Consider that if fees are above `BASE_12` this is equivalent to infinite fees
207
+ if (castedFees >= types_1.BASE_12)
208
+ throw new Error('InvalidSwap');
209
+ return (amountOut * (types_1.BASE_9 + castedFees)) / types_1.BASE_9;
210
+ }
211
+ else {
212
+ return (amountOut * (types_1.BASE_9 - Math.abs(-fees))) / types_1.BASE_9;
213
+ }
214
+ }
215
+ function _applyFeeBurn(amountIn, fees) {
216
+ if (fees >= 0) {
217
+ const castedFees = fees;
218
+ if (castedFees >= types_1.MAX_BURN_FEE)
219
+ throw new Error('InvalidSwap');
220
+ return ((types_1.BASE_9 - castedFees) * amountIn) / types_1.BASE_9;
221
+ }
222
+ else {
223
+ return ((types_1.BASE_9 + Math.abs(-fees)) * amountIn) / types_1.BASE_9;
224
+ }
225
+ }
226
+ function _invertFeeBurn(amountOut, fees) {
227
+ if (fees >= 0) {
228
+ const castedFees = fees;
229
+ if (castedFees >= types_1.MAX_BURN_FEE)
230
+ throw new Error('InvalidSwap');
231
+ return (amountOut * types_1.BASE_9) / (types_1.BASE_9 - castedFees);
232
+ }
233
+ else {
234
+ return (amountOut * types_1.BASE_9) / (types_1.BASE_9 + Math.abs(-fees));
235
+ }
236
+ }
237
+ function _computeFee(quoteType, amount, fees) {
238
+ if (quoteType === types_1.QuoteType.MintExactInput) {
239
+ return _applyFeeMint(amount, fees);
240
+ }
241
+ else if (quoteType === types_1.QuoteType.MintExactOutput) {
242
+ return _invertFeeMint(amount, fees);
243
+ }
244
+ else if (quoteType === types_1.QuoteType.BurnExactInput) {
245
+ return _applyFeeBurn(amount, fees);
246
+ }
247
+ else {
248
+ return _invertFeeBurn(amount, fees);
249
+ }
250
+ }
251
+ function filterDictionaryOnly(obj) {
252
+ const result = {};
253
+ Object.keys(obj).map(key => {
254
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
255
+ // Skip numeric keys to exclude array-like properties
256
+ if (isNaN(Number(key))) {
257
+ result[key] = obj[key];
258
+ }
259
+ }
260
+ });
261
+ return result;
262
+ }
263
+ exports.filterDictionaryOnly = filterDictionaryOnly;
264
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/angle-transmuter/utils.ts"],"names":[],"mappings":";;;AAAA,mCAAyE;AAEzE,iHAAiH;AACjH,SAAgB,oBAAoB,CAClC,WAAmB,EACnB,QAAgB,EAChB,IAAU,EACV,iBAAyB,EACzB,qBAA6B;IAE7B,MAAM,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IACzC,OAAO,UAAU,CACf,IAAI,EACJ,iBAAS,CAAC,cAAc,EACxB,SAAS,EACT,iBAAiB,EACjB,qBAAqB,CACtB,CAAC;AACJ,CAAC;AAfD,oDAeC;AAED,oGAAoG;AACpG,SAAgB,qBAAqB,CACnC,WAAmB,EACnB,SAAiB,EACjB,IAAU,EACV,iBAAyB,EACzB,qBAA6B;IAE7B,MAAM,QAAQ,GAAG,UAAU,CACzB,IAAI,EACJ,iBAAS,CAAC,eAAe,EACzB,SAAS,EACT,iBAAiB,EACjB,qBAAqB,CACtB,CAAC;IACF,OAAO,QAAQ,GAAG,WAAW,CAAC;AAChC,CAAC;AAfD,sDAeC;AAED,iGAAiG;AAC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CAAC;AAED,SAAgB,oBAAoB,CAClC,GAAM;IAEN,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACzB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;YAClD,qDAAqD;YACrD,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBACtB,MAAM,CAAC,GAAc,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;aACnC;SACF;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAbD,oDAaC"}
@@ -9,3 +9,31 @@ export declare const HASHFLOW_API_URL = "https://api.hashflow.com";
9
9
  export declare const HASHFLOW_API_CLIENT_NAME = "paraswap";
10
10
  export declare const HASHFLOW_GAS_COST = 100000;
11
11
  export declare const HASHFLOW_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION: BigNumber;
12
+ export declare const RESTRICT_79_TTL_MS: number;
13
+ export declare const RESTRICT_SLIPPAGE_TTL_MS: number;
14
+ export declare const RESTRICT_84_TTL_MS: number;
15
+ export declare const RESTRICT_76_TTL_MS: number;
16
+ export declare const RESTRICT_82_TTL_MS: number;
17
+ export declare const RESTRICT_42_TTL_MS: number;
18
+ export declare const RESTRICT_85_TTL_MS: number;
19
+ export declare const RESTRICT_SOCKET_HANG_UP_TTL_MS: number;
20
+ export declare const RESTRICT_74_TTL_MS: number;
21
+ export declare const RESTRICT_UNKNOWN_TTL_MS: number;
22
+ export declare const RESTRICT_MISSING_QUOTE_DATA_TTL_MS: number;
23
+ export declare const RESTRICT_MISSING_SIGNATURE_TTL_MS: number;
24
+ export declare const UNKNOWN_ERROR_CODE = "UNKNOWN";
25
+ export declare const ERROR_CODE_TO_RESTRICT_TTL: {
26
+ '79': number;
27
+ SLIPPAGE: number;
28
+ '84': number;
29
+ '76': number;
30
+ '82': number;
31
+ '42': number;
32
+ '85': number;
33
+ '74': number;
34
+ MISSING_QUOTE_DATA: number;
35
+ MISSING_SIGNATURE_DATA: number;
36
+ UNKNOWN: number;
37
+ };
38
+ export declare const CONSECUTIVE_ERROR_TIMESPAN_MS: number;
39
+ export declare const CONSECUTIVE_ERROR_THRESHOLD = 3;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.HASHFLOW_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION = exports.HASHFLOW_GAS_COST = exports.HASHFLOW_API_CLIENT_NAME = exports.HASHFLOW_API_URL = exports.HASHFLOW_API_MARKET_MAKERS_POLLING_INTERVAL_MS = exports.HASHFLOW_API_PRICES_POLLING_INTERVAL_MS = exports.HASHFLOW_MARKET_MAKERS_CACHES_TTL_S = exports.HASHFLOW_PRICES_CACHES_TTL_S = exports.HASHFLOW_MM_RESTRICT_TTL_S = exports.HASHFLOW_BLACKLIST_TTL_S = void 0;
6
+ exports.CONSECUTIVE_ERROR_THRESHOLD = exports.CONSECUTIVE_ERROR_TIMESPAN_MS = exports.ERROR_CODE_TO_RESTRICT_TTL = exports.UNKNOWN_ERROR_CODE = exports.RESTRICT_MISSING_SIGNATURE_TTL_MS = exports.RESTRICT_MISSING_QUOTE_DATA_TTL_MS = exports.RESTRICT_UNKNOWN_TTL_MS = exports.RESTRICT_74_TTL_MS = exports.RESTRICT_SOCKET_HANG_UP_TTL_MS = exports.RESTRICT_85_TTL_MS = exports.RESTRICT_42_TTL_MS = exports.RESTRICT_82_TTL_MS = exports.RESTRICT_76_TTL_MS = exports.RESTRICT_84_TTL_MS = exports.RESTRICT_SLIPPAGE_TTL_MS = exports.RESTRICT_79_TTL_MS = exports.HASHFLOW_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION = exports.HASHFLOW_GAS_COST = exports.HASHFLOW_API_CLIENT_NAME = exports.HASHFLOW_API_URL = exports.HASHFLOW_API_MARKET_MAKERS_POLLING_INTERVAL_MS = exports.HASHFLOW_API_PRICES_POLLING_INTERVAL_MS = exports.HASHFLOW_MARKET_MAKERS_CACHES_TTL_S = exports.HASHFLOW_PRICES_CACHES_TTL_S = exports.HASHFLOW_MM_RESTRICT_TTL_S = exports.HASHFLOW_BLACKLIST_TTL_S = void 0;
7
7
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
8
  exports.HASHFLOW_BLACKLIST_TTL_S = 60 * 60 * 24 * 7; // 7 days
9
9
  exports.HASHFLOW_MM_RESTRICT_TTL_S = 60 * 60;
@@ -15,4 +15,34 @@ exports.HASHFLOW_API_URL = 'https://api.hashflow.com';
15
15
  exports.HASHFLOW_API_CLIENT_NAME = 'paraswap';
16
16
  exports.HASHFLOW_GAS_COST = 100000;
17
17
  exports.HASHFLOW_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION = new bignumber_js_1.default('0.001');
18
+ exports.RESTRICT_79_TTL_MS = 60 * 10 * 1000; // 10 mins
19
+ exports.RESTRICT_SLIPPAGE_TTL_MS = 60 * 5 * 1000; // 5 mins
20
+ exports.RESTRICT_84_TTL_MS = 60 * 10 * 1000; // 10 mins
21
+ exports.RESTRICT_76_TTL_MS = 60 * 5 * 1000; // 5 mins
22
+ exports.RESTRICT_82_TTL_MS = 60 * 5 * 1000; // 5 mins
23
+ exports.RESTRICT_42_TTL_MS = 60 * 5 * 1000; // 5 mins
24
+ exports.RESTRICT_85_TTL_MS = 60 * 5 * 1000; // 5 mins
25
+ exports.RESTRICT_SOCKET_HANG_UP_TTL_MS = 60 * 5 * 1000; // 5 mins
26
+ exports.RESTRICT_74_TTL_MS = 60 * 5 * 1000; // 5 mins
27
+ exports.RESTRICT_UNKNOWN_TTL_MS = 60 * 30 * 1000; // 30 mins
28
+ exports.RESTRICT_MISSING_QUOTE_DATA_TTL_MS = 60 * 5 * 1000; // 5 mins
29
+ exports.RESTRICT_MISSING_SIGNATURE_TTL_MS = 60 * 5 * 1000; // 5 mins
30
+ exports.UNKNOWN_ERROR_CODE = 'UNKNOWN';
31
+ exports.ERROR_CODE_TO_RESTRICT_TTL = {
32
+ '79': exports.RESTRICT_79_TTL_MS,
33
+ SLIPPAGE: exports.RESTRICT_SLIPPAGE_TTL_MS,
34
+ '84': exports.RESTRICT_84_TTL_MS,
35
+ '76': exports.RESTRICT_76_TTL_MS,
36
+ '82': exports.RESTRICT_82_TTL_MS,
37
+ '42': exports.RESTRICT_42_TTL_MS,
38
+ '85': exports.RESTRICT_85_TTL_MS,
39
+ // SOCKET_HANG_UP: RESTRICT_SOCKET_HANG_UP_TTL_MS, // Error: REST API error: ECONNRESET. socket hang up
40
+ '74': exports.RESTRICT_74_TTL_MS,
41
+ MISSING_QUOTE_DATA: exports.RESTRICT_MISSING_QUOTE_DATA_TTL_MS,
42
+ MISSING_SIGNATURE_DATA: exports.RESTRICT_MISSING_SIGNATURE_TTL_MS,
43
+ [exports.UNKNOWN_ERROR_CODE]: exports.RESTRICT_UNKNOWN_TTL_MS, // unknown error
44
+ };
45
+ // not actually consecutive, meaning is if the error appeared > CONSECUTIVE_ERROR_THRESHOLD times within CONSECUTIVE_ERROR_TIMESPAN_MS ms -> restrict mm for ERROR_CODE_TO_RESTRICT_TTL[errorCode] ms
46
+ exports.CONSECUTIVE_ERROR_TIMESPAN_MS = 60 * 60 * 1000; // 1 hour
47
+ exports.CONSECUTIVE_ERROR_THRESHOLD = 3;
18
48
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/hashflow/constants.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAExB,QAAA,wBAAwB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS;AAEtD,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,CAAC"}
@@ -6,7 +6,7 @@ import { IDexHelper } from '../../dex-helper/idex-helper';
6
6
  import { IDex } from '../../dex/idex';
7
7
  import { AdapterExchangeParam, Address, ExchangePrices, ExchangeTxInfo, Logger, OptimalSwapExchange, PoolLiquidity, PoolPrices, PreprocessTransactionOptions, SimpleExchangeParam, Token } from '../../types';
8
8
  import { SimpleExchange } from '../simple-exchange';
9
- import { HashflowData, PriceLevel } from './types';
9
+ import { ErrorCode, HashflowData, PriceLevel } from './types';
10
10
  export declare class Hashflow extends SimpleExchange implements IDex<HashflowData> {
11
11
  readonly network: Network;
12
12
  readonly dexKey: string;
@@ -24,6 +24,7 @@ export declare class Hashflow extends SimpleExchange implements IDex<HashflowDat
24
24
  private hashFlowAuthToken;
25
25
  private disabledMMs;
26
26
  private runtimeMMsRestrictHashMapKey;
27
+ private runtimeMMsRestrictHashMapErrorCodesKey;
27
28
  private pricesCacheKey;
28
29
  private marketMakersCacheKey;
29
30
  static dexKeysWithNetwork: {
@@ -54,7 +55,7 @@ export declare class Hashflow extends SimpleExchange implements IDex<HashflowDat
54
55
  normalizeToken(token: Token): Token;
55
56
  getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<HashflowData>>;
56
57
  preProcessTransaction(optimalSwapExchange: OptimalSwapExchange<HashflowData>, srcToken: Token, destToken: Token, side: SwapSide, options: PreprocessTransactionOptions): Promise<[OptimalSwapExchange<HashflowData>, ExchangeTxInfo]>;
57
- restrictMM(mm: string): Promise<void>;
58
+ restrictMM(mm: string, errorCode: ErrorCode): Promise<void>;
58
59
  getCalldataGasCost(poolPrices: PoolPrices<HashflowData>): number | number[];
59
60
  getTokenFromAddress?(address: Address): Token;
60
61
  getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: HashflowData, side: SwapSide): AdapterExchangeParam;
@@ -83,6 +83,8 @@ class Hashflow extends simple_exchange_1.SimpleExchange {
83
83
  this.disabledMMs = new Set(dexHelper.config.data.hashFlowDisabledMMs);
84
84
  this.runtimeMMsRestrictHashMapKey =
85
85
  `${constants_1.CACHE_PREFIX}_${this.dexKey}_${this.network}_restricted_mms`.toLowerCase();
86
+ this.runtimeMMsRestrictHashMapErrorCodesKey =
87
+ `${constants_1.CACHE_PREFIX}_${this.dexKey}_${this.network}_restricted_mms_error_codes`.toLowerCase();
86
88
  this.rateFetcher = new rate_fetcher_1.RateFetcher(this.dexHelper, this.dexKey, this.network, this.logger, {
87
89
  rateConfig: {
88
90
  pricesIntervalMs: constants_2.HASHFLOW_API_PRICES_POLLING_INTERVAL_MS,
@@ -363,17 +365,18 @@ class Hashflow extends simple_exchange_1.SimpleExchange {
363
365
  if (rfq.status !== 'success') {
364
366
  const message = `${this.dexKey}-${this.network}: Failed to fetch RFQ for ${this.getPairName(normalizedSrcToken.address, normalizedDestToken.address)}: ${JSON.stringify(rfq)}`;
365
367
  this.logger.warn(message);
366
- throw new types_2.RfqError(message);
368
+ // TODO: Fix types
369
+ throw new types_2.RfqError(message, `${rfq?.error?.code}`);
367
370
  }
368
371
  else if (!rfq.quotes[0].quoteData) {
369
372
  const message = `${this.dexKey}-${this.network}: Failed to fetch RFQ for ${this.getPairName(normalizedSrcToken.address, normalizedDestToken.address)}. Missing quote data`;
370
373
  this.logger.warn(message);
371
- throw new types_2.RfqError(message);
374
+ throw new types_2.RfqError(message, 'MISSING_QUOTE_DATA');
372
375
  }
373
376
  else if (!rfq.quotes[0].signature) {
374
377
  const message = `${this.dexKey}-${this.network}: Failed to fetch RFQ for ${this.getPairName(normalizedSrcToken.address, normalizedDestToken.address)}. Missing signature`;
375
378
  this.logger.warn(message);
376
- throw new types_2.RfqError(message);
379
+ throw new types_2.RfqError(message, 'MISSING_SIGNATURE_DATA');
377
380
  }
378
381
  (0, ts_essentials_1.assert)(rfq.quotes[0].quoteData.baseToken === normalizedSrcToken.address, `QuoteData baseToken=${rfq.quotes[0].quoteData.baseToken} is different from srcToken=${normalizedSrcToken.address}`);
379
382
  (0, ts_essentials_1.assert)(rfq.quotes[0].quoteData.quoteToken === normalizedDestToken.address, `QuoteData baseToken=${rfq.quotes[0].quoteData.quoteToken} is different from srcToken=${normalizedDestToken.address}`);
@@ -460,20 +463,92 @@ class Hashflow extends simple_exchange_1.SimpleExchange {
460
463
  }
461
464
  else {
462
465
  this.logger.warn(`${this.dexKey}-${this.network} MM unknown preprocess transaction error: ${e}`);
463
- await this.restrictMM(mm);
466
+ const code = e instanceof types_2.RfqError || e instanceof types_2.SlippageCheckError
467
+ ? e.code
468
+ : constants_2.UNKNOWN_ERROR_CODE;
469
+ await this.restrictMM(mm, code).catch(err => this.logger.warn(`Failed to restrict MM ${mm}: ${err}`));
464
470
  }
465
471
  }
466
472
  throw e;
467
473
  }
468
474
  }
469
- async restrictMM(mm) {
470
- this.logger.warn(`${this.dexKey}-${this.network}: ${mm} was restricted for ${constants_2.HASHFLOW_MM_RESTRICT_TTL_S} sec. due to fails`);
471
- // We use timestamp for creation date to later discern if it already expired or not
472
- await this.dexHelper.cache.hset(this.runtimeMMsRestrictHashMapKey, mm, Date.now().toString());
473
- // Expiry cache because it has levels for blacklisted MM
474
- this.dexHelper.cache.del(this.dexKey, this.network, 'levels').catch(e => {
475
- this.logger.error(`${this.dexKey}-${this.network}: Failed to delete levels cache: ${e.message}`);
476
- });
475
+ async restrictMM(mm, errorCode) {
476
+ const errorCodesRaw = await this.dexHelper.cache.hget(this.runtimeMMsRestrictHashMapErrorCodesKey, mm);
477
+ const errorCodes = utils_2.Utils.Parse(errorCodesRaw);
478
+ const error = errorCodes[errorCode];
479
+ if (!error) {
480
+ this.logger.warn(`First encounter of ${errorCode} for ${mm}, setting up counter`);
481
+ const data = {
482
+ ...errorCodes,
483
+ [errorCode]: {
484
+ count: 1,
485
+ addedDatetimeMS: Date.now(),
486
+ },
487
+ };
488
+ await this.dexHelper.cache.hset(this.runtimeMMsRestrictHashMapErrorCodesKey, mm, utils_2.Utils.Serialize(data));
489
+ return;
490
+ }
491
+ else {
492
+ const restrictTTLMs = constants_2.ERROR_CODE_TO_RESTRICT_TTL[errorCode] ||
493
+ constants_2.ERROR_CODE_TO_RESTRICT_TTL[constants_2.UNKNOWN_ERROR_CODE];
494
+ if (error.addedDatetimeMS + constants_2.CONSECUTIVE_ERROR_TIMESPAN_MS < Date.now()) {
495
+ this.logger.warn(`Error: ${errorCode} for ${mm} occured not within threshold timespan for restriction. Resetting counter`);
496
+ // Clear counter, this error code appeared after CONSECUTIVE_ERROR_TIMESPAN_MS
497
+ const data = {
498
+ ...errorCodes,
499
+ [errorCode]: {
500
+ count: 1,
501
+ addedDatetimeMS: Date.now(),
502
+ },
503
+ };
504
+ await this.dexHelper.cache.hset(this.runtimeMMsRestrictHashMapErrorCodesKey, mm, utils_2.Utils.Serialize(data));
505
+ return;
506
+ }
507
+ if (error.count + 1 > constants_2.CONSECUTIVE_ERROR_THRESHOLD) {
508
+ this.logger.warn(`${this.dexKey}-${this.network}: ${mm} was restricted for ${restrictTTLMs / 1000} sec. due to ${errorCode} happening ${error.count + 1} within last ${Math.floor(constants_2.CONSECUTIVE_ERROR_TIMESPAN_MS / 1000 / 60)} minutes`);
509
+ // date added is checked against HASHFLOW_MM_RESTRICT_TTL_S, as a hack we set a date so that it's checked against specific ttls based on error type to not change & increase time for parsing restricted mms during pricing request
510
+ // Example: ttl for a particular error is 20 minutes (< default 60 minutes)
511
+ //
512
+ // Meaning we need to set dateAdded for restrict hash as Date.now() + 40 minutes (diff between default restrict ttl=1h and particular error restrict ttl = 20 minutes). So the dateAdded is in the future, and after 20 minutes in pricing we'll clear that restriction
513
+ //
514
+ //
515
+ // Example 2: ttl for a particular error is 80 minutes (> default 60 minutes)
516
+ //
517
+ // Meaning we need to set dateAdded for restrict hash as Date.now() - 20 minutes, then after an hour (default) it'll still be 20 minutes left for restriction to be cleared
518
+ const defaultRestrictTTLMS = Math.floor(constants_2.HASHFLOW_MM_RESTRICT_TTL_S / 1000);
519
+ const dateModifierMS = defaultRestrictTTLMS > restrictTTLMs
520
+ ? defaultRestrictTTLMS - restrictTTLMs
521
+ : -(restrictTTLMs - defaultRestrictTTLMS);
522
+ const date = (Date.now() + dateModifierMS).toString();
523
+ // We use timestamp for creation date to later discern if it already expired or not
524
+ await this.dexHelper.cache.hset(this.runtimeMMsRestrictHashMapKey, mm, date);
525
+ // resetting error count
526
+ const data = {
527
+ ...errorCodes,
528
+ [errorCode]: null,
529
+ };
530
+ await this.dexHelper.cache.hset(this.runtimeMMsRestrictHashMapErrorCodesKey, mm, utils_2.Utils.Serialize(data));
531
+ // Expiry cache because it has levels for blacklisted MM
532
+ await this.dexHelper.cache
533
+ .del(this.dexKey, this.network, 'levels')
534
+ .catch(e => {
535
+ this.logger.error(`${this.dexKey}-${this.network}: Failed to delete levels cache: ${e.message}`);
536
+ });
537
+ return;
538
+ }
539
+ else {
540
+ const newCount = +error.count + 1;
541
+ this.logger.warn(`${this.dexKey}-${this.network}: ${mm} Error with code: ${errorCode} happenned ${newCount} (below limit: ${constants_2.CONSECUTIVE_ERROR_THRESHOLD}), updating counter`);
542
+ const data = {
543
+ ...errorCodes,
544
+ [errorCode]: {
545
+ count: newCount,
546
+ addedDatetimeMS: error.addedDatetimeMS, // initial date stays
547
+ },
548
+ };
549
+ await this.dexHelper.cache.hset(this.runtimeMMsRestrictHashMapErrorCodesKey, mm, utils_2.Utils.Serialize(data));
550
+ }
551
+ }
477
552
  }
478
553
  getCalldataGasCost(poolPrices) {
479
554
  // I am not sure if that is correct. If anybody know how to fix it,