[trail of bits audit] #1 Loss of precision may allow an attacker to get funds for free
This commit is contained in:
@@ -10,6 +10,7 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import {SafeMath} from "./SafeMath.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title DecimalMath
|
||||
* @author DODO Breeder
|
||||
@@ -25,6 +26,10 @@ library DecimalMath {
|
||||
return target.mul(d) / ONE;
|
||||
}
|
||||
|
||||
function mulCeil(uint256 target, uint256 d) internal pure returns (uint256) {
|
||||
return target.mul(d).divCeil(ONE);
|
||||
}
|
||||
|
||||
function divFloor(uint256 target, uint256 d) internal pure returns (uint256) {
|
||||
return target.mul(ONE).div(d);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user