pub struct NormalizedQuote {Show 17 fields
pub source: String,
pub token_in: String,
pub token_out: String,
pub amount_in: String,
pub amount_out: String,
pub amount_out_min: Option<String>,
pub estimated_gas: Option<u64>,
pub gas_price: Option<String>,
pub gas_usd: Option<f64>,
pub price_impact: Option<f64>,
pub router_address: Option<String>,
pub tx_data: Option<String>,
pub tx_value: Option<String>,
pub route: Option<Vec<String>>,
pub protocols: Option<Vec<String>>,
pub fee_amount: Option<String>,
pub fee_token: Option<String>,
}Expand description
Normalized swap quote with consistent formatting across all sources
Fields§
§source: StringSource aggregator name
token_in: StringInput token address
token_out: StringOutput token address
amount_in: StringInput amount (raw, with decimals)
amount_out: StringOutput amount (raw, with decimals)
amount_out_min: Option<String>Minimum output after slippage (if set)
estimated_gas: Option<u64>Estimated gas cost
gas_price: Option<String>Gas price in wei
gas_usd: Option<f64>Estimated gas cost in USD
price_impact: Option<f64>Price impact percentage (negative means loss)
router_address: Option<String>Router contract address to approve/call
tx_data: Option<String>Encoded transaction data (if available)
tx_value: Option<String>Value to send with transaction (for native token swaps)
route: Option<Vec<String>>Swap route path (token addresses or pool names)
protocols: Option<Vec<String>>Protocols/DEXs used in the route
fee_amount: Option<String>Protocol fee amount (e.g., CowSwap fee in sell token units)
fee_token: Option<String>Token the fee is denominated in
Implementations§
Source§impl NormalizedQuote
impl NormalizedQuote
Sourcepub fn new(
source: impl Into<String>,
token_in: impl Into<String>,
token_out: impl Into<String>,
amount_in: impl Into<String>,
amount_out: impl Into<String>,
) -> Self
pub fn new( source: impl Into<String>, token_in: impl Into<String>, token_out: impl Into<String>, amount_in: impl Into<String>, amount_out: impl Into<String>, ) -> Self
Create a new normalized quote with required fields
pub fn with_min_out(self, min: impl Into<String>) -> Self
pub fn with_gas(self, gas: u64) -> Self
pub fn with_gas_price(self, price: impl Into<String>) -> Self
pub fn with_gas_usd(self, usd: f64) -> Self
pub fn with_price_impact(self, impact: f64) -> Self
pub fn with_router(self, router: impl Into<String>) -> Self
pub fn with_tx_data(self, data: impl Into<String>) -> Self
pub fn with_tx_value(self, value: impl Into<String>) -> Self
pub fn with_route(self, route: Vec<String>) -> Self
pub fn with_protocols(self, protocols: Vec<String>) -> Self
pub fn with_fee( self, amount: impl Into<String>, token: impl Into<String>, ) -> Self
Sourcepub fn amount_out_u128(&self) -> Option<u128>
pub fn amount_out_u128(&self) -> Option<u128>
Parse amount_out as u128 for comparison
Sourcepub fn effective_output(&self) -> Option<u128>
pub fn effective_output(&self) -> Option<u128>
Calculate effective output (output minus gas cost in output token terms) This is a simplified calculation - real implementation would need price data
Trait Implementations§
Source§impl Clone for NormalizedQuote
impl Clone for NormalizedQuote
Source§fn clone(&self) -> NormalizedQuote
fn clone(&self) -> NormalizedQuote
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NormalizedQuote
impl Debug for NormalizedQuote
Source§impl<'de> Deserialize<'de> for NormalizedQuote
impl<'de> Deserialize<'de> for NormalizedQuote
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for NormalizedQuote
impl RefUnwindSafe for NormalizedQuote
impl Send for NormalizedQuote
impl Sync for NormalizedQuote
impl Unpin for NormalizedQuote
impl UnwindSafe for NormalizedQuote
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
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>
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>
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