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