Elprognerd1 - overall eth
    Updated 2023-05-16
    WITH eth_price AS (
    SELECT
    date_trunc('day', hour) AS date,
    avg(price) AS price_usd
    FROM ethereum.core.fact_hourly_token_prices
    WHERE symbol = 'WETH'
    GROUP BY 1
    )

    SELECT
    count(DISTINCT a.origin_from_address) AS total_users,
    count(DISTINCT a.tx_hash) AS total_transactions,
    sum(a.amount_in_usd) AS total_usd_volumes,
    sum(b.tx_fee * c.price_usd) AS total_fees_usd,
    count(DISTINCT a.origin_from_address) / count(DISTINCT date_trunc('month', a.block_timestamp)) AS avg_users,
    count(DISTINCT a.tx_hash) / count(DISTINCT date_trunc('month', a.block_timestamp)) AS avg_transactions,
    sum(a.amount_in_usd) / count(DISTINCT date_trunc('month', a.block_timestamp)) AS avg_usd_volumes,
    sum(b.tx_fee * c.price_usd) / count(DISTINCT date_trunc('month', a.block_timestamp)) AS avg_fees_usd
    FROM ethereum.core.ez_dex_swaps a
    JOIN ethereum.core.fact_transactions b ON a.tx_hash = b.tx_hash
    JOIN eth_price c ON date_trunc('day', a.block_timestamp) = c.date

    WHERE
    a.block_timestamp > current_date - interval '365 days'
    AND a.block_timestamp < current_date
    AND a.platform LIKE 'uniswap%'
    AND a.amount_in_usd IS NOT NULL
    AND a.amount_in_usd > 0
    Run a query to Download Data