0xHaM-dUntitled Query
    Updated 2022-09-06
    with DEPOSIT as (
    SELECT
    BLOCK_TIMESTAMP,
    'DEPOSITOR' as status,
    TX_HASH,
    DEPOSITOR,
    AMOUNT_DEPOSITED as amount
    FROM ethereum.maker.ez_deposits
    WHERE TX_STATUS = 'SUCCESS'
    )
    ,WITHDRAW as (
    SELECT
    a.BLOCK_TIMESTAMP,
    'WITHDRAWER' as status,
    a.TX_HASH,
    WITHDRAWER,
    AMOUNT_WITHDRAWN as amount
    FROM ethereum.maker.ez_withdrawals a join DEPOSIT b on WITHDRAWER = DEPOSITOR and a.BLOCK_TIMESTAMP > b.BLOCK_TIMESTAMP
    )
    SELECT
    date_trunc('{{interval}}', block_timestamp) as date,
    status,
    COUNT(DISTINCT TX_HASH) as tx_cnt,
    COUNT(DISTINCT DEPOSITOR) as user_cnt,
    sum(tx_cnt) over (partition by status order by date) as cum_tx_cnt,
    sum(user_cnt) over (partition by status order by date) as cum_user_cnt
    from DEPOSIT
    WHERE date >= '{{since_date}}'
    group by 1,2

    UNION

    SELECT
    date_trunc('{{interval}}', block_timestamp) as date,
    status,
    Run a query to Download Data