Use get_traces_by_transaction_hash in swaps too
This commit is contained in:
parent
4a35a07a1c
commit
919bdeb7a2
@ -1,4 +1,3 @@
|
|||||||
from itertools import groupby
|
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from mev_inspect.schemas.classified_traces import (
|
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.swaps import Swap
|
||||||
from mev_inspect.schemas.transfers import ERC20Transfer
|
from mev_inspect.schemas.transfers import ERC20Transfer
|
||||||
|
from mev_inspect.traces import get_traces_by_transaction_hash
|
||||||
from mev_inspect.transfers import (
|
from mev_inspect.transfers import (
|
||||||
get_child_transfers,
|
get_child_transfers,
|
||||||
filter_transfers,
|
filter_transfers,
|
||||||
@ -19,15 +19,9 @@ UNISWAP_V3_POOL_ABI_NAME = "UniswapV3Pool"
|
|||||||
|
|
||||||
|
|
||||||
def get_swaps(traces: List[ClassifiedTrace]) -> List[Swap]:
|
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 = []
|
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))
|
swaps += _get_swaps_for_transaction(list(transaction_traces))
|
||||||
|
|
||||||
return swaps
|
return swaps
|
||||||
|
Loading…
x
Reference in New Issue
Block a user