Dexploit is in public beta. Share feedback →

Skip to content
← Back to Blog
solanarug-pullwebsocketalertstutorial

How to Get a Live Alert When a Solana Pool Is Drained

Dexploit Team··6 min read
How to Get a Live Alert When a Solana Pool Is Drained

Sometimes a Solana pool loses almost all of its liquidity in a single transaction. If you run a bot, a dashboard or a Discord server, you probably want to know when that happens. Dexploit publishes these events on one WebSocket room, so an alert is about fifty lines of Node.

This tutorial uses a Free key: 10 requests per second, 10,000 requests a month, 14 days of history, one stream at a time (authentication). Get a key from the dashboard.

What counts as "drained"

Dexploit watches liquidity-pool events on the AMM venues and classifies a withdrawal by how much of the pool it removed (reference):

classificationMeaning
RUGGEDA pool drained past 95% of its liquidity
LIQUIDITY_DRAININGA large drain between 50% and 95% that is not a full rug

This records what happened to the pool, not why. A drain can be a scam, a team moving liquidity, or something else, and nothing here predicts which tokens will be drained. Treat an alert as a prompt to look, not as a verdict.

Setup

mkdir drain-alerts && cd drain-alerts
npm init -y
npm install ws
export DEXPLOIT_API_KEY=your-key-here

The scripts use .mjs files and the built-in fetch, so you need Node 18 or newer.

Step 1: join the rugs room

Save this as alerts.mjs:

import WebSocket from "ws";

const KEY = process.env.DEXPLOIT_API_KEY;
const MIN_SOL = Number(process.env.MIN_SOL ?? 5); // ignore drains smaller than this
const WEBHOOK_URL = process.env.WEBHOOK_URL; // optional: Discord or Slack incoming webhook

// the `dex` field is a number on this feed
const DEX = { 2: "pumpswap", 3: "raydium_amm", 4: "raydium_clmm", 5: "raydium_cpmm", 6: "orca", 7: "meteora_damm_v2", 9: "meteora_dlmm" };
const short = (s) => s.slice(0, 6) + "…" + s.slice(-4);

const ws = new WebSocket("wss://ws.dexploit.dev/ws/swaps", {
  headers: { Authorization: `Bearer ${KEY}` },
});

ws.on("open", () => ws.send(JSON.stringify({ type: "join", room: "rugs" })));

ws.on("message", async (raw) => {
  const msg = JSON.parse(raw.toString());
  if (msg.type !== "message" || msg.room !== "rugs") return; // skip "joined" acks and anything else
  const r = msg.data;
  if (r.event_type !== "rug_detected") return;

  const sol = r.lp_sol_pulled / 1e9; // lamports here; the REST /rugs feed is already in SOL
  if (sol < MIN_SOL) return;

  const line =
    `${new Date(r.timestamp_ms).toISOString().slice(11, 19)}Z ${r.classification} ` +
    `${short(r.token_mint)} on ${DEX[r.dex] ?? "dex " + r.dex}: ` +
    `${(r.drained_pct * 100).toFixed(0)}% of the pool, ${sol.toFixed(1)} SOL out (tx ${short(r.signature)})`;
  console.log(line);

  if (WEBHOOK_URL) {
    // Discord reads `content`, Slack reads `text`
    await fetch(WEBHOOK_URL, {
      method: "POST",
      headers: { "content-type": "application/json" },
      body: JSON.stringify({ content: line, text: line }),
    }).catch((err) => console.error("webhook failed:", err.message));
  }
});

// keep-alive: the server answers {"type":"pong"}
setInterval(() => {
  if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: "ping" }));
}, 30000);

ws.on("close", (code) => console.log("closed", code));
ws.on("error", (err) => console.error("error:", err.message));

Run node alerts.mjs. A live run printed:

04:35:01Z RUGGED DT1fK6…NcG3 on meteora_damm_v2: 100% of the pool, 120.6 SOL out (tx 4ABpyh…MEU8)
04:35:14Z RUGGED 4SbxUT…5aZX on pumpswap: 100% of the pool, 126.1 SOL out (tx 3Ds71L…Femv)

Each frame is wrapped as { "type": "message", "room": "rugs", "data": { … } }. The data object has the token mint, the pool address, the venue, drained_pct (a fraction from 0 to 1), lp_sol_pulled, the transaction signature and a reason field that is only on this live feed (rugs room).

MIN_SOL is the size filter. Set it to the smallest drain you care about, for example MIN_SOL=20 node alerts.mjs. You will want one: in a four-minute run on 2026-11-12 the room sent 15 drain events, and the 7-day REST window held about 32,000 events at 95% or more.

Step 2: send it to Discord or Slack

Set WEBHOOK_URL to an incoming-webhook URL and every alert is also posted there. The script sends both keys because Discord reads content and Slack reads text.

MIN_SOL=20 WEBHOOK_URL='https://discord.com/api/webhooks/…' node alerts.mjs

Gotchas: the stream and REST disagree on units

The live room and the REST feed describe the same events, but not in the same units. All of these were checked on the live API:

FieldWebSocket rugs roomREST GET /rugs
SOL removedlp_sol_pulled in lamportslp_sol_pulled already in SOL
Venuedex is a number (2 = PumpSwap, 7 = Meteora DAMM v2)dex is a name
Event timetimestamp_msts_ms
Whyreason (for example lp_withdraw)not included

drained_pct is a fraction from 0 to 1 on both.

Which venues are covered

LP and drain events are live for PumpSwap (2), Raydium AMM (3), CLMM (4) and CPMM (5), Orca (6), Meteora DAMM v2 (7) and Meteora DLMM (9). They are not emitted for meteora_dbc (8) or meteora_pools (10), and a pump.fun bonding curve has no liquidity pool to drain. A missing alert on one of those venues does not mean the pool is safe (coverage matrix).

Catch up after a disconnect

A WebSocket drops sometimes. When yours reconnects, fill the gap from the REST feed, which keeps a 7-day window. Save this as backfill.mjs:

const KEY = process.env.DEXPLOIT_API_KEY;
const sinceMs = Date.now() - 10 * 60 * 1000; // for example: everything from the last 10 minutes

const res = await fetch("https://api.dexploit.dev/rugs?limit=100&min_drained_pct=0.95", {
  headers: { "X-API-Key": KEY },
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const { rugs } = await res.json();

for (const r of rugs.filter((x) => x.ts_ms >= sinceMs)) {
  // here lp_sol_pulled is already in SOL, and dex is a name
  console.log(new Date(r.ts_ms).toISOString(), r.classification, r.dex, `${r.lp_sol_pulled.toFixed(1)} SOL`);
}

A live run printed:

2026-11-12T04:35:14.000Z RUGGED pumpswap 126.1 SOL
2026-11-12T04:35:01.858Z RUGGED meteora_damm_v2 120.6 SOL
2026-11-12T04:34:19.474Z RUGGED meteora_damm_v2 97.1 SOL

The first two rows are the same events the room sent. For reconnect and back-pressure handling, see Reconnect and backpressure.

Things worth knowing before you build on it

  • Free means one stream. A second connection with the same key is refused until the first closes (streaming caps).
  • How soon an alert reaches you depends on your network and host. Measure it from where you will run the code.
  • Pool-level events only. This tells you a pool lost liquidity. It does not tell you who removed it or why.

Next