HosseinNear Native Transfer
    Updated 2024-03-07
    with token_prices as (
    select
    timestamp :: date as date,
    token_contract as token_contract,
    avg(price_usd) as price_usd
    from
    near.price.fact_prices
    where
    token_contract = 'wrap.near'
    group by
    1,
    2
    ), main as (
    select
    block_id,
    block_timestamp,
    tx_hash,
    signer_id as from_address,
    receiver_id as to_address,
    iff(
    regexp_like(action_data:deposit, '^[0-9]+$'), --numeric validation (there are some exceptions that needs to be ignored)
    action_data:deposit,
    null
    ) as amount_unadjusted
    from
    near.core.fact_actions_events
    where
    action_name = 'Transfer'
    and amount_unadjusted > 0

    union all

    select
    block_id,
    block_timestamp,
    tx_hash,
    QueryRunArchived: QueryRun has been archived