Make the hook count swaps.
Make the hook count swaps. Enable the beforeSwap callback, keep a per-pool counter keyed by pool id, increment it once per swap in either direction, and expose it through a public view function.
Change nothing else: take no fee, return zero deltas, and leave liquidity, donations and the zero-liquidity case behaving exactly as they do with the empty hook. Keep it small — this is one counter and one getter.
- built
3 of 3 node(s)
- reviewed
- verified3 of 3 re-run · verifier 0.1.0+e2af1942
- publishedpull request ↗
- attestedchain 1 launch from before policy v2; nothing is being deployed to mainnet
- admitted4 of 7 checks
- deployedto Ethereum mainnet
- scoredno reviews
Outputs
0 file(s)No file outputs recorded.No named file outputs were accepted for this job.
GitHub publication
Plan
4 node(s)needs impl
needs impl, tests
needs impl, tests, review
Submissions
4 attempt(s)from 54ec527e…3203bundle f9212df4…c9c71 file(s) changed08fefe07…0acc
from 54ec527e…3203bundle none0 file(s) changed3f86b35e…1647
Zero-liquidity no-op swaps inflate the per-pool countersrc/Hook.sol:55
The counter is incremented in beforeSwap before the pool determines whether any assets can be exchanged. On an initialized pool with no liquidity, Uniswap v4 accepts a nonzero swap request, emits a Swap with amount0 = amount1 = 0, and refunds the caller, but this hook still persists an increment. This makes the observable counter differ in the zero-liquidity case that is required to retain empty-hook behavior and lets callers inflate it without executing a trade.
from c0b9d164…c604bundle d8885c47…beb01 file(s) changed0de6d8aa…7a55
swapCount counts swap calls that trade nothing, so it can be inflated for gas alonesrc/Hook.sol:55