Alexayusd donut
    Updated 2022-09-18
    with compound as ( select count (distinct tx_hash) as txns,
    count (distinct redeemer) as users, sum (received_amount) as volume, sum (received_amount_usd) as volume_usd
    from ethereum.compound.ez_redemptions
    where received_contract_symbol ilike '%ETH%'
    and block_timestamp >= '2022-06-01'
    and block_number <= 15537393 --last block mined.

    ),


    makerdao as ( with price as ( select date_trunc('day',HOUR) as day , avg(price) as eth_price
    from ethereum.core.fact_hourly_token_prices
    where SYMBOL = 'WETH'
    group by 1 )

    select count(distinct a.tx_hash) as txns,
    count(distinct a.withdrawer) as users, sum(a.amount_withdrawn) as volume,
    sum(amount_withdrawn * p.eth_price) as volume_usd
    from ethereum.maker.ez_withdrawals a
    join price p on p.day = a.block_timestamp::date
    where symbol ilike '%ETH%'
    and a.block_timestamp >= '2022-06-01'
    and tx_status = 'SUCCESS'
    and block_number <= 15537393 --last block mined.
    ),

    aave as ( select count (distinct tx_hash) as txns,
    count (distinct depositor_address) as users,sum (withdrawn_tokens) as volume,
    sum (withdrawn_usd) as volume_usd
    from ethereum.aave.ez_withdraws
    where symbol ilike '%ETH%'
    and block_timestamp >= '2022-06-01'
    and withdrawn_tokens>0
    Run a query to Download Data