select
tx_receiver as pool,
count(distinct (tx_hash)) as stakes_count,
count(distinct (tx_signer)) as stakers_count,
sum(coalesce(tx:actions[0]:FunctionCall:deposit/pow(10,24), 0)) total_volume_staked,
avg(coalesce(tx:actions[0]:FunctionCall:deposit/pow(10,24), 0)) average_volume_staked
from near.core.fact_actions_events_function_call a
join near.core.fact_transactions b
using(tx_hash)
where method_name in ('deposit_and_stake')
and year(a.block_timestamp) = 2022
group by 1
order by stakes_count desc
limit 10