Query editor
WITH cb AS (SELECT token,MIN(block_time) cb_buy_timeFROM dune.tusa3112.result_rh_top100_provenance_eventsWHERE wallet=0xcb4d28c2106fe9f781615005ff87056d114135c9AND event_class='PAID_BUY'AND target=0xcaf681a66d020601342297493863e78c959e5cb2AND selector=0x04e45aafGROUP BY 1),tx AS (SELECT t."from" wallet,t.hash,t.block_timeFROM robinhood.transactions tWHERE t.block_date>=DATE '2026-07-10' AND t.block_date<=CURRENT_DATEAND t.successAND t."to"=0xcaf681a66d020601342297493863e78c959e5cb2AND VARBINARY_STARTS_WITH(t.data,0x04e45aaf)),hits AS (SELECT tx.wallet,tx.hash,tx.block_time,c.token,c.cb_buy_time,ABS(DATE_DIFF('second',c.cb_buy_time,tx.block_time)) abs_lag_secondsFROM txJOIN tokens.transfers tr ON tr.blockchain='robinhood'AND tr.block_date>=DATE '2026-07-10' AND tr.block_date<=CURRENT_DATEAND tr.tx_hash=tx.hash AND tr."to"=tx.walletJOIN cb c ON c.token=tr.contract_addressWHERE tx.wallet<>0xcb4d28c2106fe9f781615005ff87056d114135c9AND LOWER(tr.token_standard)<>'native'),per_token AS (SELECT wallet,token,MIN(abs_lag_seconds) abs_lag_seconds,MIN_BY(block_time,abs_lag_seconds) peer_buy_time,MAX(cb_buy_time) cb_buy_timeFROM hits GROUP BY 1,2),a AS (SELECT wallet,COUNT(*) shared_tokens,APPROX_PERCENTILE(abs_lag_seconds,0.5) median_abs_lag_seconds,APPROX_PERCENTILE(abs_lag_seconds,0.9) p90_abs_lag_seconds,COUNT_IF(abs_lag_seconds=0) exact_second_tokens,COUNT_IF(abs_lag_seconds<=5) within_5s_tokens,COUNT_IF(abs_lag_seconds<=60) within_60s_tokens,MIN(peer_buy_time) first_shared_buy,MAX(peer_buy_time) last_shared_buyFROM per_token GROUP BY 1)SELECT CONCAT('0x',TO_HEX(a.wallet)) peer_wallet,a.shared_tokens,a.median_abs_lag_seconds,a.p90_abs_lag_seconds,a.exact_second_tokens,a.within_5s_tokens,a.within_60s_tokens,a.first_shared_buy,a.last_shared_buy,s.raw_net_after_gas_usd current_raw_net_usd,s.max_single_outlay_after_gas_usd current_max_outlay_usd,f.frozen_scale,f.hist_days,f.hist_days_ge_500,f.hist_worst_day_usd,f.hist_scaled_strict_zero_mark_usd,f.hist_scaled_capital_plus_gas_usd,f.oos_scaled_strict_net_usd,f.oos_scaled_peak_plus_gas_usd,f.hist_provenance_gate,f.oos_provenance_gateFROM aLEFT JOIN dune.tusa3112.result_rh_current_all_contract_raw_scanner s ON s.wallet=a.walletLEFT JOIN dune.tusa3112.result_rh_top100_paid_fifo_gate f ON f.wallet=a.walletWHERE shared_tokens>=2ORDER BY shared_tokens DESC,median_abs_lag_seconds ASC