pub enum SwapConstraint {
TradeLimitPrice {
limit: Price,
tolerance: f64,
min_amount_in: Option<BigUint>,
max_amount_in: Option<BigUint>,
},
PoolTargetPrice {
target: Price,
tolerance: f64,
min_amount_in: Option<BigUint>,
max_amount_in: Option<BigUint>,
},
}Expand description
Options on how to constrain the pool swap query.
All prices use units [token_out/token_in] with amounts in atomic units (wei). When selling
token_in into a pool, prices decrease due to slippage.
Variants§
TradeLimitPrice
Calculates the maximum trade while respecting a minimum trade price.
Fields
PoolTargetPrice
Calculates the swap required to move the pool’s marginal price down to a target.
§Edge Cases and Limitations
Computing the exact amount to move a pool’s marginal price to a target has several challenges:
- The definition of marginal price varies between protocols. It is usually not an attribute of the pool but a consequence of its liquidity distribution and current state.
- For protocols with concentrated liquidity, the marginal price is discrete, meaning we can’t always find an exact trade amount to reach the target price.
- Not all protocols support analytical solutions for this problem, requiring numerical methods.
Trait Implementations§
Source§impl Clone for SwapConstraint
impl Clone for SwapConstraint
Source§fn clone(&self) -> SwapConstraint
fn clone(&self) -> SwapConstraint
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SwapConstraint
impl Debug for SwapConstraint
Source§impl PartialEq for SwapConstraint
impl PartialEq for SwapConstraint
impl StructuralPartialEq for SwapConstraint
Auto Trait Implementations§
impl Freeze for SwapConstraint
impl RefUnwindSafe for SwapConstraint
impl Send for SwapConstraint
impl Sync for SwapConstraint
impl Unpin for SwapConstraint
impl UnwindSafe for SwapConstraint
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)