feyikemi2024-06-07 02:17 AM
    Updated 2024-06-07
    WITH Prices AS (
    SELECT
    date_trunc('day', hour) AS Date,
    avg(price) AS price
    FROM
    ethereum.price.ez_prices_hourly
    WHERE
    symbol ILIKE 'weth'
    GROUP BY
    Date
    ),

    DexSwapsWithPrice AS (
    SELECT
    block_timestamp,
    tx_hash,
    origin_from_address,
    amount_in_usd,
    tx_fee * price AS tx_fee_usd,
    'Uniswap on Ethereum' as Platform
    FROM ethereum.defi.ez_dex_swaps
    JOIN
    ethereum.core.fact_transactions USING (tx_hash)
    JOIN
    Prices P ON date_trunc('day', block_timestamp) = P.Date
    where platform ilike 'uniswap%'

    union

    SELECT
    block_timestamp,
    tx_hash,
    origin_from_address,
    amount_in_usd,
    tx_fee * price AS tx_fee_usd,
    'Uniswap on Arbitrum' AS Platform
    QueryRunArchived: QueryRun has been archived