WadRayMath

Git Source

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.

Functions

wadMulDown

Multiplies two WAD numbers and returns the result as a WAD rounding the result down.

function wadMulDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

wadMulUp

Multiplies two WAD numbers and returns the result as a WAD rounding the result up.

function wadMulUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

wadDivDown

Divides two WAD numbers and returns the result as a WAD rounding the result down.

function wadDivDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

wadDivUp

Divides two WAD numbers and returns the result as a WAD rounding the result up.

function wadDivUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

rayMulDown

Multiplies two RAY numbers and returns the result as a RAY rounding the result down.

function rayMulDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

rayMulUp

Multiplies two RAY numbers and returns the result as a RAY rounding the result up.

function rayMulUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

rayDivDown

Divides two RAY numbers and returns the result as a RAY rounding the result down.

function rayDivDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

rayDivUp

Divides two RAY numbers and returns the result as a RAY rounding the result up.

function rayDivUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

radMulDown

Multiplies two RAD numbers and returns the result as a RAD rounding the result down.

function radMulDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

radMulUp

Multiplies two RAD numbers and returns the result as a RAD rounding the result up.

function radMulUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

radDivDown

Divides two RAD numbers and returns the result as a RAD rounding the result down.

function radDivDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

radDivUp

Divides two RAD numbers and returns the result as a RAD rounding the result up.

function radDivUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

scaleUpToWad

Scales a value up from WAD. NOTE: The scale value must be less than 18.

function scaleUpToWad(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

scaleUpToRay

Scales a value up from RAY. NOTE: The scale value must be less than 27.

function scaleUpToRay(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

scaleUpToRad

Scales a value up from RAD. NOTE: The scale value must be less than 45.

function scaleUpToRad(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

scaleDownToWad

Scales a value down to WAD. NOTE: The scale value must be greater than 18.

function scaleDownToWad(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

scaleDownToRay

Scales a value down to RAY. NOTE: The scale value must be greater than 27.

function scaleDownToRay(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

scaleDownToRad

Scales a value down to RAD. NOTE: The scale value must be greater than 45.

function scaleDownToRad(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

scaleUp

Scales a value up from one fixed-point precision to another.

function scaleUp(uint256 value, uint256 from, uint256 to) internal pure returns (uint256);

Parameters

scaleDown

Scales a value down from one fixed-point precision to another.

function scaleDown(uint256 value, uint256 from, uint256 to) internal pure returns (uint256);

Parameters

Errors

NotScalingUp

error NotScalingUp(uint256 from, uint256 to);

NotScalingDown

error NotScalingDown(uint256 from, uint256 to);