VolumeDynamicFeeHook on Optimism
Uniswap v4 Hook Contract 0xb78a87702aaf69cadd6bb05b0b30ac8d0d86d040 on Optimism · Dynamic fee · Verified contract
- Volume (24h)
- $0
- Value locked (TVL)
- <$0.01
- All-time volume
- $755.32K
- Pools using this hook
- 1
- Swaps (24h)
- 0 (0 traders)
- Total swaps
- 27,379
What it does
A Uniswap v4 pool hook that raises or lowers the LP fee across seven fixed tiers based on recent stable-coin swap volume, with a guardian-controlled pause that locks the fee at a set level.
How it works step by step
- Starts each pool at a configured initial fee tier when afterInitialize runs.
- Accumulates stable-coin swap volume per fixed period, converted to USD6 with immutable decimal scaling.
- Maintains an exponential moving average of period volume and compares each closed period against it using a deadband.
- Steps the fee index up when volume rises above the deadband and down when it falls below, bounded by floor and cap indices.
- Resets the fee to the initial tier after a prolonged lull and drops toward the floor during empty periods.
- Lets the guardian pause the pool to a fixed pause fee tier, and unpause it back to the initial tier.
- Swap behaviour
- After each swap, the hook adds the stable-side swap amount (converted to USD6, counted twice for in and out) to the current period volume and rolls periods forward. When a period closes, it updates the EMA of volume and moves the fee index up, down or leaves it unchanged. While paused, swaps execute without state updates.
- Liquidity behaviour
- No liquidity callbacks.
- Fee behaviour
- Sets the LP fee dynamically from a fixed table of seven tiers (0.095%, 0.40%, 0.90%, 2.5%, 3.0%, 6.0%, 9.0%). The fee index moves up one step when period volume exceeds the EMA by more than the deadband, down one step when it falls below, and drops toward the floor during empty periods. Pool fees are updated via poolManager.updateDynamicLPFee. The guardian can force the fee to the pause tier. No fee is taken by the hook itself and no fee revenue is redirected.
- Owner & admin controls
- A single guardian address (set immutably at deployment, not upgradeable) can call pause() and unpause(). Pausing forces the pool fee to a fixed pauseFeeIdx tier and freezes volume-driven fee updates; unpausing returns the fee to initialFeeIdx. All other parameters (fee tiers, periods, EMA, deadband, reset window, pool key) are immutable and cannot be changed after deployment. There is no proxy or upgrade path and no owner transfer function.
Enabled Uniswap v4 callbacks
afterInitialize, afterSwap
afterInitialize: validates the pool key, initialises state and sets the starting dynamic fee tier. afterSwap: accumulates stable-side swap volume per period, rolls periods forward, updates the EMA and adjusts the dynamic LP fee tier.
Security & trust assessment
Risk level: low (verified source, high confidence).
Who controls it: The guardian can pause the pool at any time, locking the fee at pauseFeeIdx and stopping automatic fee adaptation. Because the guardian can only set fees within the hook's floor-to-cap bounds and cannot touch liquidity or move funds, the worst case is holding fees at a chosen tier. The guardian key is set at deployment and cannot be rotated.
Risk to user funds: The hook does not hold, move or block user or pool funds: afterSwap returns a zero delta and there are no transfers. The only user-facing effect is the LP fee level, which a guardian pause can fix at the pause tier while swaps keep executing.
Security findings
- [info] Single guardian controls pause state: Only the immutable guardian address can call pause() and unpause(), which change the pool fee to the configured pause tier and reset volume state.
- [info] Fee range is bounded and immutable: Fee tier changes are bounded by the immutable floor and cap indices, so the guardian cannot set a fee outside the configured range, and the hook has no path to change fees beyond what afterSwap computes.
- [low] Volume-based fee can be manipulated by wash trading: Volume is derived from the stable side of each swap and converted using immutable decimal scaling; volume can be inflated by a trader within a period, which can push the fee up or down by one tier per period.
- [info] No custody or delta handling: The hook never takes tokens or return deltas; it returns zero from afterSwap and does not hold balances, so pool funds are not custodied by the hook.
Contract details
- Verified source
- Yes (VolumeDynamicFeeHook)
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Bytecode size
- 8,594 bytes
- Upgradeable proxy
- No
- Detected patterns
- dynamic-fee
Pools using VolumeDynamicFeeHook
- ETH / USDC (Dynamic fee) — 24h volume $0, TVL <$0.01, 0 swaps today