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 1 commit
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
8 changes: 1 addition & 7 deletions src/MetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -738,15 +738,9 @@ 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;
}
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 wasEnabled = vault.config(id).enabled;
MathisGD marked this conversation as resolved.
Show resolved Hide resolved
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 (!wasEnabled) {
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);
}
}
MathisGD marked this conversation as resolved.
Show resolved Hide resolved
}

function _sortSupplyQueueIdleLast() internal {
Expand Down