pub struct SwapEvent {Show 13 fields
pub dex: SharedDex,
pub pool_address: Address,
pub block_number: u64,
pub transaction_hash: String,
pub transaction_index: u32,
pub log_index: u32,
pub sender: Address,
pub receiver: Address,
pub amount0: I256,
pub amount1: I256,
pub sqrt_price_x96: U160,
pub liquidity: u128,
pub tick: i32,
}Expand description
Represents a token swap event from liquidity pools emitted from smart contract.
This struct captures the essential data from a swap transaction on decentralized exchanges (DEXs) that use automated market maker (AMM) protocols.
Fields§
§dex: SharedDexThe decentralized exchange where the event happened.
pool_address: AddressThe address of the smart contract which emitted the event.
block_number: u64The block number in which this swap transaction was included.
transaction_hash: StringThe unique hash identifier of the transaction containing this event.
transaction_index: u32The position of this transaction within the block.
log_index: u32The position of this event log within the transaction.
sender: AddressThe address that initiated the swap transaction.
receiver: AddressThe address that received the swapped tokens.
amount0: I256The amount of token0 involved in the swap. Negative values indicate tokens flowing out of the pool, positive values indicate tokens flowing in.
amount1: I256The amount of token1 involved in the swap. Negative values indicate tokens flowing out of the pool, positive values indicate tokens flowing in.
sqrt_price_x96: U160The square root of the price ratio encoded as a Q64.96 fixed-point number. This represents the price of token1 in terms of token0 after the swap.
liquidity: u128The liquidity of the pool after the swap occurred.
tick: i32The current tick of the pool after the swap occurred.
Implementations§
Source§impl SwapEvent
impl SwapEvent
Sourcepub const fn new(
dex: SharedDex,
pool_address: Address,
block_number: u64,
transaction_hash: String,
transaction_index: u32,
log_index: u32,
sender: Address,
receiver: Address,
amount0: I256,
amount1: I256,
sqrt_price_x96: U160,
liquidity: u128,
tick: i32,
) -> Self
pub const fn new( dex: SharedDex, pool_address: Address, block_number: u64, transaction_hash: String, transaction_index: u32, log_index: u32, sender: Address, receiver: Address, amount0: I256, amount1: I256, sqrt_price_x96: U160, liquidity: u128, tick: i32, ) -> Self
Creates a new SwapEvent instance with the specified parameters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SwapEvent
impl RefUnwindSafe for SwapEvent
impl Send for SwapEvent
impl Sync for SwapEvent
impl Unpin for SwapEvent
impl UnwindSafe for SwapEvent
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