Skip to content

Commit

Permalink
Merge pull request #120 from morpho-labs/feat/max-queue-size
Browse files Browse the repository at this point in the history
Feat/max queue size
  • Loading branch information
Rubilmax authored Sep 29, 2023
2 parents 8b04450 + c6277c2 commit 2082490
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const config: HardhatUserConfig = {
initialBaseFeePerGas: 0,
allowBlocksWithSameTimestamp: true,
accounts: {
count: 153, // must be odd
count: 103, // must be odd
},
},
},
Expand Down
5 changes: 2 additions & 3 deletions src/libraries/ConstantsLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ uint256 constant MAX_TIMELOCK = 2 weeks;
/// @dev OpenZeppelin's decimals offset used in MetaMorpho's ERC4626 implementation.
uint8 constant DECIMALS_OFFSET = 6;

/// @dev The maximum supply/withdraw queue size ensuring the cost of depositing/withdrawing from the vault fits in a
/// block.
uint256 constant MAX_QUEUE_SIZE = 64;
/// @dev The maximum number of markets in the supply/withdraw queue.
uint256 constant MAX_QUEUE_SIZE = 30;

/// @dev The maximum fee the vault can have (50%).
uint256 constant MAX_FEE = 0.5e18;
23 changes: 12 additions & 11 deletions test/hardhat/MetaMorpho.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ describe("MetaMorpho", () => {
}),
);

const withdrawnAssets = allocation.reduce(
(total, { market, shares }) =>
total + shares.mulDivDown(market.totalSupplyAssets + virtualAssets, market.totalSupplyShares + virtualShares),
0n,
);

await metaMorpho.connect(allocator).reallocate(
allocation
.map(({ marketParams, shares }) => ({
Expand All @@ -204,17 +210,12 @@ describe("MetaMorpho", () => {
shares,
}))
.filter(({ shares }) => shares > 0n),
allocation
.map(({ marketParams, market, shares }) => {
const assets = shares.mulDivDown(
market.totalSupplyAssets + virtualAssets,
market.totalSupplyShares + virtualShares,
);

// Always supply 3/4 of what the vault withdrawn.
return { marketParams, assets: (assets * 3n) / 4n, shares: 0n };
})
.filter(({ assets }) => assets > 0n),
allocation.map(({ marketParams }) => ({
marketParams,
// Always supply evenly between markets + idle.
assets: withdrawnAssets / toBigInt(nbMarkets + 1),
shares: 0n,
})),
);

const borrower = borrowers[i];
Expand Down

0 comments on commit 2082490

Please sign in to comment.