Dynamic fee hook on BNB Chain

Uniswap v4 Hook Contract 0xb178f98fd157c4549f9204380da60f35154ba58b on BNB Chain · 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 charges a fee through return deltas on swaps and liquidity changes and sends it to an owner-set fee receiver, so the fee cost applies to trades in both directions, but the exact rate and which direction pays more cannot be determined from the bytecode.

How it works step by step

  • Runs on beforeInitialize and records pool-level configuration in storage slots 0 and 4 (uint16 values and an address), likely a fee or tick parameter plus a fee receiver
  • Uses beforeSwap with return delta permission, so it can alter swap amounts or take a fee outside the pool's static fee
  • Tracks a mapping of uint256 keys to per-address uint256 balances (slot 1) that is updated on add and remove liquidity, which suggests it accounts for its own claims or debts
  • Uses afterAddLiquidity and afterRemoveLiquidity return deltas, so it can take or give currency during liquidity changes
  • Exposes setFeeReceiver and a payable entry point (0xb8216c95) that moves value through a take-style call to an external address
  • Has Ownable-style owner controls (transferOwnership, renounceOwnership) and interacts with a pancakeV3SwapCallback and uniswapV3SwapCallback, so it may be used as a PancakeSwap v4 style hook
Swap behaviour
beforeSwap is active and can return a delta, so the hook can change what a swapper receives or pays; the exact fee formula cannot be determined from the decoded bytecode.
Liquidity behaviour
afterAddLiquidity and afterRemoveLiquidity are active with return deltas, and they update the slot 1 balance mapping; the hook can take or return currency when LPs add or remove liquidity.
Fee behaviour
Fees are not the pool's static fee alone; the hook appears to take a fee through return deltas and sends it to feeReceiver, but the rate and which trades pay more or less cannot be determined from the bytecode.
Owner & admin controls
The owner (slot 2) can transfer or renounce ownership and set the fee receiver via setFeeReceiver; it is not clear whether the owner can change fee rates or pause the hook.

Enabled Uniswap v4 callbacks

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

beforeInitialize sets up per-pool configuration; beforeSwap can return a delta to adjust swap amounts or charge a fee; afterAddLiquidity and afterRemoveLiquidity can return deltas to take or credit currency; the return-delta flags let the hook move currency.

Security & trust assessment

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

Who controls it: The owner can change the fee receiver and possibly fee parameters, and can transfer ownership to any address; a compromised owner key could redirect user-paid fees.

Risk to user funds: The hook can take tokens from swaps and liquidity actions through return deltas and the take call, so user and LP funds pass through hook-controlled logic.

Security findings

  • [high] Hook moves currency via return deltas: beforeSwap and liquidity callbacks have return-delta permissions and the bytecode calls take(address,address,uint256), so the hook can extract tokens from swaps and LP actions.
  • [medium] Owner can redirect fees: setFeeReceiver lets the owner change where collected fees go; a malicious owner could redirect all hook-collected value.
  • [medium] Owner controls not fully visible: Ownership can be transferred and renounced, and the owner-set uint16 values in slots 0 and 2 may control fee or threshold parameters that cannot be confirmed without source.
  • [info] Unnamed payable entry point: Selector 0xb8216c95 is payable and reads slots 0, 1, 3 and 4; its purpose is unknown from bytecode alone.

Contract details

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

Pools using Dynamic fee hook