@mento-protocol/mento-sdk 2.0.0-beta.9 → 3.0.0-beta.10
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 +204 -132
- package/dist/cache/routes.d.ts +13 -0
- package/dist/cache/routes.d.ts.map +1 -0
- package/dist/cache/routes.js +130 -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/bipoolmanager.d.ts +34 -0
- package/dist/core/abis/bipoolmanager.d.ts.map +1 -0
- package/dist/core/abis/bipoolmanager.js +72 -0
- package/dist/core/abis/bipoolmanager.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/broker.d.ts +2 -0
- package/dist/core/abis/broker.d.ts.map +1 -0
- package/dist/core/abis/broker.js +9 -0
- package/dist/core/abis/broker.js.map +1 -0
- package/dist/core/abis/erc20.d.ts +9 -0
- package/dist/core/abis/erc20.d.ts.map +1 -0
- package/dist/core/abis/erc20.js +21 -0
- package/dist/core/abis/erc20.js.map +1 -0
- package/dist/core/abis/fpmm.d.ts +160 -0
- package/dist/core/abis/fpmm.d.ts.map +1 -0
- package/dist/core/abis/fpmm.js +21 -0
- package/dist/core/abis/fpmm.js.map +1 -0
- package/dist/core/abis/fpmmFactory.d.ts +21 -0
- package/dist/core/abis/fpmmFactory.d.ts.map +1 -0
- package/dist/core/abis/fpmmFactory.js +9 -0
- package/dist/core/abis/fpmmFactory.js.map +1 -0
- package/dist/core/abis/index.d.ts +12 -0
- package/dist/core/abis/index.d.ts.map +1 -0
- package/dist/{abis → core/abis}/index.js +6 -0
- package/dist/core/abis/index.js.map +1 -0
- package/dist/core/abis/pricingmodule.d.ts +2 -0
- package/dist/core/abis/pricingmodule.d.ts.map +1 -0
- package/dist/core/abis/pricingmodule.js +6 -0
- package/dist/core/abis/pricingmodule.js.map +1 -0
- package/dist/core/abis/reserve.d.ts +2 -0
- package/dist/core/abis/reserve.d.ts.map +1 -0
- package/dist/core/abis/reserve.js +10 -0
- package/dist/core/abis/reserve.js.map +1 -0
- package/dist/core/abis/router.d.ts +2 -0
- package/dist/core/abis/router.d.ts.map +1 -0
- package/dist/core/abis/router.js +10 -0
- package/dist/core/abis/router.js.map +1 -0
- package/dist/core/abis/uniswapV3.d.ts +4 -0
- package/dist/core/abis/uniswapV3.d.ts.map +1 -0
- package/dist/{abis → core/abis}/uniswapV3.js +7 -6
- package/dist/core/abis/uniswapV3.js.map +1 -0
- package/dist/core/abis/virtualPool.d.ts +40 -0
- package/dist/core/abis/virtualPool.d.ts.map +1 -0
- package/dist/core/abis/virtualPool.js +10 -0
- package/dist/core/abis/virtualPool.js.map +1 -0
- package/dist/core/abis/virtualPoolFactory.d.ts +27 -0
- package/dist/core/abis/virtualPoolFactory.d.ts.map +1 -0
- package/dist/core/abis/virtualPoolFactory.js +9 -0
- package/dist/core/abis/virtualPoolFactory.js.map +1 -0
- package/dist/core/constants/aaveConfig.d.ts.map +1 -0
- package/dist/{constants → core/constants}/aaveConfig.js +2 -2
- package/dist/core/constants/aaveConfig.js.map +1 -0
- package/dist/{constants → core/constants}/addresses.d.ts +4 -5
- package/dist/core/constants/addresses.d.ts.map +1 -0
- package/dist/core/constants/addresses.js +78 -0
- package/dist/core/constants/addresses.js.map +1 -0
- package/dist/core/constants/chainId.d.ts +5 -0
- package/dist/core/constants/chainId.d.ts.map +1 -0
- package/dist/{constants → core/constants}/chainId.js +1 -1
- package/dist/core/constants/chainId.js.map +1 -0
- package/dist/core/constants/contractNames.d.ts.map +1 -0
- package/dist/core/constants/contractNames.js.map +1 -0
- package/dist/{constants → core/constants}/index.d.ts +0 -2
- package/dist/core/constants/index.d.ts.map +1 -0
- package/dist/{constants → core/constants}/index.js +0 -2
- package/dist/core/constants/index.js.map +1 -0
- package/dist/{constants → core/constants}/mentoAddresses.d.ts +2 -0
- package/dist/core/constants/mentoAddresses.d.ts.map +1 -0
- package/dist/{constants → core/constants}/mentoAddresses.js +2 -0
- package/dist/core/constants/mentoAddresses.js.map +1 -0
- package/dist/core/constants/protocolAddresses.d.ts.map +1 -0
- package/dist/core/constants/protocolAddresses.js.map +1 -0
- package/dist/core/errors/base.d.ts +8 -0
- package/dist/core/errors/base.d.ts.map +1 -0
- package/dist/core/errors/base.js +17 -0
- package/dist/core/errors/base.js.map +1 -0
- package/dist/core/errors/index.d.ts +3 -0
- package/dist/core/errors/index.d.ts.map +1 -0
- package/dist/{types → core/errors}/index.js +2 -4
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/errors/router.d.ts +8 -0
- package/dist/core/errors/router.d.ts.map +1 -0
- package/dist/core/errors/router.js +14 -0
- package/dist/core/errors/router.js.map +1 -0
- package/dist/core/types/contractAddresses.d.ts +41 -0
- package/dist/core/types/contractAddresses.d.ts.map +1 -0
- package/dist/core/types/contractAddresses.js.map +1 -0
- package/dist/core/types/index.d.ts +8 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/index.js +24 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/types/pool.d.ts +145 -0
- package/dist/core/types/pool.d.ts.map +1 -0
- package/dist/core/types/pool.js +14 -0
- package/dist/core/types/pool.js.map +1 -0
- package/dist/core/types/provider.d.ts +45 -0
- package/dist/core/types/provider.d.ts.map +1 -0
- package/dist/{types → core/types}/provider.js.map +1 -1
- package/dist/core/types/route.d.ts +62 -0
- package/dist/core/types/route.d.ts.map +1 -0
- package/dist/{types/exchange.js → core/types/route.js} +1 -1
- package/dist/core/types/route.js.map +1 -0
- package/dist/{types → core/types}/token.d.ts +16 -6
- package/dist/core/types/token.d.ts.map +1 -0
- package/dist/{types → core/types}/token.js.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 +50 -109
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -152
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +7 -6
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +7 -6
- package/dist/services/index.js.map +1 -1
- package/dist/services/pools/PoolService.d.ts +49 -0
- package/dist/services/pools/PoolService.d.ts.map +1 -0
- package/dist/services/pools/PoolService.js +92 -0
- package/dist/services/pools/PoolService.js.map +1 -0
- package/dist/services/pools/index.d.ts +2 -0
- package/dist/services/pools/index.d.ts.map +1 -0
- package/dist/services/pools/index.js +18 -0
- package/dist/services/pools/index.js.map +1 -0
- 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 +136 -0
- package/dist/services/pools/poolDetails.js.map +1 -0
- package/dist/services/pools/poolDiscovery.d.ts +13 -0
- package/dist/services/pools/poolDiscovery.d.ts.map +1 -0
- package/dist/services/pools/poolDiscovery.js +115 -0
- package/dist/services/pools/poolDiscovery.js.map +1 -0
- package/dist/services/quotes/QuoteService.d.ts +50 -0
- package/dist/services/quotes/QuoteService.d.ts.map +1 -0
- package/dist/services/quotes/QuoteService.js +74 -0
- package/dist/services/quotes/QuoteService.js.map +1 -0
- package/dist/services/quotes/index.d.ts +2 -0
- package/dist/services/quotes/index.d.ts.map +1 -0
- package/dist/services/quotes/index.js +18 -0
- package/dist/services/quotes/index.js.map +1 -0
- package/dist/services/routes/RouteService.d.ts +109 -0
- package/dist/services/routes/RouteService.d.ts.map +1 -0
- package/dist/services/routes/RouteService.js +239 -0
- package/dist/services/routes/RouteService.js.map +1 -0
- package/dist/services/routes/index.d.ts +2 -0
- package/dist/services/routes/index.d.ts.map +1 -0
- package/dist/services/routes/index.js +18 -0
- package/dist/services/routes/index.js.map +1 -0
- package/dist/services/swap/SwapService.d.ts +162 -0
- package/dist/services/swap/SwapService.d.ts.map +1 -0
- package/dist/services/swap/SwapService.js +180 -0
- package/dist/services/swap/SwapService.js.map +1 -0
- package/dist/services/swap/index.d.ts +2 -0
- package/dist/services/swap/index.d.ts.map +1 -0
- package/dist/services/swap/index.js +18 -0
- package/dist/services/swap/index.js.map +1 -0
- package/dist/services/tokens/index.d.ts +2 -0
- package/dist/services/tokens/index.d.ts.map +1 -0
- package/dist/services/tokens/index.js +18 -0
- package/dist/services/tokens/index.js.map +1 -0
- package/dist/services/tokens/supply/ISupplyCalculator.d.ts.map +1 -0
- package/dist/services/tokens/supply/ISupplyCalculator.js.map +1 -0
- package/dist/services/{supply → tokens/supply}/aaveSupplyCalculator.d.ts +4 -3
- package/dist/services/tokens/supply/aaveSupplyCalculator.d.ts.map +1 -0
- package/dist/services/{supply → tokens/supply}/aaveSupplyCalculator.js +7 -7
- package/dist/services/tokens/supply/aaveSupplyCalculator.js.map +1 -0
- package/dist/services/tokens/supply/calculatorFactory.d.ts +8 -0
- package/dist/services/tokens/supply/calculatorFactory.d.ts.map +1 -0
- package/dist/services/tokens/supply/calculatorFactory.js.map +1 -0
- package/dist/services/tokens/supply/defaultCalculatorFactory.d.ts +9 -0
- package/dist/services/tokens/supply/defaultCalculatorFactory.d.ts.map +1 -0
- package/dist/services/{supply → tokens/supply}/defaultCalculatorFactory.js +12 -7
- package/dist/services/tokens/supply/defaultCalculatorFactory.js.map +1 -0
- package/dist/services/tokens/supply/index.d.ts.map +1 -0
- package/dist/services/tokens/supply/index.js.map +1 -0
- package/dist/services/tokens/supply/multisigSupplyCalculator.d.ts +9 -0
- package/dist/services/tokens/supply/multisigSupplyCalculator.d.ts.map +1 -0
- package/dist/services/tokens/supply/multisigSupplyCalculator.js +33 -0
- package/dist/services/tokens/supply/multisigSupplyCalculator.js.map +1 -0
- package/dist/services/{supply → tokens/supply}/uniV3SupplyCalculator.d.ts +3 -3
- package/dist/services/tokens/supply/uniV3SupplyCalculator.d.ts.map +1 -0
- package/dist/services/{supply → tokens/supply}/uniV3SupplyCalculator.js +11 -6
- package/dist/services/tokens/supply/uniV3SupplyCalculator.js.map +1 -0
- package/dist/services/{supplyAdjustmentService.d.ts → tokens/supplyAdjustmentService.d.ts} +3 -2
- package/dist/services/tokens/supplyAdjustmentService.d.ts.map +1 -0
- package/dist/services/{supplyAdjustmentService.js → tokens/supplyAdjustmentService.js} +11 -13
- package/dist/services/tokens/supplyAdjustmentService.js.map +1 -0
- package/dist/services/tokens/tokenService.d.ts +33 -0
- package/dist/services/tokens/tokenService.d.ts.map +1 -0
- package/dist/services/tokens/tokenService.js +136 -0
- package/dist/services/tokens/tokenService.js.map +1 -0
- 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/chainConfig.d.ts +16 -0
- package/dist/utils/chainConfig.d.ts.map +1 -0
- package/dist/utils/chainConfig.js +62 -0
- package/dist/utils/chainConfig.js.map +1 -0
- package/dist/utils/costUtils.d.ts +12 -0
- package/dist/utils/costUtils.d.ts.map +1 -0
- package/dist/utils/costUtils.js +59 -0
- package/dist/utils/costUtils.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/pathEncoder.d.ts +29 -0
- package/dist/utils/pathEncoder.d.ts.map +1 -0
- package/dist/utils/pathEncoder.js +73 -0
- package/dist/utils/pathEncoder.js.map +1 -0
- 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 +295 -0
- package/dist/utils/routeUtils.d.ts.map +1 -0
- package/dist/utils/routeUtils.js +371 -0
- package/dist/utils/routeUtils.js.map +1 -0
- package/dist/utils/routes.d.ts +3 -0
- package/dist/utils/routes.d.ts.map +1 -0
- package/dist/utils/routes.js +8 -0
- package/dist/utils/routes.js.map +1 -0
- package/dist/utils/sortUtils.d.ts +24 -0
- package/dist/utils/sortUtils.d.ts.map +1 -0
- package/dist/utils/sortUtils.js +39 -0
- package/dist/utils/sortUtils.js.map +1 -0
- package/dist/utils/tokens.d.ts +2 -0
- package/dist/utils/tokens.d.ts.map +1 -0
- package/dist/utils/tokens.js +13 -0
- package/dist/utils/tokens.js.map +1 -0
- 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 +10 -23
- package/dist/abis/bipoolmanager.d.ts +0 -15
- package/dist/abis/bipoolmanager.d.ts.map +0 -1
- package/dist/abis/bipoolmanager.js +0 -26
- package/dist/abis/bipoolmanager.js.map +0 -1
- package/dist/abis/broker.d.ts +0 -2
- package/dist/abis/broker.d.ts.map +0 -1
- package/dist/abis/broker.js +0 -15
- package/dist/abis/broker.js.map +0 -1
- package/dist/abis/erc20.d.ts +0 -2
- package/dist/abis/erc20.d.ts.map +0 -1
- package/dist/abis/erc20.js +0 -11
- package/dist/abis/erc20.js.map +0 -1
- package/dist/abis/index.d.ts +0 -6
- package/dist/abis/index.d.ts.map +0 -1
- package/dist/abis/index.js.map +0 -1
- package/dist/abis/pricingmodule.d.ts +0 -2
- package/dist/abis/pricingmodule.d.ts.map +0 -1
- package/dist/abis/pricingmodule.js +0 -5
- package/dist/abis/pricingmodule.js.map +0 -1
- package/dist/abis/reserve.d.ts +0 -2
- package/dist/abis/reserve.d.ts.map +0 -1
- package/dist/abis/reserve.js +0 -9
- package/dist/abis/reserve.js.map +0 -1
- package/dist/abis/uniswapV3.d.ts +0 -4
- package/dist/abis/uniswapV3.d.ts.map +0 -1
- package/dist/abis/uniswapV3.js.map +0 -1
- package/dist/adapters/implementations/ethersAdapter.d.ts +0 -13
- package/dist/adapters/implementations/ethersAdapter.d.ts.map +0 -1
- package/dist/adapters/implementations/ethersAdapter.js +0 -92
- package/dist/adapters/implementations/ethersAdapter.js.map +0 -1
- package/dist/adapters/implementations/ethersV5Adapter.d.ts +0 -13
- package/dist/adapters/implementations/ethersV5Adapter.d.ts.map +0 -1
- package/dist/adapters/implementations/ethersV5Adapter.js +0 -92
- package/dist/adapters/implementations/ethersV5Adapter.js.map +0 -1
- package/dist/adapters/implementations/viemAdapter.d.ts +0 -18
- package/dist/adapters/implementations/viemAdapter.d.ts.map +0 -1
- package/dist/adapters/implementations/viemAdapter.js +0 -126
- package/dist/adapters/implementations/viemAdapter.js.map +0 -1
- package/dist/adapters/index.d.ts +0 -5
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js +0 -10
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/proxies/ethersAdapterProxy.d.ts +0 -26
- package/dist/adapters/proxies/ethersAdapterProxy.d.ts.map +0 -1
- package/dist/adapters/proxies/ethersAdapterProxy.js +0 -78
- package/dist/adapters/proxies/ethersAdapterProxy.js.map +0 -1
- package/dist/adapters/proxies/ethersV5AdapterProxy.d.ts +0 -26
- package/dist/adapters/proxies/ethersV5AdapterProxy.d.ts.map +0 -1
- package/dist/adapters/proxies/ethersV5AdapterProxy.js +0 -78
- package/dist/adapters/proxies/ethersV5AdapterProxy.js.map +0 -1
- package/dist/adapters/proxies/viemAdapterProxy.d.ts +0 -29
- package/dist/adapters/proxies/viemAdapterProxy.d.ts.map +0 -1
- package/dist/adapters/proxies/viemAdapterProxy.js +0 -78
- package/dist/adapters/proxies/viemAdapterProxy.js.map +0 -1
- package/dist/constants/aaveConfig.d.ts.map +0 -1
- package/dist/constants/aaveConfig.js.map +0 -1
- package/dist/constants/addresses.d.ts.map +0 -1
- package/dist/constants/addresses.js +0 -61
- package/dist/constants/addresses.js.map +0 -1
- package/dist/constants/chainId.d.ts +0 -5
- package/dist/constants/chainId.d.ts.map +0 -1
- package/dist/constants/chainId.js.map +0 -1
- package/dist/constants/contractNames.d.ts.map +0 -1
- package/dist/constants/contractNames.js.map +0 -1
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js.map +0 -1
- package/dist/constants/mentoAddresses.d.ts.map +0 -1
- package/dist/constants/mentoAddresses.js.map +0 -1
- package/dist/constants/proposalState.d.ts +0 -11
- package/dist/constants/proposalState.d.ts.map +0 -1
- package/dist/constants/proposalState.js +0 -15
- package/dist/constants/proposalState.js.map +0 -1
- package/dist/constants/protocolAddresses.d.ts.map +0 -1
- package/dist/constants/protocolAddresses.js.map +0 -1
- package/dist/constants/stableTokenMetadata.d.ts +0 -12
- package/dist/constants/stableTokenMetadata.d.ts.map +0 -1
- package/dist/constants/stableTokenMetadata.js +0 -14
- package/dist/constants/stableTokenMetadata.js.map +0 -1
- package/dist/services/collateralAssetService.d.ts +0 -8
- package/dist/services/collateralAssetService.d.ts.map +0 -1
- package/dist/services/collateralAssetService.js +0 -47
- package/dist/services/collateralAssetService.js.map +0 -1
- package/dist/services/stableTokenService.d.ts +0 -9
- package/dist/services/stableTokenService.d.ts.map +0 -1
- package/dist/services/stableTokenService.js +0 -40
- package/dist/services/stableTokenService.js.map +0 -1
- package/dist/services/supply/ISupplyCalculator.d.ts.map +0 -1
- package/dist/services/supply/ISupplyCalculator.js.map +0 -1
- package/dist/services/supply/aaveSupplyCalculator.d.ts.map +0 -1
- package/dist/services/supply/aaveSupplyCalculator.js.map +0 -1
- package/dist/services/supply/calculatorFactory.d.ts +0 -8
- package/dist/services/supply/calculatorFactory.d.ts.map +0 -1
- package/dist/services/supply/calculatorFactory.js.map +0 -1
- package/dist/services/supply/defaultCalculatorFactory.d.ts +0 -9
- package/dist/services/supply/defaultCalculatorFactory.d.ts.map +0 -1
- package/dist/services/supply/defaultCalculatorFactory.js.map +0 -1
- package/dist/services/supply/index.d.ts.map +0 -1
- package/dist/services/supply/index.js.map +0 -1
- package/dist/services/supply/multisigSupplyCalculator.d.ts +0 -9
- package/dist/services/supply/multisigSupplyCalculator.d.ts.map +0 -1
- package/dist/services/supply/multisigSupplyCalculator.js +0 -21
- package/dist/services/supply/multisigSupplyCalculator.js.map +0 -1
- package/dist/services/supply/uniV3SupplyCalculator.d.ts.map +0 -1
- package/dist/services/supply/uniV3SupplyCalculator.js.map +0 -1
- package/dist/services/supplyAdjustmentService.d.ts.map +0 -1
- package/dist/services/supplyAdjustmentService.js.map +0 -1
- package/dist/services/swapService.d.ts +0 -70
- package/dist/services/swapService.d.ts.map +0 -1
- package/dist/services/swapService.js +0 -134
- package/dist/services/swapService.js.map +0 -1
- package/dist/services/tokenMetadataService.d.ts +0 -8
- package/dist/services/tokenMetadataService.d.ts.map +0 -1
- package/dist/services/tokenMetadataService.js +0 -44
- package/dist/services/tokenMetadataService.js.map +0 -1
- package/dist/types/contractAddresses.d.ts +0 -23
- package/dist/types/contractAddresses.d.ts.map +0 -1
- package/dist/types/contractAddresses.js.map +0 -1
- package/dist/types/exchange.d.ts +0 -6
- package/dist/types/exchange.d.ts.map +0 -1
- package/dist/types/exchange.js.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/provider.d.ts +0 -29
- package/dist/types/provider.d.ts.map +0 -1
- package/dist/types/token.d.ts.map +0 -1
- /package/dist/{constants → core/constants}/aaveConfig.d.ts +0 -0
- /package/dist/{constants → core/constants}/contractNames.d.ts +0 -0
- /package/dist/{constants → core/constants}/contractNames.js +0 -0
- /package/dist/{constants → core/constants}/protocolAddresses.d.ts +0 -0
- /package/dist/{constants → core/constants}/protocolAddresses.js +0 -0
- /package/dist/{types → core/types}/contractAddresses.js +0 -0
- /package/dist/{types → core/types}/provider.js +0 -0
- /package/dist/{types → core/types}/token.js +0 -0
- /package/dist/services/{supply → tokens/supply}/ISupplyCalculator.d.ts +0 -0
- /package/dist/services/{supply → tokens/supply}/ISupplyCalculator.js +0 -0
- /package/dist/services/{supply → tokens/supply}/calculatorFactory.js +0 -0
- /package/dist/services/{supply → tokens/supply}/index.d.ts +0 -0
- /package/dist/services/{supply → tokens/supply}/index.js +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchFPMMPoolDetails = fetchFPMMPoolDetails;
|
|
4
|
+
exports.fetchVirtualPoolDetails = fetchVirtualPoolDetails;
|
|
5
|
+
const constants_1 = require("../../core/constants");
|
|
6
|
+
const abis_1 = require("../../core/abis");
|
|
7
|
+
/**
|
|
8
|
+
* Fetches enriched details for an FPMM pool
|
|
9
|
+
*/
|
|
10
|
+
async function fetchFPMMPoolDetails(publicClient, chainId, pool) {
|
|
11
|
+
const address = pool.poolAddr;
|
|
12
|
+
try {
|
|
13
|
+
// Known liquidity strategy addresses for this chain
|
|
14
|
+
const knownStrategies = getKnownLiquidityStrategies(chainId);
|
|
15
|
+
const [reservesResult, pricesResult, decimals0, decimals1, lpFee, protocolFee, rebalanceIncentive, rebalanceThresholdAbove, rebalanceThresholdBelow, ...strategyResults] = await Promise.all([
|
|
16
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'getReserves' }),
|
|
17
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'getPrices' }),
|
|
18
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'decimals0' }),
|
|
19
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'decimals1' }),
|
|
20
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'lpFee' }),
|
|
21
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'protocolFee' }),
|
|
22
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceIncentive' }),
|
|
23
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceThresholdAbove' }),
|
|
24
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceThresholdBelow' }),
|
|
25
|
+
...knownStrategies.map((strategyAddr) => publicClient.readContract({
|
|
26
|
+
address,
|
|
27
|
+
abi: abis_1.FPMM_ABI,
|
|
28
|
+
functionName: 'liquidityStrategy',
|
|
29
|
+
args: [strategyAddr],
|
|
30
|
+
})),
|
|
31
|
+
]);
|
|
32
|
+
const [reserve0, reserve1, blockTimestampLast] = reservesResult;
|
|
33
|
+
const [oraclePriceNum, oraclePriceDen, reservePriceNum, reservePriceDen, priceDifference, reservePriceAboveOraclePrice,] = pricesResult;
|
|
34
|
+
const lpFeeBps = lpFee;
|
|
35
|
+
const protocolFeeBps = protocolFee;
|
|
36
|
+
const rebalanceIncentiveBps = rebalanceIncentive;
|
|
37
|
+
const thresholdAboveBps = rebalanceThresholdAbove;
|
|
38
|
+
const thresholdBelowBps = rebalanceThresholdBelow;
|
|
39
|
+
// Find the active liquidity strategy (first match wins)
|
|
40
|
+
// Note: this could break at some point in the future if we decide to use
|
|
41
|
+
// more than one stragegy for a pool. For now it is not an issue,
|
|
42
|
+
// if we do forget to change this the impact is low as this function
|
|
43
|
+
// is just for informational purposes.
|
|
44
|
+
const activeIndex = strategyResults.findIndex((result) => result === true);
|
|
45
|
+
const liquidityStrategy = activeIndex >= 0 ? knownStrategies[activeIndex] : null;
|
|
46
|
+
const applicableThreshold = reservePriceAboveOraclePrice ? thresholdAboveBps : thresholdBelowBps;
|
|
47
|
+
const inBand = priceDifference < applicableThreshold;
|
|
48
|
+
return {
|
|
49
|
+
...pool,
|
|
50
|
+
poolType: 'FPMM',
|
|
51
|
+
decimals0: decimals0,
|
|
52
|
+
decimals1: decimals1,
|
|
53
|
+
reserve0,
|
|
54
|
+
reserve1,
|
|
55
|
+
blockTimestampLast,
|
|
56
|
+
pricing: {
|
|
57
|
+
oraclePriceNum,
|
|
58
|
+
oraclePriceDen,
|
|
59
|
+
oraclePrice: Number(oraclePriceNum) / Number(oraclePriceDen),
|
|
60
|
+
reservePriceNum,
|
|
61
|
+
reservePriceDen,
|
|
62
|
+
reservePrice: Number(reservePriceNum) / Number(reservePriceDen),
|
|
63
|
+
priceDifferenceBps: priceDifference,
|
|
64
|
+
priceDifferencePercent: Number(priceDifference) / 100,
|
|
65
|
+
reservePriceAboveOraclePrice,
|
|
66
|
+
},
|
|
67
|
+
fees: {
|
|
68
|
+
lpFeeBps,
|
|
69
|
+
lpFeePercent: Number(lpFeeBps) / 100,
|
|
70
|
+
protocolFeeBps,
|
|
71
|
+
protocolFeePercent: Number(protocolFeeBps) / 100,
|
|
72
|
+
totalFeePercent: (Number(lpFeeBps) + Number(protocolFeeBps)) / 100,
|
|
73
|
+
},
|
|
74
|
+
rebalancing: {
|
|
75
|
+
rebalanceIncentiveBps,
|
|
76
|
+
rebalanceIncentivePercent: Number(rebalanceIncentiveBps) / 100,
|
|
77
|
+
rebalanceThresholdAboveBps: thresholdAboveBps,
|
|
78
|
+
rebalanceThresholdAbovePercent: Number(thresholdAboveBps) / 100,
|
|
79
|
+
rebalanceThresholdBelowBps: thresholdBelowBps,
|
|
80
|
+
rebalanceThresholdBelowPercent: Number(thresholdBelowBps) / 100,
|
|
81
|
+
inBand,
|
|
82
|
+
liquidityStrategy,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new Error(`Failed to fetch FPMM pool details for ${pool.poolAddr}: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Fetches enriched details for a Virtual pool
|
|
92
|
+
*/
|
|
93
|
+
async function fetchVirtualPoolDetails(publicClient, pool) {
|
|
94
|
+
const address = pool.poolAddr;
|
|
95
|
+
try {
|
|
96
|
+
const [reservesResult, protocolFee, metadataResult] = await Promise.all([
|
|
97
|
+
publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'getReserves' }),
|
|
98
|
+
publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'protocolFee' }),
|
|
99
|
+
publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'metadata' }),
|
|
100
|
+
]);
|
|
101
|
+
const [reserve0, reserve1, blockTimestampLast] = reservesResult;
|
|
102
|
+
const [dec0, dec1] = metadataResult;
|
|
103
|
+
const spreadBps = protocolFee;
|
|
104
|
+
return {
|
|
105
|
+
...pool,
|
|
106
|
+
poolType: 'Virtual',
|
|
107
|
+
decimals0: dec0,
|
|
108
|
+
decimals1: dec1,
|
|
109
|
+
reserve0,
|
|
110
|
+
reserve1,
|
|
111
|
+
blockTimestampLast,
|
|
112
|
+
spreadBps,
|
|
113
|
+
spreadPercent: Number(spreadBps) / 100,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
throw new Error(`Failed to fetch Virtual pool details for ${pool.poolAddr}: ${error.message}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns the known liquidity strategy addresses for the given chain.
|
|
122
|
+
*/
|
|
123
|
+
function getKnownLiquidityStrategies(chainId) {
|
|
124
|
+
const strategies = [];
|
|
125
|
+
const chainAddresses = constants_1.addresses[chainId];
|
|
126
|
+
if (!chainAddresses)
|
|
127
|
+
return strategies;
|
|
128
|
+
if (chainAddresses.ReserveLiquidityStrategy) {
|
|
129
|
+
strategies.push(chainAddresses.ReserveLiquidityStrategy);
|
|
130
|
+
}
|
|
131
|
+
if (chainAddresses.CDPLiquidityStrategy) {
|
|
132
|
+
strategies.push(chainAddresses.CDPLiquidityStrategy);
|
|
133
|
+
}
|
|
134
|
+
return strategies;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=poolDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolDetails.js","sourceRoot":"","sources":["../../../src/services/pools/poolDetails.ts"],"names":[],"mappings":";;AAQA,oDA6GC;AAKD,0DA4BC;AAtJD,oDAAyD;AAEzD,0CAA4D;AAG5D;;GAEG;AACI,KAAK,UAAU,oBAAoB,CACxC,YAA0B,EAC1B,OAAe,EACf,IAAU;IAEV,MAAM,OAAO,GAAG,IAAI,CAAC,QAAmB,CAAA;IAExC,IAAI,CAAC;QACH,oDAAoD;QACpD,MAAM,eAAe,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAA;QAE5D,MAAM,CACJ,cAAc,EACd,YAAY,EACZ,SAAS,EACT,SAAS,EACT,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,GAAG,eAAe,CACnB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACpB,YAAY,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,eAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;YAClF,YAA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Q,EAAE,kBAAkB,CAAC,GAAG,cAA0C,CAAA;QAC3F,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,cAAkE,CAAA;QACvF,MAAM,SAAS,GAAG,WAAqB,CAAA;QAEvC,OAAO;YACL,GAAG,IAAI;YACP,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;YACf,QAAQ;YACR,QAAQ;YACR,kBAAkB;YAClB,SAAS;YACT,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,GAAG;SACvC,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,CAAC,QAAQ,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3G,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,2BAA2B,CAAC,OAAe;IAClD,MAAM,UAAU,GAAa,EAAE,CAAA;IAC/B,MAAM,cAAc,GAAG,qBAAS,CAAC,OAAkB,CAAC,CAAA;IACpD,IAAI,CAAC,cAAc;QAAE,OAAO,UAAU,CAAA;IAEtC,IAAI,cAAc,CAAC,wBAAwB,EAAE,CAAC;QAC5C,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAA;IAC1D,CAAC;IACD,IAAI,cAAc,CAAC,oBAAoB,EAAE,CAAC;QACxC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Pool } from '../../core/types';
|
|
2
|
+
import { PublicClient } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Fetches all FPMM pools from the FPMM Factory
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetchFPMMPools(publicClient: PublicClient, chainId: number): Promise<Pool[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetches all Virtual pools by discovering them from BiPoolManager exchanges.
|
|
9
|
+
* VirtualPoolFactory doesn't have an enumeration method,
|
|
10
|
+
* so we have to derive pools from BiPoolManager.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchVirtualPools(publicClient: PublicClient, chainId: number): Promise<Pool[]>;
|
|
13
|
+
//# sourceMappingURL=poolDiscovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolDiscovery.d.ts","sourceRoot":"","sources":["../../../src/services/pools/poolDiscovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,YAAY,EAAW,MAAM,MAAM,CAAA;AAG5C;;GAEG;AACH,wBAAsB,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CA8CjG;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAiEpG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchFPMMPools = fetchFPMMPools;
|
|
4
|
+
exports.fetchVirtualPools = fetchVirtualPools;
|
|
5
|
+
const constants_1 = require("../../core/constants");
|
|
6
|
+
const types_1 = require("../../core/types");
|
|
7
|
+
const abis_1 = require("../../core/abis");
|
|
8
|
+
const sortUtils_1 = require("../../utils/sortUtils");
|
|
9
|
+
/**
|
|
10
|
+
* Fetches all FPMM pools from the FPMM Factory
|
|
11
|
+
*/
|
|
12
|
+
async function fetchFPMMPools(publicClient, chainId) {
|
|
13
|
+
const fpmmFactoryAddress = (0, constants_1.getContractAddress)(chainId, 'FPMMFactory');
|
|
14
|
+
if (!fpmmFactoryAddress) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
// Get all deployed FPMM pool addresses
|
|
19
|
+
const poolAddresses = (await publicClient.readContract({
|
|
20
|
+
address: fpmmFactoryAddress,
|
|
21
|
+
abi: abis_1.FPMM_FACTORY_ABI,
|
|
22
|
+
functionName: 'deployedFPMMAddresses',
|
|
23
|
+
}));
|
|
24
|
+
if (poolAddresses.length === 0) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const poolDataPromises = poolAddresses.map(async (poolAddress) => {
|
|
28
|
+
const [token0, token1] = await Promise.all([
|
|
29
|
+
publicClient.readContract({
|
|
30
|
+
address: poolAddress,
|
|
31
|
+
abi: abis_1.FPMM_ABI,
|
|
32
|
+
functionName: 'token0',
|
|
33
|
+
}),
|
|
34
|
+
publicClient.readContract({
|
|
35
|
+
address: poolAddress,
|
|
36
|
+
abi: abis_1.FPMM_ABI,
|
|
37
|
+
functionName: 'token1',
|
|
38
|
+
}),
|
|
39
|
+
]);
|
|
40
|
+
return {
|
|
41
|
+
factoryAddr: fpmmFactoryAddress,
|
|
42
|
+
poolAddr: poolAddress,
|
|
43
|
+
token0: token0,
|
|
44
|
+
token1: token1,
|
|
45
|
+
poolType: types_1.PoolType.FPMM,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
return await Promise.all(poolDataPromises);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Failed to fetch FPMM pools: ${error.message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Fetches all Virtual pools by discovering them from BiPoolManager exchanges.
|
|
56
|
+
* VirtualPoolFactory doesn't have an enumeration method,
|
|
57
|
+
* so we have to derive pools from BiPoolManager.
|
|
58
|
+
*/
|
|
59
|
+
async function fetchVirtualPools(publicClient, chainId) {
|
|
60
|
+
const virtualPoolFactoryAddress = (0, constants_1.getContractAddress)(chainId, 'VirtualPoolFactory');
|
|
61
|
+
const biPoolManagerAddress = (0, constants_1.getContractAddress)(chainId, 'BiPoolManager');
|
|
62
|
+
if (!virtualPoolFactoryAddress || !biPoolManagerAddress) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
// TODO: When the latest virtual pool factory contract is deployed
|
|
67
|
+
// we can simplify this by using VirtualPoolFactory.getAllPools() returns(address[])
|
|
68
|
+
// Get all exchanges from BiPoolManager
|
|
69
|
+
const exchangesData = (await publicClient.readContract({
|
|
70
|
+
address: biPoolManagerAddress,
|
|
71
|
+
abi: abis_1.BIPOOL_MANAGER_ABI,
|
|
72
|
+
functionName: 'getExchanges',
|
|
73
|
+
}));
|
|
74
|
+
if (exchangesData.length === 0) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
// For each exchange, check if a virtual pool exists, and if so, return the pool address.
|
|
78
|
+
const poolPromises = exchangesData.map(async (exchange) => {
|
|
79
|
+
if (exchange.assets.length !== 2) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const [token0, token1] = (0, sortUtils_1.sortTokenAddresses)(exchange.assets[0], exchange.assets[1]);
|
|
83
|
+
const poolAddress = (await publicClient.readContract({
|
|
84
|
+
address: virtualPoolFactoryAddress,
|
|
85
|
+
abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
|
|
86
|
+
functionName: 'getOrPrecomputeProxyAddress',
|
|
87
|
+
args: [token0, token1],
|
|
88
|
+
}));
|
|
89
|
+
const isDeployed = (await publicClient.readContract({
|
|
90
|
+
address: virtualPoolFactoryAddress,
|
|
91
|
+
abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
|
|
92
|
+
functionName: 'isPool',
|
|
93
|
+
args: [poolAddress],
|
|
94
|
+
}));
|
|
95
|
+
if (!isDeployed) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const pool = {
|
|
99
|
+
factoryAddr: virtualPoolFactoryAddress,
|
|
100
|
+
poolAddr: poolAddress,
|
|
101
|
+
token0: token0,
|
|
102
|
+
token1: token1,
|
|
103
|
+
poolType: types_1.PoolType.Virtual,
|
|
104
|
+
exchangeId: exchange.exchangeId,
|
|
105
|
+
};
|
|
106
|
+
return pool;
|
|
107
|
+
});
|
|
108
|
+
const results = await Promise.all(poolPromises);
|
|
109
|
+
return results.filter((pool) => pool !== null);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
throw new Error(`Failed to fetch Virtual pools: ${error.message}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=poolDiscovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolDiscovery.js","sourceRoot":"","sources":["../../../src/services/pools/poolDiscovery.ts"],"names":[],"mappings":";;AASA,wCA8CC;AAOD,8CAiEC;AA/HD,oDAAkE;AAClE,4CAAiD;AACjD,0CAA0G;AAE1G,qDAA0D;AAE1D;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,YAA0B,EAAE,OAAe;IAC9E,MAAM,kBAAkB,GAAG,IAAA,8BAAkB,EAAC,OAAkB,EAAE,aAAa,CAAC,CAAA;IAEhF,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,CAAC;QACH,uCAAuC;QACvC,MAAM,aAAa,GAAG,CAAC,MAAM,YAAY,CAAC,YAAY,CAAC;YACrD,OAAO,EAAE,kBAA6B;YACtC,GAAG,EAAE,uBAAgB;YACrB,YAAY,EAAE,uBAAuB;SACtC,CAAC,CAAc,CAAA;QAEhB,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAA;QACX,CAAC;QAED,MAAM,gBAAgB,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;YAC/D,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CA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AO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAC/C,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAgB,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IAC9D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kCAAmC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;IAC/E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PublicClient } from 'viem';
|
|
2
|
+
import { RouteService } from '../routes';
|
|
3
|
+
import { Route } from '../../core/types';
|
|
4
|
+
/**
|
|
5
|
+
* Service for getting swap quotes from the Mento protocol.
|
|
6
|
+
* Calculates expected output amounts for trades without executing them.
|
|
7
|
+
*/
|
|
8
|
+
export declare class QuoteService {
|
|
9
|
+
private publicClient;
|
|
10
|
+
private chainId;
|
|
11
|
+
private routeService;
|
|
12
|
+
constructor(publicClient: PublicClient, chainId: number, routeService: RouteService);
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the expected output amount for a swap between two tokens.
|
|
15
|
+
*
|
|
16
|
+
* @param tokenIn - The address of the input token (e.g., '0x765DE816845861e75A25fCA122bb6898B8B1282a')
|
|
17
|
+
* @param tokenOut - The address of the output token (e.g., '0x471EcE3750Da237f93B8E339c536989b8978a438')
|
|
18
|
+
* @param amountIn - The amount of input tokens (in wei/smallest unit)
|
|
19
|
+
* @param route - Optional pre-fetched route. If not provided, the optimal route will be found automatically.
|
|
20
|
+
* @returns The expected output amount (in wei/smallest unit)
|
|
21
|
+
* @throws {RouteNotFoundError} If no route exists between the token pair
|
|
22
|
+
* @throws {Error} If the Router contract call fails
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Calculate output for 100 USDm
|
|
27
|
+
* const amountIn = BigInt(100) * BigInt(10 ** 18) // 100 USDm in wei
|
|
28
|
+
* const expectedOut = await quoteService.getAmountOut(
|
|
29
|
+
* '0x765DE816845861e75A25fCA122bb6898B8B1282a', // USDm
|
|
30
|
+
* '0x471EcE3750Da237f93B8E339c536989b8978a438', // CELO
|
|
31
|
+
* amountIn
|
|
32
|
+
* )
|
|
33
|
+
* console.log(`Expected CELO output: ${expectedOut}`)
|
|
34
|
+
*
|
|
35
|
+
* // Or provide a pre-fetched route for better performance
|
|
36
|
+
* const route = await routeService.findRoute(
|
|
37
|
+
* '0x765DE816845861e75A25fCA122bb6898B8B1282a',
|
|
38
|
+
* '0x471EcE3750Da237f93B8E339c536989b8978a438'
|
|
39
|
+
* )
|
|
40
|
+
* const expectedOut2 = await quoteService.getAmountOut(
|
|
41
|
+
* '0x765DE816845861e75A25fCA122bb6898B8B1282a',
|
|
42
|
+
* '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
43
|
+
* amountIn,
|
|
44
|
+
* route
|
|
45
|
+
* )
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
getAmountOut(tokenIn: string, tokenOut: string, amountIn: bigint, route?: Route): Promise<bigint>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=QuoteService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuoteService.d.ts","sourceRoot":"","sources":["../../../src/services/quotes/QuoteService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAMxC;;;GAGG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,YAAY;gBAFZ,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,YAAY;IAGpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;CAuBxG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuoteService = void 0;
|
|
4
|
+
const abis_1 = require("../../core/abis");
|
|
5
|
+
const constants_1 = require("../../core/constants");
|
|
6
|
+
const pathEncoder_1 = require("../../utils/pathEncoder");
|
|
7
|
+
const validation_1 = require("../../utils/validation");
|
|
8
|
+
/**
|
|
9
|
+
* Service for getting swap quotes from the Mento protocol.
|
|
10
|
+
* Calculates expected output amounts for trades without executing them.
|
|
11
|
+
*/
|
|
12
|
+
class QuoteService {
|
|
13
|
+
constructor(publicClient, chainId, routeService) {
|
|
14
|
+
this.publicClient = publicClient;
|
|
15
|
+
this.chainId = chainId;
|
|
16
|
+
this.routeService = routeService;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Calculates the expected output amount for a swap between two tokens.
|
|
20
|
+
*
|
|
21
|
+
* @param tokenIn - The address of the input token (e.g., '0x765DE816845861e75A25fCA122bb6898B8B1282a')
|
|
22
|
+
* @param tokenOut - The address of the output token (e.g., '0x471EcE3750Da237f93B8E339c536989b8978a438')
|
|
23
|
+
* @param amountIn - The amount of input tokens (in wei/smallest unit)
|
|
24
|
+
* @param route - Optional pre-fetched route. If not provided, the optimal route will be found automatically.
|
|
25
|
+
* @returns The expected output amount (in wei/smallest unit)
|
|
26
|
+
* @throws {RouteNotFoundError} If no route exists between the token pair
|
|
27
|
+
* @throws {Error} If the Router contract call fails
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Calculate output for 100 USDm
|
|
32
|
+
* const amountIn = BigInt(100) * BigInt(10 ** 18) // 100 USDm in wei
|
|
33
|
+
* const expectedOut = await quoteService.getAmountOut(
|
|
34
|
+
* '0x765DE816845861e75A25fCA122bb6898B8B1282a', // USDm
|
|
35
|
+
* '0x471EcE3750Da237f93B8E339c536989b8978a438', // CELO
|
|
36
|
+
* amountIn
|
|
37
|
+
* )
|
|
38
|
+
* console.log(`Expected CELO output: ${expectedOut}`)
|
|
39
|
+
*
|
|
40
|
+
* // Or provide a pre-fetched route for better performance
|
|
41
|
+
* const route = await routeService.findRoute(
|
|
42
|
+
* '0x765DE816845861e75A25fCA122bb6898B8B1282a',
|
|
43
|
+
* '0x471EcE3750Da237f93B8E339c536989b8978a438'
|
|
44
|
+
* )
|
|
45
|
+
* const expectedOut2 = await quoteService.getAmountOut(
|
|
46
|
+
* '0x765DE816845861e75A25fCA122bb6898B8B1282a',
|
|
47
|
+
* '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
48
|
+
* amountIn,
|
|
49
|
+
* route
|
|
50
|
+
* )
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async getAmountOut(tokenIn, tokenOut, amountIn, route) {
|
|
54
|
+
// Validate address inputs
|
|
55
|
+
(0, validation_1.validateAddress)(tokenIn, 'tokenIn');
|
|
56
|
+
(0, validation_1.validateAddress)(tokenOut, 'tokenOut');
|
|
57
|
+
// If the consumer does not provide a route then we find the best route.
|
|
58
|
+
if (!route) {
|
|
59
|
+
route = await this.routeService.findRoute(tokenIn, tokenOut);
|
|
60
|
+
}
|
|
61
|
+
// Convert route.path to Router contract's Route[] format
|
|
62
|
+
const routerRoutes = (0, pathEncoder_1.encodeRoutePath)(route.path, tokenIn, tokenOut);
|
|
63
|
+
const routerAddress = (0, constants_1.getContractAddress)(this.chainId, 'Router');
|
|
64
|
+
const amounts = (await this.publicClient.readContract({
|
|
65
|
+
address: routerAddress,
|
|
66
|
+
abi: abis_1.ROUTER_ABI,
|
|
67
|
+
functionName: 'getAmountsOut',
|
|
68
|
+
args: [amountIn, routerRoutes],
|
|
69
|
+
}));
|
|
70
|
+
return amounts[amounts.length - 1];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.QuoteService = QuoteService;
|
|
74
|
+
//# sourceMappingURL=QuoteService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuoteService.js","sourceRoot":"","sources":["../../../src/services/quotes/QuoteService.ts"],"names":[],"mappings":";;;AAGA,0CAA4C;AAC5C,oDAAkE;AAClE,yDAAyD;AACzD,uDAAwD;AAExD;;;GAGG;AACH,MAAa,YAAY;IACvB,YACU,YAA0B,EAC1B,OAAe,EACf,YAA0B;QAF1B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,YAAO,GAAP,OAAO,CAAQ;QACf,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,KAAK,CAAC,YAAY,CAAC,OAAe,EAAE,QAAgB,EAAE,QAAgB,EAAE,KAAa;QACnF,0BAA0B;QAC1B,IAAA,4BAAe,EAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QACnC,IAAA,4BAAe,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QAErC,wEAAwE;QACxE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC9D,CAAC;QAED,yDAAyD;QACzD,MAAM,YAAY,GAAG,IAAA,6BAAe,EAAC,KAAK,CAAC,IAAI,EAAE,OAAkB,EAAE,QAAmB,CAAC,CAAA;QACzF,MAAM,aAAa,GAAG,IAAA,8BAAkB,EAAC,IAAI,CAAC,OAAkB,EAAE,QAAQ,CAAC,CAAA;QAE3E,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;YACpD,OAAO,EAAE,aAA8B;YACvC,GAAG,EAAE,iBAAU;YACf,YAAY,EAAE,eAAe;YAC7B,IAAI,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC;SAC/B,CAAC,CAAa,CAAA;QAEf,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACpC,CAAC;CACF;AAjED,oCAiEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/quotes/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
__exportStar(require("./QuoteService"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/quotes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { PoolService } from '../pools';
|
|
2
|
+
import { Route, RouteWithCost } from '../../core/types';
|
|
3
|
+
import { PublicClient } from 'viem';
|
|
4
|
+
export interface RouteOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to use pre-generated cached routes (default: true)
|
|
7
|
+
*/
|
|
8
|
+
cached?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to return all possible routes or just the optimal one per pair (default: false)
|
|
11
|
+
*/
|
|
12
|
+
returnAllRoutes?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Service for discovering and managing trading routes in the Mento protocol.
|
|
16
|
+
* Handles route discovery for both direct (single-hop) and multi-hop trading paths.
|
|
17
|
+
*
|
|
18
|
+
* Routes are identified by their token pair and include the path of pools
|
|
19
|
+
* needed to execute the trade. Multi-hop routes (up to 2 hops) are automatically
|
|
20
|
+
* discovered when no direct route exists between two tokens.
|
|
21
|
+
*/
|
|
22
|
+
export declare class RouteService {
|
|
23
|
+
private publicClient;
|
|
24
|
+
private chainId;
|
|
25
|
+
private poolService;
|
|
26
|
+
private symbolCache;
|
|
27
|
+
constructor(publicClient: PublicClient, chainId: number, poolService: PoolService);
|
|
28
|
+
/**
|
|
29
|
+
* Generates all direct (single-hop) routes from available pools
|
|
30
|
+
* Routes are deduplicated and assets are sorted alphabetically by symbol
|
|
31
|
+
*
|
|
32
|
+
* @returns Array of direct routes with single-hop paths
|
|
33
|
+
* @throws {Error} If RPC calls fail
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const directRoutes = await routeService.getDirectRoutes()
|
|
38
|
+
* console.log(`Found ${directRoutes.length} direct routes`)
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
getDirectRoutes(): Promise<Route[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Discovers all tradable routes including multi-hop routes (up to 2 hops)
|
|
44
|
+
* Uses cached data by default for instant results, or generates fresh from blockchain
|
|
45
|
+
*
|
|
46
|
+
* @param options - Configuration options
|
|
47
|
+
* @param options.cached - Whether to use pre-generated cached routes (default: true)
|
|
48
|
+
* @param options.returnAllRoutes - Whether to return all possible routes or just the optimal one per pair (default: false)
|
|
49
|
+
* @returns Array of all tradable routes (direct + multi-hop routes)
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // Fast: use pre-generated cache
|
|
54
|
+
* const cachedRoutes = await routeService.getRoutes({ cached: true })
|
|
55
|
+
*
|
|
56
|
+
* // Slower but fresh: generate from blockchain
|
|
57
|
+
* const freshRoutes = await routeService.getRoutes({ cached: false })
|
|
58
|
+
*
|
|
59
|
+
* // Get all route variants (useful for cache generation)
|
|
60
|
+
* const allRoutes = await routeService.getRoutes({ cached: false, returnAllRoutes: true })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
getRoutes(options?: RouteOptions): Promise<readonly (Route | RouteWithCost)[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Looks up the tradable route between two tokens (direct or multi-hop)
|
|
66
|
+
*
|
|
67
|
+
* @param tokenIn - Input token address (direction matters for routing)
|
|
68
|
+
* @param tokenOut - Output token address (direction matters for routing)
|
|
69
|
+
* @param options - Optional configuration (e.g., cached)
|
|
70
|
+
* @returns The optimal tradable route connecting the two tokens
|
|
71
|
+
* @throws {RouteNotFoundError} If no route exists between the token pair
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const USDm = '0x765DE816845861e75A25fCA122bb6898B8B1282a'
|
|
76
|
+
* const BRLm = '0xE4D5...'
|
|
77
|
+
* const route = await routeService.findRoute(USDm, BRLm)
|
|
78
|
+
*
|
|
79
|
+
* if (route.path.length === 1) {
|
|
80
|
+
* console.log('Direct route available')
|
|
81
|
+
* } else {
|
|
82
|
+
* console.log('Two-hop route:', route.path)
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
findRoute(tokenIn: string, tokenOut: string, options?: {
|
|
87
|
+
cached?: boolean;
|
|
88
|
+
}): Promise<Route>;
|
|
89
|
+
/**
|
|
90
|
+
* Generate fresh tradable routes from blockchain data
|
|
91
|
+
* @param returnAllRoutes - Whether to return all routes or just optimal ones per pair
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
private generateFreshRoutes;
|
|
95
|
+
/**
|
|
96
|
+
* Load cached tradable routes for current chain
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
private loadCachedRoutes;
|
|
100
|
+
/**
|
|
101
|
+
* Helper: Fetch token symbol from on-chain
|
|
102
|
+
* Results are cached to avoid redundant RPC calls
|
|
103
|
+
* Falls back to address if symbol fetch fails
|
|
104
|
+
*
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
private fetchTokenSymbol;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=RouteService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteService.d.ts","sourceRoot":"","sources":["../../../src/services/routes/RouteService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAGtC,OAAO,EAAE,KAAK,EAAiB,aAAa,EAAc,MAAM,kBAAkB,CAAA;AAGlF,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAEnC,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;;;;;;;GAOG;AACH,qBAAa,YAAY;IAGX,OAAO,CAAC,YAAY;IAAgB,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,WAAW;IAF5F,OAAO,CAAC,WAAW,CAAiC;gBAEhC,YAAY,EAAE,YAAY,EAAU,OAAO,EAAE,MAAM,EAAU,WAAW,EAAE,WAAW;IAEzG;;;;;;;;;;;;OAYG;IACG,eAAe,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAuDzC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,SAAS,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,GAAG,aAAa,CAAC,EAAE,CAAC;IAoBpF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IAuBlG;;;;OAIG;YACW,mBAAmB;IAoBjC;;;OAGG;YACW,gBAAgB;IAM9B;;;;;;OAMG;YACW,gBAAgB;CAuB/B"}
|