with LP_users as (select
block_timestamp::date as date,
tx_id,
liquidity_provider_address as user,
amount/power(10, decimal) as volume
from osmosis.core.fact_liquidity_provider_actions
where currency = 'uosmo'
and tx_status = 'SUCCEEDED'),
holders as (select
block_timestamp::date as date,
tx_id,
receiver as user,
amount/power(10, decimal) as volume
from osmosis.core.fact_transfers
where currency = 'uosmo'
and tx_status = 'SUCCEEDED'
and receiver not in (select user from LP_users)
union
select
block_timestamp::date as date,
tx_id,
trader as user,
to_amount/power(10, to_decimal) as volume
from osmosis.core.fact_swaps
where to_currency = 'uosmo'
and tx_status = 'SUCCEEDED'
and trader not in (select user from LP_users))
select
'LPers' as type,
date,
count(distinct tx_id) as number_of_txs,
count(distinct user) as number_of_users,
sum(volume) as total_volume
from LP_users