diff --git a/CHANGELOG.md b/CHANGELOG.md index c3e4a1aa1..12ee9fa7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,27 @@ ## [Unreleased](https://github.com/bancorprotocol/fastlane-bot/tree/HEAD) -[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.9...HEAD) +[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v...HEAD) -- \_encoded\_data\[0\] index error [\#584](https://github.com/bancorprotocol/fastlane-bot/issues/584) - last\_updated\_block error when mgr.pool\_data is empty [\#583](https://github.com/bancorprotocol/fastlane-bot/issues/583) + +Closed issues + +- Bot should only import from top level [\#625](https://github.com/bancorprotocol/fastlane-bot/issues/625) +- Dealing with overlapping strategies in the Optimizer [\#595](https://github.com/bancorprotocol/fastlane-bot/issues/595) +- cvxpy [\#537](https://github.com/bancorprotocol/fastlane-bot/issues/537) + +## [v](https://github.com/bancorprotocol/fastlane-bot/tree/v) (2024-05-06) + +[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.9...v) + +- \_encoded\_data\[0\] index error [\#584](https://github.com/bancorprotocol/fastlane-bot/issues/584) - Tests 048, 903 and 906 are broken [\#579](https://github.com/bancorprotocol/fastlane-bot/issues/579) - The terraformer script is malfunctioning [\#577](https://github.com/bancorprotocol/fastlane-bot/issues/577) - Key `last_updated_block` not found in dictionary [\#564](https://github.com/bancorprotocol/fastlane-bot/issues/564) - Erroneous trade instructions possibly not filtered out [\#554](https://github.com/bancorprotocol/fastlane-bot/issues/554) - Optimzer test fails randomly [\#472](https://github.com/bancorprotocol/fastlane-bot/issues/472) +- Removed fraxswap - not yet supported [\#552](https://github.com/bancorprotocol/fastlane-bot/pull/552) ([Lesigh-3100](https://github.com/Lesigh-3100)) - Solidly V2 stable pools not supported [\#566](https://github.com/bancorprotocol/fastlane-bot/issues/566) - Fix test 900 [\#562](https://github.com/bancorprotocol/fastlane-bot/issues/562) @@ -21,6 +33,44 @@ Closed issues - Main Loop Function / Exception Handling [\#489](https://github.com/bancorprotocol/fastlane-bot/issues/489) +Merged pull requests + +- Release candidate [\#619](https://github.com/bancorprotocol/fastlane-bot/pull/619) ([zavelevsky](https://github.com/zavelevsky)) +- Add 1 ppm fee to univ3 cal calculator [\#590](https://github.com/bancorprotocol/fastlane-bot/pull/590) ([barakman](https://github.com/barakman)) +- NBTest: allowing import from tools without fastlane\_bot [\#589](https://github.com/bancorprotocol/fastlane-bot/pull/589) ([sklbancor](https://github.com/sklbancor)) +- OptimizerTesting [\#587](https://github.com/bancorprotocol/fastlane-bot/pull/587) ([sklbancor](https://github.com/sklbancor)) +- Fix issue 584 in multicaller.py [\#586](https://github.com/bancorprotocol/fastlane-bot/pull/586) ([barakman](https://github.com/barakman)) +- Chore/requirements [\#581](https://github.com/bancorprotocol/fastlane-bot/pull/581) ([platonfloria](https://github.com/platonfloria)) +- feat: databricks init script [\#580](https://github.com/bancorprotocol/fastlane-bot/pull/580) ([platonfloria](https://github.com/platonfloria)) +- Test900 fails [\#578](https://github.com/bancorprotocol/fastlane-bot/pull/578) ([sklbancor](https://github.com/sklbancor)) +- Inject async poa middleware when needed [\#576](https://github.com/bancorprotocol/fastlane-bot/pull/576) ([barakman](https://github.com/barakman)) +- Update data files 24 april [\#573](https://github.com/bancorprotocol/fastlane-bot/pull/573) ([barakman](https://github.com/barakman)) +- Remove `MultiProviderContractWrapper` [\#571](https://github.com/bancorprotocol/fastlane-bot/pull/571) ([barakman](https://github.com/barakman)) +- Remove time-assertions in various tests [\#570](https://github.com/bancorprotocol/fastlane-bot/pull/570) ([barakman](https://github.com/barakman)) +- Refrain from including the access-list when it contains an error [\#569](https://github.com/bancorprotocol/fastlane-bot/pull/569) ([barakman](https://github.com/barakman)) +- Clean the `manager` module [\#568](https://github.com/bancorprotocol/fastlane-bot/pull/568) ([barakman](https://github.com/barakman)) +- Gracefully handle solidly stable pools not supported errors [\#567](https://github.com/bancorprotocol/fastlane-bot/pull/567) ([barakman](https://github.com/barakman)) +- Improve error logging when sending private transactions [\#565](https://github.com/bancorprotocol/fastlane-bot/pull/565) ([barakman](https://github.com/barakman)) +- Add support for XfaiV0 as a fork of SolidlyV2 [\#563](https://github.com/bancorprotocol/fastlane-bot/pull/563) ([barakman](https://github.com/barakman)) +- Module bot cleanup [\#559](https://github.com/bancorprotocol/fastlane-bot/pull/559) ([barakman](https://github.com/barakman)) +- Get rid of checking arb-contract version [\#557](https://github.com/bancorprotocol/fastlane-bot/pull/557) ([barakman](https://github.com/barakman)) +- Merge rc to dev [\#545](https://github.com/bancorprotocol/fastlane-bot/pull/545) ([zavelevsky](https://github.com/zavelevsky)) +- Class TxHelpers Revision \(April 11\) [\#542](https://github.com/bancorprotocol/fastlane-bot/pull/542) ([barakman](https://github.com/barakman)) +- chore: poetry project setup [\#534](https://github.com/bancorprotocol/fastlane-bot/pull/534) ([platonfloria](https://github.com/platonfloria)) +- Exclude known tax tokens [\#528](https://github.com/bancorprotocol/fastlane-bot/pull/528) ([barakman](https://github.com/barakman)) +- Merge main to dev april 08 [\#527](https://github.com/bancorprotocol/fastlane-bot/pull/527) ([barakman](https://github.com/barakman)) +- Fixing small stuff [\#513](https://github.com/bancorprotocol/fastlane-bot/pull/513) ([sklbancor](https://github.com/sklbancor)) +- Clean the `async_event_update_utils` module [\#511](https://github.com/bancorprotocol/fastlane-bot/pull/511) ([barakman](https://github.com/barakman)) +- Clean ABIs following the removal of the factory address retrieval [\#507](https://github.com/bancorprotocol/fastlane-bot/pull/507) ([barakman](https://github.com/barakman)) +- Fix json import [\#487](https://github.com/bancorprotocol/fastlane-bot/pull/487) ([barakman](https://github.com/barakman)) +- Remove unused module receipt-handler [\#482](https://github.com/bancorprotocol/fastlane-bot/pull/482) ([barakman](https://github.com/barakman)) +- Remove the pool-shutdown module, script and test [\#481](https://github.com/bancorprotocol/fastlane-bot/pull/481) ([barakman](https://github.com/barakman)) +- Clean the submit-handler and router-handler modules [\#479](https://github.com/bancorprotocol/fastlane-bot/pull/479) ([barakman](https://github.com/barakman)) +- Remove unused class `TxHelper` [\#476](https://github.com/bancorprotocol/fastlane-bot/pull/476) ([barakman](https://github.com/barakman)) +- Docstrings for files [\#450](https://github.com/bancorprotocol/fastlane-bot/pull/450) ([sklbancor](https://github.com/sklbancor)) +- ABI Cleanup [\#435](https://github.com/bancorprotocol/fastlane-bot/pull/435) ([barakman](https://github.com/barakman)) +- Solidly curves [\#322](https://github.com/bancorprotocol/fastlane-bot/pull/322) ([sklbancor](https://github.com/sklbancor)) + ## [v3.1.9](https://github.com/bancorprotocol/fastlane-bot/tree/v3.1.9) (2024-04-15) [Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.8...v3.1.9) diff --git a/fastlane_bot/events/event_gatherer.py b/fastlane_bot/events/event_gatherer.py index fa6b9bb4b..93156cab8 100644 --- a/fastlane_bot/events/event_gatherer.py +++ b/fastlane_bot/events/event_gatherer.py @@ -27,7 +27,6 @@ def __init__( config: Config, w3: AsyncWeb3, exchanges: Dict[str, Exchange], - event_contracts: Dict[str, Contract], ): """ Initializes the EventManager. Args: @@ -37,13 +36,11 @@ def __init__( self._config = config self._w3 = w3 self._subscriptions = [] - unique_topics = set() - for exchange_name, exchange in exchanges.items(): - subscriptions = exchange.get_subscriptions(event_contracts[exchange_name]) + for exchange in exchanges.values(): + subscriptions = exchange.get_subscriptions(w3) for sub in subscriptions: - if sub.topic not in unique_topics: - unique_topics.add(sub.topic) + if sub.topic not in [s.topic for s in self._subscriptions]: self._subscriptions.append(sub) def get_all_events(self, from_block: int, to_block: int): diff --git a/fastlane_bot/events/exchanges/balancer.py b/fastlane_bot/events/exchanges/balancer.py index 384ee5fda..efba312e1 100644 --- a/fastlane_bot/events/exchanges/balancer.py +++ b/fastlane_bot/events/exchanges/balancer.py @@ -12,8 +12,9 @@ Licensed under MIT. """ from dataclasses import dataclass -from typing import List, Type, Tuple, Any +from typing import List, Type, Tuple, Any, Union +from web3 import Web3, AsyncWeb3 from web3.contract import Contract from fastlane_bot.data.abi import BALANCER_VAULT_ABI, BALANCER_POOL_ABI_V1 @@ -48,7 +49,7 @@ def get_pool_abi(self): def get_events(self, contract: Contract) -> List[Type[Contract]]: return [contract.events.AuthorizerChanged] - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: return [] async def get_fee(self, pool_id: str, contract: Contract) -> Tuple[str, float]: diff --git a/fastlane_bot/events/exchanges/bancor_pol.py b/fastlane_bot/events/exchanges/bancor_pol.py index 25ba9be5f..2c63dda6d 100644 --- a/fastlane_bot/events/exchanges/bancor_pol.py +++ b/fastlane_bot/events/exchanges/bancor_pol.py @@ -12,8 +12,9 @@ Licensed under MIT. """ from dataclasses import dataclass -from typing import List, Type, Tuple, Any, Dict, Callable +from typing import List, Type, Tuple, Any, Dict, Callable, Union +from web3 import Web3, AsyncWeb3 from web3.contract import Contract from fastlane_bot.data.abi import BANCOR_POL_ABI @@ -48,7 +49,8 @@ def factory_abi(self): def get_events(self, contract: Contract) -> List[Type[Contract]]: return [contract.events.TokenTraded, contract.events.TradingEnabled] - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: + contract = self.get_event_contract(w3) return [ Subscription(contract.events.TokenTraded, collect_all=True), Subscription(contract.events.TradingEnabled, "0xae3f48c001771f8e9868e24d47b9e4295b06b1d78072acf96f167074aa3fab64", collect_all=True), diff --git a/fastlane_bot/events/exchanges/bancor_v2.py b/fastlane_bot/events/exchanges/bancor_v2.py index a4ab5db4a..efa54f433 100644 --- a/fastlane_bot/events/exchanges/bancor_v2.py +++ b/fastlane_bot/events/exchanges/bancor_v2.py @@ -12,8 +12,9 @@ Licensed under MIT. """ from dataclasses import dataclass -from typing import List, Type, Tuple +from typing import List, Type, Tuple, Union +from web3 import Web3, AsyncWeb3 from web3.contract import Contract, AsyncContract from fastlane_bot.data.abi import BANCOR_V2_CONVERTER_ABI @@ -46,7 +47,8 @@ def factory_abi(self): def get_events(self, contract: Contract) -> List[Type[Contract]]: return [contract.events.TokenRateUpdate] - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: + contract = self.get_event_contract(w3) return [Subscription(contract.events.TokenRateUpdate)] # def async convert_address(self, address: str, contract: Contract) -> str: diff --git a/fastlane_bot/events/exchanges/bancor_v3.py b/fastlane_bot/events/exchanges/bancor_v3.py index b9ea312b7..ed5ba0720 100644 --- a/fastlane_bot/events/exchanges/bancor_v3.py +++ b/fastlane_bot/events/exchanges/bancor_v3.py @@ -12,8 +12,9 @@ Licensed under MIT. """ from dataclasses import dataclass -from typing import List, Type, Tuple +from typing import List, Type, Tuple, Union +from web3 import Web3, AsyncWeb3 from web3.contract import Contract from fastlane_bot.data.abi import BANCOR_V3_POOL_COLLECTION_ABI @@ -50,7 +51,8 @@ def factory_abi(self): def get_events(self, contract: Contract) -> List[Type[Contract]]: return [contract.events.TradingLiquidityUpdated] - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: + contract = self.get_event_contract(w3) return [ Subscription(contract.events.TradingLiquidityUpdated, TRADING_LIQUIDITY_UPDATED_TOPIC), # Subscription(contract.events.TotalLiquidityUpdated, TOTAL_LIQUIDITY_UPDATED_TOPIC), # Unused diff --git a/fastlane_bot/events/exchanges/base.py b/fastlane_bot/events/exchanges/base.py index 8ff438a1b..62bfe7996 100644 --- a/fastlane_bot/events/exchanges/base.py +++ b/fastlane_bot/events/exchanges/base.py @@ -12,8 +12,9 @@ """ from abc import ABC, abstractmethod from dataclasses import dataclass, field -from typing import Dict, List, Type, Any +from typing import Dict, List, Type, Any, Union +from web3 import Web3, AsyncWeb3 from web3.contract import Contract, AsyncContract from fastlane_bot.config.constants import CARBON_V1_NAME @@ -51,6 +52,9 @@ def get_pools(self) -> List[Pool]: """ return list(self.pools.values()) + def get_event_contract(self, w3: Union[Web3, AsyncWeb3]) -> Union[Contract, AsyncContract]: + return w3.eth.contract(abi=self.get_abi()) + @abstractmethod def add_pool(self, pool: Pool): """ @@ -99,7 +103,7 @@ def get_events(self, contract: Contract) -> List[Type[Contract]]: pass @abstractmethod - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: ... @staticmethod diff --git a/fastlane_bot/events/exchanges/carbon_v1.py b/fastlane_bot/events/exchanges/carbon_v1.py index fa4a40107..125dadb26 100644 --- a/fastlane_bot/events/exchanges/carbon_v1.py +++ b/fastlane_bot/events/exchanges/carbon_v1.py @@ -12,9 +12,10 @@ Licensed under MIT. """ from dataclasses import dataclass -from typing import List, Type, Tuple, Any, Dict, Callable +from typing import List, Type, Tuple, Any, Dict, Callable, Union from fastlane_bot import Config +from web3 import Web3, AsyncWeb3 from web3.contract import Contract from fastlane_bot.data.abi import CARBON_CONTROLLER_ABI @@ -80,7 +81,8 @@ def get_events(self, contract: Contract) -> List[Type[Contract]]: contract.events.PairCreated, ] if self.exchange_initialized else [] - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: + contract = self.get_event_contract(w3) return [ Subscription(contract.events.StrategyCreated, STRATEGY_CREATED_TOPIC), Subscription(contract.events.StrategyUpdated, STRATEGY_UPDATED_TOPIC), diff --git a/fastlane_bot/events/exchanges/solidly_v2/base.py b/fastlane_bot/events/exchanges/solidly_v2/base.py index 7bffef541..693c82197 100644 --- a/fastlane_bot/events/exchanges/solidly_v2/base.py +++ b/fastlane_bot/events/exchanges/solidly_v2/base.py @@ -13,8 +13,9 @@ """ from abc import abstractmethod from dataclasses import dataclass -from typing import List, Type, Any +from typing import List, Type, Any, Union +from web3 import Web3, AsyncWeb3 from web3.contract import Contract, AsyncContract from fastlane_bot.data.abi import SOLIDLY_V2_POOL_ABI @@ -50,7 +51,8 @@ def add_pool(self, pool: Pool): def get_events(self, contract: Contract) -> List[Type[Contract]]: return [contract.events.Sync] if self.exchange_initialized else [] - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: + contract = self.get_event_contract(w3) return [Subscription(contract.events.Sync)] def get_abi(self): diff --git a/fastlane_bot/events/exchanges/uniswap_v2.py b/fastlane_bot/events/exchanges/uniswap_v2.py index ce1e209cc..3fb5b902d 100644 --- a/fastlane_bot/events/exchanges/uniswap_v2.py +++ b/fastlane_bot/events/exchanges/uniswap_v2.py @@ -12,8 +12,9 @@ Licensed under MIT. """ from dataclasses import dataclass -from typing import List, Type, Tuple, Any +from typing import List, Type, Tuple, Any, Union +from web3 import Web3, AsyncWeb3 from web3.contract import Contract, AsyncContract from fastlane_bot.data.abi import UNISWAP_V2_POOL_ABI, UNISWAP_V2_FACTORY_ABI @@ -49,7 +50,8 @@ def get_abi(self): def get_events(self, contract: Contract) -> List[Type[Contract]]: return [contract.events.Sync] if self.exchange_initialized else [] - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: + contract = self.get_event_contract(w3) return [Subscription(contract.events.Sync)] async def get_fee(self, address: str, contract: AsyncContract) -> Tuple[str, float]: diff --git a/fastlane_bot/events/exchanges/uniswap_v3.py b/fastlane_bot/events/exchanges/uniswap_v3.py index 76d8a93d5..6a478faf6 100644 --- a/fastlane_bot/events/exchanges/uniswap_v3.py +++ b/fastlane_bot/events/exchanges/uniswap_v3.py @@ -12,8 +12,9 @@ Licensed under MIT. """ from dataclasses import dataclass -from typing import List, Type, Tuple, Any +from typing import List, Type, Tuple, Any, Union +from web3 import Web3, AsyncWeb3 from web3.contract import Contract from fastlane_bot.config.constants import AGNI_V3_NAME, PANCAKESWAP_V3_NAME, FUSIONX_V3_NAME, ECHODEX_V3_NAME, SECTA_V3_NAME @@ -46,7 +47,8 @@ def factory_abi(self): def get_events(self, contract: Contract) -> List[Type[Contract]]: return [contract.events.Swap] if self.exchange_initialized else [] - def get_subscriptions(self, contract: Contract) -> List[Subscription]: + def get_subscriptions(self, w3: Union[Web3, AsyncWeb3]) -> List[Subscription]: + contract = self.get_event_contract(w3) return [Subscription(contract.events.Swap)] async def get_fee(self, address: str, contract: Contract) -> Tuple[str, float]: diff --git a/fastlane_bot/tests/test_event_topics.py b/fastlane_bot/tests/test_event_topics.py index 67e456f71..506f9b280 100644 --- a/fastlane_bot/tests/test_event_topics.py +++ b/fastlane_bot/tests/test_event_topics.py @@ -46,7 +46,6 @@ ]) def test_event_topic(config, cls, exchange_name, event_topics): exchange = cls(exchange_name=exchange_name) - contract = config.w3.eth.contract(abi=exchange.get_abi()) - for subscription in exchange.get_subscriptions(contract): + for subscription in exchange.get_subscriptions(config.w3): assert event_topics.pop(subscription._event.event_name) == subscription.topic assert event_topics == {} diff --git a/main.py b/main.py index e335f3fa8..fba6b7563 100644 --- a/main.py +++ b/main.py @@ -310,7 +310,6 @@ def run(mgr, args, tenderly_uri=None) -> None: config=mgr.cfg, w3=mgr.w3_async, exchanges=mgr.exchanges, - event_contracts=mgr.event_contracts ) pool_finder = PoolFinder( diff --git a/pyproject.toml b/pyproject.toml index 163fdfd82..375156cc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fastlane-bot" -version = "3.2.1" +version = "3.2.2" description = "Carbon Arbitrage Bot, an open-source arbitrage protocol, allows any user to perform arbitrage between Bancor ecosystem protocols and external exchanges and redirect arbitrage profits back to the protocol." authors = ["Bancor Network "] license = "MIT"