pub struct DexClient { /* private fields */ }Expand description
Client for fetching DEX aggregator data.
Implementations§
Source§impl DexClient
impl DexClient
Sourcepub async fn get_token_price(
&self,
chain: &str,
token_address: &str,
) -> Option<f64>
pub async fn get_token_price( &self, chain: &str, token_address: &str, ) -> Option<f64>
Fetches the USD price of a token by its address.
Returns None if the token is not found or has no price data.
Sourcepub async fn get_native_token_price(&self, chain: &str) -> Option<f64>
pub async fn get_native_token_price(&self, chain: &str) -> Option<f64>
Fetches the native token price for a chain.
Uses well-known wrapped token addresses to determine the native token price.
Sourcepub async fn get_token_data(
&self,
chain: &str,
token_address: &str,
) -> Result<DexTokenData>
pub async fn get_token_data( &self, chain: &str, token_address: &str, ) -> Result<DexTokenData>
Sourcepub async fn search_tokens(
&self,
query: &str,
chain: Option<&str>,
) -> Result<Vec<TokenSearchResult>>
pub async fn search_tokens( &self, query: &str, chain: Option<&str>, ) -> Result<Vec<TokenSearchResult>>
Sourcepub async fn get_token_profiles(&self) -> Result<Vec<DiscoverToken>>
pub async fn get_token_profiles(&self) -> Result<Vec<DiscoverToken>>
Fetches latest token profiles (featured tokens) from DexScreener.
Sourcepub async fn get_token_boosts(&self) -> Result<Vec<DiscoverToken>>
pub async fn get_token_boosts(&self) -> Result<Vec<DiscoverToken>>
Fetches latest boosted tokens from DexScreener.
Sourcepub async fn get_token_boosts_top(&self) -> Result<Vec<DiscoverToken>>
pub async fn get_token_boosts_top(&self) -> Result<Vec<DiscoverToken>>
Fetches top boosted tokens (most active boosts) from DexScreener.
Sourcepub fn estimate_7d_volume(volume_24h: f64) -> f64
pub fn estimate_7d_volume(volume_24h: f64) -> f64
Gets the 7-day volume by extrapolating from 24h data.
Note: DexScreener doesn’t provide 7d volume directly, so we estimate based on 24h volume.
Trait Implementations§
Source§impl DexDataSource for DexClient
impl DexDataSource for DexClient
Source§fn get_token_price<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chain: &'life1 str,
address: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_token_price<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chain: &'life1 str,
address: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetches the price for a specific token on a chain.
Source§fn get_native_token_price<'life0, 'life1, 'async_trait>(
&'life0 self,
chain: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_native_token_price<'life0, 'life1, 'async_trait>(
&'life0 self,
chain: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetches the native token price for a chain (e.g., ETH for ethereum).
Source§fn get_token_data<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chain: &'life1 str,
address: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<DexTokenData>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_token_data<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chain: &'life1 str,
address: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<DexTokenData>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetches comprehensive token data including pairs, volume, liquidity.
Source§fn search_tokens<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
chain: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<TokenSearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search_tokens<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
chain: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<TokenSearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Searches for tokens by query string with optional chain filter.
Auto Trait Implementations§
impl Freeze for DexClient
impl !RefUnwindSafe for DexClient
impl Send for DexClient
impl Sync for DexClient
impl Unpin for DexClient
impl !UnwindSafe for DexClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more