Submitted by cmichel
The TWAPOracle.registerPair function takes in a factory and (token0, token1).
The function accepts a _factory argument which means any Uniswap-like factory can be used.
When using the actual Uniswap factorys IUniswapV2Factory(factory).getPair(token0, token1) call, it could be that the token0 and token1 are reversed as it ignores the order.
Meaning, the price0/1CumulativeLast could also be reversed as it matches the internal order.
The code however pushes the _pairs assuming that the internal price0CumulativeLast, price1CumulativeLast order matches the order of the function arguments token0, token1.
The prices could be inverted which leads to the oracle providing wrong prices.
It should be checked if Uniswaps internal order matches the order of the token0/1 function arguments.
If not, the cumulative prices must be swapped.
SamSteinGG (Vader) confirmed
