Updated 2024-07-09
    WITH tab1 AS (
    SELECT
    from_address AS user
    ,ABS(nvl(amount0_usd, amount1_usd)) AS amount_usd
    ,a.tx_hash
    ,a.block_timestamp::date as dt
    ,CASE WHEN dt<'2023-10-17' THEN 'without fee'
    WHEN dt>='2023-10-17' AND dt<='2024-04-10' THEN 'introducing 0.15% fee'
    ELSE 'introducing 0.25% fee'
    END AS timeEvent
    ,tx_fee
    FROM ethereum.uniswapv3.ez_swaps a
    JOIN ethereum.core.fact_transactions b
    ON a.tx_hash=b.tx_hash
    WHERE dt>='2023-04-10'
    AND amount_usd>0
    AND amount_usd IS NOT NULL
    AND amount_usd<10000000
    )

    SELECT
    COUNT(DISTINCT(tx_hash)) AS "swaps"
    ,COUNT(DISTINCT user) AS "users"
    ,SUM(amount_usd) AS "volume($)"
    ,AVG(amount_usd) AS "avg volume($)"
    ,SUM(tx_fee) AS "total fee($ETH)"
    ,AVG(tx_fee) AS "average fee($ETH)"
    ,timeEvent AS "type"
    FROM tab1
    GROUP BY "type"
    QueryRunArchived: QueryRun has been archived