Protocol's calculation fails for twapPrice < 1e6
As per developer comments:
However, protocol will not be able to fall back on twap & incorrectly always revert when twapPrice < 1e6, as division has been performed before multiplication, causing precision loss.
If twapPrice returned by the following line of code (L82) ever goes below 1e6,
then in the next line, the twapPriceInEther is incorrectly calculated as zero:
Multiplication should have been performed first, followed by division.
Example:
Assume twapPrice returned to be 1e6 - 1 = 999999. The twapPriceInEther calculated should ideally be:
CORRECT FORMULA:
However, the protocol incorrectly calculates it as:
INCORRECT FORMULA:
Protocol not able to fall back on twap when twapPrice < 1e6.
Manual review
Perform multiplication before division:
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.