Skip to main content

Migrate Pump.fun

Want to buy or sell first the moment a token migrates? On Pump.fun you can initiate the migration yourself β€” and act before anyone else.

How It Works​

Migration can only be initialized during a short window when tokensInPool == 0.

After a few seconds, the Pump.fun keeper will initialize the migration automatically β€” but you can do it first. No admin access required. Anyone can call it.

Just call the migrate action and you'll trigger the migration. This action is fail-safe, meaning your transaction will not fail even if someone executes it before you. You can even test it on already migrated tokens.


Buy or Sell on Migration​

If you also want to trade at migration time, you have two options:

  • Jito Bundles (recommended) β€” send migrate and the trade as two separate transactions inside one atomic bundle. Simpler, faster, and no CPI workarounds needed.
  • Actions β€” pack migrate + trade into one transaction. Requires a wSOL workaround due to Solana's CPI limit.

Pick a tab below.

Jito Bundles Approach​

With Jito Bundles, migrate and the trade live in separate transactions inside one atomic bundle. Both land together or neither lands β€” and because each transaction has its own CPI budget, you don't need any wSOL tricks.

The flow is dead simple:

  • tx1 β€” migrate (initiates the migration)
  • tx2 β€” buy or sell (executes immediately after migration)

Example Request​

{
"jitoTip": 0.00001,
"transactions": [
{
"privateKey": "base58_private_key",
"action": "migrate",
"mint": "token_address",
"quoteMint": "quote_token_address", // usually wsol address, but it can also be usdc
},
{
"privateKey": "base58_private_key",
"action": "buy",
"mint": "token_address",
"quoteMint": "quote_token_address", // usually wsol address, but it can also be usdc
"amount": 0.2,
"denominatedInQuote": true,
"slippage": 200
}
]
}

That's it. No wrapSol, no disableSolWrapper, no CPI math.

Code Example​

The example below listens to the stream and fires a Jito Bundle (migrate + buy) the moment tokensInPool == 0.

import websockets
import orjson as json # or use the standard json module (orjson is faster)
import asyncio
import aiohttp

url = "https://api.pumpapi.io"

async def pumpapi_data_stream():
async with websockets.connect("wss://stream.pumpapi.io/") as websocket:
async for message in websocket:
event = json.loads(message)
if event.get("pool") == "pump" and event.get("tokensInPool") == 0:
print(event)
data = {
"jitoTip": 0.00001,
"transactions": [
{
"privateKey": "base58_private_key",
"action": "migrate",
"mint": event["mint"],
"quoteMint": event["quoteMint"],
},
{
"privateKey": "base58_private_key",
"action": "buy", # or "sell"
"mint": event["mint"],
"quoteMint": event["quoteMint"],
"amount": 0.2,
"denominatedInQuote": True,
"slippage": 200,
},
],
}
async with aiohttp.ClientSession() as session:
async with session.post(url, json=data) as response:
text = await response.text()
print(text)

asyncio.run(pumpapi_data_stream())

Endpoint​

POST https://api.pumpapi.io

Local Transactions​

Local transactions are supported for both approaches above, but will be slower. Use the same logic as on the Trade API page.


Need help? Join our Telegram group.