with top_gamma_pool as (
select tx_id, from_address
from ethereum.udm_events
where contract_address = '0x9a98bffabc0abf291d6811c034e239e916bbcec0' -- 'WETH-USDT' pool
),
transaction_gas as (
select
date_trunc('day', block_timestamp) AS dt,
s.from_address,
s.tx_id,
fee_usd,
gas_limit,
gas_price,
gas_used
from ethereum.transactions e join top_gamma_pool s on e.tx_id = s.tx_id
)
select dt, from_address as users, SUM(fee_usd) as FEE_USD, SUM(gas_used) as GAS_USED
from transaction_gas
where from_address is not null
group by 1, 2