dweinstein33Overview of Users copy
    Updated 2024-03-11
    -- forked from Masi / Overview of Users @ https://flipsidecrypto.xyz/Masi/q/ZxN6tlk8pU5g/overview-of-users

    with tb1 as ( select DISTINCT tx_hash
    from near.core.fact_actions_events_function_call
    where receiver_id = 'meme-farming_011.ref-labs.near')
    ,
    tb2 as (select DISTINCT tx_hash
    from near.core.fact_actions_events_function_call
    where tx_hash in (select tx_hash from tb1)
    and receiver_id in ('token.0xshitzu.near', -- 24
    'token.lonkingnearbackto2024.near', --8
    'ftv2.nekotoken.near',--24
    'blackdragon.tkn.near')) --24
    ,
    tb3 as (select block_timestamp ,
    tx_hash,
    signer_id,
    case when receiver_id = 'token.0xshitzu.near' then ARGS:"amount"/pow(10,18)
    when receiver_id = 'token.lonkingnearbackto2024.near' then ARGS:"amount"/pow(10,8)
    when receiver_id = 'ftv2.nekotoken.near' then ARGS:"amount"/pow(10,24)
    when receiver_id = 'blackdragon.tkn.near' then ARGS:"amount"/pow(10,24) end as amount,
    case when receiver_id = 'token.0xshitzu.near' then 'SHITZU'
    when receiver_id = 'token.lonkingnearbackto2024.near' then 'LONK'
    when receiver_id = 'ftv2.nekotoken.near' then 'NEKO'
    when receiver_id = 'blackdragon.tkn.near' then 'BLACKDRAGON' end as token_name
    from near.core.fact_actions_events_function_call
    where tx_hash in (select tx_hash from tb2)
    and method_name = 'ft_resolve_transfer'
    )
    ,
    tb4 as ( select trunc(block_timestamp,'day') as day,
    symbol_out ,
    (sum(AMOUNT_IN)/sum(AMOUNT_OUT)) as price
    from near.defi.ez_dex_swaps
    where symbol_in in ('wNEAR')
    and AMOUNT_OUT > 0 and AMOUNT_IN > 0
    QueryRunArchived: QueryRun has been archived