pub struct UniswapV3PoolContract { /* private fields */ }Expand description
Interface for interacting with UniswapV3Pool contracts on a blockchain.
This struct provides methods to query pool state including slot0, liquidity, fee growth, tick data, and position data. Supports both single calls and batch multicalls for efficiency.
Implementations§
Source§impl UniswapV3PoolContract
impl UniswapV3PoolContract
Sourcepub fn new(client: Arc<BlockchainHttpRpcClient>) -> Self
pub fn new(client: Arc<BlockchainHttpRpcClient>) -> Self
Creates a new UniswapV3Pool contract interface with the specified RPC client.
Sourcepub async fn get_global_state(
&self,
pool_address: &Address,
block: Option<u64>,
) -> Result<PoolState, UniswapV3PoolError>
pub async fn get_global_state( &self, pool_address: &Address, block: Option<u64>, ) -> Result<PoolState, UniswapV3PoolError>
Gets all global state in a single multicall.
§Errors
Returns an error if the multicall fails or any decoding fails.
Sourcepub async fn get_tick(
&self,
pool_address: &Address,
tick: i32,
block: Option<u64>,
) -> Result<PoolTick, UniswapV3PoolError>
pub async fn get_tick( &self, pool_address: &Address, tick: i32, block: Option<u64>, ) -> Result<PoolTick, UniswapV3PoolError>
Gets tick data for a specific tick.
§Errors
Returns an error if the RPC call fails or decoding fails.
Sourcepub async fn batch_get_ticks(
&self,
pool_address: &Address,
ticks: &[i32],
block: Option<u64>,
) -> Result<HashMap<i32, PoolTick>, UniswapV3PoolError>
pub async fn batch_get_ticks( &self, pool_address: &Address, ticks: &[i32], block: Option<u64>, ) -> Result<HashMap<i32, PoolTick>, UniswapV3PoolError>
Gets tick data for multiple ticks in a single multicall.
§Errors
Returns an error if the multicall fails or if any tick decoding fails. Uninitialized ticks are silently skipped (not included in the result HashMap).
Sourcepub fn compute_position_key(
owner: &Address,
tick_lower: i32,
tick_upper: i32,
) -> [u8; 32]
pub fn compute_position_key( owner: &Address, tick_lower: i32, tick_upper: i32, ) -> [u8; 32]
Computes the position key used by Uniswap V3.
The key is: keccak256(abi.encodePacked(owner, tickLower, tickUpper))
Sourcepub async fn batch_get_positions(
&self,
pool_address: &Address,
positions: &[(Address, i32, i32)],
block: Option<u64>,
) -> Result<Vec<PoolPosition>, UniswapV3PoolError>
pub async fn batch_get_positions( &self, pool_address: &Address, positions: &[(Address, i32, i32)], block: Option<u64>, ) -> Result<Vec<PoolPosition>, UniswapV3PoolError>
Gets position data for multiple positions in a single multicall.
§Errors
Returns an error if the multicall fails. Individual position failures are captured in the Result values of the returned Vec.
Sourcepub async fn fetch_snapshot(
&self,
pool_address: &Address,
instrument_id: InstrumentId,
tick_values: &[i32],
position_keys: &[(Address, i32, i32)],
block_position: BlockPosition,
) -> Result<PoolSnapshot, UniswapV3PoolError>
pub async fn fetch_snapshot( &self, pool_address: &Address, instrument_id: InstrumentId, tick_values: &[i32], position_keys: &[(Address, i32, i32)], block_position: BlockPosition, ) -> Result<PoolSnapshot, UniswapV3PoolError>
Fetches a complete pool snapshot directly from on-chain state.
Retrieves global state, tick data, and position data from the blockchain
and constructs a PoolSnapshot representing the current on-chain state.
This snapshot can be compared against profiler state for validation.
§Errors
Returns error if any RPC calls fail or data cannot be decoded.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UniswapV3PoolContract
impl !RefUnwindSafe for UniswapV3PoolContract
impl Send for UniswapV3PoolContract
impl Sync for UniswapV3PoolContract
impl Unpin for UniswapV3PoolContract
impl !UnwindSafe for UniswapV3PoolContract
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
§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