From 4a69fdd07021b02214755c7baeaf9037ab127fba Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 3 Feb 2026 04:09:00 -0800 Subject: [PATCH] =?UTF-8?q?fix(trading):=20getConfig=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E4=BB=8E=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E5=A1=AB=E5=85=85?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E9=92=B1=E5=8C=85=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前只有 initializeConfig 会读取 env 填充钱包地址, getConfig 只读数据库。导致新增 eusdtWalletAddress 字段后 即使 .env 配置了地址,前端仍显示"未配置"。 Co-Authored-By: Claude Opus 4.5 --- .../services/market-maker.service.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/services/trading-service/src/application/services/market-maker.service.ts b/backend/services/trading-service/src/application/services/market-maker.service.ts index 0c86e9bf..a98e0ab1 100644 --- a/backend/services/trading-service/src/application/services/market-maker.service.ts +++ b/backend/services/trading-service/src/application/services/market-maker.service.ts @@ -85,6 +85,25 @@ export class MarketMakerService { }); if (!config) return null; + // 自动从环境变量填充空的钱包地址 + const updateData: Record = {}; + if (!config.kavaWalletAddress) { + const addr = this.configService.get('FUSDT_MARKET_MAKER_ADDRESS'); + if (addr) updateData.kavaWalletAddress = addr; + } + if (!config.eusdtWalletAddress) { + const addr = this.configService.get('EUSDT_MARKET_MAKER_ADDRESS'); + if (addr) updateData.eusdtWalletAddress = addr; + } + if (Object.keys(updateData).length > 0) { + await this.prisma.marketMakerConfig.update({ + where: { name }, + data: updateData, + }); + Object.assign(config, updateData); + this.logger.log(`Auto-filled wallet addresses from env for ${name}: ${JSON.stringify(updateData)}`); + } + // 从交易账户获取实际余额(保证一致性) const tradingAccount = await this.accountRepository.findByAccountSequence(config.accountSequence); const cashBalance = tradingAccount ? new Decimal(tradingAccount.cashBalance.value.toString()) : new Decimal(0);