Uniswap V3 Pools
Fetch USDC-WETH 5 bps pool at 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::GetPoolsRequest,
};
#[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 = GetPoolsRequest {
chains: HashSet::from([ChainId::ETH]),
from_block: Bound::Exact(0),
to_block: Bound::Latest,
pool_address__in: HashSet::from(["0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"
.parse()
.unwrap()]),
..Default::default()
};
let stream = match client
.get_pools_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": 12376729,
"block_hash": "0x3496d03e6efd9a02417c713fa0de00915b78581a2eaf0e8b3fce435a96ab02c7",
"transaction_hash": "0x125e0b641d4a4b08806bf52c0c6757648c9963bcda8681e4f996f09e00d4c2cc",
"transaction_index": 59,
"log_index": 101,
"factory": "0x1f98431c8ad98523631ae4a59f267346ea31f984",
"token0_address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"token0_decimals": 6,
"token0_name": "USD//C",
"token0_symbol": "USDC",
"token1_address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"token1_decimals": 18,
"token1_name": "Wrapped Ether",
"token1_symbol": "WETH",
"pool_address": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
"fee": 500,
"tick_spacing": 10,
"timestamp": 1620250931
}
]
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
.factory_address__in
: Filters the data by a list of poolfactory_address
.token0__in
/token0_address__in
: Filters the data by a list oftoken0_address
.token1__in
/token1_address__in
: Filters the data by a list oftoken1_address
.tokens__in
: Filters the data by a list of bothtoken0_address
andtoken1_address
.fee__gte
: Filters the data byfee
using the greater than or equal to operator.fee__lte
: Filters the data byfee
using the less than or equal to operator.tick_spacing__gte
: Filters the data bytick_spacing
using the greater than or equal to operator.tick_spacing__lte
: Filters the data bytick_spacing
using the less than or equal to operator.