Closed github-actions[bot] closed 1 year ago
Avci
medium
divCeil gives strange results
divCeil(1001, 1000) returns 2 divCeil(1, 1000) returns 1
should return ceil amount only if above half
wrong dive results
function divCeil(uint256 a, uint256 b) internal pure returns (uint256) { return (a + b - 1) / b; }
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/libraries/BBMath.sol#L7
Manual Review
May use this modified function
function divCeil2(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; if ( 2 * (a % b) > b ) c = c + 1;` return c; }
Avci
medium
divCeil gives strange results
Summary
divCeil gives strange results
Vulnerability Detail
divCeil(1001, 1000) returns 2 divCeil(1, 1000) returns 1
should return ceil amount only if above half
Impact
wrong dive results
Code Snippet
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/libraries/BBMath.sol#L7
Tool used
Manual Review
Recommendation
May use this modified function