This library provides mul/div[up/down] functionality for WAD, RAY and RAD with phantom overflow protection as well as scale[up/down] functionality for WAD, RAY and RAD.
Multiplies two WAD numbers and returns the result as a WAD rounding the result down.
Parameters
a
uint256
Multiplicand.
b
uint256
Multiplier.
Multiplies two WAD numbers and returns the result as a WAD rounding the result up.
Parameters
a
uint256
Multiplicand.
b
uint256
Multiplier.
Divides two WAD numbers and returns the result as a WAD rounding the result down.
Parameters
a
uint256
Dividend.
b
uint256
Divisor.
Divides two WAD numbers and returns the result as a WAD rounding the result up.
Parameters
a
uint256
Dividend.
b
uint256
Divisor.
Multiplies two RAY numbers and returns the result as a RAY rounding the result down.
Parameters
a
uint256
Multiplicand
b
uint256
Multiplier
Multiplies two RAY numbers and returns the result as a RAY rounding the result up.
Parameters
a
uint256
Multiplicand
b
uint256
Multiplier
Divides two RAY numbers and returns the result as a RAY rounding the result down.
Parameters
a
uint256
Dividend
b
uint256
Divisor
Divides two RAY numbers and returns the result as a RAY rounding the result up.
Parameters
a
uint256
Dividend
b
uint256
Divisor
Multiplies two RAD numbers and returns the result as a RAD rounding the result down.
Parameters
a
uint256
Multiplicand
b
uint256
Multiplier
Multiplies two RAD numbers and returns the result as a RAD rounding the result up.
Parameters
a
uint256
Multiplicand
b
uint256
Multiplier
Divides two RAD numbers and returns the result as a RAD rounding the result down.
Parameters
a
uint256
Dividend
b
uint256
Divisor
Divides two RAD numbers and returns the result as a RAD rounding the result up.
Parameters
a
uint256
Dividend
b
uint256
Divisor
Scales a value up from WAD. NOTE: The scale
value must be less than 18.
Parameters
value
uint256
to scale up.
scale
uint256
of the returned value.
Scales a value up from RAY. NOTE: The scale
value must be less than 27.
Parameters
value
uint256
to scale up.
scale
uint256
of the returned value.
Scales a value up from RAD. NOTE: The scale
value must be less than 45.
Parameters
value
uint256
to scale up.
scale
uint256
of the returned value.
Scales a value down to WAD. NOTE: The scale
value must be greater than 18.
Parameters
value
uint256
to scale down.
scale
uint256
of the returned value.
Scales a value down to RAY. NOTE: The scale
value must be greater than 27.
Parameters
value
uint256
to scale down.
scale
uint256
of the returned value.
Scales a value down to RAD. NOTE: The scale
value must be greater than 45.
Parameters
value
uint256
to scale down.
scale
uint256
of the returned value.
Scales a value up from one fixed-point precision to another.
Parameters
value
uint256
to scale up.
from
uint256
Precision to scale from.
to
uint256
Precision to scale to.
Scales a value down from one fixed-point precision to another.
Parameters
value
uint256
to scale down.
from
uint256
Precision to scale from.
to
uint256
Precision to scale to.