c2ctrader04- Collateral Impact
    Updated 2022-05-18
    with
    eth_volatility as (
    select
    hour,
    price,
    stddev(price) over(order by hour rows between 168 preceding and current row) as volatility
    from ethereum.token_prices_hourly
    where symbol = 'WETH'
    and hour >= dateadd('year',-1,current_date)
    ),
    dai_balances as (
    select
    balance_date,
    sum(balance) as dai_balances,
    sum(amount_usd) as dai_usd_balances
    from ethereum.erc20_balances
    where
    symbol = 'DAI'
    and balance_date>=dateadd('year',-1,current_date)
    group by balance_date
    ),
    maker_collaterals as (
    select
    date(block_timestamp) as date,
    count(tx_id) as ntx,
    sum(amount) asamount_asset,
    sum(amount_usd) as usd_amount_assets
    from ethereum.udm_events
    where
    ( event_type ='erc20_transfer' or event_type = 'native_eth') and
    to_label='maker'
    and amount_usd is not null
    and date>=dateadd('year',-1,current_date)
    group by date
    )

    Run a query to Download Data