ZookTerra 124 - Compare Anchor liquidations with LUNA price over time, discuss any potential correlations
    Updated 2021-12-25
    with
    liquidation_history as (
    select
    block_timestamp::date as date,
    sum(liquidated_amount_usd) as liquidated_usd ,
    count(tx_id) as nb_liquidations
    from
    anchor.liquidations
    group by 1
    ),

    price_history as (
    select
    block_timestamp::date as date,
    avg(price_usd) as luna_price
    from
    terra.oracle_prices
    where
    symbol = 'LUNA'
    group by 1
    )

    select
    lh.date,
    lh.liquidated_usd,
    lh.nb_liquidations,
    ph.luna_price
    from
    liquidation_history lh join price_history ph
    on lh.date = ph.date
    order by 1 desc
    Run a query to Download Data