The mint function in DebtToken incorrectly calculates totalUsage by dividing by the index instead of multiplying, leading to an underestimation of total debt.
Additionally, the balanceIncrease logic artificially inflates totalUsage, causing excessive interest accumulation.
This results in distorted protocol-wide debt metrics, potential borrower overcharging, incorrect lending rates, and overall protocol instability.
Below provided code is for testing purpose only & the original rectified version is in the Recommendations section.
Replace the existing DebtToken::mint with the below code snippet.
also we have used 2e27 & 4e27 just for testing purpose to show what happens if index increases. The code will still behave in same fashion if increment is small.
Now paste the below snippet code in LendingPool.test.js
As console.log reveals :
When borrowed 100 crvUSD, @2e27 index, totalUsage only increases by the borrowed amount, but interest accrual isn't properly reflected. Instead of dividing totalUsage by the ongoing index, it should be multiplied to correctly track the total debt (principal + interest).
Incorrect Approach (Dividing)
Correct Approach (Multiplying)
When borrowing 100 crvUSD @4e27, after a prior borrow of 100 crvUSD @2e27 & rectifying the rayDiv as mentioned above via rayMul, totalUsage is incorrectly inflated to 700. This overestimation occurs due to the improper handling of interest accrual in balanceIncrease:
Issue: balanceIncrease applies an unnecessary multiplication with both the new and old index, then subtracts them, artificially compounding interest accrual and leading to an inflated debt amount.
Incorrect Approach (With balanceIncrease)
Borrow 100 @4e27, resulting in:
Total Borrowed: 100 @2e27 + 100 @4e27 = 200 crvUSD
Interest Accrued (Incorrectly Calculated): 500 crvUSD
Final totalUsage = 700 (Excessive and Incorrect)
Correct Approach (Without balanceIncrease)
Borrow 100 @4e27, leading to:
Total Borrowed: 200 crvUSD
Interest Accrued (Correctly Calculated): 100 crvUSD
Final totalUsage = 300 (Accurate Debt Representation)
Multiplying by the index ensures totalUsage reflects both the borrowed amount and accumulated interest, preventing underestimation of utilization(a.k.a utilizationRatio), interest rates(currentUsageRate & currentLiquidityRate), and liquidity growth(usageIndex & liquidityIndex).
Overestimated totalUsage inflates protocol-wide debt metrics, leading to incorrect economic assumptions, potential borrower overcharging due to excessive interest accumulation, miscalculated lending rates causing inefficiencies in capital allocation, and protocol instability as total debt does not match actual borrowed amounts.
Manual Review
Remove the balanceIncrease logic entirely to prevent artificial inflation of totalUsage.
Ensure totalUsage is updated correctly by multiplying by the ongoing index rather than 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.