KARTODANCHOR - Deposits, withdrawls, net dep
    Updated 2022-01-15
    with luna_prices as (
    select
    date_trunc('day', block_timestamp) as block_date,
    symbol,
    avg(price_usd) as avg_price_usd
    from terra.oracle_prices
    where symbol = 'LUNA'
    and block_timestamp < '2021-09-30'
    and block_timestamp > '2021-01-01'
    group by 1, 2
    ),
    daily_stable_deposits as (
    select
    date_trunc('day', block_timestamp) as block_date,
    sum(m.msg_value:coins[0]:amount) / pow(10, 6) as total_stable_deposits
    from terra.msgs m
    where m.msg_value:execute_msg:deposit_stable is not null
    and tx_status = 'SUCCEEDED'
    and block_timestamp < '2021-09-30'
    and block_timestamp > '2021-01-01'
    group by 1
    ),
    daily_stable_withdrawals as (
    select
    date_trunc('day', block_timestamp) as block_date,
    sum(m.msg_value:execute_msg:send:amount) / pow(10, 6) as total_stable_withdrawals
    from terra.msgs m
    where m.msg_value:execute_msg:send:msg:redeem_stable is not null
    and tx_status = 'SUCCEEDED'
    and block_timestamp < '2021-09-30'
    and block_timestamp > '2021-01-01'
    group by 1
    ),
    daily_net_deposits as (
    select
    d.block_date,
    Run a query to Download Data