@mento-protocol/mento-sdk 3.0.0-beta.9 → 3.0.0-rc.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/README.md +132 -309
- package/dist/cache/routes.js +11389 -36
- package/dist/cache/tokens.js +8 -8
- 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/borrowerOperations.d.ts +9 -0
- package/dist/core/abis/borrowerOperations.js +89 -0
- package/dist/core/abis/fpmm.d.ts +128 -18
- package/dist/core/abis/fpmm.js +29 -1
- package/dist/core/abis/fpmmFactory.d.ts +64 -0
- package/dist/core/abis/fpmmFactory.js +17 -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 +10 -1
- package/dist/core/abis/index.js +10 -1
- 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/router.d.ts +520 -1
- package/dist/core/abis/router.js +35 -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 +10 -0
- package/dist/core/abis/virtualPool.js +1 -0
- package/dist/core/abis/virtualPoolFactory.d.ts +32 -0
- package/dist/core/abis/virtualPoolFactory.js +8 -0
- package/dist/core/constants/addresses.js +11 -8
- 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 +30 -0
- package/dist/core/constants/index.d.ts +2 -3
- package/dist/core/constants/index.js +2 -3
- package/dist/core/errors/index.d.ts +1 -0
- package/dist/core/errors/index.js +1 -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 +6 -0
- package/dist/core/errors/router.js +11 -1
- package/dist/core/types/borrow.d.ts +87 -0
- package/dist/{services/tokens/supply/ISupplyCalculator.js → core/types/borrow.js} +1 -1
- package/dist/core/types/index.d.ts +2 -0
- package/dist/core/types/index.js +2 -0
- package/dist/core/types/liquidity.d.ts +151 -0
- package/dist/{services/tokens/supply/calculatorFactory.js → core/types/liquidity.js} +1 -1
- package/dist/core/types/pool.d.ts +8 -8
- package/dist/core/types/token.d.ts +0 -14
- package/dist/esm/cache/routes.js +11478 -0
- package/dist/esm/cache/tokens.js +371 -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 +20 -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 +6 -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 +76 -0
- package/dist/esm/core/constants/borrowConstants.js +12 -0
- package/dist/esm/core/constants/borrowRegistries.js +25 -0
- package/dist/esm/core/constants/chainId.js +5 -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 +123 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/services/borrow/BorrowService.js +418 -0
- package/dist/esm/services/borrow/borrowHelpers.js +3 -0
- package/dist/esm/services/borrow/borrowMath.js +119 -0
- package/dist/esm/services/borrow/index.js +1 -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 +213 -0
- package/dist/esm/services/borrow/internal/borrowRegistryReader.js +91 -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 +82 -0
- package/dist/esm/services/index.js +6 -0
- package/dist/esm/services/liquidity/LiquidityService.js +139 -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 +66 -0
- package/dist/esm/services/liquidity/zapHelpers.js +124 -0
- package/dist/esm/services/liquidity/zapIn.js +119 -0
- package/dist/esm/services/liquidity/zapOut.js +236 -0
- package/dist/esm/services/pools/PoolService.js +100 -0
- package/dist/esm/services/pools/index.js +1 -0
- package/dist/esm/services/pools/poolDetails.js +146 -0
- package/dist/esm/services/pools/poolDiscovery.js +109 -0
- package/dist/esm/services/quotes/QuoteService.js +83 -0
- package/dist/esm/services/quotes/index.js +1 -0
- package/dist/esm/services/routes/RouteService.js +210 -0
- package/dist/esm/services/routes/index.js +1 -0
- package/dist/esm/services/swap/SwapService.js +190 -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 +120 -0
- package/dist/esm/services/trading/TradingLimitsService.js +151 -0
- package/dist/esm/services/trading/TradingService.js +157 -0
- package/dist/esm/services/trading/index.js +2 -0
- package/dist/esm/utils/chainConfig.js +57 -0
- package/dist/esm/utils/costUtils.js +57 -0
- package/dist/esm/utils/deadline.js +22 -0
- package/dist/esm/utils/index.js +9 -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 +22 -3
- package/dist/index.js +43 -12
- package/dist/services/borrow/BorrowService.d.ts +348 -0
- package/dist/services/borrow/BorrowService.js +423 -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 +13 -0
- package/dist/services/borrow/borrowMath.js +129 -0
- package/dist/services/borrow/index.d.ts +2 -0
- package/dist/services/{tokens/supply → borrow}/index.js +1 -6
- 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 +28 -0
- package/dist/services/borrow/internal/borrowReadService.js +218 -0
- package/dist/services/borrow/internal/borrowRegistryReader.d.ts +5 -0
- package/dist/services/borrow/internal/borrowRegistryReader.js +96 -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 +13 -0
- package/dist/services/borrow/internal/borrowValidation.js +96 -0
- package/dist/services/index.d.ts +1 -2
- package/dist/services/index.js +1 -2
- package/dist/services/liquidity/LiquidityService.d.ts +122 -0
- package/dist/services/liquidity/LiquidityService.js +144 -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 +13 -0
- package/dist/services/liquidity/liquidityHelpers.js +74 -0
- package/dist/services/liquidity/zapHelpers.d.ts +66 -0
- package/dist/services/liquidity/zapHelpers.js +133 -0
- package/dist/services/liquidity/zapIn.d.ts +17 -0
- package/dist/services/liquidity/zapIn.js +125 -0
- package/dist/services/liquidity/zapOut.d.ts +17 -0
- package/dist/services/liquidity/zapOut.js +242 -0
- package/dist/services/pools/PoolService.d.ts +13 -0
- package/dist/services/pools/PoolService.js +18 -5
- package/dist/services/pools/poolDetails.js +45 -30
- package/dist/services/pools/poolDiscovery.d.ts +2 -3
- package/dist/services/pools/poolDiscovery.js +35 -36
- package/dist/services/quotes/QuoteService.js +21 -7
- package/dist/services/routes/RouteService.js +1 -2
- package/dist/services/swap/SwapService.d.ts +15 -5
- package/dist/services/swap/SwapService.js +23 -8
- package/dist/services/tokens/tokenService.d.ts +3 -3
- package/dist/services/tokens/tokenService.js +26 -37
- package/dist/services/trading/TradingLimitsService.js +0 -1
- package/dist/utils/costUtils.js +7 -5
- package/dist/utils/deadline.d.ts +21 -0
- package/dist/utils/deadline.js +26 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/pathEncoder.d.ts +5 -0
- package/package.json +35 -13
- package/dist/cache/routes.d.ts.map +0 -1
- package/dist/cache/routes.js.map +0 -1
- package/dist/cache/tokens.d.ts.map +0 -1
- package/dist/cache/tokens.js.map +0 -1
- package/dist/core/abis/bipoolmanager.d.ts.map +0 -1
- package/dist/core/abis/bipoolmanager.js.map +0 -1
- package/dist/core/abis/breakerbox.d.ts.map +0 -1
- package/dist/core/abis/breakerbox.js.map +0 -1
- package/dist/core/abis/broker.d.ts.map +0 -1
- package/dist/core/abis/broker.js.map +0 -1
- package/dist/core/abis/erc20.d.ts.map +0 -1
- package/dist/core/abis/erc20.js.map +0 -1
- package/dist/core/abis/fpmm.d.ts.map +0 -1
- package/dist/core/abis/fpmm.js.map +0 -1
- package/dist/core/abis/fpmmFactory.d.ts.map +0 -1
- package/dist/core/abis/fpmmFactory.js.map +0 -1
- package/dist/core/abis/index.d.ts.map +0 -1
- package/dist/core/abis/index.js.map +0 -1
- package/dist/core/abis/pricingmodule.d.ts.map +0 -1
- package/dist/core/abis/pricingmodule.js.map +0 -1
- package/dist/core/abis/reserve.d.ts.map +0 -1
- package/dist/core/abis/reserve.js.map +0 -1
- package/dist/core/abis/router.d.ts.map +0 -1
- package/dist/core/abis/router.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/abis/virtualPool.d.ts.map +0 -1
- package/dist/core/abis/virtualPool.js.map +0 -1
- package/dist/core/abis/virtualPoolFactory.d.ts.map +0 -1
- package/dist/core/abis/virtualPoolFactory.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/addresses.d.ts.map +0 -1
- package/dist/core/constants/addresses.js.map +0 -1
- package/dist/core/constants/chainId.d.ts.map +0 -1
- package/dist/core/constants/chainId.js.map +0 -1
- package/dist/core/constants/contractNames.d.ts.map +0 -1
- package/dist/core/constants/contractNames.js.map +0 -1
- package/dist/core/constants/index.d.ts.map +0 -1
- package/dist/core/constants/index.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/core/errors/base.d.ts.map +0 -1
- package/dist/core/errors/base.js.map +0 -1
- package/dist/core/errors/index.d.ts.map +0 -1
- package/dist/core/errors/index.js.map +0 -1
- package/dist/core/errors/router.d.ts.map +0 -1
- package/dist/core/errors/router.js.map +0 -1
- package/dist/core/types/contractAddresses.d.ts.map +0 -1
- package/dist/core/types/contractAddresses.js.map +0 -1
- package/dist/core/types/index.d.ts.map +0 -1
- package/dist/core/types/index.js.map +0 -1
- package/dist/core/types/pool.d.ts.map +0 -1
- package/dist/core/types/pool.js.map +0 -1
- package/dist/core/types/provider.d.ts.map +0 -1
- package/dist/core/types/provider.js.map +0 -1
- package/dist/core/types/route.d.ts.map +0 -1
- package/dist/core/types/route.js.map +0 -1
- package/dist/core/types/token.d.ts.map +0 -1
- package/dist/core/types/token.js.map +0 -1
- package/dist/core/types/tradingLimits.d.ts.map +0 -1
- package/dist/core/types/tradingLimits.js.map +0 -1
- package/dist/core/types/tradingMode.d.ts.map +0 -1
- package/dist/core/types/tradingMode.js.map +0 -1
- package/dist/core/types/transaction.d.ts.map +0 -1
- package/dist/core/types/transaction.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js.map +0 -1
- package/dist/services/pools/PoolService.d.ts.map +0 -1
- package/dist/services/pools/PoolService.js.map +0 -1
- package/dist/services/pools/index.d.ts.map +0 -1
- package/dist/services/pools/index.js.map +0 -1
- package/dist/services/pools/poolDetails.d.ts.map +0 -1
- package/dist/services/pools/poolDetails.js.map +0 -1
- package/dist/services/pools/poolDiscovery.d.ts.map +0 -1
- package/dist/services/pools/poolDiscovery.js.map +0 -1
- package/dist/services/quotes/QuoteService.d.ts.map +0 -1
- package/dist/services/quotes/QuoteService.js.map +0 -1
- package/dist/services/quotes/index.d.ts.map +0 -1
- package/dist/services/quotes/index.js.map +0 -1
- package/dist/services/routes/RouteService.d.ts.map +0 -1
- package/dist/services/routes/RouteService.js.map +0 -1
- package/dist/services/routes/index.d.ts.map +0 -1
- package/dist/services/routes/index.js.map +0 -1
- package/dist/services/swap/SwapService.d.ts.map +0 -1
- package/dist/services/swap/SwapService.js.map +0 -1
- package/dist/services/swap/index.d.ts.map +0 -1
- package/dist/services/swap/index.js.map +0 -1
- package/dist/services/tokens/index.d.ts.map +0 -1
- package/dist/services/tokens/index.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 -15
- package/dist/services/tokens/supplyAdjustmentService.d.ts.map +0 -1
- package/dist/services/tokens/supplyAdjustmentService.js +0 -44
- package/dist/services/tokens/supplyAdjustmentService.js.map +0 -1
- package/dist/services/tokens/tokenService.d.ts.map +0 -1
- package/dist/services/tokens/tokenService.js.map +0 -1
- package/dist/services/trading/TradingLimitsService.d.ts.map +0 -1
- package/dist/services/trading/TradingLimitsService.js.map +0 -1
- package/dist/services/trading/TradingService.d.ts.map +0 -1
- package/dist/services/trading/TradingService.js.map +0 -1
- package/dist/services/trading/index.d.ts.map +0 -1
- package/dist/services/trading/index.js.map +0 -1
- package/dist/utils/chainConfig.d.ts.map +0 -1
- package/dist/utils/chainConfig.js.map +0 -1
- package/dist/utils/costUtils.d.ts.map +0 -1
- package/dist/utils/costUtils.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/pathEncoder.d.ts.map +0 -1
- package/dist/utils/pathEncoder.js.map +0 -1
- package/dist/utils/rateFeed.d.ts.map +0 -1
- package/dist/utils/rateFeed.js.map +0 -1
- package/dist/utils/retry.d.ts.map +0 -1
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/routeUtils.d.ts.map +0 -1
- package/dist/utils/routeUtils.js.map +0 -1
- package/dist/utils/routes.d.ts.map +0 -1
- package/dist/utils/routes.js.map +0 -1
- package/dist/utils/sortUtils.d.ts.map +0 -1
- package/dist/utils/sortUtils.js.map +0 -1
- package/dist/utils/tokens.d.ts.map +0 -1
- package/dist/utils/tokens.js.map +0 -1
- package/dist/utils/tradingLimits.d.ts.map +0 -1
- package/dist/utils/tradingLimits.js.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,382 +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/). 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
|
-
})
|
|
29
|
-
|
|
30
|
-
// Initialize Mento SDK
|
|
31
|
-
const mento = new Mento({ provider })
|
|
13
|
+
`viem` is a peer dependency required for blockchain interactions.
|
|
32
14
|
|
|
33
|
-
|
|
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
|
-
```
|
|
18
|
+
import { Mento, ChainId, deadlineFromMinutes } from '@mento-protocol/mento-sdk'
|
|
19
|
+
import { parseUnits } from 'viem'
|
|
65
20
|
|
|
66
|
-
|
|
21
|
+
// Initialize the SDK (uses default public RPC)
|
|
22
|
+
const mento = await Mento.create(ChainId.CELO)
|
|
67
23
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Development Workflow
|
|
24
|
+
// Or with a custom RPC URL
|
|
25
|
+
const mento = await Mento.create(ChainId.CELO, 'https://your-rpc-url.com')
|
|
73
26
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
pnpm build
|
|
27
|
+
// Or with an existing viem PublicClient
|
|
28
|
+
const mento = await Mento.create(ChainId.CELO, yourPublicClient)
|
|
78
29
|
```
|
|
79
30
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
# Run all tests
|
|
84
|
-
pnpm test
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
#### Cache Generation Scripts
|
|
88
|
-
|
|
89
|
-
The SDK includes scripts to generate and update cached route and token data:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
# Generate route cache
|
|
93
|
-
pnpm cacheRoutes
|
|
94
|
-
|
|
95
|
-
# Generate token cache
|
|
96
|
-
pnpm cacheTokens
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**Environment Variables:**
|
|
100
|
-
|
|
101
|
-
You can override the default RPC URLs used by cache generation scripts:
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# Use custom RPC for Celo mainnet
|
|
105
|
-
export CELO_RPC_URL=https://your-custom-rpc.example.com
|
|
106
|
-
pnpm cacheRoutes
|
|
107
|
-
|
|
108
|
-
# Use custom RPC for Celo Sepolia testnet
|
|
109
|
-
export CELO_SEPOLIA_RPC_URL=https://your-sepolia-rpc.example.com
|
|
110
|
-
pnpm cacheRoutes
|
|
111
|
-
|
|
112
|
-
# Or set both
|
|
113
|
-
CELO_RPC_URL=https://your-rpc.com CELO_SEPOLIA_RPC_URL=https://your-sepolia.com pnpm cacheRoutes
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
By default, scripts use the public Forno RPC endpoints:
|
|
117
|
-
|
|
118
|
-
- Celo mainnet: `https://forno.celo.org`
|
|
119
|
-
- Celo Sepolia: `https://forno.celo-sepolia.celo-testnet.org`
|
|
120
|
-
|
|
121
|
-
### Project Structure
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
├── src/
|
|
125
|
-
│ ├── abis/ # Contract ABIs
|
|
126
|
-
│ ├── adapters/ # Provider adapters (Ethers, Viem)
|
|
127
|
-
│ ├── constants/ # Constants and addresses
|
|
128
|
-
│ ├── services/ # Core services
|
|
129
|
-
│ ├── types/ # TypeScript type definitions
|
|
130
|
-
| ├── utils/ # Utility functions
|
|
131
|
-
│ └── index.ts # Main entry point
|
|
132
|
-
├── tests/
|
|
133
|
-
│ ├── unit/ # Unit tests
|
|
134
|
-
│ └── integration/ # Integration tests
|
|
135
|
-
```
|
|
31
|
+
## Services
|
|
136
32
|
|
|
137
|
-
|
|
33
|
+
The SDK is organized into service namespaces:
|
|
138
34
|
|
|
139
|
-
|
|
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 |
|
|
140
45
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
Query Mento stable tokens:
|
|
46
|
+
## Token Queries
|
|
144
47
|
|
|
145
48
|
```typescript
|
|
146
|
-
// Get all stable tokens
|
|
147
|
-
const
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
#### Collateral Assets
|
|
151
|
-
|
|
152
|
-
Retrieve collateral assets:
|
|
49
|
+
// Get all Mento stable tokens
|
|
50
|
+
const stableTokens = await mento.tokens.getStableTokens()
|
|
153
51
|
|
|
154
|
-
```typescript
|
|
155
52
|
// Get all collateral assets
|
|
156
|
-
const
|
|
53
|
+
const collateral = await mento.tokens.getCollateralAssets()
|
|
157
54
|
```
|
|
158
55
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
Query exchanges and tradable pairs:
|
|
56
|
+
## Swaps
|
|
162
57
|
|
|
163
58
|
```typescript
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
// Get
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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) }
|
|
174
74
|
)
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Write Operations
|
|
178
|
-
|
|
179
|
-
The SDK supports write transactions for submitting state-changing operations to the blockchain. Write operations require a signer (Ethers) or wallet client (Viem).
|
|
180
|
-
|
|
181
|
-
#### Setup for Write Operations
|
|
182
|
-
|
|
183
|
-
**With Viem:**
|
|
184
75
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// Create account from private key
|
|
192
|
-
const account = privateKeyToAccount('0x...')
|
|
193
|
-
|
|
194
|
-
// Create public and wallet clients
|
|
195
|
-
const publicClient = createPublicClient({
|
|
196
|
-
chain: celo,
|
|
197
|
-
transport: http('https://forno.celo.org'),
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
const walletClient = createWalletClient({
|
|
201
|
-
account,
|
|
202
|
-
chain: celo,
|
|
203
|
-
transport: http('https://forno.celo.org'),
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
// Initialize SDK with write support
|
|
207
|
-
const mento = await Mento.create({
|
|
208
|
-
provider: publicClient,
|
|
209
|
-
signer: walletClient, // Add wallet client for write operations
|
|
210
|
-
})
|
|
76
|
+
// Execute with any viem wallet client
|
|
77
|
+
if (approval) {
|
|
78
|
+
await walletClient.sendTransaction(approval)
|
|
79
|
+
}
|
|
80
|
+
await walletClient.sendTransaction(swap.params)
|
|
211
81
|
```
|
|
212
82
|
|
|
213
|
-
|
|
83
|
+
## Routes
|
|
214
84
|
|
|
215
85
|
```typescript
|
|
216
|
-
|
|
217
|
-
|
|
86
|
+
// Find a route between two tokens
|
|
87
|
+
const route = await mento.routes.findRoute(USDm, CELO)
|
|
88
|
+
console.log(`Hops: ${route.path.length}`)
|
|
218
89
|
|
|
219
|
-
//
|
|
220
|
-
const
|
|
221
|
-
const signer = new Wallet('0x...', provider)
|
|
90
|
+
// Get all tradable routes (uses pre-generated cache by default)
|
|
91
|
+
const routes = await mento.routes.getRoutes()
|
|
222
92
|
|
|
223
|
-
//
|
|
224
|
-
const
|
|
225
|
-
provider,
|
|
226
|
-
signer, // Add signer for write operations
|
|
227
|
-
})
|
|
93
|
+
// Generate fresh routes from blockchain
|
|
94
|
+
const freshRoutes = await mento.routes.getRoutes({ cached: false })
|
|
228
95
|
```
|
|
229
96
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
Approve tokens for Mento protocol interactions:
|
|
97
|
+
## Trading Status
|
|
233
98
|
|
|
234
99
|
```typescript
|
|
235
|
-
//
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
// Approve USDC for Mento Broker
|
|
239
|
-
const tx = await adapter.writeContract({
|
|
240
|
-
address: '0x765DE816845861e75A25fCA122bb6898B8B1282a', // USDC on Celo
|
|
241
|
-
abi: ['function approve(address spender, uint256 amount) returns (bool)'],
|
|
242
|
-
functionName: 'approve',
|
|
243
|
-
args: [
|
|
244
|
-
'0x...', // Spender address (e.g., Mento Broker)
|
|
245
|
-
1000000n, // Amount (1 USDC with 6 decimals)
|
|
246
|
-
],
|
|
247
|
-
})
|
|
100
|
+
// Check if a pair is tradable (circuit breaker check)
|
|
101
|
+
const isTradable = await mento.trading.isPairTradable(USDm, CELO)
|
|
248
102
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
103
|
+
// Get full tradability status for a pool
|
|
104
|
+
const pools = await mento.pools.getPools()
|
|
105
|
+
const status = await mento.trading.getPoolTradabilityStatus(pools[0])
|
|
252
106
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
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
|
+
}
|
|
257
112
|
```
|
|
258
113
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
Monitor transaction status and confirmations:
|
|
114
|
+
## Liquidity
|
|
262
115
|
|
|
263
116
|
```typescript
|
|
264
|
-
//
|
|
265
|
-
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
|
+
)
|
|
266
123
|
|
|
267
|
-
//
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
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
|
+
)
|
|
272
130
|
|
|
273
|
-
//
|
|
274
|
-
const
|
|
275
|
-
console.log('Transaction confirmed after 3 blocks')
|
|
131
|
+
// Get LP token balance
|
|
132
|
+
const balance = await mento.liquidity.getLPTokenBalance(poolAddress, owner)
|
|
276
133
|
```
|
|
277
134
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
Estimate gas before submitting transactions:
|
|
135
|
+
## Borrowing
|
|
281
136
|
|
|
282
137
|
```typescript
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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),
|
|
289
148
|
})
|
|
290
149
|
|
|
291
|
-
|
|
292
|
-
|
|
150
|
+
// Get trove data
|
|
151
|
+
const trove = await mento.borrow.getTroveData('USDm', troveId)
|
|
293
152
|
|
|
294
|
-
|
|
153
|
+
// Get system parameters
|
|
154
|
+
const params = await mento.borrow.getSystemParams('USDm')
|
|
295
155
|
|
|
296
|
-
|
|
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
|
+
```
|
|
297
163
|
|
|
298
|
-
|
|
299
|
-
// Legacy gas price (Type 0/1 transactions)
|
|
300
|
-
const tx = await adapter.writeContract({
|
|
301
|
-
address: '0x...',
|
|
302
|
-
abi: [...],
|
|
303
|
-
functionName: 'approve',
|
|
304
|
-
args: [...],
|
|
305
|
-
gasLimit: 100000n, // Custom gas limit
|
|
306
|
-
gasPrice: 5000000000n, // 5 gwei
|
|
307
|
-
})
|
|
164
|
+
## Supported Chains
|
|
308
165
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
functionName: 'approve',
|
|
314
|
-
args: [...],
|
|
315
|
-
gasLimit: 100000n,
|
|
316
|
-
maxFeePerGas: 10000000000n, // 10 gwei max
|
|
317
|
-
maxPriorityFeePerGas: 2000000000n, // 2 gwei priority
|
|
318
|
-
})
|
|
166
|
+
| Chain | Chain ID | Constant |
|
|
167
|
+
|-------|----------|----------|
|
|
168
|
+
| Celo Mainnet | 42220 | `ChainId.CELO` |
|
|
169
|
+
| Celo Sepolia | 11142220 | `ChainId.CELO_SEPOLIA` |
|
|
319
170
|
|
|
320
|
-
|
|
321
|
-
const tx = await adapter.writeContract({
|
|
322
|
-
address: '0x...',
|
|
323
|
-
abi: [...],
|
|
324
|
-
functionName: 'approve',
|
|
325
|
-
args: [...],
|
|
326
|
-
nonce: 42n, // Explicit nonce
|
|
327
|
-
})
|
|
328
|
-
```
|
|
171
|
+
## Development
|
|
329
172
|
|
|
330
|
-
|
|
173
|
+
```bash
|
|
174
|
+
# Install dependencies
|
|
175
|
+
pnpm install
|
|
331
176
|
|
|
332
|
-
|
|
177
|
+
# Build
|
|
178
|
+
pnpm build
|
|
333
179
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
try {
|
|
338
|
-
const tx = await adapter.writeContract({...})
|
|
339
|
-
const receipt = await tx.wait()
|
|
340
|
-
} catch (error) {
|
|
341
|
-
if (error instanceof ValidationError) {
|
|
342
|
-
// Pre-submission validation errors (no gas cost)
|
|
343
|
-
console.error('Invalid parameters:', error.message)
|
|
344
|
-
} else if (error instanceof ExecutionError) {
|
|
345
|
-
// Transaction reverted on-chain (gas was consumed)
|
|
346
|
-
console.error('Transaction failed:', error.message)
|
|
347
|
-
console.error('Revert reason:', error.revertReason)
|
|
348
|
-
} else if (error instanceof NetworkError) {
|
|
349
|
-
// RPC/network errors
|
|
350
|
-
console.error('Network error:', error.message)
|
|
351
|
-
if (error.retry) {
|
|
352
|
-
console.log('This error is retryable')
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
```
|
|
180
|
+
# Run tests
|
|
181
|
+
pnpm test
|
|
357
182
|
|
|
358
|
-
|
|
183
|
+
# Lint
|
|
184
|
+
pnpm lint
|
|
185
|
+
```
|
|
359
186
|
|
|
360
|
-
|
|
187
|
+
### Cache Generation
|
|
361
188
|
|
|
362
|
-
|
|
363
|
-
// Get signer/wallet address
|
|
364
|
-
const address = await adapter.getSignerAddress()
|
|
365
|
-
console.log('Wallet address:', address)
|
|
189
|
+
The SDK ships with pre-generated route and token caches for fast startup:
|
|
366
190
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
191
|
+
```bash
|
|
192
|
+
pnpm cacheRoutes
|
|
193
|
+
pnpm cacheTokens
|
|
370
194
|
```
|
|
371
195
|
|
|
372
|
-
|
|
196
|
+
Override RPC URLs via environment variables:
|
|
373
197
|
|
|
374
|
-
|
|
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
|
+
```
|
|
375
202
|
|
|
376
203
|
## License
|
|
377
204
|
|
|
378
205
|
MIT
|
|
379
|
-
|
|
380
|
-
---
|
|
381
|
-
|
|
382
|
-
For more detailed documentation and examples, visit our [documentation site](https://docs.mento.org).
|