[!IMPORTANT] eth-prices aims to provide ethereum price estimation only. It is not intended for nor provides 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
Documentation
You can read the documentation at docs.rs/eth-prices.