@mento-protocol/mento-sdk 3.0.0-beta.3 → 3.0.0-beta.31

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 (371) hide show
  1. package/README.md +132 -275
  2. package/dist/cache/routes.d.ts +13 -0
  3. package/dist/cache/routes.d.ts.map +1 -0
  4. package/dist/cache/routes.js +11483 -0
  5. package/dist/cache/routes.js.map +1 -0
  6. package/dist/cache/tokens.d.ts +67 -0
  7. package/dist/cache/tokens.d.ts.map +1 -0
  8. package/dist/cache/tokens.js +379 -0
  9. package/dist/cache/tokens.js.map +1 -0
  10. package/dist/core/abis/activePool.d.ts +2 -0
  11. package/dist/core/abis/activePool.d.ts.map +1 -0
  12. package/dist/core/abis/activePool.js +14 -0
  13. package/dist/core/abis/activePool.js.map +1 -0
  14. package/dist/core/abis/addressesRegistry.d.ts +2 -0
  15. package/dist/core/abis/addressesRegistry.d.ts.map +1 -0
  16. package/dist/core/abis/addressesRegistry.js +26 -0
  17. package/dist/core/abis/addressesRegistry.js.map +1 -0
  18. package/dist/core/abis/borrowerOperations.d.ts +9 -0
  19. package/dist/core/abis/borrowerOperations.d.ts.map +1 -0
  20. package/dist/core/abis/borrowerOperations.js +89 -0
  21. package/dist/core/abis/borrowerOperations.js.map +1 -0
  22. package/dist/core/abis/breakerbox.d.ts +13 -0
  23. package/dist/core/abis/breakerbox.d.ts.map +1 -0
  24. package/dist/core/abis/breakerbox.js +8 -0
  25. package/dist/core/abis/breakerbox.js.map +1 -0
  26. package/dist/core/abis/erc20.d.ts +7 -0
  27. package/dist/core/abis/erc20.d.ts.map +1 -1
  28. package/dist/core/abis/erc20.js +7 -0
  29. package/dist/core/abis/erc20.js.map +1 -1
  30. package/dist/core/abis/fpmm.d.ts +236 -0
  31. package/dist/core/abis/fpmm.d.ts.map +1 -1
  32. package/dist/core/abis/fpmm.js +38 -0
  33. package/dist/core/abis/fpmm.js.map +1 -1
  34. package/dist/core/abis/fpmmFactory.d.ts +64 -0
  35. package/dist/core/abis/fpmmFactory.d.ts.map +1 -1
  36. package/dist/core/abis/fpmmFactory.js +17 -0
  37. package/dist/core/abis/fpmmFactory.js.map +1 -1
  38. package/dist/core/abis/hintHelpers.d.ts +2 -0
  39. package/dist/core/abis/hintHelpers.d.ts.map +1 -0
  40. package/dist/core/abis/hintHelpers.js +14 -0
  41. package/dist/core/abis/hintHelpers.js.map +1 -0
  42. package/dist/core/abis/index.d.ts +12 -1
  43. package/dist/core/abis/index.d.ts.map +1 -1
  44. package/dist/core/abis/index.js +12 -1
  45. package/dist/core/abis/index.js.map +1 -1
  46. package/dist/core/abis/multiTroveGetter.d.ts +8 -0
  47. package/dist/core/abis/multiTroveGetter.d.ts.map +1 -0
  48. package/dist/core/abis/multiTroveGetter.js +15 -0
  49. package/dist/core/abis/multiTroveGetter.js.map +1 -0
  50. package/dist/core/abis/priceFeed.d.ts +7 -0
  51. package/dist/core/abis/priceFeed.d.ts.map +1 -0
  52. package/dist/core/abis/priceFeed.js +16 -0
  53. package/dist/core/abis/priceFeed.js.map +1 -0
  54. package/dist/core/abis/router.d.ts +520 -1
  55. package/dist/core/abis/router.d.ts.map +1 -1
  56. package/dist/core/abis/router.js +35 -0
  57. package/dist/core/abis/router.js.map +1 -1
  58. package/dist/core/abis/sortedTroves.d.ts +2 -0
  59. package/dist/core/abis/sortedTroves.d.ts.map +1 -0
  60. package/dist/core/abis/sortedTroves.js +15 -0
  61. package/dist/core/abis/sortedTroves.js.map +1 -0
  62. package/dist/core/abis/systemParams.d.ts +2 -0
  63. package/dist/core/abis/systemParams.d.ts.map +1 -0
  64. package/dist/core/abis/systemParams.js +14 -0
  65. package/dist/core/abis/systemParams.js.map +1 -0
  66. package/dist/core/abis/troveManager.d.ts +2 -0
  67. package/dist/core/abis/troveManager.d.ts.map +1 -0
  68. package/dist/core/abis/troveManager.js +27 -0
  69. package/dist/core/abis/troveManager.js.map +1 -0
  70. package/dist/core/abis/troveNFT.d.ts +2 -0
  71. package/dist/core/abis/troveNFT.d.ts.map +1 -0
  72. package/dist/core/abis/troveNFT.js +9 -0
  73. package/dist/core/abis/troveNFT.js.map +1 -0
  74. package/dist/core/abis/virtualPool.d.ts +40 -0
  75. package/dist/core/abis/virtualPool.d.ts.map +1 -1
  76. package/dist/core/abis/virtualPool.js +6 -1
  77. package/dist/core/abis/virtualPool.js.map +1 -1
  78. package/dist/core/abis/virtualPoolFactory.d.ts +32 -0
  79. package/dist/core/abis/virtualPoolFactory.d.ts.map +1 -1
  80. package/dist/core/abis/virtualPoolFactory.js +8 -0
  81. package/dist/core/abis/virtualPoolFactory.js.map +1 -1
  82. package/dist/core/constants/addresses.d.ts.map +1 -1
  83. package/dist/core/constants/addresses.js +12 -4
  84. package/dist/core/constants/addresses.js.map +1 -1
  85. package/dist/core/constants/borrowConstants.d.ts +10 -0
  86. package/dist/core/constants/borrowConstants.d.ts.map +1 -0
  87. package/dist/core/constants/borrowConstants.js +16 -0
  88. package/dist/core/constants/borrowConstants.js.map +1 -0
  89. package/dist/core/constants/borrowRegistries.d.ts +7 -0
  90. package/dist/core/constants/borrowRegistries.d.ts.map +1 -0
  91. package/dist/core/constants/borrowRegistries.js +30 -0
  92. package/dist/core/constants/borrowRegistries.js.map +1 -0
  93. package/dist/core/constants/index.d.ts +2 -3
  94. package/dist/core/constants/index.d.ts.map +1 -1
  95. package/dist/core/constants/index.js +2 -3
  96. package/dist/core/constants/index.js.map +1 -1
  97. package/dist/core/errors/index.d.ts +1 -0
  98. package/dist/core/errors/index.d.ts.map +1 -1
  99. package/dist/core/errors/index.js +1 -0
  100. package/dist/core/errors/index.js.map +1 -1
  101. package/dist/core/errors/oracle.d.ts +9 -0
  102. package/dist/core/errors/oracle.d.ts.map +1 -0
  103. package/dist/core/errors/oracle.js +15 -0
  104. package/dist/core/errors/oracle.js.map +1 -0
  105. package/dist/core/errors/router.d.ts +6 -0
  106. package/dist/core/errors/router.d.ts.map +1 -1
  107. package/dist/core/errors/router.js +11 -1
  108. package/dist/core/errors/router.js.map +1 -1
  109. package/dist/core/types/borrow.d.ts +87 -0
  110. package/dist/core/types/borrow.d.ts.map +1 -0
  111. package/dist/{services/tokens/supply/ISupplyCalculator.js → core/types/borrow.js} +1 -1
  112. package/dist/core/types/borrow.js.map +1 -0
  113. package/dist/core/types/contractAddresses.d.ts +2 -0
  114. package/dist/core/types/contractAddresses.d.ts.map +1 -1
  115. package/dist/core/types/index.d.ts +5 -1
  116. package/dist/core/types/index.d.ts.map +1 -1
  117. package/dist/core/types/index.js +5 -1
  118. package/dist/core/types/index.js.map +1 -1
  119. package/dist/core/types/liquidity.d.ts +117 -0
  120. package/dist/core/types/liquidity.d.ts.map +1 -0
  121. package/dist/{services/tokens/supply/calculatorFactory.js → core/types/liquidity.js} +1 -1
  122. package/dist/core/types/liquidity.js.map +1 -0
  123. package/dist/core/types/pool.d.ts +110 -0
  124. package/dist/core/types/pool.d.ts.map +1 -1
  125. package/dist/core/types/provider.d.ts.map +1 -1
  126. package/dist/core/types/provider.js +0 -1
  127. package/dist/core/types/provider.js.map +1 -1
  128. package/dist/core/types/route.d.ts +3 -3
  129. package/dist/core/types/route.d.ts.map +1 -1
  130. package/dist/core/types/token.d.ts +13 -17
  131. package/dist/core/types/token.d.ts.map +1 -1
  132. package/dist/core/types/tradingLimits.d.ts +91 -0
  133. package/dist/core/types/tradingLimits.d.ts.map +1 -0
  134. package/dist/core/types/tradingLimits.js +3 -0
  135. package/dist/core/types/tradingLimits.js.map +1 -0
  136. package/dist/core/types/tradingMode.d.ts +24 -0
  137. package/dist/core/types/tradingMode.d.ts.map +1 -0
  138. package/dist/core/types/tradingMode.js +31 -0
  139. package/dist/core/types/tradingMode.js.map +1 -0
  140. package/dist/core/types/transaction.d.ts +45 -0
  141. package/dist/core/types/transaction.d.ts.map +1 -0
  142. package/dist/core/types/transaction.js +3 -0
  143. package/dist/core/types/transaction.js.map +1 -0
  144. package/dist/index.d.ts +35 -5
  145. package/dist/index.d.ts.map +1 -1
  146. package/dist/index.js +57 -14
  147. package/dist/index.js.map +1 -1
  148. package/dist/services/borrow/BorrowService.d.ts +54 -0
  149. package/dist/services/borrow/BorrowService.d.ts.map +1 -0
  150. package/dist/services/borrow/BorrowService.js +129 -0
  151. package/dist/services/borrow/BorrowService.js.map +1 -0
  152. package/dist/services/borrow/borrowHelpers.d.ts +4 -0
  153. package/dist/services/borrow/borrowHelpers.d.ts.map +1 -0
  154. package/dist/services/borrow/borrowHelpers.js +13 -0
  155. package/dist/services/borrow/borrowHelpers.js.map +1 -0
  156. package/dist/services/borrow/borrowMath.d.ts +13 -0
  157. package/dist/services/borrow/borrowMath.d.ts.map +1 -0
  158. package/dist/services/borrow/borrowMath.js +129 -0
  159. package/dist/services/borrow/borrowMath.js.map +1 -0
  160. package/dist/services/borrow/index.d.ts +2 -0
  161. package/dist/services/borrow/index.d.ts.map +1 -0
  162. package/dist/services/{tokens/supply → borrow}/index.js +1 -6
  163. package/dist/services/borrow/index.js.map +1 -0
  164. package/dist/services/borrow/internal/borrowApprovalService.d.ts +14 -0
  165. package/dist/services/borrow/internal/borrowApprovalService.d.ts.map +1 -0
  166. package/dist/services/borrow/internal/borrowApprovalService.js +53 -0
  167. package/dist/services/borrow/internal/borrowApprovalService.js.map +1 -0
  168. package/dist/services/borrow/internal/borrowContextStore.d.ts +11 -0
  169. package/dist/services/borrow/internal/borrowContextStore.d.ts.map +1 -0
  170. package/dist/services/borrow/internal/borrowContextStore.js +40 -0
  171. package/dist/services/borrow/internal/borrowContextStore.js.map +1 -0
  172. package/dist/services/borrow/internal/borrowErc20.d.ts +5 -0
  173. package/dist/services/borrow/internal/borrowErc20.d.ts.map +1 -0
  174. package/dist/services/borrow/internal/borrowErc20.js +43 -0
  175. package/dist/services/borrow/internal/borrowErc20.js.map +1 -0
  176. package/dist/services/borrow/internal/borrowHints.d.ts +7 -0
  177. package/dist/services/borrow/internal/borrowHints.d.ts.map +1 -0
  178. package/dist/services/borrow/internal/borrowHints.js +31 -0
  179. package/dist/services/borrow/internal/borrowHints.js.map +1 -0
  180. package/dist/services/borrow/internal/borrowPositionParser.d.ts +4 -0
  181. package/dist/services/borrow/internal/borrowPositionParser.d.ts.map +1 -0
  182. package/dist/services/borrow/internal/borrowPositionParser.js +87 -0
  183. package/dist/services/borrow/internal/borrowPositionParser.js.map +1 -0
  184. package/dist/services/borrow/internal/borrowReadService.d.ts +28 -0
  185. package/dist/services/borrow/internal/borrowReadService.d.ts.map +1 -0
  186. package/dist/services/borrow/internal/borrowReadService.js +218 -0
  187. package/dist/services/borrow/internal/borrowReadService.js.map +1 -0
  188. package/dist/services/borrow/internal/borrowRegistryReader.d.ts +5 -0
  189. package/dist/services/borrow/internal/borrowRegistryReader.d.ts.map +1 -0
  190. package/dist/services/borrow/internal/borrowRegistryReader.js +96 -0
  191. package/dist/services/borrow/internal/borrowRegistryReader.js.map +1 -0
  192. package/dist/services/borrow/internal/borrowTransactionService.d.ts +23 -0
  193. package/dist/services/borrow/internal/borrowTransactionService.d.ts.map +1 -0
  194. package/dist/services/borrow/internal/borrowTransactionService.js +276 -0
  195. package/dist/services/borrow/internal/borrowTransactionService.js.map +1 -0
  196. package/dist/services/borrow/internal/borrowTypes.d.ts +15 -0
  197. package/dist/services/borrow/internal/borrowTypes.d.ts.map +1 -0
  198. package/dist/services/borrow/internal/borrowTypes.js +3 -0
  199. package/dist/services/borrow/internal/borrowTypes.js.map +1 -0
  200. package/dist/services/borrow/internal/borrowValidation.d.ts +13 -0
  201. package/dist/services/borrow/internal/borrowValidation.d.ts.map +1 -0
  202. package/dist/services/borrow/internal/borrowValidation.js +96 -0
  203. package/dist/services/borrow/internal/borrowValidation.js.map +1 -0
  204. package/dist/services/index.d.ts +2 -2
  205. package/dist/services/index.d.ts.map +1 -1
  206. package/dist/services/index.js +2 -2
  207. package/dist/services/index.js.map +1 -1
  208. package/dist/services/liquidity/LiquidityService.d.ts +154 -0
  209. package/dist/services/liquidity/LiquidityService.d.ts.map +1 -0
  210. package/dist/services/liquidity/LiquidityService.js +184 -0
  211. package/dist/services/liquidity/LiquidityService.js.map +1 -0
  212. package/dist/services/liquidity/basicLiquidity.d.ts +11 -0
  213. package/dist/services/liquidity/basicLiquidity.d.ts.map +1 -0
  214. package/dist/services/liquidity/basicLiquidity.js +172 -0
  215. package/dist/services/liquidity/basicLiquidity.js.map +1 -0
  216. package/dist/services/liquidity/index.d.ts +2 -0
  217. package/dist/services/liquidity/index.d.ts.map +1 -0
  218. package/dist/services/liquidity/index.js +18 -0
  219. package/dist/services/liquidity/index.js.map +1 -0
  220. package/dist/services/liquidity/liquidityHelpers.d.ts +13 -0
  221. package/dist/services/liquidity/liquidityHelpers.d.ts.map +1 -0
  222. package/dist/services/liquidity/liquidityHelpers.js +74 -0
  223. package/dist/services/liquidity/liquidityHelpers.js.map +1 -0
  224. package/dist/services/liquidity/zapHelpers.d.ts +66 -0
  225. package/dist/services/liquidity/zapHelpers.d.ts.map +1 -0
  226. package/dist/services/liquidity/zapHelpers.js +133 -0
  227. package/dist/services/liquidity/zapHelpers.js.map +1 -0
  228. package/dist/services/liquidity/zapIn.d.ts +17 -0
  229. package/dist/services/liquidity/zapIn.d.ts.map +1 -0
  230. package/dist/services/liquidity/zapIn.js +125 -0
  231. package/dist/services/liquidity/zapIn.js.map +1 -0
  232. package/dist/services/liquidity/zapOut.d.ts +17 -0
  233. package/dist/services/liquidity/zapOut.d.ts.map +1 -0
  234. package/dist/services/liquidity/zapOut.js +242 -0
  235. package/dist/services/liquidity/zapOut.js.map +1 -0
  236. package/dist/services/pools/PoolService.d.ts +35 -10
  237. package/dist/services/pools/PoolService.d.ts.map +1 -1
  238. package/dist/services/pools/PoolService.js +61 -112
  239. package/dist/services/pools/PoolService.js.map +1 -1
  240. package/dist/services/pools/poolDetails.d.ts +11 -0
  241. package/dist/services/pools/poolDetails.d.ts.map +1 -0
  242. package/dist/services/pools/poolDetails.js +151 -0
  243. package/dist/services/pools/poolDetails.js.map +1 -0
  244. package/dist/services/pools/poolDiscovery.d.ts +12 -0
  245. package/dist/services/pools/poolDiscovery.d.ts.map +1 -0
  246. package/dist/services/pools/poolDiscovery.js +114 -0
  247. package/dist/services/pools/poolDiscovery.js.map +1 -0
  248. package/dist/services/quotes/QuoteService.d.ts +21 -12
  249. package/dist/services/quotes/QuoteService.d.ts.map +1 -1
  250. package/dist/services/quotes/QuoteService.js +44 -17
  251. package/dist/services/quotes/QuoteService.js.map +1 -1
  252. package/dist/services/routes/RouteService.d.ts +3 -3
  253. package/dist/services/routes/RouteService.d.ts.map +1 -1
  254. package/dist/services/routes/RouteService.js +3 -6
  255. package/dist/services/routes/RouteService.js.map +1 -1
  256. package/dist/services/swap/SwapService.d.ts +23 -19
  257. package/dist/services/swap/SwapService.d.ts.map +1 -1
  258. package/dist/services/swap/SwapService.js +42 -17
  259. package/dist/services/swap/SwapService.js.map +1 -1
  260. package/dist/services/tokens/tokenService.d.ts +3 -3
  261. package/dist/services/tokens/tokenService.d.ts.map +1 -1
  262. package/dist/services/tokens/tokenService.js +26 -37
  263. package/dist/services/tokens/tokenService.js.map +1 -1
  264. package/dist/services/trading/TradingLimitsService.d.ts +38 -0
  265. package/dist/services/trading/TradingLimitsService.d.ts.map +1 -0
  266. package/dist/services/trading/TradingLimitsService.js +157 -0
  267. package/dist/services/trading/TradingLimitsService.js.map +1 -0
  268. package/dist/services/trading/TradingService.d.ts +110 -0
  269. package/dist/services/trading/TradingService.d.ts.map +1 -0
  270. package/dist/services/trading/TradingService.js +162 -0
  271. package/dist/services/trading/TradingService.js.map +1 -0
  272. package/dist/services/trading/index.d.ts +3 -0
  273. package/dist/services/trading/index.d.ts.map +1 -0
  274. package/dist/services/trading/index.js +19 -0
  275. package/dist/services/trading/index.js.map +1 -0
  276. package/dist/utils/costUtils.js +4 -4
  277. package/dist/utils/costUtils.js.map +1 -1
  278. package/dist/utils/deadline.d.ts +21 -0
  279. package/dist/utils/deadline.d.ts.map +1 -0
  280. package/dist/utils/deadline.js +26 -0
  281. package/dist/utils/deadline.js.map +1 -0
  282. package/dist/utils/index.d.ts +3 -0
  283. package/dist/utils/index.d.ts.map +1 -1
  284. package/dist/utils/index.js +3 -0
  285. package/dist/utils/index.js.map +1 -1
  286. package/dist/utils/pathEncoder.d.ts +8 -2
  287. package/dist/utils/pathEncoder.d.ts.map +1 -1
  288. package/dist/utils/pathEncoder.js +19 -3
  289. package/dist/utils/pathEncoder.js.map +1 -1
  290. package/dist/utils/rateFeed.d.ts +18 -0
  291. package/dist/utils/rateFeed.d.ts.map +1 -0
  292. package/dist/utils/rateFeed.js +27 -0
  293. package/dist/utils/rateFeed.js.map +1 -0
  294. package/dist/utils/routeUtils.d.ts +53 -53
  295. package/dist/utils/routeUtils.d.ts.map +1 -1
  296. package/dist/utils/routeUtils.js +41 -41
  297. package/dist/utils/routeUtils.js.map +1 -1
  298. package/dist/utils/routes.d.ts +2 -8
  299. package/dist/utils/routes.d.ts.map +1 -1
  300. package/dist/utils/routes.js +5 -46
  301. package/dist/utils/routes.js.map +1 -1
  302. package/dist/utils/tokens.d.ts +1 -62
  303. package/dist/utils/tokens.d.ts.map +1 -1
  304. package/dist/utils/tokens.js +10 -163
  305. package/dist/utils/tokens.js.map +1 -1
  306. package/dist/utils/tradingLimits.d.ts +41 -0
  307. package/dist/utils/tradingLimits.d.ts.map +1 -0
  308. package/dist/utils/tradingLimits.js +171 -0
  309. package/dist/utils/tradingLimits.js.map +1 -0
  310. package/dist/utils/validation.d.ts +19 -0
  311. package/dist/utils/validation.d.ts.map +1 -0
  312. package/dist/utils/validation.js +34 -0
  313. package/dist/utils/validation.js.map +1 -0
  314. package/package.json +6 -6
  315. package/dist/cache/routes.42220.d.ts +0 -3
  316. package/dist/cache/routes.42220.d.ts.map +0 -1
  317. package/dist/cache/routes.42220.js +0 -112
  318. package/dist/cache/routes.42220.js.map +0 -1
  319. package/dist/cache/tokens.11142220.d.ts +0 -3
  320. package/dist/cache/tokens.11142220.d.ts.map +0 -1
  321. package/dist/cache/tokens.11142220.js +0 -129
  322. package/dist/cache/tokens.11142220.js.map +0 -1
  323. package/dist/cache/tokens.42220.d.ts +0 -3
  324. package/dist/cache/tokens.42220.d.ts.map +0 -1
  325. package/dist/cache/tokens.42220.js +0 -129
  326. package/dist/cache/tokens.42220.js.map +0 -1
  327. package/dist/core/abis/uniswapV3.d.ts +0 -4
  328. package/dist/core/abis/uniswapV3.d.ts.map +0 -1
  329. package/dist/core/abis/uniswapV3.js +0 -16
  330. package/dist/core/abis/uniswapV3.js.map +0 -1
  331. package/dist/core/constants/aaveConfig.d.ts +0 -7
  332. package/dist/core/constants/aaveConfig.d.ts.map +0 -1
  333. package/dist/core/constants/aaveConfig.js +0 -22
  334. package/dist/core/constants/aaveConfig.js.map +0 -1
  335. package/dist/core/constants/mentoAddresses.d.ts +0 -7
  336. package/dist/core/constants/mentoAddresses.d.ts.map +0 -1
  337. package/dist/core/constants/mentoAddresses.js +0 -10
  338. package/dist/core/constants/mentoAddresses.js.map +0 -1
  339. package/dist/core/constants/protocolAddresses.d.ts +0 -5
  340. package/dist/core/constants/protocolAddresses.d.ts.map +0 -1
  341. package/dist/core/constants/protocolAddresses.js +0 -8
  342. package/dist/core/constants/protocolAddresses.js.map +0 -1
  343. package/dist/services/tokens/supply/ISupplyCalculator.d.ts +0 -14
  344. package/dist/services/tokens/supply/ISupplyCalculator.d.ts.map +0 -1
  345. package/dist/services/tokens/supply/ISupplyCalculator.js.map +0 -1
  346. package/dist/services/tokens/supply/aaveSupplyCalculator.d.ts +0 -22
  347. package/dist/services/tokens/supply/aaveSupplyCalculator.d.ts.map +0 -1
  348. package/dist/services/tokens/supply/aaveSupplyCalculator.js +0 -46
  349. package/dist/services/tokens/supply/aaveSupplyCalculator.js.map +0 -1
  350. package/dist/services/tokens/supply/calculatorFactory.d.ts +0 -8
  351. package/dist/services/tokens/supply/calculatorFactory.d.ts.map +0 -1
  352. package/dist/services/tokens/supply/calculatorFactory.js.map +0 -1
  353. package/dist/services/tokens/supply/defaultCalculatorFactory.d.ts +0 -9
  354. package/dist/services/tokens/supply/defaultCalculatorFactory.d.ts.map +0 -1
  355. package/dist/services/tokens/supply/defaultCalculatorFactory.js +0 -28
  356. package/dist/services/tokens/supply/defaultCalculatorFactory.js.map +0 -1
  357. package/dist/services/tokens/supply/index.d.ts +0 -7
  358. package/dist/services/tokens/supply/index.d.ts.map +0 -1
  359. package/dist/services/tokens/supply/index.js.map +0 -1
  360. package/dist/services/tokens/supply/multisigSupplyCalculator.d.ts +0 -9
  361. package/dist/services/tokens/supply/multisigSupplyCalculator.d.ts.map +0 -1
  362. package/dist/services/tokens/supply/multisigSupplyCalculator.js +0 -33
  363. package/dist/services/tokens/supply/multisigSupplyCalculator.js.map +0 -1
  364. package/dist/services/tokens/supply/uniV3SupplyCalculator.d.ts +0 -21
  365. package/dist/services/tokens/supply/uniV3SupplyCalculator.d.ts.map +0 -1
  366. package/dist/services/tokens/supply/uniV3SupplyCalculator.js +0 -238
  367. package/dist/services/tokens/supply/uniV3SupplyCalculator.js.map +0 -1
  368. package/dist/services/tokens/supplyAdjustmentService.d.ts +0 -19
  369. package/dist/services/tokens/supplyAdjustmentService.d.ts.map +0 -1
  370. package/dist/services/tokens/supplyAdjustmentService.js +0 -49
  371. package/dist/services/tokens/supplyAdjustmentService.js.map +0 -1
