with deposit_table as (select trunc(block_timestamp,'day') as date,'deposit' as deposit_or_withdraw,
count(distinct tx_id) as number_transactions, sum(issued_tokens) as amount
from flipside_prod_db.aave.deposits
where block_timestamp >= current_date - 90 and block_timestamp <= current_date - 1 and symbol = 'AAVE' and issued_tokens is not null
group by 1, 2),
withdraw_table as (select trunc(block_timestamp,'day') as date, 'withdraw' as deposit_or_withdraw,
count(distinct tx_id) as number_transactions,
sum(withdrawn_tokens) as amount
from flipside_prod_db.aave.withdraws
where block_timestamp >= current_date - 90 and block_timestamp <= current_date - 1 and symbol = 'AAVE' and withdrawn_tokens is not null
group by 1, 2)
(select * from deposit_table)
union all (select * from withdraw_table)