Skip to content

feat(studio): add Phoenix state scenarios - #9

Open
92Infinitus92 wants to merge 2 commits into
feat/scenarios/phoenix-eternalfrom
feat/phoenix-eternal-ui-integrated
Open

feat(studio): add Phoenix state scenarios#9
92Infinitus92 wants to merge 2 commits into
feat/scenarios/phoenix-eternalfrom
feat/phoenix-eternal-ui-integrated

Conversation

@92Infinitus92

@92Infinitus92 92Infinitus92 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Adds Phoenix Eternal scenario support to Studio:

  • Phoenix state preset with live market selection
  • collateral stress, direct mark shock, and spot/perp divergence
    flows
  • AI chip for two-stage liquidation cascade scenarios
  • Phoenix protocol icon and scenario-editor support
  • constrained, scrollable market selection
  • scenario API integration and validation feedback

Verification

  • 298 Studio tests
  • TypeScript typecheck
  • Studio lint
  • manual validation of collateral, mark-price, reference-
    divergence, and two-stage cascade scenarios

Stacking

This PR is stacked on feat/pump-protocol-ui.

Once the Pump UI PR is merged into develop, this branch will be rebased and retargeted to develop.

Greptile Summary

The PR adds Phoenix Eternal state-scenario creation and editing to Studio, designed to integrate with the explicitly coupled backend PR.

  • Adds collateral-stress, direct-mark-shock, and reference-price-divergence scenario flows.
  • Adds live Phoenix market selection and dynamic editor options.
  • Preserves exact collateral values and saved override account addresses while editing.
  • Adds Phoenix presets, protocol branding, AI scenario guidance, and constrained Listbox scrolling.

Confidence Score: 5/5

The PR appears safe to merge once its explicitly documented coupled backend dependency is available.

No blocking failure remains within the eligible follow-up-review scope.

Important Files Changed

Filename Overview
apps/studio/src/components/svm/phoenix-state-dialog.tsx Implements validated Phoenix state-scenario inputs, live market selection, submission, and backend error feedback.
apps/studio/src/lib/scenarios-api.ts Adds Phoenix market discovery and scenario creation helpers for the coupled backend contracts.
apps/studio/src/components/svm/scenario-editor.tsx Adds Phoenix templates, dynamic market options, exact collateral editing, and preservation of saved account addresses.
packages/ui/src/catalyst/listbox.tsx Constrains and scrolls Listbox option panels to support larger live market catalogs.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Phoenix preset] --> B[Phoenix state dialog]
  B --> C{State goal}
  C -->|Collateral stress| D[Phoenix scenario MCP tool]
  C -->|Direct mark shock| E[Load live markets]
  C -->|Reference divergence| E
  E --> F[Create scenario API]
  D --> G[Open scenario editor]
  F --> G
  G --> H[Edit and persist overrides]
Loading

Reviews (13): Last reviewed commit: "feat(studio): add Phoenix Eternal state ..." | Re-trigger Greptile

@92Infinitus92 92Infinitus92 self-assigned this Aug 20, 2026
Comment thread apps/studio/src/lib/scenarios-api.ts Outdated
@github-actions

Copy link
Copy Markdown
  • P1 — Phoenix workflows call nonexistent backend routes (scenarios-api.ts:69): The coupled Surfpool router does not register phoenix-markets, phoenix-collateral, phoenix-direct-mark, or phoenix-reference-prices. All newly exposed Phoenix flows therefore fail with 404s. Add the backend routes before exposing these controls, or use existing supported endpoints.

  • P2 — Listboxes no longer avoid viewport boundaries (listbox.tsx:83): Replacing Headless UI’s anchored positioning with absolute top-full removes automatic flipping and available-height calculation. Listboxes near the bottom of a dialog or viewport can render partially off-screen. Retain anchored positioning and constrain its calculated available height.

@github-actions

Copy link
Copy Markdown
  • High: scenarios-api.ts:68 calls four new Phoenix endpoints, but this PR provides no corresponding server routes. Market discovery and all creation flows will return 404 unless the backend changes land first. Add/stack the required server implementation or gate the UI until available.

@92Infinitus92

Copy link
Copy Markdown
Collaborator Author

@greptileai

@92Infinitus92

Copy link
Copy Markdown
Collaborator Author
  • High: scenarios-api.ts:68 calls four new Phoenix endpoints, but this PR provides no corresponding server routes. Market discovery and all creation flows will return 404 unless the backend changes land first. Add/stack the required server implementation or gate the UI until available.

could you please check this PR here LimeChain/surfpool#9 as i believe it resolves the above mentioned reported problem

@github-actions

Copy link
Copy Markdown
  • P1 – Invalid Phoenix markets can be saved as scenarios. phoenix-state-dialog.tsx:68 accepts any non-empty symbol, while scenarios-api.ts:135 posts directly to the generic scenario endpoint. This bypasses live market discovery/validation, so typos like BTCC can create unusable scenarios that fail only when applied. Restore market discovery or validate through the Phoenix tool/backend before creation.

