@mento-protocol/mento-sdk 3.0.0-beta.3 → 3.0.0-beta.30
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/README.md +132 -275
- package/dist/cache/routes.d.ts +13 -0
- package/dist/cache/routes.d.ts.map +1 -0
- package/dist/cache/routes.js +11483 -0
- package/dist/cache/routes.js.map +1 -0
- package/dist/cache/tokens.d.ts +67 -0
- package/dist/cache/tokens.d.ts.map +1 -0
- package/dist/cache/tokens.js +379 -0
- package/dist/cache/tokens.js.map +1 -0
- package/dist/core/abis/activePool.d.ts +2 -0
- package/dist/core/abis/activePool.d.ts.map +1 -0
- package/dist/core/abis/activePool.js +14 -0
- package/dist/core/abis/activePool.js.map +1 -0
- package/dist/core/abis/addressesRegistry.d.ts +2 -0
- package/dist/core/abis/addressesRegistry.d.ts.map +1 -0
- package/dist/core/abis/addressesRegistry.js +26 -0
- package/dist/core/abis/addressesRegistry.js.map +1 -0
- package/dist/core/abis/borrowerOperations.d.ts +9 -0
- package/dist/core/abis/borrowerOperations.d.ts.map +1 -0
- package/dist/core/abis/borrowerOperations.js +89 -0
- package/dist/core/abis/borrowerOperations.js.map +1 -0
- package/dist/core/abis/breakerbox.d.ts +13 -0
- package/dist/core/abis/breakerbox.d.ts.map +1 -0
- package/dist/core/abis/breakerbox.js +8 -0
- package/dist/core/abis/breakerbox.js.map +1 -0
- package/dist/core/abis/erc20.d.ts +7 -0
- package/dist/core/abis/erc20.d.ts.map +1 -1
- package/dist/core/abis/erc20.js +7 -0
- package/dist/core/abis/erc20.js.map +1 -1
- package/dist/core/abis/fpmm.d.ts +236 -0
- package/dist/core/abis/fpmm.d.ts.map +1 -1
- package/dist/core/abis/fpmm.js +38 -0
- package/dist/core/abis/fpmm.js.map +1 -1
- package/dist/core/abis/fpmmFactory.d.ts +64 -0
- package/dist/core/abis/fpmmFactory.d.ts.map +1 -1
- package/dist/core/abis/fpmmFactory.js +17 -0
- package/dist/core/abis/fpmmFactory.js.map +1 -1
- package/dist/core/abis/hintHelpers.d.ts +2 -0
- package/dist/core/abis/hintHelpers.d.ts.map +1 -0
- package/dist/core/abis/hintHelpers.js +14 -0
- package/dist/core/abis/hintHelpers.js.map +1 -0
- package/dist/core/abis/index.d.ts +12 -1
- package/dist/core/abis/index.d.ts.map +1 -1
- package/dist/core/abis/index.js +12 -1
- package/dist/core/abis/index.js.map +1 -1
- package/dist/core/abis/multiTroveGetter.d.ts +8 -0
- package/dist/core/abis/multiTroveGetter.d.ts.map +1 -0
- package/dist/core/abis/multiTroveGetter.js +15 -0
- package/dist/core/abis/multiTroveGetter.js.map +1 -0
- package/dist/core/abis/priceFeed.d.ts +7 -0
- package/dist/core/abis/priceFeed.d.ts.map +1 -0
- package/dist/core/abis/priceFeed.js +16 -0
- package/dist/core/abis/priceFeed.js.map +1 -0
- package/dist/core/abis/router.d.ts +520 -1
- package/dist/core/abis/router.d.ts.map +1 -1
- package/dist/core/abis/router.js +35 -0
- package/dist/core/abis/router.js.map +1 -1
- package/dist/core/abis/sortedTroves.d.ts +2 -0
- package/dist/core/abis/sortedTroves.d.ts.map +1 -0
- package/dist/core/abis/sortedTroves.js +15 -0
- package/dist/core/abis/sortedTroves.js.map +1 -0
- package/dist/core/abis/systemParams.d.ts +2 -0
- package/dist/core/abis/systemParams.d.ts.map +1 -0
- package/dist/core/abis/systemParams.js +14 -0
- package/dist/core/abis/systemParams.js.map +1 -0
- package/dist/core/abis/troveManager.d.ts +2 -0
- package/dist/core/abis/troveManager.d.ts.map +1 -0
- package/dist/core/abis/troveManager.js +27 -0
- package/dist/core/abis/troveManager.js.map +1 -0
- package/dist/core/abis/troveNFT.d.ts +2 -0
- package/dist/core/abis/troveNFT.d.ts.map +1 -0
- package/dist/core/abis/troveNFT.js +9 -0
- package/dist/core/abis/troveNFT.js.map +1 -0
- package/dist/core/abis/virtualPool.d.ts +40 -0
- package/dist/core/abis/virtualPool.d.ts.map +1 -1
- package/dist/core/abis/virtualPool.js +6 -1
- package/dist/core/abis/virtualPool.js.map +1 -1
- package/dist/core/abis/virtualPoolFactory.d.ts +32 -0
- package/dist/core/abis/virtualPoolFactory.d.ts.map +1 -1
- package/dist/core/abis/virtualPoolFactory.js +8 -0
- package/dist/core/abis/virtualPoolFactory.js.map +1 -1
- package/dist/core/constants/addresses.d.ts.map +1 -1
- package/dist/core/constants/addresses.js +14 -4
- package/dist/core/constants/addresses.js.map +1 -1
- package/dist/core/constants/borrowConstants.d.ts +10 -0
- package/dist/core/constants/borrowConstants.d.ts.map +1 -0
- package/dist/core/constants/borrowConstants.js +16 -0
- package/dist/core/constants/borrowConstants.js.map +1 -0
- package/dist/core/constants/borrowRegistries.d.ts +7 -0
- package/dist/core/constants/borrowRegistries.d.ts.map +1 -0
- package/dist/core/constants/borrowRegistries.js +31 -0
- package/dist/core/constants/borrowRegistries.js.map +1 -0
- package/dist/core/constants/index.d.ts +2 -3
- package/dist/core/constants/index.d.ts.map +1 -1
- package/dist/core/constants/index.js +2 -3
- package/dist/core/constants/index.js.map +1 -1
- package/dist/core/errors/index.d.ts +1 -0
- package/dist/core/errors/index.d.ts.map +1 -1
- package/dist/core/errors/index.js +1 -0
- package/dist/core/errors/index.js.map +1 -1
- package/dist/core/errors/oracle.d.ts +9 -0
- package/dist/core/errors/oracle.d.ts.map +1 -0
- package/dist/core/errors/oracle.js +15 -0
- package/dist/core/errors/oracle.js.map +1 -0
- package/dist/core/errors/router.d.ts +6 -0
- package/dist/core/errors/router.d.ts.map +1 -1
- package/dist/core/errors/router.js +11 -1
- package/dist/core/errors/router.js.map +1 -1
- package/dist/core/types/borrow.d.ts +87 -0
- package/dist/core/types/borrow.d.ts.map +1 -0
- package/dist/{services/tokens/supply/ISupplyCalculator.js → core/types/borrow.js} +1 -1
- package/dist/core/types/borrow.js.map +1 -0
- package/dist/core/types/contractAddresses.d.ts +2 -0
- package/dist/core/types/contractAddresses.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +5 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/types/index.js +5 -1
- package/dist/core/types/index.js.map +1 -1
- package/dist/core/types/liquidity.d.ts +117 -0
- package/dist/core/types/liquidity.d.ts.map +1 -0
- package/dist/{services/tokens/supply/calculatorFactory.js → core/types/liquidity.js} +1 -1
- package/dist/core/types/liquidity.js.map +1 -0
- package/dist/core/types/pool.d.ts +110 -0
- package/dist/core/types/pool.d.ts.map +1 -1
- package/dist/core/types/provider.d.ts.map +1 -1
- package/dist/core/types/provider.js +0 -1
- package/dist/core/types/provider.js.map +1 -1
- package/dist/core/types/route.d.ts +3 -3
- package/dist/core/types/route.d.ts.map +1 -1
- package/dist/core/types/token.d.ts +13 -17
- package/dist/core/types/token.d.ts.map +1 -1
- package/dist/core/types/tradingLimits.d.ts +91 -0
- package/dist/core/types/tradingLimits.d.ts.map +1 -0
- package/dist/core/types/tradingLimits.js +3 -0
- package/dist/core/types/tradingLimits.js.map +1 -0
- package/dist/core/types/tradingMode.d.ts +24 -0
- package/dist/core/types/tradingMode.d.ts.map +1 -0
- package/dist/core/types/tradingMode.js +31 -0
- package/dist/core/types/tradingMode.js.map +1 -0
- package/dist/core/types/transaction.d.ts +45 -0
- package/dist/core/types/transaction.d.ts.map +1 -0
- package/dist/core/types/transaction.js +3 -0
- package/dist/core/types/transaction.js.map +1 -0
- package/dist/index.d.ts +29 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -5
- package/dist/index.js.map +1 -1
- package/dist/services/borrow/BorrowService.d.ts +54 -0
- package/dist/services/borrow/BorrowService.d.ts.map +1 -0
- package/dist/services/borrow/BorrowService.js +129 -0
- package/dist/services/borrow/BorrowService.js.map +1 -0
- package/dist/services/borrow/borrowHelpers.d.ts +4 -0
- package/dist/services/borrow/borrowHelpers.d.ts.map +1 -0
- package/dist/services/borrow/borrowHelpers.js +13 -0
- package/dist/services/borrow/borrowHelpers.js.map +1 -0
- package/dist/services/borrow/borrowMath.d.ts +13 -0
- package/dist/services/borrow/borrowMath.d.ts.map +1 -0
- package/dist/services/borrow/borrowMath.js +129 -0
- package/dist/services/borrow/borrowMath.js.map +1 -0
- package/dist/services/borrow/index.d.ts +2 -0
- package/dist/services/borrow/index.d.ts.map +1 -0
- package/dist/services/{tokens/supply → borrow}/index.js +1 -6
- package/dist/services/borrow/index.js.map +1 -0
- package/dist/services/borrow/internal/borrowApprovalService.d.ts +14 -0
- package/dist/services/borrow/internal/borrowApprovalService.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowApprovalService.js +53 -0
- package/dist/services/borrow/internal/borrowApprovalService.js.map +1 -0
- package/dist/services/borrow/internal/borrowContextStore.d.ts +11 -0
- package/dist/services/borrow/internal/borrowContextStore.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowContextStore.js +40 -0
- package/dist/services/borrow/internal/borrowContextStore.js.map +1 -0
- package/dist/services/borrow/internal/borrowErc20.d.ts +5 -0
- package/dist/services/borrow/internal/borrowErc20.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowErc20.js +43 -0
- package/dist/services/borrow/internal/borrowErc20.js.map +1 -0
- package/dist/services/borrow/internal/borrowHints.d.ts +7 -0
- package/dist/services/borrow/internal/borrowHints.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowHints.js +31 -0
- package/dist/services/borrow/internal/borrowHints.js.map +1 -0
- package/dist/services/borrow/internal/borrowPositionParser.d.ts +4 -0
- package/dist/services/borrow/internal/borrowPositionParser.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowPositionParser.js +87 -0
- package/dist/services/borrow/internal/borrowPositionParser.js.map +1 -0
- package/dist/services/borrow/internal/borrowReadService.d.ts +28 -0
- package/dist/services/borrow/internal/borrowReadService.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowReadService.js +218 -0
- package/dist/services/borrow/internal/borrowReadService.js.map +1 -0
- package/dist/services/borrow/internal/borrowRegistryReader.d.ts +5 -0
- package/dist/services/borrow/internal/borrowRegistryReader.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowRegistryReader.js +96 -0
- package/dist/services/borrow/internal/borrowRegistryReader.js.map +1 -0
- package/dist/services/borrow/internal/borrowTransactionService.d.ts +23 -0
- package/dist/services/borrow/internal/borrowTransactionService.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowTransactionService.js +276 -0
- package/dist/services/borrow/internal/borrowTransactionService.js.map +1 -0
- package/dist/services/borrow/internal/borrowTypes.d.ts +15 -0
- package/dist/services/borrow/internal/borrowTypes.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowTypes.js +3 -0
- package/dist/services/borrow/internal/borrowTypes.js.map +1 -0
- package/dist/services/borrow/internal/borrowValidation.d.ts +13 -0
- package/dist/services/borrow/internal/borrowValidation.d.ts.map +1 -0
- package/dist/services/borrow/internal/borrowValidation.js +96 -0
- package/dist/services/borrow/internal/borrowValidation.js.map +1 -0
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/liquidity/LiquidityService.d.ts +154 -0
- package/dist/services/liquidity/LiquidityService.d.ts.map +1 -0
- package/dist/services/liquidity/LiquidityService.js +184 -0
- package/dist/services/liquidity/LiquidityService.js.map +1 -0
- package/dist/services/liquidity/basicLiquidity.d.ts +11 -0
- package/dist/services/liquidity/basicLiquidity.d.ts.map +1 -0
- package/dist/services/liquidity/basicLiquidity.js +172 -0
- package/dist/services/liquidity/basicLiquidity.js.map +1 -0
- package/dist/services/liquidity/index.d.ts +2 -0
- package/dist/services/liquidity/index.d.ts.map +1 -0
- package/dist/services/liquidity/index.js +18 -0
- package/dist/services/liquidity/index.js.map +1 -0
- package/dist/services/liquidity/liquidityHelpers.d.ts +13 -0
- package/dist/services/liquidity/liquidityHelpers.d.ts.map +1 -0
- package/dist/services/liquidity/liquidityHelpers.js +74 -0
- package/dist/services/liquidity/liquidityHelpers.js.map +1 -0
- package/dist/services/liquidity/zapHelpers.d.ts +66 -0
- package/dist/services/liquidity/zapHelpers.d.ts.map +1 -0
- package/dist/services/liquidity/zapHelpers.js +133 -0
- package/dist/services/liquidity/zapHelpers.js.map +1 -0
- package/dist/services/liquidity/zapIn.d.ts +17 -0
- package/dist/services/liquidity/zapIn.d.ts.map +1 -0
- package/dist/services/liquidity/zapIn.js +125 -0
- package/dist/services/liquidity/zapIn.js.map +1 -0
- package/dist/services/liquidity/zapOut.d.ts +17 -0
- package/dist/services/liquidity/zapOut.d.ts.map +1 -0
- package/dist/services/liquidity/zapOut.js +242 -0
- package/dist/services/liquidity/zapOut.js.map +1 -0
- package/dist/services/pools/PoolService.d.ts +35 -10
- package/dist/services/pools/PoolService.d.ts.map +1 -1
- package/dist/services/pools/PoolService.js +61 -109
- package/dist/services/pools/PoolService.js.map +1 -1
- package/dist/services/pools/poolDetails.d.ts +11 -0
- package/dist/services/pools/poolDetails.d.ts.map +1 -0
- package/dist/services/pools/poolDetails.js +151 -0
- package/dist/services/pools/poolDetails.js.map +1 -0
- package/dist/services/pools/poolDiscovery.d.ts +12 -0
- package/dist/services/pools/poolDiscovery.d.ts.map +1 -0
- package/dist/services/pools/poolDiscovery.js +114 -0
- package/dist/services/pools/poolDiscovery.js.map +1 -0
- package/dist/services/quotes/QuoteService.d.ts +21 -12
- package/dist/services/quotes/QuoteService.d.ts.map +1 -1
- package/dist/services/quotes/QuoteService.js +44 -17
- package/dist/services/quotes/QuoteService.js.map +1 -1
- package/dist/services/routes/RouteService.d.ts +3 -3
- package/dist/services/routes/RouteService.d.ts.map +1 -1
- package/dist/services/routes/RouteService.js +3 -5
- package/dist/services/routes/RouteService.js.map +1 -1
- package/dist/services/swap/SwapService.d.ts +23 -19
- package/dist/services/swap/SwapService.d.ts.map +1 -1
- package/dist/services/swap/SwapService.js +36 -15
- package/dist/services/swap/SwapService.js.map +1 -1
- package/dist/services/tokens/tokenService.d.ts +3 -3
- package/dist/services/tokens/tokenService.d.ts.map +1 -1
- package/dist/services/tokens/tokenService.js +26 -37
- package/dist/services/tokens/tokenService.js.map +1 -1
- package/dist/services/trading/TradingLimitsService.d.ts +38 -0
- package/dist/services/trading/TradingLimitsService.d.ts.map +1 -0
- package/dist/services/trading/TradingLimitsService.js +157 -0
- package/dist/services/trading/TradingLimitsService.js.map +1 -0
- package/dist/services/trading/TradingService.d.ts +110 -0
- package/dist/services/trading/TradingService.d.ts.map +1 -0
- package/dist/services/trading/TradingService.js +162 -0
- package/dist/services/trading/TradingService.js.map +1 -0
- package/dist/services/trading/index.d.ts +3 -0
- package/dist/services/trading/index.d.ts.map +1 -0
- package/dist/services/trading/index.js +19 -0
- package/dist/services/trading/index.js.map +1 -0
- package/dist/utils/costUtils.js +4 -4
- package/dist/utils/costUtils.js.map +1 -1
- package/dist/utils/deadline.d.ts +21 -0
- package/dist/utils/deadline.d.ts.map +1 -0
- package/dist/utils/deadline.js +26 -0
- package/dist/utils/deadline.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/pathEncoder.d.ts +8 -2
- package/dist/utils/pathEncoder.d.ts.map +1 -1
- package/dist/utils/pathEncoder.js +19 -3
- package/dist/utils/pathEncoder.js.map +1 -1
- package/dist/utils/rateFeed.d.ts +18 -0
- package/dist/utils/rateFeed.d.ts.map +1 -0
- package/dist/utils/rateFeed.js +27 -0
- package/dist/utils/rateFeed.js.map +1 -0
- package/dist/utils/routeUtils.d.ts +53 -53
- package/dist/utils/routeUtils.d.ts.map +1 -1
- package/dist/utils/routeUtils.js +41 -41
- package/dist/utils/routeUtils.js.map +1 -1
- package/dist/utils/routes.d.ts +2 -8
- package/dist/utils/routes.d.ts.map +1 -1
- package/dist/utils/routes.js +5 -46
- package/dist/utils/routes.js.map +1 -1
- package/dist/utils/tokens.d.ts +1 -62
- package/dist/utils/tokens.d.ts.map +1 -1
- package/dist/utils/tokens.js +10 -163
- package/dist/utils/tokens.js.map +1 -1
- package/dist/utils/tradingLimits.d.ts +41 -0
- package/dist/utils/tradingLimits.d.ts.map +1 -0
- package/dist/utils/tradingLimits.js +171 -0
- package/dist/utils/tradingLimits.js.map +1 -0
- package/dist/utils/validation.d.ts +19 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +34 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +6 -6
- package/dist/cache/routes.42220.d.ts +0 -3
- package/dist/cache/routes.42220.d.ts.map +0 -1
- package/dist/cache/routes.42220.js +0 -112
- package/dist/cache/routes.42220.js.map +0 -1
- package/dist/cache/tokens.11142220.d.ts +0 -3
- package/dist/cache/tokens.11142220.d.ts.map +0 -1
- package/dist/cache/tokens.11142220.js +0 -129
- package/dist/cache/tokens.11142220.js.map +0 -1
- package/dist/cache/tokens.42220.d.ts +0 -3
- package/dist/cache/tokens.42220.d.ts.map +0 -1
- package/dist/cache/tokens.42220.js +0 -129
- package/dist/cache/tokens.42220.js.map +0 -1
- package/dist/core/abis/uniswapV3.d.ts +0 -4
- package/dist/core/abis/uniswapV3.d.ts.map +0 -1
- package/dist/core/abis/uniswapV3.js +0 -16
- package/dist/core/abis/uniswapV3.js.map +0 -1
- package/dist/core/constants/aaveConfig.d.ts +0 -7
- package/dist/core/constants/aaveConfig.d.ts.map +0 -1
- package/dist/core/constants/aaveConfig.js +0 -22
- package/dist/core/constants/aaveConfig.js.map +0 -1
- package/dist/core/constants/mentoAddresses.d.ts +0 -7
- package/dist/core/constants/mentoAddresses.d.ts.map +0 -1
- package/dist/core/constants/mentoAddresses.js +0 -10
- package/dist/core/constants/mentoAddresses.js.map +0 -1
- package/dist/core/constants/protocolAddresses.d.ts +0 -5
- package/dist/core/constants/protocolAddresses.d.ts.map +0 -1
- package/dist/core/constants/protocolAddresses.js +0 -8
- package/dist/core/constants/protocolAddresses.js.map +0 -1
- package/dist/services/tokens/supply/ISupplyCalculator.d.ts +0 -14
- package/dist/services/tokens/supply/ISupplyCalculator.d.ts.map +0 -1
- package/dist/services/tokens/supply/ISupplyCalculator.js.map +0 -1
- package/dist/services/tokens/supply/aaveSupplyCalculator.d.ts +0 -22
- package/dist/services/tokens/supply/aaveSupplyCalculator.d.ts.map +0 -1
- package/dist/services/tokens/supply/aaveSupplyCalculator.js +0 -46
- package/dist/services/tokens/supply/aaveSupplyCalculator.js.map +0 -1
- package/dist/services/tokens/supply/calculatorFactory.d.ts +0 -8
- package/dist/services/tokens/supply/calculatorFactory.d.ts.map +0 -1
- package/dist/services/tokens/supply/calculatorFactory.js.map +0 -1
- package/dist/services/tokens/supply/defaultCalculatorFactory.d.ts +0 -9
- package/dist/services/tokens/supply/defaultCalculatorFactory.d.ts.map +0 -1
- package/dist/services/tokens/supply/defaultCalculatorFactory.js +0 -28
- package/dist/services/tokens/supply/defaultCalculatorFactory.js.map +0 -1
- package/dist/services/tokens/supply/index.d.ts +0 -7
- package/dist/services/tokens/supply/index.d.ts.map +0 -1
- package/dist/services/tokens/supply/index.js.map +0 -1
- package/dist/services/tokens/supply/multisigSupplyCalculator.d.ts +0 -9
- package/dist/services/tokens/supply/multisigSupplyCalculator.d.ts.map +0 -1
- package/dist/services/tokens/supply/multisigSupplyCalculator.js +0 -33
- package/dist/services/tokens/supply/multisigSupplyCalculator.js.map +0 -1
- package/dist/services/tokens/supply/uniV3SupplyCalculator.d.ts +0 -21
- package/dist/services/tokens/supply/uniV3SupplyCalculator.d.ts.map +0 -1
- package/dist/services/tokens/supply/uniV3SupplyCalculator.js +0 -238
- package/dist/services/tokens/supply/uniV3SupplyCalculator.js.map +0 -1
- package/dist/services/tokens/supplyAdjustmentService.d.ts +0 -19
- package/dist/services/tokens/supplyAdjustmentService.d.ts.map +0 -1
- package/dist/services/tokens/supplyAdjustmentService.js +0 -49
- package/dist/services/tokens/supplyAdjustmentService.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,348 +1,205 @@
|
|
|
1
1
|
# Mento SDK
|
|
2
2
|
|
|
3
|
-
A TypeScript SDK for interacting with the Mento
|
|
3
|
+
A TypeScript SDK for interacting with the [Mento Protocol](https://www.mento.org/) on Celo. Provides a simple interface for token swaps, liquidity management, borrowing, and trading status queries.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @mento/sdk
|
|
8
|
+
npm install @mento-protocol/mento-sdk viem
|
|
9
9
|
# or
|
|
10
|
-
|
|
11
|
-
# or
|
|
12
|
-
pnpm add @mento/sdk
|
|
10
|
+
pnpm add @mento-protocol/mento-sdk viem
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
### Initialize with Viem
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { createPublicClient, http } from 'viem'
|
|
21
|
-
import { celo } from 'viem/chains'
|
|
22
|
-
import { Mento } from '@mento/sdk'
|
|
23
|
-
|
|
24
|
-
// Create Viem client
|
|
25
|
-
const provider = createPublicClient({
|
|
26
|
-
chain: celo,
|
|
27
|
-
transport: http(),
|
|
28
|
-
})
|
|
13
|
+
`viem` is a peer dependency required for blockchain interactions.
|
|
29
14
|
|
|
30
|
-
|
|
31
|
-
const mento = new Mento({ provider })
|
|
32
|
-
|
|
33
|
-
// Use the SDK
|
|
34
|
-
const stableTokens = await mento.tokens.getStableTokens()
|
|
35
|
-
console.log('Stable Tokens:', stableTokens)
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Initialize with Ethers.js
|
|
15
|
+
## Quick Start
|
|
39
16
|
|
|
40
17
|
```typescript
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
|
|
44
|
-
// Create Ethers provider
|
|
45
|
-
const provider = new JsonRpcProvider('YOUR_RPC_URL')
|
|
46
|
-
|
|
47
|
-
// Initialize Mento SDK
|
|
48
|
-
const mento = new Mento({ provider })
|
|
49
|
-
|
|
50
|
-
// Use the SDK
|
|
51
|
-
const collateralAssets = await mento.collateral.getCollateralAssets()
|
|
52
|
-
console.log('Collateral Assets:', collateralAssets)
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Development Setup
|
|
56
|
-
|
|
57
|
-
### Project Setup
|
|
58
|
-
|
|
59
|
-
1. Clone the repository
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
git clone git@github.com:mento-protocol/mento-sdk.git
|
|
63
|
-
cd mento-sdk
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
2. Install dependencies
|
|
18
|
+
import { Mento, ChainId, deadlineFromMinutes } from '@mento-protocol/mento-sdk'
|
|
19
|
+
import { parseUnits } from 'viem'
|
|
67
20
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Development Workflow
|
|
73
|
-
|
|
74
|
-
#### Build
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
pnpm build
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
#### Running Tests
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
# Run all tests
|
|
84
|
-
pnpm test
|
|
85
|
-
```
|
|
21
|
+
// Initialize the SDK (uses default public RPC)
|
|
22
|
+
const mento = await Mento.create(ChainId.CELO)
|
|
86
23
|
|
|
87
|
-
|
|
24
|
+
// Or with a custom RPC URL
|
|
25
|
+
const mento = await Mento.create(ChainId.CELO, 'https://your-rpc-url.com')
|
|
88
26
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
│ ├── abis/ # Contract ABIs
|
|
92
|
-
│ ├── adapters/ # Provider adapters (Ethers, Viem)
|
|
93
|
-
│ ├── constants/ # Constants and addresses
|
|
94
|
-
│ ├── services/ # Core services
|
|
95
|
-
│ ├── types/ # TypeScript type definitions
|
|
96
|
-
| ├── utils/ # Utility functions
|
|
97
|
-
│ └── index.ts # Main entry point
|
|
98
|
-
├── tests/
|
|
99
|
-
│ ├── unit/ # Unit tests
|
|
100
|
-
│ └── integration/ # Integration tests
|
|
27
|
+
// Or with an existing viem PublicClient
|
|
28
|
+
const mento = await Mento.create(ChainId.CELO, yourPublicClient)
|
|
101
29
|
```
|
|
102
30
|
|
|
103
|
-
##
|
|
31
|
+
## Services
|
|
104
32
|
|
|
105
|
-
|
|
33
|
+
The SDK is organized into service namespaces:
|
|
106
34
|
|
|
107
|
-
|
|
35
|
+
| Service | Description |
|
|
36
|
+
|---------|-------------|
|
|
37
|
+
| `mento.tokens` | Query stable tokens and collateral assets |
|
|
38
|
+
| `mento.pools` | Discover and inspect liquidity pools |
|
|
39
|
+
| `mento.routes` | Find trading routes (direct and multi-hop) |
|
|
40
|
+
| `mento.quotes` | Get expected swap output amounts |
|
|
41
|
+
| `mento.swap` | Build swap transactions with approvals |
|
|
42
|
+
| `mento.trading` | Check circuit breakers and trading limits |
|
|
43
|
+
| `mento.liquidity` | Add/remove liquidity, zap in/out |
|
|
44
|
+
| `mento.borrow` | Open, adjust, and close troves |
|
|
108
45
|
|
|
109
|
-
|
|
46
|
+
## Token Queries
|
|
110
47
|
|
|
111
48
|
```typescript
|
|
112
|
-
// Get all stable tokens
|
|
113
|
-
const
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
#### Collateral Assets
|
|
117
|
-
|
|
118
|
-
Retrieve collateral assets:
|
|
49
|
+
// Get all Mento stable tokens
|
|
50
|
+
const stableTokens = await mento.tokens.getStableTokens()
|
|
119
51
|
|
|
120
|
-
```typescript
|
|
121
52
|
// Get all collateral assets
|
|
122
|
-
const
|
|
53
|
+
const collateral = await mento.tokens.getCollateralAssets()
|
|
123
54
|
```
|
|
124
55
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
Query exchanges and tradable pairs:
|
|
56
|
+
## Swaps
|
|
128
57
|
|
|
129
58
|
```typescript
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
// Get
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
59
|
+
const USDm = '0x765DE816845861e75A25fCA122bb6898B8B1282a'
|
|
60
|
+
const CELO = '0x471EcE3750Da237f93B8E339c536989b8978a438'
|
|
61
|
+
|
|
62
|
+
// Get a quote
|
|
63
|
+
const amountIn = parseUnits('100', 18)
|
|
64
|
+
const expectedOut = await mento.quotes.getAmountOut(USDm, CELO, amountIn)
|
|
65
|
+
|
|
66
|
+
// Build a swap transaction (includes approval if needed)
|
|
67
|
+
const { approval, swap } = await mento.swap.buildSwapTransaction(
|
|
68
|
+
USDm,
|
|
69
|
+
CELO,
|
|
70
|
+
amountIn,
|
|
71
|
+
recipientAddress,
|
|
72
|
+
ownerAddress,
|
|
73
|
+
{ slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
140
74
|
)
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Write Operations
|
|
144
|
-
|
|
145
|
-
The SDK supports write transactions for submitting state-changing operations to the blockchain. Write operations require a signer (Ethers) or wallet client (Viem).
|
|
146
|
-
|
|
147
|
-
#### Setup for Write Operations
|
|
148
|
-
|
|
149
|
-
**With Viem:**
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
import { createPublicClient, createWalletClient, http } from 'viem'
|
|
153
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
154
|
-
import { celo } from 'viem/chains'
|
|
155
|
-
import { Mento } from '@mento/sdk'
|
|
156
|
-
|
|
157
|
-
// Create account from private key
|
|
158
|
-
const account = privateKeyToAccount('0x...')
|
|
159
|
-
|
|
160
|
-
// Create public and wallet clients
|
|
161
|
-
const publicClient = createPublicClient({
|
|
162
|
-
chain: celo,
|
|
163
|
-
transport: http('https://forno.celo.org'),
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
const walletClient = createWalletClient({
|
|
167
|
-
account,
|
|
168
|
-
chain: celo,
|
|
169
|
-
transport: http('https://forno.celo.org'),
|
|
170
|
-
})
|
|
171
75
|
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
76
|
+
// Execute with any viem wallet client
|
|
77
|
+
if (approval) {
|
|
78
|
+
await walletClient.sendTransaction(approval)
|
|
79
|
+
}
|
|
80
|
+
await walletClient.sendTransaction(swap.params)
|
|
177
81
|
```
|
|
178
82
|
|
|
179
|
-
|
|
83
|
+
## Routes
|
|
180
84
|
|
|
181
85
|
```typescript
|
|
182
|
-
|
|
183
|
-
|
|
86
|
+
// Find a route between two tokens
|
|
87
|
+
const route = await mento.routes.findRoute(USDm, CELO)
|
|
88
|
+
console.log(`Hops: ${route.path.length}`)
|
|
184
89
|
|
|
185
|
-
//
|
|
186
|
-
const
|
|
187
|
-
const signer = new Wallet('0x...', provider)
|
|
90
|
+
// Get all tradable routes (uses pre-generated cache by default)
|
|
91
|
+
const routes = await mento.routes.getRoutes()
|
|
188
92
|
|
|
189
|
-
//
|
|
190
|
-
const
|
|
191
|
-
provider,
|
|
192
|
-
signer, // Add signer for write operations
|
|
193
|
-
})
|
|
93
|
+
// Generate fresh routes from blockchain
|
|
94
|
+
const freshRoutes = await mento.routes.getRoutes({ cached: false })
|
|
194
95
|
```
|
|
195
96
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
Approve tokens for Mento protocol interactions:
|
|
97
|
+
## Trading Status
|
|
199
98
|
|
|
200
99
|
```typescript
|
|
201
|
-
//
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
// Approve USDC for Mento Broker
|
|
205
|
-
const tx = await adapter.writeContract({
|
|
206
|
-
address: '0x765DE816845861e75A25fCA122bb6898B8B1282a', // USDC on Celo
|
|
207
|
-
abi: ['function approve(address spender, uint256 amount) returns (bool)'],
|
|
208
|
-
functionName: 'approve',
|
|
209
|
-
args: [
|
|
210
|
-
'0x...', // Spender address (e.g., Mento Broker)
|
|
211
|
-
1000000n, // Amount (1 USDC with 6 decimals)
|
|
212
|
-
],
|
|
213
|
-
})
|
|
100
|
+
// Check if a pair is tradable (circuit breaker check)
|
|
101
|
+
const isTradable = await mento.trading.isPairTradable(USDm, CELO)
|
|
214
102
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
103
|
+
// Get full tradability status for a pool
|
|
104
|
+
const pools = await mento.pools.getPools()
|
|
105
|
+
const status = await mento.trading.getPoolTradabilityStatus(pools[0])
|
|
218
106
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
console.log('
|
|
107
|
+
if (!status.circuitBreakerOk) {
|
|
108
|
+
console.log('Trading suspended by circuit breaker')
|
|
109
|
+
} else if (!status.limitsOk) {
|
|
110
|
+
console.log('Trading limit reached')
|
|
111
|
+
}
|
|
223
112
|
```
|
|
224
113
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
Monitor transaction status and confirmations:
|
|
114
|
+
## Liquidity
|
|
228
115
|
|
|
229
116
|
```typescript
|
|
230
|
-
//
|
|
231
|
-
const
|
|
117
|
+
// Add liquidity to a pool
|
|
118
|
+
const addTx = await mento.liquidity.buildAddLiquidityTransaction(
|
|
119
|
+
poolAddress, tokenA, amountA, tokenB, amountB,
|
|
120
|
+
recipient, owner,
|
|
121
|
+
{ slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
122
|
+
)
|
|
232
123
|
|
|
233
|
-
//
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
124
|
+
// Zap in with a single token
|
|
125
|
+
const zapTx = await mento.liquidity.buildZapInTransaction(
|
|
126
|
+
poolAddress, tokenIn, amountIn, 0.5, // split ratio
|
|
127
|
+
recipient, owner,
|
|
128
|
+
{ slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
129
|
+
)
|
|
238
130
|
|
|
239
|
-
//
|
|
240
|
-
const
|
|
241
|
-
console.log('Transaction confirmed after 3 blocks')
|
|
131
|
+
// Get LP token balance
|
|
132
|
+
const balance = await mento.liquidity.getLPTokenBalance(poolAddress, owner)
|
|
242
133
|
```
|
|
243
134
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
Estimate gas before submitting transactions:
|
|
135
|
+
## Borrowing
|
|
247
136
|
|
|
248
137
|
```typescript
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
138
|
+
import { parseUnits } from 'viem'
|
|
139
|
+
|
|
140
|
+
// Open a trove (borrow against collateral)
|
|
141
|
+
const openTx = await mento.borrow.buildOpenTroveTransaction('USDm', {
|
|
142
|
+
owner: ownerAddress,
|
|
143
|
+
ownerIndex: 0,
|
|
144
|
+
collAmount: parseUnits('10', 18),
|
|
145
|
+
boldAmount: parseUnits('1000', 18),
|
|
146
|
+
annualInterestRate: parseUnits('0.05', 18), // 5%
|
|
147
|
+
maxUpfrontFee: parseUnits('100', 18),
|
|
255
148
|
})
|
|
256
149
|
|
|
257
|
-
|
|
258
|
-
|
|
150
|
+
// Get trove data
|
|
151
|
+
const trove = await mento.borrow.getTroveData('USDm', troveId)
|
|
259
152
|
|
|
260
|
-
|
|
153
|
+
// Get system parameters
|
|
154
|
+
const params = await mento.borrow.getSystemParams('USDm')
|
|
261
155
|
|
|
262
|
-
|
|
156
|
+
// Predict upfront fee before opening
|
|
157
|
+
const fee = await mento.borrow.predictOpenTroveUpfrontFee(
|
|
158
|
+
'USDm',
|
|
159
|
+
parseUnits('1000', 18),
|
|
160
|
+
parseUnits('0.05', 18)
|
|
161
|
+
)
|
|
162
|
+
```
|
|
263
163
|
|
|
264
|
-
|
|
265
|
-
// Legacy gas price (Type 0/1 transactions)
|
|
266
|
-
const tx = await adapter.writeContract({
|
|
267
|
-
address: '0x...',
|
|
268
|
-
abi: [...],
|
|
269
|
-
functionName: 'approve',
|
|
270
|
-
args: [...],
|
|
271
|
-
gasLimit: 100000n, // Custom gas limit
|
|
272
|
-
gasPrice: 5000000000n, // 5 gwei
|
|
273
|
-
})
|
|
164
|
+
## Supported Chains
|
|
274
165
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
functionName: 'approve',
|
|
280
|
-
args: [...],
|
|
281
|
-
gasLimit: 100000n,
|
|
282
|
-
maxFeePerGas: 10000000000n, // 10 gwei max
|
|
283
|
-
maxPriorityFeePerGas: 2000000000n, // 2 gwei priority
|
|
284
|
-
})
|
|
166
|
+
| Chain | Chain ID | Constant |
|
|
167
|
+
|-------|----------|----------|
|
|
168
|
+
| Celo Mainnet | 42220 | `ChainId.CELO` |
|
|
169
|
+
| Celo Sepolia | 11142220 | `ChainId.CELO_SEPOLIA` |
|
|
285
170
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
args: [...],
|
|
292
|
-
nonce: 42n, // Explicit nonce
|
|
293
|
-
})
|
|
294
|
-
```
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Install dependencies
|
|
175
|
+
pnpm install
|
|
295
176
|
|
|
296
|
-
|
|
177
|
+
# Build
|
|
178
|
+
pnpm build
|
|
297
179
|
|
|
298
|
-
|
|
180
|
+
# Run tests
|
|
181
|
+
pnpm test
|
|
299
182
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
try {
|
|
304
|
-
const tx = await adapter.writeContract({...})
|
|
305
|
-
const receipt = await tx.wait()
|
|
306
|
-
} catch (error) {
|
|
307
|
-
if (error instanceof ValidationError) {
|
|
308
|
-
// Pre-submission validation errors (no gas cost)
|
|
309
|
-
console.error('Invalid parameters:', error.message)
|
|
310
|
-
} else if (error instanceof ExecutionError) {
|
|
311
|
-
// Transaction reverted on-chain (gas was consumed)
|
|
312
|
-
console.error('Transaction failed:', error.message)
|
|
313
|
-
console.error('Revert reason:', error.revertReason)
|
|
314
|
-
} else if (error instanceof NetworkError) {
|
|
315
|
-
// RPC/network errors
|
|
316
|
-
console.error('Network error:', error.message)
|
|
317
|
-
if (error.retry) {
|
|
318
|
-
console.log('This error is retryable')
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
183
|
+
# Lint
|
|
184
|
+
pnpm lint
|
|
322
185
|
```
|
|
323
186
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
Additional helper methods for write operations:
|
|
187
|
+
### Cache Generation
|
|
327
188
|
|
|
328
|
-
|
|
329
|
-
// Get signer/wallet address
|
|
330
|
-
const address = await adapter.getSignerAddress()
|
|
331
|
-
console.log('Wallet address:', address)
|
|
189
|
+
The SDK ships with pre-generated route and token caches for fast startup:
|
|
332
190
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
191
|
+
```bash
|
|
192
|
+
pnpm cacheRoutes
|
|
193
|
+
pnpm cacheTokens
|
|
336
194
|
```
|
|
337
195
|
|
|
338
|
-
|
|
196
|
+
Override RPC URLs via environment variables:
|
|
339
197
|
|
|
340
|
-
|
|
198
|
+
```bash
|
|
199
|
+
CELO_RPC_URL=https://your-rpc.com pnpm cacheRoutes
|
|
200
|
+
CELO_SEPOLIA_RPC_URL=https://your-sepolia-rpc.com pnpm cacheTokens
|
|
201
|
+
```
|
|
341
202
|
|
|
342
203
|
## License
|
|
343
204
|
|
|
344
205
|
MIT
|
|
345
|
-
|
|
346
|
-
---
|
|
347
|
-
|
|
348
|
-
For more detailed documentation and examples, visit our [documentation site](https://docs.mento.org).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RouteWithCost } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Cached routes indexed by chain ID
|
|
4
|
+
* Routes that don't exist for a chain will return an empty array
|
|
5
|
+
*/
|
|
6
|
+
export declare const cachedRoutes: Record<number, RouteWithCost[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Get cached routes for a specific chain
|
|
9
|
+
* @param chainId - The chain ID
|
|
10
|
+
* @returns The cached routes array, or empty array if not available
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCachedRoutes(chainId: number): RouteWithCost[];
|
|
13
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/cache/routes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAusWxD,CAAA;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAEhE"}
|