SELECT
CASE
WHEN action LIKE '%deposit%' THEN 'Stake'
WHEN action LIKE '%withdraw' THEN 'Unstake'
END AS action,
SUM(amount/1e9) AS amount,
AVG(amount/1e9) AS avg_amount,
COUNT(DISTINCT tx_id) tx_count,
COUNT(DISTINCT address) user_count
FROM
solana.core.fact_stake_pool_actions
WHERE
succeeded = 'TRUE'
AND
block_timestamp BETWEEN '2022-11-07' AND '2022-11-14'
AND
action LIKE '%deposit%'
OR
action LIKE '%withdraw'
GROUP BY 1