fix: gracefully handle unsupported EURC -> USDC swap direction - #23
Open
ayushsingh82 wants to merge 1 commit into
Open
fix: gracefully handle unsupported EURC -> USDC swap direction#23ayushsingh82 wants to merge 1 commit into
ayushsingh82 wants to merge 1 commit into
Conversation
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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
isUnsupportedSwapDirection()/UNSUPPORTED_DIRECTION_MESSAGEtosrc/lib/fx.ts, shared by server and client code.estimateSwap()andexecuteSwap()insrc/lib/appkit/swap.tsnow short-circuit before calling the SDK for this direction, avoiding a wasted network round-trip.SwapPaneldisables 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.Test plan
npm run test— 5/5 passing (src/lib/fx.test.ts,src/lib/appkit/swap.test.ts)npx eslinton all changed files — 0 errors, 0 warningsnpx tsc --noEmit— cleannpm run build— compiles successfully (only unrelated failure is missing Supabase env vars in this sandbox, expected without real credentials)