Skip to content

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

Description

@MrDennisV

What happens

Picking most tokens on the swap screen fails with "Failed to get quote from Dexie. Please try again later.", and a TypeError reaches the console:

api.dexie.space/v1/swap/quote?from=XCH&to=fcfdda5d…&from_amount=1000000000
  Failed to load resource: the server responded with a status of 400 ()

TypeError: Cannot read properties of undefined (reading 'to_amount')

The message suggests an outage, so it invites a retry that can never succeed.

Why

Dexie publishes two different token lists, and the swap screen reads the wrong one:

Endpoint Tokens (mainnet, today)
/v1/assets?type=cat — what CatQueue records 943
/v1/swap/tokens — what /v1/swap/quote accepts 328

Swap.tsx renders its receive selector with showAllCats={true}, so TokenSelector calls get_all_cats, which returns every asset the catalog holds. Roughly two thirds of those cannot be swapped, and the quote request answers:

HTTP/1.1 400 Bad Request
{"success":false,"error_message":"Unknown from or to assets."}

Reproducible outside the app:

curl -i "https://api.dexie.space/v1/swap/quote?from=XCH&to=fcfdda5dbdbda19ca7fe0ad8ced1afca935cc59810bdb5bec30ef6b058e77fac&from_amount=1000000000"

The selector also offers tokens the wallet itself discovered, which Dexie may not list at all — the asset above is one of those, absent from both listings.

getDexieQuote never checks response.ok, so a 400 falls through to data.quote.to_amount on an undefined quote. The TypeError is caught by the surrounding try, which is why the user sees the generic retry message rather than the reason.

Steps to reproduce

  1. Let the CAT queue fill the catalog.
  2. Open the swap screen.
  3. In the receive selector, pick a token that is not in /v1/swap/tokens — most of the list.
  4. Enter an amount.

Suggested fix

Offer only what Dexie can swap: fetch /v1/swap/tokens and restrict both selectors on the swap screen to that set. Separately, having getDexieQuote check response.ok and surface error_message would turn the remaining failures into something a user can act on.

Happy to open a PR if the approach sounds right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions