Index / MevWindow
pattern · MIT · last updated 2026-08-27
MevWindow
Elevated swap fee and blocked add-liquidity for mevBlocks after pool init.
First-party teaching hook inspired by Clanker MEV module window. afterInitialize records launchBlock; while block.number < launchBlock + mevBlocks, beforeSwap returns mevFee and beforeAddLiquidity reverts MevWindowActive. After the window, baseFee applies and LP adds resume. Requires dynamic fee pool. Experimental. Forge tests in test/MevWindow.t.sol. Listing is not an audit.
Permission bits
These bits must match the deployed address. Confirm on-chain before you route.
afterInitializebeforeAddLiquiditybeforeSwap
Solidity
Excerpt from contracts/MevWindow.sol. Copy the full file to implement this. Not an audit.
// SPDX-License-Identifier: MIT
function feeFor(PoolId poolId) public view returns (uint24) {
return inMevWindow(poolId) ? mevFee : baseFee;
}
function _beforeAddLiquidity(...) internal view override returns (bytes4) {
if (inMevWindow(key.toId())) revert MevWindowActive();
return this.beforeAddLiquidity.selector;
}Spec
| Kind | pattern |
|---|---|
| Status | experimental |
| License | MIT |
| Source | https://github.com/CryptoGnome/v4hooks |
| Categories | LaunchpadsMEV protectionDynamic fees |
| Properties | Dynamic feeVanilla swap |
| Chains | Base |
FAQ
Can I paste this into production? The snippet is an excerpt. Use the full file at the source URL, match flags to the address, and treat this page as a map, not a guarantee.
How do I build this safely? Start with secure v4 hooks and the OpenZeppelin hooks guide.