Custom pricing hook on Optimism

Uniswap v4 Hook Contract 0x886320ad4632fb8d675e54e4c2abf2b900f98088 on Optimism · Custom pricing

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

What it does

A single-pool custom AMM hook where swaps are priced by an external price engine and filled from the hook's own ETH and USDC inventory held in the PoolManager, rather than from the pool's liquidity.

How it works step by step

  • Overrides every swap via beforeSwap and returns a custom delta, so the pool's curve is not used
  • Prices swaps by calling getQuote on an owner-set external price engine contract
  • Enforces a price sanity range of 10 to 50000 USDC on each quote
  • Mints input and burns output ERC6909 claims on the PoolManager to settle the swap
  • Lets the owner deposit ETH or ERC20 inventory into the PoolManager via depositToUniv4
  • Lets the owner withdraw inventory to any address via withdrawFromUniv4 and the unlock callback
Swap behaviour
beforeSwap fetches a quote from the price engine, mints the input currency to the hook and burns the output currency from the hook's own ERC6909 balance, then returns a delta that settles the swap. Exact-input and exact-output swaps are both handled, and each emits a HookSwap event.
Liquidity behaviour
No liquidity callbacks. The hook does not hook add or remove liquidity; liquidity is supplied to the PoolManager as ERC6909 balances by the owner through depositToUniv4 and withdrawn through withdrawFromUniv4.
Fee behaviour
Uses the pool's static fee for LP fee purposes (beforeSwap returns fee 0 override). The hook does not take a fee of its own; swap pricing is set entirely by the external price engine quote.
Owner & admin controls
Owner address is hardcoded (0x1ef9...32d0). Only the owner can call setPriceEngine to swap the external price engine contract, and depositToUniv4 / withdrawFromUniv4 to move the hook's own ERC6909 balances in and out of the PoolManager. Owner-restricted functions also require tx.origin to be the owner in unlockCallback. No pause, upgrade proxy, or ownership transfer function was found.

Enabled Uniswap v4 callbacks

beforeSwap, beforeSwapReturnDelta

beforeSwap: prices and executes every swap against the hook's own ERC6909 inventory by minting input claims and burning output claims. beforeSwapReturnDelta: returns a custom delta so the swap is settled by the hook's inventory instead of the pool's liquidity curve.

Security & trust assessment

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

Who controls it: The owner controls the price engine address, which determines every swap price via getQuote and therefore the value of the hook's inventory. A malicious or compromised engine could quote arbitrary prices. The owner can also withdraw the entire ERC6909 inventory at will and deposit funds, so the owner has full custody of the liquidity.

Risk to user funds: The hook holds ERC6909 claims for ETH and USDC on the PoolManager and fills all swaps from them. Traders are exposed to the price engine's quotes, and the owner can withdraw the inventory, so user funds are only as safe as the owner key and the engine contract.

Security findings

  • [high] Owner-controlled price engine: Swap prices come from an owner-settable external priceEngine contract. Replacing the engine with a malicious one lets the owner dictate execution prices for every swap.
  • [high] Owner can drain inventory: withdrawFromUniv4 lets the owner burn the hook's ERC6909 claims and take the underlying tokens to any recipient at any time, with no timelock or limits.
  • [medium] Hardcoded owner with tx.origin check: unlockCallback requires tx.origin to equal the owner, and the owner address is hardcoded with no transfer or rotation path. Loss or compromise of that key is irreversible and tx.origin checks can be bypassed by contract wallets only in the owner's own transactions.
  • [info] Swaps bypass pool liquidity: The hook returns a beforeSwap delta that fully replaces the pool curve, so swaps settle against the hook's inventory and LPs in the pool do not earn the swap fees they would normally receive.
  • [info] Hardcoded price range check: Price bounds are hardcoded to between 10 and 50000 USDC (in 6-decimal units) on quoted prices, which can cause swaps to revert outside that range.

Contract details

Verified source
No
Bytecode size
13,237 bytes
Upgradeable proxy
No
Detected patterns
erc6909-claims, moves-currency, return-delta, self-unlock

Pools using Custom pricing hook