use std::fmt::{self, Debug, Display};
use alloy::{
primitives::{BlockNumber, U256},
providers::DynProvider,
};
use crate::{Result, token::identity::TokenIdentifier};
pub mod any;
pub mod direction;
pub use any::AnyQuoter;
pub use direction::RateDirection;
pub mod erc4626;
pub mod fixed;
pub mod uniswap_v2;
pub mod uniswap_v3;
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
pub trait Quoter: Send + Sync + Debug {
fn identity(&self) -> String;
fn tokens(&self) -> (TokenIdentifier, TokenIdentifier);
async fn rate(
&self,
amount_in: U256,
direction: RateDirection,
block: BlockNumber,
provider: &DynProvider,
) -> Result<U256>;
}
impl Display for dyn Quoter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.identity())
}
}