The RToken.mint() function is called when a user deposits reserve tokens into the protocol. However, the the amountToMint it returns and emited in Deposit event is incorrect.
When users deposit reserve tokens via LendingPool.deposit(), they specify the amount of reserve tokens to they intend to supply.
It invokes ReserveLibrary.deposit() which does the following:
Now in RToken.mint(), this amount is passed down as amountToMint and now notice the values it returns and their order:
Now, the amountToMint in underlying units is scaled into amountScaled. The function the calls _mint() with this value then returns the same amountToMint as the second return value. This is not right:
When _mint() is called with amountScaled, it internally calls _update() function which is overriden here as follows:
As seen, it first scaled the provided amount by the current liquidityIndex then mints the result to the user. So, actually the amount of RTokens minted to the user is not amountToMint but amountScaled calculated in mint() above.
Now, when mint() returns amountToMint as the second return value, this becomes amountScaled in ReserveLibrary.deposit(). The amountMinted there is then set to this amountScaled and Deposit event emited and it further returns amountToMint which is again used in LendingPool.deposit() in Deposit event.
According to the comment given:
// amountMinted The amount of RTokens minted.
Therefore, the returned value fromRToken.mint()is incorrect.
External users who depend on these events receive inaccurate information about the actual amount of RTokens minted to users in exchange for their deposits.
Manual Review
Modify the RToken.mint() to return correct values:
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.