Break swap outs / ins check into a function
This commit is contained in:
parent
9894450e0c
commit
69cad7537e
@ -120,11 +120,7 @@ def _get_shortest_route(
|
|||||||
)
|
)
|
||||||
|
|
||||||
for next_swap in other_swaps:
|
for next_swap in other_swaps:
|
||||||
if start_swap.token_out_address == next_swap.token_in_address and (
|
if _swap_outs_match_swap_ins(start_swap, next_swap):
|
||||||
start_swap.contract_address == next_swap.from_address
|
|
||||||
or start_swap.to_address == next_swap.contract_address
|
|
||||||
or start_swap.to_address == next_swap.from_address
|
|
||||||
):
|
|
||||||
shortest_from_next = _get_shortest_route(
|
shortest_from_next = _get_shortest_route(
|
||||||
next_swap,
|
next_swap,
|
||||||
end_swaps,
|
end_swaps,
|
||||||
@ -174,3 +170,11 @@ def _get_all_start_end_swaps(swaps: List[Swap]) -> List[Tuple[Swap, List[Swap]]]
|
|||||||
valid_start_ends.append((potential_start_swap, ends_for_start))
|
valid_start_ends.append((potential_start_swap, ends_for_start))
|
||||||
|
|
||||||
return valid_start_ends
|
return valid_start_ends
|
||||||
|
|
||||||
|
|
||||||
|
def _swap_outs_match_swap_ins(swap_out, swap_in) -> bool:
|
||||||
|
return swap_out.token_out_address == swap_in.token_in_address and (
|
||||||
|
swap_out.contract_address == swap_in.from_address
|
||||||
|
or swap_out.to_address == swap_in.contract_address
|
||||||
|
or swap_out.to_address == swap_in.from_address
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user