Building a v4 hook? Four house hooks already earn on every swap: volatility fee, anti-snipe, agent rebate and weekend gap guard.Read the protocol.Building a v4 hook? Four house hooks already earn on every swap: volatility fee, anti-snipe, agent rebate and weekend gap guard.Read the protocol.

Protocol

Formulas

fee = max(baseFee, proposal_1 ... proposal_n) x (100 - max rebate_i) / 100
royalty_i = |unspecified amount| x royaltyBps_i / 10,000, with sum(royaltyBps_i) <= 30
author_i = royalty_i x 0.8, vesting 7 days reserve += royalty_i - author_i
a hook may run only if gasleft >= gasLimit x 64 / 63 + 30,000, else the swap reverts
repay per unit (Q128) += seized x 2^128 / total LP units of the pool

Invariants

Claims held by the ledger equal what it owes, per currencyinvariant test, 64 runs x 40 calls
Royalties never exceed 30 bps of a swapfuzz test, 256 runs
An honest hook never fails because a caller sent too little gasfuzz over 60,000 to 1,500,000 gas
Fee composition is the max of proposals less the largest rebatefuzz test, 256 runs
Only createDam can initialise a pool on the hook stackunit test
The four house hooks run on live chain state without a failed runfork test on the live PoolManager

Parameters

ParameterValueWhere
v4 hooks per pool5Dam.MAX_LOGS
Royalty per hook0 to 10 bpsStorefronts.MAX_ROYALTY_BPS
Stack royalty cap30 bpsDam.MAX_STACK_ROYALTY_BPS
Stack gas budget400,000Dam.STACK_GAS_BUDGET
Gas per fee hook10,000 to 80,000Storefronts.MAX_FEE_LOG_GAS
afterSwap stipend40,000Dam.AFTER_SWAP_GAS
Royalty split80% author, 20% burn reserveRoyaltyLedger.AUTHOR_SHARE_BPS
Vesting7 days, daily bucketsRoyaltyLedger.VEST
Stake to list10,000 $V4M (50,000 for a hook that holds funds)Storefronts.MIN_STAKE
Failed-run slash10% at 3 failed runs in 7 days, hook removedStorefronts.CRACK_SLASH_BPS
Exploit slashup to 100% after a 48 h challenge windowStorefronts.CHALLENGE_WINDOW
Stack change delay48 hoursDam.STACK_CHANGE_DELAY
burnBuyonce an hour, 3 hops, 0.5% price move a hop, 1% tipRoyaltyLedger
Timelock48 hours, 14 days graceTimelock.DELAY
Simulator over x4020.002 USDG a call/api/simulate

Contracts

Hook stack (Dam)0xfa80B85CD044Be80795e3344bE1A7435Dbb3fAcc
Storefronts0xd497D8327554ad8c2fd0B3F7E8c100Bb1773dA00
Royalty ledger0xd065aAC3419a018Def2e1f118ADa0aCf6A439468
Router0x951C76d97f80355Fe8f3aAEbd6F7f1D2bA9e8DB5
Timelock0x09A4322b9857FC53a6035D35C009d752E4F575D9
v4 PoolManager0x8366a39cc670b4001a1121b8f6a443a643e40951

Timelock queue

Every parameter change waits 48 hours here before it can run.

CallTargetExecutable from
Nothing queued.