Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into module-bot-cleanup
  • Loading branch information
barak manos committed Apr 21, 2024
2 parents bf51678 + b15d962 commit 37d48b5
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 89 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ You can configure the Fastlane Arbitrage Bot using the options in the `@click.op
- **pool_data_update_frequency** (int): The frequency in bot cycles in which the bot will search for new pools. **Recommended not to modify.**
- **use_specific_exchange_for_target_tokens** (str): This filter will limit pool data to include only tokens contained by the specified exchange. For example "carbon_v1" would limit the scope of pool data to only include pools that have tokens currently traded on Carbon.
- **prefix_path** (str): An optional file path modification, intended for cloud deployment requirements. **Recommended not to modify.**
- **version_check_frequency** (int): The frequency (in bot cycles) the bot will check the version of the Fastlane smart contract. Set to -1 to disable.
- **self_fund** (bool): **USE AT YOUR OWN RISK** If set to True, the bot will use funds in the user's wallet to execute trades. Note that upon start, the bot will attempt to set an approval for all tokens specified in the flashloan_tokens field.


Expand Down
11 changes: 0 additions & 11 deletions fastlane_bot/config/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,9 @@ def new(cls, network: ConfigNetwork, provider=None, **kwargs):

def __init__(self, network: ConfigNetwork, **kwargs):
super().__init__(**kwargs)
self.ARB_CONTRACT_VERSION = None
self.BANCOR_ARBITRAGE_CONTRACT = None
self.network = network

def check_version_of_arb_contract(self):
if self.BANCOR_ARBITRAGE_CONTRACT is not None:
try:
self.ARB_CONTRACT_VERSION = self.BANCOR_ARBITRAGE_CONTRACT.caller.version()
except Exception as e:
# Failed to get latest version of arbitrage contract
print(f"Failed to get latest version of arbitrage contract due to exception: {e}")

class _ConfigProviderAlchemy(ConfigProvider):
"""
Fastlane bot config -- provider [Alchemy]
Expand Down Expand Up @@ -124,7 +115,6 @@ def __init__(self, network: ConfigNetwork, **kwargs):
abi=GAS_ORACLE_ABI,
)

self.ARB_CONTRACT_VERSION = self.BANCOR_ARBITRAGE_CONTRACT.caller.version()
self.ARB_REWARDS_PPM = self.BANCOR_ARBITRAGE_CONTRACT.caller.rewards()[0]


Expand Down Expand Up @@ -163,7 +153,6 @@ def __init__(self, network: ConfigNetwork, **kwargs):
abi=GAS_ORACLE_ABI,
)

self.ARB_CONTRACT_VERSION = self.BANCOR_ARBITRAGE_CONTRACT.caller.version()
self.ARB_REWARDS_PPM = self.BANCOR_ARBITRAGE_CONTRACT.caller.rewards()[0]


Expand Down
56 changes: 0 additions & 56 deletions fastlane_bot/data/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@
"stateMutability": "view",
"inputs": [],
"outputs": [{"components": [{"internalType": "uint32", "name": "percentagePPM", "type": "uint32"}, {"internalType": "uint256", "name": "maxAmount", "type": "uint256"}], "internalType": "struct BancorArbitrage.Rewards", "name": "", "type": "tuple"}]
},
{
"type": "function",
"name": "version",
"stateMutability": "pure",
"inputs": [],
"outputs": [{"internalType": "uint16", "name": "", "type": "uint16"}]
}
]

Expand Down Expand Up @@ -162,13 +155,6 @@
"stateMutability": "view",
"inputs": [],
"outputs": [{"internalType": "uint32", "name": "", "type": "uint32"}]
},
{
"type": "function",
"name": "version",
"stateMutability": "pure",
"inputs": [],
"outputs": [{"internalType": "uint16", "name": "", "type": "uint16"}]
}
]

Expand Down Expand Up @@ -498,13 +484,6 @@
"stateMutability": "view",
"inputs": [],
"outputs": [{"internalType": "contract IERC20[]", "name": "", "type": "address[]"}]
},
{
"type": "function",
"name": "version",
"stateMutability": "view",
"inputs": [],
"outputs": [{"internalType": "uint16", "name": "", "type": "uint16"}]
}
]

Expand All @@ -521,13 +500,6 @@
"anonymous": False,
"inputs": [{"indexed": True, "internalType": "bytes32", "name": "contextId", "type": "bytes32"}, {"indexed": True, "internalType": "contract Token", "name": "sourceToken", "type": "address"}, {"indexed": True, "internalType": "contract Token", "name": "targetToken", "type": "address"}, {"indexed": False, "internalType": "uint256", "name": "sourceAmount", "type": "uint256"}, {"indexed": False, "internalType": "uint256", "name": "targetAmount", "type": "uint256"}, {"indexed": False, "internalType": "uint256", "name": "bntAmount", "type": "uint256"}, {"indexed": False, "internalType": "uint256", "name": "targetFeeAmount", "type": "uint256"}, {"indexed": False, "internalType": "uint256", "name": "bntFeeAmount", "type": "uint256"}, {"indexed": False, "internalType": "address", "name": "trader", "type": "address"}]
},
{
"type": "function",
"name": "version",
"stateMutability": "pure",
"inputs": [],
"outputs": [{"internalType": "uint16", "name": "", "type": "uint16"}]
},
{
"type": "function",
"name": "withdrawPOL",
Expand All @@ -544,13 +516,6 @@
"stateMutability": "view",
"inputs": [],
"outputs": [{"internalType": "contract Token[]", "name": "", "type": "address[]"}]
},
{
"type": "function",
"name": "version",
"stateMutability": "pure",
"inputs": [],
"outputs": [{"internalType": "uint16", "name": "", "type": "uint16"}]
}
]

Expand All @@ -568,13 +533,6 @@
"stateMutability": "view",
"inputs": [{"internalType": "contract Token", "name": "pool", "type": "address"}],
"outputs": [{"components": [{"internalType": "uint128", "name": "bntTradingLiquidity", "type": "uint128"}, {"internalType": "uint128", "name": "baseTokenTradingLiquidity", "type": "uint128"}], "internalType": "struct TradingLiquidity", "name": "", "type": "tuple"}]
},
{
"type": "function",
"name": "version",
"stateMutability": "pure",
"inputs": [],
"outputs": [{"internalType": "uint16", "name": "", "type": "uint16"}]
}
]

Expand Down Expand Up @@ -610,13 +568,6 @@
"stateMutability": "view",
"inputs": [{"internalType": "contract Token", "name": "pool", "type": "address"}],
"outputs": [{"internalType": "uint32", "name": "", "type": "uint32"}]
},
{
"type": "function",
"name": "version",
"stateMutability": "view",
"inputs": [],
"outputs": [{"internalType": "uint16", "name": "", "type": "uint16"}]
}
]

Expand Down Expand Up @@ -646,13 +597,6 @@
"stateMutability": "view",
"inputs": [{"internalType": "Token", "name": "token", "type": "address"}],
"outputs": [{"components": [{"internalType": "uint128", "name": "sourceAmount", "type": "uint128"}, {"internalType": "uint128", "name": "targetAmount", "type": "uint128"}], "internalType": "struct ICarbonPOL.Price", "name": "", "type": "tuple"}]
},
{
"type": "function",
"name": "version",
"stateMutability": "pure",
"inputs": [],
"outputs": [{"internalType": "uint16", "name": "", "type": "uint16"}]
}
]

Expand Down
3 changes: 1 addition & 2 deletions fastlane_bot/events/multicall_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def multicall_fn(exchange: str, mc: Any, mgr: Any, multicall_contract: Any, pool
mc.add_call(multicall_contract.functions.tradingLiquidity, pool_info["tkn1_address"])
elif exchange == "bancor_pol":
mc.add_call(multicall_contract.functions.tokenPrice, pool_info["tkn0_address"])
if mgr.cfg.ARB_CONTRACT_VERSION >= 10:
mc.add_call(multicall_contract.functions.amountAvailableForTrading, pool_info["tkn0_address"])
mc.add_call(multicall_contract.functions.amountAvailableForTrading, pool_info["tkn0_address"])
elif exchange in mgr.cfg.CARBON_V1_FORKS:
mc.add_call(multicall_contract.functions.strategy, pool_info["cid"])
elif exchange == 'balancer':
Expand Down
1 change: 0 additions & 1 deletion fastlane_bot/events/pools/bancor_pol.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class BancorPolPool(Pool):
ONE = 2**48
contract: Contract = None
BANCOR_POL_ADDRESS = "0xD06146D292F9651C1D7cf54A3162791DFc2bEf46"
ARB_CONTRACT_VERSION = None

@staticmethod
def unique_key() -> str:
Expand Down
1 change: 0 additions & 1 deletion fastlane_bot/tests_on_hold/test_907_RuntimeParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(self):
self.pool_data_update_frequency = -1
self.use_specific_exchange_for_target_tokens = None
self.prefix_path = ""
self.version_check_frequency = 1
self.self_fund = 'False'
self.read_only = 'True'
self.is_args_test = 'True'
Expand Down
18 changes: 1 addition & 17 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def int_or_none(x):
"increment_time": int,
"increment_blocks": int,
"pool_data_update_frequency": int,
"version_check_frequency": int,
"self_fund": is_true,
"read_only": is_true,
"is_args_test": is_true,
Expand Down Expand Up @@ -226,7 +225,6 @@ def main(args: argparse.Namespace) -> None:
increment_blocks: {args.increment_blocks}
pool_data_update_frequency: {args.pool_data_update_frequency}
prefix_path: {args.prefix_path}
version_check_frequency: {args.version_check_frequency}
self_fund: {args.self_fund}
read_only: {args.read_only}
Expand Down Expand Up @@ -503,16 +501,7 @@ def run(mgr, args, tenderly_uri=None) -> None:

params = [w3.to_hex(args.increment_blocks)] # number of blocks
w3.provider.make_request(method="evm_increaseBlocks", params=params)
if (
loop_idx % args.version_check_frequency == 0
and args.version_check_frequency != -1
and args.blockchain in "ethereum"
):
# Check the version of the deployed arbitrage contract
mgr.cfg.provider.check_version_of_arb_contract()
mgr.cfg.logger.info(
f"[main] Checking latest version of Arbitrage Contract. Found version: {mgr.cfg.ARB_CONTRACT_VERSION}"
)

if (
loop_idx % args.pool_data_update_frequency == 0
and args.pool_data_update_frequency != -1
Expand Down Expand Up @@ -740,11 +729,6 @@ def run_async_update_with_retries(mgr, current_block, logging_path, max_retries=
default="",
help="Prefixes the path to the write folders (used for deployment)",
)
parser.add_argument(
"--version_check_frequency",
default=1,
help="How frequently pool data should be updated, in main loop iterations.",
)
parser.add_argument(
"--self_fund",
default='False',
Expand Down

0 comments on commit 37d48b5

Please sign in to comment.