Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: low
Invalid

Minor unnecessary precision loss takes place in realizedDebtChangeUsdX18 / unrealizedDebtChangeUsdX18 usdcCreditChangeX18

Summary

Division before multiplication in realizedDebtChangeUsdX18 / unrealizedDebtChangeUsdX18 usdcCreditChangeX18 leads to unnecessary precision loss.

Vulnerability Details

Here is the division: https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/leaves/Market.sol#L296
Here are the instances of multiplication following the division (division will cause rounding down before the multiplication so additional precision loss):
https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/leaves/Market.sol#L302
https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/leaves/Market.sol#L308
https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/leaves/Market.sol#L314

Impact

Potential for dust amounts to not be accounted for in the values.
https://solodit.cyfrin.io/?b=false&f=&fc=gte&ff=&fn=1&i=HIGH%2CMEDIUM%2CLOW&p=1&pc=&r=all&s=division+before+multiplication+ud60x18&t=
Also, note that cyfrin has already found issues like this before where SD59x18 variables can have precision loss through division before multiplication and this issue was submitted as a valid low in a cyfrin audit report.

Tools Used

Manual review

Recommendations

Multiply before dividing to avoid unnecessary precision loss.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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