Dynamic fee hook on BNB Chain

Uniswap v4 Hook Contract 0x178c0dfb6c0111a07363ab8bb9e98f28dd1769cc on BNB Chain · Dynamic fee

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

What it does

This hook sets a per-pool swap fee that the owner can change and that is read on every swap, and it can also adjust swap amounts through return deltas, though it cannot be determined from the bytecode which trades pay more or less.

This read was written for the hook 0xf0e1…a9cc on BNB Chain and reused here: the two share a code shape, so constants such as fees, owners and addresses can differ.

How it works step by step

  • Sets a per-pool swap fee stored in a mapping keyed by pool id, with a default swap fee constant exposed as DEFAULT_SWAP_FEE
  • Exposes a dynamicFee value and setDynamicFee/setSwapFee functions that let the owner change fee levels
  • Counts swaps per pool (swapCount mapping) and enforces a MAX_SWAPS limit that can revert swaps with SwapLimitReached
  • Uses a gasLimit setting and a mid-price address (setMid) that the swap logic reads
  • Has beforeSwap and afterSwap hooks with return-delta permissions, so it can alter swap amounts or take a currency delta
  • Adds liquidity gating through beforeAddLiquidity and afterRemoveLiquidity callbacks
Swap behaviour
beforeSwap and afterSwap run on every swap. beforeSwap reads the stored pool fee and the swap counter, may revert with SwapLimitReached once MAX_SWAPS is hit, and has return-delta permission, so it can adjust the amounts settled. afterSwap can also return a delta. Exact per-trade fee direction cannot be determined from decoded bytecode, so which trades pay more or less is unclear.
Liquidity behaviour
beforeAddLiquidity gates additions and afterRemoveLiquidity runs after removals. The bytecode shows no clear logic that changes the amounts LPs receive beyond these callbacks, so the exact effect is not determinable.
Fee behaviour
Fee is stored per pool in a mapping and set by the owner via setSwapFee and setDynamicFee, with an InvalidFee revert path for out-of-range values. beforeSwap reads the fee at swap time, so it is dynamic and owner-controlled rather than the pool's static fee.
Owner & admin controls
An owner (owner() view, initialize and OnlyOwner revert) can call setSwapFee, setDynamicFee, setMid, setGasLimit and an address-setting function. The contract is ownable and carries an upgradeable-proxy tag, so the implementation can be replaced by whoever controls the proxy admin. Pausing is not identified.

Enabled Uniswap v4 callbacks

beforeInitialize, beforeAddLiquidity, afterRemoveLiquidity, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta

beforeInitialize: records pool fee at pool creation. beforeAddLiquidity: gates or inspects liquidity additions. afterRemoveLiquidity: runs after withdrawals. beforeSwap: reads fee, counts swaps, can enforce swap limit and apply return deltas. afterSwap: updates swap accounting and can return a delta. beforeSwapReturnDelta and afterSwapReturnDelta: allow the hook to change amounts settled with the pool manager.

Security & trust assessment

Risk level: high, estimated (decoded bytecode, medium confidence).

Who controls it: A single owner key can change fees, the mid price, gas limit and the implementation via the proxy, which could drain value from swappers or disable trading.

Risk to user funds: Because return-delta permissions are enabled and fees are owner-set, the hook can affect amounts settled on swaps and so can move or redirect user and pool funds.

Security findings

  • [high] Owner-controlled swap fee: setSwapFee and setDynamicFee let the owner set pool fees, subject only to InvalidFee bounds that are not visible here; a high fee would extract value from every swap.
  • [high] Return-delta permissions: beforeSwapReturnDelta and afterSwapReturnDelta are enabled, so the hook can take or redirect currency amounts during swaps.
  • [medium] Upgradeable proxy: The hook delegates to implementation 0x187642f33eac9afea2cc53e1fb7877d1630de4e2, which the proxy admin can replace, changing all behaviour.
  • [medium] Swap limit can block trading: MAX_SWAPS and SwapLimitReached can revert swaps once a count is reached, potentially freezing trading in a pool.
  • [medium] Source not verified: No verified source is available, so the analysis rests on decoded bytecode and inferred function names.

Contract details

Verified source
No
Bytecode size
1,112 bytes
Upgradeable proxy
Yes
Detected patterns
dynamic-fee, ownable, return-delta, upgradeable

Pools using Dynamic fee hook