pinehearstNEAR Balances - 0. Overview
    Updated 2022-09-06
    with tx AS ( -- finding transfers from multisender, which does not appears in transfers table
    SELECT
    block_timestamp,
    tx_hash,
    tx_signer,
    tx_receiver,
    tx_status,
    method_name,
    TRY_PARSE_JSON(args):accounts as accounts
    FROM near.core.fact_actions_events_function_call
    LEFT JOIN (SELECT tx_hash as tx_hash1, tx_signer, tx_receiver, tx_status FROM near.core.fact_transactions) ON tx_hash = tx_hash1
    WHERE 1=1
    -- AND tx_receiver = 'multisender.app.near'
    AND tx_Status = 'Success'
    AND method_name LIKE '%multisend%'
    -- AND tx_hash IN ('6vLNZ2eyYvPq34WeVAeWermU7cgJNWDPJJBJDPvUVeRT', -- multisend_from_balance_unsafe / shows up in function call / fs payments
    -- 'ApGcBzUw4FY4b6fznemzTpdF8EVAx14rJLit3XVzGRXM', -- multisend_from_balance / shows up in function call
    -- '99z3PaHjB8uyCpbAkN11sDNnTbRDzEBqw9QDpYGHptV', -- multisend_attached_tokens / shows up in function call
    -- 'FcECK8UwFKxTVsaHfyW6EYvZPXuuBQ2HUt3t7Ek4WYGw', -- simple transfer / does NOT show up in function call
    -- '73RQQF15hjwfioAdJbSp5MyyDzRW9WfBpvKHy4DN34Kp') -- swaps / shows up in function call / need to filter token_in, token_out (need wrapped near)
    ),
    ---------------------------------------- SWAPS ----------------------------------------
    near_token_address AS (
    select 'wrap.near' as contract_address, 'NEAR' as symbol, 24 as decimal
    ),
    transaction_logs AS (
    SELECT
    block_timestamp,
    tx_hash,
    receiver_id,
    regexp_substr(status_value, 'Success') as reg_success,
    logs as logs1
    FROM near.core.fact_receipts
    WHERE reg_success IS NOT NULL
    ),
    swaps_unlabelled AS (
    Run a query to Download Data