I know TWAP formula = priceDifference / timeElapsed;
but still not able to get how uniswapv2 is doing that.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
Here's the math contracts: https://github.com/Uniswap/v2-core/blob/master/contracts/libraries/UQ112x112.sol
And I know this is for v3, but this article explains the twaps in Uniswap a bit more (note it has more to do with ticks than actual time): https://chaoslabs.xyz/posts/chaos-labs-uniswap-v3-twap-deep-dive-pt-1.