Dynamic fee hook on Ethereum

Uniswap v4 Hook Contract 0xb7bfc227c21ef4819400db1b63713f392260a58b on Ethereum · Dynamic fee

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

What it does

This hook sets a dynamic fee on swaps and takes a share of pool flows through return deltas, with an owner who can change the fee receiver and parameters, though the exact fee direction and rates cannot be confirmed without source.

How it works step by step

  • Runs at pool initialization (beforeInitialize) and stores two uint16 parameters plus a fee receiver address in slot 0 and slot 2.
  • Applies gating and a fee-related computation in beforeSwap, which can return a delta to the pool.
  • Tracks per-position or per-key debt in a nested mapping (slot 1) and a uint256 counter (slot 3), updated during afterAddLiquidity and afterRemoveLiquidity.
  • Calls take(address,address,uint256) on the pool manager, so the hook moves currency out of the pool when it returns deltas.
  • Exposes a debtOf view and a fee receiver setter, and includes Unauthorized() revert logic for restricted calls.
  • Implements pancakeV3/uniswapV3 swap callback selectors, suggesting it may also swap against an external pool or route internally.
Swap behaviour
beforeSwap is implemented and can return a delta and take currency from the pool via take(); the exact fee or price adjustment direction cannot be determined from decoded bytecode alone.
Liquidity behaviour
afterAddLiquidity and afterRemoveLiquidity update nested debt accounting in storage and can return deltas, so the hook may take or credit a share of liquidity flows.
Fee behaviour
Dynamic fee logic is indicated by the dynamic-fee and return-delta tags and the beforeSwap callback; the fee receiver address is stored and settable, so some fee portion is likely routed to it, but exact rates are not determinable from the bytecode.
Owner & admin controls
An owner exists (owner(), transferOwnership, renounceOwnership) and can set the fee receiver via setFeeReceiver; the owner may also be able to change stored uint16 parameters through selectors 0x534eb4cf and 0xcb9442e2, but this is unverified.

Enabled Uniswap v4 callbacks

beforeInitialize, afterAddLiquidity, afterRemoveLiquidity, beforeSwap, beforeSwapReturnDelta, afterAddLiquidityReturnDelta, afterRemoveLiquidityReturnDelta

beforeInitialize sets initial parameters; beforeSwap returns a swap delta to adjust fees or amounts; afterAddLiquidity and afterRemoveLiquidity return liquidity deltas and update debt accounting; the return-delta flags allow the hook to take currency from the pool.

Security & trust assessment

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

Who controls it: The owner can change the fee receiver and likely the uint16 parameters, which could shift fee revenue or the effective fee charged to traders and LPs.

Risk to user funds: The hook can take currency from the pool through return deltas and take(), so user and LP funds routed through this pool are exposed to the hook's logic and the owner's parameter control.

Security findings

  • [high] Return deltas move pool currency: The hook enables beforeSwapReturnDelta and afterAdd/RemoveLiquidityReturnDelta and calls take(), so it can extract tokens from the pool on swaps and liquidity changes.
  • [medium] Owner-settable fee parameters and receiver: An owner can change the fee receiver and uint16 parameters, which could redirect fees or raise the fee charged to traders.
  • [medium] Unverified source: Without verified source, the exact fee formula, access checks and upgrade paths cannot be confirmed from bytecode alone.
  • [low] Debt accounting in storage: Nested mapping debt tracking updated during liquidity callbacks may create accounting edge cases if misused or manipulated.

Contract details

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

Pools using Dynamic fee hook