Updated 2022-03-25
    with bETH_coll as (
    SELECT sum(amount) AS coll1
    from anchor.collateral WHERE currency='terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun' and event_type= 'provide'
    ),
    bETH_with AS (
    SELECT sum(amount) AS coll2
    from anchor.collateral WHERE currency='terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun' and event_type= 'withdraw'),
    bETH_liq as (
    SELECT sum(liquidated_amount) AS coll3
    from anchor.liquidations
    WHERE LIQUIDATED_CURRENCY='terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun')
    select coll1-coll2 + coll3 as bETH_total_supply, coll1-coll2 as BETH_collateral, (BETH_collateral/bETH_total_supply)*100 as percent_beth_locked
    from bETH_coll,bETH_with,bETH_liq