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/SELECTdate_trunc('week', tr.block_time) as week,COALESCE(c.name, tr."from") as integration_type,approx_distinct(tr.tx_hash) as times_called,SUM(cast(value as double)/1e18)OVER (order by tx_hash, block_time desc) as value_eth_per_txFROM {{chain}}.traces trLEFT JOIN labels.contracts c ON blockchain in ('{{chain}}') AND c.address = tr."from"LEFT JOIN {{chain}}.signatures sig_fx ON substring(tr.input, 1,10) = sig_fx.idWHERE tr.to = lower('{{contract}}')AND cardinality(trace_address) != 0 --must be a contract calling not a walletAND successAND tr.block_time >= now() - interval '{{months ago}}' monthAND lower(c.name) NOT LIKE '%gnosis%' AND lower(c.name) NOT LIKE '%argent%' --filter safes out, they're not protocols.AND ('{{modify_only}}' = 'false' OR (json_value(sig_fx.abi,'strict $.stateMutability') NOT IN ('pure', 'view') OR sig_fx.abi is null))GROUP BY block_time, c.name, tr."from", value , tx_hash