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

Feat/max queue size #120

Merged
merged 4 commits into from
Sep 29, 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
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
Loading