contracts/core/tokens/DebtToken.sol
According to the specification comments, the borrowing and lending mechanism of the protocol aligns with Aave’s implementation, scaling deposit token balances by liquidity index and borrow balances by usage index, however the debt token minting logic deviates from aave’s implementation causing the DebtToken contract to mint more than expected thereby increasing the user’s debt token balance leading to overpayment.
Within Aave, debt tokens minted are only scaled by the reserve index which sets the exchange rate between the tokens and its underlying asset, during debt token minting and burning, if the new index results to an increase in the user’s balance, the new increment is emitted within a mint event.
Aave's implementation of scaled token mint function, logic used by both Atoken and debtTokens
However, within the RAAC Debt token contract, if there’s an increase in the debt token balance of a user between the last stored and current index, the increment is added to the amount to be minted to the user, this unduly increases the user’s debt causing the user to be overcharged during repayments
This implementation is wrong as not only does it deviates from Aave’s implementation, it also leads to loss of funds for borrowers, ideally the usage index should should set the exchange rate between the debt token and it’s underlying asset
Manual Review
Refactor the debt token minting logic to only emit balance increments between indices and not add them to the amount to be minted.
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.