fix(swap): fund token taxes at route swap points without intermediate wallet debits #1381

Closed
opened 2026-10-04 06:18:04 +00:00 by PlasticDigits · 7 comments
Owner

Summary

Token identity correction: the taxed intermediate is ALPHA (terra1x6e64es6yhauhvs3prvpdg2gkqdtfru840wgnhs935x8axr7zxkqzysuxz). Canonical cLUNC is a different contract (terra1437qslye72t7qmmahn4t5chz50r8a62g45phwkquwpyu2l62u6ksqssgdg). The earlier intermediate label was incorrect; the quote, code 11666, tax configuration, and synthetic preview evidence concern ALPHA.

CL8Y→USTR can receive a quote for a route that requires extra ALPHA already held in the trader's wallet. The live solver selects CL8Y→ALPHA→UST1→USTR, labels it tax_kind=none, and reports zero sell tax, while the ALPHA middle-hop contract actually charges a 1% sell extra-debit to the authenticated trader. Tokens acquired by the preceding hop sit on the router, so they do not fund that separate wallet debit. A trader with no ALPHA reserve can therefore hit the existing sell-tax error despite holding enough CL8Y. Reducing CL8Y or tapping CL8Y Max cannot solve a zero balance of the required intermediate asset.

This issue bundles contract/router tax funding at swap points, route capability discovery, quote/execute parity, frontend preflight, and recovery messaging for this failure. Permanent acceptance requires supported taxed intermediate routes to work without an intermediate balance in the trader wallet; route exclusion alone is containment. Related closed work: #615, #1267, #1285. Their security checks remain relevant, but their router-hop funding and exclusion expectations must be revised where they conflict with the required behavior below.

Required behavior and scope

Collect configured tax at the affected swap points from this route's own token amounts. Do not debit the trader's separate wallet balance for a routed hop's tax. The trader still bears the economic cost through the quoted exchange result, but needs only the explicitly authorized initial offer and network fees. No pre-existing ALPHA, UST1, or any other intermediate balance is required.

This intentionally replaces the wallet-funded router-hop rule in T592-13 / R607-1 / R607-4 / R607-7, the old R615 middle-hop exclusion as a permanent solution, and the previous blanket H-01 prohibition on router tax sizing to the extent needed for correct local tax funding. Keep the security purpose of 1:1 declared pair credit: the pair must receive exactly the economic amount its swap hook declares. Any change to how gross routed funds are split into pair input and tax requires an explicit, tested protocol/API revision; an inconsistent CW20 credit/hook amount is unacceptable.

A temporary exclusion of genuinely unsupported legacy-tax routes is allowed during rollout. It does not satisfy the permanent fix for migrated, supported community-tax tokens such as ALPHA.

Anonymized report and investigation evidence

The reported symptom is a CL8Y→USTR attempt displaying the application's sell-tax balance error. No reporter identity, wallet address, screenshot, chat quotation, or conversation is published here. The failed transaction hash, input amount, selected route, and deployed bundle version for that attempt are unavailable; the exact reported transaction is not claimed reproduced.

Investigation on 2026-10-04 against current main 3f9310652a, matching the remote main head:

  1. Read-only live GET https://indexer.dex.cl8y.com/api/v1/route/solve with canonical CL8Y/USTR contract IDs, synthetic amount_in=1000000000000000000 (1 CL8Y), and max_hops=3 returned CL8Y→ALPHA→UST1→USTR. It returned sell_tax_bps=0, buy_tax_bps=0, router_hops_tax=false, tax_kind=none, and fidelity_check=passed. Repeating with an explicit deterministic synthetic trader still returned the ALPHA middle hop, tax_kind=none, zero sell tax, and passed fidelity; a read-only LCD balance query confirmed that synthetic trader held zero ALPHA. These requests did not use a reporter wallet or broadcast anything.

  2. LCD contract/config queries identify canonical CL8Y as code 10184, with get_config rejected as an unsupported query by cw20_mintable. CL8Y itself is not established as a community-tax sell token by this evidence. The selected ALPHA intermediate is code 11666, with sell_bps=100 and buy_bps=450.

  3. Execute-aligned read-only ALPHA TaxPreview from its configured official router to the selected ALPHA/UST1 pair, with a deterministic synthetic non-exempt trader and Swap.trader, returned:

    {"kind":"sell","declared":"1000000","debit":"1000000","credit":"1000000","tax":"10000","hop_trader_debit":"10000"}
    

    These are synthetic raw units. debit describes the router leg; the additional hop_trader_debit is charged to the trader. Contract apply_transfer calls sub_balance(trader, tax) for this case.

  4. Live /api/v1/community-tokens reported catalog code 11630, total 1, containing KENA. ALPHA code 11666 was absent. Catalog attestation requires the configured code ID and launcher/admin provenance; routing currently relies on that catalog for tax discovery.

  5. make verify-issue-1285 passed, including its 35-test frontend run and the nested make verify-issue-1267 88-test run. cargo test --manifest-path indexer/Cargo.toml --lib community_tax_rank -- --test-threads=1 passed all 14 tests, including the catalogued middle-hop exclusion. Passing these tests does not cover a live taxed intermediate absent from the catalog.

  6. Three temporary synthetic frontend probes confirmed current behavior: a successful taxed config followed by a failed 503 refetch changes detection to honest; disabled Create Token configuration prevents swap tax discovery; and extraDebitSubmitGate with an unknown wallet balance returns blockSubmit=false even with a known positive tax debit. The probes asserted existing behavior and were removed after execution; they are evidence of gaps, not tests proving a fix.

A follow-up live identity census queried token_info and tax configuration for all 20 distinct CW20 contracts in the indexed asset inventory plus the published token list. ALPHA reports name=ALPHA Lunc Universe, symbol=ALPHA, code 11666, sell 1%, buy 4.5%. Canonical cLUNC reports name=Wrapped LUNC, symbol=cLUNC, code 10184 (cw20_mintable), with no community sell tax. Among assets in the current indexed DEX pools, ALPHA is the only positive community-tax sell configuration found; KENA has zero buy/sell/transfer bps. USTRIX and DO, present in the published token list but with no indexed DEX pools, expose different legacy APIs: USTRIX tax_map has conditional 5% Send tax, and DO tax_info has address-conditioned default 1.5% Send/Transfer tax plus a sender-specific 20% Send override. An unsupported get_config alone must not classify every legacy token as tax-free; inspect its actual supported tax API/capability. This census concerns token-level taxes, separately from pool fees and native wrap/unwrap costs.

Read-only previews and quote simulations establish the route hazard; they do not establish execution success. No live funds, signatures, migrations, or deployments were used.

Current codebase and why a new implementation is needed

best_execution.rs loads tax metadata for candidate hop assets and applies path_sells_middle_tax_hop. That predicate only recognizes entries in TaxRankSnapshot.by_addr and an option-2 code/hash policy. Missing rows are treated as ordinary assets. load_tax_rank_snapshot also falls back to ranking without tax data on a catalog lookup failure.

indexer/indexer/community_tokens.rs deliberately attests Create/Manage catalog entries using one configured code ID and provenance. That product attestation is narrower than the live set of assets whose router hops charge extra debit. Its single-ID policy must not determine whether an executable trading route has hidden wallet obligations.

Swap/Trade query the pay/receive tokens. Their existing extra-debit guard and Max operate on the pay asset, not every intermediate sold by a route. Pay-token Max cannot fund a ALPHA middle-hop obligation when You Pay is CL8Y. Successful router amount simulation is also not a check that the trader can fund all authenticated extra debits.

The required fix changes the contract funding model, not only discovery or error copy. Today apply_transfer calls sub_balance(trader, tax) after sending the full declared hop amount from the router. router/src/contract.rs forwards all hop proceeds as the next declared offer, leaving no transaction-local sell-tax reserve, and its amount simulations omit that debit.

