How to Stream Real-Time Solana DEX Trades with WebSockets
Build a Solana DEX trade monitor on MadeOnSol's filtered WebSocket firehose. Covers the current permanent stream-token flow, 14 decoded programs across 8 venues, named subscriptions, replay, and production reconnects.

Disclosure: This article contains affiliate links. If you sign up through them, MadeOnSol may earn a commission at no extra cost to you. This never affects our rankings, ratings, or reviews.
MadeOnSol's DEX firehose is a filtered WebSocket view of parsed Solana swaps. It currently decodes 14 program IDs across 8 venues — Pump.fun, PumpSwap, Raydium, Jupiter, Orca, Meteora, LaunchLab and Moonshot — so a client can consume normalized trade frames without running Yellowstone or maintaining a parser per venue.
Updated September 2026: this tutorial now matches the live firehose protocol. Stream tokens no longer expire, the socket must be authenticated with the stream token, trade frames use channel: "dex:trades", ULTRA and BUSINESS have DEX-firehose slots, and the service supports named subscriptions plus bounded replay.
What you'll build
A TypeScript process that:
- fetches the account's permanent stream token;
- authenticates
wss://madeonsol.com/ws/v1/dex-stream; - creates a named, filtered subscription;
- consumes
dex:tradesframes; - reconnects safely when the socket drops.
Prerequisites
- Node.js 18+
- an authenticated MadeOnSol API key
- an ULTRA or BUSINESS-class plan for the Solana DEX firehose
- basic TypeScript/WebSocket knowledge
PRO has the main signal WebSocket but no DEX-firehose connection slots. ULTRA has 2 DEX connections; BUSINESS has 5. Enterprise inherits at least the Business floor unless its contract says otherwise.
Coverage: 14 programs, 8 venues
The canonical decoder registry currently covers:
- Pump.fun
- PumpSwap
- Raydium AMM v4
- Raydium CPMM
- Raydium CLMM
- Raydium Route
- Jupiter
- Orca Whirlpool
- Meteora DBC
- Meteora DLMM
- Meteora DAMM
- Meteora CPAMM
- Raydium LaunchLab
- Moonshot
The important distinction is programs versus venues: several Raydium and Meteora program IDs roll up to the same venue name.
Step 1: get a stream token
The REST endpoint uses your normal msk_ API key:
import { MadeOnSol } from "madeonsol";
const client = new MadeOnSol({
apiKey: process.env.MADEONSOL_API_KEY!,
});
const stream = await client.stream.getToken();
console.log(stream.ws_url);
console.log(stream.dex_ws_url);
console.log(stream.expires_at); // null
Current stream-token behavior:
expires_atisnull;next_refresh_atisnull;- calling the endpoint again normally returns the same token;
- the token stops working if streaming entitlement lapses or it is explicitly rotated;
POST /api/v1/stream/token {"rotate":true}replaces it, with 60 seconds of grace for the previous value.
Do not implement the retired 24-hour refresh timer.
Step 2: connect with the token
The DEX socket does not accept your msk_ API key as WebSocket auth. It accepts the stream token returned above.
For Node's ws package, prefer the Authorization header:
import WebSocket from "ws";
const { token, dex_ws_url } = await client.stream.getToken();
if (!dex_ws_url) {
throw new Error("DEX stream requires an ULTRA-class plan");
}
const ws = new WebSocket(dex_ws_url, {
headers: {
Authorization: `Bearer ${token}`,
},
});
The query-string form also works:
const ws = new WebSocket(
`${dex_ws_url}?token=${encodeURIComponent(token)}`
);
Step 3: create a filtered subscription
The firehose requires at least one targeting filter. A named subscription is useful because you can run several independent views on one socket.
ws.on("open", () => {
ws.send(JSON.stringify({
type: "subscribe",
sub_id: "pumpfun-large-buys",
filters: {
dex: "pumpfun",
min_sol: 1,
action: "buy"
},
replay: 50
}));
});
The service caps one socket at 10 subscriptions. If you omit sub_id, the subscription is named default.
Useful trade filters include:
| Filter | Meaning |
|---|---|
token_mint | one mint |
token_mints | up to 50 mints |
wallet | one trader wallet |
wallets | up to 50 wallets |
dex | venue name |
program | exact decoded program ID |
min_sol / max_sol | SOL-size bounds |
action | buy or sell |
Filters on the same subscription are ANDed.
Step 4: consume the actual wire frame
A normal trade is delivered under the dex:trades channel:
{
"channel": "dex:trades",
"sub_id": "pumpfun-large-buys",
"data": {
"wallet": "7xKX...",
"mint": "DezX...",
"action": "buy",
"sol_amount": 2.5,
"token_amount": 1500000,
"tx_signature": "5xYz...",
"block_time": "2026-09-29T20:30:15Z",
"slot": 312456789,
"program": "6EF8...",
"dex": "pumpfun",
"executed_price_sol": 0.00000167,
"pool_address": "...",
"pool_model": "bonding_curve",
"dust": false
},
"ts": 1790713815000
}
The frame intentionally does not promise token names or symbols. Resolve metadata separately and cache it.
A minimal handler:
ws.on("message", (raw) => {
const msg = JSON.parse(raw.toString());
if (msg.type === "heartbeat") return;
if (msg.type === "subscribed") {
console.log("subscription accepted:", msg.sub_id);
return;
}
if (msg.type === "replay_done") {
console.log("replay finished:", msg.sub_id, msg.sent);
return;
}
if (msg.channel !== "dex:trades") return;
const trade = msg.data;
console.log(
`[${trade.dex}] ${trade.action} ${trade.mint.slice(0, 8)}… — ${trade.sol_amount} SOL`
);
});
Step 5: track several strategies on one socket
Do not repeatedly overwrite one anonymous filter when you actually want independent views. Use distinct sub_id values:
ws.send(JSON.stringify({
type: "subscribe",
sub_id: "mint-watch",
filters: {
token_mints: watchedMints
}
}));
ws.send(JSON.stringify({
type: "subscribe",
sub_id: "pumpfun-size",
filters: {
dex: "pumpfun",
min_sol: 2
}
}));
ws.send(JSON.stringify({
type: "subscribe",
sub_id: "wallet-watch",
filters: {
wallets: watchedWallets
}
}));
Every delivered frame carries the matching sub_id, so dedupe keys should include the subscription identity when the same trade intentionally matches more than one view.
The service also supports updating, listing and removing named subscriptions. Keep your desired subscription set in application state so you can recreate it after reconnect.
Building a product on Solana or Robinhood Chain data?
Skip the Geyser pipeline — embed KOL flow, deployer reputation, and the all-DEX firehose over REST, WebSocket, or webhooks. The Business tier (€400/mo) is the self-serve embed license at 500k calls/day — Enterprise adds white-label & redistribution.
Step 6: use replay for short disconnects
The DEX stream keeps an in-memory replay buffer. On subscribe, replay: N asks for recent matching frames, up to the server cap of 500.
ws.send(JSON.stringify({
type: "subscribe",
sub_id: "mint-watch",
filters: {
token_mints: watchedMints
},
replay: 100
}));
The server finishes with a replay_done frame describing how many matching frames were sent and whether the replay was complete.
Replay is a recovery aid, not a historical database. If your application needs durable trade history beyond the in-memory window, store the events you consume or use the relevant REST/history surface.
Step 7: build a production reconnect loop
The token is permanent; the socket is not. Reconnect after network failures and server restarts, and back off when the server tells you the connection limit is full.
import WebSocket from "ws";
import { MadeOnSol } from "madeonsol";
const client = new MadeOnSol({
apiKey: process.env.MADEONSOL_API_KEY!,
});
const desiredSubscriptions = [
{
type: "subscribe",
sub_id: "pumpfun-large-buys",
filters: { dex: "pumpfun", min_sol: 1, action: "buy" },
replay: 100,
},
];
async function runForever() {
let backoff = 2_000;
for (;;) {
try {
const { token, dex_ws_url } = await client.stream.getToken();
if (!dex_ws_url) throw new Error("No DEX stream entitlement");
await new Promise<void>((resolve, reject) => {
const ws = new WebSocket(dex_ws_url, {
headers: { Authorization: `Bearer ${token}` },
});
ws.on("open", () => {
for (const sub of desiredSubscriptions) {
ws.send(JSON.stringify(sub));
}
});
ws.on("message", (raw) => {
const msg = JSON.parse(raw.toString());
if (msg.type === "subscribed") {
backoff = 2_000;
return;
}
if (msg.channel === "dex:trades") {
onTrade(msg.sub_id, msg.data);
}
});
ws.on("close", (code, reason) => {
reject(Object.assign(
new Error(`DEX socket closed ${code}: ${reason.toString()}`),
{ code }
));
});
ws.on("error", reject);
});
} catch (err: any) {
if (Number(err?.code) === 4002) {
backoff = Math.max(backoff, 60_000);
} else {
backoff = Math.min(Math.round(backoff * 1.5), 60_000);
}
await new Promise((r) => setTimeout(r, backoff));
}
}
}
Resetting backoff after a successful subscription acknowledgement is safer than resetting it on TCP open: a socket that opens but cannot subscribe is not healthy.
Step 8: combine the firehose with intelligence APIs
The firehose answers "what trade just happened?" It intentionally does not recompute every higher-order signal in the hot path.
A common architecture is:
DEX firehose
↓
cheap local filters
↓
interesting mint
↓
POST /api/v1/token/batch
or buyer-quality / deployer / KOL endpoints
↓
strategy decision
If several new mints arrive together, use the batch endpoints rather than issuing one REST call per mint. The batch-token guide explains the 50-mint request shape and the quota implications.
Optional views: route legs and liquidity events
The DEX stream has grown beyond the legacy one-trade-per-transaction frame.
For applications that need execution-path detail, subscriptions can opt into route/leg frames. For liquidity monitoring, liquidity: true adds dex:liquidity events and liquidity: "only" creates a liquidity-only subscription.
These are additive views of the same decoded transaction, not extra trades. If you use them for volume analytics, do not add leg events and the legacy dex:trades frame together or you will double-count the transaction.
Current plan limits
| Feature | PRO | ULTRA | BUSINESS |
|---|---|---|---|
| Main signal WebSocket connections | 2 | 3 | 10 |
| Solana DEX firehose connections | 0 | 2 | 5 |
| REST requests/day | 10,000 | 100,000 | 500,000 |
| Generic webhooks | 3 | 10 | 30 |
The Free/BASIC plan has 200 REST requests/day but no paid WebSocket connection slot.
See the live pricing page for the current plan presentation.
FAQ
Does the firehose include every Solana transaction?
No. It is a DEX trade stream over the decoded program registry, not a general-purpose Solana transaction feed. The current registry is 14 program IDs across 8 venues.
Is the stream confirmed or processed?
Treat the firehose as a low-latency live feed rather than a finality guarantee. Strategy code that moves money should define its own confirmation/finality policy instead of inferring it from a marketing latency number.
Can I subscribe to several filters at once?
Yes. Use named subscriptions (sub_id) when the views are independent. One connection can hold up to 10 DEX subscriptions. A single subscription can also combine several filters, which are evaluated together.
Does the stream include symbols and names?
No guarantee. The stable trade identity is the mint address. Resolve display metadata separately and cache it.
Do I need to refresh the stream token every 24 hours?
No. That behavior was retired on August 27, 2026. The token has no scheduled expiry; reconnect the socket when necessary and fetch the current token again during reconnect.
Resources
- Streaming overview
- API reference
- Permanent stream-token reconnect guide
- Batch token lookup guide
- DEX data solutions page
The production rule is simple: authenticate with the stream token, subscribe narrowly, treat the wire schema as the contract, and make reconnect/replay part of the client from day one.
Tools mentioned
Compare features and read reviews.
Live health scores, average ratings, and direct links on MadeOnSol.

