Dynamic fee hook on MegaETH
Uniswap v4 Hook Contract 0xbd21e55ccf401add220f0cb4c42d0c2b9c5700c4 on MegaETH · 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
- 1
What it does
A Uniswap v4 hook that applies buy and sell fees to swaps in registered pools, with a launch-phase sniper fee and splits collected fees between treasury, team and protocol wallets.
This read was written for the hook 0xcfb6…00c4 on MegaETH and reused here: the two run the same code.
How it works step by step
- Gates swaps on pools registered by the owner via registerPool and unregisterPool
- Applies a buy fee or sell fee depending on swap direction, stored in the buyFee and sellFee slots
- Applies a higher SNIPER_FEE during an early launch window tied to launchTime and launched
- Takes its fee from swap output using afterSwapReturnDelta and transfers it onward in afterSwap
- Routes collected fees to treasuryWallet, teamWallet and protocolWallet, which the owner can change with setWallets
- Exposes owner-only controls for fee values (setFees), launch toggling (launch) and two-step ownership
- Swap behaviour
- beforeSwap checks pool registration and launch state; afterSwap collects a fee from the swap output via return delta and transfers it to the configured wallets.
- Liquidity behaviour
- beforeAddLiquidity, afterAddLiquidity, beforeRemoveLiquidity and afterRemoveLiquidity selectors exist in the dispatcher but are not enabled in the hook permissions, so the hook does not receive these callbacks.
- Fee behaviour
- Fees are stored in storage slots 2 and 3 (buyFee and sellFee, set via setFees, with MAX_FEE and SNIPER_FEE constants and a currentFee value). Based on the selectors, the hook appears to apply a direction-dependent fee, likely a higher sniper fee in an early launch window (launchTime, launched) and standard buy/sell fees afterwards. The hook returns a fee delta through afterSwapReturnDelta, so fees are taken from swap output, split between treasury, team and protocol wallets; exact split logic cannot be confirmed without source.
- Owner & admin controls
- Owner (Ownable2Step: transferOwnership, acceptOwnership, renounceOwnership) can call setFees to set buy/sell fee values, setWallets to change treasury, team and protocol fee recipient addresses, and registerPool/unregisterPool to control which pools are active. The owner can also call launch() to toggle the launched state.
Enabled Uniswap v4 callbacks
beforeSwap, afterSwap, afterSwapReturnDelta
beforeSwap: checks pool registration and launch state before swaps. afterSwap: takes fees from swap output via return delta and transfers them to treasury, team and protocol wallets. afterSwapReturnDelta: lets the hook adjust the swap's unspecified-currency amount to collect its fee.
Security & trust assessment
Risk level: medium, estimated (decoded bytecode, low confidence).
Who controls it: The owner can change buy and sell fees (up to MAX_FEE), redirect fee recipients via setWallets, and enable or disable pools via registerPool and unregisterPool. A malicious or compromised owner could set fees near the maximum on all pools or divert fee income to new addresses. Ownership is two-step transferable and can be renounced.
Risk to user funds: The hook takes a fee from swap output using return deltas and transfers it to configured wallets during afterSwap, so it can take and move user swap proceeds. It can also revert swaps through beforeSwap checks on pool registration and launch state, though it does not appear to hold user liquidity.
Security findings
- [medium] Owner-adjustable swap fees: The owner can change buyFee and sellFee through setFees, so trading costs can be raised for all users of registered pools, bounded by MAX_FEE.
- [medium] Owner-controlled fee recipients: setWallets lets the owner replace the treasury, team and protocol fee recipients, so future fees could be routed to an address the owner controls.
- [medium] Hook moves currency during swaps: The hook calls take and transfer on the pool manager and token contracts from afterSwap, so it can move currency in the swap path. A failing transfer could make swaps revert for registered pools.
- [info] Two-step ownership: Ownership is managed with an Ownable two-step pattern (pendingOwner, acceptOwnership), which reduces the risk of accidental ownership loss.
Contract details
- Verified source
- No
- Bytecode size
- 6,125 bytes
- Upgradeable proxy
- No
- Detected patterns
- moves-currency, ownable, return-delta
Pools using Dynamic fee hook
- HOMIE / WETH (0.00% fee) — 24h volume $0, TVL $0, 0 swaps today