fix(swap): restrict quotes to Dexie-supported assets and fix price calculation - #835
Conversation
Keep bidirectional quote updates reliable while preventing unsupported CAT selections from reaching the Dexie quote API.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ 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.
| setPayAssetId(value); | ||
| updatePayAmount(value, receiveAmount); | ||
| if (value !== null) setReceiveAssetId(null); | ||
| updatePayAmount(value, nextReceiveAssetId, receiveAmount); |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit e8dad14. Configure here.
| }) | ||
| .finally(() => { | ||
| if (!controller.signal.aborted) setIsLoadingDexieAssets(false); | ||
| }); |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit e8dad14. Configure here.


Summary
Closes #808
Test plan
pnpm lintpnpm build:frontendNote
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/tokenslist 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.
SearchableSelectnow notifiesonSearchChange('')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.