@paraswap/dex-lib 2.28.9-take-surplus.0 → 2.28.9-take-surplus.1

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 (330) hide show
  1. package/build/abi/RamsesV2StateMulticall.abi.json +891 -0
  2. package/build/abi/aerodrome/aerodrome-pool-factory.json +586 -0
  3. package/build/abi/algebra/AlgebraFactory-v1_1.abi.json +250 -0
  4. package/build/abi/api3-proxy.json +53 -0
  5. package/build/abi/api3-server-v1.json +463 -0
  6. package/build/abi/nomiswap-v2/nomiswap-v2-pool.json +773 -0
  7. package/build/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
  8. package/build/abi/quick-perps/fast-price-events.json +70 -0
  9. package/build/abi/quick-perps/fast-price-feed.json +741 -0
  10. package/build/abi/quick-perps/reader.json +313 -0
  11. package/build/abi/quick-perps/vault-price-feed.json +323 -0
  12. package/build/abi/quick-perps/vault.json +1953 -0
  13. package/build/abi/quickPerps/fast-price-events.json +70 -0
  14. package/build/abi/quickPerps/fast-price-feed.json +748 -0
  15. package/build/abi/quickPerps/reader.json +313 -0
  16. package/build/abi/quickPerps/vault-price-feed.json +477 -0
  17. package/build/abi/quickPerps/vault.json +1953 -0
  18. package/build/abi/ramses-v2/RamsesV2Pool.abi.json +1599 -0
  19. package/build/abi/uniswap-v3/UniswapV3Factory.abi.json +148 -0
  20. package/build/abi/uniswap-v3/UniswapV3QuoterV2.abi.json +155 -0
  21. package/build/composed-event-subscriber.js +8 -2
  22. package/build/composed-event-subscriber.js.map +1 -1
  23. package/build/config.d.ts +0 -1
  24. package/build/config.js +75 -14
  25. package/build/config.js.map +1 -1
  26. package/build/constants.d.ts +2 -1
  27. package/build/constants.js +1 -0
  28. package/build/constants.js.map +1 -1
  29. package/build/dex/algebra/algebra-factory.d.ts +25 -0
  30. package/build/dex/algebra/algebra-factory.js +43 -0
  31. package/build/dex/algebra/algebra-factory.js.map +1 -0
  32. package/build/dex/algebra/algebra-pool-v1_1.d.ts +16 -2
  33. package/build/dex/algebra/algebra-pool-v1_1.js +166 -4
  34. package/build/dex/algebra/algebra-pool-v1_1.js.map +1 -1
  35. package/build/dex/algebra/algebra.d.ts +4 -1
  36. package/build/dex/algebra/algebra.js +42 -21
  37. package/build/dex/algebra/algebra.js.map +1 -1
  38. package/build/dex/algebra/config.js +1 -0
  39. package/build/dex/algebra/config.js.map +1 -1
  40. package/build/dex/algebra/lib/TickTable.js +51 -40
  41. package/build/dex/algebra/lib/TickTable.js.map +1 -1
  42. package/build/dex/algebra/types.d.ts +5 -2
  43. package/build/dex/algebra/utils.d.ts +3 -1
  44. package/build/dex/algebra/utils.js +59 -1
  45. package/build/dex/algebra/utils.js.map +1 -1
  46. package/build/dex/balancer-v2/balancer-v2.js +79 -6
  47. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  48. package/build/dex/balancer-v2/config.js +10 -2
  49. package/build/dex/balancer-v2/config.js.map +1 -1
  50. package/build/dex/balancer-v2/optimizer.js +38 -51
  51. package/build/dex/balancer-v2/optimizer.js.map +1 -1
  52. package/build/dex/balancer-v2/types.d.ts +0 -4
  53. package/build/dex/balancer-v2/types.js.map +1 -1
  54. package/build/dex/curve-v1/config.js +40 -38
  55. package/build/dex/curve-v1/config.js.map +1 -1
  56. package/build/dex/curve-v1-factory/config.js +17 -9
  57. package/build/dex/curve-v1-factory/config.js.map +1 -1
  58. package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +1 -1
  59. package/build/dex/curve-v1-factory/curve-v1-factory.js +205 -182
  60. package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
  61. package/build/dex/curve-v1-factory/curve-v1-pool-manager.d.ts +2 -1
  62. package/build/dex/curve-v1-factory/curve-v1-pool-manager.js +8 -2
  63. package/build/dex/curve-v1-factory/curve-v1-pool-manager.js.map +1 -1
  64. package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js +1 -0
  65. package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js.map +1 -1
  66. package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js +1 -0
  67. package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js.map +1 -1
  68. package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js +2 -1
  69. package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js.map +1 -1
  70. package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js +1 -0
  71. package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js.map +1 -1
  72. package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js +1 -0
  73. package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js.map +1 -1
  74. package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +61 -14
  75. package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
  76. package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js +1 -0
  77. package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js.map +1 -1
  78. package/build/dex/curve-v1-factory/price-handlers/functions/constants.js +10 -0
  79. package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
  80. package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js +1 -0
  81. package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js.map +1 -1
  82. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js +1 -0
  83. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js.map +1 -1
  84. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js +1 -0
  85. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js.map +1 -1
  86. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js +1 -0
  87. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js.map +1 -1
  88. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js +1 -0
  89. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js.map +1 -1
  90. package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js +1 -0
  91. package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js.map +1 -1
  92. package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js +1 -0
  93. package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
  94. package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js +11 -4
  95. package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js.map +1 -1
  96. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +1 -1
  97. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +2 -2
  98. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
  99. package/build/dex/curve-v1-factory/types.d.ts +4 -1
  100. package/build/dex/curve-v1-factory/types.js +1 -0
  101. package/build/dex/curve-v1-factory/types.js.map +1 -1
  102. package/build/dex/generic-rfq/generic-rfq.d.ts +2 -1
  103. package/build/dex/generic-rfq/generic-rfq.js +9 -5
  104. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  105. package/build/dex/generic-rfq/rate-fetcher.d.ts +1 -1
  106. package/build/dex/generic-rfq/rate-fetcher.js +2 -1
  107. package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
  108. package/build/dex/generic-rfq/types.d.ts +1 -0
  109. package/build/dex/generic-rfq/types.js.map +1 -1
  110. package/build/dex/hashflow/hashflow.d.ts +1 -0
  111. package/build/dex/hashflow/hashflow.js +1 -0
  112. package/build/dex/hashflow/hashflow.js.map +1 -1
  113. package/build/dex/idex.d.ts +1 -0
  114. package/build/dex/index.d.ts +1 -0
  115. package/build/dex/index.js +21 -0
  116. package/build/dex/index.js.map +1 -1
  117. package/build/dex/maverick-v1/config.js +9 -0
  118. package/build/dex/maverick-v1/config.js.map +1 -1
  119. package/build/dex/maverick-v1/maverick-v1.js +11 -2
  120. package/build/dex/maverick-v1/maverick-v1.js.map +1 -1
  121. package/build/dex/maverick-v1/scripts/event-sequence.d.ts +1 -0
  122. package/build/dex/maverick-v1/scripts/event-sequence.js +110 -0
  123. package/build/dex/maverick-v1/scripts/event-sequence.js.map +1 -0
  124. package/build/dex/pancakeswap-v3/config.js +17 -0
  125. package/build/dex/pancakeswap-v3/config.js.map +1 -1
  126. package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.d.ts +26 -0
  127. package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js +44 -0
  128. package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js.map +1 -0
  129. package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +3 -0
  130. package/build/dex/pancakeswap-v3/pancakeswap-v3.js +26 -2
  131. package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
  132. package/build/dex/quick-perps/config.d.ts +11 -0
  133. package/build/dex/quick-perps/config.js +27 -0
  134. package/build/dex/quick-perps/config.js.map +1 -0
  135. package/build/dex/quick-perps/fast-price-feed.d.ts +26 -0
  136. package/build/dex/quick-perps/fast-price-feed.js +176 -0
  137. package/build/dex/quick-perps/fast-price-feed.js.map +1 -0
  138. package/build/dex/quick-perps/pool.d.ts +21 -0
  139. package/build/dex/quick-perps/pool.js +225 -0
  140. package/build/dex/quick-perps/pool.js.map +1 -0
  141. package/build/dex/quick-perps/quick-perps.d.ts +52 -0
  142. package/build/dex/quick-perps/quick-perps.js +211 -0
  143. package/build/dex/quick-perps/quick-perps.js.map +1 -0
  144. package/build/dex/quick-perps/types.d.ts +98 -0
  145. package/build/dex/quick-perps/types.js +3 -0
  146. package/build/dex/quick-perps/types.js.map +1 -0
  147. package/build/dex/quick-perps/usdq.d.ts +15 -0
  148. package/build/dex/quick-perps/usdq.js +61 -0
  149. package/build/dex/quick-perps/usdq.js.map +1 -0
  150. package/build/dex/quick-perps/vault-price-feed.d.ts +43 -0
  151. package/build/dex/quick-perps/vault-price-feed.js +194 -0
  152. package/build/dex/quick-perps/vault-price-feed.js.map +1 -0
  153. package/build/dex/quick-perps/vault-utils.d.ts +8 -0
  154. package/build/dex/quick-perps/vault-utils.js +41 -0
  155. package/build/dex/quick-perps/vault-utils.js.map +1 -0
  156. package/build/dex/quick-perps/vault.d.ts +46 -0
  157. package/build/dex/quick-perps/vault.js +166 -0
  158. package/build/dex/quick-perps/vault.js.map +1 -0
  159. package/build/dex/solidly/config.js +52 -2
  160. package/build/dex/solidly/config.js.map +1 -1
  161. package/build/dex/solidly/forks-override/aerodrome.d.ts +14 -0
  162. package/build/dex/solidly/forks-override/aerodrome.js +48 -0
  163. package/build/dex/solidly/forks-override/aerodrome.js.map +1 -0
  164. package/build/dex/solidly/forks-override/equalizer.d.ts +20 -0
  165. package/build/dex/solidly/forks-override/equalizer.js +46 -0
  166. package/build/dex/solidly/forks-override/equalizer.js.map +1 -0
  167. package/build/dex/solidly/forks-override/ramses.d.ts +44 -0
  168. package/build/dex/solidly/forks-override/ramses.js +144 -0
  169. package/build/dex/solidly/forks-override/ramses.js.map +1 -0
  170. package/build/dex/solidly/forks-override/velodromeV2.d.ts +20 -0
  171. package/build/dex/solidly/forks-override/velodromeV2.js +50 -0
  172. package/build/dex/solidly/forks-override/velodromeV2.js.map +1 -0
  173. package/build/dex/solidly/solidly.js +4 -0
  174. package/build/dex/solidly/solidly.js.map +1 -1
  175. package/build/dex/uniswap-v2/nomiswap-v2.d.ts +24 -0
  176. package/build/dex/uniswap-v2/nomiswap-v2.js +44 -0
  177. package/build/dex/uniswap-v2/nomiswap-v2.js.map +1 -0
  178. package/build/dex/uniswap-v3/config.js +166 -0
  179. package/build/dex/uniswap-v3/config.js.map +1 -1
  180. package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.d.ts +19 -0
  181. package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.js +99 -0
  182. package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.js.map +1 -0
  183. package/build/dex/uniswap-v3/forks/ramses-v2/utils.d.ts +4 -0
  184. package/build/dex/uniswap-v3/forks/ramses-v2/utils.js +63 -0
  185. package/build/dex/uniswap-v3/forks/ramses-v2/utils.js.map +1 -0
  186. package/build/dex/uniswap-v3/types.d.ts +10 -1
  187. package/build/dex/uniswap-v3/types.js.map +1 -1
  188. package/build/dex/uniswap-v3/uniswap-v3-factory.d.ts +26 -0
  189. package/build/dex/uniswap-v3/uniswap-v3-factory.js +44 -0
  190. package/build/dex/uniswap-v3/uniswap-v3-factory.js.map +1 -0
  191. package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +8 -6
  192. package/build/dex/uniswap-v3/uniswap-v3-pool.js +5 -2
  193. package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
  194. package/build/dex/uniswap-v3/uniswap-v3.d.ts +7 -4
  195. package/build/dex/uniswap-v3/uniswap-v3.js +51 -10
  196. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  197. package/build/dex/weth/config.js +3 -0
  198. package/build/dex/weth/config.js.map +1 -1
  199. package/build/dex/woo-fi-v2/config.js +13 -0
  200. package/build/dex/woo-fi-v2/config.js.map +1 -1
  201. package/build/dex-helper/dummy-dex-helper.js +7 -1
  202. package/build/dex-helper/dummy-dex-helper.js.map +1 -1
  203. package/build/dex-helper/icache.d.ts +1 -0
  204. package/build/lib/api3-feed.d.ts +30 -0
  205. package/build/lib/api3-feed.js +100 -0
  206. package/build/lib/api3-feed.js.map +1 -0
  207. package/build/lib/decoders.d.ts +3 -0
  208. package/build/lib/decoders.js +9 -1
  209. package/build/lib/decoders.js.map +1 -1
  210. package/build/stateful-event-subscriber.d.ts +1 -0
  211. package/build/stateful-event-subscriber.js +6 -0
  212. package/build/stateful-event-subscriber.js.map +1 -1
  213. package/build/types.d.ts +2 -0
  214. package/build/workers.d.ts +0 -0
  215. package/build/workers.js +2 -0
  216. package/build/workers.js.map +1 -0
  217. package/package.json +1 -1
  218. package/src/abi/RamsesV2Pool.abi.json +1554 -0
  219. package/src/abi/RamsesV2Quoter.abi.json +274 -0
  220. package/src/abi/RamsesV2StateMulticall.abi.json +891 -0
  221. package/src/abi/aerodrome/aerodrome-pool-factory.json +586 -0
  222. package/src/abi/algebra/AlgebraFactory-v1_1.abi.json +250 -0
  223. package/src/abi/api3-proxy.json +53 -0
  224. package/src/abi/api3-server-v1.json +463 -0
  225. package/src/abi/nomiswap-v2/nomiswap-v2-pool.json +773 -0
  226. package/src/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
  227. package/src/abi/quick-perps/fast-price-events.json +70 -0
  228. package/src/abi/quick-perps/fast-price-feed.json +741 -0
  229. package/src/abi/quick-perps/reader.json +313 -0
  230. package/src/abi/quick-perps/vault-price-feed.json +323 -0
  231. package/src/abi/quick-perps/vault.json +1953 -0
  232. package/src/abi/ramses-v2/RamsesV2Pool.abi.json +1599 -0
  233. package/src/composed-event-subscriber.ts +16 -11
  234. package/src/config.ts +80 -14
  235. package/src/constants.ts +1 -0
  236. package/src/dex/algebra/algebra-factory.ts +70 -0
  237. package/src/dex/algebra/algebra-integration.test.ts +316 -16
  238. package/src/dex/algebra/algebra-pool-v1_1.ts +259 -8
  239. package/src/dex/algebra/algebra.ts +73 -22
  240. package/src/dex/algebra/config.ts +1 -0
  241. package/src/dex/algebra/lib/TickTable.ts +75 -74
  242. package/src/dex/algebra/types.ts +6 -2
  243. package/src/dex/algebra/utils.ts +83 -2
  244. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +133 -4
  245. package/src/dex/balancer-v2/balancer-v2.ts +87 -6
  246. package/src/dex/balancer-v2/config.ts +11 -2
  247. package/src/dex/balancer-v2/optimizer.ts +49 -62
  248. package/src/dex/balancer-v2/types.ts +0 -4
  249. package/src/dex/curve-v1/config.ts +40 -38
  250. package/src/dex/curve-v1-factory/config.ts +17 -9
  251. package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +19 -0
  252. package/src/dex/curve-v1-factory/curve-v1-factory-integration.test.ts +165 -45
  253. package/src/dex/curve-v1-factory/curve-v1-factory.ts +477 -415
  254. package/src/dex/curve-v1-factory/curve-v1-pool-manager.ts +15 -2
  255. package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +1 -0
  256. package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +1 -0
  257. package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +2 -1
  258. package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +1 -0
  259. package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +1 -0
  260. package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +71 -13
  261. package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +1 -0
  262. package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +11 -0
  263. package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +2 -0
  264. package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +1 -0
  265. package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +1 -0
  266. package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +1 -0
  267. package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +1 -0
  268. package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +1 -0
  269. package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +1 -0
  270. package/src/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.ts +13 -5
  271. package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +2 -1
  272. package/src/dex/curve-v1-factory/types.ts +3 -1
  273. package/src/dex/generic-rfq/example-api.test.ts +1 -1
  274. package/src/dex/generic-rfq/generic-rfq.ts +12 -4
  275. package/src/dex/generic-rfq/rate-fetcher.ts +4 -2
  276. package/src/dex/generic-rfq/types.ts +1 -0
  277. package/src/dex/hashflow/hashflow-e2e.test.ts +36 -3
  278. package/src/dex/hashflow/hashflow.ts +2 -1
  279. package/src/dex/idex.ts +1 -0
  280. package/src/dex/index.ts +21 -0
  281. package/src/dex/maverick-v1/config.ts +10 -0
  282. package/src/dex/maverick-v1/maverick-v1-e2e.test.ts +115 -1
  283. package/src/dex/maverick-v1/maverick-v1.ts +12 -2
  284. package/src/dex/pancakeswap-v3/config.ts +19 -0
  285. package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +114 -0
  286. package/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts +73 -0
  287. package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +50 -2
  288. package/src/dex/quick-perps/config.ts +31 -0
  289. package/src/dex/quick-perps/fast-price-feed.ts +279 -0
  290. package/src/dex/quick-perps/pool.ts +407 -0
  291. package/src/dex/quick-perps/quick-perps-e2e.test.ts +65 -0
  292. package/src/dex/quick-perps/quick-perps-events.test.ts +100 -0
  293. package/src/dex/quick-perps/quick-perps-integration.test.ts +153 -0
  294. package/src/dex/quick-perps/quick-perps.ts +302 -0
  295. package/src/dex/quick-perps/types.ts +97 -0
  296. package/src/dex/quick-perps/usdq.ts +83 -0
  297. package/src/dex/quick-perps/vault-price-feed.ts +322 -0
  298. package/src/dex/quick-perps/vault-utils.ts +53 -0
  299. package/src/dex/quick-perps/vault.ts +290 -0
  300. package/src/dex/solidly/config.ts +58 -2
  301. package/src/dex/solidly/forks-override/aerodrome.ts +53 -0
  302. package/src/dex/solidly/forks-override/equalizer.ts +58 -0
  303. package/src/dex/solidly/forks-override/ramses.ts +253 -0
  304. package/src/dex/solidly/forks-override/velodromeV2.ts +63 -0
  305. package/src/dex/solidly/solidly-e2e.test.ts +313 -1
  306. package/src/dex/solidly/solidly-integration.test.ts +540 -41
  307. package/src/dex/solidly/solidly.ts +5 -0
  308. package/src/dex/uniswap-v2/nomiswap-v2.ts +63 -0
  309. package/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +120 -1
  310. package/src/dex/uniswap-v3/config.ts +174 -0
  311. package/src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts +156 -0
  312. package/src/dex/uniswap-v3/forks/ramses-v2/utils.ts +72 -0
  313. package/src/dex/uniswap-v3/types.ts +14 -1
  314. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +1071 -346
  315. package/src/dex/uniswap-v3/uniswap-v3-factory.ts +73 -0
  316. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +787 -14
  317. package/src/dex/uniswap-v3/uniswap-v3-pool.ts +13 -5
  318. package/src/dex/uniswap-v3/uniswap-v3.ts +87 -20
  319. package/src/dex/weth/config.ts +3 -0
  320. package/src/dex/woo-fi-v2/config.ts +13 -0
  321. package/src/dex/woo-fi-v2/woo-fi-v2-e2e.test.ts +64 -0
  322. package/src/dex-helper/dummy-dex-helper.ts +8 -1
  323. package/src/dex-helper/icache.ts +2 -0
  324. package/src/lib/api3-feed.ts +175 -0
  325. package/src/lib/decoders.ts +13 -0
  326. package/src/stateful-event-subscriber.ts +8 -0
  327. package/src/types.ts +2 -0
  328. package/tests/constants-e2e.ts +102 -6
  329. package/tests/tenderly-simulation.ts +48 -4
  330. package/tests/utils-e2e.ts +21 -11
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  import dotenv from 'dotenv';
2
3
  dotenv.config();
