-- number of active users during time
with tx_types as (
select
distinct tx_id,
'Staking' as txtype
from
osmosis.core.fact_staking
union
select
distinct tx_id, 'Staking Reward' as txtype
from
osmosis.core.fact_staking_rewards
union
select
distinct tx_id, 'Swap' as txtype
from
osmosis.core.fact_swaps
union
select
distinct tx_id, 'LP Action' as txtype
from
osmosis.core.fact_liquidity_provider_actions
), user_txs as (
select
TX_FROM as user_id,
date_trunc('week', block_timestamp) as week,
date_trunc('day', block_timestamp) as day,
b.txtype
from
osmosis.core.fact_transactions a join tx_types b on a.tx_id=b.tx_id
where
day < '2022-10-17'
), user_weekly_txns as (
select
week,
user_id,