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§
- Http
Client Config - HTTP client configuration
- Retry
Config - Configuration for retry behavior
- Retry
Error - Error wrapper that includes retry information
Constants§
- DEFAULT_
BASE_ URL - Default base URL for the Curve Finance API
Traits§
- Retryable
Error - 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