TestHook on Ethereum

Uniswap v4 Hook Contract 0x2bca0856addd3b7b560fa568f9923271a1c4a0cc 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 between 1% and 3% on buys or sells of the token against the native currency, with the buy tax taken on exact-input buys and the sell tax on exact-output sells, and forwards the collected amounts to a vault.

How it works step by step

  • Takes a configurable tax on swaps of the pool's native-currency side (currency0 is ADDRESS_ZERO, paired with the token) using beforeSwap and afterSwap return deltas
  • Buy tax (zeroForOne with exact input) is taken in beforeSwap from the input amount; sell tax (oneForZero with exact output) is taken in beforeSwap from the specified amount
  • For buys with exact output and sells with exact input, the tax is computed in afterSwap from the realized delta and taken via afterSwap return delta
  • Collected tax is minted to the hook as ERC-6909 claims on the native currency in the PoolManager
  • distribute() permissionlessly burns the accrued claims and takes the native currency to the configured vault address
  • Tax rates for buy and sell are each bounded between 100 and 300 basis points and can be changed by the owner or tax manager
Swap behaviour
On swaps in the pool, a buy (native currency in, token out) pays buyTaxBps of the input, and a sell (token in, native currency out) pays sellTaxBps of the output, with the tax taken as a hook return delta so the trader's effective amounts change. Buys with exact-input and sells with exact-output are taxed in beforeSwap; the opposite directions are taxed in afterSwap. Trades in the other combinations are not taxed.
Liquidity behaviour
No liquidity callbacks.
Fee behaviour
Uses the pool's static fee for the LP fee; the hook additionally charges a buy or sell tax of 1% to 3% (configurable per direction) that is minted as claims to the hook and later distributed to the vault.
Owner & admin controls
The owner can transfer ownership, set the tax manager, and change the vault address. The owner or the tax manager can set buy and sell tax rates, always within 100 to 300 basis points. 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 restricts the pool to the configured native/token pair and records the pool id. beforeSwap computes and takes the buy tax on exact-input buys and the sell tax on exact-output sells via a return delta. afterSwap computes and takes the remaining-direction tax via a return delta. beforeSwapReturnDelta and afterSwapReturnDelta are enabled so these deltas are honoured by the PoolManager.

Security & trust assessment

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

Who controls it: The owner controls the vault address and can transfer ownership; the owner or tax manager can raise taxes to 3% per direction at any time. No pause or emergency withdrawal is present.

Risk to user funds: The hook does not hold user principal in pool positions; it holds only ERC-6909 claims minted from tax on swaps, which are paid to the vault on distribute(). Swaps pass through the hook and pay the configured tax, but the hook cannot block swaps beyond the pool-restriction checks and the taxes are bounded.

Security findings

  • [medium] Tax rates adjustable by privileged keys: setTaxes lets the owner or taxManager change buyTaxBps and sellTaxBps anywhere between 100 and 300 bps, so trader cost can increase by up to 3x from the initial setting without user consent or a delay.
  • [medium] Hook takes value via return deltas: beforeSwap and afterSwap return non-zero deltas and mint claims to the hook, so the hook takes a share of every qualifying swap; the fee amount is computed from user-controlled amounts and the current rate.
  • [low] Vault can be redirected by owner: setVault lets the owner change the address that receives distributed native currency, so accrued tax can be directed to a different recipient at any time.
  • [low] Ownership transfer is single-step: transferOwnership sets the new owner immediately with no acceptance step, so a wrong address would permanently lose control of tax parameters and the vault.
  • [info] Distribution is permissionless: Anyone can call distribute(), which burns and takes the accrued claims to the configured vault; this is intended behaviour and does not expose user funds to extraction by the caller.

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