Skip to content

fix(swap): restrict quotes to Dexie-supported assets and fix price calculation - #835

Merged
Rigidity merged 1 commit into
mainfrom
fix/dexie-swap-token-filter
Aug 19, 2026
Merged

fix(swap): restrict quotes to Dexie-supported assets and fix price calculation#835
Rigidity merged 1 commit into
mainfrom
fix/dexie-swap-token-filter

Conversation

@Rigidity

@Rigidity Rigidity commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • restrict swap token selectors and manual asset IDs to Dexie's supported swap token list
  • keep XCH/CAT selection and bidirectional quote recalculation in sync
  • ignore stale quote responses and surface actionable Dexie API errors
  • clear hidden selector search filters when the dropdown closes

Closes #808

Test plan

  • pnpm lint
  • pnpm build:frontend
  • Prettier check for modified files
  • Verify supported CAT-to-XCH quotes in the desktop app
  • Verify unsupported CATs are absent from both selectors

Note

Medium Risk
Changes swap quoting, asset eligibility, and selection sync with external Dexie APIs; mistakes could block valid swaps or show wrong amounts, but scope is mostly the Swap page and optional TokenSelector props.

Overview
Swap asset pickers now load Dexie’s v1/swap/tokens list and only show CATs (and manual asset IDs) that Dexie supports, with a loading state while that list fetches. XCH stays available; choosing a CAT on one side clears the other side to XCH so quotes stay aligned with CAT↔XCH-style swaps.

Dexie quote and token-list responses are validated with zod, HTTP/API failures surface specific error text, and in-flight quote requests are ignored when inputs change so stale amounts don’t overwrite newer edits. SearchableSelect now notifies onSearchChange('') when the dropdown closes or an item is selected so parent filters don’t stick after the popover dismisses.

Reviewed by Cursor Bugbot for commit e8dad14. Bugbot is set up for automated code reviews on this repo. Configure here.

Keep bidirectional quote updates reliable while preventing unsupported CAT selections from reaching the Dexie quote API.
@Rigidity Rigidity changed the title fix(swap): restrict quotes to Dexie-supported assets fix(swap): restrict quotes to Dexie-supported assets and fix price calculation Aug 19, 2026
@Rigidity
Rigidity merged commit f659424 into main Aug 19, 2026
10 of 11 checks passed
@Rigidity
Rigidity deleted the fix/dexie-swap-token-filter branch August 19, 2026 21:39

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e8dad14. Configure here.

Comment thread src/pages/Swap.tsx
setPayAssetId(value);
updatePayAmount(value, receiveAmount);
if (value !== null) setReceiveAssetId(null);
updatePayAmount(value, nextReceiveAssetId, receiveAmount);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pair flip reuses counterpart amount

High Severity

Selecting a CAT on one side forces the other side to XCH but leaves the counterpart amount unchanged. That leftover value is then converted with XCH precision and sent to Dexie, so the new quote (and a still-enabled Swap action) is for the wrong trade.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e8dad14. Configure here.

Comment thread src/pages/Swap.tsx
})
.finally(() => {
if (!controller.signal.aborted) setIsLoadingDexieAssets(false);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed token fetch blocks swaps

Medium Severity

A Dexie token-list failure leaves dexieAssetIds as an empty Set. TokenSelector treats any provided set as an allow-list, so every CAT is hidden. With only XCH left and XCH disabled on the opposite selector, no valid pair can be chosen.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e8dad14. Configure here.

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.

Swap offers tokens Dexie cannot quote, so most picks fail with a retry message

1 participant