Skip to content

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

Merged
92Infinitus92 merged 12 commits into
feat/scenarios/phoenix-eternalfrom
feat/phoenix-eternal-ui-integrated
Oct 2, 2026
Merged

92Infinitus92 merged 12 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 maintenance margin stress 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 and Studio lint
  • manual validation of collateral, mark-price, maintenance-margin and two-stage cascade scenarios

Pairs with LimeChain/surfpool#9.

RetriggerConfidence Score: 5/5

The PR appears safe to merge on the findings assessed here, subject to the stated backend-PR dependency.

Summary

The PR adds Phoenix state presets, market discovery and scenario creation, editor support, and a constrained market dropdown. The changes since the previous review consolidate field extraction and MCP parsing and adjust the shared Listbox structure.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Preset[Phoenix state preset] --> Dialog[State dialog]
  Dialog --> Market[Live market selection]
  Dialog --> Collateral[Collateral stress]
  Market --> Template[Phoenix market template]
  Template --> API[Scenario API]
  Collateral --> MCP[Phoenix MCP tool]
  API --> Editor[Scenario editor]
  MCP --> Editor
Loading

Reviews (19) · Last reviewed commit: "refactor(studio): trim the Phoenix integ..."

@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 listboxes — listbox.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 actions — scenario-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
@92Infinitus92
92Infinitus92 force-pushed the feat/phoenix-eternal-ui-integrated branch from e01ff36 to 3a7d038 Compare September 9, 2026 11:51
@92Infinitus92
92Infinitus92 force-pushed the feat/phoenix-eternal-ui-integrated branch from ec3921b to 35221f3 Compare September 28, 2026 04:59
@92Infinitus92
92Infinitus92 changed the base branch from feat/scenarios/phoenix-eternal to feat/scenarios/override/raw-layout September 28, 2026 04:59
Comment thread apps/studio/src/lib/phoenix-state.ts Outdated
Comment thread apps/studio/src/lib/phoenix-state.ts Outdated
Comment thread apps/studio/src/lib/phoenix-state.ts Outdated
@92Infinitus92
92Infinitus92 force-pushed the feat/phoenix-eternal-ui-integrated branch from 35221f3 to ec3921b Compare September 28, 2026 05:19
@92Infinitus92
92Infinitus92 changed the base branch from feat/scenarios/override/raw-layout to feat/scenarios/phoenix-eternal September 28, 2026 05:20
Comment thread apps/studio/src/components/svm/scenario-editor.tsx Outdated
@92Infinitus92

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@LimeChain LimeChain deleted a comment from greptile-apps Bot Sep 28, 2026
@LimeChain LimeChain deleted a comment from greptile-apps Bot Sep 28, 2026
@github-actions

Copy link
Copy Markdown
  • [P2] Preserving saved accounts can break PDA selector edits — scenario-editor.tsx:748. Updating an existing action now retains its saved account, including resolved PDA seeds. Changing a token/feed selector updates values but leaves those seeds pointing to the previous account. Preserve explicit pubkeys for Phoenix, but rebuild property-dependent PDA seeds when selectors change. Add a regression test that changes a saved PDA selector and checks the submitted account.

Tests weren’t run; dependencies aren’t installed.

@92Infinitus92
92Infinitus92 force-pushed the feat/phoenix-eternal-ui-integrated branch from 56cb865 to f1eb2f1 Compare September 30, 2026 08:06
@github-actions

Copy link
Copy Markdown
  • P2 — Manually added Phoenix market actions can use stale state. scenario-editor.tsx:672 forks the market map when selecting an action, but handleActionSelect defaults fetchBeforeUse to false. Waiting before playback can therefore trigger Phoenix’s mark-staleness validation. Default these actions to fetchBeforeUse: true, as the preset creation flow does.

  • P2 — Review CI fails for fork PRs. openai-review.yaml:38 requires OPENAI_API_KEY, which GitHub withholds from fork-triggered pull_request workflows. Add a guard to skip unsupported runs cleanly.

Tests were not run; dependencies are not installed.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1] Editing PDA selectors can retain the old account. scenario-editor.tsx:836 now preserves the saved account for every unchanged template. For saved PDAs with resolved seeds, changing a token or configuration selector updates the values but retains the previous PDA seeds, potentially targeting the wrong account. Preserve explicit pubkeys where needed, but rebuild PDA addresses from template references. Add a regression test that changes a saved PDA selector.

Tests weren’t run because dependencies aren’t installed.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P2] Preserve custom markets when reopening the dialog — phoenix-state-dialog.tsx:182. Every catalog reload replaces an unlisted custom symbol with the first listed market, while retaining the entered ticks or margin factor. Closing and reopening can therefore create a shock for a different market. Preserve nonempty custom selections; apply the catalog default only before the user selects a market.

Tests could not be run because dependencies are not installed.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P2] Preserve custom markets when reopening the dialog — phoenix-state-dialog.tsx:191: Loading the catalog replaces any unlisted symbol with the first listed market. Entering a custom market, cancelling, and reopening silently changes the market while retaining the tick or margin target. Preserve nonempty custom values and add a reopen regression test.

Tests were not run; dependencies are not installed.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • Validate Phoenix values in the editor too. scenario-editor.tsx renders market parameters as unrestricted text inputs. Users can save values outside the dialog’s limits (mark ticks: 1–4294967295; risk factor: 1–10000). Reuse the dialog validators and show errors before saving.
  • Add tests using the real Combobox. The Phoenix dialog and editor tests mock it, leaving Headless UI keyboard selection, custom-value commitment, and dialog portal behavior unverified.

No other definite bugs found in the PR diff. Tests weren’t run because dependencies aren’t installed.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • Add Phoenix validation in the editor (scenario-editor.tsx). The new value_type inputs accept arbitrary strings, allowing edits such as target_ticks = 0 or maintenance_risk_factor_bps = 10001, which the creation dialog rejects. Apply the same range checks before updating an action and show inline feedback.

No other concrete issues found in the PR changes. Tests weren’t run; dependencies are unavailable locally.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
  • [P2] Review workflow fails on fork PRs — openai-review.yaml:35: pull_request workflows from forks cannot access OPENAI_API_KEY, so the Codex step fails. Their GITHUB_TOKEN also cannot post comments despite the requested write permissions. Skip fork PRs explicitly, or use a separate trusted workflow to publish feedback.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
  • [P2] Unit fallback silently reinterprets an entered amount — phoenix-state-dialog.tsx:143. If a user enters a USD target, then selects a custom market without conversion metadata—or reopens the dialog and market discovery fails—activeChoice falls back to raw ticks while retaining amount. A $85,000 target becomes 85,000 ticks, and creation remains enabled. Clear the amount or require an explicit unit selection when the selected unit becomes unavailable.

Tests weren’t run because dependencies and pnpm are unavailable in this workspace.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
  • [P2] Silent unit changes can create an unintended price shock — phoenix-state-dialog.tsx:145. Selecting a custom market without metadata falls back from % or USD to ticks while retaining both the amount and the previous unit state. Returning to a listed market silently restores that previous unit: entering 1500 ticks for a custom market can become a +1500% adjustment. Clear the amount and update the unit when availability changes, or require explicit unit selection.

Tests could not be run because dependencies are not installed.

@92Infinitus92
92Infinitus92 merged commit 84a1ad6 into feat/scenarios/phoenix-eternal Oct 2, 2026
2 checks passed
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