Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Add migrations for JIT liquidity tables #299

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions alembic/versions/a46974a623b3_add_jit_liquidity_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""add_jit_liquidity_table

Revision ID: a46974a623b3
Revises: 5c5375de15fd
Create Date: 2022-05-10 12:36:57.139209

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "a46974a623b3"
down_revision = "5c5375de15fd"
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
"jit_liquidity",
sa.Column("id", sa.String, primary_key=True),
sa.Column("block_number", sa.Numeric(), nullable=False),
sa.Column("bot_address", sa.String(42), nullable=True),
sa.Column("pool_address", sa.String(42), nullable=False),
sa.Column("token0_address", sa.String(42), nullable=True),
sa.Column("token1_address", sa.String(42), nullable=True),
sa.Column("mint_transaction_hash", sa.String(66), nullable=False),
sa.Column("mint_transaction_trace", sa.ARRAY(sa.Integer)),
sa.Column("burn_transaction_hash", sa.String(66), nullable=False),
sa.Column("burn_transaction_trace", sa.ARRAY(sa.Integer)),
sa.Column("mint_token0_amount", sa.Numeric),
sa.Column("mint_token1_amount", sa.Numeric),
sa.Column("burn_token0_amount", sa.Numeric),
sa.Column("burn_token1_amount", sa.Numeric),
sa.Column("token0_swap_volume", sa.Numeric),
sa.Column("token1_swap_volume", sa.Numeric),
)
op.create_index("ix_jit_liquidity_block_number", "jit_liquidity", ["block_number"])


def downgrade():
op.drop_index("ix_jit_liquidity_block_number")
op.drop_table("jit_liquidity")
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""add_jit_liquidity_swaps_join_table

Revision ID: c77f5db6105e
Revises: a46974a623b3
Create Date: 2022-05-10 12:37:25.275799

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "c77f5db6105e"
down_revision = "a46974a623b3"
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
"jit_liquidity_swaps",
sa.Column("created_at", sa.TIMESTAMP, server_default=sa.func.now()),
sa.Column("jit_liquidity_id", sa.String(1024), primary_key=True),
sa.Column("swap_transaction_hash", sa.String(66), primary_key=True),
sa.Column("swap_trace_address", sa.ARRAY(sa.Integer), primary_key=True),
sa.ForeignKeyConstraint(
["jit_liquidity_id"], ["jit_liquidity.id"], ondelete="CASCADE"
),
)


def downgrade():
op.drop_table("jit_liquidity_swaps")