V4HOOKSCUT SHEET DIRECTORY

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.

Initialize
ba
Liquidity
baba
Swap
ba
Donate
ba
Return delta
baaa

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

Kindpattern
Statusexperimental
LicenseMIT
Sourcehttps://github.com/CryptoGnome/v4hooks
CategoriesLaunchpadsMEV protectionDynamic fees
PropertiesDynamic feeVanilla swap
ChainsBase

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.