diff --git a/Cargo.toml b/Cargo.toml index 8806aca..ba6952f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uniswap-lens" -version = "0.10.0" +version = "0.11.0" edition = "2021" authors = ["Shuhui Luo "] description = "A library for querying Uniswap V3 using ephemeral lens contracts." @@ -12,7 +12,7 @@ keywords = ["alloy", "ethereum", "solidity", "uniswap"] include = ["src/**/*.rs"] [dependencies] -alloy = { version = "0.9", features = ["contract", "json-rpc", "rpc-types"] } +alloy = { version = "0.11", features = ["contract", "json-rpc", "rpc-types"] } thiserror = { version = "2", default-features = false } [features] @@ -20,7 +20,7 @@ default = [] std = ["alloy/std", "thiserror/std"] [dev-dependencies] -alloy = { version = "0.9", features = ["transport-http"] } +alloy = { version = "0.11", features = ["transport-http"] } dotenv = "0.15" futures = "0.3" once_cell = "1.20" diff --git a/src/pool_lens.rs b/src/pool_lens.rs index dd3fd2e..906ed24 100644 --- a/src/pool_lens.rs +++ b/src/pool_lens.rs @@ -27,10 +27,11 @@ use alloc::vec::Vec; use alloy::{ contract::Error as ContractError, eips::BlockId, + network::Network, primitives::{aliases::I24, Address}, providers::Provider, sol_types::SolCall, - transports::{Transport, TransportError}, + transports::TransportError, }; /// Get the populated ticks in a tick range. @@ -47,7 +48,7 @@ use alloy::{ /// /// A vector of populated ticks within the range #[inline] -pub async fn get_populated_ticks_in_range( +pub async fn get_populated_ticks_in_range( pool: Address, tick_lower: I24, tick_upper: I24, @@ -55,8 +56,8 @@ pub async fn get_populated_ticks_in_range( block_id: Option, ) -> Result<(Vec, I24), Error> where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { let deploy_builder = EphemeralGetPopulatedTicksInRange::deploy_builder(provider, pool, tick_lower, tick_upper); @@ -97,14 +98,14 @@ macro_rules! get_pool_storage { /// /// A vector of slots containing the storage data #[inline] -pub async fn get_static_slots( +pub async fn get_static_slots( pool: Address, provider: P, block_id: Option, ) -> Result, Error> where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { get_pool_storage!(EphemeralPoolSlots::deploy_builder(provider, pool), block_id) } @@ -123,7 +124,7 @@ where /// /// A vector of slots containing the storage data #[inline] -pub async fn get_ticks_slots( +pub async fn get_ticks_slots( pool: Address, tick_lower: I24, tick_upper: I24, @@ -131,8 +132,8 @@ pub async fn get_ticks_slots( block_id: Option, ) -> Result, Error> where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { get_pool_storage!( EphemeralPoolTicks::deploy_builder(provider, pool, tick_lower, tick_upper), @@ -152,14 +153,14 @@ where /// /// A vector of slots containing the storage data #[inline] -pub async fn get_tick_bitmap_slots( +pub async fn get_tick_bitmap_slots( pool: Address, provider: P, block_id: Option, ) -> Result, Error> where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { get_pool_storage!( EphemeralPoolTickBitmap::deploy_builder(provider, pool), @@ -180,15 +181,15 @@ where /// /// A vector of slots containing the storage data #[inline] -pub async fn get_positions_slots( +pub async fn get_positions_slots( pool: Address, positions: Vec, provider: P, block_id: Option, ) -> Result, Error> where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { get_pool_storage!( EphemeralPoolPositions::deploy_builder(provider, pool, positions), @@ -260,10 +261,10 @@ mod tests { // } } - async fn verify_slots(slots: Vec, provider: P) + async fn verify_slots(slots: Vec, provider: P) where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { assert!(!slots.is_empty()); let provider = provider.root(); diff --git a/src/position_lens.rs b/src/position_lens.rs index b2a0b49..2a52261 100644 --- a/src/position_lens.rs +++ b/src/position_lens.rs @@ -24,10 +24,11 @@ use alloc::vec::Vec; use alloy::{ contract::Error as ContractError, eips::BlockId, + network::Network, primitives::{Address, U256}, providers::Provider, sol_types::SolCall, - transports::{Transport, TransportError}, + transports::TransportError, }; /// Get the details of a position given the token ID. @@ -43,15 +44,15 @@ use alloy::{ /// /// The position details #[inline] -pub async fn get_position_details( +pub async fn get_position_details( npm: Address, token_id: U256, provider: P, block_id: Option, ) -> Result where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { let deploy_builder = EphemeralGetPosition::deploy_builder(provider, npm, token_id); match call_ephemeral_contract!(deploy_builder, getPositionCall, block_id) { @@ -73,15 +74,15 @@ where /// /// The array of position details #[inline] -pub async fn get_positions( +pub async fn get_positions( npm: Address, token_ids: Vec, provider: P, block_id: Option, ) -> Result, Error> where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { let deploy_builder = EphemeralGetPositions::deploy_builder(provider, npm, token_ids); match call_ephemeral_contract!(deploy_builder, getPositionsCall, block_id) { @@ -103,15 +104,15 @@ where /// /// The array of position details #[inline] -pub async fn get_all_positions_by_owner( +pub async fn get_all_positions_by_owner( npm: Address, owner: Address, provider: P, block_id: Option, ) -> Result, Error> where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { let deploy_builder = EphemeralAllPositionsByOwner::deploy_builder(provider, npm, owner); match call_ephemeral_contract!(deploy_builder, allPositionsCall, block_id) { diff --git a/src/storage_lens.rs b/src/storage_lens.rs index 3aadcb9..1de30b0 100644 --- a/src/storage_lens.rs +++ b/src/storage_lens.rs @@ -7,10 +7,10 @@ use crate::{bindings::ephemeralstoragelens::EphemeralStorageLens, error::Error}; use alloc::vec::Vec; use alloy::{ eips::BlockId, + network::Network, primitives::{Address, B256}, providers::Provider, rpc::types::state::{AccountOverride, StateOverride}, - transports::Transport, }; /// Batch `eth_getStorageAt` RPC calls in a single `eth_call` by overriding the target contract's @@ -27,15 +27,15 @@ use alloy::{ /// /// The storage values at the given slots #[inline] -pub async fn get_storage_at( +pub async fn get_storage_at( address: Address, slots: Vec, provider: P, block_id: Option, ) -> Result, Error> where - T: Transport + Clone, - P: Provider, + N: Network, + P: Provider, { // override the deployed bytecode at `address` let state = StateOverride::from_iter([( diff --git a/src/tests.rs b/src/tests.rs index 0d7efed..f91a110 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,6 +1,6 @@ use alloy::{ eips::{BlockId, BlockNumberOrTag}, - providers::{ProviderBuilder, ReqwestProvider}, + providers::{ProviderBuilder, RootProvider}, transports::http::reqwest::Url, }; use dotenv::dotenv; @@ -11,5 +11,8 @@ pub(crate) static RPC_URL: Lazy = Lazy::new(|| { dotenv().ok(); std::env::var("MAINNET_RPC_URL").unwrap().parse().unwrap() }); -pub(crate) static PROVIDER: Lazy = - Lazy::new(|| ProviderBuilder::new().on_http(RPC_URL.clone())); +pub(crate) static PROVIDER: Lazy = Lazy::new(|| { + ProviderBuilder::new() + .disable_recommended_fillers() + .on_http(RPC_URL.clone()) +});