mz0111osmo 3
    Updated 2022-10-20
    --credit : 0xHaM☰d

    with active_user as (
    select
    date_trunc('week', block_timestamp)::date as date,
    tx_from as active_users,
    count(distinct block_timestamp::date) as dt_cnt
    from osmosis.core.fact_transactions
    group by 1, 2
    having dt_cnt >= 5
    )
    , activity as (
    select
    date_trunc('week', block_timestamp)::date as date,
    'Swap' as status,
    tx_id,
    TRADER as users
    from osmosis.core.fact_swaps
    where TRADER in (select active_users from active_user)
    union all

    select
    date_trunc('week', block_timestamp)::date as date,
    'LP' as status,
    tx_id,
    liquidity_provider_address as users
    from osmosis.core.fact_liquidity_provider_actions
    where liquidity_provider_address in (select active_users from active_user)
    union all

    select
    date_trunc('week', block_timestamp)::date as date,
    'Stake' as status,
    tx_id,
    Run a query to Download Data