services
Get a key

library / Blockchain ideas / BI0028

DEX activity leaderboard

A ranked table of the busiest Solana swap programs from one getSignaturesForAddress call each on Carbium: transactions per minute, failed share and the sample behind each number, with the cells each refresh costs on every plan and a main.ts you can run.

By Carbium · Data products · BI0028 · updated 2026-11-22

01

Who uses it

A hackathon team putting a screen in front of a room wants to show which swap programs are busiest right now. The table that answers it has one row per program, ranked.

The data comes from the history of each program's own address, so you index and decode nothing yourself. One run makes one call per program and prints the ranking in a few seconds. History and every other call come from services.carbium.sh under one key.

02

What it ranks

Each program is one row. The rows are sorted by rate, highest first.

ColumnHow it is computedExample
ProgramA label from a short list in the code, or the first 8 characters of the address for one you pass inOrca Whirlpool
Per minRows with a block time, divided by the seconds between the page's newest and oldest block time, times 602307.7
FailedShare of rows whose err is not null65.3%
SampleHow many rows the page held and how many seconds they span1000 rows over 26 s

The rate comes from the page's own span because a count over a fixed window cannot be had from one call. The busiest pages span under half a minute, so an hour of such a program is about 150 pages of 1,000 rows, and a question like "how many in the last hour" would need well over a hundred pages. The span of the newest page is what one call can measure, and it is a current rate.

Block times are whole seconds, so a page carries about a second of rounding error. Pages run from under half a minute to about ten minutes, and one second on a 24 s page moves the rate by about a twenty-fourth, less on a longer page. A page of 1,000 rows widens the span and steadies the rate.

03

The build

The leaderboard is one file. It needs @solana/kit and what Node 24 ships, and it is read-only and signs nothing. Run it as node main.ts, or add program addresses after it to rank your own list.

  1. Read CARBIUM_KEY and exit with a message if it is missing. Take the program addresses from the command line, or use the five in the code: Jupiter v6, Raydium AMM v4, Raydium CPMM, Orca Whirlpool and Meteora DLMM.
  2. Create the RPC client once, with the key in the x-api-key header.
  3. For each program, call getSignaturesForAddress with a limit of 1000. Each call reads at confirmed. All the calls go out together.
  4. Settle every call on its own. A program that fails prints its reason and leaves the other rows intact.
  5. Work out rate and failed share per program, sort by rate, and print one line each.
main.ts
// BI0028 · DEX activity leaderboard// https://carbium.sh/library/blockchainideas/dex-activity-leaderboard// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) {  console.error("Set CARBIUM_KEY to your Carbium API key.");  process.exit(1);}const rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": key },  }),);const PAGE = 1000; // newest rows read per programconst KNOWN: Record<string, string> = {  JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4: "Jupiter v6",  "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8": "Raydium AMM v4",  CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C: "Raydium CPMM",  whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc: "Orca Whirlpool",  LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo: "Meteora DLMM",};const programs = process.argv.length > 2 ? process.argv.slice(2) : Object.keys(KNOWN);async function sample(program: string) {  const rows = await rpc    .getSignaturesForAddress(address(program), { limit: PAGE, commitment: "confirmed" })    .send();  // kit returns blockTime as a bigint; null rows are left out of the span  const times = rows.flatMap((r) => (r.blockTime === null ? [] : [Number(r.blockTime)]));  if (times.length < 2) throw new Error("fewer than 2 timed rows");  const span = Math.max(1, Math.max(...times) - Math.min(...times));  const failed = rows.filter((r) => r.err !== null).length;  return {    name: KNOWN[program] ?? program.slice(0, 8),    perMin: (times.length / span) * 60,    failedPct: (100 * failed) / rows.length,    rows: rows.length,    span,  };}type Row = Awaited<ReturnType<typeof sample>>;Promise.allSettled(programs.map(sample)).then((settled) => {  const board: Row[] = [];  settled.forEach((r, i) => {    if (r.status === "fulfilled") board.push(r.value);    else console.error(`${programs[i]} failed:`, r.reason instanceof Error ? r.reason.message : r.reason);  });  board.sort((a, b) => b.perMin - a.perMin);  console.log("rank  program          per_min  failed   sample");  board.forEach((b, i) => {    console.log(      `${String(i + 1).padStart(4)}  ${b.name.padEnd(15)}  ${b.perMin.toFixed(1).padStart(7)}  ${b.failedPct.toFixed(1).padStart(5)}%   ${b.rows} rows over ${b.span} s`,    );  });  if (board.length === 0) process.exitCode = 1;});

run: CARBIUM_KEY=<YOUR_KEY> node main.ts [PROGRAM_ADDRESS ...]

