fateeUser Interaction Rank In Hot Contracts (>100 $ETH Paid Fee)
    Updated 2023-12-04
    with
    top_contracts as (
    select CONTRACT_ADDRESS, ifnull(CONTRACT_NAME,ADDRESS_NAME) as CONTRACT_NAME, TOTAL_FEE
    from
    (select
    value[0]::string as CONTRACT_ADDRESS,
    value[1]::string as SYMBOL,
    value[2]::string as CONTRACT_NAME,
    value[3]::string as TOTAL_FEE
    from (select livequery.live.udf_api('https://flipsidecrypto.xyz/api/queries/4d9e7c78-d47c-46b4-b201-08e03c23e28c/latest-run')
    as response), lateral FLATTEN (input => response:data:data))
    left join ethereum.core.dim_labels
    on CONTRACT_ADDRESS=ADDRESS
    ),

    top_contracts_users as
    (select CONTRACT_ADDRESS, CONTRACT_NAME, TOTAL_FEE,
    FROM_ADDRESS as user,
    min(BLOCK_TIMESTAMP) as min_date,
    rank() over (partition by CONTRACT_ADDRESS order by min_date asc) as rank
    from ethereum.core.fact_transactions a
    join top_contracts b
    on CONTRACT_ADDRESS=TO_ADDRESS
    group by 1,2,3,4),

    eth_og_users as
    (select user, count(CONTRACT_ADDRESS) as contracts
    from top_contracts_users
    where rank<=1000
    group by 1)

    select
    case when rank<=1000 then '✅' else '❌' end as "Early",
    CONTRACT_ADDRESS as "Contract",
    CONTRACT_NAME as "Contract Name", rank as "User Early Rank", min_date as "First Interaction Date"
    from top_contracts_users