Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/withbase as (SELECTconcat('<a href="', get_chain_explorer.explorer, '/address/', cast(tx."from" as varchar), '" target = "blank">', cast(tx."from" as varchar)-- , coalesce(get_ens(tx."from"),CONCAT('0',substring(tx."from",2,4),'..',substring(tx."from",40,3))), '</a>') as caller, tx."from" as raw_caller, arbitrary(concat('<a href="', get_chain_explorer.explorer, '/tx/', cast(tx.hash as varchar), '" target = "blank"> example tx </a>')) as example_call, approx_distinct(tx.hash) as times_calledFROM ethereum.traces trLEFT JOIN ethereum.transactions tx ON tx.hash = tr.tx_hashLEFT JOIN query_1747157 get_chain_explorer ON get_chain_explorer.chain = 'ethereum'LEFT JOIN decoding.evm_signatures sig_fx ON bytearray_substring(tr.input,1,4) = sig_fx.id AND sig_fx.type = 'function_call'WHERE ('true' = 'false' OR (json_value(sig_fx.abi,'strict $.stateMutability') NOT IN ('pure', 'view') OR sig_fx.abi is null))AND tr.to = 0xdAC17F958D2ee523a2206206994597C13D831ec7 /*USDT*/AND tr.block_time >= now() - interval '1' dayGROUP BY 1,2ORDER BY times_called descLIMIT 50)--we do this join here so that we only join on the limited number of addressesSELECTcaller, times_called, array_agg(distinct all.name) as identifiers, array_agg(distinct nft.name) as nft_activity_labels, array_agg(distinct dex.name) as dex_activity_labels, example_callFROM base bLEFT JOIN labels.addresses all ON all.label_type = 'identifier'AND all.blockchain = 'ethereum'AND b.raw_caller = all.addressAND all.name is not null AND length(all.name) > 0LEFT JOIN labels.nft nft ON nft.blockchain = 'ethereum' AND nft.label_type = 'usage' AND b.raw_caller = nft.address AND nft.name is not nullLEFT JOIN labels.dex dex ON dex.blockchain = 'ethereum' AND dex.model_name = 'trader_frequencies' AND b.raw_caller = dex.address AND dex.name is not nullgroup by 1,2, example_callorder by 2 desc