feat: improve detection of unsupported tokens - closes #30 (#32)

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>
This commit is contained in:
Eru Ilúvatar 2023-01-19 08:46:51 +01:00 committed by GitHub
parent 221b5aa6b4
commit bb6d267460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -63,11 +63,14 @@ def get_usd_profit(profit, chain, save_to_csv=False):
'profit_usd' ]
"""
tokens = profit[CG_ID_RECEIVED_KEY].unique()
addresses = profit[TOKEN_RECEIVED_KEY].unique()
mapping = get_address_to_coingecko_ids_mapping(chain)
profit_with_price_tokens = pd.DataFrame()
failures = {}
for token in tokens:
print("Processing", token)
for i in range(len(tokens)):
token = tokens[i]
token_address = addresses[i]
print(f"Processing {token} ({token_address})")
try:
profit_by_received_token = pd.DataFrame(
@ -196,9 +199,9 @@ def get_usd_profit(profit, chain, save_to_csv=False):
)
except Exception as e:
# @TODO: save into list to add later
print(" Failed for token=", token)
print(" Failed for token=", token_address)
print(e)
failures[token] = e
failures[token_address] = e
print("Finished processing all tokens")
profit_with_price_tokens[PRICE_DEBT_KEY] = profit_with_price_tokens[
PRICE_DEBT_KEY

View File

@ -45,6 +45,12 @@ def add_cg_ids(profit_by_block, chain):
profit_by_block = profit_by_block.merge(
token_cg_ids[[TOKEN_RECEIVED_KEY, CG_ID_RECEIVED_KEY]], how="left"
)
addresses_with_nan_cg_ids = profit_by_block.loc[
pd.isna(profit_by_block[CG_ID_RECEIVED_KEY]), TOKEN_RECEIVED_KEY
]
print(
f"Tokens with missing coingecko ids in mapping:\n{addresses_with_nan_cg_ids.value_counts()}"
)
return profit_by_block[
[
"block_number",