Dynamic fee hook on Robinhood Chain

Uniswap v4 Hook Contract 0x40d251274e17d246c701f4ee2a21af79dc5b30c4 on Robinhood Chain · Dynamic fee

Volume (24h)
$190
Value locked (TVL)
$765
All-time volume
$2.26K
Pools using this hook
2
Swaps (24h)
11 (11 traders)
Total swaps
165

What it does

A Uniswap v4 hook that applies admin-configurable dynamic fees and takes a share of swap output for the protocol, with a kill switch and allowlisted pools.

This read was written for the hook 0x7a85…30c4 on Base 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

  • Allowlists pools through allowPool and checks them at initialization
  • Sets a dynamic LP fee bounded by MIN_LP_FEE and MAX_LP_FEE
  • Takes a hook fee in basis points from swap output via return delta
  • Enforces a maximum swap amount and an owner or guardian kill switch
  • Tracks per-address accounting in afterSwap
  • Allows the owner to withdraw accumulated tokens to a treasury
Swap behaviour
beforeSwap checks the kill switch and swap size limit and may set a dynamic LP fee; afterSwap updates accounting and afterSwapReturnDelta routes a portion of the swap output to the hook as a fee.
Liquidity behaviour
beforeAddLiquidity, afterAddLiquidity, beforeRemoveLiquidity and afterRemoveLiquidity are present as selectors but their behaviour is not confirmed; they are not listed as enabled permissions, so the hook is not expected to act on liquidity changes.
Fee behaviour
Fees appear to be dynamic: the hook stores an LP fee (lpFee, bounded by MIN_LP_FEE and MAX_LP_FEE), a hook fee in basis points (hookFeeBps, currentHookFeeBps) and an oracle deviation threshold (oracleDeviationBps). Afterwards it takes a share of swap output via afterSwapReturnDelta, so part of the swap is diverted to the hook as a fee.
Owner & admin controls
Owner-gated functions (per selector set) include setGuardian, allowPool, setKill, withdraw and a fee/parameter setter taking (uint24,uint16) and another taking (uint128,uint16); the owner can toggle a kill switch, allowlist pairs, change the guardian and set LP/hook fee parameters. Exact access checks cannot be confirmed without source.

Enabled Uniswap v4 callbacks

beforeInitialize, afterInitialize, beforeSwap, afterSwap, afterSwapReturnDelta

beforeInitialize and afterInitialize check or register pools (allowedPairs mapping written by allowPool); beforeSwap reads the kill switch and swap limit (maxSwapAmountIn) and may compute the dynamic fee; afterSwap updates per-address accounting and computes the hook fee; afterSwapReturnDelta lets the hook take a portion of the swap output as a return delta.

Security & trust assessment

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

Who controls it: The owner or guardian can set the kill switch to halt swaps, change the LP and hook fee levels within the bounds the code allows, add or remove allowed pairs, change the guardian, and withdraw accumulated funds. A compromised owner key could raise fees and redirect hook-held tokens to the treasury.

Risk to user funds: The hook can hold and withdraw tokens taken from swap output (via afterSwapReturnDelta and afterSwap accounting) and can block swaps through the kill switch. Pool liquidity itself is not expected to be moved by the hook, but swap proceeds routed through the hook are exposed to its owner-controlled withdrawal.

Security findings

  • [medium] Hook takes swap output via return delta: afterSwapReturnDelta is enabled, so the hook takes tokens from swap outputs and holds or forwards them, which means swaps for the pool depend on the hook's accounting being correct.
  • [medium] Privileged kill switch can block swaps: A setKill function and a guardian role exist, so a privileged key can halt swaps through beforeSwap.
  • [medium] Owner can withdraw hook-held tokens: A withdraw(address) function lets a privileged account move tokens the hook has collected.
  • [low] Fee parameters are admin-adjustable: Fee parameters are set by admin-callable functions, so the owner can change the fee charged on swaps within the code's bounds.
  • [info] No verified source: Analysis is based only on decoded bytecode and selectors without verified source, so exact logic and access checks are uncertain.

Contract details

Verified source
No
Bytecode size
9,326 bytes
Upgradeable proxy
No
Detected patterns
return-delta

Pools using Dynamic fee hook