Question:

How to get price of ETH to DAI within smart contract?

Noah: 5 weeks ago

Is it possible to get the current price of Ethereum to Dai within a smart contract? Can this be done without a transaction, using a read operation by the nodes on some kind of existing decentralized exchange or the dai contract itself?

Answer:
Emma: 5 weeks ago

You can use MakerDAO's ETHUSD feeds (https://developer.makerdao.com/feeds/) to get price of ETH in USD. This should be extremely close (<1% difference usually) to ETHDAI in the short term, and average to much closer in the long term (<0.1% usually).

Alternatively, you can use the ratio of ETH to DAI in the Uniswap ETH/DAI exchange to estimate the price, which is located here (https://etherscan.io/address/0x09cabec1ead1c0ba254b09efb3ee13841712be14)