Every few hours a new token launches on Pump.fun or a fresh Uniswap V2 pair goes live. Within seconds of launch, bots swarm the token. Within minutes, the price is either up 10x or approaching zero. Human traders simply cannot react fast enough to participate in the opening seconds — but a well-built Python agent can.

Memecoin sniping is the practice of buying a newly launched token within seconds of its first liquidity event, before the broader market discovers it. The thesis is simple: early buyers in winning memecoins see 10x to 1000x returns. The challenge is that the vast majority of new launches are scams, honeypots, or simply die within minutes. The bot must be fast enough to snipe and smart enough to skip the traps.

Risk disclosure: Most new memecoins go to zero. This is not a reliable income strategy — it is a high-variance, high-risk speculation. Only use capital you are fully prepared to lose. Never snipe with funds you need.

What Memecoin Sniping Is

A memecoin snipe has a defined lifecycle:

  1. Detect: monitor on-chain events for new liquidity pool creation or token mint events
  2. Validate: run safety checks on the contract within 2-5 seconds
  3. Buy: submit a swap transaction with high priority fee to land early in the block
  4. Monitor: watch price and volume for exit signals
  5. Sell: auto-exit at profit target (e.g., 3x) or stop-loss (e.g., -50%)

Speed in steps 1-3 is everything. The difference between landing in the first 10 transactions and the first 1,000 transactions is often 50-200x in entry price for tokens that eventually pump. A slow bot that does thorough validation may never get a profitable entry price.

<3s
Target detect-to-buy
$10k
Min liquidity threshold
3-5x
Required winner multiple

Setting Up Purple Flea Webhooks for New Pool Events

The fastest way to detect new liquidity pools is via the Purple Flea memecoin webhook service. Instead of polling an RPC node on a timer, Purple Flea's infrastructure subscribes to the Solana and Ethereum validator mempool and pushes new pool events to your endpoint within 200ms of the transaction landing.

register_webhook.py
import os, requests API_KEY = os.environ["PURPLEFLEA_API_KEY"] BASE = "https://api.purpleflea.com" HDR = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"} # Register a webhook to receive new pool events r = requests.post( f"{BASE}/memecoin/webhooks", headers=HDR, json={ "url": "https://yourbot.example.com/new-pool", "events": ["pump_fun_new_mint", "uniswap_v2_pair_created"], "chains": ["solana", "ethereum", "base"], "filters": { "min_initial_liquidity_usd": 5000, # skip tiny launches }, }, ) r.raise_for_status() webhook = r.json() print(f"Webhook registered: id={webhook['id']} secret={webhook['secret']}")

Your bot receives a POST to /new-pool with the token address, chain, initial liquidity, deployer address, and metadata parsed from the token contract. From there, validation and buy happen inline within the same request handler.

The Validation Checklist

Running safety checks before buying is the difference between a trading bot and a money-burning machine. These checks must complete in under 3 seconds total — Purple Flea's validation API bundles all of them into a single call:

validate.py
def validate_token(token_address: str, chain: str) -> dict: """ Run full safety validation. Returns dict with 'safe' bool and reasons. Typically completes in 800ms-1500ms. """ r = requests.post( f"{BASE}/memecoin/validate", headers=HDR, json={ "token": token_address, "chain": chain, "checks": [ "honeypot_simulation", "ownership_renounced", "blacklist_functions", "liquidity_lock", "deployer_history", ], }, timeout=8, ) r.raise_for_status() return r.json() # returns: {safe: bool, score: 0-100, checks: {name: pass/fail}, reasons: [...]}

The Full MemeSniper Class

Below is the complete sniping agent. It receives webhook events, validates the token, buys if safe, monitors price, and auto-sells at targets. The full class is approximately 80 lines of core logic excluding the webhook server scaffolding.

