zackmendelUniswap Basic Stats
    Updated 2024-06-26
    WITH eth_price AS (
    SELECT
    hour::date AS timespan,
    symbol,
    avg (price) AS price
    FROM ethereum.price.ez_prices_hourly
    WHERE symbol IN ('WETH', 'WAVAX', 'WMATIC')
    GROUP BY 1, 2
    ),

    base_table AS (
    SELECT
    DISTINCT t.tx_hash,
    'Ethereum' AS chain,
    t.block_timestamp,
    sender,
    amount_in_usd,
    tx_fee AS tx_fee_eth,
    tx_fee * price AS tx_fee_usd
    FROM ethereum.core.fact_transactions t JOIN ethereum.defi.ez_dex_swaps s
    ON t.tx_hash = s.tx_hash AND t.block_timestamp::date = s.block_timestamp::date
    JOIN eth_price p ON t.block_timestamp::date = p.timespan
    WHERE platform LIKE 'uniswap%'
    AND symbol = 'WETH'
    AND status = 'SUCCESS'

    UNION ALL

    SELECT
    DISTINCT t.tx_hash,
    'Arbitrum' AS chain,
    t.block_timestamp,
    sender,
    amount_in_usd,
    tx_fee AS tx_fee_eth,
    tx_fee * price AS tx_fee_usd
    QueryRunArchived: QueryRun has been archived