Skip to content

Commit 51ad7bb

Browse files
feat: routing responses (#667)
1 parent ec173e8 commit 51ad7bb

File tree

5 files changed

+91
-64
lines changed

5 files changed

+91
-64
lines changed

docs/100-swap-api/common-errors.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
sidebar_label: "Common Errors"
3+
description: "Common errors when using the Jupiter Swap API."
4+
title: "Common Errors"
5+
---
6+
7+
<head>
8+
<title>Common Errors</title>
9+
<meta name="twitter:card" content="summary" />
10+
</head>
11+
12+
In this section, you can find the list of errors that can be returned by the Jupiter Swap API, Swap Program or from other programs like DEXes, System or Token programs.
13+
14+
## Program Errors
15+
16+
### Jupiter Swap Program Errors
17+
18+
:::note Jupiter Swap Program IDL
19+
You can find the full Swap Program IDL here:
20+
https://solscan.io/account/JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4#anchorProgramIdl
21+
:::
22+
23+
:::info Abnormal Error Rates
24+
If you face high or consistent amounts of errors, please reach out to [Jupiter Discord](https://discord.gg/jup).
25+
:::
26+
27+
| Error Code | Error Name | Debug |
28+
| ---------- | ---------- | ----------- |
29+
| 6001 | SlippageToleranceExceeded | Try higher fixed slippage or try [`dynamicSlippage`](/docs/swap-api/send-swap-transaction#how-jupiter-estimates-slippage) |
30+
| 6008 | NotEnoughAccountKeys | Likely modified swap transaction causing missing account keys |
31+
| 6014 | IncorrectTokenProgramID | Likely attempted to take platform fees on a Token2022 token (This is also 0x177e) |
32+
| 6017 | ExactOutAmountNotMatched | Similar to slippage |
33+
34+
### Solana Program Errors
35+
36+
| Program | Link |
37+
| ------- | -------------- |
38+
| Token Program | https://github.com/solana-program/token/blob/main/program/src/error.rs |
39+
| Token2022 Program | https://github.com/solana-program/token-2022/blob/main/program/src/error.rs |
40+
| Associated Token Account Program | https://github.com/solana-program/associated-token-account/blob/main/program/src/error.rs |
41+
| Other Solana Programs | https://github.com/solana-program |
42+
43+
### DEX Program Errors
44+
45+
In the swap transaction, the DEX in routing may return errors. You can find some of their IDLs and/or error codes in an explorer. If they do not support public IDLs or open source code, you can reference the common errors below or if you need additional help, please reach out to [Jupiter Discord](https://discord.gg/jup).
46+
47+
| Error | Description |
48+
| --- | --- |
49+
| Error related to tick array or bitmap extension account | Similar to slippage, the price or market has "moved out of range", hence the swap transaction failed. |
50+
51+
## Routing Errors
52+
53+
The common routing errors you may encounter are usually related to attempting to swap a token that is not tradable on Jupiter, for reasons such as lack of liquidity or the token is not supported.
54+
55+
| Error | Description | Debug |
56+
|-------|-------------|-------|
57+
| NO_ROUTES_FOUND | No routes were found for the requested swap | <ul><li>Check jup.ag if it's routable</li><li>[Check the liquidity of the token's markets](https://support.jup.ag/hc/en-us/articles/18453861473436-Why-is-this-token-not-tradable-on-Jupiter)</li></ul> |
58+
| COULD_NOT_FIND_ANY_ROUTE | Unable to find any valid route for the swap | <ul><li>Check jup.ag if it's routable</li><li>[Check the liquidity of the token's markets](https://support.jup.ag/hc/en-us/articles/18453861473436-Why-is-this-token-not-tradable-on-Jupiter)</li></ul> |
59+
| ROUTE_PLAN_DOES_NOT_<br/>CONSUME_ALL_THE_AMOUNT | The calculated route cannot process the entire input amount, you can get more output amount by reducing your input amount | <ul><li>Try reducing your input amount</li></ul> |
60+
| MARKET_NOT_FOUND | The specified market address was not found | <ul><li>Verify the market address exists and is active</li></ul> |
61+
| TOKEN_NOT_TRADABLE | The specified token mint is not available for trading | <ul><li>Check jup.ag if it's routable</li><li>[Check the liquidity of the token's markets](https://support.jup.ag/hc/en-us/articles/18453861473436-Why-is-this-token-not-tradable-on-Jupiter)</li></ul> |
62+
| NOT_SUPPORTED | Generic error for unsupported operations | <ul><li>Check the specific error message for details</li></ul> |
63+
| CIRCULAR_ARBITRAGE_<br/>IS_DISABLED | Attempted to swap a token for itself | <ul><li>Input and output tokens must be different</li></ul> |
64+
| CANNOT_COMPUTE_<br/>OTHER_AMOUNT_THRESHOLD | Failed to calculate the minimum output amount based on slippage | <ul><li>Verify the input amount and slippage parameters are valid</li></ul> |
65+
66+
## Swap Transaction Composing Errors
67+
68+
| Error | Description | Debug |
69+
|-------|-------------|-------|
70+
| MAX_ACCOUNT_GREATER_THAN_MAX | The specified number of accounts exceeds the maximum allowed | <ul><li>Reduce the number of accounts in the transaction</li></ul> |
71+
| INVALID_COMPUTE_UNIT_PRICE_AND_PRIORITIZATION_FEE | Both compute unit price and prioritization fee were specified | <ul><li>Use either compute unit price or prioritization fee, not both</li></ul> |
72+
| FAILED_TO_GET_SWAP_AND_ACCOUNT_METAS | Failed to generate the swap transaction | <ul><li>Check the error message for specific details</li></ul> |
73+
74+
## Best Practices
75+
76+
It is important to understand the error codes when your products are user facing. This will help you provide a better experience for your users, helping them make an informed decision or follow up step to help their transaction succeed.
77+
78+
:::tip Jup.ag as a reference
79+
You can use https://jup.ag/ as a reference to understand how we handle errors on the UI.
80+
:::
81+
82+
| Error Type | Best Practice |
83+
| ---------- | ------------- |
84+
| Slippage exceeding threshold | Show the user the current slippage tolerance and the incurred slippage |
85+
| Insufficient funds | Show the user the current balance of the account and the required balance |
86+
| Non Jupiter Program Errors | Allow the user to retry with a different route and/or exclude the specific DEX from the quote request |
87+
| Token not tradable | Show the user the token is not tradable and provide context on why it's not tradable |

docs/100-swap-api/program-errors.md

Lines changed: 0 additions & 62 deletions
This file was deleted.

docs/api-responses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ displayed_sidebar: docs
1313
In this section, you can find the list of responses that can be returned by the Jupiter API.
1414

1515
:::info Program Errors
16-
For more information on error codes from programs, see the [Swap API - Program Errors](/docs/swap-api/program-errors).
16+
For more information on error codes from programs, see the [Swap API - Common Errors](/docs/swap-api/common-errors).
1717
:::
1818

1919
| Common Codes | Description | Debug |

redirects.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[
2+
{"to":"/docs/swap-api/common-errors","from":"/docs/swap-api/program-errors"},
3+
24
{"to":"/docs/routing/dex-integration","from":"/docs/dex-integration"},
35

46
{"to":"/docs/misc/integrator-guidelines","from":"/docs/misc/support-guidelines"},

sidebars-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ const sidebars = {
234234
items: [
235235
{
236236
type: 'doc',
237-
id: 'swap-api/program-errors',
237+
id: 'swap-api/common-errors',
238238
},
239239
{
240240
type: 'doc',

0 commit comments

Comments
 (0)