feat(swap): make receive amounts editable on native and client routes #1374

Merged
PlasticDigits merged 1 commit from fix/issue-1256-receive-input into main 2026-10-04 02:18:15 +00:00
Owner

What

Swap previously made You Receive editable only for direct CW20 pairs. It now accepts receive targets on native/wrapped, mapper-only wrap/unwrap, and client multi-hop routes, then sizes the pay offer using pair/router reverse simulation or shared integer fee/tax inverses.

Submission uses that offer through the forward quote and minimum-receive checks. Direct reverse swaps include a forward-quote minimum, community-tax receive targets are net with pre-tax execution floors, and stale/failed reverse offers cannot submit. Indexer-only routes without client operations silently restore pay-sided intent. No indexer exact-out endpoint is introduced.

Why

Closes #1256. Investigated the issue and its comments (none present); the direct-only implementation on main did not cover this product slice.

The shared wrap inverse also serves invoice payment, including integer skim rounding. Native output inversion accounts for mapper unwrap fee, burn-tax rate, and tax cap. Forward/reverse router quotes carry matching trader/sender context.

Testing

  • make verify-issue-1256: repeated PASS, 216 unit/RTL tests plus 9 Chromium tests with five workers; PASS=5 FAIL=0 SKIP=0.
  • make verify-issue-713, make verify-issue-678, and make verify-issue-512: repeated PASS. The legacy #713 live-chain browser substep skips without a deployed factory/environment; the new #1256 browser suite runs using mocked LCD.
  • Existing Swap page suites: 67 tests passed, then repeated after the submit-floor changes.
  • TypeScript build and full frontend lint: passed (five existing warnings in unrelated files).
  • Independent production review: passed after correcting test fixtures and adding connected direct/native submit, insufficient balance, and stale/error assertions.
  • Commit hooks: Rust format/clippy, TypeScript, staged ESLint/Prettier, secret scan; push hooks retained.
  • Live wallet signing and chain execution: not performed. Connected-wallet tests assert offer/minimum arguments; browser fixtures exercise the real UI and reverse query dispatch without broadcasting.

Liquidity add/remove and production deployment are outside this frontend receive-sizing scope. No migration or production environment change is required.

Issue acceptance checklist

  • AC1 — Default/native receive is an input; reverse pay and debounced canonical URL replacement work.
  • AC2 — Direct factory CW20 pair reverse remains pair simulation; execute sends the offer.
  • AC3 — Direct wrap/unwrap inverses preserve W8/W9 with exact raw rounding and capped burn tax.
  • AC4 — Client/native multi-hop uses router reverse operations; forward execution and hop floors retained.
  • AC5 — Indexer-only output silently becomes pay-sided; no reverse solver, brute force, or lecture banner.
  • AC6 — Max/all fractions become pay-sided; clear/flip, stale/error, balance, and existing safety regressions pass.
  • AC7 — Community-tax target is net; execution minimum is pre-tax and sell debit is not duplicated.
  • AC8 — New verifier and #713/#678/#512/chrome checks pass, with the legacy live browser skip disclosed above.
  • AC9 — No new chrome layer, indexer/contract/nginx API change, or amount persistence.

Agent review instructions

Check out this head, record git rev-parse HEAD, and follow the review checklist. Run make verify-issue-1256, then the #713/#678/#512 verifiers, frontend lint, and chrome nesting check. Inspect connected submit assertions to confirm pay raw equals the reverse offer and minimum receive uses the correct pre-tax base.

Agents may mark truly unavailable items SKIP with a concrete reason and remaining scope, while marking the overall review PASS with explicit skips when completed checks pass. Never check off an unexecuted criterion or turn a failed assertion into PASS. The new verifier reports PASS/FAIL/SKIP separately and supports documented skip-reason variables. Retest affected checks after corrections.

Invariants and code map: R1256 / Q713-4 / Q711-6, third-party agent playbook. Recorded implementation evidence: verification.md.

Checklist

  • No added runtime contract pins, credentials, or keys; synthetic addresses exist only in isolated browser fixtures.
  • Lint and tests pass; unavailable live checks are explicitly disclosed.
  • Documentation, invariants, agent skills, and verification instructions crosslinked.
