The mint
function of the DebtToken contract incorrectly calculates the balanceIncrease
because it uses the balanceOf
function, which returns a scaled balance adjusted by the normalized debt. This leads to incorrect calculations of the balanceIncrease
, resulting in inaccurate debt tracking and potential over- or under-issuance of debt tokens.
Function: mint
Issue: Incorrect calculation of balanceIncrease
due to the use of balanceOf
, which returns a scaled balance.
Code Location:
https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/tokens/DebtToken.sol#L150
https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/tokens/DebtToken.sol#L223
Expected Behavior:
The balanceIncrease
should be calculated using the unscaled balance (i.e., the raw balance stored in the contract, not adjusted by the normalized debt). The correct calculation should use the scaledBalanceOf
function, which returns the unscaled balance.
https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/tokens/DebtToken.sol#L274
Actual Behavior:
The function uses balanceOf
, which returns a scaled balance, leading to incorrect balanceIncrease
calculations.
Root Cause:
The balanceOf
function returns a scaled balance adjusted by the normalized debt, while the balanceIncrease
calculation assumes an unscaled balance. This inconsistency results in incorrect calculations.
The formula would be
Incorrect balanceIncrease
:
The balanceIncrease
will be calculated incorrectly, leading to inaccurate adjustments to the user's debt balance.
User Trust:
Users may lose confidence in the protocol if they notice discrepancies in their debt balances or the protocol's financial reporting.
To fix this issue, the mint
function should use the scaledBalanceOf
function to retrieve the unscaled balance for calculating the balanceIncrease
.
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.