An issue exists in the transfer()
and transferFrom()
functions of RToken.sol, where token amounts are incorrectly scaled twice before being transferred. This results in users transferring fewer tokens than intended, leading to unexpected dust balances, failed full transfers or incorrect amount transferred to the recipient, and inefficient fund movements. This bug directly violates user expectations and disrupts accurate balance accounting.
The RToken contract integrates interest accrual through scaling, meaning balances and transfers should always adjust according to the reserve’s liquidityIndex
. This is done via _update()
, which already applies scaling to all operations.
This ensures that all mint, burn, and transfer operations correctly account for interest accrual, as already implied in the function NatSpec.
The transfer()
and transferFrom
functions each scales down via rayDiv()
the amount before calling super.transfer()
, which will eventually trigger _update()
, applying the same scaling down again.
The recipient receives less than the intended amount, and the sender is left with unexpected dust amounts. As a result,
This makes full transfers impossible without multiple transactions that's pretty much never ending.
It also makes sending exact amount to the recipient impossible.
The avid users could probably circumvent the issue by manually scaling up the intended recipient amount twice via rayMul()
prior to inputting amount
, but this pretty much breaks the intended functionality of the overriden transfer()
and transferFrom()
.
Users end up transferring fewer tokens than intended.
Dust balances accumulate, preventing full balance transfers.
Repeated transactions are required to clean up balances.
Confusing user experience due to unexpected discrepancies.
Breaks compatibility with external integrations expecting precise token transfers.
Manual
Consider implementing the following refactoring:
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.