diff --git a/alembic/versions/b26ab0051a88_add_profit_amount_column_to_sandwiches_.py b/alembic/versions/b26ab0051a88_add_profit_amount_column_to_sandwiches_.py index 7fa9af3..015bae9 100644 --- a/alembic/versions/b26ab0051a88_add_profit_amount_column_to_sandwiches_.py +++ b/alembic/versions/b26ab0051a88_add_profit_amount_column_to_sandwiches_.py @@ -18,10 +18,11 @@ depends_on = None def upgrade(): op.add_column( - "sandwiches", - sa.Column("profit_amount", sa.Numeric, nullable=True), + "sandwiches", sa.Column("profit_token_address", sa.String(256), nullable=True) ) + op.add_column("sandwiches", sa.Column("profit_amount", sa.Numeric, nullable=True)) def downgrade(): + op.drop_column("sandwiches", "profit_token_address") op.drop_column("sandwiches", "profit_amount") diff --git a/mev_inspect/crud/sandwiches.py b/mev_inspect/crud/sandwiches.py index 7d40a40..566063a 100644 --- a/mev_inspect/crud/sandwiches.py +++ b/mev_inspect/crud/sandwiches.py @@ -39,6 +39,7 @@ def write_sandwiches( frontrun_swap_trace_address=sandwich.frontrun_swap.trace_address, backrun_swap_transaction_hash=sandwich.backrun_swap.transaction_hash, backrun_swap_trace_address=sandwich.backrun_swap.trace_address, + profit_token_address=sandwich.profit_token_address, profit_amount=sandwich.profit_amount, ) ) diff --git a/mev_inspect/models/sandwiches.py b/mev_inspect/models/sandwiches.py index f6ce902..676f038 100644 --- a/mev_inspect/models/sandwiches.py +++ b/mev_inspect/models/sandwiches.py @@ -14,4 +14,5 @@ class SandwichModel(Base): frontrun_swap_trace_address = Column(ARRAY(Integer), nullable=False) backrun_swap_transaction_hash = Column(String(256), nullable=False) backrun_swap_trace_address = Column(ARRAY(Integer), nullable=False) + profit_token_address = Column(String(256), nullable=False) profit_amount = Column(Numeric, nullable=False) diff --git a/mev_inspect/sandwiches.py b/mev_inspect/sandwiches.py index 0a39e1d..fe6bf58 100644 --- a/mev_inspect/sandwiches.py +++ b/mev_inspect/sandwiches.py @@ -62,6 +62,7 @@ def _get_sandwich_starting_with_swap( frontrun_swap=front_swap, backrun_swap=other_swap, sandwiched_swaps=sandwiched_swaps, + profit_token_address=front_swap.token_in_address, profit_amount=other_swap.token_out_amount - front_swap.token_in_amount, ) diff --git a/mev_inspect/schemas/sandwiches.py b/mev_inspect/schemas/sandwiches.py index 8621164..b88b703 100644 --- a/mev_inspect/schemas/sandwiches.py +++ b/mev_inspect/schemas/sandwiches.py @@ -11,4 +11,5 @@ class Sandwich(BaseModel): frontrun_swap: Swap backrun_swap: Swap sandwiched_swaps: List[Swap] + profit_token_address: str profit_amount: int