boomer77daily beth prov
    Updated 2022-03-29
    with provide as (select date_trunc('day', block_timestamp) as dt, sum(amount) as beth_provided, count(distinct sender) as users_count
    from anchor.collateral
    where event_type = 'provide' and currency = 'terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun' and date(block_timestamp) >= CURRENT_DATE - 90
    group by 1),

    price as (select date_trunc('day', block_timestamp) as dt, avg(price_usd) as beth_price
    from terra.oracle_prices
    where symbol = 'bETH'
    group by 1)

    select a.dt, a.beth_provided, b.beth_price, (a.beth_provided*b.beth_price) as beth_provided_usd, a.users_count
    from provide a
    left join price b on a.dt = b.dt
    Run a query to Download Data