RToken::mint should mint the amountScaled as opposed to the amount. This doesn't work with the interest accrual mechanism.
The mint function mints the raw amount instead of the scaled amount:
Example scenario:
User A deposits 100 USDC when index = 1.0
Receives 100 RTokens
User B deposits 100 USDC when index = 1.1
Should receive ~90.91 RTokens (100/1.1)
Currently receives 100 RTokens
Result: User B's tokens represent more value at deposit, despite the same deposit time, because the value of their RTokens will be 100 * 1.1 = 110, but in reality, the function should mint the scaled amout so that when scaled up by the interest, the RTokens equal the amount being minted at whatever time they were minted.
Also, just to reitorate how clearly this is wrong, RToken::balanceOf
perfectly verifies this finding.
As you can see, when balanceOf is done, it is the users token balance scaled by the liquidity index.
Therefore, going back to the original example, User A now rightfully has 110 tokens due to interest accrual, yet User B also has 110 tokens, but they haven't deposited for nearly as long as A. This mechanism is unfair and breaks basic logic.
Favours later users over previous, a user can use the instant increase in token value upon deposit to withdraw an amount greater than the amount they initially inputted into the protocol.
This is because balanceOf considers the interest accrual. So a user could mint tokens (which is a process that doesn't consider interest accrual), than have a greater balance immediately (due to interest accrual), then use their inflated balance to withdraw more tokens than they deposited. So a user could extract all the underlying assets if liquidityIndex > 1.
Manual review
Mint the scaled amount
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.