The twapPriceInEther calculation should multiply first and divide after, or otherwise the calculation could lead to precision loss and would be rounded to zero if WETH is worth less than a dollar in the future.
This is the formula to calculate the twapPriceInEther:
The twapPrice is divided by the 10 ** 6 and multiplied by 1e18 after that. Dividing first can lead to precision loss, also if WETH would be for any reason below one dollar in the future the twapPrice would be below 10 ** 6 and therefore the calculation would be rounded down to zero by solidity. This would lead to a DoS, as the following check would revert:
Precision Loss, DoS
Manual Review
Multiply first and divide after.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.