KaskoazulRef_finance staked
    Updated 2022-08-10
    with raw_stake as (
    select t.tx_hash,
    t.block_timestamp,
    t.tx_signer,
    try_parse_json(e.args) as p_args,
    p_args:amount / pow (10,18) as amount,
    p_args:receiver_id as receiver
    from near.core.fact_transactions t
    left join near.core.fact_actions_events_function_call e
    on t.tx_hash = e.tx_hash
    where t.tx_receiver = 'token.v2.ref-finance.near'
    and e.method_name = 'ft_transfer_call'
    and receiver = 'xtoken.ref-finance.near'
    ),

    raw_unstake as (
    select t.tx_hash,
    t.block_timestamp,
    t.tx_signer,
    try_parse_json(e.args) as p_args,
    p_args:amount / pow (10,18) as amount,
    p_args:receiver_id as receiver
    from near.core.fact_transactions t
    left join near.core.fact_actions_events_function_call e
    on t.tx_hash = e.tx_hash
    where t.tx_receiver = 'xtoken.ref-finance.near'
    and e.method_name = 'unstake'
    )

    select sum (amount) as stake, count (distinct tx_signer) as users from raw_stake
    Run a query to Download Data