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)
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.
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:
- Aggregator: 0x37bC7498f4FF12C19678ee8fE19d713b87F6a9e6
- ValidatorProxy: 0x264BDDFD9D93D48d759FBDB0670bE1C6fDd50236
- Chainlink Visual: data.chain.link/eth-usd
USDC/USD:
- Hardcoded at $1
DAI/USD:
- Aggregator: 0xDEc0a100eaD1fAa37407f0Edc76033426CF90b82
- ValidatorProxy: 0xb2419f587f497CDd64437f1B367E2e80889631ea
- Chainlink Visual: data.chain.link/dai-usd
WBTC/USD:
- Aggregator: 0xAe74faA92cB67A95ebCAB07358bC222e33A34dA7
- ValidatorProxy: 0x4846efc15CC725456597044e6267ad0b3B51353E
- Chainlink Visual: data.chain.link/btc-usd
USDT/USD:
- Hardcoded at $1
UNI/USD:
- Aggregator: 0x68577f915131087199Fe48913d8b416b3984fd38
- ValidatorProxy: 0x70f4D236FD678c9DB41a52d28f90E299676d9D90
- Chainlink Visual: data.chain.link/uni-usd
COMP/USD:
- Aggregator: 0x6eaC850f531d0588c0114f1E93F843B78669E6d2
- ValidatorProxy: 0xE270B8E9d7a7d2A7eE35a45E43d17D56b3e272b1
- Chainlink Visual: data.chain.link/comp-usd
ZRX/USD:
- Aggregator: 0x3d47eF9690Bd00C77c568b73140dC20F34453766
- ValidatorProxy: 0x5c5db112c98dbe5977A4c37AD33F8a4c9ebd5575
- Chainlink Visual: data.chain.link/zrx-usd
BAT/USD:
- Aggregator: 0xd90CA9ac986e453CF51d958071D68B82d17a47E6
- ValidatorProxy: 0xeBa6F33730B9751a8BA0b18d9C256093E82f6bC2
- Chainlink Visual: data.chain.link/bat-usd
TUSD/USD:
- Hardcoded at $1
LINK/USD:
- Aggregator: 0xDfd03BfC3465107Ce570a0397b247F546a42D0fA
- ValidatorProxy: 0xBcFd9b1a97cCD0a3942f0408350cdc281cDCa1B1
- Chainlink Visual: data.chain.link/link-usd
SAI/USD:
- Hardcoded to 0.005285 ETH
REP/USD:
- Aggregator: 0x9AdF01321833A5Cba51B9f8A4C420C7e62481Ae5
- ValidatorProxy: 0x90655316479383795416B615B61282C72D8382C1
- Chainlink Visual: data.chain.link/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.
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?
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.
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...)
?
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.
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.
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.
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!
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!
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)
Good point; here is the reasoning for that. Chainlink OCR aggregators as reporters 🚀 by alexroan · Pull Request #1 · smartcontractkit/open-oracle · GitHub