SocioAnalyticaLiNEAR - Daily Stake/Unstake Net
    Updated 2024-03-27
    -- forked from LiNEAR - Daily Stake/Unstake recent @ https://flipsidecrypto.xyz/edit/queries/b9bc106f-ed5b-4875-938d-6824fc58c209

    -- forked from BlockTracker / LiNEAR - Daily Stake/Unstake @ https://flipsidecrypto.xyz/BlockTracker/q/dFI1TIzRskHG/linear---daily-stake-unstake

    -- forked from Yousefi_1994 / LiNEAR - Daily Stake/Unstake @ https://flipsidecrypto.xyz/Yousefi_1994/q/shD6KePZ6pEX/linear-daily-stake-unstake

    with
    linear_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 = 'linear-protocol.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'
    ),
    linear_unstake_v1 as (
    select
    receipts.block_timestamp,
    receipts.tx_hash,
    receipts.actions:predecessor_id as user_address,
    (
    replace(
    replace(
    (
    split(split(array_to_string(logs, ','), ':') [7], ',') [0]
    ),
    '\"',
    QueryRunArchived: QueryRun has been archived