Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(metamorpho): cannot unset fee recipient if fee > 0 #81

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/MetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/libraries/ErrorsLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Loading