

# import pathlib
# import numpy as np
# import sys
from base_class import BaseVariableFunction
from base_class import *
# import math
# import json
# import pandas as pd
old_print = print


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


print = timestamped_print



baseclass = BaseVariableFunction(__file__)
base_library = baseclass.open_base_library()

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


mintLpAddress_file = baseclass.librarydata_path/f"mintLpAddress.json"


mintLpAddress_dict = None
with mintLpAddress_file.open(mode='r', encoding="utf-8") as f:
    mintLpAddress_dict = json.load(f)
for lp_address, lp_info in mintLpAddress_dict.items():
    if lp_info['islp'] != True:
        continue

    if not (baseclass.token_lp_info_path/f"{lp_address}.json").exists():
        print(f"to_json lp_address={lp_address}")
        token_lp_info = {}
        token_lp_info[lp_address] = {
            "token0": lp_info['token0'],
            "token1": lp_info['token1']
        }
        with (baseclass.token_lp_info_path/f"{lp_address}.json").open(mode='w', encoding="utf-8") as f:
            json.dump(token_lp_info, f)


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