Only keep the shortest route instead
This commit is contained in:
parent
154d356621
commit
46f7786c4f
@ -51,7 +51,7 @@ def _get_arbitrages_from_swaps(swaps: List[Swap]) -> List[Arbitrage]:
|
|||||||
if start in used_swaps:
|
if start in used_swaps:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
longest_route = None
|
shortest_route = None
|
||||||
|
|
||||||
for end in ends:
|
for end in ends:
|
||||||
if end in used_swaps:
|
if end in used_swaps:
|
||||||
@ -70,12 +70,12 @@ def _get_arbitrages_from_swaps(swaps: List[Swap]) -> List[Arbitrage]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
for route in routes:
|
for route in routes:
|
||||||
if longest_route is None or len(route) > len(longest_route):
|
if shortest_route is None or len(route) < len(shortest_route):
|
||||||
longest_route = route
|
shortest_route = route
|
||||||
|
|
||||||
if longest_route is not None:
|
if shortest_route is not None:
|
||||||
start_amount = longest_route[0].token_in_amount
|
start_amount = shortest_route[0].token_in_amount
|
||||||
end_amount = longest_route[-1].token_out_amount
|
end_amount = shortest_route[-1].token_out_amount
|
||||||
profit_amount = end_amount - start_amount
|
profit_amount = end_amount - start_amount
|
||||||
error = None
|
error = None
|
||||||
for swap in route:
|
for swap in route:
|
||||||
@ -83,11 +83,11 @@ def _get_arbitrages_from_swaps(swaps: List[Swap]) -> List[Arbitrage]:
|
|||||||
error = swap.error
|
error = swap.error
|
||||||
|
|
||||||
arb = Arbitrage(
|
arb = Arbitrage(
|
||||||
swaps=longest_route,
|
swaps=shortest_route,
|
||||||
block_number=longest_route[0].block_number,
|
block_number=shortest_route[0].block_number,
|
||||||
transaction_hash=longest_route[0].transaction_hash,
|
transaction_hash=shortest_route[0].transaction_hash,
|
||||||
account_address=longest_route[0].from_address,
|
account_address=shortest_route[0].from_address,
|
||||||
profit_token_address=longest_route[0].token_in_address,
|
profit_token_address=shortest_route[0].token_in_address,
|
||||||
start_amount=start_amount,
|
start_amount=start_amount,
|
||||||
end_amount=end_amount,
|
end_amount=end_amount,
|
||||||
profit_amount=profit_amount,
|
profit_amount=profit_amount,
|
||||||
@ -95,7 +95,7 @@ def _get_arbitrages_from_swaps(swaps: List[Swap]) -> List[Arbitrage]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
all_arbitrages.append(arb)
|
all_arbitrages.append(arb)
|
||||||
used_swaps.extend(longest_route)
|
used_swaps.extend(shortest_route)
|
||||||
|
|
||||||
if len(all_arbitrages) == 1:
|
if len(all_arbitrages) == 1:
|
||||||
return all_arbitrages
|
return all_arbitrages
|
||||||
|
Loading…
x
Reference in New Issue
Block a user