The transfer functions in RToken
contract performs doble scaling of the provided amount resulting in recipients receiving incorrect amounts.
The protocol overrides the _update()
function in RToken contract as follows:
The comment states cleraly that this will be applied for all operations including transfers
.
The scaling done here is based on the current liquidityIndex
in the lendingpool returned by getNormalizedIncome()
and then the scaledAmount
is what the is sent to the to
address.
However, the protocol again defines _liquidityIndex
which is set to WadRayMath.RAY
during initialization.
Now when performing transfers, this _liquidityIndex
is first used as shown here:
The amount
provided is in underlying asset units
but gets scaled by the currect liquidityIndex
given by ILendingPool(_reservePool).getNormalizedIncome()
in transfer()
and the set _liquidityIndex
in transferFrom()
before being passed into the overriden transfer functions as scaledAmount
.
However, internally, these functions will invoke the _update()
function which again has been overriden as shown above.
As such, the amount gets scaled twice:
Before calling super.transfer()
and super.transferFrom()
functions
In the _update()
function that calls super._update()
The intended funtionality is to scale the amount in underlying units during transfer based on the liquidityIndex
. However, the double scaling results in the recipient of the transsfers ending up with incorrect amounts.
Manual Review
Scale once:
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.