@mento-protocol/mento-sdk 2.0.0-beta.9 → 3.0.0-beta.2
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 +170 -132
- package/dist/cache/routes.11142220.js +1 -0
- package/dist/cache/routes.42220.d.ts +3 -0
- package/dist/cache/routes.42220.d.ts.map +1 -0
- package/dist/cache/routes.42220.js +112 -0
- package/dist/cache/routes.42220.js.map +1 -0
- package/dist/cache/tokens.11142220.d.ts +3 -0
- package/dist/cache/tokens.11142220.d.ts.map +1 -0
- package/dist/cache/tokens.11142220.js +129 -0
- package/dist/cache/tokens.11142220.js.map +1 -0
- package/dist/cache/tokens.42220.d.ts +3 -0
- package/dist/cache/tokens.42220.d.ts.map +1 -0
- package/dist/cache/tokens.42220.js +129 -0
- package/dist/cache/tokens.42220.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/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 +2 -0
- package/dist/core/abis/erc20.d.ts.map +1 -0
- package/dist/{abis → core/abis}/erc20.js +5 -2
- package/dist/core/abis/erc20.js.map +1 -0
- package/dist/core/abis/fpmm.d.ts +34 -0
- package/dist/core/abis/fpmm.d.ts.map +1 -0
- package/dist/core/abis/fpmm.js +11 -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 +10 -0
- package/dist/core/abis/index.d.ts.map +1 -0
- package/dist/{abis → core/abis}/index.js +4 -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 +10 -0
- package/dist/core/abis/virtualPool.d.ts.map +1 -0
- package/dist/core/abis/virtualPool.js +6 -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/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 +73 -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/core/errors/index.js +19 -0
- 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 +39 -0
- package/dist/core/types/contractAddresses.d.ts.map +1 -0
- package/dist/core/types/contractAddresses.js.map +1 -0
- package/dist/{types → core/types}/index.d.ts +2 -1
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/{types → core/types}/index.js +2 -1
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/types/pool.d.ts +35 -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/core/types/provider.js +4 -0
- package/dist/core/types/provider.js.map +1 -0
- package/dist/core/types/route.d.ts +62 -0
- package/dist/core/types/route.d.ts.map +1 -0
- package/dist/{types/provider.js → core/types/route.js} +1 -1
- package/dist/core/types/route.js.map +1 -0
- package/dist/{types → core/types}/token.d.ts +7 -7
- package/dist/core/types/token.d.ts.map +1 -0
- package/dist/{types → core/types}/token.js.map +1 -1
- package/dist/index.d.ts +39 -109
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -152
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +6 -6
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +6 -6
- package/dist/services/index.js.map +1 -1
- package/dist/services/pools/PoolService.d.ts +37 -0
- package/dist/services/pools/PoolService.d.ts.map +1 -0
- package/dist/services/pools/PoolService.js +158 -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/quotes/QuoteService.d.ts +41 -0
- package/dist/services/quotes/QuoteService.d.ts.map +1 -0
- package/dist/services/quotes/QuoteService.js +61 -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 +241 -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 +158 -0
- package/dist/services/swap/SwapService.d.ts.map +1 -0
- package/dist/services/swap/SwapService.js +160 -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} +7 -2
- package/dist/services/tokens/supplyAdjustmentService.d.ts.map +1 -0
- package/dist/services/{supplyAdjustmentService.js → tokens/supplyAdjustmentService.js} +14 -11
- 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/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 +5 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/pathEncoder.d.ts +28 -0
- package/dist/utils/pathEncoder.d.ts.map +1 -0
- package/dist/utils/pathEncoder.js +57 -0
- package/dist/utils/pathEncoder.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 +9 -0
- package/dist/utils/routes.d.ts.map +1 -0
- package/dist/utils/routes.js +49 -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 +78 -0
- package/dist/utils/tokens.d.ts.map +1 -0
- package/dist/utils/tokens.js +181 -0
- package/dist/utils/tokens.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.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 +0 -3
- package/dist/types/exchange.js.map +0 -1
- 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/provider.js.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}/aaveConfig.js +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}/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,371 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildConnectivityStructures = buildConnectivityStructures;
|
|
4
|
+
exports.generateAllRoutes = generateAllRoutes;
|
|
5
|
+
exports.createTwoHopRoute = createTwoHopRoute;
|
|
6
|
+
exports.selectOptimalRoutes = selectOptimalRoutes;
|
|
7
|
+
exports.selectBestRoute = selectBestRoute;
|
|
8
|
+
exports.getIntermediateToken = getIntermediateToken;
|
|
9
|
+
exports.hasCostData = hasCostData;
|
|
10
|
+
const sortUtils_1 = require("./sortUtils");
|
|
11
|
+
/**
|
|
12
|
+
* Builds the connectivity data structures needed for route generation.
|
|
13
|
+
*
|
|
14
|
+
* Transforms a list of direct trading pairs into our ConnectivityData
|
|
15
|
+
* that allow us to quickly find trading routes.
|
|
16
|
+
*
|
|
17
|
+
* **Construction Process:**
|
|
18
|
+
*
|
|
19
|
+
* ```
|
|
20
|
+
* Input: TradablePairs = [
|
|
21
|
+
* { id: 'cUSD-CELO', assets: [cUSD, CELO], path: [exchange1_CELO_cUSD] },
|
|
22
|
+
* { id: 'CELO-cEUR', assets: [CELO, cEUR], path: [exchange2_CELO_cEUR] }
|
|
23
|
+
* ]
|
|
24
|
+
*
|
|
25
|
+
* Step 1 - Build addrToSymbol map:
|
|
26
|
+
* cUSD.address → 'cUSD'
|
|
27
|
+
* CELO.address → 'CELO'
|
|
28
|
+
* cEUR.address → 'cEUR'
|
|
29
|
+
*
|
|
30
|
+
* Step 2 - Build directPathMap (sorted alphabetically for consistency):
|
|
31
|
+
* 'CELO_addr-cEUR_addr' → exchange2_CELO_cEUR
|
|
32
|
+
* 'CELO_addr-cUSD_addr' → exchange1_CELO_cUSD
|
|
33
|
+
*
|
|
34
|
+
* Step 3 - Build bidirectional tokenGraph:
|
|
35
|
+
* cUSD.address → Set([CELO.address])
|
|
36
|
+
* CELO.address → Set([cUSD.address, cEUR.address])
|
|
37
|
+
* cEUR.address → Set([CELO.address])
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* **Result**: We can now efficiently answer:
|
|
41
|
+
* - "What's the symbol for address X?" → addrToSymbol.get(addr)
|
|
42
|
+
* - "What exchange connects tokens X and Y?" → directPathMap.get(sortedAddressPairKey)
|
|
43
|
+
* - "What tokens can I reach from token X?" → tokenGraph.get(X)
|
|
44
|
+
*
|
|
45
|
+
* @param directRoutes - Array of direct trading pairs
|
|
46
|
+
* @returns Connectivity data structure for efficient route generation
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const directPairs = [
|
|
51
|
+
* { id: 'cUSD-CELO', assets: [cUSD, CELO], path: [exchange1] },
|
|
52
|
+
* { id: 'CELO-cEUR', assets: [CELO, cEUR], path: [exchange2] }
|
|
53
|
+
* ]
|
|
54
|
+
*
|
|
55
|
+
* const connectivityData = buildConnectivityStructures(directPairs)
|
|
56
|
+
*
|
|
57
|
+
* // Now we can efficiently find routes:
|
|
58
|
+
* // 1. Check if cUSD connects to anything: connectivityData.tokenGraph.get(cUSD.address) → [CELO.address]
|
|
59
|
+
* // 2. Check if CELO connects to cEUR: connectivityData.tokenGraph.get(CELO.address) → [cUSD.address, cEUR.address] ✓
|
|
60
|
+
* // 3. Get exchange details: connectivityData.directPathMap.get('CELO_addr-cEUR_addr') → exchange2_CELO_cEUR
|
|
61
|
+
* // Result: Found route cUSD → CELO → cEUR with exchange details
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function buildConnectivityStructures(directRoutes) {
|
|
65
|
+
const addrToSymbol = new Map();
|
|
66
|
+
const directRouteMap = new Map();
|
|
67
|
+
const tokenGraph = new Map();
|
|
68
|
+
for (const route of directRoutes) {
|
|
69
|
+
const [tokenA, tokenB] = route.tokens;
|
|
70
|
+
// Build address-to-symbol map for quick symbol lookups
|
|
71
|
+
addrToSymbol.set(tokenA.address, tokenA.symbol);
|
|
72
|
+
addrToSymbol.set(tokenB.address, tokenB.symbol);
|
|
73
|
+
// Build direct path map (sorted addresses as key for consistency)
|
|
74
|
+
// for quick lookup of exchange details for any token pair
|
|
75
|
+
const routeId = (0, sortUtils_1.canonicalSymbolKey)(tokenA.symbol, tokenB.symbol);
|
|
76
|
+
if (!directRouteMap.has(routeId)) {
|
|
77
|
+
directRouteMap.set(routeId, route.path[0]);
|
|
78
|
+
}
|
|
79
|
+
// Build bidirectional connectivity graph for route traversal
|
|
80
|
+
// Each token can reach its directly connected tokens
|
|
81
|
+
if (!tokenGraph.has(tokenA.address))
|
|
82
|
+
tokenGraph.set(tokenA.address, new Set());
|
|
83
|
+
if (!tokenGraph.has(tokenB.address))
|
|
84
|
+
tokenGraph.set(tokenB.address, new Set());
|
|
85
|
+
tokenGraph.get(tokenA.address).add(tokenB.address);
|
|
86
|
+
tokenGraph.get(tokenB.address).add(tokenA.address);
|
|
87
|
+
}
|
|
88
|
+
return { addrToSymbol, directRouteMap, tokenGraph, directRoutes };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Generates all possible routes (direct + two-hop) using connectivity data.
|
|
92
|
+
*
|
|
93
|
+
* This function implements a route discovery algorithm that:
|
|
94
|
+
*
|
|
95
|
+
* 1. **Adds all direct routes** (single-hop routes)
|
|
96
|
+
* 2. **Discovers two-hop routes** using graph traversal:
|
|
97
|
+
* - For each token A, find its neighbors (tokens directly connected)
|
|
98
|
+
* - For each neighbor B, find B's neighbors
|
|
99
|
+
* - If B connects to token C (C ≠ A), then A->B->C is a valid route
|
|
100
|
+
*
|
|
101
|
+
* **Route Deduplication**: Multiple routes between the same token pair
|
|
102
|
+
* are collected in arrays, allowing the selection algorithm to choose
|
|
103
|
+
* the best one based on cost data or heuristics.
|
|
104
|
+
*
|
|
105
|
+
* **Canonical Route IDs**: All routes use alphabetically sorted symbols
|
|
106
|
+
* (e.g., 'cEUR-cUSD' not 'cUSD-cEUR') for consistent identification.
|
|
107
|
+
*
|
|
108
|
+
* @param connectivityData - The connectivity data from buildConnectivityStructures()
|
|
109
|
+
* @returns Map of route ID -> array of possible routes for that token pair
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* // Given direct routes: cUSD-CELO, CELO-cEUR, cUSD-USDC
|
|
114
|
+
* const allRoutes = generateAllRoutes(connectivityData)
|
|
115
|
+
*
|
|
116
|
+
* // Results might include:
|
|
117
|
+
* // 'cUSD-CELO' -> [{ path: [cUSD->CELO] }] // direct route
|
|
118
|
+
* // 'cEUR-cUSD' -> [
|
|
119
|
+
* // { path: [cUSD->USDC, USDC->cEUR] } // two-hop via USDC
|
|
120
|
+
* // { path: [cUSD->CELO, CELO->cEUR] } // two-hop via CELO
|
|
121
|
+
* // ]
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
function generateAllRoutes(connectivityData) {
|
|
125
|
+
const { addrToSymbol, directRouteMap, tokenGraph, directRoutes } = connectivityData;
|
|
126
|
+
const allRoutes = new Map();
|
|
127
|
+
// Step 1: Add all direct pairs (single-hop routes)
|
|
128
|
+
for (const route of directRoutes) {
|
|
129
|
+
if (!allRoutes.has(route.id)) {
|
|
130
|
+
allRoutes.set(route.id, []);
|
|
131
|
+
}
|
|
132
|
+
allRoutes.get(route.id).push(route);
|
|
133
|
+
}
|
|
134
|
+
// Step 2: Generate two-hop routes using graph traversal
|
|
135
|
+
// Algorithm: For each token, explore all paths of length 2
|
|
136
|
+
// OUTER LOOP: "For each starting token..." (e.g., cUSD, CELO, cEUR, etc.)
|
|
137
|
+
for (const [start, neighbors] of tokenGraph.entries()) {
|
|
138
|
+
// MIDDLE LOOP: "Where can I go from the starting token?" (first hop)
|
|
139
|
+
// Example: If start = cUSD, neighbors might be [CELO, USDC, cKES]
|
|
140
|
+
for (const intermediate of neighbors) {
|
|
141
|
+
// Get all tokens reachable from this intermediate token (second hop destinations)
|
|
142
|
+
const secondHopNeighbors = tokenGraph.get(intermediate);
|
|
143
|
+
if (!secondHopNeighbors)
|
|
144
|
+
continue;
|
|
145
|
+
// INNER LOOP: "From the intermediate token, where can I go?" (second hop)
|
|
146
|
+
// Example: If intermediate = CELO, secondHopNeighbors might be [cUSD, cEUR, cBRL]
|
|
147
|
+
for (const end of secondHopNeighbors) {
|
|
148
|
+
// Skip circular routes like cUSD → CELO → cUSD (pointless)
|
|
149
|
+
if (end === start)
|
|
150
|
+
continue;
|
|
151
|
+
// At this point we have a potential route: start → intermediate → end
|
|
152
|
+
// Example: cUSD → CELO → cEUR
|
|
153
|
+
// Try to create a valid two-hop trading pair from this route
|
|
154
|
+
const twoHopRoute = createTwoHopRoute(start, intermediate, end, addrToSymbol, directRouteMap);
|
|
155
|
+
// If we successfully created the pair, add it to our collection
|
|
156
|
+
if (twoHopRoute) {
|
|
157
|
+
if (!allRoutes.has(twoHopRoute.id)) {
|
|
158
|
+
allRoutes.set(twoHopRoute.id, []);
|
|
159
|
+
}
|
|
160
|
+
allRoutes.get(twoHopRoute.id).push(twoHopRoute);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return allRoutes;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Creates a two-hop tradable pair if valid exchange hops exist.
|
|
169
|
+
*
|
|
170
|
+
* 1. **Validates tokens exist** in the asset map
|
|
171
|
+
* 2. **Finds exchange hops** for both segments of the route
|
|
172
|
+
* 3. **Creates canonical pair structure** with sorted symbols
|
|
173
|
+
*
|
|
174
|
+
* **Route Structure**: The resulting pair represents trading from start->end
|
|
175
|
+
* via intermediate token, but the assets are ordered alphabetically by symbol
|
|
176
|
+
* for consistency (canonical form).
|
|
177
|
+
*
|
|
178
|
+
* **Path Representation**: The path array contains the actual exchange hops
|
|
179
|
+
* needed to execute the trade, preserving the routing information.
|
|
180
|
+
*
|
|
181
|
+
* @param startToken - Starting token address
|
|
182
|
+
* @param intermediate - Intermediate token address for routing
|
|
183
|
+
* @param end - Destination token address
|
|
184
|
+
* @param assetMap - Map of token address -> Asset details
|
|
185
|
+
* @param directPathMap - Map of token pairs -> exchange hop details
|
|
186
|
+
* @returns Route if valid route exists, null otherwise
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* // Create route: cUSD -> CELO -> cEUR
|
|
191
|
+
* const pair = createTwoHopPair(
|
|
192
|
+
* '0x765D...', // cUSD address
|
|
193
|
+
* '0x471E...', // CELO address
|
|
194
|
+
* '0xD876...', // cEUR address
|
|
195
|
+
* addrToSymbol,
|
|
196
|
+
* directPathMap
|
|
197
|
+
* )
|
|
198
|
+
*
|
|
199
|
+
* // Result:
|
|
200
|
+
* // {
|
|
201
|
+
* // id: 'cEUR-cUSD', // alphabetical order
|
|
202
|
+
* // assets: [cEUR, cUSD], // alphabetical order
|
|
203
|
+
* // path: [ // actual routing path
|
|
204
|
+
* // { cUSD->CELO exchange },
|
|
205
|
+
* // { CELO->cEUR exchange }
|
|
206
|
+
* // ]
|
|
207
|
+
* // }
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
function createTwoHopRoute(startAddr, intermediateAddr, endAddr, addrToSymbol, directRouteMap) {
|
|
211
|
+
// Validate that both all tokens exist in our address-to-symbol map
|
|
212
|
+
const startSymbol = addrToSymbol.get(startAddr);
|
|
213
|
+
const intermediateSymbol = addrToSymbol.get(intermediateAddr);
|
|
214
|
+
const endSymbol = addrToSymbol.get(endAddr);
|
|
215
|
+
if (!startSymbol || !intermediateSymbol || !endSymbol)
|
|
216
|
+
return null;
|
|
217
|
+
// Find exchange hops for both segments of the two-hop route
|
|
218
|
+
// Keys are sorted token addresses for consistent lookup
|
|
219
|
+
const hop1Key = (0, sortUtils_1.canonicalSymbolKey)(startSymbol, intermediateSymbol);
|
|
220
|
+
const hop2Key = (0, sortUtils_1.canonicalSymbolKey)(intermediateSymbol, endSymbol);
|
|
221
|
+
const hop1 = directRouteMap.get(hop1Key);
|
|
222
|
+
const hop2 = directRouteMap.get(hop2Key);
|
|
223
|
+
// If either hop doesn't exist, this route is invalid
|
|
224
|
+
if (!hop1 || !hop2)
|
|
225
|
+
return null;
|
|
226
|
+
// Create canonical pair structure (alphabetical symbol ordering)
|
|
227
|
+
const routeId = (0, sortUtils_1.canonicalSymbolKey)(startSymbol, endSymbol);
|
|
228
|
+
// Create Token objects from address and symbol
|
|
229
|
+
const startToken = { address: startAddr, symbol: startSymbol };
|
|
230
|
+
const endToken = { address: endAddr, symbol: endSymbol };
|
|
231
|
+
// Token array follows alphabetical ordering for consistency
|
|
232
|
+
const tokens = startSymbol <= endSymbol ? [startToken, endToken] : [endToken, startToken];
|
|
233
|
+
return {
|
|
234
|
+
id: routeId,
|
|
235
|
+
tokens,
|
|
236
|
+
path: [hop1, hop2], // Preserves actual routing path for execution
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Selects optimal routes from all candidates based on spread data or heuristics.
|
|
241
|
+
*
|
|
242
|
+
* This is the route optimization engine that implements the following logic:
|
|
243
|
+
*
|
|
244
|
+
* **For Single Route**: Use it directly (no optimization needed)
|
|
245
|
+
*
|
|
246
|
+
* **For Multiple Routes**:
|
|
247
|
+
* - If `returnAllRoutes=true`: Return all routes (used for cache generation)
|
|
248
|
+
* - If `returnAllRoutes=false`: Apply optimization to select the best route
|
|
249
|
+
*
|
|
250
|
+
* **Route Selection Strategy**: Delegates to `selectBestRoute()` which uses
|
|
251
|
+
* a multi-tier approach prioritizing cost efficiency and reliability.
|
|
252
|
+
*
|
|
253
|
+
* @param allRoutes - Map of pair ID -> array of possible routes
|
|
254
|
+
* @param returnAllRoutes - Whether to return all routes or optimize selection
|
|
255
|
+
* @param assetMap - Asset map for token symbol lookups during optimization
|
|
256
|
+
* @returns Array of selected optimal routes
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* // Multiple routes for cUSD-cEUR pair
|
|
261
|
+
* const candidates = new Map([
|
|
262
|
+
* ['cEUR-cUSD', [
|
|
263
|
+
* { path: [cUSD->CELO->cEUR], costData: { totalCostPercent: 0.5 } },
|
|
264
|
+
* { path: [cUSD->cREAL->cEUR], costData: { totalCostPercent: 0.3 } },
|
|
265
|
+
* { path: [cUSD->cEUR] } // direct route, no cost data
|
|
266
|
+
* ]]
|
|
267
|
+
* ])
|
|
268
|
+
*
|
|
269
|
+
* const optimal = selectOptimalRoutes(candidates, false, assetMap)
|
|
270
|
+
* // Returns the cUSD->cREAL->cEUR route (lowest cost: 0.3%)
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
function selectOptimalRoutes(allRoutes, returnAllRoutes, addrToSymbol) {
|
|
274
|
+
const result = new Map();
|
|
275
|
+
for (const [routeId, routes] of allRoutes) {
|
|
276
|
+
if (routes.length === 1) {
|
|
277
|
+
// Only one route available - use it directly
|
|
278
|
+
result.set(routeId, routes[0]);
|
|
279
|
+
}
|
|
280
|
+
else if (returnAllRoutes) {
|
|
281
|
+
// Return all routes with unique keys (used for cache generation)
|
|
282
|
+
routes.forEach((route, index) => {
|
|
283
|
+
result.set(`${routeId}_${index}`, route);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
// Multiple routes - select the best one using optimization logic
|
|
288
|
+
const bestRoute = selectBestRoute(routes, addrToSymbol);
|
|
289
|
+
result.set(routeId, bestRoute);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return Array.from(result.values());
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Selects the best route from candidates using cost data or fallback heuristics.
|
|
296
|
+
*
|
|
297
|
+
* This function implements a sophisticated route selection algorithm with
|
|
298
|
+
* multiple optimization tiers:
|
|
299
|
+
*
|
|
300
|
+
* **Tier 1 - Cost-Based Optimization** (Preferred):
|
|
301
|
+
* - Use routes with cost data (actual cost information)
|
|
302
|
+
* - Select route with lowest `totalCostPercent`
|
|
303
|
+
* - This provides the most cost-efficient trading
|
|
304
|
+
*
|
|
305
|
+
* **Tier 2 - Direct Route Preference** (Fallback):
|
|
306
|
+
* - If no cost data available, prefer direct (single-hop) routes
|
|
307
|
+
* - Direct routes have lower execution risk and gas costs
|
|
308
|
+
*
|
|
309
|
+
* **Tier 3 - Major Stablecoin Preference** (Final Fallback):
|
|
310
|
+
* - For two-hop routes, prefer those going through major stablecoins
|
|
311
|
+
* - Major FX currencies like cUSD and cEUR typically have better liquidity
|
|
312
|
+
*
|
|
313
|
+
* **Tier 4 - First Available** (Last Resort):
|
|
314
|
+
* - If no other heuristics apply, use the first route found
|
|
315
|
+
*
|
|
316
|
+
* @param candidates - Array of possible routes for the same token pair
|
|
317
|
+
* @param assetMap - Asset map for token symbol lookups
|
|
318
|
+
* @returns The optimal route selected using the tier system
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* const candidates = [
|
|
323
|
+
* { path: [A->B->C], costData: { totalCostPercent: 0.8 } },
|
|
324
|
+
* { path: [A->D->C], costData: { totalCostPercent: 0.4 } }, // Winner: lowest cost
|
|
325
|
+
* { path: [A->C] }, // direct route, no cost data
|
|
326
|
+
* ]
|
|
327
|
+
*
|
|
328
|
+
* const best = selectBestRoute(candidates, assetMap)
|
|
329
|
+
* // Returns the A->D->C route (0.4% cost)
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
function selectBestRoute(candidates, addrToSymbol) {
|
|
333
|
+
// Tier 1: Prefer routes with cost data (lowest cost wins)
|
|
334
|
+
const candidatesWithCost = candidates.filter(hasCostData);
|
|
335
|
+
if (candidatesWithCost.length > 0) {
|
|
336
|
+
return candidatesWithCost.reduce((best, current) => current.costData.totalCostPercent < best.costData.totalCostPercent ? current : best);
|
|
337
|
+
}
|
|
338
|
+
// Tier 2: Prefer direct routes (single-hop, lower risk)
|
|
339
|
+
const directRoute = candidates.find((c) => c.path.length === 1);
|
|
340
|
+
if (directRoute)
|
|
341
|
+
return directRoute;
|
|
342
|
+
// Tier 3: Prefer routes through major stablecoins (better liquidity)
|
|
343
|
+
const stablecoins = ['cUSD', 'cEUR', 'USDC', 'USDT'];
|
|
344
|
+
const routeWithStablecoin = candidates.find((candidate) => {
|
|
345
|
+
const intermediateToken = getIntermediateToken(candidate);
|
|
346
|
+
if (!intermediateToken)
|
|
347
|
+
return false;
|
|
348
|
+
const symbol = addrToSymbol.get(intermediateToken);
|
|
349
|
+
return symbol && stablecoins.includes(symbol);
|
|
350
|
+
});
|
|
351
|
+
// Tier 4: Use first available route as last resort
|
|
352
|
+
return routeWithStablecoin || candidates[0];
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Extracts the intermediate token address from a two-hop route.
|
|
356
|
+
* In a two-hop route A->B->C, this function finds token B (the intermediate).
|
|
357
|
+
*/
|
|
358
|
+
function getIntermediateToken(route) {
|
|
359
|
+
// Find the common token between the two hops
|
|
360
|
+
const [hop1, hop2] = route.path;
|
|
361
|
+
const hop1Tokens = [hop1.token0, hop1.token1];
|
|
362
|
+
const hop2Tokens = [hop2.token0, hop2.token1];
|
|
363
|
+
return hop1Tokens.find((addr) => hop2Tokens.includes(addr));
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Type guard to check if a Route has cost data.
|
|
367
|
+
*/
|
|
368
|
+
function hasCostData(pair) {
|
|
369
|
+
return 'costData' in pair && pair.costData !== undefined;
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=routeUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeUtils.js","sourceRoot":"","sources":["../../src/utils/routeUtils.ts"],"names":[],"mappings":";;AA4IA,kEA4BC;AAoCD,8CAgDC;AA6CD,8CAsCC;AAoCD,kDAwBC;AAwCD,0CAwBC;AAMD,oDAMC;AAKD,kCAEC;AA7dD,2CAAqE;AAsFrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,SAAgB,2BAA2B,CAAC,YAAqB;IAC/D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwB,CAAA;IACpD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAiB,CAAA;IAC/C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAA;IAEjD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAA;QAErC,uDAAuD;QACvD,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAC/C,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAE/C,kEAAkE;QAClE,0DAA0D;QAC1D,MAAM,OAAO,GAAG,IAAA,8BAAkB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IAC7C,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAC7C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;AAC7D,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,IAA2B;IACrD,OAAO,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAA;AAC1D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Route, RouteWithCost } from '../core/types';
|
|
2
|
+
export type { RouteWithCost };
|
|
3
|
+
/**
|
|
4
|
+
* Gets cached routes for a specific chain ID
|
|
5
|
+
* @param chainId - The chain ID to get cached routes for
|
|
6
|
+
* @returns Promise resolving to the cached routes or undefined if not available
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCachedRoutes(chainId: number): Promise<readonly (Route | RouteWithCost)[] | undefined>;
|
|
9
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/utils/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAGzD,YAAY,EAAE,aAAa,EAAE,CAAA;AAE7B;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,KAAK,GAAG,aAAa,CAAC,EAAE,GAAG,SAAS,CAAC,CAmBzD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getCachedRoutes = getCachedRoutes;
|
|
27
|
+
/**
|
|
28
|
+
* Gets cached routes for a specific chain ID
|
|
29
|
+
* @param chainId - The chain ID to get cached routes for
|
|
30
|
+
* @returns Promise resolving to the cached routes or undefined if not available
|
|
31
|
+
*/
|
|
32
|
+
async function getCachedRoutes(chainId) {
|
|
33
|
+
try {
|
|
34
|
+
switch (chainId) {
|
|
35
|
+
case 42220:
|
|
36
|
+
// @ts-ignore - Cache files are generated by scripts and may not exist yet
|
|
37
|
+
return await Promise.resolve().then(() => __importStar(require('../cache/routes.42220'))).then((module) => module.routes42220);
|
|
38
|
+
case 11142220:
|
|
39
|
+
// @ts-ignore - Cache files are generated by scripts and may not exist yet
|
|
40
|
+
return await Promise.resolve().then(() => __importStar(require('../cache/routes.11142220'))).then((module) => module.routes11142220);
|
|
41
|
+
default:
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/utils/routes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUA,0CAqBC;AA1BD;;;;GAIG;AACI,KAAK,UAAU,eAAe,CACnC,OAAe;IAEf,IAAI,CAAC;QACH,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,KAAK;gBACR,0EAA0E;gBAC1E,OAAO,MAAM,kDAAO,uBAAuB,IAAE,IAAI,CAC/C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAC/B,CAAA;YACH,KAAK,QAAQ;gBACX,0EAA0E;gBAC1E,OAAO,MAAM,kDAAO,0BAA0B,IAAE,IAAI,CAClD,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAClC,CAAA;YACH;gBACE,OAAO,SAAS,CAAA;QACpB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Sorts two token addresses to match the smart contract's _sortTokens behavior.
|
|
4
|
+
* Compares addresses as numeric values (BigInt), matching Solidity's address comparison.
|
|
5
|
+
*
|
|
6
|
+
* Solidity reference:
|
|
7
|
+
* ```solidity
|
|
8
|
+
* function _sortTokens(address a, address b) private pure returns (address, address) {
|
|
9
|
+
* return (a < b) ? (a, b) : (b, a);
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function sortTokenAddresses(tokenA: Address, tokenB: Address): [Address, Address];
|
|
14
|
+
/**
|
|
15
|
+
* Creates a canonical route ID from two addresses.
|
|
16
|
+
* Uses numeric address comparison to match contract behavior.
|
|
17
|
+
*/
|
|
18
|
+
export declare function canonicalAddressKey(addressA: Address, addressB: Address, separator?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a canonical pair key from two symbols.
|
|
21
|
+
* Uses standard string comparison for human-readable IDs.
|
|
22
|
+
*/
|
|
23
|
+
export declare function canonicalSymbolKey(symbolA: string, symbolB: string, separator?: string): string;
|
|
24
|
+
//# sourceMappingURL=sortUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortUtils.d.ts","sourceRoot":"","sources":["../../src/utils/sortUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,OAAO,GACd,CAAC,OAAO,EAAE,OAAO,CAAC,CAIpB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,SAAS,SAAM,GACd,MAAM,CAGR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,SAAM,GACd,MAAM,CAIR"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortTokenAddresses = sortTokenAddresses;
|
|
4
|
+
exports.canonicalAddressKey = canonicalAddressKey;
|
|
5
|
+
exports.canonicalSymbolKey = canonicalSymbolKey;
|
|
6
|
+
/**
|
|
7
|
+
* Sorts two token addresses to match the smart contract's _sortTokens behavior.
|
|
8
|
+
* Compares addresses as numeric values (BigInt), matching Solidity's address comparison.
|
|
9
|
+
*
|
|
10
|
+
* Solidity reference:
|
|
11
|
+
* ```solidity
|
|
12
|
+
* function _sortTokens(address a, address b) private pure returns (address, address) {
|
|
13
|
+
* return (a < b) ? (a, b) : (b, a);
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function sortTokenAddresses(tokenA, tokenB) {
|
|
18
|
+
return BigInt(tokenA) < BigInt(tokenB)
|
|
19
|
+
? [tokenA, tokenB]
|
|
20
|
+
: [tokenB, tokenA];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a canonical route ID from two addresses.
|
|
24
|
+
* Uses numeric address comparison to match contract behavior.
|
|
25
|
+
*/
|
|
26
|
+
function canonicalAddressKey(addressA, addressB, separator = '-') {
|
|
27
|
+
const [first, second] = sortTokenAddresses(addressA, addressB);
|
|
28
|
+
return `${first}${separator}${second}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a canonical pair key from two symbols.
|
|
32
|
+
* Uses standard string comparison for human-readable IDs.
|
|
33
|
+
*/
|
|
34
|
+
function canonicalSymbolKey(symbolA, symbolB, separator = '-') {
|
|
35
|
+
return symbolA < symbolB
|
|
36
|
+
? `${symbolA}${separator}${symbolB}`
|
|
37
|
+
: `${symbolB}${separator}${symbolA}`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=sortUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortUtils.js","sourceRoot":"","sources":["../../src/utils/sortUtils.ts"],"names":[],"mappings":";;AAaA,gDAOC;AAMD,kDAOC;AAMD,gDAQC;AA7CD;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAChC,MAAe,EACf,MAAe;IAEf,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QACpC,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC;QAClB,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AACtB,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,QAAiB,EACjB,QAAiB,EACjB,SAAS,GAAG,GAAG;IAEf,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAC9D,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,EAAE,CAAA;AACxC,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAChC,OAAe,EACf,OAAe,EACf,SAAS,GAAG,GAAG;IAEf,OAAO,OAAO,GAAG,OAAO;QACtB,CAAC,CAAC,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,EAAE;QACpC,CAAC,CAAC,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,EAAE,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Token } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Enum of all token symbols across all supported chains
|
|
4
|
+
*/
|
|
5
|
+
export declare enum TokenSymbol {
|
|
6
|
+
AUDm = "AUDm",
|
|
7
|
+
BRLm = "BRLm",
|
|
8
|
+
CADm = "CADm",
|
|
9
|
+
CELO = "CELO",
|
|
10
|
+
CHFm = "CHFm",
|
|
11
|
+
COPm = "COPm",
|
|
12
|
+
EURm = "EURm",
|
|
13
|
+
GBPm = "GBPm",
|
|
14
|
+
GHSm = "GHSm",
|
|
15
|
+
JPYm = "JPYm",
|
|
16
|
+
KESm = "KESm",
|
|
17
|
+
NGNm = "NGNm",
|
|
18
|
+
PHPm = "PHPm",
|
|
19
|
+
PUSO = "PUSO",
|
|
20
|
+
USDC = "USDC",
|
|
21
|
+
USDm = "USDm",
|
|
22
|
+
USD_ = "USD\u20AE",
|
|
23
|
+
XOFm = "XOFm",
|
|
24
|
+
ZARm = "ZARm",
|
|
25
|
+
axlEUROC = "axlEUROC",
|
|
26
|
+
axlUSDC = "axlUSDC",
|
|
27
|
+
cAUD = "cAUD",
|
|
28
|
+
cCAD = "cCAD",
|
|
29
|
+
cCHF = "cCHF",
|
|
30
|
+
cCOP = "cCOP",
|
|
31
|
+
cEUR = "cEUR",
|
|
32
|
+
cGBP = "cGBP",
|
|
33
|
+
cGHS = "cGHS",
|
|
34
|
+
cJPY = "cJPY",
|
|
35
|
+
cKES = "cKES",
|
|
36
|
+
cNGN = "cNGN",
|
|
37
|
+
cREAL = "cREAL",
|
|
38
|
+
cUSD = "cUSD",
|
|
39
|
+
cZAR = "cZAR",
|
|
40
|
+
eXOF = "eXOF"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get cached tokens for a specific chain ID
|
|
44
|
+
* @param chainId - The chain ID to get tokens for
|
|
45
|
+
* @returns Promise resolving to the cached tokens array, or undefined if not available
|
|
46
|
+
*/
|
|
47
|
+
export declare function getCachedTokens(chainId: number): Promise<readonly Token[] | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* Get cached tokens synchronously for a specific chain ID
|
|
50
|
+
* @param chainId - The chain ID to get tokens for
|
|
51
|
+
* @returns The cached tokens array
|
|
52
|
+
* @throws Error if tokens are not available for the chain
|
|
53
|
+
*/
|
|
54
|
+
export declare function getCachedTokensSync(chainId: number): readonly Token[];
|
|
55
|
+
/**
|
|
56
|
+
* Mapping of token addresses by chain ID and token symbol
|
|
57
|
+
* Useful for quickly looking up a token address by its symbol on a specific chain
|
|
58
|
+
*/
|
|
59
|
+
export declare const TOKEN_ADDRESSES_BY_CHAIN: {
|
|
60
|
+
[chainId: number]: {
|
|
61
|
+
[tokenSymbol in TokenSymbol]?: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Get token address by chain ID and symbol
|
|
66
|
+
* @param chainId - The chain ID
|
|
67
|
+
* @param symbol - The token symbol
|
|
68
|
+
* @returns The token address or undefined if not found
|
|
69
|
+
*/
|
|
70
|
+
export declare function getTokenAddress(chainId: number, symbol: TokenSymbol): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Find a token by its symbol on a specific chain
|
|
73
|
+
* @param chainId - The chain ID
|
|
74
|
+
* @param symbol - The token symbol
|
|
75
|
+
* @returns The token object or undefined if not found
|
|
76
|
+
*/
|
|
77
|
+
export declare function findTokenBySymbol(chainId: number, symbol: TokenSymbol): Token | undefined;
|
|
78
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/utils/tokens.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C;;GAEG;AACH,oBAAY,WAAW;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,cAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,KAAK,EAAE,GAAG,SAAS,CAAC,CASvC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,EAAE,CAWrE;AAED;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