maybeyonasliq_withdraw
    Updated 2022-10-01
    with
    liq_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 method_name in ('deposit_and_stake','unstake','unstake_all','withdraw_all','withdraw')
    and tx_receiver in ('meta-pool.near','linear-protocol.near','v2-nearx.stader-labs.near')
    ),
    metapool_withdraw_receipts as (
    select
    block_timestamp,
    tx_hash,
    parse_json(replace(logs[0],'EVENT_JSON:','')) as log_json,
    log_json:account_id::string as user,
    log_json:amount::integer/pow(10,24) as amt
    from near.core.fact_receipts
    where array_size(logs) > 0
    and tx_hash in (
    select tx_hash from liq_stake_txs
    where method_name in (
    'withdraw',
    'withdraw_all'
    )
    and tx_receiver = 'meta-pool.near'
    )
    ),
    linear_withdraw_receipts as (
    select
    block_timestamp,
    Run a query to Download Data