From eef8c6cc9b1835d4e8f4d4b701e363e629cc297b Mon Sep 17 00:00:00 2001 From: Platon Floria Date: Wed, 22 May 2024 15:17:21 +0800 Subject: [PATCH] fix: do not update event mappings in read_only mode --- fastlane_bot/events/utils.py | 17 +++++++++-------- main.py | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fastlane_bot/events/utils.py b/fastlane_bot/events/utils.py index 87e378456..f6b97b1b3 100644 --- a/fastlane_bot/events/utils.py +++ b/fastlane_bot/events/utils.py @@ -793,17 +793,18 @@ def save_events_to_json( mgr.cfg.logger.debug(f"[events.utils.save_events_to_json] Saved events to {path}") -def process_new_events(new_event_mappings, event_mappings, filename): +def process_new_events(new_event_mappings, event_mappings, filename, read_only): # Update the manager's event mappings event_mappings.update(new_event_mappings) - # Update the local event_mappings csvs - df = pd.DataFrame.from_dict(event_mappings, orient='index').reset_index() - if len(df)>0: - df.columns = ['address', 'exchange'] - # if the csvs are always sorted then the diffs will be readable - df.sort_values(by=['exchange','address'], inplace=True) - df.to_csv(filename, index=False) + if not read_only: + # Update the local event_mappings csvs + df = pd.DataFrame.from_dict(event_mappings, orient='index').reset_index() + if len(df)>0: + df.columns = ['address', 'exchange'] + # if the csvs are always sorted then the diffs will be readable + df.sort_values(by=['exchange','address'], inplace=True) + df.to_csv(filename, index=False) def update_pools_from_events(n_jobs: int, mgr: Any, latest_events: List[Event]): diff --git a/main.py b/main.py index 722539278..4c3dffe51 100644 --- a/main.py +++ b/main.py @@ -534,9 +534,9 @@ def run(mgr, args, tenderly_uri=None) -> None: if args.pool_finder_period > 0 and (loop_idx - 1) % args.pool_finder_period == 0: mgr.cfg.logger.info(f"Searching for unsupported Carbon pairs.") uni_v2, uni_v3, solidly_v2 = pool_finder.get_pools_for_unsupported_pairs(mgr.pool_data, arb_mode=args.arb_mode) - process_new_events(uni_v2, mgr.uniswap_v2_event_mappings, f"fastlane_bot/data/blockchain_data/{args.blockchain}/uniswap_v2_event_mappings.csv") - process_new_events(uni_v3, mgr.uniswap_v3_event_mappings, f"fastlane_bot/data/blockchain_data/{args.blockchain}/uniswap_v3_event_mappings.csv") - process_new_events(solidly_v2, mgr.solidly_v2_event_mappings, f"fastlane_bot/data/blockchain_data/{args.blockchain}/solidly_v2_event_mappings.csv") + process_new_events(uni_v2, mgr.uniswap_v2_event_mappings, f"fastlane_bot/data/blockchain_data/{args.blockchain}/uniswap_v2_event_mappings.csv", args.read_only) + process_new_events(uni_v3, mgr.uniswap_v3_event_mappings, f"fastlane_bot/data/blockchain_data/{args.blockchain}/uniswap_v3_event_mappings.csv", args.read_only) + process_new_events(solidly_v2, mgr.solidly_v2_event_mappings, f"fastlane_bot/data/blockchain_data/{args.blockchain}/solidly_v2_event_mappings.csv", args.read_only) handle_static_pools_update(mgr) mgr.cfg.logger.info(f"Number of pools added: {len(uni_v2) + len(uni_v3) + len(solidly_v2)}")