Query editor
-- FOMO Solana per-wallet PnL ledger — REHEARSAL WINDOW (3 days), invariant summary.-- Quote set is 4 mints: native SOL is distinct from wSOL (established by probe 8436889).with fee as (select tx_id, from_owner as walletfrom tokens_solana.transferswhere block_date >= date '2026-08-21' and block_date < date '2026-08-24'and to_owner = 'R4rNJHaffSUotNmqSKNEfDcJE8A7zJUkaoM5Jkd7cYX'and token_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),cohort as (select distinct wallet from fee),fomo_tx as (select distinct tx_id from fee),flows as (select t.tx_id, t.action, t.token_mint_address as mint,t.from_owner, t.to_owner, t.amount_display as qty, t.amount_usdfrom tokens_solana.transfers tjoin fomo_tx f on f.tx_id = t.tx_idwhere t.block_date >= date '2026-08-21' and t.block_date < date '2026-08-24'and t.to_owner <> 'R4rNJHaffSUotNmqSKNEfDcJE8A7zJUkaoM5Jkd7cYX'),-- cohort anchoring: a leg counts only if a FOMO wallet is a direct counterpartylegs as (select fl.tx_id, fl.to_owner as wallet, fl.mint, fl.action, fl.qty, fl.amount_usd as usdfrom flows fl join cohort c on c.wallet = fl.to_ownerunion allselect fl.tx_id, fl.from_owner, fl.mint, fl.action, -fl.qty, -fl.amount_usdfrom flows fl join cohort c on c.wallet = fl.from_owner),legs_q as (select l.*,l.mint in ('So11111111111111111111111111111111111111112','So11111111111111111111111111111111111111111','EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v','Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') as is_quotefrom legs l),net as (select wallet, mint, is_quote,sum(qty) as net_qty,sum(coalesce(usd,0)) as net_usd,sum(case when action = 'create_account' then coalesce(usd,0) else 0 end) as rent_usd,count(*) as legsfrom legs_q group by 1,2,3),-- Cost basis cannot come from the token leg (memecoin amount_usd is NULL).-- Attribute it from the QUOTE side of the same transaction instead.tx_wallet as (select wallet, tx_id,sum(case when is_quote then coalesce(usd,0) else 0 end) as quote_usd,count(distinct case when not is_quote then mint end) as nq_mints,max(case when not is_quote then mint end) as nq_mint,sum(case when not is_quote then qty else 0 end) as nq_qtyfrom legs_q group by 1,2),attrib as (select wallet, nq_mint as mint,sum(case when nq_qty > 0 then nq_qty else 0 end) as buy_qty,sum(case when nq_qty > 0 then -quote_usd else 0 end) as buy_usd,sum(case when nq_qty < 0 then -nq_qty else 0 end) as sell_qty,sum(case when nq_qty < 0 then quote_usd else 0 end) as sell_usdfrom tx_wallet