Afonso_Diazmigrated users
    Updated 2024-07-09
    WITH tab1 AS (
    SELECT
    from_address AS user
    ,amount_in_usd AS amount_usd
    ,a.tx_hash
    ,a.block_timestamp::date as dt
    ,tx_fee
    ,platform
    FROM ethereum.defi.ez_dex_swaps a
    JOIN ethereum.core.fact_transactions b
    ON a.tx_hash=b.tx_hash
    WHERE dt>='2023-10-17'
    AND amount_usd>0
    AND amount_usd IS NOT NULL
    AND amount_usd<10000000
    ), tab2 AS (
    SELECT
    DISTINCT from_address AS user
    FROM ethereum.uniswapv3.ez_swaps a
    JOIN ethereum.core.fact_transactions b
    ON a.tx_hash=b.tx_hash
    WHERE a.block_timestamp::Date<'2023-10-17'
    AND NOT EXISTS (
    SELECT *
    FROM ethereum.uniswapv3.ez_swaps c
    JOIN ethereum.core.fact_transactions d
    ON c.tx_hash=d.tx_hash
    WHERE b.from_address=d.from_address
    AND c.block_timestamp::Date>='2023-10-17'
    )
    )

    SELECT
    COUNT(DISTINCT(tx_hash)) AS "swaps"
    ,COUNT(DISTINCT user) AS "users"
    ,SUM(amount_usd) AS "volume($)"
    QueryRunArchived: QueryRun has been archived