Skip to content

feat(market): persist user token preference in Market Detail Buy/Sell#10355

Open
haicongliao wants to merge 6 commits intoOneKeyHQ:xfrom
haicongliao:feat/market-remember-token-preference
Open

feat(market): persist user token preference in Market Detail Buy/Sell#10355
haicongliao wants to merge 6 commits intoOneKeyHQ:xfrom
haicongliao:feat/market-remember-token-preference

Conversation

@haicongliao
Copy link
Contributor

@haicongliao haicongliao commented Feb 26, 2026

Summary

  • Add persistent Jotai atom (marketTokenPreferencePersistAtom) to remember user's selected payment token (e.g. USDT/USDC) per network in Market Detail's Instant Mode swap panel
  • On initialization, prefer saved token preference; fallback to default if unavailable or token delisted
  • User-initiated token changes are automatically persisted; shared across Buy/Sell modes
  • Storage is per-network: Ethereum preference doesn't affect BSC, etc.

Jira

OK-50555

Test plan

  • Open Market Detail for a token (e.g. cbBTC on Base)
  • Open Instant Mode, switch payment token from default to USDC
  • Close the dialog and reopen — USDC should be pre-selected
  • Switch to Sell mode — USDC should still be shown as Sell For token
  • Close app completely, reopen, and verify USDC is still remembered
  • Switch to a different network token (e.g. ETH on Ethereum) — should use its own default
  • Reset app — all preferences should be cleared

Open with Devin

Remember the user's selected payment token (e.g. USDT/USDC) per network
in Market Detail's Instant Mode swap panel. The preference is stored
locally via a persistent Jotai atom and restored on next app launch.

Closes OK-50555
@revan-zhang
Copy link
Contributor

revan-zhang commented Feb 26, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@haicongliao
Copy link
Contributor Author

CleanShot 2026-02-26 at 16 13 37@2x 视频太大没法上传。

主要就是记住用户在这个位置选择的“偏向代币”,没有 UI 修改

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Pro Mode BUY/SELL now share the same persisted token preference with
Instant Mode. Changing the counterparty token in either direction
cross-syncs the other direction's atom so both stay in sync.
devin-ai-integration[bot]

This comment was marked as resolved.

Move stale preference clearing from findPreferredToken into the
useEffect to avoid a dependency cycle where tokenPreference changes
trigger callback recreation and effect re-runs.
Migrate per-network token preference storage from globalAtom (persist)
to simpledb for better performance and memory usage. Add revalidateOnFocus
to enable bidirectional sync between Market and Pro Mode.
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 8 additional findings in Devin Review.

Open in Devin Review

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