diff --git a/backend/app/config.py b/backend/app/config.py index fea9dcf..249bf3d 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -212,8 +212,8 @@ class Settings(BaseSettings): hyperliquid_trading_enabled: bool = False # Hyperliquid 实盘交易开关(默认关闭) # Hyperliquid 环境变量(由 clawfi-hyperliquid-skill 安装脚本注入) - # CLAWFI_WALLET_ADDRESS - 主钱包地址 - # CLAWFI_PRIVATE_KEY - Agent 专用私钥 + clawfi_wallet_address: Optional[str] = None # 主钱包地址 + clawfi_private_key: Optional[str] = None # Agent 专用私钥 # Hyperliquid 风险控制 hyperliquid_max_total_leverage: float = 10.0 # 总杠杆上限(≤10x,ClawFi 强制规则) diff --git a/backend/app/services/hyperliquid_trading_service.py b/backend/app/services/hyperliquid_trading_service.py index 63447a0..908f7ff 100644 --- a/backend/app/services/hyperliquid_trading_service.py +++ b/backend/app/services/hyperliquid_trading_service.py @@ -28,14 +28,14 @@ class HyperliquidTradingService: self.settings = get_settings() - # 从环境变量加载认证信息 - self.wallet_address = os.getenv("CLAWFI_WALLET_ADDRESS") - self.private_key = os.getenv("CLAWFI_PRIVATE_KEY") + # 从 settings 加载认证信息 + self.wallet_address = self.settings.clawfi_wallet_address + self.private_key = self.settings.clawfi_private_key if not self.wallet_address or not self.private_key: raise ValueError( - "缺少 Hyperliquid 认证信息。请运行: " - "npx clawfi-hyperliquid-skill --wallet=0x... --key=0x..." + "缺少 Hyperliquid 认证信息。请在 .env 中设置: " + "CLAWFI_WALLET_ADDRESS 和 CLAWFI_PRIVATE_KEY" ) # 风控配置