@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,83 +1,70 @@
1
- import _ from 'lodash';
2
- import { UnoptimizedRate } from '../../types';
1
+ import { UnoptimizedRate, OptimalSwapExchange } from '../../types';
2
+ import { BalancerSwapV2 } from './types';
3
3
  import { SwapSide } from '../../constants';
4
4
  import { BalancerConfig } from './config';
5
- import { OptimalSwap } from '@paraswap/core';
5
+
6
+ const MAX_UINT256 =
7
+ '115792089237316195423570985008687907853269984665640564039457584007913129639935';
8
+
9
+ const AllBalancerV2Forks = Object.keys(BalancerConfig);
6
10
 
7
11
  export function balancerV2Merge(or: UnoptimizedRate): UnoptimizedRate {
8
- const balancerForksList = Object.keys(BalancerConfig).map(b =>
9
- b.toLowerCase(),
10
- );
11
- const fixSwap = (rawRate: OptimalSwap[], side: SwapSide): OptimalSwap[] => {
12
- let lastExchange: false | OptimalSwap = false;
13
- let optimizedRate = new Array<OptimalSwap>();
14
- rawRate.forEach((s: OptimalSwap) => {
15
- if (
16
- s.swapExchanges.length !== 1 ||
17
- !balancerForksList.includes(s.swapExchanges[0].exchange.toLowerCase())
18
- ) {
19
- lastExchange = false;
20
- optimizedRate.push(s);
21
- } else if (
22
- lastExchange &&
23
- lastExchange.swapExchanges[0].exchange.toLowerCase() ===
24
- s.swapExchanges[0].exchange.toLowerCase() &&
25
- _.last(
26
- <any[]>lastExchange.swapExchanges[0].data.swaps,
27
- )!.tokenOut.toLowerCase() ===
28
- s.swapExchanges[0].data.tokenIn.toLowerCase()
29
- ) {
30
- const [lastExchangeSwap] = lastExchange.swapExchanges;
31
- const [currentSwap] = s.swapExchanges;
32
- lastExchangeSwap.srcAmount = (
33
- BigInt(lastExchangeSwap.srcAmount) + BigInt(currentSwap.srcAmount)
12
+ const fixSwap = (
13
+ rawSwap: OptimalSwapExchange<any>[],
14
+ side: SwapSide,
15
+ ): OptimalSwapExchange<any>[] => {
16
+ const newBalancers: { [key: string]: OptimalSwapExchange<any> } = {};
17
+ let optimizedSwap = new Array<OptimalSwapExchange<any>>();
18
+ rawSwap.forEach((s: OptimalSwapExchange<any>) => {
19
+ const exchangeKey = s.exchange.toLowerCase();
20
+ if (AllBalancerV2Forks.some(d => d.toLowerCase() === exchangeKey)) {
21
+ if (!(exchangeKey in newBalancers)) {
22
+ newBalancers[exchangeKey] = {
23
+ exchange: s.exchange,
24
+ srcAmount: '0',
25
+ destAmount: '0',
26
+ percent: 0,
27
+ poolAddresses: [],
28
+ data: {
29
+ swaps: new Array<BalancerSwapV2>(),
30
+ gasUSD: '0',
31
+ },
32
+ };
33
+ }
34
+ newBalancers[exchangeKey].srcAmount = (
35
+ BigInt(newBalancers[exchangeKey].srcAmount) + BigInt(s.srcAmount)
34
36
  ).toString();
35
37
 
36
- lastExchangeSwap.destAmount = (
37
- BigInt(lastExchangeSwap.destAmount) + BigInt(currentSwap.destAmount)
38
+ newBalancers[exchangeKey].destAmount = (
39
+ BigInt(newBalancers[exchangeKey].destAmount) + BigInt(s.destAmount)
38
40
  ).toString();
39
41
 
40
- lastExchangeSwap.percent += currentSwap.percent;
41
- lastExchangeSwap.data.gasUSD = (
42
- parseFloat(lastExchangeSwap.data.gasUSD) +
43
- parseFloat(currentSwap.data.gasUSD)
42
+ newBalancers[exchangeKey].percent += s.percent;
43
+ newBalancers[exchangeKey].data.exchangeProxy = s.data.exchangeProxy;
44
+ newBalancers[exchangeKey].data.gasUSD = (
45
+ parseFloat(newBalancers[exchangeKey].data.gasUSD) +
46
+ parseFloat(s.data.gasUSD)
44
47
  ).toFixed(6);
45
48
 
46
- lastExchangeSwap.data.swaps.push({
47
- poolId: currentSwap.data.poolId,
48
- amount:
49
- side === SwapSide.SELL
50
- ? currentSwap.srcAmount
51
- : currentSwap.destAmount,
52
- tokenIn: currentSwap.data.tokenIn,
53
- tokenOut: currentSwap.data.tokenOut,
49
+ newBalancers[exchangeKey].data.swaps.push({
50
+ poolId: s.data.poolId,
51
+ amount: side === SwapSide.SELL ? s.srcAmount : s.destAmount,
54
52
  });
55
- lastExchangeSwap.poolAddresses!.push(currentSwap.poolAddresses![0]);
53
+ newBalancers[exchangeKey].poolAddresses!.push(s.poolAddresses![0]);
56
54
  } else {
57
- lastExchange = _.cloneDeep(s);
58
- lastExchange.swapExchanges[0].data = {};
59
- lastExchange.swapExchanges[0].data.gasUSD =
60
- s.swapExchanges[0].data.gasUSD;
61
- lastExchange.swapExchanges[0].data.swaps = [
62
- {
63
- poolId: s.swapExchanges[0].data.poolId,
64
- amount:
65
- side === SwapSide.SELL
66
- ? s.swapExchanges[0].srcAmount
67
- : s.swapExchanges[0].destAmount,
68
- tokenIn: s.swapExchanges[0].data.tokenIn,
69
- tokenOut: s.swapExchanges[0].data.tokenOut,
70
- },
71
- ];
72
- optimizedRate.push(lastExchange);
55
+ optimizedSwap.push(s);
73
56
  }
74
57
  });
75
- return optimizedRate;
58
+ optimizedSwap = optimizedSwap.concat(Object.values(newBalancers));
59
+ return optimizedSwap;
76
60
  };
77
61
 
78
62
  or.bestRoute = or.bestRoute.map(r => ({
79
63
  ...r,
80
- swaps: fixSwap(r.swaps, or.side),
64
+ swaps: r.swaps.map(s => ({
65
+ ...s,
66
+ swapExchanges: fixSwap(s.swapExchanges, or.side),
67
+ })),
81
68
  }));
82
69
  return or;
83
70
  }
@@ -82,8 +82,6 @@ export interface SubgraphPoolBase {
82
82
  export type BalancerSwapV2 = {
83
83
  poolId: string;
84
84
  amount: string;
85
- tokenIn: string;
86
- tokenOut: string;
87
85
  };
88
86
 
89
87
  export type OptimizedBalancerV2Data = {
@@ -141,8 +139,6 @@ export type BalancerV2DirectParam = [
141
139
 
142
140
  export type BalancerV2Data = {
143
141
  poolId: string;
144
- tokenIn: string;
145
- tokenOut: string;
146
142
  };
147
143
 
148
144
  export type DexParams = {
@@ -939,44 +939,46 @@ export const CurveV1Config: DexConfigMap<DexParams> = {
939
939
  isMetapool: false,
940
940
  baseToken: '0x321162Cd933E2Be498Cd2267a90534A804051b11',
941
941
  },
942
- main_gDAI_gUSDC_gUSDT: {
943
- underlying: [
944
- '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // DAI
945
- '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // USDC
946
- '0x049d68029688eAbF473097a2fC38ef61633A3C7A', // fUSDT
947
- ],
948
- coins: [
949
- '0x07E6332dD090D287d3489245038daF987955DCFB', // gDAI
950
- '0xe578C856933D8e1082740bf7661e379Aa2A30b26', // gUSDC
951
- '0x940F41F0ec9ba1A34CF001cc03347ac092F5F6B5', // gUSDT
952
- ],
953
- address: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f',
954
- name: 'main_gDAI_gUSDC_gUSDT',
955
- type: 2,
956
- version: 3,
957
- isLending: true,
958
- isMetapool: false,
959
- baseToken: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E',
960
- },
961
- main_iDAI_iUSDC_iFUSDT: {
962
- underlying: [
963
- '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // DAI
964
- '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // USDC
965
- '0x049d68029688eAbF473097a2fC38ef61633A3C7A', // fUSDT
966
- ],
967
- coins: [
968
- '0x04c762a5dF2Fa02FE868F25359E0C259fB811CfE', // iDAI
969
- '0x328A7b4d538A2b3942653a9983fdA3C12c571141', // iUSDC
970
- '0x70faC71debfD67394D1278D98A29dea79DC6E57A', // iFUSDT
971
- ],
972
- address: '0x4FC8D635c3cB1d0aa123859e2B2587d0FF2707b1',
973
- name: 'main_iDAI_iUSDC_iFUSDT',
974
- type: 2,
975
- version: 3,
976
- isLending: true,
977
- isMetapool: false,
978
- baseToken: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E',
979
- },
942
+ // Disabled pool
943
+ // main_gDAI_gUSDC_gUSDT: {
944
+ // underlying: [
945
+ // '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // DAI
946
+ // '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // USDC
947
+ // '0x049d68029688eAbF473097a2fC38ef61633A3C7A', // fUSDT
948
+ // ],
949
+ // coins: [
950
+ // '0x07E6332dD090D287d3489245038daF987955DCFB', // gDAI
951
+ // '0xe578C856933D8e1082740bf7661e379Aa2A30b26', // gUSDC
952
+ // '0x940F41F0ec9ba1A34CF001cc03347ac092F5F6B5', // gUSDT
953
+ // ],
954
+ // address: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f',
955
+ // name: 'main_gDAI_gUSDC_gUSDT',
956
+ // type: 2,
957
+ // version: 3,
958
+ // isLending: true,
959
+ // isMetapool: false,
960
+ // baseToken: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E',
961
+ // },
962
+ // Disabled pool
963
+ // main_iDAI_iUSDC_iFUSDT: {
964
+ // underlying: [
965
+ // '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // DAI
966
+ // '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // USDC
967
+ // '0x049d68029688eAbF473097a2fC38ef61633A3C7A', // fUSDT
968
+ // ],
969
+ // coins: [
970
+ // '0x04c762a5dF2Fa02FE868F25359E0C259fB811CfE', // iDAI
971
+ // '0x328A7b4d538A2b3942653a9983fdA3C12c571141', // iUSDC
972
+ // '0x70faC71debfD67394D1278D98A29dea79DC6E57A', // iFUSDT
973
+ // ],
974
+ // address: '0x4FC8D635c3cB1d0aa123859e2B2587d0FF2707b1',
975
+ // name: 'main_iDAI_iUSDC_iFUSDT',
976
+ // type: 2,
977
+ // version: 3,
978
+ // isLending: true,
979
+ // isMetapool: false,
980
+ // baseToken: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E',
981
+ // },
980
982
  },
981
983
  },
982
984
  [Network.AVALANCHE]: {
@@ -13,7 +13,10 @@ import { normalizeAddress } from '../../utils';
13
13
  const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
14
14
  CurveV1Factory: {
15
15
  [Network.MAINNET]: {
16
- factoryAddress: '0xB9fC157394Af804a3578134A6585C0dc9cc990d4',
16
+ factoryAddresses: [
17
+ '0xB9fC157394Af804a3578134A6585C0dc9cc990d4',
18
+ '0x4f8846ae9380b90d2e71d5e3d042dff3e7ebb40d',
19
+ ],
17
20
  stateUpdatePeriodMs: 5 * 1000,
18
21
  disabledPools: new Set([
19
22
  '0x28B0Cf1baFB707F2c6826d10caf6DD901a6540C5', // It is rug pool token
@@ -150,6 +153,11 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
150
153
  name: ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED,
151
154
  address: '0xad4753d045d3aed5c1a6606dfb6a7d7ad67c1ad7',
152
155
  },
156
+ '0x67fe41A94e779CcFa22cff02cc2957DC9C0e4286': {
157
+ name: ImplementationNames.FACTORY_PLAIN_2_CRV_EMA,
158
+ address: '0x67fe41A94e779CcFa22cff02cc2957DC9C0e4286',
159
+ liquidityApiSlug: '/factory-crvusd',
160
+ },
153
161
  },
154
162
  customPools: {
155
163
  '0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2': {
@@ -200,7 +208,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
200
208
  },
201
209
  },
202
210
  [Network.POLYGON]: {
203
- factoryAddress: '0x722272D36ef0Da72FF51c5A65Db7b870E2e8D4ee',
211
+ factoryAddresses: ['0x722272D36ef0Da72FF51c5A65Db7b870E2e8D4ee'],
204
212
  stateUpdatePeriodMs: 2 * 1000,
205
213
  disabledPools: new Set([
206
214
  '0x666Dc3b4baBfd063FaF965BD020024AF0dC51B64',
@@ -306,7 +314,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
306
314
  },
307
315
  },
308
316
  [Network.FANTOM]: {
309
- factoryAddress: '0x686d67265703D1f124c45E33d47d794c566889Ba',
317
+ factoryAddresses: ['0x686d67265703D1f124c45E33d47d794c566889Ba'],
310
318
  stateUpdatePeriodMs: 2 * 1000,
311
319
  disabledPools: new Set([]),
312
320
  disabledImplementations: new Set([]),
@@ -421,7 +429,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
421
429
  },
422
430
  },
423
431
  [Network.AVALANCHE]: {
424
- factoryAddress: '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
432
+ factoryAddresses: ['0xb17b674D9c5CB2e441F8e196a2f048A81355d031'],
425
433
  stateUpdatePeriodMs: 2 * 1000,
426
434
  // FIX: This must be removed when we go for full CurveV1 event based support
427
435
  disabledPools: new Set(['0x16a7da911a4dd1d83f3ff066fe28f3c792c50d90']),
@@ -519,7 +527,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
519
527
  },
520
528
  },
521
529
  [Network.ARBITRUM]: {
522
- factoryAddress: '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
530
+ factoryAddresses: ['0xb17b674D9c5CB2e441F8e196a2f048A81355d031'],
523
531
  stateUpdatePeriodMs: 2 * 1000,
524
532
  disabledPools: new Set([]),
525
533
  disabledImplementations: new Set([]),
@@ -645,7 +653,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
645
653
  },
646
654
  },
647
655
  [Network.OPTIMISM]: {
648
- factoryAddress: '0x2db0E83599a91b508Ac268a6197b8B14F5e72840',
656
+ factoryAddresses: ['0x2db0E83599a91b508Ac268a6197b8B14F5e72840'],
649
657
  stateUpdatePeriodMs: 2 * 1000,
650
658
  disabledPools: new Set([]),
651
659
  disabledImplementations: new Set([]),
@@ -869,9 +877,9 @@ const configAddressesNormalizer = (
869
877
 
870
878
  // Unite everything into top level config
871
879
  const normalizedConfig: DexParams = {
872
- factoryAddress: _config.factoryAddress
873
- ? _config.factoryAddress.toLowerCase()
874
- : _config.factoryAddress,
880
+ factoryAddresses: _config.factoryAddresses
881
+ ? _config.factoryAddresses.map(e => e.toLowerCase())
882
+ : _config.factoryAddresses,
875
883
  stateUpdatePeriodMs: _config.stateUpdatePeriodMs,
876
884
  factoryPoolImplementations,
877
885
  customPools,
@@ -111,6 +111,25 @@ describe('CurveV1Factory E2E', () => {
111
111
  tokenBAmount,
112
112
  );
113
113
  });
114
+
115
+ describe('Mainnet crvUSD', () => {
116
+ const network = Network.MAINNET;
117
+
118
+ const tokenASymbol: string = 'crvUSD';
119
+ const tokenBSymbol: string = 'USDT';
120
+
121
+ const tokenAAmount: string = '10000000000000000000';
122
+ const tokenBAmount: string = '10000000';
123
+
124
+ testForNetwork(
125
+ network,
126
+ dexKey,
127
+ tokenASymbol,
128
+ tokenBSymbol,
129
+ tokenAAmount,
130
+ tokenBAmount,
131
+ );
132
+ });
114
133
  describe('Mainnet ng pool', () => {
115
134
  const network = Network.MAINNET;
116
135
 
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  import dotenv from 'dotenv';
2
3
  dotenv.config();
3
4
 
@@ -143,23 +144,6 @@ describe('CurveV1Factory', function () {
143
144
 
144
145
  const tokens = Tokens[network];
145
146
 
146
- const srcTokenSymbol = 'USDD';
147
- const destTokenSymbol = 'USDT';
148
-
149
- const amountsForSell = [
150
- 0n,
151
- 1n * BI_POWS[tokens[srcTokenSymbol].decimals],
152
- 2n * BI_POWS[tokens[srcTokenSymbol].decimals],
153
- 3n * BI_POWS[tokens[srcTokenSymbol].decimals],
154
- 4n * BI_POWS[tokens[srcTokenSymbol].decimals],
155
- 5n * BI_POWS[tokens[srcTokenSymbol].decimals],
156
- 6n * BI_POWS[tokens[srcTokenSymbol].decimals],
157
- 7n * BI_POWS[tokens[srcTokenSymbol].decimals],
158
- 8n * BI_POWS[tokens[srcTokenSymbol].decimals],
159
- 9n * BI_POWS[tokens[srcTokenSymbol].decimals],
160
- 10n * BI_POWS[tokens[srcTokenSymbol].decimals],
161
- ];
162
-
163
147
  beforeAll(async () => {
164
148
  blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
165
149
  // @ts-expect-error for testing there is dummy blocknumber, but it is not
@@ -178,39 +162,175 @@ describe('CurveV1Factory', function () {
178
162
  if (curveV1Factory) curveV1Factory.releaseResources();
179
163
  });
180
164
 
181
- it('getPoolIdentifiers and getPricesVolume SELL', async function () {
182
- await testPricingOnNetwork(
183
- curveV1Factory,
184
- network,
185
- dexKey,
186
- blockNumber,
187
- srcTokenSymbol,
188
- destTokenSymbol,
189
- SwapSide.SELL,
190
- amountsForSell,
191
- );
165
+ describe(`USDD-USDT`, () => {
166
+ const srcTokenSymbol = 'USDD';
167
+ const destTokenSymbol = 'USDT';
168
+ const amountsForSell = [
169
+ 0n,
170
+ 1n * BI_POWS[tokens[srcTokenSymbol].decimals],
171
+ 2n * BI_POWS[tokens[srcTokenSymbol].decimals],
172
+ 3n * BI_POWS[tokens[srcTokenSymbol].decimals],
173
+ 4n * BI_POWS[tokens[srcTokenSymbol].decimals],
174
+ 5n * BI_POWS[tokens[srcTokenSymbol].decimals],
175
+ 6n * BI_POWS[tokens[srcTokenSymbol].decimals],
176
+ 7n * BI_POWS[tokens[srcTokenSymbol].decimals],
177
+ 8n * BI_POWS[tokens[srcTokenSymbol].decimals],
178
+ 9n * BI_POWS[tokens[srcTokenSymbol].decimals],
179
+ 10n * BI_POWS[tokens[srcTokenSymbol].decimals],
180
+ ];
181
+
182
+ it('getPoolIdentifiers and getPricesVolume SELL', async function () {
183
+ await testPricingOnNetwork(
184
+ curveV1Factory,
185
+ network,
186
+ dexKey,
187
+ blockNumber,
188
+ srcTokenSymbol,
189
+ destTokenSymbol,
190
+ SwapSide.SELL,
191
+ amountsForSell,
192
+ );
193
+ });
194
+
195
+ it('getTopPoolsForToken', async function () {
196
+ // We have to check without calling initializePricing, because
197
+ // pool-tracker is not calling that function
198
+ const newCurveV1Factory = new CurveV1Factory(
199
+ network,
200
+ dexKey,
201
+ dexHelper,
202
+ );
203
+ if (newCurveV1Factory.updatePoolState) {
204
+ await newCurveV1Factory.updatePoolState();
205
+ }
206
+ const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
207
+ tokens[srcTokenSymbol].address,
208
+ 10,
209
+ );
210
+ console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
211
+
212
+ if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
213
+ checkPoolsLiquidity(
214
+ poolLiquidity,
215
+ Tokens[network][srcTokenSymbol].address,
216
+ dexKey,
217
+ );
218
+ }
219
+ });
192
220
  });
193
221
 
194
- it('getTopPoolsForToken', async function () {
195
- // We have to check without calling initializePricing, because
196
- // pool-tracker is not calling that function
197
- const newCurveV1Factory = new CurveV1Factory(network, dexKey, dexHelper);
198
- if (newCurveV1Factory.updatePoolState) {
199
- await newCurveV1Factory.updatePoolState();
200
- }
201
- const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
202
- tokens[srcTokenSymbol].address,
203
- 10,
204
- );
205
- console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
222
+ describe(`crvUSD-GHO`, () => {
223
+ const srcTokenSymbol = 'crvUSD';
224
+ const destTokenSymbol = 'GHO';
225
+ const amountsForSell = [
226
+ 0n,
227
+ 1n * BI_POWS[tokens[srcTokenSymbol].decimals],
228
+ 2n * BI_POWS[tokens[srcTokenSymbol].decimals],
229
+ 3n * BI_POWS[tokens[srcTokenSymbol].decimals],
230
+ 4n * BI_POWS[tokens[srcTokenSymbol].decimals],
231
+ 5n * BI_POWS[tokens[srcTokenSymbol].decimals],
232
+ 6n * BI_POWS[tokens[srcTokenSymbol].decimals],
233
+ 7n * BI_POWS[tokens[srcTokenSymbol].decimals],
234
+ 8n * BI_POWS[tokens[srcTokenSymbol].decimals],
235
+ 9n * BI_POWS[tokens[srcTokenSymbol].decimals],
236
+ 10n * BI_POWS[tokens[srcTokenSymbol].decimals],
237
+ ];
238
+
239
+ it('getPoolIdentifiers and getPricesVolume SELL', async function () {
240
+ await testPricingOnNetwork(
241
+ curveV1Factory,
242
+ network,
243
+ dexKey,
244
+ blockNumber,
245
+ srcTokenSymbol,
246
+ destTokenSymbol,
247
+ SwapSide.SELL,
248
+ amountsForSell,
249
+ );
250
+ });
206
251
 
207
- if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
208
- checkPoolsLiquidity(
209
- poolLiquidity,
210
- Tokens[network][srcTokenSymbol].address,
252
+ it('getTopPoolsForToken', async function () {
253
+ // We have to check without calling initializePricing, because
254
+ // pool-tracker is not calling that function
255
+ const newCurveV1Factory = new CurveV1Factory(
256
+ network,
211
257
  dexKey,
258
+ dexHelper,
212
259
  );
213
- }
260
+ if (newCurveV1Factory.updatePoolState) {
261
+ await newCurveV1Factory.updatePoolState();
262
+ }
263
+ const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
264
+ tokens[srcTokenSymbol].address,
265
+ 10,
266
+ );
267
+ console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
268
+
269
+ if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
270
+ checkPoolsLiquidity(
271
+ poolLiquidity,
272
+ Tokens[network][srcTokenSymbol].address,
273
+ dexKey,
274
+ );
275
+ }
276
+ });
277
+ });
278
+
279
+ describe(`renBTC-wibBTC`, () => {
280
+ const srcTokenSymbol = 'renBTC';
281
+ const destTokenSymbol = 'wibBTC';
282
+ const amountsForSell = [
283
+ 0n,
284
+ 1n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
285
+ 2n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
286
+ 3n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
287
+ 4n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
288
+ 5n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
289
+ 6n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
290
+ 7n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
291
+ 8n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
292
+ 9n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
293
+ 10n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
294
+ ];
295
+
296
+ it('getPoolIdentifiers and getPricesVolume SELL', async function () {
297
+ await testPricingOnNetwork(
298
+ curveV1Factory,
299
+ network,
300
+ dexKey,
301
+ blockNumber,
302
+ srcTokenSymbol,
303
+ destTokenSymbol,
304
+ SwapSide.SELL,
305
+ amountsForSell,
306
+ );
307
+ });
308
+
309
+ it('getTopPoolsForToken', async function () {
310
+ // We have to check without calling initializePricing, because
311
+ // pool-tracker is not calling that function
312
+ const newCurveV1Factory = new CurveV1Factory(
313
+ network,
314
+ dexKey,
315
+ dexHelper,
316
+ );
317
+ if (newCurveV1Factory.updatePoolState) {
318
+ await newCurveV1Factory.updatePoolState();
319
+ }
320
+ const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
321
+ tokens[srcTokenSymbol].address,
322
+ 10,
323
+ );
324
+ console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
325
+
326
+ if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
327
+ checkPoolsLiquidity(
328
+ poolLiquidity,
329
+ Tokens[network][srcTokenSymbol].address,
330
+ dexKey,
331
+ );
332
+ }
333
+ });
214
334
  });
215
335
  });
216
336
  describe('Polygon', () => {