shreyash-5873Mirror: Cumulative Asset Growth
    Updated 2021-11-11
    with oracle_prices as (
    select
    date(block_timestamp) as block_date,
    currency,
    symbol,
    avg(price_usd) as avg_price
    from terra.oracle_prices
    group by 1, 2, 3
    ),
    daily_mint_deposits_increases as (
    select
    date(block_timestamp) as block_date,
    sum(m.msg_value:execute_msg:deposit:collateral:amount / pow(10, 6)) as deposit_quantity,
    sum(m.msg_value:execute_msg:deposit:collateral:amount / pow(10, 6) * o.avg_price) as deposit_value_usd
    from terra.msgs m
    inner join oracle_prices o
    on o.currency = m.msg_value:execute_msg:deposit:collateral:info:native_token:denom::string
    and date(block_timestamp) = o.block_date
    where m.msg_value:contract::string = 'terra1wfz7h3aqf4cjmjcvc6s8lxdhh7k30nkczyf0mj'
    and msg_value:execute_msg:deposit:collateral is not null
    and tx_status = 'SUCCEEDED'
    group by 1
    ),
    cumsum_activity as (
    select
    block_date,
    m.deposit_value_usd as cumulative_deposits_usd
    from daily_mint_deposits_increases m
    where block_date = date('2021-01-01')
    union all
    select
    c.block_date,
    c.deposit_value_usd + s.cumulative_deposits_usd as cumulative_deposits_usd
    from daily_mint_deposits_increases c
    inner join cumsum_activity s
    on c.block_date = dateadd(dd, 1, s.block_date)
    Run a query to Download Data