Skip to content

fix: gracefully handle unsupported EURC -> USDC swap direction - #23

Open
ayushsingh82 wants to merge 1 commit into
circlefin:masterfrom
ayushsingh82:fix/eurc-usdc-unsupported-route-issue-1
Open

fix: gracefully handle unsupported EURC -> USDC swap direction#23
ayushsingh82 wants to merge 1 commit into
circlefin:masterfrom
ayushsingh82:fix/eurc-usdc-unsupported-route-issue-1

Conversation

@ayushsingh82

Copy link
Copy Markdown

Summary

Fixes #1. Circle's AppKit Swap SDK has no seeded liquidity route for EURC -> USDC on Arc Testnet, so estimateSwap()/swap() always fail with error 331001 (INPUT_UNSUPPORTED_ROUTE). That routing gap lives in Circle's testnet infra and isn't fixable from this repo, but the app was still round-tripping to the SDK on every attempt and surfacing the raw SDK error to users after the fact.

This PR makes the failure mode graceful instead of fixing the underlying route (which this repo can't do):

  • Added isUnsupportedSwapDirection() / UNSUPPORTED_DIRECTION_MESSAGE to src/lib/fx.ts, shared by server and client code.
  • estimateSwap() and executeSwap() in src/lib/appkit/swap.ts now short-circuit before calling the SDK for this direction, avoiding a wasted network round-trip.
  • SwapPanel disables the swap button and shows a clear inline notice when EURC -> USDC is selected, instead of only showing a destructive alert after a failed quote.
  • Added Vitest (no test framework previously existed in this repo) with tests covering the short-circuit for both functions and confirming the unaffected USDC -> EURC path still calls the SDK normally.

Test plan

  • npm run test — 5/5 passing (src/lib/fx.test.ts, src/lib/appkit/swap.test.ts)
  • npx eslint on all changed files — 0 errors, 0 warnings
  • npx tsc --noEmit — clean
  • npm run build — compiles successfully (only unrelated failure is missing Supabase env vars in this sandbox, expected without real credentials)

Circle's AppKit Swap SDK has no seeded liquidity route for EURC -> USDC
on Arc Testnet, so estimateSwap()/swap() always fail with error 331001
(INPUT_UNSUPPORTED_ROUTE). That's a routing gap in Circle's testnet
infra, not something fixable client-side, but this app was still
round-tripping to the SDK on every attempt and surfacing the raw SDK
error to users.

- Add isUnsupportedSwapDirection()/UNSUPPORTED_DIRECTION_MESSAGE to
  lib/fx.ts, shared by server and client code.
- Short-circuit estimateSwap() and executeSwap() in lib/appkit/swap.ts
  before calling the SDK for this direction.
- Disable the swap button and show an inline notice in SwapPanel when
  EURC -> USDC is selected, instead of a generic destructive alert
  after a failed quote.
- Add Vitest and tests covering the short-circuit for both functions
  and the unaffected USDC -> EURC path.

Fixes circlefin#1
@ayushsingh82

Copy link
Copy Markdown
Author

@akelani-circle Opened this for issue #1 (EURC → USDC always failing with 331001).

Since the routing gap is on Circle's infra side (not fixable here), this makes the failure graceful instead: short-circuits before hitting the SDK for that direction, disables it in the swap UI with a clear message, and adds Vitest (repo had no test framework) covering both the blocked and unaffected directions.

Happy to adjust the approach if you'd prefer something different.

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.

bug: EURC → USDC has no swap route on Arc Testnet (error 331001) — only USDC → EURC direction works

1 participant