View Source: contracts/StableMath.sol
StableMath
Accesses the Stable Math library using generic system wide variables for managing precision Derives from OpenZeppelin's SafeMath lib
Constants & Variables
uint256 private constant fullScale;
- getScale()
- scale(uint256 a)
- add(uint256 a, uint256 b)
- sub(uint256 a, uint256 b)
- mul(uint256 a, uint256 b)
- mulTruncate(uint256 a, uint256 b, uint256 _scale)
- mulTruncate(uint256 a, uint256 b)
- div(uint256 a, uint256 b)
- divPrecisely(uint256 a, uint256 b)
Getters
function getScale() internal pure
returns(uint256)
Arguments
Name | Type | Description |
---|
Scaled a given integer to the power of the full scale.
function scale(uint256 a) internal pure
returns(b uint256)
Arguments
Name | Type | Description |
---|---|---|
a | uint256 |
Returns the addition of two unsigned integers, reverting on overflow.
function add(uint256 a, uint256 b) internal pure
returns(c uint256)
Arguments
Name | Type | Description |
---|---|---|
a | uint256 | |
b | uint256 |
Returns the subtraction of two unsigned integers, reverting on overflow.
function sub(uint256 a, uint256 b) internal pure
returns(c uint256)
Arguments
Name | Type | Description |
---|---|---|
a | uint256 | |
b | uint256 |
Returns the multiplication of two unsigned integers, reverting on overflow.
function mul(uint256 a, uint256 b) internal pure
returns(c uint256)
Arguments
Name | Type | Description |
---|---|---|
a | uint256 | |
b | uint256 |
Multiplies two numbers and truncates
function mulTruncate(uint256 a, uint256 b, uint256 _scale) internal pure
returns(c uint256)
Arguments
Name | Type | Description |
---|---|---|
a | uint256 | |
b | uint256 | |
_scale | uint256 |
Multiplies two numbers and truncates using standard full scale
function mulTruncate(uint256 a, uint256 b) internal pure
returns(c uint256)
Arguments
Name | Type | Description |
---|---|---|
a | uint256 | |
b | uint256 |
Returns the integer division of two unsigned integers
function div(uint256 a, uint256 b) internal pure
returns(c uint256)
Arguments
Name | Type | Description |
---|---|---|
a | uint256 | |
b | uint256 |
Precisely divides two numbers, first by expanding
function divPrecisely(uint256 a, uint256 b) internal pure
returns(c uint256)
Arguments
Name | Type | Description |
---|---|---|
a | uint256 | |
b | uint256 |