Query editor
with avalanche_topholders_contract as (with usdc_in as (select to as address, sum(cast(tr.value as double)) as amountInfrom erc20_avalanche_c.evt_Transfer trwhere tr.contract_address = 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6Egroup by 1),usdc_out as (select "from" as address, sum(cast(tr.value as double)) as amountOutfrom erc20_avalanche_c.evt_Transfer trwhere tr.contract_address = 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6Egroup by 1),balance as (select'avalanche_c' as blockchain, 'USDC' as token, usdc_in.address, case when t.tx_hash is not null then 'contract' else 'EOA' end as address_type, amountIn/1e6 - coalesce(amountOut, 0)/1e6 as balancefrom usdc_inleft join usdc_out on usdc_in.address = usdc_out.addressleft join avalanche_c.creation_traces t on usdc_in.address = t.address)select *, rank() over (order by balance desc) as rankfrom balancewhere address_type = 'contract'order by balance desclimit 20),arbitrum_native_topholders_contract as (with usdc_in as (select to as address, sum(cast(tr.value as double)) as amountInfrom erc20_arbitrum.evt_Transfer trwhere tr.contract_address = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831group by 1),usdc_out as (select "from" as address, sum(cast(tr.value as double)) as amountOutfrom erc20_arbitrum.evt_Transfer trwhere tr.contract_address = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831group by 1),balance as (select'arbitrum' as blockchain, 'USDC (native)' as token, usdc_in.address, case when t.tx_hash is not null then 'contract' else 'EOA' end as address_type, amountIn/1e6 - coalesce(amountOut, 0)/1e6 as balancefrom usdc_inleft join usdc_out on usdc_in.address = usdc_out.addressleft join arbitrum.creation_traces t on usdc_in.address = t.address)