import os
from dotenv import load_dotenv

# Load the .env file
load_dotenv()

class Config:
    """Centralized configuration manager."""
    
    # Polymarket
    KEY = os.getenv("POLY_KEY")
    FUNDER = os.getenv("POLY_FUNDER")
    HOST = os.getenv("POLY_HOST", "https://clob.polymarket.com")
    CHAIN_ID = int(os.getenv("POLY_CHAIN_ID", 137))
    # Default Trade Settings (Used if Payload is missing values)
    DEFAULT_SIZE = 2.0
    DEFAULT_PRICE = 0.99
    ASSETS_TO_TRACK = ["btc", "eth"] # Add "etf" here if needed

    
    # App Settings
    PORT = int(os.getenv("FLASK_PORT", 80))
    LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")

    @classmethod
    def validate(cls):
        """Ensure all critical keys are present."""
        required = ["KEY", "FUNDER"]
        for var in required:
            if not getattr(cls, var):
                raise ValueError(f"CRITICAL ERROR: {var} is missing from .env file!")

# Validate on import
Config.validate()
