@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
@@ -9,31 +9,47 @@ import {
9
9
  } from '../../stateful-event-subscriber';
10
10
  import { IDexHelper } from '../../dex-helper/idex-helper';
11
11
  import {
12
+ DecodedGlobalStateV1_1,
12
13
  PoolStateV1_1,
13
14
  TickBitMapMappingsWithBigNumber,
14
15
  TickInfoMappingsWithBigNumber,
16
+ TickInfoWithBigNumber,
15
17
  } from './types';
16
- import { ethers } from 'ethers';
18
+ import { BigNumber, ethers } from 'ethers';
17
19
  import { Contract } from 'web3-eth-contract';
18
20
  import AlgebraABI from '../../abi/algebra/AlgebraPool-v1_1.abi.json';
21
+ import FactoryABI from '../../abi/algebra/AlgebraFactory-v1_1.abi.json';
19
22
  import { DecodedStateMultiCallResultWithRelativeBitmapsV1_1 } from './types';
20
23
  import {
21
24
  OUT_OF_RANGE_ERROR_POSTFIX,
22
25
  TICK_BITMAP_BUFFER,
23
26
  TICK_BITMAP_TO_USE,
24
27
  } from '../uniswap-v3/constants';
25
- import { uint256ToBigInt } from '../../lib/decoders';
28
+ import {
29
+ addressDecode,
30
+ uint256ToBigInt,
31
+ uint128ToBigNumber,
32
+ int24ToNumber,
33
+ } from '../../lib/decoders';
26
34
  import { MultiCallParams } from '../../lib/multi-wrapper';
27
- import { decodeStateMultiCallResultWithRelativeBitmapsV1_1 } from './utils';
35
+ import {
36
+ decodeGlobalStateV1_1,
37
+ decodeStateMultiCallResultWithRelativeBitmapsV1_1,
38
+ decodeTicksV1_1,
39
+ } from './utils';
28
40
  import { AlgebraMath } from './lib/AlgebraMath';
29
41
  import {
30
42
  _reduceTickBitmap,
31
43
  _reduceTicks,
32
44
  } from '../uniswap-v3/contract-math/utils';
33
45
  import { Constants } from './lib/Constants';
34
- import { Network } from '../../constants';
46
+ import { Network, NULL_ADDRESS } from '../../constants';
35
47
  import { TickTable } from './lib/TickTable';
36
48
 