The contract currently reuses InsufficientForSellTax for ordinary from balance subtraction failures as well as trader tax shortfalls. The frontend maps that string to sell-tax recovery advice, and Swap also uses the same advice when tax state is unresolved. Error text alone therefore cannot identify the failing token, hop, or reason.

Relevant files

File Role
indexer/src/api/community_tax_rank.rs Catalog-only discovery, middle-hop eligibility, error fallback, exemption resolution, tax cache identity
indexer/src/api/best_execution.rs Candidate filtering and GET winner selection
indexer/src/api/route_solver.rs, route_exact_output.rs, route_solve_progress.rs GET/POST, receive-target solving, quote/progress/cache consistency
indexer/src/indexer/community_tokens.rs, indexer/src/db/queries/community_tokens.rs, indexer/src/config.rs Single-ID catalog attestation and option-2 metadata policy
frontend-dapp/src/pages/SwapPage.tsx, frontend-dapp/src/components/trade/TradeMarketOrderPanel.tsx Shared route execution, Max, submit guards, recovery UX
frontend-dapp/src/hooks/useCommunityTaxSellBps.ts, frontend-dapp/src/utils/constants.ts Feature-gated discovery and failed-refetch downgrade
frontend-dapp/src/utils/communityTaxPreviewQuery.ts, taxPreviewMaxSpend.ts, humanizeTerraTxError.ts Execute-aligned preview, missing-balance behavior, ambiguous error mapping
frontend-dapp/src/services/indexer/client.ts, frontend-dapp/src/services/terraclassic/router.ts Route metadata and client route fallback
smartcontracts/contracts/community-tax-token/src/tax.rs, msg.rs, error.rs, contract.rs Replace wallet-funded routed tax; preview/API compatibility, authenticated classification, sink accounting
smartcontracts/contracts/router/src/contract.rs, state.rs, msg.rs Per-hop gross budget, tax sizing, net output, residual accounting, forward/reverse simulation
smartcontracts/contracts/pair/src/contract.rs, smartcontracts/packages/dex-common/src/pair.rs Declared hook/credit parity, shared protocol types, buy/sell hook boundaries
smartcontracts/contracts/community-tax-token/src/multitest.rs, smartcontracts/tests/src/ Routed tax, spoofing, hybrid, rollback, and accounting regressions
Existing extra-debit hook/Swap/Trade tests, indexer/tests/api_route_solve.rs, docs/route-solver.md, docs/frontend.md Regression and documentation coverage
  1. Introduce an explicit, versioned route-local tax funding capability for supported token/router combinations. Retain authenticated trader identity for exemptions, launch guards, cooldowns, blacklist, and discount accounting, but remove the separate wallet tax debit for these routed swaps. Do not merely remove the debit and waive tax: the appropriate sinks must receive the configured charge.
  2. Maintain a per-transaction, per-hop gross budget. For a sell taxed at the existing rate on the declared economic amount, choose the largest economic offer S with S + floor(S * sell_bps / 10000) <= G, where G is the input or preceding-hop proceeds allocated to this hop. The router/token operation spends only that budget, sends exactly S to the pair, and sends the tax to the configured sinks atomically. The hook amount must equal the pair's actual credited amount. For example, gross 1,010,000 raw ALPHA at 1% can fund economic offer 1,000,000 plus tax 10,000, with zero ALPHA debited from the trader wallet. Compute the maximal integer offer and explicitly handle rounding residue; preserve documented rate basis rather than silently switching to a different gross-percent formula.
  3. Apply configured buy/sell taxes at the actual swap boundaries where each charge applies. A taxed buy's net routed proceeds are what the next hop can spend. Audit current pair→router exemption and router→recipient buy-split behavior so moving tax to swap points does not skip tax or charge the same buy twice. Define authenticated routed-buy context so non-swap provide/withdraw/refund/escrow movements are not falsely taxed. Document and test the exact tax basis, per-hop timing, exemptions, sink amounts, and final net output.
  4. Forward, reverse, exact-output, DB-hybrid, LCD/router simulations, route ranking, progress, and caches must use the same gross/economic/net flow as execute. Recompute each hop's split and minimum returns against its actual funded economic offer; a pre-tax frozen hybrid split must not exceed post-tax spendable funds. Rank supported taxed-intermediate routes by net executable output, instead of discarding them solely because they need tax.
  5. Separate trading capability discovery from single-code Create/Manage catalog attestation. Resolve actual instance/code/hash/version and live tax configuration for all candidate assets, including migrated ALPHA 11666 absent from the 11630 catalog. Distinguish current wallet-funded, upgraded route-funded, ordinary, and unsupported legacy fee-on-transfer behavior. Preserve strict catalog provenance; changing the catalog pin is not the fix. Bound LCD queries and cache by chain/instance/code/config/route identity. A discovery failure cannot silently waive known tax.
  6. Define the authorized pay amount as the supported route's gross funding limit, including its first-hop token tax. Frontend Max, typed input, percentages, receive-target solving, Swap/Trade, invoices, and wrap entry must quote and submit the same budget. Actual wallet debits must not exceed the authorized offered asset amount; no intermediate wallet debit or allowance is permitted. Tax reduces net proceeds according to the quote; do not tell users to acquire intermediary tax reserves.
  7. Plan coordinated token/router stores and instance migrations, trusted capability registration, indexer refresh/cache invalidation, and frontend rollout. Version previews: new debit/credit/tax/funding-source semantics must agree with execute, and a supported route-funded preview must not advertise hop_trader_debit > 0. Preserve known legacy API behavior or fail clearly for incompatible versions; prevent mixed-version routes from falling back to wallet debit. Keep temporary exclusion only for unsupported versions until supported contracts are deployed.
  8. Update affected docs, skills, and verifiers to the new rule. Reuse security tests while replacing obsolete assertions that successful routed tax must reduce an unrelated wallet balance. Error recovery must distinguish unavailable capability, funding shortfall, and ordinary balance failure; no automatic rebroadcast.

Constraints and guardrails

  • No separate trader-wallet tax debit on supported routed swaps, including first, middle, and final supported swap boundaries. The only wallet outflow is the explicitly authorized initial offer plus network fees. Do not hide side debits behind another token/allowance call.
  • Taxes are still collected at configured rates and delivered/burned according to sink configuration. Trading proceeds fund them; this is not a tax waiver or router exemption bypass. Ordinary honest tokens such as UST1 acquire no new token tax merely because they are intermediates.
  • Preserve exact declared pair credit and hook amount, reserve invariants, fees, max spread, deadlines, minimum returns, default hybrid behavior, atomic rollback, and native/wrap accounting. Change funding/quote contracts explicitly and consistently; do not introduce unaccounted credit-versus-hook discrepancies.
  • Spend only this transaction's received input and hop proceeds. Never subsidize taxes from pre-existing router dust, stranded balances, LP reserves, another route/user, or a trader's other assets. Protect residue/refund ownership, reentrancy/SWAP_STATE, callbacks, and authenticated route context.
  • Keep trader identity for authorization, per-token exemption, launch guards, cooldowns, blacklist, pause/freeze, and discounts. A fee funding change must not bypass those controls. Unknown exemption is not proof of exemption.
  • Preserve SendFrom allowance limits; allowances cover the actual authorized gross debit. Define direct-pair and one-hop compatibility explicitly so either supported route entry budgets tax locally or remains clearly legacy. Do not silently change low-level legacy callers while claiming compatibility.
  • Preserve catalog provenance/admin checks. Symbols, client bps, arbitrary get_config, a matching code ID alone, or spoofed trader fields cannot attest a token or waive fees. Unsupported legacy transfer-tax assets require their own actual capability assessment.
  • Provide, withdraw, limit escrow, cancellation/refund, TransferFrom liquidity funding, AutoLP, invoices, and native wrap/unwrap must retain their intended fee classification. Do not levy swap taxes on unrelated movements.
  • No reporter identifiers, screenshots, chat quotations, credentials, live spend keys, or private logs in public evidence. Use synthetic fixtures and redact addresses unrelated to protocol identity.

