> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Uniswap V4

> Interact with Uniswap V4 pools, hooks, and the singleton contract

<Warning>
  **Looking for Contributors!** This Skill needs an implementation.

  Contributing a Skill involves:

  1. Writing a reference implementation with full functionality
  2. Adding comprehensive tests
  3. Writing documentation with usage examples

  See the [ethers-provider Skill](https://github.com/evmts/voltaire/tree/main/examples/ethers-provider) for an example of a complete Skill implementation.

  Interested? Open an issue or PR at [github.com/evmts/voltaire](https://github.com/evmts/voltaire).
</Warning>

<Info>
  **Skill** — Copyable reference implementation. Use as-is or customize. See [Skills Philosophy](/concepts/skills).
</Info>

Interact with Uniswap V4's singleton architecture, custom hooks, and flash accounting system.

## Why Uniswap V4?

V4 introduces major architectural changes:

* **Singleton contract** — All pools in one contract (gas savings)
* **Hooks** — Custom logic at every pool lifecycle point
* **Flash accounting** — Net-zero balance requirements
* **Native ETH** — No more WETH wrapping required
* **Dynamic fees** — Hooks can modify swap fees

## Planned Implementation

### Pool Interaction

```typescript theme={null}
import { UniswapV4 } from './UniswapV4.js';

const v4 = UniswapV4({
  provider,
  poolManager: POOL_MANAGER_ADDRESS,
});

// Get pool state
const pool = await v4.getPool({
  currency0: USDC,
  currency1: WETH,
  fee: 3000,
  tickSpacing: 60,
  hooks: HOOK_ADDRESS,
});

console.log('sqrtPriceX96:', pool.sqrtPriceX96);
console.log('liquidity:', pool.liquidity);
console.log('tick:', pool.tick);
```

### Swaps

```typescript theme={null}
// Execute swap through V4
const tx = await v4.swap({
  poolKey: {
    currency0: USDC,
    currency1: WETH,
    fee: 3000,
    tickSpacing: 60,
    hooks: ZERO_ADDRESS,
  },
  params: {
    zeroForOne: true,
    amountSpecified: parseUnits('1000', 6), // 1000 USDC
    sqrtPriceLimitX96: MIN_SQRT_RATIO + 1n,
  },
  signer,
});
```

### Liquidity Provision

```typescript theme={null}
// Add liquidity to a V4 pool
const tx = await v4.modifyLiquidity({
  poolKey,
  params: {
    tickLower: -887220,
    tickUpper: 887220,
    liquidityDelta: parseEther('1'),
  },
  signer,
});
```

### Hook Development

```typescript theme={null}
// Encode hook permissions
import { HookFlags } from './hooks.js';

const permissions = HookFlags.encode({
  beforeSwap: true,
  afterSwap: true,
  beforeAddLiquidity: false,
  afterAddLiquidity: false,
  // ...
});

// Validate hook address matches permissions
const isValid = HookFlags.validate(hookAddress, permissions);
```

## Resources

* [Uniswap V4 Documentation](https://docs.uniswap.org/contracts/v4/overview)
* [V4 Core Repository](https://github.com/Uniswap/v4-core)
* [V4 Periphery Repository](https://github.com/Uniswap/v4-periphery)

## Related

* [multicall](/skills/multicall) — Batch pool queries
* [event-listening](/skills/event-listening) — Watch swap events
