@mento-protocol/mento-sdk 3.2.2 → 3.2.3
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/cjs/ChainClient.d.ts +9 -0
- package/dist/cjs/ChainClient.js +58 -0
- package/dist/cjs/TestChainClient.d.ts +7 -0
- package/dist/cjs/TestChainClient.js +41 -0
- package/dist/cjs/constants/addresses.d.ts +4 -0
- package/dist/cjs/constants/addresses.js +59 -0
- package/dist/cjs/constants/currencies.d.ts +5 -0
- package/dist/cjs/constants/currencies.js +29 -0
- package/dist/cjs/constants/index.d.ts +4 -0
- package/dist/{services/borrow → cjs/constants}/index.js +4 -4
- package/dist/cjs/constants/tokens.11142220.d.ts +2 -0
- package/dist/cjs/constants/tokens.11142220.js +128 -0
- package/dist/cjs/constants/tokens.42220.d.ts +2 -0
- package/dist/cjs/constants/tokens.42220.js +128 -0
- package/dist/cjs/constants/tokens.d.ts +65 -0
- package/dist/cjs/constants/tokens.js +170 -0
- package/dist/cjs/constants/tradablePairs.11142220.d.ts +2 -0
- package/dist/cjs/constants/tradablePairs.11142220.js +7391 -0
- package/dist/cjs/constants/tradablePairs.42220.d.ts +2 -0
- package/dist/cjs/constants/tradablePairs.42220.js +7391 -0
- package/dist/cjs/constants/tradablePairs.d.ts +16 -0
- package/dist/cjs/constants/tradablePairs.js +53 -0
- package/dist/cjs/enums/chainId.d.ts +4 -0
- package/dist/{core/constants → cjs/enums}/chainId.js +1 -4
- package/dist/cjs/enums/index.d.ts +3 -0
- package/dist/{services/liquidity → cjs/enums}/index.js +3 -2
- package/dist/cjs/enums/proposalState.d.ts +10 -0
- package/dist/cjs/enums/proposalState.js +14 -0
- package/dist/cjs/enums/tradingMode.d.ts +17 -0
- package/dist/cjs/enums/tradingMode.js +21 -0
- package/dist/cjs/governance.d.ts +62 -0
- package/dist/cjs/governance.js +151 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/{core/constants → cjs}/index.js +7 -6
- package/dist/cjs/interfaces/IChainClient.d.ts +6 -0
- package/dist/{core/types/route.js → cjs/interfaces/IChainClient.js} +0 -1
- package/dist/cjs/interfaces/index.d.ts +4 -0
- package/dist/{core/errors → cjs/interfaces}/index.js +4 -4
- package/dist/cjs/interfaces/tradingLimit.d.ts +7 -0
- package/dist/{core/types/token.js → cjs/interfaces/tradingLimit.js} +0 -1
- package/dist/cjs/interfaces/tradingLimitsConfig.d.ts +10 -0
- package/dist/{core/types/borrow.js → cjs/interfaces/tradingLimitsConfig.js} +0 -1
- package/dist/cjs/interfaces/tradingLimitsState.d.ts +9 -0
- package/dist/{core/types/provider.js → cjs/interfaces/tradingLimitsState.js} +0 -1
- package/dist/cjs/limits.d.ts +33 -0
- package/dist/cjs/limits.js +130 -0
- package/dist/cjs/mento.d.ts +287 -0
- package/dist/cjs/mento.js +699 -0
- package/dist/{utils → cjs}/routeUtils.d.ts +93 -84
- package/dist/{utils → cjs}/routeUtils.js +124 -123
- package/dist/cjs/types/contractAddressMap.d.ts +4 -0
- package/dist/cjs/types/contractAddressMap.js +2 -0
- package/dist/cjs/types/contractAddresses.d.ts +23 -0
- package/dist/cjs/types/contractAddresses.js +2 -0
- package/dist/cjs/types/index.d.ts +2 -0
- package/dist/{services/pools → cjs/types}/index.js +2 -2
- package/dist/cjs/utils.d.ts +80 -0
- package/dist/cjs/utils.js +177 -0
- package/dist/esm/ChainClient.d.ts +9 -0
- package/dist/esm/ChainClient.js +54 -0
- package/dist/esm/TestChainClient.d.ts +7 -0
- package/dist/esm/TestChainClient.js +37 -0
- package/dist/esm/constants/addresses.d.ts +4 -0
- package/dist/esm/constants/addresses.js +55 -0
- package/dist/esm/constants/currencies.d.ts +5 -0
- package/dist/esm/constants/currencies.js +26 -0
- package/dist/esm/constants/index.d.ts +4 -0
- package/dist/esm/constants/index.js +4 -0
- package/dist/esm/constants/tokens.11142220.d.ts +2 -0
- package/dist/esm/constants/tokens.11142220.js +125 -0
- package/dist/esm/constants/tokens.42220.d.ts +2 -0
- package/dist/esm/constants/tokens.42220.js +125 -0
- package/dist/esm/constants/tokens.d.ts +65 -0
- package/dist/esm/constants/tokens.js +142 -0
- package/dist/esm/constants/tradablePairs.11142220.d.ts +2 -0
- package/dist/esm/constants/tradablePairs.11142220.js +7388 -0
- package/dist/esm/constants/tradablePairs.42220.d.ts +2 -0
- package/dist/esm/constants/tradablePairs.42220.js +7388 -0
- package/dist/esm/constants/tradablePairs.d.ts +16 -0
- package/dist/esm/constants/tradablePairs.js +26 -0
- package/dist/esm/enums/chainId.d.ts +4 -0
- package/dist/esm/{core/constants → enums}/chainId.js +0 -2
- package/dist/esm/enums/index.d.ts +3 -0
- package/dist/esm/enums/index.js +3 -0
- package/dist/esm/enums/proposalState.d.ts +10 -0
- package/dist/esm/enums/proposalState.js +11 -0
- package/dist/esm/enums/tradingMode.d.ts +17 -0
- package/dist/esm/enums/tradingMode.js +18 -0
- package/dist/esm/governance.d.ts +62 -0
- package/dist/esm/governance.js +147 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +6 -138
- package/dist/esm/interfaces/IChainClient.d.ts +6 -0
- package/dist/esm/interfaces/index.d.ts +4 -0
- package/dist/esm/interfaces/index.js +4 -0
- package/dist/esm/interfaces/tradingLimit.d.ts +7 -0
- package/dist/esm/interfaces/tradingLimitsConfig.d.ts +10 -0
- package/dist/esm/interfaces/tradingLimitsState.d.ts +9 -0
- package/dist/esm/limits.d.ts +33 -0
- package/dist/esm/limits.js +123 -0
- package/dist/esm/mento.d.ts +287 -0
- package/dist/esm/mento.js +671 -0
- package/dist/esm/routeUtils.d.ts +304 -0
- package/dist/esm/{utils/routeUtils.js → routeUtils.js} +116 -115
- package/dist/esm/types/contractAddressMap.d.ts +4 -0
- package/dist/esm/types/contractAddresses.d.ts +23 -0
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/utils.d.ts +80 -0
- package/dist/esm/utils.js +162 -0
- package/package.json +1 -1
- package/dist/cache/routes.d.ts +0 -13
- package/dist/cache/routes.js +0 -13733
- package/dist/cache/tokens.d.ts +0 -68
- package/dist/cache/tokens.js +0 -446
- package/dist/core/abis/activePool.d.ts +0 -2
- package/dist/core/abis/activePool.js +0 -14
- package/dist/core/abis/addressesRegistry.d.ts +0 -2
- package/dist/core/abis/addressesRegistry.js +0 -26
- package/dist/core/abis/bipoolmanager.d.ts +0 -34
- package/dist/core/abis/bipoolmanager.js +0 -72
- package/dist/core/abis/borrowerOperations.d.ts +0 -9
- package/dist/core/abis/borrowerOperations.js +0 -89
- package/dist/core/abis/breakerbox.d.ts +0 -13
- package/dist/core/abis/breakerbox.js +0 -8
- package/dist/core/abis/broker.d.ts +0 -2
- package/dist/core/abis/broker.js +0 -9
- package/dist/core/abis/erc20.d.ts +0 -9
- package/dist/core/abis/erc20.js +0 -21
- package/dist/core/abis/fpmm.d.ts +0 -270
- package/dist/core/abis/fpmm.js +0 -49
- package/dist/core/abis/fpmmFactory.d.ts +0 -85
- package/dist/core/abis/fpmmFactory.js +0 -26
- package/dist/core/abis/hintHelpers.d.ts +0 -2
- package/dist/core/abis/hintHelpers.js +0 -14
- package/dist/core/abis/index.d.ts +0 -22
- package/dist/core/abis/index.js +0 -38
- package/dist/core/abis/liquidityStrategy.d.ts +0 -132
- package/dist/core/abis/liquidityStrategy.js +0 -10
- package/dist/core/abis/multiTroveGetter.d.ts +0 -8
- package/dist/core/abis/multiTroveGetter.js +0 -15
- package/dist/core/abis/priceFeed.d.ts +0 -7
- package/dist/core/abis/priceFeed.js +0 -16
- package/dist/core/abis/pricingmodule.d.ts +0 -2
- package/dist/core/abis/pricingmodule.js +0 -6
- package/dist/core/abis/reserve.d.ts +0 -3
- package/dist/core/abis/reserve.js +0 -18
- package/dist/core/abis/router.d.ts +0 -521
- package/dist/core/abis/router.js +0 -45
- package/dist/core/abis/sortedTroves.d.ts +0 -2
- package/dist/core/abis/sortedTroves.js +0 -15
- package/dist/core/abis/systemParams.d.ts +0 -2
- package/dist/core/abis/systemParams.js +0 -14
- package/dist/core/abis/troveManager.d.ts +0 -2
- package/dist/core/abis/troveManager.js +0 -27
- package/dist/core/abis/troveNFT.d.ts +0 -2
- package/dist/core/abis/troveNFT.js +0 -9
- package/dist/core/abis/virtualPool.d.ts +0 -50
- package/dist/core/abis/virtualPool.js +0 -11
- package/dist/core/abis/virtualPoolFactory.d.ts +0 -59
- package/dist/core/abis/virtualPoolFactory.js +0 -17
- package/dist/core/constants/addresses.d.ts +0 -18
- package/dist/core/constants/addresses.js +0 -113
- package/dist/core/constants/borrowConstants.d.ts +0 -10
- package/dist/core/constants/borrowConstants.js +0 -16
- package/dist/core/constants/borrowRegistries.d.ts +0 -7
- package/dist/core/constants/borrowRegistries.js +0 -30
- package/dist/core/constants/chainId.d.ts +0 -7
- package/dist/core/constants/contractNames.d.ts +0 -21
- package/dist/core/constants/contractNames.js +0 -24
- package/dist/core/constants/index.d.ts +0 -6
- package/dist/core/errors/base.d.ts +0 -8
- package/dist/core/errors/base.js +0 -17
- package/dist/core/errors/index.d.ts +0 -4
- package/dist/core/errors/oracle.d.ts +0 -9
- package/dist/core/errors/oracle.js +0 -15
- package/dist/core/errors/router.d.ts +0 -14
- package/dist/core/errors/router.js +0 -24
- package/dist/core/types/borrow.d.ts +0 -87
- package/dist/core/types/contractAddresses.d.ts +0 -42
- package/dist/core/types/contractAddresses.js +0 -3
- package/dist/core/types/index.d.ts +0 -10
- package/dist/core/types/index.js +0 -26
- package/dist/core/types/liquidity.d.ts +0 -194
- package/dist/core/types/liquidity.js +0 -3
- package/dist/core/types/pool.d.ts +0 -208
- package/dist/core/types/pool.js +0 -14
- package/dist/core/types/provider.d.ts +0 -45
- package/dist/core/types/route.d.ts +0 -62
- package/dist/core/types/token.d.ts +0 -21
- package/dist/core/types/tradingLimits.d.ts +0 -91
- package/dist/core/types/tradingLimits.js +0 -3
- package/dist/core/types/tradingMode.d.ts +0 -24
- package/dist/core/types/tradingMode.js +0 -31
- package/dist/core/types/transaction.d.ts +0 -45
- package/dist/core/types/transaction.js +0 -3
- package/dist/esm/cache/routes.js +0 -13728
- package/dist/esm/cache/tokens.js +0 -438
- package/dist/esm/core/abis/activePool.js +0 -10
- package/dist/esm/core/abis/addressesRegistry.js +0 -22
- package/dist/esm/core/abis/bipoolmanager.js +0 -68
- package/dist/esm/core/abis/borrowerOperations.js +0 -85
- package/dist/esm/core/abis/breakerbox.js +0 -4
- package/dist/esm/core/abis/broker.js +0 -5
- package/dist/esm/core/abis/erc20.js +0 -17
- package/dist/esm/core/abis/fpmm.js +0 -45
- package/dist/esm/core/abis/fpmmFactory.js +0 -22
- package/dist/esm/core/abis/hintHelpers.js +0 -10
- package/dist/esm/core/abis/index.js +0 -21
- package/dist/esm/core/abis/liquidityStrategy.js +0 -6
- package/dist/esm/core/abis/multiTroveGetter.js +0 -11
- package/dist/esm/core/abis/priceFeed.js +0 -12
- package/dist/esm/core/abis/pricingmodule.js +0 -2
- package/dist/esm/core/abis/reserve.js +0 -14
- package/dist/esm/core/abis/router.js +0 -41
- package/dist/esm/core/abis/sortedTroves.js +0 -11
- package/dist/esm/core/abis/systemParams.js +0 -10
- package/dist/esm/core/abis/troveManager.js +0 -23
- package/dist/esm/core/abis/troveNFT.js +0 -5
- package/dist/esm/core/abis/virtualPool.js +0 -7
- package/dist/esm/core/abis/virtualPoolFactory.js +0 -13
- package/dist/esm/core/constants/addresses.js +0 -107
- package/dist/esm/core/constants/borrowConstants.js +0 -12
- package/dist/esm/core/constants/borrowRegistries.js +0 -25
- package/dist/esm/core/constants/contractNames.js +0 -20
- package/dist/esm/core/constants/index.js +0 -5
- package/dist/esm/core/errors/base.js +0 -12
- package/dist/esm/core/errors/index.js +0 -3
- package/dist/esm/core/errors/oracle.js +0 -10
- package/dist/esm/core/errors/router.js +0 -18
- package/dist/esm/core/types/index.js +0 -9
- package/dist/esm/core/types/pool.js +0 -10
- package/dist/esm/core/types/tradingLimits.js +0 -1
- package/dist/esm/core/types/tradingMode.js +0 -26
- package/dist/esm/core/types/transaction.js +0 -1
- package/dist/esm/package.json +0 -1
- package/dist/esm/services/borrow/BorrowService.js +0 -455
- package/dist/esm/services/borrow/borrowHelpers.js +0 -3
- package/dist/esm/services/borrow/borrowMath.js +0 -127
- package/dist/esm/services/borrow/index.js +0 -3
- package/dist/esm/services/borrow/internal/borrowApprovalService.js +0 -48
- package/dist/esm/services/borrow/internal/borrowContextStore.js +0 -35
- package/dist/esm/services/borrow/internal/borrowErc20.js +0 -38
- package/dist/esm/services/borrow/internal/borrowHints.js +0 -27
- package/dist/esm/services/borrow/internal/borrowPositionParser.js +0 -82
- package/dist/esm/services/borrow/internal/borrowReadService.js +0 -271
- package/dist/esm/services/borrow/internal/borrowRegistryReader.js +0 -108
- package/dist/esm/services/borrow/internal/borrowTransactionService.js +0 -271
- package/dist/esm/services/borrow/internal/borrowTypes.js +0 -1
- package/dist/esm/services/borrow/internal/borrowValidation.js +0 -89
- package/dist/esm/services/index.js +0 -8
- package/dist/esm/services/liquidity/LiquidityService.js +0 -163
- package/dist/esm/services/liquidity/basicLiquidity.js +0 -162
- package/dist/esm/services/liquidity/index.js +0 -1
- package/dist/esm/services/liquidity/liquidityHelpers.js +0 -95
- package/dist/esm/services/liquidity/rebalance.js +0 -59
- package/dist/esm/services/liquidity/zapHelpers.js +0 -120
- package/dist/esm/services/liquidity/zapIn.js +0 -112
- package/dist/esm/services/liquidity/zapOut.js +0 -248
- package/dist/esm/services/pools/PoolService.js +0 -204
- package/dist/esm/services/pools/index.js +0 -1
- package/dist/esm/services/pools/poolDetails.js +0 -209
- package/dist/esm/services/pools/poolDiscovery.js +0 -112
- package/dist/esm/services/pools/rebalancePreview.js +0 -181
- package/dist/esm/services/quotes/QuoteService.js +0 -85
- package/dist/esm/services/quotes/index.js +0 -1
- package/dist/esm/services/routes/RouteService.js +0 -268
- package/dist/esm/services/routes/index.js +0 -1
- package/dist/esm/services/swap/SwapService.js +0 -247
- package/dist/esm/services/swap/index.js +0 -1
- package/dist/esm/services/tokens/index.js +0 -1
- package/dist/esm/services/tokens/tokenService.js +0 -285
- package/dist/esm/services/trading/TradingLimitsService.js +0 -154
- package/dist/esm/services/trading/TradingService.js +0 -196
- package/dist/esm/services/trading/index.js +0 -2
- package/dist/esm/utils/chainConfig.js +0 -118
- package/dist/esm/utils/costUtils.js +0 -56
- package/dist/esm/utils/deadline.js +0 -22
- package/dist/esm/utils/index.js +0 -9
- package/dist/esm/utils/multicall.js +0 -47
- package/dist/esm/utils/pathEncoder.js +0 -69
- package/dist/esm/utils/rateFeed.js +0 -23
- package/dist/esm/utils/retry.js +0 -24
- package/dist/esm/utils/routes.js +0 -2
- package/dist/esm/utils/sortUtils.js +0 -33
- package/dist/esm/utils/tokens.js +0 -2
- package/dist/esm/utils/tradingLimits.js +0 -163
- package/dist/esm/utils/validation.js +0 -30
- package/dist/index.d.ts +0 -101
- package/dist/index.js +0 -158
- package/dist/services/borrow/BorrowService.d.ts +0 -381
- package/dist/services/borrow/BorrowService.js +0 -460
- package/dist/services/borrow/borrowHelpers.d.ts +0 -4
- package/dist/services/borrow/borrowHelpers.js +0 -13
- package/dist/services/borrow/borrowMath.d.ts +0 -21
- package/dist/services/borrow/borrowMath.js +0 -137
- package/dist/services/borrow/index.d.ts +0 -4
- package/dist/services/borrow/internal/borrowApprovalService.d.ts +0 -14
- package/dist/services/borrow/internal/borrowApprovalService.js +0 -53
- package/dist/services/borrow/internal/borrowContextStore.d.ts +0 -11
- package/dist/services/borrow/internal/borrowContextStore.js +0 -40
- package/dist/services/borrow/internal/borrowErc20.d.ts +0 -5
- package/dist/services/borrow/internal/borrowErc20.js +0 -43
- package/dist/services/borrow/internal/borrowHints.d.ts +0 -7
- package/dist/services/borrow/internal/borrowHints.js +0 -31
- package/dist/services/borrow/internal/borrowPositionParser.d.ts +0 -4
- package/dist/services/borrow/internal/borrowPositionParser.js +0 -87
- package/dist/services/borrow/internal/borrowReadService.d.ts +0 -31
- package/dist/services/borrow/internal/borrowReadService.js +0 -276
- package/dist/services/borrow/internal/borrowRegistryReader.d.ts +0 -5
- package/dist/services/borrow/internal/borrowRegistryReader.js +0 -113
- package/dist/services/borrow/internal/borrowTransactionService.d.ts +0 -23
- package/dist/services/borrow/internal/borrowTransactionService.js +0 -276
- package/dist/services/borrow/internal/borrowTypes.d.ts +0 -15
- package/dist/services/borrow/internal/borrowTypes.js +0 -3
- package/dist/services/borrow/internal/borrowValidation.d.ts +0 -14
- package/dist/services/borrow/internal/borrowValidation.js +0 -104
- package/dist/services/index.d.ts +0 -9
- package/dist/services/index.js +0 -25
- package/dist/services/liquidity/LiquidityService.d.ts +0 -139
- package/dist/services/liquidity/LiquidityService.js +0 -168
- package/dist/services/liquidity/basicLiquidity.d.ts +0 -11
- package/dist/services/liquidity/basicLiquidity.js +0 -172
- package/dist/services/liquidity/index.d.ts +0 -2
- package/dist/services/liquidity/liquidityHelpers.d.ts +0 -19
- package/dist/services/liquidity/liquidityHelpers.js +0 -104
- package/dist/services/liquidity/rebalance.d.ts +0 -6
- package/dist/services/liquidity/rebalance.js +0 -64
- package/dist/services/liquidity/zapHelpers.d.ts +0 -66
- package/dist/services/liquidity/zapHelpers.js +0 -129
- package/dist/services/liquidity/zapIn.d.ts +0 -18
- package/dist/services/liquidity/zapIn.js +0 -119
- package/dist/services/liquidity/zapOut.d.ts +0 -9
- package/dist/services/liquidity/zapOut.js +0 -255
- package/dist/services/pools/PoolService.d.ts +0 -69
- package/dist/services/pools/PoolService.js +0 -209
- package/dist/services/pools/index.d.ts +0 -2
- package/dist/services/pools/poolDetails.d.ts +0 -13
- package/dist/services/pools/poolDetails.js +0 -216
- package/dist/services/pools/poolDiscovery.d.ts +0 -12
- package/dist/services/pools/poolDiscovery.js +0 -117
- package/dist/services/pools/rebalancePreview.d.ts +0 -5
- package/dist/services/pools/rebalancePreview.js +0 -186
- package/dist/services/quotes/QuoteService.d.ts +0 -51
- package/dist/services/quotes/QuoteService.js +0 -91
- package/dist/services/quotes/index.d.ts +0 -2
- package/dist/services/quotes/index.js +0 -18
- package/dist/services/routes/RouteService.d.ts +0 -117
- package/dist/services/routes/RouteService.js +0 -306
- package/dist/services/routes/index.d.ts +0 -2
- package/dist/services/routes/index.js +0 -18
- package/dist/services/swap/SwapService.d.ts +0 -198
- package/dist/services/swap/SwapService.js +0 -252
- package/dist/services/swap/index.d.ts +0 -2
- package/dist/services/swap/index.js +0 -18
- package/dist/services/tokens/index.d.ts +0 -2
- package/dist/services/tokens/index.js +0 -18
- package/dist/services/tokens/tokenService.d.ts +0 -55
- package/dist/services/tokens/tokenService.js +0 -290
- package/dist/services/trading/TradingLimitsService.d.ts +0 -38
- package/dist/services/trading/TradingLimitsService.js +0 -159
- package/dist/services/trading/TradingService.d.ts +0 -113
- package/dist/services/trading/TradingService.js +0 -201
- package/dist/services/trading/index.d.ts +0 -3
- package/dist/services/trading/index.js +0 -19
- package/dist/utils/chainConfig.d.ts +0 -16
- package/dist/utils/chainConfig.js +0 -123
- package/dist/utils/costUtils.d.ts +0 -12
- package/dist/utils/costUtils.js +0 -60
- package/dist/utils/deadline.d.ts +0 -21
- package/dist/utils/deadline.js +0 -26
- package/dist/utils/index.d.ts +0 -10
- package/dist/utils/index.js +0 -26
- package/dist/utils/multicall.d.ts +0 -30
- package/dist/utils/multicall.js +0 -52
- package/dist/utils/pathEncoder.d.ts +0 -34
- package/dist/utils/pathEncoder.js +0 -73
- package/dist/utils/rateFeed.d.ts +0 -18
- package/dist/utils/rateFeed.js +0 -27
- package/dist/utils/retry.d.ts +0 -12
- package/dist/utils/retry.js +0 -28
- package/dist/utils/routes.d.ts +0 -3
- package/dist/utils/routes.js +0 -8
- package/dist/utils/sortUtils.d.ts +0 -24
- package/dist/utils/sortUtils.js +0 -39
- package/dist/utils/tokens.d.ts +0 -2
- package/dist/utils/tokens.js +0 -13
- package/dist/utils/tradingLimits.d.ts +0 -41
- package/dist/utils/tradingLimits.js +0 -171
- package/dist/utils/validation.d.ts +0 -19
- package/dist/utils/validation.js +0 -34
- /package/dist/esm/{core/types/borrow.js → interfaces/IChainClient.js} +0 -0
- /package/dist/esm/{core/types/contractAddresses.js → interfaces/tradingLimit.js} +0 -0
- /package/dist/esm/{core/types/liquidity.js → interfaces/tradingLimitsConfig.js} +0 -0
- /package/dist/esm/{core/types/provider.js → interfaces/tradingLimitsState.js} +0 -0
- /package/dist/esm/{core/types/route.js → types/contractAddressMap.js} +0 -0
- /package/dist/esm/{core/types/token.js → types/contractAddresses.js} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TradablePair } from '../mento';
|
|
2
|
+
export interface TradablePairWithSpread extends TradablePair {
|
|
3
|
+
spreadData: {
|
|
4
|
+
totalSpreadPercent: number;
|
|
5
|
+
hops: Array<{
|
|
6
|
+
exchangeId: string;
|
|
7
|
+
spreadPercent: number;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Gets cached tradable pairs for a specific chain ID
|
|
13
|
+
* @param chainId - The chain ID to get cached pairs for
|
|
14
|
+
* @returns Promise resolving to the cached tradable pairs or undefined if not available
|
|
15
|
+
*/
|
|
16
|
+
export declare function getCachedTradablePairs(chainId: number): Promise<readonly (TradablePair | TradablePairWithSpread)[] | undefined>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Gets cached tradable pairs for a specific chain ID
|
|
12
|
+
* @param chainId - The chain ID to get cached pairs for
|
|
13
|
+
* @returns Promise resolving to the cached tradable pairs or undefined if not available
|
|
14
|
+
*/
|
|
15
|
+
export function getCachedTradablePairs(chainId) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
switch (chainId) {
|
|
18
|
+
case 42220:
|
|
19
|
+
return yield import('./tradablePairs.42220').then((module) => module.tradablePairs42220);
|
|
20
|
+
case 11142220:
|
|
21
|
+
return yield import('./tradablePairs.11142220').then((module) => module.tradablePairs11142220);
|
|
22
|
+
default:
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -2,6 +2,4 @@ export var ChainId;
|
|
|
2
2
|
(function (ChainId) {
|
|
3
3
|
ChainId[ChainId["CELO"] = 42220] = "CELO";
|
|
4
4
|
ChainId[ChainId["CELO_SEPOLIA"] = 11142220] = "CELO_SEPOLIA";
|
|
5
|
-
ChainId[ChainId["MONAD_TESTNET"] = 10143] = "MONAD_TESTNET";
|
|
6
|
-
ChainId[ChainId["MONAD"] = 143] = "MONAD";
|
|
7
5
|
})(ChainId || (ChainId = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var ProposalState;
|
|
2
|
+
(function (ProposalState) {
|
|
3
|
+
ProposalState[ProposalState["PENDING"] = 0] = "PENDING";
|
|
4
|
+
ProposalState[ProposalState["ACTIVE"] = 1] = "ACTIVE";
|
|
5
|
+
ProposalState[ProposalState["CANCELED"] = 2] = "CANCELED";
|
|
6
|
+
ProposalState[ProposalState["DEFEATED"] = 3] = "DEFEATED";
|
|
7
|
+
ProposalState[ProposalState["SUCCEEDED"] = 4] = "SUCCEEDED";
|
|
8
|
+
ProposalState[ProposalState["QUEUED"] = 5] = "QUEUED";
|
|
9
|
+
ProposalState[ProposalState["EXPIRED"] = 6] = "EXPIRED";
|
|
10
|
+
ProposalState[ProposalState["EXECUTED"] = 7] = "EXECUTED";
|
|
11
|
+
})(ProposalState || (ProposalState = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trading modes for rate feeds in the BreakerBox
|
|
3
|
+
*/
|
|
4
|
+
export declare enum TradingMode {
|
|
5
|
+
/**
|
|
6
|
+
* Bidirectional trading is enabled
|
|
7
|
+
*/
|
|
8
|
+
BIDIRECTIONAL = 0,
|
|
9
|
+
/**
|
|
10
|
+
* Trading is temporarily halted (circuit breaker tripped)
|
|
11
|
+
*/
|
|
12
|
+
HALTED = 1,
|
|
13
|
+
/**
|
|
14
|
+
* Trading is permanently disabled
|
|
15
|
+
*/
|
|
16
|
+
DISABLED = 2
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trading modes for rate feeds in the BreakerBox
|
|
3
|
+
*/
|
|
4
|
+
export var TradingMode;
|
|
5
|
+
(function (TradingMode) {
|
|
6
|
+
/**
|
|
7
|
+
* Bidirectional trading is enabled
|
|
8
|
+
*/
|
|
9
|
+
TradingMode[TradingMode["BIDIRECTIONAL"] = 0] = "BIDIRECTIONAL";
|
|
10
|
+
/**
|
|
11
|
+
* Trading is temporarily halted (circuit breaker tripped)
|
|
12
|
+
*/
|
|
13
|
+
TradingMode[TradingMode["HALTED"] = 1] = "HALTED";
|
|
14
|
+
/**
|
|
15
|
+
* Trading is permanently disabled
|
|
16
|
+
*/
|
|
17
|
+
TradingMode[TradingMode["DISABLED"] = 2] = "DISABLED";
|
|
18
|
+
})(TradingMode || (TradingMode = {}));
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BigNumberish, Signer, providers } from 'ethers';
|
|
2
|
+
import { MentoGovernor } from '@mento-protocol/mento-core-ts';
|
|
3
|
+
import { IChainClient } from './interfaces';
|
|
4
|
+
export declare class Governance {
|
|
5
|
+
private chainClient;
|
|
6
|
+
constructor(chainClient: IChainClient);
|
|
7
|
+
constructor(signerOrProvider: Signer | providers.Provider);
|
|
8
|
+
/**
|
|
9
|
+
* This function retrieves the MentoGovernor contract.
|
|
10
|
+
* @returns The MentoGovernor contract.
|
|
11
|
+
*/
|
|
12
|
+
getGovernorContract(): Promise<MentoGovernor>;
|
|
13
|
+
/**
|
|
14
|
+
* Generates a transaction that submits a proposal to be created to the Mento Governor contract using the specified values.
|
|
15
|
+
* @param targets The addresses of the contracts to be called during proposal execution.
|
|
16
|
+
* @param values The values to be passed to the calls to the target contracts.
|
|
17
|
+
* @param calldatas The calldata to be passed to the calls to the target contracts.
|
|
18
|
+
* @param description A human readable description of the proposal.
|
|
19
|
+
* @returns The transaction request.
|
|
20
|
+
*/
|
|
21
|
+
createProposal(targets: string[], values: BigNumberish[], calldatas: string[], description: string): Promise<providers.TransactionRequest>;
|
|
22
|
+
/**
|
|
23
|
+
* Generates a transaction that will queue the proposal with the specified id to be executed.
|
|
24
|
+
* @param proposalId The id of the proposal to queue.
|
|
25
|
+
* @returns The transaction request.
|
|
26
|
+
*/
|
|
27
|
+
queueProposal(proposalId: BigNumberish): Promise<providers.TransactionRequest>;
|
|
28
|
+
/**
|
|
29
|
+
* Executes the proposal with the specified id.
|
|
30
|
+
* @param proposalId The id of the proposal to execute.
|
|
31
|
+
* @returns The transaction request.
|
|
32
|
+
*/
|
|
33
|
+
executeProposal(proposalId: BigNumberish): Promise<providers.TransactionRequest>;
|
|
34
|
+
/**
|
|
35
|
+
* Submits a vote to the Mento Governor contract for the specified proposal.
|
|
36
|
+
* @param proposalId The id of the proposal to vote on.
|
|
37
|
+
* @param support Whether or not to support the proposal.
|
|
38
|
+
* @returns The transaction request.
|
|
39
|
+
*/
|
|
40
|
+
castVote(proposalId: BigNumberish, support: BigNumberish): Promise<providers.TransactionRequest>;
|
|
41
|
+
/**
|
|
42
|
+
* Cancels the proposal with the specified id.
|
|
43
|
+
* @param proposalId The id of the proposal to vote on.
|
|
44
|
+
* @param support Whether or not to support the proposal.
|
|
45
|
+
* @returns The transaction request.
|
|
46
|
+
*/
|
|
47
|
+
cancelProposal(proposalId: BigNumberish): Promise<providers.TransactionRequest>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the state of the proposal with the specified id.
|
|
50
|
+
* @param proposalId The id of the proposal to get the state of.
|
|
51
|
+
* @returns The state of the proposal.
|
|
52
|
+
*/
|
|
53
|
+
getProposalState(proposalId: BigNumberish): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* This function validates the args that are to be used in the createProposal function.
|
|
56
|
+
* @param targets The addresses of the contracts to be called during proposal execution.
|
|
57
|
+
* @param values The values to be passed to the calls to the target contracts.
|
|
58
|
+
* @param calldatas The calldata to be passed to the calls to the target contracts.
|
|
59
|
+
* @param description A human readable description of the proposal.
|
|
60
|
+
*/
|
|
61
|
+
private validateProposalArgs;
|
|
62
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Signer, providers } from 'ethers';
|
|
11
|
+
import { MentoGovernor__factory, } from '@mento-protocol/mento-core-ts';
|
|
12
|
+
import { ChainClient } from './ChainClient';
|
|
13
|
+
import { TestChainClient } from './TestChainClient';
|
|
14
|
+
import { ProposalState } from './enums';
|
|
15
|
+
import { addresses } from './constants';
|
|
16
|
+
export class Governance {
|
|
17
|
+
constructor(arg) {
|
|
18
|
+
// TODO: Remove use of TestChainClient in future this is only meant for testing
|
|
19
|
+
if (arg instanceof ChainClient || arg instanceof TestChainClient) {
|
|
20
|
+
this.chainClient = arg;
|
|
21
|
+
}
|
|
22
|
+
else if (Signer.isSigner(arg) || providers.Provider.isProvider(arg)) {
|
|
23
|
+
this.chainClient = new ChainClient(arg);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new Error('Invalid constructor argument');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* This function retrieves the MentoGovernor contract.
|
|
31
|
+
* @returns The MentoGovernor contract.
|
|
32
|
+
*/
|
|
33
|
+
getGovernorContract() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const chainId = yield this.chainClient.getChainId();
|
|
36
|
+
const contracts = addresses[chainId];
|
|
37
|
+
if (!contracts) {
|
|
38
|
+
throw new Error(`Contracts not deployed on network with chain id ${chainId}`);
|
|
39
|
+
}
|
|
40
|
+
const mentoGovernorAddress = contracts.MentoGovernor;
|
|
41
|
+
return MentoGovernor__factory.connect(mentoGovernorAddress, yield this.chainClient.getSigner());
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Generates a transaction that submits a proposal to be created to the Mento Governor contract using the specified values.
|
|
46
|
+
* @param targets The addresses of the contracts to be called during proposal execution.
|
|
47
|
+
* @param values The values to be passed to the calls to the target contracts.
|
|
48
|
+
* @param calldatas The calldata to be passed to the calls to the target contracts.
|
|
49
|
+
* @param description A human readable description of the proposal.
|
|
50
|
+
* @returns The transaction request.
|
|
51
|
+
*/
|
|
52
|
+
createProposal(targets, values, calldatas, description) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
this.validateProposalArgs(targets, values, calldatas, description);
|
|
55
|
+
const governor = yield this.getGovernorContract();
|
|
56
|
+
const tx = yield governor.populateTransaction['propose(address[],uint256[],bytes[],string)'](targets, values, calldatas, description);
|
|
57
|
+
return yield this.chainClient.populateTransaction(tx);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generates a transaction that will queue the proposal with the specified id to be executed.
|
|
62
|
+
* @param proposalId The id of the proposal to queue.
|
|
63
|
+
* @returns The transaction request.
|
|
64
|
+
*/
|
|
65
|
+
queueProposal(proposalId) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const governor = yield this.getGovernorContract();
|
|
68
|
+
const tx = yield governor.populateTransaction['queue(uint256)'](proposalId);
|
|
69
|
+
return yield this.chainClient.populateTransaction(tx);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Executes the proposal with the specified id.
|
|
74
|
+
* @param proposalId The id of the proposal to execute.
|
|
75
|
+
* @returns The transaction request.
|
|
76
|
+
*/
|
|
77
|
+
executeProposal(proposalId) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const governor = yield this.getGovernorContract();
|
|
80
|
+
const tx = yield governor.populateTransaction['execute(uint256)'](proposalId);
|
|
81
|
+
return yield this.chainClient.populateTransaction(tx);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Submits a vote to the Mento Governor contract for the specified proposal.
|
|
86
|
+
* @param proposalId The id of the proposal to vote on.
|
|
87
|
+
* @param support Whether or not to support the proposal.
|
|
88
|
+
* @returns The transaction request.
|
|
89
|
+
*/
|
|
90
|
+
castVote(proposalId, support) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const governor = yield this.getGovernorContract();
|
|
93
|
+
const tx = yield governor.populateTransaction.castVote(proposalId, support);
|
|
94
|
+
return yield this.chainClient.populateTransaction(tx);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Cancels the proposal with the specified id.
|
|
99
|
+
* @param proposalId The id of the proposal to vote on.
|
|
100
|
+
* @param support Whether or not to support the proposal.
|
|
101
|
+
* @returns The transaction request.
|
|
102
|
+
*/
|
|
103
|
+
cancelProposal(proposalId) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const governor = yield this.getGovernorContract();
|
|
106
|
+
const tx = yield governor.populateTransaction.cancel(proposalId);
|
|
107
|
+
return yield this.chainClient.populateTransaction(tx);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns the state of the proposal with the specified id.
|
|
112
|
+
* @param proposalId The id of the proposal to get the state of.
|
|
113
|
+
* @returns The state of the proposal.
|
|
114
|
+
*/
|
|
115
|
+
getProposalState(proposalId) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const governor = yield this.getGovernorContract();
|
|
118
|
+
const state = (yield governor.functions.state(proposalId))[0];
|
|
119
|
+
return ProposalState[state];
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* This function validates the args that are to be used in the createProposal function.
|
|
124
|
+
* @param targets The addresses of the contracts to be called during proposal execution.
|
|
125
|
+
* @param values The values to be passed to the calls to the target contracts.
|
|
126
|
+
* @param calldatas The calldata to be passed to the calls to the target contracts.
|
|
127
|
+
* @param description A human readable description of the proposal.
|
|
128
|
+
*/
|
|
129
|
+
validateProposalArgs(targets, values, calldatas, description) {
|
|
130
|
+
if (!targets || targets.length === 0) {
|
|
131
|
+
throw new Error('Targets must be specified');
|
|
132
|
+
}
|
|
133
|
+
if (!values || values.length === 0) {
|
|
134
|
+
throw new Error('Values must be specified');
|
|
135
|
+
}
|
|
136
|
+
if (!calldatas || calldatas.length === 0) {
|
|
137
|
+
throw new Error('Calldatas must be specified');
|
|
138
|
+
}
|
|
139
|
+
if (!description) {
|
|
140
|
+
throw new Error('Description must be specified');
|
|
141
|
+
}
|
|
142
|
+
if (targets.length !== values.length ||
|
|
143
|
+
targets.length !== calldatas.length) {
|
|
144
|
+
throw new Error('Targets, values, and calldatas must all have the same length');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,139 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { RouteService } from './services/routes';
|
|
8
|
-
import { QuoteService } from './services/quotes';
|
|
9
|
-
import { SwapService } from './services/swap';
|
|
10
|
-
import { TradingService } from './services/trading';
|
|
11
|
-
import { LiquidityService } from './services/liquidity';
|
|
12
|
-
import { BorrowService } from './services/borrow';
|
|
13
|
-
const DEFAULT_HTTP_BATCH_OPTIONS = {
|
|
14
|
-
batchSize: 1000,
|
|
15
|
-
wait: 8,
|
|
16
|
-
};
|
|
17
|
-
const DEFAULT_MULTICALL_BATCH_OPTIONS = {
|
|
18
|
-
batchSize: 1024,
|
|
19
|
-
wait: 8,
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* @class Mento
|
|
23
|
-
* @description The main class for the Mento SDK. Initializes a viem PublicClient internally
|
|
24
|
-
* and provides a public API for interacting with the Mento Protocol.
|
|
25
|
-
* @dev example usage:
|
|
26
|
-
* const mento = await Mento.create(ChainId.CELO);
|
|
27
|
-
* // or with custom RPC URL
|
|
28
|
-
* const mento = await Mento.create(ChainId.CELO, 'https://custom-rpc-url.com');
|
|
29
|
-
* // or with an existing viem PublicClient
|
|
30
|
-
* const mento = await Mento.create(ChainId.CELO, myPublicClient);
|
|
31
|
-
*
|
|
32
|
-
* // Get all stable tokens
|
|
33
|
-
* const stableTokens = await mento.tokens.getStableTokens();
|
|
34
|
-
*
|
|
35
|
-
* // Get all collateral assets
|
|
36
|
-
* const collateralAssets = await mento.tokens.getCollateralAssets();
|
|
37
|
-
*
|
|
38
|
-
* // Get all pools
|
|
39
|
-
* const pools = await mento.pools.getPools();
|
|
40
|
-
*
|
|
41
|
-
* // Find a route between tokens
|
|
42
|
-
* const route = await mento.routes.findRoute(USDm, CELO);
|
|
43
|
-
*
|
|
44
|
-
* // Get a quote for a swap
|
|
45
|
-
* const amountOut = await mento.quotes.getAmountOut(USDm, CELO, amountIn);
|
|
46
|
-
*
|
|
47
|
-
* // Build swap parameters
|
|
48
|
-
* const swapDetails = await mento.swap.buildSwapParams(USDm, CELO, amountIn, recipient, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) });
|
|
49
|
-
*
|
|
50
|
-
* // Check if a pair is tradable (circuit breaker check)
|
|
51
|
-
* const isTradable = await mento.trading.isPairTradable(USDm, CELO);
|
|
52
|
-
*
|
|
53
|
-
* // Get trading limits for a pool
|
|
54
|
-
* const limits = await mento.trading.getPoolTradingLimits(pool);
|
|
55
|
-
*
|
|
56
|
-
* // Get full tradability status (circuit breaker + limits)
|
|
57
|
-
* const status = await mento.trading.getPoolTradabilityStatus(pool);
|
|
58
|
-
*
|
|
59
|
-
* // Add liquidity to a pool
|
|
60
|
-
* const { approval0, approval1, addLiquidity } = await mento.liquidity.buildAddLiquidityTransaction(
|
|
61
|
-
* poolAddress, amount0, amount1, recipient, owner, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
62
|
-
* );
|
|
63
|
-
*
|
|
64
|
-
* // Add liquidity using a single token (zap in)
|
|
65
|
-
* const { approval, zapIn } = await mento.liquidity.buildZapInTransaction(
|
|
66
|
-
* poolAddress, tokenIn, amountIn, 0.5, recipient, owner, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
67
|
-
* );
|
|
68
|
-
*/
|
|
69
|
-
export class Mento {
|
|
70
|
-
constructor(chainId, tokens, pools, routes, quotes, swap, trading, liquidity, borrow) {
|
|
71
|
-
this.chainId = chainId;
|
|
72
|
-
this.tokens = tokens;
|
|
73
|
-
this.pools = pools;
|
|
74
|
-
this.routes = routes;
|
|
75
|
-
this.quotes = quotes;
|
|
76
|
-
this.swap = swap;
|
|
77
|
-
this.trading = trading;
|
|
78
|
-
this.liquidity = liquidity;
|
|
79
|
-
this.borrow = borrow;
|
|
80
|
-
}
|
|
81
|
-
static async create(chainId, rpcUrlOrClient, options) {
|
|
82
|
-
// Validate chainId is supported
|
|
83
|
-
const supportedChainIds = Object.values(ChainId).filter((v) => typeof v === 'number');
|
|
84
|
-
if (!supportedChainIds.includes(chainId)) {
|
|
85
|
-
throw new Error(`ChainId ${chainId} is not supported. ` +
|
|
86
|
-
`Supported chains: ${supportedChainIds.map((id) => `${id} (${ChainId[id]})`).join(', ')}`);
|
|
87
|
-
}
|
|
88
|
-
let publicClient;
|
|
89
|
-
if (rpcUrlOrClient && typeof rpcUrlOrClient !== 'string') {
|
|
90
|
-
publicClient = rpcUrlOrClient;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
const transport = http(rpcUrlOrClient || getDefaultRpcUrl(chainId), {
|
|
94
|
-
batch: options?.httpBatch === false
|
|
95
|
-
? false
|
|
96
|
-
: {
|
|
97
|
-
...DEFAULT_HTTP_BATCH_OPTIONS,
|
|
98
|
-
...(options?.httpBatch ?? {}),
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
publicClient = createPublicClient({
|
|
102
|
-
batch: {
|
|
103
|
-
multicall: options?.multicallBatch === false
|
|
104
|
-
? false
|
|
105
|
-
: {
|
|
106
|
-
...DEFAULT_MULTICALL_BATCH_OPTIONS,
|
|
107
|
-
...(options?.multicallBatch ?? {}),
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
chain: getChainConfig(chainId),
|
|
111
|
-
transport,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
const tokenService = new TokenService(publicClient, chainId);
|
|
115
|
-
const poolService = new PoolService(publicClient, chainId);
|
|
116
|
-
const routeService = new RouteService(publicClient, chainId, poolService);
|
|
117
|
-
const quoteService = new QuoteService(publicClient, chainId, routeService);
|
|
118
|
-
const swapService = new SwapService(publicClient, chainId, routeService, quoteService);
|
|
119
|
-
const tradingService = new TradingService(publicClient, chainId, routeService);
|
|
120
|
-
const liquidityService = new LiquidityService(publicClient, chainId, poolService, routeService);
|
|
121
|
-
const borrowService = new BorrowService(publicClient, chainId);
|
|
122
|
-
// Return new mento
|
|
123
|
-
return new Mento(chainId, tokenService, poolService, routeService, quoteService, swapService, tradingService, liquidityService, borrowService);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get the address of a contract for the current chain
|
|
127
|
-
* @param contractName - The contract name
|
|
128
|
-
* @returns The contract address
|
|
129
|
-
*/
|
|
130
|
-
getContractAddress(contractName) {
|
|
131
|
-
return getContractAddress(this.chainId, contractName);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
export * from './core/constants';
|
|
135
|
-
export * from './core/errors';
|
|
136
|
-
export * from './core/types';
|
|
137
|
-
export * from './core/abis';
|
|
138
|
-
export * from './services';
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
export * from './constants';
|
|
3
|
+
export * from './enums';
|
|
4
|
+
export * from './governance';
|
|
5
|
+
export * from './mento';
|
|
6
|
+
export * from './routeUtils';
|
|
139
7
|
export * from './utils';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Address, TradingLimit, TradingLimitsConfig, TradingLimitsState } from './interfaces';
|
|
2
|
+
import { Broker } from '@mento-protocol/mento-core-ts';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the limit configuration in the broker for the given exchange and asset
|
|
5
|
+
* @param broker an instance of the broker
|
|
6
|
+
* @param exchangeId the id of the exchange
|
|
7
|
+
* @param asset the address of the limited asset
|
|
8
|
+
* @returns the limit configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function getLimitsConfig(broker: Broker, exchangeId: string, asset: Address): Promise<TradingLimitsConfig>;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the limit state in the broker for the given exchange and asset
|
|
13
|
+
* @param broker an instance of the broker
|
|
14
|
+
* @param exchangeId the id of the exchange
|
|
15
|
+
* @param asset the address of the limited asset
|
|
16
|
+
* @returns the limit state
|
|
17
|
+
*/
|
|
18
|
+
export declare function getLimitsState(broker: Broker, exchangeId: string, asset: Address): Promise<TradingLimitsState>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns a human-friendly representation of the limits for the given exchange and asset
|
|
21
|
+
* @param broker an instance of the broker
|
|
22
|
+
* @param exchangeId the id of the exchange
|
|
23
|
+
* @param asset the address of the asset with the limit
|
|
24
|
+
* @returns a list of TradingLimit objects
|
|
25
|
+
*/
|
|
26
|
+
export declare function getLimits(broker: Broker, exchangeId: string, asset: Address): Promise<TradingLimit[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the limit id for the given exchange and asset
|
|
29
|
+
* @param exchangeId the id of the exchange
|
|
30
|
+
* @param asset the address of the asset with the limit
|
|
31
|
+
* @returns the limit id
|
|
32
|
+
*/
|
|
33
|
+
export declare function getLimitId(exchangeId: string, asset: Address): string;
|