The calculateCompoundedInterest function uses a Taylor series expansion for interest calculation, while calculateLinearInterest follows a simple linear formula. This inconsistency can cause the interest collected from borrowers to be insufficient (or excessive) to pay lenders, potentially leading to liquidity imbalances.
Underestimation of Interest: Due to precision loss and differences in calculation methods, the interest charged to borrowers may be lower than necessary, leading to insufficient liquidity for lenders.
Overestimation of Interest: In some scenarios, the compounded calculation may result in higher interest charged to borrowers, leading to unfair borrowing costs.
Potential Insolvency Risks: If interest collected from borrowers is insufficient to pay the promised returns to lenders, the protocol may face liquidity issues.
calculateLinearInterest(uint256 rate, uint256 timeDelta, uint256 lastIndex)
Uses a simple linear formula:
This does not compound the interest, leading to a mismatch when compared with the borrower-side calculations.
calculateCompoundedInterest(uint256 rate, uint256 timeDelta)
Uses a Taylor series expansion to approximate compound interest:
This results in compounded interest, making the effective rate differ from the lenders' linear rate.
The protocol applies linear interest for lenders while using compounded interest for borrowers.
Set rate = 10% (expressed in RAY) and timeDelta = 1 year.
Compute calculateLinearInterest(rate, timeDelta, lastIndex).
Compute calculateCompoundedInterest(rate, timeDelta).
Compare results: The compounded interest will typically be higher than the linear interest.
Ensure that both lender and borrower interest use the same formula (preferably compounded).
Update calculateLinearInterest to use WadRayMath.rayExp to match calculateCompoundedInterest.
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.