The totalSupply function in the DebtToken contract is incorrectly computing the total supply due to improper usage of rayDiv. This causes the reported supply to be significantly lower than expected. In contrast, the balanceOf function correctly applies rayMul for individual balances. The discrepancy leads to misrepresented token supply, which can affect contract functions that rely on accurate supply calculations.
Issue:
The totalSupply function applies rayDiv when adjusting the scaled total supply:
This incorrectly reduces the supply value, making it much smaller than intended. Meanwhile, the balanceOf function correctly scales balances using rayMul. Instead of rayDiv, the total supply calculation should be based on multiplying by the normalized debt.
Affected Code:
The incorrect scaling method distorts the total supply figure, impacting the accuracy of token-related metrics.
Underreported Total Supply:
The contract returns a lower total supply than the actual circulating amount, leading to misaligned calculations for liquidity, borrowing rates, and valuation.
Potential Financial Implications:
Functions relying on an accurate supply, such as token distribution, interest calculations, and reserves, may be affected, leading to imbalances.
Discrepancies in Token Metrics:
Incorrect supply representation may mislead users and external systems relying on this data, potentially causing integration issues.
Manual Code Review
Fix the Total Supply Calculation:
Update totalSupply to correctly scale the value using rayMul instead of rayDiv:
Ensure Consistency in Scaling Logic:
Align the scaling logic in both balanceOf and totalSupply to ensure uniform calculations across the contract.
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.