Custom pricing hook on Ethereum

Uniswap v4 Hook Contract 0xbccb1d17b7c80b07a1693123a76dc7bf45f26dd0 on Ethereum · Custom pricing

Volume (24h)
$0
Value locked (TVL)
$0
All-time volume
$0
Pools using this hook
1
Swaps (24h)
299 (92 traders)
Total swaps
299

What it does

This hook sets a dynamic fee on swaps and gates liquidity additions and removals through an external gate contract, though the exact fee direction and who can change the gate could not be confirmed from the bytecode.

How it works step by step

  • Stores a gate address (setGate) and a pool reference set at deployment, with a deployer, builder and burner address recorded in storage slots 1 to 3
  • Records an opening sqrt price per pool when the pool is initialized (beforeInitialize) and reads it back through blockOpenSqrtPrice
  • Gates liquidity additions and removals through beforeAddLiquidity and beforeRemoveLiquidity, which are view functions that revert or allow based on the configured gate
  • Tracks a dynamic fee (currentFee, BASE_FEE) that is applied in beforeSwap, with a per-key uint64 mapping updated during swaps
  • Calls back into the PoolManager through creditPoolManager and extsload, indicating it can account for or credit balances outside the standard swap path
  • Runs afterSwap, afterAddLiquidity, afterRemoveLiquidity and afterDonate callbacks that update internal state and may move deltas
Swap behaviour
beforeSwap is nonpayable and applies a fee taken from the hook's stored currentFee value, and afterSwap updates per-pool state; the exact direction-based fee split cannot be determined from bytecode alone, so which trades pay more or less is not confirmed.
Liquidity behaviour
beforeAddLiquidity and beforeRemoveLiquidity are view functions that appear to check the gate and pool state before allowing liquidity changes; afterAddLiquidity and afterRemoveLiquidity are nonpayable and update hook state, and can return balance deltas via the creditPoolManager path.
Fee behaviour
Dynamic fee: the hook exposes currentFee and BASE_FEE and sets the swap fee in beforeSwap; the exact formula and how fees are split or shared could not be determined from decoded bytecode.
Owner & admin controls
setGate(address) is callable and writes the gate address in storage slot 0, which controls the liquidity gating checks. Access control on setGate could not be confirmed from bytecode, so it may be open to any caller unless a check exists in the code path not decoded here.

Enabled Uniswap v4 callbacks

beforeInitialize, beforeAddLiquidity, afterAddLiquidity, afterRemoveLiquidity, beforeSwap, afterSwap, afterDonate

beforeInitialize records the opening sqrt price for the pool; beforeAddLiquidity and beforeRemoveLiquidity gate liquidity changes; afterAddLiquidity and afterRemoveLiquidity update hook state after liquidity changes; beforeSwap sets the dynamic fee and afterSwap updates state after swaps; afterDonate updates state after donations.

Security & trust assessment

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

Who controls it: A key able to call setGate can change which gate contract controls liquidity; if the fee-setting path is also controllable, that key could alter swap pricing. Exact privileges could not be confirmed without verified source.

Risk to user funds: The hook can gate liquidity deposits and withdrawals and can apply credits through the PoolManager, so it can block or affect LP funds and swap settlement; the extent of fund movement could not be fully confirmed from decoded bytecode.

Security findings

  • [high] Unverified setGate access control: setGate(address) writes the gate address that controls beforeAddLiquidity and beforeRemoveLiquidity; no owner check could be confirmed in the decoded bytecode, so anyone who can call it might redirect or block liquidity changes.
  • [medium] Hook can credit the PoolManager: The bytecode references creditPoolManager(bool,uint256), so the hook can move accounting in the PoolManager, which affects how funds are settled for pool participants.
  • [medium] Dynamic fee set by hook: beforeSwap applies a fee from storage (currentFee), and the writer of that value could not be fully determined, so the fee could be changed by whoever controls the stored parameters.
  • [info] Liquidity changes gated by external contract: Add and remove liquidity both pass through a gate address, so an external contract can allow or block LP actions.

Contract details

Verified source
No
Bytecode size
4,011 bytes
Upgradeable proxy
No

Pools using Custom pricing hook