@mento-protocol/mento-sdk 3.2.7-beta.0 → 3.2.7

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 (302) hide show
  1. package/package.json +1 -1
  2. package/dist/cache/routes.d.ts +0 -13
  3. package/dist/cache/routes.js +0 -14649
  4. package/dist/cache/tokens.d.ts +0 -68
  5. package/dist/cache/tokens.js +0 -488
  6. package/dist/core/abis/activePool.d.ts +0 -2
  7. package/dist/core/abis/activePool.js +0 -14
  8. package/dist/core/abis/addressesRegistry.d.ts +0 -2
  9. package/dist/core/abis/addressesRegistry.js +0 -26
  10. package/dist/core/abis/bipoolmanager.d.ts +0 -34
  11. package/dist/core/abis/bipoolmanager.js +0 -72
  12. package/dist/core/abis/borrowerOperations.d.ts +0 -9
  13. package/dist/core/abis/borrowerOperations.js +0 -89
  14. package/dist/core/abis/breakerbox.d.ts +0 -13
  15. package/dist/core/abis/breakerbox.js +0 -8
  16. package/dist/core/abis/broker.d.ts +0 -2
  17. package/dist/core/abis/broker.js +0 -9
  18. package/dist/core/abis/erc20.d.ts +0 -9
  19. package/dist/core/abis/erc20.js +0 -21
  20. package/dist/core/abis/fpmm.d.ts +0 -270
  21. package/dist/core/abis/fpmm.js +0 -49
  22. package/dist/core/abis/fpmmFactory.d.ts +0 -85
  23. package/dist/core/abis/fpmmFactory.js +0 -26
  24. package/dist/core/abis/hintHelpers.d.ts +0 -2
  25. package/dist/core/abis/hintHelpers.js +0 -14
  26. package/dist/core/abis/index.d.ts +0 -22
  27. package/dist/core/abis/index.js +0 -38
  28. package/dist/core/abis/liquidityStrategy.d.ts +0 -132
  29. package/dist/core/abis/liquidityStrategy.js +0 -10
  30. package/dist/core/abis/multiTroveGetter.d.ts +0 -8
  31. package/dist/core/abis/multiTroveGetter.js +0 -15
  32. package/dist/core/abis/priceFeed.d.ts +0 -7
  33. package/dist/core/abis/priceFeed.js +0 -16
  34. package/dist/core/abis/pricingmodule.d.ts +0 -2
  35. package/dist/core/abis/pricingmodule.js +0 -6
  36. package/dist/core/abis/reserve.d.ts +0 -3
  37. package/dist/core/abis/reserve.js +0 -18
  38. package/dist/core/abis/router.d.ts +0 -521
  39. package/dist/core/abis/router.js +0 -45
  40. package/dist/core/abis/sortedTroves.d.ts +0 -2
  41. package/dist/core/abis/sortedTroves.js +0 -15
  42. package/dist/core/abis/systemParams.d.ts +0 -2
  43. package/dist/core/abis/systemParams.js +0 -14
  44. package/dist/core/abis/troveManager.d.ts +0 -2
  45. package/dist/core/abis/troveManager.js +0 -27
  46. package/dist/core/abis/troveNFT.d.ts +0 -2
  47. package/dist/core/abis/troveNFT.js +0 -9
  48. package/dist/core/abis/virtualPool.d.ts +0 -50
  49. package/dist/core/abis/virtualPool.js +0 -11
  50. package/dist/core/abis/virtualPoolFactory.d.ts +0 -59
  51. package/dist/core/abis/virtualPoolFactory.js +0 -17
  52. package/dist/core/constants/addresses.d.ts +0 -18
  53. package/dist/core/constants/addresses.js +0 -113
  54. package/dist/core/constants/borrowConstants.d.ts +0 -10
  55. package/dist/core/constants/borrowConstants.js +0 -16
  56. package/dist/core/constants/borrowRegistries.d.ts +0 -7
  57. package/dist/core/constants/borrowRegistries.js +0 -34
  58. package/dist/core/constants/chainId.d.ts +0 -7
  59. package/dist/core/constants/chainId.js +0 -11
  60. package/dist/core/constants/contractNames.d.ts +0 -21
  61. package/dist/core/constants/contractNames.js +0 -24
  62. package/dist/core/constants/index.d.ts +0 -6
  63. package/dist/core/constants/index.js +0 -22
  64. package/dist/core/errors/base.d.ts +0 -8
  65. package/dist/core/errors/base.js +0 -17
  66. package/dist/core/errors/index.d.ts +0 -4
  67. package/dist/core/errors/index.js +0 -20
  68. package/dist/core/errors/oracle.d.ts +0 -9
  69. package/dist/core/errors/oracle.js +0 -15
  70. package/dist/core/errors/router.d.ts +0 -14
  71. package/dist/core/errors/router.js +0 -24
  72. package/dist/core/types/borrow.d.ts +0 -87
  73. package/dist/core/types/borrow.js +0 -3
  74. package/dist/core/types/contractAddresses.d.ts +0 -42
  75. package/dist/core/types/contractAddresses.js +0 -3
  76. package/dist/core/types/index.d.ts +0 -10
  77. package/dist/core/types/index.js +0 -26
  78. package/dist/core/types/liquidity.d.ts +0 -194
  79. package/dist/core/types/liquidity.js +0 -3
  80. package/dist/core/types/pool.d.ts +0 -208
  81. package/dist/core/types/pool.js +0 -14
  82. package/dist/core/types/provider.d.ts +0 -45
  83. package/dist/core/types/provider.js +0 -3
  84. package/dist/core/types/route.d.ts +0 -62
  85. package/dist/core/types/route.js +0 -3
  86. package/dist/core/types/token.d.ts +0 -21
  87. package/dist/core/types/token.js +0 -3
  88. package/dist/core/types/tradingLimits.d.ts +0 -91
  89. package/dist/core/types/tradingLimits.js +0 -3
  90. package/dist/core/types/tradingMode.d.ts +0 -24
  91. package/dist/core/types/tradingMode.js +0 -31
  92. package/dist/core/types/transaction.d.ts +0 -45
  93. package/dist/core/types/transaction.js +0 -3
  94. package/dist/esm/cache/routes.js +0 -14644
  95. package/dist/esm/cache/tokens.js +0 -480
  96. package/dist/esm/core/abis/activePool.js +0 -10
  97. package/dist/esm/core/abis/addressesRegistry.js +0 -22
  98. package/dist/esm/core/abis/bipoolmanager.js +0 -68
  99. package/dist/esm/core/abis/borrowerOperations.js +0 -85
  100. package/dist/esm/core/abis/breakerbox.js +0 -4
  101. package/dist/esm/core/abis/broker.js +0 -5
  102. package/dist/esm/core/abis/erc20.js +0 -17
  103. package/dist/esm/core/abis/fpmm.js +0 -45
  104. package/dist/esm/core/abis/fpmmFactory.js +0 -22
  105. package/dist/esm/core/abis/hintHelpers.js +0 -10
  106. package/dist/esm/core/abis/index.js +0 -21
  107. package/dist/esm/core/abis/liquidityStrategy.js +0 -6
  108. package/dist/esm/core/abis/multiTroveGetter.js +0 -11
  109. package/dist/esm/core/abis/priceFeed.js +0 -12
  110. package/dist/esm/core/abis/pricingmodule.js +0 -2
  111. package/dist/esm/core/abis/reserve.js +0 -14
  112. package/dist/esm/core/abis/router.js +0 -41
  113. package/dist/esm/core/abis/sortedTroves.js +0 -11
  114. package/dist/esm/core/abis/systemParams.js +0 -10
  115. package/dist/esm/core/abis/troveManager.js +0 -23
  116. package/dist/esm/core/abis/troveNFT.js +0 -5
  117. package/dist/esm/core/abis/virtualPool.js +0 -7
  118. package/dist/esm/core/abis/virtualPoolFactory.js +0 -13
  119. package/dist/esm/core/constants/addresses.js +0 -107
  120. package/dist/esm/core/constants/borrowConstants.js +0 -12
  121. package/dist/esm/core/constants/borrowRegistries.js +0 -29
  122. package/dist/esm/core/constants/chainId.js +0 -7
  123. package/dist/esm/core/constants/contractNames.js +0 -20
  124. package/dist/esm/core/constants/index.js +0 -5
  125. package/dist/esm/core/errors/base.js +0 -12
  126. package/dist/esm/core/errors/index.js +0 -3
  127. package/dist/esm/core/errors/oracle.js +0 -10
  128. package/dist/esm/core/errors/router.js +0 -18
  129. package/dist/esm/core/types/borrow.js +0 -1
  130. package/dist/esm/core/types/contractAddresses.js +0 -1
  131. package/dist/esm/core/types/index.js +0 -9
  132. package/dist/esm/core/types/liquidity.js +0 -1
  133. package/dist/esm/core/types/pool.js +0 -10
  134. package/dist/esm/core/types/provider.js +0 -1
  135. package/dist/esm/core/types/route.js +0 -1
  136. package/dist/esm/core/types/token.js +0 -1
  137. package/dist/esm/core/types/tradingLimits.js +0 -1
  138. package/dist/esm/core/types/tradingMode.js +0 -26
  139. package/dist/esm/core/types/transaction.js +0 -1
  140. package/dist/esm/index.js +0 -139
  141. package/dist/esm/package.json +0 -1
  142. package/dist/esm/services/borrow/BorrowService.js +0 -455
  143. package/dist/esm/services/borrow/borrowHelpers.js +0 -3
  144. package/dist/esm/services/borrow/borrowMath.js +0 -127
  145. package/dist/esm/services/borrow/index.js +0 -3
  146. package/dist/esm/services/borrow/internal/borrowApprovalService.js +0 -48
  147. package/dist/esm/services/borrow/internal/borrowContextStore.js +0 -35
  148. package/dist/esm/services/borrow/internal/borrowErc20.js +0 -38
  149. package/dist/esm/services/borrow/internal/borrowHints.js +0 -27
  150. package/dist/esm/services/borrow/internal/borrowPositionParser.js +0 -82
  151. package/dist/esm/services/borrow/internal/borrowReadService.js +0 -271
  152. package/dist/esm/services/borrow/internal/borrowRegistryReader.js +0 -108
  153. package/dist/esm/services/borrow/internal/borrowTransactionService.js +0 -271
  154. package/dist/esm/services/borrow/internal/borrowTypes.js +0 -1
  155. package/dist/esm/services/borrow/internal/borrowValidation.js +0 -89
  156. package/dist/esm/services/index.js +0 -8
  157. package/dist/esm/services/liquidity/LiquidityService.js +0 -163
  158. package/dist/esm/services/liquidity/basicLiquidity.js +0 -162
  159. package/dist/esm/services/liquidity/index.js +0 -1
  160. package/dist/esm/services/liquidity/liquidityHelpers.js +0 -95
  161. package/dist/esm/services/liquidity/rebalance.js +0 -59
  162. package/dist/esm/services/liquidity/zapHelpers.js +0 -181
  163. package/dist/esm/services/liquidity/zapIn.js +0 -131
  164. package/dist/esm/services/liquidity/zapOut.js +0 -248
  165. package/dist/esm/services/pools/PoolService.js +0 -204
  166. package/dist/esm/services/pools/index.js +0 -1
  167. package/dist/esm/services/pools/poolDetails.js +0 -209
  168. package/dist/esm/services/pools/poolDiscovery.js +0 -112
  169. package/dist/esm/services/pools/rebalancePreview.js +0 -181
  170. package/dist/esm/services/quotes/QuoteService.js +0 -85
  171. package/dist/esm/services/quotes/index.js +0 -1
  172. package/dist/esm/services/routes/RouteService.js +0 -268
  173. package/dist/esm/services/routes/index.js +0 -1
  174. package/dist/esm/services/swap/SwapService.js +0 -247
  175. package/dist/esm/services/swap/index.js +0 -1
  176. package/dist/esm/services/tokens/index.js +0 -1
  177. package/dist/esm/services/tokens/tokenService.js +0 -285
  178. package/dist/esm/services/trading/TradingLimitsService.js +0 -154
  179. package/dist/esm/services/trading/TradingService.js +0 -222
  180. package/dist/esm/services/trading/index.js +0 -2
  181. package/dist/esm/utils/chainConfig.js +0 -118
  182. package/dist/esm/utils/costUtils.js +0 -56
  183. package/dist/esm/utils/deadline.js +0 -22
  184. package/dist/esm/utils/index.js +0 -9
  185. package/dist/esm/utils/multicall.js +0 -47
  186. package/dist/esm/utils/pathEncoder.js +0 -69
  187. package/dist/esm/utils/rateFeed.js +0 -23
  188. package/dist/esm/utils/retry.js +0 -24
  189. package/dist/esm/utils/routeUtils.js +0 -361
  190. package/dist/esm/utils/routes.js +0 -2
  191. package/dist/esm/utils/sortUtils.js +0 -33
  192. package/dist/esm/utils/tokens.js +0 -2
  193. package/dist/esm/utils/tradingLimits.js +0 -163
  194. package/dist/esm/utils/validation.js +0 -30
  195. package/dist/index.d.ts +0 -101
  196. package/dist/index.js +0 -158
  197. package/dist/services/borrow/BorrowService.d.ts +0 -381
  198. package/dist/services/borrow/BorrowService.js +0 -460
  199. package/dist/services/borrow/borrowHelpers.d.ts +0 -4
  200. package/dist/services/borrow/borrowHelpers.js +0 -13
  201. package/dist/services/borrow/borrowMath.d.ts +0 -21
  202. package/dist/services/borrow/borrowMath.js +0 -137
  203. package/dist/services/borrow/index.d.ts +0 -4
  204. package/dist/services/borrow/index.js +0 -20
  205. package/dist/services/borrow/internal/borrowApprovalService.d.ts +0 -14
  206. package/dist/services/borrow/internal/borrowApprovalService.js +0 -53
  207. package/dist/services/borrow/internal/borrowContextStore.d.ts +0 -11
  208. package/dist/services/borrow/internal/borrowContextStore.js +0 -40
  209. package/dist/services/borrow/internal/borrowErc20.d.ts +0 -5
  210. package/dist/services/borrow/internal/borrowErc20.js +0 -43
  211. package/dist/services/borrow/internal/borrowHints.d.ts +0 -7
  212. package/dist/services/borrow/internal/borrowHints.js +0 -31
  213. package/dist/services/borrow/internal/borrowPositionParser.d.ts +0 -4
  214. package/dist/services/borrow/internal/borrowPositionParser.js +0 -87
  215. package/dist/services/borrow/internal/borrowReadService.d.ts +0 -31
  216. package/dist/services/borrow/internal/borrowReadService.js +0 -276
  217. package/dist/services/borrow/internal/borrowRegistryReader.d.ts +0 -5
  218. package/dist/services/borrow/internal/borrowRegistryReader.js +0 -113
  219. package/dist/services/borrow/internal/borrowTransactionService.d.ts +0 -23
  220. package/dist/services/borrow/internal/borrowTransactionService.js +0 -276
  221. package/dist/services/borrow/internal/borrowTypes.d.ts +0 -15
  222. package/dist/services/borrow/internal/borrowTypes.js +0 -3
  223. package/dist/services/borrow/internal/borrowValidation.d.ts +0 -14
  224. package/dist/services/borrow/internal/borrowValidation.js +0 -104
  225. package/dist/services/index.d.ts +0 -9
  226. package/dist/services/index.js +0 -25
  227. package/dist/services/liquidity/LiquidityService.d.ts +0 -139
  228. package/dist/services/liquidity/LiquidityService.js +0 -168
  229. package/dist/services/liquidity/basicLiquidity.d.ts +0 -11
  230. package/dist/services/liquidity/basicLiquidity.js +0 -172
  231. package/dist/services/liquidity/index.d.ts +0 -2
  232. package/dist/services/liquidity/index.js +0 -18
  233. package/dist/services/liquidity/liquidityHelpers.d.ts +0 -19
  234. package/dist/services/liquidity/liquidityHelpers.js +0 -104
  235. package/dist/services/liquidity/rebalance.d.ts +0 -6
  236. package/dist/services/liquidity/rebalance.js +0 -64
  237. package/dist/services/liquidity/zapHelpers.d.ts +0 -100
  238. package/dist/services/liquidity/zapHelpers.js +0 -192
  239. package/dist/services/liquidity/zapIn.d.ts +0 -18
  240. package/dist/services/liquidity/zapIn.js +0 -138
  241. package/dist/services/liquidity/zapOut.d.ts +0 -9
  242. package/dist/services/liquidity/zapOut.js +0 -255
  243. package/dist/services/pools/PoolService.d.ts +0 -69
  244. package/dist/services/pools/PoolService.js +0 -209
  245. package/dist/services/pools/index.d.ts +0 -2
  246. package/dist/services/pools/index.js +0 -18
  247. package/dist/services/pools/poolDetails.d.ts +0 -13
  248. package/dist/services/pools/poolDetails.js +0 -216
  249. package/dist/services/pools/poolDiscovery.d.ts +0 -12
  250. package/dist/services/pools/poolDiscovery.js +0 -117
  251. package/dist/services/pools/rebalancePreview.d.ts +0 -5
  252. package/dist/services/pools/rebalancePreview.js +0 -186
  253. package/dist/services/quotes/QuoteService.d.ts +0 -51
  254. package/dist/services/quotes/QuoteService.js +0 -91
  255. package/dist/services/quotes/index.d.ts +0 -2
  256. package/dist/services/quotes/index.js +0 -18
  257. package/dist/services/routes/RouteService.d.ts +0 -117
  258. package/dist/services/routes/RouteService.js +0 -306
  259. package/dist/services/routes/index.d.ts +0 -2
  260. package/dist/services/routes/index.js +0 -18
  261. package/dist/services/swap/SwapService.d.ts +0 -198
  262. package/dist/services/swap/SwapService.js +0 -252
  263. package/dist/services/swap/index.d.ts +0 -2
  264. package/dist/services/swap/index.js +0 -18
  265. package/dist/services/tokens/index.d.ts +0 -2
  266. package/dist/services/tokens/index.js +0 -18
  267. package/dist/services/tokens/tokenService.d.ts +0 -55
  268. package/dist/services/tokens/tokenService.js +0 -290
  269. package/dist/services/trading/TradingLimitsService.d.ts +0 -38
  270. package/dist/services/trading/TradingLimitsService.js +0 -159
  271. package/dist/services/trading/TradingService.d.ts +0 -115
  272. package/dist/services/trading/TradingService.js +0 -227
  273. package/dist/services/trading/index.d.ts +0 -3
  274. package/dist/services/trading/index.js +0 -19
  275. package/dist/utils/chainConfig.d.ts +0 -16
  276. package/dist/utils/chainConfig.js +0 -123
  277. package/dist/utils/costUtils.d.ts +0 -12
  278. package/dist/utils/costUtils.js +0 -60
  279. package/dist/utils/deadline.d.ts +0 -21
  280. package/dist/utils/deadline.js +0 -26
  281. package/dist/utils/index.d.ts +0 -10
  282. package/dist/utils/index.js +0 -26
  283. package/dist/utils/multicall.d.ts +0 -30
  284. package/dist/utils/multicall.js +0 -52
  285. package/dist/utils/pathEncoder.d.ts +0 -34
  286. package/dist/utils/pathEncoder.js +0 -73
  287. package/dist/utils/rateFeed.d.ts +0 -18
  288. package/dist/utils/rateFeed.js +0 -27
  289. package/dist/utils/retry.d.ts +0 -12
  290. package/dist/utils/retry.js +0 -28
  291. package/dist/utils/routeUtils.d.ts +0 -295
  292. package/dist/utils/routeUtils.js +0 -371
  293. package/dist/utils/routes.d.ts +0 -3
  294. package/dist/utils/routes.js +0 -8
  295. package/dist/utils/sortUtils.d.ts +0 -24
  296. package/dist/utils/sortUtils.js +0 -39
  297. package/dist/utils/tokens.d.ts +0 -2
  298. package/dist/utils/tokens.js +0 -13
  299. package/dist/utils/tradingLimits.d.ts +0 -41
  300. package/dist/utils/tradingLimits.js +0 -171
  301. package/dist/utils/validation.d.ts +0 -19
  302. package/dist/utils/validation.js +0 -34
@@ -1,139 +0,0 @@
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
@@ -1,168 +0,0 @@
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
@@ -1,11 +0,0 @@
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
@@ -1,172 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- export * from './LiquidityService';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./LiquidityService"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1,19 +0,0 @@
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
@@ -1,104 +0,0 @@
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
@@ -1,6 +0,0 @@
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