feat(frontend): 手动下单功能增强与金额模式支持

- 后端返回 amountMode 和 amountValue 字段,支持前端获取策略配置
- 手动下单确认弹窗显示用户可用余额(绿色高亮)
- 价格输入框右侧添加"获取最新价"按钮,支持实时更新价格
- 数量输入框右侧添加"最大"按钮,根据余额自动计算最大购买数量
- 修正数量计算逻辑:FIXED 和 RATIO 模式均按实际金额计算数量,保留2位小数
  - FIXED 模式:使用配置的固定金额
  - RATIO 模式:按比例计算可用余额
- 数量计算使用保留小数方式(而非向上取整),确保精确匹配投入金额
  - 示例:固定1U,价格0.4,自动填充2.5张
  - 示例:比例30%,余额20U,价格0.4,自动填充15张

Made-with: Cursor
This commit is contained in:
WrBug
2026-02-26 21:19:06 +08:00
parent 9b4d8fc001
commit 79b154515d
6 changed files with 175 additions and 31 deletions
@@ -57,7 +57,11 @@ data class CryptoTailMonitorInitResponse(
/** 当前时间 (毫秒时间戳) */
val currentTimestamp: Long = System.currentTimeMillis(),
/** 是否启用 */
val enabled: Boolean = true
val enabled: Boolean = true,
/** 投入金额模式: FIXED or RATIO */
val amountMode: String? = null,
/** 投入金额数值 */
val amountValue: String? = null
)
/**
@@ -208,7 +208,9 @@ class CryptoTailMonitorService(
tokenIdUp = tokenIds.getOrNull(0),
tokenIdDown = tokenIds.getOrNull(1),
currentTimestamp = System.currentTimeMillis(),
enabled = strategy.enabled
enabled = strategy.enabled,
amountMode = strategy.amountMode,
amountValue = strategy.amountValue.toPlainString()
)
Result.success(response)