marquWorld Cup - [Polygon] txs and price
    Updated 2023-04-06
    with
    gas as (

    select

    block_timestamp,
    block_number,
    tx_hash,
    tx_fee * price as fee_usd,
    'MATIC' as token,
    price as price_usd,
    'Polygon' as blockchain

    from polygon.core.fact_transactions txs
    left join ethereum.core.fact_hourly_token_prices prices
    on date_trunc('hour',txs.block_timestamp) = prices.hour
    and prices.token_address = '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0' -- MATIC
    where block_timestamp ::date >= current_date() - interval '{{months}} months'
    ),

    transactions as (

    select

    date_trunc('day',block_timestamp) as date,
    count(distinct tx_hash) as txs,
    sum(fee_usd) as fees_usd
    from gas
    group by 1
    ),

    prices as (

    Run a query to Download Data