@mento-protocol/mento-sdk 3.2.7 → 3.2.8
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 +14649 -0
- package/dist/cache/tokens.d.ts +68 -0
- package/dist/cache/tokens.js +488 -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 +113 -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 +7 -0
- package/dist/core/constants/chainId.js +11 -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 +14644 -0
- package/dist/esm/cache/tokens.js +480 -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 +107 -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 +7 -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 +118 -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 +123 -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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* ERC20 ABI for standard token operations
|
|
4
|
+
*
|
|
5
|
+
* Note: `as any` is used because viem's parseAbi returns a complex readonly tuple type
|
|
6
|
+
* that can cause type verbosity. This doesn't compromise type safety - viem's
|
|
7
|
+
* readContract/writeContract still infer types correctly from the ABI at usage sites.
|
|
8
|
+
*/
|
|
9
|
+
export const ERC20_ABI = parseAbi([
|
|
10
|
+
'function name() view returns (string)',
|
|
11
|
+
'function symbol() view returns (string)',
|
|
12
|
+
'function decimals() view returns (uint8)',
|
|
13
|
+
'function totalSupply() view returns (uint256)',
|
|
14
|
+
'function balanceOf(address) view returns (uint256)',
|
|
15
|
+
'function approve(address spender, uint256 amount) returns (bool)',
|
|
16
|
+
'function allowance(address owner, address spender) view returns (uint256)',
|
|
17
|
+
]);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const FPMM_ABI = parseAbi([
|
|
3
|
+
'function token0() view returns (address)',
|
|
4
|
+
'function token1() view returns (address)',
|
|
5
|
+
'function lpFee() view returns (uint256)',
|
|
6
|
+
'function protocolFee() view returns (uint256)',
|
|
7
|
+
'function referenceRateFeedID() view returns (address)',
|
|
8
|
+
'function getTradingLimits(address token) view returns ((int120 limit0, int120 limit1, uint8 decimals) config, (uint32 lastUpdated0, uint32 lastUpdated1, int96 netflow0, int96 netflow1) state)',
|
|
9
|
+
'function getReserves() view returns (uint256, uint256, uint256)',
|
|
10
|
+
'function decimals0() view returns (uint256)',
|
|
11
|
+
'function decimals1() view returns (uint256)',
|
|
12
|
+
'function rebalanceIncentive() view returns (uint256)',
|
|
13
|
+
'function rebalanceThresholdAbove() view returns (uint256)',
|
|
14
|
+
'function rebalanceThresholdBelow() view returns (uint256)',
|
|
15
|
+
'function liquidityStrategy(address) view returns (bool)',
|
|
16
|
+
'function getRebalancingState() view returns (uint256, uint256, uint256, uint256, bool, uint16, uint256)',
|
|
17
|
+
// Custom errors
|
|
18
|
+
'error ReferenceRateNotSet()',
|
|
19
|
+
'error ReservesEmpty()',
|
|
20
|
+
'error InvalidToken()',
|
|
21
|
+
'error ZeroAddress()',
|
|
22
|
+
'error ProtocolFeeRecipientRequired()',
|
|
23
|
+
'error NotFeeSetter()',
|
|
24
|
+
'error FeeTooHigh()',
|
|
25
|
+
'error InsufficientLiquidityMinted()',
|
|
26
|
+
'error InsufficientLiquidityBurned()',
|
|
27
|
+
'error InsufficientOutputAmount()',
|
|
28
|
+
'error InsufficientLiquidity()',
|
|
29
|
+
'error InvalidToAddress()',
|
|
30
|
+
'error InsufficientInputAmount()',
|
|
31
|
+
'error NotLiquidityStrategy()',
|
|
32
|
+
'error OneOutputAmountRequired()',
|
|
33
|
+
'error PriceDifferenceTooSmall()',
|
|
34
|
+
'error PriceDifferenceNotImproved()',
|
|
35
|
+
'error PriceDifferenceMovedInWrongDirection()',
|
|
36
|
+
'error PriceDifferenceMovedTooFarFromThresholds()',
|
|
37
|
+
'error InsufficientAmount0In()',
|
|
38
|
+
'error InsufficientAmount1In()',
|
|
39
|
+
'error ReserveValueDecreased()',
|
|
40
|
+
'error RebalanceIncentiveTooHigh()',
|
|
41
|
+
'error RebalanceThresholdTooHigh()',
|
|
42
|
+
'error RebalanceDirectionInvalid()',
|
|
43
|
+
'error LimitDoesNotFitInInt120()',
|
|
44
|
+
'error InvalidTokenDecimals()',
|
|
45
|
+
]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const FPMM_FACTORY_ABI = parseAbi([
|
|
3
|
+
'function deployedFPMMAddresses() view returns (address[])',
|
|
4
|
+
'function isPool(address pool) view returns (bool)',
|
|
5
|
+
// Custom errors
|
|
6
|
+
'error CreateXBytecodeHashMismatch()',
|
|
7
|
+
'error ZeroAddress()',
|
|
8
|
+
'error IdenticalTokenAddresses()',
|
|
9
|
+
'error SortTokensZeroAddress()',
|
|
10
|
+
'error InvalidOracleAdapter()',
|
|
11
|
+
'error InvalidProxyAdmin()',
|
|
12
|
+
'error InvalidOwner()',
|
|
13
|
+
'error InvalidReferenceRateFeedID()',
|
|
14
|
+
'error PairAlreadyExists()',
|
|
15
|
+
'error ImplementationNotRegistered()',
|
|
16
|
+
'error ImplementationAlreadyRegistered()',
|
|
17
|
+
'error IndexOutOfBounds()',
|
|
18
|
+
'error ImplementationIndexMismatch()',
|
|
19
|
+
'error FeeTooHigh()',
|
|
20
|
+
'error RebalanceIncentiveTooHigh()',
|
|
21
|
+
'error RebalanceThresholdTooHigh()',
|
|
22
|
+
]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const HINT_HELPERS_ABI = parseAbi([
|
|
3
|
+
'function getApproxHint(uint256 _collIndex, uint256 _interestRate, uint256 _numTrials, uint256 _inputRandomSeed) view returns (uint256 hintId, uint256 diff, uint256 latestRandomSeed)',
|
|
4
|
+
'function predictOpenTroveUpfrontFee(uint256 _collIndex, uint256 _borrowedAmount, uint256 _interestRate) view returns (uint256)',
|
|
5
|
+
'function predictAdjustTroveUpfrontFee(uint256 _collIndex, uint256 _troveId, uint256 _debtIncrease) view returns (uint256)',
|
|
6
|
+
'function predictAdjustInterestRateUpfrontFee(uint256 _collIndex, uint256 _troveId, uint256 _newInterestRate) view returns (uint256)',
|
|
7
|
+
'function forcePredictAdjustInterestRateUpfrontFee(uint256 _collIndex, uint256 _troveId, uint256 _newInterestRate) view returns (uint256)',
|
|
8
|
+
'function predictAdjustBatchInterestRateUpfrontFee(uint256 _collIndex, address _batchAddress, uint256 _newInterestRate) view returns (uint256)',
|
|
9
|
+
'function predictJoinBatchInterestRateUpfrontFee(uint256 _collIndex, uint256 _troveId, address _batchAddress) view returns (uint256)',
|
|
10
|
+
]);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './erc20';
|
|
2
|
+
export * from './reserve';
|
|
3
|
+
export * from './bipoolmanager';
|
|
4
|
+
export * from './broker';
|
|
5
|
+
export * from './fpmmFactory';
|
|
6
|
+
export * from './fpmm';
|
|
7
|
+
export * from './virtualPoolFactory';
|
|
8
|
+
export * from './virtualPool';
|
|
9
|
+
export * from './router';
|
|
10
|
+
export * from './breakerbox';
|
|
11
|
+
export * from './borrowerOperations';
|
|
12
|
+
export * from './troveManager';
|
|
13
|
+
export * from './hintHelpers';
|
|
14
|
+
export * from './sortedTroves';
|
|
15
|
+
export * from './activePool';
|
|
16
|
+
export * from './multiTroveGetter';
|
|
17
|
+
export * from './troveNFT';
|
|
18
|
+
export * from './priceFeed';
|
|
19
|
+
export * from './addressesRegistry';
|
|
20
|
+
export * from './systemParams';
|
|
21
|
+
export * from './liquidityStrategy';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const LIQUIDITY_STRATEGY_ABI = parseAbi([
|
|
3
|
+
'function poolConfigs(address) view returns (bool isToken0Debt, uint32 lastRebalance, uint32 rebalanceCooldown, address protocolFeeRecipient, uint64 liquiditySourceIncentiveExpansion, uint64 protocolIncentiveExpansion, uint64 liquiditySourceIncentiveContraction, uint64 protocolIncentiveContraction)',
|
|
4
|
+
'function determineAction(address pool) view returns ((address pool, (uint256 reserveNum, uint256 reserveDen) reserves, (uint256 oracleNum, uint256 oracleDen, bool poolPriceAbove, uint16 rebalanceThreshold) prices, address token0, address token1, uint64 token0Dec, uint64 token1Dec, bool isToken0Debt, (uint64 liquiditySourceIncentiveExpansion, uint64 protocolIncentiveExpansion, uint64 liquiditySourceIncentiveContraction, uint64 protocolIncentiveContraction) incentives) ctx, (uint8 dir, uint256 amount0Out, uint256 amount1Out, uint256 amountOwedToPool) action)',
|
|
5
|
+
'function rebalance(address pool)',
|
|
6
|
+
]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* MultiTroveGetter ABI for batch trove queries
|
|
4
|
+
*
|
|
5
|
+
* Source: MultiTroveGetter.sol
|
|
6
|
+
* Note: Both functions require `_collIndex` as first param — SDK passes `0n`.
|
|
7
|
+
*/
|
|
8
|
+
export const MULTI_TROVE_GETTER_ABI = parseAbi([
|
|
9
|
+
'function getMultipleSortedTroves(uint256 _collIndex, int256 _startIdx, uint256 _count) view returns ((uint256 id, uint256 entireDebt, uint256 entireColl, uint256 redistBoldDebtGain, uint256 redistCollGain, uint256 accruedInterest, uint256 recordedDebt, uint256 annualInterestRate, uint256 accruedBatchManagementFee, uint256 lastInterestRateAdjTime, uint256 stake, uint256 lastDebtUpdateTime, address interestBatchManager, uint256 batchDebtShares, uint256 snapshotETH, uint256 snapshotBoldDebt)[])',
|
|
10
|
+
'function getDebtPerInterestRateAscending(uint256 _collIndex, uint256 _startId, uint256 _maxIterations) view returns ((address interestBatchManager, uint256 interestRate, uint256 debt)[] data, uint256 currId)',
|
|
11
|
+
]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Deliberate frontend-read shim:
|
|
4
|
+
* `fetchPrice` is non-view in source contracts, but marked `view` here so it can
|
|
5
|
+
* be called via `readContract`/`eth_call` without write simulation.
|
|
6
|
+
*/
|
|
7
|
+
export const PRICE_FEED_ABI = parseAbi([
|
|
8
|
+
'function fetchPrice() view returns (uint256)',
|
|
9
|
+
'function lastValidPrice() view returns (uint256)',
|
|
10
|
+
'function isL2SequencerUp() view returns (bool)',
|
|
11
|
+
'function isShutdown() view returns (bool)',
|
|
12
|
+
]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
// Legacy Reserve (Celo)
|
|
3
|
+
export const RESERVE_ABI = parseAbi([
|
|
4
|
+
'function getTokens() view returns (address[])',
|
|
5
|
+
'function isToken(address) view returns (bool)',
|
|
6
|
+
'function isCollateralAsset(address) view returns (bool)',
|
|
7
|
+
]);
|
|
8
|
+
// ReserveV2 (Monad)
|
|
9
|
+
export const RESERVE_V2_ABI = parseAbi([
|
|
10
|
+
'function getStableAssets() view returns (address[])',
|
|
11
|
+
'function getCollateralAssets() view returns (address[])',
|
|
12
|
+
'function isStableAsset(address) view returns (bool)',
|
|
13
|
+
'function isCollateralAsset(address) view returns (bool)',
|
|
14
|
+
]);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const ROUTER_ABI = parseAbi([
|
|
3
|
+
// Swap operations
|
|
4
|
+
'function getAmountsOut(uint256 amountIn, Route[] memory routes) view returns (uint256[] memory amounts)',
|
|
5
|
+
'function swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, Route[] calldata routes, address to, uint256 deadline) returns (uint256[] memory amounts)',
|
|
6
|
+
// Basic liquidity operations
|
|
7
|
+
'function addLiquidity(address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256 amountA, uint256 amountB, uint256 liquidity)',
|
|
8
|
+
'function removeLiquidity(address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256 amountA, uint256 amountB)',
|
|
9
|
+
'function quoteAddLiquidity(address tokenA, address tokenB, address _factory, uint256 amountADesired, uint256 amountBDesired) view returns (uint256 amountA, uint256 amountB, uint256 liquidity)',
|
|
10
|
+
'function quoteRemoveLiquidity(address tokenA, address tokenB, address _factory, uint256 liquidity) view returns (uint256 amountA, uint256 amountB)',
|
|
11
|
+
// Zap operations
|
|
12
|
+
'function zapIn(address tokenIn, uint256 amountInA, uint256 amountInB, Zap calldata zapInPool, Route[] calldata routesA, Route[] calldata routesB, address to) payable returns (uint256 liquidity)',
|
|
13
|
+
'function zapOut(address tokenOut, uint256 liquidity, Zap calldata zapOutPool, Route[] calldata routesA, Route[] calldata routesB)',
|
|
14
|
+
'function generateZapInParams(address tokenA, address tokenB, address _factory, uint256 amountInA, uint256 amountInB, Route[] calldata routesA, Route[] calldata routesB) view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin)',
|
|
15
|
+
'function generateZapOutParams(address tokenA, address tokenB, address _factory, uint256 liquidity, Route[] calldata routesA, Route[] calldata routesB) view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin)',
|
|
16
|
+
// Structs
|
|
17
|
+
'struct Route { address from; address to; address factory; }',
|
|
18
|
+
'struct Zap { address tokenA; address tokenB; address factory; uint256 amountOutMinA; uint256 amountOutMinB; uint256 amountAMin; uint256 amountBMin; }',
|
|
19
|
+
// Custom errors (Router)
|
|
20
|
+
'error ETHTransferFailed()',
|
|
21
|
+
'error Expired()',
|
|
22
|
+
'error InsufficientAmount()',
|
|
23
|
+
'error InsufficientAmountA()',
|
|
24
|
+
'error InsufficientAmountB()',
|
|
25
|
+
'error InsufficientAmountADesired()',
|
|
26
|
+
'error InsufficientAmountBDesired()',
|
|
27
|
+
'error InsufficientAmountAOptimal()',
|
|
28
|
+
'error InsufficientLiquidity()',
|
|
29
|
+
'error InsufficientOutputAmount()',
|
|
30
|
+
'error InvalidAmountInForETHDeposit()',
|
|
31
|
+
'error InvalidTokenInForETHDeposit()',
|
|
32
|
+
'error InvalidPath()',
|
|
33
|
+
'error InvalidRouteA()',
|
|
34
|
+
'error InvalidRouteB()',
|
|
35
|
+
'error OnlyWETH()',
|
|
36
|
+
'error PoolDoesNotExist()',
|
|
37
|
+
'error PoolFactoryDoesNotExist()',
|
|
38
|
+
'error SameAddresses()',
|
|
39
|
+
'error ZeroAddress()',
|
|
40
|
+
'error FXMarketClosed()',
|
|
41
|
+
]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const SORTED_TROVES_ABI = parseAbi([
|
|
3
|
+
'function findInsertPosition(uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) view returns (uint256, uint256)',
|
|
4
|
+
'function getSize() view returns (uint256)',
|
|
5
|
+
'function getFirst() view returns (uint256)',
|
|
6
|
+
'function getLast() view returns (uint256)',
|
|
7
|
+
'function getNext(uint256 _id) view returns (uint256)',
|
|
8
|
+
'function getPrev(uint256 _id) view returns (uint256)',
|
|
9
|
+
'function contains(uint256 _id) view returns (bool)',
|
|
10
|
+
'function isEmpty() view returns (bool)',
|
|
11
|
+
]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const SYSTEM_PARAMS_ABI = parseAbi([
|
|
3
|
+
'function CCR() view returns (uint256)',
|
|
4
|
+
'function MCR() view returns (uint256)',
|
|
5
|
+
'function SCR() view returns (uint256)',
|
|
6
|
+
'function BCR() view returns (uint256)',
|
|
7
|
+
'function MIN_DEBT() view returns (uint256)',
|
|
8
|
+
'function ETH_GAS_COMPENSATION() view returns (uint256)',
|
|
9
|
+
'function MIN_ANNUAL_INTEREST_RATE() view returns (uint256)',
|
|
10
|
+
]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const TROVE_MANAGER_ABI = parseAbi([
|
|
3
|
+
'function getLatestTroveData(uint256 _troveId) view returns ((uint256 entireDebt, uint256 entireColl, uint256 redistBoldDebtGain, uint256 redistCollGain, uint256 accruedInterest, uint256 recordedDebt, uint256 annualInterestRate, uint256 weightedRecordedDebt, uint256 accruedBatchManagementFee, uint256 lastInterestRateAdjTime))',
|
|
4
|
+
'function getTroveStatus(uint256 _troveId) view returns (uint8)',
|
|
5
|
+
'function getTroveAnnualInterestRate(uint256 _troveId) view returns (uint256)',
|
|
6
|
+
'function Troves(uint256 _id) view returns (uint256 debt, uint256 coll, uint256 stake, uint8 status, uint64 arrayIndex, uint64 lastDebtUpdateTime, uint64 lastInterestRateAdjTime, uint256 annualInterestRate, address interestBatchManager, uint256 batchDebtShares)',
|
|
7
|
+
'function getCurrentICR(uint256 _troveId, uint256 _price) view returns (uint256)',
|
|
8
|
+
'function getTroveIdsCount() view returns (uint256)',
|
|
9
|
+
'function getTroveFromTroveIdsArray(uint256 _index) view returns (uint256)',
|
|
10
|
+
'function shutdownTime() view returns (uint256)',
|
|
11
|
+
// Custom errors
|
|
12
|
+
'error EmptyData()',
|
|
13
|
+
'error NothingToLiquidate()',
|
|
14
|
+
'error CallerNotBorrowerOperations()',
|
|
15
|
+
'error CallerNotCollateralRegistry()',
|
|
16
|
+
'error OnlyOneTroveLeft()',
|
|
17
|
+
'error NotShutDown()',
|
|
18
|
+
'error ZeroAmount()',
|
|
19
|
+
'error NotEnoughBoldBalance()',
|
|
20
|
+
'error MinCollNotReached(uint256 _coll)',
|
|
21
|
+
'error BatchSharesRatioTooHigh()',
|
|
22
|
+
'error L2SequencerDown()',
|
|
23
|
+
]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const VIRTUAL_POOL_ABI = parseAbi([
|
|
3
|
+
'function protocolFee() view returns (uint256)',
|
|
4
|
+
'function getReserves() view returns (uint256, uint256, uint256)',
|
|
5
|
+
'function metadata() view returns (uint256, uint256, uint256, uint256, address, address)',
|
|
6
|
+
'function tokens() view returns (address, address)',
|
|
7
|
+
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const VIRTUAL_POOL_FACTORY_ABI = parseAbi([
|
|
3
|
+
'function getOrPrecomputeProxyAddress(address token0, address token1) view returns (address)',
|
|
4
|
+
'function isPool(address pool) view returns (bool)',
|
|
5
|
+
'function getAllPools() view returns (address[])',
|
|
6
|
+
// Custom errors
|
|
7
|
+
'error InvalidExchangeProvider()',
|
|
8
|
+
'error InvalidExchangeId()',
|
|
9
|
+
'error VirtualPoolAlreadyExistsForThisPair()',
|
|
10
|
+
'error InvalidCreateXBytecode()',
|
|
11
|
+
'error PoolNotFound()',
|
|
12
|
+
'error PoolAlreadyDeprecated()',
|
|
13
|
+
]);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ChainId } from './chainId';
|
|
2
|
+
export const addresses = {
|
|
3
|
+
[ChainId.CELO]: {
|
|
4
|
+
// Oracles & Breakers
|
|
5
|
+
BreakerBox: '0x303ED1df62Fa067659B586EbEe8De0EcE824Ab39',
|
|
6
|
+
MedianDeltaBreaker: '0x49349F92D2B17d491e42C8fdB02D19f072F9B5D9',
|
|
7
|
+
SortedOracles: '0xefB84935239dAcdecF7c5bA76d8dE40b077B7b33',
|
|
8
|
+
ValueDeltaBreaker: '0x4DBC33B3abA78475A5AA4BC7A5B11445d387BF68',
|
|
9
|
+
// DEX
|
|
10
|
+
BiPoolManager: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
|
|
11
|
+
Broker: '0x777A8255cA72412f0d706dc03C9D1987306B4CaD',
|
|
12
|
+
ConstantProductPricingModule: '0x0c07126d0CB30E66eF7553Cc7C37143B4f06DddB',
|
|
13
|
+
ConstantSumPricingModule: '0xDebED1F6f6ce9F6e73AA25F95acBFFE2397550Fb',
|
|
14
|
+
MentoRouter: '0xbe729350f8cdfc19db6866e8579841188ee57f67',
|
|
15
|
+
Reserve: '0x9380fA34Fd9e4Fd14c06305fd7B6199089eD4eb9',
|
|
16
|
+
// Stable Tokens
|
|
17
|
+
StableToken: '0x765DE816845861e75A25fCA122bb6898B8B1282a', // USDm
|
|
18
|
+
// Governance
|
|
19
|
+
Airgrab: '0x7D8E73deafDBAfc98fDBe7974168cFA6d8B9AE0C',
|
|
20
|
+
Emission: '0x5C789592E2611df1873b46D394c69f75faB99778',
|
|
21
|
+
Locking: '0x001Bb66636dCd149A1A2bA8C50E408BdDd80279C',
|
|
22
|
+
MentoGovernor: '0x47036d78bB3169b4F5560dD77BF93f4412A59852',
|
|
23
|
+
MentoToken: '0x7FF62f59e3e89EA34163EA1458EEBCc81177Cfb6',
|
|
24
|
+
TimelockController: '0x890DB8A597940165901372Dd7DB61C9f246e2147',
|
|
25
|
+
// V3
|
|
26
|
+
FPMMFactory: '0xa849b475FE5a4B5C9C3280152c7a1945b907613b',
|
|
27
|
+
VirtualPoolFactory: '0x22abd4ADF6aab38aC1022352d496A07Acee5aCB3',
|
|
28
|
+
Router: '0x4861840C2EfB2b98312B0aE34d86fD73E8f9B6f6',
|
|
29
|
+
ReserveLiquidityStrategy: '0xa0fB8b16ce6AF3634fF9F3f4F40E49E1C1ae4f0B',
|
|
30
|
+
CDPLiquidityStrategy: '0x4e78BD9565341EAbe99cDC024acB044d9BDcB985',
|
|
31
|
+
},
|
|
32
|
+
[ChainId.MONAD_TESTNET]: {
|
|
33
|
+
BreakerBox: '0x88869E30609D2C0E4032463D713328C6f541878e',
|
|
34
|
+
MedianDeltaBreaker: '0xf923C884F319b8866F67C5719A80E5cB4D0FAF2c',
|
|
35
|
+
SortedOracles: '0x85ed9ac57827132B8F60938F3165BC139E1F53cd',
|
|
36
|
+
ValueDeltaBreaker: '0xbbD0D093F5F11D16D4456FBd6229c9a3b70B8Aaf',
|
|
37
|
+
Reserve: '0xbCdc1D0b92DfceEaa0FcD0a0D53355F4bF1DB8a7',
|
|
38
|
+
StableToken: '0x5eCc03111ad2A78F981A108759bc73BAE2AB31bc', // USDm
|
|
39
|
+
FPMMFactory: '0x353ED52bF8482027C0e0b9e3c0e5d96A9F680980',
|
|
40
|
+
Router: '0xcf6cD45210b3ffE3cA28379C4683F1e60D0C2CCd',
|
|
41
|
+
ReserveLiquidityStrategy: '0x734bb3251Ec3f1A83f8f2A8609bcEF649D54EbF8',
|
|
42
|
+
OpenLiquidityStrategy: '0xCCd2aD0603a08EBc14D223a983171ef18192e8c9',
|
|
43
|
+
},
|
|
44
|
+
[ChainId.MONAD]: {
|
|
45
|
+
BreakerBox: '0x9fc1E0d10fb38954Da385B8B25aB2BbaF3241722',
|
|
46
|
+
MedianDeltaBreaker: '0x3E4F2Bca4f7192Be4C3c5E5bD4840F2E90a8Ba84',
|
|
47
|
+
SortedOracles: '0x6f92C745346057a61b259579256159458a0a6A92',
|
|
48
|
+
ValueDeltaBreaker: '0xca2e7563dfC30bc94687F3deAcF682E1dBAffA13',
|
|
49
|
+
Reserve: '0x4255Cf38e51516766180b33122029A88Cb853806',
|
|
50
|
+
StableToken: '0xBC69212B8E4d445b2307C9D32dD68E2A4Df00115', // USDm
|
|
51
|
+
FPMMFactory: '0xa849b475FE5a4B5C9C3280152c7a1945b907613b',
|
|
52
|
+
Router: '0x4861840C2EfB2b98312B0aE34d86fD73E8f9B6f6',
|
|
53
|
+
ReserveLiquidityStrategy: '0xa0fB8b16ce6AF3634fF9F3f4F40E49E1C1ae4f0B',
|
|
54
|
+
OpenLiquidityStrategy: '0x54e2Ae8c8448912E17cE0b2453bAFB7B0D80E40f',
|
|
55
|
+
},
|
|
56
|
+
[ChainId.CELO_SEPOLIA]: {
|
|
57
|
+
// Oracles & Breakers
|
|
58
|
+
BreakerBox: '0x578bD46003B9D3fd4c3C3f47c98B329562a6a1dE',
|
|
59
|
+
MedianDeltaBreaker: '0xd29B4e743F7B84D63fBF9149B6D983DF2eF5C952',
|
|
60
|
+
SortedOracles: '0xfaa7Ca2B056E60F6733aE75AA0709140a6eAfD20',
|
|
61
|
+
ValueDeltaBreaker: '0x03CDf2966185Eb0b980f2481Ad386B8aFdAB4534',
|
|
62
|
+
// DEX
|
|
63
|
+
BiPoolManager: '0xeCB3C656C131fCd9bB8D1d80898716bD684feb78',
|
|
64
|
+
Broker: '0xB9Ae2065142EB79b6c5EB1E8778F883fad6B07Ba',
|
|
65
|
+
ConstantProductPricingModule: '0x2584a5835e3aE7E901e6462E1de06920c2C68028',
|
|
66
|
+
ConstantSumPricingModule: '0x3b199d9EbEbe509bb711BfFb455c2d79102A9602',
|
|
67
|
+
MentoRouter: '0x8e4Fb12D86D5DF911086a9153e79CA27e0c96156',
|
|
68
|
+
Reserve: '0x2bC2D48735842924C508468C5A02580aD4F6d99A',
|
|
69
|
+
// Governance
|
|
70
|
+
Emission: '0x3C1BEA0F35b5dcAc1065CA9b3b6877657dEa4A69',
|
|
71
|
+
Locking: '0xB72320fC501cb30E55bAF0DA48c20b11fAc9f79D',
|
|
72
|
+
MentoGovernor: '0x23173Ac37b8E4e5a60d787aC543B3F51e8f398b4',
|
|
73
|
+
MentoToken: '0x07867fd40EB56b4380bE39c88D0a7EA59Aa99A20',
|
|
74
|
+
TimelockController: '0x74c44Be99937815173A3C56274331e0A05611e0D',
|
|
75
|
+
// V3
|
|
76
|
+
FPMMFactory: '0x353ED52bF8482027C0e0b9e3c0e5d96A9F680980',
|
|
77
|
+
VirtualPoolFactory: '0x887955f28723B0e9Bddc358448CB5B1FDe692da4',
|
|
78
|
+
Router: '0xcf6cD45210b3ffE3cA28379C4683F1e60D0C2CCd',
|
|
79
|
+
ReserveLiquidityStrategy: '0x734bb3251Ec3f1A83f8f2A8609bcEF649D54EbF8',
|
|
80
|
+
CDPLiquidityStrategy: '0x065AE7D4e207C8f4dca112D0B79E668cc7e93e03',
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Get the address of a contract for a given chain, returning undefined if not found.
|
|
85
|
+
* Use this when the contract may not be deployed on the target chain.
|
|
86
|
+
*/
|
|
87
|
+
export function tryGetContractAddress(chainId, contractName) {
|
|
88
|
+
const addressesForChain = addresses[chainId];
|
|
89
|
+
if (!addressesForChain) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
return addressesForChain[contractName];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the address of a contract for a given chain
|
|
96
|
+
* @param chainId - The chain ID
|
|
97
|
+
* @param contractName - The contract name
|
|
98
|
+
* @returns The contract address
|
|
99
|
+
* @throws Error if the address is not found for the given chain
|
|
100
|
+
*/
|
|
101
|
+
export function getContractAddress(chainId, contractName) {
|
|
102
|
+
const address = tryGetContractAddress(chainId, contractName);
|
|
103
|
+
if (!address) {
|
|
104
|
+
throw new Error(`Address not found for contract ${contractName} on chain ID ${chainId}`);
|
|
105
|
+
}
|
|
106
|
+
return address;
|
|
107
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Compile-time constants from Constants.sol
|
|
2
|
+
export const MAX_ANNUAL_INTEREST_RATE = 2500000000000000000n; // 250%
|
|
3
|
+
export const UPFRONT_INTEREST_PERIOD = 604800; // 7 days in seconds
|
|
4
|
+
export const INTEREST_RATE_ADJ_COOLDOWN = 604800; // 7 days in seconds
|
|
5
|
+
// UI-level constants from Bold frontend (constants.ts)
|
|
6
|
+
export const MAX_LTV_ALLOWED_RATIO = 916n; // 91.6% (per-mille)
|
|
7
|
+
export const LTV_RISK_MEDIUM = 540n; // 54% of maxLtv
|
|
8
|
+
export const LTV_RISK_HIGH = 730n; // 73% of maxLtv
|
|
9
|
+
export const REDEMPTION_RISK_MEDIUM = 50n; // 5% of total debt
|
|
10
|
+
export const REDEMPTION_RISK_LOW = 600n; // 60% of total debt
|
|
11
|
+
// Single branch index for Mento
|
|
12
|
+
export const COLL_INDEX = 0n;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ChainId } from './chainId';
|
|
2
|
+
/**
|
|
3
|
+
* Known AddressesRegistry contracts per chain, keyed by debt token symbol.
|
|
4
|
+
* Each registry is the entry point for one Bold deployment.
|
|
5
|
+
*/
|
|
6
|
+
export const borrowRegistries = {
|
|
7
|
+
[ChainId.CELO]: {
|
|
8
|
+
GBPm: '0xB3136DBadB14Ab587FFa91545538126938Fe0C6E',
|
|
9
|
+
CHFm: '0xCa70801D91576d069190d1D4CFDDEbdc237A4537',
|
|
10
|
+
JPYm: '0x8f99Aac2FE09A1390617D4AcDD1519f775eE931A',
|
|
11
|
+
},
|
|
12
|
+
[ChainId.CELO_SEPOLIA]: {
|
|
13
|
+
GBPm: '0x8b33D626E8d79388889d404fBC515Ed131c9508e',
|
|
14
|
+
CHFm: '0x1e3CCCC62cEBd9Bf2a26Ba512E3abee086816c58',
|
|
15
|
+
JPYm: '0x812e5ccEC5E55B81F4270898FDF1C916e3a284Fb',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export function getBorrowRegistry(chainId, debtTokenSymbol) {
|
|
19
|
+
const registries = borrowRegistries[chainId];
|
|
20
|
+
if (!registries) {
|
|
21
|
+
throw new Error(`No borrow registries found for chain ID ${chainId}`);
|
|
22
|
+
}
|
|
23
|
+
const registry = registries[debtTokenSymbol];
|
|
24
|
+
if (!registry) {
|
|
25
|
+
const available = Object.keys(registries).join(', ') || 'none';
|
|
26
|
+
throw new Error(`No borrow registry found for "${debtTokenSymbol}" on chain ${chainId}. Available: ${available}`);
|
|
27
|
+
}
|
|
28
|
+
return registry;
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var ChainId;
|
|
2
|
+
(function (ChainId) {
|
|
3
|
+
ChainId[ChainId["CELO"] = 42220] = "CELO";
|
|
4
|
+
ChainId[ChainId["CELO_SEPOLIA"] = 11142220] = "CELO_SEPOLIA";
|
|
5
|
+
ChainId[ChainId["MONAD_TESTNET"] = 10143] = "MONAD_TESTNET";
|
|
6
|
+
ChainId[ChainId["MONAD"] = 143] = "MONAD";
|
|
7
|
+
})(ChainId || (ChainId = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const GOVERNANCEFACTORY = 'GovernanceFactory';
|
|
2
|
+
export const AIRGRAB = 'Airgrab';
|
|
3
|
+
export const EMISSION = 'Emission';
|
|
4
|
+
export const MENTOGOVERNOR = 'MentoGovernor';
|
|
5
|
+
export const MENTOTOKEN = 'MentoToken';
|
|
6
|
+
export const TIMELOCKCONTROLLER = 'TimelockController';
|
|
7
|
+
export const LOCKING = 'Locking';
|
|
8
|
+
export const BROKER = 'Broker';
|
|
9
|
+
export const BIPOOLMANAGER = 'BiPoolManager';
|
|
10
|
+
export const BREAKERBOX = 'BreakerBox';
|
|
11
|
+
export const RESERVE = 'Reserve';
|
|
12
|
+
export const CONSTANTSUM = 'ConstantSumPricingModule';
|
|
13
|
+
export const CONSTANTPRODUCT = 'ConstantProductPricingModule';
|
|
14
|
+
export const MEDIANDELTA = 'MedianDeltaBreaker';
|
|
15
|
+
export const VALUEDELTA = 'ValueDeltaBreaker';
|
|
16
|
+
export const STABLETOKEN = 'StableToken';
|
|
17
|
+
export const STABLETOKNEUR = 'StableTokenEUR';
|
|
18
|
+
export const STABLETOKENBRL = 'StableTokenBRL';
|
|
19
|
+
export const STABLETOKENXOF = 'StableTokenXOF';
|
|
20
|
+
export const SORTEDORACLES = 'SortedOracles';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Mento SDK errors.
|
|
3
|
+
* Provides consistent error naming and proper prototype chain setup.
|
|
4
|
+
*/
|
|
5
|
+
export class MentoError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = this.constructor.name;
|
|
9
|
+
// Maintains proper prototype chain for instanceof checks
|
|
10
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MentoError } from './base';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when the FX market is closed and oracle prices are unavailable.
|
|
4
|
+
* The OracleAdapter reverts with FXMarketClosed() (sig 0xa407143a) during market closure.
|
|
5
|
+
*/
|
|
6
|
+
export class FXMarketClosedError extends MentoError {
|
|
7
|
+
constructor() {
|
|
8
|
+
super('FX market is currently closed. Swap quotes are unavailable until the market reopens.');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MentoError } from './base';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when no tradable route exists between two tokens.
|
|
4
|
+
*/
|
|
5
|
+
export class RouteNotFoundError extends MentoError {
|
|
6
|
+
constructor(tokenIn, tokenOut) {
|
|
7
|
+
super(`No route found for tokens ${tokenIn} and ${tokenOut}. They may not have a tradable path.`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when no executable zap-out route exists for the requested amount.
|
|
12
|
+
*/
|
|
13
|
+
export class ZapOutRouteNotViableError extends MentoError {
|
|
14
|
+
constructor(poolAddress, tokenOut) {
|
|
15
|
+
super(`No viable zap-out route for pool ${poolAddress} to ${tokenOut}. ` +
|
|
16
|
+
'Try reducing the amount or removing liquidity in balanced mode.');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './contractAddresses';
|
|
2
|
+
export * from './transaction';
|
|
3
|
+
export * from './token';
|
|
4
|
+
export * from './route';
|
|
5
|
+
export * from './pool';
|
|
6
|
+
export * from './tradingMode';
|
|
7
|
+
export * from './tradingLimits';
|
|
8
|
+
export * from './liquidity';
|
|
9
|
+
export * from './borrow';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of liquidity pools supported in the Mento protocol
|
|
3
|
+
*/
|
|
4
|
+
export var PoolType;
|
|
5
|
+
(function (PoolType) {
|
|
6
|
+
/** FPMM (Fixed Product Market Maker) pools - v3 native pools */
|
|
7
|
+
PoolType["FPMM"] = "FPMM";
|
|
8
|
+
/** Virtual pools - wrapper around v2 BiPoolManager exchanges */
|
|
9
|
+
PoolType["Virtual"] = "Virtual";
|
|
10
|
+
})(PoolType || (PoolType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trading modes for rate feeds in the BreakerBox circuit breaker.
|
|
3
|
+
*
|
|
4
|
+
* The BreakerBox uses a bitmask approach where multiple breakers can
|
|
5
|
+
* contribute to the final trading mode. In practice:
|
|
6
|
+
* - 0 = Bidirectional (trading enabled)
|
|
7
|
+
* - Any non-zero value = Trading suspended
|
|
8
|
+
*
|
|
9
|
+
* For SDK consumers, use isTradingEnabled() helper to check if trading
|
|
10
|
+
* is allowed.
|
|
11
|
+
*/
|
|
12
|
+
export var TradingMode;
|
|
13
|
+
(function (TradingMode) {
|
|
14
|
+
/** Bidirectional trading is enabled (normal operation) */
|
|
15
|
+
TradingMode[TradingMode["BIDIRECTIONAL"] = 0] = "BIDIRECTIONAL";
|
|
16
|
+
/** Trading is suspended (circuit breaker tripped) - any non-zero value */
|
|
17
|
+
TradingMode[TradingMode["SUSPENDED"] = 1] = "SUSPENDED";
|
|
18
|
+
})(TradingMode || (TradingMode = {}));
|
|
19
|
+
/**
|
|
20
|
+
* Check if trading is enabled for a given trading mode.
|
|
21
|
+
* @param mode - The trading mode value from BreakerBox
|
|
22
|
+
* @returns true if trading is enabled (mode === 0)
|
|
23
|
+
*/
|
|
24
|
+
export function isTradingEnabled(mode) {
|
|
25
|
+
return mode === TradingMode.BIDIRECTIONAL;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|