When calculating DebtToken's totalSupply, scaledSupply is divided by reserve.usageIndex. However, correct amount would be scaledSupply * reserve.usageIndex. This inconsistency affects calculation of reserve's utilizationRate, currentUsageRateand currentLiquidityRate. Thus, all three important calculations will be incorrect.
DebtToken's totalSupply is calculated as the following:
In other words:
However, individual account's debt is calculated differently:
In other words, account's balance is calculated as the following:
Indeed, multiplication is the correct operation. Because when DebtToken is minted or burned, scaledAmount is calculated as amount / reserve.usageIndex:
To make it very clear, the following equation holds:
which implies that
Thus, account balance and total supply should be multiplied by reserve.usageIndex
reserve.totalUsage is equal to DebtToken's totalSupply. You can confirm that in borrow, repay and liquidation logic.
reserve.totalUsage is equal to pool's total debt. And pool's totalDebt takes part in calculating utilizationRate
And utilizationRate takes part in calculating currentUsageRate and currentLiquidityRate.
Thus important parameters will be calculated incorrectly and protocol will suffer from fund loss and reputation damage.
More specifically:
totalSupply is deflated
utilzationRate, is deflated
Thus borrowRate will be lower when actual utilizationRate is greater than optimizationUtilizationRate
Manual Review
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.