Expand description

Math for preserving precision of ratios and percentages.

Usages and their ranges include:

  • Collateral exchange ratio <= 5.0
  • Loan to value ratio <= 0.9
  • Max borrow rate <= 2.56
  • Percentages <= 1.0

Rates are internally scaled by a WAD (10^18) to preserve precision up to 18 decimal places. Rates are sized to support both serialization and precise math for the full range of unsigned 8-bit integers. The underlying representation is a u128 rather than u192 to reduce compute cost while losing support for arithmetic operations at the high end of u8 range.

Structs

Small decimal values, precise to 18 digits
Little-endian large integer type