Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
barak manos committed May 28, 2024
1 parent 650912f commit ae5f0ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 62 deletions.
60 changes: 2 additions & 58 deletions fastlane_bot/events/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,39 +260,13 @@ def remove_unmapped_uniswap_v2_pools(self) -> None:
"""
initial_state = self.state.copy()
self.state = [
pool
for pool in self.state
if pool["exchange_name"] != "uniswap_v2"
or (
pool["exchange_name"] in self.cfg.UNI_V2_FORKS
and pool["address"] in self.uniswap_v2_event_mappings
)
pool for pool in self.state
if pool["exchange_name"] not in self.cfg.UNI_V2_FORKS or pool["address"] in self.uniswap_v2_event_mappings
]
self.cfg.logger.debug(
f"Removed {len(initial_state) - len(self.state)} unmapped uniswap_v2/sushi pools. {len(self.state)} uniswap_v2/sushi pools remaining"
)
self.log_umapped_pools_by_exchange(initial_state)

def remove_unmapped_uniswap_v3_pools(self) -> None:
"""
Remove unmapped uniswap_v2 pools
"""
initial_state = self.state.copy()
self.state = [
pool
for pool in self.state
if pool["exchange_name"] != "uniswap_v3"
or (
pool["exchange_name"] in self.cfg.UNI_V3_FORKS
and pool["address"] in self.uniswap_v3_event_mappings
)
]
self.cfg.logger.debug(
f"Removed {len(initial_state) - len(self.state)} unmapped uniswap_v2/sushi pools. {len(self.state)} uniswap_v2/sushi pools remaining"
)
self.log_umapped_pools_by_exchange(initial_state)

def log_umapped_pools_by_exchange(self, initial_state):
# Log the total number of pools filtered out for each exchange
self.ConfigObj.logger.debug("Unmapped uniswap_v2/sushi pools:")
unmapped_pools = [pool for pool in initial_state if pool not in self.state]
Expand All @@ -310,30 +284,6 @@ def log_umapped_pools_by_exchange(self, initial_state):
]
self.log_pool_numbers(sushiswap_v2_unmapped, "sushiswap_v2")

def remove_faulty_token_pools(self) -> None:
"""
Remove pools with faulty tokens
"""
self.cfg.logger.debug(
f"Total number of pools. {len(self.state)} before removing faulty token pools"
)

safe_pools = []
for pool in self.state:
self.cfg.logger.info(pool)
try:
self.get_token(pool["tkn0_address"])
self.get_token(pool["tkn1_address"])
safe_pools.append(pool)
except Exception as e:

self.cfg.logger.warning(f"[events.interface] Exception: {e}")
self.cfg.logger.warning(
f"Removing pool for exchange={pool['pair_name']}, pair_name={pool['pair_name']} token={pool['tkn0_key']} from state for faulty token"
)

self.state = safe_pools

def update_state(self, state: List[Dict[str, Any]]) -> None:
"""
Update the state.
Expand All @@ -348,12 +298,6 @@ def update_state(self, state: List[Dict[str, Any]]) -> None:
if self.state == state:
self.cfg.logger.warning("WARNING: State not updated")

def drop_all_tables(self) -> None:
"""
Drop all tables. Deprecated.
"""
raise DeprecationWarning("Method not implemented")

def get_pool_data_with_tokens(self) -> List[PoolAndTokens]:
"""
Get pool data with tokens as a List
Expand Down
4 changes: 0 additions & 4 deletions fastlane_bot/events/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,13 +1013,9 @@ def handle_subsequent_iterations(
The block number to fork from.
"""
# bot.db.handle_token_key_cleanup()
bot.db.remove_unmapped_uniswap_v2_pools()
bot.db.remove_zero_liquidity_pools()
bot.db.remove_unsupported_exchanges()
# bot.db.remove_faulty_token_pools()
# bot.db.remove_pools_with_invalid_tokens()
# bot.db.ensure_descr_in_pool_data()

# Filter the target tokens
if target_tokens:
Expand Down

0 comments on commit ae5f0ef

Please sign in to comment.