maybeyonasUST Holder Stats
    Updated 2022-07-06
    with krt_ust as(
    select * -- distinct address_label_type
    from terra.daily_balances
    where
    address_label_type is NULL and
    currency in ('KRT','UST') and
    date = current_date
    ),
    krt_holders as(
    select * from krt_ust
    where
    currency = 'KRT' and
    balance > 1000000
    ),
    ust_holders as(
    select * from krt_ust
    where
    currency = 'UST' and
    balance > 3000
    ),
    ust_addrs as(
    select address from ust_holders
    ),
    ust_holder_txs as (
    select * from terra.transfers t
    join ust_addrs u on u.address = t.event_from
    where tx_status = 'SUCCEEDED'
    ),
    stats as (
    select event_from, event_currency, sum(event_amount) as total, sum(event_amount_usd) as total_usd, count(tx_id) as total_transactions
    from ust_holder_txs
    group by event_from, event_currency
    ),
    total_stats as(
    select event_currency, avg(total_usd) as avg_usd_tx_value,median(total_usd) as median_usd_tx_value,mode(total_usd) as mode_usd_tx_value, avg(total_transactions) as avg_txs
    from stats
    Run a query to Download Data