Query editor
with last_period_trades as (select *from ton.dex_tradeswhere block_time > now() - interval '30' day),last_period_traders as (select trader_address, count(1) as trades_count,sum(volume_usd) as trading_volumefrom last_period_tradesgroup by 1), trader_types as (select t.*,casewhen cardinality(FILTER(A.interfaces, i->regexp_like(i, '.*highload.*') )) > 0 then 'highload wallet'when cardinality(FILTER(A.interfaces, i->regexp_like(i, 'wallet_.*') )) > 0 then 'wallet'else 'other smart contracts'end as acc_typefrom last_period_traders tjoin ton.accounts A on address = trader_address), first_messages as (select T.trader_address, avg(100 * bitwise_right_shift(varbinary_to_uint256(from_base64(M.msg_hash)), 255)) as average_optimized from last_period_trades Tjoin ton.messages M on M.block_date = T.block_date and M.trace_id = M.tx_hash and M.direction = 'out' and M.tx_hash = T.trace_idwhere M.block_time > now() - interval '30' daygroup by 1)select get_href('https://tonviewer.com/' || trader_address, trader_address) as trader_address,acc_type || casewhen trades_count > 20 and (average_optimized < 20) then ' (+Priority mining)'else ''end as "Trader type",trades_count, trading_volume,average_optimized / 100 as average_optimizedfrom trader_typesjoin first_messages using(trader_address)order by trading_volume desc limit 1000