Division before multiplication in realizedDebtChangeUsdX18 / unrealizedDebtChangeUsdX18 usdcCreditChangeX18 leads to unnecessary precision loss.
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
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.
Manual review
Multiply before dividing to avoid unnecessary precision loss.
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.