Precision loss could happen when division comes before multiplication #274
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
edited-by-warden
grade-c
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-01-numoen/blob/2ad9a73d793ea23a25a381faadc86ae0c8cb5913/src/core/Pair.sol#L56-L57
Vulnerability details
Impact
Detailed description of the impact of this finding.
There appears to be division before multiplication in this line of code which could result to precision loss or unexpected output.
Proof of Concept
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
https://github.com/code-423n4/2023-01-numoen/blob/2ad9a73d793ea23a25a381faadc86ae0c8cb5913/src/core/Pair.sol#L56-L57
Tools Used
Manual Review
Recommended Mitigation Steps
It is recommended to multiply before doing division
uint256 scale0 = FullMath.mulDiv(amount0 * 1e18 * token0Scale, 1, liquidity);
uint256 scale0 = FullMath.mulDiv(amount0 * 1e18 * token1Scale, 1, liquidity);
The text was updated successfully, but these errors were encountered: