ArioGas Guzzlers - MATIC - 3
    Updated 2022-11-16
    with MATIC_Price as (
    select
    hour::date as date,
    avg(price) as MATIC_Price
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'MATIC'
    group by 1
    ),
    Transfer as (
    select
    block_timestamp::date as date,
    sum(amount_usd) as Transfer
    from polygon.core.ez_matic_transfers
    where block_timestamp >= CURRENT_DATE - 30
    group by 1
    ),
    tab3 as (
    select
    block_timestamp::date as date,
    sum(tx_fee * MATIC_Price) as USD_Gas
    from polygon.core.fact_transactions a join MATIC_Price b on a.block_timestamp::Date = b.date
    where block_timestamp >= CURRENT_DATE - 30
    and status = 'SUCCESS'
    group by 1
    )
    select
    a.date,
    a.USD_Gas/b.Transfer * 1e6 as average_per_1M
    from tab3 a join Transfer b on a.date = b.date

    Run a query to Download Data