
# https://dexscreener.com/?rankBy=volume&order=desc&chainIds=solana&maxAge=24&min24HTxns=500&min24HSells=200&min24HChg=100

# 将油猴脚本获取的top trader
from base_class import BaseVariableFunction
from base_class import *
baseclass = BaseVariableFunction(__file__)

old_print = print


def timestamped_print(*args, **kwargs):
    old_print(datetime.datetime.utcnow().replace(
        microsecond=0), *args, **kwargs)


print = timestamped_print
baseclass.makedirpath(baseclass.dalao_tran_dexscreen_path)
baseclass.makedirpath(baseclass.dalao_merge_path)
print('\n'*5)
print(f"{'{:<6}'.format('ENTER')} {baseclass.scriptfilename} ----------------NOTE-----------NOTE---------------")

def make_pump_url(urlname, urlparam):
    urlname = urlname + urlparam
    return '=HYPERLINK("{}","{}")'.format(urlname, urlname)



def filter_simple_dalao():

    csv_file_list = [f for f in os.listdir(
        baseclass.dalao_ori_tran_dexscreen_path) if f.endswith(".csv")]
    arr_token_address = [tokenadd.split("_")[0] for tokenadd in csv_file_list  ]
    arr_token_address=list(set(arr_token_address))
 
    res_df = None
    big_amount_df = None
    # csv_file_list=csv_file_list[0:1]
    # print("csv_file_list=",csv_file_list)

    for tokenadd in arr_token_address:
        df_pump =None
        df_raydium =None

        if ( baseclass.dalao_ori_tran_dexscreen_path / f"{tokenadd}_pump.csv").exists():
            df_pump = pd.read_csv(
            baseclass.dalao_ori_tran_dexscreen_path / f"{tokenadd}_pump.csv", dtype=object)

            arr_maker = df_pump["MAKER"].drop_duplicates().tolist()
            arr_special_maker = [maker for maker in arr_maker if len(maker)<15]
            print(f"tokenadd= {tokenadd}",arr_special_maker)
            special_df_pump = df_pump[df_pump["MAKER"].isin(arr_special_maker)]
            df_pump =   pd.concat([special_df_pump, df_pump], ignore_index=True)
            df_pump=df_pump.drop_duplicates(keep="first")

            df_pump['PumpURL'] = df_pump.apply(lambda ser: make_pump_url(
                "https://pump.fun/profile/", f"{ser['MAKER']}"), axis=1)
            df_pump.to_excel(baseclass.dalao_ori_tran_dexscreen_path / f"new_{tokenadd}_pump.xlsx",index=False)


    
 

        continue
  
 
 
 
    return


filter_simple_dalao()

print(f"{'{:<6}'.format('END')} {baseclass.scriptfilename} ----------------NOTE-----------NOTE---------------")
