maybeyonasstaking
    Updated 2022-09-30
    with
    stake_txs as (
    select
    t.block_timestamp,
    t.tx_hash,
    method_name,
    tx_signer,
    tx_receiver,
    deposit
    from near.core.fact_transactions t
    join near.core.fact_actions_events_function_call f on t.tx_hash = f.tx_hash
    where t.tx_status = 'Success'
    and split(tx_receiver,'.')[1]::string in ('poolv1', 'pool')
    and method_name in ('deposit_and_stake','unstake','unstake_all','withdraw_all','withdraw')
    ),
    stake_receipts as (
    select
    block_timestamp,
    tx_hash,
    split(logs[0],' ') as log,
    log[0]::string as user,
    log[1]::string as action,
    log[2]::integer/pow(10,24) as amt
    from near.core.fact_receipts
    where tx_hash in (select tx_hash from stake_txs)
    and array_size(logs) > 0
    and split(logs[0],' ')[1] in ('deposited','unstaking','withdrawing')
    ),
    stake_data as (
    select
    t.block_timestamp,
    t.tx_hash,
    method_name,
    tx_signer,
    tx_receiver,
    deposit,
    Run a query to Download Data