Skip to content

Commit

Permalink
Merge branch 'triangle-mode-refactor' of https://github.com/bancorpro…
Browse files Browse the repository at this point in the history
…tocol/fastlane-bot into refactor-encode-decode-orders
  • Loading branch information
barak manos committed May 27, 2024
2 parents 9ebe05d + 15efcc5 commit 3cb6a05
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions fastlane_bot/modes/triangle_bancor_v3_two_hop.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

class ArbitrageFinderTriangleBancor3TwoHop(ArbitrageFinderTriangleBase):
def get_combos(self) -> List[Any]:
miniverse_combos = []

fltkns = self.CCm.byparams(exchange="bancor_v3").tknys()
if self.ConfigObj.LIMIT_BANCOR3_FLASHLOAN_TOKENS:
# Filter out tokens that are not in the existing flashloan_tokens list
Expand All @@ -23,36 +25,33 @@ def get_combos(self) -> List[Any]:
else:
flashloan_tokens = fltkns

miniverse_combos = []

for tkn0, tkn1 in [(tkn0, tkn1) for tkn0, tkn1 in product(flashloan_tokens, flashloan_tokens) if tkn0 != tkn1]:
all_curves = list(set(self.CCm.bypairs(f"{tkn0}/{tkn1}")) | set(self.CCm.bypairs(f"{tkn1}/{tkn0}")))

carbon_curves = [curve for curve in all_curves if curve.params.get("exchange") in self.ConfigObj.CARBON_V1_FORKS]
if len(carbon_curves) == 0:
bancor_curve_0 = self.CCm.bypairs(f"{self.ConfigObj.BNT_ADDRESS}/{tkn0}").byparams(exchange="bancor_v3").curves
if len(bancor_curve_0) == 0:
continue

external_curves = [curve for curve in all_curves if curve.params.get("exchange") not in self.ConfigObj.CARBON_V1_FORKS]
if len(external_curves) == 0:
bancor_curve_1 = self.CCm.bypairs(f"{self.ConfigObj.BNT_ADDRESS}/{tkn1}").byparams(exchange="bancor_v3").curves
if len(bancor_curve_1) == 0:
continue

bancor_v3_curve_0 = self.CCm.bypairs(f"{self.ConfigObj.BNT_ADDRESS}/{tkn0}").byparams(exchange="bancor_v3").curves
if len(bancor_v3_curve_0) == 0:
continue

bancor_v3_curve_1 = self.CCm.bypairs(f"{self.ConfigObj.BNT_ADDRESS}/{tkn1}").byparams(exchange="bancor_v3").curves
if len(bancor_v3_curve_1) == 0:
continue
all_curves = list(set(self.CCm.bypairs(f"{tkn0}/{tkn1}")) | set(self.CCm.bypairs(f"{tkn1}/{tkn0}")))
carbon_curves = [curve for curve in all_curves if curve.params.exchange in self.ConfigObj.CARBON_V1_FORKS]
other_curves = [curve for curve in all_curves if curve.params.exchange not in self.ConfigObj.CARBON_V1_FORKS]
bancor_curves = bancor_curve_0 + bancor_curve_1

base_dir_one = [curve for curve in carbon_curves if curve.pair == carbon_curves[0].pair]
base_dir_two = [curve for curve in carbon_curves if curve.pair != carbon_curves[0].pair]
miniverses = [bancor_v3_curve_0 + bancor_v3_curve_1 + [curve] for curve in external_curves]

miniverses = []

if len(other_curves) > 0:
miniverses += [bancor_curves + [curve] for curve in other_curves]

if len(base_dir_one) > 0:
miniverses += [bancor_v3_curve_0 + bancor_v3_curve_1 + base_dir_one]
miniverses += [bancor_curves + base_dir_one]

if len(base_dir_two) > 0:
miniverses += [bancor_v3_curve_0 + bancor_v3_curve_1 + base_dir_two]
miniverses += [bancor_curves + base_dir_two]

miniverse_combos += [(tkn1, miniverse) for miniverse in miniverses]

Expand Down

0 comments on commit 3cb6a05

Please sign in to comment.