Uniswap V3 Fees
Fetch Collect events for blocks 21000000 to 21010000 for pool_address 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640.
Code
Rust
use futures::StreamExt;
use std::{collections::HashSet, sync::Arc};
use pangea_client::{
core::types::ChainId, query::Bound,
ClientBuilder, Format, WsProvider,
provider::UniswapV3Provider, requests::uniswap_v3::GetFeesRequest,
};
#[tokio::main]
async fn main() {
dotenvy::dotenv_override().ok();
let client = match ClientBuilder::default()
.endpoint("app.pangea.foundation")
.build::<WsProvider>()
.await
{
Ok(client) => Arc::new(client),
Err(e) => {
eprintln!("Client failed to initialize:\n{e}");
return;
}
};
{
let request = GetFeesRequest {
chains: HashSet::from([ChainId::ETH]),
from_block: Bound::Exact(21000000),
to_block: Bound::Exact(21010000),
pool_address__in: HashSet::from(["0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"
.parse()
.unwrap()]),
..Default::default()
};
let stream = match client
.get_fees_by_format(request, Format::JsonStream, false)
.await
{
Ok(stream) => stream,
Err(e) => {
eprintln!("Request failed\n{e}");
return;
}
};
futures::pin_mut!(stream);
while let Some(chunk) = stream.next().await {
let chunk = String::from_utf8(chunk.unwrap()).unwrap();
println!("{chunk}");
}
}
}Response
[
...
{
"chain": 1,
"block_number": 21009973,
"block_hash": "0x490223b3d3d242be208b33f1feab7c1d54c846b52c069b942a1e177b5877e741",
"transaction_hash": "0xccfa41ef4044dc6988ccd19382dc3757f2b0763cf36e11339ffe287b7b2f29e8",
"transaction_index": 61,
"log_index": 192,
"timestamp": 1729465703,
"event": "Collect",
"sender": "0xc36442b4a4522e871399cd717abdd847ab11fe88",
"recipient": "0xc36442b4a4522e871399cd717abdd847ab11fe88",
"tick_lower": 197290,
"tick_upper": 197690,
"amount0": 24125.917285,
"amount1": 0.03878239127376524,
"pool_address": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"
}
]Query Parameters
chains: Filters the data by specific blockchain networks.from_block: Filters the data by a starting block number.to_block: Filters the data by an ending block number.pool_address__in: Filters the data by a list ofpool_address.sender__in: Filters the data by a list ofsender.recipient__in: Filters the data by a list ofrecipient.amount0__gte: Filters the data byamount0using the greater than or equal to operator.amount0__lte: Filters the data byamount0using the less than or equal to operator.amount1__gte: Filters the data byamount1using the greater than or equal to operator.amount1__lte: Filters the data byamount1using the less than or equal to operator.tick_lower__gte: Filters the data bytick_lowerusing the greater than or equal to operator.tick_lower__lte: Filters the data bytick_lowerusing the less than or equal to operator.tick_upper__gte: Filters the data bytick_upperusing the greater than or equal to operator.tick_upper__lte: Filters the data bytick_upperusing the less than or equal to operator.tick__gte: Filters the data by the minimumtick_lowervalue using the greater than or equal to operator.tick__lte: Filters the data by the maximumtick_uppervalue using the greater than or equal to operator.