Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(alloy): Refactor position_lens for Alloy #4

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uniswap-lens"
version = "0.0.1"
version = "0.0.2"
edition = "2021"
authors = ["Shuhui Luo <twitter.com/aureliano_law>"]
description = "Contains ephemeral lens contracts that can be called without deployment and their Rust interfaces."
Expand All @@ -19,4 +19,5 @@ alloy = { version = "0.2.0", features = ["rpc-types", "transport-http"] }
dotenv = "0.15.0"
futures = "0.3"
once_cell = "1.19"
ruint = "1.12"
tokio = { version = "1", features = ["full"] }
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
pub mod bindings;
pub mod caller;
pub mod pool_lens;
// pub mod position_lens;
pub mod position_lens;

#[cfg(test)]
mod tests;

// pub mod storage_lens;

pub mod prelude {
pub use super::{bindings::*, pool_lens::*};
pub use super::{bindings::*, pool_lens::*, position_lens::*};
}
26 changes: 4 additions & 22 deletions src/pool_lens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,15 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::bindings::iuniswapv3pool::IUniswapV3Pool::{IUniswapV3PoolInstance, Mint};
use alloy::{
primitives::address,
providers::{ProviderBuilder, ReqwestProvider},
rpc::types::Filter,
sol_types::SolEvent,
transports::http::reqwest::Url,
use crate::{
bindings::iuniswapv3pool::IUniswapV3Pool::{IUniswapV3PoolInstance, Mint},
tests::*,
};
use alloy::{primitives::address, rpc::types::Filter, sol_types::SolEvent};
use anyhow::Result;
use dotenv::dotenv;
use futures::future::join_all;
use once_cell::sync::Lazy;

const POOL_ADDRESS: Address = address!("88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640");
static BLOCK_NUMBER: Lazy<BlockId> = Lazy::new(|| BlockId::from(17000000));
static RPC_URL: Lazy<Url> = Lazy::new(|| {
dotenv().ok();
format!(
"https://mainnet.infura.io/v3/{}",
std::env::var("INFURA_API_KEY").unwrap()
)
.parse()
.unwrap()
});
static PROVIDER: Lazy<ReqwestProvider> =
Lazy::new(|| ProviderBuilder::new().on_http(RPC_URL.clone()));

#[tokio::test]
async fn test_get_populated_ticks_in_range() -> Result<()> {
let provider = PROVIDER.clone();
Expand Down
Loading