Skip to main content

WadMath

Git Source

Author: Modified from Solmate:v6

Arithmetic library with operations for fixed-point numbers.

State Variables

WAD

uint256 internal constant WAD = 1e18;

Functions

wadMul

function wadMul(uint256 x, uint256 y) internal pure returns (uint256 z);

wadDiv

function wadDiv(uint256 x, uint256 y) internal pure returns (uint256 z);

mulDiv

Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0

See https://2π.com/21/muldiv

function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result);

Parameters

NameTypeDescription
auint256The multiplicand
buint256The multiplier
denominatoruint256The divisor

Returns

NameTypeDescription
resultuint256The 256-bit result

Errors

DivideByZero

error DivideByZero();

Overflow

error Overflow();