In the RToken::mint
function, the logic to calculate balanceIncrease may produce an incorrect result when the user’s RToken balance has changed due to transfers. Specifically, if a user has never interacted with the protocol but receives RToken via a transfer, _userState[onBehalfOf].index
is still zero, so balanceIncrease is never calculated.
Since balanceIncrease
depends on comparing the current index to a previous index, any user who has an index set to zero will skip this calculation. This means if they received RToken through a transfer, their effective previous index is never updated, leading to a potential mismatch whenever the protocol tries to calculate interest-based increases.
Although balanceIncrease is not currently used by other parts of the contract, it represents a clearly incorrect implementation. This could become problematic if future protocol features rely on balanceIncrease.
Manual Code Review and Foundry
Update the mint function to handle the case where _userState[onBehalfOf].index is zero but the user has received RToken via transfers.
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.