ABDKMath64 performs multiplication on results of division
A fixed-point maths library performed division before multiplication, so Solidity's integer truncation could discard precision from the intermediate result. An attacker could not directly exploit this, but callers relying on the library could compute slightly wrong values.
Submitted by AlleyCat
https://github.com/code-423n4/2022-04-mimo/blob/main/core/contracts/libraries/ABDKMath64x64.sol#L626
https://github.com/code-423n4/2022-04-mimo/blob/main/core/contracts/libraries/ABDKMath64x64.sol#L629
https://github.com/code-423n4/2022-04-mimo/blob/main/core/contracts/libraries/ABDKMath64x64.sol#L630
Solidity could truncate the results, performing multiplication before division will prevent rounding/truncation in solidity math.
Recommended Mitigation Steps
Consider ordering multiplication first.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the expression divides two values and then multiplies the result, so integer truncation in the division step loses precision that a later multiplication cannot recover.
Impact
Calculations using this library could return slightly inaccurate values due to truncation; the report does not show a concrete exploit.
What the attacker needed
Contract code calls the affected library function
The fix
The order of operations should be changed so multiplication happens before division.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Solidity, the language smart contracts are written in, only works with whole numbers, so any fraction is simply cut off. If you divide first and multiply afterwards, that cut-off fraction is lost and the final answer can be slightly wrong. Doing the multiplication first keeps more precision before the division happens.