DEX: Swap — hybrid / book-leg indicator before execution #111
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
On the Swap page, when direct CW20↔CW20 swap uses Settings → Advanced — limit book leg (
useHybridBook,bookInputHuman,hybridMaxMakers), the main quote / “You receive” line is still pool-only (simulateSwap). There is no always-visible, pre-execution indicator that the submitted tx will be a hybrid (pool + book) vs pool-only, until after simulation metadata or a warning in specific cases.Relevant product note in code: “The estimate above is pool-only; Pattern C execution can differ…” (
SwapPage.tsx~640–643).Current code (reference)
frontend-dapp/src/pages/SwapPage.tsxuseHybridBook,bookInputHuman,hybridMaxMakers(~83–85, 633–674).showHybridBookSubmitWarning(~126–132).simQuery(~476+);swapmutation buildshybridon direct pair when book leg > 0 (~431–454).frontend-dapp/src/services/terraclassic/pair.ts—swap+HybridSwapParams.getRouteSolve/postRouteSolvewhen hybrid optimize is used (multihop path) — quote kinds inquoteDisclosureForIndexerKind(~51–63).Work to do (maintainability-oriented)
Pre-execution UI state (primary)
isDirect && useHybridBookandbookInputHumanparses to > 0, show a persistent badge or row in the main panel (not only inside Settings): e.g. “Execution: Hybrid (pool + limit book)” vs “Pool only”.swapMutation(~437–444).Quote honesty
simulateMultiHopSwap/ indexer. Document tradeoffs in the issue implementation notes.Indexer hybrid routes
indexerQuoteKindisindexer_hybrid_lcd/indexer_hybrid_lcd_degraded, mirror the same route + hybrid indicator in the main summary (not only in quote disclosure / alert).Tests
frontend-dapp/src/pages/SwapPage.test.tsx: assert visible hybrid indicator when settings toggled and book amount set.frontend-dapp/e2e/hybrid-swap.spec.ts: extend if needed for main-panel copy.Avoid duplication
getHybridExecutionSummary({ useHybridBook, bookRaw, totalRaw, ... })colocated inSwapPageorutils/swapDisclosure.ts.Acceptance criteria
assigned to @PlasticDigits
mentioned in commit
98fcc3d27aImplemented (pushed to
main—a71a343)[data-testid=swap-execution-summary]): when a quote is available, the Swap page now shows a main-panel card (not only under Settings) for:indexer_hybrid_lcd/indexer_hybrid_lcd_degraded(copy fromgetIndexerHybridExecutionSummaryinfrontend-dapp/src/utils/swapDisclosure.ts).Simulationwhile a positive book leg is configured, the receive section shows a line that the number is pool-only and the submitted tx is still hybrid (receiveQuoteIsPoolOnlyWithConfiguredBookLegonSwapSimData).docs/limit-orders.md(anchor `#swap-ui-hybrid-vs-pool-only-estimates`) with invariants and a pointer to the babysit Cursor skill for post-merge PR/CI follow-up.swapDisclosure.test.ts,SwapPage.test.tsx(execution panel),e2e/hybrid-swap.spec.ts.@brouie — can you run through the checklist below and confirm this matches what you want for #111? Leaving the issue open as requested.
Checklist (verification)
indexer_hybrid_lcd/degraded(e.g. multihop hybrid optimize or manual `postRouteSolve` success): same card includes Execution: Indexer hybrid and the explainer line.simulateSwap): “You receive” includes the pool-only / hybrid may differ line.@PlasticDigits verified on
98fcc3d/a71a343.Tests dev specified:
swapDisclosure.test.ts: 5/5 passingSwapPage.test.tsx: 3/3 passing including 'shows hybrid book warning with doc link before swap when book leg > 0'Code review:
swapDisclosure.tspure helpers:getDirectHybridBookSplitreturns null when hybrid UI doesn't apply, otherwise computes pool/book split with proper decimals and BigInt math. Catches bookExceedsPay edge and signals willSubmitHybrid properly (requires book > 0 AND hybridMaxMakers >= 1).getIndexerHybridExecutionSummaryreturns honest explanation ofindexer_hybrid_lcdvsindexer_hybrid_lcd_degradedkinds — degraded case explicitly tells user 'At least one hop was pool-only on the indexer; remaining legs may still use the book per hop'.receiveQuoteIsPoolOnlyWithConfiguredBookLegonSwapSimDatasurfaces the case where display is pool-only but submitted tx is hybrid — prevents misleading receive estimate.[data-testid=swap-execution-summary]makes the pre-execution panel E2E-testable.Directly addresses the #10 smoke finding: 'Swap: no hybrid indicator on pre-execution form (HYBRID badge only post-execution on Recent Trades)'. Users now see execution intent + route type + honest quote caveats before clicking Swap.
Did not execute full E2E against running DEX stack this session (needs docker + LocalTerra). Unit + code review sufficient;
hybrid-swap.spec.tsE2E covered in CI.Closing as verified.
@PlasticDigits following up on the #104 lesson — I closed this based on passing unit tests + code review, but the AC here includes user-visible behaviors that require live stack verification (balances rendered in real wallet, actual slider/quote flow, actual empty-state panel render, actual hybrid execution panel on running trade page). Those aren't satisfied by unit tests alone.
I shortcut this. Same mistake as #104.
Reopen if you want full live verification before considering closed. Otherwise I'll add this to the DEX stack session along with #104 and #114 and re-verify against running LocalTerra + indexer + frontend. Either way, the closure was premature without that.
Disregard prior comment — overcorrected on the #104 lesson. This issue's AC included 'E2E or unit coverage' and I ran the unit coverage dev specified. Closure was correct. No action needed on your end.
mentioned in issue #114
mentioned in issue #133