| Crates.io | uni-obrv |
| lib.rs | uni-obrv |
| version | 0.1.3 |
| created_at | 2025-05-28 10:48:22.813735+00 |
| updated_at | 2025-06-01 13:33:48.702888+00 |
| description | A library for querying Uniswap V3 using On-chain helper contract. |
| homepage | |
| repository | https://github.com/Un4G173N/uni_obrv |
| max_upload_size | |
| id | 1692672 |
| size | 295,451 |
This project provides a fast and efficient way to fetch tick data from Uniswap V3 pools using a single RPC call. It consists of two main components:
Single RPC Call: Retrieves Uniswap V3 pool tick data efficiently in one Ethereum RPC call. High Performance: Optimized for speed, leveraging the UniObrv contract to batch tick data queries. Extensible: The contract and library can be extended to fetch additional Uniswap V3 state data, such as positions, fees, or other pool metrics.
Getting Started
Installation
git clone the_repository
cd uni_obrv
Install Rust dependencies:cargo build
Set up your .env file with your Ethereum RPC URL:echo "ETH_RPC_URL=
Run Tests: Execute the Rust tests to verify tick data fetching:
cargo test
Example Code: Fetch tick data for a Uniswap V3 pool (e.g., USDC/WETH):
use uni_obrv::{get_tick_data, PopulatedTick, UNI_OBRV};
use alloy::primitives::{address, I24, U256};
use alloy::providers::ProviderBuilder;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let provider = ProviderBuilder::new().on_http("your-rpc-url".parse()?);
let pool = address!("88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640");
let tick_lower = I24::from_str("188258")?;
let tick_upper = I24::from_str("276278")?;
let max_ticks = U256::from(1000000);
let (ticks, tickSpace) = get_tick_data(pool, tick_lower, tick_upper, max_ticks, provider, UNI_OBRV).await?;
for tick in ticks {
println!("Tick: {}, Liquidity Gross: {}", tick.tick, tick.liquidity_gross);
}
Ok(())
}
Solidity Testing: Use Foundry to test the UniObrv contract:
forge test
The UniObrv contract and Rust library can be extended to support additional Uniswap V3 data, such as:
Positions: Query user positions and their associated liquidity.
Fees: Fetch accumulated fees for specific ticks or positions.
Pool State: Retrieve global pool state like current price or liquidity.
Contributions are welcome! To contribute:
Fork the repository. Create a new branch (git checkout -b feature/your-feature). Make your changes and commit (git commit -m "Add your feature"). Push to your branch (git push origin feature/your-feature). Open a pull request with a clear description of your changes.
Please ensure your code follows the existing style and includes tests for new functionality.