The withdraw function in the ReserveLibrary returns incorrect values, specifically for the amountWithdrawn, amountScaled, and amountUnderlying parameters. This can inconsistent state and incorrect data being used by the calling contract (LendingPool in this case).
The withdraw function calculates and uses different amounts for internal operations, but the returned values do not accurately reflect these amounts. Specifically:
amountWithdrawn: This should represent the actual amount of underlying asset withdrawn by the user.
amountScaled: This should be the scaled amount of RTokens burned. However, the current implementation returns an intermediate amount.
amountUnderlying: This should represent the actual burned amount of RTokens in underlying asset units.
Inaccurate Data Reporting: The incorrect return values can lead to confusion and incorrect data being used by the LendingPool contract when processing withdrawals.
Potential for Errors in LendingPool: The LendingPool contract relies on the return values of the withdraw function. If these values are incorrect, it could lead to errors in the LendingPool's logic, potentially affecting user balances or the protocol's overall state.
Correct Return Values: Change the withdraw function to return the 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.