The Open Price Feed

Coburn Berry
Compound Labs
Published in
3 min readAug 19, 2019

The Compound protocol currently relies on a price feed, maintained by our team, to determine each user’s borrowing capacity and to measure liquidation thresholds. Although there are safeguards hard-coded into the contracts on-chain (limiting the damage that could be caused by a broken price feed), the system presents a potential single point of failure. And we’re not alone; most DeFi projects host a price feed in one way or another.

An ecosystem is needed, that can build a reliable price feed for Compound, DeFi projects, and any developer that would like to reliably access on-chain prices — a system that can operate perpetually without reliance on any one project.

Today, we’re proud to announce that we’ve broken ground on that vision, with a project called the Open Price Feed.

The Open Price Feed (OPF) splits the trust and logic required for an Ethereum price feed into four parts:

1: Off-chain Price Data

In the OPF, any number of sources, known as Reporters, sign a message (price data) with a private key. Reporters can be exchanges, DeFi projects, applications, OTC trading desks, hobbyists, etc. — basically, anybody with access to price data. Reporters make this signed data available to the public.

The OPF repo contains a JavaScript SDK to host this data through a web endpoint.

2: Posting Price Data to Ethereum

A crypto exchange may have an extremely accurate and reputable price for a trading pair, but lack the technical capacity (or incentive) to post the data on chain reliably. This responsibility is shared among many Posters.

Under the OPF, anyone with gas and a web3 connection has the ability to post the signed data on-chain.

3: On-chain Storage

The Reporter’s timestamped price data is decoded from the signed data, and stored under their public key in the Data Contract on Ethereum. The Data Contract holds the most recent price information from each Reporter.

In fact, anyone can sign price data and store it under their public key in the Data Contract.

4: Price Views

Finally, the on-chain application (or user) requesting price data selects a subset of reported price feeds. For example, a DeFi application might average price data from three reporters e.g. Coinbase, Wyre, and an OTC desk and combine it with two on-chain prices, e.g. Uniswap and Chainlink (examples only).

This is accomplished through a View Contract, which reads, parses, aggregates, transforms, etc from the storage contract. The determination of trustworthiness or quality of the data signed by reporters is a decision ultimately made in the View. Views may use a median price, an average, or whatever methodology they favor.

If an application wishes to change methodology, or if a Reporter is no longer trusted, deploying a new View Contract is a trivial update, since storage and logic are completely decoupled.

Project Status

An end to end prototype of the Open Price Feed is currently running on Rinkeby.

Three Reporters are signing price data (observed on exchanges), which are read from exchange APIs:
a. https://api.stage.compound.finance/prices?source=coinbasepro
b. https://api.stage.compound.finance/prices?source=kraken
c. https://api.stage.compound.finance/prices?source=binance

A single poster is repeatedly reading from these public urls and posting on chain: https://rinkeby.etherscan.io/address/0x64316d763d3925d12678778b0586a01318b44eab

The storage contract is holding the data: https://rinkeby.etherscan.io/address/0xf8273110c08af3407c6ae8bf92b1f310b15d3020#readContract

The view is aggregating the data and exposing readable prices: https://rinkeby.etherscan.io/address/0xf8273110c08af3407c6ae8bf92b1f310b15d3020#readContract

Roadmap

We’d love your help developing the Open Price Feed, which we hope can become a common good for the Ethereum ecosystem.

The Open Price Feed is designed to be a foundation that anybody can build on, extend, and improve. The number of Reporters, Posters, and Views can scale over time, as the ecosystem develops.

  • If you’re a developer, join the Github; your eyes and brain on the project are crucial!
  • If you have access to unique price data, please consider joining the system as a Reporter. You can email us or join us in Discord.

--

--