Dynamic fee hook on BNB Chain

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

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 on BSC that applies tiered dynamic fees on swaps and takes a share of swap and liquidity flows, with the owner able to adjust fee parameters and withdraw collected tokens.

This read was written for the hook 0x1268…c5c7 on BNB Chain and reused here: the two run the same code.

How it works step by step

  • Stores three fee tiers as packed uint24 values in storage slot 2 and protocol and LP basis-point splits in slot 3.
  • Applies a tier fee in beforeSwap through the swap path.
  • Splits collected fees between the protocol and LPs using splitFee and the BPS parameters.
  • Uses return-delta hooks on swaps and liquidity events to take a portion of token flows.
  • Lets the owner update fee tiers, the gas threshold, the recipient, and the quoter.
  • Lets the owner withdraw tokens held by the hook.
Swap behaviour
beforeSwap sets a tiered fee for each swap based on stored tier values, and afterSwap distributes the collected fee between protocol and LP shares, with afterSwapReturnDelta letting the hook take tokens from the swap.
Liquidity behaviour
afterAddLiquidity and afterRemoveLiquidity run with return-delta permissions, so the hook can return a balance delta on liquidity changes, possibly taking a fee or redistributing amounts. beforeAddLiquidity and beforeRemoveLiquidity exist as view stubs and do not modify state.
Fee behaviour
Fees appear to be dynamic and tiered: the hook reads packed uint24 tier fees (tierOne, tierTwo, tierThree) and uint16 protocol and LP basis-point splits (protocolBps, lpBps) from storage, and a splitFee function divides a fee between protocol and LPs. Fee tier selection likely depends on swap size or pool conditions read in beforeSwap, but the exact tier logic cannot be determined from bytecode alone.
Owner & admin controls
Owner (slot 0) can transfer ownership, set the fee recipient (setRecipient), set the quoter (setQuoter), set the gas threshold (setGasThreshold), withdraw tokens held by the hook (withdraw), and update fee tiers and BPS parameters via selector 0x705a571a (uint24/uint16 config setter, nonpayable). Admin functions appear gated by an owner check, which is inferred from the Ownable tag and storage slot 0 usage, not confirmed in source.

Enabled Uniswap v4 callbacks

afterAddLiquidity, afterRemoveLiquidity, beforeSwap, afterSwap, afterSwapReturnDelta, afterAddLiquidityReturnDelta, afterRemoveLiquidityReturnDelta

afterAddLiquidity: post-deposit hook, can adjust balances via return delta. afterRemoveLiquidity: post-withdrawal hook, can adjust balances via return delta. beforeSwap: sets per-swap fee/tier logic before execution. afterSwap: post-swap accounting and fee distribution. afterSwapReturnDelta: the hook can take or give tokens after a swap. afterAddLiquidityReturnDelta and afterRemoveLiquidityReturnDelta: the hook can take or give tokens on liquidity events.

Security & trust assessment

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

Who controls it: The owner can change fee tiers and split parameters, change the fee recipient and quoter, and withdraw tokens the hook holds. A malicious or compromised owner could redirect fees to a new recipient, set fees high to extract value from swappers, or drain accumulated balances.

Risk to user funds: The hook can hold tokens from swap and liquidity return deltas and the owner can withdraw them, so pool participants' value flowing through the hook is exposed to owner action. The hook does not appear to block swaps or liquidity directly, based on the view-only before-liquidity stubs.

Security findings

  • [medium] Return-delta permissions allow the hook to take tokens: Hook uses afterSwapReturnDelta and afterAddLiquidityReturnDelta/afterRemoveLiquidityReturnDelta, so it can take a cut of swap and liquidity flows and hold those tokens.
  • [medium] Owner can withdraw hook-held tokens: Selector 0xd9caed12 withdraw(address,address,uint256) is callable by the owner and moves tokens held by the hook.
  • [medium] Owner can change fee parameters: Selector 0x705a571a sets tier fees and split BPS values and is nonpayable with no visible bounds in the decoded signature; a high fee value could be set by the owner.
  • [low] Single-owner control with no visible timelock: Selector 0xf2fde38b transferOwnership and setRecipient/setQuoter allow a single key to redirect fees and routing.
  • [info] Access control inferred, not verified: Owner-gated functions are inferred from storage slot 0 usage and the Ownable heuristic; no source confirms the access checks.

Contract details

Verified source
No
Bytecode size
10,729 bytes
Upgradeable proxy
No
Detected patterns
ownable, return-delta

Pools using Dynamic fee hook