theericstonecollateral value
    Updated 2022-07-07
    with add_eth as (select date_trunc('day',block_timestamp) as block_date,
    sum(amount) as added_usd
    from anchor.collateral
    where event_type = 'provide'
    and currency = 'terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun'
    group by 1),
    remove_eth as (select date_trunc('day',block_timestamp) as block_date,
    sum(amount) as removed_usd
    from anchor.collateral
    where event_type = 'withdraw'
    and currency = 'terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun'
    group by 1),

    add_luna as (select date_trunc('day',block_timestamp) as block_date,
    sum(amount) as added_usd
    from anchor.collateral
    where event_type = 'provide'
    and currency in ('terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp') --, 'terra17wgmccdu57lx09yzhnnev39srqj7msg9ky2j76')
    group by 1),
    remove_luna as (select date_trunc('day',block_timestamp) as block_date,
    sum(amount) as removed_usd
    from anchor.collateral
    where event_type = 'withdraw'
    and currency in ('terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp') --, 'terra17wgmccdu57lx09yzhnnev39srqj7msg9ky2j76')
    group by 1),

    bluna as (select a.block_date,
    sum(added_usd) over (order by a.block_date) as added_luna,
    sum(removed_usd) over (order by a.block_date) as withdrawn_luna,
    sum(added_usd-removed_usd) over (order by a.block_date) as net_collateral_luna
    from add_luna a
    inner join remove_luna r
    on a.block_date = r.block_date),

    Run a query to Download Data