diff --git a/src/MetaMorpho.sol b/src/MetaMorpho.sol index 68caf89f..9b4bd871 100644 --- a/src/MetaMorpho.sol +++ b/src/MetaMorpho.sol @@ -123,19 +123,19 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph /* MODIFIERS */ - /// @dev Reverts if the caller doesn't have the curator's privilege. - modifier onlyCurator() { + /// @dev Reverts if the caller doesn't have the curator role. + modifier onlyCuratorRole() { address sender = _msgSender(); - if (sender != curator && sender != owner()) revert ErrorsLib.NotCurator(); + if (sender != curator && sender != owner()) revert ErrorsLib.NotCuratorRole(); _; } - /// @dev Reverts if the caller doesn't have the allocator's privilege. - modifier onlyAllocator() { + /// @dev Reverts if the caller doesn't have the allocator role. + modifier onlyAllocatorRole() { address sender = _msgSender(); if (!isAllocator[sender] && sender != curator && sender != owner()) { - revert ErrorsLib.NotAllocator(); + revert ErrorsLib.NotAllocatorRole(); } _; @@ -251,7 +251,7 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph /* ONLY CURATOR FUNCTIONS */ /// @notice Submits a `newSupplyCap` for the market defined by `marketParams`. - function submitCap(MarketParams memory marketParams, uint256 newSupplyCap) external onlyCurator { + function submitCap(MarketParams memory marketParams, uint256 newSupplyCap) external onlyCuratorRole { Id id = marketParams.id(); if (marketParams.loanToken != asset()) revert ErrorsLib.InconsistentAsset(id); if (MORPHO.lastUpdate(id) == 0) revert ErrorsLib.MarketNotCreated(); @@ -273,7 +273,7 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph /// @notice Sets `supplyQueue` to `newSupplyQueue`. /// @dev The supply queue can be a set containing duplicate markets, but it would only increase the cost of /// depositing to the vault. - function setSupplyQueue(Id[] calldata newSupplyQueue) external onlyAllocator { + function setSupplyQueue(Id[] calldata newSupplyQueue) external onlyAllocatorRole { for (uint256 i; i < newSupplyQueue.length; ++i) { if (config[newSupplyQueue[i]].cap == 0) revert ErrorsLib.UnauthorizedMarket(newSupplyQueue[i]); } @@ -289,7 +289,7 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph /// vault so the call to `sortWithdrawQueue` can be griefed by a frontrun. To circumvent this, the allocator can /// simply bundle a reallocation that withdraws max from this market with a call to `sortWithdrawQueue`. /// @param indexes The indexes of each market in the previous withdraw queue, in the new withdraw queue's order. - function sortWithdrawQueue(uint256[] calldata indexes) external onlyAllocator { + function sortWithdrawQueue(uint256[] calldata indexes) external onlyAllocatorRole { uint256 newLength = indexes.length; uint256 currLength = withdrawQueue.length; @@ -333,7 +333,7 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph /// token of the market is the same as the vault's asset. function reallocate(MarketAllocation[] calldata withdrawn, MarketAllocation[] calldata supplied) external - onlyAllocator + onlyAllocatorRole { uint256 totalWithdrawn; for (uint256 i; i < withdrawn.length; ++i) { diff --git a/src/libraries/ErrorsLib.sol b/src/libraries/ErrorsLib.sol index 1370ebe3..fe16ec44 100644 --- a/src/libraries/ErrorsLib.sol +++ b/src/libraries/ErrorsLib.sol @@ -11,11 +11,11 @@ library ErrorsLib { /// @notice Thrown when the address passed is the zero address. error ZeroAddress(); - /// @notice Thrown when the caller doesn't have the curator's privilege. - error NotCurator(); + /// @notice Thrown when the caller doesn't have the curator role. + error NotCuratorRole(); - /// @notice Thrown when the caller doesn't have the allocator's privilege. - error NotAllocator(); + /// @notice Thrown when the caller doesn't have the allocator role. + error NotAllocatorRole(); /// @notice Thrown when the caller is not the guardian. error NotGuardian(); diff --git a/test/forge/RoleTest.sol b/test/forge/RoleTest.sol index d2c1ec90..033c2a24 100644 --- a/test/forge/RoleTest.sol +++ b/test/forge/RoleTest.sol @@ -75,18 +75,18 @@ contract RoleTest is IntegrationTest { vm.stopPrank(); } - function testCuratorFunctionsShouldRevertWhenNotCuratorAndNotOwner(address caller) public { + function testCuratorFunctionsShouldRevertWhenNotCuratorRole(address caller) public { vm.assume(caller != vault.owner() && caller != vault.curator()); vm.startPrank(caller); - vm.expectRevert(ErrorsLib.NotCurator.selector); + vm.expectRevert(ErrorsLib.NotCuratorRole.selector); vault.submitCap(allMarkets[0], CAP); vm.stopPrank(); } - function testAllocatorFunctionsShouldRevertWhenNotAllocatorAndNotCuratorAndNotOwner(address caller) public { + function testAllocatorFunctionsShouldRevertWhenNotAllocatorRole(address caller) public { vm.assume(!vault.isAllocator(caller)); vm.startPrank(caller); @@ -95,13 +95,13 @@ contract RoleTest is IntegrationTest { MarketAllocation[] memory allocation; uint256[] memory withdrawQueueFromRanks; - vm.expectRevert(ErrorsLib.NotAllocator.selector); + vm.expectRevert(ErrorsLib.NotAllocatorRole.selector); vault.setSupplyQueue(supplyQueue); - vm.expectRevert(ErrorsLib.NotAllocator.selector); + vm.expectRevert(ErrorsLib.NotAllocatorRole.selector); vault.sortWithdrawQueue(withdrawQueueFromRanks); - vm.expectRevert(ErrorsLib.NotAllocator.selector); + vm.expectRevert(ErrorsLib.NotAllocatorRole.selector); vault.reallocate(allocation, allocation); vm.stopPrank(); diff --git a/test/metamorpho_tests.tree b/test/metamorpho_tests.tree index 115146c3..d7aa0193 100644 --- a/test/metamorpho_tests.tree +++ b/test/metamorpho_tests.tree @@ -160,7 +160,7 @@ . └── submitCap(MarketParams memory marketParams, uint256 newSupplyCap) external ├── when msg.sender not owner or curator - │ └── revert with NotCurator() + │ └── revert with NotCuratorRole() └── when msg.sender is owner or curator ├── when marketParams.loanToken != asset() │ └── revert with InconsistentAsset() @@ -212,7 +212,7 @@ . └── setSupplyQueue(Id[] calldata newSupplyQueue) external ├── when msg.sender not owner or curator or allocator - │ └── revert with NotAllocator() + │ └── revert with NotAllocatorRole() └── when msg.sender is owner or curator or allocator ├── when some markets of newSupplyQueue have a zero cap │ └── revert with UnauthorizedMarket() @@ -223,7 +223,7 @@ . └── sortWithdrawQueue(uint256[] calldata indexes) external ├── when msg.sender not owner or curator or allocator - │ └── revert with NotAllocator() + │ └── revert with NotAllocatorRole() └── when msg.sender is owner or curator or allocator ├── when indexes contains a duplicate market │ ├── it should compute the id of the duplicate market @@ -243,7 +243,7 @@ └── reallocate(MarketAllocation[] calldata withdrawn, MarketAllocation[] calldata supplied) external ├── external ├── when msg.sender not owner or curator or allocator - │ └── revert with NotAllocator() + │ └── revert with NotAllocatorRole() └── when msg.sender is owner or curator or allocator ├── for each market withdrawn[i] from withdrawn │ ├── it should withdraw withdrawn[i].assets or withdrawn[i].shares