Price feeds are a crucial component in the decentralized finance (DeFi) ecosystem, allowing for a wide range of financial activities such as lending, borrowing, trading, and derivatives. Price feeds enable dapps to access accurate and updated pricing data in a secure and trustless manner.
eOracle price feeds aggregate information from many different data source and are published on-chain for easy consumption by dApps. This guide shows you how to read and use eOracle price feeds using Solidity.
Reading eOracle price feeds on EVM-compatible blockchains follows a consistent format for both queries and responses across different chains.
eOracle follows Chainlink's AggregatorV3Interface, allowing a smooth transition between oracle providers.
You have a basic understanding of smart contract development.
An interface named IEOFeedAdapter
defines several functions for accessing data from an external source.
These functions include retrieving the decimals, description, and version of the data feed, as well as fetching round data and the latest round data.
The constructor initializes a public variable named _feedAdapter
, which is of type IEOFeedAdapter
. It sets _feedAdapter
to connect to a specific EOFeedAdapter
contract deployed on the Holesky network at address 0xDD8387185C9e0a173702fc4a3285FA576141A9cd
. This adapter is designated for the BTC
feed.
The getPrice()
function retrieves the latest price data from the _feedAdapter
by calling the latestRoundData()
function. It returns the answer, which represents the latest price of the BTC
feed.
The usePrice()
function internally calls getPrice()
to fetch the latest price , illustrating how the price could be parsed and used.
Contact support@eoracle.io for more details on deployments and usage.