Split Swap Settings into retail defaults and advanced integrator controls #413

Closed
opened 2026-06-25 14:12:44 +00:00 by PlasticDigits · 12 comments
PlasticDigits commented 2026-06-25 14:12:44 +00:00 (Migrated from gitlab.com)

Parent

#411 — Updated Gap Analysis (recommendation 2)

Current codebase

SwapPage.tsx Settings drawer (~L1040–1217) interleaves retail controls with integrator tooling:

  • Retail: slippage presets, custom slippage, expert mode toggle.
  • Advanced integrator: direct-pair hybrid book leg (useHybridBook, bookInputHuman, hybridMaxMakers) with "Pattern C" copy.
  • Indexer route debug: "Indexer route check" panel with BFS hop dump, pair addresses, client vs indexer hop counts.

Casual users opening Settings (Uniswap-class migrants) see debug UI before useful swap prefs.

Why needed

Settings is the first place users configure execution risk. Exposing indexer hop addresses and hybrid leg overrides causes information overload and implies quotes match hybrid execution when they may not.

Constraints / guardrails

  • Do not remove hybrid book leg or indexer route check — relocate behind Advanced / Expert disclosure (collapsed by default).
  • Expert mode gate for extreme route slippage (#293) must remain reachable from retail panel.
  • Preserve data-testid hooks used by Playwright (swap-expert-mode-toggle, etc.).
  • Direct-pair hybrid controls only apply when isDirect && !isWrapOrUnwrap.

Relevant files

  • frontend-dapp/src/pages/SwapPage.tsx
  • frontend-dapp/src/pages/SwapPage.test.tsx
  • frontend-dapp/src/components/swap/ExpertModeModal.tsx
  • skills/AGENTS_FRONTEND_SWAP_ROUTE_DISPLAY.md
  1. Default Settings to slippage + deadline + expert mode only.
  2. Add collapsible "Advanced" section for hybrid book leg (rename copy to plain language; drop "Pattern C" in retail path).
  3. Move Indexer route check to Advanced or a separate "Developer tools" subsection, off by default.
  4. Consider persisting "show advanced" in localStorage for power users.

Acceptance criteria

  • First open of Settings shows only retail swap prefs (no hop addresses, no indexer BFS).
  • Advanced panels require explicit expand.
  • Hybrid book leg still functional when expanded.
  • Indexer route check still functional when expanded.
  • Screenshot: Swap Settings — default collapsed retail view.
  • Screenshot: Swap Settings — Advanced expanded showing hybrid + route check.

Test plan

  • SwapPage.test.tsx — add/update tests for Settings sections visibility.
  • make test-frontend
  • Manual: / → Settings → confirm progressive disclosure.

Attack / abuse test plan

  • Confirm expert-mode block for >30% route slippage still works with Advanced collapsed.
  • Hybrid leg max makers (256 cap) unchanged.

Verification criteria

  • Existing swap E2E specs still pass (make test-e2e subset for swap if LocalTerra available).
  • No new alert stack on default Settings open.
## Parent [#411 — Updated Gap Analysis](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/411) (recommendation 2) ## Current codebase `SwapPage.tsx` Settings drawer (~L1040–1217) interleaves retail controls with integrator tooling: - **Retail:** slippage presets, custom slippage, expert mode toggle. - **Advanced integrator:** direct-pair hybrid book leg (`useHybridBook`, `bookInputHuman`, `hybridMaxMakers`) with "Pattern C" copy. - **Indexer route debug:** "Indexer route check" panel with BFS hop dump, pair addresses, client vs indexer hop counts. Casual users opening Settings (Uniswap-class migrants) see debug UI before useful swap prefs. ## Why needed Settings is the first place users configure execution risk. Exposing indexer hop addresses and hybrid leg overrides causes information overload and implies quotes match hybrid execution when they may not. ## Constraints / guardrails - Do **not** remove hybrid book leg or indexer route check — relocate behind **Advanced** / **Expert** disclosure (collapsed by default). - Expert mode gate for extreme route slippage (#293) must remain reachable from retail panel. - Preserve `data-testid` hooks used by Playwright (`swap-expert-mode-toggle`, etc.). - Direct-pair hybrid controls only apply when `isDirect && !isWrapOrUnwrap`. ## Relevant files - `frontend-dapp/src/pages/SwapPage.tsx` - `frontend-dapp/src/pages/SwapPage.test.tsx` - `frontend-dapp/src/components/swap/ExpertModeModal.tsx` - `skills/AGENTS_FRONTEND_SWAP_ROUTE_DISPLAY.md` ## Recommended direction 1. Default Settings to **slippage + deadline + expert mode** only. 2. Add collapsible **"Advanced"** section for hybrid book leg (rename copy to plain language; drop "Pattern C" in retail path). 3. Move **Indexer route check** to Advanced or a separate "Developer tools" subsection, off by default. 4. Consider persisting "show advanced" in `localStorage` for power users. ## Acceptance criteria - [ ] First open of Settings shows only retail swap prefs (no hop addresses, no indexer BFS). - [ ] Advanced panels require explicit expand. - [ ] Hybrid book leg still functional when expanded. - [ ] Indexer route check still functional when expanded. - [ ] **Screenshot:** Swap Settings — default collapsed retail view. - [ ] **Screenshot:** Swap Settings — Advanced expanded showing hybrid + route check. ## Test plan - `SwapPage.test.tsx` — add/update tests for Settings sections visibility. - `make test-frontend` - Manual: `/` → Settings → confirm progressive disclosure. ## Attack / abuse test plan - Confirm expert-mode block for >30% route slippage still works with Advanced collapsed. - Hybrid leg max makers (256 cap) unchanged. ## Verification criteria - Existing swap E2E specs still pass (`make test-e2e` subset for swap if LocalTerra available). - No new alert stack on default Settings open.
PlasticDigits commented 2026-06-25 14:13:22 +00:00 (Migrated from gitlab.com)

mentioned in issue #411

mentioned in issue #411
PlasticDigits commented 2026-06-25 20:51:19 +00:00 (Migrated from gitlab.com)

mentioned in merge request !942

mentioned in merge request !942
PlasticDigits commented 2026-06-25 20:51:30 +00:00 (Migrated from gitlab.com)

mentioned in commit fe41122cdb

mentioned in commit fe41122cdbc5b2c201b1c7eef0b9d5e0738953d9
PlasticDigits commented 2026-06-25 21:55:27 +00:00 (Migrated from gitlab.com)

mentioned in commit e7c7fd090d

mentioned in commit e7c7fd090d07e2cb7d5dc09b580ef0eb9596f6d5
PlasticDigits commented 2026-06-25 22:20:19 +00:00 (Migrated from gitlab.com)

mentioned in commit 617b9e0fd3

mentioned in commit 617b9e0fd32ccf1f830aa4edfcde8bbb2bf09edb
PlasticDigits commented 2026-06-26 07:07:22 +00:00 (Migrated from gitlab.com)

mentioned in commit 6deb64a6ff

mentioned in commit 6deb64a6ff242e06fd5e99063435544a4b38879a
PlasticDigits commented 2026-06-26 07:07:41 +00:00 (Migrated from gitlab.com)

mentioned in merge request !949

mentioned in merge request !949
PlasticDigits commented 2026-06-26 08:00:33 +00:00 (Migrated from gitlab.com)

mentioned in commit 4ca88cb49f

mentioned in commit 4ca88cb49f8efdc0dca782312be0d92d3e9c5788
PlasticDigits commented 2026-06-26 08:17:18 +00:00 (Migrated from gitlab.com)

mentioned in commit 9bc362308d

mentioned in commit 9bc362308dbcca9a729bd12effaf6dcfadda186f
PlasticDigits commented 2026-06-26 08:38:53 +00:00 (Migrated from gitlab.com)

Verification — #413 (PASS)

Verified on main @ 9bc36230 (includes merge of issue-413-verify-advanced-toggle / 6deb64a6).

Acceptance criteria

Criterion Result How verified
First open of Settings shows only retail swap prefs (no hop addresses, no indexer BFS) PASS SwapPage.test.tsx → Swap Settings progressive disclosure (#413) / shows retail prefs only when Settings first opens; Playwright smoke on / confirms swap-indexer-route-check hidden when aria-expanded=false
Advanced panels require explicit expand PASS swap-advanced-settings-toggle defaults aria-expanded=false; content gated on open in SwapAdvancedSettings.tsx
Hybrid book leg still functional when expanded PASS hybrid-swap.spec.ts (3/3) uses openSwapAdvancedSettings; unit test shows hybrid and indexer route check when Advanced is expanded
Indexer route check still functional when expanded PASS Same as above; Compare indexer route button present after expand
Screenshot — default collapsed retail view PASS Playwright capture /tmp/issue-413-settings-retail.png (slippage, deadline, Expert Mode only; Advanced collapsed)
Screenshot — Advanced expanded (hybrid + route check) PASS Playwright capture /tmp/issue-413-settings-advanced.png

Test plan

Check Result Command / output
Settings section visibility tests PASS make test-frontend — 184 files, 1084 tests passed (includes SwapPage.test.tsx 27 tests)
Full frontend suite PASS same
Manual / → Settings progressive disclosure PASS Playwright e2e/issue-413-screenshots.spec.ts (ephemeral, not committed) + LocalTerra stack

Attack / abuse / verification criteria

Check Result How verified
Expert-mode block for >30% route slippage with Advanced collapsed PASS SwapPage.test.tsx blocks swap above 30% route slippage unless Expert Mode is enabled (GitLab #293) — Expert Mode toggle in retail panel (swap-expert-mode-toggle), no Advanced expand required
Hybrid leg max makers 256 cap unchanged PASS SwapAdvancedSettings.tsx input max={256}
Swap E2E subset PASS npx playwright test e2e/swap.spec.ts --project=e2e-smoke (10/10); npx playwright test e2e/hybrid-swap.spec.ts --project=e2e-tx (3/3) on fresh LocalTerra deploy
No alert stack on default Settings open PASS Retail-only open shows slippage/deadline/expert controls; no role=alert stack observed in progressive-disclosure unit test or screenshot run
data-testid hooks preserved PASS swap-expert-mode-toggle, swap-advanced-settings, swap-advanced-settings-toggle present
Pattern C copy removed from retail path PASS No "Pattern C" in SwapPage.tsx or components/swap/*; Advanced copy uses plain "Limit book leg" language
Advanced expand persisted in localStorage PASS persists Advanced expanded state in localStorage test; key cl8y-dex-swap-settings-advanced-open

Implementation notes

  • Retail panel: #swap-slippage-settings (slippage, transaction deadline, Expert Mode).
  • Integrator controls: SwapAdvancedSettings.tsx (collapsed by default, swapSettingsAdvanced.ts persistence).
  • Docs/skills already aligned: docs/frontend.md, skills/AGENTS_FRONTEND_SWAP_ROUTE_DISPLAY.md.

No repo changes required from this verification pass.

## Verification — #413 (PASS) Verified on `main` @ `9bc36230` (includes merge of `issue-413-verify-advanced-toggle` / `6deb64a6`). ### Acceptance criteria | Criterion | Result | How verified | |-----------|--------|--------------| | First open of Settings shows only retail swap prefs (no hop addresses, no indexer BFS) | **PASS** | `SwapPage.test.tsx` → `Swap Settings progressive disclosure (#413)` / `shows retail prefs only when Settings first opens`; Playwright smoke on `/` confirms `swap-indexer-route-check` hidden when `aria-expanded=false` | | Advanced panels require explicit expand | **PASS** | `swap-advanced-settings-toggle` defaults `aria-expanded=false`; content gated on `open` in `SwapAdvancedSettings.tsx` | | Hybrid book leg still functional when expanded | **PASS** | `hybrid-swap.spec.ts` (3/3) uses `openSwapAdvancedSettings`; unit test `shows hybrid and indexer route check when Advanced is expanded` | | Indexer route check still functional when expanded | **PASS** | Same as above; `Compare indexer route` button present after expand | | Screenshot — default collapsed retail view | **PASS** | Playwright capture `/tmp/issue-413-settings-retail.png` (slippage, deadline, Expert Mode only; Advanced collapsed) | | Screenshot — Advanced expanded (hybrid + route check) | **PASS** | Playwright capture `/tmp/issue-413-settings-advanced.png` | ### Test plan | Check | Result | Command / output | |-------|--------|------------------| | Settings section visibility tests | **PASS** | `make test-frontend` — 184 files, 1084 tests passed (includes `SwapPage.test.tsx` 27 tests) | | Full frontend suite | **PASS** | same | | Manual `/` → Settings progressive disclosure | **PASS** | Playwright `e2e/issue-413-screenshots.spec.ts` (ephemeral, not committed) + LocalTerra stack | ### Attack / abuse / verification criteria | Check | Result | How verified | |-------|--------|--------------| | Expert-mode block for >30% route slippage with Advanced collapsed | **PASS** | `SwapPage.test.tsx` `blocks swap above 30% route slippage unless Expert Mode is enabled (GitLab #293)` — Expert Mode toggle in retail panel (`swap-expert-mode-toggle`), no Advanced expand required | | Hybrid leg max makers 256 cap unchanged | **PASS** | `SwapAdvancedSettings.tsx` input `max={256}` | | Swap E2E subset | **PASS** | `npx playwright test e2e/swap.spec.ts --project=e2e-smoke` (10/10); `npx playwright test e2e/hybrid-swap.spec.ts --project=e2e-tx` (3/3) on fresh LocalTerra deploy | | No alert stack on default Settings open | **PASS** | Retail-only open shows slippage/deadline/expert controls; no `role=alert` stack observed in progressive-disclosure unit test or screenshot run | | `data-testid` hooks preserved | **PASS** | `swap-expert-mode-toggle`, `swap-advanced-settings`, `swap-advanced-settings-toggle` present | | Pattern C copy removed from retail path | **PASS** | No "Pattern C" in `SwapPage.tsx` or `components/swap/*`; Advanced copy uses plain "Limit book leg" language | | Advanced expand persisted in `localStorage` | **PASS** | `persists Advanced expanded state in localStorage` test; key `cl8y-dex-swap-settings-advanced-open` | ### Implementation notes - Retail panel: `#swap-slippage-settings` (slippage, transaction deadline, Expert Mode). - Integrator controls: `SwapAdvancedSettings.tsx` (collapsed by default, `swapSettingsAdvanced.ts` persistence). - Docs/skills already aligned: `docs/frontend.md`, `skills/AGENTS_FRONTEND_SWAP_ROUTE_DISPLAY.md`. No repo changes required from this verification pass.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-06-26 08:38:54 +00:00
Brouie commented 2026-06-28 22:40:29 +00:00 (Migrated from gitlab.com)

mentioned in merge request !951

mentioned in merge request !951
Brouie commented 2026-06-28 22:41:06 +00:00 (Migrated from gitlab.com)

mentioned in issue #337

mentioned in issue #337
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#413
No description provided.