Break swap outs / ins check into a function

This commit is contained in:
Luke Van Seters 2022-01-07 12:22:45 -05:00
parent 9894450e0c
commit 69cad7537e

View File

@ -120,11 +120,7 @@ def _get_shortest_route(
)
for next_swap in other_swaps:
if start_swap.token_out_address == next_swap.token_in_address and (
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
):
if _swap_outs_match_swap_ins(start_swap, next_swap):
shortest_from_next = _get_shortest_route(
next_swap,
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))
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
)