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 ↗

Build the v4 hook your pool needs

Pick the modules and set the numbers. v4 Builder writes the Solidity, proves it on the live PoolManager and deploys it from your wallet.

A v4 hook without a line of Solidity

A v4 hook decides what each swap in its pool pays and who may swap at all. Writing one has meant Solidity, a mined address and a fork test. v4 Builder brings it down to four steps: pick, set, prove, deploy.

Open the builder
01

Pick the modules

Ten modules, each one a rule the builder knows how to write: anti-snipe fee, volatility fee, off-hours fee, cooldown, price guard, launch allowlist, holder rebate, AI agent rebate, swap tax and liquidity lock. Take one, or combine several in the same v4 hook.

Read the modules ↗
02

Set the numbers

Each module takes a few numbers inside checked bounds: fees in pips, windows in seconds, cuts in basis points. Every choice reads back as one plain sentence, and the same recipe always writes the same Solidity.

Read about recipes ↗
03

Prove it on the live PoolManager

The source compiles with solc 0.8.26 and runs on the live chain in one eth_simulateV1 request: your hook at a mined address, a pool opened with it next to a twin pool with no hook and no fee, the same swaps through both.

Read the proof ↗
04

Deploy from your wallet

The v4 Builder factory puts the code at its CREATE2 address with a salt bound to your wallet, checks the callbacks against the address bits and writes the recipe on chain. Then open a pool with it, or list it on v4 Marketplace.

Read about deploying ↗

Ten modules, one v4 hook

Each module is a rule with its own numbers. A card reads the way the builder writes it: the sentence at the default numbers, then the line of Solidity behind it.
01Fee

Anti-snipe fee

The fee starts at 25% when the pool opens and falls in a straight line to zero over 10 minutes.

fee = 250,000 x (600 - t) / 600 pips
Own hookStacked
Read the formula ↗
02Fee

Volatility fee

The fee follows the average price move between swaps: 0.05% when calm, plus 0.2% for each 1% the price moves on average, up to 2%.

fee = min(500 + 2,000 x e / 10,000, 20,000) pips
Own hookStacked
Read the formula ↗
03Fee

Off-hours fee

From 20:00 to 14:30 UTC on weekdays and all weekend, when the stock market is closed, the fee is 1%.

market closed: fee = max(fee, 10,000) pips
Own hookStacked
Read the formula ↗
04Guard

Cooldown

A wallet that just swapped in this pool waits 30 seconds before its next swap.

now < lastSwapAt + 30: refused
Own hookStacked
Read the formula ↗
05Guard

Price guard

Once the price has moved more than 10% within 5 minutes, swaps that push it further are refused until the window rolls over. Swaps that bring it back go through.

moved > 953 ticks in 300 s, pushing further: refused
Own hookStacked
Read the formula ↗
06Guard

Launch allowlist

For the first 15 minutes, only wallets you list can swap. You can add more from your wallet after the deploy.

now < openedAt + 900 and not allowed: refused
Own hookStacked
Read the formula ↗
07Rebate

Holder rebate

A wallet holding at least the minimum of the token at an address pays 25% less fee.

balance >= HOLD_MIN: fee x 75 / 100
Own hookStacked
Read the formula ↗
08Rebate

AI agent rebate

A wallet that holds an AI agent identity in the chain's ERC-8004 registry pays 25% less fee.

ERC-8004 identity held: fee x 75 / 100
Own hookStacked
Read the formula ↗
09Funds

Swap tax

0.3% of every swap's output (or input, on exact-output swaps) is sent to an address.

cut = amount x 30 / 10,000, taken to TAX_TO
Own hook only
Read the formula ↗
10Liquidity

Liquidity lock

Liquidity added to the pool cannot be removed for 30 days after the pool opens.

now < openedAt + 2,592,000: removal refused
Own hook only
Read the formula ↗

Two ways to ship

The same recipe builds two different contracts. Pick the one that fits the pool: a v4 hook of its own, or a hook stacked with others on v4 Marketplace.
01

Your own v4 hook

An OpenZeppelin BaseHook contract. Its CREATE2 address is mined so the low 14 bits carry exactly the callbacks it uses, then you open a pool with it and every swap in that pool runs it. A hook that sets fees opens its pools with the dynamic fee flag.

Fair Launch: the last 14 bits of its address0x1280
0
1
0
0
1
0
1
0
0
0
0
0
0
0
bit 13bit 0

afterInitialize, beforeRemoveLiquidity, beforeSwap: the callbacks its modules need, nothing more.

Takes all ten modules
Anti-snipe feeVolatility feeOff-hours feeCooldownPrice guardLaunch allowlistHolder rebateAI agent rebateSwap taxLiquidity lock

