SocioAnalyticaMetaPool - Daily Stake/Unstake
    Updated 2024-03-27
    -- forked from Yousefi_1994 / MetaPool - Daily Stake/Unstake @ https://flipsidecrypto.xyz/Yousefi_1994/q/tCX5GuTt6e5K/metapool-daily-stake-unstake

    with
    metapool_stake_v1 as (
    select
    receipts.block_timestamp,
    receipts.tx_hash,
    receipts.actions:predecessor_id as user_address,
    (
    receipts.actions:receipt:Action:actions[0]:FunctionCall:deposit
    ) * pow(10, -24) as amount
    from
    near.core.fact_receipts receipts
    join near.core.fact_transactions transactions using (tx_hash)
    where
    receipts.receiver_id = 'meta-pool.near'
    and receipts.actions:receipt:Action:actions[0]:FunctionCall:method_name in ('deposit_and_stake')
    and receipts.status_value:Failure is null
    and transactions.tx_status = 'Success'
    ),
    metapool_unstake_v1 as (
    select
    receipts.block_timestamp,
    receipts.tx_hash,
    receipts.actions:predecessor_id as user_address,
    (
    replace(
    (
    split(split(array_to_string(logs, ','), ':') [3], ',') [0]
    ),
    '\"',
    ''
    )::float
    ) * pow(10, -24) as amount
    from
    near.core.fact_receipts receipts
    QueryRunArchived: QueryRun has been archived