hailin
534d4ce70c
fix(2.0): 所有 Kafka consumer 改为 fromBeginning: true 确保 full-reset 全量同步
...
- mining-blockchain-service: withdrawal/mpc/deposit-ack consumer 改为 fromBeginning: true
- trading-service: cdc-consumer/market-maker-deposit consumer 改为 fromBeginning: true
- mining-service: contribution-event handler 改为 fromBeginning: true
- deploy-mining.sh: CDC_CONSUMER_GROUPS 补充所有 2.0 服务的 consumer group ID
确保 ./deploy-mining.sh full-reset 可以 100% 从 0 开始同步所有 1.0 数据。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 22:20:23 -08:00
hailin
7e289430ae
feat(auth-service): CDC 同步 wallet_addresses 并提供内部 API
...
- auth-service: 新增 SyncedWalletAddress Prisma model 和 migration
- auth-service: 新增 WalletAddressCdcConsumer 消费 1.0 钱包地址变更
- auth-service: 新增 InternalController 提供 kava 地址查询 API
- trading-service: IdentityClient 改调 auth-service 内部 API
- docker-compose.2.0.yml: 添加 CDC_TOPIC_WALLET_ADDRESSES 和 AUTH_SERVICE_URL
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 12:20:23 -08:00
hailin
83fa6bec74
feat(c2c): 支持绿积分(GREEN_POINTS)作为默认支付方式
...
- 后端 paymentMethod 字段从 PostgreSQL 枚举改为 String,支持逗号分隔多种支付方式
- 添加数据库迁移将 C2cPaymentMethod 枚举列转为 TEXT 类型
- DTO 验证改为 @IsString() 接受 GREEN_POINTS 及其组合
- 前端保持发送完整的支付方式列表(含 GREEN_POINTS)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 11:39:00 -08:00
hailin
263f1ecf8e
feat(c2c): 卖单自动获取账户ID和Kava地址,移除手动输入
...
后端创建卖单时自动从 identity-service 获取卖家 Kava 地址并存入订单,
前端发布页面自动展示 accountSequence(只读),不再需要手动输入1.0系统ID。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 11:08:56 -08:00
hailin
776d181ef3
fix(trading-service): 修复P2P转账API响应双重包装问题
...
- 移除controller中的手动包装,由TransformInterceptor统一处理
- 前端增加类型检查防止解析错误
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:11:59 -08:00
hailin
28c73136a8
fix(trading-service): 修复P2P转账历史查询参数解析
...
确保 page 和 pageSize 是有效数字,避免 skip: NaN 错误
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:00:28 -08:00
hailin
dcc83b9f79
fix(trading-service): 使用Docker容器名调用auth-service
...
改为使用 auth-service:3024 替代 IP 地址
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 08:56:24 -08:00
hailin
8b459dd33f
fix(trading-service): 修复P2P转账AUTH_SERVICE_URL默认值
...
默认值从localhost改为内网IP,解决Docker环境中调用auth-service失败的问题
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 08:49:54 -08:00
hailin
40389fcfc7
feat(trading-service, mining-admin-web): 支持在管理后台配置做市商钱包地址
...
- 后端: 在 UpdateConfigDto 和 updateConfig 方法中添加 kavaWalletAddress 字段
- 前端: 在充值对话框中添加钱包地址配置输入框
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 07:53:04 -08:00
hailin
7a8a3a8fd1
feat(trading-service): 初始化做市商时自动读取环境变量配置钱包地址
...
- 从 FUSDT_MARKET_MAKER_ADDRESS 环境变量读取做市商钱包地址
- 初始化时自动设置 kavaWalletAddress
- 如果做市商已存在但钱包地址为空,也会从环境变量更新
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 07:31:16 -08:00
hailin
812b127ace
fix(trading-service): 添加缺失的数据库字段迁移
...
Schema 中有但 migration 中缺失的字段:
- market_maker_configs: kava_wallet_address, mpc_username
- c2c_orders: seller_kava_address, bot_purchased, payment_tx_hash
这些字段缺失导致 500 错误:
"The column `market_maker_configs.kava_wallet_address` does not exist"
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 07:20:21 -08:00
hailin
58feec255d
feat(market-maker): 实现做市商区块链充提功能
...
- 扩展 mining-blockchain-service 支持 eUSDT/fUSDT 转账
- 添加 trading-service 区块链提现 API(自动回滚失败交易)
- 前端支持中心化和区块链充提两种模式(Tab切换)
- 区块链充值显示钱包地址和二维码
- 区块链提现支持输入目标地址直接转账
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:56:15 -08:00
hailin
94f9e7d5b5
fix(trading-service): 使用事务确保成交时账户余额更新的原子性
...
## 问题描述
用户 D25122700015 的卖单成交后,订单状态变为 FILLED,成交记录存在,
但 frozenShares 未释放,cashBalance 未增加,交易流水缺少 SELL 记录。
## 根本原因
`tryMatch` 方法中的数据库操作没有使用事务:
1. trade.create - 单独提交
2. orderRepository.save - 单独提交
3. accountRepository.save(buyerAccount) - 单独提交
4. accountRepository.save(sellerAccount) - 可能因前面异常而跳过
如果步骤 1-3 成功但步骤 4 失败,会导致:
- 成交记录存在 ✓
- 订单状态 FILLED ✓
- 买方账户正常 ✓
- 卖方账户未更新 ✗
## 修复方案
使用 Prisma 事务包装所有关键操作,确保原子性:
1. 创建成交记录
2. 更新买单状态
3. 更新卖单状态(含销毁信息)
4. 更新买方账户(扣除冻结现金,增加积分股)
5. 更新卖方账户(扣除冻结积分股,增加现金)
6. 记录交易流水
任何一步失败,整个事务回滚。
## 受影响用户
- D25122700015: 订单 OMKXYTXS6KKC3A6
- 成交记录: TMKXYTXXH8CYQZ7
- 需要手动修复现有数据
## 回滚方法
git revert <此commit>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:20:31 -08:00
hailin
1974c43eba
feat(market-maker): 实现做市商区块链充值监控功能
...
- mining-blockchain-service:
- 添加 MarketMakerDeposit 和 MarketMakerBlockCheckpoint 表
- 添加 eUSDT/fUSDT 代币合约配置
- 实现做市商钱包充值检测服务
- 添加启动时配置验证和错误日志
- 发布充值确认事件到 Kafka
- trading-service:
- 添加做市商充提记录表 (MarketMakerDeposit, MarketMakerWithdraw)
- 添加 Kafka 消费者监听充值确认事件
- 实现充值自动入账和流水记录
- 部署配置:
- 更新 docker-compose 添加新环境变量
- 更新 deploy-mining.sh 添加 blockchain 服务
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:13:41 -08:00
hailin
042a52550b
feat(c2c): 实现C2C Bot自动交易系统
...
- 创建独立的 mining-blockchain-service 服务 (基于 blockchain-service)
- 添加 dUSDT 转账接口供 C2C Bot 调用
- 实现 C2cBotService 自动购买卖单
- 实现 C2cBotScheduler 每10秒扫描待处理卖单
- 添加 BlockchainClient 和 IdentityClient 客户端
- 更新 C2cOrder 模型添加 Bot 购买相关字段
- 使用 MPC 热钱包签名交易
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:10:25 -08:00
hailin
2597d0ef46
feat: 实现P2P转账功能及前端资产页面优化
...
- trading-service: 添加P2pTransfer模型和P2P转账API
- auth-service: 添加用户手机号查询接口用于转账验证
- frontend: 修复资产页面冻结份额显示和转账页面余额字段
- frontend: 添加P2P转账记录页面
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 06:25:42 -08:00
hailin
81b2e7a4c2
refactor(migrations): 合并各服务的 migration 文件为单个 0001_init
...
将各服务的多个 migration 文件合并到单一的初始化 migration 中:
- contribution-service: 3→1 (含 region 支持)
- mining-service: 4→1 (含 second 分配和 region 支持)
- mining-admin-service: 4→1 (含 region 和算力明细同步)
- auth-service: 2→1 (含 CDC 幂等)
- trading-service: 9→1 (含销毁系统/做市商/C2C)
- mining-wallet-service: 2→1 (含 SHARE_POOL 拆分)
所有迁移统一使用 TEXT 类型(非 VARCHAR)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:34:56 -08:00
hailin
e8e1193387
fix(trading): 添加 original_quantity 数据库迁移文件
...
修复服务器上缺少 trades.original_quantity 列的问题
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 08:21:29 -08:00
hailin
995dfa898e
feat(trading): 添加涨跌幅显示及修复成交明细数据
...
1. 后端:
- 添加 getFirstSnapshot() 获取上线首日价格
- PriceInfo 接口增加 priceChangePercent 和 initialPrice 字段
- 计算涨跌幅 = (当前价格 - 首日价格) / 首日价格 × 100%
- 修复 originalQuantity 为0时的数据计算逻辑
2. 前端:
- 交易页面涨跌幅移到价格下方单独显示
- 添加"较上线首日"说明文字
- 根据涨跌正负显示不同颜色和图标
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 05:24:23 -08:00
hailin
8728fdce4c
feat(trading): 成交明细显示完整卖出信息(销毁倍数、有效积分股、手续费等)
...
- 后端Trade表新增originalQuantity字段存储原始卖出数量
- quantity字段改为存储有效积分股(含销毁倍数)
- API返回完整明细:销毁倍数、有效积分股、交易总额、进入积分股池
- 前端成交明细页面显示完整卖出信息,类似确认卖出弹窗样式
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 04:07:52 -08:00
hailin
7da98c248b
feat(trading): 交易记录页面添加成交明细Tab,显示手续费
...
后端:
- trading-service 添加 GET /trading/trades API 获取成交记录
- 成交记录包含: 交易总额、手续费(10%)、实际收到金额
前端:
- 新增 TradeRecord 实体和 TradesPageModel
- 交易记录页面添加 Tab: "订单记录" 和 "成交明细"
- 成交明细显示: 价格、数量、交易总额、手续费、实际收到
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 03:15:25 -08:00
hailin
13f1b687ee
feat(kline): add dynamic history loading on pan
...
Add support for loading more K-line history data when user pans to the
left edge. Backend API now accepts 'before' parameter for pagination.
Frontend uses KlinesNotifier to manage accumulated data with proper
deduplication.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 22:21:39 -08:00
hailin
d8df50a68f
fix(c2c): 修复分页参数类型转换问题导致的500错误
...
- 为 QueryC2cOrdersDto 和 QueryMyC2cOrdersDto 的 page/pageSize 字段添加 @Type(() => Number) 装饰器
- Query参数从URL获取时默认为字符串,需要显式转换为数字类型
- 添加 @IsInt() 验证确保参数为整数
- 修复 Prisma findMany take 参数期望 Int 但收到 String 的错误
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 18:32:38 -08:00
hailin
af339b19b9
feat(c2c): 完善C2C场外交易功能 - 收款信息与订单超时处理
...
## 后端更新
### Prisma Schema (0008_add_c2c_orders migration)
- 新增 C2cPaymentMethod 枚举 (ALIPAY/WECHAT/BANK)
- C2cOrder 模型新增字段:
- 收款信息:paymentMethod, paymentAccount, paymentQrCode, paymentRealName
- 超时配置:paymentTimeoutMinutes (默认15分钟), confirmTimeoutMinutes (默认60分钟)
- 截止时间:paymentDeadline, confirmDeadline
- 新增索引优化超时查询
### API层
- c2c.dto.ts: 新增收款信息和超时配置字段
- c2c.controller.ts: 新增C2C控制器,支持完整的订单生命周期管理
### 业务层
- c2c.service.ts:
- createOrder: 卖单必须提供收款信息验证
- takeOrder: 接单时自动设置付款截止时间
- confirmPayment: 确认付款时设置确认收款截止时间
- processExpiredOrders/expireOrder: 处理超时订单(释放冻结资产)
- c2c-expiry.scheduler.ts: 每分钟执行超时订单检查(带分布式锁)
### 数据层
- c2c-order.repository.ts: 新增 findExpiredOrders 方法
- trading-account.repository.ts: 新增 unfreezeShares/unfreezeCash 方法
## 前端更新
### 数据模型
- c2c_order_model.dart:
- 新增 C2cPaymentMethod 枚举
- 新增收款信息和超时相关字段
- 新增辅助方法:paymentMethodText, hasPaymentInfo, paymentRemainingSeconds, confirmRemainingSeconds
### API层
- trading_remote_datasource.dart: createC2cOrder/takeC2cOrder 支持收款信息参数
### 状态管理
- c2c_providers.dart: createOrder/takeOrder 方法支持收款信息参数
### UI层
- c2c_publish_page.dart:
- 新增收款方式选择器 (支付宝/微信/银行卡)
- 新增收款账号和收款人姓名输入框
- 卖单发布时验证收款信息必填
- 确认对话框显示收款信息摘要
- c2c_order_detail_page.dart:
- 新增收款信息卡片展示(买家视角/卖家视角区分)
- 新增倒计时进度条显示(付款/确认收款截止时间)
- 剩余时间<5分钟时高亮警告
- 支持复制收款账号
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 07:17:22 -08:00
hailin
c05bcc9a76
feat(trading): 实现10%交易手续费进入积分股池
...
- 在成交时从卖方收益中扣除10%手续费
- 手续费流入积分股池(greenPoints/200万账户)
- 添加详细分类账记录,包含买卖双方账户和来源标注
- Trade表新增fee字段记录每笔交易的手续费
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 21:33:40 -08:00
hailin
192e2551bf
feat(trading): 资产页面实时价格 WebSocket 推送
...
## 后端变更
- 添加 @nestjs/websockets, @nestjs/platform-socket.io, socket.io 依赖
- 新增 PriceGateway (price.gateway.ts): WebSocket 网关,namespace /price
- 新增 PriceBroadcastScheduler: 每秒广播价格更新到所有连接的客户端
- 更新 ApiModule 和 ApplicationModule 注册新模块
## Kong API Gateway
- 添加 WebSocket 路由: /ws/price -> trading-service:3022/price
- 支持 ws/wss 协议
## 前端变更
- 添加 socket_io_client 依赖
- 新增 PriceWebSocketService: 带自动断线重连机制的 WebSocket 服务
- 指数退避重连策略 (1s -> 30s)
- 最大重连次数 10 次
- 连接状态流监听
- 资产页面集成 WebSocket:
- initState 时连接,dispose 时断开
- 实时更新价格和销毁倍数
- 保持原有的每秒积分股增长计算
## 调试日志
- 前后端都添加了详细的调试日志方便排查问题
- 日志前缀: [PriceWS], [AssetPage], [PriceGateway], [PriceBroadcastScheduler]
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 21:18:34 -08:00
hailin
f6458dd12e
fix(trading): 做市商吃单间隔从1-4秒改为固定1秒
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 21:00:21 -08:00
hailin
07247fe05f
fix: 将划转最小限制从5改为0.01积分股
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 19:29:05 -08:00
hailin
b7c8cdd249
fix(trading): 销毁和快照只在交易系统激活时执行
...
- BurnScheduler 检查 trading_configs.isActive 状态
- 交易系统未激活时跳过每分钟销毁和价格快照
- 交易系统未激活时跳过每小时状态日志
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 08:28:48 -08:00
hailin
096d87e2a8
fix(trading): 区分买方支付和卖方收款金额
...
问题:executeBuy使用含销毁倍数的tradeAmount,但买方冻结的是原始金额
原因:买方支付=原始数量×价格,卖方收款=有效数量×价格(含销毁)
修复:
- buyerPayAmount = tradeQuantity × price(买方实际支付)
- sellerReceiveAmount = effectiveQuantity × price(卖方实际收款)
- executeBuy 使用 buyerPayAmount
- executeSell 使用 sellerReceiveAmount
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 08:08:58 -08:00
hailin
64b9dcb6c7
fix(trading): 修复订单撮合时buyOrderId为null的问题
...
问题:在createOrder中调用tryMatch时,传入的order对象没有id
原因:orderRepository.save()返回orderId但没有更新到order对象
解决:保存后重新从数据库获取订单,确保有id再进行撮合
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 07:44:44 -08:00
hailin
1760f9b82c
fix(trading): 为所有 DTO 添加 class-validator 装饰器
...
修复 trading.controller、admin.controller、transfer.controller
的 DTO 验证问题,解决 App 下单时 400 错误。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 06:14:06 -08:00
hailin
edd6ced2a3
fix(trading): 为做市商 DTO 添加 class-validator 装饰器
...
修复做市商初始化失败问题。由于 ValidationPipe 配置了
forbidNonWhitelisted: true,没有装饰器的属性会被拒绝。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 05:47:03 -08:00
hailin
5a719eef61
fix(trading): 合并销毁和快照任务确保K线价格正确
...
将 executeMinuteBurn 和 createPriceSnapshot 合并为单个 cron 任务,
确保快照在销毁完成后创建,避免K线出现价格不变的间隔
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 23:26:04 -08:00
hailin
b1fedd417f
fix(trading): 修复 migration 执行顺序问题
...
将 0003_add_market_maker_depth 重命名为 0006_add_market_maker_depth,
确保在 0005_add_market_maker_and_order_source 创建 market_maker_configs 表
之后再执行添加深度字段的 migration。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:59:06 -08:00
hailin
3265ee2506
feat(trading): 将初始绿积分从5760调整为57.6亿
...
## 变更说明
将积分股池的初始绿积分从 5760 调整为 5,760,000,000 (57.6亿)
### 价格影响
- 初始价格:5760 / 100.02亿 ≈ 5.76×10⁻⁷ → 57.6亿 / 100.02亿 ≈ 0.576
- 价格从极小数值变为正常交易数值
- 更符合实际交易习惯
### 技术评估
- 数据库精度 Decimal(30,8) 完全足够
- 价格公式线性放大,逻辑不变
- 销毁倍数公式不涉及 greenPoints,不受影响
- "越卖越涨"机制保持不变
### 修改文件
- prisma/seed.ts: 初始化种子数据
- burn.service.ts: 运行时初始化逻辑
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:50:43 -08:00
hailin
8c78f26e6d
feat(trading): 实现做市商吃单/挂单模式互斥机制
...
## 后端 - trading-service
### MarketMakerService
- 新增 MarketMakerMode 类型:'idle' | 'taker' | 'maker'
- 新增 getCurrentMode() 和 getRunningStatus() 方法获取当前运行状态
- start() (吃单模式): 启动前自动停止挂单模式
- startMaker() (挂单模式): 启动前自动停止吃单模式
- 两种模式互斥,同一时间只能运行一种
### MarketMakerController
- getConfig 接口返回 runningStatus 运行状态
- 新增 GET /status 接口获取做市商运行状态
## 前端 - mining-admin-web
### 做市商管理页面
- 新增运行模式状态卡片,显示当前模式(空闲/吃单/挂单)
- 吃单模式和挂单模式使用 runningStatus 判断状态
- 添加互斥提示:启动一个模式会自动停止另一个
- 挂单模式添加警告提示:卖单被吃会触发销毁导致价格上涨
### API 更新
- 新增 RunningStatus 接口类型
- getConfig 返回类型增加 runningStatus
- 新增 getRunningStatus API
## 设计说明
- 吃单模式(推荐):做市商只作为买方,不触发额外销毁
- 挂单模式(谨慎使用):做市商挂卖单会触发销毁机制
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:41:39 -08:00
hailin
3b6bd29283
feat(trading): 实现完整的CEX做市商双边深度系统
...
## 后端 - trading-service
### 数据库模型扩展 (Prisma Schema)
- TradingConfig: 新增 depthEnabled 字段控制深度显示开关
- MarketMakerConfig: 新增双边挂单配置
- makerEnabled: 做市商挂单模式开关
- bidEnabled/askEnabled: 买/卖方向独立开关
- bidLevels/askLevels: 买/卖档位数量
- bidSpread/askSpread: 买/卖价差比例
- bidLevelSpacing/askLevelSpacing: 档位间距
- bidQuantityPerLevel/askQuantityPerLevel: 每档数量
- refreshIntervalMs: 刷新间隔
- MarketMakerOrder: 新增做市商订单追踪模型
- MarketMakerLedger: 新增做市商账户流水模型
### 做市商服务 (MarketMakerService)
- depositShares/withdrawShares: 积分股充值/提现
- startMaker/stopMaker: 做市商挂单模式启停
- refreshMakerOrders: 核心双边挂单逻辑
- 根据当前价格计算买卖各档位价格和数量
- 自动撤销旧订单并创建新订单
- 记录做市商订单关联
- cancelAllMakerOrders: 撤销所有做市商订单
- getDepth: 获取订单簿深度数据
- updateMakerConfig/getMakerOrders: 配置和订单查询
### API 端点
- MarketMakerController:
- POST /deposit-shares: 积分股充值
- POST /withdraw-shares: 积分股提现
- POST /start-maker: 启动挂单模式
- POST /stop-maker: 停止挂单模式
- POST /refresh-orders: 手动刷新订单
- POST /cancel-all-orders: 撤销所有订单
- PUT /maker-config: 更新挂单配置
- GET /maker-orders: 查询做市商订单
- GET /depth: 获取深度数据
- AdminController:
- GET/POST /trading/depth-enabled: 深度显示开关
- PriceController:
- GET /depth: 公开深度接口 (受 depthEnabled 控制)
### 领域层扩展
- TradingAccountAggregate: 新增 depositShares/withdrawShares 方法
- OrderAggregate: 支持 source 字段标识订单来源
## 前端 - mining-admin-web
### 做市商管理页面 (/market-maker)
- 账户余额展示: 积分值和积分股余额
- 资金管理: 积分值/积分股的充值和提现对话框
- 吃单模式: 启动/停止/手动吃单控制
- 挂单模式: 启动/停止/刷新订单/撤销所有
- 深度开关: 控制公开 API 是否返回深度数据
- 深度展示: 实时显示买卖盘深度数据表格
### 前端架构
- market-maker.api.ts: 完整的 API 客户端
- use-market-maker.ts: React Query hooks 封装
- sidebar.tsx: 新增"做市商管理"导航菜单
## 数据库迁移
- 0003_add_market_maker_depth: 双边深度相关字段
- 0005_add_market_maker_and_order_source: 订单来源追踪
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:11:23 -08:00
hailin
11ff3cc9bd
fix: correct totalShares and distributionPool values
...
- totalShares: 100020000000 → 10002000000 (100.02亿 = 100亿 + 200万)
- distributionPool: 200000000 → 2000000 (200万)
Fixed in:
- trading-service/prisma/schema.prisma
- trading-service/prisma/migrations/0002_add_trading_burn_system/migration.sql
- mining-service/.env.example
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:01:17 -08:00
hailin
481a355d72
feat(trading): add buy function control switch with admin management
...
- Add buyEnabled field to TradingConfig in trading-service with migration
- Add API endpoints for get/set buy enabled status in admin controller
- Add buy function switch card in mining-admin-web trading page
- Implement buyEnabledProvider in mining-app with 2-minute cache
- Show "待开启" when buy function is disabled in trading page
- Add real-time asset value refresh in asset page (1-second updates)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:56:35 -08:00
hailin
72b3b44d37
feat(trading): 实现K线图真实数据展示与Y轴自适应
...
后端 (trading-service):
- 新增 GET /api/v2/price/klines API 端点
- 支持多周期K线聚合 (1m/5m/15m/30m/1h/4h/1d)
- 将 PriceSnapshot 数据聚合为 OHLC 格式
前端 (mining-app):
- 添加 klinesProvider 获取K线数据
- 重写 _CandlestickPainter 使用真实数据
- 实现 Y轴自适应显示,放大价格变化
- 周期选择器联动数据刷新
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 23:57:12 -08:00
hailin
8018fa5110
feat(admin): add trading system management UI and API
...
- Add trading system activate/deactivate endpoints to trading-service
- Add trading management page to mining-admin-web with:
- Trading system status display and control
- Market overview (price, green points, circulation pool)
- Burn progress visualization
- Burn records list with filtering
- Add trading-service proxy configuration to next.config.js
- Add trading menu item to sidebar navigation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 20:37:52 -08:00
hailin
1e2d8d1df7
feat(asset): aggregate mining and trading account balances in asset display
...
- Modify AssetService to fetch mining account balance from mining-service
- Sum mining balance + trading balance for total share display
- Add miningShareBalance and tradingShareBalance fields to AssetDisplay
- Update frontend entity and model to support new fields
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 19:53:31 -08:00
hailin
ed715111ae
fix(trading): auto-initialize SharePool and CirculationPool on startup
...
- Add SharePool and CirculationPool initialization in BurnService.initialize()
- Initialize SharePool with 5760 green points (fixes price showing as 0)
- Remove misleading "= 5,760 积分值" display from trading page
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 19:32:46 -08:00
hailin
e611894b55
fix(trading-service): use payload.sub as accountSequence in JWT guard
...
auth-service puts accountSequence in payload.sub, not payload.accountSequence.
This mismatch caused 401 errors when accessing trading endpoints.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 17:54:28 -08:00
hailin
0420b0acab
fix(trading,auth): add parent .env path for shared JWT_SECRET
...
Both services need to read JWT_SECRET from the shared .env file
in the parent directory (backend/services/.env).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:57:57 -08:00
hailin
40869ef00f
feat: split share pool into A (100亿) and B (200万) accounts
...
Backend changes:
- mining-wallet-service: Split SHARE_POOL into SHARE_POOL_A (100亿, for burning)
and SHARE_POOL_B (200万, for mining distribution)
- Add /pool-accounts/share-pool-balance API endpoint to get total balance
- Update pool initialization logic and seed data
- Fix Kong routing for mining-wallet-service (strip_path: true)
- Fix Kong routing for trading-service (strip_path: true)
Constant updates (100.02亿 = 10,002,000,000):
- mining-service: TOTAL_SHARES
- trading-service: TOTAL_SHARES, trading config defaults
- trading-service seed: initial green points = 5760
Frontend changes:
- Add sharePoolBalanceProvider to fetch pool balance from mining-wallet-service
- Update contribution page to display real-time share pool balance (A + B)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:55:52 -08:00
hailin
a1508b208e
fix(api-gateway): correct Kong routing for trading-service
...
- Change strip_path to true to strip /api/v2/trading prefix
- Add /api/v2 to upstream URL so requests route correctly
- Revert accidental main.ts change
Request flow: /api/v2/trading/asset/market -> strip /api/v2/trading -> /asset/market -> upstream /api/v2/asset/market
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:27:46 -08:00
hailin
c60d3b2f26
fix(trading-service): correct global prefix to match Kong routing
...
Change prefix from 'api/v2' to 'api/v2/trading' to match Kong gateway
configuration with strip_path: false.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:26:11 -08:00
hailin
bb4143d75b
fix(trading-service): exclude prisma from tsconfig to fix build output path
2026-01-15 04:46:01 -08:00