maybeyonasnearx_ref_target_token_overall
    Updated 2022-10-07
    with
    swaps_txs as (
    select
    f.block_timestamp,
    f.tx_hash,
    t.tx_receiver as token_contract,
    t.tx_signer as user,
    try_parse_json(args) as args_json, -- check for null edge cases
    try_parse_json(args_json:msg) as msg, -- might check for null edge cases
    msg:actions as actions,
    args_json:amount as amt,
    deposit
    from near.core.fact_actions_events_function_call f
    join near.core.fact_transactions t on t.tx_hash = f.tx_hash
    where true
    and action_name = 'FunctionCall'
    and method_name = 'ft_transfer_call'
    and args_json:receiver_id = 'v2.ref-finance.near'
    and msg is not null
    -- an
    ),
    swap_details as (
    select
    block_timestamp,
    tx_hash,
    user,
    actions[0]:token_in as swap_start,
    actions[array_size(actions)-1]:token_out as swap_target,
    case when actions[0]:amount_in is null then amt else actions[0]:amount_in end as amount_in,
    actions[array_size(actions)-1]:min_amount_out as min_out
    from swaps_txs
    ),
    swap_data as (
    select
    block_timestamp,
    tx_hash,
    Run a query to Download Data