diff --git a/src/MetaMorpho.sol b/src/MetaMorpho.sol index 97cdf6e9..9746434b 100644 --- a/src/MetaMorpho.sol +++ b/src/MetaMorpho.sol @@ -156,6 +156,7 @@ contract MetaMorpho is ERC4626, Ownable2Step, IMetaMorpho { function setFeeRecipient(address newFeeRecipient) external onlyOwner { require(newFeeRecipient != feeRecipient, ErrorsLib.ALREADY_SET); + require(newFeeRecipient != address(0) || fee == 0, ErrorsLib.ZERO_FEE_RECIPIENT); // Accrue interest to the previous fee recipient set before changing it. _updateLastTotalAssets(_accrueFee()); @@ -448,6 +449,8 @@ contract MetaMorpho is ERC4626, Ownable2Step, IMetaMorpho { } function _setFee(uint256 newFee) internal { + require(newFee == 0 || feeRecipient != address(0), ErrorsLib.ZERO_FEE_RECIPIENT); + // Safe "unchecked" cast because newFee <= WAD. fee = uint96(newFee); diff --git a/src/libraries/ErrorsLib.sol b/src/libraries/ErrorsLib.sol index b496e2ad..34468919 100644 --- a/src/libraries/ErrorsLib.sol +++ b/src/libraries/ErrorsLib.sol @@ -33,4 +33,6 @@ library ErrorsLib { string internal constant TIMELOCK_EXPIRATION_EXCEEDED = "timelock expiration exceeded"; string internal constant MAX_QUEUE_SIZE_EXCEEDED = "max queue size exceeded"; + + string internal constant ZERO_FEE_RECIPIENT = "fee recipient is zero"; }