@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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* BorrowerOperations ABI for Bold protocol trove 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 BORROWER_OPERATIONS_ABI = parseAbi([
|
|
10
|
+
// Core trove operations
|
|
11
|
+
'function openTrove(address _owner, uint256 _ownerIndex, uint256 _ETHAmount, uint256 _boldAmount, uint256 _upperHint, uint256 _lowerHint, uint256 _annualInterestRate, uint256 _maxUpfrontFee, address _addManager, address _removeManager, address _receiver) returns (uint256)',
|
|
12
|
+
'function openTroveAndJoinInterestBatchManager((address owner, uint256 ownerIndex, uint256 collAmount, uint256 boldAmount, uint256 upperHint, uint256 lowerHint, address interestBatchManager, uint256 maxUpfrontFee, address addManager, address removeManager, address receiver) _params) returns (uint256)',
|
|
13
|
+
'function addColl(uint256 _troveId, uint256 _ETHAmount)',
|
|
14
|
+
'function withdrawColl(uint256 _troveId, uint256 _amount)',
|
|
15
|
+
'function withdrawBold(uint256 _troveId, uint256 _amount, uint256 _maxUpfrontFee)',
|
|
16
|
+
'function repayBold(uint256 _troveId, uint256 _amount)',
|
|
17
|
+
'function closeTrove(uint256 _troveId)',
|
|
18
|
+
'function adjustTrove(uint256 _troveId, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool isDebtIncrease, uint256 _maxUpfrontFee)',
|
|
19
|
+
'function adjustZombieTrove(uint256 _troveId, uint256 _collChange, bool _isCollIncrease, uint256 _boldChange, bool _isDebtIncrease, uint256 _upperHint, uint256 _lowerHint, uint256 _maxUpfrontFee)',
|
|
20
|
+
'function adjustTroveInterestRate(uint256 _troveId, uint256 _newAnnualInterestRate, uint256 _upperHint, uint256 _lowerHint, uint256 _maxUpfrontFee)',
|
|
21
|
+
'function applyPendingDebt(uint256 _troveId, uint256 _lowerHint, uint256 _upperHint)',
|
|
22
|
+
'function claimCollateral()',
|
|
23
|
+
// Batch manager operations
|
|
24
|
+
'function setInterestBatchManager(uint256 _troveId, address _newBatchManager, uint256 _upperHint, uint256 _lowerHint, uint256 _maxUpfrontFee)',
|
|
25
|
+
'function removeFromBatch(uint256 _troveId, uint256 _newAnnualInterestRate, uint256 _upperHint, uint256 _lowerHint, uint256 _maxUpfrontFee)',
|
|
26
|
+
'function switchBatchManager(uint256 _troveId, uint256 _removeUpperHint, uint256 _removeLowerHint, address _newBatchManager, uint256 _addUpperHint, uint256 _addLowerHint, uint256 _maxUpfrontFee)',
|
|
27
|
+
// Individual delegate
|
|
28
|
+
'function setInterestIndividualDelegate(uint256 _troveId, address _delegate, uint128 _minInterestRate, uint128 _maxInterestRate, uint256 _newAnnualInterestRate, uint256 _upperHint, uint256 _lowerHint, uint256 _maxUpfrontFee, uint256 _minInterestRateChangePeriod)',
|
|
29
|
+
'function removeInterestIndividualDelegate(uint256 _troveId)',
|
|
30
|
+
// View functions
|
|
31
|
+
'function hasBeenShutDown() view returns (bool)',
|
|
32
|
+
'function interestBatchManagerOf(uint256 _troveId) view returns (address)',
|
|
33
|
+
'function getInterestBatchManager(address _account) view returns ((uint128 minInterestRate, uint128 maxInterestRate, uint256 minInterestRateChangePeriod))',
|
|
34
|
+
'function checkBatchManagerExists(address _batchManager) view returns (bool)',
|
|
35
|
+
'function getInterestIndividualDelegateOf(uint256 _troveId) view returns ((address account, uint128 minInterestRate, uint128 maxInterestRate, uint256 minInterestRateChangePeriod))',
|
|
36
|
+
// Inherited view functions from LiquityBase
|
|
37
|
+
'function getEntireBranchDebt() view returns (uint256)',
|
|
38
|
+
'function getEntireBranchColl() view returns (uint256)',
|
|
39
|
+
'function systemParams() view returns (address)',
|
|
40
|
+
'function CCR() view returns (uint256)',
|
|
41
|
+
'function MCR() view returns (uint256)',
|
|
42
|
+
// Custom errors (BorrowerOperations.sol)
|
|
43
|
+
'error IsShutDown()',
|
|
44
|
+
'error TCRNotBelowSCR()',
|
|
45
|
+
'error ZeroAdjustment()',
|
|
46
|
+
'error NotOwnerNorInterestManager()',
|
|
47
|
+
'error TroveInBatch()',
|
|
48
|
+
'error TroveNotInBatch()',
|
|
49
|
+
'error InterestNotInRange()',
|
|
50
|
+
'error BatchInterestRateChangePeriodNotPassed()',
|
|
51
|
+
'error DelegateInterestRateChangePeriodNotPassed()',
|
|
52
|
+
'error TroveExists()',
|
|
53
|
+
'error TroveNotOpen()',
|
|
54
|
+
'error TroveNotActive()',
|
|
55
|
+
'error TroveNotZombie()',
|
|
56
|
+
'error TroveWithZeroDebt()',
|
|
57
|
+
'error UpfrontFeeTooHigh()',
|
|
58
|
+
'error ICRBelowMCR()',
|
|
59
|
+
'error ICRBelowMCRPlusBCR()',
|
|
60
|
+
'error RepaymentNotMatchingCollWithdrawal()',
|
|
61
|
+
'error TCRBelowCCR()',
|
|
62
|
+
'error DebtBelowMin()',
|
|
63
|
+
'error CollWithdrawalTooHigh()',
|
|
64
|
+
'error NotEnoughBoldBalance()',
|
|
65
|
+
'error InterestRateTooLow()',
|
|
66
|
+
'error InterestRateTooHigh()',
|
|
67
|
+
'error InterestRateNotNew()',
|
|
68
|
+
'error InvalidInterestBatchManager()',
|
|
69
|
+
'error BatchManagerExists()',
|
|
70
|
+
'error BatchManagerNotNew()',
|
|
71
|
+
'error NewFeeNotLower()',
|
|
72
|
+
'error CallerNotTroveManager()',
|
|
73
|
+
'error CallerNotPriceFeed()',
|
|
74
|
+
'error CallerNotSelf()',
|
|
75
|
+
'error MinGeMax()',
|
|
76
|
+
'error AnnualManagementFeeTooHigh()',
|
|
77
|
+
'error MinInterestRateChangePeriodTooLow()',
|
|
78
|
+
'error NewOracleFailureDetected()',
|
|
79
|
+
'error BatchSharesRatioTooLow()',
|
|
80
|
+
// Custom errors (inherited from AddRemoveManagers)
|
|
81
|
+
'error EmptyManager()',
|
|
82
|
+
'error NotBorrower()',
|
|
83
|
+
'error NotOwnerNorAddManager()',
|
|
84
|
+
'error NotOwnerNorRemoveManager()',
|
|
85
|
+
]);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
export const BROKER_ABI = parseAbi([
|
|
3
|
+
'function tradingLimitsConfig(bytes32) view returns (uint32 timestep0, uint32 timestep1, int48 limit0, int48 limit1, int48 limitGlobal, uint8 flags)',
|
|
4
|
+
'function tradingLimitsState(bytes32) view returns (uint32 lastUpdated0, uint32 lastUpdated1, int48 netflow0, int48 netflow1, int48 netflowGlobal)',
|
|
5
|
+
]);
|
|
@@ -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,119 @@
|
|
|
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.POLYGON_AMOY]: {
|
|
57
|
+
BreakerBox: '0x88869E30609D2C0E4032463D713328C6f541878e',
|
|
58
|
+
MedianDeltaBreaker: '0xf923C884F319b8866F67C5719A80E5cB4D0FAF2c',
|
|
59
|
+
SortedOracles: '0x85ed9ac57827132B8F60938F3165BC139E1F53cd',
|
|
60
|
+
ValueDeltaBreaker: '0xbbD0D093F5F11D16D4456FBd6229c9a3b70B8Aaf',
|
|
61
|
+
Reserve: '0xbCdc1D0b92DfceEaa0FcD0a0D53355F4bF1DB8a7',
|
|
62
|
+
StableToken: '0x5eCc03111ad2A78F981A108759bc73BAE2AB31bc', // USDm
|
|
63
|
+
FPMMFactory: '0x353ED52bF8482027C0e0b9e3c0e5d96A9F680980',
|
|
64
|
+
Router: '0xcf6cD45210b3ffE3cA28379C4683F1e60D0C2CCd',
|
|
65
|
+
ReserveLiquidityStrategy: '0x734bb3251Ec3f1A83f8f2A8609bcEF649D54EbF8',
|
|
66
|
+
OpenLiquidityStrategy: '0xCCd2aD0603a08EBc14D223a983171ef18192e8c9',
|
|
67
|
+
},
|
|
68
|
+
[ChainId.CELO_SEPOLIA]: {
|
|
69
|
+
// Oracles & Breakers
|
|
70
|
+
BreakerBox: '0x578bD46003B9D3fd4c3C3f47c98B329562a6a1dE',
|
|
71
|
+
MedianDeltaBreaker: '0xd29B4e743F7B84D63fBF9149B6D983DF2eF5C952',
|
|
72
|
+
SortedOracles: '0xfaa7Ca2B056E60F6733aE75AA0709140a6eAfD20',
|
|
73
|
+
ValueDeltaBreaker: '0x03CDf2966185Eb0b980f2481Ad386B8aFdAB4534',
|
|
74
|
+
// DEX
|
|
75
|
+
BiPoolManager: '0xeCB3C656C131fCd9bB8D1d80898716bD684feb78',
|
|
76
|
+
Broker: '0xB9Ae2065142EB79b6c5EB1E8778F883fad6B07Ba',
|
|
77
|
+
ConstantProductPricingModule: '0x2584a5835e3aE7E901e6462E1de06920c2C68028',
|
|
78
|
+
ConstantSumPricingModule: '0x3b199d9EbEbe509bb711BfFb455c2d79102A9602',
|
|
79
|
+
MentoRouter: '0x8e4Fb12D86D5DF911086a9153e79CA27e0c96156',
|
|
80
|
+
Reserve: '0x2bC2D48735842924C508468C5A02580aD4F6d99A',
|
|
81
|
+
// Governance
|
|
82
|
+
Emission: '0x3C1BEA0F35b5dcAc1065CA9b3b6877657dEa4A69',
|
|
83
|
+
Locking: '0xB72320fC501cb30E55bAF0DA48c20b11fAc9f79D',
|
|
84
|
+
MentoGovernor: '0x23173Ac37b8E4e5a60d787aC543B3F51e8f398b4',
|
|
85
|
+
MentoToken: '0x07867fd40EB56b4380bE39c88D0a7EA59Aa99A20',
|
|
86
|
+
TimelockController: '0x74c44Be99937815173A3C56274331e0A05611e0D',
|
|
87
|
+
// V3
|
|
88
|
+
FPMMFactory: '0x353ED52bF8482027C0e0b9e3c0e5d96A9F680980',
|
|
89
|
+
VirtualPoolFactory: '0x887955f28723B0e9Bddc358448CB5B1FDe692da4',
|
|
90
|
+
Router: '0xcf6cD45210b3ffE3cA28379C4683F1e60D0C2CCd',
|
|
91
|
+
ReserveLiquidityStrategy: '0x734bb3251Ec3f1A83f8f2A8609bcEF649D54EbF8',
|
|
92
|
+
CDPLiquidityStrategy: '0x065AE7D4e207C8f4dca112D0B79E668cc7e93e03',
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Get the address of a contract for a given chain, returning undefined if not found.
|
|
97
|
+
* Use this when the contract may not be deployed on the target chain.
|
|
98
|
+
*/
|
|
99
|
+
export function tryGetContractAddress(chainId, contractName) {
|
|
100
|
+
const addressesForChain = addresses[chainId];
|
|
101
|
+
if (!addressesForChain) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
return addressesForChain[contractName];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the address of a contract for a given chain
|
|
108
|
+
* @param chainId - The chain ID
|
|
109
|
+
* @param contractName - The contract name
|
|
110
|
+
* @returns The contract address
|
|
111
|
+
* @throws Error if the address is not found for the given chain
|
|
112
|
+
*/
|
|
113
|
+
export function getContractAddress(chainId, contractName) {
|
|
114
|
+
const address = tryGetContractAddress(chainId, contractName);
|
|
115
|
+
if (!address) {
|
|
116
|
+
throw new Error(`Address not found for contract ${contractName} on chain ID ${chainId}`);
|
|
117
|
+
}
|
|
118
|
+
return address;
|
|
119
|
+
}
|
|
@@ -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,8 @@
|
|
|
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["POLYGON_AMOY"] = 80002] = "POLYGON_AMOY";
|
|
8
|
+
})(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
|
+
}
|