Skip to content

Uniswap V3 Positions

Fetch Mint and Burn 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::GetPositionsRequest, 
};
 
#[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 = GetPositionsRequest { 
            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_positions_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": 188,
    "timestamp": 1729465703,
    "event": "Burn",
    "sender": "0xc36442b4a4522e871399cd717abdd847ab11fe88",
    "recipient": "0xc36442b4a4522e871399cd717abdd847ab11fe88",
    "tick_lower": 197290,
    "tick_upper": 197690,
    "amount": 23318830090566240,
    "amount0": 24015.731726,
    "amount1": 0,
    "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 of pool_address.
  • sender__in: Filters the data by a list of sender.
  • recipient__in: Filters the data by a list of recipient.
  • amount0__gte: Filters the data by amount0 using the greater than or equal to operator.
  • amount0__lte: Filters the data by amount0 using the less than or equal to operator.
  • amount1__gte: Filters the data by amount1 using the greater than or equal to operator.
  • amount1__lte: Filters the data by amount1 using the less than or equal to operator.
  • amount__gte: Filters the data by amount using the greater than or equal to operator.
  • amount__lte: Filters the data by amount using the less than or equal to operator.
  • tick_lower__gte: Filters the data by tick_lower using the greater than or equal to operator.
  • tick_lower__lte: Filters the data by tick_lower using the less than or equal to operator.
  • tick_upper__gte: Filters the data by tick_upper using the greater than or equal to operator.
  • tick_upper__lte: Filters the data by tick_upper using the less than or equal to operator.
  • tick__gte: Filters the data by the minimum tick_lower value using the greater than or equal to operator.
  • tick__lte: Filters the data by the maximum tick_upper value using the greater than or equal to operator.