import { BigNumber } from '@ethersproject/bignumber'; import { BaseProvider } from '@ethersproject/providers'; import { Protocol } from '@uniswap/router-sdk'; import { ChainId, Currency, Token, TradeType } from '@uniswap/sdk-core'; import { UniversalRouterVersion } from '@uniswap/universal-router-sdk'; import { Position } from '@uniswap/v3-sdk'; import { CacheMode, IOnChainQuoteProvider, IRouteCachingProvider, ISwapRouterProvider, ITokenPropertiesProvider, IV2QuoteProvider, IV2SubgraphProvider, IV4SubgraphProvider, MobulaClient, MobulaClientOptions, MobulaSubgraphProviderOptions, Simulator, UniswapMulticallProvider } from '../../providers'; import { ITokenListProvider } from '../../providers/caching-token-list-provider'; import { IGasPriceProvider } from '../../providers/gas-price-provider'; import { IPortionProvider } from '../../providers/portion-provider'; import { ITokenProvider } from '../../providers/token-provider'; import { ITokenValidatorProvider } from '../../providers/token-validator-provider'; import { IV2PoolProvider } from '../../providers/v2/pool-provider'; import { PSSPoolProvider } from '../../providers/pss/pool-provider'; import { PV4BINPoolProvider } from '../../providers/pv4bin/pool-provider'; import { IPV4BINSubgraphProvider } from '../../providers/pv4bin/subgraph-provider'; import { PV4CLPoolProvider } from '../../providers/pv4cl/pool-provider'; import { IPV4CLSubgraphProvider } from '../../providers/pv4cl/subgraph-provider'; import { ArbitrumGasData, IL2GasDataProvider } from '../../providers/v3/gas-data-provider'; import { IV3PoolProvider } from '../../providers/v3/pool-provider'; import { IV3SubgraphProvider } from '../../providers/v3/subgraph-provider'; import { IV4PoolProvider } from '../../providers/v4/pool-provider'; import { HooksOptions } from '../../util'; import { CurrencyAmount } from '../../util/amounts'; import { type PV4CLPoolParamSpec } from '../../util/pv4cl-constants'; import { INTENT } from '../../util/intent'; import { IRouter, ISwapToRatio, MixedRoute, SwapAndAddConfig, SwapAndAddOptions, SwapOptions, SwapRoute, SwapToRatioResponse, V2Route, V3Route, V4Route } from '../router'; import { MixedRouteWithValidQuote, RouteWithValidQuote, V3RouteWithValidQuote, V4RouteWithValidQuote } from './entities/route-with-valid-quote'; import { IOnChainGasModelFactory, IV2GasModelFactory } from './gas-models/gas-model'; import { MixedQuoter, V2Quoter, V3Quoter } from './quoters'; import { PSSQuoter } from './quoters/pss-quoter'; import { PV2Quoter } from './quoters/pv2-quoter'; import { PV3Quoter } from './quoters/pv3-quoter'; import { PV4BINQuoter } from './quoters/pv4bin-quoter'; import { PV4CLQuoter } from './quoters/pv4cl-quoter'; import { V4Quoter } from './quoters/v4-quoter'; export type AlphaRouterParams = { /** * The chain id for this instance of the Alpha Router. */ chainId: ChainId; /** * The Web3 provider for getting on-chain data. */ provider: BaseProvider; /** * The provider to use for making multicalls. Used for getting on-chain data * like pools, tokens, quotes in batch. */ multicall2Provider?: UniswapMulticallProvider; /** * The provider for getting all pools that exist on V4 from the Subgraph. The pools * from this provider are filtered during the algorithm to a set of candidate pools. */ v4SubgraphProvider?: IV4SubgraphProvider; /** * The provider for getting data about V4 pools. */ v4PoolProvider?: IV4PoolProvider; /** * The provider for getting all pools that exist on V3 from the Subgraph. The pools * from this provider are filtered during the algorithm to a set of candidate pools. */ v3SubgraphProvider?: IV3SubgraphProvider; /** * The provider for getting data about V3 pools. */ v3PoolProvider?: IV3PoolProvider; /** * The provider for getting V3 quotes. */ onChainQuoteProvider?: IOnChainQuoteProvider; /** * The provider for getting all pools that exist on V2 from the Subgraph. The pools * from this provider are filtered during the algorithm to a set of candidate pools. */ v2SubgraphProvider?: IV2SubgraphProvider; /** * The provider for getting data about V2 pools. */ v2PoolProvider?: IV2PoolProvider; /** * The provider for getting V3 quotes. */ v2QuoteProvider?: IV2QuoteProvider; /** * The provider for getting data about Tokens. */ tokenProvider?: ITokenProvider; /** * The provider for getting the current gas price to use when account for gas in the * algorithm. */ gasPriceProvider?: IGasPriceProvider; /** * A factory for generating a gas model that is used when estimating the gas used by * V4 routes. */ v4GasModelFactory?: IOnChainGasModelFactory; /** * A factory for generating a gas model that is used when estimating the gas used by * V3 routes. */ v3GasModelFactory?: IOnChainGasModelFactory; /** * A factory for generating a gas model that is used when estimating the gas used by * V2 routes. */ v2GasModelFactory?: IV2GasModelFactory; /** * A factory for generating a gas model that is used when estimating the gas used by * V3 routes. */ mixedRouteGasModelFactory?: IOnChainGasModelFactory; /** * A token list that specifies Token that should be blocked from routing through. * Defaults to Uniswap's unsupported token list. */ blockedTokenListProvider?: ITokenListProvider; /** * Calls lens function on SwapRouter02 to determine ERC20 approval types for * LP position tokens. */ swapRouterProvider?: ISwapRouterProvider; /** * A token validator for detecting fee-on-transfer tokens or tokens that can't be transferred. */ tokenValidatorProvider?: ITokenValidatorProvider; /** * Calls the arbitrum gas data contract to fetch constants for calculating the l1 fee. */ arbitrumGasDataProvider?: IL2GasDataProvider; /** * Simulates swaps and returns new SwapRoute with updated gas estimates. */ simulator?: Simulator; /** * A provider for caching the best route given an amount, quoteToken, tradeType */ routeCachingProvider?: IRouteCachingProvider; /** * A provider for getting token properties for special tokens like fee-on-transfer tokens. */ tokenPropertiesProvider?: ITokenPropertiesProvider; /** * A provider for computing the portion-related data for routes and quotes. */ portionProvider?: IPortionProvider; /** * All the supported v2 chains configuration */ v2Supported?: ChainId[]; /** * Provider for PancakeSwap V2 subgraph pool data. * If not supplied, a fallback chain is built automatically: * real subgraph (if URL provided) -> static provider. */ pv2SubgraphProvider?: IV2SubgraphProvider; /** * Per-chain PancakeSwap V2 subgraph URLs. * Only used when pv2SubgraphProvider is NOT supplied. * Example: { [ChainId.MAINNET]: 'https://...', [ChainId.BNB]: 'https://...' } */ pv2SubgraphUrls?: { [chainId: number]: string; }; /** * Provider for PancakeSwap V2 pool data. */ pv2PoolProvider?: IV2PoolProvider; /** * All the supported PancakeSwap V2 chains configuration */ pv2Supported?: ChainId[]; /** * PancakeSwap V3 subgraph provider. * Falls back to: real subgraph (if URL provided) -> static provider. */ pv3SubgraphProvider?: IV3SubgraphProvider; /** * Per-chain PancakeSwap V3 subgraph URLs. * Only used when pv3SubgraphProvider is NOT supplied. */ pv3SubgraphUrls?: { [chainId: number]: string; }; /** * Provider for PancakeSwap V3 pool data. */ pv3PoolProvider?: IV3PoolProvider; /** * All the supported PancakeSwap V3 chains configuration */ pv3Supported?: ChainId[]; /** * PancakeSwap Infinity CL subgraph provider. * Falls back to: real subgraph (if URL provided) -> static provider. */ pv4clSubgraphProvider?: IPV4CLSubgraphProvider; /** * Per-chain PancakeSwap Infinity CL subgraph URLs. * Only used when pv4clSubgraphProvider is NOT supplied. */ pv4clSubgraphUrls?: { [chainId: number]: string; }; /** * Additional PancakeSwap Infinity CL pool rows **appended** to * {@link PV4CL_DEFAULT_POOL_PARAMS}. Use {@link PV4CLPoolParamSpec}: optional * 4th element is on-chain `PoolKey.parameters` (bytes32), not Uniswap v4 layout. */ pv4clPoolParams?: PV4CLPoolParamSpec[]; /** * All the supported PancakeSwap Infinity CL chains configuration */ pv4clSupported?: ChainId[]; /** * PancakeSwap Infinity Bin subgraph provider. * Falls back to static provider if not supplied. */ pv4binSubgraphProvider?: IPV4BINSubgraphProvider; /** * Additional PV4BIN pool params [fee, binStep, hooks][] that are * **appended** to the built-in PV4BIN_DEFAULT_POOL_PARAMS. */ pv4binPoolParams?: Array<[number, number, string]>; /** * All the supported PancakeSwap Infinity Bin chains configuration */ pv4binSupported?: ChainId[]; /** * Provider for PancakeSwap StableSwap pool data. */ pssPoolProvider?: PSSPoolProvider; /** * All the supported PancakeSwap StableSwap chains configuration */ pssSupported?: ChainId[]; /** * All the supported v4 chains configuration */ v4Supported?: ChainId[]; /** * All the supported mixed chains configuration */ mixedSupported?: ChainId[]; /** * All the supported mixed cross-liquidity high v3 tvl pools against low-to-mid v4 pools chains configuration */ mixedCrossLiquidityV3AgainstV4Supported?: ChainId[]; /** * Additional V4 pool params [fee, tickSpacing, hooks][] that are * **appended** to the built-in defaults. Use this to add * DYNAMIC_FEE_FLAG entries with custom hook addresses without * having to repeat all the standard fee tiers. */ v4PoolParams?: Array<[number, number, string]>; /** * We want to rollout the cached routes cache invalidation carefully. * Because a wrong fix might impact prod success rate and/or latency. */ cachedRoutesCacheInvalidationFixRolloutPercentage?: number; /** * All the chains that have the cache invalidation enabled * https://linear.app/uniswap/issue/ROUTE-467/tenderly-simulation-during-caching-lambda */ deleteCacheEnabledChains?: ChainId[]; /** * Additional base tokens appended to BASES_TO_CHECK_TRADES_AGAINST * in the Uniswap V2 static subgraph provider. */ v2AdditionalBases?: Token[]; /** * Additional base tokens appended to BASES_TO_CHECK_TRADES_AGAINST * in the Uniswap V3 static subgraph provider. */ v3AdditionalBases?: Token[]; /** * Additional base tokens appended to BASES_TO_CHECK_TRADES_AGAINST * in the Uniswap V4 static subgraph provider. */ v4AdditionalBases?: Token[]; /** * Additional base tokens appended to PV2_BASES_TO_CHECK_TRADES_AGAINST * in the PancakeSwap V2 static subgraph provider. */ pv2AdditionalBases?: Token[]; /** * Additional base tokens appended to PV3_BASES_TO_CHECK_TRADES_AGAINST * in the PancakeSwap V3 static subgraph provider. */ pv3AdditionalBases?: Token[]; /** * Additional base tokens appended to PV4CL_BASES_TO_CHECK_TRADES_AGAINST * in the PancakeSwap Infinity CL static subgraph provider. */ pv4clAdditionalBases?: Token[]; /** * Additional base tokens appended to PV4BIN_BASES_TO_CHECK_TRADES_AGAINST * in the PancakeSwap Infinity Bin static subgraph provider. */ pv4binAdditionalBases?: Token[]; /** * Mobula API key. When set (or MOBULA_API_KEY is in the environment) Mobula * is queried first for pool discovery on supported chains; the existing * subgraph/static providers remain as fallbacks. */ mobulaApiKey?: string; /** * Override the Mobula base URL (default https://api.mobula.io). */ mobulaBaseUrl?: string; /** * Tuning for Mobula discovery (pages per token, chain-wide pages, * liquidity floor, TTLs, timeout). */ mobulaOptions?: MobulaSubgraphProviderOptions & Pick; /** * Fully constructed Mobula client (tests / shared caches). Takes precedence * over mobulaApiKey. */ mobulaClient?: MobulaClient; }; export declare class MapWithLowerCaseKey extends Map { set(key: string, value: V): this; } export declare class LowerCaseStringArray extends Array { constructor(...items: string[]); } /** * Determines the pools that the algorithm will consider when finding the optimal swap. * * All pools on each protocol are filtered based on the heuristics specified here to generate * the set of candidate pools. The Top N pools are taken by Total Value Locked (TVL). * * Higher values here result in more pools to explore which results in higher latency. */ export type ProtocolPoolSelection = { /** * The top N pools by TVL out of all pools on the protocol. */ topN: number; /** * The top N pools by TVL of pools that consist of tokenIn and tokenOut. */ topNDirectSwaps: number; /** * The top N pools by TVL of pools where one token is tokenIn and the * top N pools by TVL of pools where one token is tokenOut tokenOut. */ topNTokenInOut: number; /** * Given the topNTokenInOut pools, gets the top N pools that involve the other token. * E.g. for a WETH -> USDC swap, if topNTokenInOut found WETH -> DAI and WETH -> USDT, * a value of 2 would find the top 2 pools that involve DAI and top 2 pools that involve USDT. */ topNSecondHop: number; /** * Given the topNTokenInOut pools and a token address, * gets the top N pools that involve the other token. * If token address is not on the list, we default to topNSecondHop. * E.g. for a WETH -> USDC swap, if topNTokenInOut found WETH -> DAI and WETH -> USDT, * and there's a mapping USDT => 4, but no mapping for DAI * it would find the top 4 pools that involve USDT, and find the topNSecondHop pools that involve DAI */ topNSecondHopForTokenAddress?: MapWithLowerCaseKey; /** * List of token addresses to avoid using as a second hop. * There might be multiple reasons why we would like to avoid a specific token, * but the specific reason that we are trying to solve is when the pool is not synced properly * e.g. when the pool has a rebasing token that isn't syncing the pool on every rebase. */ tokensToAvoidOnSecondHops?: LowerCaseStringArray; /** * The top N pools for token in and token out that involve a token from a list of * hardcoded 'base tokens'. These are standard tokens such as WETH, USDC, DAI, etc. * This is similar to how the legacy routing algorithm used by Uniswap would select * pools and is intended to make the new pool selection algorithm close to a superset * of the old algorithm. */ topNWithEachBaseToken: number; /** * Given the topNWithEachBaseToken pools, takes the top N pools from the full list. * E.g. for a WETH -> USDC swap, if topNWithEachBaseToken found WETH -0.05-> DAI, * WETH -0.01-> DAI, WETH -0.05-> USDC, WETH -0.3-> USDC, a value of 2 would reduce * this set to the top 2 pools from that full list. */ topNWithBaseToken: number; /** * For each route on this protocol, the maximum number of hops (pools) to consider. * More hops increase latency of the algorithm. */ maxSwapsPerPath: number; }; export type AlphaRouterConfig = { /** * The block number to use for all on-chain data. If not provided, the router will * use the latest block returned by the provider. */ blockNumber?: number | Promise; /** * The protocols to consider when finding the optimal swap. If not provided all protocols * will be used. */ protocols?: Protocol[]; /** * The protocols-version pools to be excluded from the mixed routes. */ excludedProtocolsFromMixed?: Protocol[]; /** * Config for selecting which pools to consider routing via on V2. */ v2PoolSelection: ProtocolPoolSelection; /** * Config for selecting which pools to consider routing via on V3. */ v3PoolSelection: ProtocolPoolSelection; /** * Config for selecting which pools to consider routing via on V4. */ v4PoolSelection: ProtocolPoolSelection; /** * Config for selecting which pools to consider routing via on PancakeSwap Infinity CL. */ pv4clPoolSelection: ProtocolPoolSelection; /** * Optional extra tokens merged with the router's per-chain base list for topByBaseWithTokenIn/Out * pool selection (V2, V3, V4, PV4CL). Deduped by address. Useful for tests or app-specific bases. */ additionalRoutingBaseTokens?: Token[]; /** * The maximum number of splits in the returned route. A higher maximum will increase latency of the algorithm. */ maxSplits: number; /** * The minimum number of splits in the returned route. * This parameters should always be set to 1. It is only included for testing purposes. */ minSplits: number; /** * Forces the returned swap to route across all protocols. * This parameter should always be false. It is only included for testing purposes. */ forceCrossProtocol: boolean; /** * Force the alpha router to choose a mixed route swap. * Default will be falsy. It is only included for testing purposes. */ forceMixedRoutes?: boolean; /** * The minimum percentage of the input token to use for each route in a split route. * All routes will have a multiple of this value. For example is distribution percentage is 5, * a potential return swap would be: * * 5% of input => Route 1 * 55% of input => Route 2 * 40% of input => Route 3 */ distributionPercent: number; /** * Flag to indicate whether to use the cached routes or not. * By default, the cached routes will be used. */ useCachedRoutes?: boolean; /** * Flag to indicate whether to write to the cached routes or not. * By default, the cached routes will be written to. */ writeToCachedRoutes?: boolean; /** * Flag to indicate whether to use the CachedRoutes in optimistic mode. * Optimistic mode means that we will allow blocksToLive greater than 1. */ optimisticCachedRoutes?: boolean; /** * Debug param that helps to see the short-term latencies improvements without impacting the main path. */ debugRouting?: boolean; /** * Flag that allow us to override the cache mode. */ overwriteCacheMode?: CacheMode; /** * Flag for token properties provider to enable fetching fee-on-transfer tokens. */ enableFeeOnTransferFeeFetching?: boolean; /** * Tenderly natively support save simulation failures if failed, * we need this as a pass-through flag to enable/disable this feature. */ saveTenderlySimulationIfFailed?: boolean; /** * Include an additional response field specifying the swap gas estimation in terms of a specific gas token. * This requires a suitable Native/GasToken pool to exist on V3. If one does not exist this field will return null. */ gasToken?: string; /** * The version of the universal router to use. */ universalRouterVersion?: UniversalRouterVersion; /** * pass in routing-api intent to align the intent between routing-api and SOR */ intent?: INTENT; /** * boolean flag to control whether we should enable mixed route that connects ETH <-> WETH */ shouldEnableMixedRouteEthWeth?: boolean; /** * hashed router ids of the cached route, if the online routing lambda uses the cached route to serve the quote */ cachedRoutesRouteIds?: string; /** * enable mixed route with UR1_2 version backward compatibility issue */ enableMixedRouteWithUR1_2?: boolean; /** * enable debug mode for async routing lambda */ enableDebug?: boolean; /** * pass in hooks options for hooks routing toggles from the frontend */ hooksOptions?: HooksOptions; /** * sync call request id passed from the upstream (TAPI) */ requestId?: string; /** * async call request id passed from sync routing lambda */ asyncRequestId?: string; /** * pools to manually route through * couple use cases for this, the top one is to route through hooked pool(s) * Note this can only work when cached routes are not hit */ poolsToManuallyRouteThrough?: string[]; /** * Pre-fetched gas price in wei. When provided, the router skips the on-chain * getGasPriceWei call entirely, saving one RPC round-trip. */ gasPrice?: BigNumber; /** * When true, the router skips building gas models (which require multiple * on-chain pool lookups). Gas-adjusted quotes will use defaultGasAdjustment * instead. This dramatically reduces latency at the cost of less accurate * gas-adjusted pricing. */ skipGasModel?: boolean; /** * The default gas cost value (in quote-token units) to use when skipGasModel * is true. Defaults to 0, meaning quotes are returned without gas adjustment. */ defaultGasAdjustment?: number; /** * Per-protocol quote timeout in milliseconds. Every protocol's quoting * promise (V2, V3, V4, PV2, PV3, PV4CL, PV4BIN, PSS, Mixed) is wrapped in * a `Promise.race` against this timeout so that a single slow RPC cannot * block the entire pipeline indefinitely. Defaults to 30 000 ms. */ protocolQuoteTimeoutMs?: number; /** * Arc (chain id 5042) only. USDC is Arc's gas asset and exists both as the * native currency (18 decimals, address(0) in V4 pools) and as the ERC-20 * predeploy 0x3600…0000 (6 decimals, V3 pools and V4 ERC-20 pools) over one * balance. When true (default), a swap involving either view is also routed * through the other view's pools and the better gas-adjusted result is * returned, with the top-level quote converted back to the requested view. * Set to false to route only with the currencies as given. * See docs/ARC-NATIVE-USDC.md. */ arcUsdcAliasSearch?: boolean; }; export declare class AlphaRouter implements IRouter, ISwapToRatio { protected chainId: ChainId; protected provider: BaseProvider; protected multicall2Provider: UniswapMulticallProvider; protected v4SubgraphProvider: IV4SubgraphProvider; protected v4PoolProvider: IV4PoolProvider; protected v3SubgraphProvider: IV3SubgraphProvider; protected v3PoolProvider: IV3PoolProvider; protected onChainQuoteProvider: IOnChainQuoteProvider; protected v2SubgraphProvider: IV2SubgraphProvider; protected v2QuoteProvider: IV2QuoteProvider; protected v2PoolProvider: IV2PoolProvider; protected tokenProvider: ITokenProvider; protected gasPriceProvider: IGasPriceProvider; protected swapRouterProvider: ISwapRouterProvider; protected v4GasModelFactory: IOnChainGasModelFactory; protected v3GasModelFactory: IOnChainGasModelFactory; protected v2GasModelFactory: IV2GasModelFactory; protected mixedRouteGasModelFactory: IOnChainGasModelFactory; protected tokenValidatorProvider?: ITokenValidatorProvider; protected blockedTokenListProvider?: ITokenListProvider; protected l2GasDataProvider?: IL2GasDataProvider; protected simulator?: Simulator; protected v2Quoter: V2Quoter; protected v3Quoter: V3Quoter; protected v4Quoter: V4Quoter; protected mixedQuoter: MixedQuoter; protected pv2Quoter: PV2Quoter; protected pv2SubgraphProvider: IV2SubgraphProvider; protected pv2PoolProvider: IV2PoolProvider; protected pv2Supported?: ChainId[]; protected pv3Quoter: PV3Quoter; protected pv3SubgraphProvider: IV3SubgraphProvider; protected pv3PoolProvider: IV3PoolProvider; protected pv3Supported?: ChainId[]; protected pv3OnChainQuoteProvider: IOnChainQuoteProvider; protected pv4clQuoter: PV4CLQuoter; protected pv4clSubgraphProvider: IPV4CLSubgraphProvider; protected pv4clPoolProvider: PV4CLPoolProvider; protected pv4clSupported?: ChainId[]; protected pv4binQuoter: PV4BINQuoter; protected pv4binSubgraphProvider: IPV4BINSubgraphProvider; protected pv4binPoolProvider: PV4BINPoolProvider; protected pv4binSupported?: ChainId[]; protected pssQuoter: PSSQuoter; protected pssPoolProvider: PSSPoolProvider; protected pssSupported?: ChainId[]; protected routeCachingProvider?: IRouteCachingProvider; protected tokenPropertiesProvider: ITokenPropertiesProvider; protected portionProvider: IPortionProvider; protected v2Supported?: ChainId[]; protected v4Supported?: ChainId[]; protected mixedSupported?: ChainId[]; protected mixedCrossLiquidityV3AgainstV4Supported?: ChainId[]; protected v4PoolParams?: Array<[number, number, string]>; protected cachedRoutesCacheInvalidationFixRolloutPercentage?: number; protected shouldEnableMixedRouteEthWeth?: boolean; protected deleteCacheEnabledChains?: ChainId[]; protected v2AdditionalBases: Token[]; protected v3AdditionalBases: Token[]; protected v4AdditionalBases: Token[]; protected pv2AdditionalBases: Token[]; protected pv3AdditionalBases: Token[]; protected pv4clAdditionalBases: Token[]; protected pv4binAdditionalBases: Token[]; protected mobulaClient?: MobulaClient; private gasPriceCache; private static GAS_PRICE_CACHE_TTL_MS; private static DEFAULT_GAS_PRICE_CACHE_TTL_MS; constructor({ chainId, provider, multicall2Provider, v4SubgraphProvider, v4PoolProvider, v3PoolProvider, onChainQuoteProvider, v2PoolProvider, v2QuoteProvider, v2SubgraphProvider, tokenProvider, blockedTokenListProvider, v3SubgraphProvider, gasPriceProvider, v4GasModelFactory, v3GasModelFactory, v2GasModelFactory, mixedRouteGasModelFactory, swapRouterProvider, tokenValidatorProvider, arbitrumGasDataProvider, simulator, routeCachingProvider, tokenPropertiesProvider, portionProvider, v2Supported, pv2SubgraphProvider, pv2SubgraphUrls, pv2PoolProvider, pv2Supported, pv3SubgraphProvider, pv3SubgraphUrls, pv3PoolProvider, pv3Supported, pv4clSubgraphProvider, pv4clSubgraphUrls, pv4clPoolParams, pv4clSupported, pv4binSubgraphProvider, pv4binPoolParams, pv4binSupported, pssPoolProvider, pssSupported, v4Supported, mixedSupported, mixedCrossLiquidityV3AgainstV4Supported, v4PoolParams, cachedRoutesCacheInvalidationFixRolloutPercentage, deleteCacheEnabledChains, v2AdditionalBases, v3AdditionalBases, v4AdditionalBases, pv2AdditionalBases, pv3AdditionalBases, pv4clAdditionalBases, pv4binAdditionalBases, mobulaApiKey, mobulaBaseUrl, mobulaOptions, mobulaClient, }: AlphaRouterParams); routeToRatio(token0Balance: CurrencyAmount, token1Balance: CurrencyAmount, position: Position, swapAndAddConfig: SwapAndAddConfig, swapAndAddOptions?: SwapAndAddOptions, routingConfig?: Partial): Promise; /** * @inheritdoc IRouter * * On Arc, a swap involving native USDC or the ERC-20 USDC predeploy is also * routed through the other view's pools and the better result is returned * (see src/util/arc-usdc-alias.ts and docs/ARC-NATIVE-USDC.md). Disable with * `arcUsdcAliasSearch: false` in the routing config. */ route(amount: CurrencyAmount, quoteCurrency: Currency, tradeType: TradeType, swapConfig?: SwapOptions, partialRoutingConfig?: Partial): Promise; private routeWithCurrencies; /** * Refreshes the pools for the given routes. * * @param routes the routes to refresh the pools for * @param routingConfig the routing config */ protected refreshPools(routes: RouteWithValidQuote[], routingConfig: AlphaRouterConfig, v2PoolProvider: IV2PoolProvider, v3PoolProvider: IV3PoolProvider, v4PoolProvider: IV4PoolProvider): Promise; /** * Refreshes the V2 pools for the given route. * * @param route the route to refresh the V2 pools for * @param config the routing config * @param v2PoolProvider the V2 pool provider * @returns the refreshed route */ protected static refreshV2Pools(route: V2Route, config: AlphaRouterConfig, v2PoolProvider: IV2PoolProvider): Promise; /** * Refreshes the V3 pools for the given route. * * @param route the route to refresh the V3 pools for * @param config the routing config * @param v3PoolProvider the V3 pool provider * @returns the refreshed route */ protected static refreshV3Pools(route: V3Route, config: AlphaRouterConfig, v3PoolProvider: IV3PoolProvider): Promise; /** * Refreshes the V4 pools for the given route. * * @param route the route to refresh the V4 pools for * @param config the routing config * @param v4PoolProvider the V4 pool provider * @returns the refreshed route */ protected static refreshV4Pools(route: V4Route, config: AlphaRouterConfig, v4PoolProvider: IV4PoolProvider): Promise; /** * Refreshes the mixed pools for the given route. * * @param route the route to refresh the mixed pools for * @param config the routing config * @param v2PoolProvider the V2 pool provider * @param v3PoolProvider the V3 pool provider * @param v4PoolProvider the V4 pool provider * @returns the refreshed route */ protected static refreshMixedPools(route: MixedRoute, config: AlphaRouterConfig, v2PoolProvider: IV2PoolProvider, v3PoolProvider: IV3PoolProvider, v4PoolProvider: IV4PoolProvider): Promise; private static logV2PoolRefreshError; private static logV3PoolRefreshError; private static logV4PoolRefreshError; private setCachedRoutesAndLog; private getSwapRouteFromCache; private getSwapRouteFromChain; private tradeTypeStr; private tokenPairSymbolTradeTypeChainId; private determineCurrencyInOutFromTradeType; private getGasPriceWei; private getGasModels; /** * When routing only uses Pancake-style protocols (e.g. PSS, PV2, PV4CL), * skip building full Uniswap V2/V3/V4/mixed gas models and skip the extra * V3 native/amount pool fetch — only USD + native↔quote pools for Pancake gas. */ private getGasModelsForPancakeProtocolsOnly; /** * @param pancakeGasQuoteToken When set, Pancake (PSS/PV2/…) zero gas uses this * token for `gasCostInToken` / `gasCostInUSD` so it matches `quoteToken` on * route quotes (required for EXACT_OUTPUT: `quote.add(gasCostInToken)`). */ private buildNoOpGasModels; private getAmountDistribution; private buildSwapAndAddMethodParameters; private emitPoolSelectionMetrics; private calculateOptimalRatio; userHasSufficientBalance(fromAddress: string, tradeType: TradeType, amount: CurrencyAmount, quote: CurrencyAmount): Promise; private absoluteValue; private getBlockNumberPromise; static isAllowedToEnterCachedRoutes(intent?: INTENT, hooksOptions?: HooksOptions, swapRouter?: boolean): boolean; }