pub struct SwapQuote {
pub amount0: I256,
pub amount1: I256,
pub sqrt_price_before_x96: U160,
pub sqrt_price_after_x96: U160,
pub tick_before: i32,
pub tick_after: i32,
pub liquidity_after: u128,
pub fee_growth_global_after: U256,
pub lp_fee: U256,
pub protocol_fee: U256,
pub crossed_ticks: Vec<CrossedTick>,
}Expand description
Comprehensive swap quote containing profiling metrics for a hypothetical swap.
This structure provides detailed analysis of what would happen if a swap were executed, including price impact, fees, slippage, and execution details, without actually modifying the pool state.
Fields§
§amount0: I256Amount of token0 that would be swapped (positive = in, negative = out).
amount1: I256Amount of token1 that would be swapped (positive = in, negative = out).
sqrt_price_before_x96: U160Square root price before the swap (Q96 format).
sqrt_price_after_x96: U160Square root price after the swap (Q96 format).
tick_before: i32Tick position before the swap.
tick_after: i32Tick position after the swap.
liquidity_after: u128Active liquidity after the swap.
fee_growth_global_after: U256Fee growth global for target token after the swap (Q128.128 format).
lp_fee: U256Total fees paid to liquidity providers.
protocol_fee: U256Total fees paid to the protocol.
crossed_ticks: Vec<CrossedTick>List of tick boundaries crossed during the swap, in order of crossing.
Implementations§
Source§impl SwapQuote
impl SwapQuote
Sourcepub fn new(
amount0: I256,
amount1: I256,
sqrt_price_before_x96: U160,
sqrt_price_after_x96: U160,
tick_before: i32,
tick_after: i32,
liquidity_after: u128,
fee_growth_global_after: U256,
lp_fee: U256,
protocol_fee: U256,
crossed_ticks: Vec<CrossedTick>,
) -> Self
pub fn new( amount0: I256, amount1: I256, sqrt_price_before_x96: U160, sqrt_price_after_x96: U160, tick_before: i32, tick_after: i32, liquidity_after: u128, fee_growth_global_after: U256, lp_fee: U256, protocol_fee: U256, crossed_ticks: Vec<CrossedTick>, ) -> Self
Creates a SwapQuote instance with comprehensive swap simulation results.
Sourcepub fn zero_for_one(&self) -> bool
pub fn zero_for_one(&self) -> bool
Determines swap direction from tick movement or amount sign.
Returns true if swapping token0 for token1 (zero_for_one),
false if swapping token1 for token0.
The direction is inferred from:
- Tick movement (if ticks changed): downward = token0→token1
- Amount sign (if tick unchanged): positive amount0 = token0→token1
Sourcepub fn total_crossed_ticks(&self) -> u32
pub fn total_crossed_ticks(&self) -> u32
Returns the number of tick boundaries crossed during this swap.
This equals the length of the crossed_ticks vector and indicates
how much liquidity the swap traversed.
Sourcepub fn get_output_amount(&self) -> U256
pub fn get_output_amount(&self) -> U256
Gets the output amount for the given swap direction.
Sourcepub fn validate_exact_output(&self, amount_out_requested: U256) -> Result<()>
pub fn validate_exact_output(&self, amount_out_requested: U256) -> Result<()>
Validates that the quote satisfied an exact output request.
§Errors
Returns error if the actual output is less than the requested amount.
Sourcepub fn to_swap_event(
&self,
chain: SharedChain,
dex: SharedDex,
pool_address: &Address,
block: BlockPosition,
sender: Address,
recipient: Address,
) -> PoolSwap
pub fn to_swap_event( &self, chain: SharedChain, dex: SharedDex, pool_address: &Address, block: BlockPosition, sender: Address, recipient: Address, ) -> PoolSwap
Trait Implementations§
Source§impl<'py> IntoPyObject<'py> for SwapQuote
impl<'py> IntoPyObject<'py> for SwapQuote
Source§impl PyClassImpl for SwapQuote
impl PyClassImpl for SwapQuote
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// Comprehensive swap quote containing profiling metrics for a hypothetical swap.
///
/// This structure provides detailed analysis of what would happen if a swap were executed,
/// including price impact, fees, slippage, and execution details, without actually
/// modifying the pool state.
const RAW_DOC: &'static CStr = /// Comprehensive swap quote containing profiling metrics for a hypothetical swap. /// /// This structure provides detailed analysis of what would happen if a swap were executed, /// including price impact, fees, slippage, and execution details, without actually /// modifying the pool state.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<SwapQuote>
type ThreadChecker = SendablePyClass<SwapQuote>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyMethods<SwapQuote> for PyClassImplCollector<SwapQuote>
impl PyMethods<SwapQuote> for PyClassImplCollector<SwapQuote>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for SwapQuote
impl PyTypeInfo for SwapQuote
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for SwapQuote
impl ExtractPyClassWithClone for SwapQuote
Auto Trait Implementations§
impl Freeze for SwapQuote
impl RefUnwindSafe for SwapQuote
impl Send for SwapQuote
impl Sync for SwapQuote
impl Unpin for SwapQuote
impl UnwindSafe for SwapQuote
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read moreSource§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
Source§fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more