Query editor
WITH product_addresses(chain_key, component_name, component_group, address) AS (VALUES('ethereumSepolia','Ethereum Intent Router','router',0x8a996eB1AC6580662b66CE5Df7f1892EA6382e72),('arcTestnet','Arc Intent Router','router',0xB8d19Db51A912010b913201af33CB0CF5Df1FE83),('arcTestnet','Circle Gateway Wallet','gateway',0x0077777d7EBA4688BDeF3E311b846F25870A19B9)), raw_activity AS (SELECT p.chain_key, p.component_name, p.component_group, 'direct_tx' AS activity_type, concat('0x', to_hex(tx."from")) AS user_address, tx.block_time, concat('0x', to_hex(tx.hash)) AS tx_hash, tx.success, cast(tx.gas_used AS double) AS gas_used, cast(NULL AS varchar) AS token_symbol, cast(NULL AS double) AS amount_rawFROM sepolia.transactions txJOIN product_addresses p ON p.chain_key='ethereumSepolia' AND (tx."to"=p.address OR tx."from"=p.address)WHERE tx.block_date >= current_date - interval '180' dayUNION ALLSELECT p.chain_key, p.component_name, p.component_group, 'erc20_flow' AS activity_type, CASE WHEN tr."from"=p.address THEN concat('0x', to_hex(tr."to")) ELSE concat('0x', to_hex(tr."from")) END AS user_address, tr.evt_block_time AS block_time, concat('0x', to_hex(tr.evt_tx_hash)) AS tx_hash, true AS success, cast(NULL AS double) AS gas_used, 'USDC' AS token_symbol, cast(tr.value AS double) AS amount_rawFROM erc20_arc.evt_transfer trJOIN product_addresses p ON p.chain_key='arcTestnet' AND (tr."from"=p.address OR tr."to"=p.address)WHERE tr.contract_address=0x3600000000000000000000000000000000000000 AND tr.evt_block_date >= current_date - interval '180' dayUNION ALLSELECT p.chain_key, p.component_name, p.component_group, 'erc20_flow' AS activity_type, CASE WHEN tr."from"=p.address THEN concat('0x', to_hex(tr."to")) ELSE concat('0x', to_hex(tr."from")) END AS user_address, tr.evt_block_time AS block_time, concat('0x', to_hex(tr.evt_tx_hash)) AS tx_hash, true AS success, cast(NULL AS double) AS gas_used, 'USDC' AS token_symbol, cast(tr.value AS double) AS amount_rawFROM erc20_sepolia.evt_transfer trJOIN product_addresses p ON p.chain_key='ethereumSepolia' AND (tr."from"=p.address OR tr."to"=p.address)WHERE tr.contract_address=0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238 AND tr.evt_block_date >= current_date - interval '180' day)SELECT chain_key, component_name, component_group, activity_type, user_address, count(*) AS activity_count, count(DISTINCT tx_hash) AS distinct_txs, min(block_time) AS first_seen, max(block_time) AS last_seen, sum(CASE WHEN success THEN 1 ELSE 0 END) AS success_count, sum(COALESCE(gas_used, 0)) AS total_gas_used, array_join(array_sort(array_distinct(array_agg(token_symbol) FILTER (WHERE token_symbol IS NOT NULL))), ', ') AS tokens, sum(COALESCE(amount_raw, 0)) AS total_raw_amountFROM raw_activityGROUP BY 1,2,3,4,5ORDER BY last_seen DESC, activity_count DESCLIMIT 500