with table1 as (select
distinct tx_hash
from avalanche.core.fact_event_logs
where event_name ilike 'swap'
)
select
distinct origin_from_address as user,
'swap' as type,
count(distinct tx_hash) as "count of action",
sum(event_inputs:value/power(10,6)) as "total action volume"
from avalanche.core.fact_event_logs
where contract_address = '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e'
and event_inputs:value/1e6 < 1e9
and tx_status = 'SUCCESS'
and block_timestamp >= '2022-07-01'
and tx_hash in (select tx_hash from table1)
group by 1,2
Order by 4 desc
limit 10