2

These are Compound Finance's former oracle contracts:

I say "former" because Compound switched to the Open Price Feed UniwapAnchoredView.sol oracle on Aug 17, 2020.

While studying this function:

function getUnderlyingPrice(CToken cToken) public view returns (uint) {
    address cTokenAddress = address(cToken);
    (bool isListed, ) = comptroller.markets(cTokenAddress);

    if (!isListed) {
        // not listed, worthless
        return 0;
    } else if (cTokenAddress == cEtherAddress) {
        // ether always worth 1
        return 1e18;
    } else if (cTokenAddress == cUsdcAddress) {
        // read from hand picked key
        return v1PriceOracle.assetPrices(usdcOracleKey);
    } else {
        // read from v1 oracle
        address underlying = CErc20(cTokenAddress).underlying();
        return v1PriceOracle.assetPrices(underlying);
    }
}

I started to wonder why did they choose ETH as the base unit of price reference? Their web interface tracks all values in USD.

What advantages are there in using ETH instead of USD?

1 Answer 1

2

I'm only speculating here, but...

One might ask a counter-question: why would anyone use USD as a reference price? USD has nothing to do with blockchain while Eth is a native asset in the blockchain. So in my opinion it makes more sense to use Eth. Also, the conversions between tokens are Eth are also more fluent and can be performed on-chain.

I guess it's also a bit of a industry standard. I think Aave uses Eth (search for 'wei' in https://docs.aave.com/developers/developing-on-aave/the-protocol/atokens), and I think Chainlink also gave prices in weis but can't really find a reference for that now so can't be sure.

5
  • I've seen USD as reference also. Maybe it's just like a. Copy blockchain project => use ETH as reference. b. Copy real-world project => use USD as reference Commented Sep 11, 2020 at 21:37
  • ChainLink uses USD as of today (Sep 2020). The "latest" property in the ETH/USD Aggregator returns "36783000000", which is $367.83. Commented Sep 12, 2020 at 9:37
  • And about Aave - I am not familiar with their protocol, but I am pretty sure that by "wei" in the document you reference, they refer to the token's most basic unit. So for USDC, which has 6 decimals, a wei would be 1e-6. Commented Sep 12, 2020 at 9:39
  • Ok, I really don't know about these, was just speculating. If you're correct about your wei interpretation it's rather...disturbing, I'd say (like mixing up euro/dollar cents with Russian ruble kopeks). Commented Sep 12, 2020 at 13:33
  • 2
    @PaulRazvanBerg Chainlink uses whatever reference the price feed calls for. ETH/USD uses USD since the price feed itself is looking for ETH in terms of USD. DAI/ETH however is using ETH as the base, since thats what the price feed is looking for. Commented Sep 12, 2020 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.