The function _rebalanceLiquidity(), and _ensureLiquidity() are called during deposit(), withdraw() and borrow() to ensure enough liquidity for user operations. These functions deposit/withdraw the excess/needed liquidity from the curveUSD vault by using _depositIntoVault() and _withdrawFromVault(), both of which assumes that the input parameter amount is the curveUSD held by the LendingPool. But the lendingPool never holds the underlying asset but instead keep them in the RToken contract. This will cause reverts in the major functions when a curveUSDVault is set and break the core functionalities of the pool.
The amount is determined in _ensureLiquidity() and _rebalanceLiquidity(),
Both of them uses the crvUSD balance of the RToken contract, do calculations and pass the amount into the _depositIntoVault() and _withdrawFromVault() functions. The LendingPool will then try to deposit tokens which it does not have, or withdraw tokens into itself with shares it does not have.
The current implementation of the LendingPool cant interact with the curveUsdVault as it does not hold the liquidity. Setting the curveUsdVault address will break the contract.
Manual Review
Move the _depositIntoVault() and _withdrawFromVault() into the RToken contract, make them pull liquidity in and out of the RToken contracts, put the onlyReservePool modifier on both functions, and have the _ensureLiquidity() and _rebalanceLiquidity() functions call the RToken contract when liquidity is excess or needed.
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.