diff --git a/fastlane_bot/config/network.py b/fastlane_bot/config/network.py index dc18271c1..243202cff 100644 --- a/fastlane_bot/config/network.py +++ b/fastlane_bot/config/network.py @@ -278,6 +278,10 @@ class ConfigNetwork(ConfigBase): NETWORK_POLYGON_ZKEVM = S.NETWORK_POLYGON_ZKEVM NETWORK_OPTIMISM = S.NETWORK_OPTIMISM + # FLAGS + ####################################################################################### + GAS_TKN_IN_FLASHLOAN_TOKENS = None + @classmethod def new(cls, network=None): """ @@ -558,6 +562,9 @@ class _ConfigNetworkTenderly(ConfigNetwork): BALANCER_VAULT_ADDRESS = "0xBA12222222228d8Ba445958a75a0704d566BF2C8" + CHAIN_SPECIFIC_EXCHANGES = ["carbon_v1", "bancor_v2", "bancor_v3", "bancor_pol"] + CHAIN_SPECIFIC_EXCHANGES = [ex for ex in CHAIN_SPECIFIC_EXCHANGES if ex is not None] + def __init__(self, **kwargs): super().__init__(**kwargs) diff --git a/fastlane_bot/events/interface.py b/fastlane_bot/events/interface.py index 204bf4a57..d1dee1af6 100644 --- a/fastlane_bot/events/interface.py +++ b/fastlane_bot/events/interface.py @@ -507,6 +507,9 @@ def get_tokens(self) -> List[Token]: for record in self.state: for idx in range(len(record["descr"].split("/"))): token_set.add(self.create_token(record, f"tkn{str(idx)}_")) + if self.ConfigObj.GAS_TKN_IN_FLASHLOAN_TOKENS: + token_set.add(Token(symbol=self.ConfigObj.NATIVE_GAS_TOKEN_KEY.split("-")[0], key=self.ConfigObj.NATIVE_GAS_TOKEN_KEY, address=self.ConfigObj.NATIVE_GAS_TOKEN_ADDRESS, decimals=18)) + token_set.add(Token(symbol=self.ConfigObj.WRAPPED_GAS_TOKEN_KEY.split("-")[0], key=self.ConfigObj.WRAPPED_GAS_TOKEN_KEY, address=self.ConfigObj.WRAPPED_GAS_TOKEN_ADDRESS, decimals=18)) return list(token_set) def create_token(self, record: Dict[str, Any], prefix: str) -> Token: diff --git a/fastlane_bot/events/utils.py b/fastlane_bot/events/utils.py index c2c4da64f..36362cbae 100644 --- a/fastlane_bot/events/utils.py +++ b/fastlane_bot/events/utils.py @@ -461,6 +461,7 @@ def get_config( loglevel: str, logging_path: str, blockchain: str, + flashloan_tokens: str, tenderly_fork_id: str = None, ) -> Config: """ @@ -478,6 +479,8 @@ def get_config( The logging path. blockchain : str The name of the blockchain + flashloan_tokens (str): + Comma seperated list of tokens that the bot can use for flash loans. tenderly_fork_id : str, optional The Tenderly fork ID, by default None @@ -507,6 +510,7 @@ def get_config( cfg.logger.info("Using mainnet 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_KEY in flashloan_tokens or cfg.WRAPPED_GAS_TOKEN_KEY in flashloan_tokens) return cfg diff --git a/main.py b/main.py index 51f8ae5f7..cb75d046d 100644 --- a/main.py +++ b/main.py @@ -320,6 +320,7 @@ def main( loglevel, logging_path, blockchain, + flashloan_tokens, tenderly_fork_id, ) # TODO: add blockchain support diff --git a/resources/NBTest/NBTest_034_Interface.ipynb b/resources/NBTest/NBTest_034_Interface.ipynb index 30d714fa9..4d9bb5b1f 100644 --- a/resources/NBTest/NBTest_034_Interface.ipynb +++ b/resources/NBTest/NBTest_034_Interface.ipynb @@ -73,6 +73,7 @@ "source": [ "cfg_mock = Mock()\n", "cfg_mock.logger = MagicMock()\n", + "cfg_mock.GAS_TKN_IN_FLASHLOAN_TOKENS = False\n", "qi = QueryInterface(mgr=None, ConfigObj=cfg_mock)\n", "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}]" ] @@ -207,7 +208,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "id": "d2df5597", "metadata": { "ExecuteTime": { @@ -220,6 +221,7 @@ "new_state = [{'exchange_name': 'bancor_v2', 'address': '0xabc', 'descr': 'TKN-0x123/TKN-0xdef', 'tkn0_key': 'TKN-0x123', 'tkn1_key': 'TKN-0xdef', 'pair_name': 'Pair-0xghi', 'liquidity': 10}]\n", "qi.update_state(new_state)\n", "token = qi.get_token('TKN-0x123')\n", + "\n", "assert isinstance(token, Token)" ] }, @@ -233,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 9, "id": "d2696dba", "metadata": { "ExecuteTime": { diff --git a/resources/NBTest/NBTest_034_Interface.py b/resources/NBTest/NBTest_034_Interface.py index 10936ec86..8f0a828c5 100644 --- a/resources/NBTest/NBTest_034_Interface.py +++ b/resources/NBTest/NBTest_034_Interface.py @@ -45,6 +45,7 @@ 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}] @@ -75,10 +76,13 @@ # ## test_get_token +# + new_state = [{'exchange_name': 'bancor_v2', 'address': '0xabc', 'descr': 'TKN-0x123/TKN-0xdef', 'tkn0_key': 'TKN-0x123', 'tkn1_key': 'TKN-0xdef', 'pair_name': 'Pair-0xghi', 'liquidity': 10}] qi.update_state(new_state) token = qi.get_token('TKN-0x123') + assert isinstance(token, Token) +# - # ## test_get_pool