John_Galt1 Deposit and Withdrawal in Reg Staking by Date
    Updated 2022-07-07
    with table1 as (select
    date(block_timestamp) as date,
    sum(event_attributes:"1_amount") / pow(10, 6) as in_regular_staking -- into regular staking
    from terra.msg_events
    where event_attributes:"1_contract_address" = 'terra1p7jp8vlt57cf8qwazjg58qngwvarmszsamzaru'
    and event_attributes:"1_action" = 'bond'
    and event_index = 3
    group by 1
    ),

    table2 as (select
    date(block_timestamp) as date,
    sum(event_attributes:"0_amount") / pow(10, 6) as out_regular_staking --gone out of regular staking
    from terra.msg_events
    where event_attributes:"from" = 'terra1p7jp8vlt57cf8qwazjg58qngwvarmszsamzaru'
    and event_attributes:"0_action" = 'unbond'
    and event_index = 3
    group by 1
    )

    select table1.date, table1.in_regular_staking, table2.out_regular_staking,
    table1.in_regular_staking - table2.out_regular_staking as daily_change,
    sum(daily_change) over (order by table1.date) as cumulative_yluna_in_reg_staking
    from table1
    inner join table2 on table1.date = table2.date