Skip to content

feat: swap pro order panel slider, stable-coin payment and limit rate precision (OK-57853)#12546

Open
haicongliao wants to merge 31 commits into
OneKeyHQ:xfrom
haicongliao:feat/swap-pro-order-panel
Open

feat: swap pro order panel slider, stable-coin payment and limit rate precision (OK-57853)#12546
haicongliao wants to merge 31 commits into
OneKeyHQ:xfrom
haicongliao:feat/swap-pro-order-panel

Conversation

@haicongliao

@haicongliao haicongliao commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Jira: OK-57853

Rework the Swap Pro order panel per the 6.6 design:

  • Replace the quick-amount segment input with a draggable percentage slider (0/25/50/75/100, continuous drag, native haptics), for both BUY/SELL and Market/Limit; slider position is derived from the typed amount so typing, presets and token switches stay in sync.
  • Balance row: add a deposit "+" entry (reuses ReceiveSelector) and a pay-token switcher (text-style trigger; hidden on single-token networks; switching resets the amount and re-quotes).
  • Stock tokens trade only against stable coins in BOTH directions: native coin is filtered from candidate pools, grayed out in the selector, and a persisted native-coin preference never re-applies while a stock token is selected.
  • 100% drag on a native token keeps the network-fee reserve (with the same toast as balance max press).

Sub-1 limit rate precision family (many-leading-zeros tokens no longer collapse to "0"):

  • clampLimitRateDecimals in shared numberUtils, applied at the market-rate source atom, rate storage, price display, order card and order detail modal; sub-1 rates always keep leading zeros + at least 6 significant digits.
  • Typing ultra-small prices key-by-key now works (all-zero prefixes are accepted while composing); unknown token decimals fall back to 6 instead of 0.
  • Order card and its detail modal now compute the same display price via one shared helper (with degenerate-order guards), plus unit tests.

Action button & review dialog:

  • Button label amount is single-sourced with the Est. Receive row; the parenthesized fiat value always shows what the user pays (was mixing limit-derived quantity with market unit price).
  • Loading only on the first actionable quote of a pair; account-resolving shows a skeleton instead of flashing "Select wallet".
  • New warning in the review dialog (mobile Pro + desktop, same component): when the market rate already beats the user's limit rate, show "Market price is better than your limit — this order may fill at market price instantly" (limit.marketable_fill_tip, gated on the quote's own limit protocol and pair-matched rates).

Also: per-direction amount stash with context fingerprints (no cross trade-type/pay-token resurrection), Android Nitro hybridRef re-fire guard for SegmentSlider, quote input debounce constants (300ms Pro / 500ms base), left/right column bottom alignment, trade list row tuning (5/9 rows).

Test Plan

  • yarn agent:check --profile commit passes; jest packages/kit/src/views/Swap 346/346 passes.
  • Manually verified on iOS simulator: slider drag/typing/presets, stock token payment restrictions, ultra-small price token (dmt-nat) limit flows, marketable-limit warning in review dialog, order card/detail price display.

🤖 Generated with Claude Code

@haicongliao
haicongliao requested a review from huhuanming as a code owner July 18, 2026 12:23
@haicongliao

Copy link
Copy Markdown
Contributor Author
e09ea624f5852e0bfb27af302f47f199 4dfb25751db7c2d9737651974753bce2

zhaono1
zhaono1 previously approved these changes Jul 18, 2026
@zhaono1
zhaono1 enabled auto-merge (squash) July 18, 2026 13:35
Comment thread packages/kit/src/views/Swap/pages/components/SwapProPayTokenSelector.tsx Outdated
auto-merge was automatically disabled July 18, 2026 16:02

Head branch was pushed to by a user without write access

Comment thread packages/kit/src/views/Swap/hooks/useSwapPro.ts
Comment thread packages/kit/src/views/Swap/hooks/useSwapPro.ts
@zhaono1
zhaono1 enabled auto-merge (squash) July 19, 2026 03:54
Comment thread packages/shared/src/locale/json/de.json Outdated
auto-merge was automatically disabled July 19, 2026 11:35

Head branch was pushed to by a user without write access

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants