Query editor
with fee as (select tx_id, from_owner as walletfrom tokens_solana.transferswhere to_owner = 'R4rNJHaffSUotNmqSKNEfDcJE8A7zJUkaoM5Jkd7cYX'and token_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'and block_date between date '2026-08-10' and date '2026-08-16'),cohort as (select distinct wallet from fee),fomo_txs as (select distinct tx_id from fee),flows as (select t.from_owner, t.to_owner, t.token_mint_address as mint,t.amount_display as qty, t.amount_usd as usdfrom tokens_solana.transfers tjoin fomo_txs f on f.tx_id = t.tx_idwhere t.block_date between date '2026-08-10' and date '2026-08-16'and t.to_owner <> 'R4rNJHaffSUotNmqSKNEfDcJE8A7zJUkaoM5Jkd7cYX'),legs as (select c.wallet, f.mint, f.qty as qty, f.usd as usdfrom flows f join cohort c on c.wallet = f.to_ownerunion allselect c.wallet, f.mint, -f.qty, -f.usdfrom flows f join cohort c on c.wallet = f.from_owner),net as (select wallet, mint, sum(qty) as net_qty, sum(usd) as net_usdfrom legs group by 1, 2),px as (select mint, sum(usd) / nullif(sum(qty), 0) as pricefrom (select token_bought_mint_address as mint, token_bought_amount as qty, amount_usd as usdfrom dex_solana.tradeswhere block_month = date '2026-08-01'and block_date between date '2026-08-15' and date '2026-08-16'and amount_usd > 0 and token_bought_amount > 0union allselect token_sold_mint_address, token_sold_amount, amount_usdfrom dex_solana.tradeswhere block_month = date '2026-08-01'and block_date between date '2026-08-15' and date '2026-08-16'and amount_usd > 0 and token_sold_amount > 0) sgroup by 1),quotes(qmint) as (values('So11111111111111111111111111111111111111112'),('So11111111111111111111111111111111111111111'),('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')),w as (select n.wallet,sum(case when n.mint in (select qmint from quotes) then n.net_usd else 0 end) as cash_usd,sum(case when n.mint not in (select qmint from quotes)then greatest(n.net_qty, 0) * coalesce(p.price, 0) else 0 end) as inv_usd,sum(case when n.mint not in (select qmint from quotes)then least(n.net_qty, 0) * coalesce(p.price, 0) else 0 end) as neg_usd,count_if(n.mint not in (select qmint from quotes)and n.net_qty > 0 and p.price is null) as unpriced_open,count_if(n.mint not in (select qmint from quotes) and n.net_qty > 0) as open_positions