> 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/graduation.md).

# Graduation

Track the transition from curve trading to a Uniswap V4 pool.

#### Understand the launch status

Graduation closes curve trading and moves liquidity toward a Uniswap V4 pool. A buy that exhausts the sellable supply attempts the first step automatically; pool creation is a separate transaction.

* `notGraduated`: use the curve while `graduationReady` is false. Once ready, curve trading stops.
* `swept`: assets have left the curve; the V4 pool is not ready yet.
* `poolCreated`: use the V4 pool for trading. Curve trading remains closed.
* `emergencyExited`: use the active EmergencyDistributor for redemption.

#### Complete Graduation when needed

Most integrations only need to display the current status. If your application offers a completion action, both Graduation and pool creation are permissionless. Read the state before submitting:

### 1. Complete the curve sweep

```ts
import { launchpadGraduateIsIdempotentSuccess } from "@masterpeach/launchpad-sdk";

const state = await client.getTokenState(token, {
  blockNumber: await publicClient.getBlockNumber(),
});
if (state.graduation.status === "notGraduated" && state.curveState.graduationReady) {
  try {
    const prepared = await client.prepareGraduate(token);
    const hash = await client.send(prepared);
    const result = await client.wait(hash, { confirmations: chain.confirmations });
    if (result.status !== "confirmed") throw new Error("Graduation reverted");
  } catch (error) {
    const { status } = await client.getGraduation(token);
    if (!launchpadGraduateIsIdempotentSuccess(status)) throw error;
  }
}
```

### 2. Create the V4 pool

Run this when the refreshed status is `swept`. Pool creation is a separate transaction; another caller may complete it first, so refresh the status after a failure before offering a retry.

```ts
const graduation = await client.getGraduation(token);
if (graduation.status === "swept") {
  const prepared = await client.prepareCreateGraduatedPool(token);
  const hash = await client.send(prepared);
  const result = await client.wait(hash, { confirmations: chain.confirmations });
  if (result.status !== "confirmed") throw new Error("Pool creation reverted; refresh status");
}
const latest = await client.getGraduation(token);
```

`AutoGraduationFailed` does not revert a successful buy or token creation. Refresh the status before offering a retry. Another transaction may already have completed the step.

#### Resume trading or recover

If pool creation fails, assets remain in GraduationExecutor and the launch stays `swept`. Retry pool creation. The seven-day Emergency Exit delay starts at `sweptAt`.

After `poolCreated`, `client.getPoolId(token)` returns the V4 pool ID; before then it returns `bytes32(0)`. Route trading to the pool. Curve trading is permanently closed and returns `LaunchpadTradingClosedError`.

Continue trading through the Aggregator after pool creation. For routing in both stages, see[Trading before and after graduation](https://docs.peach.ag/documentation/arc/launchpad/core-features/trading-before-and-after-graduation)

### Uniswap V4 Hooks

Pool creation and Aggregator route availability are separate conditions. Continue with [Pool structure](https://docs.peach.ag/documentation/arc/launchpad/core-features/uniswap-v4-hooks/overview-and-pool-structure) for PoolKey/poolId and [Trading integration](https://docs.peach.ag/documentation/arc/launchpad/core-features/uniswap-v4-hooks/trading-integration) for post-graduation execution.

### Direct contract calls

SDK equivalents: getGraduation, prepareGraduate and prepareCreateGraduatedPool. Use LaunchFactory as the public transaction entry; the coordinator and executor implement the internal lifecycle.

`Factory.graduations(address token)` returns `(uint8 status, uint64 sweptAt, uint256 tokenAmount, uint256 quoteAmount, uint256 positionId)`. Status: 0 NotGraduated, 1 Swept, 2 PoolCreated, 3 EmergencyExited.

* `Factory.graduate(address token)`: permissionless first step when the curve is ready and status is 0. A boundary buy may already perform it. If automatic graduation fails, the buy can still succeed; inspect its events and refresh state before retrying.
* `Factory.createGraduatedPool(address token) → uint256 positionId`: permissionless second step from status 1. No user token approval is required for either graduation call.
* After graduation, stop calling the old curve for trades. Read `MemeHook.poolForToken(token)` and `poolConfig(poolId)`, then use a supported V4 Router or Arc Aggregator route. See [V4 trading integration](https://docs.peach.ag/documentation/arc/launchpad/core-features/uniswap-v4-hooks/trading-integration) for PoolKey, swap and hookData examples. Hook callbacks are invoked by PoolManager.


---

# 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/graduation.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.
