Let's assume that I'm writing a UniswapV2 LP token price oracle. Would it be a bad idea to rely on the LP token totalSupply for my calculation? Would it be possible to manipulate its value through a flash loan attack?
I'm mainly asking this question as I'm currently researching Alpha Finance's code for their LP token price oracle. They introduce the concept of fair reserves through the following formula:
Which could be simplified as follows:
p1 could be made flashloan-proof, as they could be pulled from Chainlink or Uniswap's TWAP price oracles. But I'm not sure if a flash loan attacker would be able to manipulate the total supply of the LP token (
L), or even
k for that matter. Or if it's simply the case that in case of a flash loan attack, both
k would change and both changes would cancel out.