Dynamic fee hook on Ethereum

Uniswap v4 Hook Contract 0xefa51b682deee8578a26c54222ec39fb791bd0c0 on Ethereum · Dynamic fee

Volume (24h)
$17.26K
Value locked (TVL)
$18.80K
All-time volume
$552.81K
Pools using this hook
1
Swaps (24h)
89 (40 traders)
Total swaps
2,236

What it does

A dynamic-fee hook that sets swap fees per pool using recent price or oracle data, with owner-adjustable bounds, for traders paying fees and LPs earning them.

How it works step by step

  • Sets a dynamic LP fee per swap in beforeSwap, bounded by minFee and maxFee.
  • Falls back to a configured fallbackFee when no fresh directive is available.
  • Records pool initialization time in afterInitialize.
  • Updates per-pool fee directive and per-block state in afterSwap.
  • Reads observation data from an external oracle contract to inform fee calculation.
  • Exposes owner and operator setters for fee parameters and block-window settings.
Swap behaviour
beforeSwap returns a dynamic fee override based on previewFee and stored directive state; afterSwap updates the stored fee state for the pool.
Liquidity behaviour
Liquidity add and remove callbacks are present as selectors in the dispatch table but no state-changing logic was identified for them; they appear to be no-op or revert-by-default implementations.
Fee behaviour
Fees are set dynamically in beforeSwap via previewFee and a directive mapping keyed by pool id (slot 5). Fees are bounded by minFee, maxFee and a fallbackFee, with parameters (block window, multipliers) owner-adjustable. The afterSwap hook updates fee state, and observation reads (observe on an external oracle) appear to feed the fee calculation.
Owner & admin controls
Owner (slot 0) can transfer ownership, set an operator (slot 4), and call owner/operator-gated setters for fee parameters: setMaxFee, setFallbackFee and several uint24/uint32 parameter setters (selectors 0x6a786210, 0xde0bc4fb, 0xed406181, 0xcc508a00, 0x6828a486, 0xc8058828, 0x2c0b84c6, 0x364fe150, 0xc21b4623, 0x7e565e87, 0xb8a4a872). No pause function was identified.

Enabled Uniswap v4 callbacks

afterInitialize, beforeSwap, afterSwap

afterInitialize records pool initialization time and state (slot 2 timestamp mapping). beforeSwap computes the dynamic fee override for the swap. afterSwap updates per-pool fee state and tracks a per-block flag (slot 3) and directive data (slot 5).

Security & trust assessment

Risk level: medium (decoded bytecode, low confidence).

Who controls it: The owner can change maxFee, fallbackFee, minFee-related and multiplier parameters and reassign the operator, directly changing the fee users pay on every swap. A malicious or compromised key could raise fees to the maximum on all pools using this hook.

Risk to user funds: The hook does not appear to hold or transfer user tokens; it returns fee overrides. Exposure is indirect: owner-adjustable fee parameters can make swaps more expensive for traders, but the hook does not seem to custody pool funds.

Security findings

  • [medium] Owner can alter swap fees: Owner-controlled setters (setMaxFee, setFallbackFee and others) can change fee bounds that apply to every swap through this hook.
  • [low] Operator role with fee control: An owner-set operator (slot 4) can call fee-adjustment functions in addition to the owner, widening the set of privileged keys.
  • [medium] Dependence on external oracle data: Fee calculation depends on external oracle observations (observe on a time-weighted source); manipulation of the referenced pool or stale data could skew fees.
  • [info] No pause or upgrade path identified: No upgrade proxy or pause mechanism was identified in the decoded bytecode, so a fixed-logic hook is likely but unverified.

Contract details

Verified source
No
Bytecode size
15,680 bytes
Upgradeable proxy
No
Detected patterns
oracle, ownable

Pools using Dynamic fee hook