pub struct Swap { /* private fields */ }Expand description
Result of an advanced swap calculation with constraints.
Contains the calculated swap amounts, optionally the new pool state, and price points traversed during calculation for optimization purposes.
Implementations§
Source§impl Swap
impl Swap
Sourcepub fn new(
amount_in: BigUint,
amount_out: BigUint,
new_state: Option<Arc<dyn SwapQuoter>>,
price_points: Option<Vec<PricePoint>>,
) -> Self
pub fn new( amount_in: BigUint, amount_out: BigUint, new_state: Option<Arc<dyn SwapQuoter>>, price_points: Option<Vec<PricePoint>>, ) -> Self
Creates a new swap result.
§Arguments
amount_in- The amount of input tokens usedamount_out- The amount of output tokens receivednew_state- The new pool state after the swap (if calculated)price_points- Optional price trajectory data for optimization
Sourcepub fn amount_out(&self) -> &BigUint
pub fn amount_out(&self) -> &BigUint
Returns the amount of output tokens received.
Sourcepub fn new_state(&self) -> Option<Arc<dyn SwapQuoter>>
pub fn new_state(&self) -> Option<Arc<dyn SwapQuoter>>
Returns the new pool state after the swap, if calculated.
Sourcepub fn price_points(&self) -> &Option<Vec<PricePoint>>
pub fn price_points(&self) -> &Option<Vec<PricePoint>>
Returns the price points traversed during calculation.
Each tuple contains (amount_in, amount_out, price) at various points during the swap calculation, useful for optimizing subsequent calls.
Auto Trait Implementations§
impl Freeze for Swap
impl !RefUnwindSafe for Swap
impl Send for Swap
impl Sync for Swap
impl Unpin for Swap
impl UnsafeUnpin for Swap
impl !UnwindSafe for Swap
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> 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