Query by @astrolabe-pumpfun, updated 2026-11-05. #pumpfun #pnl #traders #wallets
Example query
WITH
pos AS (
SELECT
toStringCutToZero(signing_wallet) AS wallet,
toStringCutToZero(base_coin) AS mint,
sumIf(quote_coin_amount, direction = 'buy') / 1e9 AS sol_in,
sumIf(quote_coin_amount, direction = 'sell') / 1e9 AS sol_out,
sumIf(base_coin_amount, direction = 'buy') AS tok_bought,
sumIf(base_coin_amount, direction = 'sell') AS tok_sold,
count() AS trades,
sum(fee) / 1e9 AS fees_sol,
any(transform(parent_program,
['', 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4', 'DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH',
'T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT', 'GMGNreQcJFufBiCTLDBgKhYEfEe9B454UjpDr5CaSLA1',
'GMgnVFR8Jb39LoXsEVzb3DvBy3ywCmdmJquHUy1Lrkqb', 'MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e'],
['direct call', 'Jupiter', 'DFlow', 'Titan', 'GMGN', 'GMGN', 'Pump.fun Mayhem'],
concat(substring(parent_program, 1, 6), '…'))) AS router
FROM pumpfun_v2_swaps
WHERE failed = 0 AND block_date_utc >= toDate((SELECT max(block_time) FROM solana_blocks) - INTERVAL {{hours}} HOUR) AND block_time > (SELECT max(block_time) FROM solana_blocks) - INTERVAL {{hours}} HOUR AND block_time <= (SELECT max(block_time) FROM solana_blocks)
GROUP BY wallet, mint
),
last_state AS (
-- the curve's virtual reserves after the token's last trade in the window
SELECT toStringCutToZero(base_coin) AS mint,
argMax(virtual_sol_balance_after, (block_time, slot, tx_idx)) AS vsol,
argMax(virtual_token_balance_after, (block_time, slot, tx_idx)) AS vtok
FROM pumpfun_v2_swaps
WHERE failed = 0 AND block_date_utc >= toDate((SELECT max(block_time) FROM solana_blocks) - INTERVAL {{hours}} HOUR) AND block_time > (SELECT max(block_time) FROM solana_blocks) - INTERVAL {{hours}} HOUR AND block_time <= (SELECT max(block_time) FROM solana_blocks) AND virtual_token_balance_after > 0
GROUP BY mint
),
position AS (
SELECT wallet, mint, sol_in, sol_out, trades, fees_sol, router,
greatest(tok_bought - tok_sold, 0) AS tok_left,
-- what selling the remaining tokens into the curve would return now: constant product, minus the 1% fee
if(tok_left > 0, toFloat64(vsol) * tok_left / (toFloat64(vtok) + tok_left) / 1e9 * 0.99, 0) AS held_sol,
sol_out - sol_in AS realized_sol,
sol_out - sol_in + held_sol AS pnl_sol
FROM pos
LEFT JOIN last_state USING mint
),
wallets AS (
SELECT wallet,
sum(pnl_sol) AS pnl,
sum(realized_sol) AS realized,
sum(held_sol) AS held,
sum(sol_in) + sum(sol_out) AS volume,
sum(sol_in) AS bought,
sum(trades) AS n_trades,
count() AS n_tokens,
countIf(pnl_sol > 0) AS n_tokens_won,
sum(fees_sol) AS fees,
argMax(router, trades) AS main_router,
-- a signer with thousands of tokens in a day is a bundler or relayer signing for other people, not a trader
(sum(trades) > 50000 OR count() > 3000) AS infra
FROM position
GROUP BY wallet
)
SELECT
count() AS traders,
round(sum(volume)) AS volume_sol,
round(countIf(pnl > 0) / count() * 100, 1) AS winners_pct,
round(sum(realized)) AS realized_pnl_sol,
round(sum(held)) AS paper_pnl_sol,
round(sumIf(pnl, pnl > 0)) AS gains_sol,
round(sumIf(pnl, pnl < 0)) AS losses_sol,
round(median(pnl), 3) AS median_pnl_sol,
round(sum(fees)) AS tx_fees_sol,
round(arraySum(arraySlice(arrayReverseSort(groupArrayIf(pnl, pnl > 0 AND NOT infra)), 1, 100)) / greatest(sumIf(pnl, pnl > 0), 1e-9) * 100) AS top100_share_of_gains_pct,
countIf(infra) AS infra_wallets
FROM walletsCharts: Traders, Winners, Realized, Still held, Gains, Losses, Top 100 take, Tx fees.
| traders | volume_sol | winners_pct | realized_pnl_sol | paper_pnl_sol | gains_sol | losses_sol | median_pnl_sol | tx_fees_sol | top100_share_of_gains_pct | infra_wallets |
|---|---|---|---|---|---|---|---|---|---|---|
| 157495 | 73364564.0 | 52.5 | -5573184.0 | 7121774.0 | 5003061.0 | -3454471.0 | 0.001 | 1521.0 | 40.0 | 7 |
1 rows. Computed 2026-11-05T13:16:59Z.