NX0AntiBotHook on Base
Uniswap v4 Hook Contract 0x89123ff792912119cc88bdae622aaab3e11c3080 on Base · Oracle · Verified contract
- Volume (24h)
- $11
- Value locked (TVL)
- $11.28K
- All-time volume
- $205
- Pools using this hook
- 1
- Swaps (24h)
- 2 (1 traders)
- Total swaps
- 27
What it does
An anti-bot oracle hook for the NX0/EURC pool that validates the initial price, gates swaps to trusted routes or quoters in Restricted mode, and exposes a TWAP-based EUR price for NX0.
How it works step by step
- Accepts pool initialization only for the protected NX0/EURC pool at the expected starting sqrt price.
- Restricts swaps while tradingMode is Restricted to the trusted quoter and trusted router.
- Requires trusted router swaps to pass an actor address in hookData.
- Maintains a Uniswap oracle observation history for the pool via BaseOracleHook.
- Exposes consult() to return spot and time-weighted EURC-per-NX0 prices, liquidity and cardinality.
- Takes no fees, holds no tokens and does not modify swap deltas.
- Swap behaviour
- In beforeSwap, the pool must match the protected pool; trades from the trusted router must carry a 32-byte hookData encoding a non-zero actor; other senders must be the trusted quoter or the trading mode must be Public, and must send empty hookData.
- Liquidity behaviour
- No liquidity callbacks.
- Fee behaviour
- Uses the pool's static fee; the hook returns no fee override or fee delta.
- Owner & admin controls
- DEFAULT_ADMIN_ROLE and CONFIG_ROLE (granted to admin) can set the protected pool and trusted router once via setProtectedPool; MODE_ROLE (modeController) can switch tradingMode between Restricted and Public via setTradingMode; roles can be granted/revoked by DEFAULT_ADMIN_ROLE; contract is non-upgradeable with immutable token, quoter and expected price addresses.
Enabled Uniswap v4 callbacks
beforeInitialize, afterInitialize, beforeSwap
beforeInitialize validates the protected pool and that the initial sqrt price equals expectedSqrtPriceX96; afterInitialize repeats that validation and initializes the TWAP oracle observation state; beforeSwap restricts which swappers may trade in the protected pool and enforces hookData rules before delegating to the oracle hook.
Security & trust assessment
Risk level: medium (verified source, high confidence).
Who controls it: A holder of MODE_ROLE can switch trading to Restricted, blocking all swaps except from the trusted quoter and trusted router; a DEFAULT_ADMIN_ROLE/CONFIG_ROLE holder can bind the protected pool and router once, and admin can grant itself or others roles. There is no pause on liquidity operations and no upgrade path.
Risk to user funds: The hook holds no funds and returns zero deltas, so it cannot directly move pool tokens; however it can block swaps entirely in Restricted mode, so users may be unable to exit positions through the pool during that period.
Security findings
- [high] Privileged trading restriction: When tradingMode is Restricted, beforeSwap reverts with RestrictedTrading for any sender other than the trusted quoter or the trusted router, so a MODE_ROLE holder can halt ordinary public swaps in the protected NX0/EURC pool.
- [medium] Trusted router exemption set by admin: trustedRouter can be set once through setProtectedPool and cannot be changed afterwards, but a re-call with the same pool and router is a no-op; the router is an unchecked address that gains exemption from the restriction and receives an actor-address hookData requirement.
- [medium] Anti-bot gate depends on trusted router: The trading gate relies on the sender parameter and hookData actor address, which the trusted router passes through; users cannot be verified as the economic actor beyond what the router reports, so the anti-bot protection depends on router honesty.
- [low] Zeroed TWAP on failed observation: consult() returns a zeroed TWAP when the observation window is not yet available or the observe call reverts, so downstream consumers may silently read zero prices.
- [info] No fund custody or delta changes: The hook does not take or redirect tokens and does not modify swap deltas or fees; it only gates swaps and reads pool state for the oracle.
Contract details
- Verified source
- Yes (NX0AntiBotHook)
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Bytecode size
- 11,290 bytes
- Upgradeable proxy
- No
- Detected patterns
- oracle
Pools using NX0AntiBotHook
- NX0 / EURC (0.30% fee) — 24h volume $11, TVL $11.28K, 2 swaps today