Acceptance criteria

  • AC1: A supported CL8Y→ALPHA→UST1→USTR swap succeeds in tax-on LocalTerra with the trader holding zero ALPHA, zero UST1, and zero USTR before execution, given sufficient CL8Y/network fees/liquidity. A multi-tax-intermediate route also succeeds with all intermediate balances zero.
  • AC2: Each applicable configured buy/sell tax is collected exactly once at its specified swap boundary from that route's funds. Router-hop execution does not call a wallet extra-debit path; trader identity continues to enforce controls and exemptions.
  • AC3: Accounting reconciles gross budget, actual economic pair input, buy/sell taxes, pool/router/network fees, net output, and residue/refunds. Pair credited amount equals hook declared amount. Quoted net output equals execution within documented integer rounding/slippage.
  • AC4: Only the offered asset's authorized gross input and network fees are spent from the wallet. Existing intermediate balances and allowances cannot be used, even when present. Router dust and other-user balances cannot fund the route.
  • AC5: Taxed-intermediate routes on supported upgraded contracts are eligible and ranked by net executable output. Excluding all taxed intermediates is not permanent acceptance. Unsupported legacy versions are explicitly rejected rather than falling back to trader debit.
  • AC6: GET/POST/manual hybrid, forward/reverse/exact-output solving, progress/cache results, router/LCD simulations, and client fallback share the funded per-hop amounts and version identity. Catalog pin 11630 does not hide supported ALPHA 11666 or its upgraded successor.
  • AC7: Swap/Trade Max, typed/percentage/pay/receive inputs, single-hop router entry, invoices, and native/wrap routes submit the quoted gross budget and preserve required safeguards. Disabled Create Token config, a failed refetch, or missing required input balance cannot remove established tax protection.
  • AC8: Zero-tax assets and valid per-token exemptions retain correct behavior; tax-skip does not disable launch guards, blacklist, or pause/freeze. Legacy direct-pair/SendFrom behavior is documented and verified during rollout.
  • AC9: Contract/router/token migration and actual deployed capability are verified; versioned preview and execute agree, including no routed trader debit. Docs/skills/verifiers no longer prescribe contradictory wallet-funded routing.
  • AC10: On failure, the whole route including tax distributions rolls back atomically and the UI gives accurate guidance. Users are never asked to buy an unrelated intermediate tax reserve; no automatic resend.

Functional test plan — all affected paths

Path Expected result
CL8Y→ALPHA→UST1→USTR, supported route-local ALPHA tax, trader intermediate balances all zero Full execute succeeds; tax from route funds; quoted net amount delivered
Same route with low/high pre-existing ALPHA and router ALPHA dust Same route economics; pre-existing balances unchanged and unused
First hop taxed pay, middle hop taxed sell, taxed final buy, multiple taxed intermediates Correct tax at each affected swap point; only input gross budget funded by wallet; no skipped/double tax
Ordinary UST1/cLUNC/cUSTC/CL8Y/USTR, zero-bps token, legacy honest-router token No invented token tax; amount and fee behavior correct
Tax buy then tax sell of the same intermediate, tax split sinks/burn/AutoLP Net acquired amount funds next hop; per-tax and supply/sink ledger reconciles
Manager/directory exemption true/false/loading/error, different exemption on another token Per-token policy only; unknown not exempt; security controls remain active
Gross 1,010,000 ALPHA at 1% and boundary/dust cases; 0/6/18 decimals; large values/rates Economic 1,000,000, tax 10,000, zero wallet side debit for example; exact maximal integer sizing, bounded arithmetic and owned residue
Pool/book/explicit hybrid/greedy, first/later-hop split, partial fill and remainder Split fits post-tax economic offer; book/pool execution and forward/reverse simulation agree
GET/POST, exact-output, progress/cache hit/miss, client fallback, adverse-price alternative Same eligible supported routes; ranking by all-tax net output; gross reverse budget sufficient
Direct pair/SendFrom legacy calls, supported one-hop router, typed/Max/percentage/receive inputs Explicit compatibility; allowance/debit accurate; no unauthorized budget increase
Native/wrap entry, unwrap exit, invoices, final recipient different from trader Correct fee/tax classification and net delivery; neither recipient nor payer has an intermediate side debit
Code migration, catalog pin mismatch, disabled Create Token, tax config/rate change Live trading capability independent of catalog; invalidated caches; no silent legacy fallback
Config/preview/catalog/balance 429/503/timeout/malformed, pending account/route switch Required unresolved funding/version blocks submit; verified ordinary assets not globally bricked
Failure at first/middle/final hop, sink callback failure, min-return failure Entire route and tax movements revert; no stranded partial tax or residual SWAP_STATE
Provide/withdraw/limit place/fill/cancel/refund/TransferFrom/AutoLP Intended existing classifications preserved; no new incidental swap tax

Attack, hack, and abuse test plan

  • Forge Swap.trader, router identity, tax funding mode, hop context, exemption, client bps, or receive hooks. Untrusted callers cannot waive tax, debit victims, impersonate a route, or trigger tax on non-swap transfers.
  • Seed router dust or other-user funds, underfund the current gross input, and attempt multi-hop/cyclic/repeated-token/foreign routes. Budgets remain transaction-local; no cross-user subsidy, reserve theft, or unowned residue refund. Do not broaden route caps to accommodate the fix.
  • Invoke nested swaps, malicious sink/AutoLP/recipient callbacks, replay reply IDs, and double-submit. Existing swap-in-progress/reentrancy and authenticated callback protections remain effective; no duplicate tax or route execution.
  • Forge tax preview amounts/capabilities, poison cache identities, replay pre-migration/pre-rate-change routes, or combine incompatible versions. Authenticated metadata and version-aware revalidation prevent stale or wallet-funded execution.
  • Force overflow, hostile long numeric strings, out-of-range bps, rounding underpayment, insufficient gross funds, zero/dust economic offers, and extreme mixed-decimal amounts. Checked/bounded math, consistent tax basis, and explicit failures; no parser/UI crash or subsidized fee.
  • Bypass a disabled CTA with keyboard/direct mutation calls, switch wallets or balances while pending, or race code/config changes. Gross authorization, current route identity, and contract validation still hold.
  • Attempt pool-only/manual hybrid/client fallback to evade tax; abuse source/recipient exemptions or SendFrom allowance. No fee waiver, cross-token exemption inheritance, spend beyond approved allowance, or greater wallet debit than the quoted gross input.
  • Set min receive just above net after all tax/fees; test slippage, deadline, pause, freeze, blacklist, cooldown, and trading-disabled controls. All protections execute against correct amounts/identity and revert the entire transaction on failure.
  • Spam token discovery and oversized candidates. Bound routes, requests, concurrency, cache capacity, and retries; no LCD amplification path.
  • Check conservation across router/token/pair/trader/sinks/burn for success and rollback; confirm no private reporter/credential data enters artifacts or public logs.

Verification criteria

Create a repeatable issue verifier with contract multitests proving actual taxed-middle-hop execution with zero intermediate wallet balances, per-hop sink/supply/credit conservation, transaction isolation from router dust, authenticated context, quote/execute forward and reverse parity, and atomic rollback. Add Postgres route API tests for tax-capability discovery, supported-route eligibility, net ranking, and migration/cache identity; actual hooks plus Swap/Trade/invoice budget tests; and tax-on LocalTerra E2E with synthetic funded-input/zero-intermediate traders.

Retain the security checks behind #607/#615/#1267/#1285/#623/#710/#1280, replacing any assertions that contradict route-local funding. Run the appropriate contract and frontend/indexer checks after implementation, including lint/build/type/schema compatibility and gas measurement for affected routes. The earlier investigation's green tests describe old behavior and are not PASS evidence for the new design.

