Index / MEV donate
pattern · MIT · last updated 2026-08-27
MEV donate
Skim swap output to pending, then flush() donates to in-range LPs.
First-party rewrite inspired by FairArbooors (EthLondon) and Detox. afterSwapReturnDelta takes skimBps of swap output into pending balances per pool; flush() unlocks a donate + settle path so in-range LPs receive the skim (same unlock pattern as LpRewards). Skims both swap directions. Teaching cut of MEV-to-LP redistribution — not a production MEV auction. Experimental. Listing is not an audit. Forge tests under test/MevDonate.t.sol.
Permission bits
These bits must match the deployed address. Confirm on-chain before you route.
afterSwapafterSwapReturnDelta
Solidity
Excerpt from contracts/MevDonate.sol. Copy the full file to implement this. Not an audit.
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
return Hooks.Permissions({
beforeInitialize: false,
afterInitialize: false,
beforeAddLiquidity: false,
afterAddLiquidity: false,
beforeRemoveLiquidity: false,
afterRemoveLiquidity: false,
beforeSwap: false,
afterSwap: true,
beforeDonate: false,
afterDonate: false,
beforeSwapReturnDelta: false,
afterSwapReturnDelta: true,
afterAddLiquidityReturnDelta: false,
afterRemoveLiquidityReturnDelta: false
});
}Spec
| Kind | pattern |
|---|---|
| Status | experimental |
| License | MIT |
| Source | https://github.com/CryptoGnome/v4hooks |
| Categories | MEV protectionLP management |
| Properties | Vanilla swap |
| Chains | Ethereum |
| Docs | https://github.com/LVooooors/ETHGlobalLondon |
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.