DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: low
Valid

Loss of precision in TWAP price in ether

Summary

Loss of precision in baseOracleCircuitBreaker() could cause incorrect calculation price.

Vulnerability Details

There will be precision loss when calculating price, because solidity truncates values when dividing and dividing before multiplying causes precision loss.

Impact

It could cause incorrect calculation of price.

Tools Used

Manual review

Recommendations

-uint256 twapPriceInEther = (twapPrice / Constants.DECIMAL_USDC) * 1 ether; // (5 / 2) * 10) = 20
+uint256 twapPriceInEther = twapPrice * 1 ether / Constants.DECIMAL_USDC; // 5 * 10 / 2 = 25
Updates

Lead Judging Commences

0xnevi Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-535

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.