CryptoIcicleMega-Near - Staking Numbers
    Updated 2023-01-07
    -- SQL Credit https://app.flipsidecrypto.com/velocity/queries/b4a2bb41-cfd6-48f6-821c-4f492c4189d7
    SELECT
    COUNT(DISTINCT tx_signer) as number_of_stakers,
    COUNT(DISTINCT a.TX_HASH) as number_transactions,
    SUM(b.tx:actions[0]:FunctionCall:deposit/pow(10,24)) amount_near_staked,
    SUM(b.tx:actions[0]:FunctionCall:deposit/pow(10,24))/COUNT(DISTINCT tx_signer) as near_per_staker
    FROM near.core.fact_actions_events_function_call a
    JOIN near.core.fact_transactions b
    ON a.tx_hash = b.tx_hash
    WHERE method_name = 'deposit_and_stake'
    AND b.block_timestamp::date >= CURRENT_DATE - {{n_days}}
    AND a.block_timestamp::date >= CURRENT_DATE- {{n_days}}
    Run a query to Download Data