@paraswap/dex-lib 3.8.22 → 3.8.23

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 (327) hide show
  1. package/.vscode/launch.json +16 -0
  2. package/.vscode/settings.json +3 -0
  3. package/build/abi/AaveV1_lending_pool.json +27 -0
  4. package/build/abi/Uncompressor.json +250 -0
  5. package/build/abi/integral/factory.json +333 -0
  6. package/build/abi/integral/oracle.json +501 -0
  7. package/build/abi/integral/pool.json +1041 -0
  8. package/build/abi/integral/relayer.json +1536 -0
  9. package/build/abi/oswap/oswap.abi.json +452 -0
  10. package/build/abi/platypus/asset.json +490 -0
  11. package/build/abi/platypus/avax-pool.json +820 -0
  12. package/build/abi/platypus/oracle.json +119 -0
  13. package/build/abi/platypus/pool.json +677 -0
  14. package/build/abi/smardex/all/smardex-router.json +648 -0
  15. package/build/abi/smardex/layer-1/smardex-factory.json +242 -0
  16. package/build/abi/smardex/layer-1/smardex-pool.json +506 -0
  17. package/build/abi/smardex/layer-2/smardex-factory.json +185 -0
  18. package/build/abi/smardex/layer-2/smardex-pool.json +578 -0
  19. package/build/abi/swaap-v1/pool.json +1346 -0
  20. package/build/dex/aave-v1/aave-v1.d.ts +33 -0
  21. package/build/dex/aave-v1/aave-v1.js +158 -0
  22. package/build/dex/aave-v1/aave-v1.js.map +1 -0
  23. package/build/dex/aave-v1/config.d.ts +11 -0
  24. package/build/dex/aave-v1/config.js +20 -0
  25. package/build/dex/aave-v1/config.js.map +1 -0
  26. package/build/dex/aave-v1/tokens-mainnet.json +134 -0
  27. package/build/dex/aave-v1/tokens.d.ts +3 -0
  28. package/build/dex/aave-v1/tokens.js +50 -0
  29. package/build/dex/aave-v1/tokens.js.map +1 -0
  30. package/build/dex/aave-v1/types.d.ts +12 -0
  31. package/build/dex/aave-v1/types.js +3 -0
  32. package/build/dex/aave-v1/types.js.map +1 -0
  33. package/build/dex/bProtocol.d.ts +18 -0
  34. package/build/dex/bProtocol.js +39 -0
  35. package/build/dex/bProtocol.js.map +1 -0
  36. package/build/dex/bancor.d.ts +26 -0
  37. package/build/dex/bancor.js +58 -0
  38. package/build/dex/bancor.js.map +1 -0
  39. package/build/dex/compound.d.ts +18 -0
  40. package/build/dex/compound.js +46 -0
  41. package/build/dex/compound.js.map +1 -0
  42. package/build/dex/curve-v2.d.ts +58 -0
  43. package/build/dex/curve-v2.js +180 -0
  44. package/build/dex/curve-v2.js.map +1 -0
  45. package/build/dex/dodo-v1.d.ts +33 -0
  46. package/build/dex/dodo-v1.js +63 -0
  47. package/build/dex/dodo-v1.js.map +1 -0
  48. package/build/dex/etherfi/etherfi.d.ts +26 -0
  49. package/build/dex/etherfi/etherfi.js +96 -0
  50. package/build/dex/etherfi/etherfi.js.map +1 -0
  51. package/build/dex/integral/config.d.ts +4 -0
  52. package/build/dex/integral/config.js +20 -0
  53. package/build/dex/integral/config.js.map +1 -0
  54. package/build/dex/integral/context.d.ts +40 -0
  55. package/build/dex/integral/context.js +158 -0
  56. package/build/dex/integral/context.js.map +1 -0
  57. package/build/dex/integral/helpers.d.ts +17 -0
  58. package/build/dex/integral/helpers.js +157 -0
  59. package/build/dex/integral/helpers.js.map +1 -0
  60. package/build/dex/integral/integral-factory.d.ts +24 -0
  61. package/build/dex/integral/integral-factory.js +95 -0
  62. package/build/dex/integral/integral-factory.js.map +1 -0
  63. package/build/dex/integral/integral-pool.d.ts +50 -0
  64. package/build/dex/integral/integral-pool.js +149 -0
  65. package/build/dex/integral/integral-pool.js.map +1 -0
  66. package/build/dex/integral/integral-pricing.d.ts +18 -0
  67. package/build/dex/integral/integral-pricing.js +114 -0
  68. package/build/dex/integral/integral-pricing.js.map +1 -0
  69. package/build/dex/integral/integral-relayer.d.ts +42 -0
  70. package/build/dex/integral/integral-relayer.js +192 -0
  71. package/build/dex/integral/integral-relayer.js.map +1 -0
  72. package/build/dex/integral/integral-token.d.ts +27 -0
  73. package/build/dex/integral/integral-token.js +59 -0
  74. package/build/dex/integral/integral-token.js.map +1 -0
  75. package/build/dex/integral/integral.d.ts +41 -0
  76. package/build/dex/integral/integral.js +376 -0
  77. package/build/dex/integral/integral.js.map +1 -0
  78. package/build/dex/integral/types.d.ts +85 -0
  79. package/build/dex/integral/types.js +9 -0
  80. package/build/dex/integral/types.js.map +1 -0
  81. package/build/dex/integral/utils-e2e.d.ts +9 -0
  82. package/build/dex/integral/utils-e2e.js +131 -0
  83. package/build/dex/integral/utils-e2e.js.map +1 -0
  84. package/build/dex/integral/utils.d.ts +17 -0
  85. package/build/dex/integral/utils.js +94 -0
  86. package/build/dex/integral/utils.js.map +1 -0
  87. package/build/dex/lido.d.ts +19 -0
  88. package/build/dex/lido.js +42 -0
  89. package/build/dex/lido.js.map +1 -0
  90. package/build/dex/maverick-v2/config.js +4 -0
  91. package/build/dex/maverick-v2/config.js.map +1 -1
  92. package/build/dex/maverick-v2/maverick-math/maverick-pool-math.js +4 -0
  93. package/build/dex/maverick-v2/maverick-math/maverick-pool-math.js.map +1 -1
  94. package/build/dex/maverick-v2/maverick-v2-pool.d.ts +1 -1
  95. package/build/dex/maverick-v2/maverick-v2-pool.js +8 -8
  96. package/build/dex/maverick-v2/maverick-v2-pool.js.map +1 -1
  97. package/build/dex/maverick-v2/maverick-v2.d.ts +5 -4
  98. package/build/dex/maverick-v2/maverick-v2.js +73 -63
  99. package/build/dex/maverick-v2/maverick-v2.js.map +1 -1
  100. package/build/dex/maverick-v2/types.d.ts +4 -0
  101. package/build/dex/onebit.d.ts +25 -0
  102. package/build/dex/onebit.js +42 -0
  103. package/build/dex/onebit.js.map +1 -0
  104. package/build/dex/oswap/config.d.ts +5 -0
  105. package/build/dex/oswap/config.js +31 -0
  106. package/build/dex/oswap/config.js.map +1 -0
  107. package/build/dex/oswap/oswap-pool.d.ts +51 -0
  108. package/build/dex/oswap/oswap-pool.js +150 -0
  109. package/build/dex/oswap/oswap-pool.js.map +1 -0
  110. package/build/dex/oswap/oswap.d.ts +46 -0
  111. package/build/dex/oswap/oswap.js +266 -0
  112. package/build/dex/oswap/oswap.js.map +1 -0
  113. package/build/dex/oswap/types.d.ts +20 -0
  114. package/build/dex/oswap/types.js +3 -0
  115. package/build/dex/oswap/types.js.map +1 -0
  116. package/build/dex/platypus/asset.d.ts +14 -0
  117. package/build/dex/platypus/asset.js +97 -0
  118. package/build/dex/platypus/asset.js.map +1 -0
  119. package/build/dex/platypus/config.d.ts +11 -0
  120. package/build/dex/platypus/config.js +69 -0
  121. package/build/dex/platypus/config.js.map +1 -0
  122. package/build/dex/platypus/platypus.d.ts +62 -0
  123. package/build/dex/platypus/platypus.js +442 -0
  124. package/build/dex/platypus/platypus.js.map +1 -0
  125. package/build/dex/platypus/pool-avax.d.ts +8 -0
  126. package/build/dex/platypus/pool-avax.js +54 -0
  127. package/build/dex/platypus/pool-avax.js.map +1 -0
  128. package/build/dex/platypus/pool-base.d.ts +19 -0
  129. package/build/dex/platypus/pool-base.js +86 -0
  130. package/build/dex/platypus/pool-base.js.map +1 -0
  131. package/build/dex/platypus/pool-pure.d.ts +8 -0
  132. package/build/dex/platypus/pool-pure.js +37 -0
  133. package/build/dex/platypus/pool-pure.js.map +1 -0
  134. package/build/dex/platypus/pool-subscriber.d.ts +14 -0
  135. package/build/dex/platypus/pool-subscriber.js +167 -0
  136. package/build/dex/platypus/pool-subscriber.js.map +1 -0
  137. package/build/dex/platypus/pool.d.ts +8 -0
  138. package/build/dex/platypus/pool.js +58 -0
  139. package/build/dex/platypus/pool.js.map +1 -0
  140. package/build/dex/platypus/types.d.ts +92 -0
  141. package/build/dex/platypus/types.js +10 -0
  142. package/build/dex/platypus/types.js.map +1 -0
  143. package/build/dex/quickswap/spiritswap-v3.d.ts +6 -0
  144. package/build/dex/quickswap/spiritswap-v3.js +19 -0
  145. package/build/dex/quickswap/spiritswap-v3.js.map +1 -0
  146. package/build/dex/sdai/config.d.ts +11 -0
  147. package/build/dex/sdai/config.js +21 -0
  148. package/build/dex/sdai/config.js.map +1 -0
  149. package/build/dex/sdai/constants.d.ts +2 -0
  150. package/build/dex/sdai/constants.js +6 -0
  151. package/build/dex/sdai/constants.js.map +1 -0
  152. package/build/dex/sdai/scripts/validate-state.d.ts +1 -0
  153. package/build/dex/sdai/scripts/validate-state.js +102 -0
  154. package/build/dex/sdai/scripts/validate-state.js.map +1 -0
  155. package/build/dex/sdai/sdai-pool.d.ts +16 -0
  156. package/build/dex/sdai/sdai-pool.js +85 -0
  157. package/build/dex/sdai/sdai-pool.js.map +1 -0
  158. package/build/dex/sdai/sdai.d.ts +51 -0
  159. package/build/dex/sdai/sdai.js +172 -0
  160. package/build/dex/sdai/sdai.js.map +1 -0
  161. package/build/dex/sdai/types.d.ts +21 -0
  162. package/build/dex/sdai/types.js +11 -0
  163. package/build/dex/sdai/types.js.map +1 -0
  164. package/build/dex/sdai/utils.d.ts +4 -0
  165. package/build/dex/sdai/utils.js +39 -0
  166. package/build/dex/sdai/utils.js.map +1 -0
  167. package/build/dex/smardex/config.d.ts +4 -0
  168. package/build/dex/smardex/config.js +64 -0
  169. package/build/dex/smardex/config.js.map +1 -0
  170. package/build/dex/smardex/constants.d.ts +18 -0
  171. package/build/dex/smardex/constants.js +33 -0
  172. package/build/dex/smardex/constants.js.map +1 -0
  173. package/build/dex/smardex/sdk/constants.d.ts +6 -0
  174. package/build/dex/smardex/sdk/constants.js +13 -0
  175. package/build/dex/smardex/sdk/constants.js.map +1 -0
  176. package/build/dex/smardex/sdk/core.d.ts +113 -0
  177. package/build/dex/smardex/sdk/core.js +499 -0
  178. package/build/dex/smardex/sdk/core.js.map +1 -0
  179. package/build/dex/smardex/sdk/errors.d.ts +15 -0
  180. package/build/dex/smardex/sdk/errors.js +22 -0
  181. package/build/dex/smardex/sdk/errors.js.map +1 -0
  182. package/build/dex/smardex/sdk/types.d.ts +62 -0
  183. package/build/dex/smardex/sdk/types.js +3 -0
  184. package/build/dex/smardex/sdk/types.js.map +1 -0
  185. package/build/dex/smardex/sdk/utils.d.ts +44 -0
  186. package/build/dex/smardex/sdk/utils.js +133 -0
  187. package/build/dex/smardex/sdk/utils.js.map +1 -0
  188. package/build/dex/smardex/smardex-event-pool.d.ts +28 -0
  189. package/build/dex/smardex/smardex-event-pool.js +119 -0
  190. package/build/dex/smardex/smardex-event-pool.js.map +1 -0
  191. package/build/dex/smardex/smardex.d.ts +65 -0
  192. package/build/dex/smardex/smardex.js +519 -0
  193. package/build/dex/smardex/smardex.js.map +1 -0
  194. package/build/dex/smardex/types.d.ts +55 -0
  195. package/build/dex/smardex/types.js +3 -0
  196. package/build/dex/smardex/types.js.map +1 -0
  197. package/build/dex/smoothy.d.ts +26 -0
  198. package/build/dex/smoothy.js +48 -0
  199. package/build/dex/smoothy.js.map +1 -0
  200. package/build/dex/solidly/forks-override/cone.d.ts +22 -0
  201. package/build/dex/solidly/forks-override/cone.js +53 -0
  202. package/build/dex/solidly/forks-override/cone.js.map +1 -0
  203. package/build/dex/solidly/forks-override/solisnek.d.ts +8 -0
  204. package/build/dex/solidly/forks-override/solisnek.js +15 -0
  205. package/build/dex/solidly/forks-override/solisnek.js.map +1 -0
  206. package/build/dex/stable-pool.d.ts +28 -0
  207. package/build/dex/stable-pool.js +62 -0
  208. package/build/dex/stable-pool.js.map +1 -0
  209. package/build/dex/swaap-v1/config.d.ts +17 -0
  210. package/build/dex/swaap-v1/config.js +56 -0
  211. package/build/dex/swaap-v1/config.js.map +1 -0
  212. package/build/dex/swaap-v1/constants.d.ts +6 -0
  213. package/build/dex/swaap-v1/constants.js +17 -0
  214. package/build/dex/swaap-v1/constants.js.map +1 -0
  215. package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +25 -0
  216. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +62 -0
  217. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +1 -0
  218. package/build/dex/swaap-v1/libraries/Const.d.ts +18 -0
  219. package/build/dex/swaap-v1/libraries/Const.js +26 -0
  220. package/build/dex/swaap-v1/libraries/Const.js.map +1 -0
  221. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +77 -0
  222. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +316 -0
  223. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +1 -0
  224. package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +75 -0
  225. package/build/dex/swaap-v1/libraries/LogExpMath.js +418 -0
  226. package/build/dex/swaap-v1/libraries/LogExpMath.js.map +1 -0
  227. package/build/dex/swaap-v1/libraries/MathMMM.d.ts +185 -0
  228. package/build/dex/swaap-v1/libraries/MathMMM.js +453 -0
  229. package/build/dex/swaap-v1/libraries/MathMMM.js.map +1 -0
  230. package/build/dex/swaap-v1/libraries/Num.d.ts +31 -0
  231. package/build/dex/swaap-v1/libraries/Num.js +167 -0
  232. package/build/dex/swaap-v1/libraries/Num.js.map +1 -0
  233. package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +23 -0
  234. package/build/dex/swaap-v1/libraries/PoolQuotations.js +131 -0
  235. package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +1 -0
  236. package/build/dex/swaap-v1/libraries/Struct.d.ts +56 -0
  237. package/build/dex/swaap-v1/libraries/Struct.js +3 -0
  238. package/build/dex/swaap-v1/libraries/Struct.js.map +1 -0
  239. package/build/dex/swaap-v1/swaap-v1-pool.d.ts +45 -0
  240. package/build/dex/swaap-v1/swaap-v1-pool.js +656 -0
  241. package/build/dex/swaap-v1/swaap-v1-pool.js.map +1 -0
  242. package/build/dex/swaap-v1/swaap-v1.d.ts +61 -0
  243. package/build/dex/swaap-v1/swaap-v1.js +369 -0
  244. package/build/dex/swaap-v1/swaap-v1.js.map +1 -0
  245. package/build/dex/swaap-v1/types.d.ts +106 -0
  246. package/build/dex/swaap-v1/types.js +9 -0
  247. package/build/dex/swaap-v1/types.js.map +1 -0
  248. package/build/dex/trader-joe-v2.1/optimizer.js +1 -4
  249. package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -1
  250. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  251. package/build/dex/trader-joe-v2.1.js +79 -0
  252. package/build/dex/trader-joe-v2.1.js.map +1 -0
  253. package/build/executor/compressor/Compressor.d.ts +23 -0
  254. package/build/executor/compressor/Compressor.js +144 -0
  255. package/build/executor/compressor/Compressor.js.map +1 -0
  256. package/build/executor/compressor/compress.d.ts +17 -0
  257. package/build/executor/compressor/compress.js +187 -0
  258. package/build/executor/compressor/compress.js.map +1 -0
  259. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
  260. package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
  261. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
  262. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
  263. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
  264. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
  265. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
  266. package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
  267. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
  268. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
  269. package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
  270. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
  271. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
  272. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
  273. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
  274. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
  275. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
  276. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
  277. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
  278. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
  279. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
  280. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
  281. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
  282. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
  283. package/build/executor/compressor/fetchSaved.d.ts +0 -0
  284. package/build/executor/compressor/fetchSaved.js +17 -0
  285. package/build/executor/compressor/fetchSaved.js.map +1 -0
  286. package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
  287. package/build/executor/compressor/utils/computeCostL2.js +14 -0
  288. package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
  289. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
  290. package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
  291. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
  292. package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
  293. package/build/executor/compressor/utils/getAllIndexes.js +12 -0
  294. package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
  295. package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
  296. package/build/executor/compressor/utils/getByteForAddress.js +14 -0
  297. package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
  298. package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
  299. package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
  300. package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
  301. package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
  302. package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
  303. package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
  304. package/build/executor/compressor/utils/intToByte.d.ts +2 -0
  305. package/build/executor/compressor/utils/intToByte.js +10 -0
  306. package/build/executor/compressor/utils/intToByte.js.map +1 -0
  307. package/package.json +1 -1
  308. package/src/abi/maverick-v2/MaverickV2Router.json +778 -0
  309. package/src/dex/maverick-v2/config.ts +4 -0
  310. package/src/dex/maverick-v2/maverick-math/maverick-pool-math.ts +5 -0
  311. package/src/dex/maverick-v2/maverick-v2-e2e.test.ts +21 -43
  312. package/src/dex/maverick-v2/maverick-v2-integration.test.ts +100 -96
  313. package/src/dex/maverick-v2/maverick-v2-pool.ts +8 -8
  314. package/src/dex/maverick-v2/maverick-v2.ts +111 -81
  315. package/src/dex/maverick-v2/types.ts +4 -0
  316. package/tests/constants-e2e.ts +9 -0
  317. package/.idea/aws.xml +0 -17
  318. package/.idea/codeStyles/Project.xml +0 -19
  319. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  320. package/.idea/misc.xml +0 -6
  321. package/.idea/modules.xml +0 -8
  322. package/.idea/paraswap-dex-lib.iml +0 -9
  323. package/.idea/prettier.xml +0 -7
  324. package/.idea/vcs.xml +0 -6
  325. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
  326. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
  327. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
