Module 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::wad_ray_math
@title WadRayMath library @author Aave @notice Provides functions to perform calculations with Wad and Ray units @dev Provides mul and div function for wads (decimal numbers with 18 digits of precision) and rays (decimal numbers with 27 digits of precision) @dev Operations are rounded. If a value is >=.5, will be rounded up, otherwise rounded down.
- Constants
- Function
wad
- Function
half_wad
- Function
ray
- Function
half_ray
- Function
wad_mul
- Function
wad_div
- Function
ray_mul
- Function
ray_div
- Function
ray_to_wad
- Function
wad_to_ray
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
Constants
@notice Maximum value for u256
const U256_MAX: u256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
@notice 5 * 10^26 - Half RAY, used for rounding
const HALF_RAY: u256 = 500000000000000000000000000;
@notice 5 * 10^17 - Half WAD, used for rounding
const HALF_WAD: u256 = 500000000000000000;
@notice 10^27 - Used for calculations in ray (27 decimals)
const RAY: u256 = 1000000000000000000000000000;
@notice 10^18 - Used for calculations in wad (18 decimals)
const WAD: u256 = 1000000000000000000;
@notice 10^9 - The ratio between ray and wad (ray/wad)
const WAD_RAY_RATIO: u256 = 1000000000;
Function wad
@notice Returns the WAD value (10^18) @return The WAD constant
public fun wad(): u256
Function half_wad
@notice Returns the HALF_WAD value (5 * 10^17) @return The HALF_WAD constant
public fun half_wad(): u256
Function ray
@notice Returns the RAY value (10^27) @return The RAY constant
public fun ray(): u256
Function half_ray
@notice Returns the HALF_RAY value (5 * 10^26) @return The HALF_RAY constant
public fun half_ray(): u256
Function wad_mul
@notice Multiplies two wad, rounding half up to the nearest wad @param a First wad value @param b Second wad value @return c Result of a*b, in wad
public fun wad_mul(a: u256, b: u256): u256
Function wad_div
@notice Divides two wad, rounding half up to the nearest wad @param a Wad numerator @param b Wad denominator @return c Result of a/b, in wad
public fun wad_div(a: u256, b: u256): u256
Function ray_mul
@notice Multiplies two ray, rounding half up to the nearest ray @param a First ray value @param b Second ray value @return c Result of a*b, in ray
public fun ray_mul(a: u256, b: u256): u256
Function ray_div
@notice Divides two ray, rounding half up to the nearest ray @param a Ray numerator @param b Ray denominator @return c Result of a/b, in ray
public fun ray_div(a: u256, b: u256): u256
Function ray_to_wad
@notice Casts ray down to wad @param a Ray value to convert @return b The value converted to wad, rounded half up to the nearest wad
public fun ray_to_wad(a: u256): u256
Function wad_to_ray
@notice Converts wad up to ray @param a Wad value to convert @return b The value converted to ray, rounded half up to the nearest ray
public fun wad_to_ray(a: u256): u256