From 81e3ee06c7f0210d320102029be3a5b618c94c93 Mon Sep 17 00:00:00 2001 From: Nicholas Welch Date: Wed, 8 May 2024 10:41:08 +1000 Subject: [PATCH 1/3] remove handle_target_token_addresses --- fastlane_bot/events/utils.py | 38 ------------------------------------ main.py | 7 +------ 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/fastlane_bot/events/utils.py b/fastlane_bot/events/utils.py index 8f2e66618..154683b69 100644 --- a/fastlane_bot/events/utils.py +++ b/fastlane_bot/events/utils.py @@ -1678,44 +1678,6 @@ def delete_tenderly_forks(forks_to_cleanup: List[str], mgr: Any) -> List[str]: return forks_to_keep - -def handle_target_token_addresses(static_pool_data: pd.DataFrame, target_tokens: List): - """ - Get the addresses of the target tokens. - - Parameters - ---------- - static_pool_data : pd.DataFrame - The static pool data. - target_tokens : List - The target tokens. - - Returns - ------- - List - The addresses of the target tokens. - - """ - # Get the addresses of the target tokens - target_token_addresses = [] - if target_tokens: - for token in target_tokens: - target_token_addresses = ( - target_token_addresses - + static_pool_data[static_pool_data["tkn0_address"] == token][ - "tkn0_address" - ].tolist() - ) - target_token_addresses = ( - target_token_addresses - + static_pool_data[static_pool_data["tkn1_address"] == token][ - "tkn1_address" - ].tolist() - ) - target_token_addresses = list(set(target_token_addresses)) - return target_token_addresses - - def get_current_block( last_block: int, mgr: Any, diff --git a/main.py b/main.py index 468909357..6db9fd8d0 100644 --- a/main.py +++ b/main.py @@ -47,7 +47,6 @@ get_start_block, set_network_to_mainnet_if_replay, set_network_to_tenderly_if_replay, - handle_target_token_addresses, get_current_block, handle_tenderly_event_exchanges, handle_static_pools_update, @@ -255,10 +254,6 @@ def main(args: argparse.Namespace) -> None: cfg, exchanges, args.blockchain, args.static_pool_data_filename, args.read_only ) - target_token_addresses = handle_target_token_addresses( - static_pool_data, args.target_tokens - ) - # Break if timeout is hit to test the bot flags if args.timeout == 1: cfg.logger.info("Timeout to test the bot flags") @@ -284,7 +279,7 @@ def main(args: argparse.Namespace) -> None: solidly_v2_event_mappings=solidly_v2_event_mappings, tokens=tokens.to_dict(orient="records"), replay_from_block=args.replay_from_block, - target_tokens=target_token_addresses, + target_tokens=args.target_tokens, tenderly_fork_id=args.tenderly_fork_id, tenderly_event_exchanges=tenderly_event_exchanges, w3_tenderly=w3_tenderly, From 85fe29fa67a9e503c441de04ce06274b1dd3d952 Mon Sep 17 00:00:00 2001 From: Nicholas Welch Date: Wed, 8 May 2024 10:41:38 +1000 Subject: [PATCH 2/3] bugfix always add native wrapped gas infor to the token objects --- fastlane_bot/events/interface.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fastlane_bot/events/interface.py b/fastlane_bot/events/interface.py index cc7ab2888..a0f200db3 100644 --- a/fastlane_bot/events/interface.py +++ b/fastlane_bot/events/interface.py @@ -509,11 +509,11 @@ def populate_tokens(self): self.token_list[token.address] = token except AttributeError: pass - if self.ConfigObj.GAS_TKN_IN_FLASHLOAN_TOKENS: - native_gas_tkn = Token(symbol=self.ConfigObj.NATIVE_GAS_TOKEN_SYMBOL, address=self.ConfigObj.NATIVE_GAS_TOKEN_ADDRESS, decimals=18) - wrapped_gas_tkn = Token(symbol=self.ConfigObj.WRAPPED_GAS_TOKEN_SYMBOL, address=self.ConfigObj.WRAPPED_GAS_TOKEN_ADDRESS, decimals=18) - self.token_list[native_gas_tkn.address] = native_gas_tkn - self.token_list[wrapped_gas_tkn.address] = wrapped_gas_tkn + # native and wrapped gas token info populated everytime + native_gas_tkn = Token(symbol=self.ConfigObj.NATIVE_GAS_TOKEN_SYMBOL, address=self.ConfigObj.NATIVE_GAS_TOKEN_ADDRESS, decimals=18) + wrapped_gas_tkn = Token(symbol=self.ConfigObj.WRAPPED_GAS_TOKEN_SYMBOL, address=self.ConfigObj.WRAPPED_GAS_TOKEN_ADDRESS, decimals=18) + self.token_list[native_gas_tkn.address] = native_gas_tkn + self.token_list[wrapped_gas_tkn.address] = wrapped_gas_tkn def create_token(self, record: Dict[str, Any], prefix: str) -> Token: """ From caa89a9c64221a496d2ca932e790681642b91074 Mon Sep 17 00:00:00 2001 From: barak manos <> Date: Thu, 9 May 2024 15:19:41 +0300 Subject: [PATCH 3/3] Remove the `GAS_TKN_IN_FLASHLOAN_TOKENS` flag --- fastlane_bot/config/network.py | 1 - fastlane_bot/events/interface.py | 5 ++--- fastlane_bot/events/utils.py | 4 ---- fastlane_bot/tests/test_034_Interface.py | 1 - 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/fastlane_bot/config/network.py b/fastlane_bot/config/network.py index 70b4e562a..621eaea16 100644 --- a/fastlane_bot/config/network.py +++ b/fastlane_bot/config/network.py @@ -280,7 +280,6 @@ class ConfigNetwork(ConfigBase): # FLAGS ####################################################################################### - GAS_TKN_IN_FLASHLOAN_TOKENS = None IS_NO_FLASHLOAN_AVAILABLE = False # HOOKS diff --git a/fastlane_bot/events/interface.py b/fastlane_bot/events/interface.py index a0f200db3..1672cfafc 100644 --- a/fastlane_bot/events/interface.py +++ b/fastlane_bot/events/interface.py @@ -492,9 +492,8 @@ def get_tokens(self) -> List[Token]: token_set.add(self.create_token(record, f"tkn{str(idx)}_")) except AttributeError: pass - if self.ConfigObj.GAS_TKN_IN_FLASHLOAN_TOKENS: - token_set.add(Token(symbol=self.ConfigObj.NATIVE_GAS_TOKEN_SYMBOL, address=self.ConfigObj.NATIVE_GAS_TOKEN_ADDRESS, decimals=18)) - token_set.add(Token(symbol=self.ConfigObj.WRAPPED_GAS_TOKEN_SYMBOL, address=self.ConfigObj.WRAPPED_GAS_TOKEN_ADDRESS, decimals=18)) + token_set.add(Token(symbol=self.ConfigObj.NATIVE_GAS_TOKEN_SYMBOL, address=self.ConfigObj.NATIVE_GAS_TOKEN_ADDRESS, decimals=18)) + token_set.add(Token(symbol=self.ConfigObj.WRAPPED_GAS_TOKEN_SYMBOL, address=self.ConfigObj.WRAPPED_GAS_TOKEN_ADDRESS, decimals=18)) return list(token_set) def populate_tokens(self): diff --git a/fastlane_bot/events/utils.py b/fastlane_bot/events/utils.py index 154683b69..719ebf09b 100644 --- a/fastlane_bot/events/utils.py +++ b/fastlane_bot/events/utils.py @@ -637,10 +637,6 @@ def get_config( cfg.LIMIT_BANCOR3_FLASHLOAN_TOKENS = limit_bancor3_flashloan_tokens cfg.DEFAULT_MIN_PROFIT_GAS_TOKEN = Decimal(default_min_profit_gas_token) - cfg.GAS_TKN_IN_FLASHLOAN_TOKENS = ( - cfg.NATIVE_GAS_TOKEN_ADDRESS in flashloan_tokens - or cfg.WRAPPED_GAS_TOKEN_ADDRESS in flashloan_tokens - ) return cfg diff --git a/fastlane_bot/tests/test_034_Interface.py b/fastlane_bot/tests/test_034_Interface.py index 8b7f3dea8..82a98ee87 100644 --- a/fastlane_bot/tests/test_034_Interface.py +++ b/fastlane_bot/tests/test_034_Interface.py @@ -35,7 +35,6 @@ cfg_mock = Mock() cfg_mock.logger = MagicMock() -cfg_mock.GAS_TKN_IN_FLASHLOAN_TOKENS = False qi = QueryInterface(mgr=None, ConfigObj=cfg_mock) qi.state = [{'exchange_name': 'uniswap_v2', 'address': '0x123', 'tkn0_key': 'TKN-0x123', 'tkn1_key': 'TKN-0x456', 'pair_name': 'Pair-0x789', 'liquidity': 10}, {'exchange_name': 'sushiswap_v2', 'address': '0xabc', 'tkn0_key': 'TKN-0xabc', 'tkn1_key': 'TKN-0xdef', 'pair_name': 'Pair-0xghi', 'liquidity': 0}]