Store/migrate the required supported token/router versions, refresh trusted tax capabilities and invalidate old route caches, then verify deployment with read-only code/hash/config/preview checks. Use existing authorized execution facilities for bounded deployment smoke when available; do not invent successful execution or require reporter custody. A successful read-only preview or old fidelity_check=passed alone is insufficient. Record actual results and remaining unexecuted checks with revision/time. Deployment and protocol/documentation changes are part of the implementation ticket; they are not a reason to leave the issue scoped to frontend-only route exclusion.

Temporary protection for unsupported legacy routes can ship before coordinated migrations. Final closure requires actual supported hop-funded execution and no intermediate wallet debit. Unavailable reporter/device details do not hold independent implementation work or issue publication.

## Summary **Token identity correction:** the taxed intermediate is ALPHA (`terra1x6e64es6yhauhvs3prvpdg2gkqdtfru840wgnhs935x8axr7zxkqzysuxz`). Canonical cLUNC is a different contract (`terra1437qslye72t7qmmahn4t5chz50r8a62g45phwkquwpyu2l62u6ksqssgdg`). The earlier intermediate label was incorrect; the quote, code 11666, tax configuration, and synthetic preview evidence concern ALPHA. CL8Y→USTR can receive a quote for a route that requires extra ALPHA already held in the trader's wallet. The live solver selects **CL8Y→ALPHA→UST1→USTR**, labels it `tax_kind=none`, and reports zero sell tax, while the ALPHA middle-hop contract actually charges a **1% sell extra-debit** to the authenticated trader. Tokens acquired by the preceding hop sit on the router, so they do not fund that separate wallet debit. A trader with no ALPHA reserve can therefore hit the existing sell-tax error despite holding enough CL8Y. Reducing CL8Y or tapping CL8Y Max cannot solve a zero balance of the required intermediate asset. This issue bundles contract/router tax funding at swap points, route capability discovery, quote/execute parity, frontend preflight, and recovery messaging for this failure. Permanent acceptance requires supported taxed intermediate routes to work without an intermediate balance in the trader wallet; route exclusion alone is containment. Related closed work: [#615](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/615), [#1267](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1267), [#1285](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1285). Their security checks remain relevant, but their router-hop funding and exclusion expectations must be revised where they conflict with the required behavior below. ## Required behavior and scope **Collect configured tax at the affected swap points from this route's own token amounts. Do not debit the trader's separate wallet balance for a routed hop's tax.** The trader still bears the economic cost through the quoted exchange result, but needs only the explicitly authorized initial offer and network fees. No pre-existing ALPHA, UST1, or any other intermediate balance is required. This intentionally replaces the wallet-funded router-hop rule in **T592-13 / R607-1 / R607-4 / R607-7**, the old **R615 middle-hop exclusion as a permanent solution**, and the previous blanket **H-01 prohibition on router tax sizing** to the extent needed for correct local tax funding. Keep the security purpose of 1:1 declared pair credit: the pair must receive exactly the economic amount its swap hook declares. Any change to how gross routed funds are split into pair input and tax requires an explicit, tested protocol/API revision; an inconsistent CW20 credit/hook amount is unacceptable. A temporary exclusion of genuinely unsupported legacy-tax routes is allowed during rollout. It does not satisfy the permanent fix for migrated, supported community-tax tokens such as ALPHA. ## Anonymized report and investigation evidence The reported symptom is a CL8Y→USTR attempt displaying the application's sell-tax balance error. No reporter identity, wallet address, screenshot, chat quotation, or conversation is published here. The failed transaction hash, input amount, selected route, and deployed bundle version for that attempt are unavailable; the exact reported transaction is **not** claimed reproduced. Investigation on 2026-10-04 against current `main` **3f9310652ac83818749f5d32c4e32057b08817bc**, matching the remote main head: 1. Read-only live `GET https://indexer.dex.cl8y.com/api/v1/route/solve` with canonical CL8Y/USTR contract IDs, synthetic `amount_in=1000000000000000000` (1 CL8Y), and `max_hops=3` returned CL8Y→ALPHA→UST1→USTR. It returned `sell_tax_bps=0`, `buy_tax_bps=0`, `router_hops_tax=false`, `tax_kind=none`, and `fidelity_check=passed`. Repeating with an explicit deterministic synthetic trader still returned the ALPHA middle hop, `tax_kind=none`, zero sell tax, and passed fidelity; a read-only LCD balance query confirmed that synthetic trader held **zero ALPHA**. These requests did not use a reporter wallet or broadcast anything. 2. LCD contract/config queries identify canonical CL8Y as code **10184**, with `get_config` rejected as an unsupported query by `cw20_mintable`. CL8Y itself is not established as a community-tax sell token by this evidence. The selected ALPHA intermediate is code **11666**, with `sell_bps=100` and `buy_bps=450`. 3. Execute-aligned read-only ALPHA `TaxPreview` from its configured official router to the selected ALPHA/UST1 pair, with a deterministic synthetic non-exempt trader and `Swap.trader`, returned: ```json {"kind":"sell","declared":"1000000","debit":"1000000","credit":"1000000","tax":"10000","hop_trader_debit":"10000"} ``` These are synthetic raw units. `debit` describes the router leg; the additional `hop_trader_debit` is charged to the trader. Contract `apply_transfer` calls `sub_balance(trader, tax)` for this case. 4. Live `/api/v1/community-tokens` reported catalog code **11630**, total **1**, containing KENA. ALPHA code 11666 was absent. Catalog attestation requires the configured code ID and launcher/admin provenance; routing currently relies on that catalog for tax discovery. 5. `make verify-issue-1285` **passed**, including its 35-test frontend run and the nested `make verify-issue-1267` 88-test run. `cargo test --manifest-path indexer/Cargo.toml --lib community_tax_rank -- --test-threads=1` **passed all 14 tests**, including the catalogued middle-hop exclusion. Passing these tests does not cover a live taxed intermediate absent from the catalog. 6. Three temporary synthetic frontend probes confirmed current behavior: a successful taxed config followed by a failed 503 refetch changes detection to `honest`; disabled Create Token configuration prevents swap tax discovery; and `extraDebitSubmitGate` with an unknown wallet balance returns `blockSubmit=false` even with a known positive tax debit. The probes asserted existing behavior and were removed after execution; they are evidence of gaps, not tests proving a fix. A follow-up live identity census queried `token_info` and tax configuration for all 20 distinct CW20 contracts in the indexed asset inventory plus the published token list. ALPHA reports `name=ALPHA Lunc Universe`, `symbol=ALPHA`, code 11666, sell 1%, buy 4.5%. Canonical cLUNC reports `name=Wrapped LUNC`, `symbol=cLUNC`, code 10184 (`cw20_mintable`), with no community sell tax. Among assets in the current indexed DEX pools, ALPHA is the only positive community-tax sell configuration found; KENA has zero buy/sell/transfer bps. USTRIX and DO, present in the published token list but with no indexed DEX pools, expose different legacy APIs: USTRIX `tax_map` has conditional 5% Send tax, and DO `tax_info` has address-conditioned default 1.5% Send/Transfer tax plus a sender-specific 20% Send override. An unsupported `get_config` alone must not classify every legacy token as tax-free; inspect its actual supported tax API/capability. This census concerns token-level taxes, separately from pool fees and native wrap/unwrap costs. Read-only previews and quote simulations establish the route hazard; they do not establish execution success. No live funds, signatures, migrations, or deployments were used. ## Current codebase and why a new implementation is needed `best_execution.rs` loads tax metadata for candidate hop assets and applies `path_sells_middle_tax_hop`. That predicate only recognizes entries in `TaxRankSnapshot.by_addr` and an option-2 code/hash policy. Missing rows are treated as ordinary assets. `load_tax_rank_snapshot` also falls back to ranking without tax data on a catalog lookup failure. `indexer/indexer/community_tokens.rs` deliberately attests Create/Manage catalog entries using one configured code ID and provenance. That product attestation is narrower than the live set of assets whose router hops charge extra debit. Its single-ID policy must not determine whether an executable trading route has hidden wallet obligations. Swap/Trade query the pay/receive tokens. Their existing extra-debit guard and Max operate on the pay asset, not every intermediate sold by a route. Pay-token Max cannot fund a ALPHA middle-hop obligation when You Pay is CL8Y. Successful router amount simulation is also not a check that the trader can fund all authenticated extra debits. The required fix changes the contract funding model, not only discovery or error copy. Today `apply_transfer` calls `sub_balance(trader, tax)` after sending the full declared hop amount from the router. `router/src/contract.rs` forwards all hop proceeds as the next declared offer, leaving no transaction-local sell-tax reserve, and its amount simulations omit that debit. The contract currently reuses `InsufficientForSellTax` for ordinary `from` balance subtraction failures as well as trader tax shortfalls. The frontend maps that string to sell-tax recovery advice, and Swap also uses the same advice when tax state is unresolved. Error text alone therefore cannot identify the failing token, hop, or reason. ## Relevant files | File | Role | | --- | --- | | `indexer/src/api/community_tax_rank.rs` | Catalog-only discovery, middle-hop eligibility, error fallback, exemption resolution, tax cache identity | | `indexer/src/api/best_execution.rs` | Candidate filtering and GET winner selection | | `indexer/src/api/route_solver.rs`, `route_exact_output.rs`, `route_solve_progress.rs` | GET/POST, receive-target solving, quote/progress/cache consistency | | `indexer/src/indexer/community_tokens.rs`, `indexer/src/db/queries/community_tokens.rs`, `indexer/src/config.rs` | Single-ID catalog attestation and option-2 metadata policy | | `frontend-dapp/src/pages/SwapPage.tsx`, `frontend-dapp/src/components/trade/TradeMarketOrderPanel.tsx` | Shared route execution, Max, submit guards, recovery UX | | `frontend-dapp/src/hooks/useCommunityTaxSellBps.ts`, `frontend-dapp/src/utils/constants.ts` | Feature-gated discovery and failed-refetch downgrade | | `frontend-dapp/src/utils/communityTaxPreviewQuery.ts`, `taxPreviewMaxSpend.ts`, `humanizeTerraTxError.ts` | Execute-aligned preview, missing-balance behavior, ambiguous error mapping | | `frontend-dapp/src/services/indexer/client.ts`, `frontend-dapp/src/services/terraclassic/router.ts` | Route metadata and client route fallback | | `smartcontracts/contracts/community-tax-token/src/tax.rs`, `msg.rs`, `error.rs`, `contract.rs` | Replace wallet-funded routed tax; preview/API compatibility, authenticated classification, sink accounting | | `smartcontracts/contracts/router/src/contract.rs`, `state.rs`, `msg.rs` | Per-hop gross budget, tax sizing, net output, residual accounting, forward/reverse simulation | | `smartcontracts/contracts/pair/src/contract.rs`, `smartcontracts/packages/dex-common/src/pair.rs` | Declared hook/credit parity, shared protocol types, buy/sell hook boundaries | | `smartcontracts/contracts/community-tax-token/src/multitest.rs`, `smartcontracts/tests/src/` | Routed tax, spoofing, hybrid, rollback, and accounting regressions | | Existing extra-debit hook/Swap/Trade tests, `indexer/tests/api_route_solve.rs`, `docs/route-solver.md`, `docs/frontend.md` | Regression and documentation coverage | ## Recommended direction 1. Introduce an explicit, versioned **route-local tax funding** capability for supported token/router combinations. Retain authenticated trader identity for exemptions, launch guards, cooldowns, blacklist, and discount accounting, but remove the separate wallet tax debit for these routed swaps. Do not merely remove the debit and waive tax: the appropriate sinks must receive the configured charge. 2. Maintain a per-transaction, per-hop **gross budget**. For a sell taxed at the existing rate on the declared economic amount, choose the largest economic offer `S` with `S + floor(S * sell_bps / 10000) <= G`, where `G` is the input or preceding-hop proceeds allocated to this hop. The router/token operation spends only that budget, sends exactly `S` to the pair, and sends the tax to the configured sinks atomically. The hook amount must equal the pair's actual credited amount. For example, gross `1,010,000` raw ALPHA at 1% can fund economic offer `1,000,000` plus tax `10,000`, with **zero ALPHA debited from the trader wallet**. Compute the maximal integer offer and explicitly handle rounding residue; preserve documented rate basis rather than silently switching to a different gross-percent formula. 3. Apply configured buy/sell taxes at the actual swap boundaries where each charge applies. A taxed buy's net routed proceeds are what the next hop can spend. Audit current pair→router exemption and router→recipient buy-split behavior so moving tax to swap points does not skip tax or charge the same buy twice. Define authenticated routed-buy context so non-swap provide/withdraw/refund/escrow movements are not falsely taxed. Document and test the exact tax basis, per-hop timing, exemptions, sink amounts, and final net output. 4. Forward, reverse, exact-output, DB-hybrid, LCD/router simulations, route ranking, progress, and caches must use the same gross/economic/net flow as execute. Recompute each hop's split and minimum returns against its actual funded economic offer; a pre-tax frozen hybrid split must not exceed post-tax spendable funds. Rank supported taxed-intermediate routes by **net executable output**, instead of discarding them solely because they need tax. 5. Separate trading capability discovery from single-code Create/Manage catalog attestation. Resolve actual instance/code/hash/version and live tax configuration for all candidate assets, including migrated ALPHA 11666 absent from the 11630 catalog. Distinguish current wallet-funded, upgraded route-funded, ordinary, and unsupported legacy fee-on-transfer behavior. Preserve strict catalog provenance; changing the catalog pin is not the fix. Bound LCD queries and cache by chain/instance/code/config/route identity. A discovery failure cannot silently waive known tax. 6. Define the authorized pay amount as the supported route's gross funding limit, including its first-hop token tax. Frontend Max, typed input, percentages, receive-target solving, Swap/Trade, invoices, and wrap entry must quote and submit the same budget. Actual wallet debits must not exceed the authorized offered asset amount; no intermediate wallet debit or allowance is permitted. Tax reduces net proceeds according to the quote; do not tell users to acquire intermediary tax reserves. 7. Plan coordinated token/router stores and instance migrations, trusted capability registration, indexer refresh/cache invalidation, and frontend rollout. Version previews: new `debit`/`credit`/`tax`/funding-source semantics must agree with execute, and a supported route-funded preview must not advertise `hop_trader_debit > 0`. Preserve known legacy API behavior or fail clearly for incompatible versions; prevent mixed-version routes from falling back to wallet debit. Keep temporary exclusion only for unsupported versions until supported contracts are deployed. 8. Update affected docs, skills, and verifiers to the new rule. Reuse security tests while replacing obsolete assertions that successful routed tax must reduce an unrelated wallet balance. Error recovery must distinguish unavailable capability, funding shortfall, and ordinary balance failure; no automatic rebroadcast. ## Constraints and guardrails - **No separate trader-wallet tax debit on supported routed swaps**, including first, middle, and final supported swap boundaries. The only wallet outflow is the explicitly authorized initial offer plus network fees. Do not hide side debits behind another token/allowance call. - Taxes are still collected at configured rates and delivered/burned according to sink configuration. Trading proceeds fund them; this is not a tax waiver or router exemption bypass. Ordinary honest tokens such as UST1 acquire no new token tax merely because they are intermediates. - Preserve exact declared pair credit and hook amount, reserve invariants, fees, max spread, deadlines, minimum returns, default hybrid behavior, atomic rollback, and native/wrap accounting. Change funding/quote contracts explicitly and consistently; do not introduce unaccounted credit-versus-hook discrepancies. - Spend only this transaction's received input and hop proceeds. **Never subsidize taxes from pre-existing router dust, stranded balances, LP reserves, another route/user, or a trader's other assets.** Protect residue/refund ownership, reentrancy/SWAP_STATE, callbacks, and authenticated route context. - Keep trader identity for authorization, per-token exemption, launch guards, cooldowns, blacklist, pause/freeze, and discounts. A fee funding change must not bypass those controls. Unknown exemption is not proof of exemption. - Preserve SendFrom allowance limits; allowances cover the actual authorized gross debit. Define direct-pair and one-hop compatibility explicitly so either supported route entry budgets tax locally or remains clearly legacy. Do not silently change low-level legacy callers while claiming compatibility. - Preserve catalog provenance/admin checks. Symbols, client bps, arbitrary `get_config`, a matching code ID alone, or spoofed trader fields cannot attest a token or waive fees. Unsupported legacy transfer-tax assets require their own actual capability assessment. - Provide, withdraw, limit escrow, cancellation/refund, TransferFrom liquidity funding, AutoLP, invoices, and native wrap/unwrap must retain their intended fee classification. Do not levy swap taxes on unrelated movements. - No reporter identifiers, screenshots, chat quotations, credentials, live spend keys, or private logs in public evidence. Use synthetic fixtures and redact addresses unrelated to protocol identity. ## Acceptance criteria - AC1: A supported CL8Y→ALPHA→UST1→USTR swap succeeds in tax-on LocalTerra with the trader holding **zero ALPHA, zero UST1, and zero USTR before execution**, given sufficient CL8Y/network fees/liquidity. A multi-tax-intermediate route also succeeds with all intermediate balances zero. - AC2: Each applicable configured buy/sell tax is collected exactly once at its specified swap boundary from that route's funds. Router-hop execution does not call a wallet extra-debit path; trader identity continues to enforce controls and exemptions. - AC3: Accounting reconciles gross budget, actual economic pair input, buy/sell taxes, pool/router/network fees, net output, and residue/refunds. Pair credited amount equals hook declared amount. Quoted net output equals execution within documented integer rounding/slippage. - AC4: Only the offered asset's authorized gross input and network fees are spent from the wallet. Existing intermediate balances and allowances cannot be used, even when present. Router dust and other-user balances cannot fund the route. - AC5: Taxed-intermediate routes on supported upgraded contracts are eligible and ranked by net executable output. Excluding all taxed intermediates is not permanent acceptance. Unsupported legacy versions are explicitly rejected rather than falling back to trader debit. - AC6: GET/POST/manual hybrid, forward/reverse/exact-output solving, progress/cache results, router/LCD simulations, and client fallback share the funded per-hop amounts and version identity. Catalog pin 11630 does not hide supported ALPHA 11666 or its upgraded successor. - AC7: Swap/Trade Max, typed/percentage/pay/receive inputs, single-hop router entry, invoices, and native/wrap routes submit the quoted gross budget and preserve required safeguards. Disabled Create Token config, a failed refetch, or missing required input balance cannot remove established tax protection. - AC8: Zero-tax assets and valid per-token exemptions retain correct behavior; tax-skip does not disable launch guards, blacklist, or pause/freeze. Legacy direct-pair/SendFrom behavior is documented and verified during rollout. - AC9: Contract/router/token migration and actual deployed capability are verified; versioned preview and execute agree, including no routed trader debit. Docs/skills/verifiers no longer prescribe contradictory wallet-funded routing. - AC10: On failure, the whole route including tax distributions rolls back atomically and the UI gives accurate guidance. Users are never asked to buy an unrelated intermediate tax reserve; no automatic resend. ## Functional test plan — all affected paths | Path | Expected result | | --- | --- | | CL8Y→ALPHA→UST1→USTR, supported route-local ALPHA tax, trader intermediate balances all zero | Full execute succeeds; tax from route funds; quoted net amount delivered | | Same route with low/high pre-existing ALPHA and router ALPHA dust | Same route economics; pre-existing balances unchanged and unused | | First hop taxed pay, middle hop taxed sell, taxed final buy, multiple taxed intermediates | Correct tax at each affected swap point; only input gross budget funded by wallet; no skipped/double tax | | Ordinary UST1/cLUNC/cUSTC/CL8Y/USTR, zero-bps token, legacy honest-router token | No invented token tax; amount and fee behavior correct | | Tax buy then tax sell of the same intermediate, tax split sinks/burn/AutoLP | Net acquired amount funds next hop; per-tax and supply/sink ledger reconciles | | Manager/directory exemption true/false/loading/error, different exemption on another token | Per-token policy only; unknown not exempt; security controls remain active | | Gross `1,010,000` ALPHA at 1% and boundary/dust cases; 0/6/18 decimals; large values/rates | Economic `1,000,000`, tax `10,000`, zero wallet side debit for example; exact maximal integer sizing, bounded arithmetic and owned residue | | Pool/book/explicit hybrid/greedy, first/later-hop split, partial fill and remainder | Split fits post-tax economic offer; book/pool execution and forward/reverse simulation agree | | GET/POST, exact-output, progress/cache hit/miss, client fallback, adverse-price alternative | Same eligible supported routes; ranking by all-tax net output; gross reverse budget sufficient | | Direct pair/SendFrom legacy calls, supported one-hop router, typed/Max/percentage/receive inputs | Explicit compatibility; allowance/debit accurate; no unauthorized budget increase | | Native/wrap entry, unwrap exit, invoices, final recipient different from trader | Correct fee/tax classification and net delivery; neither recipient nor payer has an intermediate side debit | | Code migration, catalog pin mismatch, disabled Create Token, tax config/rate change | Live trading capability independent of catalog; invalidated caches; no silent legacy fallback | | Config/preview/catalog/balance 429/503/timeout/malformed, pending account/route switch | Required unresolved funding/version blocks submit; verified ordinary assets not globally bricked | | Failure at first/middle/final hop, sink callback failure, min-return failure | Entire route and tax movements revert; no stranded partial tax or residual SWAP_STATE | | Provide/withdraw/limit place/fill/cancel/refund/TransferFrom/AutoLP | Intended existing classifications preserved; no new incidental swap tax | ## Attack, hack, and abuse test plan - Forge `Swap.trader`, router identity, tax funding mode, hop context, exemption, client bps, or receive hooks. Untrusted callers cannot waive tax, debit victims, impersonate a route, or trigger tax on non-swap transfers. - Seed router dust or other-user funds, underfund the current gross input, and attempt multi-hop/cyclic/repeated-token/foreign routes. Budgets remain transaction-local; no cross-user subsidy, reserve theft, or unowned residue refund. Do not broaden route caps to accommodate the fix. - Invoke nested swaps, malicious sink/AutoLP/recipient callbacks, replay reply IDs, and double-submit. Existing swap-in-progress/reentrancy and authenticated callback protections remain effective; no duplicate tax or route execution. - Forge tax preview amounts/capabilities, poison cache identities, replay pre-migration/pre-rate-change routes, or combine incompatible versions. Authenticated metadata and version-aware revalidation prevent stale or wallet-funded execution. - Force overflow, hostile long numeric strings, out-of-range bps, rounding underpayment, insufficient gross funds, zero/dust economic offers, and extreme mixed-decimal amounts. Checked/bounded math, consistent tax basis, and explicit failures; no parser/UI crash or subsidized fee. - Bypass a disabled CTA with keyboard/direct mutation calls, switch wallets or balances while pending, or race code/config changes. Gross authorization, current route identity, and contract validation still hold. - Attempt pool-only/manual hybrid/client fallback to evade tax; abuse source/recipient exemptions or SendFrom allowance. No fee waiver, cross-token exemption inheritance, spend beyond approved allowance, or greater wallet debit than the quoted gross input. - Set min receive just above net after all tax/fees; test slippage, deadline, pause, freeze, blacklist, cooldown, and trading-disabled controls. All protections execute against correct amounts/identity and revert the entire transaction on failure. - Spam token discovery and oversized candidates. Bound routes, requests, concurrency, cache capacity, and retries; no LCD amplification path. - Check conservation across router/token/pair/trader/sinks/burn for success and rollback; confirm no private reporter/credential data enters artifacts or public logs. ## Verification criteria Create a repeatable issue verifier with contract multitests proving actual taxed-middle-hop execution with zero intermediate wallet balances, per-hop sink/supply/credit conservation, transaction isolation from router dust, authenticated context, quote/execute forward and reverse parity, and atomic rollback. Add Postgres route API tests for tax-capability discovery, supported-route eligibility, net ranking, and migration/cache identity; actual hooks plus Swap/Trade/invoice budget tests; and tax-on LocalTerra E2E with synthetic funded-input/zero-intermediate traders. Retain the security checks behind #607/#615/#1267/#1285/#623/#710/#1280, replacing any assertions that contradict route-local funding. Run the appropriate contract and frontend/indexer checks after implementation, including lint/build/type/schema compatibility and gas measurement for affected routes. The earlier investigation's green tests describe old behavior and are not PASS evidence for the new design. Store/migrate the required supported token/router versions, refresh trusted tax capabilities and invalidate old route caches, then verify deployment with read-only code/hash/config/preview checks. Use existing authorized execution facilities for bounded deployment smoke when available; do not invent successful execution or require reporter custody. A successful read-only preview or old `fidelity_check=passed` alone is insufficient. Record actual results and remaining unexecuted checks with revision/time. Deployment and protocol/documentation changes are part of the implementation ticket; they are not a reason to leave the issue scoped to frontend-only route exclusion. Temporary protection for unsupported legacy routes can ship before coordinated migrations. Final closure requires actual supported hop-funded execution and no intermediate wallet debit. Unavailable reporter/device details do not hold independent implementation work or issue publication.
PlasticDigits changed title from fix(swap): CL8Y to USTR selects a taxed cLUNC middle hop while reporting no tax to fix(swap): CL8Y to USTR selects a taxed ALPHA middle hop while reporting no tax 2026-10-04 08:11:14 +00:00
PlasticDigits changed title from fix(swap): CL8Y to USTR selects a taxed ALPHA middle hop while reporting no tax to fix(swap): fund token taxes at route swap points without intermediate wallet debits 2026-10-04 08:19:03 +00:00
Author
Owner

