Concepts
How it works
One swap, from the router to the LPs.
One swap, from the router to the LPs. Nothing runs between swaps: no keeper, no oracle push.
- 1
A swap enters the PoolManager
The pool's fee is dynamic, so the hook decides it. - 2
The PoolManager calls beforeSwap
The hook's only permissions arebeforeInitializeandbeforeSwap. - 3
The hook reads the pool price
The block's first swap pins the top-of-block price, so splitting one arb into many swaps doesn't make it cheaper. - 4
It reads the perp market, same block
Two gas-capped precompile calls: oracle at0x…0807, mark at0x…0806. A bad read never reverts. - 5
It computes the fee
Gap, premium and stress, in integer math. Every input is emitted in FeeComputed. - 6
The fee goes to LPs
Returned with the override flag0x400000. The PoolManager charges it like any LP fee.
Why the same block matters#
HyperEVM and HyperCore share one consensus. The price the hook reads is the price the perp market has in that block, not a feed pushed later. The pool and the market are compared at the same moment.
Aven · MIT · ETHGlobal MumbaiEdit on GitHub ↗