Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5912a3de1 | ||
|
|
4dd1337c21 | ||
|
|
5fa7c6b567 | ||
|
|
b9544eb18b | ||
|
|
c23b9a1651 | ||
|
|
94a05d8845 | ||
|
|
8b6bf7d76d | ||
|
|
2c251fb72e | ||
|
|
bda96b04ce | ||
|
|
bd73820123 | ||
|
|
7bc820fb33 | ||
|
|
4b909ad88e | ||
|
|
2ec2bf44ba | ||
|
|
ccd409e9cf | ||
|
|
138b1a0eef | ||
|
|
d62d547da1 | ||
|
|
9ffe9fe131 | ||
|
|
c6eba733a0 | ||
|
|
c853cee43e | ||
|
|
e84d946ebb | ||
|
|
2046cd2e51 | ||
|
|
bb23fce13c | ||
|
|
5d7d84aa02 | ||
|
|
767cf2df8f | ||
|
|
d5f73b5e3a | ||
|
|
bc46c2929b |
@@ -2,8 +2,15 @@ repos:
|
|||||||
- repo: https://github.com/ambv/black
|
- repo: https://github.com/ambv/black
|
||||||
rev: 20.8b1
|
rev: 20.8b1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3.9
|
language_version: python3.9
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
name: isort
|
||||||
|
entry: poetry run isort .
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: pylint
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ int-import-graph=
|
|||||||
known-standard-library=
|
known-standard-library=
|
||||||
|
|
||||||
# Force import order to recognize a module as part of a third party library.
|
# Force import order to recognize a module as part of a third party library.
|
||||||
known-third-party=enchant
|
known-third-party=alembic
|
||||||
|
|
||||||
# Couples of modules and preferred modules, separated by a comma.
|
# Couples of modules and preferred modules, separated by a comma.
|
||||||
preferred-modules=
|
preferred-modules=
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
from sqlalchemy import engine_from_config
|
|
||||||
from sqlalchemy import pool
|
|
||||||
|
|
||||||
from alembic import context
|
from alembic import context
|
||||||
|
from sqlalchemy import engine_from_config, pool
|
||||||
|
|
||||||
from mev_inspect.db import get_inspect_database_uri
|
from mev_inspect.db import get_inspect_database_uri
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Create Date: 2021-11-02 22:42:01.702538
|
|||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "04a3bb3740c3"
|
revision = "04a3bb3740c3"
|
||||||
down_revision = "a10d68643476"
|
down_revision = "a10d68643476"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-11-26 15:31:21.111693
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "04b76ab1d2af"
|
revision = "04b76ab1d2af"
|
||||||
down_revision = "0cef835f7b36"
|
down_revision = "0cef835f7b36"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-11-26 18:25:13.402822
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "d498bdb0a641"
|
revision = "d498bdb0a641"
|
||||||
down_revision = "b9fa1ecc9929"
|
down_revision = "b9fa1ecc9929"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-08-30 17:42:25.548130
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "083978d6e455"
|
revision = "083978d6e455"
|
||||||
down_revision = "92f28a2b4f52"
|
down_revision = "92f28a2b4f52"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Create Date: 2021-11-19 15:36:15.152622
|
|||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "0cef835f7b36"
|
revision = "0cef835f7b36"
|
||||||
down_revision = "5427d62a2cc0"
|
down_revision = "5427d62a2cc0"
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
"""Add nullable transaction_position field to swaps and traces
|
||||||
|
|
||||||
|
Revision ID: 15ba9c27ee8a
|
||||||
|
Revises: 04b76ab1d2af
|
||||||
|
Create Date: 2021-12-02 18:24:18.218880
|
||||||
|
|
||||||
|
"""
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "15ba9c27ee8a"
|
||||||
|
down_revision = "ead7eb8283b9"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.add_column(
|
||||||
|
"classified_traces",
|
||||||
|
sa.Column("transaction_position", sa.Numeric, nullable=True),
|
||||||
|
)
|
||||||
|
op.add_column("swaps", sa.Column("transaction_position", sa.Numeric, nullable=True))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_column("classified_traces", "transaction_position")
|
||||||
|
op.drop_column("swaps", "transaction_position")
|
||||||
@@ -8,7 +8,6 @@ Create Date: 2021-10-04 19:52:40.017084
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "205ce02374b3"
|
revision = "205ce02374b3"
|
||||||
down_revision = "c8363617aa07"
|
down_revision = "c8363617aa07"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-11-17 18:29:13.065944
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "2c90b2b8a80b"
|
revision = "2c90b2b8a80b"
|
||||||
down_revision = "04a3bb3740c3"
|
down_revision = "04a3bb3740c3"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Create Date: 2021-09-14 11:11:41.559137
|
|||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "320e56b0a99f"
|
revision = "320e56b0a99f"
|
||||||
down_revision = "a02f3f2c469f"
|
down_revision = "a02f3f2c469f"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Create Date: 2021-11-02 20:50:32.854996
|
|||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "3417f49d97b3"
|
revision = "3417f49d97b3"
|
||||||
down_revision = "205ce02374b3"
|
down_revision = "205ce02374b3"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-11-26 20:35:58.954138
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "52d75a7e0533"
|
revision = "52d75a7e0533"
|
||||||
down_revision = "7cf0eeb41da0"
|
down_revision = "7cf0eeb41da0"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-11-19 13:25:11.252774
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "5427d62a2cc0"
|
revision = "5427d62a2cc0"
|
||||||
down_revision = "d540242ae368"
|
down_revision = "d540242ae368"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-11-26 20:27:28.936516
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "7cf0eeb41da0"
|
revision = "7cf0eeb41da0"
|
||||||
down_revision = "d498bdb0a641"
|
down_revision = "d498bdb0a641"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-08-06 15:58:04.556762
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "7eec417a4f3e"
|
revision = "7eec417a4f3e"
|
||||||
down_revision = "9d8c69b3dccb"
|
down_revision = "9d8c69b3dccb"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-08-17 03:46:21.498821
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "92f28a2b4f52"
|
revision = "92f28a2b4f52"
|
||||||
down_revision = "9b8ae51c5d56"
|
down_revision = "9b8ae51c5d56"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-08-06 17:06:55.364516
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "9b8ae51c5d56"
|
revision = "9b8ae51c5d56"
|
||||||
down_revision = "7eec417a4f3e"
|
down_revision = "7eec417a4f3e"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-08-05 21:46:35.209199
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "9d8c69b3dccb"
|
revision = "9d8c69b3dccb"
|
||||||
down_revision = "2116e2f36a19"
|
down_revision = "2116e2f36a19"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-09-13 21:32:27.181344
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "a02f3f2c469f"
|
revision = "a02f3f2c469f"
|
||||||
down_revision = "d70c08b4db6f"
|
down_revision = "d70c08b4db6f"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Create Date: 2021-11-02 22:03:26.312317
|
|||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "a10d68643476"
|
revision = "a10d68643476"
|
||||||
down_revision = "3417f49d97b3"
|
down_revision = "3417f49d97b3"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-12-01 23:32:40.574108
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "b9fa1ecc9929"
|
revision = "b9fa1ecc9929"
|
||||||
down_revision = "04b76ab1d2af"
|
down_revision = "04b76ab1d2af"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Create Date: 2021-07-30 17:37:27.335475
|
|||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "c5da44eb072c"
|
revision = "c5da44eb072c"
|
||||||
down_revision = "0660432b9840"
|
down_revision = "0660432b9840"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-09-29 14:00:06.857103
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "c8363617aa07"
|
revision = "c8363617aa07"
|
||||||
down_revision = "cd96af55108e"
|
down_revision = "cd96af55108e"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-09-17 12:44:45.245137
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "cd96af55108e"
|
revision = "cd96af55108e"
|
||||||
down_revision = "320e56b0a99f"
|
down_revision = "320e56b0a99f"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-11-18 04:30:06.802857
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "d540242ae368"
|
revision = "d540242ae368"
|
||||||
down_revision = "2c90b2b8a80b"
|
down_revision = "2c90b2b8a80b"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ Create Date: 2021-08-30 22:10:04.186251
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = "d70c08b4db6f"
|
revision = "d70c08b4db6f"
|
||||||
down_revision = "083978d6e455"
|
down_revision = "083978d6e455"
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
"""Create sandwiches and sandwiched swaps tables
|
||||||
|
|
||||||
|
Revision ID: ead7eb8283b9
|
||||||
|
Revises: a5d80460f0e6
|
||||||
|
Create Date: 2021-12-03 16:37:28.077158
|
||||||
|
|
||||||
|
"""
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "ead7eb8283b9"
|
||||||
|
down_revision = "52d75a7e0533"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
"sandwiches",
|
||||||
|
sa.Column("id", sa.String(256), primary_key=True),
|
||||||
|
sa.Column("created_at", sa.TIMESTAMP, server_default=sa.func.now()),
|
||||||
|
sa.Column("block_number", sa.Numeric, nullable=False),
|
||||||
|
sa.Column("sandwicher_address", sa.String(256), nullable=False),
|
||||||
|
sa.Column("frontrun_swap_transaction_hash", sa.String(256), nullable=False),
|
||||||
|
sa.Column("frontrun_swap_trace_address", sa.ARRAY(sa.Integer), nullable=False),
|
||||||
|
sa.Column("backrun_swap_transaction_hash", sa.String(256), nullable=False),
|
||||||
|
sa.Column("backrun_swap_trace_address", sa.ARRAY(sa.Integer), nullable=False),
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_index(
|
||||||
|
"ik_sandwiches_frontrun",
|
||||||
|
"sandwiches",
|
||||||
|
[
|
||||||
|
"block_number",
|
||||||
|
"frontrun_swap_transaction_hash",
|
||||||
|
"frontrun_swap_trace_address",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_index(
|
||||||
|
"ik_sandwiches_backrun",
|
||||||
|
"sandwiches",
|
||||||
|
["block_number", "backrun_swap_transaction_hash", "backrun_swap_trace_address"],
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
"sandwiched_swaps",
|
||||||
|
sa.Column("created_at", sa.TIMESTAMP, server_default=sa.func.now()),
|
||||||
|
sa.Column("sandwich_id", sa.String(1024), primary_key=True),
|
||||||
|
sa.Column("block_number", sa.Numeric, primary_key=True),
|
||||||
|
sa.Column("transaction_hash", sa.String(66), primary_key=True),
|
||||||
|
sa.Column("trace_address", sa.ARRAY(sa.Integer), primary_key=True),
|
||||||
|
sa.ForeignKeyConstraint(["sandwich_id"], ["sandwiches.id"], ondelete="CASCADE"),
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_index(
|
||||||
|
"ik_sandwiched_swaps_secondary",
|
||||||
|
"sandwiched_swaps",
|
||||||
|
["block_number", "transaction_hash", "trace_address"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_index("ik_sandwiched_swaps_secondary")
|
||||||
|
op.drop_table("sandwiched_swaps")
|
||||||
|
op.drop_index("ik_sandwiches_frontrun")
|
||||||
|
op.drop_index("ik_sandwiches_backrun")
|
||||||
|
op.drop_table("sandwiches")
|
||||||
@@ -15,7 +15,6 @@ from mev_inspect.inspector import MEVInspector
|
|||||||
from mev_inspect.provider import get_base_provider
|
from mev_inspect.provider import get_base_provider
|
||||||
from mev_inspect.signal_handler import GracefulKiller
|
from mev_inspect.signal_handler import GracefulKiller
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(filename="listener.log", filemode="a", level=logging.INFO)
|
logging.basicConfig(filename="listener.log", filemode="a", level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
1
loop.py
1
loop.py
@@ -3,7 +3,6 @@ import time
|
|||||||
|
|
||||||
from mev_inspect.signal_handler import GracefulKiller
|
from mev_inspect.signal_handler import GracefulKiller
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(filename="loop.log", level=logging.INFO)
|
logging.basicConfig(filename="loop.log", level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
3
mev
3
mev
@@ -48,8 +48,9 @@ case "$1" in
|
|||||||
poetry run inspect-many-blocks $start_block_number $end_block_number
|
poetry run inspect-many-blocks $start_block_number $end_block_number
|
||||||
;;
|
;;
|
||||||
test)
|
test)
|
||||||
|
shift
|
||||||
echo "Running tests"
|
echo "Running tests"
|
||||||
kubectl exec -ti deploy/mev-inspect -- poetry run pytest tests
|
kubectl exec -ti deploy/mev-inspect -- poetry run pytest tests $@
|
||||||
;;
|
;;
|
||||||
fetch)
|
fetch)
|
||||||
block_number=$2
|
block_number=$2
|
||||||
|
|||||||
@@ -1,21 +1,16 @@
|
|||||||
from typing import List, Tuple, Optional
|
from typing import List, Optional, Tuple
|
||||||
|
|
||||||
from mev_inspect.traces import (
|
from mev_inspect.schemas.liquidations import Liquidation
|
||||||
get_child_traces,
|
|
||||||
is_child_of_any_address,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.traces import (
|
from mev_inspect.schemas.traces import (
|
||||||
ClassifiedTrace,
|
|
||||||
CallTrace,
|
CallTrace,
|
||||||
DecodedCallTrace,
|
|
||||||
Classification,
|
Classification,
|
||||||
|
ClassifiedTrace,
|
||||||
|
DecodedCallTrace,
|
||||||
Protocol,
|
Protocol,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
from mev_inspect.transfers import get_transfer
|
|
||||||
from mev_inspect.schemas.transfers import Transfer
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
from mev_inspect.schemas.liquidations import Liquidation
|
from mev_inspect.traces import get_child_traces, is_child_of_any_address
|
||||||
|
from mev_inspect.transfers import get_transfer
|
||||||
|
|
||||||
AAVE_CONTRACT_ADDRESSES: List[str] = [
|
AAVE_CONTRACT_ADDRESSES: List[str] = [
|
||||||
# AAVE Proxy
|
# AAVE Proxy
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from pydantic import parse_obj_as
|
|||||||
from mev_inspect.schemas.abi import ABI
|
from mev_inspect.schemas.abi import ABI
|
||||||
from mev_inspect.schemas.traces import Protocol
|
from mev_inspect.schemas.traces import Protocol
|
||||||
|
|
||||||
|
|
||||||
THIS_FILE_DIRECTORY = Path(__file__).parents[0]
|
THIS_FILE_DIRECTORY = Path(__file__).parents[0]
|
||||||
ABI_DIRECTORY_PATH = THIS_FILE_DIRECTORY / "abis"
|
ABI_DIRECTORY_PATH = THIS_FILE_DIRECTORY / "abis"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from mev_inspect.schemas.receipts import Receipt
|
|||||||
from mev_inspect.schemas.traces import Trace, TraceType
|
from mev_inspect.schemas.traces import Trace, TraceType
|
||||||
from mev_inspect.utils import hex_to_int
|
from mev_inspect.utils import hex_to_int
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
from typing import Optional, List, Sequence
|
from typing import List, Optional, Sequence
|
||||||
|
|
||||||
from mev_inspect.schemas.swaps import Swap
|
from mev_inspect.schemas.swaps import Swap
|
||||||
from mev_inspect.schemas.transfers import Transfer, ETH_TOKEN_ADDRESS
|
from mev_inspect.schemas.traces import ClassifiedTrace, DecodedCallTrace
|
||||||
|
from mev_inspect.schemas.transfers import ETH_TOKEN_ADDRESS, Transfer
|
||||||
from mev_inspect.schemas.traces import DecodedCallTrace, ClassifiedTrace
|
|
||||||
|
|
||||||
|
|
||||||
def create_swap_from_pool_transfers(
|
def create_swap_from_pool_transfers(
|
||||||
@@ -41,6 +40,7 @@ def create_swap_from_pool_transfers(
|
|||||||
return Swap(
|
return Swap(
|
||||||
abi_name=trace.abi_name,
|
abi_name=trace.abi_name,
|
||||||
transaction_hash=trace.transaction_hash,
|
transaction_hash=trace.transaction_hash,
|
||||||
|
transaction_position=trace.transaction_position,
|
||||||
block_number=trace.block_number,
|
block_number=trace.block_number,
|
||||||
trace_address=trace.trace_address,
|
trace_address=trace.trace_address,
|
||||||
contract_address=pool_address,
|
contract_address=pool_address,
|
||||||
@@ -78,6 +78,7 @@ def create_swap_from_recipient_transfers(
|
|||||||
return Swap(
|
return Swap(
|
||||||
abi_name=trace.abi_name,
|
abi_name=trace.abi_name,
|
||||||
transaction_hash=trace.transaction_hash,
|
transaction_hash=trace.transaction_hash,
|
||||||
|
transaction_position=trace.transaction_position,
|
||||||
block_number=trace.block_number,
|
block_number=trace.block_number,
|
||||||
trace_address=trace.trace_address,
|
trace_address=trace.trace_address,
|
||||||
contract_address=pool_address,
|
contract_address=pool_address,
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
from typing import Dict, Optional, Tuple, Type
|
from typing import Dict, Optional, Tuple, Type
|
||||||
|
|
||||||
|
from mev_inspect.schemas.classifiers import Classifier, ClassifierSpec
|
||||||
from mev_inspect.schemas.traces import DecodedCallTrace, Protocol
|
from mev_inspect.schemas.traces import DecodedCallTrace, Protocol
|
||||||
from mev_inspect.schemas.classifiers import ClassifierSpec, Classifier
|
|
||||||
|
|
||||||
from .aave import AAVE_CLASSIFIER_SPECS
|
from .aave import AAVE_CLASSIFIER_SPECS
|
||||||
|
from .balancer import BALANCER_CLASSIFIER_SPECS
|
||||||
|
from .bancor import BANCOR_CLASSIFIER_SPECS
|
||||||
|
from .compound import COMPOUND_CLASSIFIER_SPECS
|
||||||
|
from .cryptopunks import CRYPTOPUNKS_CLASSIFIER_SPECS
|
||||||
from .curve import CURVE_CLASSIFIER_SPECS
|
from .curve import CURVE_CLASSIFIER_SPECS
|
||||||
from .erc20 import ERC20_CLASSIFIER_SPECS
|
from .erc20 import ERC20_CLASSIFIER_SPECS
|
||||||
from .uniswap import UNISWAP_CLASSIFIER_SPECS
|
from .uniswap import UNISWAP_CLASSIFIER_SPECS
|
||||||
from .weth import WETH_CLASSIFIER_SPECS, WETH_ADDRESS
|
from .weth import WETH_ADDRESS, WETH_CLASSIFIER_SPECS
|
||||||
from .zero_ex import ZEROX_CLASSIFIER_SPECS
|
from .zero_ex import ZEROX_CLASSIFIER_SPECS
|
||||||
from .balancer import BALANCER_CLASSIFIER_SPECS
|
|
||||||
from .compound import COMPOUND_CLASSIFIER_SPECS
|
|
||||||
from .cryptopunks import CRYPTOPUNKS_CLASSIFIER_SPECS
|
|
||||||
from .bancor import BANCOR_CLASSIFIER_SPECS
|
|
||||||
|
|
||||||
ALL_CLASSIFIER_SPECS = (
|
ALL_CLASSIFIER_SPECS = (
|
||||||
ERC20_CLASSIFIER_SPECS
|
ERC20_CLASSIFIER_SPECS
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
from mev_inspect.schemas.classifiers import (
|
from mev_inspect.schemas.classifiers import (
|
||||||
ClassifierSpec,
|
ClassifierSpec,
|
||||||
DecodedCallTrace,
|
DecodedCallTrace,
|
||||||
TransferClassifier,
|
|
||||||
LiquidationClassifier,
|
LiquidationClassifier,
|
||||||
|
TransferClassifier,
|
||||||
)
|
)
|
||||||
from mev_inspect.schemas.traces import Protocol
|
from mev_inspect.schemas.traces import Protocol
|
||||||
from mev_inspect.schemas.transfers import Transfer
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
from typing import Optional, List
|
from typing import List, Optional
|
||||||
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.helpers import create_swap_from_pool_transfers
|
from mev_inspect.classifiers.helpers import create_swap_from_pool_transfers
|
||||||
|
from mev_inspect.schemas.classifiers import ClassifierSpec, SwapClassifier
|
||||||
|
from mev_inspect.schemas.swaps import Swap
|
||||||
|
from mev_inspect.schemas.traces import DecodedCallTrace, Protocol
|
||||||
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
|
|
||||||
BALANCER_V1_POOL_ABI_NAME = "BPool"
|
BALANCER_V1_POOL_ABI_NAME = "BPool"
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
from typing import Optional, List
|
from typing import List, Optional
|
||||||
from mev_inspect.schemas.transfers import Transfer
|
|
||||||
|
from mev_inspect.classifiers.helpers import create_swap_from_recipient_transfers
|
||||||
|
from mev_inspect.schemas.classifiers import ClassifierSpec, SwapClassifier
|
||||||
from mev_inspect.schemas.swaps import Swap
|
from mev_inspect.schemas.swaps import Swap
|
||||||
from mev_inspect.schemas.traces import (
|
from mev_inspect.schemas.traces import DecodedCallTrace, Protocol
|
||||||
DecodedCallTrace,
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
Protocol,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.classifiers import (
|
|
||||||
ClassifierSpec,
|
|
||||||
SwapClassifier,
|
|
||||||
)
|
|
||||||
from mev_inspect.classifiers.helpers import (
|
|
||||||
create_swap_from_recipient_transfers,
|
|
||||||
)
|
|
||||||
|
|
||||||
BANCOR_NETWORK_ABI_NAME = "BancorNetwork"
|
BANCOR_NETWORK_ABI_NAME = "BancorNetwork"
|
||||||
BANCOR_NETWORK_CONTRACT_ADDRESS = "0x2F9EC37d6CcFFf1caB21733BdaDEdE11c823cCB0"
|
BANCOR_NETWORK_CONTRACT_ADDRESS = "0x2F9EC37d6CcFFf1caB21733BdaDEdE11c823cCB0"
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
from mev_inspect.schemas.traces import (
|
|
||||||
Protocol,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.classifiers import (
|
from mev_inspect.schemas.classifiers import (
|
||||||
ClassifierSpec,
|
ClassifierSpec,
|
||||||
LiquidationClassifier,
|
LiquidationClassifier,
|
||||||
SeizeClassifier,
|
SeizeClassifier,
|
||||||
)
|
)
|
||||||
|
from mev_inspect.schemas.traces import Protocol
|
||||||
|
|
||||||
COMPOUND_V2_CETH_SPEC = ClassifierSpec(
|
COMPOUND_V2_CETH_SPEC = ClassifierSpec(
|
||||||
abi_name="CEther",
|
abi_name="CEther",
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
from mev_inspect.schemas.traces import Protocol, Classification
|
from mev_inspect.schemas.classifiers import Classifier, ClassifierSpec
|
||||||
|
from mev_inspect.schemas.traces import Classification, Protocol
|
||||||
from mev_inspect.schemas.classifiers import (
|
|
||||||
ClassifierSpec,
|
|
||||||
Classifier,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PunkBidAcceptanceClassifier(Classifier):
|
class PunkBidAcceptanceClassifier(Classifier):
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
from typing import Optional, List
|
from typing import List, Optional
|
||||||
from mev_inspect.schemas.transfers import Transfer
|
|
||||||
from mev_inspect.schemas.swaps import Swap
|
|
||||||
from mev_inspect.schemas.traces import (
|
|
||||||
Protocol,
|
|
||||||
DecodedCallTrace,
|
|
||||||
)
|
|
||||||
|
|
||||||
from mev_inspect.schemas.classifiers import (
|
|
||||||
ClassifierSpec,
|
|
||||||
SwapClassifier,
|
|
||||||
)
|
|
||||||
from mev_inspect.classifiers.helpers import create_swap_from_pool_transfers
|
from mev_inspect.classifiers.helpers import create_swap_from_pool_transfers
|
||||||
|
from mev_inspect.schemas.classifiers import ClassifierSpec, SwapClassifier
|
||||||
|
from mev_inspect.schemas.swaps import Swap
|
||||||
|
from mev_inspect.schemas.traces import DecodedCallTrace, Protocol
|
||||||
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
|
|
||||||
|
|
||||||
class CurveSwapClassifier(SwapClassifier):
|
class CurveSwapClassifier(SwapClassifier):
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
|
from mev_inspect.schemas.classifiers import ClassifierSpec, TransferClassifier
|
||||||
from mev_inspect.schemas.traces import DecodedCallTrace
|
from mev_inspect.schemas.traces import DecodedCallTrace
|
||||||
from mev_inspect.schemas.classifiers import (
|
|
||||||
ClassifierSpec,
|
|
||||||
TransferClassifier,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.transfers import Transfer
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
from typing import Optional, List
|
from typing import List, Optional
|
||||||
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.helpers import create_swap_from_pool_transfers
|
|
||||||
|
|
||||||
|
from mev_inspect.classifiers.helpers import create_swap_from_pool_transfers
|
||||||
|
from mev_inspect.schemas.classifiers import ClassifierSpec, SwapClassifier
|
||||||
|
from mev_inspect.schemas.swaps import Swap
|
||||||
|
from mev_inspect.schemas.traces import DecodedCallTrace, Protocol
|
||||||
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
|
|
||||||
UNISWAP_V2_PAIR_ABI_NAME = "UniswapV2Pair"
|
UNISWAP_V2_PAIR_ABI_NAME = "UniswapV2Pair"
|
||||||
UNISWAP_V3_POOL_ABI_NAME = "UniswapV3Pool"
|
UNISWAP_V3_POOL_ABI_NAME = "UniswapV3Pool"
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
from mev_inspect.schemas.traces import (
|
|
||||||
Protocol,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.classifiers import (
|
from mev_inspect.schemas.classifiers import (
|
||||||
ClassifierSpec,
|
ClassifierSpec,
|
||||||
DecodedCallTrace,
|
DecodedCallTrace,
|
||||||
TransferClassifier,
|
TransferClassifier,
|
||||||
)
|
)
|
||||||
|
from mev_inspect.schemas.traces import Protocol
|
||||||
from mev_inspect.schemas.transfers import Transfer
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
from typing import Optional, List, Tuple
|
from typing import List, Optional, Tuple
|
||||||
from mev_inspect.schemas.transfers import Transfer
|
|
||||||
|
from mev_inspect.schemas.classifiers import ClassifierSpec, SwapClassifier
|
||||||
from mev_inspect.schemas.swaps import Swap
|
from mev_inspect.schemas.swaps import Swap
|
||||||
from mev_inspect.schemas.traces import (
|
from mev_inspect.schemas.traces import DecodedCallTrace, Protocol
|
||||||
DecodedCallTrace,
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
Protocol,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.classifiers import (
|
|
||||||
ClassifierSpec,
|
|
||||||
SwapClassifier,
|
|
||||||
)
|
|
||||||
|
|
||||||
ANY_TAKER_ADDRESS = "0x0000000000000000000000000000000000000000"
|
ANY_TAKER_ADDRESS = "0x0000000000000000000000000000000000000000"
|
||||||
|
|
||||||
@@ -40,6 +35,7 @@ class ZeroExSwapClassifier(SwapClassifier):
|
|||||||
return Swap(
|
return Swap(
|
||||||
abi_name=trace.abi_name,
|
abi_name=trace.abi_name,
|
||||||
transaction_hash=trace.transaction_hash,
|
transaction_hash=trace.transaction_hash,
|
||||||
|
transaction_position=trace.transaction_position,
|
||||||
block_number=trace.block_number,
|
block_number=trace.block_number,
|
||||||
trace_address=trace.trace_address,
|
trace_address=trace.trace_address,
|
||||||
contract_address=trace.to_address,
|
contract_address=trace.to_address,
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ from mev_inspect.abi import get_abi
|
|||||||
from mev_inspect.decode import ABIDecoder
|
from mev_inspect.decode import ABIDecoder
|
||||||
from mev_inspect.schemas.blocks import CallAction, CallResult
|
from mev_inspect.schemas.blocks import CallAction, CallResult
|
||||||
from mev_inspect.schemas.traces import (
|
from mev_inspect.schemas.traces import (
|
||||||
|
CallTrace,
|
||||||
Classification,
|
Classification,
|
||||||
ClassifiedTrace,
|
ClassifiedTrace,
|
||||||
CallTrace,
|
|
||||||
DecodedCallTrace,
|
DecodedCallTrace,
|
||||||
|
Trace,
|
||||||
|
TraceType,
|
||||||
)
|
)
|
||||||
from mev_inspect.schemas.traces import Trace, TraceType
|
|
||||||
|
|
||||||
from .specs import ALL_CLASSIFIER_SPECS
|
from .specs import ALL_CLASSIFIER_SPECS
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
from mev_inspect.classifiers.specs.weth import WETH_ADDRESS
|
from mev_inspect.classifiers.specs.weth import WETH_ADDRESS
|
||||||
from mev_inspect.schemas.transfers import ETH_TOKEN_ADDRESS
|
|
||||||
from mev_inspect.schemas.coinbase import CoinbasePrices, CoinbasePricesResponse
|
from mev_inspect.schemas.coinbase import CoinbasePrices, CoinbasePricesResponse
|
||||||
from mev_inspect.schemas.prices import (
|
from mev_inspect.schemas.prices import (
|
||||||
WBTC_TOKEN_ADDRESS,
|
|
||||||
LINK_TOKEN_ADDRESS,
|
|
||||||
YEARN_TOKEN_ADDRESS,
|
|
||||||
AAVE_TOKEN_ADDRESS,
|
AAVE_TOKEN_ADDRESS,
|
||||||
|
LINK_TOKEN_ADDRESS,
|
||||||
|
REN_TOKEN_ADDRESS,
|
||||||
UNI_TOKEN_ADDRESS,
|
UNI_TOKEN_ADDRESS,
|
||||||
USDC_TOKEN_ADDRESS_ADDRESS,
|
USDC_TOKEN_ADDRESS_ADDRESS,
|
||||||
REN_TOKEN_ADDRESS,
|
WBTC_TOKEN_ADDRESS,
|
||||||
|
YEARN_TOKEN_ADDRESS,
|
||||||
)
|
)
|
||||||
|
from mev_inspect.schemas.transfers import ETH_TOKEN_ADDRESS
|
||||||
|
|
||||||
COINBASE_API_BASE = "https://www.coinbase.com/api/v2"
|
COINBASE_API_BASE = "https://www.coinbase.com/api/v2"
|
||||||
COINBASE_TOKEN_NAME_BY_ADDRESS = {
|
COINBASE_TOKEN_NAME_BY_ADDRESS = {
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from mev_inspect.traces import get_child_traces
|
|
||||||
from mev_inspect.schemas.traces import (
|
|
||||||
ClassifiedTrace,
|
|
||||||
Classification,
|
|
||||||
Protocol,
|
|
||||||
)
|
|
||||||
|
|
||||||
from mev_inspect.schemas.liquidations import Liquidation
|
from mev_inspect.schemas.liquidations import Liquidation
|
||||||
|
from mev_inspect.schemas.traces import Classification, ClassifiedTrace, Protocol
|
||||||
|
from mev_inspect.traces import get_child_traces
|
||||||
|
|
||||||
V2_COMPTROLLER_ADDRESS = "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B"
|
V2_COMPTROLLER_ADDRESS = "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B"
|
||||||
V2_C_ETHER = "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5"
|
V2_C_ETHER = "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5"
|
||||||
@@ -49,6 +44,7 @@ def get_compound_liquidations(
|
|||||||
debt_purchase_amount=trace.value,
|
debt_purchase_amount=trace.value,
|
||||||
protocol=trace.protocol,
|
protocol=trace.protocol,
|
||||||
received_amount=seize_trace.inputs["seizeTokens"],
|
received_amount=seize_trace.inputs["seizeTokens"],
|
||||||
|
received_token_address=trace.to_address,
|
||||||
transaction_hash=trace.transaction_hash,
|
transaction_hash=trace.transaction_hash,
|
||||||
trace_address=trace.trace_address,
|
trace_address=trace.trace_address,
|
||||||
block_number=trace.block_number,
|
block_number=trace.block_number,
|
||||||
@@ -65,6 +61,7 @@ def get_compound_liquidations(
|
|||||||
debt_purchase_amount=trace.inputs["repayAmount"],
|
debt_purchase_amount=trace.inputs["repayAmount"],
|
||||||
protocol=trace.protocol,
|
protocol=trace.protocol,
|
||||||
received_amount=seize_trace.inputs["seizeTokens"],
|
received_amount=seize_trace.inputs["seizeTokens"],
|
||||||
|
received_token_address=trace.to_address,
|
||||||
transaction_hash=trace.transaction_hash,
|
transaction_hash=trace.transaction_hash,
|
||||||
trace_address=trace.trace_address,
|
trace_address=trace.trace_address,
|
||||||
block_number=trace.block_number,
|
block_number=trace.block_number,
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import json
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from mev_inspect.models.punks import (
|
from mev_inspect.models.punks import (
|
||||||
PunkSnipeModel,
|
|
||||||
PunkBidModel,
|
|
||||||
PunkBidAcceptanceModel,
|
PunkBidAcceptanceModel,
|
||||||
|
PunkBidModel,
|
||||||
|
PunkSnipeModel,
|
||||||
)
|
)
|
||||||
from mev_inspect.schemas.punk_snipe import PunkSnipe
|
|
||||||
from mev_inspect.schemas.punk_bid import PunkBid
|
|
||||||
from mev_inspect.schemas.punk_accept_bid import PunkBidAcceptance
|
from mev_inspect.schemas.punk_accept_bid import PunkBidAcceptance
|
||||||
|
from mev_inspect.schemas.punk_bid import PunkBid
|
||||||
|
from mev_inspect.schemas.punk_snipe import PunkSnipe
|
||||||
|
|
||||||
|
|
||||||
def delete_punk_bid_acceptances_for_block(
|
def delete_punk_bid_acceptances_for_block(
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ def write_classified_traces(
|
|||||||
models.append(
|
models.append(
|
||||||
ClassifiedTraceModel(
|
ClassifiedTraceModel(
|
||||||
transaction_hash=trace.transaction_hash,
|
transaction_hash=trace.transaction_hash,
|
||||||
|
transaction_position=trace.transaction_position,
|
||||||
block_number=trace.block_number,
|
block_number=trace.block_number,
|
||||||
classification=trace.classification.value,
|
classification=trace.classification.value,
|
||||||
trace_type=trace.type.value,
|
trace_type=trace.type.value,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
|
|
||||||
import eth_utils.abi
|
import eth_utils.abi
|
||||||
|
|
||||||
from eth_abi import decode_abi
|
from eth_abi import decode_abi
|
||||||
from eth_abi.exceptions import InsufficientDataBytes, NonEmptyPaddingBytes
|
from eth_abi.exceptions import InsufficientDataBytes, NonEmptyPaddingBytes
|
||||||
from hexbytes._utils import hexstr_to_bytes
|
from hexbytes._utils import hexstr_to_bytes
|
||||||
@@ -9,7 +8,6 @@ from hexbytes._utils import hexstr_to_bytes
|
|||||||
from mev_inspect.schemas.abi import ABI, ABIFunctionDescription
|
from mev_inspect.schemas.abi import ABI, ABIFunctionDescription
|
||||||
from mev_inspect.schemas.call_data import CallData
|
from mev_inspect.schemas.call_data import CallData
|
||||||
|
|
||||||
|
|
||||||
# 0x + 8 characters
|
# 0x + 8 characters
|
||||||
SELECTOR_LENGTH = 10
|
SELECTOR_LENGTH = 10
|
||||||
|
|
||||||
|
|||||||
@@ -7,45 +7,35 @@ from web3 import Web3
|
|||||||
from mev_inspect.arbitrages import get_arbitrages
|
from mev_inspect.arbitrages import get_arbitrages
|
||||||
from mev_inspect.block import create_from_block_number
|
from mev_inspect.block import create_from_block_number
|
||||||
from mev_inspect.classifiers.trace import TraceClassifier
|
from mev_inspect.classifiers.trace import TraceClassifier
|
||||||
from mev_inspect.crud.arbitrages import (
|
from mev_inspect.crud.arbitrages import delete_arbitrages_for_block, write_arbitrages
|
||||||
delete_arbitrages_for_block,
|
from mev_inspect.crud.blocks import delete_block, write_block
|
||||||
write_arbitrages,
|
from mev_inspect.crud.liquidations import (
|
||||||
)
|
delete_liquidations_for_block,
|
||||||
|
write_liquidations,
|
||||||
from mev_inspect.crud.punks import (
|
|
||||||
delete_punk_snipes_for_block,
|
|
||||||
write_punk_snipes,
|
|
||||||
delete_punk_bids_for_block,
|
|
||||||
write_punk_bids,
|
|
||||||
delete_punk_bid_acceptances_for_block,
|
|
||||||
write_punk_bid_acceptances,
|
|
||||||
)
|
|
||||||
|
|
||||||
from mev_inspect.crud.blocks import (
|
|
||||||
delete_block,
|
|
||||||
write_block,
|
|
||||||
)
|
|
||||||
from mev_inspect.crud.traces import (
|
|
||||||
delete_classified_traces_for_block,
|
|
||||||
write_classified_traces,
|
|
||||||
)
|
)
|
||||||
from mev_inspect.crud.miner_payments import (
|
from mev_inspect.crud.miner_payments import (
|
||||||
delete_miner_payments_for_block,
|
delete_miner_payments_for_block,
|
||||||
write_miner_payments,
|
write_miner_payments,
|
||||||
)
|
)
|
||||||
|
from mev_inspect.crud.punks import (
|
||||||
from mev_inspect.crud.swaps import delete_swaps_for_block, write_swaps
|
delete_punk_bid_acceptances_for_block,
|
||||||
from mev_inspect.crud.transfers import delete_transfers_for_block, write_transfers
|
delete_punk_bids_for_block,
|
||||||
from mev_inspect.crud.liquidations import (
|
delete_punk_snipes_for_block,
|
||||||
delete_liquidations_for_block,
|
write_punk_bid_acceptances,
|
||||||
write_liquidations,
|
write_punk_bids,
|
||||||
|
write_punk_snipes,
|
||||||
)
|
)
|
||||||
|
from mev_inspect.crud.swaps import delete_swaps_for_block, write_swaps
|
||||||
|
from mev_inspect.crud.traces import (
|
||||||
|
delete_classified_traces_for_block,
|
||||||
|
write_classified_traces,
|
||||||
|
)
|
||||||
|
from mev_inspect.crud.transfers import delete_transfers_for_block, write_transfers
|
||||||
|
from mev_inspect.liquidations import get_liquidations
|
||||||
from mev_inspect.miner_payments import get_miner_payments
|
from mev_inspect.miner_payments import get_miner_payments
|
||||||
from mev_inspect.punks import get_punk_bid_acceptances, get_punk_bids, get_punk_snipes
|
from mev_inspect.punks import get_punk_bid_acceptances, get_punk_bids, get_punk_snipes
|
||||||
from mev_inspect.swaps import get_swaps
|
from mev_inspect.swaps import get_swaps
|
||||||
from mev_inspect.transfers import get_transfers
|
from mev_inspect.transfers import get_transfers
|
||||||
from mev_inspect.liquidations import get_liquidations
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,8 @@ from typing import List
|
|||||||
|
|
||||||
from mev_inspect.aave_liquidations import get_aave_liquidations
|
from mev_inspect.aave_liquidations import get_aave_liquidations
|
||||||
from mev_inspect.compound_liquidations import get_compound_liquidations
|
from mev_inspect.compound_liquidations import get_compound_liquidations
|
||||||
from mev_inspect.schemas.traces import (
|
|
||||||
ClassifiedTrace,
|
|
||||||
Classification,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.liquidations import Liquidation
|
from mev_inspect.schemas.liquidations import Liquidation
|
||||||
|
from mev_inspect.schemas.traces import Classification, ClassifiedTrace
|
||||||
|
|
||||||
|
|
||||||
def has_liquidations(classified_traces: List[ClassifiedTrace]) -> bool:
|
def has_liquidations(classified_traces: List[ClassifiedTrace]) -> bool:
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from mev_inspect.schemas.traces import ClassifiedTrace
|
|
||||||
from mev_inspect.schemas.miner_payments import MinerPayment
|
from mev_inspect.schemas.miner_payments import MinerPayment
|
||||||
from mev_inspect.schemas.receipts import Receipt
|
from mev_inspect.schemas.receipts import Receipt
|
||||||
|
from mev_inspect.schemas.traces import ClassifiedTrace
|
||||||
from mev_inspect.traces import get_traces_by_transaction_hash
|
from mev_inspect.traces import get_traces_by_transaction_hash
|
||||||
from mev_inspect.transfers import (
|
from mev_inspect.transfers import filter_transfers, get_eth_transfers
|
||||||
filter_transfers,
|
|
||||||
get_eth_transfers,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_miner_payments(
|
def get_miner_payments(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from sqlalchemy import Column, Numeric, String, ARRAY, Integer
|
from sqlalchemy import ARRAY, Column, Integer, Numeric, String
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from sqlalchemy import Column, Numeric, String, TIMESTAMP
|
from sqlalchemy import TIMESTAMP, Column, Numeric, String
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from sqlalchemy import Column, Numeric, String, ARRAY, Integer
|
from sqlalchemy import ARRAY, Column, Integer, Numeric, String
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from sqlalchemy import Column, Numeric, String, ARRAY, Integer
|
from sqlalchemy import ARRAY, Column, Integer, Numeric, String
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from sqlalchemy import Column, Numeric, String, ARRAY, Integer
|
from sqlalchemy import ARRAY, Column, Integer, Numeric, String
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ class SwapModel(Base):
|
|||||||
|
|
||||||
abi_name = Column(String, nullable=False)
|
abi_name = Column(String, nullable=False)
|
||||||
transaction_hash = Column(String, primary_key=True)
|
transaction_hash = Column(String, primary_key=True)
|
||||||
|
transaction_position = Column(Numeric, nullable=True)
|
||||||
block_number = Column(Numeric, nullable=False)
|
block_number = Column(Numeric, nullable=False)
|
||||||
trace_address = Column(ARRAY(Integer), nullable=False)
|
trace_address = Column(ARRAY(Integer), nullable=False)
|
||||||
protocol = Column(String, nullable=True)
|
protocol = Column(String, nullable=True)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from sqlalchemy import Column, JSON, Numeric, String, ARRAY, Integer
|
from sqlalchemy import ARRAY, JSON, Column, Integer, Numeric, String
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ class ClassifiedTraceModel(Base):
|
|||||||
__tablename__ = "classified_traces"
|
__tablename__ = "classified_traces"
|
||||||
|
|
||||||
transaction_hash = Column(String, primary_key=True)
|
transaction_hash = Column(String, primary_key=True)
|
||||||
|
transaction_position = Column(Numeric, nullable=True)
|
||||||
block_number = Column(Numeric, nullable=False)
|
block_number = Column(Numeric, nullable=False)
|
||||||
classification = Column(String, nullable=False)
|
classification = Column(String, nullable=False)
|
||||||
trace_type = Column(String, nullable=False)
|
trace_type = Column(String, nullable=False)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from sqlalchemy import Column, Numeric, String, ARRAY, Integer
|
from sqlalchemy import ARRAY, Column, Integer, Numeric, String
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
|
|
||||||
|
|||||||
@@ -3,18 +3,17 @@ from typing import List
|
|||||||
from mev_inspect.classifiers.specs.weth import WETH_ADDRESS
|
from mev_inspect.classifiers.specs.weth import WETH_ADDRESS
|
||||||
from mev_inspect.coinbase import fetch_coinbase_prices
|
from mev_inspect.coinbase import fetch_coinbase_prices
|
||||||
from mev_inspect.schemas.prices import (
|
from mev_inspect.schemas.prices import (
|
||||||
Price,
|
|
||||||
WBTC_TOKEN_ADDRESS,
|
|
||||||
LINK_TOKEN_ADDRESS,
|
|
||||||
YEARN_TOKEN_ADDRESS,
|
|
||||||
AAVE_TOKEN_ADDRESS,
|
AAVE_TOKEN_ADDRESS,
|
||||||
|
LINK_TOKEN_ADDRESS,
|
||||||
|
REN_TOKEN_ADDRESS,
|
||||||
UNI_TOKEN_ADDRESS,
|
UNI_TOKEN_ADDRESS,
|
||||||
USDC_TOKEN_ADDRESS_ADDRESS,
|
USDC_TOKEN_ADDRESS_ADDRESS,
|
||||||
REN_TOKEN_ADDRESS,
|
WBTC_TOKEN_ADDRESS,
|
||||||
|
YEARN_TOKEN_ADDRESS,
|
||||||
|
Price,
|
||||||
)
|
)
|
||||||
from mev_inspect.schemas.transfers import ETH_TOKEN_ADDRESS
|
from mev_inspect.schemas.transfers import ETH_TOKEN_ADDRESS
|
||||||
|
|
||||||
|
|
||||||
SUPPORTED_TOKENS = [
|
SUPPORTED_TOKENS = [
|
||||||
WETH_ADDRESS,
|
WETH_ADDRESS,
|
||||||
ETH_TOKEN_ADDRESS,
|
ETH_TOKEN_ADDRESS,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from web3 import Web3, AsyncHTTPProvider
|
from web3 import AsyncHTTPProvider, Web3
|
||||||
|
|
||||||
from mev_inspect.retry import http_retry_with_backoff_request_middleware
|
from mev_inspect.retry import http_retry_with_backoff_request_middleware
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from mev_inspect.schemas.traces import (
|
|
||||||
ClassifiedTrace,
|
|
||||||
Classification,
|
|
||||||
DecodedCallTrace,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.punk_bid import PunkBid
|
|
||||||
from mev_inspect.schemas.punk_accept_bid import PunkBidAcceptance
|
from mev_inspect.schemas.punk_accept_bid import PunkBidAcceptance
|
||||||
|
from mev_inspect.schemas.punk_bid import PunkBid
|
||||||
from mev_inspect.schemas.punk_snipe import PunkSnipe
|
from mev_inspect.schemas.punk_snipe import PunkSnipe
|
||||||
|
from mev_inspect.schemas.traces import Classification, ClassifiedTrace, DecodedCallTrace
|
||||||
from mev_inspect.traces import get_traces_by_transaction_hash
|
from mev_inspect.traces import get_traces_by_transaction_hash
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,19 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
from typing import (
|
|
||||||
Any,
|
|
||||||
Callable,
|
|
||||||
Collection,
|
|
||||||
Type,
|
|
||||||
Coroutine,
|
|
||||||
)
|
|
||||||
from asyncio.exceptions import TimeoutError
|
from asyncio.exceptions import TimeoutError
|
||||||
|
from typing import Any, Callable, Collection, Coroutine, Type
|
||||||
|
|
||||||
from aiohttp.client_exceptions import (
|
from aiohttp.client_exceptions import (
|
||||||
ClientOSError,
|
ClientOSError,
|
||||||
|
ClientResponseError,
|
||||||
ServerDisconnectedError,
|
ServerDisconnectedError,
|
||||||
ServerTimeoutError,
|
ServerTimeoutError,
|
||||||
ClientResponseError,
|
|
||||||
)
|
|
||||||
from requests.exceptions import (
|
|
||||||
ConnectionError,
|
|
||||||
HTTPError,
|
|
||||||
Timeout,
|
|
||||||
TooManyRedirects,
|
|
||||||
)
|
)
|
||||||
|
from requests.exceptions import ConnectionError, HTTPError, Timeout, TooManyRedirects
|
||||||
from web3 import Web3
|
from web3 import Web3
|
||||||
from web3.middleware.exception_retry_request import check_if_retry_on_failure
|
from web3.middleware.exception_retry_request import check_if_retry_on_failure
|
||||||
from web3.types import (
|
from web3.types import RPCEndpoint, RPCResponse
|
||||||
RPCEndpoint,
|
|
||||||
RPCResponse,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
request_exceptions = (ConnectionError, HTTPError, Timeout, TooManyRedirects)
|
request_exceptions = (ConnectionError, HTTPError, Timeout, TooManyRedirects)
|
||||||
aiohttp_exceptions = (
|
aiohttp_exceptions = (
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional, Union
|
||||||
from typing_extensions import Literal
|
|
||||||
|
|
||||||
import eth_utils.abi
|
import eth_utils.abi
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from typing_extensions import Literal
|
||||||
from web3 import Web3
|
from web3 import Web3
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ from typing import Dict, List, Optional, Type
|
|||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from .swaps import Swap
|
||||||
from .traces import Classification, DecodedCallTrace, Protocol
|
from .traces import Classification, DecodedCallTrace, Protocol
|
||||||
from .transfers import Transfer
|
from .transfers import Transfer
|
||||||
from .swaps import Swap
|
|
||||||
|
|
||||||
|
|
||||||
class Classifier(ABC):
|
class Classifier(ABC):
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from mev_inspect.schemas.traces import Protocol
|
from mev_inspect.schemas.traces import Protocol
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from mev_inspect.schemas.traces import Protocol
|
|||||||
class Swap(BaseModel):
|
class Swap(BaseModel):
|
||||||
abi_name: str
|
abi_name: str
|
||||||
transaction_hash: str
|
transaction_hash: str
|
||||||
|
transaction_position: int
|
||||||
block_number: int
|
block_number: int
|
||||||
trace_address: List[int]
|
trace_address: List[int]
|
||||||
contract_address: str
|
contract_address: str
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class ClassifiedTrace(Trace):
|
|||||||
value: Optional[int]
|
value: Optional[int]
|
||||||
gas_used: Optional[int]
|
gas_used: Optional[int]
|
||||||
transaction_hash: str
|
transaction_hash: str
|
||||||
|
transaction_position: int
|
||||||
protocol: Optional[Protocol]
|
protocol: Optional[Protocol]
|
||||||
function_name: Optional[str]
|
function_name: Optional[str]
|
||||||
function_signature: Optional[str]
|
function_signature: Optional[str]
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from typing import List
|
|||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
ETH_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
|
ETH_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from mev_inspect.classifiers.specs import get_classifier
|
from mev_inspect.classifiers.specs import get_classifier
|
||||||
from mev_inspect.schemas.traces import (
|
|
||||||
ClassifiedTrace,
|
|
||||||
Classification,
|
|
||||||
DecodedCallTrace,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.classifiers import SwapClassifier
|
from mev_inspect.schemas.classifiers import SwapClassifier
|
||||||
from mev_inspect.schemas.swaps import Swap
|
from mev_inspect.schemas.swaps import Swap
|
||||||
|
from mev_inspect.schemas.traces import Classification, ClassifiedTrace, DecodedCallTrace
|
||||||
from mev_inspect.schemas.transfers import Transfer
|
from mev_inspect.schemas.transfers import Transfer
|
||||||
from mev_inspect.traces import get_traces_by_transaction_hash
|
from mev_inspect.traces import get_traces_by_transaction_hash
|
||||||
from mev_inspect.transfers import (
|
from mev_inspect.transfers import (
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ from typing import Dict, List, Optional, Sequence
|
|||||||
|
|
||||||
from mev_inspect.classifiers.specs import get_classifier
|
from mev_inspect.classifiers.specs import get_classifier
|
||||||
from mev_inspect.schemas.classifiers import TransferClassifier
|
from mev_inspect.schemas.classifiers import TransferClassifier
|
||||||
from mev_inspect.schemas.traces import (
|
from mev_inspect.schemas.traces import ClassifiedTrace, DecodedCallTrace
|
||||||
ClassifiedTrace,
|
|
||||||
DecodedCallTrace,
|
|
||||||
)
|
|
||||||
from mev_inspect.schemas.transfers import ETH_TOKEN_ADDRESS, Transfer
|
from mev_inspect.schemas.transfers import ETH_TOKEN_ADDRESS, Transfer
|
||||||
from mev_inspect.traces import is_child_trace_address, get_child_traces
|
from mev_inspect.traces import get_child_traces, is_child_trace_address
|
||||||
|
|
||||||
|
|
||||||
def get_transfers(traces: List[ClassifiedTrace]) -> List[Transfer]:
|
def get_transfers(traces: List[ClassifiedTrace]) -> List[Transfer]:
|
||||||
|
|||||||
35
poetry.lock
generated
35
poetry.lock
generated
@@ -383,6 +383,14 @@ category = "main"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6"
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gprof2dot"
|
||||||
|
version = "2021.2.21"
|
||||||
|
description = "Generate a dot graph from the output of several profilers."
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "greenlet"
|
name = "greenlet"
|
||||||
version = "1.1.1"
|
version = "1.1.1"
|
||||||
@@ -768,6 +776,22 @@ toml = "*"
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtualenv"]
|
testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtualenv"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pytest-profiling"
|
||||||
|
version = "1.7.0"
|
||||||
|
description = "Profiling plugin for py.test"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
gprof2dot = "*"
|
||||||
|
pytest = "*"
|
||||||
|
six = "*"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
tests = ["pytest-virtualenv"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest-sugar"
|
name = "pytest-sugar"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
@@ -1032,7 +1056,7 @@ multidict = ">=4.0"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.9"
|
python-versions = "^3.9"
|
||||||
content-hash = "03aa2d5981665ade1b81682c1e797a06b56c5fb68d61ae69fd2f1e95bd32cfb6"
|
content-hash = "0aa43e887fe106d4142d68b7a891ba94f2de28df9df0ed765d285b1e5ccee391"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
aiohttp = [
|
aiohttp = [
|
||||||
@@ -1362,6 +1386,9 @@ frozenlist = [
|
|||||||
{file = "frozenlist-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:735f386ec522e384f511614c01d2ef9cf799f051353876b4c6fb93ef67a6d1ee"},
|
{file = "frozenlist-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:735f386ec522e384f511614c01d2ef9cf799f051353876b4c6fb93ef67a6d1ee"},
|
||||||
{file = "frozenlist-1.2.0.tar.gz", hash = "sha256:68201be60ac56aff972dc18085800b6ee07973c49103a8aba669dee3d71079de"},
|
{file = "frozenlist-1.2.0.tar.gz", hash = "sha256:68201be60ac56aff972dc18085800b6ee07973c49103a8aba669dee3d71079de"},
|
||||||
]
|
]
|
||||||
|
gprof2dot = [
|
||||||
|
{file = "gprof2dot-2021.2.21.tar.gz", hash = "sha256:1223189383b53dcc8ecfd45787ac48c0ed7b4dbc16ee8b88695d053eea1acabf"},
|
||||||
|
]
|
||||||
greenlet = [
|
greenlet = [
|
||||||
{file = "greenlet-1.1.1-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:476ba9435afaead4382fbab8f1882f75e3fb2285c35c9285abb3dd30237f9142"},
|
{file = "greenlet-1.1.1-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:476ba9435afaead4382fbab8f1882f75e3fb2285c35c9285abb3dd30237f9142"},
|
||||||
{file = "greenlet-1.1.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:44556302c0ab376e37939fd0058e1f0db2e769580d340fb03b01678d1ff25f68"},
|
{file = "greenlet-1.1.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:44556302c0ab376e37939fd0058e1f0db2e769580d340fb03b01678d1ff25f68"},
|
||||||
@@ -1771,6 +1798,12 @@ pytest-cov = [
|
|||||||
{file = "pytest-cov-2.12.1.tar.gz", hash = "sha256:261ceeb8c227b726249b376b8526b600f38667ee314f910353fa318caa01f4d7"},
|
{file = "pytest-cov-2.12.1.tar.gz", hash = "sha256:261ceeb8c227b726249b376b8526b600f38667ee314f910353fa318caa01f4d7"},
|
||||||
{file = "pytest_cov-2.12.1-py2.py3-none-any.whl", hash = "sha256:261bb9e47e65bd099c89c3edf92972865210c36813f80ede5277dceb77a4a62a"},
|
{file = "pytest_cov-2.12.1-py2.py3-none-any.whl", hash = "sha256:261bb9e47e65bd099c89c3edf92972865210c36813f80ede5277dceb77a4a62a"},
|
||||||
]
|
]
|
||||||
|
pytest-profiling = [
|
||||||
|
{file = "pytest-profiling-1.7.0.tar.gz", hash = "sha256:93938f147662225d2b8bd5af89587b979652426a8a6ffd7e73ec4a23e24b7f29"},
|
||||||
|
{file = "pytest_profiling-1.7.0-py2.7.egg", hash = "sha256:3b255f9db36cb2dd7536a8e7e294c612c0be7f7850a7d30754878e4315d56600"},
|
||||||
|
{file = "pytest_profiling-1.7.0-py2.py3-none-any.whl", hash = "sha256:999cc9ac94f2e528e3f5d43465da277429984a1c237ae9818f8cfd0b06acb019"},
|
||||||
|
{file = "pytest_profiling-1.7.0-py3.6.egg", hash = "sha256:6bce4e2edc04409d2f3158c16750fab8074f62d404cc38eeb075dff7fcbb996c"},
|
||||||
|
]
|
||||||
pytest-sugar = [
|
pytest-sugar = [
|
||||||
{file = "pytest-sugar-0.9.4.tar.gz", hash = "sha256:b1b2186b0a72aada6859bea2a5764145e3aaa2c1cfbb23c3a19b5f7b697563d3"},
|
{file = "pytest-sugar-0.9.4.tar.gz", hash = "sha256:b1b2186b0a72aada6859bea2a5764145e3aaa2c1cfbb23c3a19b5f7b697563d3"},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ coverage = "^5.5"
|
|||||||
alembic = "^1.6.5"
|
alembic = "^1.6.5"
|
||||||
CProfileV = "^1.0.7"
|
CProfileV = "^1.0.7"
|
||||||
regex = "^2021.10.8"
|
regex = "^2021.10.8"
|
||||||
|
pytest-profiling = "^1.7.0"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
@@ -64,10 +65,10 @@ exclude = '''
|
|||||||
profile = "black"
|
profile = "black"
|
||||||
atomic = true
|
atomic = true
|
||||||
include_trailing_comma = true
|
include_trailing_comma = true
|
||||||
lines_after_imports = 2
|
|
||||||
lines_between_types = 1
|
|
||||||
use_parentheses = true
|
use_parentheses = true
|
||||||
src_paths = ["poetry", "tests"]
|
src_paths = ["mev_inspect", "tests"]
|
||||||
skip_glob = ["*/setup.py"]
|
skip_glob = ["*/setup.py"]
|
||||||
filter_files = true
|
filter_files = true
|
||||||
known_first_party = "poetry"
|
known_first_party = "mev_inspect"
|
||||||
|
known_third_party = "alembic"
|
||||||
|
py_version=39
|
||||||
|
|||||||
@@ -3,6 +3,13 @@ from typing import List
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from mev_inspect.classifiers.trace import TraceClassifier
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def trace_classifier() -> TraceClassifier:
|
||||||
|
return TraceClassifier()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="get_transaction_hashes")
|
@pytest.fixture(name="get_transaction_hashes")
|
||||||
def fixture_get_transaction_hashes():
|
def fixture_get_transaction_hashes():
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ def make_transfer_trace(
|
|||||||
):
|
):
|
||||||
return DecodedCallTrace(
|
return DecodedCallTrace(
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=0,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
type=TraceType.call,
|
type=TraceType.call,
|
||||||
trace_address=trace_address,
|
trace_address=trace_address,
|
||||||
@@ -53,6 +54,7 @@ def make_swap_trace(
|
|||||||
):
|
):
|
||||||
return DecodedCallTrace(
|
return DecodedCallTrace(
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=0,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
type=TraceType.call,
|
type=TraceType.call,
|
||||||
trace_address=trace_address,
|
trace_address=trace_address,
|
||||||
@@ -78,6 +80,7 @@ def make_unknown_trace(
|
|||||||
return ClassifiedTrace(
|
return ClassifiedTrace(
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=0,
|
||||||
trace_address=trace_address,
|
trace_address=trace_address,
|
||||||
action={},
|
action={},
|
||||||
subtraces=0,
|
subtraces=0,
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from mev_inspect.aave_liquidations import get_aave_liquidations
|
from mev_inspect.aave_liquidations import get_aave_liquidations
|
||||||
|
from mev_inspect.classifiers.trace import TraceClassifier
|
||||||
from mev_inspect.schemas.liquidations import Liquidation
|
from mev_inspect.schemas.liquidations import Liquidation
|
||||||
from mev_inspect.schemas.traces import Protocol
|
from mev_inspect.schemas.traces import Protocol
|
||||||
from mev_inspect.classifiers.trace import TraceClassifier
|
|
||||||
from mev_inspect.transfers import ETH_TOKEN_ADDRESS
|
from mev_inspect.transfers import ETH_TOKEN_ADDRESS
|
||||||
from tests.utils import load_test_block
|
from tests.utils import load_test_block
|
||||||
|
|
||||||
|
|
||||||
def test_single_weth_liquidation():
|
def test_single_weth_liquidation(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0xb7575eedc9d8cfe82c4a11cd1a851221f2eafb93d738301995ac7103ffe877f7"
|
"0xb7575eedc9d8cfe82c4a11cd1a851221f2eafb93d738301995ac7103ffe877f7"
|
||||||
)
|
)
|
||||||
@@ -31,15 +30,13 @@ def test_single_weth_liquidation():
|
|||||||
]
|
]
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_aave_liquidations(classified_traces)
|
result = get_aave_liquidations(classified_traces)
|
||||||
|
|
||||||
_assert_equal_list_of_liquidations(result, liquidations)
|
_assert_equal_list_of_liquidations(result, liquidations)
|
||||||
|
|
||||||
|
|
||||||
def test_single_liquidation():
|
def test_single_liquidation(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0xe6c0e3ef0436cb032e1ef292141f4fc4dcd47a75a2559602133114952190e76b"
|
"0xe6c0e3ef0436cb032e1ef292141f4fc4dcd47a75a2559602133114952190e76b"
|
||||||
)
|
)
|
||||||
@@ -61,15 +58,13 @@ def test_single_liquidation():
|
|||||||
]
|
]
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_aave_liquidations(classified_traces)
|
result = get_aave_liquidations(classified_traces)
|
||||||
|
|
||||||
_assert_equal_list_of_liquidations(result, liquidations)
|
_assert_equal_list_of_liquidations(result, liquidations)
|
||||||
|
|
||||||
|
|
||||||
def test_single_liquidation_with_atoken_payback():
|
def test_single_liquidation_with_atoken_payback(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0xde551a73e813f1a1e5c843ac2c6a0e40d71618f4040bb7d0cd7cf7b2b6cf4633"
|
"0xde551a73e813f1a1e5c843ac2c6a0e40d71618f4040bb7d0cd7cf7b2b6cf4633"
|
||||||
)
|
)
|
||||||
@@ -91,15 +86,13 @@ def test_single_liquidation_with_atoken_payback():
|
|||||||
]
|
]
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_aave_liquidations(classified_traces)
|
result = get_aave_liquidations(classified_traces)
|
||||||
|
|
||||||
_assert_equal_list_of_liquidations(result, liquidations)
|
_assert_equal_list_of_liquidations(result, liquidations)
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_liquidations_in_block():
|
def test_multiple_liquidations_in_block(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction1 = "0xedd062c3a728db4b114f2e83cac281d19a9f753e36afa8a35cdbdf1e1dd5d017"
|
transaction1 = "0xedd062c3a728db4b114f2e83cac281d19a9f753e36afa8a35cdbdf1e1dd5d017"
|
||||||
transaction2 = "0x18492f250cf4735bd67a21c6cc26b7d9c59cf2fb077356dc924f36bc68a810e5"
|
transaction2 = "0x18492f250cf4735bd67a21c6cc26b7d9c59cf2fb077356dc924f36bc68a810e5"
|
||||||
transaction3 = "0x191b05b28ebaf460e38e90ac6a801681b500f169041ae83a45b32803ef2ec98c"
|
transaction3 = "0x191b05b28ebaf460e38e90ac6a801681b500f169041ae83a45b32803ef2ec98c"
|
||||||
@@ -145,7 +138,6 @@ def test_multiple_liquidations_in_block():
|
|||||||
)
|
)
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_aave_liquidations(classified_traces)
|
result = get_aave_liquidations(classified_traces)
|
||||||
liquidations = [liquidation1, liquidation2, liquidation3]
|
liquidations = [liquidation1, liquidation2, liquidation3]
|
||||||
@@ -153,8 +145,7 @@ def test_multiple_liquidations_in_block():
|
|||||||
_assert_equal_list_of_liquidations(result, liquidations)
|
_assert_equal_list_of_liquidations(result, liquidations)
|
||||||
|
|
||||||
|
|
||||||
def test_liquidations_with_eth_transfer():
|
def test_liquidations_with_eth_transfer(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0xf687fedbc4bbc25adb3ef3a35c20c38fb7d35d86d7633d5061d2e3c4f86311b7"
|
"0xf687fedbc4bbc25adb3ef3a35c20c38fb7d35d86d7633d5061d2e3c4f86311b7"
|
||||||
)
|
)
|
||||||
@@ -187,7 +178,6 @@ def test_liquidations_with_eth_transfer():
|
|||||||
)
|
)
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_aave_liquidations(classified_traces)
|
result = get_aave_liquidations(classified_traces)
|
||||||
liquidations = [liquidation1, liquidation2]
|
liquidations = [liquidation1, liquidation2]
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
from mev_inspect.schemas.swaps import Swap
|
|
||||||
from mev_inspect.swaps import get_swaps
|
|
||||||
from mev_inspect.schemas.traces import Protocol
|
|
||||||
from mev_inspect.classifiers.trace import TraceClassifier
|
from mev_inspect.classifiers.trace import TraceClassifier
|
||||||
|
from mev_inspect.schemas.swaps import Swap
|
||||||
|
from mev_inspect.schemas.traces import Protocol
|
||||||
|
from mev_inspect.swaps import get_swaps
|
||||||
from tests.utils import load_test_block
|
from tests.utils import load_test_block
|
||||||
|
|
||||||
|
|
||||||
def test_fillLimitOrder_swap():
|
def test_fillLimitOrder_swap(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0xa043976d736ec8dc930c0556dffd0a86a4bfc80bf98fb7995c791fb4dc488b5d"
|
"0xa043976d736ec8dc930c0556dffd0a86a4bfc80bf98fb7995c791fb4dc488b5d"
|
||||||
)
|
)
|
||||||
@@ -15,6 +14,7 @@ def test_fillLimitOrder_swap():
|
|||||||
swap = Swap(
|
swap = Swap(
|
||||||
abi_name="INativeOrdersFeature",
|
abi_name="INativeOrdersFeature",
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=2,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[0, 2, 0, 1],
|
trace_address=[0, 2, 0, 1],
|
||||||
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
||||||
@@ -29,15 +29,13 @@ def test_fillLimitOrder_swap():
|
|||||||
)
|
)
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_swaps(classified_traces)
|
result = get_swaps(classified_traces)
|
||||||
|
|
||||||
assert result.count(swap) == 1
|
assert result.count(swap) == 1
|
||||||
|
|
||||||
|
|
||||||
def test__fillLimitOrder_swap():
|
def test__fillLimitOrder_swap(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0x9255addffa2dbeb9560c5e20e78a78c949488d2054c70b2155c39f9e28394cbf"
|
"0x9255addffa2dbeb9560c5e20e78a78c949488d2054c70b2155c39f9e28394cbf"
|
||||||
)
|
)
|
||||||
@@ -46,6 +44,7 @@ def test__fillLimitOrder_swap():
|
|||||||
swap = Swap(
|
swap = Swap(
|
||||||
abi_name="INativeOrdersFeature",
|
abi_name="INativeOrdersFeature",
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=8,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[0, 1],
|
trace_address=[0, 1],
|
||||||
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
||||||
@@ -60,15 +59,13 @@ def test__fillLimitOrder_swap():
|
|||||||
)
|
)
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_swaps(classified_traces)
|
result = get_swaps(classified_traces)
|
||||||
|
|
||||||
assert result.count(swap) == 1
|
assert result.count(swap) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_RfqLimitOrder_swap():
|
def test_RfqLimitOrder_swap(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0x1c948eb7c59ddbe6b916cf68f5df86eb44a7c9e728221fcd8ab750f137fd2a0f"
|
"0x1c948eb7c59ddbe6b916cf68f5df86eb44a7c9e728221fcd8ab750f137fd2a0f"
|
||||||
)
|
)
|
||||||
@@ -77,6 +74,7 @@ def test_RfqLimitOrder_swap():
|
|||||||
swap = Swap(
|
swap = Swap(
|
||||||
abi_name="INativeOrdersFeature",
|
abi_name="INativeOrdersFeature",
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=9,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[0, 1, 13, 0, 1],
|
trace_address=[0, 1, 13, 0, 1],
|
||||||
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
||||||
@@ -91,15 +89,13 @@ def test_RfqLimitOrder_swap():
|
|||||||
)
|
)
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_swaps(classified_traces)
|
result = get_swaps(classified_traces)
|
||||||
|
|
||||||
assert result.count(swap) == 1
|
assert result.count(swap) == 1
|
||||||
|
|
||||||
|
|
||||||
def test__RfqLimitOrder_swap():
|
def test__RfqLimitOrder_swap(trace_classifier: TraceClassifier):
|
||||||
|
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0x4f66832e654f8a4d773d9769571155df3722401343247376d6bb56626db29b90"
|
"0x4f66832e654f8a4d773d9769571155df3722401343247376d6bb56626db29b90"
|
||||||
)
|
)
|
||||||
@@ -108,6 +104,7 @@ def test__RfqLimitOrder_swap():
|
|||||||
swap = Swap(
|
swap = Swap(
|
||||||
abi_name="INativeOrdersFeature",
|
abi_name="INativeOrdersFeature",
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=168,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[1, 0, 1, 0, 1],
|
trace_address=[1, 0, 1, 0, 1],
|
||||||
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
||||||
@@ -122,7 +119,6 @@ def test__RfqLimitOrder_swap():
|
|||||||
)
|
)
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_swaps(classified_traces)
|
result = get_swaps(classified_traces)
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ from mev_inspect.swaps import get_swaps
|
|||||||
from .utils import load_test_block
|
from .utils import load_test_block
|
||||||
|
|
||||||
|
|
||||||
def test_arbitrage_real_block():
|
def test_arbitrage_real_block(trace_classifier: TraceClassifier):
|
||||||
block = load_test_block(12914944)
|
block = load_test_block(12914944)
|
||||||
|
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
|
|
||||||
swaps = get_swaps(classified_traces)
|
swaps = get_swaps(classified_traces)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from mev_inspect.arbitrages import get_arbitrages, _get_all_routes
|
from mev_inspect.arbitrages import _get_all_routes, get_arbitrages
|
||||||
from mev_inspect.schemas.swaps import Swap
|
|
||||||
from mev_inspect.classifiers.specs.uniswap import (
|
from mev_inspect.classifiers.specs.uniswap import (
|
||||||
UNISWAP_V2_PAIR_ABI_NAME,
|
UNISWAP_V2_PAIR_ABI_NAME,
|
||||||
UNISWAP_V3_POOL_ABI_NAME,
|
UNISWAP_V3_POOL_ABI_NAME,
|
||||||
)
|
)
|
||||||
|
from mev_inspect.schemas.swaps import Swap
|
||||||
|
|
||||||
|
|
||||||
def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
|
def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
|
||||||
@@ -25,11 +25,13 @@ def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
|
|||||||
first_token_in_amount = 10
|
first_token_in_amount = 10
|
||||||
first_token_out_amount = 11
|
first_token_out_amount = 11
|
||||||
second_token_amount = 15
|
second_token_amount = 15
|
||||||
|
transaction_position = 0
|
||||||
|
|
||||||
arb_swaps = [
|
arb_swaps = [
|
||||||
Swap(
|
Swap(
|
||||||
abi_name=UNISWAP_V2_PAIR_ABI_NAME,
|
abi_name=UNISWAP_V2_PAIR_ABI_NAME,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=transaction_position,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[0],
|
trace_address=[0],
|
||||||
contract_address=first_pool_address,
|
contract_address=first_pool_address,
|
||||||
@@ -43,6 +45,7 @@ def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
|
|||||||
Swap(
|
Swap(
|
||||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=transaction_position,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[1],
|
trace_address=[1],
|
||||||
contract_address=second_pool_address,
|
contract_address=second_pool_address,
|
||||||
@@ -58,6 +61,7 @@ def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
|
|||||||
unrelated_swap = Swap(
|
unrelated_swap = Swap(
|
||||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=transaction_position,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[2, 0],
|
trace_address=[2, 0],
|
||||||
contract_address=unrelated_pool_address,
|
contract_address=unrelated_pool_address,
|
||||||
@@ -106,11 +110,13 @@ def test_three_pool_arbitrage(get_transaction_hashes, get_addresses):
|
|||||||
first_token_out_amount = 11
|
first_token_out_amount = 11
|
||||||
second_token_amount = 15
|
second_token_amount = 15
|
||||||
third_token_amount = 40
|
third_token_amount = 40
|
||||||
|
transaction_position = 0
|
||||||
|
|
||||||
swaps = [
|
swaps = [
|
||||||
Swap(
|
Swap(
|
||||||
abi_name=UNISWAP_V2_PAIR_ABI_NAME,
|
abi_name=UNISWAP_V2_PAIR_ABI_NAME,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=transaction_position,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[0],
|
trace_address=[0],
|
||||||
contract_address=first_pool_address,
|
contract_address=first_pool_address,
|
||||||
@@ -124,6 +130,7 @@ def test_three_pool_arbitrage(get_transaction_hashes, get_addresses):
|
|||||||
Swap(
|
Swap(
|
||||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=transaction_position,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[1],
|
trace_address=[1],
|
||||||
contract_address=second_pool_address,
|
contract_address=second_pool_address,
|
||||||
@@ -137,6 +144,7 @@ def test_three_pool_arbitrage(get_transaction_hashes, get_addresses):
|
|||||||
Swap(
|
Swap(
|
||||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
|
transaction_position=transaction_position,
|
||||||
block_number=block_number,
|
block_number=block_number,
|
||||||
trace_address=[2],
|
trace_address=[2],
|
||||||
contract_address=third_pool_address,
|
contract_address=third_pool_address,
|
||||||
@@ -218,6 +226,7 @@ def create_generic_swap(
|
|||||||
return Swap(
|
return Swap(
|
||||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||||
transaction_hash="0xfake",
|
transaction_hash="0xfake",
|
||||||
|
transaction_position=0,
|
||||||
block_number=0,
|
block_number=0,
|
||||||
trace_address=trace_address,
|
trace_address=trace_address,
|
||||||
contract_address="0xfake",
|
contract_address="0xfake",
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
|
from mev_inspect.classifiers.trace import TraceClassifier
|
||||||
from mev_inspect.compound_liquidations import get_compound_liquidations
|
from mev_inspect.compound_liquidations import get_compound_liquidations
|
||||||
from mev_inspect.schemas.liquidations import Liquidation
|
from mev_inspect.schemas.liquidations import Liquidation
|
||||||
from mev_inspect.schemas.traces import Protocol
|
from mev_inspect.schemas.traces import Protocol
|
||||||
from mev_inspect.classifiers.trace import TraceClassifier
|
from tests.utils import load_comp_markets, load_cream_markets, load_test_block
|
||||||
from tests.utils import load_test_block, load_comp_markets, load_cream_markets
|
|
||||||
|
|
||||||
comp_markets = load_comp_markets()
|
comp_markets = load_comp_markets()
|
||||||
cream_markets = load_cream_markets()
|
cream_markets = load_cream_markets()
|
||||||
|
|
||||||
|
|
||||||
def test_c_ether_liquidations():
|
def test_c_ether_liquidations(trace_classifier: TraceClassifier):
|
||||||
block_number = 13234998
|
block_number = 13234998
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0x78f7e67391c2bacde45e5057241f8b9e21a59330bce4332eecfff8fac279d090"
|
"0x78f7e67391c2bacde45e5057241f8b9e21a59330bce4332eecfff8fac279d090"
|
||||||
@@ -21,6 +21,7 @@ def test_c_ether_liquidations():
|
|||||||
debt_token_address="0x39aa39c021dfbae8fac545936693ac917d5e7563",
|
debt_token_address="0x39aa39c021dfbae8fac545936693ac917d5e7563",
|
||||||
debt_purchase_amount=268066492249420078,
|
debt_purchase_amount=268066492249420078,
|
||||||
received_amount=4747650169097,
|
received_amount=4747650169097,
|
||||||
|
received_token_address="0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
|
||||||
protocol=Protocol.compound_v2,
|
protocol=Protocol.compound_v2,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
trace_address=[1],
|
trace_address=[1],
|
||||||
@@ -28,7 +29,6 @@ def test_c_ether_liquidations():
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_compound_liquidations(classified_traces)
|
result = get_compound_liquidations(classified_traces)
|
||||||
assert result == liquidations
|
assert result == liquidations
|
||||||
@@ -45,6 +45,7 @@ def test_c_ether_liquidations():
|
|||||||
debt_token_address="0x35a18000230da775cac24873d00ff85bccded550",
|
debt_token_address="0x35a18000230da775cac24873d00ff85bccded550",
|
||||||
debt_purchase_amount=414547860568297082,
|
debt_purchase_amount=414547860568297082,
|
||||||
received_amount=321973320649,
|
received_amount=321973320649,
|
||||||
|
received_token_address="0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
|
||||||
protocol=Protocol.compound_v2,
|
protocol=Protocol.compound_v2,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
trace_address=[1],
|
trace_address=[1],
|
||||||
@@ -53,7 +54,6 @@ def test_c_ether_liquidations():
|
|||||||
]
|
]
|
||||||
|
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_compound_liquidations(classified_traces)
|
result = get_compound_liquidations(classified_traces)
|
||||||
assert result == liquidations
|
assert result == liquidations
|
||||||
@@ -70,6 +70,7 @@ def test_c_ether_liquidations():
|
|||||||
debt_token_address="0x35a18000230da775cac24873d00ff85bccded550",
|
debt_token_address="0x35a18000230da775cac24873d00ff85bccded550",
|
||||||
debt_purchase_amount=1106497772527562662,
|
debt_purchase_amount=1106497772527562662,
|
||||||
received_amount=910895850496,
|
received_amount=910895850496,
|
||||||
|
received_token_address="0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
|
||||||
protocol=Protocol.compound_v2,
|
protocol=Protocol.compound_v2,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
trace_address=[1],
|
trace_address=[1],
|
||||||
@@ -77,13 +78,12 @@ def test_c_ether_liquidations():
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_compound_liquidations(classified_traces)
|
result = get_compound_liquidations(classified_traces)
|
||||||
assert result == liquidations
|
assert result == liquidations
|
||||||
|
|
||||||
|
|
||||||
def test_c_token_liquidation():
|
def test_c_token_liquidation(trace_classifier: TraceClassifier):
|
||||||
block_number = 13326607
|
block_number = 13326607
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0x012215bedd00147c58e1f59807664914b2abbfc13c260190dc9cfc490be3e343"
|
"0x012215bedd00147c58e1f59807664914b2abbfc13c260190dc9cfc490be3e343"
|
||||||
@@ -96,6 +96,7 @@ def test_c_token_liquidation():
|
|||||||
debt_token_address="0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
|
debt_token_address="0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
|
||||||
debt_purchase_amount=1207055531,
|
debt_purchase_amount=1207055531,
|
||||||
received_amount=21459623305,
|
received_amount=21459623305,
|
||||||
|
received_token_address="0x39aa39c021dfbae8fac545936693ac917d5e7563",
|
||||||
protocol=Protocol.compound_v2,
|
protocol=Protocol.compound_v2,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
trace_address=[1],
|
trace_address=[1],
|
||||||
@@ -103,13 +104,12 @@ def test_c_token_liquidation():
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_compound_liquidations(classified_traces)
|
result = get_compound_liquidations(classified_traces)
|
||||||
assert result == liquidations
|
assert result == liquidations
|
||||||
|
|
||||||
|
|
||||||
def test_cream_token_liquidation():
|
def test_cream_token_liquidation(trace_classifier: TraceClassifier):
|
||||||
block_number = 12674514
|
block_number = 12674514
|
||||||
transaction_hash = (
|
transaction_hash = (
|
||||||
"0x0809bdbbddcf566e5392682a9bd9d0006a92a4dc441163c791b1136f982994b1"
|
"0x0809bdbbddcf566e5392682a9bd9d0006a92a4dc441163c791b1136f982994b1"
|
||||||
@@ -122,6 +122,7 @@ def test_cream_token_liquidation():
|
|||||||
debt_token_address="0x44fbebd2f576670a6c33f6fc0b00aa8c5753b322",
|
debt_token_address="0x44fbebd2f576670a6c33f6fc0b00aa8c5753b322",
|
||||||
debt_purchase_amount=14857434973806369550,
|
debt_purchase_amount=14857434973806369550,
|
||||||
received_amount=1547215810826,
|
received_amount=1547215810826,
|
||||||
|
received_token_address="0x697256caa3ccafd62bb6d3aa1c7c5671786a5fd9",
|
||||||
protocol=Protocol.cream,
|
protocol=Protocol.cream,
|
||||||
transaction_hash=transaction_hash,
|
transaction_hash=transaction_hash,
|
||||||
trace_address=[],
|
trace_address=[],
|
||||||
@@ -129,7 +130,6 @@ def test_cream_token_liquidation():
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
block = load_test_block(block_number)
|
block = load_test_block(block_number)
|
||||||
trace_classifier = TraceClassifier()
|
|
||||||
classified_traces = trace_classifier.classify(block.traces)
|
classified_traces = trace_classifier.classify(block.traces)
|
||||||
result = get_compound_liquidations(classified_traces)
|
result = get_compound_liquidations(classified_traces)
|
||||||
assert result == liquidations
|
assert result == liquidations
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
from mev_inspect.swaps import get_swaps
|
|
||||||
from mev_inspect.classifiers.specs.balancer import BALANCER_V1_POOL_ABI_NAME
|
from mev_inspect.classifiers.specs.balancer import BALANCER_V1_POOL_ABI_NAME
|
||||||
from mev_inspect.classifiers.specs.uniswap import (
|
|
||||||
UNISWAP_V2_PAIR_ABI_NAME,
|
|
||||||
UNISWAP_V3_POOL_ABI_NAME,
|
|
||||||
)
|
|
||||||
from mev_inspect.classifiers.specs.bancor import (
|
from mev_inspect.classifiers.specs.bancor import (
|
||||||
BANCOR_NETWORK_ABI_NAME,
|
BANCOR_NETWORK_ABI_NAME,
|
||||||
BANCOR_NETWORK_CONTRACT_ADDRESS,
|
BANCOR_NETWORK_CONTRACT_ADDRESS,
|
||||||
)
|
)
|
||||||
from mev_inspect.schemas.traces import Protocol
|
from mev_inspect.classifiers.specs.uniswap import (
|
||||||
|
UNISWAP_V2_PAIR_ABI_NAME,
|
||||||
from .helpers import (
|
UNISWAP_V3_POOL_ABI_NAME,
|
||||||
make_unknown_trace,
|
|
||||||
make_transfer_trace,
|
|
||||||
make_swap_trace,
|
|
||||||
)
|
)
|
||||||
|
from mev_inspect.schemas.traces import Protocol
|
||||||
|
from mev_inspect.swaps import get_swaps
|
||||||
|
|
||||||
|
from .helpers import make_swap_trace, make_transfer_trace, make_unknown_trace
|
||||||
|
|
||||||
|
|
||||||
def test_swaps(
|
def test_swaps(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from mev_inspect.schemas.traces import ClassifiedTrace
|
from mev_inspect.schemas.traces import ClassifiedTrace
|
||||||
from mev_inspect.traces import is_child_trace_address, get_child_traces
|
from mev_inspect.traces import get_child_traces, is_child_trace_address
|
||||||
|
|
||||||
from .helpers import make_many_unknown_traces
|
from .helpers import make_many_unknown_traces
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ from typing import Dict
|
|||||||
|
|
||||||
from mev_inspect.schemas.blocks import Block
|
from mev_inspect.schemas.blocks import Block
|
||||||
|
|
||||||
|
|
||||||
THIS_FILE_DIRECTORY = os.path.dirname(__file__)
|
THIS_FILE_DIRECTORY = os.path.dirname(__file__)
|
||||||
TEST_BLOCKS_DIRECTORY = os.path.join(THIS_FILE_DIRECTORY, "blocks")
|
TEST_BLOCKS_DIRECTORY = os.path.join(THIS_FILE_DIRECTORY, "blocks")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user