From 63caa85a23273d1de3c1ea9ed270d382bb49ac5f Mon Sep 17 00:00:00 2001 From: barak manos <> Date: Mon, 27 May 2024 21:01:40 +0300 Subject: [PATCH] Fix syntax --- fastlane_bot/modes/base_pairwise.py | 10 +++++----- fastlane_bot/modes/base_triangle.py | 12 ++++++------ fastlane_bot/modes/pairwise_multi_all.py | 6 +++--- fastlane_bot/modes/pairwise_multi_pol.py | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/fastlane_bot/modes/base_pairwise.py b/fastlane_bot/modes/base_pairwise.py index 209853c42..91b5b5d4e 100644 --- a/fastlane_bot/modes/base_pairwise.py +++ b/fastlane_bot/modes/base_pairwise.py @@ -19,15 +19,15 @@ def find_arbitrage(self) -> Dict[List[Any], List[Any]]: combos = self.get_combos() for dst_token, src_token in combos: - CC = self.CCm.bypairs(f"{dst_token}/{src_token}") - if len(CC) < 2: + curves = self.CCm.bypairs(f"{dst_token}/{src_token}").curves + if len(curves) < 2: continue - for curve_combo in self.get_curve_combos(CC): - if len(curve_combo) < 2: + for curve_combos in self.get_curve_combos(curves): + if len(curve_combos) < 2: continue try: - container = CPCContainer(curve_combo) + container = CPCContainer(curve_combos) optimizer = PairOptimizer(container) params = get_params(container, dst_token, src_token) optimization = optimizer.optimize(src_token, params=params) diff --git a/fastlane_bot/modes/base_triangle.py b/fastlane_bot/modes/base_triangle.py index 1d6174ea8..a77459b4f 100644 --- a/fastlane_bot/modes/base_triangle.py +++ b/fastlane_bot/modes/base_triangle.py @@ -42,13 +42,13 @@ def find_arbitrage(self) -> Dict[List[Any], List[Any]]: def get_params(container, src_token): pstart = {src_token: 1} for dst_token in [token for token in container.tokens() if token != src_token]: - CC = container.bytknx(dst_token).bytkny(src_token) - if CC: - pstart[dst_token] = CC.curves[0].p + curves = container.bytknx(dst_token).bytkny(src_token).curves + if len(curves) > 0: + pstart[dst_token] = curves[0].p else: - CC = container.bytknx(src_token).bytkny(dst_token) - if CC: - pstart[dst_token] = 1 / CC.curves[0].p + curves = container.bytknx(src_token).bytkny(dst_token).curves + if len(curves) > 0: + pstart[dst_token] = 1 / curves[0].p else: return None return {"pstart": pstart} diff --git a/fastlane_bot/modes/pairwise_multi_all.py b/fastlane_bot/modes/pairwise_multi_all.py index b0c591970..ca0ce678e 100644 --- a/fastlane_bot/modes/pairwise_multi_all.py +++ b/fastlane_bot/modes/pairwise_multi_all.py @@ -19,9 +19,9 @@ def get_combos(self) -> List[Any]: flashloan_tokens_intersect = all_tokens.intersection(set(self.flashloan_tokens)) return [(tkn0, tkn1) for tkn0, tkn1 in product(all_tokens, flashloan_tokens_intersect) if tkn0 != tkn1] - def get_curve_combos(self, CC: Any) -> List[Any]: - carbon_curves = [curve for curve in CC.curves if curve.params.exchange in self.ConfigObj.CARBON_V1_FORKS] - other_curves = [curve for curve in CC.curves if curve.params.exchange not in self.ConfigObj.CARBON_V1_FORKS] + def get_curve_combos(self, curves: List[Any]) -> List[Any]: + carbon_curves = [curve for curve in curves if curve.params.exchange in self.ConfigObj.CARBON_V1_FORKS] + other_curves = [curve for curve in curves if curve.params.exchange not in self.ConfigObj.CARBON_V1_FORKS] if len(carbon_curves) > 0: curve_combos = [] diff --git a/fastlane_bot/modes/pairwise_multi_pol.py b/fastlane_bot/modes/pairwise_multi_pol.py index 91c5c2fcd..011215f87 100644 --- a/fastlane_bot/modes/pairwise_multi_pol.py +++ b/fastlane_bot/modes/pairwise_multi_pol.py @@ -19,10 +19,10 @@ def get_combos(self) -> List[Any]: bancor_pol_tkns = set([tkn for tkn in bancor_pol_tkns if tkn != self.ConfigObj.WETH_ADDRESS]) return [(tkn0, tkn1) for tkn0, tkn1 in product(bancor_pol_tkns, [self.ConfigObj.WETH_ADDRESS]) if tkn0 != tkn1] - def get_curve_combos(self, CC: Any) -> List[Any]: - pol_curves = [curve for curve in CC.curves if curve.params.exchange == "bancor_pol"] - carbon_curves = [curve for curve in CC.curves if curve.params.exchange in self.ConfigObj.CARBON_V1_FORKS] - other_curves = [curve for curve in CC.curves if curve.params.exchange not in ["bancor_pol"] + self.ConfigObj.CARBON_V1_FORKS] + def get_curve_combos(self, curves: List[Any]) -> List[Any]: + pol_curves = [curve for curve in curves if curve.params.exchange == "bancor_pol"] + carbon_curves = [curve for curve in curves if curve.params.exchange in self.ConfigObj.CARBON_V1_FORKS] + other_curves = [curve for curve in curves if curve.params.exchange not in ["bancor_pol"] + self.ConfigObj.CARBON_V1_FORKS] curve_combos = [[curve] + pol_curves for curve in other_curves] if len(carbon_curves) > 0: