Quickstart
cargo add eth-prices
use eth_prices::{
quoter::{Quoter, RateDirection},
asset::Asset,
};
let quoter = vec![
UniswapV2Quoter::from_selector(provider, UniswapV2Selector::Pair { pair_address }).await,
UniswapV3Quoter::from_selector(provider, UniswapV3Selector::Pool { pool_address }).await,
ERC4626Quoter::new(vault_address, provider).await,
FixedQuoter::new(fixed_rate, provider).await,
];
let router = QuoterGraph::new(quoters);
let token_in = TokenIdentifier::ERC20 { address: address!("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48") };
let token_out = TokenIdentifier::Fiat { symbol: "usd".to_string() };
let route = router.compute(&token_in, &token_out).await.unwrap();
let block = provider.get_block_number().await.unwrap();
let quote = route.quote(block, amount_in).await.unwrap();
Examples
This crate has a few examples you can toy around with: