Skip to content

Commit

Permalink
refactor(revoke): rename revoke functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Nov 3, 2023
1 parent 2990c1f commit 9a17841
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
18 changes: 9 additions & 9 deletions src/MetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -399,24 +399,24 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph
/* ONLY GUARDIAN FUNCTIONS */

/// @notice Revokes the `pendingTimelock`.
function revokeTimelock() external onlyGuardian {
emit EventsLib.RevokeTimelock(_msgSender(), pendingTimelock);

function revokePendingTimelock() external onlyGuardian {
delete pendingTimelock;

emit EventsLib.RevokeTimelock(_msgSender());
}

/// @notice Revokes the `pendingGuardian`.
function revokeGuardian() external onlyGuardian {
emit EventsLib.RevokeGuardian(_msgSender(), pendingGuardian);

function revokePendingGuardian() external onlyGuardian {
delete pendingGuardian;

emit EventsLib.RevokeGuardian(_msgSender());
}

/// @notice Revokes the pending cap of the market defined by `id`.
function revokeCap(Id id) external onlyGuardian {
emit EventsLib.RevokeCap(_msgSender(), id, pendingCap[id]);

function revokePendingCap(Id id) external onlyGuardian {
delete pendingCap[id];

emit EventsLib.RevokeCap(_msgSender(), id);
}

/* EXTERNAL */
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/IMetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ interface IMetaMorpho is IERC4626 {

function submitTimelock(uint256 newTimelock) external;
function acceptTimelock() external;
function revokeTimelock() external;
function revokePendingTimelock() external;
function pendingTimelock() external view returns (uint192 value, uint64 submittedAt);

function submitCap(MarketParams memory marketParams, uint256 supplyCap) external;
function acceptCap(Id id) external;
function revokeCap(Id id) external;
function revokePendingCap(Id id) external;
function pendingCap(Id) external view returns (uint192 value, uint64 submittedAt);

function submitFee(uint256 newFee) external;
Expand All @@ -71,7 +71,7 @@ interface IMetaMorpho is IERC4626 {

function submitGuardian(address newGuardian) external;
function acceptGuardian() external;
function revokeGuardian() external;
function revokePendingGuardian() external;
function pendingGuardian() external view returns (address guardian, uint96 submittedAt);

function transferRewards(address) external;
Expand Down
12 changes: 6 additions & 6 deletions src/libraries/EventsLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ library EventsLib {
/// @notice Emitted when an `allocator` is set to `isAllocator`.
event SetIsAllocator(address indexed allocator, bool isAllocator);

/// @notice Emitted when a `pendingTimelock` is revoked by `guardian`.
event RevokeTimelock(address indexed guardian, PendingUint192 pendingTimelock);
/// @notice Emitted when the pending timelock is revoked by `guardian`.
event RevokeTimelock(address indexed guardian);

/// @notice Emitted when a `pendingCap` for the market identified by `id` is revoked by `guardian`.
event RevokeCap(address indexed guardian, Id indexed id, PendingUint192 pendingCap);
/// @notice Emitted when the pending cap of a market identified by `id` is revoked by `guardian`.
event RevokeCap(address indexed guardian, Id indexed id);

/// @notice Emitted when a `pendingGuardian` is revoked by `guardian`.
event RevokeGuardian(address indexed guardian, PendingAddress pendingGuardian);
/// @notice Emitted when the pending guardian is revoked by `guardian`.
event RevokeGuardian(address indexed guardian);

/// @notice Emitted when the `supplyQgueue` is set to `newSupplyQueue`.
event SetSupplyQueue(address indexed allocator, Id[] newSupplyQueue);
Expand Down
18 changes: 9 additions & 9 deletions test/forge/GuardianTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ contract GuardianTest is IntegrationTest {

vm.warp(block.timestamp + elapsed);

vm.expectEmit();
emit EventsLib.RevokeTimelock(GUARDIAN, IPending(address(vault)).pendingTimelock());
vm.expectEmit(address(vault));
emit EventsLib.RevokeTimelock(GUARDIAN);
vm.prank(GUARDIAN);
vault.revokeTimelock();
vault.revokePendingTimelock();

uint256 newTimelock = vault.timelock();
(uint256 pendingTimelock, uint64 submittedAt) = vault.pendingTimelock();
Expand All @@ -62,10 +62,10 @@ contract GuardianTest is IntegrationTest {

Id id = marketParams.id();

vm.expectEmit();
emit EventsLib.RevokeCap(GUARDIAN, id, IPending(address(vault)).pendingCap(id));
vm.expectEmit(address(vault));
emit EventsLib.RevokeCap(GUARDIAN, id);
vm.prank(GUARDIAN);
vault.revokeCap(id);
vault.revokePendingCap(id);

(uint192 newCap, uint64 withdrawRank) = vault.config(id);
(uint256 pendingCap, uint64 submittedAt) = vault.pendingCap(id);
Expand All @@ -86,10 +86,10 @@ contract GuardianTest is IntegrationTest {

vm.warp(block.timestamp + elapsed);

vm.expectEmit();
emit EventsLib.RevokeGuardian(GUARDIAN, IPending(address(vault)).pendingGuardian());
vm.expectEmit(address(vault));
emit EventsLib.RevokeGuardian(GUARDIAN);
vm.prank(GUARDIAN);
vault.revokeGuardian();
vault.revokePendingGuardian();

address newGuardian = vault.guardian();
(address pendingGuardian, uint96 submittedAt) = vault.pendingGuardian();
Expand Down
6 changes: 3 additions & 3 deletions test/metamorpho_tests.tree
Original file line number Diff line number Diff line change
Expand Up @@ -289,23 +289,23 @@


.
└── revokeTimelock() external
└── revokePendingTimelock() external
├── when msg.sender not guardian
│ └── revert with NotGuardian()
└── when msg.sender is guardian
├── it should emit RevokeTimelock(msg.sender, pendingTimelock)
└── it should delete pendingTimelock

.
└── revokeCap(Id id) external
└── revokePendingCap(Id id) external
├── when msg.sender not guardian
│ └── revert with NotGuardian()
└── when msg.sender is guardian
├── it should emit RevokeCap(msg.sender, id, pendingCap[id])
└── it should delete pendingCap[id]

.
└── revokeGuardian() external
└── revokePendingGuardian() external
├── when msg.sender not guardian
│ └── revert with NotGuardian()
└── when msg.sender is guardian
Expand Down

0 comments on commit 9a17841

Please sign in to comment.