0-MIDCorrelation between DAI borrowed and WETH Price
    Updated 2023-04-13
    with task1 as (
    with act1 as(
    with tab1 as (
    select tx_hash
    from ethereum.maker.ez_vault_creation),
    tab2 as (
    select tx_hash
    from ethereum.maker.ez_deposits
    where TOKEN_DEPOSITED='0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    )
    select tab2.tx_hash
    from tab1
    left join tab2
    on tab1.tx_hash=tab2.tx_hash),
    act2 as (
    select date_trunc('day',BLOCK_TIMESTAMP)as day,tx_hash,AMOUNT_USD
    from ethereum.core.ez_token_transfers
    where CONTRACT_ADDRESS='0x6b175474e89094c44da98b954eedeac495271d0f'
    and FROM_ADDRESS='0x0000000000000000000000000000000000000000'
    group by 1,2,3)
    select day,sum(AMOUNT_USD)as dai_borrowed
    from act1
    left join act2
    on act1.tx_hash=act2.tx_hash
    where AMOUNT_USD is not null
    group by 1
    order by 1),
    task2 as (
    select HOUR::date as day,avg(PRICE) as weth_price
    from ethereum.core.fact_hourly_token_prices
    where SYMBOL='WETH'
    group by 1)
    select task2.day,dai_borrowed,weth_price
    from task1
    left join task2
    on task1.day=task2.day
    Run a query to Download Data