The RAAC protocol takes from AAVE's self-indexing tokens, and as AAVE overwrites the RToken and DebtToken internal balanceOf() and totalSupply() functions, so that when queried they return the normalized amount (i.e. including the interest), instead of showing the scaled one. However, in DebtToken, the protocol incorrectly double-scales the return value. This leads to setting an incorrect reserve.totalUsage value, which in turn leads to calculating incorrect liquidity and borrowing rates.
Whenever new loans are taken, DebtTokens are being minted, and each mint, the reserve.totalUsage variable is updated with the scaled amount of circulating tokens. The same happens when, the tokens are being burned, the new totalSupply is returned and is again set as the reserve.totalUsage
However, when returning totalSupply(), the DebtToken incorrectly uses rayDIv, instead of rayMul, which returns a lower value of tokens than what is currently in the system:
This means that the reserve.totalUsage is set to an incorrect value, meaning that afterward all interest rate calculations in the ReserveLibrary will be incorrectly set, leading to wrong protocol accounting.
Invalid reserve.totalUsage, leading to invalid calculations of interest rates in the protocol
Manual review
Change the rayDiv in DebtToken::totalSupply() to rayMul as done in the RToken function.
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.