Merge review found a docs/frontend.md conflict after PRs #1379 and #1382 landed. Resolved by preserving E1376-9 in its invariant table, then the full route-funded swap budget section, then the Protocol liquidity quality section. The shared indexer LCD client, test configuration and frontend API types merged automatically; combined checks are running.

Completed independently: 884 full contract-workspace tests passed; a fresh isolated LocalTerra fixture passed router/token migrations and pair-pin preservation, all six route-budget/tax/dust/rollback cases, and all five atomic invoice/native wrap/unwrap flow cases. No production execution is claimed. Production rollout is now tracked separately in #1384. CI remains skipped under the explicit merge instruction.

Merge review found a docs/frontend.md conflict after PRs #1379 and #1382 landed. Resolved by preserving E1376-9 in its invariant table, then the full route-funded swap budget section, then the Protocol liquidity quality section. The shared indexer LCD client, test configuration and frontend API types merged automatically; combined checks are running. Completed independently: 884 full contract-workspace tests passed; a fresh isolated LocalTerra fixture passed router/token migrations and pair-pin preservation, all six route-budget/tax/dust/rollback cases, and all five atomic invoice/native wrap/unwrap flow cases. No production execution is claimed. Production rollout is now tracked separately in #1384. CI remains skipped under the explicit merge instruction.
Author
Owner

