43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
from typing import Optional, List
|
|
from mev_inspect.schemas.transfers import Transfer
|
|
from mev_inspect.schemas.swaps import Swap
|
|
from mev_inspect.schemas.traces import (
|
|
DecodedCallTrace,
|
|
Protocol,
|
|
)
|
|
from mev_inspect.schemas.classifiers import (
|
|
ClassifierSpec,
|
|
SwapClassifier,
|
|
)
|
|
from mev_inspect.classifiers.utils import create_swap_from_transfers
|
|
|
|
BALANCER_V1_POOL_ABI_NAME = "BPool"
|
|
|
|
|
|
class BalancerSwapClassifier(SwapClassifier):
|
|
@staticmethod
|
|
def parse_swap(
|
|
trace: DecodedCallTrace,
|
|
prior_transfers: List[Transfer],
|
|
child_transfers: List[Transfer],
|
|
) -> Optional[Swap]:
|
|
|
|
swap = create_swap_from_transfers(trace, prior_transfers, child_transfers)
|
|
return swap
|
|
|
|
|
|
BALANCER_V1_SPECS = [
|
|
ClassifierSpec(
|
|
abi_name=BALANCER_V1_POOL_ABI_NAME,
|
|
protocol=Protocol.balancer_v1,
|
|
classifiers={
|
|
"swapExactAmountIn(address,uint256,address,uint256,uint256)": BalancerSwapClassifier,
|
|
"swapExactAmountOut(address,uint256,address,uint256,uint256)": BalancerSwapClassifier,
|
|
},
|
|
),
|
|
]
|
|
|
|
BALANCER_CLASSIFIER_SPECS = [
|
|
*BALANCER_V1_SPECS,
|
|
]
|