Skip to main content

Oracle system

An accurate and reliable oracle for asset prices allows loans and liquidations to occur quickly without errors. Interest Protocol uses a read-based oracle system that calls for live prices at each instance a price is needed. While this method could be inefficient at times, it provides the highest level of accuracy and safety for borrowers and lenders.

All asset prices are aggregated into the OracleMaster, which maintains a list of asset-specific oracle contracts called the AnchorViewRelay. Each AnchorViewRelay has two sub-oracles and a configurable buffer. One sub-oracle is specified as the main oracle and the other as the anchor. Currently, the ChainlinkOracleRelay is the main, and UniswapV3OracleRelay is the anchor. Whenever a price is utilized in a transaction, the protocol reads the main oracle price and the anchor oracle and certifies that the main oracle price is within the specified deviation of the anchor oracle price.

The VaultController contract queries prices. Functions such as borrow & liquidate require price data because they need to value the collateral assets in the vault. To query the price those functions call the _oracleMaster.getLivePrice(token_address). The OracleMaster will use the specified token address to query the relevant AnchorViewRelay, and the corresponding main and anchor relays will be called to read their respective prices.

If the main oracle price falls outside the buffer, the price will not update, and the underlying transaction will fail. This acts as an immediate safety feature and prevents further usage until governance can react or the market rectifies itself. Additionally, governance can pause an oracle to temporarily suspend lending operations related to a specific asset.

This system allows Interest Protocol to use Chainlink as the main oracle without it becoming a single point of failure. Chainlink is optimal because it can use price inputs from a much larger sample than what is realistically possible for the protocol to build and maintain. Chainlink also filters their data for outlier data points, and their price feeds are available across multiple chains. The anchor oracle for the initial markets will be Uniswap V3, but governance can implement an additional wrapper for other markets such as Uniswap V2, Balancer, Curve, etc.

While the oracle contracts are not upgradable themselves, the VaultController has a configurable OracleMaster via the register_oracle_master(master_oracle_address) function callable by governance. The OracleMaster contract can configure markets via the set_relay(token_address, relay_address) function. Governance has the power to adapt the system however they see best.