Skip to main content

Crate crv

Crate crv 

Source
Expand description

Rust client for the Curve Finance APIs

This crate provides clients for both Curve APIs:

  • Curve API (api.curve.finance) - Pools, gauges, volumes, lending vaults
  • Curve Prices API (prices.curve.finance) - Detailed pricing, OHLC, trades, DAO

§Quick Start

use crv::Client;

#[tokio::main]
async fn main() -> Result<(), crv::Error> {
    // Create client for the main Curve API
    let client = Client::new()?;

    // Get all pools on Ethereum
    let pools = client.pools().get_all_on_chain("ethereum").await?;
    println!("Found {} pools", pools.data.pool_data.len());

    // Get lending vaults
    let vaults = client.lending().get_all().await?;

    Ok(())
}

§Using the Prices API

use crv::PricesClient;

#[tokio::main]
async fn main() -> Result<(), crv::Error> {
    let client = PricesClient::new()?;

    // Get USD price for a token
    let price = client.get_usd_price("ethereum", "0x...").await?;

    Ok(())
}

Re-exports§

pub use client::Client;
pub use client::Config;
pub use error::Error;
pub use error::Result;
pub use lending::LendingVault;
pub use lending::LendingVaultsResponse;
pub use pools::Pool;
pub use pools::PoolsResponse;
pub use router::Route;
pub use router::RouteGraph;
pub use router::RouterApi;
pub use router::RouterStats;
pub use tokens::TokenInfo;
pub use tokens::TokensResponse;
pub use volumes::GaugesResponse;
pub use volumes::VolumesResponse;
pub use prices::PricesClient;

Modules§

client
HTTP client for the Curve API
crvusd
Curve crvUSD API
error
Error types for the Curve API client
lending
Curve Lending API
pools
Curve Pools API
prices
Curve Prices API client
router
Curve Router API
tokens
Curve Tokens API
volumes
Curve Volumes and APYs API

Structs§

HttpClientConfig
HTTP client configuration
RetryConfig
Configuration for retry behavior
RetryError
Error wrapper that includes retry information

Constants§

DEFAULT_BASE_URL
Default base URL for the Curve Finance API

Traits§

RetryableError
Determines if an error should be retried

Functions§

default_config
Create a default Curve config
with_retry
Execute an async operation with retries
with_simple_retry
Simple retry wrapper for operations that return Result with any error type