@@ -1,5 +1,12 @@
1
- import { Pool } from '../../core/types';
1
+ import { Pool, PoolDetails } from '../../core/types';
2
2
  import { PublicClient } from 'viem';
3
+ /**
4
+ * Result of pool discovery including any warnings from failed factories
5
+ */
6
+ export interface PoolDiscoveryResult {
7
+ pools: Pool[];
8
+ warnings: string[];
9
+ }
3
10
  /**
4
11
  * Service for discovering liquidity pools in the Mento protocol.
5
12
  * Aggregates pools from multiple factory contracts (FPMM and VirtualPool).
@@ -8,13 +15,19 @@ export declare class PoolService {
8
15
  private publicClient;
9
16
  private chainId;
10
17
  private poolsCache;
18
+ private discoveryWarnings;
11
19
  constructor(publicClient: PublicClient, chainId: number);
20
+ /**
21
+ * Returns any warnings from the last pool discovery operation.
22
+ * Useful for debugging when some factories fail but others succeed.
23
+ */
24
+ getDiscoveryWarnings(): string[];
12
25
  /**
13
26
  * Fetches all pools available in the protocol from both FPMM and Virtual pool factories
14
27
  * Results are cached in memory for the service instance lifetime
15
28
  *
16
29
  * @returns Array of all pools available in the protocol
17
- * @throws {Error} If RPC call fails or pools are unavailable
30
+ * @throws {Error} If no pools can be discovered from any factory
18
31
  *
19
32
  * @example
20
33
  * ```typescript
@@ -24,14 +37,26 @@ export declare class PoolService {
24
37
  */
