add sandwich profit
This commit is contained in:
parent
72433ece39
commit
189b7d1220
@ -0,0 +1,27 @@
|
||||
"""add profit_amount column to sandwiches table
|
||||
|
||||
Revision ID: b26ab0051a88
|
||||
Revises: 3c54832385e3
|
||||
Create Date: 2022-01-16 13:45:10.190969
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "b26ab0051a88"
|
||||
down_revision = "3c54832385e3"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column(
|
||||
"sandwiches",
|
||||
sa.Column("profit_amount", sa.Numeric, nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column("sandwiches", "profit_amount")
|
@ -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_amount=sandwich.profit_amount,
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -14,3 +14,4 @@ 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_amount = Column(Numeric, nullable=False)
|
||||
|
@ -62,6 +62,8 @@ def _get_sandwich_starting_with_swap(
|
||||
frontrun_swap=front_swap,
|
||||
backrun_swap=other_swap,
|
||||
sandwiched_swaps=sandwiched_swaps,
|
||||
profit_amount=other_swap.token_out_amount
|
||||
- front_swap.token_in_amount,
|
||||
)
|
||||
|
||||
return None
|
||||
|
@ -11,3 +11,4 @@ class Sandwich(BaseModel):
|
||||
frontrun_swap: Swap
|
||||
backrun_swap: Swap
|
||||
sandwiched_swaps: List[Swap]
|
||||
profit_amount: int
|
||||
|
Loading…
x
Reference in New Issue
Block a user