pub struct SwapEvent {
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,
}
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§
§block_number: u64
The block number in which this swap transaction was included.
transaction_hash: String
The unique hash identifier of the transaction containing this event.
transaction_index: u32
The position of this transaction within the block.
log_index: u32
The position of this event log within the transaction.
sender: Address
The address that initiated the swap transaction.
receiver: Address
The address that received the swapped tokens.
amount0: I256
The amount of token0 involved in the swap. Negative values indicate tokens flowing out of the pool, positive values indicate tokens flowing in.
amount1: I256
The 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: U160
The 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.
Implementations§
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> 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