@mento-protocol/mento-sdk 3.2.3 → 3.2.5

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 (396) hide show
  1. package/dist/cache/routes.d.ts +13 -0
  2. package/dist/cache/routes.js +14089 -0
  3. package/dist/cache/tokens.d.ts +68 -0
  4. package/dist/cache/tokens.js +460 -0
  5. package/dist/core/abis/activePool.d.ts +2 -0
  6. package/dist/core/abis/activePool.js +14 -0
  7. package/dist/core/abis/addressesRegistry.d.ts +2 -0
  8. package/dist/core/abis/addressesRegistry.js +26 -0
  9. package/dist/core/abis/bipoolmanager.d.ts +34 -0
  10. package/dist/core/abis/bipoolmanager.js +72 -0
  11. package/dist/core/abis/borrowerOperations.d.ts +9 -0
  12. package/dist/core/abis/borrowerOperations.js +89 -0
  13. package/dist/core/abis/breakerbox.d.ts +13 -0
  14. package/dist/core/abis/breakerbox.js +8 -0
  15. package/dist/core/abis/broker.d.ts +2 -0
  16. package/dist/core/abis/broker.js +9 -0
  17. package/dist/core/abis/erc20.d.ts +9 -0
  18. package/dist/core/abis/erc20.js +21 -0
  19. package/dist/core/abis/fpmm.d.ts +270 -0
  20. package/dist/core/abis/fpmm.js +49 -0
  21. package/dist/core/abis/fpmmFactory.d.ts +85 -0
  22. package/dist/core/abis/fpmmFactory.js +26 -0
  23. package/dist/core/abis/hintHelpers.d.ts +2 -0
  24. package/dist/core/abis/hintHelpers.js +14 -0
  25. package/dist/core/abis/index.d.ts +22 -0
  26. package/dist/core/abis/index.js +38 -0
  27. package/dist/core/abis/liquidityStrategy.d.ts +132 -0
  28. package/dist/core/abis/liquidityStrategy.js +10 -0
  29. package/dist/core/abis/multiTroveGetter.d.ts +8 -0
  30. package/dist/core/abis/multiTroveGetter.js +15 -0
  31. package/dist/core/abis/priceFeed.d.ts +7 -0
  32. package/dist/core/abis/priceFeed.js +16 -0
  33. package/dist/core/abis/pricingmodule.d.ts +2 -0
  34. package/dist/core/abis/pricingmodule.js +6 -0
  35. package/dist/core/abis/reserve.d.ts +3 -0
  36. package/dist/core/abis/reserve.js +18 -0
  37. package/dist/core/abis/router.d.ts +521 -0
  38. package/dist/core/abis/router.js +45 -0
  39. package/dist/core/abis/sortedTroves.d.ts +2 -0
  40. package/dist/core/abis/sortedTroves.js +15 -0
  41. package/dist/core/abis/systemParams.d.ts +2 -0
  42. package/dist/core/abis/systemParams.js +14 -0
  43. package/dist/core/abis/troveManager.d.ts +2 -0
  44. package/dist/core/abis/troveManager.js +27 -0
  45. package/dist/core/abis/troveNFT.d.ts +2 -0
  46. package/dist/core/abis/troveNFT.js +9 -0
  47. package/dist/core/abis/virtualPool.d.ts +50 -0
  48. package/dist/core/abis/virtualPool.js +11 -0
  49. package/dist/core/abis/virtualPoolFactory.d.ts +59 -0
  50. package/dist/core/abis/virtualPoolFactory.js +17 -0
  51. package/dist/core/constants/addresses.d.ts +18 -0
  52. package/dist/core/constants/addresses.js +113 -0
  53. package/dist/core/constants/borrowConstants.d.ts +10 -0
  54. package/dist/core/constants/borrowConstants.js +16 -0
  55. package/dist/core/constants/borrowRegistries.d.ts +7 -0
  56. package/dist/core/constants/borrowRegistries.js +30 -0
  57. package/dist/core/constants/chainId.d.ts +7 -0
  58. package/dist/{cjs/enums → core/constants}/chainId.js +4 -1
  59. package/dist/core/constants/contractNames.d.ts +21 -0
  60. package/dist/core/constants/contractNames.js +24 -0
  61. package/dist/core/constants/index.d.ts +6 -0
  62. package/dist/core/constants/index.js +22 -0
  63. package/dist/core/errors/base.d.ts +8 -0
  64. package/dist/core/errors/base.js +17 -0
  65. package/dist/core/errors/index.d.ts +4 -0
  66. package/dist/{cjs/constants → core/errors}/index.js +4 -4
  67. package/dist/core/errors/oracle.d.ts +9 -0
  68. package/dist/core/errors/oracle.js +15 -0
  69. package/dist/core/errors/router.d.ts +14 -0
  70. package/dist/core/errors/router.js +24 -0
  71. package/dist/core/types/borrow.d.ts +87 -0
  72. package/dist/{cjs/interfaces/tradingLimitsConfig.js → core/types/borrow.js} +1 -0
  73. package/dist/core/types/contractAddresses.d.ts +42 -0
  74. package/dist/{cjs → core}/types/contractAddresses.js +1 -0
  75. package/dist/core/types/index.d.ts +10 -0
  76. package/dist/core/types/index.js +26 -0
  77. package/dist/core/types/liquidity.d.ts +194 -0
  78. package/dist/core/types/liquidity.js +3 -0
  79. package/dist/core/types/pool.d.ts +208 -0
  80. package/dist/core/types/pool.js +14 -0
  81. package/dist/core/types/provider.d.ts +45 -0
  82. package/dist/{cjs/interfaces/tradingLimitsState.js → core/types/provider.js} +1 -0
  83. package/dist/core/types/route.d.ts +62 -0
  84. package/dist/{cjs/interfaces/IChainClient.js → core/types/route.js} +1 -0
  85. package/dist/core/types/token.d.ts +21 -0
  86. package/dist/{cjs/interfaces/tradingLimit.js → core/types/token.js} +1 -0
  87. package/dist/core/types/tradingLimits.d.ts +91 -0
  88. package/dist/core/types/tradingLimits.js +3 -0
  89. package/dist/core/types/tradingMode.d.ts +24 -0
  90. package/dist/core/types/tradingMode.js +31 -0
  91. package/dist/core/types/transaction.d.ts +45 -0
  92. package/dist/core/types/transaction.js +3 -0
  93. package/dist/esm/cache/routes.js +14084 -0
  94. package/dist/esm/cache/tokens.js +452 -0
  95. package/dist/esm/core/abis/activePool.js +10 -0
  96. package/dist/esm/core/abis/addressesRegistry.js +22 -0
  97. package/dist/esm/core/abis/bipoolmanager.js +68 -0
  98. package/dist/esm/core/abis/borrowerOperations.js +85 -0
  99. package/dist/esm/core/abis/breakerbox.js +4 -0
  100. package/dist/esm/core/abis/broker.js +5 -0
  101. package/dist/esm/core/abis/erc20.js +17 -0
  102. package/dist/esm/core/abis/fpmm.js +45 -0
  103. package/dist/esm/core/abis/fpmmFactory.js +22 -0
  104. package/dist/esm/core/abis/hintHelpers.js +10 -0
  105. package/dist/esm/core/abis/index.js +21 -0
  106. package/dist/esm/core/abis/liquidityStrategy.js +6 -0
  107. package/dist/esm/core/abis/multiTroveGetter.js +11 -0
  108. package/dist/esm/core/abis/priceFeed.js +12 -0
  109. package/dist/esm/core/abis/pricingmodule.js +2 -0
  110. package/dist/esm/core/abis/reserve.js +14 -0
  111. package/dist/esm/core/abis/router.js +41 -0
  112. package/dist/esm/core/abis/sortedTroves.js +11 -0
  113. package/dist/esm/core/abis/systemParams.js +10 -0
  114. package/dist/esm/core/abis/troveManager.js +23 -0
  115. package/dist/esm/core/abis/troveNFT.js +5 -0
  116. package/dist/esm/core/abis/virtualPool.js +7 -0
  117. package/dist/esm/core/abis/virtualPoolFactory.js +13 -0
  118. package/dist/esm/core/constants/addresses.js +107 -0
  119. package/dist/esm/core/constants/borrowConstants.js +12 -0
  120. package/dist/esm/core/constants/borrowRegistries.js +25 -0
  121. package/dist/esm/{enums → core/constants}/chainId.js +2 -0
  122. package/dist/esm/core/constants/contractNames.js +20 -0
  123. package/dist/esm/core/constants/index.js +5 -0
  124. package/dist/esm/core/errors/base.js +12 -0
  125. package/dist/esm/core/errors/index.js +3 -0
  126. package/dist/esm/core/errors/oracle.js +10 -0
  127. package/dist/esm/core/errors/router.js +18 -0
  128. package/dist/esm/core/types/index.js +9 -0
  129. package/dist/esm/core/types/pool.js +10 -0
  130. package/dist/esm/core/types/tradingLimits.js +1 -0
  131. package/dist/esm/core/types/tradingMode.js +26 -0
  132. package/dist/esm/core/types/transaction.js +1 -0
  133. package/dist/esm/index.js +138 -6
  134. package/dist/esm/package.json +1 -0
  135. package/dist/esm/services/borrow/BorrowService.js +455 -0
  136. package/dist/esm/services/borrow/borrowHelpers.js +3 -0
  137. package/dist/esm/services/borrow/borrowMath.js +127 -0
  138. package/dist/esm/services/borrow/index.js +3 -0
  139. package/dist/esm/services/borrow/internal/borrowApprovalService.js +48 -0
  140. package/dist/esm/services/borrow/internal/borrowContextStore.js +35 -0
  141. package/dist/esm/services/borrow/internal/borrowErc20.js +38 -0
  142. package/dist/esm/services/borrow/internal/borrowHints.js +27 -0
  143. package/dist/esm/services/borrow/internal/borrowPositionParser.js +82 -0
  144. package/dist/esm/services/borrow/internal/borrowReadService.js +271 -0
  145. package/dist/esm/services/borrow/internal/borrowRegistryReader.js +108 -0
  146. package/dist/esm/services/borrow/internal/borrowTransactionService.js +271 -0
  147. package/dist/esm/services/borrow/internal/borrowTypes.js +1 -0
  148. package/dist/esm/services/borrow/internal/borrowValidation.js +89 -0
  149. package/dist/esm/services/index.js +8 -0
  150. package/dist/esm/services/liquidity/LiquidityService.js +163 -0
  151. package/dist/esm/services/liquidity/basicLiquidity.js +162 -0
  152. package/dist/esm/services/liquidity/index.js +1 -0
  153. package/dist/esm/services/liquidity/liquidityHelpers.js +95 -0
  154. package/dist/esm/services/liquidity/rebalance.js +59 -0
  155. package/dist/esm/services/liquidity/zapHelpers.js +120 -0
  156. package/dist/esm/services/liquidity/zapIn.js +112 -0
  157. package/dist/esm/services/liquidity/zapOut.js +248 -0
  158. package/dist/esm/services/pools/PoolService.js +204 -0
  159. package/dist/esm/services/pools/index.js +1 -0
  160. package/dist/esm/services/pools/poolDetails.js +209 -0
  161. package/dist/esm/services/pools/poolDiscovery.js +112 -0
  162. package/dist/esm/services/pools/rebalancePreview.js +181 -0
  163. package/dist/esm/services/quotes/QuoteService.js +85 -0
  164. package/dist/esm/services/quotes/index.js +1 -0
  165. package/dist/esm/services/routes/RouteService.js +268 -0
  166. package/dist/esm/services/routes/index.js +1 -0
  167. package/dist/esm/services/swap/SwapService.js +247 -0
  168. package/dist/esm/services/swap/index.js +1 -0
  169. package/dist/esm/services/tokens/index.js +1 -0
  170. package/dist/esm/services/tokens/tokenService.js +285 -0
  171. package/dist/esm/services/trading/TradingLimitsService.js +154 -0
  172. package/dist/esm/services/trading/TradingService.js +222 -0
  173. package/dist/esm/services/trading/index.js +2 -0
  174. package/dist/esm/utils/chainConfig.js +118 -0
  175. package/dist/esm/utils/costUtils.js +56 -0
  176. package/dist/esm/utils/deadline.js +22 -0
  177. package/dist/esm/utils/index.js +9 -0
  178. package/dist/esm/utils/multicall.js +47 -0
  179. package/dist/esm/utils/pathEncoder.js +69 -0
  180. package/dist/esm/utils/rateFeed.js +23 -0
  181. package/dist/esm/utils/retry.js +24 -0
  182. package/dist/esm/{routeUtils.js → utils/routeUtils.js} +115 -116
  183. package/dist/esm/utils/routes.js +2 -0
  184. package/dist/esm/utils/sortUtils.js +33 -0
  185. package/dist/esm/utils/tokens.js +2 -0
  186. package/dist/esm/utils/tradingLimits.js +163 -0
  187. package/dist/esm/utils/validation.js +30 -0
  188. package/dist/index.d.ts +101 -0
  189. package/dist/index.js +158 -0
  190. package/dist/services/borrow/BorrowService.d.ts +381 -0
  191. package/dist/services/borrow/BorrowService.js +460 -0
  192. package/dist/services/borrow/borrowHelpers.d.ts +4 -0
  193. package/dist/services/borrow/borrowHelpers.js +13 -0
  194. package/dist/services/borrow/borrowMath.d.ts +21 -0
  195. package/dist/services/borrow/borrowMath.js +137 -0
  196. package/dist/services/borrow/index.d.ts +4 -0
  197. package/dist/{cjs/interfaces → services/borrow}/index.js +4 -4
  198. package/dist/services/borrow/internal/borrowApprovalService.d.ts +14 -0
  199. package/dist/services/borrow/internal/borrowApprovalService.js +53 -0
  200. package/dist/services/borrow/internal/borrowContextStore.d.ts +11 -0
  201. package/dist/services/borrow/internal/borrowContextStore.js +40 -0
  202. package/dist/services/borrow/internal/borrowErc20.d.ts +5 -0
  203. package/dist/services/borrow/internal/borrowErc20.js +43 -0
  204. package/dist/services/borrow/internal/borrowHints.d.ts +7 -0
  205. package/dist/services/borrow/internal/borrowHints.js +31 -0
  206. package/dist/services/borrow/internal/borrowPositionParser.d.ts +4 -0
  207. package/dist/services/borrow/internal/borrowPositionParser.js +87 -0
  208. package/dist/services/borrow/internal/borrowReadService.d.ts +31 -0
  209. package/dist/services/borrow/internal/borrowReadService.js +276 -0
  210. package/dist/services/borrow/internal/borrowRegistryReader.d.ts +5 -0
  211. package/dist/services/borrow/internal/borrowRegistryReader.js +113 -0
  212. package/dist/services/borrow/internal/borrowTransactionService.d.ts +23 -0
  213. package/dist/services/borrow/internal/borrowTransactionService.js +276 -0
  214. package/dist/services/borrow/internal/borrowTypes.d.ts +15 -0
  215. package/dist/services/borrow/internal/borrowTypes.js +3 -0
  216. package/dist/services/borrow/internal/borrowValidation.d.ts +14 -0
  217. package/dist/services/borrow/internal/borrowValidation.js +104 -0
  218. package/dist/services/index.d.ts +9 -0
  219. package/dist/{cjs → services}/index.js +9 -7
  220. package/dist/services/liquidity/LiquidityService.d.ts +139 -0
  221. package/dist/services/liquidity/LiquidityService.js +168 -0
  222. package/dist/services/liquidity/basicLiquidity.d.ts +11 -0
  223. package/dist/services/liquidity/basicLiquidity.js +172 -0
  224. package/dist/services/liquidity/index.d.ts +2 -0
  225. package/dist/{cjs/types → services/liquidity}/index.js +2 -2
  226. package/dist/services/liquidity/liquidityHelpers.d.ts +19 -0
  227. package/dist/services/liquidity/liquidityHelpers.js +104 -0
  228. package/dist/services/liquidity/rebalance.d.ts +6 -0
  229. package/dist/services/liquidity/rebalance.js +64 -0
  230. package/dist/services/liquidity/zapHelpers.d.ts +66 -0
  231. package/dist/services/liquidity/zapHelpers.js +129 -0
  232. package/dist/services/liquidity/zapIn.d.ts +18 -0
  233. package/dist/services/liquidity/zapIn.js +119 -0
  234. package/dist/services/liquidity/zapOut.d.ts +9 -0
  235. package/dist/services/liquidity/zapOut.js +255 -0
  236. package/dist/services/pools/PoolService.d.ts +69 -0
  237. package/dist/services/pools/PoolService.js +209 -0
  238. package/dist/services/pools/index.d.ts +2 -0
  239. package/dist/{cjs/enums → services/pools}/index.js +2 -3
  240. package/dist/services/pools/poolDetails.d.ts +13 -0
  241. package/dist/services/pools/poolDetails.js +216 -0
  242. package/dist/services/pools/poolDiscovery.d.ts +12 -0
  243. package/dist/services/pools/poolDiscovery.js +117 -0
  244. package/dist/services/pools/rebalancePreview.d.ts +5 -0
  245. package/dist/services/pools/rebalancePreview.js +186 -0
  246. package/dist/services/quotes/QuoteService.d.ts +51 -0
  247. package/dist/services/quotes/QuoteService.js +91 -0
  248. package/dist/services/quotes/index.d.ts +2 -0
  249. package/dist/services/quotes/index.js +18 -0
  250. package/dist/services/routes/RouteService.d.ts +117 -0
  251. package/dist/services/routes/RouteService.js +306 -0
  252. package/dist/services/routes/index.d.ts +2 -0
  253. package/dist/services/routes/index.js +18 -0
  254. package/dist/services/swap/SwapService.d.ts +198 -0
  255. package/dist/services/swap/SwapService.js +252 -0
  256. package/dist/services/swap/index.d.ts +2 -0
  257. package/dist/services/swap/index.js +18 -0
  258. package/dist/services/tokens/index.d.ts +2 -0
  259. package/dist/services/tokens/index.js +18 -0
  260. package/dist/services/tokens/tokenService.d.ts +55 -0
  261. package/dist/services/tokens/tokenService.js +290 -0
  262. package/dist/services/trading/TradingLimitsService.d.ts +38 -0
  263. package/dist/services/trading/TradingLimitsService.js +159 -0
  264. package/dist/services/trading/TradingService.d.ts +115 -0
  265. package/dist/services/trading/TradingService.js +227 -0
  266. package/dist/services/trading/index.d.ts +3 -0
  267. package/dist/services/trading/index.js +19 -0
  268. package/dist/utils/chainConfig.d.ts +16 -0
  269. package/dist/utils/chainConfig.js +123 -0
  270. package/dist/utils/costUtils.d.ts +12 -0
  271. package/dist/utils/costUtils.js +60 -0
  272. package/dist/utils/deadline.d.ts +21 -0
  273. package/dist/utils/deadline.js +26 -0
  274. package/dist/utils/index.d.ts +10 -0
  275. package/dist/utils/index.js +26 -0
  276. package/dist/utils/multicall.d.ts +30 -0
  277. package/dist/utils/multicall.js +52 -0
  278. package/dist/utils/pathEncoder.d.ts +34 -0
  279. package/dist/utils/pathEncoder.js +73 -0
  280. package/dist/utils/rateFeed.d.ts +18 -0
  281. package/dist/utils/rateFeed.js +27 -0
  282. package/dist/utils/retry.d.ts +12 -0
  283. package/dist/utils/retry.js +28 -0
  284. package/dist/{esm → utils}/routeUtils.d.ts +84 -93
  285. package/dist/{cjs → utils}/routeUtils.js +123 -124
  286. package/dist/utils/routes.d.ts +3 -0
  287. package/dist/utils/routes.js +8 -0
  288. package/dist/utils/sortUtils.d.ts +24 -0
  289. package/dist/utils/sortUtils.js +39 -0
  290. package/dist/utils/tokens.d.ts +2 -0
  291. package/dist/utils/tokens.js +13 -0
  292. package/dist/utils/tradingLimits.d.ts +41 -0
  293. package/dist/utils/tradingLimits.js +171 -0
  294. package/dist/utils/validation.d.ts +19 -0
  295. package/dist/utils/validation.js +34 -0
  296. package/package.json +1 -1
  297. package/dist/cjs/ChainClient.d.ts +0 -9
  298. package/dist/cjs/ChainClient.js +0 -58
  299. package/dist/cjs/TestChainClient.d.ts +0 -7
  300. package/dist/cjs/TestChainClient.js +0 -41
  301. package/dist/cjs/constants/addresses.d.ts +0 -4
  302. package/dist/cjs/constants/addresses.js +0 -59
  303. package/dist/cjs/constants/currencies.d.ts +0 -5
  304. package/dist/cjs/constants/currencies.js +0 -29
  305. package/dist/cjs/constants/index.d.ts +0 -4
  306. package/dist/cjs/constants/tokens.11142220.d.ts +0 -2
  307. package/dist/cjs/constants/tokens.11142220.js +0 -128
  308. package/dist/cjs/constants/tokens.42220.d.ts +0 -2
  309. package/dist/cjs/constants/tokens.42220.js +0 -128
  310. package/dist/cjs/constants/tokens.d.ts +0 -65
  311. package/dist/cjs/constants/tokens.js +0 -170
  312. package/dist/cjs/constants/tradablePairs.11142220.d.ts +0 -2
  313. package/dist/cjs/constants/tradablePairs.11142220.js +0 -7391
  314. package/dist/cjs/constants/tradablePairs.42220.d.ts +0 -2
  315. package/dist/cjs/constants/tradablePairs.42220.js +0 -7391
  316. package/dist/cjs/constants/tradablePairs.d.ts +0 -16
  317. package/dist/cjs/constants/tradablePairs.js +0 -53
  318. package/dist/cjs/enums/chainId.d.ts +0 -4
  319. package/dist/cjs/enums/index.d.ts +0 -3
  320. package/dist/cjs/enums/proposalState.d.ts +0 -10
  321. package/dist/cjs/enums/proposalState.js +0 -14
  322. package/dist/cjs/enums/tradingMode.d.ts +0 -17
  323. package/dist/cjs/enums/tradingMode.js +0 -21
  324. package/dist/cjs/governance.d.ts +0 -62
  325. package/dist/cjs/governance.js +0 -151
  326. package/dist/cjs/index.d.ts +0 -7
  327. package/dist/cjs/interfaces/IChainClient.d.ts +0 -6
  328. package/dist/cjs/interfaces/index.d.ts +0 -4
  329. package/dist/cjs/interfaces/tradingLimit.d.ts +0 -7
  330. package/dist/cjs/interfaces/tradingLimitsConfig.d.ts +0 -10
  331. package/dist/cjs/interfaces/tradingLimitsState.d.ts +0 -9
  332. package/dist/cjs/limits.d.ts +0 -33
  333. package/dist/cjs/limits.js +0 -130
  334. package/dist/cjs/mento.d.ts +0 -287
  335. package/dist/cjs/mento.js +0 -699
  336. package/dist/cjs/routeUtils.d.ts +0 -304
  337. package/dist/cjs/types/contractAddressMap.d.ts +0 -4
  338. package/dist/cjs/types/contractAddressMap.js +0 -2
  339. package/dist/cjs/types/contractAddresses.d.ts +0 -23
  340. package/dist/cjs/types/index.d.ts +0 -2
  341. package/dist/cjs/utils.d.ts +0 -80
  342. package/dist/cjs/utils.js +0 -177
  343. package/dist/esm/ChainClient.d.ts +0 -9
  344. package/dist/esm/ChainClient.js +0 -54
  345. package/dist/esm/TestChainClient.d.ts +0 -7
  346. package/dist/esm/TestChainClient.js +0 -37
  347. package/dist/esm/constants/addresses.d.ts +0 -4
  348. package/dist/esm/constants/addresses.js +0 -55
  349. package/dist/esm/constants/currencies.d.ts +0 -5
  350. package/dist/esm/constants/currencies.js +0 -26
  351. package/dist/esm/constants/index.d.ts +0 -4
  352. package/dist/esm/constants/index.js +0 -4
  353. package/dist/esm/constants/tokens.11142220.d.ts +0 -2
  354. package/dist/esm/constants/tokens.11142220.js +0 -125
  355. package/dist/esm/constants/tokens.42220.d.ts +0 -2
  356. package/dist/esm/constants/tokens.42220.js +0 -125
  357. package/dist/esm/constants/tokens.d.ts +0 -65
  358. package/dist/esm/constants/tokens.js +0 -142
  359. package/dist/esm/constants/tradablePairs.11142220.d.ts +0 -2
  360. package/dist/esm/constants/tradablePairs.11142220.js +0 -7388
  361. package/dist/esm/constants/tradablePairs.42220.d.ts +0 -2
  362. package/dist/esm/constants/tradablePairs.42220.js +0 -7388
  363. package/dist/esm/constants/tradablePairs.d.ts +0 -16
  364. package/dist/esm/constants/tradablePairs.js +0 -26
  365. package/dist/esm/enums/chainId.d.ts +0 -4
  366. package/dist/esm/enums/index.d.ts +0 -3
  367. package/dist/esm/enums/index.js +0 -3
  368. package/dist/esm/enums/proposalState.d.ts +0 -10
  369. package/dist/esm/enums/proposalState.js +0 -11
  370. package/dist/esm/enums/tradingMode.d.ts +0 -17
  371. package/dist/esm/enums/tradingMode.js +0 -18
  372. package/dist/esm/governance.d.ts +0 -62
  373. package/dist/esm/governance.js +0 -147
  374. package/dist/esm/index.d.ts +0 -7
  375. package/dist/esm/interfaces/IChainClient.d.ts +0 -6
  376. package/dist/esm/interfaces/index.d.ts +0 -4
  377. package/dist/esm/interfaces/index.js +0 -4
  378. package/dist/esm/interfaces/tradingLimit.d.ts +0 -7
  379. package/dist/esm/interfaces/tradingLimitsConfig.d.ts +0 -10
  380. package/dist/esm/interfaces/tradingLimitsState.d.ts +0 -9
  381. package/dist/esm/limits.d.ts +0 -33
  382. package/dist/esm/limits.js +0 -123
  383. package/dist/esm/mento.d.ts +0 -287
  384. package/dist/esm/mento.js +0 -671
  385. package/dist/esm/types/contractAddressMap.d.ts +0 -4
  386. package/dist/esm/types/contractAddresses.d.ts +0 -23
  387. package/dist/esm/types/index.d.ts +0 -2
  388. package/dist/esm/types/index.js +0 -2
  389. package/dist/esm/utils.d.ts +0 -80
  390. package/dist/esm/utils.js +0 -162
  391. /package/dist/esm/{interfaces/IChainClient.js → core/types/borrow.js} +0 -0
  392. /package/dist/esm/{types → core/types}/contractAddresses.js +0 -0
  393. /package/dist/esm/{interfaces/tradingLimit.js → core/types/liquidity.js} +0 -0
  394. /package/dist/esm/{interfaces/tradingLimitsConfig.js → core/types/provider.js} +0 -0
  395. /package/dist/esm/{interfaces/tradingLimitsState.js → core/types/route.js} +0 -0
  396. /package/dist/esm/{types/contractAddressMap.js → core/types/token.js} +0 -0
