I need to get the exchange rate for every token on Uniswap with Web3 like Uniswap itself which they then display on their web interface on app.uniswap.org like this:
So when I enter to swap the amount of tokens I want to to give (1 ETH in this example) it shows me the estimated amount of tokens I will receive (1691.53 DAI in this example)
What I've tried
I want to get the information directly from the blockchain and don't wanna use an API because I need the prices to be as up to date as possible so I thought of searching for a function in one of Uniswap's smart contracts but only found a function called quote() but I couldn't do anything with that.
-> If someone can help me please provide me with some code examples on how to exactly do that.
Also I need to know if I got the concept of Uniswap... To be able to exchange one token for another there has to be a pool already for this exact pair I want to exchange is this right?