DB_Net Staked Luna (7 days)
    Updated 2023-03-06
    with d as (
    select
    date_trunc('day', block_timestamp) as date,
    sum(amount) as delegations

    from terra.core.ez_staking
    where action = 'Delegate' and date >= current_date - 6

    group by 1
    order by 1),

    u as (
    select
    date_trunc('day', block_timestamp) as date,
    sum(amount)*(-1)as undelegations

    from terra.core.ez_staking
    where action = 'Undelegate' and date >= current_date - 6

    group by 1
    order by 1
    )

    select
    d.date,
    d.delegations,
    u.undelegations,
    d.delegations + u.undelegations as net_delegations,
    sum(net_delegations) over (order by d.date) as flow
    from d left join u
    where d.date = u.date

    order by date
    Run a query to Download Data