Designing Fixed Point Math in OpenZeppelin Contracts

References to Ether/Wei or token decimals are misleading, as both, ether and token amounts are actually integers when measured in base units, and it is generally accepted best practice to always use integers for money amounts.
Real use cases to be considered for fixed point numbers are: interest rates, compound interest ratios, bonding curve bid/ask prices, exchange rates etc, but not raw money amounts.
There is also a use case when 256-bit integer money amount has to be multiplied by fractional (fixed-point in our case) factor producing 256-bit integer result. This use case should be treated separately from fixed-point math, as it is cross-type math.

4 Likes