Building a v4 hook? Pick what it does, set the numbers, and deploy it as your own hook or stacked on v4 Marketplace. Open the builder ↗
v4 Builder docs
Build a v4 hook from modules

The proof

Before a hook can be deployed, the builder runs it on the live chain. The whole run is one eth_simulateV1 request against the chain's real PoolManager at the latest block: nothing is sent, nothing is paid, and the result is the hook's behaviour on the chain state of that block.

Compile

The source is compiled on the site with solc 0.8.26, the optimizer at 200 runs and the cancun EVM, with the IR pipeline only when the legacy one runs out of stack. These are the settings a deploy uses, so the code that was proven is the code that ships. A contract over 24,576 bytes stops here.

Own hook: twin pools

  1. The hook is deployed inside the simulation at an address mined for its callbacks.
  2. A pool is opened with it, next to a twin pool with the same tokens, no hook and no fee, and both get the same liquidity.
  3. At each moment the recipe cares about, the same small swap goes through both pools, from two wallets: a plain one, and one that holds an ERC-8004 agent identity. A wallet tries several swaps in a row, so a cooldown shows.
  4. Paid is what the swapper received less than in the twin, as a share of the trade: the fee, the tax and the rebate together.
  5. At the end, the liquidity is taken out, which shows a lock. The gas of the hook is the hooked swap less the twin swap.

The moments

Time moves inside the simulation from block to block, so every rule that depends on time is seen at the moment it changes:

  • The open, always.
  • Half of the anti-snipe window and its end.
  • The end of the allowlist window.
  • One second after the cooldown, when the cooldown is an hour or less.
  • 30 seconds after the open, for the volatility fee and the price guard.
  • A weekday with the stock market open, and a Saturday, for the off-hours fee.
  • One hour after the open, when the recipe gives fewer than three moments.

Stacked hook: cold calls

A stacked hook is called exactly the way the hook stack calls it, on the live TSLA / USDG pool of v4 Marketplace: onStack first, then beforeSwap at each moment, from both wallets, with a second call from the same wallet when the recipe has a cooldown. Each call is its own transaction, so storage is as cold as on a real swap, and the gas of every answer is measured.

The hook is listed with the heaviest answer plus a quarter, rounded up to the next 1,000 gas, within the hook stack's 10,000 to 80,000. An answer over 80,000 gas fails the proof.

A proof shows what the hook does on the chain state of the block it ran on. Pools, prices and balances move after that block, and the hook follows the rules it was written with.

Real runs

The three example recipes, run on the live chain:

Fair Launch

Anti-snipe fee from 25% to zero over 10 minutes, 30-second cooldown, 30-day liquidity lock, base fee 0.30%.

Fair Launch · Own v4 hook · block 99,404,157 ↗
MomentPaid
At the open
Small swap
24.98%
31 seconds after the open
Small swap
23.69%
5 minutes after the open
Small swap
12.49%
10 minutes after the open
Small swap
0.30%
Within the 30-second cooldown
2nd, 3rd and 4th swap of the same wallet
Refused: cooling down
At the end
Liquidity exit
Refused: locked until 2026-11-26
About 27,000 gas per swap for the hook.

Stock Hours

Volatility fee from 0.05% when calm up to 2%, off-hours fee of 1%, price guard of 5% in 15 minutes, as a stacked hook.

Stock Hours · Stacked on v4 Marketplace · block 99,404,260 ↗
MomentProposal
A weekday, market open
Fee proposal on TSLA / USDG
0.05%
Saturday, market closed
Fee proposal on TSLA / USDG
1.00%
At most 17,492 gas per answer, listed with a 22,000 gas limit.

Agent Lane

AI agent rebate of 50% and a swap tax of 0.20% sent to 0x…dEaD, base fee 0.30%.

Agent Lane · Own v4 hook · block 99,404,281 ↗
MomentPaid in total
Any time
A plain wallet
0.50%
Any time
A wallet holding an ERC-8004 agent identity
0.35%
Fee and swap tax together, against a twin pool with no hook and no fee.