Skip to content

Commit

Permalink
Fix syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
barak manos committed May 27, 2024
1 parent 314efb1 commit 63caa85
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions fastlane_bot/modes/base_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions fastlane_bot/modes/base_triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
6 changes: 3 additions & 3 deletions fastlane_bot/modes/pairwise_multi_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
8 changes: 4 additions & 4 deletions fastlane_bot/modes/pairwise_multi_pol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 63caa85

Please sign in to comment.