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 (
|
from mev_inspect.schemas.classified_traces import (
|
||||||
Classification,
|
Classification,
|
||||||
ClassifierSpec,
|
|
||||||
Protocol,
|
Protocol,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||||
from mev_inspect.schemas.classified_traces import (
|
from mev_inspect.schemas.classified_traces import (
|
||||||
Classification,
|
Classification,
|
||||||
ClassifierSpec,
|
|
||||||
Protocol,
|
Protocol,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||||
from mev_inspect.schemas.classified_traces import (
|
from mev_inspect.schemas.classified_traces import (
|
||||||
ClassifierSpec,
|
|
||||||
Protocol,
|
Protocol,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,15 +1,34 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||||
from mev_inspect.schemas.classified_traces import (
|
from mev_inspect.schemas.classified_traces import (
|
||||||
Classification,
|
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(
|
ERC20_SPEC = ClassifierSpec(
|
||||||
abi_name="ERC20",
|
abi_name="ERC20",
|
||||||
|
transfer_classifiers={
|
||||||
|
"transferFrom(address,address,uint256)": classify_transfer,
|
||||||
|
"transfer(address,uint256)": classify_transfer,
|
||||||
|
},
|
||||||
classifications={
|
classifications={
|
||||||
"transferFrom(address,address,uint256)": Classification.transfer,
|
"transferFrom(address,address,uint256)": Classification.transfer,
|
||||||
"transfer(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 (
|
from mev_inspect.schemas.classified_traces import (
|
||||||
Classification,
|
Classification,
|
||||||
ClassifierSpec,
|
|
||||||
Protocol,
|
Protocol,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,17 +1,39 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||||
from mev_inspect.schemas.classified_traces import (
|
from mev_inspect.schemas.classified_traces import (
|
||||||
Classification,
|
Classification,
|
||||||
ClassifierSpec,
|
DecodedCallTrace,
|
||||||
Protocol,
|
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(
|
WETH_SPEC = ClassifierSpec(
|
||||||
abi_name="WETH9",
|
abi_name="WETH9",
|
||||||
protocol=Protocol.weth,
|
protocol=Protocol.weth,
|
||||||
valid_contract_addresses=["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"],
|
valid_contract_addresses=["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"],
|
||||||
|
transfer_classifiers={
|
||||||
|
"transferFrom(address,address,uint256)": classify_transfer,
|
||||||
|
"transfer(address,uint256)": classify_transfer,
|
||||||
|
},
|
||||||
classifications={
|
classifications={
|
||||||
"transferFrom(address,address,uint256)": Classification.transfer,
|
"transferFrom(address,address,uint256)": Classification.transfer,
|
||||||
"transfer(address,uint256)": Classification.transfer,
|
"transfer(address,uint256)": Classification.transfer,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
WETH_CLASSIFIER_SPECS = [WETH_SPEC]
|
WETH_CLASSIFIER_SPECS = [WETH_SPEC]
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
from mev_inspect.schemas.classified_traces import (
|
from mev_inspect.schemas.classifier_specs import ClassifierSpec
|
||||||
ClassifierSpec,
|
from mev_inspect.schemas.classified_traces import Protocol
|
||||||
Protocol,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
ZEROX_CONTRACT_SPECS = [
|
ZEROX_CONTRACT_SPECS = [
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from .blocks import Trace
|
from .blocks import Trace
|
||||||
|
|
||||||
|
|
||||||
@ -64,10 +62,3 @@ class DecodedCallTrace(CallTrace):
|
|||||||
gas_used: Optional[int]
|
gas_used: Optional[int]
|
||||||
function_name: Optional[str]
|
function_name: Optional[str]
|
||||||
function_signature: 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