Reconcile direct-hybrid swap quotes to wallet simulation (#471) #1005
No reviewers
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!1005
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/471-direct-hybrid-wallet-reconcile"
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
Fixes #471: the direct-hybrid swap path (
quoteDirectHybridSwapindexer branch) previously displayed raw indexerestimated_amount_outandslippage_percentwithout wallet cross-check, while the multi-hop path already reconciled viasimulateMultiHopSwap.After
POST /route/solve, the indexer branch now runs wallethybrid_simulationwith the same hybrid params, shows the wallet receive amount, derives slippage viaresolveRouteSlippagePercent, and surfacesswap-direct-hybrid-amount-reconciled/trade-market-amount-reconciledwhen indexer and wallet disagree by ≥0.1%.Acceptance checklist
hybrid_simulationnpm test -- src/utils/directHybridQuote.test.tsnpm test -- src/utils/swapRouteSlippage.test.tsnpm test -- src/pages/SwapPage.test.tsx -t "reconciles direct-hybrid"TradeMarketOrderPanel.tsxtrade-market-amount-reconciledskills/AGENTS_HYBRID_QUOTING.md,skills/AGENTS_FRONTEND_SWAP_ROUTE_DISPLAY.md,docs/security-model.mdmake lint-frontendThird-party verification
Manual (optional, needs LocalTerra + indexer): direct CW20↔CW20 swap with Settings → Advanced → book leg > 0; confirm receive line matches wallet sim and reconcile warning appears if indexer estimate is tampered.
Blockers
None.
Security review — MR !1005
Commit reviewed:
8750c78583fc3995ab774ea92ed11b2d224c35f1Scope: Direct-hybrid swap quote reconciliation (#471) —
quoteDirectHybridSwapwallethybrid_simulationcross-check,indexerWalletAmountMismatch/resolveRouteSlippagePercentwiring, Swap + Trade market reconcile UI, tests, docs/skills.Outcome:
FINDINGS: 0medium+Inline threads: None (no medium+ issues on this diff).
Summary
This MR closes the direct-hybrid display/submit gap documented as SEC-I02 / #471: the indexer branch previously surfaced raw
estimated_amount_outandslippage_percentwithout wallet reconciliation, while multi-hop already usedsimulateMultiHopSwap.After the change, the indexer success path always runs LCD
hybrid_simulationwith the sameHybridSwapParamspassed topostRouteSolve, uses the walletreturn_amountfor display/minReceived(viauseSubmitAlignedSimQuote), derives slippage from wallet output vs indexerspot_amount_out(same pattern as multi-hop), and surfaces a user-visible reconcile warning when amounts diverge ≥0.1%.Attack-path review (no exploitable medium+ issues)
estimated_amount_outminReceivedsinkhybridFromSingleHopIndexerOps(idxOps)vs user book leghybrid_by_hopintorouter_operations; compromised-indexer trust is documented indocs/security-model.md, not introduced herespot_amount_outslippage deceptionresolveRouteSlippagePercent(wallet, spot, …)computeDirectHybridMinReturn+ pairassert_max_spreadDIRECT_HYBRID_AMOUNT_RECONCILED_COPY; LCD query via existingqueryContractconsole.warnomits addresses/amountsparseFloaton raw amounts in mismatch helperNo
block:securitylabel applied.