HaiRongClassifying Top Source of the First SUSHI Wallets
    Updated 2022-06-19
    with useraddress as (
    select ORIGIN_TO_ADDRESS as wallett, min(block_timestamp) as min_date
    FROM ethereum.core.fact_token_transfers
    WHERE CONTRACT_ADDRESS='0x6b3595068778dd592e39a122f4f5a5cf09c90fe2'
    group by ORIGIN_TO_ADDRESS
    ),
    findsource as (
    select ORIGIN_TO_ADDRESS as wallet,ORIGIN_FROM_ADDRESS, BLOCK_TIMESTAMP as fundtime, TX_HASH
    from ethereum.core.fact_token_transfers
    ),
    findaddress as (
    select f.ORIGIN_FROM_ADDRESS as source_address, count(distinct f.TX_HASH) as source_wallet
    from useraddress u INNER join findsource f on u.min_date = f.fundtime
    group by 1
    order by 2 DESC
    limit 10000
    ),
    label as (
    select ADDRESS_NAME as name, ADDRESS as addresss,LABEL_TYPE as Label_type
    from ethereum.core.dim_labels
    ),
    final_label as (
    select l.Label_type as sublabel, l.name as labelname ,l.addresss as label_addreees, r.source_wallet as number_of_transaction
    from findaddress r INNER join label l on r.source_address = l.addresss
    order by 4 DESC
    )
    SELECT case when (sublabel='defi' or sublabel='layer2') then 'LP_Staking_Rewards' when (sublabel='nft' or sublabel='flotsam' or sublabel='token') then 'Airdrop'
    when (sublabel='dex' or sublabel='dapp') then 'DEX' when sublabel='cex' then 'CEX' END as Fund_label,
    sum (number_of_transaction)
    from final_label
    group by 1
    order by 2 DESC




    Run a query to Download Data