select sum(AMOUNT/1e6) as amount ,count(distinct TX_ID) as tx_count ,count(distinct LIQUIDITY_PROVIDER_ADDRESS) as user_count,date_trunc('day', block_timestamp) as block_day
from osmosis.core.fact_liquidity_provider_actions
where block_timestamp>= '2022-01-01'
and ACTION='pool_joined'
and TX_STATUS='SUCCEEDED'
and CURRENCY ='uosmo'
and LIQUIDITY_PROVIDER_ADDRESS in
(select DELEGATOR_ADDRESS as LIQUIDITY_PROVIDER_ADDRESS from osmosis.core.fact_staking where block_timestamp>= '2022-01-01' and ACTION ='undelegate')
group by block_day