Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Oracles

bweick edited this page Jul 15, 2019 · 2 revisions

Oracles

Maker Oracles

Currently all of Set’s oracles are in one way or another reliant on oracles used by MakerDAO (Maker) to secure their system, at present Set uses WETH and WBTC oracles deployed by Maker. Set uses Maker’s Oracles in two ways, 1) to read current price data for use in the Manager contracts and 2) to log data for use in “Meta” oracles that use historic price data to calculate various price indicators used in the Manager contracts.

At a high level, Maker’s oracles (also known as medianizer) read from a set of approved price feeds and choose the median price from those feeds. Price feeds are meant to be updated 1) when the source price feed is greater than 1% away from current price, or 2) 6 hours has passed since last update. It should be noted, as a consequence, that Maker’s oracles do not provide instantaneous “live” prices and as a result there can be a lag or delay in accounting for price movements in Set’s system. For more on Maker's oracles read here.

HistoricalPriceFeed

Currently, HistoricalPriceFeeds use data from Maker’s oracles to build a price history for the underlying asset, but any oracle adhering to Maker's interface could be used. The HistoricalPriceFeed is intended to represent the historical prices of one asset at consistent time intervals. Additionally, there is a defined upper limit to the amount of historical data, after which old data is overwritten. The HistoricalPriceFeed’s functions are as follows:

constructor(uint256 _updateFrequency, address _medianizerAddress, string _dataDescription, uint256[] _seededArray): Upon instantiation the parameters of the price feed are set. The _updateFrequency sets the minimum amount of time allowed to pass between data points and the _medianizerAddress gives what oracle to read data from (thus implying the underlying asset it’s gathering data for). Additionally, a _dataDescription is passed so that one can easily tell the parameters of the HistoricalPriceFeed off-chain, and the price feed can be seeded with values in order for immediate use in production.

poke(): Requires lastUpdatedAt + updateFrequency < current block timestamp. Assuming condition is met the underlying oracle’s price is logged and the lastUpdatedAt timestamp is updated. Anyone can call this function to update the HistoricalPriceFeed.

read(uint256 _dataDays): Returns array of _dataDays length of historical price data. The returned array starts with the most recent price. If not enough data has been logged to satisfy _dataDays then the call will revert.

changeMedianizer(address _newMedianizerAddress): Allow for an update to the underlying medianizer address in case old medianizer is corrupted or not maintained. Only owner of price feed can call.

MovingAverageOracle

The MovingAverageOracle leverages data available from the HistoricalPriceFeed to calculate a simple moving average of a desired amount of data points. The MovingAverageOracle’s functions are as follows:

constructor(address _priceFeed, string _dataDescription): Sets the address of the HistoricalPriceFeed to read from and _dataDescription is passed so that one can easily tell the parameters of the MovingAverageOracle off-chain.

read(uint256 _dataPoints): Queries array of data from HistoricalPriceFeed of length _dataPoints and calculates the simple moving average of those data points.

getSourceMedianizer(): Returns the medianizer that the HistoricalPriceFeed underlying the MovingAverageOracle uses.

Current Deployed Contracts

HistoricalPriceFeed

Network Address updateFrequency Asset medianizerAddress
Mainnet 0x7956cE4fbA992987A11bd44ff0Ddb62504711Be8 Daily Wrapped Ethereum 0x729D19f657BD0614b4985Cf1D82531c67569197B
Kovan 0x44Fd7B522255d6Ff8DF234488F9031e5c91373d7 Daily Wrapped Ethereum 0x9Fe3077E4468e503a304909B6005E69D5C5B8907

MovingAverageOracle

Network Address Asset priceFeedAddress
Mainnet 0x90b242eDd278E636E02C2054C861Fd46A7B96271 Wrapped Ethereum 0x7956cE4fbA992987A11bd44ff0Ddb62504711Be8
Kovan 0x813F19236b7d241A6a3b42384DEd85bc159549Da Wrapped Ethereum 0x44Fd7B522255d6Ff8DF234488F9031e5c91373d7