@92Infinitus92
92Infinitus92 force-pushed the feat/phoenix-eternal-ui-integrated branch from 8d8eeeb to f6fb37f Compare August 31, 2026 06:21
@92Infinitus92

Copy link
Copy Markdown
Collaborator Author

@greptileai

@github-actions

Copy link
Copy Markdown

Found one issue:

  • scenarios-api.ts:237: new URL(payload.url) rejects relative scenario URLs such as /scenarios?id=..., although these are valid MCP responses. Resolve against studioUrl, e.g. new URL(payload.url, studioUrl), and add a relative-URL test.

@92Infinitus92
92Infinitus92 force-pushed the feat/phoenix-eternal-ui-integrated branch from f6fb37f to 9cb3fbb Compare August 31, 2026 06:38
@github-actions

Copy link
Copy Markdown
  • scenarios-bento.types.ts:95: The cascade prompt names a trader and market but instructs create_scenario values containing only quote_lot_collateral and target_ticks. Explicitly include the trader and symbol bindings in their respective overrides; otherwise the generated scenario may target unresolved/default accounts.

  • phoenix-state-dialog.tsx:142: Clear symbolOptions before each market lookup. If a previous lookup succeeded and a later one fails, the old catalog remains and incorrectly validates/rejects symbols for the new Studio instance.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
  • [P3] Preserve field spacing around listboxeslistbox.tsx:23: The new wrapper leaves data-slot="control" on the nested button. Catalyst’s Field spacing selectors require the control to be a direct child, so labels, descriptions, and errors lose their margins when used with this component. Add data-slot="control" to the wrapper or remove the unnecessary wrapper.

Tests weren’t run because dependencies aren’t installed. Backend compatibility could not be verified from this repository.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
  • [P2] Editing loses the live PerpAssetMap address. scenarios-api.ts:179 creates overrides against the discovered map, but updateActionInSlot replaces their account with action.template.address. When the live map differs from the template, clicking Update Action silently retargets the scenario. Preserve the saved account when editing, and test creation → editing with different live/template addresses.

Tests were not run because dependencies are not installed.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
  • [P2] Newly added editor actions still target the static market account. scenario-editor.tsx:130 fetches symbols but discards the live perpAssetMap. “Add Action” consequently saves template.address. On forks with a migrated map, these actions target the wrong account. Retain the catalog address and use it for new Phoenix market actions.

  • [P3] Listbox wrapper breaks Field spacing. listbox.tsx:23 moves data-slot="control" beneath an unmarked wrapper, breaking Field’s direct-child spacing selectors. Put data-slot="control" on the wrapper.

Tests were not run; dependencies are unavailable in this checkout.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
  • [P2] Wait for live market discovery before saving new actionsscenario-editor.tsx:135. Catalog loading neither clears previous dynamicOptions nor disables “Add Action.” Saving while discovery is pending can persist a stale PerpAssetMap or the template’s fixed address. Closing the panel then cancels the discovery update, leaving that incorrect address saved. Track loading per Studio URL/source and require successful address resolution before adding a Phoenix market action.

Review limited to the specified changes. Tests were not run.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
  • [P2] Failed market discovery still permits saving a stale account address. In override-account.ts:16, missing catalog data silently falls back to the template address. Since discovery errors return an empty catalog and re-enable Add Action, a new Phoenix action can target the old PerpAssetMap after migration. Require successful address discovery for new dynamic actions and offer retry; saved actions can retain their existing address.

Could not run the focused tests because pnpm is unavailable.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
  • [P2] Prevent saving Phoenix actions without a market. In scenario-editor.tsx:129, market discovery runs independently of account loading, but “Add to Selected Slot” only checks whether a slot and action are selected. Users can save while markets are loading—or after discovery fails—with no symbol, producing an invalid Phoenix override. Disable adding until a required market is selected, and show discovery failures with a retry option. Preserve the ability to edit saved actions whose symbols are already present.

@failfmi
failfmi changed the base branch from feat/pump-protocol-ui to feat/scenarios/phoenix-eternal September 9, 2026 11:39
Phoenix state preset and dialog for collateral stress, direct mark
shock and spot/perp reference divergence, plus the liquidation cascade
AI chip. Collateral goes through the MCP tool for its vault-backing
check; market scenarios are built client-side and posted to the generic
scenarios API. Market symbols come live from list_phoenix_markets, and
the scenario editor renders dynamic_ref properties as that live
dropdown. Update Action keeps a saved override's address.
@92Infinitus92
92Infinitus92 force-pushed the feat/phoenix-eternal-ui-integrated branch from e01ff36 to 3a7d038 Compare September 9, 2026 11:51
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