49
+ const BN_ZERO = BigNumber.from(0);
50
+ const MAX_BATCH_SIZE = 100;
51
+ const MAX_NUMBER_OF_BATCH_REQUEST_HALVING = 3;
52
+
37
53
  export class AlgebraEventPoolV1_1 extends StatefulEventSubscriber<PoolStateV1_1> {
38
54
  handlers: {
39
55
  [event: string]: (
@@ -53,6 +69,13 @@ export class AlgebraEventPoolV1_1 extends StatefulEventSubscriber<PoolStateV1_1>
53
69
  readonly token1: Address;
54
70
 
55
71
  public readonly poolIface = new Interface(AlgebraABI);
72
+ public readonly factoryIface = new Interface(FactoryABI);
73
+
74
+ private readonly cachedStateMultiCalls: MultiCallParams<
75
+ string | bigint | BigNumber | number | DecodedGlobalStateV1_1
76
+ >[];
77
+
78
+ private optimalTickRequestBatchSize?: number;
56
79
 
57
80
  public initFailed = false;
58
81
  public initRetryAttemptCount = 0;
@@ -69,6 +92,7 @@ export class AlgebraEventPoolV1_1 extends StatefulEventSubscriber<PoolStateV1_1>
69
92
  mapKey: string = '',
70
93
  readonly poolInitCodeHash: string,
71
94
  readonly poolDeployer: string,
95
+ private readonly forceManualStateGeneration: boolean = false,
72
96
  ) {
73
97
  super(parentName, `${token0}_${token1}`, dexHelper, logger, true, mapKey);
74
98
  this.token0 = token0.toLowerCase();
@@ -84,6 +108,8 @@ export class AlgebraEventPoolV1_1 extends StatefulEventSubscriber<PoolStateV1_1>
84
108
  this.handlers['Flash'] = this.handleFlashEvent.bind(this);
85
109
  this.handlers['Collect'] = this.handleCollectEvent.bind(this);
86
110
  this.handlers['CommunityFee'] = this.handleCommunityFee.bind(this);
111
+
112
+ this.cachedStateMultiCalls = this._getStateMulticall();
87
113
  }
88
114
 
89
115
  get poolAddress() {
@@ -174,7 +200,7 @@ export class AlgebraEventPoolV1_1 extends StatefulEventSubscriber<PoolStateV1_1>
174
200
  return TICK_BITMAP_TO_USE + TICK_BITMAP_BUFFER;
175
201
  }
176
202
 
177
- private async _fetchPoolStateSingleStep(
203
+ async fetchPoolStateSingleStep(
178
204
  blockNumber: number,
179
205
  ): Promise<
180
206
  [bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmapsV1_1]
@@ -336,7 +362,7 @@ export class AlgebraEventPoolV1_1 extends StatefulEventSubscriber<PoolStateV1_1>
336
362
  [bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmapsV1_1]
337
363
  > {
338
364
  try {
339
- return await this._fetchPoolStateSingleStep(blockNumber);
365
+ return await this.fetchPoolStateSingleStep(blockNumber);
340
366
  } catch (e) {
341
367
  if (e instanceof Error && e.message.includes('Pool does not exist'))
342
368
  throw e;
@@ -347,9 +373,234 @@ export class AlgebraEventPoolV1_1 extends StatefulEventSubscriber<PoolStateV1_1>
347
373
  }
348
374
  }
349
375
 
376
+ private _getStateMulticall(): MultiCallParams<
377
+ string | bigint | BigNumber | number | DecodedGlobalStateV1_1
378
+ >[] {
379
+ return [
380
+ {
381
+ target: this.factoryAddress,
382
+ callData: this.factoryIface.encodeFunctionData('poolByPair', [
383
+ this.token0,
384
+ this.token1,
385
+ ]),
386
+ decodeFunction: addressDecode,
387
+ },
388
+ {
389
+ target: this.token0,
390
+ callData: this.erc20Interface.encodeFunctionData('balanceOf', [
391
+ this.poolAddress,
392
+ ]),
393
+ decodeFunction: uint256ToBigInt,
394
+ },
395
+ {
396
+ target: this.token1,
397
+ callData: this.erc20Interface.encodeFunctionData('balanceOf', [
398
+ this.poolAddress,
399
+ ]),
400
+ decodeFunction: uint256ToBigInt,
401
+ },
402
+ {
403
+ target: this.poolAddress,
404
+ callData: this.poolIface.encodeFunctionData('liquidity', []),
405
+ decodeFunction: uint128ToBigNumber,
406
+ },
407
+ {
408
+ target: this.poolAddress,
409
+ callData: this.poolIface.encodeFunctionData('tickSpacing', []),
410
+ decodeFunction: int24ToNumber,
411
+ },
412
+ {
413
+ target: this.poolAddress,
414
+ callData: this.poolIface.encodeFunctionData('maxLiquidityPerTick', []),
415
+ decodeFunction: uint128ToBigNumber,
416
+ },
417
+ {
418
+ target: this.poolAddress,
419
+ callData: this.poolIface.encodeFunctionData('globalState', []),
420
+ decodeFunction: decodeGlobalStateV1_1,
421
+ },
422
+ ];
423
+ }
424
+
425
+ async fetchStateManually(
426
+ blockNumber: number,
427
+ ): Promise<
428
+ [bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmapsV1_1]
429
+ > {
430
+ // Unfortunately I can not unite this call with the next one. For some reason even if pool does not exist
431
+ // call succeeds and makes decoding function to throw. Otherwise, I should rewrite decoders in different which
432
+ // require some time
433
+ const [poolAddress] = (await this.dexHelper.multiWrapper.aggregate<
434
+ string | bigint | BigNumber | number | DecodedGlobalStateV1_1
435
+ >(this.cachedStateMultiCalls.slice(0, 1), blockNumber, MAX_BATCH_SIZE)) as [
436
+ string,
437
+ ];
438
+
439
+ if (poolAddress === NULL_ADDRESS) {
440
+ throw new Error('Pool does not exist');
441
+ }
442
+
443
+ const [
444
+ balance0,
445
+ balance1,
446
+ liquidity,
447
+ tickSpacing,
448
+ maxLiquidityPerTick,
449
+ globalState,
450
+ ] = (await this.dexHelper.multiWrapper.aggregate<
451
+ string | bigint | BigNumber | number | DecodedGlobalStateV1_1
452
+ >(this.cachedStateMultiCalls.slice(1), blockNumber, MAX_BATCH_SIZE)) as [
453
+ bigint,
454
+ bigint,
455
+ BigNumber,
456
+ number,
457
+ BigNumber,
458
+ DecodedGlobalStateV1_1,
459
+ ];
460
+
461
+ assert(
462
+ poolAddress.toLowerCase() === this.poolAddress.toLowerCase(),
463
+ `Pool address mismatch: ${poolAddress.toLowerCase()} != ${this.poolAddress.toLowerCase()}`,
464
+ );
465
+
466
+ const currentBitMapIndex = TickTable.position(
467
+ BigInt(BigInt(globalState.tick) / BigInt(tickSpacing)),
468
+ )[0];
469
+
470
+ const leftBitMapIndex = currentBitMapIndex - this.getBitmapRangeToRequest();
471
+ const rightBitMapIndex =
472
+ currentBitMapIndex + this.getBitmapRangeToRequest();
473
+
474
+ const allTickBitMaps = await this.dexHelper.multiWrapper.aggregate(
475
+ _.range(Number(leftBitMapIndex), Number(rightBitMapIndex + 1n)).map(
476
+ index => {
477
+ return {
478
+ target: poolAddress,
479
+ callData: this.poolIface.encodeFunctionData('tickTable', [
480
+ int16(BigInt(index)),
481
+ ]),
482
+ decodeFunction: uint256ToBigInt,
483
+ };
484
+ },
485
+ ),
486
+ blockNumber,
487
+ MAX_BATCH_SIZE,
488
+ );
489
+
490
+ const tickBitmap: TickBitMapMappingsWithBigNumber[] = [];
491
+
492
+ let globalIndex = 0;
493
+ for (let i = leftBitMapIndex; i <= rightBitMapIndex; i++) {
494
+ const index = Number(int16(i));
495
+ const bitmap = allTickBitMaps[globalIndex];
496
+ globalIndex++;
497
+ if (bitmap == 0n) continue;
498
+ tickBitmap.push({ index: Number(index), value: BigNumber.from(bitmap) });
499
+ }
500
+
501
+ const tickIndexes: bigint[] = [];
502
+
503
+ const tickRequests = tickBitmap
504
+ .map(tb => {
505
+ const allBits: MultiCallParams<TickInfoWithBigNumber>[] = [];
506
+ if (tb.value === BN_ZERO) return allBits;
507
+
508
+ _.range(0, 256).forEach(j => {
509
+ if ((tb.value.toBigInt() & (1n << BigInt(j))) > 0n) {
510
+ const populatedTick =
511
+ (BigInt.asIntN(16, BigInt(tb.index) << 8n) + BigInt(j)) *
512
+ BigInt(tickSpacing);
513
+
514
+ tickIndexes.push(populatedTick);
515
+ allBits.push({
516
+ target: poolAddress,
517
+ callData: this.poolIface.encodeFunctionData('ticks', [
518
+ populatedTick,
519
+ ]),
520
+ decodeFunction: decodeTicksV1_1,
521
+ });
522
+ }
523
+ });
524
+ return allBits;
525
+ })
526
+ .flat();
527
+
528
+ let ticksValues: TickInfoWithBigNumber[] = [];
529
+ if (this.optimalTickRequestBatchSize) {
530
+ ticksValues = await this.dexHelper.multiWrapper.aggregate(
531
+ tickRequests,
532
+ blockNumber,
533
+ this.optimalTickRequestBatchSize,
534
+ );
535
+ // If we don't know what is optimal number of requests for this pool, we want to try it experimentally and save it
536
+ // Maybe later to consider distant caching
537
+ } else {
538
+ for (const i of _.range(0, MAX_NUMBER_OF_BATCH_REQUEST_HALVING)) {
539
+ const currentBatchSize = MAX_BATCH_SIZE / (+i + 1);
540
+ try {
541
+ // Some of the pools fails with 100 batch size, for them we want to try additionally with reduced batch size
542
+ ticksValues = await this.dexHelper.multiWrapper.aggregate(
543
+ tickRequests,
544
+ blockNumber,
545
+ currentBatchSize,
546
+ );
547
+ this.optimalTickRequestBatchSize = currentBatchSize;
548
+ break;
549
+ } catch (e) {
550
+ if (+i + 1 === MAX_NUMBER_OF_BATCH_REQUEST_HALVING) {
551
+ this.logger.warn(
552
+ `Failed to fetch ticks for pool ${poolAddress} (${this.token0}_${this.token1}) with batch size ${currentBatchSize}`,
553
+ e,
554
+ );
555
+ throw e;
556
+ }
557
+ }
558
+ }
559
+ }
560
+
561
+ assert(
562
+ tickIndexes.length === ticksValues.length,
563
+ `Tick indexes mismatch: ${tickIndexes.length} != ${ticksValues.length}`,
564
+ );
565
+
566
+ const ticks: TickInfoMappingsWithBigNumber[] = new Array(
567
+ tickIndexes.length,
568
+ );
569
+
570
+ tickIndexes.forEach((tickIndex, index) => {
571
+ ticks[index] = {
572
+ index: Number(tickIndex),
573
+ value: ticksValues[index],
574
+ };
575
+ });
576
+
577
+ return [
578
+ balance0,
579
+ balance1,
580
+ {
581
+ pool: poolAddress,
582
+ blockTimestamp: BigNumber.from(Date.now()),
583
+ globalState,
584
+ liquidity,
585
+ tickSpacing,
586
+ maxLiquidityPerTick,
587
+ tickBitmap,
588
+ ticks,
589
+ },
590
+ ];
591
+ }
592
+
350
593
  async generateState(blockNumber: number): Promise<Readonly<PoolStateV1_1>> {
351
- const [balance0, balance1, _state] =
352
- await this._fetchInitStateMultiStrategies(blockNumber);
594
+ let balance0 = 0n;
595
+ let balance1 = 0n;
596
+ let _state: DecodedStateMultiCallResultWithRelativeBitmapsV1_1;
597
+ if (this.forceManualStateGeneration) {
598
+ [balance0, balance1, _state] = await this.fetchStateManually(blockNumber);
599
+ } else {
600
+ [balance0, balance1, _state] = await this._fetchInitStateMultiStrategies(
601
+ blockNumber,
602
+ );
603
+ }
353
604
 
354
605
  const tickBitmap = {};
355
606
  const ticks = {};
@@ -38,14 +38,15 @@ import {
38
38
  import { AlgebraMath } from './lib/AlgebraMath';
39
39
  import { AlgebraEventPoolV1_1 } from './algebra-pool-v1_1';
40
40
  import { AlgebraEventPoolV1_9 } from './algebra-pool-v1_9';
41
+ import { AlgebraFactory, OnPoolCreatedCallback } from './algebra-factory';
41
42
 
42
43
  type PoolPairsInfo = {
43
44
  token0: Address;
44
45
  token1: Address;
45
46
  };
46
47
 
47
- const ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 60 * 60 * 1000; // 3 hours
48
- const ALGEBRA_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 30 * 60 * 1000; // Once in 30 minutes
48
+ const ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
49
+ const ALGEBRA_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
49
50
  const ALGEBRA_EFFICIENCY_FACTOR = 3;
50
51
  const ALGEBRA_TICK_GAS_COST = 24_000; // Ceiled
51
52
  const ALGEBRA_TICK_BASE_OVERHEAD = 75_000;
@@ -59,6 +60,7 @@ const MAX_STALE_STATE_BLOCK_AGE = {
59
60
  type IAlgebraEventPool = AlgebraEventPoolV1_1 | AlgebraEventPoolV1_9;
60
61
 
61
62
  export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
63
+ private readonly factory: AlgebraFactory;
62
64
  readonly isFeeOnTransferSupported: boolean = false;
63
65
  protected eventPools: Record<string, IAlgebraEventPool | null> = {};
64
66
 
@@ -88,7 +90,7 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
88
90
  protected adapters = Adapters[network] || {},
89
91
  readonly routerIface = new Interface(UniswapV3RouterABI), // same abi as uniswapV3
90
92
  readonly quoterIface = new Interface(AlgebraQuoterABI),
91
- protected config = AlgebraConfig[dexKey][network],
93
+ readonly config = AlgebraConfig[dexKey][network],
92
94
  ) {
93
95
  super(dexHelper, dexKey);
94
96
  this.logger = dexHelper.getLogger(dexKey + '-' + network);
@@ -104,12 +106,24 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
104
106
  this.dexHelper.web3Provider.eth.handleRevert = false;
105
107
 
106
108
  this.config = this._toLowerForAllConfigAddresses();
109
+ // External configuration has priority over internal
110
+ this.config.forceRPC = dexHelper.config.data.forceRpcFallbackDexs.includes(
111
+ dexKey.toLowerCase(),
112
+ );
107
113
 
108
114
  this.notExistingPoolSetKey =
109
115
  `${CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();
110
116
 
111
117
  this.AlgebraPoolImplem =
112
118
  config.version === 'v1.1' ? AlgebraEventPoolV1_1 : AlgebraEventPoolV1_9;
119
+
120
+ this.factory = new AlgebraFactory(
121
+ dexHelper,
122
+ dexKey,
123
+ this.config.factory,
124
+ this.logger,
125
+ this.onPoolCreatedDeleteFromNonExistingSet,
126
+ );
113
127
  }
114
128
 
115
129
  getAdapters(side: SwapSide): { name: string; index: number }[] | null {
@@ -122,6 +136,9 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
122
136
  }
123
137
 
124
138
  async initializePricing(blockNumber: number) {
139
+ // Init listening to new pools creation
140
+ await this.factory.initialize(blockNumber);
141
+
125
142
  if (!this.dexHelper.config.isSlave) {
126
143
  const cleanExpiredNotExistingPoolsKeys = async () => {
127
144
  const maxTimestamp =
@@ -140,6 +157,37 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
140
157
  }
141
158
  }
142
159
 
160
+ /*
161
+ * When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
162
+ * Once the pool is created, it gets immediately flagged
163
+ */
164
+ onPoolCreatedDeleteFromNonExistingSet: OnPoolCreatedCallback = async ({
165
+ token0,
166
+ token1,
167
+ }) => {
168
+ const logPrefix = '[Algebra.onPoolCreatedDeleteFromNonExistingSet]';
169
+ const [_token0, _token1] = this._sortTokens(token0, token1);
170
+ const poolKey = `${_token0}_${_token1}`;
171
+
172
+ // consider doing it only from master pool for less calls to distant cache
173
+
174
+ // delete entry locally to let local instance discover the pool
175
+ delete this.eventPools[this.getPoolIdentifier(_token0, _token1)];
176
+
177
+ try {
178
+ this.logger.info(
179
+ `${logPrefix} delete pool from not existing set: ${poolKey}`,
180
+ );
181
+ // delete pool record from set
182
+ await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
183
+ } catch (error) {
184
+ this.logger.error(
185
+ `${logPrefix} failed to delete pool from set: ${poolKey}`,
186
+ error,
187
+ );
188
+ }
189
+ };
190
+
143
191
  async getPool(
144
192
  srcAddress: Address,
145
193
  destAddress: Address,
@@ -156,14 +204,15 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
156
204
  if (this.network !== Network.ZKEVM) return pool;
157
205
 
158
206
  if (
159
- pool.getState(blockNumber) === null &&
160
- blockNumber - pool.getStateBlockNumber() >
161
- MAX_STALE_STATE_BLOCK_AGE[this.network]
207
+ pool.getStaleState() === null ||
208
+ (pool.getState(blockNumber) === null &&
209
+ blockNumber - pool.getStateBlockNumber() >
210
+ MAX_STALE_STATE_BLOCK_AGE[this.network])
162
211
  ) {
163
212
  /* reload state, on zkEVM this would most likely timeout during request life
164
213
  * but would allow to rely on staleState for couple of min for next requests
165
214
  */
166
- await pool.initialize(blockNumber);
215
+ await pool.initialize(blockNumber, { forceRegenerate: true });
167
216
  }
168
217
 
169
218
  return pool;
@@ -222,6 +271,7 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
222
271
  this.cacheStateKey,
223
272
  this.config.initHash,
224
273
  this.config.deployer,
274
+ this.config.forceManualStateGenerate,
225
275
  );
226
276
 
227
277
  try {
@@ -251,10 +301,10 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
251
301
  e,
252
302
  );
253
303
  } else {
254
- // on unkown error mark as failed and increase retryCount for retry init strategy
304
+ // on unknown error mark as failed and increase retryCount for retry init strategy
255
305
  // note: state would be null by default which allows to fallback
256
306
  this.logger.warn(
257
- `${this.dexKey}: Can not generate pool state for srcAddress=${srcAddress}, destAddress=${destAddress}pool fallback to rpc and retry every ${this.config.initRetryFrequency} times, initRetryAttemptCount=${pool.initRetryAttemptCount}`,
307
+ `${this.dexKey}: Can not generate pool state for srcAddress=${srcAddress}, destAddress=${destAddress} pool fallback to rpc and retry every ${this.config.initRetryFrequency} times, initRetryAttemptCount=${pool.initRetryAttemptCount}`,
258
308
  e,
259
309
  );
260
310
  pool.initFailed = true;
@@ -446,6 +496,18 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
446
496
 
447
497
  if (!pool) return null;
448
498
 
499
+ if (this.config.forceRPC) {
500
+ const rpcPrice = await this.getPricingFromRpc(
501
+ _srcToken,
502
+ _destToken,
503
+ amounts,
504
+ side,
505
+ pool,
506
+ );
507
+
508
+ return rpcPrice;
509
+ }
510
+
449
511
  let state = pool.getState(blockNumber);
450
512
 
451
513
  if (state === null) {
@@ -773,6 +835,8 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
773
835
  initHash: this.config.initHash,
774
836
  subgraphURL: this.config.subgraphURL,
775
837
  version: this.config.version,
838
+ forceRPC: this.config.forceRPC,
839
+ forceManualStateGenerate: this.config.forceManualStateGenerate,
776
840
  };
777
841
  return newConfig;
778
842
  }
@@ -797,20 +861,7 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
797
861
  return null;
798
862
  }
799
863
 
800
- // TODO buy
801
- let lastNonZeroOutput = 0n;
802
- let lastNonZeroTickCountsOutputs = 0;
803
-
804
864
  for (let i = 0; i < outputsResult.outputs.length; i++) {
805
- // local pricing algo may output 0s at the tail for some out of range amounts, prefer to propagating last amount to appease top algo
806
- if (outputsResult.outputs[i] > 0n) {
807
- lastNonZeroOutput = outputsResult.outputs[i];
808
- lastNonZeroTickCountsOutputs = outputsResult.tickCounts[i];
809
- } else {
810
- outputsResult.outputs[i] = lastNonZeroOutput;
811
- outputsResult.tickCounts[i] = lastNonZeroTickCountsOutputs;
812
- }
813
-
814
865
  if (outputsResult.outputs[i] > destTokenBalance) {
815
866
  outputsResult.outputs[i] = 0n;
816
867
  outputsResult.tickCounts[i] = 0;
@@ -33,6 +33,7 @@ export const AlgebraConfig: DexConfigMap<DexParams> = {
33
33
  uniswapMulticall: '0x61530d6E1c7A47BBB3e48e8b8EdF7569DcFeE121',
34
34
  deployer: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270',
35
35
  version: 'v1.1',
36
+ forceManualStateGenerate: true,
36
37
  },
37
38
  },
38
39
  ZyberSwapV3: {