diff --git a/backend/services/trading-service/src/application/services/asset.service.ts b/backend/services/trading-service/src/application/services/asset.service.ts index 5e2248ae..b8abb536 100644 --- a/backend/services/trading-service/src/application/services/asset.service.ts +++ b/backend/services/trading-service/src/application/services/asset.service.ts @@ -221,6 +221,38 @@ export class AssetService { }; } + /** + * 从 mining-service 获取全网已挖矿产出的积分股总量 + * + * 调用 mining-service 的 GET /mining/progress 接口,返回 totalDistributed + * (用户已挖 + 系统已挖的总和)。 + * + * 该值用于前端"流通池"展示,表示已经通过挖矿产出并进入流通的积分股数量。 + * 注意:此值不参与价格公式计算,价格公式使用的是交易流通池(circulationPool)。 + */ + private async getTotalMinedFromMiningService(): Promise { + try { + const response = await fetch( + `${this.miningServiceUrl}/api/v2/mining/progress`, + ); + + if (!response.ok) { + this.logger.warn(`Failed to fetch mining progress: HTTP ${response.status}`); + return Money.zero(); + } + + const result = await response.json(); + // totalDistributed = 用户已挖总量 + 系统已挖总量 + if (result?.totalDistributed) { + return new Money(result.totalDistributed); + } + return Money.zero(); + } catch (error) { + this.logger.warn(`Failed to fetch total mined from mining-service: ${error}`); + return Money.zero(); + } + } + /** * 获取做市商积分值余额(即价格公式中的"绿积分") */ @@ -241,27 +273,37 @@ export class AssetService { /** * 获取市场概览 + * + * 返回字段说明: + * - circulationPool: 价格公式中的流通池(卖出交易产生的积分股),用于价格/倍数计算 + * - totalMined: 全网已挖矿产出的积分股总量(用户+系统),前端"流通池"展示此值 + * + * 注意:前端"流通池"显示的是 totalMined(已产出积分股),而非 circulationPool。 + * circulationPool 仅在交易发生后才有值,目前系统尚无交易,其值为 0。 + * 用户期望在"流通池"位置看到的是已经挖矿产出的积分股数量,因此新增 totalMined 字段。 */ async getMarketOverview(): Promise<{ price: string; greenPoints: string; blackHoleAmount: string; circulationPool: string; + totalMined: string; effectiveDenominator: string; burnMultiplier: string; totalShares: string; burnTarget: string; burnProgress: string; }> { - const [greenPoints, blackHole, circulationPool] = await Promise.all([ + const [greenPoints, blackHole, circulationPool, totalMined] = await Promise.all([ this.getGreenPoints(), this.blackHoleRepository.getBlackHole(), this.circulationPoolRepository.getPool(), + this.getTotalMinedFromMiningService(), ]); const blackHoleAmount = blackHole?.totalBurned || Money.zero(); const circulationPoolAmount = circulationPool?.totalShares || Money.zero(); - // 计算价格 + // 计算价格(使用交易流通池,非已挖总量) const price = this.calculator.calculatePrice(greenPoints, blackHoleAmount, circulationPoolAmount); // 计算有效分母 @@ -285,6 +327,7 @@ export class AssetService { greenPoints: greenPoints.toFixed(8), blackHoleAmount: blackHoleAmount.toFixed(8), circulationPool: circulationPoolAmount.toFixed(8), + totalMined: totalMined.toFixed(8), effectiveDenominator: effectiveDenominator.toFixed(8), burnMultiplier: burnMultiplier.toFixed(18), totalShares: TradingCalculatorService.TOTAL_SHARES.toFixed(8), diff --git a/frontend/mining-app/lib/data/models/market_overview_model.dart b/frontend/mining-app/lib/data/models/market_overview_model.dart index 436ae179..117538b6 100644 --- a/frontend/mining-app/lib/data/models/market_overview_model.dart +++ b/frontend/mining-app/lib/data/models/market_overview_model.dart @@ -6,6 +6,7 @@ class MarketOverviewModel extends MarketOverview { required super.greenPoints, required super.blackHoleAmount, required super.circulationPool, + required super.totalMined, required super.effectiveDenominator, required super.burnMultiplier, required super.totalShares, @@ -19,6 +20,7 @@ class MarketOverviewModel extends MarketOverview { greenPoints: json['greenPoints']?.toString() ?? '0', blackHoleAmount: json['blackHoleAmount']?.toString() ?? '0', circulationPool: json['circulationPool']?.toString() ?? '0', + totalMined: json['totalMined']?.toString() ?? '0', effectiveDenominator: json['effectiveDenominator']?.toString() ?? '0', burnMultiplier: json['burnMultiplier']?.toString() ?? '0', totalShares: json['totalShares']?.toString() ?? '0', diff --git a/frontend/mining-app/lib/domain/entities/market_overview.dart b/frontend/mining-app/lib/domain/entities/market_overview.dart index d5a55522..0cc9b8f4 100644 --- a/frontend/mining-app/lib/domain/entities/market_overview.dart +++ b/frontend/mining-app/lib/domain/entities/market_overview.dart @@ -8,8 +8,10 @@ class MarketOverview extends Equatable { final String greenPoints; /// 黑洞销毁量 final String blackHoleAmount; - /// 流通池 + /// 流通池(价格公式用,卖出交易产生的积分股) final String circulationPool; + /// 已挖矿产出总量(用户+系统),前端"流通池"展示此值 + final String totalMined; /// 有效分母 final String effectiveDenominator; /// 销毁倍数 @@ -26,6 +28,7 @@ class MarketOverview extends Equatable { required this.greenPoints, required this.blackHoleAmount, required this.circulationPool, + required this.totalMined, required this.effectiveDenominator, required this.burnMultiplier, required this.totalShares, @@ -39,6 +42,7 @@ class MarketOverview extends Equatable { greenPoints, blackHoleAmount, circulationPool, + totalMined, effectiveDenominator, burnMultiplier, totalShares, diff --git a/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart b/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart index fc20c0ad..97023bb8 100644 --- a/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart +++ b/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart @@ -363,9 +363,11 @@ class _TradingPageState extends ConsumerState { ), Container(width: 1, height: 24, color: bgGray), const SizedBox(width: 16), + // 流通池:显示全网已挖矿产出的积分股总量(totalMined), + // 而非交易流通池(circulationPool,目前无交易故为0) _buildMarketDataItem( '流通池', - market != null ? formatCompact(market.circulationPool) : null, + market != null ? formatCompact(market.totalMined) : null, _orange, isLoading, ),