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

Remove automatic supply queue push #351

Merged
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
10 changes: 3 additions & 7 deletions src/MetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -738,17 +738,13 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph

if (supplyCap > 0) {
if (!marketConfig.enabled) {
supplyQueue.push(id);
withdrawQueue.push(id);

if (
supplyQueue.length > ConstantsLib.MAX_QUEUE_LENGTH
|| withdrawQueue.length > ConstantsLib.MAX_QUEUE_LENGTH
) {
revert ErrorsLib.MaxQueueLengthExceeded();
}
if (withdrawQueue.length > ConstantsLib.MAX_QUEUE_LENGTH) revert ErrorsLib.MaxQueueLengthExceeded();

marketConfig.enabled = true;

emit EventsLib.SetWithdrawQueue(msg.sender, withdrawQueue);
Rubilmax marked this conversation as resolved.
Show resolved Hide resolved
}

marketConfig.removableAt = 0;
Expand Down
1 change: 1 addition & 0 deletions test/forge/MetaMorphoInternalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contract MetaMorphoInternalTest is InternalTest {

Id id = allMarkets[0].id();
_setCap(id, CAP);
supplyQueue = [id];
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved

loanToken.setBalance(SUPPLIER, suppliedAmount);
vm.prank(SUPPLIER);
Expand Down
13 changes: 13 additions & 0 deletions test/forge/helpers/IntegrationTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ contract IntegrationTest is BaseTest {
function _setCap(MarketParams memory marketParams, uint256 newCap) internal {
Id id = marketParams.id();
uint256 cap = vault.config(id).cap;
bool isEnabled = vault.config(id).enabled;
if (newCap == cap) return;

PendingUint192 memory pendingCap = vault.pendingCap(id);
Expand All @@ -115,6 +116,18 @@ contract IntegrationTest is BaseTest {
vault.acceptCap(id);

assertEq(vault.config(id).cap, newCap, "_setCap");

if (newCap > 0) {
if (!isEnabled) {
Comment on lines +120 to +121
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (newCap > 0) {
if (!isEnabled) {
if (newCap > 0 && !isEnabled) {

Id[] memory newSupplyQueue = new Id[](vault.supplyQueueLength() + 1);
for (uint256 k; k < vault.supplyQueueLength(); k++) {
newSupplyQueue[k] = vault.supplyQueue(k);
}
newSupplyQueue[vault.supplyQueueLength()] = id;
vm.prank(ALLOCATOR);
vault.setSupplyQueue(newSupplyQueue);
}
}
}

function _sortSupplyQueueIdleLast() internal {
Expand Down
Loading