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

refactor(revoke): rename revoke functions #305

Merged
merged 3 commits into from
Nov 6, 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
18 changes: 9 additions & 9 deletions src/MetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -405,24 +405,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.RevokePendingTimelock(_msgSender());
}

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

function revokePendingGuardian() external onlyGuardian {
delete pendingGuardian;

emit EventsLib.RevokePendingGuardian(_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.RevokePendingCap(_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
6 changes: 3 additions & 3 deletions src/libraries/EventsLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ library EventsLib {
event SetIsAllocator(address indexed allocator, bool isAllocator);

/// @notice Emitted when a `pendingTimelock` is revoked.
event RevokeTimelock(address indexed caller, PendingUint192 pendingTimelock);
event RevokePendingTimelock(address indexed caller);

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

/// @notice Emitted when a `pendingGuardian` is revoked.
event RevokeGuardian(address indexed caller, PendingAddress pendingGuardian);
event RevokePendingGuardian(address indexed caller);

/// @notice Emitted when the `supplyQgueue` is set to `newSupplyQueue`.
event SetSupplyQueue(address indexed caller, Id[] newSupplyQueue);
Expand Down
24 changes: 12 additions & 12 deletions test/forge/GuardianTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract GuardianTest is IntegrationTest {
vault.submitGuardian(GUARDIAN);
}

function testRevokeTimelockDecreased(uint256 timelock, uint256 elapsed) public {
function testRevokePendingTimelockDecreased(uint256 timelock, uint256 elapsed) public {
timelock = bound(timelock, ConstantsLib.MIN_TIMELOCK, TIMELOCK - 1);
elapsed = bound(elapsed, 0, TIMELOCK - 1);

Expand All @@ -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.RevokePendingTimelock(GUARDIAN);
vm.prank(GUARDIAN);
vault.revokeTimelock();
vault.revokePendingTimelock();

uint256 newTimelock = vault.timelock();
(uint256 pendingTimelock, uint64 submittedAt) = vault.pendingTimelock();
Expand All @@ -50,7 +50,7 @@ contract GuardianTest is IntegrationTest {
assertEq(submittedAt, 0, "submittedAt");
}

function testRevokeCapIncreased(uint256 seed, uint256 cap, uint256 elapsed) public {
function testRevokePendingCapIncreased(uint256 seed, uint256 cap, uint256 elapsed) public {
MarketParams memory marketParams = _randomMarketParams(seed);
elapsed = bound(elapsed, 0, TIMELOCK - 1);
cap = bound(cap, 1, type(uint192).max);
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.RevokePendingCap(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 @@ -76,7 +76,7 @@ contract GuardianTest is IntegrationTest {
assertEq(submittedAt, 0, "submittedAt");
}

function testRevokeGuardian(uint256 elapsed) public {
function testRevokePendingGuardian(uint256 elapsed) public {
elapsed = bound(elapsed, 0, TIMELOCK - 1);

address guardian = makeAddr("Guardian2");
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.RevokePendingGuardian(GUARDIAN);
vm.prank(GUARDIAN);
vault.revokeGuardian();
vault.revokePendingGuardian();

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


.
└── 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 emit RevokePendingTimelock(msg.sender)
└── 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 emit RevokePendingCap(msg.sender, id)
└── it should delete pendingCap[id]

.
└── revokeGuardian() external
└── revokePendingGuardian() external
├── when msg.sender not guardian
│ └── revert with NotGuardian()
└── when msg.sender is guardian
├── it should emit RevokeGuardian(msg.sender, pendingGuardian);
├── it should emit RevokePendingGuardian(msg.sender);
└── it should delete pendingGuardian


Expand Down
Loading