Afonso_Diaz2023-05-06 09:37 PM
    Updated 2023-05-06
    with
    t0 as (
    select tx_receiver as validator
    from near.core.fact_transactions
    where tx_receiver ilike any ('%.poolv1.near', '%.pool.near')
    group by 1
    having count(distinct tx_hash) > 10
    ),

    t as (
    select
    tx_hash,
    'Stake' as action,
    block_timestamp,
    tx_signer as user,
    tx:actions[0]:FunctionCall:deposit/1e24 amount_near
    from near.core.fact_transactions
    where tx_hash in (
    select distinct tx_hash
    from near.core.fact_actions_events_function_call
    where method_name in ('deposit_and_stake', 'stake', 'stake_all')
    )
    and tx_receiver in (select distinct validator from t0)
    ),

    t2 as (
    select
    user,
    min(block_timestamp) as min_date
    from t
    group by 1
    ),

    t3 as (
    select
    date_trunc('month', min_date)::date as month,
    Run a query to Download Data