with transactions as (
select
block_timestamp,
try_base64_decode_string(tx_message :txn :apaa [0] :: STRING) as pool_action,
tx_group_id
from algorand.application_call_transaction
where app_id = 710543830
and pool_action in ('W', 'S')
)
select
date_trunc('day', block_timestamp) as time,
case when pool_action = 'W' then 'Unstake' else 'Stake' end as pool_action,
count(distinct tx_group_id) as number_of_actions
from transactions
group by 1, 2