Dynamic fee hook on Ethereum

Uniswap v4 Hook Contract 0x322d4f640a5263fc4e28c3896009502453d620cc on Ethereum · Dynamic fee

Volume (24h)
$701
Value locked (TVL)
$5.20K
All-time volume
$844.15K
Pools using this hook
2
Swaps (24h)
6 (2 traders)
Total swaps
975

What it does

LiquidGuard skims a configurable RARE-denominated fee from swaps in pools that pair RARE with a Liquid token and forwards it to a fee distributor.

This read was written for the hook 0x8ff5…e0cc on Ethereum 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

  • Charges totalFeeBPS on RARE amounts in swaps across RARE/Liquid pools
  • Takes the fee from PoolManager and transfers it to feeDistributor
  • Notifies the distributor of each fee and continues if the notification fails
  • Returns the fee as a hook delta in beforeSwap or afterSwap so PoolManager accounting nets to zero
  • Restricts pool initialization to allowlisted initializer addresses
Swap behaviour
On swaps where RARE is the specified currency, beforeSwap takes the fee via PoolManager and returns it as a specified delta; on swaps where RARE is the unspecified currency, afterSwap takes the fee and returns it as an unspecified delta. Non-RARE pools and zero-amount or zero-fee swaps pass through unchanged.
Liquidity behaviour
No liquidity callbacks.
Fee behaviour
A RARE-side fee of totalFeeBPS (set from the feeDistributor) is taken on swaps where RARE is the specified currency in beforeSwap or the unspecified currency in afterSwap, computed on the absolute swap amount and clamped below the swap amount. The fee is sent to feeDistributor via PoolManager.take and the distributor is notified; if no distributor is set, no fee is charged.
Owner & admin controls
Owner (Ownable) can set feeDistributor via setFeeDistributor, which also sets totalFeeBPS from the distributor's value (must be at most 10000); owner or factory can add initializers to the beforeInitialize allowlist; only owner can set factory, remove initializers and transfer or renounce ownership. No pause or upgrade mechanism is present; the contract is not a proxy.

Enabled Uniswap v4 callbacks

beforeInitialize, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta

beforeInitialize restricts pool initialization to allowlisted sender addresses. beforeSwap takes the RARE fee when RARE is the specified currency and returns it as a specified-side delta. afterSwap takes the fee when RARE is the unspecified currency and returns it as an unspecified delta. beforeSwapReturnDelta and afterSwapReturnDelta enable those returned deltas.

Security & trust assessment

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

Who controls it: The owner can set the feeDistributor and totalFeeBPS (up to 100% of RARE swap amounts, since the clamp keeps fee below the swap amount), redirect fee recipients, and grant or revoke pool-initialization rights. Factory can also add initializers.

Risk to user funds: The hook takes RARE from PoolManager on each eligible swap and sends it to feeDistributor, so it moves trader and pool value. It does not custody funds itself, and the owner can change where fees go and how large they are, but it cannot block swaps except via the distributor's totalFeeBPS being invalid during configuration.

Security findings

  • [medium] Owner can set fee up to 100%: setFeeDistributor lets the owner set totalFeeBPS to any value up to 10000 (100%) by pointing to a distributor that reports it, taking nearly all RARE swap value from traders.
  • [low] No timelock on fee and distributor changes: The hook is deployed with a mined address and the fee and distributor can be swapped at any time by the owner, with no timelock or cap below 100%.
  • [info] Distributor failure does not revert swaps: Fee notification is wrapped in try/catch and emits FeeNotifyFailed, so distributor failures do not block swaps, but the take still sends RARE to the distributor address.
  • [info] Initialization allowlist: Pool initialization is restricted to allowlisted senders, so only whitelisted Liquid token contracts can create pools with this hook.

Contract details

Verified source
No
Bytecode size
4,286 bytes
Upgradeable proxy
No
Detected patterns
moves-currency, ownable, return-delta

Pools using Dynamic fee hook