25
38
  getPools(): Promise<Pool[]>;
26
39
  /**
27
- * Fetches all FPMM pools from the FPMM Factory
28
- */
29
- private fetchFPMMPools;
30
- /**
31
- * Fetches all Virtual pools by discovering them from BiPoolManager exchanges.
32
- * VirtualPoolFactory doesn't have an enumeration method,
33
- * so we have to derive pools from BiPoolManager.
40
+ * Fetches enriched on-chain details for a specific pool by address.
41
+ * Resolves the pool type from the discovery cache, then fetches
42
+ * pool-type-specific data (pricing, fees, rebalancing for FPMM; reserves and spread for Virtual).
43
+ *
44
+ * @param poolAddr - The deployed pool contract address
45
+ * @returns Enriched pool details (FPMMPoolDetails or VirtualPoolDetails)
46
+ * @throws {Error} If the pool address is not found in any known factory
47
+ * @throws {Error} If on-chain calls fail
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const details = await poolService.getPoolDetails('0x...')
52
+ * if (details.poolType === 'FPMM') {
53
+ * console.log(details.pricing.oraclePrice)
54
+ * console.log(details.rebalancing.inBand)
55
+ * } else {
56
+ * console.log(details.spreadPercent)
57
+ * }
58
+ * ```
34
59
  */