Soldex AI
AI-powered decentralized exchange and automated trading on Solana

DexVault
Decentralized community crowdfunding for DEXScreener listings

Dexlab
No-code Solana token minting with DEX swaps, a Telegram bot, and an API

Dexrank
Expert DEX reviews, real-time rankings, and security ratings for Solana exchanges

Dexsport
Licensed Web3 sports betting with 40+ crypto tokens across 20+ chains
Build a deployer sniper bot
Access deployer alerts, bonding stats, and tier data via API. Free tier: 200 requests/day.
import { MadeOnSol } from "madeonsol";
const client = new MadeOnSol({ apiKey: "msk_your_key" });
// Elite deployer alerts with KOL buy enrichment
const { alerts } = await client.deployer.alerts({ limit: 5 });
// Top deployers by bonding rate
const { deployers } = await client.deployer.leaderboard({ tier: "elite" });Building a product on Solana or Robinhood Chain data?
MadeOnSol isn't an RPC or another generic token API — it's Solana & Robinhood Chain memecoin intelligence that's painful to build in-house, pulled from dual-region gRPC shred streams and our own Robinhood Chain node, pushed to your app as events land.
Signals you'd otherwise build
KOL & smart-money flow from 2,000+ labeled wallets, deployer reputation, coordination clusters, linked-wallet entity resolution, and an all-DEX firehose.
Embed it in your product
The Business tier (€400/mo, self-serve) licenses you to display MadeOnSol data inside your own product — 500k calls/day, 15 WS + 6 firehose connections. Enterprise above adds white-label & redistribution rights and custom endpoints.
Evaluate first, commit later
Test everything on a free ULTRA key — no commitment. If it fits, we scope volume or white-label pricing.
Keep reading
More from the blog.

