Oracle Infrastructure: Chainlink Proposal

Very exciting! Thank you for all the hard work on this initiative @getty. I’m looking forward to seeing what the community thinks getting this put to a vote.

The Compound Community Multisig is voting to accept the ownership of the new UniswapAnchoredView at 0x34aB75D077c148F1eCAa435e7125c16842A0AeA3.

Check how the vote is going at
Gnosis Safe (gnosis-safe.io)

5 Likes

I found a small/cosmetic issue with the UniswapAnchorView deployment. The cWBTC v2 token configuration had the cWBTC v1 address instead of the v2 address. While this wouldn’t affect anything within the Compound protocol and has zero impact on the price reporting, we thought it would be best to correct it and redeploy.
I have coordinated with the Chainlink team, and they have redeployed the UAV and pointed the validator proxy contract to the new UAV. The community multisig will need to accept ownership of the UAV at 0x841616a5CBA946CF415Efe8a326A621A794D0f97.

5 Likes

Hey everyone, to provide some additional insight to some of the questions raised on the dev call today in the Discord, I wanted to provide some data and analytics info to show that the integration work with Chainlink price feeds and Compound is working as expected without issue.

First to note, the UniswapAnchoredView (UAV) contract used here is the same UAV contract that is currently being used in-production by the Compound protocol. It uses the same logic of ingesting data from a reporter, checking it against the Uniswap V2 TWAP, and storing the price if it is within the deviation threshold. The only change has been switching the reporter from Coinbase to Chainlink price feeds and a conversion of the decimal spacing to align to what is already being used. Additionally, the deviation threshold between the reporter and Uniswap has been lowered from 20% to 15%, providing additional protection against any potential outlier data.

The deployed UAV contract address is 0x841616a5CBA946CF415Efe8a326A621A794D0f97 and the recent updates can be seen on the Etherscan events page. PriceUpdated() is an event emitted when the stored price is updated and PriceGuarded() is an event when new prices are posted but the stored price is not updated due to the anchor deviation. The contract is also open-source and has been verified on Etherscan. Additionally, the UAV contract has been audited by Trail of Bits and the ValidatorProxy contracts has been audited by SigmaPrime.

The Chainlink Price Feeds being used by the UAV are the same data feeds that are already being used by other DeFi projects like Syntheix and Aave, and have operated for many months without issue. This includes during the recent market crash and network congestion when gas prices on Ethereum mainnet spiked to 2,500 Gwei. A visualization for these feeds is available from data.chain.link, which displays data that is stored on-chain and can be cross-referenced with the contracts on Etherscan. Below are the contract addresses and Etherscan links to the events page for each price feed which delivers data to the UAV through the ValidatorProxy contracts.

ETH/USD:

USDC/USD:

  • Hardcoded at $1

DAI/USD:

WBTC/USD:

USDT/USD:

  • Hardcoded at $1

UNI/USD:

COMP/USD:

ZRX/USD:

BAT/USD:

TUSD/USD:

  • Hardcoded at $1

LINK/USD:

SAI/USD:

  • Hardcoded to 0.005285 ETH

REP/USD:

Auditing the Chainlink Visualization Page

The values displayed on the Chainlink visualization page can be audited by using the Etherscan events tab on the Aggregator contract of each market (hyperlinks above). Each price feed update generates an AnswerUpdated() event, which has a field [topic1] containing the new value encoded in hexadecimal. This value can be converted into decimals to see the price data and divided by 10^8 to get the correct price with decimals to then compare against the data displayed on data.chain.link.

For example, on the BAT/USD feed, this update transaction has an index_topic_1 int256 current value of 0x0000000000000000000000000000000000000000000000000000000004ca1b37. When converting into decimal, this results in a value of 80354103. When divided by 10^8, this results in a value of 0.80354103. When looking at the BAT/USD visualization page, this same value is shown in USD form $0.80354103.

Ethtx.info does a nice job showing the execution trace and emitted events.

To showcase that the decimal conversion in the UAV contract is occurring as expected, here is output of a script showing a comparison of pricing data from the production open oracle system with Coinbase, the proposed UAV with Chainlink price feeds, and the market-wide price from CoinGecko.

Values retrieved at: 2021-06-02 18:15:10.727044

bat

production: 835071000000000000

proposed: 811253000000000000

coingecko: 806510000000000000

comp

production: 449050000000000000000

proposed: 447514145000000000000

coingecko: 448400000000000000000

dai

production: 1001271000000000000

proposed: 1001143000000000000

coingecko: 1000000000000000000

eth

production: 2772600000000000000000