35
- private fetchVirtualPools;
60
+ getPoolDetails(poolAddr: string): Promise<PoolDetails>;
36
61
  }
37
62
  //# sourceMappingURL=PoolService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PoolService.d.ts","sourceRoot":"","sources":["../../../src/services/pools/PoolService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,YAAY,EAAW,MAAM,MAAM,CAAA;AAK5C;;;GAGG;AACH,qBAAa,WAAW;IAGV,OAAO,CAAC,YAAY;IAAgB,OAAO,CAAC,OAAO;IAF/D,OAAO,CAAC,UAAU,CAAsB;gBAEpB,YAAY,EAAE,YAAY,EAAU,OAAO,EAAE,MAAM;IAEvE;;;;;;;;;;;;OAYG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAoBjC;;OAEG;YACW,cAAc;IAkD5B;;;;OAIG;YACW,iBAAiB;CAmEhC"}
1
+ {"version":3,"file":"PoolService.d.ts","sourceRoot":"","sources":["../../../src/services/pools/PoolService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAInC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;GAGG;AACH,qBAAa,WAAW;IAIV,OAAO,CAAC,YAAY;IAAgB,OAAO,CAAC,OAAO;IAH/D,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,iBAAiB,CAAe;gBAEpB,YAAY,EAAE,YAAY,EAAU,OAAO,EAAE,MAAM;IAEvE;;;OAGG;IACH,oBAAoB,IAAI,MAAM,EAAE;IAIhC;;;;;;;;;;;;OAYG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAwCjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAc7D"}
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PoolService = void 0;
4
- const constants_1 = require("../../core/constants");
5
4
  const types_1 = require("../../core/types");
6
- const abis_1 = require("../../core/abis");
7
- const sortUtils_1 = require("../../utils/sortUtils");
8
- // TODO: Update to enrich pools with more data as needed. Use optional flag to include more data.
5
+ const poolDiscovery_1 = require("./poolDiscovery");
6
+ const poolDetails_1 = require("./poolDetails");
9
7
  /**
10
8
  * Service for discovering liquidity pools in the Mento protocol.
11
9
  * Aggregates pools from multiple factory contracts (FPMM and VirtualPool).
@@ -15,13 +13,21 @@ class PoolService {
15
13
  this.publicClient = publicClient;
16
14
  this.chainId = chainId;
17
15
  this.poolsCache = null;
16
+ this.discoveryWarnings = [];
17
+ }
18
+ /**
19
+ * Returns any warnings from the last pool discovery operation.
20
+ * Useful for debugging when some factories fail but others succeed.
21
+ */
22
+ getDiscoveryWarnings() {
23
+ return [...this.discoveryWarnings];
18
24
  }
19
25
  /**
20
26
  * Fetches all pools available in the protocol from both FPMM and Virtual pool factories
21
27
  * Results are cached in memory for the service instance lifetime
22
28
  *
23
29
  * @returns Array of all pools available in the protocol
24
- * @throws {Error} If RPC call fails or pools are unavailable
30
+ * @throws {Error} If no pools can be discovered from any factory
25
31
  *
26
32
  * @example
27
33
  * ```typescript
@@ -33,124 +39,67 @@ class PoolService {
33
39
  if (this.poolsCache) {
34
40
  return this.poolsCache;
35
41
  }
36
- // TODO: Update to use router.factoryRegistry.poolFactories()
37
- // for dynamic factory discovery. For now we will use
38
- // the hardcoded factory addresses for the chain for v1.
39
42
  const pools = [];
40
- const fpmmPools = await this.fetchFPMMPools();
41
- pools.push(...fpmmPools);
42
- const virtualPools = await this.fetchVirtualPools();
43
- pools.push(...virtualPools);
44
- this.poolsCache = pools;
45
- return pools;
46
- }
47
- /**
48
- * Fetches all FPMM pools from the FPMM Factory
49
- */
50
- async fetchFPMMPools() {
51
- const fpmmFactoryAddress = (0, constants_1.getContractAddress)(this.chainId, 'FPMMFactory');
52
- if (!fpmmFactoryAddress) {
53
- console.warn('FPMM Factory address not found for this chain');
54
- return [];
43
+ const warnings = [];
44
+ try {
45
+ const fpmmPools = await (0, poolDiscovery_1.fetchFPMMPools)(this.publicClient, this.chainId);
46
+ pools.push(...fpmmPools);
47
+ }
48
+ catch (error) {
49
+ const message = `Failed to fetch FPMM pools: ${error instanceof Error ? error.message : String(error)}`;
50
+ console.warn(`[PoolService] ${message}`);
51
+ warnings.push(message);
55
52
  }
56
53
  try {
57
- // Get all deployed FPMM pool addresses
58
- const poolAddresses = (await this.publicClient.readContract({
59
- address: fpmmFactoryAddress,
60
- abi: abis_1.FPMM_FACTORY_ABI,
61
- functionName: 'deployedFPMMAddresses',
62
- }));
63
- if (poolAddresses.length === 0) {
64
- return [];
65
- }
66
- const poolDataPromises = poolAddresses.map(async (poolAddress) => {
67
- const [token0, token1] = await Promise.all([
68
- this.publicClient.readContract({
69
- address: poolAddress,
70
- abi: abis_1.FPMM_ABI,
71
- functionName: 'token0',
72
- }),
73
- this.publicClient.readContract({
74
- address: poolAddress,
75
- abi: abis_1.FPMM_ABI,
76
- functionName: 'token1',
77
- }),
78
- ]);
79
- return {
80
- factoryAddr: fpmmFactoryAddress,
81
- poolAddr: poolAddress,
82
- token0: token0,
83
- token1: token1,
84
- poolType: types_1.PoolType.FPMM,
85
- };
86
- });
87
- return await Promise.all(poolDataPromises);
54
+ const virtualPools = await (0, poolDiscovery_1.fetchVirtualPools)(this.publicClient, this.chainId);
55
+ pools.push(...virtualPools);
88
56
  }
89
57
  catch (error) {
90
- console.error('Failed to fetch FPMM pools:', error);
91
- throw new Error(`Failed to fetch FPMM pools: ${error.message}`);
58
+ const message = `Failed to fetch Virtual pools: ${error instanceof Error ? error.message : String(error)}`;
59
+ console.warn(`[PoolService] ${message}`);
60
+ warnings.push(message);
92
61
  }
62
+ this.discoveryWarnings = warnings;
63
+ // Only throw if NO pools were discovered from any factory
64
+ if (pools.length === 0) {
65
+ throw new Error('Failed to discover any pools from any factory. ' +
66
+ 'All pool factory queries failed. Check network connectivity and RPC endpoint.');
67
+ }
68
+ this.poolsCache = pools;
69
+ return pools;
93
70
  }
94
71
  /**
95
- * Fetches all Virtual pools by discovering them from BiPoolManager exchanges.
96
- * VirtualPoolFactory doesn't have an enumeration method,
97
- * so we have to derive pools from BiPoolManager.
72
+ * Fetches enriched on-chain details for a specific pool by address.
73
+ * Resolves the pool type from the discovery cache, then fetches
74
+ * pool-type-specific data (pricing, fees, rebalancing for FPMM; reserves and spread for Virtual).
75
+ *
76
+ * @param poolAddr - The deployed pool contract address
77
+ * @returns Enriched pool details (FPMMPoolDetails or VirtualPoolDetails)
78
+ * @throws {Error} If the pool address is not found in any known factory
79
+ * @throws {Error} If on-chain calls fail
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const details = await poolService.getPoolDetails('0x...')
84
+ * if (details.poolType === 'FPMM') {
85
+ * console.log(details.pricing.oraclePrice)
86
+ * console.log(details.rebalancing.inBand)
87
+ * } else {
88
+ * console.log(details.spreadPercent)
89
+ * }
90
+ * ```
98
91
  */
99
- async fetchVirtualPools() {
100
- const virtualPoolFactoryAddress = (0, constants_1.getContractAddress)(this.chainId, 'VirtualPoolFactory');
101
- const biPoolManagerAddress = (0, constants_1.getContractAddress)(this.chainId, 'BiPoolManager');
102
- if (!virtualPoolFactoryAddress || !biPoolManagerAddress) {
103
- console.warn('VirtualPoolFactory or BiPoolManager address not found for this chain');
104
- return [];
92
+ async getPoolDetails(poolAddr) {
93
+ const pools = await this.getPools();
94
+ const pool = pools.find((p) => p.poolAddr.toLowerCase() === poolAddr.toLowerCase());
95
+ if (!pool) {
96
+ throw new Error(`Pool not found: ${poolAddr}. ` + 'Ensure the address is a valid pool discovered by getPools().');
105
97
  }
106
- try {
107
- // TODO: When new virtual pool factory is deployed
108
- // we can simplify this by using VirtualPoolFactory.getAllPools() returns(address[])
109
- // Get all exchanges from BiPoolManager
110
- const exchangesData = (await this.publicClient.readContract({
111
- address: biPoolManagerAddress,
112
- abi: abis_1.BIPOOL_MANAGER_ABI,
113
- functionName: 'getExchanges',
114
- }));
115
- if (exchangesData.length === 0) {
116
- return [];
117
- }
118
- // For each exchange, check if a virtual pool exists, and if so, return the pool address.
119
- const poolPromises = exchangesData.map(async (exchange) => {
120
- if (exchange.assets.length !== 2) {
121
- console.warn(`Skipping invalid exchange ${exchange.exchangeId}: expected 2 assets`);
122
- return null;
123
- }
124
- const [token0, token1] = (0, sortUtils_1.sortTokenAddresses)(exchange.assets[0], exchange.assets[1]);
125
- const poolAddress = (await this.publicClient.readContract({
126
- address: virtualPoolFactoryAddress,
127
- abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
128
- functionName: 'getOrPrecomputeProxyAddress',
129
- args: [token0, token1],
130
- }));
131
- const isDeployed = (await this.publicClient.readContract({
132
- address: virtualPoolFactoryAddress,
133
- abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
134
- functionName: 'isPool',
135
- args: [poolAddress],
136
- }));
137
- if (!isDeployed) {
138
- return null;
139
- }
140
- return {
141
- factoryAddr: virtualPoolFactoryAddress,
142
- poolAddr: poolAddress,
143
- token0: token0,
144
- token1: token1,
145
- poolType: types_1.PoolType.Virtual,
146
- };
147
- });
148
- const results = await Promise.all(poolPromises);
149
- return results.filter((pool) => pool !== null);
98
+ if (pool.poolType === types_1.PoolType.FPMM) {
99
+ return (0, poolDetails_1.fetchFPMMPoolDetails)(this.publicClient, this.chainId, pool);
150
100
  }
151
- catch (error) {
152
- console.error('Failed to fetch Virtual pools:', error);
153
- throw new Error(`Failed to fetch Virtual pools: ${error.message}`);
101
+ else {
102
+ return (0, poolDetails_1.fetchVirtualPoolDetails)(this.publicClient, pool);
154
103
  }
155
104
  }
156
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PoolService.js","sourceRoot":"","sources":["../../../src/services/pools/PoolService.ts"],"names":[],"mappings":";;;AAAA,oDAAkE;AAClE,4CAAiD;AACjD,0CAA0G;AAE1G,qDAA0D;AAE1D,iGAAiG;AAEjG;;;GAGG;AACH,MAAa,WAAW;IAGtB,YAAoB,YAA0B,EAAU,OAAe;QAAnD,iBAAY,GAAZ,Y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;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACvB,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,cAAc,CAAC,QAAgB;QACnC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAA;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;QAEnF,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,QAAQ,IAAI,GAAG,8DAA8D,CAAC,CAAA;QACnH,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,KAAK,gBAAQ,CAAC,IAAI,EAAE,CAAC;YACpC,OAAO,IAAA,kCAAoB,EAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACpE,CAAC;aAAM,CAAC;YACN,OAAO,IAAA,qCAAuB,EAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;CACF;AAtGD,kCAsGC"}
@@ -0,0 +1,11 @@
1
+ import { Pool, FPMMPoolDetails, VirtualPoolDetails } from '../../core/types';
2
+ import { PublicClient } from 'viem';
3
+ /**
4
+ * Fetches enriched details for an FPMM pool
5
+ */
6
+ export declare function fetchFPMMPoolDetails(publicClient: PublicClient, chainId: number, pool: Pool): Promise<FPMMPoolDetails>;
7
+ /**
8
+ * Fetches enriched details for a Virtual pool
9
+ */
10
+ export declare function fetchVirtualPoolDetails(publicClient: PublicClient, pool: Pool): Promise<VirtualPoolDetails>;
11
+ //# sourceMappingURL=poolDetails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poolDetails.d.ts","sourceRoot":"","sources":["../../../src/services/pools/poolDetails.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAe,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAEzF,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAA;AAExD;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,CAAC,CAmH1B;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4BjH"}
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchFPMMPoolDetails = fetchFPMMPoolDetails;
4
+ exports.fetchVirtualPoolDetails = fetchVirtualPoolDetails;
5
+ const constants_1 = require("../../core/constants");
6
+ const abis_1 = require("../../core/abis");
7
+ const viem_1 = require("viem");
8
+ /**
9
+ * Fetches enriched details for an FPMM pool
10
+ */
11
+ async function fetchFPMMPoolDetails(publicClient, chainId, pool) {
12
+ const address = pool.poolAddr;
13
+ try {
14
+ // Known liquidity strategy addresses for this chain
15
+ const knownStrategies = getKnownLiquidityStrategies(chainId);
16
+ // Fetch core data
17
+ const [reservesResult, decimals0, decimals1, lpFee, protocolFee, rebalanceIncentive, rebalanceThresholdAbove, rebalanceThresholdBelow, ...strategyResults] = await Promise.all([
18
+ publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'getReserves' }),
19
+ publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'decimals0' }),
20
+ publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'decimals1' }),
21
+ publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'lpFee' }),
22
+ publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'protocolFee' }),
23
+ publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceIncentive' }),
24
+ publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceThresholdAbove' }),
25
+ publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceThresholdBelow' }),
26
+ ...knownStrategies.map((strategyAddr) => publicClient.readContract({
27
+ address,
28
+ abi: abis_1.FPMM_ABI,
29
+ functionName: 'liquidityStrategy',
30
+ args: [strategyAddr],
31
+ })),
32
+ ]);
33
+ const [reserve0, reserve1, blockTimestampLast] = reservesResult;
34
+ const lpFeeBps = lpFee;
35
+ const protocolFeeBps = protocolFee;
36
+ const rebalanceIncentiveBps = rebalanceIncentive;
37
+ const thresholdAboveBps = rebalanceThresholdAbove;
38
+ const thresholdBelowBps = rebalanceThresholdBelow;
39
+ // Find the active liquidity strategy (first match wins)
40
+ const activeIndex = strategyResults.findIndex((result) => result === true);
41
+ const liquidityStrategy = activeIndex >= 0 ? knownStrategies[activeIndex] : null;
42
+ // Fetch pricing separately — graceful degradation when FX market is closed
43
+ let pricing = null;
44
+ let inBand = null;
45
+ try {
46
+ const rebalancingStateResult = await publicClient.readContract({
47
+ address,
48
+ abi: abis_1.FPMM_ABI,
49
+ functionName: 'getRebalancingState',
50
+ });
51
+ const [oraclePriceNum, oraclePriceDen, reservePriceNum, reservePriceDen, reservePriceAboveOraclePrice, rebalanceThreshold, priceDifference,] = rebalancingStateResult;
52
+ pricing = {
53
+ oraclePriceNum,
54
+ oraclePriceDen,
55
+ oraclePrice: Number(oraclePriceNum) / Number(oraclePriceDen),
56
+ reservePriceNum,
57
+ reservePriceDen,
58
+ reservePrice: Number(reservePriceNum) / Number(reservePriceDen),
59
+ priceDifferenceBps: priceDifference,
60
+ priceDifferencePercent: Number(priceDifference) / 100,
61
+ reservePriceAboveOraclePrice,
62
+ };
63
+ inBand = priceDifference < BigInt(rebalanceThreshold);
64
+ }
65
+ catch {
66
+ // getRebalancingState() failed (likely FXMarketClosed) — pricing stays null
67
+ }
68
+ return {
69
+ ...pool,
70
+ poolType: 'FPMM',
71
+ scalingFactor0: decimals0,
72
+ scalingFactor1: decimals1,
73
+ reserve0,
74
+ reserve1,
75
+ blockTimestampLast,
76
+ pricing,
77
+ fees: {
78
+ lpFeeBps,
79
+ lpFeePercent: Number(lpFeeBps) / 100,
80
+ protocolFeeBps,
81
+ protocolFeePercent: Number(protocolFeeBps) / 100,
82
+ totalFeePercent: (Number(lpFeeBps) + Number(protocolFeeBps)) / 100,
83
+ },
84
+ rebalancing: {
85
+ rebalanceIncentiveBps,
86
+ rebalanceIncentivePercent: Number(rebalanceIncentiveBps) / 100,
87
+ rebalanceThresholdAboveBps: thresholdAboveBps,
88
+ rebalanceThresholdAbovePercent: Number(thresholdAboveBps) / 100,
89
+ rebalanceThresholdBelowBps: thresholdBelowBps,
90
+ rebalanceThresholdBelowPercent: Number(thresholdBelowBps) / 100,
91
+ inBand,
92
+ liquidityStrategy,
93
+ },
94
+ };
95
+ }
96
+ catch (error) {
97
+ throw new Error(`Failed to fetch FPMM pool details for ${pool.poolAddr}: ${error.message}`);
98
+ }
99
+ }
100
+ /**
101
+ * Fetches enriched details for a Virtual pool
102
+ */
103
+ async function fetchVirtualPoolDetails(publicClient, pool) {
104
+ const address = pool.poolAddr;
105
+ try {
106
+ const [reservesResult, protocolFee, metadataResult] = await Promise.all([
107
+ publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'getReserves' }),
108
+ publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'protocolFee' }),
109
+ publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'metadata' }),
110
+ ]);
111
+ const [reserve0, reserve1, blockTimestampLast] = reservesResult;
112
+ const [dec0, dec1] = metadataResult;
113
+ const spreadBps = protocolFee;
114
+ return {
115
+ ...pool,
116
+ poolType: 'Virtual',
117
+ scalingFactor0: dec0,
118
+ scalingFactor1: dec1,
119
+ reserve0,
120
+ reserve1,
121
+ blockTimestampLast,
122
+ spreadBps,
123
+ spreadPercent: Number(spreadBps) / 100,
124
+ };
125
+ }
126
+ catch (error) {
127
+ throw new Error(`Failed to fetch Virtual pool details for ${pool.poolAddr}: ${error.message}`);
128
+ }
129
+ }
130
+ /**
131
+ * Returns the known liquidity strategy addresses for the given chain.
132
+ */
133
+ function getKnownLiquidityStrategies(chainId) {
134
+ const chainAddresses = constants_1.addresses[chainId];
135
+ if (!chainAddresses)
136
+ return [];
137
+ const strategyCandidates = [
138
+ chainAddresses.ReserveLiquidityStrategy,
139
+ chainAddresses.CDPLiquidityStrategy,
140
+ ].filter((address) => Boolean(address));
141
+ // Normalize to checksummed addresses and ignore malformed config values.
142
+ return strategyCandidates.flatMap((address) => {
143
+ try {
144
+ return [(0, viem_1.getAddress)(address)];
145
+ }
146
+ catch {
147
+ return [];
148
+ }
149
+ });
150
+ }
151
+ //# sourceMappingURL=poolDetails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poolDetails.js","sourceRoot":"","sources":["../../../src/services/pools/poolDetails.ts"],"names":[],"mappings":";;AAQA,oDAuHC;AAKD,0DA4BC;AAhKD,oDAAyD;AAEzD,0CAA4D;AAC5D,+BAAwD;AAExD;;GAEG;AACI,KAAK,UAAU,oBAAoB,CACxC,YAA0B,EAC1B,OAAe,EACf,IAAU;IAEV,MAAM,OAAO,GAAG,IAAI,CAAC,QAAmB,CAAA;IAExC,IAAI,CAAC;QACH,oDAAoD;QACpD,MAAM,eAAe,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAA;QAE5D,kBAAkB;QAClB,MAAM,CACJ,cAAc,EACd,SAAS,EACT,SAAS,EACT,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,GAAG,eAAe,CACnB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACpB,YAAY,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,eAAQ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"}
@@ -0,0 +1,12 @@
1
+ import { Pool } from '../../core/types';
2
+ import { PublicClient } from 'viem';
3
+ /**
4
+ * Fetches all FPMM pools from the FPMM Factory
5
+ */
6
+ export declare function fetchFPMMPools(publicClient: PublicClient, chainId: number): Promise<Pool[]>;
7
+ /**
8
+ * Fetches all active Virtual pools from the VirtualPoolFactory,
9
+ * then resolves token pairs and exchange IDs from each pool and BiPoolManager.
10
+ */
11
+ export declare function fetchVirtualPools(publicClient: PublicClient, chainId: number): Promise<Pool[]>;
12
+ //# sourceMappingURL=poolDiscovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poolDiscovery.d.ts","sourceRoot":"","sources":["../../../src/services/pools/poolDiscovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAA;AAQjD,OAAO,EAAE,YAAY,EAAW,MAAM,MAAM,CAAA;AAG5C;;GAEG;AACH,wBAAsB,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CA8CjG;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CA8DpG"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchFPMMPools = fetchFPMMPools;
4
+ exports.fetchVirtualPools = fetchVirtualPools;
5
+ const constants_1 = require("../../core/constants");
6
+ const types_1 = require("../../core/types");
7
+ const abis_1 = require("../../core/abis");
8
+ const sortUtils_1 = require("../../utils/sortUtils");
9
+ /**
10
+ * Fetches all FPMM pools from the FPMM Factory
11
+ */
12
+ async function fetchFPMMPools(publicClient, chainId) {
13
+ const fpmmFactoryAddress = (0, constants_1.getContractAddress)(chainId, 'FPMMFactory');
14
+ if (!fpmmFactoryAddress) {
15
+ return [];
16
+ }
17
+ try {
18
+ // Get all deployed FPMM pool addresses
19
+ const poolAddresses = (await publicClient.readContract({
20
+ address: fpmmFactoryAddress,
21
+ abi: abis_1.FPMM_FACTORY_ABI,
22
+ functionName: 'deployedFPMMAddresses',
23
+ }));
24
+ if (poolAddresses.length === 0) {
25
+ return [];
26
+ }
27
+ const poolDataPromises = poolAddresses.map(async (poolAddress) => {
28
+ const [token0, token1] = await Promise.all([
29
+ publicClient.readContract({
30
+ address: poolAddress,
31
+ abi: abis_1.FPMM_ABI,
32
+ functionName: 'token0',
33
+ }),
34
+ publicClient.readContract({
35
+ address: poolAddress,
36
+ abi: abis_1.FPMM_ABI,
37
+ functionName: 'token1',
38
+ }),
39
+ ]);
40
+ return {
41
+ factoryAddr: fpmmFactoryAddress,
42
+ poolAddr: poolAddress,
43
+ token0: token0,
44
+ token1: token1,
45
+ poolType: types_1.PoolType.FPMM,
46
+ };
47
+ });
48
+ return await Promise.all(poolDataPromises);
49
+ }
50
+ catch (error) {
51
+ throw new Error(`Failed to fetch FPMM pools: ${error.message}`);
52
+ }
53
+ }
54
+ /**
55
+ * Fetches all active Virtual pools from the VirtualPoolFactory,
56
+ * then resolves token pairs and exchange IDs from each pool and BiPoolManager.
57
+ */
58
+ async function fetchVirtualPools(publicClient, chainId) {
59
+ const virtualPoolFactoryAddress = (0, constants_1.getContractAddress)(chainId, 'VirtualPoolFactory');
60
+ const biPoolManagerAddress = (0, constants_1.getContractAddress)(chainId, 'BiPoolManager');
61
+ if (!virtualPoolFactoryAddress || !biPoolManagerAddress) {
62
+ return [];
63
+ }
64
+ try {
65
+ // Fetch active pool addresses and all exchanges in parallel
66
+ const [poolAddresses, exchangesData] = await Promise.all([
67
+ publicClient.readContract({
68
+ address: virtualPoolFactoryAddress,
69
+ abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
70
+ functionName: 'getAllPools',
71
+ }),
72
+ publicClient.readContract({
73
+ address: biPoolManagerAddress,
74
+ abi: abis_1.BIPOOL_MANAGER_ABI,
75
+ functionName: 'getExchanges',
76
+ }),
77
+ ]);
78
+ if (poolAddresses.length === 0) {
79
+ return [];
80
+ }
81
+ // Build a lookup from sorted token pair to exchangeId
82
+ const tokenPairToExchangeId = new Map();
83
+ for (const exchange of exchangesData) {
84
+ if (exchange.assets.length === 2) {
85
+ const [t0, t1] = (0, sortUtils_1.sortTokenAddresses)(exchange.assets[0], exchange.assets[1]);
86
+ tokenPairToExchangeId.set(`${t0}:${t1}`, exchange.exchangeId);
87
+ }
88
+ }
89
+ // For each pool, read its token pair and match to an exchangeId
90
+ const poolPromises = poolAddresses.map(async (poolAddress) => {
91
+ const [token0, token1] = (await publicClient.readContract({
92
+ address: poolAddress,
93
+ abi: abis_1.VIRTUAL_POOL_ABI,
94
+ functionName: 'tokens',
95
+ }));
96
+ const [sorted0, sorted1] = (0, sortUtils_1.sortTokenAddresses)(token0, token1);
97
+ const exchangeId = tokenPairToExchangeId.get(`${sorted0}:${sorted1}`);
98
+ const pool = {
99
+ factoryAddr: virtualPoolFactoryAddress,
100
+ poolAddr: poolAddress,
101
+ token0: sorted0,
102
+ token1: sorted1,
103
+ poolType: types_1.PoolType.Virtual,
104
+ exchangeId,
105
+ };
106
+ return pool;
107
+ });
108
+ return await Promise.all(poolPromises);
109
+ }
110
+ catch (error) {
111
+ throw new Error(`Failed to fetch Virtual pools: ${error.message}`);
112
+ }
113
+ }
114
+ //# sourceMappingURL=poolDiscovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poolDiscovery.js","sourceRoot":"","sources":["../../../src/services/pools/poolDiscovery.ts"],"names":[],"mappings":";;AAeA,wCA8CC;AAMD,8CA8DC;AAjID,oDAAkE;AAClE,4CAAiD;AACjD,0CAMwB;AAExB,qDAA0D;AAE1D;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,YAA0B,EAAE,OAAe;IAC9E,MAAM,kBAAkB,GAAG,IAAA,8BAAkB,EAAC,OAAkB,EAAE,aAAa,CAAC,CAAA;IAEhF,IA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