The calculateCompoundedInterest() function performs division before multiplication when calculating interest rates, leading to precision loss that compounds over time and results in incorrect borrowing rates.
In ReserveLibrary::calculateCompoundedInterest(), the rate per second is calculated by dividing the annual rate by seconds per year before multiplying by the time delta:
This approach loses precision because Solidity truncates decimal places during division. The loss is amplified because:
The result is used as an exponent in interest calculations
The error compounds over time as interest accrues
The precision loss affects all subsequent calculations that depend on the interest rate
Assume an annual rate of 5% (5e27 in RAY)
Current calculation:
Correct calculation:
The difference grows exponentially due to the exponent calculation
Borrowers receive incorrect interest rates that deviate from intended rates
Protocol calculations are inaccurate
Protocol will receive less than it should
Reorder operations to multiply before dividing:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.