code-423n4 / 2022-01-elasticswap-findings

1 stars 0 forks source link

Shift Right instead of Dividing by 2 #100

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

byterocket

Vulnerability details

Impact

Issue Information: G008

Findings:

libraries/MathLib.sol::43 => return ((a * WAD) + (b / 2)) / b;
libraries/MathLib.sol::55 => return ((a + (n / 2)) / n) * n;
libraries/MathLib.sol::67 => return ((a * b) + (WAD / 2)) / WAD;
libraries/MathLib.sol::85 => uint256 x = y / 2 + 1;
libraries/MathLib.sol::88 => x = (y / x + x) / 2;

Tools used

c4udit

0xean commented 2 years ago

prefer readability.

GalloDaSballo commented 2 years ago

Agree with the finding, and don't mind a nofix for readability