Query editor
with swaps as (select tx_hash, count(*) as swaps_ctfrom dex.tradeswhere blockchain = 'base'and block_month > date('2024-03-01') -- now() - interval '3' daygroup by 1), dobbya as (select distinct tx_hash, 'atomic_mev' as labelfrom dex.atomic_arbitrageswhere blockchain = 'base'and block_month > date('2024-03-01') -- now() - interval '3' day)-- , dobbys as (-- select distinct tx_hash, 'sandwich/backrun/frontrun' as label -- distinct tx_to-- from dex.sandwiches-- where blockchain = 'base'-- and block_month > date('2024-03-01') -- now() - interval '3' day-- ), longtail as (select router, 1.00*sum(case when ct=1 then 1 else 0 end)/count(eoa) as eoa_once_pct-- , 1.00*sum(case when ct<=2 then 1 else 0 end)/count(eoa) as eoa_once_twice_pctfrom (select "to" as router, "from" as eoa, count(*) as ctfrom base.transactionswhere block_time > date('2024-03-01') -- now() - interval '3' daygroup by 1,2) agroup by 1), final as (select "to" as router, c.name as name,count(distinct t."from") as eoa_ct, count(*) as tx_ct,-- count(case when swaps_ct is not null then hash else null end) as success_swap_tx,1.0000*count(case when dobbya.tx_hash is not null then hash else null end)/nullif(count(case when success = true then hash else null end),0) as atomic_mev_rate_of_success,-- 1.0000*count(case when dobbys.tx_hash is not null then hash else null end)/nullif(count(case when success = true then hash else null end),0) as sandfrontback_mev_rate_of_success,1.0000*count(case when swaps_ct is not null then hash else null end)/nullif(count(case when success = true then hash else null end),0) as swap_pct_of_success_tx,count(distinct hour(block_time)) timezone_coverage_24h,count(block_number)/count(distinct block_number) as num_tx_per_block,avg(eoa_once_pct) as eoa_once_pct,-- avg(eoa_once_twice_pct) as eoa_once_twice_pct,1.0000*count(case when success = false then hash else null end)/count(*) as revert_rate-- , avg(gas_price/1e9) as avg_gas_price_gweifrom base.transactions tleft join swaps s on s.tx_hash = t.hashleft join base.contracts c on c.address = t."to"left join dobbya on dobbya.tx_hash = t.hash-- left join dobbys on dobbys.tx_hash = t.hashleft join longtail l on l.router = t."to"where block_time > date('2024-03-01') -- now() - interval '3' daygroup by 1, 2 order by 3 desc) select *-- case when eoa_ct<=10 and swap_pct_of_success_tx>=0.75 and (timezone_coverage_24h=24 or num_tx_per_block>1) and eoa_once_pct<=0.5 then 'MEV bot' else null end as tagfrom finalwhere eoa_ct<=10and swap_pct_of_success_tx>=0.75and (timezone_coverage_24h=24 or num_tx_per_block>1)