Skip to content

feat(studio): add Tessera fair-value preset and staleness chip - #11

Open
92Infinitus92 wants to merge 4 commits into
feat/phoenix-eternal-ui-integratedfrom
feat/tessera-support
Open

92Infinitus92 wants to merge 4 commits into
feat/phoenix-eternal-ui-integratedfrom
feat/tessera-support

Conversation

@92Infinitus92

@92Infinitus92 92Infinitus92 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Pairs with LimeChain/surfpool#11 (the create_tessera_fair_value_scenario tool and the tessera templates) — merge after it, the preset needs that backend.

Stacked on #9 — reuses its string-values scenarios API, the constant-catalog fetch and the MCP creator seam.

  • "PMM fair value" preset: market picker fed by the 26-pair catalog (free-text address fallback when the catalog fails to load), price input, and creation through the create_tessera_fair_value_scenario MCP tool — no client-side math, the backend derives both ratio fields.
  • "Tessera Stale Quote" AI chip, goal-level like every other protocol's chip; the procedure lives in the backend template's llm_context.
  • Three file-internal phoenix helpers are generalized instead of duplicated (scenarioTemplate, createScenarioWithMcpTool, ScenarioCreationResult) — expect a small, mechanical conflict on those lines when this merges alongside the phoenix branch.
  • 317 tests green, tsc clean.

Greptile Summary

The PR adds a Tessera fair-value preset, live market discovery with a free-text fallback, Tessera scenario-editor support, and stale-quote/depth-stress AI prompts.

  • Creates fair-value scenarios through the paired Tessera MCP tool.
  • Adds Tessera protocol metadata, iconography, and raw-layout field handling.
  • Preserves wide integer values and original account metadata while editing scenarios.

Confidence Score: 5/5

The PR appears safe to merge with its explicitly paired Surfpool backend change.

No blocking failure remains; the only prior finding was invalidated after the paired backend PR was verified to register the required Tessera tool and template.

Important Files Changed

Filename Overview
apps/studio/src/lib/scenarios-api.ts Adds Tessera market discovery and fair-value scenario creation through the generalized MCP helper.
apps/studio/src/components/svm/pmm-fair-value-dialog.tsx Implements catalog-backed market selection, fallback address entry, price validation, and scenario creation feedback.
apps/studio/src/components/svm/scenario-editor.tsx Enables Tessera templates while preserving raw-layout wide integers and loaded override metadata during edits.
apps/studio/src/components/svm/scenarios-bento.types.ts Adds Tessera stale-quote and depth-stress example prompts.
apps/studio/src/lib/scenario-fields.ts Derives editable fields and integer encodings for IDL-less raw-layout templates.

Sequence Diagram

sequenceDiagram
  actor User
  participant UI as Studio UI
  participant MCP as Surfpool MCP
  participant Store as Scenario Store
  UI->>MCP: list_tessera_markets
  MCP-->>UI: "markets[{label,address}]"
  User->>UI: Select market and enter price
  UI->>MCP: "create_tessera_fair_value_scenario({market?, price})"
  MCP->>Store: Validate market and create overrides
  Store-->>MCP: Scenario ID
  MCP-->>UI: "{url: /scenarios?id=...&tab=editor}"
  UI-->>User: Open scenario editor
Loading

Reviews (9): Last reviewed commit: "fix(studio): reconcile market selection ..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
  • pmm-fair-value-dialog.tsx:80 — The empty initial catalog is treated as a failed catalog. While loading, users see free-text input and can submit any market before the catalog resolves, bypassing catalog-only validation. Track an explicit loading state and enable fallback only after loading finishes unsuccessfully.

Comment thread apps/studio/src/lib/scenarios-api.ts
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
  • scenarios-api.ts:171Blocking: The preset calls create_tessera_fair_value_scenario and expects tessera-fair-value, but the coupled Surfpool backend exposes neither contract. Catalog loading falls back to free text, then every creation attempt fails. Land/version the backend support before enabling this UI, or feature-detect the tool/template and hide the preset.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
  • Medium — pmm-fair-value-dialog.tsx:46: canCreate remains true while marketOptions === null. After reopening, a previously selected market persists and can be submitted while the UI displays “Loading markets…”, bypassing catalog validation. Require catalog loading to finish before enabling creation, or reset market when opening.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
  • scenario-editor.tsx:394: Raw Tessera u64/u128 fields are classified as numeric, then converted with Number(...) when edited. Atomic ratio values can exceed Number.MAX_SAFE_INTEGER, causing precision loss before saving. Preserve these values as decimal strings, consistent with the string-values API.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
  • Minor: reconcile the selected market when refreshing the catalog (pmm-fair-value-dialog.tsx:110). current || options[0]?.value retains a previously entered address even if it is absent from the refreshed catalog. After fallback entry or a catalog change, reopening can show an empty selection and disable creation. Keep current only if it exists in the new options; otherwise select the first market.

No other concrete issues found in the PR changes. Tests could not run because pnpm is unavailable.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
  • [P2] Preserve the existing account only when the template is unchangedscenario-editor.tsx:749. While editing an override, users can select another action from the sidebar. Updating now saves the new template with the old action’s account—for example, switching Phoenix collateral stress to a market action retains the trader account. This can cause validation failures or target the wrong account. Use the new template’s address when actionId changes, and add a regression test for switching templates.

Tests weren’t run; dependencies are not installed.

The PMM fair-value dialog picks a market from the tessera-fair-value template's
constant catalog and posts a human price through the Tessera MCP tool. Every
atomic ratio is derived backend-side from the two mints' decimals, so there is
no price math in the client.

The staleness chip reads each market's own freshness_limit_slots out of the same
catalog and passes its negation as the slot lead, because the limit differs per
market. It goes through create_scenario and the tessera-stale-quote template
rather than a protocol-specific tool.
updateActionInSlot rebuilt an edited action without its original backend
override, so editing a persisted override (Tessera's "Keep quote fresh")
dropped persist on save. Carry original through the edit.
Load market choices through MCP and add the depth-stress AI prompt. Preserve selected accounts and wide integer values when editing scenario actions, with component regressions.
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