Docs / Uniswap v4⌄

Reference

Uniswap v4

The market is an ordinary Uniswap v4 pool. Every swap is priced by Uniswap's own math, so the Uniswap interface, aggregators and trackers see real liquidity and a real price.

What the hook does#

CallbackWhat it does
beforeInitializeRefuses: only the hook itself opens its pool, once, at launch
beforeAddLiquidityRefuses: nobody but the hook provides liquidity
beforeDonateRefuses
beforeSwap, afterSwapTake the 1% tax on the ETH side, whichever side of the trade ETH is on

The hook does not touch the swap itself. Its permissions are spelled out in its address, as v4 requires, and anyone can read them there.

The tax#

  • Exact input of ETH, or exact output of ETH: taken in beforeSwap, from the ETH amount named.
  • Exact input or output of the token: taken in afterSwap, from the ETH the swap settled.
  • So there is no untaxed route through the pool, and the tax never arrives as tokens. It is booked as a claim during the swap and paid out by claimDev, outside any swap.

Routing#

Buys and sells go through the Universal Router like those of any other token, priced by the V4Quoter the Uniswap interface uses. Both are tested on a fork of mainnet, windows open and holes in the book included.

A window cannot be bought through a router: it is a call to the hook itself, buy, because the right to undo belongs to a person, and a swap only tells the hook which router sent it.