
- Create project structure with FastAPI - Add database models for blocks, transactions, arbitrages, pools, and DEXes - Implement Solana RPC client for fetching blockchain data - Create arbitrage detection algorithm - Implement comprehensive API endpoints for analytics - Set up database migrations with Alembic - Add detailed project documentation generated with BackendIM... (backend.im) Co-Authored-By: Claude <noreply@anthropic.com>
32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
from datetime import datetime
|
|
from sqlalchemy import (
|
|
Column, Integer, String, DateTime, BigInteger,
|
|
Float, Boolean, ForeignKey, Text, JSON
|
|
)
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Transaction(Base):
|
|
"""Solana blockchain transaction model."""
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
block_id = Column(Integer, ForeignKey("block.id"), nullable=False)
|
|
transaction_hash = Column(String, unique=True, index=True, nullable=False)
|
|
slot = Column(BigInteger, index=True, nullable=False)
|
|
signature = Column(String, unique=True, index=True, nullable=False)
|
|
success = Column(Boolean, nullable=False, default=False)
|
|
fee = Column(BigInteger, nullable=True)
|
|
fee_payer = Column(String, index=True, nullable=True)
|
|
program_ids = Column(JSON, nullable=True) # Array of program IDs involved
|
|
accounts = Column(JSON, nullable=True) # Array of account addresses involved
|
|
raw_data = Column(Text, nullable=True) # Raw transaction data for detailed analysis
|
|
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
|
|
|
# Relationships
|
|
block = relationship("Block", back_populates="transactions")
|
|
arbitrages = relationship("Arbitrage", back_populates="transaction", cascade="all, delete-orphan")
|
|
|
|
def __repr__(self):
|
|
return f"<Transaction(hash={self.transaction_hash}, success={self.success})>" |