with tx_list as (
select
distinct tx_group_id
from algorand.transactions
where asset_id ='571576867'
), tx_list_raw as (
select
distinct tx_group_id
from algorand.transactions
where tx_group_id in (select * from tx_list)
and TRY_BASE64_DECODE_STRING(tx_message :txn :apaa [0] :: STRING) = 'S'
)
select
block_timestamp as datetime,
sum(tx_message:txn:aamt / 1e6) as staking_total_vol
from algorand.transactions
where tx_group_id in (select * from tx_list_raw)
and asset_id = '571576867' and inner_tx = 'FALSE'
and tx_type = 'axfer' and tx_type_name = 'asset transfer'
group by 1
order by 1