## What Swap previously made You Receive editable only for direct CW20 pairs. It now accepts receive targets on native/wrapped, mapper-only wrap/unwrap, and client multi-hop routes, then sizes the pay offer using pair/router reverse simulation or shared integer fee/tax inverses. Submission uses that offer through the forward quote and minimum-receive checks. Direct reverse swaps include a forward-quote minimum, community-tax receive targets are net with pre-tax execution floors, and stale/failed reverse offers cannot submit. Indexer-only routes without client operations silently restore pay-sided intent. No indexer exact-out endpoint is introduced. ## Why Closes #1256. Investigated the issue and its comments (none present); the direct-only implementation on main did not cover this product slice. The shared wrap inverse also serves invoice payment, including integer skim rounding. Native output inversion accounts for mapper unwrap fee, burn-tax rate, and tax cap. Forward/reverse router quotes carry matching trader/sender context. ## Testing - [x] `make verify-issue-1256`: repeated PASS, 216 unit/RTL tests plus 9 Chromium tests with five workers; `PASS=5 FAIL=0 SKIP=0`. - [x] `make verify-issue-713`, `make verify-issue-678`, and `make verify-issue-512`: repeated PASS. The legacy #713 live-chain browser substep skips without a deployed factory/environment; the new #1256 browser suite runs using mocked LCD. - [x] Existing Swap page suites: 67 tests passed, then repeated after the submit-floor changes. - [x] TypeScript build and full frontend lint: passed (five existing warnings in unrelated files). - [x] Independent production review: passed after correcting test fixtures and adding connected direct/native submit, insufficient balance, and stale/error assertions. - [x] Commit hooks: Rust format/clippy, TypeScript, staged ESLint/Prettier, secret scan; push hooks retained. - [ ] Live wallet signing and chain execution: not performed. Connected-wallet tests assert offer/minimum arguments; browser fixtures exercise the real UI and reverse query dispatch without broadcasting. Liquidity add/remove and production deployment are outside this frontend receive-sizing scope. No migration or production environment change is required. ## Issue acceptance checklist - [x] AC1 — Default/native receive is an input; reverse pay and debounced canonical URL replacement work. - [x] AC2 — Direct factory CW20 pair reverse remains pair simulation; execute sends the offer. - [x] AC3 — Direct wrap/unwrap inverses preserve W8/W9 with exact raw rounding and capped burn tax. - [x] AC4 — Client/native multi-hop uses router reverse operations; forward execution and hop floors retained. - [x] AC5 — Indexer-only output silently becomes pay-sided; no reverse solver, brute force, or lecture banner. - [x] AC6 — Max/all fractions become pay-sided; clear/flip, stale/error, balance, and existing safety regressions pass. - [x] AC7 — Community-tax target is net; execution minimum is pre-tax and sell debit is not duplicated. - [x] AC8 — New verifier and #713/#678/#512/chrome checks pass, with the legacy live browser skip disclosed above. - [x] AC9 — No new chrome layer, indexer/contract/nginx API change, or amount persistence. ## Agent review instructions Check out this head, record `git rev-parse HEAD`, and follow [the review checklist](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/7bce02f108be1b7dd0c5886ae23f0d2d6f410683/docs/qa/issue-1256/README.md). Run `make verify-issue-1256`, then the #713/#678/#512 verifiers, frontend lint, and chrome nesting check. Inspect connected submit assertions to confirm pay raw equals the reverse offer and minimum receive uses the correct pre-tax base. Agents may mark truly unavailable items **SKIP** with a concrete reason and remaining scope, while marking the overall review **PASS with explicit skips** when completed checks pass. Never check off an unexecuted criterion or turn a failed assertion into PASS. The new verifier reports PASS/FAIL/SKIP separately and supports documented skip-reason variables. Retest affected checks after corrections. Invariants and code map: [R1256 / Q713-4 / Q711-6](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/7bce02f108be1b7dd0c5886ae23f0d2d6f410683/docs/frontend.md#swap-reverse-quotes), [third-party agent playbook](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/7bce02f108be1b7dd0c5886ae23f0d2d6f410683/skills/AGENTS_FRONTEND_SWAP_REVERSE_QUOTES.md). Recorded implementation evidence: [verification.md](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/7bce02f108be1b7dd0c5886ae23f0d2d6f410683/docs/qa/issue-1256/verification.md). ## Checklist - [x] No added runtime contract pins, credentials, or keys; synthetic addresses exist only in isolated browser fixtures. - [x] Lint and tests pass; unavailable live checks are explicitly disclosed. - [x] Documentation, invariants, agent skills, and verification instructions crosslinked.
feat(swap): support receive sizing on native and client routes
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
7bce02f108
Add shared fee and tax inverses, client reverse quotes, and forward submit floors. Cover native and CW20 sizing with regression tests, browser checks, and agent verification guidance.
PlasticDigits deleted branch fix/issue-1256-receive-input 2026-10-04 02:18:15 +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!1374
No description provided.