In DebtToken::totalSupply , the total supply is incorrectly calculated by dividing an already scaled total supply value by the usage index. This results in an incorrect total supply value, which can lead to miscalculations in the contract's logic, particularly in functions that rely on the accurate total supply of debt tokens.
DebtToken::totalSupply contains the following code:
The actual totalsupply is derived in this function by dividing an already scaled total supply value by the usage index. It is already scaled because when a user borrows a token via LendingPool::borrow, they are minted DebtTokens and in the flow of DebtToken::mint , the overriden DebtToken::_update function is called which normalizes the amount of tokens minted before upating the user's balance. See below:
As a result, when the totalSupply is retrieved, it should be multiplied by the current usageIndex to get the actual total supply which isnt the case as seen above.
This test was run in protocols-test.js in the "StabilityPool" describe block
Incorrect Total Supply: The totalSupply function returns an incorrect value, which is smaller than the actual total supply of debt tokens. This can lead to miscalculations in functions that rely on the total supply, such as interest accrual, liquidation, or stability pool calculations.
Miscalculations in Contract Logic: Functions that depend on the total supply (e.g., calculating interest rates, distributing rewards, or determining liquidation thresholds) may behave incorrectly, leading to financial losses or unintended behavior.
Manual Review, Hardhat
Fix the totalSupply Function: The totalSupply function should multiply the scaled total supply by the usage index instead of dividing it. Update the function as follows:
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.