fix(trading): show order slippage separately from fees and reference-price deviation #1500
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#1500
Loading…
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 and why this change is needed
Swap displays a total fair-reference/net-output difference as “Price difference … — trading costs”, “wrapping costs” or “different pricing”. This combines order size/book pricing with fees, wrapper losses and reference divergence. It does not give users the requested order-slippage metric. Bundle corrected metric semantics, cost disclosure and concise consistent copy in one implementation. The retail summary must show order slippage separately from trading fees; detailed fees/costs belong in the single DETAILS disclosure.
Investigation baseline: reviewed repository HEAD (
efb5fba29d3dc401d0d026d8b683db8054458920) (2026-10-14 UTC). This report is a sanitized technical synthesis. No reporter identity, conversation, supplied screenshot, wallet actor/context digest, credential, private endpoint or workstation information is attached. Reported live symptoms are distinguished from independently observed/source-confirmed behavior.Current codebase and independently confirmed behavior
frontend-dapp/src/utils/swapRouteSlippage.ts:49–85computes100 × abs(fair − net) / max(fair, net)with checked raw integer threshold handling. Despite routeSlippage variable names, this is symmetric fair-reference deviation including output losses/costs, not order slippage alone.utils/cw20RouteSolveQuote.tsandutils/nativeWrapRouteSolve.tspopulaterouteSlippagePercentfrom delivered net and reference output.pages/SwapPage.tsx:1181–1238uses this value for display and 5/30/99 review/guard decisions.utils/routeEconomicExplanation.tsvalidates signed common-output attribution and selects its dominant cause.components/swap/SwapImpactAside.tsx:26–43attaches that cause to the entire aggregate percentage. Thus a percentage containing several effects is followed by a phrase such as “trading costs” or the vague “different pricing”.components/trade/TradeMarketOrderPanel.tsxshares this component and economic logic.indexer/src/api/local_quote/attribution.rsalready separateswrapper_loss,trading_cost,market_movement,reference_divergenceas signed raw final-output units. They telescope tofair_amount_out − net_amount_out. This arithmetic bridge is advisory; it is not an independent oracle or a fee-free executable quote.market_movementcan be favorable with book execution and is not safely interchangeable with the aggregate fair-reference percentage.api/local_quote/attribution.rs,protection.rs,local_quote.rs(response construction),diagnostics.rs,db_orderbook_sim.rs,local_wrapper_quote.rsandindexer/tests/scenarios/route_cost_attribution_1483.rs; frontend files above plustypes/index.ts,utils/localRouteQuote.ts,utils/localWrapperOnlyQuote.ts,utils/routeEconomicExplanation.test.ts,utils/swapRouteSlippage.test.ts,components/swap/SwapImpactAside.test.tsx,pages/SwapPage.test.tsx, Trade tests anddocs/route-solver.md.Relevant source links: swapRouteSlippage.ts, routeEconomicExplanation.ts, SwapImpactAside.tsx, attribution.rs.
Recommended direction and metric contract
market_movement / fair_amount_outis correct when the reference itself diverges; independently establish the selected-route baseline/denominator.Slippage X% Fee Y% token → token…, using truthful concise labels. Define the fee percentage's basis; aggregate multihop fees with exact common-unit economics rather than adding fee bps. Show canonical raw/human trading, tax/hook and wrapper costs with denomination in DETAILS, and network fee once separately in LUNC. Unknown costs remain visibly unavailable; no double counting or treating gas as output loss.Constraints and guardrails
This product requirement explicitly supersedes RC1483-2's “only retail percentage” presentation rule and RC1483-7's old “Price difference”/“Signing details” copy placement; update associated docs/agent instructions. It does not replace the signed raw-attribution reconciliation contract, independently admitted reference quality (including the $10 total-TVL and separate $100 independently priced hub-depth floors), economic admission thresholds or signing controls. Preserve genuine >5% consent, >30% Expert and ≥99% nonwaivable fair-deviation refusal independently of the new displayed order metric, including favorable reference differences. Preserve quote-relative selected tolerance, separately derived execution market ceiling, exact upward-rounded positive post-hook/hop/final floors, gross route-local funding/tax credit, original expiry/context, wrapper policy, unknown offline-budget refusal and fee/Max/signing parity. Requests remain offline with existing search/resource limits and independently scheduled observations. Diagnostics cannot authorize signing; network fees remain external to delivered swap output and principal.
Acceptance criteria
Test plan for all paths
Attack, hack and abuse test plan
Forge a cheap/zero/slightly negative fee or slippage, signed raw components, denominator, method/version, dominant cause, token decimals, route boundaries, expiry or generation; mismatched/overflow/noncanonical fields must fail closed at the relevant boundary. Use adversarial spot/reference divergence and tiny liquidity to make order slippage look small while fair risk is extreme: 5/30/99 and reference admission must still operate. Replay advisory economics across amount/native credit/actor/tier/mode/operations; no diagnostic can change authorization, ranking or reviewed signing. Fuzz cyclic/repeated assets, overlong hops/plans, huge book/reserve values and hostile labels/errors for bounded work, no panics/XSS and no unexpected provider calls. Test genuine freeze/pause/blacklist, supported tax/hook settlement, hook floor and refund ownership, fee-envelope errors and no-resend recovery.
Verification criteria
Run
make verify-issue-1483,1489,1473,1480,1452and applicable reference/floor/tax/launch checks after adding meaningful independent metric fixtures. Repeat stable final source in owned disposable fixtures. Actual Swap/Trade desktop/phone checks must show the new row/cost semantics with valid matched quote provenance; API arithmetic alone cannot attest UI, independent reference truth or funded settlement. Separately attest deployed frontend/backend/root and contract artifacts for live claims; useful socket/browser clocks remain ≤500ms/≤750ms from original inputs. Complete feasible checks first; unavailable workflow holds or verification prerequisites do not block implementation/reporting. Keep skipped acceptance unchecked and preserve executed failures; no safeguard weakening, invented 0% or suppressed failure is an acceptable workaround.Related work
Follow-up to #1483 with explicit revised presentation requirements. Preserve #1480 offline fees, #1473 quote-relative policy/outcomes, #1479 reference quality and #1489 exact-net promotion. Coordinate with #1498 for the single row/DETAILS layout and #1499 for stable quote lifecycle. This issue owns metric definitions/cost attribution and risk wording.
Completed baseline verification and retained limits
Unchanged reviewed source
efb5fba29d3dc401d0d026d8b683db8054458920; independent first/retest checks on 2026-10-14 UTC. Owned disposable Postgres had a dedicated QA role/admin-owned marked control database and fresh per-process child databases; its containers were removed. The final repository working tree is clean. These are baseline investigation checks, not implementation/acceptance of this issue.make verify-issue-1483make verify-issue-1489make verify-issue-1480make verify-issue-1473corrected, scoped retesttruncated:true; not the full matrix.make verify-issue-1452final full local runThe scoped #1473 production-build browser fixture completed 240 rows across desktop/phone: 220 useful quotes, 20 typed blockers, zero fixture failures, 114 quote requests and zero provider requests. Its original-input-through-render useful timing was p50/p95/p99/max 89.7/149.1/166.7/169.8ms against 750ms. Directions actually exercised were UST1→CL8Y, CL8Y→UST1 and USTC→CL8Y at 5%; no complete pair/protection corpus is claimed. The fixture uses synthetic pinned pool economics and zero-fee native wrappers, not production settlement or nonzero-wrapper-cost acceptance.
Retained failures: the initial #1473 run finished FAIL (14 PASS, 3 FAIL, 2 SKIP). Two configured-default fixture assertions failed in both first/retest (480/482 frontend tests passed); explicit fixture-aligned CL8Y configuration subsequently passed all 482 twice, plus a standalone 16-test retest. The initial full browser attempt failed writing its receipt with
ENOSPC; its generated truncated QA file was restored from a pre-run backup. The initial #1452 run was interrupted during the disk-space incident; the later full local run above is separate. Passing later/subset tests do not erase these failures or certify the failed full browser matrix. No shared build/user data was deleted to obtain a pass.Live evidence remains narrower: the anonymous API sample has 12 useful responses, one typed unsupported outcome and two no-response probe failures. One useful HTTP duration was 849.278ms (above the separate 500ms target); transport classes were not captured, so this is retained rather than claimed as initialized socket acceptance. Phone/desktop live DOM transitions reproduce the presentation failures but do not independently validate every response. Initial browser setup/timeouts and the stopped independent deployment attester remain failed/incomplete; a later public health read matches the reviewed backend SHA only. Exact frontend/root/contracts, full sustained live matrix, physical wallets and funded execution remain unverified. No incomplete acceptance criterion is checked, and related open issues are not closed by these source passes.
Implementation merged in PR #1501, main revision
9dfa373f989ca9684c00ce40bc0525265243dfe9(2026-10-14 UTC). Woodpecker PR pipeline #456 passed, including secrets, contracts, full frontend, indexer library/Postgres and required functional checks.Completed source/local scope:
Individual acceptance criteria are not closed by this shared source summary. Evidence, retained failures and remaining scope and the individual QA checklists are included in main. The initial documentation/owned-fixture failures were corrected and retested; prior failures remain recorded. Final issue-specific live results will follow; this issue remains open until all body/comment criteria pass.
Producer follow-up PR #1502 is merged into main
14055610ebe86fd3640ff85e8adc15e16785c6dd; required CI #458 passed all eight steps. Main and the feature worktree are synchronized.See release results and invariant links. This is source/CI completion, not a claim that every issue criterion passed. Final issue-specific live results will follow; the issues remain open.
Final QA/evidence PR #1503 merged into main
4bd3e8d31485613d6c3ddca62abbac1a1f6e6469; required CI #460 passed all eight steps. Main and the worktree are clean and synchronized with origin/main. Application runtime inputs did not change in this QA-only merge; the actual deployed revision remains the attested14055610…below.Fixes merged in PR #1501 and PR #1502. Both Coolify applications finished at independently attested release
14055610ebe86fd3640ff85e8adc15e16785c6dd; required CI pipelines 456/458 each passed all eight steps. Later helper/evidence changes do not claim a newer application deployment.A current-release physical-wallet card is queued through the inbox-assigner skill on cl8y-pm, linked to operator tracking #143. Its ready command consumes OpenBao credentials privately and prepares one reviewed attempt. It explicitly supersedes the earlier obsolete 9dfa card; the assigner cannot withdraw that older card. No mainnet transaction was signed by the agent.
Results, retained failed runs and invariant links. All issue bodies and current comments were reviewed. No complete acceptance claim: this issue stays open for the unchecked scope.
QA provenance limit: final V5 tools pass 27/27 regressions first/retest; no new full live trial was run after those corrections. Executed V4 driver/clock hashes and raw receipts were retained, but their exact source bytes were not archived. This limits exact replay; original failed live verdicts remain unchanged.
PlasticDigits referenced this issue2026-10-15 05:32:59 +00:00
Closed at the user's request as part of consolidating issues #1449–#1500.
Separate signed order slippage, trading fees, actual route and fair-reference safeguards are implemented and deployed. Remaining actual native recovery and protected wrapper rollout move to #1504.
Replacement: #1504
Wallet/device chores and verification-only holds are intentionally excluded. Historical failed receipts remain unchanged; this closure does not claim every old acceptance checkbox passed.