Building an on-chain price oracle with cumulative prices
A price oracle is a technology for providing data for smart contracts to access the prices of various assets. Usually, the smart contracts that access the price oracle can call a function to fetch the prices for specific assets. The assets can be cryptocurrencies, fiat currencies, stocks, or futures. Chainlink (https://chain.link/) is one of the most widely used oracles on the market. Figure 13.1 shows a screenshot of the data feed page (https://data.chain.link/feeds/ethereum/mainnet/eth-usd), which shows the ETH price in US dollars.
Figure 13.1 – The data feed page for showing the ETH price in USD on Chainlink
The Chainlink price oracle provides manipulation-resistant and robust pricing data for various assets. The feature of manipulation resistance is implemented by aggregating multiple data sources (AKA oracle responses) of prices of the single asset. Figure 13.2 shows the oracle responses...