Fixed Point Math Errors
Fixed point math errors occur because standard programming languages, including Solidity, do not natively support floating-point numbers. To handle decimals, protocols use fixed-point math, where numbers are scaled by a factor, such as 10 to the power of 18.
Errors arise when developers perform operations without correctly accounting for these scales, leading to massive rounding errors or incorrect pricing. For example, multiplying two numbers that are both scaled by 10 to the 18 results in a number scaled by 10 to the 36, which must be scaled back down.
Failure to manage these scales correctly can lead to significant financial loss or protocol insolvency. Auditing these contracts requires verifying the scaling logic at every step of the calculation to ensure precision is maintained throughout.