@@ -0,0 +1,139 @@
1
+ import { PublicClient } from 'viem';
2
+ import { PoolService } from '../pools';
3
+ import { RouteService } from '../routes';
4
+ import { AddLiquidityInput, RemoveLiquidityInput, RebalanceDetails, RebalanceInput, RebalanceTransaction, ZapInInput, ZapOutInput, PrepareZapInInput, PrepareZapOutInput, AddLiquidityQuote, RemoveLiquidityQuote, AddLiquidityDetails, RemoveLiquidityDetails, AddLiquidityTransaction, RemoveLiquidityTransaction, LPTokenBalance, LiquidityOptions, PreparedZapIn, PreparedZapOut, ZapInQuote, ZapOutQuote, ZapInDetails, ZapOutDetails, ZapInTransaction, ZapOutTransaction } from '../../core/types';
5
+ export declare class LiquidityService {
6
+ private publicClient;
7
+ private chainId;
8
+ private poolService;
9
+ private routeService;
10
+ constructor(publicClient: PublicClient, chainId: number, poolService: PoolService, routeService: RouteService);
11
+ /**
12
+ * Builds add liquidity transaction with token approvals if needed.
13
+ * Provide two tokens in any order - the Router handles token ordering automatically.
14
+ * @param input - Add liquidity parameters including owner for allowance checks
15
+ * @returns Transaction with approvals (if needed) and add liquidity call
16
+ */
17
+ buildAddLiquidityTransaction(input: AddLiquidityInput & {
18
+ owner: string;
19
+ }): Promise<AddLiquidityTransaction>;
20
+ /**
21
+ * Builds add liquidity transaction parameters without checking token approvals.
22
+ * Use buildAddLiquidityTransaction if you need approval handling.
23
+ * @param input - Add liquidity parameters
24
+ * @returns Transaction details with encoded call data
25
+ */
26
+ buildAddLiquidityParams(input: AddLiquidityInput): Promise<AddLiquidityDetails>;
27
+ /**
28
+ * Builds remove liquidity transaction with LP token approval if needed.
29
+ * @param input - Remove liquidity parameters including owner for allowance check
30
+ * @returns Transaction with approval (if needed) and remove liquidity call
31
+ */
32
+ buildRemoveLiquidityTransaction(input: RemoveLiquidityInput & {
33
+ owner: string;
34
+ }): Promise<RemoveLiquidityTransaction>;
35
+ /**
36
+ * Builds remove liquidity transaction parameters without checking LP token approval.
37
+ * Use buildRemoveLiquidityTransaction if you need approval handling.
38
+ * @param input - Remove liquidity parameters
39
+ * @returns Transaction details with encoded call data
40
+ */
41
+ buildRemoveLiquidityParams(input: RemoveLiquidityInput): Promise<RemoveLiquidityDetails>;
42
+ /**
43
+ * Quotes an add liquidity operation (read-only call).
44
+ * Returns expected amounts and LP tokens based on current pool reserves.
45
+ * @param poolAddress - FPMM pool address
46
+ * @param tokenA - First token address
47
+ * @param amountA - Amount of first token
48
+ * @param tokenB - Second token address
49
+ * @param amountB - Amount of second token
50
+ * @returns Expected amounts and LP tokens to be minted
51
+ */
52
+ quoteAddLiquidity(poolAddress: string, tokenA: string, amountA: bigint, tokenB: string, amountB: bigint): Promise<AddLiquidityQuote>;
53
+ /**
54
+ * Quotes a remove liquidity operation (read-only call).
55
+ * Returns expected token amounts based on current pool reserves.
56
+ * @param poolAddress - FPMM pool address
57
+ * @param liquidity - Amount of LP tokens to burn
58
+ * @returns Expected amounts of token0 and token1
59
+ */
60
+ quoteRemoveLiquidity(poolAddress: string, liquidity: bigint): Promise<RemoveLiquidityQuote>;
61
+ /**
62
+ * Gets LP token balance and pool share percentage for an address.
63
+ * @param poolAddress - FPMM pool address (also the LP token address)
64
+ * @param owner - Address to check balance for
65
+ * @returns Balance, total supply, and share percentage
66
+ */
67
+ getLPTokenBalance(poolAddress: string, owner: string): Promise<LPTokenBalance>;
68
+ /**
69
+ * Builds zap in transaction with approval if needed.
70
+ * Adds liquidity using a single input token - the Router swaps it to both pool tokens automatically.
71
+ * @param input - Zap in parameters including owner for allowance check
72
+ * @returns Transaction with approval (if needed) and zap in call
73
+ */
74
+ buildZapInTransaction(input: ZapInInput & {
75
+ owner: string;
76
+ }): Promise<ZapInTransaction>;
77
+ /**
78
+ * Builds zap in transaction parameters without checking approval.
79
+ * Use buildZapInTransaction if you need approval handling.
80
+ * @param input - Zap in parameters
81
+ * @returns Transaction details with encoded call data and routing information
82
+ */
83
+ buildZapInParams(input: ZapInInput): Promise<ZapInDetails>;
84
+ prepareZapIn(input: PrepareZapInInput): Promise<PreparedZapIn>;
85
+ /**
86
+ * Builds zap out transaction with approval if needed.
87
+ * Removes liquidity and swaps both tokens to a single output token.
88
+ * @param input - Zap out parameters including owner for allowance check
89
+ * @returns Transaction with approval (if needed) and zap out call
90
+ */
91
+ buildZapOutTransaction(input: ZapOutInput & {
92
+ owner: string;
93
+ }): Promise<ZapOutTransaction>;
94
+ /**
95
+ * Builds zap out transaction parameters without checking approval.
96
+ * Use buildZapOutTransaction if you need approval handling.
97
+ * @param input - Zap out parameters
98
+ * @returns Transaction details with encoded call data and routing information
99
+ */
100
+ buildZapOutParams(input: ZapOutInput): Promise<ZapOutDetails>;
101
+ prepareZapOut(input: PrepareZapOutInput): Promise<PreparedZapOut>;
102
+ /**
103
+ * Quotes a zap in operation (read-only call).
104
+ * Estimates expected LP tokens and minimum amounts after swaps and slippage.
105
+ * @param poolAddress - FPMM pool address
106
+ * @param tokenIn - Input token address
107
+ * @param amountIn - Total input amount
108
+ * @param amountInSplit - Split ratio (0-1)
109
+ * @param options - Slippage tolerance and deadline
110
+ * @returns Expected LP tokens and minimum amounts for both pool tokens
111
+ */
112
+ quoteZapIn(poolAddress: string, tokenIn: string, amountIn: bigint, amountInSplit: number, options: LiquidityOptions): Promise<ZapInQuote>;
113
+ /**
114
+ * Quotes a zap out operation (read-only call).
115
+ * Estimates expected output tokens after removing liquidity and swapping.
116
+ * @param poolAddress - FPMM pool address
117
+ * @param tokenOut - Output token address
118
+ * @param liquidity - Amount of LP tokens to burn
119
+ * @param options - Slippage tolerance and deadline
120
+ * @returns Expected output amount and minimum amounts after slippage
121
+ */
122
+ quoteZapOut(poolAddress: string, tokenOut: string, liquidity: bigint, options: LiquidityOptions): Promise<ZapOutQuote>;
123
+ /**
124
+ * Builds rebalance transaction parameters without checking approval.
125
+ * Use buildRebalanceTransaction if you need approval handling.
126
+ * @param input - Rebalance parameters
127
+ * @returns Transaction details with encoded call data
128
+ */
129
+ buildRebalanceParams(input: RebalanceInput): Promise<RebalanceDetails>;
130
+ /**
131
+ * Builds a rebalance transaction with ERC20 approval if needed.
132
+ * @param input - Rebalance parameters including owner for allowance checks
133
+ * @returns Transaction with approval (if needed) and rebalance call
134
+ */
135
+ buildRebalanceTransaction(input: RebalanceInput & {
136
+ owner: string;
137
+ }): Promise<RebalanceTransaction>;
138
+ }
139
+ //# sourceMappingURL=LiquidityService.d.ts.map
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LiquidityService = void 0;
4
+ const basicLiquidity_1 = require("./basicLiquidity");
5
+ const zapIn_1 = require("./zapIn");
6
+ const zapOut_1 = require("./zapOut");
7
+ const rebalance_1 = require("./rebalance");
8
+ class LiquidityService {
9
+ constructor(publicClient, chainId, poolService, routeService) {
10
+ this.publicClient = publicClient;
11
+ this.chainId = chainId;
12
+ this.poolService = poolService;
13
+ this.routeService = routeService;
14
+ }
15
+ /**
16
+ * Builds add liquidity transaction with token approvals if needed.
17
+ * Provide two tokens in any order - the Router handles token ordering automatically.
18
+ * @param input - Add liquidity parameters including owner for allowance checks
19
+ * @returns Transaction with approvals (if needed) and add liquidity call
20
+ */
21
+ async buildAddLiquidityTransaction(input) {
22
+ return (0, basicLiquidity_1.buildAddLiquidityTransactionInternal)(this.publicClient, this.chainId, this.poolService, input.poolAddress, input.tokenA, input.amountA, input.tokenB, input.amountB, input.recipient, input.owner, input.options);
23
+ }
24
+ /**
25
+ * Builds add liquidity transaction parameters without checking token approvals.
26
+ * Use buildAddLiquidityTransaction if you need approval handling.
27
+ * @param input - Add liquidity parameters
28
+ * @returns Transaction details with encoded call data
29
+ */
30
+ async buildAddLiquidityParams(input) {
31
+ return (0, basicLiquidity_1.buildAddLiquidityParamsInternal)(this.publicClient, this.chainId, this.poolService, input.poolAddress, input.tokenA, input.amountA, input.tokenB, input.amountB, input.recipient, input.options);
32
+ }
33
+ /**
34
+ * Builds remove liquidity transaction with LP token approval if needed.
35
+ * @param input - Remove liquidity parameters including owner for allowance check
36
+ * @returns Transaction with approval (if needed) and remove liquidity call
37
+ */
38
+ async buildRemoveLiquidityTransaction(input) {
39
+ return (0, basicLiquidity_1.buildRemoveLiquidityTransactionInternal)(this.publicClient, this.chainId, this.poolService, input.poolAddress, input.liquidity, input.recipient, input.owner, input.options);
40
+ }
41
+ /**
42
+ * Builds remove liquidity transaction parameters without checking LP token approval.
43
+ * Use buildRemoveLiquidityTransaction if you need approval handling.
44
+ * @param input - Remove liquidity parameters
45
+ * @returns Transaction details with encoded call data
46
+ */
47
+ async buildRemoveLiquidityParams(input) {
48
+ return (0, basicLiquidity_1.buildRemoveLiquidityParamsInternal)(this.publicClient, this.chainId, this.poolService, input.poolAddress, input.liquidity, input.recipient, input.options);
49
+ }
50
+ /**
51
+ * Quotes an add liquidity operation (read-only call).
52
+ * Returns expected amounts and LP tokens based on current pool reserves.
53
+ * @param poolAddress - FPMM pool address
54
+ * @param tokenA - First token address
55
+ * @param amountA - Amount of first token
56
+ * @param tokenB - Second token address
57
+ * @param amountB - Amount of second token
58
+ * @returns Expected amounts and LP tokens to be minted
59
+ */
60
+ async quoteAddLiquidity(poolAddress, tokenA, amountA, tokenB, amountB) {
61
+ return (0, basicLiquidity_1.quoteAddLiquidityInternal)(this.publicClient, this.chainId, this.poolService, poolAddress, tokenA, amountA, tokenB, amountB);
62
+ }
63
+ /**
64
+ * Quotes a remove liquidity operation (read-only call).
65
+ * Returns expected token amounts based on current pool reserves.
66
+ * @param poolAddress - FPMM pool address
67
+ * @param liquidity - Amount of LP tokens to burn
68
+ * @returns Expected amounts of token0 and token1
69
+ */
70
+ async quoteRemoveLiquidity(poolAddress, liquidity) {
71
+ return (0, basicLiquidity_1.quoteRemoveLiquidityInternal)(this.publicClient, this.chainId, this.poolService, poolAddress, liquidity);
72
+ }
73
+ /**
74
+ * Gets LP token balance and pool share percentage for an address.
75
+ * @param poolAddress - FPMM pool address (also the LP token address)
76
+ * @param owner - Address to check balance for
77
+ * @returns Balance, total supply, and share percentage
78
+ */
79
+ async getLPTokenBalance(poolAddress, owner) {
80
+ return (0, basicLiquidity_1.getLPTokenBalanceInternal)(this.publicClient, this.poolService, poolAddress, owner);
81
+ }
82
+ /**
83
+ * Builds zap in transaction with approval if needed.
84
+ * Adds liquidity using a single input token - the Router swaps it to both pool tokens automatically.
85
+ * @param input - Zap in parameters including owner for allowance check
86
+ * @returns Transaction with approval (if needed) and zap in call
87
+ */
88
+ async buildZapInTransaction(input) {
89
+ return (0, zapIn_1.buildZapInTransactionInternal)(this.publicClient, this.chainId, this.poolService, this.routeService, input.poolAddress, input.tokenIn, input.amountIn, input.amountInSplit, input.recipient, input.owner, input.options);
90
+ }
91
+ /**
92
+ * Builds zap in transaction parameters without checking approval.
93
+ * Use buildZapInTransaction if you need approval handling.
94
+ * @param input - Zap in parameters
95
+ * @returns Transaction details with encoded call data and routing information
96
+ */
97
+ async buildZapInParams(input) {
98
+ return (0, zapIn_1.buildZapInParamsInternal)(this.publicClient, this.chainId, this.poolService, this.routeService, input.poolAddress, input.tokenIn, input.amountIn, input.amountInSplit, input.recipient, input.options);
99
+ }
100
+ async prepareZapIn(input) {
101
+ return (0, zapIn_1.prepareZapInInternal)(this.publicClient, this.chainId, this.poolService, this.routeService, input.poolAddress, input.tokenIn, input.amountIn, input.amountInSplit, input.recipient, input.owner, input.options);
102
+ }
103
+ /**
104
+ * Builds zap out transaction with approval if needed.
105
+ * Removes liquidity and swaps both tokens to a single output token.
106
+ * @param input - Zap out parameters including owner for allowance check
107
+ * @returns Transaction with approval (if needed) and zap out call
108
+ */
109
+ async buildZapOutTransaction(input) {
110
+ return (0, zapOut_1.buildZapOutTransactionInternal)(this.publicClient, this.chainId, this.poolService, this.routeService, input.poolAddress, input.tokenOut, input.liquidity, input.recipient, input.owner, input.options);
111
+ }
112
+ /**
113
+ * Builds zap out transaction parameters without checking approval.
114
+ * Use buildZapOutTransaction if you need approval handling.
115
+ * @param input - Zap out parameters
116
+ * @returns Transaction details with encoded call data and routing information
117
+ */
118
+ async buildZapOutParams(input) {
119
+ return (0, zapOut_1.buildZapOutParamsInternal)(this.publicClient, this.chainId, this.poolService, this.routeService, input.poolAddress, input.tokenOut, input.liquidity, input.recipient, input.options);
120
+ }
121
+ async prepareZapOut(input) {
122
+ return (0, zapOut_1.prepareZapOutInternal)(this.publicClient, this.chainId, this.poolService, this.routeService, input.poolAddress, input.tokenOut, input.liquidity, input.recipient, input.owner, input.options);
123
+ }
124
+ /**
125
+ * Quotes a zap in operation (read-only call).
126
+ * Estimates expected LP tokens and minimum amounts after swaps and slippage.
127
+ * @param poolAddress - FPMM pool address
128
+ * @param tokenIn - Input token address
129
+ * @param amountIn - Total input amount
130
+ * @param amountInSplit - Split ratio (0-1)
131
+ * @param options - Slippage tolerance and deadline
132
+ * @returns Expected LP tokens and minimum amounts for both pool tokens
133
+ */
134
+ async quoteZapIn(poolAddress, tokenIn, amountIn, amountInSplit, options) {
135
+ return (0, zapIn_1.quoteZapInInternal)(this.publicClient, this.chainId, this.poolService, this.routeService, poolAddress, tokenIn, amountIn, amountInSplit, options);
136
+ }
137
+ /**
138
+ * Quotes a zap out operation (read-only call).
139
+ * Estimates expected output tokens after removing liquidity and swapping.
140
+ * @param poolAddress - FPMM pool address
141
+ * @param tokenOut - Output token address
142
+ * @param liquidity - Amount of LP tokens to burn
143
+ * @param options - Slippage tolerance and deadline
144
+ * @returns Expected output amount and minimum amounts after slippage
145
+ */
146
+ async quoteZapOut(poolAddress, tokenOut, liquidity, options) {
147
+ return (0, zapOut_1.quoteZapOutInternal)(this.publicClient, this.chainId, this.poolService, this.routeService, poolAddress, tokenOut, liquidity, options);
148
+ }
149
+ /**
150
+ * Builds rebalance transaction parameters without checking approval.
151
+ * Use buildRebalanceTransaction if you need approval handling.
152
+ * @param input - Rebalance parameters
153
+ * @returns Transaction details with encoded call data
154
+ */
155
+ async buildRebalanceParams(input) {
156
+ return (0, rebalance_1.buildRebalanceParamsInternal)(this.publicClient, this.chainId, this.poolService, input.poolAddress);
157
+ }
158
+ /**
159
+ * Builds a rebalance transaction with ERC20 approval if needed.
160
+ * @param input - Rebalance parameters including owner for allowance checks
161
+ * @returns Transaction with approval (if needed) and rebalance call
162
+ */
163
+ async buildRebalanceTransaction(input) {
164
+ return (0, rebalance_1.buildRebalanceTransactionInternal)(this.publicClient, this.chainId, this.poolService, input.poolAddress, input.owner);
165
+ }
166
+ }
167
+ exports.LiquidityService = LiquidityService;
168
+ //# sourceMappingURL=LiquidityService.js.map
@@ -0,0 +1,11 @@
1
+ import { PublicClient } from 'viem';
2
+ import { PoolService } from '../pools';
3
+ import { LiquidityOptions, AddLiquidityQuote, RemoveLiquidityQuote, AddLiquidityDetails, RemoveLiquidityDetails, AddLiquidityTransaction, RemoveLiquidityTransaction, LPTokenBalance } from '../../core/types';
4
+ export declare function buildAddLiquidityTransactionInternal(publicClient: PublicClient, chainId: number, poolService: PoolService, poolAddress: string, tokenA: string, amountA: bigint, tokenB: string, amountB: bigint, recipient: string, owner: string, options: LiquidityOptions): Promise<AddLiquidityTransaction>;
5
+ export declare function buildAddLiquidityParamsInternal(publicClient: PublicClient, chainId: number, poolService: PoolService, poolAddress: string, tokenA: string, amountA: bigint, tokenB: string, amountB: bigint, recipient: string, options: LiquidityOptions): Promise<AddLiquidityDetails>;
6
+ export declare function quoteAddLiquidityInternal(publicClient: PublicClient, chainId: number, poolService: PoolService, poolAddress: string, tokenA: string, amountA: bigint, tokenB: string, amountB: bigint): Promise<AddLiquidityQuote>;
7
+ export declare function buildRemoveLiquidityTransactionInternal(publicClient: PublicClient, chainId: number, poolService: PoolService, poolAddress: string, liquidity: bigint, recipient: string, owner: string, options: LiquidityOptions): Promise<RemoveLiquidityTransaction>;
8
+ export declare function buildRemoveLiquidityParamsInternal(publicClient: PublicClient, chainId: number, poolService: PoolService, poolAddress: string, liquidity: bigint, recipient: string, options: LiquidityOptions): Promise<RemoveLiquidityDetails>;
9
+ export declare function quoteRemoveLiquidityInternal(publicClient: PublicClient, chainId: number, poolService: PoolService, poolAddress: string, liquidity: bigint): Promise<RemoveLiquidityQuote>;
10
+ export declare function getLPTokenBalanceInternal(publicClient: PublicClient, poolService: PoolService, poolAddress: string, owner: string): Promise<LPTokenBalance>;
11
+ //# sourceMappingURL=basicLiquidity.d.ts.map
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAddLiquidityTransactionInternal = buildAddLiquidityTransactionInternal;
4
+ exports.buildAddLiquidityParamsInternal = buildAddLiquidityParamsInternal;
5
+ exports.quoteAddLiquidityInternal = quoteAddLiquidityInternal;
6
+ exports.buildRemoveLiquidityTransactionInternal = buildRemoveLiquidityTransactionInternal;
7
+ exports.buildRemoveLiquidityParamsInternal = buildRemoveLiquidityParamsInternal;
8
+ exports.quoteRemoveLiquidityInternal = quoteRemoveLiquidityInternal;
9
+ exports.getLPTokenBalanceInternal = getLPTokenBalanceInternal;
10
+ const viem_1 = require("viem");
11
+ const abis_1 = require("../../core/abis");
12
+ const constants_1 = require("../../core/constants");
13
+ const validation_1 = require("../../utils/validation");
14
+ const liquidityHelpers_1 = require("./liquidityHelpers");
15
+ function encodeAddLiquidityCall(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, recipient, deadline) {
16
+ return (0, viem_1.encodeFunctionData)({
17
+ abi: abis_1.ROUTER_ABI,
18
+ functionName: 'addLiquidity',
19
+ args: [tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, recipient, deadline],
20
+ });
21
+ }
22
+ function encodeRemoveLiquidityCall(token0, token1, liquidity, amount0Min, amount1Min, recipient, deadline) {
23
+ return (0, viem_1.encodeFunctionData)({
24
+ abi: abis_1.ROUTER_ABI,
25
+ functionName: 'removeLiquidity',
26
+ args: [token0, token1, liquidity, amount0Min, amount1Min, recipient, deadline],
27
+ });
28
+ }
29
+ async function buildAddLiquidityTransactionInternal(publicClient, chainId, poolService, poolAddress, tokenA, amountA, tokenB, amountB, recipient, owner, options) {
30
+ const addLiquidity = await buildAddLiquidityParamsInternal(publicClient, chainId, poolService, poolAddress, tokenA, amountA, tokenB, amountB, recipient, options);
31
+ (0, validation_1.validateAddress)(owner, 'owner');
32
+ const ownerAddr = owner;
33
+ const tokenAAddr = addLiquidity.tokenA;
34
+ const tokenBAddr = addLiquidity.tokenB;
35
+ const [allowanceA, allowanceB] = await Promise.all([
36
+ (0, liquidityHelpers_1.getAllowance)(publicClient, tokenAAddr, ownerAddr, chainId),
37
+ (0, liquidityHelpers_1.getAllowance)(publicClient, tokenBAddr, ownerAddr, chainId),
38
+ ]);
39
+ const approvalA = allowanceA < amountA
40
+ ? { token: addLiquidity.tokenA, amount: amountA, params: (0, liquidityHelpers_1.buildApprovalParams)(chainId, tokenAAddr, amountA) }
41
+ : null;
42
+ const approvalB = allowanceB < amountB
43
+ ? { token: addLiquidity.tokenB, amount: amountB, params: (0, liquidityHelpers_1.buildApprovalParams)(chainId, tokenBAddr, amountB) }
44
+ : null;
45
+ return { approvalA, approvalB, addLiquidity };
46
+ }
47
+ async function buildAddLiquidityParamsInternal(publicClient, chainId, poolService, poolAddress, tokenA, amountA, tokenB, amountB, recipient, options) {
48
+ (0, validation_1.validateAddress)(poolAddress, 'poolAddress');
49
+ (0, validation_1.validateAddress)(tokenA, 'tokenA');
50
+ (0, validation_1.validateAddress)(tokenB, 'tokenB');
51
+ (0, validation_1.validateAddress)(recipient, 'recipient');
52
+ const { token0, token1, factoryAddr } = await (0, liquidityHelpers_1.getPoolInfo)(poolService, poolAddress);
53
+ (0, liquidityHelpers_1.validatePoolTokens)(token0, token1, tokenA, tokenB);
54
+ const quote = await quoteAddLiquidityInternal(publicClient, chainId, poolService, poolAddress, tokenA, amountA, tokenB, amountB);
55
+ const amountAMin = (0, liquidityHelpers_1.calculateMinAmount)(quote.amountA, options.slippageTolerance);
56
+ const amountBMin = (0, liquidityHelpers_1.calculateMinAmount)(quote.amountB, options.slippageTolerance);
57
+ const routerAddress = (0, constants_1.getContractAddress)(chainId, 'Router');
58
+ const data = encodeAddLiquidityCall(tokenA, tokenB, amountA, amountB, amountAMin, amountBMin, recipient, options.deadline);
59
+ return {
60
+ params: {
61
+ to: routerAddress,
62
+ data,
63
+ value: '0',
64
+ },
65
+ poolAddress,
66
+ token0,
67
+ token1,
68
+ tokenA,
69
+ tokenB,
70
+ amountADesired: amountA,
71
+ amountBDesired: amountB,
72
+ amountAMin,
73
+ amountBMin,
74
+ estimatedMinLiquidity: quote.liquidity,
75
+ deadline: options.deadline,
76
+ };
77
+ }
78
+ async function quoteAddLiquidityInternal(publicClient, chainId, poolService, poolAddress, tokenA, amountA, tokenB, amountB) {
79
+ (0, validation_1.validateAddress)(poolAddress, 'poolAddress');
80
+ (0, validation_1.validateAddress)(tokenA, 'tokenA');
81
+ (0, validation_1.validateAddress)(tokenB, 'tokenB');
82
+ const { token0, token1, factoryAddr } = await (0, liquidityHelpers_1.getPoolInfo)(poolService, poolAddress);
83
+ (0, liquidityHelpers_1.validatePoolTokens)(token0, token1, tokenA, tokenB);
84
+ const routerAddress = (0, constants_1.getContractAddress)(chainId, 'Router');
85
+ const [resultAmountA, resultAmountB, liquidity] = (await publicClient.readContract({
86
+ address: routerAddress,
87
+ abi: abis_1.ROUTER_ABI,
88
+ functionName: 'quoteAddLiquidity',
89
+ args: [tokenA, tokenB, factoryAddr, amountA, amountB],
90
+ }));
91
+ return { amountA: resultAmountA, amountB: resultAmountB, liquidity };
92
+ }
93
+ async function buildRemoveLiquidityTransactionInternal(publicClient, chainId, poolService, poolAddress, liquidity, recipient, owner, options) {
94
+ (0, validation_1.validateAddress)(owner, 'owner');
95
+ // Build remove liquidity params
96
+ const removeLiquidity = await buildRemoveLiquidityParamsInternal(publicClient, chainId, poolService, poolAddress, liquidity, recipient, options);
97
+ const poolAddr = poolAddress; // Pool address IS the LP token
98
+ const ownerAddr = owner;
99
+ const currentAllowance = await (0, liquidityHelpers_1.getAllowance)(publicClient, poolAddr, ownerAddr, chainId);
100
+ const approval = currentAllowance < liquidity
101
+ ? { token: poolAddress, amount: liquidity, params: (0, liquidityHelpers_1.buildApprovalParams)(chainId, poolAddr, liquidity) }
102
+ : null;
103
+ return { approval, removeLiquidity };
104
+ }
105
+ async function buildRemoveLiquidityParamsInternal(publicClient, chainId, poolService, poolAddress, liquidity, recipient, options) {
106
+ (0, validation_1.validateAddress)(poolAddress, 'poolAddress');
107
+ (0, validation_1.validateAddress)(recipient, 'recipient');
108
+ const { token0, token1 } = await (0, liquidityHelpers_1.getPoolInfo)(poolService, poolAddress);
109
+ const quote = await quoteRemoveLiquidityInternal(publicClient, chainId, poolService, poolAddress, liquidity);
110
+ const amount0Min = (0, liquidityHelpers_1.calculateMinAmount)(quote.amount0, options.slippageTolerance);
111
+ const amount1Min = (0, liquidityHelpers_1.calculateMinAmount)(quote.amount1, options.slippageTolerance);
112
+ const routerAddress = (0, constants_1.getContractAddress)(chainId, 'Router');
113
+ const data = encodeRemoveLiquidityCall(token0, token1, liquidity, amount0Min, amount1Min, recipient, options.deadline);
114
+ return {
115
+ params: {
116
+ to: routerAddress,
117
+ data,
118
+ value: '0',
119
+ },
120
+ poolAddress,
121
+ token0,
122
+ token1,
123
+ liquidity,
124
+ amount0Min,
125
+ amount1Min,
126
+ expectedAmount0: quote.amount0,
127
+ expectedAmount1: quote.amount1,
128
+ deadline: options.deadline,
129
+ };
130
+ }
131
+ async function quoteRemoveLiquidityInternal(publicClient, chainId, poolService, poolAddress, liquidity) {
132
+ (0, validation_1.validateAddress)(poolAddress, 'poolAddress');
133
+ const { token0, token1, factoryAddr } = await (0, liquidityHelpers_1.getPoolInfo)(poolService, poolAddress);
134
+ const routerAddress = (0, constants_1.getContractAddress)(chainId, 'Router');
135
+ const [amount0, amount1] = (await publicClient.readContract({
136
+ address: routerAddress,
137
+ abi: abis_1.ROUTER_ABI,
138
+ functionName: 'quoteRemoveLiquidity',
139
+ args: [token0, token1, factoryAddr, liquidity],
140
+ }));
141
+ return { amount0, amount1 };
142
+ }
143
+ async function getLPTokenBalanceInternal(publicClient, poolService, poolAddress, owner) {
144
+ (0, validation_1.validateAddress)(poolAddress, 'poolAddress');
145
+ (0, validation_1.validateAddress)(owner, 'owner');
146
+ const { token0, token1 } = await (0, liquidityHelpers_1.getPoolInfo)(poolService, poolAddress);
147
+ // Pool address IS the LP token address (FPMM pools are ERC20)
148
+ const [balance, totalSupply] = await Promise.all([
149
+ publicClient.readContract({
150
+ address: poolAddress,
151
+ abi: abis_1.ERC20_ABI,
152
+ functionName: 'balanceOf',
153
+ args: [owner],
154
+ }),
155
+ publicClient.readContract({
156
+ address: poolAddress,
157
+ abi: abis_1.ERC20_ABI,
158
+ functionName: 'totalSupply',
159
+ args: [],
160
+ }),
161
+ ]);
162
+ const sharePercent = totalSupply > 0n ? Number((balance * 10000n) / totalSupply) / 100 : 0;
163
+ return {
164
+ poolAddress,
165
+ balance,
166
+ token0,
167
+ token1,
168
+ totalSupply,
169
+ sharePercent,
170
+ };
171
+ }
172
+ //# sourceMappingURL=basicLiquidity.js.map
@@ -0,0 +1,2 @@
1
+ export * from './LiquidityService';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./contractAddresses"), exports);
18
- __exportStar(require("./contractAddressMap"), exports);
17
+ __exportStar(require("./LiquidityService"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,19 @@
1
+ import { Address, PublicClient } from 'viem';
2
+ import { PoolService } from '../pools';
3
+ import { CallParams } from '../../core/types';
4
+ export declare function buildApprovalParams(chainId: number, token: Address, amount: bigint, spender?: Address): CallParams;
5
+ export declare function getAllowance(publicClient: PublicClient, token: Address, owner: Address, chainId: number, spender?: Address): Promise<bigint>;
6
+ export declare function calculateMinAmount(amount: bigint, slippageTolerance: number): bigint;
7
+ export declare function getPoolInfo(poolService: PoolService, poolAddress: string): Promise<{
8
+ token0: Address;
9
+ token1: Address;
10
+ factoryAddr: Address;
11
+ }>;
12
+ export declare function validatePoolTokens(poolToken0: Address, poolToken1: Address, tokenA: string, tokenB: string): void;
13
+ export declare function getPoolSnapshot(publicClient: PublicClient, poolAddress: Address): Promise<{
14
+ reserve0: bigint;
15
+ reserve1: bigint;
16
+ blockTimestampLast: bigint;
17
+ totalSupply: bigint;
18
+ }>;
19
+ //# sourceMappingURL=liquidityHelpers.d.ts.map
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildApprovalParams = buildApprovalParams;
4
+ exports.getAllowance = getAllowance;
5
+ exports.calculateMinAmount = calculateMinAmount;
6
+ exports.getPoolInfo = getPoolInfo;
7
+ exports.validatePoolTokens = validatePoolTokens;
8
+ exports.getPoolSnapshot = getPoolSnapshot;
9
+ const viem_1 = require("viem");
10
+ const types_1 = require("../../core/types");
11
+ const abis_1 = require("../../core/abis");
12
+ const constants_1 = require("../../core/constants");
13
+ const validation_1 = require("../../utils/validation");
14
+ const multicall_1 = require("../../utils/multicall");
15
+ function getApprovalSpender(chainId, spender) {
16
+ return spender ?? (0, constants_1.getContractAddress)(chainId, 'Router');
17
+ }
18
+ function buildApprovalParams(chainId, token, amount, spender) {
19
+ const approvalSpender = getApprovalSpender(chainId, spender);
20
+ const data = (0, viem_1.encodeFunctionData)({
21
+ abi: abis_1.ERC20_ABI,
22
+ functionName: 'approve',
23
+ args: [approvalSpender, amount],
24
+ });
25
+ return { to: token, data, value: '0' };
26
+ }
27
+ async function getAllowance(publicClient, token, owner, chainId, spender) {
28
+ const approvalSpender = getApprovalSpender(chainId, spender);
29
+ return (await publicClient.readContract({
30
+ address: token,
31
+ abi: abis_1.ERC20_ABI,
32
+ functionName: 'allowance',
33
+ args: [owner, approvalSpender],
34
+ }));
35
+ }
36
+ function calculateMinAmount(amount, slippageTolerance) {
37
+ if (slippageTolerance < 0) {
38
+ throw new Error('Slippage tolerance cannot be negative');
39
+ }
40
+ if (slippageTolerance > 100) {
41
+ throw new Error('Slippage tolerance cannot exceed 100%');
42
+ }
43
+ const basisPoints = BigInt(Math.floor(slippageTolerance * 100));
44
+ const slippageMultiplier = 10000n - basisPoints;
45
+ return (amount * slippageMultiplier) / 10000n;
46
+ }
47
+ async function getPoolInfo(poolService, poolAddress) {
48
+ (0, validation_1.validateAddress)(poolAddress, 'poolAddress');
49
+ const pools = await poolService.getPools();
50
+ const pool = pools.find((p) => p.poolAddr.toLowerCase() === poolAddress.toLowerCase());
51
+ if (!pool) {
52
+ throw new Error(`Pool not found: ${poolAddress}. Ensure the address is a valid FPMM pool.`);
53
+ }
54
+ if (pool.poolType !== types_1.PoolType.FPMM) {
55
+ throw new Error(`Pool ${poolAddress} is type ${pool.poolType}. Only FPMM pools support liquidity provision.`);
56
+ }
57
+ return {
58
+ token0: pool.token0,
59
+ token1: pool.token1,
60
+ factoryAddr: pool.factoryAddr,
61
+ };
62
+ }
63
+ function validatePoolTokens(poolToken0, poolToken1, tokenA, tokenB) {
64
+ const tokenALower = tokenA.toLowerCase();
65
+ const tokenBLower = tokenB.toLowerCase();
66
+ const token0Lower = poolToken0.toLowerCase();
67
+ const token1Lower = poolToken1.toLowerCase();
68
+ // Ensure both tokens belong to pool
69
+ const aInPool = tokenALower === token0Lower || tokenALower === token1Lower;
70
+ const bInPool = tokenBLower === token0Lower || tokenBLower === token1Lower;
71
+ if (!aInPool || !bInPool) {
72
+ throw new Error(`Tokens don't match pool. Pool has ${poolToken0} and ${poolToken1}, but received ${tokenA} and ${tokenB}`);
73
+ }
74
+ // Ensure tokens are different
75
+ if (tokenALower === tokenBLower) {
76
+ throw new Error('tokenA and tokenB must be different');
77
+ }
78
+ }
79
+ async function getPoolSnapshot(publicClient, poolAddress) {
80
+ const results = await (0, multicall_1.multicall)(publicClient, [
81
+ {
82
+ address: poolAddress,
83
+ abi: abis_1.FPMM_ABI,
84
+ functionName: 'getReserves',
85
+ },
86
+ {
87
+ address: poolAddress,
88
+ abi: abis_1.ERC20_ABI,
89
+ functionName: 'totalSupply',
90
+ args: [],
91
+ },
92
+ ]);
93
+ if (results[0].status === 'failure' || results[1].status === 'failure') {
94
+ throw new Error(`Failed to fetch pool snapshot for ${poolAddress}`);
95
+ }
96
+ const [reserve0, reserve1, blockTimestampLast] = results[0].result;
97
+ return {
98
+ reserve0,
99
+ reserve1,
100
+ blockTimestampLast,
101
+ totalSupply: results[1].result,
102
+ };
103
+ }
104
+ //# sourceMappingURL=liquidityHelpers.js.map
@@ -0,0 +1,6 @@
1
+ import { PublicClient } from 'viem';
2
+ import { RebalanceDetails, RebalanceTransaction } from '../../core/types';
3
+ import { PoolService } from '../pools';
4
+ export declare function buildRebalanceParamsInternal(publicClient: PublicClient, chainId: number, poolService: PoolService, poolAddress: string): Promise<RebalanceDetails>;
5
+ export declare function buildRebalanceTransactionInternal(publicClient: PublicClient, chainId: number, poolService: PoolService, poolAddress: string, owner: string): Promise<RebalanceTransaction>;
6
+ //# sourceMappingURL=rebalance.d.ts.map