refactor DODOMath

This commit is contained in:
mingda
2020-11-22 13:18:44 +08:00
parent 75190a52f6
commit 3fe7dbb815
4 changed files with 124 additions and 118 deletions

View File

@@ -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);
}
}