# Get Migration details of a Pool

Raydium Launchpad pools begin in a fundraising phase using a bonding curve. Once the target amount of quote tokens (like SOL or USDC) is raised, the pool becomes eligible for <mark style="color:yellow;">migration</mark>. This migration moves the raised liquidity into a Raydium AMM or CPswap pool, enabling open trading.

Migration is tracked using the following fields:

* **`status`** — Indicates the phase of the pool:\
  `0 = Funding`, `1 = Ready to Migrate`, `2 = Migrated`.
* **`migrate_type`** — Shows the destination of the liquidity:\
  `0 = Raydium AMM`, `1 = CPswap`.
* **`total_quote_fund_raising`** — The total amount of quote tokens raised before migration.
* **`real_base`** & **`real_quote`** — The actual token balances in the pool vaults; these drop to near zero after migration.
* **`migrate_fee`** — Fee deducted during migration, defined in the global config.

These fields allow you to monitor the entire lifecycle of a pool—from launch to AMM-ready trading.

You can directly copy paste this code on <mark style="color:yellow;">replit</mark> and see it in action.

### Get all pools which are ready to migrate

As mentioned above, the pools which are ready to migrate have a \`status\` of `1`.&#x20;

{% tabs %}
{% tab title="Code Snippet" %}
{% code overflow="wrap" %}

```javascript
async function getMigrationReadyPools() {
  const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
  const operationsDoc = `
    query MyQuery {
      raydium_launchpad_PoolState(where: {status: {_eq: "1"}}) {
        pubkey
        status
        migrate_type
        migrate_fee
        total_quote_fund_raising
        total_base_sell
        quote_protocol_fee
        platform_fee
      }
    }
  `; //status `1` indicates the pool has completed its bonding curve

  const result = await fetch(
    `https://programs.shyft.to/v0/graphql?api_key=${SHYFT_API_KEY}&network=mainnet-beta`, //SHYFT's GQL endpoint
    {
      method: "POST",
      body: JSON.stringify({
        query: operationsDoc,
        variables: {},
        operationName: "MyQuery",
      }),
    }
  );

  const { errors, data } = await result.json();

  console.dir(data, { depth: null });
}
getMigrationReadyPools();
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
  "raydium_launchpad_PoolState": [
    {
      "pubkey": "CA1qvWVsoQuXqJFJFMQdtoEgMifwvGZpeZcNZHrNtm2U",
      "status": 1,
      "migrate_type": 0,
      "migrate_fee": 0,
      "total_quote_fund_raising": 85000000000,
      "total_base_sell": 793100000000000,
      "quote_protocol_fee": 1685495465,
      "platform_fee": 5056485898
    },
    {
      "pubkey": "GCEmSEvmp4nhJeNR2t8SHkNuHr8bXi2sKf5oqzg7whoP",
      "status": 1,
      "migrate_type": 1,
      "migrate_fee": 0,
      "total_quote_fund_raising": 85000000000,
      "total_base_sell": 54723900000000,
      "quote_protocol_fee": 1185672824,
      "platform_fee": 4742690963
    },
    {
      "pubkey": "BZeC16F3o6QQ6q7zdBA4ZZhwWXi6xARC8pefg4Lk9yHj",
      "status": 1,
      "migrate_type": 1,
      "migrate_fee": 0,
      "total_quote_fund_raising": 30000000000,
      "total_base_sell": 550000000000000,
      "quote_protocol_fee": 102441837,
      "platform_fee": 307325468
    }
  ]
}
```

{% endtab %}
{% endtabs %}

The response includes several key fields that provide details such as the amount raised, platform fees, and more(as described above). The `migrate_type` field specifies whether the migration destination is a Raydium AMM or CPswap.

### Fetch Status and Migration Destination of a Pool by address

{% tabs %}
{% tab title="Code Snippet" %}
{% code overflow="wrap" %}

```javascript
async function getMigrationByPoolAddress(address) {
  const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
  /*
  * The status field returns if the pool is funding, ready to migrate, or migrated
  * the migrate_type field indicates the destination, 0 for Raydium AMM, 1 for CpSwap
  */
  const operationsDoc = `
    query MyQuery {
            raydium_launchpad_PoolState(
                where: {pubkey: {_eq: ${JSON.stringify(address)}}}
            ) {
                status
                migrate_type
                total_base_sell
                total_quote_fund_raising
                pubkey
            }
      }
  `; 


  const result = await fetch(
    `https://programs.shyft.to/v0/graphql/accounts?api_key=${SHYFT_API_KEY}&network=mainnet-beta`, //SHYFT's GQL endpoint
    {
      method: "POST",
      body: JSON.stringify({
        query: operationsDoc,
        variables: {},
        operationName: "MyQuery",
      }),
    }
  );

  const { errors, data } = await result.json();

  if (errors) {
    console.error(errors);
    console.log(
      "Failed to fetch data, please provide correct API key or pool address."
    );
    return;
  }

  console.dir(data, { depth: null });
}
getMigrationByPoolAddress("4yhL99wpeeM2ptRT6U81hG8P3bCaCNabuw28gSBTCemU");
//replace with your Pool address
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
  "raydium_launchpad_PoolState": [
    {
      "status": 0, //Indicates status funding
      "migrate_type": 0, //indicated Raydium AMM
      "total_base_sell": 80000000000000,
      "total_quote_fund_raising": 85000000000,
      "pubkey": "4yhL99wpeeM2ptRT6U81hG8P3bCaCNabuw28gSBTCemU"
    }
  ]
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shyft.to/solana-indexers/case-studies/raydium-launchpad/get-migration-details-of-a-pool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
