fix(swap): size receive targets through bounded route solver #1378

Merged
PlasticDigits merged 2 commits from fix/issue-1376-receive-solver into main 2026-10-04 04:32:26 +00:00
Owner

Receive targets such as 100 CL8Y could fail a feasible pool quote at the pair's 32-call reverse-search cap, leaving Pay blank without a useful explanation. This change adds bounded server receive sizing, preserves selected operations through wallet validation/submission, and exposes finite disconnected failures with retry.

Refs #1376.

  • Compare up to five feasible fresh pool paths among 32 structural candidates, at most four hops. Use checked integer inverses, strict fee/tax context, live execution guards, and required fair-rate metadata; retain 5/30/99 protections.
  • Reuse the proven minimum pool inverse plus one forward validation. Hybrid reverse retains its 32-call cap. Pair cw2 is 1.19.0 with unchanged storage.
  • Preserve receive intent on indexer-only routes, native fee/tax inverses, selected gross offers, stale-state invalidation and a 70-second cancellable frontend deadline. Execution stays offer-in with existing minimum-receive semantics.

Validation: 878 contract tests; 449 indexer library tests plus 12 exact-output, 29 existing route and 8 DB hybrid tests; focused frontend suite 192 tests per pass; 13 browser receive cases; lint/types/Clippy; #1256/#713/#678/#512/#1280 regressions. Final make verify-issue-1376 including LocalTerra: PASS=12 FAIL=0 SKIP=1. Hooks and secret scan passed.

LocalTerra: 26 pairs migrated to the final artifact with pool state preserved. Funded CW20 execution matched the chosen two-hop operations, send amount and wallet minimum. The native dust fixture verified blocked risk consent; it did not broadcast a native transaction.

Issue criteria:

  • AC2: competing eligible pool paths, alternate-path recovery and indexer-only receive intent.
  • AC3: real 10/100 cap boundary, minimal offers and bounded failure cases.
  • AC5/AC6: finite errors/retry, receive ownership and stale execution rejection.
  • AC7: selected offer/operations/minimums verified in RTL and funded CW20 execution.
  • AC1/AC8: deploy matching indexer/frontend and migrate production pairs, then record new versions and fresh production 10/100 replay.
  • AC4: complete funded native/tax/mapper execution matrix; unit/API coverage passes, native synthetic-price fixture remains protected rather than executed.

Agent review instructions and completed evidence: QA checklist, verification, third-party agent protocol. Run the issue verifier and applicable regressions, retain exact revision/results, and repeat the public migration/browser probes after rollout. Agents may record PASS with explicit skips for unavailable checks; an executed failure remains FAIL and a skipped criterion remains unverified. The production issue stays open until remaining acceptance is substantiated.

Search scope excludes hybrid-book sizing and unsupported option-2 taxed middle hops. Fair reference-only paths use fresh bounded pool arithmetic without extra live pause/blacklist probes; actual execution candidates receive those live guards. Production rollout was not performed in this PR delivery.

Receive targets such as 100 CL8Y could fail a feasible pool quote at the pair's 32-call reverse-search cap, leaving Pay blank without a useful explanation. This change adds bounded server receive sizing, preserves selected operations through wallet validation/submission, and exposes finite disconnected failures with retry. Refs #1376. - Compare up to five feasible fresh pool paths among 32 structural candidates, at most four hops. Use checked integer inverses, strict fee/tax context, live execution guards, and required fair-rate metadata; retain 5/30/99 protections. - Reuse the proven minimum pool inverse plus one forward validation. Hybrid reverse retains its 32-call cap. Pair cw2 is 1.19.0 with unchanged storage. - Preserve receive intent on indexer-only routes, native fee/tax inverses, selected gross offers, stale-state invalidation and a 70-second cancellable frontend deadline. Execution stays offer-in with existing minimum-receive semantics. Validation: 878 contract tests; 449 indexer library tests plus 12 exact-output, 29 existing route and 8 DB hybrid tests; focused frontend suite 192 tests per pass; 13 browser receive cases; lint/types/Clippy; #1256/#713/#678/#512/#1280 regressions. Final `make verify-issue-1376` including LocalTerra: **PASS=12 FAIL=0 SKIP=1**. Hooks and secret scan passed. LocalTerra: 26 pairs migrated to the final artifact with pool state preserved. Funded CW20 execution matched the chosen two-hop operations, send amount and wallet minimum. The native dust fixture verified blocked risk consent; it did not broadcast a native transaction. Issue criteria: - [x] AC2: competing eligible pool paths, alternate-path recovery and indexer-only receive intent. - [x] AC3: real 10/100 cap boundary, minimal offers and bounded failure cases. - [x] AC5/AC6: finite errors/retry, receive ownership and stale execution rejection. - [x] AC7: selected offer/operations/minimums verified in RTL and funded CW20 execution. - [ ] AC1/AC8: deploy matching indexer/frontend and migrate production pairs, then record new versions and fresh production 10/100 replay. - [ ] AC4: complete funded native/tax/mapper execution matrix; unit/API coverage passes, native synthetic-price fixture remains protected rather than executed. Agent review instructions and completed evidence: [QA checklist](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/045812abb277d615f5736907e9aa8607971c0d48/docs/qa/issue-1376/README.md), [verification](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/045812abb277d615f5736907e9aa8607971c0d48/docs/qa/issue-1376/verification.md), [third-party agent protocol](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/045812abb277d615f5736907e9aa8607971c0d48/skills/AGENTS_SWAP_EXACT_OUTPUT.md). Run the issue verifier and applicable regressions, retain exact revision/results, and repeat the public migration/browser probes after rollout. Agents may record PASS with explicit skips for unavailable checks; an executed failure remains FAIL and a skipped criterion remains unverified. The production issue stays open until remaining acceptance is substantiated. Search scope excludes hybrid-book sizing and unsupported option-2 taxed middle hops. Fair reference-only paths use fresh bounded pool arithmetic without extra live pause/blacklist probes; actual execution candidates receive those live guards. Production rollout was not performed in this PR delivery.
fix(swap): size receive targets through bounded route solver
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
045812abb2
Repair pool reverse math, preserve selected quote operations, and document agent verification.
docs: cross-link receive sizing implementation and verification
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
1d21f095fc
PlasticDigits deleted branch fix/issue-1376-receive-solver 2026-10-04 04:32:27 +00:00
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!1378
No description provided.