@mento-protocol/mento-sdk 3.2.6 → 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 +7 -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 -120
  163. package/dist/esm/services/liquidity/zapIn.js +0 -112
  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 -66
  238. package/dist/services/liquidity/zapHelpers.js +0 -129
  239. package/dist/services/liquidity/zapIn.d.ts +0 -18
  240. package/dist/services/liquidity/zapIn.js +0 -119
  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
package/dist/esm/index.js DELETED
@@ -1,139 +0,0 @@
1
- import { createPublicClient, http } from 'viem';
2
- import { ChainId } from './core/constants/chainId';
3
- import { getContractAddress } from './core/constants/addresses';
4
- import { getDefaultRpcUrl, getChainConfig } from './utils/chainConfig';
5
- import { TokenService } from './services/tokens';
6
- import { PoolService } from './services/pools';
7
- import { RouteService } from './services/routes';
8
- import { QuoteService } from './services/quotes';
9
- import { SwapService } from './services/swap';
10
- import { TradingService } from './services/trading';
11
- import { LiquidityService } from './services/liquidity';
12
- import { BorrowService } from './services/borrow';
13
- const DEFAULT_HTTP_BATCH_OPTIONS = {
14
- batchSize: 1000,
15
- wait: 8,
16
- };
17
- const DEFAULT_MULTICALL_BATCH_OPTIONS = {
18
- batchSize: 1024,
19
- wait: 8,
20
- };
21
- /**
22
- * @class Mento
23
- * @description The main class for the Mento SDK. Initializes a viem PublicClient internally
24
- * and provides a public API for interacting with the Mento Protocol.
25
- * @dev example usage:
26
- * const mento = await Mento.create(ChainId.CELO);
27
- * // or with custom RPC URL
28
- * const mento = await Mento.create(ChainId.CELO, 'https://custom-rpc-url.com');
29
- * // or with an existing viem PublicClient
30
- * const mento = await Mento.create(ChainId.CELO, myPublicClient);
31
- *
32
- * // Get all stable tokens
33
- * const stableTokens = await mento.tokens.getStableTokens();
34
- *
35
- * // Get all collateral assets
36
- * const collateralAssets = await mento.tokens.getCollateralAssets();
37
- *
38
- * // Get all pools
39
- * const pools = await mento.pools.getPools();
40
- *
41
- * // Find a route between tokens
42
- * const route = await mento.routes.findRoute(USDm, CELO);
43
- *
44
- * // Get a quote for a swap
45
- * const amountOut = await mento.quotes.getAmountOut(USDm, CELO, amountIn);
46
- *
47
- * // Build swap parameters
48
- * const swapDetails = await mento.swap.buildSwapParams(USDm, CELO, amountIn, recipient, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) });
49
- *
50
- * // Check if a pair is tradable (circuit breaker check)
51
- * const isTradable = await mento.trading.isPairTradable(USDm, CELO);
52
- *
53
- * // Get trading limits for a pool
54
- * const limits = await mento.trading.getPoolTradingLimits(pool);
55
- *
56
- * // Get full tradability status (circuit breaker + limits)
57
- * const status = await mento.trading.getPoolTradabilityStatus(pool);
58
- *
59
- * // Add liquidity to a pool
60
- * const { approval0, approval1, addLiquidity } = await mento.liquidity.buildAddLiquidityTransaction(
61
- * poolAddress, amount0, amount1, recipient, owner, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
62
- * );
63
- *
64
- * // Add liquidity using a single token (zap in)
65
- * const { approval, zapIn } = await mento.liquidity.buildZapInTransaction(
66
- * poolAddress, tokenIn, amountIn, 0.5, recipient, owner, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
67
- * );
68
- */
69
- export class Mento {
70
- constructor(chainId, tokens, pools, routes, quotes, swap, trading, liquidity, borrow) {
71
- this.chainId = chainId;
72
- this.tokens = tokens;
73
- this.pools = pools;
74
- this.routes = routes;
75
- this.quotes = quotes;
76
- this.swap = swap;
77
- this.trading = trading;
78
- this.liquidity = liquidity;
79
- this.borrow = borrow;
80
- }
81
- static async create(chainId, rpcUrlOrClient, options) {
82
- // Validate chainId is supported
83
- const supportedChainIds = Object.values(ChainId).filter((v) => typeof v === 'number');
84
- if (!supportedChainIds.includes(chainId)) {
85
- throw new Error(`ChainId ${chainId} is not supported. ` +
86
- `Supported chains: ${supportedChainIds.map((id) => `${id} (${ChainId[id]})`).join(', ')}`);
87
- }
88
- let publicClient;
89
- if (rpcUrlOrClient && typeof rpcUrlOrClient !== 'string') {
90
- publicClient = rpcUrlOrClient;
91
- }
92
- else {
93
- const transport = http(rpcUrlOrClient || getDefaultRpcUrl(chainId), {
94
- batch: options?.httpBatch === false
95
- ? false
96
- : {
97
- ...DEFAULT_HTTP_BATCH_OPTIONS,
98
- ...(options?.httpBatch ?? {}),
99
- },
100
- });
101
- publicClient = createPublicClient({
102
- batch: {
103
- multicall: options?.multicallBatch === false
104
- ? false
105
- : {
106
- ...DEFAULT_MULTICALL_BATCH_OPTIONS,
107
- ...(options?.multicallBatch ?? {}),
108
- },
109
- },
110
- chain: getChainConfig(chainId),
111
- transport,
112
- });
113
- }
114
- const tokenService = new TokenService(publicClient, chainId);
115
- const poolService = new PoolService(publicClient, chainId);
116
- const routeService = new RouteService(publicClient, chainId, poolService);
117
- const quoteService = new QuoteService(publicClient, chainId, routeService);
118
- const swapService = new SwapService(publicClient, chainId, routeService, quoteService);
119
- const tradingService = new TradingService(publicClient, chainId, routeService);
120
- const liquidityService = new LiquidityService(publicClient, chainId, poolService, routeService);
121
- const borrowService = new BorrowService(publicClient, chainId);
122
- // Return new mento
123
- return new Mento(chainId, tokenService, poolService, routeService, quoteService, swapService, tradingService, liquidityService, borrowService);
124
- }
125
- /**
126
- * Get the address of a contract for the current chain
127
- * @param contractName - The contract name
128
- * @returns The contract address
129
- */
130
- getContractAddress(contractName) {
131
- return getContractAddress(this.chainId, contractName);
132
- }
133
- }
134
- export * from './core/constants';
135
- export * from './core/errors';
136
- export * from './core/types';
137
- export * from './core/abis';
138
- export * from './services';
139
- export * from './utils';
@@ -1 +0,0 @@
1
- {"type":"module"}
@@ -1,455 +0,0 @@
1
- import { BorrowApprovalService } from './internal/borrowApprovalService';
2
- import { BorrowContextStore } from './internal/borrowContextStore';
3
- import { BorrowReadService } from './internal/borrowReadService';
4
- import { BorrowTransactionService } from './internal/borrowTransactionService';
5
- /**
6
- * Service for managing borrowing positions (troves) in the Mento protocol.
7
- * Provides methods to open, adjust, and close troves, manage collateral and debt,
8
- * handle interest rates and batch managers, and query position data.
9
- *
10
- * All `build*` methods return `CallParams` ({ to, data, value }) that can be
11
- * executed with any wallet client. The `debtTokenSymbol` parameter (e.g., 'GBPm')
12
- * identifies which borrowing deployment to interact with.
13
- *
14
- * @example
15
- * ```typescript
16
- * const mento = await Mento.create(ChainId.CELO)
17
- *
18
- * const ownerIndex = await mento.borrow.findNextAvailableOwnerIndex('GBPm', '0x...', '0x...')
19
- *
20
- * // Open a trove
21
- * const tx = await mento.borrow.buildOpenTroveTransaction('GBPm', {
22
- * owner: '0x...', ownerIndex,
23
- * collAmount: parseUnits('10', 18),
24
- * boldAmount: parseUnits('1000', 18),
25
- * annualInterestRate: parseUnits('0.05', 18),
26
- * maxUpfrontFee: parseUnits('100', 18),
27
- * })
28
- * await walletClient.sendTransaction(tx)
29
- * ```
30
- */
31
- export class BorrowService {
32
- constructor(publicClient, chainId) {
33
- this.contextStore = new BorrowContextStore(publicClient, chainId);
34
- this.txService = new BorrowTransactionService(publicClient);
35
- this.approvalService = new BorrowApprovalService(publicClient);
36
- this.readService = new BorrowReadService(publicClient);
37
- }
38
- /**
39
- * Builds a transaction to open a new trove (borrowing position).
40
- * Requires prior collateral approval via `buildCollateralApprovalParams`.
41
- *
42
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
43
- * @param params - Trove opening parameters including collateral, debt amount, and interest rate
44
- * @returns Transaction parameters ready to send
45
- */
46
- buildOpenTroveTransaction(debtTokenSymbol, params) {
47
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildOpenTroveTransaction(ctx, params));
48
- }
49
- /**
50
- * Builds a transaction to adjust an existing trove's collateral and/or debt.
51
- *
52
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
53
- * @param params - Adjustment parameters specifying collateral/debt changes
54
- * @returns Transaction parameters ready to send
55
- */
56
- buildAdjustTroveTransaction(debtTokenSymbol, params) {
57
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildAdjustTroveTransaction(ctx, params));
58
- }
59
- /**
60
- * Builds a transaction to adjust a zombie trove. Zombie troves are still-open troves whose
61
- * debt fell below the branch minimum debt, typically after a redemption.
62
- *
63
- * Use this when `getTroveData()` or `getUserTroves()` returns `status === 'zombie'`.
64
- * Same parameters as `buildAdjustTroveTransaction`.
65
- *
66
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
67
- * @param params - Adjustment parameters specifying collateral/debt changes
68
- * @returns Transaction parameters ready to send
69
- */
70
- buildAdjustZombieTroveTransaction(debtTokenSymbol, params) {
71
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildAdjustZombieTroveTransaction(ctx, params));
72
- }
73
- /**
74
- * Builds a transaction to close a trove, repaying all debt and reclaiming collateral.
75
- *
76
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
77
- * @param troveId - The NFT token ID identifying the trove
78
- * @returns Transaction parameters ready to send
79
- */
80
- buildCloseTroveTransaction(debtTokenSymbol, troveId) {
81
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildCloseTroveTransaction(ctx, troveId));
82
- }
83
- /**
84
- * Builds a transaction to add collateral to an existing trove.
85
- * Requires prior collateral approval via `buildCollateralApprovalParams`.
86
- *
87
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
88
- * @param troveId - The NFT token ID identifying the trove
89
- * @param amount - Amount of collateral to add (in wei)
90
- * @returns Transaction parameters ready to send
91
- */
92
- buildAddCollTransaction(debtTokenSymbol, troveId, amount) {
93
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildAddCollTransaction(ctx, troveId, amount));
94
- }
95
- /**
96
- * Builds a transaction to withdraw collateral from an existing trove.
97
- *
98
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
99
- * @param troveId - The NFT token ID identifying the trove
100
- * @param amount - Amount of collateral to withdraw (in wei)
101
- * @returns Transaction parameters ready to send
102
- */
103
- buildWithdrawCollTransaction(debtTokenSymbol, troveId, amount) {
104
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildWithdrawCollTransaction(ctx, troveId, amount));
105
- }
106
- /**
107
- * Builds a transaction to borrow additional debt against an existing trove.
108
- *
109
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
110
- * @param troveId - The NFT token ID identifying the trove
111
- * @param amount - Additional debt amount to borrow (in wei)
112
- * @param maxFee - Maximum upfront fee the borrower is willing to pay (in wei)
113
- * @returns Transaction parameters ready to send
114
- */
115
- buildBorrowMoreTransaction(debtTokenSymbol, troveId, amount, maxFee) {
116
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildBorrowMoreTransaction(ctx, troveId, amount, maxFee));
117
- }
118
- /**
119
- * Builds a transaction to repay debt on an existing trove.
120
- *
121
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
122
- * @param troveId - The NFT token ID identifying the trove
123
- * @param amount - Amount of debt to repay (in wei)
124
- * @returns Transaction parameters ready to send
125
- */
126
- buildRepayDebtTransaction(debtTokenSymbol, troveId, amount) {
127
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildRepayDebtTransaction(ctx, troveId, amount));
128
- }
129
- /**
130
- * Builds a transaction to change the annual interest rate on a trove.
131
- *
132
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
133
- * @param troveId - The NFT token ID identifying the trove
134
- * @param newRate - New annual interest rate (18-decimal fixed-point, e.g., parseUnits('0.05', 18) for 5%)
135
- * @param maxFee - Maximum upfront fee the borrower is willing to pay (in wei)
136
- * @returns Transaction parameters ready to send
137
- */
138
- buildAdjustInterestRateTransaction(debtTokenSymbol, troveId, newRate, maxFee) {
139
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildAdjustInterestRateTransaction(ctx, troveId, newRate, maxFee));
140
- }
141
- /**
142
- * Builds a transaction to claim collateral surplus after a liquidation.
143
- * This is for collateral held in the surplus pool after `closedByLiquidation`.
144
- * Zombie troves with remaining collateral should usually be closed or adjusted instead.
145
- *
146
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
147
- * @returns Transaction parameters ready to send
148
- */
149
- buildClaimCollateralTransaction(debtTokenSymbol) {
150
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildClaimCollateralTransaction(ctx));
151
- }
152
- /**
153
- * Builds a transaction to delegate interest rate management to a batch manager.
154
- *
155
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
156
- * @param troveId - The NFT token ID identifying the trove
157
- * @param manager - Address of the batch manager contract
158
- * @param maxFee - Maximum upfront fee the borrower is willing to pay (in wei)
159
- * @returns Transaction parameters ready to send
160
- */
161
- buildSetBatchManagerTransaction(debtTokenSymbol, troveId, manager, maxFee) {
162
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildSetBatchManagerTransaction(ctx, troveId, manager, maxFee));
163
- }
164
- /**
165
- * Builds a transaction to remove a trove from a batch manager, setting a new individual rate.
166
- *
167
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
168
- * @param troveId - The NFT token ID identifying the trove
169
- * @param newRate - New individual annual interest rate (18-decimal fixed-point)
170
- * @param maxFee - Maximum upfront fee the borrower is willing to pay (in wei)
171
- * @returns Transaction parameters ready to send
172
- */
173
- buildRemoveFromBatchTransaction(debtTokenSymbol, troveId, newRate, maxFee) {
174
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildRemoveFromBatchTransaction(ctx, troveId, newRate, maxFee));
175
- }
176
- /**
177
- * Builds a transaction to switch a trove to a different batch manager.
178
- *
179
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
180
- * @param troveId - The NFT token ID identifying the trove
181
- * @param newManager - Address of the new batch manager contract
182
- * @param maxFee - Maximum upfront fee the borrower is willing to pay (in wei)
183
- * @returns Transaction parameters ready to send
184
- */
185
- buildSwitchBatchManagerTransaction(debtTokenSymbol, troveId, newManager, maxFee) {
186
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildSwitchBatchManagerTransaction(ctx, troveId, newManager, maxFee));
187
- }
188
- /**
189
- * Builds a transaction to delegate interest rate management to another address
190
- * with bounded rate constraints.
191
- *
192
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
193
- * @param troveId - The NFT token ID identifying the trove
194
- * @param delegate - Address to delegate interest rate management to
195
- * @param minRate - Minimum allowed annual interest rate (18-decimal fixed-point)
196
- * @param maxRate - Maximum allowed annual interest rate (18-decimal fixed-point)
197
- * @param newRate - Initial annual interest rate to set (18-decimal fixed-point)
198
- * @param maxFee - Maximum upfront fee the borrower is willing to pay (in wei)
199
- * @param minChangePeriod - Minimum time between rate changes (in seconds)
200
- * @returns Transaction parameters ready to send
201
- */
202
- buildSetInterestDelegateTransaction(debtTokenSymbol, troveId, delegate, minRate, maxRate, newRate, maxFee, minChangePeriod) {
203
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildSetInterestDelegateTransaction(ctx, troveId, delegate, minRate, maxRate, newRate, maxFee, minChangePeriod));
204
- }
205
- /**
206
- * Builds a transaction to remove the interest rate delegate from a trove.
207
- *
208
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
209
- * @param troveId - The NFT token ID identifying the trove
210
- * @returns Transaction parameters ready to send
211
- */
212
- buildRemoveInterestDelegateTransaction(debtTokenSymbol, troveId) {
213
- return this.withContext(debtTokenSymbol, (ctx) => this.txService.buildRemoveInterestDelegateTransaction(ctx, troveId));
214
- }
215
- /**
216
- * Builds approval params to allow BorrowerOperations to spend collateral tokens.
217
- * Must be executed before `buildOpenTroveTransaction` or `buildAddCollTransaction`.
218
- *
219
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
220
- * @param amount - Amount of collateral to approve (in wei)
221
- * @returns Transaction parameters for the ERC-20 approve call
222
- */
223
- buildCollateralApprovalParams(debtTokenSymbol, amount) {
224
- return this.withContext(debtTokenSymbol, (ctx) => this.approvalService.buildCollateralApprovalParams(ctx, amount));
225
- }
226
- /**
227
- * Builds approval params for the debt token (e.g., for repayment or closing).
228
- *
229
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
230
- * @param spender - Address to approve as spender
231
- * @param amount - Amount of debt tokens to approve (in wei)
232
- * @returns Transaction parameters for the ERC-20 approve call
233
- */
234
- buildDebtApprovalParams(debtTokenSymbol, spender, amount) {
235
- return this.withContext(debtTokenSymbol, (ctx) => this.approvalService.buildDebtApprovalParams(ctx, spender, amount));
236
- }
237
- /**
238
- * Builds approval params for the gas compensation token (required when opening a trove).
239
- *
240
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
241
- * @param amount - Amount to approve (in wei). If omitted, approves the gas compensation amount.
242
- * @returns Transaction parameters for the ERC-20 approve call
243
- */
244
- buildGasCompensationApprovalParams(debtTokenSymbol, amount) {
245
- return this.withContext(debtTokenSymbol, (ctx) => this.approvalService.buildGasCompensationApprovalParams(ctx, amount));
246
- }
247
- /**
248
- * Gets the current collateral token allowance for BorrowerOperations.
249
- *
250
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
251
- * @param owner - Address to check allowance for
252
- * @returns Current allowance in wei
253
- */
254
- getCollateralAllowance(debtTokenSymbol, owner) {
255
- return this.withContext(debtTokenSymbol, (ctx) => this.approvalService.getCollateralAllowance(ctx, owner));
256
- }
257
- /**
258
- * Gets the current debt token allowance for a specific spender.
259
- *
260
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
261
- * @param owner - Address to check allowance for
262
- * @param spender - Address of the approved spender
263
- * @returns Current allowance in wei
264
- */
265
- getDebtAllowance(debtTokenSymbol, owner, spender) {
266
- return this.withContext(debtTokenSymbol, (ctx) => this.approvalService.getDebtAllowance(ctx, owner, spender));
267
- }
268
- /**
269
- * Gets the current gas compensation token allowance.
270
- *
271
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
272
- * @param owner - Address to check allowance for
273
- * @returns Current allowance in wei
274
- */
275
- getGasTokenAllowance(debtTokenSymbol, owner) {
276
- return this.withContext(debtTokenSymbol, (ctx) => this.approvalService.getGasTokenAllowance(ctx, owner));
277
- }
278
- /**
279
- * Fetches on-chain data for a specific trove.
280
- * The returned position reflects the trove's current lifecycle status, including
281
- * zombie troves that may still hold collateral even when their debt is zero.
282
- *
283
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
284
- * @param troveId - The NFT token ID identifying the trove
285
- * @returns Trove position data including collateral, debt, interest rate, and status
286
- */
287
- getTroveData(debtTokenSymbol, troveId) {
288
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getTroveData(ctx, troveId));
289
- }
290
- /**
291
- * Fetches troves currently owned by an address via the Trove NFT.
292
- * This includes zombie troves that have been removed from `SortedTroves` but are still owned
293
- * by the address. Closed or liquidated troves are not returned once their Trove NFT is burned
294
- * or transferred away.
295
- *
296
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
297
- * @param owner - Address to query troves for
298
- * @returns Array of trove positions currently owned by the address
299
- */
300
- getUserTroves(debtTokenSymbol, owner) {
301
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getUserTroves(ctx, owner));
302
- }
303
- /**
304
- * Gets the current collateral token price from the price feed.
305
- *
306
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
307
- * @returns Collateral price in 18-decimal fixed-point format
308
- */
309
- getCollateralPrice(debtTokenSymbol) {
310
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getCollateralPrice(ctx));
311
- }
312
- /**
313
- * Gets the system parameters for a borrowing deployment.
314
- * Returns MCR, CCR, SCR, BCR, minimum debt, gas compensation, and minimum interest rate.
315
- *
316
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
317
- * @returns System parameters (all values in 18-decimal fixed-point)
318
- */
319
- getSystemParams(debtTokenSymbol) {
320
- return this.withContext(debtTokenSymbol, (ctx) => ({ ...ctx.systemParams }));
321
- }
322
- /**
323
- * Checks whether the borrowing system has been shut down (e.g., during a crisis).
324
- *
325
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
326
- * @returns true if the system is shut down, false otherwise
327
- */
328
- isSystemShutDown(debtTokenSymbol) {
329
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.isSystemShutDown(ctx));
330
- }
331
- /**
332
- * Gets aggregate collateral and debt statistics for the borrowing branch.
333
- *
334
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
335
- * @returns Total collateral and total debt across all troves (in wei)
336
- */
337
- getBranchStats(debtTokenSymbol) {
338
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getBranchStats(ctx));
339
- }
340
- /**
341
- * Gets the distribution of debt across interest rate brackets.
342
- *
343
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
344
- * @returns Array of brackets, each with a rate and total debt at that rate
345
- */
346
- getInterestRateBrackets(debtTokenSymbol) {
347
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getInterestRateBrackets(ctx));
348
- }
349
- /**
350
- * Gets the weighted average interest rate across all active troves.
351
- *
352
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
353
- * @returns Average annual interest rate in 18-decimal fixed-point
354
- */
355
- getAverageInterestRate(debtTokenSymbol) {
356
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getAverageInterestRate(ctx));
357
- }
358
- /**
359
- * Gets information about a batch manager's configuration.
360
- *
361
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
362
- * @param address - Address of the batch manager
363
- * @returns Batch manager config (min/max rate, min change period), or null if not a valid manager
364
- */
365
- getBatchManagerInfo(debtTokenSymbol, address) {
366
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getBatchManagerInfo(ctx, address));
367
- }
368
- /**
369
- * Estimates the upfront fee for opening a new trove.
370
- *
371
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
372
- * @param amount - Debt amount to borrow (in wei)
373
- * @param rate - Annual interest rate (18-decimal fixed-point)
374
- * @returns Estimated upfront fee in wei
375
- */
376
- predictOpenTroveUpfrontFee(debtTokenSymbol, amount, rate) {
377
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.predictOpenTroveUpfrontFee(ctx, amount, rate));
378
- }
379
- /**
380
- * Estimates the upfront fee for increasing debt on an existing trove.
381
- *
382
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
383
- * @param troveId - The NFT token ID identifying the trove
384
- * @param debtIncrease - Amount of additional debt (in wei)
385
- * @returns Estimated upfront fee in wei
386
- */
387
- predictAdjustUpfrontFee(debtTokenSymbol, troveId, debtIncrease) {
388
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.predictAdjustUpfrontFee(ctx, troveId, debtIncrease));
389
- }
390
- /**
391
- * Estimates the upfront fee for changing a trove's interest rate.
392
- *
393
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
394
- * @param troveId - The NFT token ID identifying the trove
395
- * @param newRate - New annual interest rate (18-decimal fixed-point)
396
- * @returns Estimated upfront fee in wei
397
- */
398
- predictAdjustInterestRateUpfrontFee(debtTokenSymbol, troveId, newRate) {
399
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.predictAdjustInterestRateUpfrontFee(ctx, troveId, newRate));
400
- }
401
- /**
402
- * Estimates the upfront fee for joining a batch manager.
403
- *
404
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
405
- * @param troveId - The NFT token ID identifying the trove
406
- * @param batchAddress - Address of the batch manager to join
407
- * @returns Estimated upfront fee in wei
408
- */
409
- predictJoinBatchUpfrontFee(debtTokenSymbol, troveId, batchAddress) {
410
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.predictJoinBatchUpfrontFee(ctx, troveId, batchAddress));
411
- }
412
- /**
413
- * Gets the current number of troves owned by an address via the Trove NFT.
414
- *
415
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
416
- * @param owner - Address of the trove owner
417
- * @returns The number of troves currently owned by the address
418
- */
419
- getOwnedTroveCount(debtTokenSymbol, owner) {
420
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getOwnedTroveCount(ctx, owner));
421
- }
422
- /**
423
- * Finds the first safe owner index for opening a trove with the given transaction sender.
424
- *
425
- * The `opener` must be the address that will call BorrowerOperations on-chain.
426
- * For smart accounts, pass the smart account address rather than the controlling EOA.
427
- *
428
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
429
- * @param owner - Address that will own the trove NFT
430
- * @param opener - Address that will submit the open-trove transaction on-chain
431
- * @returns The first owner index that does not already map to an existing trove
432
- */
433
- findNextAvailableOwnerIndex(debtTokenSymbol, owner, opener) {
434
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.findNextAvailableOwnerIndex(ctx, owner, opener));
435
- }
436
- /**
437
- * Gets the current number of troves owned by an address via the Trove NFT.
438
- *
439
- * @deprecated Use `findNextAvailableOwnerIndex` when preparing an open-trove transaction.
440
- *
441
- * @param debtTokenSymbol - The debt token symbol (e.g., 'GBPm')
442
- * @param owner - Address of the trove owner
443
- * @returns The number of troves currently owned by the address
444
- */
445
- getNextOwnerIndex(debtTokenSymbol, owner) {
446
- return this.withContext(debtTokenSymbol, (ctx) => this.readService.getOwnedTroveCount(ctx, owner));
447
- }
448
- async withContext(debtTokenSymbol, callback) {
449
- const ctx = await this.ensureInitialized(debtTokenSymbol);
450
- return callback(ctx);
451
- }
452
- ensureInitialized(debtTokenSymbol) {
453
- return this.contextStore.ensureInitialized(debtTokenSymbol);
454
- }
455
- }
@@ -1,3 +0,0 @@
1
- export { resolveAddressesFromRegistry, readSystemParams, } from './internal/borrowRegistryReader';
2
- export { buildErc20ApprovalParams as buildCollateralApprovalParams, readErc20Allowance as getCollateralAllowance, } from './internal/borrowErc20';
3
- export { mapTroveStatus, parseBorrowPosition } from './internal/borrowPositionParser';