PP2 UI: Swap -- "Price impact too high for this trade" hard-blocks all multi-hop swaps even with Expert Mode enabled; preflight incorrectly flags near-zero spread hops as exceeding max spread #341
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#341
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?
Summary
On the swap page, after enabling Expert Mode to bypass the 90.88% cross-rate slippage warning, the swap button remains permanently disabled with the label "Price impact too high for this trade". This state is driven by
routePreflight.anyHopExceedsMaxSpread = true, which is a hard block that Expert Mode does not bypass.Direct
hybrid_simulationcontract queries run against both hops of the CORAL to JADE to TOPAZ route return near-zero spread on each hop, well below the 0.5% max spread threshold. The preflight is incorrectly computinganyHopExceedsMaxSpread = truewhen neither hop's actual on-chain spread exceeds the limit.The same block appears on all other tested multi-hop routes including EMBER to CORAL (routed via EMBER to JADE to RUBY to CORAL by the solver), confirming this is not pair-specific.
Observed behavior
On-chain
hybrid_simulationverification for CORAL to JADE to TOPAZ:Both hops clear the threshold.
anyHopExceedsMaxSpreadshould be false. It is true.Reproduction steps
/(Swap page) on LocalTerraExpected behavior
When Expert Mode is enabled and the per-hop on-chain spread is below the configured max spread tolerance (0.5%), the swap button should become enabled. "Price impact too high" should only block when a hop's actual AMM spread ratio exceeds the max spread threshold.
Actual behavior
anyHopExceedsMaxSpreadis true for all tested multi-hop routes even when direct contract simulation confirms near-zero spread on every hop. Expert Mode does not bypass this block. No multi-hop swap can be submitted.Possible root cause area
The preflight logic is in
frontend-dapp/src/services/terraclassic/swapRoutePreflight.ts. Three code paths can setanyExceeds = true:declaredMaterialReject.kind === 'insufficient_pool_leg'materialRejectAfterSim != null(fromhybridNoBeliefMaterialPoolReject)spreadRatioStrictlyExceedsMax(spreadCmp, totalGrossOut, maxSpreadDecimalStr)Path 3 is confirmed clear by direct simulation. Paths 1 and 2 require the hop to have a non-zero book leg, but both hops are pool-only (
book_return_amount: 0), sohybridNoBeliefMaterialPoolRejectreturns null immediately. The exact trigger has not been conclusively identified from static analysis. A try-catch fallback or a different code path (e.g. isMultiHop vs indexer path atSwapPage.tsx:466-531) may be involved.Impact assessment
Environment
/(Swap)Severity: ~"blocker:launch" Blocker: no multi-hop swap can execute; blocks PP-2 and all swap-dependent checklist items.
cc: @PlasticDigits
mentioned in issue #337
mentioned in commit
76723cf513mentioned in merge request !847
MR !847 opened
Changes: Removed pre-sim #307 reject; preflight uses enriched submit ops; Expert Mode copy + hop-spread button label.
Verify
npm test -- swapRoutePreflight.test.tsmentioned in merge request !849
mentioned in merge request !848
mentioned in commit
a6c43cab31Verification complete — #341
All acceptance and verification criteria PASS on
main(83dc192).Results
swapRoutePreflight.test.tsanyHopExceedsMaxSpread=false(#341 test)Merged fix: !847.
Re-verify checklist
npm test -- swapRoutePreflight.test.tsmentioned in issue #353
mentioned in merge request !864