StablePairHook on Arbitrum

Uniswap v4 Hook Contract 0x630e9cac0fff557bd3a01daa111ed253c771bcc0 on Arbitrum · Dynamic fee · Verified contract

Volume (24h)
$327.19K
Value locked (TVL)
$1.01M
All-time volume
$3.45M
Pools using this hook
1
Swaps (24h)
43 (32 traders)
Total swaps
436

What it does

A dynamic-fee hook for stable-pair pools that charges swappers a fee based on how far the pool price has drifted from a reference price, with fees near zero for trades that restore the peg and higher fees for trades that push it further away.

How it works step by step

  • Sets a per-pool reference sqrt price representing the expected peg between the two assets.
  • Computes a dynamic LP fee each swap so pre-impact buy and sell prices stay within an optimal band around the reference.
  • Outside the band, applies an exponentially decaying fee toward a target on swaps that push price back toward the reference.
  • Charges zero fee on swaps that move price further from the reference, so arbitrage-free exits are not penalised.
  • Caches the start-of-block price per pool to prevent splitting a swap across transactions in one block to avoid fees.
  • Restricts pool creation to the hook's initializer entrypoint and requires dynamic fee pools.
Swap behaviour
On each swap the hook reads the pool price (cached at the start of the block), computes the fee for the swap direction, and overrides the LP fee. Inside the optimal range the fee aligns pre-impact prices to the band. Outside the range the decaying fee applies only to swaps that move price back toward the reference, and swaps moving it further away pay zero. The first swap in each block refreshes the cached price and decaying fee state.
Liquidity behaviour
Hook callbacks before and after add liquidity are inert defaults that return the selector without changing state. Remove-liquidity callbacks are disabled, so withdrawals are never blocked or altered by the hook.
Fee behaviour
Dynamic LP fee computed per swap from the pool's price deviation versus a reference sqrt price. Inside an optimal range the fee is set so pre-impact buy and sell prices stay consistent with the reference band. Outside the range the fee is a decaying fee toward a target, charged only on swaps that move price back toward the reference (swaps moving price further away pay zero). Fees are capped at just under 100% (MAX_FEE_E6) and rounded up to whole pips. The fee is size-independent and no protocol fee is taken by the hook.
Owner & admin controls
Proxy upgrades and all role grants are controlled by DEFAULT_ADMIN_ROLE (upgradeToAndCall, grantRole, revokeRole). CONFIG_MANAGER_ROLE can update per-pool fee configuration (k, optimalFeeE6, targetMultiplier, referenceSqrtPriceX96) via updateFeeConfig and batchUpdateFeeConfig. POOL_INITIALIZER_ROLE can initialize new pools through initializePool. No pause function was found.

Enabled Uniswap v4 callbacks

beforeInitialize, afterInitialize, beforeAddLiquidity, afterAddLiquidity, beforeSwap, afterSwap

beforeInitialize reverts on direct PoolManager initialization so pools must go through initializePool. afterInitialize is enabled but does not run in the normal flow because initializePool self-calls the PoolManager. beforeAddLiquidity and afterAddLiquidity are inert defaults with no effect. beforeSwap computes and overrides the dynamic LP fee. afterSwap is an inert default that returns zero.

Security & trust assessment

Risk level: medium (verified source, high confidence).

Who controls it: DEFAULT_ADMIN_ROLE can replace the implementation with arbitrary logic that could move or trap pool and user funds, or change any pool's reference price and fee parameters. CONFIG_MANAGER_ROLE can set k, optimalFeeE6 and targetMultiplier per pool, which changes swap fees (bounded by the on-chain validation, with the fee capped near 100%) and can be used to make swaps very expensive or to shift the reference price. POOL_INITIALIZER_ROLE can create pools that use this hook.

Risk to user funds: The hook itself does not hold or move funds and cannot block withdrawals. User exposure arises through the upgrade path, where a malicious or compromised admin could deploy an implementation that moves or traps funds, and through CONFIG_MANAGER_ROLE changing fees on swaps.

Security findings

  • [high] Upgradeable implementation controlled by a single admin role: The proxy is UUPS upgradeable and the admin can swap the implementation at any time. Hook behaviour, and anything that touches pool assets, can change without a user-visible migration.
  • [medium] Fee parameters are changeable by a privileged role: Config managers can change the per-pool fee parameters, which directly change what swappers pay. Validation bounds optimalFeeE6 to at most 1% and clamps fees, but targetMultiplier and k can still materially change pricing within those bounds.
  • [low] Cached price can be stale within a block: Fee state caches the start-of-block price, and with zero active liquidity the price can move freely within a block. The source documents that a same-block corrective swap can be charged zero fee until the next block. This is a documented tradeoff rather than a fund-loss path.
  • [info] Hook does not directly custody funds: The hook never takes tokens via return deltas, and remove-liquidity and donate flags are disabled, so the hook cannot hold, move or block pool funds directly. Exposure comes only through upgrade authority and fee changes.

Contract details

Verified source
Yes (StablePairHook)
Compiler
solc 0.8.26+commit.8a97fa7a
Bytecode size
135 bytes
Upgradeable proxy
Yes
Detected patterns
dynamic-fee, upgradeable

Pools using StablePairHook