Compare commits
3 Commits
main
...
classifier
Author | SHA1 | Date | |
---|---|---|---|
|
25e1cbcf83 | ||
|
f87016a561 | ||
|
7645726708 |
@ -1,6 +1,6 @@
|
||||
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||
from mev_inspect.schemas.classified_traces import (
|
||||
Classification,
|
||||
ClassifierSpec,
|
||||
Protocol,
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||
from mev_inspect.schemas.classified_traces import (
|
||||
Classification,
|
||||
ClassifierSpec,
|
||||
Protocol,
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||
from mev_inspect.schemas.classified_traces import (
|
||||
ClassifierSpec,
|
||||
Protocol,
|
||||
)
|
||||
|
||||
|
@ -1,15 +1,34 @@
|
||||
from typing import Optional
|
||||
|
||||
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||
from mev_inspect.schemas.classified_traces import (
|
||||
Classification,
|
||||
ClassifierSpec,
|
||||
DecodedCallTrace,
|
||||
)
|
||||
from mev_inspect.schemas.transfers import ERC20Transfer
|
||||
|
||||
|
||||
def classify_transfer(trace: DecodedCallTrace) -> Optional[ERC20Transfer]:
|
||||
return ERC20Transfer(
|
||||
block_number=trace.block_number,
|
||||
transaction_hash=trace.transaction_hash,
|
||||
trace_address=trace.trace_address,
|
||||
amount=trace.inputs["amount"],
|
||||
to_address=trace.inputs["recipient"],
|
||||
from_address=trace.inputs.get("sender", trace.from_address),
|
||||
token_address=trace.to_address,
|
||||
)
|
||||
|
||||
|
||||
ERC20_SPEC = ClassifierSpec(
|
||||
abi_name="ERC20",
|
||||
transfer_classifiers={
|
||||
"transferFrom(address,address,uint256)": classify_transfer,
|
||||
"transfer(address,uint256)": classify_transfer,
|
||||
},
|
||||
classifications={
|
||||
"transferFrom(address,address,uint256)": Classification.transfer,
|
||||
"transfer(address,uint256)": Classification.transfer,
|
||||
"burn(address)": Classification.burn,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||
from mev_inspect.schemas.classified_traces import (
|
||||
Classification,
|
||||
ClassifierSpec,
|
||||
Protocol,
|
||||
)
|
||||
|
||||
|
@ -1,17 +1,39 @@
|
||||
from typing import Optional
|
||||
|
||||
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||
from mev_inspect.schemas.classified_traces import (
|
||||
Classification,
|
||||
ClassifierSpec,
|
||||
DecodedCallTrace,
|
||||
Protocol,
|
||||
)
|
||||
from mev_inspect.schemas.transfers import ERC20Transfer
|
||||
|
||||
|
||||
def classify_transfer(trace: DecodedCallTrace) -> Optional[ERC20Transfer]:
|
||||
return ERC20Transfer(
|
||||
block_number=trace.block_number,
|
||||
transaction_hash=trace.transaction_hash,
|
||||
trace_address=trace.trace_address,
|
||||
amount=trace.inputs["wad"],
|
||||
to_address=trace.inputs["dst"],
|
||||
from_address=trace.from_address,
|
||||
token_address=trace.to_address,
|
||||
)
|
||||
|
||||
|
||||
WETH_SPEC = ClassifierSpec(
|
||||
abi_name="WETH9",
|
||||
protocol=Protocol.weth,
|
||||
valid_contract_addresses=["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"],
|
||||
transfer_classifiers={
|
||||
"transferFrom(address,address,uint256)": classify_transfer,
|
||||
"transfer(address,uint256)": classify_transfer,
|
||||
},
|
||||
classifications={
|
||||
"transferFrom(address,address,uint256)": Classification.transfer,
|
||||
"transfer(address,uint256)": Classification.transfer,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
WETH_CLASSIFIER_SPECS = [WETH_SPEC]
|
||||
|
@ -1,7 +1,5 @@
|
||||
from mev_inspect.schemas.classified_traces import (
|
||||
ClassifierSpec,
|
||||
Protocol,
|
||||
)
|
||||
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||
from mev_inspect.schemas.classified_traces import Protocol
|
||||
|
||||
|
||||
ZEROX_CONTRACT_SPECS = [
|
||||
|
@ -1,8 +1,6 @@
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .blocks import Trace
|
||||
|
||||
|
||||
@ -64,10 +62,3 @@ class DecodedCallTrace(CallTrace):
|
||||
gas_used: Optional[int]
|
||||
function_name: Optional[str]
|
||||
function_signature: Optional[str]
|
||||
|
||||
|
||||
class ClassifierSpec(BaseModel):
|
||||
abi_name: str
|
||||
protocol: Optional[Protocol] = None
|
||||
valid_contract_addresses: Optional[List[str]] = None
|
||||
classifications: Dict[str, Classification] = {}
|
||||
|
17
mev_inspect/schemas/classifier_specs.py
Normal file
17
mev_inspect/schemas/classifier_specs.py
Normal file
@ -0,0 +1,17 @@
|
||||
from typing import Callable, Dict, List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .classified_traces import Classification, DecodedCallTrace, Protocol
|
||||
from .transfers import ERC20Transfer
|
||||
|
||||
|
||||
TransferClassifier = Callable[[DecodedCallTrace], Optional[ERC20Transfer]]
|
||||
|
||||
|
||||
class ClassifierSpec(BaseModel):
|
||||
abi_name: str
|
||||
protocol: Optional[Protocol] = None
|
||||
valid_contract_addresses: Optional[List[str]] = None
|
||||
classifications: Dict[str, Classification] = {}
|
||||
transfer_classifiers: Dict[str, TransferClassifier] = {}
|
Loading…
x
Reference in New Issue
Block a user