DeFi
How to Swap Crypto Without KYC: ChangeNOW, DEXs, and What Actually Works
A practical guide to swapping crypto without KYC in 2026. Covers ChangeNOW for cross-chain instant swaps, on-chain DEXs like Jupiter and Raydium, THORChain, and when each option makes sense.

API Guides
Inside the Live Terminal Demo: REST Snapshots Plus WebSocket Updates for Solana and Robinhood Chain
A tour of the MadeOnSol live terminal demo: which panels stream, which refresh and which load on request, how one REST snapshot and one WebSocket subscription feed each screen, and how to build the same thing in your own terminal.

API Guides
Build a Realtime Solana Token Intelligence Dashboard Without Polling
Load a Solana token's risk, locks, flow and holder count with one include-scoped REST read, then keep the panel current from WebSocket events instead of polling. Runnable Node and browser code with watchTokenIntelligence() from madeonsol-x402 4.3.0.

Developer Tools
Building a Solana Portfolio Alert System: Price Drops, KOL Exits, and Recovery Signals (2026)
Combine price dip webhooks, KOL coordination WebSocket streams, and wallet tracker events into a unified Solana alert system. TypeScript code for multi-signal trading decisions — sell when smart money exits, buy when they accumulate.

API Guides
Robinhood Chain Trading Terminal Architecture: REST Snapshots Plus WebSocket Updates
How to structure a Robinhood Chain (chain id 4663) trading terminal: one include-scoped REST snapshot per token, then price, risk, lock and candle events over one WebSocket. Runnable code with watchTokenIntelligence() from robinhood-chain-x402 0.21.0, plus the Ultra firehose trade-off.

Guides
How to Get pump.fun Token Trades via API: the Per-Mint Trade Tape (2026)
One GET returns every buy and sell on a pump.fun token, newest first, with the executed price, the pool price at that slot, the wallet and the early-buyer rank. Cursor paging, buy/sell and wallet filters, and what the coverage block tells you before you trust the numbers.
Enjoyed this article?
Explore the live data.
Real-time KOL trades, Pump.fun deployer intel, and 1,200+ ranked Solana & Robinhood Chain tools — free to explore.
Open the KOL Tracker