maybeyonasp2p_token_flow_senders_overall
    Updated 2022-10-04
    with
    transfer_txs as (
    select
    t.block_timestamp,
    t.tx_hash,
    method_name,
    tx_signer as token_sender,
    tx_receiver as token_contract,
    try_parse_json(args) as args_json,
    case when l.token is null then tx_receiver else l.token end as token_name,
    case when l.symbol is null then tx_receiver else l.symbol end as token_symbol,
    case when l.decimals is null then 24 else l.decimals end as token_decimals,
    args_json:amount::integer/pow(10,token_decimals) as amt,
    args_json:receiver_id::string as token_receiver
    from near.core.fact_transactions t
    join near.core.fact_actions_events_function_call f on t.tx_hash = f.tx_hash
    left outer join near.core.dim_token_labels l on t.tx_receiver = l.token_contract
    where t.tx_status = 'Success'
    and method_name in (
    'ft_transfer'
    -- 'ft_transfer_call'
    )
    -- @notice unidentified edge case
    -- 'eyJhbW91bnQiOiAiMTAwMDAwMDAwMDAwMDAwMDAwMCIsICJyZWNlaXZlcl9pZCI6ICI5ZTBiOGVjMWZjZDhjMzJhYmJkYWFjN2UyMjQwYzgzYzU0YTY5NTAyYzg0NDcwNGM3ODgzMGExZWY3ZDcwOTEyIn0'
    -- @notice turn the below on for filtering
    and args_json:msg is null --filters function call therefore only p2p transfers
    -- and args_json:msg is not null
    -- @notice remove non lexical addresses
    and array_size(split(token_sender,'.')) > 1
    )

    select
    -- *
    -- trunc(block_timestamp,'week') as date,
    token_name,
    -- token_contract,
    Run a query to Download Data