What it is
A Uniswap v4 pool can have one hook. Lamina is one hook that runs a stack of small layers inside that slot: a dynamic fee, an MEV guard, an oracle check, a rebate.
Builders write layers and list them. Pools pick up to 6 layers and put them in order. Every swap pays a royalty to the builders whose layers ran.
Lamina lives on Elysium, the L2 on Hyperliquid (chain 99901, gas in HYPE, 100 ms blocks). The contracts deploy at launch. Until then the home page runs the same layer logic in your browser on the live HYPE market.
The hook slot
In v4 the PoolManager reads a hook’s permissions from the last 14 bits of its address. Bit 7 is beforeSwap, bit 6 is afterSwap, bit 2 is afterSwapReturnsDelta. Lamina needs those three, so its address ends in 0x00c4.
beforeSwap(sender, key, params, hookData) returns (bytes4, BeforeSwapDelta, uint24). The last value is the fee for this swap. Lamina sets it only on pools created with the dynamic fee flag (0x800000), and returns it with the override bit set (0x400000), so a 0.3% fee comes back as 0x400bb8.
afterSwap(sender, key, params, delta, hookData) returns (bytes4, int128). The int128 is how much the hook takes or gives in the unspecified currency. Lamina uses it to collect royalties and pay rebates.
Fees are in pips: 1,000,000 pips is 100%, so 3,000 pips is 0.3%. This is v4’s own unit (LPFeeLibrary.MAX_LP_FEE).
Layers
A layer is a small contract with two functions, beforeSwap and afterSwap. The hook calls them in the pool’s order: every beforeSwap layer first, then every afterSwap layer.
A beforeSwap layer can add a fee in pips or stop the swap. If any layer says no, the swap reverts, the layers below it never run and nobody is paid.
An afterSwap layer sees the result and can return a rebate. It can read what the layers above it charged, so order matters: a rebate of 20% means 20% of the fee the stack set so far.
The four house layers
drift fee: reads the last 30 one-minute prices, takes their volatility per hour and sets the fee to 500 pips plus 400,000 times that, between 500 and 10,000 pips. Calm market, low fee. Wild market, high fee.
veil guard: walks the swap through the order book and measures how far the average fill lands from the mid price. Over 25 bps it stops the swap. Over 5 bps it adds 40 pips per bp of impact.
plumb oracle: compares the pool price with the oracle price. If they are more than 30 bps apart it stops the swap, so nobody trades against a stale price.
ebb rebate: compares bid and ask depth over 10 levels. If your swap moves the book back toward balance, you get 20% of the fee back.
Stacking a pool
A pool takes up to 6 layers. Together they must fit inside 300,000 gas for one swap, so a trader always knows the worst case.
Royalties are set by each builder in bps of the swap size. The whole stack is capped at 12 bps: if the layers ask for more, every royalty is scaled down to fit.
On the home page, a $25,000 HYPE swap through all four house layers costs about 160,000 gas. At 0.5 gwei on Elysium that is under one cent.
How gas is counted
The runner on the home page prices each line by what it would cost in the EVM. Every value read from chain state is a cold SLOAD, 2,100 gas. A read from another contract adds a cold call, 2,600 gas. Adding costs 3, multiplying and dividing cost 5, a branch costs 10.
So reading 30 prices costs 63,000 gas, and a bigger swap that crosses more order book levels costs more. The hook itself adds a call into each layer, one slot read per layer, and 5,000 gas per royalty it credits.
Stake and slashing
To list a layer you stake 10,000 $LAMINA. A pool can only add layers that are staked.
A failed run is a layer that reverts on its own or goes over its gas limit. Each failed run burns 5% of its stake. A layer that drops under the minimum stake leaves every stack until it is topped up.
Stopping a swap on purpose, like veil guard does on a thin book, is not a failed run. That is the layer doing its job.
$LAMINA
$LAMINA is the stake that backs every listed layer. The contract address is posted here and on X at launch.