1use alloy::network::Network;
2use alloy::primitives::Address;
3use alloy::providers::Provider;
4use alloy::transports::Transport;
5use protocols::uniswap::v3::quoter::UniswapV3Quoter;
6use std::marker::PhantomData;
7use std::sync::Arc;
8
9use crate::protocols::uniswap::v2::{UniswapV2Factory, UniswapV2Pool, UniswapV2Router};
10use crate::protocols::uniswap::v3::{UniswapV3Factory, UniswapV3Pool, UniswapV3Router};
11use crate::token::Token;
12
13pub mod addresses;
15pub mod protocols;
16mod sync_pools;
17mod token;
18pub mod util;
19
20#[derive(Clone, Copy, PartialEq)]
21pub enum Chain {
22 Ethereum,
23 Base,
24}
25
26pub struct Gweiyser<P, T, N>
27where
28 P: Provider<T, N>,
29 T: Transport + Clone,
30 N: Network,
31{
32 http: Arc<P>,
33 chain: Chain,
34 _phantom: PhantomData<(T, N)>,
35}
36
37impl<P, T, N> Gweiyser<P, T, N>
38where
39 P: Provider<T, N>,
40 T: Transport + Clone,
41 N: Network,
42{
43 pub fn new(http_provider: Arc<P>, chain: Chain) -> Self {
45 Self {
46 http: http_provider,
47 chain,
48 _phantom: PhantomData,
49 }
50 }
51
52 pub async fn token(&self, address: Address) -> Token<P, T, N> {
54 Token::new(address, self.http.clone()).await
56 }
57
58 pub async fn uniswap_v2_pool(&self, address: Address) -> UniswapV2Pool<P, T, N> {
60 UniswapV2Pool::new(address, self.http.clone()).await
61 }
62
63 pub fn uniswap_v2_router(&self) -> UniswapV2Router<P, T, N> {
65 UniswapV2Router::new(self.http.clone(), self.chain)
66 }
67
68 pub fn uniswap_v2_factory(&self) -> UniswapV2Factory<P, T, N> {
70 UniswapV2Factory::new(self.http.clone(), self.chain)
71 }
72
73 pub async fn uniswap_v3_pool(&self, address: Address) -> UniswapV3Pool<P, T, N> {
75 UniswapV3Pool::new(address, self.http.clone()).await
76 }
77
78 pub fn uniswap_v3_factory(&self) -> UniswapV3Factory<P, T, N> {
80 UniswapV3Factory::new(self.http.clone(), self.chain)
81 }
82
83 pub fn uniswap_v3_quoter(&self) -> UniswapV3Quoter<P, T, N> {
85 UniswapV3Quoter::new(self.http.clone(), self.chain)
86 }
87
88 pub fn uniswap_v3_router(&self) -> UniswapV3Router<P, T, N> {
90 UniswapV3Router::new(self.http.clone(), self.chain)
91 }
92
93
94}