> For the complete documentation index, see [llms.txt](https://docs.peach.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peach.ag/documentation/arc/launchpad/launchpad-classic/core-features/uniswap-v4-hooks/trading-integration.md). Agents can also search and read this documentation through its [MCP server](https://docs.peach.ag/~gitbook/mcp).

# Trading integration

Use production Classic on Arc Mainnet (`5042`). Choose the execution path before choosing a spender. The Router and PoolManager invoke the Hook; a wallet does not call the Hook's swap callback directly.

### Through Arc Aggregator

Follow the [Aggregator Quickstart](https://docs.peach.ag/documentation/arc/aggregator/quickstart) and select the production network. Obtain a fresh route after graduation; pool creation, indexing and executable route availability are separate conditions.

Use the spender returned and validated by the selected Direct or Delegated flow. Confirm approvals, preserve the user's output/input limits and expiry, then simulate, send and confirm the receipt. Requote after expiry or a state change.

### Verify the official pool

Use the Mainnet addresses from [Contract Address](https://docs.peach.ag/documentation/arc/launchpad/launchpad-classic/contract-address). Save this read helper as `v4-hooks.ts`; it is also used by [Pool structure](https://docs.peach.ag/documentation/arc/launchpad/launchpad-classic/core-features/uniswap-v4-hooks/overview-and-pool-structure).

```ts
import {
  encodeAbiParameters, keccak256, parseAbiParameters, zeroHash,
  type Address, type PublicClient,
} from "viem";
import { arcMainnetLaunchpadDeployment } from "@masterpeach/launchpad-sdk";
import { memeHookAbi } from "@masterpeach/launchpad-sdk/abi";

export async function readV4Pool(publicClient: PublicClient, token: Address) {
  const deployment = arcMainnetLaunchpadDeployment;
  if (await publicClient.getChainId() !== deployment.chainId) {
    throw new Error("Use Arc Mainnet");
  }
  const address = deployment.contracts.memeHook;
  const blockNumber = await publicClient.getBlockNumber();
  const poolId = await publicClient.readContract({
    address, abi: memeHookAbi, functionName: "poolForToken", args: [token], blockNumber,
  });
  if (poolId === zeroHash) throw new Error("No registered V4 pool");
  const config = await publicClient.readContract({
    address, abi: memeHookAbi, functionName: "poolConfig", args: [poolId], blockNumber,
  });
  if (config[11] !== 2 || config[0].toLowerCase() !== token.toLowerCase()) {
    throw new Error("V4 pool is not active for this token");
  }
  const [currency0, currency1] = BigInt(token) < BigInt(config[1])
    ? [token, config[1]] : [config[1], token];
  const key = { currency0, currency1, fee: 0, tickSpacing: config[9], hooks: address } as const;
  const calculatedId = keccak256(encodeAbiParameters(
    parseAbiParameters("address,address,uint24,int24,address"),
    [key.currency0, key.currency1, key.fee, key.tickSpacing, key.hooks],
  ));
  if (calculatedId !== poolId) throw new Error("PoolKey does not match the registered pool");
  return { poolId, key, config, blockNumber };
}
```

This reads a fixed block and validates the chain, registered pool, active status and PoolKey. It does not prove liquidity or simulate a swap.

### Direct V4 Router integration

Select a production Router that enforces minimum output or maximum input, expiry, authorized payer/recipient and unlock settlement. Read its funding model to choose the allowance target. Forward the required [Partner hookData](https://docs.peach.ag/documentation/arc/launchpad/launchpad-classic/core-features/uniswap-v4-hooks/partner-and-hookdata) only when the Router supports it.

Include Hook fees and Creator Tax in the final user limits. A square-root price boundary alone is not a net-output guarantee. If the Router can partially consume input, reconcile actual spending, output and refunds from the confirmed receipt.

For failures, first check graduation and Hook state, then PoolKey, balances, allowance and the Router's limits. A valid pool can still have no Aggregator route; obtain a current executable quote before offering a swap.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.peach.ag/documentation/arc/launchpad/launchpad-classic/core-features/uniswap-v4-hooks/trading-integration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
