Skip to content

feat(tradebox): bracket toggle (desktop) #94

@vipineth

Description

@vipineth

Parent PRD

#93

What to build

Full end-to-end Bracket Order feature on the desktop tradebox. A user clicks a new prominently-placed Bracket Order chip (labeled with the default percentages, e.g. 📈 Bracket Order · Auto TP 5% · SL 2.5%), which enables TP/SL mode and prefills both exit prices computed from the current reference price and order side. The existing TpSlSection expands inline with concrete prices, per-leg PnL, and the risk/reward bar. The user can edit either prefilled value or submit as-is; entry + TP + SL are placed atomically via Hyperliquid's existing normalTpsl grouping.

Scope covers:

  • New pure-function defaults calculator (deep module) with unit tests
  • New atomic store action that toggles the bracket on/off and writes/clears the two prices
  • New BracketToggle UI component
  • Removal of the existing TP/SL checkbox from the Reduce Only / TIF row
  • New dedicated row for the toggle, positioned between the size slider block and the Reduce Only / TIF row
  • i18n strings added to all six locales (en, es, fr, hi, zh, ar)

See the PRD's Implementation Decisions and Testing Decisions sections for the full module sketch and testing approach.

Acceptance criteria

  • Clicking the Bracket chip enables TP/SL mode and prefills both price inputs with concrete values computed from the current reference price
  • Default offsets are 5% for TP and 2.5% for SL, applied in the correct direction for long vs short
  • Prefilled prices respect the market's szDecimals rounding
  • Clicking the Bracket chip again (toggling off) clears both TP and SL values
  • Toggling off and then back on recomputes fresh defaults rather than restoring prior edits
  • Existing TP/SL validation (TP must be above entry for long, etc.) continues to apply
  • Existing R:R bar and per-leg PnL display automatically when Bracket is active
  • Submit uses the atomic normalTpsl grouping; entry + TP + SL are placed as one unit
  • The old TP/SL checkbox is removed; Reduce Only and TIF remain in their current row
  • Bracket chip is hidden when the current order type does not support TP/SL (spot, trigger, scale, TWAP)
  • Bracket chip is disabled when the wallet is not connected or the form is otherwise disabled
  • Bracket chip is focusable and activatable via keyboard (Enter/Space), with an accessible name announcing the on/off state
  • When switching markets while Bracket is active, the prefilled values recompute for the new reference price
  • Unit tests cover the defaults calculator: long/short direction, percentage math, decimal rounding, invalid inputs
  • i18n strings added to all six locale files

Blocked by

None - can start immediately

User stories addressed

Reference by number from the parent PRD:

  • User story 1
  • User story 2
  • User story 3
  • User story 4
  • User story 5
  • User story 6
  • User story 7
  • User story 8
  • User story 9
  • User story 10
  • User story 11
  • User story 12
  • User story 14
  • User story 15
  • User story 16
  • User story 17
  • User story 18
  • User story 19
  • User story 20
  • User story 21
  • User story 22
  • User story 23
  • User story 24
  • User story 25

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions