Dynamic fee hook on Base
Uniswap v4 Hook Contract 0x661c7a79b59032b6901d711dafe4e2797e81a58b on Base · Dynamic fee
- Volume (24h)
- $0
- Value locked (TVL)
- $0.02
- All-time volume
- $0
- Pools using this hook
- 1
- Swaps (24h)
- 0 (0 traders)
- Total swaps
- 0
What it does
This hook sets a dynamic fee on swaps and can take a share of trades and liquidity activity for a fee receiver, but the exact trades that pay more or less cannot be confirmed without source.
How it works step by step
- Runs in beforeSwap and sets a per-swap dynamic fee override for the pool, using two uint16 fee parameters stored in slots 0 and 2
- Uses beforeSwapReturnDelta so it can take a share of swap amounts as a return delta and move currency to itself via take()
- Tracks per-pool or per-id debt in a nested mapping (slot 1) and an accumulator in slot 3, updated after liquidity adds and removes via the return-delta callbacks
- Forwards or accrues collected value to a fee receiver address stored in slot 0 and set through setFeeReceiver
- Exposes owner-gated setters for its two uint16 parameters (selectors 0x534eb4cf and 0xcb9442e2) and a payable entry point 0xb8216c95 that touches the debt mapping
- Initializes per-pool configuration in beforeInitialize
- Swap behaviour
- beforeSwap computes a dynamic fee from stored uint16 parameters and may take a portion of the swap as a return delta; which trades pay more or less cannot be determined from bytecode alone.
- Liquidity behaviour
- afterAddLiquidity and afterRemoveLiquidity run with return-delta permissions, so they can settle or adjust debt and move currency in the hook; exact accounting cannot be fully determined without source.
- Fee behaviour
- Dynamic fee set in beforeSwap from owner-configured uint16 parameters; a fee receiver address (slot 0 offset 4) can receive collected value.
- Owner & admin controls
- Owner (slot 2) can transfer or renounce ownership, change the fee receiver, and update the uint16 fee parameters.
Enabled Uniswap v4 callbacks
beforeInitialize, afterAddLiquidity, afterRemoveLiquidity, beforeSwap, beforeSwapReturnDelta, afterAddLiquidityReturnDelta, afterRemoveLiquidityReturnDelta
beforeInitialize sets up pool state; beforeSwap returns a dynamic fee override and a swap return delta; afterAddLiquidity and afterRemoveLiquidity return liquidity deltas that move currency or debt; beforeSwapReturnDelta and the two liquidity return-delta flags allow the hook to take or give tokens.
Security & trust assessment
Risk level: high, estimated (decoded bytecode, low confidence).
Who controls it: The owner key can change fees, set the fee receiver, and transfer or renounce ownership, so a compromised key could redirect collected value or make swaps prohibitively expensive.
Risk to user funds: The hook can take tokens through return deltas in swaps and liquidity operations and tracks debt in storage, so it can hold or move pool and user funds.
Security findings
- [medium] Owner-set dynamic fee: The owner can change uint16 fee parameters in slots 0 and 2, which control the fee applied in beforeSwap; an extreme value could make swaps very expensive.
- [high] Return-delta currency movement: beforeSwapReturnDelta and liquidity return-delta flags let the hook take tokens from swaps and liquidity operations via take(), so the hook holds or redirects user funds.
- [medium] Fee receiver redirection: The owner can set the fee receiver, so any value the hook collects can be redirected by the owner.
- [info] Unverified source: No verified source is available; behaviour is inferred from decoded selectors and storage, so exact logic and edge cases are uncertain.
Contract details
- Verified source
- No
- Bytecode size
- 13,513 bytes
- Upgradeable proxy
- No
- Detected patterns
- dynamic-fee, moves-currency, ownable, return-delta
Pools using Dynamic fee hook
- ETH / USDC (0.00% fee) — 24h volume $0, TVL $0.02, 0 swaps today