Compare commits
2 Commits
main
...
yaz.opense
Author | SHA1 | Date | |
---|---|---|---|
|
ed01811987 | ||
|
3663d075d9 |
18
mev_inspect/classifiers/specs/opensea.py
Normal file
18
mev_inspect/classifiers/specs/opensea.py
Normal file
@ -0,0 +1,18 @@
|
||||
from mev_inspect.schemas.classified_traces import (
|
||||
DecodedCallTrace,
|
||||
Protocol,
|
||||
)
|
||||
from mev_inspect.schemas.classifiers import (
|
||||
ClassifierSpec,
|
||||
AtomicMatchClassifier,
|
||||
)
|
||||
|
||||
OPENSEA_ATOMIC_MATCH_ABI_NAME='atomicMatch_'
|
||||
|
||||
OPENSEA_SPEC = [
|
||||
ClassifierSpec(
|
||||
abi_name="atomicMatch_",
|
||||
protocol=Protocol.opensea,
|
||||
valid_contract_addresses=["0x7be8076f4ea4a4ad08075c2508e481d6c946d12b"],
|
||||
),
|
||||
]
|
26
mev_inspect/crud/atomicmatch.py
Normal file
26
mev_inspect/crud/atomicmatch.py
Normal file
@ -0,0 +1,26 @@
|
||||
import json
|
||||
from typing import list
|
||||
|
||||
from mev_inspect.models.atomicmatch import AtomicMatchModel
|
||||
from mev_inspect.schemas.atomicmatch import AtomicMatch
|
||||
|
||||
def delete_atomicmatch_for_block(
|
||||
db_session,
|
||||
block_number: int,
|
||||
) -> None:
|
||||
(
|
||||
db_session.query(AtomicMatchModel)
|
||||
.filter(AtomicMatchModel.block_number == block_number)
|
||||
.delete()
|
||||
)
|
||||
|
||||
db_session.commit()
|
||||
|
||||
def write_atomicmatch(
|
||||
db_session,
|
||||
atomicmatches: List[AtomicMatch],
|
||||
) -> None:
|
||||
models = [AtomicMatchModel(**json.loads(atomicmatch.json())) for atomicmatch in atomicmatches]
|
||||
|
||||
db_session.bulk_save_objects(models)
|
||||
db_session.commit()
|
@ -24,6 +24,10 @@ from mev_inspect.crud.liquidations import (
|
||||
delete_liquidations_for_block,
|
||||
write_liquidations,
|
||||
)
|
||||
from mev_inspect.crud.atomicmatch import (
|
||||
delete_atomicmatch_for_block,
|
||||
write_atomicmatch,
|
||||
)
|
||||
from mev_inspect.miner_payments import get_miner_payments
|
||||
from mev_inspect.swaps import get_swaps
|
||||
from mev_inspect.transfers import get_transfers
|
||||
|
17
mev_inspect/models/atomicmatch.py
Normal file
17
mev_inspect/models/atomicmatch.py
Normal file
@ -0,0 +1,17 @@
|
||||
from sqlalchemy import Column, Numeric, String, Integer, ARRAY
|
||||
|
||||
from .base import Base
|
||||
|
||||
|
||||
class AtomicMatchModel(Base):
|
||||
__tablename__ = "atomic_match"
|
||||
|
||||
block_number = Column(Numeric, nullable=False)
|
||||
transaction_hash = Column(String, primary_key=True)
|
||||
protocol = Column(String, nullable=True)
|
||||
from_address = Column(String, nullable=False)
|
||||
to_address = Column(String, nullable=False)
|
||||
token_address = Column(String, nullable=False)
|
||||
amount = Column(Numeric, nullable=False)
|
||||
metadata = Column(ARRAY(String), nullable=False)
|
||||
error = Column(String, nullable=True)
|
14
mev_inspect/schemas/atomicmatch.py
Normal file
14
mev_inspect/schemas/atomicmatch.py
Normal file
@ -0,0 +1,14 @@
|
||||
from typing import list
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
ETH_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
|
||||
|
||||
class AtomicMatch(BaseModel):
|
||||
block_number: int
|
||||
transaction_hash: str
|
||||
protocol: str
|
||||
from_address: str
|
||||
to_address: str
|
||||
amount: str
|
||||
metadata: List[str]
|
@ -10,6 +10,7 @@ class Classification(Enum):
|
||||
transfer = "transfer"
|
||||
liquidate = "liquidate"
|
||||
seize = "seize"
|
||||
atomicmatch = "atomicmatch"
|
||||
|
||||
|
||||
class Protocol(Enum):
|
||||
@ -22,6 +23,7 @@ class Protocol(Enum):
|
||||
zero_ex = "0x"
|
||||
balancer_v1 = "balancer_v1"
|
||||
compound_v2 = "compound_v2"
|
||||
opensea = "opensea"
|
||||
|
||||
|
||||
class ClassifiedTrace(Trace):
|
||||
|
@ -41,6 +41,10 @@ class LiquidationClassifier(Classifier):
|
||||
def get_classification() -> Classification:
|
||||
return Classification.liquidate
|
||||
|
||||
class AtomicMatchClassifier(Classifier):
|
||||
@staticmethod
|
||||
def get_classification() -> Classification:
|
||||
return Classification.atomicmatch
|
||||
|
||||
class SeizeClassifier(Classifier):
|
||||
@staticmethod
|
||||
|
Loading…
x
Reference in New Issue
Block a user