3
4
 
@@ -12,6 +13,10 @@ import solidlyPairABI from '../../abi/solidly/SolidlyPair.json';
12
13
  import { SpiritSwapV2 } from './forks-override/spiritSwapV2';
13
14
  import { Cone } from './forks-override/cone';
14
15
  import { Chronos } from './forks-override/chronos';
16
+ import { Ramses } from './forks-override/ramses';
17
+ import * as util from 'util';
18
+ import { VelodromeV2 } from './forks-override/velodromeV2';
19
+ import { Equalizer } from './forks-override/equalizer';
15
20
 
16
21
  const amounts18 = [0n, BI_POWS[18], 2000000000000000000n];
17
22
  const amounts6 = [0n, BI_POWS[6], 2000000n];
@@ -43,7 +48,7 @@ function decodeReaderResult(
43
48
  const constructCheckOnChainPricing =
44
49
  (dexHelper: DummyDexHelper) =>
45
50
  async (
46
- soldily: Solidly,
51
+ solidly: Solidly,
47
52
  funcName: string,
48
53
  blockNumber: number,
49
54
  prices: bigint[],
@@ -60,7 +65,7 @@ const constructCheckOnChainPricing =
60
65
  funcName,
61
66
  tokenIn,
62
67
  );
63
- console.log('readerCallData', readerCallData);
68
+
64
69
  const readerResult = (
65
70
  await dexHelper.multiContract.methods
66
71
  .aggregate(readerCallData)
@@ -70,6 +75,8 @@ const constructCheckOnChainPricing =
70
75
  decodeReaderResult(readerResult, readerIface, funcName),
71
76
  );
72
77
 
78
+ console.log('ON-CHAIN PRICES: ', expectedPrices);
79
+
73
80
  expect(prices.map(p => p.toString())).toEqual(
74
81
  expectedPrices.map(p => p.toString()),
75
82
  );
@@ -83,7 +90,7 @@ describe('Solidly integration tests', () => {
83
90
 
84
91
  describe('Solidly', function () {
85
92
  const dexKey = 'Solidly';
86
- const soldily = new Solidly(network, dexKey, dexHelper);
93
+ const solidly = new Solidly(network, dexKey, dexHelper);
87
94
 
88
95
  describe('UniswapV2 like pool', function () {
89
96
  const TokenASymbol = 'WFTM';
@@ -95,7 +102,7 @@ describe('Solidly integration tests', () => {
95
102
 
96
103
  it('getPoolIdentifiers and getPricesVolume', async function () {
97
104
  const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
98
- const pools = await soldily.getPoolIdentifiers(
105
+ const pools = await solidly.getPoolIdentifiers(
99
106
  tokenA,
100
107
  tokenB,
101
108
  SwapSide.SELL,
@@ -108,7 +115,7 @@ describe('Solidly integration tests', () => {
108
115
 
109
116
  expect(pools.length).toBeGreaterThan(0);
110
117
 
111
- const poolPrices = await soldily.getPricesVolume(
118
+ const poolPrices = await solidly.getPricesVolume(
112
119
  tokenA,
113
120
  tokenB,
114
121
  amounts,
@@ -126,13 +133,13 @@ describe('Solidly integration tests', () => {
126
133
 
127
134
  // Check if onchain pricing equals to calculated ones
128
135
 
129
- for (const i in poolPrices || []) {
136
+ for (const poolPrice of poolPrices || []) {
130
137
  await checkOnChainPricing(
131
- soldily,
138
+ solidly,
132
139
  'getAmountOut',
133
140
  blocknumber,
134
- poolPrices![i].prices,
135
- poolPrices![i].poolAddresses![0],
141
+ poolPrice.prices,
142
+ poolPrice.poolAddresses![0],
136
143
  tokenA.address,
137
144
  amounts,
138
145
  );
@@ -140,7 +147,7 @@ describe('Solidly integration tests', () => {
140
147
  });
141
148
 
142
149
  it('getTopPoolsForToken', async function () {
143
- const poolLiquidity = await soldily.getTopPoolsForToken(
150
+ const poolLiquidity = await solidly.getTopPoolsForToken(
144
151
  tokenA.address,
145
152
  10,
146
153
  );
@@ -160,7 +167,7 @@ describe('Solidly integration tests', () => {
160
167
 
161
168
  it('getPoolIdentifiers and getPricesVolume', async function () {
162
169
  const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
163
- const pools = await soldily.getPoolIdentifiers(
170
+ const pools = await solidly.getPoolIdentifiers(
164
171
  tokenA,
165
172
  tokenB,
166
173
  SwapSide.SELL,
@@ -173,7 +180,7 @@ describe('Solidly integration tests', () => {
173
180
 
174
181
  expect(pools.length).toBeGreaterThan(0);
175
182
 
176
- const poolPrices = await soldily.getPricesVolume(
183
+ const poolPrices = await solidly.getPricesVolume(
177
184
  tokenA,
178
185
  tokenB,
179
186
  amounts,
@@ -190,13 +197,13 @@ describe('Solidly integration tests', () => {
190
197
  checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
191
198
 
192
199
  // Check if onchain pricing equals to calculated ones
193
- for (const i in poolPrices || []) {
200
+ for (const poolPrice of poolPrices || []) {
194
201
  await checkOnChainPricing(
195
- soldily,
202
+ solidly,
196
203
  'getAmountOut',
197
204
  blocknumber,
198
- poolPrices![i].prices,
199
- poolPrices![i].poolAddresses![0],
205
+ poolPrice.prices,
206
+ poolPrice.poolAddresses![0],
200
207
  tokenA.address,
201
208
  amounts,
202
209
  );
@@ -204,7 +211,7 @@ describe('Solidly integration tests', () => {
204
211
  });
205
212
 
206
213
  it('getTopPoolsForToken', async function () {
207
- const poolLiquidity = await soldily.getTopPoolsForToken(
214
+ const poolLiquidity = await solidly.getTopPoolsForToken(
208
215
  tokenA.address,
209
216
  10,
210
217
  );
@@ -260,13 +267,13 @@ describe('Solidly integration tests', () => {
260
267
 
261
268
  // Check if onchain pricing equals to calculated ones
262
269
 
263
- for (const i in poolPrices || []) {
270
+ for (const poolPrice of poolPrices || []) {
264
271
  await checkOnChainPricing(
265
272
  spiritSwapV2,
266
273
  'getAmountOut',
267
274
  blocknumber,
268
- poolPrices![i].prices,
269
- poolPrices![i].poolAddresses![0],
275
+ poolPrice.prices,
276
+ poolPrice.poolAddresses![0],
270
277
  tokenA.address,
271
278
  amounts,
272
279
  );
@@ -324,13 +331,13 @@ describe('Solidly integration tests', () => {
324
331
  checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
325
332
 
326
333
  // Check if onchain pricing equals to calculated ones
327
- for (const i in poolPrices || []) {
334
+ for (const poolPrice of poolPrices || []) {
328
335
  await checkOnChainPricing(
329
336
  spiritSwapV2,
330
337
  'getAmountOut',
331
338
  blocknumber,
332
- poolPrices![i].prices,
333
- poolPrices![i].poolAddresses![0],
339
+ poolPrice.prices,
340
+ poolPrice.poolAddresses![0],
334
341
  tokenA.address,
335
342
  amounts,
336
343
  );
@@ -348,6 +355,176 @@ describe('Solidly integration tests', () => {
348
355
  });
349
356
  });
350
357
  });
358
+
359
+ describe('Equalizer', () => {
360
+ const dexKey = 'Equalizer';
361
+ const equalizer = new Equalizer(network, dexKey, dexHelper);
362
+
363
+ describe('UniswapV2 like pool', function () {
364
+ const TokenASymbol = 'WFTM';
365
+ const tokenA = Tokens[network][TokenASymbol];
366
+ const TokenBSymbol = 'FUSDT';
367
+ const tokenB = Tokens[network][TokenBSymbol];
368
+
369
+ const amounts = amounts18;
370
+
371
+ it('getPoolIdentifiers and getPricesVolume', async function () {
372
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
373
+ const pools = await equalizer.getPoolIdentifiers(
374
+ tokenA,
375
+ tokenB,
376
+ SwapSide.SELL,
377
+ blocknumber,
378
+ );
379
+ console.log(
380
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
381
+ pools,
382
+ );
383
+
384
+ expect(pools.length).toBeGreaterThan(0);
385
+
386
+ const poolPrices = await equalizer.getPricesVolume(
387
+ tokenA,
388
+ tokenB,
389
+ amounts,
390
+ SwapSide.SELL,
391
+ blocknumber,
392
+ pools,
393
+ );
394
+ console.log(
395
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
396
+ poolPrices,
397
+ );
398
+
399
+ expect(poolPrices).not.toBeNull();
400
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
401
+
402
+ // Check if onchain pricing equals to calculated ones
403
+
404
+ for (const poolPrice of poolPrices || []) {
405
+ await checkOnChainPricing(
406
+ equalizer,
407
+ 'getAmountOut',
408
+ blocknumber,
409
+ poolPrice.prices,
410
+ poolPrice.poolAddresses![0],
411
+ tokenA.address,
412
+ amounts,
413
+ );
414
+ }
415
+ });
416
+ });
417
+
418
+ describe('Curve like stable pool', function () {
419
+ const TokenASymbol = 'FUSDT';
420
+ const tokenA = Tokens[network][TokenASymbol];
421
+ const TokenBSymbol = 'USDC';
422
+ const tokenB = Tokens[network][TokenBSymbol];
423
+
424
+ const amounts = amounts6; // amounts6;
425
+
426
+ it('getPoolIdentifiers and getPricesVolume', async function () {
427
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
428
+ const pools = await equalizer.getPoolIdentifiers(
429
+ tokenA,
430
+ tokenB,
431
+ SwapSide.SELL,
432
+ blocknumber,
433
+ );
434
+ console.log(
435
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
436
+ pools,
437
+ );
438
+
439
+ expect(pools.length).toBeGreaterThan(0);
440
+
441
+ const poolPrices = await equalizer.getPricesVolume(
442
+ tokenA,
443
+ tokenB,
444
+ amounts,
445
+ SwapSide.SELL,
446
+ blocknumber,
447
+ pools,
448
+ );
449
+ console.log(
450
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
451
+ poolPrices,
452
+ );
453
+
454
+ expect(poolPrices).not.toBeNull();
455
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
456
+
457
+ // Check if onchain pricing equals to calculated ones
458
+ for (const poolPrice of poolPrices || []) {
459
+ await checkOnChainPricing(
460
+ equalizer,
461
+ 'getAmountOut',
462
+ blocknumber,
463
+ poolPrice.prices,
464
+ poolPrice.poolAddresses![0],
465
+ tokenA.address,
466
+ amounts,
467
+ );
468
+ }
469
+ });
470
+ });
471
+
472
+ describe('FTM -> EQUAL', () => {
473
+ const TokenASymbol = 'WFTM';
474
+ const tokenA = Tokens[network][TokenASymbol];
475
+ const TokenBSymbol = 'EQUAL';
476
+ const tokenB = Tokens[network][TokenBSymbol];
477
+
478
+ const amounts = [0n, 10000000n];
479
+
480
+ console.log('AMOUNTS: ', amounts);
481
+ it('getPoolIdentifiers and getPricesVolume', async function () {
482
+ // const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
483
+ const blocknumber = 67666611;
484
+ const pools = await equalizer.getPoolIdentifiers(
485
+ tokenA,
486
+ tokenB,
487
+ SwapSide.SELL,
488
+ blocknumber,
489
+ );
490
+ console.log(
491
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
492
+ pools,
493
+ );
494
+
495
+ expect(pools.length).toBeGreaterThan(0);
496
+
497
+ const poolPrices = await equalizer.getPricesVolume(
498
+ tokenA,
499
+ tokenB,
500
+ amounts,
501
+ SwapSide.SELL,
502
+ blocknumber,
503
+ pools,
504
+ );
505
+ console.log(
506
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
507
+ poolPrices,
508
+ );
509
+
510
+ expect(poolPrices).not.toBeNull();
511
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
512
+
513
+ // Check if onchain pricing equals to calculated ones
514
+ for (const poolPrice of poolPrices || []) {
515
+ await checkOnChainPricing(
516
+ equalizer,
517
+ 'getAmountOut',
518
+ blocknumber,
519
+ poolPrice.prices,
520
+ poolPrice.poolAddresses![0],
521
+ tokenA.address,
522
+ amounts,
523
+ );
524
+ }
525
+ });
526
+ });
527
+ });
351
528
  });
352
529
 
353
530
  describe('Polygon', () => {
@@ -400,13 +577,13 @@ describe('Solidly integration tests', () => {
400
577
 
401
578
  // Check if onchain pricing equals to calculated ones
402
579
 
403
- for (const i in poolPrices || []) {
580
+ for (const poolPrice of poolPrices || []) {
404
581
  await checkOnChainPricing(
405
582
  dystopia,
406
583
  'getAmountOut',
407
584
  blocknumber,
408
- poolPrices![i].prices,
409
- poolPrices![i].poolAddresses![0],
585
+ poolPrice.prices,
586
+ poolPrice.poolAddresses![0],
410
587
  tokenA.address,
411
588
  amounts,
412
589
  );
@@ -464,13 +641,13 @@ describe('Solidly integration tests', () => {
464
641
  checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
465
642
 
466
643
  // Check if onchain pricing equals to calculated ones
467
- for (const i in poolPrices || []) {
644
+ for (const poolPrice of poolPrices || []) {
468
645
  await checkOnChainPricing(
469
646
  dystopia,
470
647
  'getAmountOut',
471
648
  blocknumber,
472
- poolPrices![i].prices,
473
- poolPrices![i].poolAddresses![0],
649
+ poolPrice.prices,
650
+ poolPrice.poolAddresses![0],
474
651
  tokenA.address,
475
652
  amounts,
476
653
  );
@@ -540,13 +717,13 @@ describe('Solidly integration tests', () => {
540
717
 
541
718
  // Check if onchain pricing equals to calculated ones
542
719
 
543
- for (const i in poolPrices || []) {
720
+ for (const poolPrice of poolPrices || []) {
544
721
  await checkOnChainPricing(
545
722
  cone,
546
723
  'getAmountOut',
547
724
  blocknumber,
548
- poolPrices![i].prices,
549
- poolPrices![i].poolAddresses![0],
725
+ poolPrice.prices,
726
+ poolPrice.poolAddresses![0],
550
727
  tokenA.address,
551
728
  amounts,
552
729
  );
@@ -604,13 +781,13 @@ describe('Solidly integration tests', () => {
604
781
  checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
605
782
 
606
783
  // Check if onchain pricing equals to calculated ones
607
- for (const i in poolPrices || []) {
784
+ for (const poolPrice of poolPrices || []) {
608
785
  await checkOnChainPricing(
609
786
  cone,
610
787
  'getAmountOut',
611
788
  blocknumber,
612
- poolPrices![i].prices,
613
- poolPrices![i].poolAddresses![0],
789
+ poolPrice.prices,
790
+ poolPrice.poolAddresses![0],
614
791
  tokenA.address,
615
792
  amounts,
616
793
  );
@@ -680,13 +857,13 @@ describe('Solidly integration tests', () => {
680
857
 
681
858
  // Check if onchain pricing equals to calculated ones
682
859
 
683
- for (const i in poolPrices || []) {
860
+ for (const poolPrice of poolPrices || []) {
684
861
  await checkOnChainPricing(
685
862
  chronos,
686
863
  'getAmountOut',
687
864
  blocknumber,
688
- poolPrices![i].prices,
689
- poolPrices![i].poolAddresses![0],
865
+ poolPrice.prices,
866
+ poolPrice.poolAddresses![0],
690
867
  tokenA.address,
691
868
  amounts,
692
869
  );
@@ -744,13 +921,13 @@ describe('Solidly integration tests', () => {
744
921
  checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
745
922
 
746
923
  // Check if onchain pricing equals to calculated ones
747
- for (const i in poolPrices || []) {
924
+ for (const poolPrice of poolPrices || []) {
748
925
  await checkOnChainPricing(
749
926
  chronos,
750
927
  'getAmountOut',
751
928
  blocknumber,
752
- poolPrices![i].prices,
753
- poolPrices![i].poolAddresses![0],
929
+ poolPrice.prices,
930
+ poolPrice.poolAddresses![0],
754
931
  tokenA.address,
755
932
  amounts,
756
933
  );
@@ -768,5 +945,327 @@ describe('Solidly integration tests', () => {
768
945
  });
769
946
  });
770
947
  });
948
+
949
+ describe('Ramses', function () {
950
+ const dexKey = 'Ramses';
951
+ const ramses = new Ramses(network, dexKey, dexHelper);
952
+
953
+ describe('UniswapV2 like pool', function () {
954
+ const TokenASymbol = 'USDCe';
955
+ const tokenA = Tokens[network][TokenASymbol];
956
+ const TokenBSymbol = 'WETH';
957
+ const tokenB = Tokens[network][TokenBSymbol];
958
+
959
+ const amounts = amounts18;
960
+
961
+ it('getPoolIdentifiers and getPricesVolume', async function () {
962
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
963
+ const pools = await ramses.getPoolIdentifiers(
964
+ tokenA,
965
+ tokenB,
966
+ SwapSide.SELL,
967
+ blocknumber,
968
+ );
969
+ console.log(
970
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
971
+ pools,
972
+ );
973
+
974
+ expect(pools.length).toBeGreaterThan(0);
975
+
976
+ console.log('AMOUNTS: ', amounts);
977
+
978
+ const poolPrices = await ramses.getPricesVolume(
979
+ tokenA,
980
+ tokenB,
981
+ amounts,
982
+ SwapSide.SELL,
983
+ blocknumber,
984
+ pools,
985
+ );
986
+ console.log(
987
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
988
+ util.inspect(poolPrices, false, null, true),
989
+ );
990
+
991
+ expect(poolPrices).not.toBeNull();
992
+ // checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
993
+
994
+ // Check if onchain pricing equals to calculated ones
995
+
996
+ for (const poolPrice of poolPrices || []) {
997
+ await checkOnChainPricing(
998
+ ramses,
999
+ 'getAmountOut',
1000
+ blocknumber,
1001
+ poolPrice.prices,
1002
+ poolPrice.poolAddresses![0],
1003
+ tokenA.address,
1004
+ amounts,
1005
+ );
1006
+ }
1007
+ });
1008
+
1009
+ it('getTopPoolsForToken', async function () {
1010
+ const poolLiquidity = await ramses.getTopPoolsForToken(
1011
+ tokenA.address,
1012
+ 10,
1013
+ );
1014
+ console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
1015
+
1016
+ checkPoolsLiquidity(poolLiquidity, tokenA.address, dexKey);
1017
+ });
1018
+ });
1019
+
1020
+ describe('Curve like stable pool', function () {
1021
+ const TokenASymbol = 'USDT';
1022
+ const tokenA = Tokens[network][TokenASymbol];
1023
+ const TokenBSymbol = 'USDCe';
1024
+ const tokenB = Tokens[network][TokenBSymbol];
1025
+
1026
+ const amounts = amounts6;
1027
+
1028
+ it('getPoolIdentifiers and getPricesVolume', async function () {
1029
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
1030
+ const pools = await ramses.getPoolIdentifiers(
1031
+ tokenA,
1032
+ tokenB,
1033
+ SwapSide.SELL,
1034
+ blocknumber,
1035
+ );
1036
+ console.log(
1037
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1038
+ pools,
1039
+ );
1040
+
1041
+ expect(pools.length).toBeGreaterThan(0);
1042
+
1043
+ const poolPrices = await ramses.getPricesVolume(
1044
+ tokenA,
1045
+ tokenB,
1046
+ amounts,
1047
+ SwapSide.SELL,
1048
+ blocknumber,
1049
+ pools,
1050
+ );
1051
+ console.log(
1052
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1053
+ poolPrices,
1054
+ );
1055
+
1056
+ expect(poolPrices).not.toBeNull();
1057
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1058
+
1059
+ // Check if onchain pricing equals to calculated ones
1060
+ for (const poolPrice of poolPrices || []) {
1061
+ await checkOnChainPricing(
1062
+ ramses,
1063
+ 'getAmountOut',
1064
+ blocknumber,
1065
+ poolPrice.prices,
1066
+ poolPrice.poolAddresses![0],
1067
+ tokenA.address,
1068
+ amounts,
1069
+ );
1070
+ }
1071
+ });
1072
+
1073
+ it('getTopPoolsForToken', async function () {
1074
+ const poolLiquidity = await ramses.getTopPoolsForToken(
1075
+ tokenA.address,
1076
+ 10,
1077
+ );
1078
+ console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
1079
+
1080
+ checkPoolsLiquidity(poolLiquidity, tokenA.address, dexKey);
1081
+ });
1082
+ });
1083
+ });
1084
+ });
1085
+
1086
+ describe('Optimism', () => {
1087
+ const network = Network.OPTIMISM;
1088
+ const dexHelper = new DummyDexHelper(network);
1089
+ const checkOnChainPricing = constructCheckOnChainPricing(dexHelper);
1090
+
1091
+ describe('VelodromeV2', () => {
1092
+ const dexKey = 'VelodromeV2';
1093
+ const velodromeV2 = new VelodromeV2(network, dexKey, dexHelper);
1094
+
1095
+ describe('UniswapV2 like pool', function () {
1096
+ const TokenASymbol = 'USDC';
1097
+ const tokenA = Tokens[network][TokenASymbol];
1098
+ const TokenBSymbol = 'WETH';
1099
+ const tokenB = Tokens[network][TokenBSymbol];
1100
+
1101
+ const amounts = amounts18;
1102
+
1103
+ it('getPoolIdentifiers and getPricesVolume SELL', async function () {
1104
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
1105
+ const pools = await velodromeV2.getPoolIdentifiers(
1106
+ tokenA,
1107
+ tokenB,
1108
+ SwapSide.SELL,
1109
+ blocknumber,
1110
+ );
1111
+ console.log(
1112
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1113
+ pools,
1114
+ );
1115
+
1116
+ expect(pools.length).toBeGreaterThan(0);
1117
+
1118
+ const poolPrices = await velodromeV2.getPricesVolume(
1119
+ tokenA,
1120
+ tokenB,
1121
+ amounts,
1122
+ SwapSide.SELL,
1123
+ blocknumber,
1124
+ pools,
1125
+ );
1126
+ console.log(
1127
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1128
+ poolPrices,
1129
+ );
1130
+
1131
+ expect(poolPrices).not.toBeNull();
1132
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1133
+
1134
+ // Check if onchain pricing equals to calculated ones
1135
+
1136
+ for (const poolPrice of poolPrices || []) {
1137
+ await checkOnChainPricing(
1138
+ velodromeV2,
1139
+ 'getAmountOut',
1140
+ blocknumber,
1141
+ poolPrice.prices,
1142
+ poolPrice.poolAddresses![0],
1143
+ tokenA.address,
1144
+ amounts,
1145
+ );
1146
+ }
1147
+ });
1148
+ });
1149
+
1150
+ describe('Curve like stable pool', function () {
1151
+ const TokenASymbol = 'USDT';
1152
+ const tokenA = Tokens[network][TokenASymbol];
1153
+ const TokenBSymbol = 'USDC';
1154
+ const tokenB = Tokens[network][TokenBSymbol];
1155
+
1156
+ const amounts = amounts6;
1157
+
1158
+ it('getPoolIdentifiers and getPricesVolume SELL', async function () {
1159
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
1160
+ const pools = await velodromeV2.getPoolIdentifiers(
1161
+ tokenA,
1162
+ tokenB,
1163
+ SwapSide.SELL,
1164
+ blocknumber,
1165
+ );
1166
+ console.log(
1167
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1168
+ pools,
1169
+ );
1170
+
1171
+ expect(pools.length).toBeGreaterThan(0);
1172
+
1173
+ const poolPrices = await velodromeV2.getPricesVolume(
1174
+ tokenA,
1175
+ tokenB,
1176
+ amounts,
1177
+ SwapSide.SELL,
1178
+ blocknumber,
1179
+ pools,
1180
+ );
1181
+ console.log(
1182
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1183
+ poolPrices,
1184
+ );
1185
+
1186
+ expect(poolPrices).not.toBeNull();
1187
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1188
+
1189
+ // Check if onchain pricing equals to calculated ones
1190
+ for (const poolPrice of poolPrices || []) {
1191
+ await checkOnChainPricing(
1192
+ velodromeV2,
1193
+ 'getAmountOut',
1194
+ blocknumber,
1195
+ poolPrice.prices,
1196
+ poolPrice.poolAddresses![0],
1197
+ tokenA.address,
1198
+ amounts,
1199
+ );
1200
+ }
1201
+ });
1202
+ });
1203
+ });
1204
+ });
1205
+
1206
+ describe('Base', () => {
1207
+ const network = Network.BASE;
1208
+ const dexHelper = new DummyDexHelper(network);
1209
+ const checkOnChainPricing = constructCheckOnChainPricing(dexHelper);
1210
+
1211
+ describe('Equalizer', () => {
1212
+ const dexKey = 'Equalizer';
1213
+ const equalizer = new Equalizer(network, dexKey, dexHelper);
1214
+
1215
+ describe('UniswapV2 like pool', function () {
1216
+ const TokenASymbol = 'USDbC';
1217
+ const tokenA = Tokens[network][TokenASymbol];
1218
+ const TokenBSymbol = 'ETH';
1219
+ const tokenB = Tokens[network][TokenBSymbol];
1220
+
1221
+ const amounts = amounts18;
1222
+
1223
+ it('getPoolIdentifiers and getPricesVolume', async function () {
1224
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
1225
+ const pools = await equalizer.getPoolIdentifiers(
1226
+ tokenA,
1227
+ tokenB,
1228
+ SwapSide.SELL,
1229
+ blocknumber,
1230
+ );
1231
+ console.log(
1232
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1233
+ pools,
1234
+ );
1235
+
1236
+ expect(pools.length).toBeGreaterThan(0);
1237
+
1238
+ const poolPrices = await equalizer.getPricesVolume(
1239
+ tokenA,
1240
+ tokenB,
1241
+ amounts,
1242
+ SwapSide.SELL,
1243
+ blocknumber,
1244
+ pools,
1245
+ );
1246
+ console.log(
1247
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1248
+ poolPrices,
1249
+ );
1250
+
1251
+ expect(poolPrices).not.toBeNull();
1252
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1253
+
1254
+ // Check if onchain pricing equals to calculated ones
1255
+
1256
+ for (const poolPrice of poolPrices || []) {
1257
+ await checkOnChainPricing(
1258
+ equalizer,
1259
+ 'getAmountOut',
1260
+ blocknumber,
1261
+ poolPrice.prices,
1262
+ poolPrice.poolAddresses![0],
1263
+ tokenA.address,
1264
+ amounts,
1265
+ );
1266
+ }
1267
+ });
1268
+ });
1269
+ });
771
1270
  });
772
1271
  });