The OperatorVCS::removeVault contains the logic for removing a vault that has been previously queued. This function can be called by anyone without restriction. The actual removal is done by calling the OperatorVault::exitVault function on the vault being removed.
According to the Natspec (https://github.com/Cyfrin/2024-09-stakelink/blob/f5824f9ad67058b24a2c08494e51ddd7efdbb90b/contracts/linkStaking/OperatorVault.sol#L219) comment in the OperatorVault::exitVault function, updateDeposits must be called before exitVault.This ensures that the vault's state is up-to-date before it's removed. However, the OperatorVCS::removeVault function is missing to call updateDeposits before calling exitVault. This means the vault's state isn't current when it's removed leading to incorrect accounting of rewards and deposits when removing a vault.
Add this test in operator-vault.test.ts and run yarn test
Calling updateDeposits before calling exitVault is necessary to update the vault's accounting for rewards earned since the last update. This ensures that all earned rewards are credited to the vault before the vault is exited. Calling _updateStrategyRewards alone will only credit the strategy and not the individual vaults. The OperatorVCS::removeVault function does not call updateDeposits before calling exitVault. This leads to incorrect accounting of rewards and deposits when removing a vault.
Manual review
Call the updateDeposit before the IOperatorVault(vault).exitVault() call in the OperatorVCS::removeVault.
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.