Swap tax and liquidity lock, in orange, run only on a hook of its own: a stacked hook never moves funds.

Read about own hooks ↗
02

Stacked on v4 Marketplace

A contract that implements ILog. The v4 Marketplace hook stack calls it on every swap of the pools that stack it, and it answers with a fee in pips, a rebate and a veto. It never holds funds, and it shares the pool with up to four other hooks.

ILog, the interface the hook stack calls
interface ILog {
    function onStack(PoolKey calldata key, bytes calldata cfg) external;
    function beforeSwap(address origin, PoolKey calldata key, SwapParams calldata params)
        external returns (uint24 feePips, uint8 rebatePct, bool veto);
    function afterSwap(PoolKey calldata key, SwapParams calldata params, BalanceDelta delta) external;
}
Takes 8 modules
Anti-snipe feeVolatility feeOff-hours feeCooldownPrice guardLaunch allowlistHolder rebateAI agent rebate

Listed from v4 Builder with a royalty of 0 to 10 bps per swap and a gas limit of 10,000 to 80,000, and active once 10,000 $V4M are staked behind it.

Proven on the live chain

Before a v4 hook can be deployed, the builder runs it on the chain's live PoolManager inside one eth_simulateV1 request. These are real runs of the three example recipes, with the block each one ran on.
Own v4 hook · block 99,404,157 ↗

Fair Launch

  • The fee starts at 25% when the pool opens and falls in a straight line to zero over 10 minutes.
  • A wallet that just swapped in this pool waits 30 seconds before its next swap.
  • Liquidity added to the pool cannot be removed for 30 days after the pool opens.
  • Every swap pays at least the base fee of 0.30%.

The hook is deployed inside the simulation at a mined address. A pool is opened with it next to a twin pool with no hook and no fee, and the same small swap goes through both at each moment the recipe cares about. Paid is what the swapper lost against the twin.

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.How the proof runs ↗
Stacked on v4 Marketplace · block 99,404,260 ↗

Stock Hours

  • The fee follows the average price move between swaps: 0.05% when calm, plus 0.2% for each 1% the price moves on average, up to 2%.
  • From 20:00 to 14:30 UTC on weekdays and all weekend, when the stock market is closed, the fee is 1%.
  • Once the price has moved more than 5% within 15 minutes, swaps that push it further are refused until the window rolls over. Swaps that bring it back go through.
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.

Own v4 hook · block 99,404,281 ↗

Agent Lane

  • A wallet that holds an AI agent identity in the chain's ERC-8004 registry pays 50% less fee.
  • 0.2% of every swap's output (or input, on exact-output swaps) is sent to 0x…dEaD, burned.
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.

A v4 hook for every pool

Every name below is a recipe the ten modules already build, from a launch with a falling fee to a stock pool that charges more while the market is closed.
Snipe ShieldFair LaunchWeekend FeeHolder DiscountBurn TaxCalm PoolBot BrakeLaunch Lock
Treasury CutRunaway GuardPresale WindowFee DecayAgent DiscountNight FeeSlow SwapsCreator Cut
Market HoursGap GuardLocked LiquidityStock HoursLoyalty FeeAllowlist OpenStorm FeePrice Fence
Holder HoursBurn LaneTeam AllowlistVolatility BandOne Swap a MinuteQuiet PoolRebate PoolFee Floor
Agent LaneEarnings GuardStock LaunchCommunity OpenTax and BurnCooldown PoolWeekend GuardLP Lock
Holder LaneFirst Hour FeeWhale BrakeClosed Market FeeAgent Only RebateTen Minute LaunchBurn FloorWallet Window
Calm Stock PoolSwap TollLaunch AllowlistVolatility TollHolder BurnSlow OpenDay LockAgent Treasury

Every deploy pays the $V4B stakers

A deploy through the v4 Builder factory costs a flat 0.0003 ETH. The factory sends it on to the wallets that stake $V4B, the token of v4 Builder. Hold 1,000,000 $V4B and you deploy for free.
Your wallet
Sends deploy() with the code, a salt and the recipe.
0.0003 ETH
v4 Builder factory
Deploys the hook with CREATE2 and records the recipe.
forwarded
$V4B stakers
Receive every deploy fee through the stakers' distributor.
A wallet holding 1,000,000 $V4B
The factory reads the balance at deploy time.
0 ETH
priceFor(wallet) returns 0 for a holder and 0.0003 ETH for everyone else. The factory caps the fee at 0.01 ETH in its code, and fees that arrive before the stakers' distributor is set wait in the factory until anyone calls forward().

Build a v4 hook

Start from Fair Launch, Stock Hours or Agent Lane, or from a single module. Pick, set the numbers, read the proof, then deploy it from your wallet.

Build a v4 hook