refactor DODOMath
This commit is contained in:
@@ -10,7 +10,6 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import {SafeMath} from "./SafeMath.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title DecimalMath
|
||||
* @author DODO Breeder
|
||||
@@ -21,24 +20,33 @@ library DecimalMath {
|
||||
using SafeMath for uint256;
|
||||
|
||||
uint256 constant ONE = 10**18;
|
||||
uint256 constant ONE2 = 10**36;
|
||||
|
||||
function mul(uint256 target, uint256 d) internal pure returns (uint256) {
|
||||
return target.mul(d) / ONE;
|
||||
return target.mul(d) / (10**18);
|
||||
}
|
||||
|
||||
function mulFloor(uint256 target, uint256 d) internal pure returns (uint256) {
|
||||
return target.mul(d) / ONE;
|
||||
return target.mul(d) / (10**18);
|
||||
}
|
||||
|
||||
function mulCeil(uint256 target, uint256 d) internal pure returns (uint256) {
|
||||
return target.mul(d).divCeil(ONE);
|
||||
return target.mul(d).divCeil(10**18);
|
||||
}
|
||||
|
||||
function divFloor(uint256 target, uint256 d) internal pure returns (uint256) {
|
||||
return target.mul(ONE).div(d);
|
||||
return target.mul(10**18).div(d);
|
||||
}
|
||||
|
||||
function divCeil(uint256 target, uint256 d) internal pure returns (uint256) {
|
||||
return target.mul(ONE).divCeil(d);
|
||||
return target.mul(10**18).divCeil(d);
|
||||
}
|
||||
|
||||
function reciprocalFloor(uint256 target) internal pure returns (uint256) {
|
||||
return uint256(10**36).div(target);
|
||||
}
|
||||
|
||||
function reciprocalCeil(uint256 target) internal pure returns (uint256) {
|
||||
return uint256(10**36).divCeil(target);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user