
- 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>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
import os
|
|
from pathlib import Path
|
|
from typing import List, Optional, Union
|
|
|
|
from pydantic import field_validator
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Solana Arbitrage Analytics"
|
|
|
|
# CORS
|
|
BACKEND_CORS_ORIGINS: List[str] = ["*"]
|
|
|
|
# Solana RPC endpoint
|
|
SOLANA_RPC_URL: str = os.getenv("SOLANA_RPC_URL", "https://api.mainnet-beta.solana.com")
|
|
|
|
# Database settings
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
# Solana settings
|
|
BLOCKS_TO_FETCH: int = 100 # Number of blocks to fetch in a batch
|
|
POLLING_INTERVAL: int = 60 # Seconds between polling new blocks
|
|
|
|
@field_validator("BACKEND_CORS_ORIGINS")
|
|
@classmethod
|
|
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
elif isinstance(v, (list, str)):
|
|
return v
|
|
raise ValueError(v)
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
env_file = ".env"
|
|
|
|
# Ensure DB directory exists
|
|
settings = Settings()
|
|
settings.DB_DIR.mkdir(parents=True, exist_ok=True) |