TomoDatamaker dao dai borrowers
    Updated 2022-08-28
    with weth_dep as (select
    BLOCK_TIMESTAMP::date as date,
    TX_HASH,
    DEPOSITOR,
    AMOUNT_DEPOSITED
    from
    ethereum.maker.ez_deposits
    where tx_hash in (select tx_hash from ethereum.maker.ez_vault_creation)
    and TOKEN_DEPOSITED = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ),

    dai_bor as (
    select
    BLOCK_TIMESTAMP::date as date,
    TX_HASH,
    ORIGIN_TO_ADDRESS,
    AMOUNT
    from ethereum.core.ez_token_transfers
    where tx_hash in (select tx_hash from weth_dep)
    and FROM_ADDRESS = '0x0000000000000000000000000000000000000000'
    )
    ,joined as (
    select
    w.date,
    w.tx_hash,
    ORIGIN_TO_ADDRESS,
    AMOUNT as dai_borrowed,
    AMOUNT_DEPOSITED as weth_deposited
    from dai_bor d join weth_dep w on d.tx_hash = w.tx_hash
    )
    ,price as (
    select
    HOUR::date as days,avg(PRICE) as price
    from ethereum.core.fact_hourly_token_prices
    where TOKEN_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    group by 1
    Run a query to Download Data