From 24e682c9d722bd38edd5d6519577e5e0d37f015b Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Tue, 17 Aug 2021 00:01:14 -0400 Subject: [PATCH] Save errors on swaps in the database --- .../92f28a2b4f52_add_error_column_to_swaps.py | 24 +++++++++++++++++++ mev_inspect/models/swaps.py | 1 + mev_inspect/schemas/swaps.py | 1 + mev_inspect/swaps.py | 1 + 4 files changed, 27 insertions(+) create mode 100644 alembic/versions/92f28a2b4f52_add_error_column_to_swaps.py diff --git a/alembic/versions/92f28a2b4f52_add_error_column_to_swaps.py b/alembic/versions/92f28a2b4f52_add_error_column_to_swaps.py new file mode 100644 index 0000000..2192469 --- /dev/null +++ b/alembic/versions/92f28a2b4f52_add_error_column_to_swaps.py @@ -0,0 +1,24 @@ +"""Add error column to swaps + +Revision ID: 92f28a2b4f52 +Revises: 9b8ae51c5d56 +Create Date: 2021-08-17 03:46:21.498821 + +""" +import sqlalchemy as sa +from alembic import op + + +# revision identifiers, used by Alembic. +revision = "92f28a2b4f52" +down_revision = "9b8ae51c5d56" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column("swaps", sa.Column("error", sa.String(256), nullable=True)) + + +def downgrade(): + op.drop_column("swaps", "error") diff --git a/mev_inspect/models/swaps.py b/mev_inspect/models/swaps.py index 318aa24..6695fd0 100644 --- a/mev_inspect/models/swaps.py +++ b/mev_inspect/models/swaps.py @@ -18,3 +18,4 @@ class SwapModel(Base): token_in_amount = Column(Numeric, nullable=False) token_out_address = Column(String, nullable=False) token_out_amount = Column(Numeric, nullable=False) + error = Column(String, nullable=True) diff --git a/mev_inspect/schemas/swaps.py b/mev_inspect/schemas/swaps.py index 3c38330..2350142 100644 --- a/mev_inspect/schemas/swaps.py +++ b/mev_inspect/schemas/swaps.py @@ -18,3 +18,4 @@ class Swap(BaseModel): token_in_amount: int token_out_address: str token_out_amount: int + error: Optional[str] diff --git a/mev_inspect/swaps.py b/mev_inspect/swaps.py index 437dfdd..1e9b8bd 100644 --- a/mev_inspect/swaps.py +++ b/mev_inspect/swaps.py @@ -103,6 +103,7 @@ def _parse_swap( token_in_amount=transfer_in.amount, token_out_address=transfer_out.token_address, token_out_amount=transfer_out.amount, + error=trace.error, )