Skip to main content
Update oracle addresses
Source Link
Paul Razvan Berg
  • 18.7k
  • 6
  • 79
  • 148

These are Compound Finance's former oracle contracts:

As per this tweet, these are Compound's oracles that run in production (as of November 2018 the least). I say "former" because Compound switched to the Open Price Feed UniwapAnchoredView.sol oracle on Aug 17, 2020.

Now, whileWhile 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.

Are there majorWhat advantages are there in using ETH instead of USD for the on-chain pricing data?

These are Compound Finance's oracle contracts:

As per this tweet, these are Compound's oracles that run in production (as of November 2018 the least).

Now, 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.

Are there major advantages in using ETH instead of USD for the on-chain pricing data?

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?

Update second contract's address
Source Link
Paul Razvan Berg
  • 18.7k
  • 6
  • 79
  • 148

These are Compound Finance's oracle contracts:

As per this tweet, these are Compound's oracles that run in production (as of November 2018 the least).

Now, 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.

Are there major advantages in using ETH instead of USD for the on-chain pricing data?

These are Compound Finance's oracle contracts:

As per this tweet, these are Compound's oracles that run in production (as of November 2018 the least).

Now, 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.

Are there major advantages in using ETH instead of USD for the on-chain pricing data?

These are Compound Finance's oracle contracts:

As per this tweet, these are Compound's oracles that run in production (as of November 2018 the least).

Now, 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.

Are there major advantages in using ETH instead of USD for the on-chain pricing data?

Source Link
Paul Razvan Berg
  • 18.7k
  • 6
  • 79
  • 148

Rationale for using ETH as the unit of account for oracle pricing data

These are Compound Finance's oracle contracts:

As per this tweet, these are Compound's oracles that run in production (as of November 2018 the least).

Now, 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.

Are there major advantages in using ETH instead of USD for the on-chain pricing data?