The LendingPool contract contains incorrect logic in its liquidity management , specifically in the _depositIntoVault function. The issue arises because the contract attempts to deposit funds into the Curve Vault directly from address(this), which does not hold any crvUSD tokens. Instead, all crvUSD tokens are held in the reserve.reserveRTokenAddress. This mismatch in token ownership can lead to failed transactions, incorrect accounting, and potential loss of funds.
In the _depositIntoVault function of the LendingPool contract:
The contract assumes that address(this) holds the crvUSD tokens, but in reality, all crvUSD tokens are stored in reserve.reserveRTokenAddress. Since address(this) does not hold the tokens, the deposit call to the Curve Vault will fail, leading to transaction reverts and potential disruptions in the protocol's liquidity management.
Initial State:
reserve.reserveRTokenAddress holds 1000 crvUSD.
address(this) holds 0 crvUSD.
totalVaultDeposits is 0.
Action:
A user calls deposit with 500 crvUSD.
The _rebalanceLiquidity function is triggered, which calls _depositIntoVault to deposit 500 crvUSD into the Curve Vault.
Expected Behavior:
The Curve Vault should receive 500 crvUSD from reserve.reserveRTokenAddress.
totalVaultDeposits should be updated to 500.
Actual Behavior:
The deposit call fails, and the transaction reverts.
User deposits crvUSD into the lending pool to mint rTokens.
In the deposit, transfer all assets from the caller to the RToken contract and mint RToken for the caller.
After that, _rebalanceLiquidity() is called. 20% will remain in the reserve.reserveAssetAddress, and the excess will be deposited into the Curve vault, but this function reverts due to incorrect logic in _depositIntoVault, which assumes that crvUSD is held by the address this.
All deposits are getting blocked, which means the _rebalanceLiquidity() function is reverting the transaction.
Manual Review
To fix the issue, the _depositIntoVault function should be modified to transfer crvUSD from reserve.reserveRTokenAddress to the Curve Vault.
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.