MLDZMNavbr1
    Updated 2023-05-26
    -- forked from ebr1 @ https://flipsidecrypto.xyz/edit/queries/1c255245-d45a-451f-aa87-0e12e7310b97

    -- forked from br2 @ https://flipsidecrypto.xyz/edit/queries/e072e453-67fd-4afc-954e-30362e05147a

    with t1 as ( select
    hour::date as day,
    avg(price) as avg_price
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'WAVAX'
    group by 1)

    select
    symbol,
    count(distinct x.to_address) as borrowers,
    count(distinct a.tx_hash) as no_borrow,
    sum(tx_fee) as paid_fee,
    sum(tx_fee*avg_price) as paid_fee_usd,
    sum(amount_usd) as volume_borrow_usd,
    avg(amount_usd) as avg_borrow_usd,
    volume_borrow_usd/borrowers as avg_borrow_user
    from avalanche.core.fact_event_logs s
    left join avalanche.core.fact_transactions a on s.tx_hash=a.tx_hash
    join avalanche.core.ez_token_transfers x on s.tx_hash=x.tx_hash
    left join t1 on s.block_timestamp::date=t1.day
    where s.CONTRACT_ADDRESS=lower('0x0cD070285380cabfc3be55176928dc8A55e6d2A7')
    and s.ORIGIN_FUNCTION_SIGNATURE in ('0xfbf37739','0x49160658')
    group by 1


    Run a query to Download Data