During the withdraw and borrow operations, the LendingPool attempts to ensure sufficient liquidity by withdrawing funds from the curveVault. However, the current implementation contains a logical flaw that causes the transaction to revert.
A user attempts to withdraw 100 assets from the LendingPool.
The reserveRTokenAddress only holds 90 assets.
The _ensureLiquidity function withdraws the missing 10 assets from the curveVault and sends them directly to the msg.sender.
The ReserveLibrary.withdraw function then attempts to withdraw 100 assets from the reserveRTokenAddress, which will revert because only 90 assets remain.
The _ensureLiquidity function does not account for the fact that the withdrawn funds from the curveVault are sent directly to the user, rather than being added to the reserveRTokenAddress. As a result, the subsequent withdrawal from reserveRTokenAddress fails due to insufficient balance.
Incorrect Accounting: The logic fails to properly account for the liquidity adjustment, leading to a mismatch between expected and actual balances.
Transaction Reverts: The withdrawal operation will always revert when additional liquidity is required from the curveVault, rendering the function unusable in such cases.
Manual review.
Modify the _ensureLiquidity function to ensure the withdrawn funds from the curveVault are added to the reserveRTokenAddress before proceeding with the withdrawal.
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.