Oracle Infrastructure: Chainlink Proposal

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