From 746c7c33892265d2a0c19d0d6c0f825da014315d Mon Sep 17 00:00:00 2001 From: robcxyz <rob@sudoblock.io> Date: Wed, 3 Jul 2024 18:35:14 -0600 Subject: [PATCH] fix: add better logging handler from potentially changed pools #58 --- balanced_backend/cron/token_stats.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/balanced_backend/cron/token_stats.py b/balanced_backend/cron/token_stats.py index e0c84a3..d2195ef 100644 --- a/balanced_backend/cron/token_stats.py +++ b/balanced_backend/cron/token_stats.py @@ -32,13 +32,17 @@ def run_token_stats( ) t.total_supply = int(total_supply, 16) / 10 ** t.decimals - t.liquidity = sum([ - i.base_supply * i.base_price for i in pools - if i.base_address == t.address - ]) + sum([ - i.quote_supply * i.quote_price for i in pools - if i.quote_address == t.address - ]) + try: + t.liquidity = sum([ + i.base_supply * i.base_price for i in pools + if i.base_address == t.address + ]) + sum([ + i.quote_supply * i.quote_price for i in pools + if i.quote_address == t.address + ]) + except TypeError: + logger.info(f"No pool found for {t.name} - {t.address}") + session.merge(t) session.commit()