mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
updated math.sol
This commit is contained in:
parent
10372bbdbd
commit
d9a2bf5671
|
@ -1,6 +1,8 @@
|
|||
pragma solidity ^0.6.0;
|
||||
|
||||
contract DSMath {
|
||||
uint constant WAD = 10 ** 18;
|
||||
uint constant RAY = 10 ** 27;
|
||||
|
||||
function add(uint x, uint y) internal pure returns (uint z) {
|
||||
require((z = x + y) >= x, "math-not-safe");
|
||||
|
@ -10,7 +12,6 @@ contract DSMath {
|
|||
require(y == 0 || (z = x * y) / y == x, "math-not-safe");
|
||||
}
|
||||
|
||||
uint constant WAD = 10 ** 18;
|
||||
|
||||
function wmul(uint x, uint y) internal pure returns (uint z) {
|
||||
z = add(mul(x, y), WAD / 2) / WAD;
|
||||
|
@ -20,4 +21,12 @@ contract DSMath {
|
|||
z = add(mul(x, WAD), y / 2) / y;
|
||||
}
|
||||
|
||||
function rdiv(uint x, uint y) internal pure returns (uint z) {
|
||||
z = add(mul(x, RAY), y / 2) / y;
|
||||
}
|
||||
|
||||
function rmul(uint x, uint y) internal pure returns (uint z) {
|
||||
z = add(mul(x, y), RAY / 2) / RAY;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user