Skip to content

feat(swap): asset clarity — confirm gate, network-everywhere, gas-on-top#264

Merged
BitHighlander merged 3 commits into
developfrom
feat/swap-asset-clarity
Jun 19, 2026
Merged

feat(swap): asset clarity — confirm gate, network-everywhere, gas-on-top#264
BitHighlander merged 3 commits into
developfrom
feat/swap-asset-clarity

Conversation

@BitHighlander

Copy link
Copy Markdown
Collaborator

Summary

Four rules to make swap asset selection unambiguous and stop the "jumping" where a selected output silently becomes a different asset.

  1. Confirmation gate (both sides) — every selection now funnels through a single chokepoint (handleSelectConfirmStepcommitSelect) that shows a full breakdown before committing: symbol, network name + CAIP-2, gas vs token, routes, and full CAIP-19. A mis-tap or a swappable-substituted row can no longer become the pick without an explicit confirm.
  2. Network everywhereAssetSelector cards (SwapDialog) and AssetListRow (AssetPickerDialog) now render the network name + GAS/TOKEN badge + exact CAIP. USDC-on-Ethereum and USDC-on-Optimism are no longer rendered identically.
  3. Gas on toppickerTier floats native/gas assets above all tokens (below only held), tagged with a GAS badge. A chain's own coin is never buried or shown as a confusing bare "ETH / ETH".
  4. USDC/USDT priority — new priority-stable tier ranks USDC/USDT directly under gas, above the broad list of uncommon stablecoins.

New pickerTier order: held-value(0) → held(1) → gas/native(2) → USDC/USDT(3) → other stables(4) → normal token(5) → junk(6) → unsupported(7).

Files

  • src/shared/swap-discovery.tspickerTier reorder, PRIORITY_STABLE_SYMBOLS, isPriorityStableEntry, isGasAsset.
  • src/mainview/components/AssetPickerDialog.tsxConfirmStep gate, GasTokenBadge, network name in rows.
  • src/mainview/components/SwapDialog.tsx — network + GAS/TOKEN + CAIP on the FROM/TO cards.
  • __tests__/swap-discovery.test.ts — tier expectations updated; +2 cases (gas-leads, USDC/USDT-priority).

Test plan

  • bun test __tests__/swap-discovery.test.ts — 61 pass
  • tsc --noEmit — no new errors (pre-existing minimatch ambient-type error only)
  • Device smoke: open swap, confirm both pickers show the gate + breakdown, gas assets lead lists with GAS badge, USDC/USDT above other stables, cards show network for same-symbol cross-network assets.

Scope decisions (confirmed with requester)

  • Gate covers both FROM and TO sides.
  • New ordering applies to the destination asset list; the held FROM list stays ranked by USD value but gains the GAS/network badges + clearer labels.

Four rules to make swap asset selection unambiguous:

1. Confirmation gate (both sides): every pick now funnels through a
   breakdown step in AssetPickerDialog showing symbol, network name +
   CAIP-2, gas-vs-token, routes, and full CAIP-19 before committing —
   stops a mis-tap or a substituted row from silently becoming the
   selection (the "jumping" symptom).

2. Network everywhere: AssetSelector cards and AssetListRow now render
   the network name + GAS/TOKEN badge + exact CAIP, so USDC-on-Ethereum
   and USDC-on-Optimism are no longer indistinguishable.

3. Gas on top: pickerTier floats native/gas assets above all tokens
   (below only held) and tags them with a GAS badge — a chain's own coin
   is never buried or mislabeled.

4. USDC/USDT priority: new priority-stable tier ranks USDC/USDT directly
   under gas, above the broad uncommon-stablecoin list.

Tests updated for the new tier order; +2 cases for gas-leads and
USDC/USDT-priority ordering.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
BitHighlander and others added 2 commits June 19, 2026 16:43
- ellipsizeCaip(): shortens only the long hex/base58 reference segments
  (erc20 contract, bip122 genesis hash) and keeps the namespace prefixes
  (eip155:1/erc20:, …/slip44:) fully readable. Replaces the end-truncating
  CSS ellipsis on the swap cards, picker rows, held tiles, network tiles,
  contract-hit and alternative rows.
- AssetSelector GAS/TOKEN badge now derives from parseCaip(caip).isToken
  (authoritative) and only falls back to contractAddress when no CAIP —
  a token CAIP with a missing contractAddress can no longer read as GAS.
  (addresses PR review comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…postors

compareForPicker now sorts by provider/route count (desc) as the primary
within-tier tiebreak, before discoveryRank. A confirmed route is the
strongest signal of a real, common, swappable asset, so:
- genuinely-routable assets float above same-symbol impostors that only
  matched by ticker (real USDC above a 0-route "Morpho USDC Pool" TRY QUOTE)
- the rest order most-routes-first, surfacing common assets

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@BitHighlander
BitHighlander merged commit 0fbd206 into develop Jun 19, 2026
1 check passed
@BitHighlander
BitHighlander deleted the feat/swap-asset-clarity branch June 19, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant