@mento-protocol/mento-sdk 3.2.2-beta1 → 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
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { pad, hexToBigInt, numberToHex } from 'viem';
|
|
2
|
-
/** V2 trading limits use 15 decimals internally */
|
|
3
|
-
const V2_INTERNAL_DECIMALS = 15;
|
|
4
|
-
/** V2 L0 window is fixed at 5 minutes */
|
|
5
|
-
const V2_L0_TIMESTEP = 5 * 60; // 300 seconds
|
|
6
|
-
/** V2 L1 window is fixed at 1 day */
|
|
7
|
-
const V2_L1_TIMESTEP = 24 * 60 * 60; // 86400 seconds
|
|
8
|
-
/** Far future timestamp for global limits (year 2030) */
|
|
9
|
-
const TIMESTAMP_FAR_FUTURE = 1893456000;
|
|
10
|
-
/**
|
|
11
|
-
* Compute limit ID for Broker (V1) trading limits.
|
|
12
|
-
* limitId = exchangeId XOR bytes32(uint256(uint160(token)))
|
|
13
|
-
*
|
|
14
|
-
* @param exchangeId - The exchange ID (bytes32)
|
|
15
|
-
* @param token - The token address
|
|
16
|
-
* @returns The limit ID as hex string
|
|
17
|
-
*/
|
|
18
|
-
export function computeLimitId(exchangeId, token) {
|
|
19
|
-
// Pad token address to 32 bytes (left-padded with zeros)
|
|
20
|
-
const tokenBytes32 = pad(token, { size: 32 });
|
|
21
|
-
// Convert both to BigInt for XOR operation
|
|
22
|
-
const exchangeIdBigInt = hexToBigInt(exchangeId);
|
|
23
|
-
const tokenBigInt = hexToBigInt(tokenBytes32);
|
|
24
|
-
// XOR operation
|
|
25
|
-
const limitIdBigInt = exchangeIdBigInt ^ tokenBigInt;
|
|
26
|
-
// Convert back to hex with proper padding
|
|
27
|
-
return pad(numberToHex(limitIdBigInt), { size: 32 });
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Calculate trading limits from V1 config and state (Broker/Virtual pools).
|
|
31
|
-
* Returns human-friendly TradingLimit objects with maxIn/maxOut/until.
|
|
32
|
-
*
|
|
33
|
-
* @param config - V1 trading limits configuration
|
|
34
|
-
* @param state - V1 trading limits state
|
|
35
|
-
* @param asset - Token address
|
|
36
|
-
* @param tokenDecimals - Token decimals for consumer reference
|
|
37
|
-
* @returns Array of TradingLimit objects
|
|
38
|
-
*/
|
|
39
|
-
export function calculateTradingLimitsV1(config, state, asset, tokenDecimals) {
|
|
40
|
-
const nowEpoch = Math.floor(Date.now() / 1000);
|
|
41
|
-
const limits = [];
|
|
42
|
-
// Check if L0 is enabled (bit 0 of flags)
|
|
43
|
-
const isL0Enabled = (config.flags & 0x01) !== 0;
|
|
44
|
-
// Check if L1 is enabled (bit 1 of flags)
|
|
45
|
-
const isL1Enabled = (config.flags & 0x02) !== 0;
|
|
46
|
-
// Check if LG is enabled (bit 2 of flags)
|
|
47
|
-
const isLGEnabled = (config.flags & 0x04) !== 0;
|
|
48
|
-
// Reset netflows if time windows have passed
|
|
49
|
-
const isL0Outdated = isL0Enabled && nowEpoch > state.lastUpdated0 + config.timestep0;
|
|
50
|
-
const isL1Outdated = isL1Enabled && nowEpoch > state.lastUpdated1 + config.timestep1;
|
|
51
|
-
const effectiveNetflow0 = isL0Outdated ? 0n : state.netflow0;
|
|
52
|
-
const effectiveNetflow1 = isL1Outdated ? 0n : state.netflow1;
|
|
53
|
-
const effectiveLastUpdated0 = isL0Outdated ? nowEpoch : state.lastUpdated0;
|
|
54
|
-
const effectiveLastUpdated1 = isL1Outdated ? nowEpoch : state.lastUpdated1;
|
|
55
|
-
// Add L0 limit if configured
|
|
56
|
-
if (isL0Enabled && config.limit0 > 0n) {
|
|
57
|
-
limits.push({
|
|
58
|
-
asset,
|
|
59
|
-
maxIn: config.limit0 - effectiveNetflow0,
|
|
60
|
-
maxOut: config.limit0 + effectiveNetflow0,
|
|
61
|
-
until: effectiveLastUpdated0 + config.timestep0,
|
|
62
|
-
decimals: tokenDecimals,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
// Add L1 limit if configured
|
|
66
|
-
if (isL1Enabled && config.limit1 > 0n) {
|
|
67
|
-
limits.push({
|
|
68
|
-
asset,
|
|
69
|
-
maxIn: config.limit1 - effectiveNetflow1,
|
|
70
|
-
maxOut: config.limit1 + effectiveNetflow1,
|
|
71
|
-
until: effectiveLastUpdated1 + config.timestep1,
|
|
72
|
-
decimals: tokenDecimals,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
// Add LG (global) limit if configured
|
|
76
|
-
if (isLGEnabled && config.limitGlobal > 0n) {
|
|
77
|
-
limits.push({
|
|
78
|
-
asset,
|
|
79
|
-
maxIn: config.limitGlobal - state.netflowGlobal,
|
|
80
|
-
maxOut: config.limitGlobal + state.netflowGlobal,
|
|
81
|
-
until: TIMESTAMP_FAR_FUTURE,
|
|
82
|
-
decimals: tokenDecimals,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
// Apply cascading restrictions: limits with larger timeframes restrict smaller ones
|
|
86
|
-
// e.g., if maxIn is 0 in LG, it should also be 0 in L1 and L0
|
|
87
|
-
for (let i = limits.length - 1; i > 0; i--) {
|
|
88
|
-
if (limits[i - 1].maxIn > limits[i].maxIn) {
|
|
89
|
-
limits[i - 1] = { ...limits[i - 1], maxIn: limits[i].maxIn };
|
|
90
|
-
}
|
|
91
|
-
if (limits[i - 1].maxOut > limits[i].maxOut) {
|
|
92
|
-
limits[i - 1] = { ...limits[i - 1], maxOut: limits[i].maxOut };
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return limits;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Calculate trading limits from V2 config and state (FPMM pools).
|
|
99
|
-
* V2 uses fixed timeframes: 5 min for L0, 1 day for L1.
|
|
100
|
-
* Values are stored with 15 decimals precision.
|
|
101
|
-
*
|
|
102
|
-
* @param config - V2 trading limits configuration
|
|
103
|
-
* @param state - V2 trading limits state
|
|
104
|
-
* @param asset - Token address
|
|
105
|
-
* @returns Array of TradingLimit objects
|
|
106
|
-
*/
|
|
107
|
-
export function calculateTradingLimitsV2(config, state, asset) {
|
|
108
|
-
const nowEpoch = Math.floor(Date.now() / 1000);
|
|
109
|
-
const limits = [];
|
|
110
|
-
// Check if L0 is configured (limit0 > 0)
|
|
111
|
-
const isL0Enabled = config.limit0 > 0n;
|
|
112
|
-
// Check if L1 is configured (limit1 > 0)
|
|
113
|
-
const isL1Enabled = config.limit1 > 0n;
|
|
114
|
-
// Reset netflows if time windows have passed
|
|
115
|
-
const isL0Outdated = isL0Enabled && nowEpoch > state.lastUpdated0 + V2_L0_TIMESTEP;
|
|
116
|
-
const isL1Outdated = isL1Enabled && nowEpoch > state.lastUpdated1 + V2_L1_TIMESTEP;
|
|
117
|
-
const effectiveNetflow0 = isL0Outdated ? 0n : state.netflow0;
|
|
118
|
-
const effectiveNetflow1 = isL1Outdated ? 0n : state.netflow1;
|
|
119
|
-
const effectiveLastUpdated0 = isL0Outdated ? nowEpoch : state.lastUpdated0;
|
|
120
|
-
const effectiveLastUpdated1 = isL1Outdated ? nowEpoch : state.lastUpdated1;
|
|
121
|
-
// Add L0 limit if configured
|
|
122
|
-
if (isL0Enabled) {
|
|
123
|
-
limits.push({
|
|
124
|
-
asset,
|
|
125
|
-
maxIn: config.limit0 - effectiveNetflow0,
|
|
126
|
-
maxOut: config.limit0 + effectiveNetflow0,
|
|
127
|
-
until: effectiveLastUpdated0 + V2_L0_TIMESTEP,
|
|
128
|
-
decimals: V2_INTERNAL_DECIMALS, // V2 returns 15 decimal values
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
// Add L1 limit if configured
|
|
132
|
-
if (isL1Enabled) {
|
|
133
|
-
limits.push({
|
|
134
|
-
asset,
|
|
135
|
-
maxIn: config.limit1 - effectiveNetflow1,
|
|
136
|
-
maxOut: config.limit1 + effectiveNetflow1,
|
|
137
|
-
until: effectiveLastUpdated1 + V2_L1_TIMESTEP,
|
|
138
|
-
decimals: V2_INTERNAL_DECIMALS, // V2 returns 15 decimal values
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
// Apply cascading restrictions
|
|
142
|
-
for (let i = limits.length - 1; i > 0; i--) {
|
|
143
|
-
if (limits[i - 1].maxIn > limits[i].maxIn) {
|
|
144
|
-
limits[i - 1] = { ...limits[i - 1], maxIn: limits[i].maxIn };
|
|
145
|
-
}
|
|
146
|
-
if (limits[i - 1].maxOut > limits[i].maxOut) {
|
|
147
|
-
limits[i - 1] = { ...limits[i - 1], maxOut: limits[i].maxOut };
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return limits;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Check if any trading limits are configured (flags > 0 for V1, or limit0/limit1 > 0 for V2)
|
|
154
|
-
*/
|
|
155
|
-
export function hasConfiguredLimitsV1(config) {
|
|
156
|
-
return config.flags > 0;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Check if any trading limits are configured for V2
|
|
160
|
-
*/
|
|
161
|
-
export function hasConfiguredLimitsV2(config) {
|
|
162
|
-
return config.limit0 > 0n || config.limit1 > 0n;
|
|
163
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { isAddress } from 'viem';
|
|
2
|
-
/**
|
|
3
|
-
* Validates an Ethereum address format using viem's isAddress utility
|
|
4
|
-
*
|
|
5
|
-
* @param address - The address string to validate
|
|
6
|
-
* @param paramName - Optional parameter name for better error messages
|
|
7
|
-
* @returns True if valid (type guard for `0x${string}`)
|
|
8
|
-
* @throws Error if address is invalid
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* validateAddress('0x765DE816845861e75A25fCA122bb6898B8B1282a')
|
|
13
|
-
* // Returns true
|
|
14
|
-
*
|
|
15
|
-
* validateAddress('invalid', 'tokenIn')
|
|
16
|
-
* // Throws: "Invalid address for tokenIn: invalid"
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function validateAddress(address, paramName) {
|
|
20
|
-
if (typeof address !== 'string') {
|
|
21
|
-
const param = paramName ? ` for ${paramName}` : '';
|
|
22
|
-
throw new Error(`Address${param} must be a string, got ${typeof address}`);
|
|
23
|
-
}
|
|
24
|
-
// Use viem's isAddress with strict: false to allow both checksummed and non-checksummed addresses
|
|
25
|
-
if (!isAddress(address, { strict: false })) {
|
|
26
|
-
const param = paramName ? ` for ${paramName}` : '';
|
|
27
|
-
throw new Error(`Invalid address${param}: ${address}. Expected 0x followed by 40 hex characters`);
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { type PublicClient } from 'viem';
|
|
2
|
-
import { ContractAddresses } from './core/types';
|
|
3
|
-
import { TokenService } from './services/tokens';
|
|
4
|
-
import { PoolService } from './services/pools';
|
|
5
|
-
import { RouteService } from './services/routes';
|
|
6
|
-
import { QuoteService } from './services/quotes';
|
|
7
|
-
import { SwapService } from './services/swap';
|
|
8
|
-
import { TradingService } from './services/trading';
|
|
9
|
-
import { LiquidityService } from './services/liquidity';
|
|
10
|
-
import { BorrowService } from './services/borrow';
|
|
11
|
-
export interface MentoBatchOptions {
|
|
12
|
-
batchSize?: number;
|
|
13
|
-
wait?: number;
|
|
14
|
-
}
|
|
15
|
-
export interface MentoClientOptions {
|
|
16
|
-
httpBatch?: MentoBatchOptions | false;
|
|
17
|
-
multicallBatch?: MentoBatchOptions | false;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @class Mento
|
|
21
|
-
* @description The main class for the Mento SDK. Initializes a viem PublicClient internally
|
|
22
|
-
* and provides a public API for interacting with the Mento Protocol.
|
|
23
|
-
* @dev example usage:
|
|
24
|
-
* const mento = await Mento.create(ChainId.CELO);
|
|
25
|
-
* // or with custom RPC URL
|
|
26
|
-
* const mento = await Mento.create(ChainId.CELO, 'https://custom-rpc-url.com');
|
|
27
|
-
* // or with an existing viem PublicClient
|
|
28
|
-
* const mento = await Mento.create(ChainId.CELO, myPublicClient);
|
|
29
|
-
*
|
|
30
|
-
* // Get all stable tokens
|
|
31
|
-
* const stableTokens = await mento.tokens.getStableTokens();
|
|
32
|
-
*
|
|
33
|
-
* // Get all collateral assets
|
|
34
|
-
* const collateralAssets = await mento.tokens.getCollateralAssets();
|
|
35
|
-
*
|
|
36
|
-
* // Get all pools
|
|
37
|
-
* const pools = await mento.pools.getPools();
|
|
38
|
-
*
|
|
39
|
-
* // Find a route between tokens
|
|
40
|
-
* const route = await mento.routes.findRoute(USDm, CELO);
|
|
41
|
-
*
|
|
42
|
-
* // Get a quote for a swap
|
|
43
|
-
* const amountOut = await mento.quotes.getAmountOut(USDm, CELO, amountIn);
|
|
44
|
-
*
|
|
45
|
-
* // Build swap parameters
|
|
46
|
-
* const swapDetails = await mento.swap.buildSwapParams(USDm, CELO, amountIn, recipient, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) });
|
|
47
|
-
*
|
|
48
|
-
* // Check if a pair is tradable (circuit breaker check)
|
|
49
|
-
* const isTradable = await mento.trading.isPairTradable(USDm, CELO);
|
|
50
|
-
*
|
|
51
|
-
* // Get trading limits for a pool
|
|
52
|
-
* const limits = await mento.trading.getPoolTradingLimits(pool);
|
|
53
|
-
*
|
|
54
|
-
* // Get full tradability status (circuit breaker + limits)
|
|
55
|
-
* const status = await mento.trading.getPoolTradabilityStatus(pool);
|
|
56
|
-
*
|
|
57
|
-
* // Add liquidity to a pool
|
|
58
|
-
* const { approval0, approval1, addLiquidity } = await mento.liquidity.buildAddLiquidityTransaction(
|
|
59
|
-
* poolAddress, amount0, amount1, recipient, owner, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
60
|
-
* );
|
|
61
|
-
*
|
|
62
|
-
* // Add liquidity using a single token (zap in)
|
|
63
|
-
* const { approval, zapIn } = await mento.liquidity.buildZapInTransaction(
|
|
64
|
-
* poolAddress, tokenIn, amountIn, 0.5, recipient, owner, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
65
|
-
* );
|
|
66
|
-
*/
|
|
67
|
-
export declare class Mento {
|
|
68
|
-
private chainId;
|
|
69
|
-
tokens: TokenService;
|
|
70
|
-
pools: PoolService;
|
|
71
|
-
routes: RouteService;
|
|
72
|
-
quotes: QuoteService;
|
|
73
|
-
swap: SwapService;
|
|
74
|
-
trading: TradingService;
|
|
75
|
-
liquidity: LiquidityService;
|
|
76
|
-
borrow: BorrowService;
|
|
77
|
-
private constructor();
|
|
78
|
-
/**
|
|
79
|
-
* Create a new Mento SDK instance
|
|
80
|
-
* @param chainId - The chain ID (e.g., ChainId.CELO, ChainId.CELO_SEPOLIA)
|
|
81
|
-
* @param rpcUrlOrClient - Optional RPC URL string or an existing viem PublicClient.
|
|
82
|
-
* If not provided, uses the default RPC URL for the chain.
|
|
83
|
-
* @param options - Optional batching configuration used only when the SDK creates the PublicClient internally.
|
|
84
|
-
* @returns A new Mento instance
|
|
85
|
-
*/
|
|
86
|
-
static create(chainId: number): Promise<Mento>;
|
|
87
|
-
static create(chainId: number, rpcUrlOrClient: string | PublicClient, options?: MentoClientOptions): Promise<Mento>;
|
|
88
|
-
/**
|
|
89
|
-
* Get the address of a contract for the current chain
|
|
90
|
-
* @param contractName - The contract name
|
|
91
|
-
* @returns The contract address
|
|
92
|
-
*/
|
|
93
|
-
getContractAddress(contractName: keyof ContractAddresses): string;
|
|
94
|
-
}
|
|
95
|
-
export * from './core/constants';
|
|
96
|
-
export * from './core/errors';
|
|
97
|
-
export * from './core/types';
|
|
98
|
-
export * from './core/abis';
|
|
99
|
-
export * from './services';
|
|
100
|
-
export * from './utils';
|
|
101
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Mento = void 0;
|
|
18
|
-
const viem_1 = require("viem");
|
|
19
|
-
const chainId_1 = require("./core/constants/chainId");
|
|
20
|
-
const addresses_1 = require("./core/constants/addresses");
|
|
21
|
-
const chainConfig_1 = require("./utils/chainConfig");
|
|
22
|
-
const tokens_1 = require("./services/tokens");
|
|
23
|
-
const pools_1 = require("./services/pools");
|
|
24
|
-
const routes_1 = require("./services/routes");
|
|
25
|
-
const quotes_1 = require("./services/quotes");
|
|
26
|
-
const swap_1 = require("./services/swap");
|
|
27
|
-
const trading_1 = require("./services/trading");
|
|
28
|
-
const liquidity_1 = require("./services/liquidity");
|
|
29
|
-
const borrow_1 = require("./services/borrow");
|
|
30
|
-
const DEFAULT_HTTP_BATCH_OPTIONS = {
|
|
31
|
-
batchSize: 1000,
|
|
32
|
-
wait: 8,
|
|
33
|
-
};
|
|
34
|
-
const DEFAULT_MULTICALL_BATCH_OPTIONS = {
|
|
35
|
-
batchSize: 1024,
|
|
36
|
-
wait: 8,
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* @class Mento
|
|
40
|
-
* @description The main class for the Mento SDK. Initializes a viem PublicClient internally
|
|
41
|
-
* and provides a public API for interacting with the Mento Protocol.
|
|
42
|
-
* @dev example usage:
|
|
43
|
-
* const mento = await Mento.create(ChainId.CELO);
|
|
44
|
-
* // or with custom RPC URL
|
|
45
|
-
* const mento = await Mento.create(ChainId.CELO, 'https://custom-rpc-url.com');
|
|
46
|
-
* // or with an existing viem PublicClient
|
|
47
|
-
* const mento = await Mento.create(ChainId.CELO, myPublicClient);
|
|
48
|
-
*
|
|
49
|
-
* // Get all stable tokens
|
|
50
|
-
* const stableTokens = await mento.tokens.getStableTokens();
|
|
51
|
-
*
|
|
52
|
-
* // Get all collateral assets
|
|
53
|
-
* const collateralAssets = await mento.tokens.getCollateralAssets();
|
|
54
|
-
*
|
|
55
|
-
* // Get all pools
|
|
56
|
-
* const pools = await mento.pools.getPools();
|
|
57
|
-
*
|
|
58
|
-
* // Find a route between tokens
|
|
59
|
-
* const route = await mento.routes.findRoute(USDm, CELO);
|
|
60
|
-
*
|
|
61
|
-
* // Get a quote for a swap
|
|
62
|
-
* const amountOut = await mento.quotes.getAmountOut(USDm, CELO, amountIn);
|
|
63
|
-
*
|
|
64
|
-
* // Build swap parameters
|
|
65
|
-
* const swapDetails = await mento.swap.buildSwapParams(USDm, CELO, amountIn, recipient, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) });
|
|
66
|
-
*
|
|
67
|
-
* // Check if a pair is tradable (circuit breaker check)
|
|
68
|
-
* const isTradable = await mento.trading.isPairTradable(USDm, CELO);
|
|
69
|
-
*
|
|
70
|
-
* // Get trading limits for a pool
|
|
71
|
-
* const limits = await mento.trading.getPoolTradingLimits(pool);
|
|
72
|
-
*
|
|
73
|
-
* // Get full tradability status (circuit breaker + limits)
|
|
74
|
-
* const status = await mento.trading.getPoolTradabilityStatus(pool);
|
|
75
|
-
*
|
|
76
|
-
* // Add liquidity to a pool
|
|
77
|
-
* const { approval0, approval1, addLiquidity } = await mento.liquidity.buildAddLiquidityTransaction(
|
|
78
|
-
* poolAddress, amount0, amount1, recipient, owner, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
79
|
-
* );
|
|
80
|
-
*
|
|
81
|
-
* // Add liquidity using a single token (zap in)
|
|
82
|
-
* const { approval, zapIn } = await mento.liquidity.buildZapInTransaction(
|
|
83
|
-
* poolAddress, tokenIn, amountIn, 0.5, recipient, owner, { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
|
|
84
|
-
* );
|
|
85
|
-
*/
|
|
86
|
-
class Mento {
|
|
87
|
-
constructor(chainId, tokens, pools, routes, quotes, swap, trading, liquidity, borrow) {
|
|
88
|
-
this.chainId = chainId;
|
|
89
|
-
this.tokens = tokens;
|
|
90
|
-
this.pools = pools;
|
|
91
|
-
this.routes = routes;
|
|
92
|
-
this.quotes = quotes;
|
|
93
|
-
this.swap = swap;
|
|
94
|
-
this.trading = trading;
|
|
95
|
-
this.liquidity = liquidity;
|
|
96
|
-
this.borrow = borrow;
|
|
97
|
-
}
|
|
98
|
-
static async create(chainId, rpcUrlOrClient, options) {
|
|
99
|
-
// Validate chainId is supported
|
|
100
|
-
const supportedChainIds = Object.values(chainId_1.ChainId).filter((v) => typeof v === 'number');
|
|
101
|
-
if (!supportedChainIds.includes(chainId)) {
|
|
102
|
-
throw new Error(`ChainId ${chainId} is not supported. ` +
|
|
103
|
-
`Supported chains: ${supportedChainIds.map((id) => `${id} (${chainId_1.ChainId[id]})`).join(', ')}`);
|
|
104
|
-
}
|
|
105
|
-
let publicClient;
|
|
106
|
-
if (rpcUrlOrClient && typeof rpcUrlOrClient !== 'string') {
|
|
107
|
-
publicClient = rpcUrlOrClient;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
const transport = (0, viem_1.http)(rpcUrlOrClient || (0, chainConfig_1.getDefaultRpcUrl)(chainId), {
|
|
111
|
-
batch: options?.httpBatch === false
|
|
112
|
-
? false
|
|
113
|
-
: {
|
|
114
|
-
...DEFAULT_HTTP_BATCH_OPTIONS,
|
|
115
|
-
...(options?.httpBatch ?? {}),
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
publicClient = (0, viem_1.createPublicClient)({
|
|
119
|
-
batch: {
|
|
120
|
-
multicall: options?.multicallBatch === false
|
|
121
|
-
? false
|
|
122
|
-
: {
|
|
123
|
-
...DEFAULT_MULTICALL_BATCH_OPTIONS,
|
|
124
|
-
...(options?.multicallBatch ?? {}),
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
chain: (0, chainConfig_1.getChainConfig)(chainId),
|
|
128
|
-
transport,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
const tokenService = new tokens_1.TokenService(publicClient, chainId);
|
|
132
|
-
const poolService = new pools_1.PoolService(publicClient, chainId);
|
|
133
|
-
const routeService = new routes_1.RouteService(publicClient, chainId, poolService);
|
|
134
|
-
const quoteService = new quotes_1.QuoteService(publicClient, chainId, routeService);
|
|
135
|
-
const swapService = new swap_1.SwapService(publicClient, chainId, routeService, quoteService);
|
|
136
|
-
const tradingService = new trading_1.TradingService(publicClient, chainId, routeService);
|
|
137
|
-
const liquidityService = new liquidity_1.LiquidityService(publicClient, chainId, poolService, routeService);
|
|
138
|
-
const borrowService = new borrow_1.BorrowService(publicClient, chainId);
|
|
139
|
-
// Return new mento
|
|
140
|
-
return new Mento(chainId, tokenService, poolService, routeService, quoteService, swapService, tradingService, liquidityService, borrowService);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Get the address of a contract for the current chain
|
|
144
|
-
* @param contractName - The contract name
|
|
145
|
-
* @returns The contract address
|
|
146
|
-
*/
|
|
147
|
-
getContractAddress(contractName) {
|
|
148
|
-
return (0, addresses_1.getContractAddress)(this.chainId, contractName);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
exports.Mento = Mento;
|
|
152
|
-
__exportStar(require("./core/constants"), exports);
|
|
153
|
-
__exportStar(require("./core/errors"), exports);
|
|
154
|
-
__exportStar(require("./core/types"), exports);
|
|
155
|
-
__exportStar(require("./core/abis"), exports);
|
|
156
|
-
__exportStar(require("./services"), exports);
|
|
157
|
-
__exportStar(require("./utils"), exports);
|
|
158
|
-
//# sourceMappingURL=index.js.map
|