Query editor
-- Plasma tracker: XPL holders by balance band and wallet-cohort flows, from chain data (incremental).-- DO NOT EDIT CASUALLY: Dune keys the stored previous result to this exact SQL, so any edit makes the next run-- rebuild everything from the base table (correct, but it rescans every day since the base date).-- Wallet labels live in dune.papaoutai.result_plasma_tracker_labels and can be changed there without touching this query.---- Balance of an address = its balance in the base table (dune.papaoutai.result_plasma_xpl_base, end of 2026-10-16)-- + value received - value sent in successful traces since (calls, creations with an endowment, selfdestruct refunds)-- - gas paid (gas_used x gas_price). The four genesis vaults get their genesis allocation added back.-- Each run reads its own previous result, scans only the days after the stored state date, and keeps the state-- three days behind today so the last days are recomputed on the next runs.---- Rows by kind:-- cum : day, k, n = addresses whose balance at the end of that UTC day is in band k or a higher one.-- Bands: k = floor(1000 * log10(balance in XPL)) for 0.1 <= balance < 1,000 XPL (-1000..2999), so band k starts at-- 10^(k/1000) XPL and is 0.23% wide (1000 = 10 XPL, 2000 = 100 XPL); 10003..10010 = decades from 10^3 to 10^10 XPL-- (10006 = 1,000,000 XPL or more); -9997 = above 0 but under 0.1 XPL; -9998 = zero; -9999 = negative.-- Wallets holding at least $1 of XPL at price p: x = 1000 * log10(1 / p), k = floor(x),-- count = n(k+1) + (n(k) - n(k+1)) * (k + 1 - x). Older days keep only every 100th band (see the carry step).-- flow : day, k, n = wallets active, w = net change in wei that day for cohort k:-- 1 fresh wallets (first native XPL activity within the 15 days ending that day, not labelled)-- 2 large wallets (held 1,000,000 XPL or more at the start of the day, not labelled, not a contract)-- 3 wallets first seen that day (not labelled)-- 4 identified exchange wallets (label kind 'exchange')-- state : address, w = net wei since the base date as of the state date, day = first active day since the base date-- meta : k = 1 state date (day) and number of state rows (n); 2 base date and query version (2); 3 last complete day and days scanned;-- 4 state date of the previous run that was used (n = 1) or not (n = 0); 5 n = 1 when the base table's date matchesWITH prev AS (SELECT * FROM TABLE(previous.query.result(schema => DESCRIPTOR(kind VARCHAR, day DATE, address VARBINARY, k INTEGER, n BIGINT, w DECIMAL(38,0))))),adj(address, wei) AS (VALUES(0x000000000000000000000000000000000a11b001, CAST(DECIMAL '2500000000000000000000000000' AS DECIMAL(38,0))),(0x000000000000000000000000000000000a11b002, CAST(DECIMAL '2500000000000000000000000000' AS DECIMAL(38,0))),(0x000000000000000000000000000000000a11b003, CAST(DECIMAL '1000000000000000000000000000' AS DECIMAL(38,0))),(0x000000000000000000000000000000000a11b004, CAST(DECIMAL '4000099822680000000000000000' AS DECIMAL(38,0)))),base AS (SELECT COALESCE(b.address, j.address) AS address,COALESCE(b.wei, DECIMAL '0') + COALESCE(j.wei, DECIMAL '0') AS wei,b.first_dayFROM dune.papaoutai.result_plasma_xpl_base bFULL OUTER JOIN adj j ON j.address = b.address),pm AS (SELECT MAX(CASE WHEN kind = 'meta' AND k = 1 THEN day END) AS s_prev0,MAX(CASE WHEN kind = 'meta' AND k = 1 THEN n END) AS state_rows_expected,MAX(CASE WHEN kind = 'meta' AND k = 2 THEN day END) AS base_date_prev,MAX(CASE WHEN kind = 'meta' AND k = 2 THEN n END) AS version_prev,COUNT(CASE WHEN kind = 'state' THEN 1 END) AS state_rows_foundFROM prev),chk AS (SELECT u.use_prev,CASE WHEN u.use_prev THEN u.s_prev0 ELSE DATE '2026-10-16' END AS s_prev,GREATEST(CASE WHEN u.use_prev THEN u.s_prev0 ELSE DATE '2026-10-16' END, date_add('day', -3, CURRENT_DATE)) AS s_new,date_add('day', -1, CURRENT_DATE) AS last_dayFROM (SELECT COALESCE(pm.version_prev = 2 AND pm.state_rows_expected = pm.state_rows_foundAND pm.base_date_prev = DATE '2026-10-16' AND pm.s_prev0 >= DATE '2026-10-16', false) AS use_prev,pm.s_prev0