DynamicFeeHookSimple on Celo

Uniswap v4 Hook Contract 0x7e2873516c7344bfe201f981d0a7bb6a6debf0c0 on Celo · Dynamic fee · Verified contract

Volume (24h)
$0
Value locked (TVL)
$0
All-time volume
$0
Pools using this hook
1
Swaps (24h)
0 (0 traders)
Total swaps
0

What it does

A Uniswap v4 hook that charges a volatility-based dynamic swap fee on dynamic-fee pools, with all fees going to LPs.

How it works step by step

  • Validates at initialization that the pool uses a dynamic fee
  • Registers each pool with a default base fee of 0.30% and max fee of 1.00%
  • Tracks an annualized EWMA of price change as a volatility estimate on every swap
  • Overrides the swap fee per swap as baseFee plus volatility times a multiplier, capped at maxFee
  • Accumulates per-pool and global swap volume without taking any protocol fee
  • Exposes view functions for current fee, volatility and pool statistics
Swap behaviour
beforeSwap reads the pool's current price, updates an EWMA volatility estimate, and overrides the LP fee to baseFee plus a volatility-scaled amount capped at maxFee. afterSwap only records swap volume and returns zero delta.
Liquidity behaviour
No liquidity callbacks.
Fee behaviour
Each swap computes fee = baseFee + volatility * feeMultiplier / 100, capped at the pool's maxFee, and returns it as an LP fee override flagged with OVERRIDE_FEE_FLAG. Pools are registered at initialization with baseFee 3000 (0.30%) and maxFee 10000 (1.00%). Volatility is an EWMA of price change per second annualized, capped at MAX_VOLATILITY. The hook takes no protocol fee, so all swap fees accrue to LPs.
Owner & admin controls
Owner (initially the treasury address, transferred via Ownable2Step) can call setVolatilityParams to change the EWMA alpha, volatility window and fee multiplier (alpha capped at 10000), and setPoolConfig to change each pool's baseFee and maxFee within MIN_FEE 100 to MAX_FEE 10000 bounds. Owner can transfer or renounce ownership. No pause mechanism, no upgradeability and no fund-withdrawal function were found; the receive() function accepts ETH with no withdrawal path.

Enabled Uniswap v4 callbacks

beforeInitialize, afterInitialize, beforeSwap, afterSwap

beforeInitialize validates the pool uses a dynamic fee; afterInitialize registers the pool config with default fees and the initial sqrt price; beforeSwap updates volatility from the current slot0 price and returns the dynamic fee override; afterSwap accumulates per-pool and global swap volume and returns zero delta.

Security & trust assessment

Risk level: medium (verified source, high confidence).

Who controls it: The owner can set maxFee up to 1% and baseFee as low as 0.01% per pool, and can change the volatility multiplier and alpha, directly controlling fees paid by traders. The owner cannot move pool funds or block swaps, since the hook returns zero deltas and has no pause, so the centralization risk is primarily fee manipulation.

Risk to user funds: The hook does not hold pool tokens or take deltas, and it cannot block swaps or liquidity, so user principal is not directly exposed. Traders and LPs are exposed to fee changes set by the owner and to fees influenced by spot-price-driven volatility.

Security findings

  • [medium] Owner-controlled fee parameters: The owner can change feeMultiplier and alpha through setVolatilityParams, and setPoolConfig adjusts baseFee and maxFee within 0.01% to 1.00%. A key holder could set fees to the minimum or maximum band on any initialized pool, affecting trader cost and LP revenue.
  • [low] Unused and unbounded parameters: setVolatilityParams accepts any volatilityWindow value, but the window is never used in the fee calculation, so the parameter has no effect. feeMultiplier is also unbounded and could be set large, though the per-pool maxFee still caps the result.
  • [low] Volatility spike sensitivity: _updateVolatility computes price change from the sqrt price and divides by timeDelta with annualization; large price jumps in one block can produce spikes that are only capped at MAX_VOLATILITY, and the first swap after a long idle period is annualized from a stale timestamp, so fees can jump sharply.
  • [low] Spot-price based volatility input: Volatility is computed from the spot price at the time of the swap, which can be moved by a trader in the same transaction, allowing fee manipulation around swaps.
  • [info] ETH can be locked: The contract has a receive() function accepting ETH but no withdrawal method, so any ETH sent directly is stuck.

Contract details

Verified source
Yes (DynamicFeeHookSimple)
Compiler
solc 0.8.26+commit.8a97fa7a
Bytecode size
7,957 bytes
Upgradeable proxy
No
Detected patterns
dynamic-fee, ownable

Pools using DynamicFeeHookSimple