Updated 2022-11-05
    with priceTb as (
    select
    hour::date as date,
    symbol,
    avg(price) as price
    from ethereum.core.fact_hourly_token_prices
    where symbol in ('WETH', 'MATIC')
    group by 1,2
    )
    , lstTb as (
    select
    a.block_timestamp,
    'GMX' as platform,
    count(distinct a.tx_hash) as TX_Cnt,
    count(distinct a.origin_from_address) as Users_Cnt,
    sum((case when symbol in ('WETH') then (TX_FEE * price) end)) as fee_usd
    from arbitrum.core.fact_token_transfers a join arbitrum.core.fact_transactions b USING(tx_hash)
    join priceTb c on a.block_timestamp::date = c.date
    where origin_to_address in ('0x3d6ba331e3d9702c5e8a8d254e5d8a285f223aba','0xb87a436b93ffe9d75c5cfa7bacfff96430b09868')
    group by 1,2
    UNION
    select
    a.block_timestamp,
    'GNS' as platform,
    count(distinct a.tx_hash) as TX_Cnt,
    count(distinct a.origin_from_address) as Users_Cnt,
    sum((case when symbol in ('MATIC') then (TX_FEE * price) end)) as fee_usd
    from polygon.core.fact_token_transfers a join polygon.core.fact_transactions b USING(tx_hash)
    join priceTb c on a.block_timestamp::date = c.date
    where origin_to_address in ('0xd8d177efc926a18ee455da6f5f6a6cfcee5f8f58','0x65187fec6ecc4774c1f632c7503466d5b4353db1','0xf8a140db8b05bec52c7e86d0d40d72f8e54fe559')
    and contract_address = '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063' -- DAI
    group by 1,2
    )
    select
    Run a query to Download Data