NFTXV4Hook on Ethereum

Uniswap v4 Hook Contract 0x477741f748395bb86d830283924332de918f2fc4 on Ethereum · Dynamic fee · Verified contract

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

What it does

A dynamic-fee Uniswap v4 hook for NFTX collection tokens that prices swaps with an owner-configurable LP fee, optional AMM fee, and fee donations to in-range liquidity, plus an on-pool oracle.

This read was written for the hook 0xaa49…afc4 on Robinhood Chain and reused here: the two share a code shape, so constants such as fees, owners and addresses can differ.

How it works step by step

  • Sets a dynamic per-swap LP fee: pool override or defaultFee, with optional flat-fee exemptions for specific origin addresses that can only lower the fee
  • Takes an optional AMM fee from the unspecified leg of each swap via afterSwapReturnDelta and credits it to ammBeneficiary through escrow
  • Donates queued protocol fees to in-range LPs before swaps and liquidity changes, deferring when no in-range liquidity exists
  • Records a truncated-tick oracle observation on every swap and skips it when the pool has no active liquidity
  • Blocks direct pool initialization and swaps on deregistered (sunset) collection pools, and mints initial liquidity via the canonical PositionManager
Swap behaviour
beforeSwap sets a dynamic LP fee (pool override, default 1%, optionally reduced by an origin exemption), flushes queued donations, and records an oracle observation. afterSwap takes an optional AMM fee from the unspecified leg and credits the AMM beneficiary.
Liquidity behaviour
beforeAddLiquidity requires the pool to be initialized and flushes any queued donation into the pool. afterAddLiquidity and afterRemoveLiquidity emit pool state updates. beforeRemoveLiquidity flushes queued donations. The hook takes no cut of liquidity operations. Initial full-range or single-sided liquidity is minted through the canonical PositionManager by the Locker flow.
Fee behaviour
Dynamic LP fee per swap: pool override if set, else defaultFee (1%), reduced by a flat-fee exemption for tx.origin if one is set (never raised), then optionally adjusted by the notifier. Fee is applied with OVERRIDE_FEE_FLAG. Additionally an AMM fee (ammFee, default zero) is taken from the unspecified leg of swaps and credited to ammBeneficiary via escrow. Queued protocol fees are donated to in-range LPs.
Owner & admin controls
Owner (solady Ownable, two-step handover) can set the default LP fee, per-pool LP fees, the AMM fee and its beneficiary, flat-fee exemptions per origin address, the notifier (external subscriber contract that can reject swaps and collection registrations), and oracle truncation caps and cardinality. Owner cannot pause swaps directly, but a notifier can revert swaps. Locker-only functions register, initialize and deregister collections.

Enabled Uniswap v4 callbacks

beforeInitialize, beforeAddLiquidity, afterAddLiquidity, beforeRemoveLiquidity, afterRemoveLiquidity, beforeSwap, afterSwap, afterSwapReturnDelta

beforeInitialize: blocks direct pool initialization so only the hook's own initializeCollection path can create pools. beforeAddLiquidity: enforces initialization and flushes pending donations. afterAddLiquidity: emits pool state. beforeRemoveLiquidity: flushes pending donations. afterRemoveLiquidity: emits pool state. beforeSwap: refuses deregistered pools, consults notifier, sets dynamic fee, flushes donations, records oracle observation. afterSwap: takes AMM fee from unspecified leg via return delta, credits beneficiary, notifies subscriber. afterSwapReturnDelta: lets the hook take an unspecified-currency delta after a swap.

Security & trust assessment

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

Who controls it: The owner can set any pool LP fee up to the V4 maximum, including 100%, which would make swaps uneconomic, and can set the AMM fee and beneficiary to siphon a share of every swap into an address it controls. The owner can attach a notifier that reverts swaps or collection registrations, effectively freezing trading. Flat-fee exemptions can be granted to any origin address. Ownership is a single key with two-step handover.

Risk to user funds: The hook holds queued donation fees and AMM fee escrow and can take an AMM fee from swap outputs. It pulls tokens via Permit2 only for the initial liquidity mint. Owner-set notifier and fee parameters can block swaps or redirect a fee share, but the hook does not hold LP positions themselves.

Security findings

  • [medium] Owner-controlled AMM fee taken on every swap: The owner can set the AMM fee up to the validated maximum and redirect it to any beneficiary, taking a cut from every swap's unspecified leg.
  • [medium] Notifier can block swaps and collection registration: The owner can attach a notifier whose validateSwap reverts, halting swaps for all pools. Notifier subscribers are explicitly trusted and their reverts are not isolated.
  • [low] Owner can reprice LP fees: Pool and default LP fees can be set by the owner up to the V4 maximum, which could make trades prohibitively expensive for traders.
  • [info] Hook holds and moves pool funds: The hook uses afterSwapReturnDelta and holds real token balances (donation reservoir, AMM fee escrow, Permit2 approvals). Permit2 allowances are scoped to exact amounts and current block, and are revoked after use.
  • [info] Oracle hardening measures: Oracle observations are skipped when pool liquidity is zero, and the truncated tick series is bounded by a per-observation cap, mitigating single-trade oracle manipulation.

Contract details

Verified source
Yes (NFTXV4Hook)
Compiler
solc 0.8.26+commit.8a97fa7a
Bytecode size
24,047 bytes
Upgradeable proxy
No
Detected patterns
donates, dynamic-fee, erc6909-claims, moves-currency, oracle, ownable, return-delta

Pools using NFTXV4Hook