Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: added liquidation model #572

Merged
merged 10 commits into from
Feb 20, 2025
1 change: 1 addition & 0 deletions margin_app/app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

from app.models.base import BaseModel
from app.models.user import User
from app.models.liquidation import Liquidation
30 changes: 30 additions & 0 deletions margin_app/app/models/liquidation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Liquidation model
"""

import uuid

from datetime import datetime
from decimal import Decimal
from sqlalchemy import DateTime, String, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import BaseModel

class Liquidation(BaseModel):
"""
Liquidation Model
Columns:
margin_position_id: Foreign key referencing MarginPosition.id.
bonus_amount: The amount of bonus given during liquidation.
bonus_token: The token in which the bonus is given.
created_at: Timestamp when the liquidation was created.
"""

margin_position_id: Mapped[UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("margin_position.id"),
nullable=False
)
bonus_amount: Mapped[Decimal] = mapped_column(nullable=False)
bonus_token: Mapped[str] = mapped_column(String, nullable=False)