The deposit
function in the ReserveLibrary.sol
contract receiving the return values incorrectly processes amountScaled
as the amountToMint
. It causes discrepancies in the interest calculations and could undermine the 1:1 value ratio between RToken and the underlying asset.
Core Issue
Mint Return Values: The mint
function in the RToken.sol
contract returns four values: isFirstMint
, amountToMint
, totalSupply()
, and amountScaled
. However, the ReserveLibrary.sol
library receiving the return values mistakenly processes amountToMint
as amountScaled
and vice versa.
Incorrect Return Value Handling: In the ReserveLibrary
, the mint function’s return values are captured as follows:
contracts/libraries/pools/ReserveLibrary.sol:deposit#L337
Incorrect Minting Process: The current implementation leads to a situation where the ReserveLibrary
uses the wrong amount (amountScaled
) for further calculations. This may cause erroneous token minting, violating the 1:1 peg between RToken and the underlying asset.
Excessive Minting: Since amountMinted
uses the incorrect value (amountScaled
), users may mint more RToken tokens than expected, leading to an imbalance in the supply and demand for the token. This could potentially result in an overvaluation of the RToken and an incorrect interest distribution.
Liquidity Pool Discrepancy: Misusing the wrong minted amount can cause issues in the liquidity pool, where the amount of underlying assets may not match the minted RToken, leading to a potential misalignment in the platform’s assets and liabilities.
Manual code review
It is recommended to revise return value Handling to ensure that the deposit
function in the ReserveLibrary
contract receive correct return values of amountScaled
and amountUnderlying
from the mint
function in the RToken.sol
contract.
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.