[!IMPORTANT] eth-prices aims to provide Ethereum price estimation only. It is not intended for, nor does it provide guarantees of, exchange rates.
Quickstart
use ;
// Define your data sources
let quoter = vec!;
// Create a router
let router = new;
// Compute a route
let token_in = ERC20 ;
let token_out = Fiat ;
let route = router.compute.await.unwrap;
// Get the latest block number
let block = provider.get_block_number.await.unwrap;
// Quote the rate
let quote = route.quote.await.unwrap;
Data Sources
Currently supported data sources include:
- Uniswap V2 - for Uniswap V2 pairs
- Uniswap V3 - for Uniswap V3 pools
- ERC-4626 - for ERC-4626-compatible vaults (Morpho, Aave, etc.)
- Fixed - for static rates, such as WETH to ETH, or USDC to USD
- European Central Bank - for fiat exchange rates (uses single HTTP call and requires feature flag
ecb) - Chainlink - for Chainlink Price Feeds
Examples
This crate has a few examples you can toy around with:
- Uniswap V2 Quoter - to quote rates for Uniswap V2 pairs
- Prometheus Exporter - to export price data to metrics
- Fiat Quoter - to quote fiat rates
- Auto Router - to automatically discover quoters and build a router
Autorouter Evaluation
The live evaluation suite in bench compares the Rust and TypeScript
autorouters at the same Ethereum block against six keyless USD price sources.
Run it with just eval. Results are written to target/evals/.
Documentation
You can read the documentation at docs.rs/eth-prices.