drone-mostafamaker copy
    Updated 2023-05-09


    with price as (SELECT
    date_trunc ('WEEK',HOUR) as tIME,SYMBOL,
    avg (price) as Price
    FROM crosschain.core.ez_hourly_prices
    GROUP BY 1,2)


    SELECT

    'Deposit' AS TYPE,
    d.SYMBOL,
    date_trunc ('week',BLOCK_TIMESTAMP) as date,
    count (DISTINCT TX_HASH) as TXN,
    count (DISTINCT DEPOSITOR) as Users,
    sum (AMOUNT_DEPOSITED * price) as USD

    FROM ethereum.maker.ez_deposits d
    LEFT JOIN price P on (tIME = date_trunc ('WEEK',BLOCK_TIMESTAMP) and d.SYMBOL = p.SYMBOL)
    WHERE TX_STATUS = 'SUCCESS'
    GROUP BY 1,2,3

    UNION ALL


    SELECT

    'Withdraw' AS TYPE,
    d.SYMBOL,
    date_trunc ('week',BLOCK_TIMESTAMP) as date,
    count (DISTINCT TX_HASH) * -1 as TXN,
    count (DISTINCT WITHDRAWER) * -1 as Users,
    sum (AMOUNT_WITHDRAWN * price) * -1 as USD

    FROM ethereum.maker.ez_withdrawals d
    Run a query to Download Data