Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Invalid

Interest Calculation Discrepancy Between Lenders and Borrowers

Summary

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.

Impact

  • 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.

Vulnerable Functions

  1. calculateLinearInterest(uint256 rate, uint256 timeDelta, uint256 lastIndex)

    • Uses a simple linear formula:

      uint256 cumulatedInterest = rate * timeDelta;
      cumulatedInterest = cumulatedInterest / SECONDS_PER_YEAR;
      return WadRayMath.RAY + cumulatedInterest;
    • This does not compound the interest, leading to a mismatch when compared with the borrower-side calculations.

  2. calculateCompoundedInterest(uint256 rate, uint256 timeDelta)

    • Uses a Taylor series expansion to approximate compound interest:

      uint256 ratePerSecond = rate.rayDiv(SECONDS_PER_YEAR);
      uint256 exponent = ratePerSecond.rayMul(timeDelta);
      return WadRayMath.rayExp(exponent);
    • This results in compounded interest, making the effective rate differ from the lenders' linear rate.

Root Cause

  • The protocol applies linear interest for lenders while using compounded interest for borrowers.

Reproduction Steps

  1. Set rate = 10% (expressed in RAY) and timeDelta = 1 year.

  2. Compute calculateLinearInterest(rate, timeDelta, lastIndex).

  3. Compute calculateCompoundedInterest(rate, timeDelta).

  4. Compare results: The compounded interest will typically be higher than the linear interest.

Recommendation : Use the Same Interest Calculation Method

  • Ensure that both lender and borrower interest use the same formula (preferably compounded).

  • Update calculateLinearInterest to use WadRayMath.rayExp to match calculateCompoundedInterest.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!