When transferring RTokens, the real value of underlying amount will be calculated by dividing normalized income. But this is done twice for all transfer, causing loss of funds for user.
Here in transfer, we can see scaled amount is derived by dividing amount by normalized income:
But in _update:
This is done again. This raises one issue, since RToken inherits OZ's ERC20 contract, and in the parent contract, both transfer and transferFrom will internally call _transfer:
And _transfer also calls _update to update accounting of token:
So, this means both RToken::transfer and RToken::transferFrom will call _update anyway, but in transfer, for instance, the transferred amount is scaled already when passing to super.transfer, which will later reach _update, and gets scaled again. This will result in incorrect transfer of amount, and gain or loss for users depending on the normalized income value.
If normalized income is less than 1, more tokens will be transferred, and vice versa.
Manual review.
Since amount is scaled already in _update, remove those in transfer and transferFrom.
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.