Custom pricing hook on Base

Uniswap v4 Hook Contract 0xc7087b5edbc7230766e6bd4980d4935eac2320cc on Base · Custom pricing

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

What it does

This hook charges a configurable toll on swaps in a pool, collected through the swap's return deltas and capped by a maximum rate, so traders pay the toll on the trades it covers while liquidity actions are left untouched.

How it works step by step

  • Stores a per-pool toll in basis points keyed by pool id, with a base toll (BASE_TOLL_BPS) and a cap (MAX_TOLL_BPS) exposed as constants
  • Takes a toll on swaps through beforeSwap/afterSwap return deltas, so the toll is settled against the swap rather than charged as a separate fee
  • Tracks totals (totalSwaps, totalToll, per-pool stats) and a reserve balance on-chain
  • Limits single buys via a MAX_BUY cap and reverts with BuyTooLarge when exceeded
  • Records a buys mapping per address and a poolAt/poolCount registry of initialized pools
  • Calls take() on the pool manager to collect toll currency, and gates initialization to canonical pools
Swap behaviour
beforeSwap computes a toll in bps from the stored tollBps for the pool and can return a before-swap delta to take part of the input; afterSwap can adjust the output delta and updates swap and toll counters. The exact direction of the toll (input versus output token, buys versus sells) cannot be fully determined from decoded bytecode alone; a buy-size cap applies to buyers.
Liquidity behaviour
beforeAddLiquidity, afterAddLiquidity, beforeRemoveLiquidity and afterRemoveLiquidity exist as selectors, but their bodies appear to be pass-through checks with no delta return; no liquidity fees or currency movement were identified for them.
Fee behaviour
Pools keep a static fee in the key; the hook layers a toll on top via return deltas stored per pool (tollBps), with a base rate and a MAX_TOLL_BPS cap, and accumulates collected amounts in totalToll and reserve.
Owner & admin controls
An OPERATOR() address and a token() address are exposed, suggesting operator-restricted functions such as setting tollBps or withdrawing reserve; the exact access checks cannot be confirmed without source. No proxy or upgrade selectors were identified.

Enabled Uniswap v4 callbacks

beforeInitialize, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta

beforeInitialize validates and records new pools; beforeSwap computes and applies the toll via a before-swap return delta; afterSwap settles the after-swap return delta and updates stats; beforeSwapReturnDelta and afterSwapReturnDelta allow the hook to move currency in the pool accounting.

Security & trust assessment

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

Who controls it: An operator key can likely change toll rates and move accumulated reserve funds; the exact privileges could not be verified without source.

Risk to user funds: The hook holds collected toll balances in reserve and takes currency from swaps via return deltas; user swaps are subject to the toll and can revert on the buy cap, but the hook does not appear to hold LP principal.

Security findings

  • [medium] Hook takes currency via return deltas: beforeSwapReturnDelta and afterSwapReturnDelta are enabled and the bytecode calls take() on the pool manager, so the hook can extract part of every swap's currency into its own balance.
  • [medium] Operator-tunable toll: Per-pool tollBps is stored in mutable storage and bounded only by MAX_TOLL_BPS; an operator key that can change it could raise the toll up to the cap on live pools.
  • [low] Reserve withdrawal path: The contract tracks a reserve balance and token address; if an operator can withdraw reserve funds, collected tolls are controlled by that key.
  • [info] Buy size cap: MAX_BUY and BuyTooLarge revert limit individual buys, which can block large swaps by design.

Contract details

Verified source
No
Bytecode size
7,949 bytes
Upgradeable proxy
No
Detected patterns
moves-currency, return-delta, tax

Pools using Custom pricing hook