@@ -27,9 +27,12 @@ import { MaverickV2EventPool } from './maverick-v2-pool';
27
27
  import { SUBGRAPH_TIMEOUT } from '../../constants';
28
28
  import { Interface } from '@ethersproject/abi';
29
29
  import MaverickV2PoolABI from '../../abi/maverick-v2/MaverickV2Pool.json';
30
+ import MaverickV2RouterABI from '../../abi/maverick-v2/MaverickV2Router.json';
30
31
  import ERC20ABI from '../../abi/erc20.json';
31
32
  import { extractReturnAmountPosition } from '../../executor/utils';
32
- const EFFICIENCY_FACTOR = 3;
33
+
34
+ const POOL_LIST_CACHE_KEY = 'maverickv2-pool-list';
35
+ const POOL_LIST_TTL_SECONDS = 60;
33
36
 
34
37
  export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
35
38
  pools: { [key: string]: MaverickV2EventPool } = {};
@@ -52,13 +55,14 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
52
55
  protected adapters = {},
53
56
  protected config = MaverickV2Config[dexKey][network],
54
57
  protected maverickV2Iface = new Interface(MaverickV2PoolABI),
58
+ protected maverickV2RouterIface = new Interface(MaverickV2RouterABI),
55
59
  ) {
56
60
  super(dexHelper, dexKey);
57
61
  this.logger = dexHelper.getLogger(dexKey);
58
62
  }
