Division by Zero: None of the division functions (div, divCeil, reciprocalFloor, reciprocalCeil) check for division by zero, which will revert the transaction. It is generally good practice to include checks for division by zero to provide clearer error messages or handle such cases gracefully.
Vulnerability Detail
function div(uint256 target, uint256 d) internal pure returns (uint256) {
return target * (10 ** 18) / d;
}
function divFloor(uint256 target, uint256 d) internal pure returns (uint256) {
return target * (10 ** 18) / d;
}
Impact
check for division by zero, which will revert the transaction.
bareli
medium
Division by Zero:
Summary
Division by Zero: None of the division functions (div, divCeil, reciprocalFloor, reciprocalCeil) check for division by zero, which will revert the transaction. It is generally good practice to include checks for division by zero to provide clearer error messages or handle such cases gracefully.
Vulnerability Detail
function div(uint256 target, uint256 d) internal pure returns (uint256) { return target * (10 ** 18) / d; }
Impact
check for division by zero, which will revert the transaction.
Code Snippet
https://github.com/sherlock-audit/2023-12-dodo/blob/main/dodo-v3/contracts/DODOV3MM/lib/DecimalMath.sol#L30
Tool used
Manual Review
Recommendation
use a require statement for 0.