Skip to content

feat(perps-controller): persist pro-mode order, chart, and draft preferences - #9922

Open
michalconsensys wants to merge 1 commit into
mainfrom
feat/core-perps-pro-mode-persistence
Open

feat(perps-controller): persist pro-mode order, chart, and draft preferences#9922
michalconsensys wants to merge 1 commit into
mainfrom
feat/core-perps-pro-mode-persistence

Conversation

@michalconsensys

@michalconsensys michalconsensys commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Explanation

Perps Pro-mode trade preferences were not fully owned by @metamask/perps-controller. Clients had to keep order type, order-book listed-by display, visible candle count, and draft reduceOnly locally, while pending trade drafts lived for five minutes and were not cleared after a successful order.

This change persists those preferences on the controller and tightens draft restore:

  • selectedOrderType is stored once for all markets (default 'market'). Saving a pending trade configuration with an orderType updates this value as well.
  • orderBookPreferences stores listed-by display as { currency: 'usd' | 'base', metric: 'total' | 'size' } (defaults to USD totals). Order-book grouping remains per-market.
  • visibleCandleCount is stored globally, defaults to 30, and is clamped to 10–250.
  • Pending trade drafts now last 30 seconds, include reduceOnly, and are cleared after a successful placeOrder. Leverage and the selected order type are kept.

Getters and selectors merge defaults so older persisted state without the new fields still reads correctly. Consumers that construct a full PerpsControllerState object must include the new fields.

Last-market landing and market-list category persistence are intentionally out of scope.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Cursor Bugbot is generating a summary for commit dd7f80d. Configure here.

…erences

Store a market-agnostic order type, order-book listed-by settings, and a shared visible candle count. Restore pending order drafts for 30 seconds, include reduce-only, and clear drafts after a successful placement without resetting leverage or order type.
@michalconsensys
michalconsensys requested review from a team as code owners August 20, 2026 12:47
@michalconsensys
michalconsensys deployed to default-branch August 20, 2026 12:47 — with GitHub Actions Active
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.

1 participant