use alloy::network::Network;
use alloy::primitives::Address;
use alloy::providers::Provider;
use alloy::transports::Transport;
use protocols::uniswap::v3::quoter::UniswapV3Quoter;
use std::marker::PhantomData;
use std::sync::Arc;
use crate::protocols::uniswap::v2::{UniswapV2Factory, UniswapV2Pool, UniswapV2Router};
use crate::protocols::uniswap::v3::{UniswapV3Factory, UniswapV3Pool, UniswapV3Router};
use crate::token::Token;
pub mod addresses;
pub mod protocols;
mod sync_pools;
mod token;
pub mod util;
#[derive(Clone, Copy, PartialEq)]
pub enum Chain {
Ethereum,
Base,
}
pub struct Gweiyser<P, T, N>
where
P: Provider<T, N>,
T: Transport + Clone,
N: Network,
{
http: Arc<P>,
chain: Chain,
_phantom: PhantomData<(T, N)>,
}
impl<P, T, N> Gweiyser<P, T, N>
where
P: Provider<T, N>,
T: Transport + Clone,
N: Network,
{
pub fn new(http_provider: Arc<P>, chain: Chain) -> Self {
Self {
http: http_provider,
chain,
_phantom: PhantomData,
}
}
pub async fn token(&self, address: Address) -> Token<P, T, N> {
Token::new(address, self.http.clone()).await
}
pub async fn uniswap_v2_pool(&self, address: Address) -> UniswapV2Pool<P, T, N> {
UniswapV2Pool::new(address, self.http.clone()).await
}
pub fn uniswap_v2_router(&self) -> UniswapV2Router<P, T, N> {
UniswapV2Router::new(self.http.clone(), self.chain)
}
pub fn uniswap_v2_factory(&self) -> UniswapV2Factory<P, T, N> {
UniswapV2Factory::new(self.http.clone(), self.chain)
}
pub async fn uniswap_v3_pool(&self, address: Address) -> UniswapV3Pool<P, T, N> {
UniswapV3Pool::new(address, self.http.clone()).await
}
pub fn uniswap_v3_factory(&self) -> UniswapV3Factory<P, T, N> {
UniswapV3Factory::new(self.http.clone(), self.chain)
}
pub fn uniswap_v3_quoter(&self) -> UniswapV3Quoter<P, T, N> {
UniswapV3Quoter::new(self.http.clone(), self.chain)
}
pub fn uniswap_v3_router(&self) -> UniswapV3Router<P, T, N> {
UniswapV3Router::new(self.http.clone(), self.chain)
}
}