sniper.py
import os, time, logging, threading import requests from flask import Flask, request, jsonify API_KEY = os.environ["PURPLEFLEA_API_KEY"] BASE = "https://api.purpleflea.com" HDR = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"} logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s") app = Flask(__name__) class MemeSniper: # Risk parameters MAX_BUY_USD = 200 # max per snipe STOP_LOSS_PCT = 0.50 # sell if down 50% TAKE_PROFIT_PCT = 3.0 # sell if up 3x (300%) PARTIAL_SELL_PCT = 0.5 # sell 50% at 2x to lock in cost basis MONITOR_INTERVAL = 15 # seconds between price checks MAX_HOLD_SECONDS = 3600 # force sell after 1 hour regardless DAILY_LOSS_LIMIT = 500 # halt all sniping if daily loss exceeds $500 MIN_SAFETY_SCORE = 70 # 0-100 score from validation API def __init__(self): self.positions = {} # token_address -> {buy_price, amount, timestamp} self.daily_pnl = 0.0 self.halted = False def on_new_pool(self, event: dict): """Called when Purple Flea webhook fires for a new token.""" token = event["token_address"] chain = event["chain"] liq_usd = event["initial_liquidity_usd"] if self.halted: logging.warning("Sniper halted (daily loss limit). Skipping %s", token[:8]) return if liq_usd < 10_000: logging.info("Skip %s: liquidity $%.0f below $10k threshold", token[:8], liq_usd) return # Validate in a background thread so we don't block the webhook response threading.Thread(target=self._validate_and_buy, args=(token, chain)).start() def _validate_and_buy(self, token: str, chain: str): validation = validate_token(token, chain) if not validation["safe"] or validation["score"] < self.MIN_SAFETY_SCORE: logging.info("Skip %s: score=%d reasons=%s", token[:8], validation["score"], validation["reasons"]) return # Buy buy_result = requests.post( f"{BASE}/memecoin/buy", headers=HDR, json={ "token": token, "chain": chain, "amount_usd": self.MAX_BUY_USD, "priority_fee_lamports": 500_000, # high tip to land early "slippage_bps": 300, }, ).json() if buy_result.get("status") != "filled": logging.warning("Buy failed for %s: %s", token[:8], buy_result) return entry_price = buy_result["fill_price_usd"] self.positions[token] = { "entry_price": entry_price, "amount_tokens": buy_result["tokens_received"], "cost_usd": self.MAX_BUY_USD, "partial_sold": False, "chain": chain, "timestamp": time.time(), } logging.info("Bought %s @ $%.8f", token[:8], entry_price) threading.Thread(target=self._monitor_position, args=(token,)).start() def _monitor_position(self, token: str): pos = self.positions[token] while token in self.positions: time.sleep(self.MONITOR_INTERVAL) price_r = requests.get( f"{BASE}/memecoin/price", headers=HDR, params={"token": token, "chain": pos["chain"]} ).json() current = price_r["price_usd"] mult = current / pos["entry_price"] age = time.time() - pos["timestamp"] # Partial sell at 2x to recover cost basis if mult >= 2.0 and not pos["partial_sold"]: self._sell(token, fraction=self.PARTIAL_SELL_PCT, reason="2x partial") pos["partial_sold"] = True # Full exit conditions elif mult >= self.TAKE_PROFIT_PCT: self._sell(token, fraction=1.0, reason=f"take profit {mult:.1f}x"); break elif mult <= (1 - self.STOP_LOSS_PCT): self._sell(token, fraction=1.0, reason=f"stop loss {mult:.2f}x"); break elif age > self.MAX_HOLD_SECONDS: self._sell(token, fraction=1.0, reason="max hold time"); break def _sell(self, token: str, fraction: float, reason: str): pos = self.positions.get(token) if not pos: return sell_amount = pos["amount_tokens"] * fraction r = requests.post( f"{BASE}/memecoin/sell", headers=HDR, json={"token": token, "chain": pos["chain"], "amount_tokens": sell_amount, "slippage_bps": 500}, ).json() proceeds = r.get("proceeds_usd", 0) pnl = proceeds - (pos["cost_usd"] * fraction) self.daily_pnl += pnl logging.info("Sold %s (%.0f%%) reason=%s pnl=$%.2f", token[:8], fraction*100, reason, pnl) if fraction >= 1.0: del self.positions[token] if self.daily_pnl <= -self.DAILY_LOSS_LIMIT: self.halted = True logging.critical("Daily loss limit hit. Sniper halted.") sniper = MemeSniper() @app.route("/new-pool", methods=["POST"]) def handle_new_pool(): event = request.get_json() sniper.on_new_pool(event) return jsonify({"ok": True}) if __name__ == "__main__": app.run(port=8080)

Pump.fun Specific: Bonding Curve Mechanics

Pump.fun uses a bonding curve rather than a traditional AMM. Tokens launch with a fixed supply and a price that increases deterministically as more tokens are bought. The curve graduates to Raydium (Solana's main DEX) once the market cap reaches approximately $69,000. This is the graduation threshold.

The strategic opportunity: buy tokens early on the bonding curve (low price), hold through graduation, and sell on Raydium where the token is now accessible to the broader market. Graduation events frequently cause 3-10x price spikes as new buyers discover the token on Raydium for the first time.

Pump.fun filter: Set "platform": "pump_fun" in your Purple Flea webhook filter to receive only Pump.fun launches. Add "min_curve_progress_pct": 0 and "max_curve_progress_pct": 10 to target early bonding curve entries specifically.

Risk Management

The most important section of any sniping bot is risk management. Without it, a single run of bad luck (or a single well-executed honeypot) wipes everything. The MemeSniper class above enforces four independent safeguards:

Expected P&L: Realistic Numbers

Memecoin sniping is a power-law game. Most tokens go to zero; a few produce life-changing returns. The math only works if your winning trades are large multiples of your losing trades.

With $200 positions instead of $100 the numbers double, but so do the losses. The key variable is win rate among the 10% winners: if any of those winners produce 20x or 50x instead of 5x, the entire portfolio outcome changes dramatically. Use the Agent Bankroll Management API to calculate Kelly-optimal position sizing based on your historical snipe results.

Competition: You are competing with professional MEV bots that colocate validators, operate private mempools, and optimize gas bidding algorithms. In the opening seconds of a launch, the most mechanically optimal bots win. The Purple Flea Solana Agent API includes priority fee recommendations calibrated to current validator tip markets to maximize your landing probability.


Deploy your memecoin sniping agent today

Purple Flea's webhook infrastructure delivers new pool events in under 200ms. Validation API, buy/sell execution, and priority fee management — all in one platform.

View Memecoin Agent API →

Related APIs