Skip to content

Commit

Permalink
Merge pull request #10 from yuriiz/master
Browse files Browse the repository at this point in the history
Skip failed swaps
  • Loading branch information
Pavel authored Jul 2, 2021
2 parents 40e8ad4 + 80c3c92 commit 8568d0a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
56 changes: 56 additions & 0 deletions alembic/versions/8dd169389646_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""empty message
Revision ID: 8dd169389646
Revises: 29c9ff4e6926
Create Date: 2021-07-02 11:44:43.666306
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "8dd169389646"
down_revision = "29c9ff4e6926"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("pair", "token1_volume")
op.drop_column("pair", "token0_volume")
op.drop_column("token", "trade_volume")
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"token",
sa.Column(
"trade_volume",
sa.NUMERIC(precision=34, scale=0),
autoincrement=False,
nullable=True,
),
)
op.add_column(
"pair",
sa.Column(
"token0_volume",
sa.NUMERIC(precision=34, scale=0),
autoincrement=False,
nullable=True,
),
)
op.add_column(
"pair",
sa.Column(
"token1_volume",
sa.NUMERIC(precision=34, scale=0),
autoincrement=False,
nullable=True,
),
)
# ### end Alembic commands ###
32 changes: 32 additions & 0 deletions alembic/versions/e3e1a25cae68_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""empty message
Revision ID: e3e1a25cae68
Revises: 8dd169389646
Create Date: 2021-07-02 11:47:57.854369
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "e3e1a25cae68"
down_revision = "8dd169389646"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("pair", sa.Column("token0_volume", sa.Numeric(), nullable=True))
op.add_column("pair", sa.Column("token1_volume", sa.Numeric(), nullable=True))
op.add_column("token", sa.Column("trade_volume", sa.Numeric(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("token", "trade_volume")
op.drop_column("pair", "token1_volume")
op.drop_column("pair", "token0_volume")
# ### end Alembic commands ###
6 changes: 3 additions & 3 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Token(Base):
symbol = Column(String(8), nullable=False)
name = Column(String(128), nullable=False)
decimals = Column(Integer, nullable=False)
trade_volume = Column(Numeric(34))
trade_volume = Column(Numeric())


class Pair(Base):
Expand All @@ -39,8 +39,8 @@ class Pair(Base):
foreign_keys=[token1_id],
backref=backref("pairs1", uselist=True, cascade="delete,all"),
)
token0_volume = Column(Numeric(34))
token1_volume = Column(Numeric(34))
token0_volume = Column(Numeric())
token1_volume = Column(Numeric())


class Swap(Base):
Expand Down
2 changes: 2 additions & 0 deletions processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def process_swap_transaction(timestamp, extrinsicEvents, ex_dict):
for event in extrinsicEvents:
if event["event_id"] == "SwapSuccess":
swap_success = True
elif event["event_id"] == "ExtrinsicFailed":
swap_success = False
elif event["event_id"] == "Exchange":
input_amount = event["params"][4]["value"]
output_amount = event["params"][5]["value"]
Expand Down

0 comments on commit 8568d0a

Please sign in to comment.