Kit returns blockTime as a bigint, so the code converts it with Number before any arithmetic. A row with a null blockTime is left out of the span. address() from kit rejects a malformed string, and because that happens inside the settled call, one bad address becomes one failed row.

A signature turns up in a program's history whenever the transaction lists that program among its accounts. A Jupiter route that ends in an Orca pool therefore counts for both rows. The leaderboard ranks how often a program appears in landed transactions.

04

What it costs

Cells are the admission charge per call, and the plan's req/s for the method sets the rate. getSignaturesForAddress costs 50 cells, so a refresh of five programs is 250 cells. Credits meter RPC work on top, and each paid month adds credits that stay if unspent.

PlanCreditsHistory call rateShortest gap between refreshes of five programs
Free ($0)500K once, at sign-up0.24 req/sabout 21 s
Dev ($20)10M per month1.2 req/sabout 4 s
Business ($250)50M per month100 req/sunder 1 s
Pro ($500)200M per month500 req/sunder 1 s

The gap is five calls divided by the plan's rate for the method. A class absorbs bursts up to 1,024 cells, so the first refresh goes through at once on any plan. On Free, that burst covers about four back-to-back refreshes of 250 cells, and 21 seconds is the steady gap once the burst is spent. Limits are per account, so other keys and tools on the account draw on the same budget.

The call count follows the length of the list: 20 programs is 20 calls and 1,000 cells per refresh, whatever the traffic of each one. On Free, rank a handful and refresh every 30 seconds. On Business or Pro, a list of dozens refreshes every few seconds.

05

What to add next

  • A loop: run the ranking every 30 seconds and insert each result into node:sqlite with the time. A day of rows gives each program a curve, and your own table is the only record past the 30 days Carbium's history keeps.
  • Volume: call getTransaction (50 cells) on a sample of signatures and read the token balance changes. On Free, sample a few per program. Pass maxSupportedTransactionVersion: 1 and handle a null answer for an older signature.
  • Unique wallets: read the fee payer from the same sampled transactions and count distinct ones per program.
  • A live ticker: logsSubscribe with mentions for one program opens at 25 credits and then costs 20 credits per MiB sent. A busy program sends a lot, so keep that for the one row on screen.
  • A chart: send the rows to a dashboard as in Grafana network metrics.
  • One wallet's side of the same data: Wallet activity tracker takes an address instead of a program.
06

Where it ends

  • A call sees the newest 1000 rows. The rate covers that page's span, from under half a minute to over ten minutes depending on the program.
  • A very busy program can fill 1,000 rows in under half a minute, and its rate then moves by about a twentieth between runs.
  • A row counts transactions that mention the program. Routed swaps count for every program on the route, and adding liquidity or closing an account counts too. Dollar volume and wallet counts come from the sampled getTransaction reads under What to add next.
  • The list is yours. A new program appears only when you add its address.
  • Failed share covers transactions that landed with an error. One that never landed leaves no signature.
  • Paging back reaches 30 days at most, from Carbium's own address index. An empty page past that is the index's age limit, so rankings from before it cannot be rebuilt.
07

When it goes wrong

what goes wrongwhat to do
A row prints fewer than 2 timed rows.The address has had at most one transaction in the last 30 days. Check it in an explorer and pass the swap program's own address.
Rows fail with 429 on Free.Five calls at 50 cells each outrun 0.24 req/s once the burst is spent, which happens when refreshes come back to back. Wait the retry-after hint and space refreshes about 21 seconds apart, or rank fewer programs.
Every row fails with 401.The key was not recognized at the door. Attach the whole key in CARBIUM_KEY, with nothing trimmed.
The rate of a busy program jumps between runs.The page spans under half a minute and block times are whole seconds, so one second of rounding moves the rate by about a twentieth. The limit is already 1,000, so average the last few runs.
One program is missing from the table and a line says failed.The reason is printed next to the address. A malformed address is rejected by kit before any call goes out, and the other rows still print.
08

Questions

Can it rank by dollar volume?

Not from this call. The history rows carry a signature, a result and a block time. Volume needs the token balance changes from getTransaction, at 50 cells for each transaction you read.

Why not stream the logs instead?

A subscription per program works for one live row, and it is metered by the MiB. The history call gives all programs a comparable rate at once, from a fixed number of rows, whatever their traffic.

How far back can I rank?

The address index keeps up to 30 days. Page back with before to reach older rows, at 50 cells a page. Rankings of earlier days need your own stored table.

Does the Free plan run it?

Yes. One run is 250 cells and fits the burst. A repeating refresh on Free is one about every 21 seconds for five programs.