core icon indicating copy to clipboard operation
core copied to clipboard

Fetch Real-Time Asset Prices Using On-Chain Data

Open gemcoder21 opened this issue 10 months ago • 0 comments

Description

Replace reliance on centralized APIs (CoinGecko, CoinMarketCap) with on-chain data sources for real-time asset prices. This improves decentralization, reliability, and data accuracy.

Approach

  • Use on-chain oracles (e.g., Chainlink, Tellor, Pyth).
  • Query DEX price feeds (Uniswap V3 TWAP, Sushiswap, Curve, Balancer).
  • Ensure data validation and handle potential failures.

Requirements

  • Fetch real-time prices for major assets.
  • Support additional assets easily.
  • Ensure accuracy and reliability.

Data to Collect:

  • provider, asset_id, price, price_change_24_hours (or calculated based on history), date ?

Ideas

pub trait PriceChainProvider {
    fn get_chain_prices(&self, chains: Vec<Chain>) -> Result<Vec<AssetPrice>, Error>;
}

pub trait PriceChainAssetsProvider {
    fn get_asset_prices(&self, chain: Chain, asset_ids: Vec<AssetId>) -> Result<Vec<AssetPrice>, Error>;
}

gemcoder21 avatar Mar 19 '25 18:03 gemcoder21