Abolfazl_771025Deposit & withdraw
    Updated 2023-03-03
    with deposit as (select
    date_trunc('week',block_timestamp) as date,
    'Deposit' as action,
    b.symbol,
    count(DISTINCT tx_hash) as tx_count,
    count(DISTINCT DEPOSITOR) as user_count,
    sum(AMOUNT_DEPOSITED * price) as action_volume
    from ethereum.maker.ez_deposits a join ethereum.core.fact_hourly_token_prices b on a.block_timestamp::date=b.hour::date and token_address = TOKEN_DEPOSITED
    where TX_STATUS = 'SUCCESS'
    and block_timestamp >= '2022-01-01'
    group by 1,2,3
    ), withdraw as (select
    date_trunc('week',block_timestamp) as date,
    'Withdraw' as action,
    b.symbol,
    count(DISTINCT tx_hash) as tx_count,
    count(DISTINCT WITHDRAWER) as user_count,
    sum(AMOUNT_WITHDRAWN * price) as action_volume
    from ethereum.maker.ez_withdrawals a join ethereum.core.fact_hourly_token_prices b on a.block_timestamp::date=b.hour::date and token_address = TOKEN_WITHDRAWN
    where TX_STATUS = 'SUCCESS'
    and block_timestamp >= '2022-01-01'
    group by 1,2,3)
    select
    *
    from deposit
    union
    select
    *
    from withdraw
    Run a query to Download Data