Dynamic fee hook on Ethereum

Uniswap v4 Hook Contract 0xbad02c0d01918f8650befbcf92380c63d294e044 on Ethereum · Dynamic fee

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

What it does

A Uniswap v4 hook that charges an owner-configurable fee on swaps and routes the collected proceeds to a fee recipient address.

How it works step by step

  • Validates pool initialization in beforeInitialize and exposes initializePool for the owner to start a pool.
  • Computes a swap fee in afterSwap using two uint16 fee parameters stored in the hook.
  • Takes the fee from the swap output through afterSwapReturnDelta and transfers it via take to the feeRecipient.
  • Lets the owner update fee parameters with updateFees and the fee recipient with setFeeRecipient.
  • Provides retrieveStuckEth so the owner can recover native ETH held by the contract.
Swap behaviour
After each swap, afterSwap computes a fee from the swap, takes it through afterSwapReturnDelta and moves it to feeRecipient, with rates read from storage that the owner can update.
Liquidity behaviour
No liquidity callbacks.
Fee behaviour
Fees are configurable by the owner via updateFees(uint16,uint16); the afterSwap path reads two uint16 values from storage slot 3 (offsets 21 and 23) and the hook takes a fee portion of swap output through a return delta and transfers it to feeRecipient.
Owner & admin controls
Owner (Ownable2Step: transferOwnership then acceptOwnership) can call updateFees(uint16,uint16) to set fee parameters, setFeeRecipient(address) to redirect fee proceeds, initializePool(uint160) to initialize the pool, retrieveStuckEth(address,uint256) to withdraw funds, and renounceOwnership(). No pause or upgrade functions were identified.

Enabled Uniswap v4 callbacks

beforeInitialize, afterSwap, afterSwapReturnDelta

beforeInitialize validates pool initialization; afterSwap computes and takes a fee from the swap and applies it via afterSwapReturnDelta; afterSwapReturnDelta lets the hook alter the swap's settled amounts.

Security & trust assessment

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

Who controls it: The owner can change fee rates through updateFees, redirect all collected fees via setFeeRecipient, and withdraw ETH via retrieveStuckEth. Ownership is transferable and renounceable, so a compromised owner key could change the economics of every swap routed through this pool.

Risk to user funds: The hook moves currency during afterSwap, taking a fee via return delta and transferring it to feeRecipient, and may hold ETH that the owner can withdraw. It does not appear to block swaps, but the owner can change the fee rate that applies to user swaps.

Security findings

  • [medium] Owner-adjustable swap fee: afterSwapReturnDelta lets the hook take a portion of each swap output, and the owner controls the fee rate with updateFees, so the owner can raise the fee to extract user value.
  • [low] Owner can redirect fee proceeds: setFeeRecipient allows the owner to redirect collected fees to any address at any time.
  • [low] Owner can withdraw ETH held by hook: retrieveStuckEth lets the owner withdraw native ETH held by the hook, which could include fees accrued from swaps.
  • [info] Ownable two-step access control: The hook uses an Ownable pattern with two-step transfer and renounce, which limits accidental ownership loss but does not remove the trust assumption on the owner key.

Contract details

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

Pools using Dynamic fee hook