Dynamic fee hook on Ethereum

Uniswap v4 Hook Contract 0x13bcadd15ac0d0deff87ac5692cb7ea4d57a80cc on Ethereum · Dynamic fee

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

What it does

This hook charges a fee on swaps with separate buy and sell rates set by the owner, while exempt addresses trade without the fee.

How it works step by step

  • Charges a swap fee on trades routed through the pool, with separate buy and sell basis-point rates (buyBps and sellBps storage slots).
  • Tracks accumulated fees in a totalFees counter, updated during beforeSwap and afterSwap.
  • Maintains an owner-managed exemption list (mapping of address to bool) that can skip fees for whitelisted addresses.
  • Takes the fee portion of the swap via return deltas, so the hook itself receives the fee currency.
  • Exposes a claim() function that forwards accumulated fees to a configured recipient address.
  • Checks the router or sender identity against the UNIVERSAL_ROUTER and POOL_MANAGER addresses before applying logic.
Swap behaviour
beforeSwap and afterSwap run on every swap. Non-exempt swaps have a fee taken through return deltas, with the rate chosen by swap direction (buyBps or sellBps). Exempt addresses pay no fee.
Liquidity behaviour
No liquidity callbacks.
Fee behaviour
Fees are set by the owner through setFees(buyBps, sellBps) and are capped by maxBps. The hook takes the fee from the swap via return deltas and accumulates it in totalFees. Exempt addresses are excluded. Fees accrue to the hook and are paid out to the recipient on claim().
Owner & admin controls
The owner can call setFees to change buy and sell rates, setExempt to change the exemption list, transferOwnership and renounceOwnership. The recipient address and token are set in storage; the bytecode shows no pause function.

Enabled Uniswap v4 callbacks

beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta

beforeSwap computes and gates the fee and applies the before-swap return delta. afterSwap settles the fee and applies the after-swap return delta. beforeSwapReturnDelta and afterSwapReturnDelta allow the hook to take currency from the swap.

Security & trust assessment

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

Who controls it: The owner key can raise the buy or sell fee up to maxBps, exempt chosen addresses, change ownership, and renounce ownership. Accrued fees go to the stored recipient on claim.

Risk to user funds: The hook holds fee currency taken via return deltas until claim() moves it to the recipient. It does not show a pause, so it cannot block swaps, but the owner can change the fee applied to every swap.

Security findings

  • [medium] Owner-set fee rates: The owner can call setFees to change buyBps and sellBps, bounded by maxBps. A high rate would extract a large share of every non-exempt swap.
  • [medium] Return-delta currency capture: The hook takes currency through beforeSwapReturnDelta and afterSwapReturnDelta, so it holds and moves swap funds directly rather than only reading pool state.
  • [low] Owner-controlled exemptions: setExempt lets the owner exclude any address from fees, so fee treatment can differ between traders.
  • [low] Fee recipient control: claim() forwards accumulated fees to a recipient address stored in the contract. Whoever controls that address receives all accrued fees.
  • [info] Decoded bytecode only: No verified source is available, so the exact fee math, rounding and claim authorization could not be confirmed from the bytecode.

Contract details

Verified source
No
Bytecode size
3,918 bytes
Upgradeable proxy
No
Detected patterns
dynamic-fee, moves-currency, ownable, return-delta

Pools using Dynamic fee hook