TestHook on Ethereum

Uniswap v4 Hook Contract 0x81fe216c9c01a047606b2bbd61ec845a509ae0cc on Ethereum · Custom pricing · Verified contract

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

What it does

This hook charges traders a configurable tax on swaps of the token, with buy and sell rates set separately by the owner or tax manager between 1% and 90%, and the collected native currency is later sent to a vault, so traders pay more when the rates are high and liquidity providers are not directly affected.

How it works step by step

  • Charges a buy tax and a sell tax on swaps in the token pool, with each rate set between 1% and 90% (MIN_TAX_BPS 100, MAX_TAX_BPS 9000).
  • Takes the tax by minting ERC-6909 claims of the native currency to the hook through the pool manager, using beforeSwap or afterSwap return deltas.
  • Tracks the pool it was initialized with (only one pool, currency0 native ETH and currency1 the configured token) and rejects swaps on any other pool.
  • Lets anyone call distribute(), which unlocks the pool manager, burns the hook's claim balance and takes the native currency out to the vault address.
  • Owner or tax manager can change buy and sell tax rates; only the owner can set the vault, the tax manager and transfer ownership.
  • Liquidity callbacks and donate callbacks are disabled and revert with HookNotImplemented.
Swap behaviour
On exact-input buys (zeroForOne with negative amountSpecified) the hook takes buyTaxBps of the input amount in beforeSwap; on exact-output buys it takes buyTaxBps of the output amount in afterSwap. On exact-input sells (oneForZero with negative amountSpecified) it takes sellTaxBps of the output in afterSwap; on exact-output sells it takes sellTaxBps of the specified amount in beforeSwap. The tax is returned as a delta so the trader pays it. Swaps on any pool other than the one stored at initialization revert with WrongPool.
Liquidity behaviour
No liquidity callbacks.
Fee behaviour
Uses a tax on swaps, not the pool's static fee: buy and sell taxes are set by owner or tax manager within 1% to 90%. Collected taxes accumulate as ERC-6909 claims held by the hook and are sent to the vault by distribute().
Owner & admin controls
Owner can set buy and sell tax rates, set the vault address, set or change the tax manager, and transfer ownership. Tax manager can only set tax rates. There is no pause function and no upgrade mechanism; the contract is not a proxy.

Enabled Uniswap v4 callbacks

beforeInitialize, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta

beforeInitialize enforces the single token pool and records its id. beforeSwap takes the tax for exact-input buys and exact-output sells and returns it as a before-swap delta. afterSwap takes the tax for exact-output buys and exact-input sells and returns it as an after-swap delta. beforeSwapReturnDelta and afterSwapReturnDelta allow these tax amounts to be applied to the trader's balance.

Security & trust assessment

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

Who controls it: The owner (and tax manager) can set taxes anywhere from 1% to 90% on every buy and sell instantly, effectively freezing or confiscating trader value, and can change the vault to receive tax proceeds. Ownership can be transferred to any non-zero address.

Risk to user funds: The hook takes a share of swap amounts through return deltas and holds them as ERC-6909 claims until distribute() sends them to the vault. It does not hold other user funds or block liquidity operations, but a high tax setting can take up to 90% of the swapped amount.

Security findings

  • [high] Owner-controlled tax up to 90%: setTaxes lets the owner or tax manager raise buyTaxBps and sellTaxBps up to MAX_TAX_BPS of 9000 (90%), so a privileged key can make swaps extremely expensive for traders at any time.
  • [medium] Owner can redirect collected taxes: setVault lets the owner change the address that distribute() sends native currency to, so the owner can redirect all future tax proceeds.
  • [medium] Return deltas move trader funds: beforeSwapReturnDelta and afterSwapReturnDelta let the hook take a portion of each swap's input or output via minted ERC-6909 claims, which are later withdrawn to the vault.
  • [low] Permissionless distribution: distribute() can be called by anyone and triggers an unlock and take to the vault, which is harmless to users but means distribution timing is not controlled by the owner.
  • [info] Single pool restriction: The hook can only ever serve the first pool initialized with the given token and native currency, and any swap on another pool reverts.

Contract details

Verified source
Yes (TestHook)
Compiler
solc 0.8.26+commit.8a97fa7a
Bytecode size
8,053 bytes
Upgradeable proxy
No
Detected patterns
erc6909-claims, liquidity-management, moves-currency, ownable, return-delta, self-unlock, tax

Pools using TestHook