Query editor
with prices as (select *from prices.usdwhere symbol in ('ETH', 'FTM', 'AVAX')and blockchain is nulland minute >= timestamp '2023-01-01'),sc_fees as (select *, 'US Residency' as typefrom holonym_optimism.IsUSResident_call_setPriceunion allselect *, 'Phone' as typefrom holonym_optimism.SybilPhone_call_setPriceunion allselect *, 'GovID' as typefrom holonym_optimism.SybilResistance_call_setPrice),res as (select d.*,p.call_block_number,p.call_block_time,p.newPrice,row_number() OVER (PARTITION BY d.evt_block_time, d.evt_block_number, d.userAddr, d.typeORDER BY call_block_number DESC) AS rnkfrom query_3097231 dleft join sc_fees p on p.type = d.type and call_block_number < evt_block_number),res2 as (select *from reswhere rnk = 1and newPrice is not NULLorder by evt_block_number),total_fees_sc as (select date_trunc('day', evt_block_time) as date, sum(newPrice * price / power(10, 18)) as sum, count(distinct userAddr) as cnt, sum(newPrice / power(10, 18)) as sum_ethfrom res2 t left join prices p on p.minute = date_trunc('minute', t.evt_block_time)where symbol='ETH'GROUP by 1),eth_fees as (select date_trunc('day', block_time) as date, sum(value * price / 1e18 ) as sum, count(distinct "from") as cnt, sum(value / power(10, 18)) as sum_ethfrom ethereum.transactions t left join prices p on p.minute = date_trunc('minute', t.block_time)where to in (0xa2ca14c7d625895e6939961B87CE378836ca840F,0xdcA2e9AE8423D7B0F94D7F9FC09E698a45F3c851, 0x0a44b68783f0525e3eaAa349c90bDa884676f2C7) and symbol='ETH'and block_time >= timestamp '2023-09-01'group by 1),opt_fees as (select date_trunc('day', block_time) as date, sum(value * price / 1e18 ) as sum, count(distinct "from") as cnt, sum(value / power(10, 18)) as sum_ethfrom optimism.transactions t left join prices p on p.minute = date_trunc('minute', t.block_time)where to in (0xbE6C430BD2d5851A1E97d468E5432BcF7d689D94,0xdcA2e9AE8423D7B0F94D7F9FC09E698a45F3c851, 0x0a44b68783f0525e3eaAa349c90bDa884676f2C7) and symbol='ETH'and block_time >= timestamp '2023-09-01'group by 1),fnt_fees as (select date_trunc('day', block_time) as date, sum(value * price / 1e18 ) as sum, count(distinct "from") as cnt, 0 as sum_ethfrom fantom.transactions t left join prices p on p.minute = date_trunc('minute', t.block_time)where to in (0xa2ca14c7d625895e6939961B87CE378836ca840F,0xdcA2e9AE8423D7B0F94D7F9FC09E698a45F3c851, 0x0a44b68783f0525e3eaAa349c90bDa884676f2C7) and symbol='FTM'