A library enabling precise decimal calculations based on the EVM's integer arithmetic.
Because the EVM does not support floating points, the Compound protocol's calculations are carried out using a WAD-point number system which allows manipulating decimal numbers using a fixed-point representation, the unit being the WAD = 1e18.

Standard arithmetic


Given two WAD-point numbers x and y, their multiplication is defined as x * y / WAD


Given two WAD-point numbers x and y, their division is defined as x * WAD / y
The operation is wrapped inside a first-place WAD multiplication and last-place WAD division to cancel its effect. The purpose of this is to keep at least 18 significant digits (the precision of the base: the WAD) in the result.