From 919bdeb7a2dbf83385d971af323e2a4eeae709ef Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Wed, 25 Aug 2021 11:25:22 -0400 Subject: [PATCH] Use get_traces_by_transaction_hash in swaps too --- mev_inspect/swaps.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mev_inspect/swaps.py b/mev_inspect/swaps.py index 799845f..00c71c3 100644 --- a/mev_inspect/swaps.py +++ b/mev_inspect/swaps.py @@ -1,4 +1,3 @@ -from itertools import groupby from typing import List, Optional from mev_inspect.schemas.classified_traces import ( @@ -7,6 +6,7 @@ from mev_inspect.schemas.classified_traces import ( ) from mev_inspect.schemas.swaps import Swap from mev_inspect.schemas.transfers import ERC20Transfer +from mev_inspect.traces import get_traces_by_transaction_hash from mev_inspect.transfers import ( get_child_transfers, filter_transfers, @@ -19,15 +19,9 @@ UNISWAP_V3_POOL_ABI_NAME = "UniswapV3Pool" def get_swaps(traces: List[ClassifiedTrace]) -> List[Swap]: - get_transaction_hash = lambda t: t.transaction_hash - traces_by_transaction = groupby( - sorted(traces, key=get_transaction_hash), - key=get_transaction_hash, - ) - swaps = [] - for _, transaction_traces in traces_by_transaction: + for _, transaction_traces in get_traces_by_transaction_hash(traces).items(): swaps += _get_swaps_for_transaction(list(transaction_traces)) return swaps