Query by @astrolabe-pumpfun, updated 2026-11-05. #pumpfun #smart money #wallets #pumpswap
Example query
WITH
-- the period ends at the newest swap, not the newest block: the tables are loaded one after another
(SELECT max(block_time) FROM pumpfun_v2_swaps WHERE failed = 0) AS end_t,
end_t - INTERVAL {{days}} DAY AS start_t,
{{hours}} * 3600 AS window_s,
toFloat64({{x}}) AS target_x,
new_tokens AS (
SELECT toStringCutToZero(mint) AS mint, min(block_time) AS created_t
FROM pumpfun_token_creation
WHERE block_time > start_t AND block_time <= end_t
GROUP BY mint
),
trades AS (
SELECT toStringCutToZero(base_coin) AS mint, slot, tx_idx, block_time,
toStringCutToZero(signing_wallet) AS wallet, direction = 'buy' AS is_buy,
quote_coin_amount / 1e9 AS sol, toFloat64(base_coin_amount) AS tok, 'pump.fun' AS venue
FROM pumpfun_v2_swaps
WHERE failed = 0 AND block_date_utc >= toDate(start_t) AND block_time > start_t AND block_time <= end_t
AND base_coin_amount > 0 AND quote_coin_amount > 0
AND toStringCutToZero(base_coin) IN (SELECT mint FROM new_tokens)
UNION ALL
-- PumpSwap, the usual orientation: the token is the base, SOL the quote; B = buying the token
SELECT base_token, slot, tx_idx, block_time, signing_wallet, direction = 'B',
quote_token_amount / 1e9, toFloat64(base_token_amount), 'PumpSwap'
FROM pumpswap_all_swaps
WHERE block_date_utc >= toDate(start_t) AND block_time > start_t AND block_time <= end_t
AND quote_token = 'So11111111111111111111111111111111111111112' AND base_token_amount > 0 AND quote_token_amount > 0
AND base_token IN (SELECT mint FROM new_tokens)
UNION ALL
-- PumpSwap, reversed pools: SOL is the base, the token the quote; S (selling SOL) = buying the token
SELECT quote_token, slot, tx_idx, block_time, signing_wallet, direction = 'S',
base_token_amount / 1e9, toFloat64(quote_token_amount), 'PumpSwap'
FROM pumpswap_all_swaps
WHERE block_date_utc >= toDate(start_t) AND block_time > start_t AND block_time <= end_t
AND base_token = 'So11111111111111111111111111111111111111112' AND base_token_amount > 0 AND quote_token_amount > 0
AND quote_token IN (SELECT mint FROM new_tokens)
),
priced AS (SELECT *, sol / tok AS price FROM trades),
by_slot AS (
SELECT mint, slot, min(block_time) AS t, argMin(price, tx_idx) AS first_price, max(price) AS slot_max, sumIf(sol, is_buy) AS buy_sol_slot
FROM priced
GROUP BY mint, slot
),
-- for every slot a token traded in: the highest price printed in the next {{hours}} hours (a necessary condition for a hit)
fwd AS (
SELECT mint, slot, t, first_price,
max(slot_max) OVER (PARTITION BY mint ORDER BY toUnixTimestamp(t) RANGE BETWEEN CURRENT ROW AND window_s FOLLOWING) AS max_fwd,
sum(buy_sol_slot) OVER (PARTITION BY mint ORDER BY toUnixTimestamp(t) RANGE BETWEEN CURRENT ROW AND window_s FOLLOWING) AS buy_vol_fwd
FROM by_slot
),
first_buys0 AS (
SELECT wallet, mint, min(slot) AS buy_slot, min(block_time) AS buy_t, argMin(sol, (slot, tx_idx)) AS buy_sol,
argMin(venue, (slot, tx_idx)) AS buy_venue,
-- the wallet's further buys of the token within the window after its first buy
greatest(arraySum(arrayMap(x -> if(x.1 > buy_t AND x.1 <= buy_t + INTERVAL window_s SECOND, x.2, 0), groupArray((block_time, sol)))) - buy_sol, 0) AS own_buy
FROM priced
WHERE is_buy
GROUP BY wallet, mint
),
-- the screen: wallets with {{min_tokens}} to {{max_tokens}} tokens entered in the period; nothing else is evaluated
-- (a first cut on tokens bought; the final one, on tokens with a filled entry, is in `wallets`)
first_buys AS (
SELECT * FROM first_buys0
WHERE wallet IN (SELECT wallet FROM first_buys0 GROUP BY wallet HAVING count() BETWEEN {{min_tokens}} AND {{max_tokens}})
),
-- the entry is the token's first trade in a later slot: one block of execution delay
entries0 AS (
SELECT f.wallet AS wallet, f.mint AS mint, f.buy_slot AS buy_slot, f.buy_t AS buy_t, f.buy_sol AS buy_sol, f.buy_venue AS buy_venue, f.own_buy AS own_buy,
e.slot AS entry_slot, e.t AS entry_t, e.first_price AS entry_price, e.max_fwd AS max_fwd, e.buy_vol_fwd AS buy_vol_fwd,
e.slot > 0 AND e.t <= f.buy_t + INTERVAL 10 MINUTE AS filled,
filled AND e.max_fwd >= target_x * e.first_price AS candidate
FROM first_buys AS f
ASOF LEFT JOIN fwd AS e ON e.mint = f.mint AND e.slot > f.buy_slot
),
-- a hit needs the target price to be printed by more than the top 1% of the window's trades: those are outliers.
-- Trades are counted per minute and per 0.5% price step, so a window is 1-minute steps and a price is +-0.5%.
by_min AS (
SELECT mint, m, sum(c) AS cnt, max(mx) AS mx, groupArray(b) AS buckets, groupArray(c) AS counts
FROM (SELECT mint, toStartOfMinute(block_time) AS m, toInt32(floor(log(price) / log(1.005))) AS b, count() AS c, max(price) AS mx
FROM priced GROUP BY mint, m, b)
GROUP BY mint, m
),
cand AS (
SELECT mint, entry_slot, thr, toInt32(ceil(log(thr) / log(1.005))) AS tb,
toStartOfMinute(entry_t) + INTERVAL arrayJoin(range(1, toUInt32({{hours}} * 60) + 1)) MINUTE AS m
FROM (SELECT DISTINCT mint, entry_slot, entry_t, target_x * entry_price AS thr FROM entries0 WHERE candidate)
),
verify AS (
SELECT c.mint AS mint, c.entry_slot AS entry_slot, sum(b.cnt) AS n_window,
sum(if(b.mx < c.thr, 0, arraySum(arrayMap((k, v) -> if(k >= c.tb, v, 0), b.buckets, b.counts)))) AS n_above
FROM cand AS c
JOIN by_min AS b ON b.mint = c.mint AND b.m = c.m
GROUP BY c.mint, c.entry_slot
),
entries AS (
SELECT e.wallet AS wallet, e.mint AS mint, e.buy_slot AS buy_slot, e.buy_t AS buy_t, e.buy_sol AS buy_sol, e.buy_venue AS buy_venue,
e.entry_slot AS entry_slot, e.entry_t AS entry_t, e.entry_price AS entry_price, e.filled AS filled,
e.candidate AND v.n_above >= floor(v.n_window * 0.01) + 1 AS hit,
-- how much of the window's buying was the wallet itself: a 2x made by one's own buys is a pump, not a call
if(e.filled AND e.buy_vol_fwd > 0, least(e.own_buy / e.buy_vol_fwd, 1), 0) AS own_share
FROM entries0 AS e
LEFT JOIN verify AS v ON v.mint = e.mint AND v.entry_slot = e.entry_slot
),
-- all trades of the screened wallets in the period's tokens: did the hit rate turn into money
flows AS (
SELECT wallet, sumIf(sol, is_buy) AS sol_in, sumIf(sol, NOT is_buy) AS sol_out, count() AS n_trades
FROM priced
WHERE wallet IN (SELECT wallet FROM first_buys)
GROUP BY wallet
),
wallets AS (
SELECT wallet,
any(f.sol_out - f.sol_in) AS realized,
any(f.n_trades) AS n_trades,
count() AS tokens,
countIf(filled) AS filled_tokens,
countIf(hit) AS hits,
round(hits / greatest(filled_tokens, 1) * 100, 1) AS hit_pct,
-- Wilson lower bound (95%): a hit rate that discounts small samples, for comparing 8 tokens with 80
round((hits / greatest(filled_tokens, 1) + 1.92 / greatest(filled_tokens, 1)
- 1.96 * sqrt((hits / greatest(filled_tokens, 1)) * (1 - hits / greatest(filled_tokens, 1)) / greatest(filled_tokens, 1) + 0.96 / pow(greatest(filled_tokens, 1), 2)))
/ (1 + 3.84 / greatest(filled_tokens, 1)) * 100, 1) AS score,
round(avg(buy_sol), 3) AS avg_buy_sol,
round(sum(buy_sol), 2) AS total_buy_sol,
round(median(entry_slot - buy_slot)) AS median_delay_slots,
round(countIf(buy_venue = 'PumpSwap') / count() * 100) AS pumpswap_pct,
round(avgIf(own_share, filled) * 100, 1) AS own_share_pct,
countIf(hit AND own_share >= 0.5) AS self_made_hits
FROM entries
LEFT JOIN flows AS f USING wallet
GROUP BY wallet
HAVING filled_tokens BETWEEN {{min_tokens}} AND {{max_tokens}}
)
SELECT
rank,
wallet,
concat(substring(wallet, 1, 4), '…', substring(wallet, length(wallet) - 3)) AS short,
hit_pct,
hits,
filled_tokens - hits AS misses,
filled_tokens AS tokens
FROM (SELECT *, row_number() OVER (ORDER BY hit_pct DESC, tokens DESC, wallet) AS rank FROM wallets)
ORDER BY rank
LIMIT 200| rank | wallet | short | hit_pct | hits | misses | tokens |
|---|---|---|---|---|---|---|
| 1 | H7Yv1jU5Rtz9bgTrSrXPFNEZsEFwHL3EkPq1n7Nd4hAt | H7Yv…4hAt | 88.9 | 8 | 1 | 9 |
| 2 | 59KA9rkunfChmq8gvAGR7Hso3XQmayo9gkSmWSRqJhZy | 59KA…JhZy | 87.5 | 7 | 1 | 8 |
| 3 | 6d1gQNxiovSbcYKbXwsww7dqD6ZDbsxfEnUgSuJf9oNK | 6d1g…9oNK | 87.5 | 7 | 1 | 8 |
| 4 | 74AawagstYyjuB2bF1GXMx1gjS6DDdcCyX1xzFcRN81p | 74Aa…N81p | 87.5 | 7 | 1 | 8 |
| 5 | 8VR6YZ9uSgAVpnt3rx7cWoBBqfbm7cmyoTh6N9umk79C | 8VR6…k79C | 87.5 | 7 | 1 | 8 |
| 6 | 93zEKKqa5ybEPGMx6ejhwwNRBF911oyoTjQdTt1r4Hou | 93zE…4Hou | 87.5 | 7 | 1 | 8 |
| 7 | Hx4sX9GuPxSyB2w41PiZqMa716TELjH7HUge4WCR5v8C | Hx4s…5v8C | 87.5 | 7 | 1 | 8 |
| 8 | W1AroTJhxdE2vBrgYK3NdVeo5Z1pUfsWBx5YYceJw2x | W1Ar…Jw2x | 87.5 | 7 | 1 | 8 |
| 9 | 61eiJCWKB5m9NdFjNn2LGNgALtHAuAwBoSALRwgcXq5N | 61ei…Xq5N | 83.3 | 10 | 2 | 12 |
| 10 | 4Q8W3aQdnCAqyu4QiCs147snosmPpNVNSFKngv85gfg7 | 4Q8W…gfg7 | 82.4 | 14 | 3 | 17 |
| 11 | 42NTg1KpbpunssAcVzZmtTb6uh4kNsPyiJA3oRfEroTA | 42NT…roTA | 80.0 | 8 | 2 | 10 |
| 12 | 9TZZsbwJowPKXT2Ug1BgNXcSU763YEJ3CvAxoVbe8X3v | 9TZZ…8X3v | 78.9 | 15 | 4 | 19 |
| 13 | 7GEhRNEYTcbTtsc5DVDb9wRetdiCQaveYBm4L5JzEKm7 | 7GEh…EKm7 | 77.8 | 7 | 2 | 9 |
| 14 | 8WmC6RSDbRHH6wevq9GjrH1ynRV9cTx7LusoU32Nc66A | 8WmC…c66A | 77.8 | 7 | 2 | 9 |
| 15 | AaGv9ZJHFCcaNtADjcPQtUqULg6wxsUbSCRNpht9SJNB | AaGv…SJNB | 77.8 | 7 | 2 | 9 |
| 16 | BNNLjD1gSMGxZuZZiuaYrjzekkQHw2KgKeHC8bGxtR2r | BNNL…tR2r | 77.8 | 7 | 2 | 9 |
| 17 | BwcAc2PPnixBnfQVaygbe9yTyGEmrnfuoSiAaf5XCias | BwcA…Cias | 77.8 | 7 | 2 | 9 |
| 18 | CHkHQCRmE9KtPDSuRTpPHQJ2prZFpmUdh1Qo8EDijZxo | CHkH…jZxo | 77.8 | 7 | 2 | 9 |
| 19 | CaMGcmX99DtxsoaZSe7Ax8TXkUyTzpqAkuQeZ62BGpSF | CaMG…GpSF | 77.8 | 7 | 2 | 9 |
| 20 | FJpoc9UMey84fJSLoKuZQtGgVxqG5ExXKJ1dgJoVfpCY | FJpo…fpCY | 77.8 | 7 | 2 | 9 |
| 21 | FeApeEAqUJQDFiGzWs3G2AmgY6zr5w4LpySdM4maCmuR | FeAp…CmuR | 77.8 | 7 | 2 | 9 |
| 22 | FgMw611SCPP6NkdxPiTN2Vv4Pfq8gyuJCLqvFK1QJxjG | FgMw…JxjG | 77.8 | 7 | 2 | 9 |
| 23 | HmetboP6tfnNFoa6FVXtjtRMonv2Kau6vSDSPN9LEhmm | Hmet…Ehmm | 77.8 | 7 | 2 | 9 |
| 24 | EGLJ9chaeiGoq8vyHsTBpQhzLydLHLeEg6q5EUjydH4z | EGLJ…dH4z | 76.9 | 10 | 3 | 13 |
| 25 | ESKAKTwuHdgxdbHsHZJNtGdgcFnvLdoSKRUiUgPAb2F5 | ESKA…b2F5 | 76.5 | 13 | 4 | 17 |
| 26 | 2P5a4WJdf55mnS1oVh8GpqrXLPBTfDx9ydQ4VLQXF7g3 | 2P5a…F7g3 | 75.0 | 6 | 2 | 8 |
| 27 | 2iNh5tcv8rsEyUsFzfsLy8qLGFWrnGuLdK6p4WuaUpqj | 2iNh…Upqj | 75.0 | 6 | 2 | 8 |
| 28 | 41jUiUZc2uo9ynBksoMwJwjZ7zymiBrCvkBzebqGaLDT | 41jU…aLDT | 75.0 | 6 | 2 | 8 |
| 29 | 4Ry2VsXqKexP9kn7dxuRBL6WMCz92aAnWjfMxWvy5pHL | 4Ry2…5pHL | 75.0 | 6 | 2 | 8 |
| 30 | 5p4mHYtgFu6e5s4S8aEHcqzfcBeNAwDrnnRFefZSwQEE | 5p4m…wQEE | 75.0 | 6 | 2 | 8 |
First 30 of 200 rows. Computed 2026-11-23T11:22:06Z.