Skip to content

chore: update error message when insufficient liquidity#5003

Merged
tomiir merged 4 commits intomainfrom
enes/apkt-3102-if-liquidity-of-a-token-is-not-available-for-swap-it-should
Sep 12, 2025
Merged

chore: update error message when insufficient liquidity#5003
tomiir merged 4 commits intomainfrom
enes/apkt-3102-if-liquidity-of-a-token-is-not-available-for-swap-it-should

Conversation

@enesozturk
Copy link
Copy Markdown
Contributor

@enesozturk enesozturk commented Sep 11, 2025

Description

On SwapController, we are fetching quotes but when there is insufficient liquidity, we are showing insufficient balance error instead, which is misleading

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-xxx
For GH issues: closes #...

Showcase (Optional)

If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copilot AI review requested due to automatic review settings September 11, 2025 11:15
@linear
Copy link
Copy Markdown

linear bot commented Sep 11, 2025

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Sep 11, 2025

🦋 Changeset detected

Latest commit: 6e141bf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@reown/appkit-controllers Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit Patch
@reown/appkit-ui Patch
@reown/appkit-core Patch
@reown/appkit-utils Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-wallet-button Patch
@reown/appkit-experimental Patch
@reown/appkit-pay Patch
@reown/appkit-cdn Patch
@reown/appkit-universal-connector Patch
@reown/appkit-testing Patch
@reown/appkit-common Patch
@reown/appkit-polyfills Patch
@reown/appkit-wallet Patch
@reown/appkit-cli Patch
@reown/appkit-codemod Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
appkit-basic-html Ready Ready Preview Comment Sep 11, 2025 11:28am
appkit-demo Ready Ready Preview Comment Sep 11, 2025 11:28am
appkit-gallery Ready Ready Preview Comment Sep 11, 2025 11:28am
appkit-laboratory Ready Ready Preview Comment Sep 11, 2025 11:28am
10 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
appkit-basic-example Ignored Ignored Sep 11, 2025 11:28am
appkit-basic-sign-client-example Ignored Ignored Sep 11, 2025 11:28am
appkit-basic-up-example Ignored Ignored Sep 11, 2025 11:28am
appkit-ethers5-bera Ignored Ignored Sep 11, 2025 11:28am
appkit-nansen-demo Ignored Ignored Sep 11, 2025 11:28am
appkit-vue-solana Ignored Ignored Sep 11, 2025 11:28am
appkit-wagmi-cdn-example Ignored Ignored Sep 11, 2025 11:28am
ethereum-provider-wagmi-example Ignored Ignored Sep 11, 2025 11:28am
next-wagmi-solana-bitcoin-example Ignored Ignored Sep 11, 2025 11:28am
vue-wagmi-example Ignored Ignored Sep 11, 2025 11:28am

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Updates the error handling in SwapController to show "Insufficient liquidity" when there's insufficient liquidity instead of the misleading "Insufficient balance" error message.

  • Added handleSwapError utility function to parse API error responses and identify insufficient liquidity errors
  • Updated SwapController to use the new error handling function when quote fetching fails
  • Added comprehensive test coverage for the new error handling logic

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/controllers/src/utils/SwapApiUtil.ts Adds new handleSwapError function to parse API errors and detect insufficient liquidity
packages/controllers/src/controllers/SwapController.ts Updates error handling in swapTokens to use new error parsing utility
packages/controllers/tests/utils/SwapApiUtil.test.ts Adds test coverage for the new handleSwapError function
.changeset/little-grapes-arrive.md Documents the change in the changeset

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@enesozturk enesozturk requested a review from a team September 11, 2025 11:16
cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.27% 35378 / 45195
🔵 Statements 78.27% 35378 / 45195
🔵 Functions 76.02% 3884 / 5109
🔵 Branches 86.54% 8391 / 9695
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/controllers/src/controllers/SwapController.ts 55.53% 81.06% 68.33% 55.53% 55-58, 187, 230-235, 266-268, 277-278, 286-300, 329, 338-339, 347-350, 391, 398, 401-403, 410-427, 436-438, 452-453, 464-465, 484-485, 489-497, 501, 503, 505, 507, 552-561, 597-627, 631-685, 689-743, 747-748, 763-764, 780-799, 803-885, 904-905, 797-881
packages/controllers/src/utils/SwapApiUtil.ts 93.39% 83.87% 100% 93.39% 53-54, 59, 103, 131, 150-151
Generated in workflow #15005 for commit 6e141bf by the Vitest Coverage Report Action

@enesozturk enesozturk added this pull request to the merge queue Sep 12, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 12, 2025
@tomiir tomiir added this pull request to the merge queue Sep 12, 2025
@tomiir tomiir removed this pull request from the merge queue due to a manual request Sep 12, 2025
@tomiir tomiir merged commit 13700b8 into main Sep 12, 2025
59 of 61 checks passed
@tomiir tomiir deleted the enes/apkt-3102-if-liquidity-of-a-token-is-not-available-for-swap-it-should branch September 12, 2025 11:30
@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants