> ## Documentation Index
> Fetch the complete documentation index at: https://pons-labs-llc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Uniswap v4 pools

> Build a graduated v2 token's pool key, quote and swap it, and what the Pons hook does to each swap.

A graduated v2 token trades in a Uniswap v4 pool against its quote asset, with
the Pons [meme hook](https://pons-labs-llc.mintlify.site/developers/contracts.md#v2) attached. Any v4 router can swap
it. The liquidity is one full-range position minted at graduation straight into
the locker, which has no way to release it.

## The pool key

Everything comes from the [launch record](https://pons-labs-llc.mintlify.site/developers/reading-state.md#the-launch-record).

```ts theme={null}
import { encodeAbiParameters, keccak256 } from "viem";

// v4 sorts currencies by address. Native ETH is the zero address, so it is
// always currency0.
const [currency0, currency1] =
  launch.pairToken.toLowerCase() < launch.token.toLowerCase()
    ? [launch.pairToken, launch.token]
    : [launch.token, launch.pairToken];

const poolKey = {
  currency0,
  currency1,
  fee: launch.poolFee,          // 0: the hook charges the fee, not the pool
  tickSpacing: launch.tickSpacing, // 200
  hooks: memeHook,              // the hook of the token's own stack
};

const poolId = keccak256(
  encodeAbiParameters(
    [{ type: "address" }, { type: "address" }, { type: "uint24" }, { type: "int24" }, { type: "address" }],
    [poolKey.currency0, poolKey.currency1, poolKey.fee, poolKey.tickSpacing, poolKey.hooks],
  ),
);
```

The pool's LP fee is zero. Uniswap's protocol fee on these pools is also zero
today.

## What the hook does to a swap

After every swap the hook takes the 1% trading fee plus the token's creator tax
from the swap's **unspecified currency**, through its return delta. On an
exact-input buy that currency is the launch token, so fees collected in the pool
can be in either asset; the sweep converts them later.

* The v4 Quoter includes the hook's cut. Spot-price maths from `slot0` does not,
  so quote through the Quoter.
* The hook does not gate trading, restrict who can swap, or tax plain transfers
  of the token.
* Its permissions are `beforeInitialize`, which only lets the factory initialize
  a pool, and `afterSwap` with a return delta. Other callbacks are off.

## Reading the hook

```ts theme={null}
const hookAbi = parseAbi([
  "function pendingFees(bytes32 poolId, address currency) view returns (uint256)",
  "function pendingCreatorTax(bytes32 poolId, address currency) view returns (uint256)",
]);
```

These are fees accrued on the pool and not yet swept, per currency. The pool's
own configuration, including the token, quote asset, which side is currency0,
recipients and rates, comes from `launches(poolId)` on the hook. Sweeping is on
[fees and claims](https://pons-labs-llc.mintlify.site/developers/fees-and-claims.md#sweeps).

## Indexing pool trades

After graduation, trades are Uniswap's `Swap` events on the PoolManager,
`0x8366a39CC670B4001A1121B8F6A443A643e40951`, filtered by `poolId` as the first
indexed topic. The factory and curve events stop at graduation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.