NFTXV4Hook on Ethereum
Uniswap v4 Hook Contract 0xd2094b5cdb1a12b6274e4a4d3a252cd94c51efcc 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
- 25
What it does
A Uniswap v4 hook for NFTX collection pools that sets a dynamic LP fee (default 1%, overridable per pool and per origin), distributes queued fees to LPs as donations, takes an optional AMM fee on swaps, and records a TWAP oracle.
How it works step by step
- Creates collection/native pools with dynamic fee and tick spacing 60 via initializeCollection, minting an initial position through the v4 PositionManager
- Sets the LP fee per swap from a pool-specific fee, a default fee, or a lower flat exemption keyed on tx.origin
- Donates queued collection-fee deposits to LPs before swaps, adds and removes
- Takes an optional AMM fee from the unspecified currency in afterSwap and escrows it for a beneficiary
- Maintains a Uniswap-style tick TWAP oracle with observe and cardinality increase
- Blocks direct pool initialization outside the locker flow
- Swap behaviour
- beforeSwap sets the dynamic LP fee, donates any queued fees to LPs and writes an oracle observation. afterSwap takes the optional AMM fee (initially zero) from the unspecified currency and credits it to the AMM beneficiary, then emits a pool state update.
- Liquidity behaviour
- beforeAddLiquidity requires the pool to be initialized and first distributes queued fees as a donation to LPs. afterAddLiquidity emits a pool state update. beforeRemoveLiquidity also distributes queued fees, and afterRemoveLiquidity emits a state update. The hook does not alter liquidity amounts or take liquidity-related deltas.
- Fee behaviour
- Swap LP fee is resolved in beforeSwap: pool-specific fee if set, otherwise defaultFee (1%). A per-origin flat-fee exemption (keyed on tx.origin) can lower it. The fee is returned with the OVERRIDE flag, so it is dynamic per swap. A separate AMM fee of ammFee (from the unspecified leg, credited to ammBeneficiary via TokenEscrow) is taken in afterSwap and is initially zero. Queued fees are donated to LPs before swaps, adds and removes.
- Owner & admin controls
- Owner (set at deployment via Solady Ownable, supports two-step handover) can set the default LP fee (setDefaultFee, validated against the v4 max), per-pool fees (setFee), the AMM fee taken on every swap (setAmmFee, validated) and its beneficiary (setAmmBeneficiary), and per-address flat-fee exemptions (setFeeExemption, removeFeeExemption). Owner can change fees instantly with no timelock or cap beyond the v4 fee validation. No pause or upgrade mechanism found; the contract is not a proxy.
Enabled Uniswap v4 callbacks
beforeInitialize, beforeAddLiquidity, afterAddLiquidity, beforeRemoveLiquidity, afterRemoveLiquidity, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta
beforeInitialize: reverts any direct pool initialization so only the initializeCollection path can create pools. beforeAddLiquidity / beforeRemoveLiquidity: enforce initialization and distribute pending fee donations to LPs. afterAddLiquidity / afterRemoveLiquidity: emit pool state events. beforeSwap: sets the dynamic LP fee, distributes pending donations, and writes a TWAP oracle observation. afterSwap: takes the AMM fee from the unspecified currency via a return delta and credits the beneficiary. beforeSwapReturnDelta and afterSwapReturnDelta are enabled because afterSwap returns a hook delta that the pool manager applies.
Security & trust assessment
Risk level: medium (verified source, high confidence).
Who controls it: The owner can set any valid LP fee up to the v4 maximum (including a very high default or per-pool fee) and an AMM fee up to the validated maximum, and can redirect that AMM fee to any beneficiary address. Changes are immediate with no timelock. The owner can also grant itself or others fee exemptions to pay lower fees. A compromised owner key could therefore raise fees on all pools or divert AMM fee revenue.
Risk to user funds: The hook takes its AMM fee from swap output via return delta, and pulls queued donation tokens into the pool on each swap and liquidity action. It holds only transient balances while settling, and tokens for initial liquidity are pulled from the locker and refunded. Its owner cannot directly withdraw pool liquidity or user escrow balances as observed in the source, but owner fee changes can significantly reduce what swappers and LPs receive.
Security findings
- [medium] Owner can change swap fees instantly: owner can set setDefaultFee, setFee and setAmmFee to any value accepted by v4 validation, with no timelock or cap, so swappers can be charged up to the maximum LP fee immediately.
- [medium] Owner-controlled AMM fee and beneficiary: afterSwap takes ammFee from the unspecified leg and credits ammBeneficiary; the owner can set both the rate and the recipient at any time, so swap proceeds can be redirected.
- [low] Fee queue donations on every swap and liquidity action: beforeSwap pulls pending fee amounts and donates them to LPs, and depositFees is callable by any caller to queue donations. Tokens from the locker are pulled in via transferFrom, so queued amounts depend on the caller's approvals.
- [low] Fee exemption keyed on tx.origin: fee exemptions are keyed on tx.origin, so a whitelisted EOA gets its lower fee on any swap it initiates, including through contracts it controls.
- [info] Return-delta fee capture: the hook uses beforeSwapReturnDelta and afterSwapReturnDelta to take fees from the unspecified currency, which is a standard v4 pattern but means the hook holds and settles pool balances.
Contract details
- Verified source
- Yes (NFTXV4Hook)
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Bytecode size
- 23,481 bytes
- Upgradeable proxy
- No
- Detected patterns
- dynamic-fee, oracle, ownable, return-delta
Pools using NFTXV4Hook
- flETH / SPOG (Dynamic fee) — 24h volume $0, TVL $0, 0 swaps today