Summary
The protocol withdraws from vault wrongly.
Vulnerability Details
LendingPool.sol#_withdrawFromVault() function is as follows.
function _withdrawFromVault(uint256 amount) internal {
@> curveVault.withdraw(amount, address(this), msg.sender, 0, new address[](0));
totalVaultDeposits -= amount;
}
As we can see above, it removes user(msg.sender)'s curve token and receives assets to this contract.
Here, ICurveCrvUSDVault.sol#withdraw() function is as follows.
* @notice Withdraws assets from the vault
* @param assets Amount of assets to withdraw
* @param receiver Address to receive the assets
* @param owner Owner of the shares
* @param maxLoss Maximum acceptable loss in basis points
* @param strategies Optional specific strategies to withdraw from
* @return shares Amount of shares burned
*/
function withdraw(
uint256 assets,
address receiver,
address owner,
uint256 maxLoss,
address[] calldata strategies
) external returns (uint256 shares);
This is error.
Rebalancing does only interacts between this contract and curveVault.
Impact
This vulnerability causes revert or user's loss.
Tools Used
Manual review
Recommendations
Modify LendingPool.sol#_withdrawFromVault function as follows.
* @notice Internal function to withdraw liquidity from the Curve vault
* @param amount The amount to withdraw
*/
function _withdrawFromVault(uint256 amount) internal {
-- curveVault.withdraw(amount, address(this), msg.sender, 0, new address[](0));
++ curveVault.withdraw(amount, reserve.reserveRTokenAddress, address(this), 0, new address[](0));
totalVaultDeposits -= amount;
}