fix(#293): Expert Mode slippage guard — docs, verify, test alignment #830

Merged
PlasticDigits merged 1 commit from cursor/gitlab-issue-workflow-c78e into main 2026-06-06 08:36:52 +00:00
PlasticDigits commented 2026-06-06 08:34:14 +00:00 (Migrated from gitlab.com)

Summary

Completes GitLab #293 acceptance from the 2026-06-06 product decision: classify excessive route slippage as a retail bug (not a decimal display bug), surface Expected slippage from indexer best-route token prices, and guard swaps with Expert Mode (default off, blocks >30% unless enabled).

Core implementation (indexer route_slippage.rs, Swap Expert Mode UI, swapRouteSlippage.ts) was merged in prior MRs. This MR:

  • Fixes SwapPage.test.tsx to expect wallet-aligned slippage (100.00%)
  • Documents route slippage enrichment invariant in docs/indexer-invariants.md
  • Documents Expert Mode + expected slippage in docs/frontend.md
  • Extends make verify-issue-293 [3c] for slippage_percent enrichment

Acceptance checklist

Criterion Verification Result
Expert Mode toggle (default off) SwapPage.test.tsx PASS
Block submit >30% unless Expert Mode SwapPage.test.tsx PASS
≥99% extreme slippage warning swap-extreme-slippage-warning test PASS
Indexer route slippage from best-route prices cargo test route_slippage --lib PASS
Invariants documented docs/indexer-invariants.md, docs/frontend.md PASS
make test-swarm-liquidity unit tests PASS
make verify-issue-293 live [3c] LocalTerra + swarm SKIP

Issue left open until live verify passes in QA.


Note

Low Risk
Documentation, unit test expectation, and optional LocalTerra QA script only—no runtime behavior changes in this diff.

Overview
Closes GitLab #293 acceptance documentation and QA around Expected slippage and Expert Mode (core indexer/UI logic was merged earlier).

Docs: docs/frontend.md now describes Expected slippage from indexer slippage_percent / spot_amount_out, wallet-aligned display via swapRouteSlippage.ts, Expert Mode blocking submit above 30%, and ≥99% extreme warnings alongside existing max-spread preflight. docs/indexer-invariants.md adds a Route slippage enrichment invariant for GET/POST /api/v1/route/solve. docs/testing.md updates make verify-issue-293 acceptance to include global vs pool_only slippage_percent checks.

Tests & QA: SwapPage.test.tsx expects 100.00% (wallet return vs spot) instead of raw indexer 99.97%. scripts/qa/verify-issue-293.sh adds live [3c] asserting extreme slippage on global routes (≥99%) and low slippage on direct pool_only (≤5%).

Reviewed by Cursor Bugbot for commit b2f2cfbdab. Bugbot is set up for automated code reviews on this repo. Configure here.

## Summary Completes GitLab [#293](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/293) acceptance from the 2026-06-06 product decision: classify excessive route slippage as a retail bug (not a decimal display bug), surface **Expected slippage** from indexer best-route token prices, and guard swaps with **Expert Mode** (default off, blocks >30% unless enabled). **Core implementation** (indexer `route_slippage.rs`, Swap Expert Mode UI, `swapRouteSlippage.ts`) was merged in prior MRs. This MR: - Fixes `SwapPage.test.tsx` to expect wallet-aligned slippage (100.00%) - Documents route slippage enrichment invariant in `docs/indexer-invariants.md` - Documents Expert Mode + expected slippage in `docs/frontend.md` - Extends `make verify-issue-293` **[3c]** for `slippage_percent` enrichment ## Acceptance checklist | Criterion | Verification | Result | |-----------|--------------|--------| | Expert Mode toggle (default off) | `SwapPage.test.tsx` | **PASS** | | Block submit >30% unless Expert Mode | `SwapPage.test.tsx` | **PASS** | | ≥99% extreme slippage warning | `swap-extreme-slippage-warning` test | **PASS** | | Indexer route slippage from best-route prices | `cargo test route_slippage --lib` | **PASS** | | Invariants documented | `docs/indexer-invariants.md`, `docs/frontend.md` | **PASS** | | `make test-swarm-liquidity` | unit tests | **PASS** | | `make verify-issue-293` live [3c] | LocalTerra + swarm | **SKIP** | Issue left **open** until live verify passes in QA. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation, unit test expectation, and optional LocalTerra QA script only—no runtime behavior changes in this diff. > > **Overview** > Closes **GitLab #293** acceptance documentation and QA around **Expected slippage** and **Expert Mode** (core indexer/UI logic was merged earlier). > > **Docs:** `docs/frontend.md` now describes **Expected slippage** from indexer `slippage_percent` / `spot_amount_out`, wallet-aligned display via `swapRouteSlippage.ts`, **Expert Mode** blocking submit above **30%**, and **≥99%** extreme warnings alongside existing max-spread preflight. `docs/indexer-invariants.md` adds a **Route slippage enrichment** invariant for `GET/POST /api/v1/route/solve`. `docs/testing.md` updates `make verify-issue-293` acceptance to include global vs `pool_only` `slippage_percent` checks. > > **Tests & QA:** `SwapPage.test.tsx` expects **100.00%** (wallet return vs spot) instead of raw indexer **99.97%**. `scripts/qa/verify-issue-293.sh` adds live **[3c]** asserting extreme slippage on global routes (≥99%) and low slippage on direct `pool_only` (≤5%). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b2f2cfbdab3c2499dd1cb8bb90b74bf344889406. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
ghost1 commented 2026-06-06 08:34:21 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-06 08:34:27 +00:00 (Migrated from gitlab.com)

mentioned in issue #293

mentioned in issue #293
ghost1 commented 2026-06-06 08:34:33 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-06 08:36:03 +00:00 (Migrated from gitlab.com)

Security review

Commit reviewed: b2f2cfbdab3c2499dd1cb8bb90b74bf344889406

Scope: Documentation (docs/frontend.md, docs/indexer-invariants.md, docs/testing.md), SwapPage.test.tsx expectation alignment (99.97% → 100.00%), and scripts/qa/verify-issue-293.sh live QA step [3c] for slippage_percent enrichment. No production runtime code changes in this diff (core Expert Mode / route slippage logic merged in prior MRs).

Method: Traced attacker-controlled inputs on modified paths. Reviewed the new QA Python block for SSRF/injection; compared against existing [3a]/[3b] patterns in the same script. Checked for auth bypass, secret leakage, XSS, and unsafe deserialization surfaces — none introduced here.

Outcome: FINDINGS: 0 medium+

Security review: no medium+ findings on this diff.

Inline threads: none (no findings to anchor)


Area Assessment
Docs Descriptive only; no new secrets, endpoints, or trust-boundary changes
SwapPage.test.tsx Test assertion only; no change to swap submit guards or slippage computation
verify-issue-293.sh [3c] Local QA harness; VERIFY293_INDEXER_URL defaults to 127.0.0.1:3001; token addresses sourced from indexer /api/v1/tokens — same urllib/f-string pattern as pre-existing [3a]/[3b]; not exposed to untrusted callers
## Security review **Commit reviewed:** `b2f2cfbdab3c2499dd1cb8bb90b74bf344889406` **Scope:** Documentation (`docs/frontend.md`, `docs/indexer-invariants.md`, `docs/testing.md`), `SwapPage.test.tsx` expectation alignment (99.97% → 100.00%), and `scripts/qa/verify-issue-293.sh` live QA step **[3c]** for `slippage_percent` enrichment. No production runtime code changes in this diff (core Expert Mode / route slippage logic merged in prior MRs). **Method:** Traced attacker-controlled inputs on modified paths. Reviewed the new QA Python block for SSRF/injection; compared against existing **[3a]/[3b]** patterns in the same script. Checked for auth bypass, secret leakage, XSS, and unsafe deserialization surfaces — none introduced here. **Outcome:** `FINDINGS: 0` medium+ Security review: **no medium+ findings** on this diff. **Inline threads:** none (no findings to anchor) --- | Area | Assessment | |------|------------| | Docs | Descriptive only; no new secrets, endpoints, or trust-boundary changes | | `SwapPage.test.tsx` | Test assertion only; no change to swap submit guards or slippage computation | | `verify-issue-293.sh` [3c] | Local QA harness; `VERIFY293_INDEXER_URL` defaults to `127.0.0.1:3001`; token addresses sourced from indexer `/api/v1/tokens` — same urllib/f-string pattern as pre-existing [3a]/[3b]; not exposed to untrusted callers |
PlasticDigits commented 2026-06-06 08:36:52 +00:00 (Migrated from gitlab.com)

mentioned in commit be290504aa

mentioned in commit be290504aa9cbd00135b378c6381ff6e23d4fc43
PlasticDigits (Migrated from gitlab.com) merged commit be290504aa into main 2026-06-06 08:36:52 +00:00
PlasticDigits commented 2026-06-08 08:43:13 +00:00 (Migrated from gitlab.com)

mentioned in commit 017fd28130

mentioned in commit 017fd281302920e6fd19f8500971e0a8bbd8ebb5
PlasticDigits commented 2026-06-08 13:42:29 +00:00 (Migrated from gitlab.com)

mentioned in commit 957ce1e39e

mentioned in commit 957ce1e39ecdab1223e7e1b7d2b3e8cb90e906fc
Sign in to join this conversation.
No reviewers
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!830
No description provided.