proposed: 2768319267000000000000

coingecko: 2760569999999999934464

link

production: 30696265000000000000

proposed: 31272512000000000000

coingecko: 31260000000000000000

rep

production: 29540000000000000000

proposed: 26186473000000000000

coingecko: 26620000000000000000

sai

production: 14653191000000000000

proposed: 14630567000000000000

coingecko: 14070000000000000000

tusd

production: 1000000000000000000

proposed: 1000000000000000000

coingecko: 999673000000000000

uni

production: 27319550000000000000

proposed: 28170000000000000000

coingecko: 28170000000000000000

usdc

production: 1000000000000000000000000000000

proposed: 1000000000000000000000000000000

coingecko: 999315000000000000000000000000

usdt

production: 1000000000000000000000000000000

proposed: 1000000000000000000000000000000

coingecko: 1000000000000000000000000000000

btc

production: 380981900000000000000000000000000

proposed: 378318378280000000000000000000000

coingecko: 378790000000000002621440000000000

btc2

production: 380981900000000000000000000000000

proposed: 378318378280000000000000000000000

coingecko: 378790000000000002621440000000000

zrx

production: 1147138000000000000

proposed: 1149519000000000000

coingecko: 1149999999999999872

As shown above, the decimal placement is correct and the proposed price feeds closely tracks the market-wide CoinGecko price.

To check each asset’s token configuration in the UniswapAnchorView contract go to the current UAV and the proposed UAV to compare them. Each contract is verified on Etherscan. To verify the token configuration use Etherscan’s read contract functionality and one/all of the getTokenConfigBy functions.

The proposed UAV also has an “owner” who has the ability to engage the failover function. Chainlink transferred ownership of the proposed UAV to the Compound community multisig

If there is any additional information the community is interested in, let me know.

11 Likes

Are the mentioned simulation scripts available for the community to see? Also, is a network fork simulation which simulates the proposal execution and sanity checks everything available?

2 Likes

Sure, you can run this script Compare UAVs · GitHub

For each supported market, this script calls getUnderlyingPrice() on both the current production UAV (being used by the protocol right now), and the proposed UAV. It prints the results as returned.

Regarding your second question, we thought about doing a fork, but it is pointless without the needed Uniswap pools and would be pretty complicated to set up and test; we do have something better to check that everything is working. All the contracts are deployed on mainnet and functioning as expected in production. We (anyone) can prove the proposed UAV doesn’t change the output of prices compared to the current UAV.

2 Likes

I ran the script and got sensible results.

But I think arr00 is also concerned about the proposal execution itself. Is it just a single call to Comptroller._setPriceOracle(0x8416...)?

1 Like

Using the Compound protocol tools built into Github, forking simulations are actually quite easy to make. I’ve run them for every proposal I’ve created. Just take a look at this folder.

2 Likes

Thanks, @arr00, I didn’t know about that. I’ll dig in.

By the way, I threw together a site for comparing the current oracle’s prices, the proposed oracle’s prices, and Chainlink’s price. defialerts.io/oracle, it shows the block number from when it pulled the data, and I have it updating every 10 minutes right now. Here is the Github repo for it as well: GitHub - gettty/ChainlinkCompound.

2 Likes

thanks @getty, appreciate the work. One question: does it not matter that the number of significant digits between current and proposed are different?

What do you mean by different? The precision of the prices doesn’t matter, just that the price is being expressed correctly. If you’re referring to the website I put together, you can see in the repo that no manual adjustments are being made and that I am reading the contracts directly.

The proposed change is now live and in review. Voting will begin in 48 hours.

https://www.withtally.com/governance/compound/proposal/47

I would like to thank Polychain for delegating their votes to the CAP and set the precedent that large voters will work with community members.

9 Likes

Excellent work Getty. Very happy to see large shareholders like Polychain signalling support for the oracle improvement. The added security and ability to support a wider range of assets it enables will be a boon to Compound’s continued growth. Looking forward to voting going live tomorrow!

3 Likes

Great work @getty and everyone else involved!

This change will greatly improve the reliability of the protocol as well as thrust us forward in our ability to expand our markets!

3 Likes

A note to any offchain event watchers: the price updated event signature is a bit different than the existing oracle. It changed from PriceUpdated (string symbol, uint256 price) to PriceUpdated (index_topic_1 bytes32 symbolHash, uint256 price)

1 Like

Good point; here is the reasoning for that. Chainlink OCR aggregators as reporters 🚀 by alexroan · Pull Request #1 · smartcontractkit/open-oracle · GitHub

1 Like