Uniswap V4 Hook | OKX Build-X Hackathon 2026 | X Layer Mainnet
Stock markets have circuit breakers. Meme pools don't. Until now.
Network: X Layer Mainnet (Chain ID: 196)
Address: 0x3B6C42EC8628a18e226c1C5d619dAABF6382d0C0
PoolManager: 0x360E68faCcca8cA495c1B759Fd9EEe466db9FB32
Owner: 0x4e59b44847b379578588920cA78FbF26c0B4956C (CREATE2 factory — effectively ownerless. No admin key, no emergency pause. Code is law.)
CircuitBreakerHook implements a fully on-chain, oracle-free circuit breaker for Uniswap V4 meme token pools — mirroring NYSE's market halt mechanism.
NORMAL → ALERT → HALTED → NORMAL (auto-reset)
| Phase | Trigger | Same-Direction Fee | Counter-Direction Fee |
|---|---|---|---|
| NORMAL | — | 0.05% | 0.05% |
| ALERT | >8% price move in 5 min | 3.00% | 0.01% |
| HALTED | ALERT sustained 10 min | Reverted | 0.01% |
| Parameter | Value |
|---|---|
| Tick threshold | 800 ticks (~8% price move) |
| Window duration | 5 minutes |
| ALERT → HALTED escalation | 10 minutes |
| HALT cooldown | 3 minutes |
| Base fee | 0.05% (500 bps) |
| ALERT same-direction fee | 3.00% (30,000 bps) |
| Counter-direction incentive | 0.01% (100 bps) |
Problem: Meme token pools on AMMs have no protection against pump-and-dump or flash crashes. Bots can drain LPs with impunity.
Solution:
- When price crashes >8% in 5 minutes → raise same-direction fee to 3% (friction), drop counter-direction to 0.01% (incentivize recovery)
- If extreme movement persists 10 minutes → hard halt for same-direction trades (3-minute pause)
- Counter-direction (recovery) trading always allowed at near-zero fee
Key advantages over existing hooks:
- Zero external dependencies (no Chainlink, no ZK proof)
- Pool-level state aggregation — split orders can't bypass the trigger
- Fully verifiable on-chain — no black box
- Ownerless on mainnet — code is law
AFTER_INITIALIZE_FLAG | BEFORE_SWAP_FLAG | AFTER_SWAP_FLAG = 0x10C0
Address lower bits: 0x3B6C42EC8628a18e226c1C5d619dAABF6382d0C0
- bit 6 (AFTER_SWAP) ✅
- bit 7 (BEFORE_SWAP) ✅
- bit 12 (AFTER_INITIALIZE) ✅
Pools using this hook must be initialized with DYNAMIC_FEE_FLAG:
PoolKey memory key = PoolKey({
currency0: currency0,
currency1: currency1,
fee: LPFeeLibrary.DYNAMIC_FEE_FLAG, // 0x800000
tickSpacing: 60,
hooks: IHooks(0x3B6C42EC8628a18e226c1C5d619dAABF6382d0C0)
});forge test --match-contract CircuitBreakerHookTest -vv15/15 tests pass, covering full state machine paths including split-order accumulation and auto-reset.
forge install
forge buildRequirements: Foundry, Solidity 0.8.26, EVM cancun
- Uniswap V4 Core
- Foundry
- Deployed on X Layer by OKX
Built for the OKX Build-X Hackathon 2026 by Water Mirror (水镜) AI team.