Skip to content

Commit

Permalink
Merge pull request #355 from morpho-org/feat/submit-cap-market-removal
Browse files Browse the repository at this point in the history
Revert when submitting cap and a removal has been submitted
  • Loading branch information
MathisGD authored Dec 26, 2023
2 parents 7520ae7 + 393798f commit d18645a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/MetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph
} else {
// newSupplyCap > supplyCap >= 0 so there's no need to check `pendingCap[id].validAt != 0`.
if (newSupplyCap == pendingCap[id].value) revert ErrorsLib.AlreadyPending();
if (config[id].removableAt != 0) revert ErrorsLib.PendingRemoval();

pendingCap[id].update(newSupplyCap.toUint184(), timelock);

Expand Down
15 changes: 12 additions & 3 deletions test/forge/MarketTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ contract MarketTest is IntegrationTest {
vault.submitCap(allMarkets[0], CAP);
}

function testSubmitCapRemovalSubmitted(uint256 cap) public {
cap = bound(cap, MIN_TEST_ASSETS, MAX_TEST_ASSETS);

vm.startPrank(CURATOR);
vault.submitMarketRemoval(allMarkets[0].id());

vm.expectRevert(ErrorsLib.PendingRemoval.selector);
vault.submitCap(allMarkets[0], cap);
vm.stopPrank();
}

function testSetSupplyQueue() public {
Id[] memory supplyQueue = new Id[](2);
supplyQueue[0] = allMarkets[1].id();
Expand Down Expand Up @@ -155,10 +166,8 @@ contract MarketTest is IntegrationTest {
function testUpdateWithdrawQueueRemovingDisabledMarket() public {
_setCap(allMarkets[2], 0);

vm.startPrank(CURATOR);
vm.prank(CURATOR);
vault.submitMarketRemoval(allMarkets[2].id());
vault.submitCap(allMarkets[2], CAP + 1);
vm.stopPrank();

vm.warp(block.timestamp + TIMELOCK);

Expand Down

0 comments on commit d18645a

Please sign in to comment.