Query editor
with top_jettons as (select jetton_master from ton.jetton_events where type = 'transfer'and block_date > now() - interval '{{days}}' day and not tx_abortedand jetton_master != '0:8CDC1D7640AD5EE326527FC1AD0514F468B30DC84B0173F0E155F451B4E11F7C'and jetton_master != '0:671963027F7F85659AB55B821671688601CDCF1EE674FC7FBBB1A776A18D34A3'group by 1 order by count(1) desc limit 10),transfers as (select distinct jetton_master, trace_id, block_date from ton.jetton_eventsjoin top_jettons using(jetton_master)where type = 'transfer'and block_date > now() - interval '{{days}}' day), tx_fees as (select jetton_master, hash, block_date, trace_id, total_fees from ton.transactions join transfers using(trace_id, block_date)where block_date > now() - interval '{{days}}' day), msg_fees as (select jetton_master, hash, M.block_date, M.trace_id, coalesce(fwd_fee, 0) as total_fees from ton.messages M join tx_feeson tx_fees.block_date = M.block_date and M.tx_hash = tx_fees.hash and direction = 'in'where M.block_date > now() - interval '{{days}}' day), all_fees as (select * from tx_feesunion allselect * from msg_fees), total_fees_for_trace as (select jetton_master, trace_id, sum(total_fees) as total_fees, count(distinct hash) as tx_countfrom all_fees group by 1, 2), output as (select jetton_master, case when tx_count <= 5 then 'Simple transfer' else 'Complex operations' end as kind, count(1) as events_count, round(sum(total_fees) / 1e9) as total_fees,sum(total_fees) / 1e9 / count(1) as average_feefrom total_fees_for_trace group by 1, 2)select get_href('https://tonviewer.com/' || jetton_master, coalesce(symbol, substring(jetton_master, 1, 10) || '...')) as symbol,sum(case when kind = 'Simple transfer' then events_count else 0 end) as "Simple transfers count",sum(case when kind = 'Simple transfer' then total_fees else 0 end) as "Simple transfers total fees, TON",sum(case when kind = 'Simple transfer' then average_fee else 0 end) as "Simple transfers average fee, TON",sum(case when kind = 'Complex operations' then events_count else 0 end) as "Complex operations count",sum(case when kind = 'Complex operations' then total_fees else 0 end) as "Complex operations total fees, TON",sum(case when kind = 'Complex operations' then average_fee else 0 end) as "Complex operations average fee, TON"from outputleft join dune.ton_foundation.result_ton_jettons_metadata_latest_values m on m.address = jetton_mastergroup by 1order by "Simple transfers count" desc