orao-oracles-price-service

Crates.ioorao-oracles-price-service
lib.rsorao-oracles-price-service
version1.1.0
created_at2025-04-25 14:13:18.83234+00
updated_at2025-04-30 10:00:22.281753+00
descriptionORAO Oracles Price Service
homepage
repository
max_upload_size
id1649048
size74,647
orao-dev (orao-dev1)

documentation

README

ORAO Price Service

This Rust library provides a client for interacting with the ORAO Price Service API. It allows users to fetch price feeds for various assets across different networks.

Features

  • Retrieve whitelists
  • Get latest price feeds for specified assets

Usage

To use this library in your Rust project, add it to your Cargo.toml:

[dependencies]
orao-oracles-price-service = { version = "1.1.0" }

Then, in your Rust code:

use orao_oracles_price_service::{Secp256k1PriceService, PriceServiceConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize the PriceService
    let price_service = Secp256k1PriceService::new(
        "https://api.example.com",
        Some(PriceServiceConfig {
            auth_token: Some("your_auth_token".to_string()),
            timeout: Some(5000),
            http_retries: Some(3),
        })
    );

    // Get whitelist
    let whitelist = price_service.get_whitelist().await?;
    println!("evm whitelist: {:?}", whitelist);

    // Get latest price feeds
    let asset_names = vec!["bitcoin", "ethereum"];
    let price_feed = price_service.get_latest_price_feeds(&asset_names).await?;
    println!("Latest price feed: {:?}", price_feed);

    // Get price feeds update data for contract call
    let price_feeds_update_data = price_service.get_price_feeds_update_data(&price_feed);
    println!("{:?}", price_feeds_update_data);

    Ok(())
}

Supported Networks

Network Service name
evm Secp256k1PriceService
fuel Ed25519PriceService
solana Ed25519PriceService

API Reference

EVMPriceService::new(endpoint: &str, config: Option<PriceServiceConfig>) -> Self

Creates a new instance of PriceService.

EVMPriceService::get_whitelist() -> Result<Vec<String>>

Retrieves the whitelist.

EVMPriceService::get_latest_price_feeds(asset_names: &[&str]) -> Result<PriceFeed>

Retrieves the latest price feeds for specified assets.

Error Handling

All methods return a Result type, allowing for proper error handling. Errors can occur due to network issues, parsing problems, or invalid responses from the API.

Logging

This library uses the tracing crate for logging. You can initialize logging by calling the init_tracing() function provided in the library.

Commit count: 0

cargo fmt