Result given by function MathMasters::mulWadUp
can be incorrect depending on the inputs.
In MathMasters::mulWadUp
the result of the multiplication (x * y) / WAD
rounded up is done by performing:
Which returns an incorrect result depending on the input.
By altering the settings of fuzz runs in foundry.toml
in the following fashion:
And running forge test --mt testMulWadUpFuzz
we find a test case where the expected result is different from what the function returns.
This causes the behaviour of the function to be different from what is specified in the natspec. Returning wrong results depending on the input.
Foundry fuzzer
To determine whether to round the result of the division up, we simply need to check if the following statement is true:
x * y % WAD != 0
In the case of it being true then we must add 1
to the result of x * y / WAD
. This is already done in the function, therefore we must simply remove the line above it which performs an unnecessary operation.
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.