Vault cannot be added back into the vault registry
When removing a vault from the registry, all states related to the vaults such as the `_vaults`, `_assets`, `_vaultsByAsset` are cleared except the `_vaultsByType` state.\\n```\\n    function removeVault(address vaultAddress) external onlyUpdater {\\n        Errors.verifyNotZero(vaultAddress, "vaultAddress");\\n\\n        // remove from vaults list\\n        if (!_vaults.remove(vaultAddress)) revert VaultNotFound(vaultAddress);\\n\\n        address asset = ILMPVault(vaultAddress).asset();\\n\\n        // remove from assets list if this was the last vault for that asset\\n        if (_vaultsByAsset[asset].length() == 1) {\\n            //slither-disable-next-line unused-return\\n            _assets.remove(asset);\\n        }\\n\\n        // remove from vaultsByAsset mapping\\n        if (!_vaultsByAsset[asset].remove(vaultAddress)) revert VaultNotFound(vaultAddress);\\n\\n        emit VaultRemoved(asset, vaultAddress);\\n    }\\n```\\n\\nThe uncleared `_vaultsByType` state will cause the `addVault` function to revert when trying to add the vault back into the registry even though the vault does not exist in the registry anymore.\\n```\\n    if (!_vaultsByType[vaultType].add(vaultAddress)) revert VaultAlreadyExists(vaultAddress);\\n```\\n
Clear the `_vaultsByType` state when removing the vault from the registry.\\n```\\n        function removeVault(address vaultAddress) external onlyUpdater {\\n            Errors.verifyNotZero(vaultAddress, "vaultAddress");\\n// Add the line below\\n            ILMPVault vault = ILMPVault(vaultAddress);\\n// Add the line below\\n            bytes32 vaultType = vault.vaultType();\\n\\n            // remove from vaults list\\n            if (!_vaults.remove(vaultAddress)) revert VaultNotFound(vaultAddress);\\n\\n            address asset = ILMPVault(vaultAddress).asset();\\n\\n            // remove from assets list if this was the last vault for that asset\\n            if (_vaultsByAsset[asset].length() == 1) {\\n                //slither-disable-next-line unused-return\\n                _assets.remove(asset);\\n            }\\n\\n            // remove from vaultsByAsset mapping\\n            if (!_vaultsByAsset[asset].remove(vaultAddress)) revert VaultNotFound(vaultAddress);\\n// Add the line below\\n           if (!_vaultsByType[vaultType].remove(vaultAddress)) revert VaultNotFound(vaultAddress);\\n\\n            emit VaultRemoved(asset, vaultAddress);\\n        }\\n```\\n
The `addVault` function is broken in the edge case when the updater tries to add the vault back into the registry after removing it. It affects all the operations of the protocol that rely on the vault registry.
```\\n    function removeVault(address vaultAddress) external onlyUpdater {\\n        Errors.verifyNotZero(vaultAddress, "vaultAddress");\\n\\n        // remove from vaults list\\n        if (!_vaults.remove(vaultAddress)) revert VaultNotFound(vaultAddress);\\n\\n        address asset = ILMPVault(vaultAddress).asset();\\n\\n        // remove from assets list if this was the last vault for that asset\\n        if (_vaultsByAsset[asset].length() == 1) {\\n            //slither-disable-next-line unused-return\\n            _assets.remove(asset);\\n        }\\n\\n        // remove from vaultsByAsset mapping\\n        if (!_vaultsByAsset[asset].remove(vaultAddress)) revert VaultNotFound(vaultAddress);\\n\\n        emit VaultRemoved(asset, vaultAddress);\\n    }\\n```\\n