Universal Router
Overview
The UniversalRouter is a pool discovery and route validation contract. It provides helper functions for finding pools, validating multi-hop paths, and creating new pools through the factory.
Due to FHE encrypted input verification, the router cannot execute swaps or liquidity operations on behalf of users. Encrypted inputs are bound to the pool address they were created for. Users must call pool functions directly.
Core Functions
createPool
function createPool(
IERC7984 tokenA,
IERC7984 tokenB,
uint24 fee,
string memory pairName,
string memory pairSymbol,
string memory pairTokenURI
) external returns (address pool)
Wrapper around EPoolFactory.createPool. Deploys a new EPOOL for the token pair.
getPool
function getPool(
IERC7984 tokenA,
IERC7984 tokenB,
uint24 fee
) external view returns (address pool)
Looks up a pool by token pair and fee tier. Returns address(0) if not found.
quotePath
function quotePath(
address[] calldata path,
uint24[] calldata fees
) external view returns (address[] memory pools)
Validates a multi-hop path and returns the pool address for each hop.
poolExists
function poolExists(
IERC7984 tokenA,
IERC7984 tokenB,
uint24 fee
) external view returns (bool)
isValidPath
function isValidPath(
address[] calldata path,
uint24[] calldata fees
) external view returns (bool)
Validates that every hop in the path has a deployed pool.
Helper Utilities (UniversalRouterHelper)
| Function | Purpose |
|---|---|
validatePath | Check path array validity |
getPoolsForPath | Resolve pools for each hop |
sortTokens | Canonical token ordering |
getSwapDirection | Determine if swap is A-to-B or B-to-A for a given pool |
Multi-Hop Routing
For multi-hop swaps (e.g. eBTC -> eUSD -> eETH), the user must:
- Use
quotePathto find pools for each hop - Execute each hop separately, calling each pool directly
- The output of one swap becomes the input of the next
This is required because encrypted inputs are pool-bound.
Deployed Addresses
| Network | Address |
|---|---|
| Ethereum Sepolia | 0x6ef96225151e207cA92cF923C4edD0aC3235842c |
| Arbitrum Sepolia | 0x4C57D92DFfBb16dC03B9c03A650C9abC9B581DC7 |