theericstonenet deposits
    Updated 2022-07-07
    with luna_prices as (
    select
    date(block_timestamp) as block_date,
    avg(price_usd) as avg_price_usd
    from terra.oracle_prices
    where symbol = 'LUNA'
    and block_timestamp > current_date - 180
    group by 1
    ),
    daily_stable_deposits as (
    select
    date(block_timestamp) as block_date,
    sum(deposit_amount) as total_stable_deposits
    from anchor.deposits where block_timestamp > current_date - 180
    group by 1
    ),
    daily_stable_withdrawals as (
    select
    date(block_timestamp) as block_date,
    sum(amount) as total_stable_withdrawals
    from anchor.redeem m
    where m.block_timestamp > current_date - 180
    group by 1),
    daily_net_deposits as (
    select
    d.block_date,
    sum(total_stable_deposits) over (order by d.block_date) as deposits_usd,
    sum(total_stable_withdrawals) over (order by d.block_date) as withdraws_usd,
    sum(total_stable_deposits-total_stable_withdrawals) over (order by d.block_date) as net_deposits_usd

    from daily_stable_deposits d
    inner join daily_stable_withdrawals w
    on d.block_date = w.block_date)
    select * from daily_net_deposits d;
    Run a query to Download Data