maybeyonastoken_flow_daily
    Updated 2022-10-03
    with
    flat_logs as (
    select
    block_timestamp,
    tx_hash,
    receiver_id,
    value as log
    from near.core.fact_receipts r,
    lateral flatten(input => r.logs)
    ),
    nep_token_transfer_logs as (
    select
    block_timestamp,
    tx_hash,
    receiver_id as token_contract,
    l.token as token_name,
    l.symbol as token_symbol,
    case when l.decimals is null then 18 else l.decimals end as token_decimals,
    try_parse_json(replace(log,'EVENT_JSON:','')) as log_json,
    log_json:data[0]:old_owner_id::string as from_id,
    log_json:data[0]:new_owner_id::string as to_id,
    log_json:data[0]:amount::integer/pow(10,token_decimals) as amt
    from flat_logs r
    left outer join near.core.dim_token_labels l on r.receiver_id = l.token_contract
    where true
    and log_json:event::string = 'ft_transfer'
    ),
    text_token_transfer_logs as (
    select
    block_timestamp,
    tx_hash,
    receiver_id as token_contract,
    l.token as token_name,
    l.symbol as token_symbol,
    case when l.decimals is null then 18 else l.decimals end as token_decimals,
    split(log,' ') as t_log,
    Run a query to Download Data