59
63
 
60
64
  async initializePricing(blockNumber: number) {
61
- const pools = await this._queryPoolsAPI(SUBGRAPH_TIMEOUT);
65
+ const pools = await this._queryPoolsAPI();
62
66
 
63
67
  await Promise.all(
64
68
  pools.map(async pool => {
@@ -97,15 +101,30 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
97
101
  return null;
98
102
  }
99
103
 
104
+ async getEventPools(srcToken: Token, destToken: Token) {
105
+ const fromToken = this.dexHelper.config.wrapETH(srcToken);
106
+ const toToken = this.dexHelper.config.wrapETH(destToken);
107
+
108
+ return Object.values(this.pools).filter((pool: MaverickV2EventPool) => {
109
+ const tokenA = pool.tokenA.address.toLowerCase();
110
+ const tokenB = pool.tokenB.address.toLowerCase();
111
+
112
+ const fromAddress = fromToken.address.toLowerCase();
113
+ const toAddress = toToken.address.toLowerCase();
114
+
115
+ return (
116
+ (tokenA === fromAddress && tokenB === toAddress) ||
117
+ (tokenA === toAddress && tokenB === fromAddress)
118
+ );
119
+ });
120
+ }
121
+
100
122
  async getPoolIdentifiers(
101
123
  srcToken: Token,
102
124
  destToken: Token,
103
125
  side: SwapSide,
104
126
  blockNumber: number,
105
127
  ): Promise<string[]> {
106
- // TODO:
107
- if (side === SwapSide.BUY) return [];
108
-
109
128
  const from = this.dexHelper.config.wrapETH(srcToken);
110
129
  const to = this.dexHelper.config.wrapETH(destToken);
111
130
 
@@ -113,25 +132,10 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
113
132
  return [];
114
133
  }
115
134
 
116
- const pools = await this.getPools(from, to);
135
+ const pools = await this.getEventPools(from, to);
117
136
  return pools.map(pool => pool.name);
118
137
  }
119
138
 
120
- async getPools(srcToken: Token, destToken: Token) {
121
- srcToken = this.dexHelper.config.wrapETH(srcToken);
122
- destToken = this.dexHelper.config.wrapETH(destToken);
123
-
124
- return Object.values(this.pools).filter((pool: MaverickV2EventPool) => {
125
- return (
126
- (pool.tokenA.address.toLowerCase() === srcToken.address.toLowerCase() ||
127
- pool.tokenA.address.toLowerCase() ===
128
- destToken.address.toLowerCase()) &&
129
- (pool.tokenB.address.toLowerCase() === srcToken.address.toLowerCase() ||
130
- pool.tokenB.address.toLowerCase() === destToken.address.toLowerCase())
131
- );
132
- });
133
- }
134
-
135
139
  async getPricesVolume(
136
140
  srcToken: Token,
137
141
  destToken: Token,
@@ -148,10 +152,7 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
148
152
  return null;
149
153
  }
150
154
 
151
- // TODO:
152
- if (side === SwapSide.BUY) return null;
153
-
154
- const allPools = await this.getPools(from, to);
155
+ const allPools = await this.getEventPools(from, to);
155
156
 
156
157
  const allowedPools = limitPools
157
158
  ? allPools.filter(pool => limitPools.includes(pool.name))
@@ -159,11 +160,9 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
159
160
 
160
161
  if (!allowedPools.length) return null;
161
162
 
162
- // const unitAmount = getBigIntPow(
163
- // side === SwapSide.BUY ? to.decimals : from.decimals,
164
- // );
165
-
166
- const unitAmount = getBigIntPow(from.decimals);
163
+ const unitAmount = getBigIntPow(
164
+ side === SwapSide.BUY ? to.decimals : from.decimals,
165
+ );
167
166
 
168
167
  const tasks = allowedPools.map(async (pool: MaverickV2EventPool) => {
169
168
  try {
@@ -173,8 +172,7 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
173
172
  return null;
174
173
  }
175
174
 
176
- // const [unit] = pool.swap(unitAmount, from, to, side === SwapSide.BUY);
177
- const [unit] = pool.swap(unitAmount, from, to, false);
175
+ const [unit] = pool.swap(unitAmount, from, to, side === SwapSide.BUY);
178
176
  let lastOutput = 1n;
179
177
 
180
178
  const dataList: [bigint, bigint][] = amounts.map(amount => {
@@ -182,8 +180,7 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
182
180
  return [0n, 0n];
183
181
  }
184
182
 
185
- // const output = pool.swap(amount, from, to, side === SwapSide.BUY);
186
- const output = pool.swap(amount, from, to, false);
183
+ const output = pool.swap(amount, from, to, side === SwapSide.BUY);
187
184
  lastOutput = output[0];
188
185
  return output;
189
186
  });
@@ -259,47 +256,60 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
259
256
  recipient: Address,
260
257
  data: MaverickV2Data,
261
258
  side: SwapSide,
262
- _: Context,
263
- executorAddress: Address,
264
259
  ): DexExchangeParam {
265
- // TODO:
266
- if (side === SwapSide.BUY) throw new Error(`Buy not supported`);
267
-
268
260
  const { pool } = data;
269
261
 
270
- srcToken = this.dexHelper.config.wrapETH(srcToken);
271
- destToken = this.dexHelper.config.wrapETH(destToken);
272
-
273
- const exchangeData = this.maverickV2Iface.encodeFunctionData('swap', [
274
- recipient,
275
- {
276
- amount: side === SwapSide.SELL ? srcAmount : destAmount,
277
- tokenAIn: data.tokenA.toLowerCase() === srcToken.toLowerCase(),
278
- // exactOutput: side === SwapSide.BUY,
279
- exactOutput: false,
280
- tickLimit:
281
- data.tokenA.toLowerCase() === srcToken.toLowerCase()
282
- ? BigInt(data.activeTick) + 100n
283
- : BigInt(data.activeTick) - 100n,
284
- },
285
- '0x',
286
- ]);
262
+ const from = this.dexHelper.config.wrapETH(srcToken);
263
+ const tokenAIn = data.tokenA.toLowerCase() === from.toLowerCase();
264
+ const tickLimit = tokenAIn
265
+ ? BigInt(data.activeTick) + 100n
266
+ : BigInt(data.activeTick) - 100n;
267
+
268
+ if (side === SwapSide.SELL) {
269
+ // Perform direct swap for SELL side
270
+
271
+ const exchangeData = this.maverickV2Iface.encodeFunctionData('swap', [
272
+ recipient,
273
+ {
274
+ amount: srcAmount,
275
+ tokenAIn,
276
+ exactOutput: false,
277
+ tickLimit,
278
+ },
279
+ '0x',
280
+ ]);
281
+
282
+ return {
283
+ needWrapNative: this.needWrapNative,
284
+ transferSrcTokenBeforeSwap: pool,
285
+ skipApproval: true,
286
+ targetExchange: pool,
287
+ dexFuncHasRecipient: true,
288
+ exchangeData,
289
+ returnAmountPos: extractReturnAmountPosition(
290
+ this.maverickV2Iface,
291
+ 'swap',
292
+ 'amountOut',
293
+ ),
294
+ };
295
+ }
296
+
297
+ // perform "exactOutputSingleMinimal" via MaverickV2's Router
298
+ const exchangeData = this.maverickV2RouterIface.encodeFunctionData(
299
+ 'exactOutputSingleMinimal',
300
+ [recipient, pool, tokenAIn, destAmount, tickLimit],
301
+ );
287
302
 
288
303
  return {
289
304
  needWrapNative: this.needWrapNative,
290
- transferSrcTokenBeforeSwap: pool,
291
- // skipApproval: true,
292
- targetExchange: pool,
305
+ targetExchange: this.config.routerAddress,
293
306
  dexFuncHasRecipient: true,
294
307
  exchangeData,
295
- returnAmountPos:
296
- side === SwapSide.SELL
297
- ? extractReturnAmountPosition(
298
- this.maverickV2Iface,
299
- 'swap',
300
- 'amountOut',
301
- )
302
- : undefined,
308
+ returnAmountPos: extractReturnAmountPosition(
309
+ this.maverickV2RouterIface,
310
+ 'exactOutputSingleMinimal',
311
+ 'amountOut_',
312
+ ),
303
313
  };
304
314
  }
305
315
 
@@ -318,9 +328,11 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
318
328
  tokenAddress: Address,
319
329
  limit: number,
320
330
  ): Promise<PoolLiquidity[]> {
321
- const _tokenAddress = this.dexHelper.config.wrapETH(tokenAddress);
331
+ const _tokenAddress = this.dexHelper.config
332
+ .wrapETH(tokenAddress)
333
+ .toLowerCase();
322
334
 
323
- const pools = await this._queryPoolsAPI(SUBGRAPH_TIMEOUT);
335
+ const pools = await this._queryPoolsAPI();
324
336
 
325
337
  if (!pools.length) {
326
338
  this.logger.error(
@@ -329,7 +341,7 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
329
341
  return [];
330
342
  }
331
343
 
332
- const filteredPools = _.filter(pools, pool => {
344
+ const filteredPools = pools.filter(pool => {
333
345
  return (
334
346
  pool.tokenA.address.toLowerCase() === _tokenAddress ||
335
347
  pool.tokenB.address.toLowerCase() === _tokenAddress
@@ -351,26 +363,44 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
351
363
  decimals: token.decimals,
352
364
  },
353
365
  ],
354
- liquidityUSD: pool.tvl.amount * EFFICIENCY_FACTOR,
366
+ liquidityUSD: pool.tvl.amount,
355
367
  };
356
368
  });
357
369
 
358
- return _.slice(
359
- _.sortBy(labeledPools, [pool => -1 * pool.liquidityUSD]),
360
- 0,
361
- limit,
362
- );
370
+ const sortedPools = _.sortBy(labeledPools, [
371
+ pool => -1 * pool.liquidityUSD,
372
+ ]);
373
+
374
+ return _.slice(sortedPools, 0, limit);
363
375
  }
364
376
 
365
- private async _queryPoolsAPI(
366
- timeout = 30000,
367
- ): Promise<PoolAPIResponse['pools'] | []> {
377
+ private async _queryPoolsAPI(): Promise<PoolAPIResponse['pools'] | []> {
378
+ let cachedPoolsJson = await this.dexHelper.cache.getAndCacheLocally(
379
+ this.dexKey,
380
+ this.network,
381
+ POOL_LIST_CACHE_KEY,
382
+ POOL_LIST_TTL_SECONDS,
383
+ );
384
+
385
+ if (cachedPoolsJson) return JSON.parse(cachedPoolsJson);
386
+
368
387
  try {
369
388
  const res = await this.dexHelper.httpRequest.get<PoolAPIResponse>(
370
389
  `${MAVERICK_API_URL}/api/v5/poolsNoBins/${this.network}`,
371
- timeout,
390
+ SUBGRAPH_TIMEOUT,
372
391
  );
373
- return res.pools || [];
392
+
393
+ const pools = res.pools || [];
394
+
395
+ await this.dexHelper.cache.setex(
396
+ this.dexKey,
397
+ this.network,
398
+ POOL_LIST_CACHE_KEY,
399
+ POOL_LIST_TTL_SECONDS,
400
+ JSON.stringify(pools),
401
+ );
402
+
403
+ return pools;
374
404
  } catch (e) {
375
405
  this.logger.error(`${this.dexKey}: can not query subgraph: `, e);
376
406
  return [];
@@ -120,6 +120,7 @@ export type MaverickV2Param = {
120
120
  };
121
121
 
122
122
  export type DexParams = {
123
+ routerAddress: string;
123
124
  quoterAddress: string;
124
125
  poolLensAddress: string;
125
126
  };
@@ -132,6 +133,9 @@ export type PoolAPIResponse = {
132
133
  lowerTick: number;
133
134
  tickSpacing: number;
134
135
  id: string;
136
+ volume: {
137
+ amount: number;
138
+ };
135
139
  tokenA: {
136
140
  name: string;
137
141
  symbol: string;
@@ -1248,6 +1248,10 @@ export const Tokens: {
1248
1248
  address: '0x6ab707aca953edaefbc4fd23ba73294241490620',
1249
1249
  decimals: 6,
1250
1250
  },
1251
+ GHO: {
1252
+ address: '0x7dff72693f6a4149b17e7c6314655f6a9f7c8b33',
1253
+ decimals: 18,
1254
+ },
1251
1255
  },
1252
1256
  [Network.OPTIMISM]: {
1253
1257
  DAI: {
@@ -1381,6 +1385,10 @@ export const Tokens: {
1381
1385
  },
1382
1386
  },
1383
1387
  [Network.BASE]: {
1388
+ wstETH: {
1389
+ address: `0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452`,
1390
+ decimals: 18,
1391
+ },
1384
1392
  PRIME: {
1385
1393
  address: '0xfA980cEd6895AC314E7dE34Ef1bFAE90a5AdD21b',
1386
1394
  decimals: 18,
@@ -1755,6 +1763,7 @@ export const Holders: {
1755
1763
  stataUSDT: '0xc5042f9d9a18e95547864438455c8f05b4987399',
1756
1764
  aaveUSDT: '0xAfa788fab589fe61C23DF76905558f4734444D67',
1757
1765
  crvUSD: '0x9755e99bdb99495d3d31d953785d993c6df8552e',
1766
+ GHO: '0xda39E48523770197EF3CbB70C1bf1cCCF9B4b1E7',
1758
1767
  },
1759
1768
  [Network.OPTIMISM]: {
1760
1769
  ETH: '0xF6D4E5a7c5215F91f59a95065190CCa24bf64554',
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>
@@ -1,7 +0,0 @@
1
- import { IDexHelper } from '../../dex-helper';
2
- import { BaseTraderJoeV2 } from './base';
3
- export declare class TraderJoeV21 extends BaseTraderJoeV2 {
4
- static dexKeys: string[];
5
- needWrapNative: boolean;
6
- constructor(dexHelper: IDexHelper);
7
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TraderJoeV21 = void 0;
7
- const abi_1 = require("@ethersproject/abi");
8
- const TraderJoeV21Router_json_1 = __importDefault(require("../../abi/TraderJoeV21Router.json"));
9
- const config_1 = require("./config");
10
- const base_1 = require("./base");
11
- class TraderJoeV21 extends base_1.BaseTraderJoeV2 {
12
- constructor(dexHelper) {
13
- super(dexHelper, 'traderjoev2.1', config_1.TRADERJOE_V2_1_ROUTER_ADDRESS[dexHelper.config.data.network], '2');
14
- this.needWrapNative = true;
15
- this.exchangeRouterInterface = new abi_1.Interface(TraderJoeV21Router_json_1.default);
16
- }
17
- }
18
- exports.TraderJoeV21 = TraderJoeV21;
19
- TraderJoeV21.dexKeys = ['traderjoev2.1'];
20
- //# sourceMappingURL=trader-joe-v2.1-new.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trader-joe-v2.1-new.js","sourceRoot":"","sources":["../../../src/dex/trader-joe-v2.1/trader-joe-v2.1-new.ts"],"names":[],"mappings":";;;;;;AACA,4CAA6D;AAC7D,gGAAsE;AACtE,qCAAyD;AACzD,iCAAyC;AAEzC,MAAa,YAAa,SAAQ,sBAAe;IAI/C,YAAY,SAAqB;QAC/B,KAAK,CACH,SAAS,EACT,eAAe,EACf,sCAA6B,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAC5D,GAAG,CACJ,CAAC;QARJ,mBAAc,GAAG,IAAI,CAAC;QAUpB,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAC1C,iCAAuC,CACxC,CAAC;IACJ,CAAC;;AAfH,oCAgBC;AAfQ,oBAAO,GAAG,CAAC,eAAe,CAAC,CAAC"}