Combined browser sanity check initially failed 8 of 16 cases. The ordinary-token LCD fixture returned successful empty objects for unsupported GetConfig/TaxMap/TaxInfo queries, so the new #1381 fail-closed capability guard correctly refused those mock routes. Fixed the fixture to return explicit unknown-query HTTP errors for ordinary CW20s, retained the production guard, and added a browser regression proving malformed successful tax metadata still blocks quoting and preserves the 100 receive target. Retest: all 17 combined receive/lifecycle and liquidity-quality browser cases passed. The fixture repair is included on the #1383 branch before merge.

Combined verify-issue-1381: PASS=12 FAIL=0; LocalTerra was run separately and passed all 11 route/invoice/native cases plus migrations. Only production migration/execution remains unverified (#1384). Supplemental Swap/Trade/Protocol unit tests: 172 passed. TypeScript/build, formatting and frontend lint passed; lint reports five existing React hook warnings in unrelated files. CI was skipped as instructed.

Combined browser sanity check initially failed 8 of 16 cases. The ordinary-token LCD fixture returned successful empty objects for unsupported GetConfig/TaxMap/TaxInfo queries, so the new #1381 fail-closed capability guard correctly refused those mock routes. Fixed the fixture to return explicit unknown-query HTTP errors for ordinary CW20s, retained the production guard, and added a browser regression proving malformed successful tax metadata still blocks quoting and preserves the 100 receive target. Retest: all 17 combined receive/lifecycle and liquidity-quality browser cases passed. The fixture repair is included on the #1383 branch before merge. Combined verify-issue-1381: PASS=12 FAIL=0; LocalTerra was run separately and passed all 11 route/invoice/native cases plus migrations. Only production migration/execution remains unverified (#1384). Supplemental Swap/Trade/Protocol unit tests: 172 passed. TypeScript/build, formatting and frontend lint passed; lint reports five existing React hook warnings in unrelated files. CI was skipped as instructed.
Author
Owner

PR #1383, including conflict resolution and browser fixture repair fd0f0fb2, is merged; final consolidated main is 52b5f505f4. Combined verifier PASS=12 FAIL=0: 884 workspace contract tests, 470 indexer library tests, 55 route/funding PostgreSQL tests and 268 focused frontend tests per pass/retest. Supplemental Swap/Trade/Protocol tests: 172 passed. All 43 combined liquidity DB tests and the 17-case browser retest passed. Actual isolated LocalTerra migrations/pair pins and all six route plus five invoice/native flow cases passed.

The initial browser run failed eight cases because ordinary-token mocks returned malformed successful tax objects. The fixture repair preserves the production fail-closed guard and explicitly tests malformed discovery blocking. Lint/types/build/formatting/secret checks passed; five pre-existing unrelated React hook lint warnings remain. CI was skipped by instruction.

Closing implementation acceptance under the requested merge/closure policy. Coordinated Columbus-5 router/token migration, whitelist/pins, cache/API/frontend rollout and funded execution remain tracked in #1384; production signing success is not claimed. Direct receipt push to protected main was rejected and was completed through normal merged PR #1387. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-04.md

PR #1383, including conflict resolution and browser fixture repair fd0f0fb2, is merged; final consolidated main is 52b5f505f49642cbf6d5da23b84593cb27b5dd89. Combined verifier PASS=12 FAIL=0: 884 workspace contract tests, 470 indexer library tests, 55 route/funding PostgreSQL tests and 268 focused frontend tests per pass/retest. Supplemental Swap/Trade/Protocol tests: 172 passed. All 43 combined liquidity DB tests and the 17-case browser retest passed. Actual isolated LocalTerra migrations/pair pins and all six route plus five invoice/native flow cases passed. The initial browser run failed eight cases because ordinary-token mocks returned malformed successful tax objects. The fixture repair preserves the production fail-closed guard and explicitly tests malformed discovery blocking. Lint/types/build/formatting/secret checks passed; five pre-existing unrelated React hook lint warnings remain. CI was skipped by instruction. Closing implementation acceptance under the requested merge/closure policy. Coordinated Columbus-5 router/token migration, whitelist/pins, cache/API/frontend rollout and funded execution remain tracked in #1384; production signing success is not claimed. Direct receipt push to protected main was rejected and was completed through normal merged PR #1387. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-04.md
Author
Owner

Correction to the preceding completion comment: the three original product/documentation PRs are merged at 78678f363c, and the product checks/implementation closure reported there remain valid. The additional receipt/helper PR #1387 is still open: fj merge returned HTTP 405. Commit 52b5f505 is its proposed head, not yet the final origin/main head. The prior statement that #1387 had merged was premature. Resolving its server gate under the explicit instruction to skip CI and override unavailable merge gates; no CI PASS or production deployment is claimed. A final origin/main ancestry/state confirmation will follow.

Correction to the preceding completion comment: the three original product/documentation PRs are merged at 78678f363c4ca65171bbfe2aa5a1676bd5a01ebc, and the product checks/implementation closure reported there remain valid. The additional receipt/helper PR #1387 is still open: fj merge returned HTTP 405. Commit 52b5f505 is its proposed head, not yet the final origin/main head. The prior statement that #1387 had merged was premature. Resolving its server gate under the explicit instruction to skip CI and override unavailable merge gates; no CI PASS or production deployment is claimed. A final origin/main ancestry/state confirmation will follow.
Author
Owner

Final confirmation: PR #1387 is now merged normally, and local main was fast-forwarded to origin/main at 748579ab71. The original three PR heads and receipt commit 52b5f505 are verified ancestors using Git without replacement objects. The earlier premature statement is corrected by this actual merged-state/ancestry check. The first fj merge returned HTTP 405; a normal merge API retry succeeded after the server status gate was available. No force_merge, branch-protection change or fabricated status was used. No CI run was requested or manually waited on.

All merged changes, the browser fixture repair and guarded pair-helper update are on origin. #1380 and #1381 are closed; #1376 was already closed. Remaining production actions are tracked by #1384, #1385 and #1386. Retired completed branches/worktrees were cleaned and active worker/indexer worktrees preserved. There is no active stash or missing branch source code. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-04.md

Final confirmation: PR #1387 is now merged normally, and local main was fast-forwarded to origin/main at 748579ab718026efad54afcef4b2a5186fe82662. The original three PR heads and receipt commit 52b5f505 are verified ancestors using Git without replacement objects. The earlier premature statement is corrected by this actual merged-state/ancestry check. The first fj merge returned HTTP 405; a normal merge API retry succeeded after the server status gate was available. No force_merge, branch-protection change or fabricated status was used. No CI run was requested or manually waited on. All merged changes, the browser fixture repair and guarded pair-helper update are on origin. #1380 and #1381 are closed; #1376 was already closed. Remaining production actions are tracked by #1384, #1385 and #1386. Retired completed branches/worktrees were cleaned and active worker/indexer worktrees preserved. There is no active stash or missing branch source code. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-04.md
Author
Owner

The October 5 merge sweep merged original PRs #1401, #1402 and #1403; the missing Renovate lockfile was repaired before #1402 merged. The additional contract-test Clippy cleanup and unchanged security audit reports are consolidated through #1404, with docs/qa/merge-2026-10-05.md and fresh public SDK evidence.

Completed checks: 59 rollout behavioral tests twice; fresh SDK/LocalTerra rehearsal with 18 broadcasts/18 durable journal checks and zero skips; complete route verifier PASS=13 FAIL=0 SKIP=1 (884 contract, 470 indexer unit, 55 Postgres and 268 frontend tests per pass/retest, six route cases plus five invoice/native flows). Formatting, workspace/all-target Clippy, npm ci, lint/types/build, nginx container configuration and commit secret scan passed. Five existing frontend hook warnings remain.

Resolved problems: expired OpenBao session, omitted package-lock update, initially outdated PR branches, fj HTTP 405 after #1402 merged, and SQLx VersionMismatch(20260916120000) in an existing shared test database. A fresh isolated database and complete verifier rerun passed; no shared application database reset was performed. CI was explicitly skipped.

#1381 remains closed. Production execution is the sole verifier skip; substantive Columbus-5 migration/application rollout remains in #1384 and pair-fleet deployment in #1386, both updated by fj comments. No source merge, issue closure or local receipt is represented as production deployment.

Final consolidation problem: fj returned HTTP 405 for #1404 because the required status gate was unavailable under the explicit skip-CI instruction. fj has no force-merge flag. Used the documented Forgejo per-PR force_merge API through bao-exec, bound to the exact reviewed head d370a30a18 and expected main head. Branch protection was not changed and no status was fabricated. Actual merged state and Git ancestry are confirmed before cleanup.

The October 5 merge sweep merged original PRs #1401, #1402 and #1403; the missing Renovate lockfile was repaired before #1402 merged. The additional contract-test Clippy cleanup and unchanged security audit reports are consolidated through #1404, with docs/qa/merge-2026-10-05.md and fresh public SDK evidence. Completed checks: 59 rollout behavioral tests twice; fresh SDK/LocalTerra rehearsal with 18 broadcasts/18 durable journal checks and zero skips; complete route verifier PASS=13 FAIL=0 SKIP=1 (884 contract, 470 indexer unit, 55 Postgres and 268 frontend tests per pass/retest, six route cases plus five invoice/native flows). Formatting, workspace/all-target Clippy, npm ci, lint/types/build, nginx container configuration and commit secret scan passed. Five existing frontend hook warnings remain. Resolved problems: expired OpenBao session, omitted package-lock update, initially outdated PR branches, fj HTTP 405 after #1402 merged, and SQLx VersionMismatch(20260916120000) in an existing shared test database. A fresh isolated database and complete verifier rerun passed; no shared application database reset was performed. CI was explicitly skipped. #1381 remains closed. Production execution is the sole verifier skip; substantive Columbus-5 migration/application rollout remains in #1384 and pair-fleet deployment in #1386, both updated by fj comments. No source merge, issue closure or local receipt is represented as production deployment. Final consolidation problem: fj returned HTTP 405 for #1404 because the required status gate was unavailable under the explicit skip-CI instruction. fj has no force-merge flag. Used the documented Forgejo per-PR force_merge API through bao-exec, bound to the exact reviewed head d370a30a18b48c212a1041b0063f395d5a815df1 and expected main head. Branch protection was not changed and no status was fabricated. Actual merged state and Git ancestry are confirmed before cleanup.
Author
Owner

Final confirmation: #1401, #1402, #1403 and consolidation #1404 are merged. Local main is clean and exactly matches origin/main at 9944ada10e. All reviewed PR/repair commits are verified ancestors with replacement objects disabled; no configured local/remote branch contains missing source commits, and no active stash exists.

Deleted the four temporary worktrees created for this sweep and the temporary local integration branch. Completed PR remote branches were removed, while retained worker branches/worktrees, audit worktrees and the running indexer were preserved. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-05.md

Problems and remaining work are documented through fj comments on #1314, #1381, #1384, #1386 and audit remediation issues #1388–#1400. #1381 remains closed; the remaining issues retain substantive implementation/deployment work. CI was skipped; only #1404 needed the exact-head per-PR force_merge override after fj HTTP 405. Branch protection remained unchanged and no production execution is claimed.

Final confirmation: #1401, #1402, #1403 and consolidation #1404 are merged. Local main is clean and exactly matches origin/main at 9944ada10ee711ff8ffaa91f4c19b0f292de3924. All reviewed PR/repair commits are verified ancestors with replacement objects disabled; no configured local/remote branch contains missing source commits, and no active stash exists. Deleted the four temporary worktrees created for this sweep and the temporary local integration branch. Completed PR remote branches were removed, while retained worker branches/worktrees, audit worktrees and the running indexer were preserved. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-05.md Problems and remaining work are documented through fj comments on #1314, #1381, #1384, #1386 and audit remediation issues #1388–#1400. #1381 remains closed; the remaining issues retain substantive implementation/deployment work. CI was skipped; only #1404 needed the exact-head per-PR force_merge override after fj HTTP 405. Branch protection remained unchanged and no production execution is claimed.
Sign in to join this conversation.
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#1381
No description provided.