Skip to content

Curve Tokens

Fetch 3pool LP token by filtering on address 0x6c3f90f043a72fa612cbac8115ee7e52bde6e490.

Code

Rust
use futures::StreamExt;
use std::{collections::HashSet, sync::Arc};
use pangea_client::{
    core::types::ChainId, query::Bound,
    ClientBuilder, Format, WsProvider,
    provider::CurveProvider, requests::curve::GetCrvTokenRequest, 
};
 
#[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 = GetCrvTokenRequest { 
            chains: HashSet::from([ChainId::ETH]), 
            from_block: Bound::Exact(0), 
            to_block: Bound::Latest, 
            address__in: HashSet::from(["0x6c3f90f043a72fa612cbac8115ee7e52bde6e490"
            .parse() 
            .unwrap()]), 
            ..Default::default() 
        }; 
        let stream = match client 
            .get_tokens_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,
    "address": "0x6c3f90f043a72fa612cbac8115ee7e52bde6e490",
    "name": "Curve.fi DAI/USDC/USDT",
    "symbol": "3Crv",
    "decimals": 18,
    "pool_address": "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7",
    "n_coins": 3
  }
]

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.
  • address__in: Filters the data by a list of LP token address.
  • symbol__in: Filters the data by a list of LP token symbol.
  • name__in: Filters the data by a list of LP token name.
  • pool_address__in: Filters the data by a list of pool_address.
  • decimals__gte: Filters the data by LP token decimals using the greater than or equal to operator.
  • decimals__lte: Filters the data by LP token decimals using the less than or equal to operator.