Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error debugging docs #604

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions docs/100-swap-api/program-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
sidebar_label: "Program Errors"
description: "Program errors for the Jupiter Swap Program."
title: "Program Errors"
---

<head>
<title>Swap Program Errors</title>
<meta name="twitter:card" content="summary" />
</head>

In this section, you can find the list of errors that can be returned by the Jupiter Swap Program or from other programs like DEXes, System or Token programs.

## Solana Program Errors

| Program | Link |
| ------- | -------------- |
| Token Program | https://github.com/solana-program/token/blob/main/program/src/error.rs |
| Token2022 Program | https://github.com/solana-program/token-2022/blob/main/program/src/error.rs |
| Associated Token Account Program | https://github.com/solana-program/associated-token-account/blob/main/program/src/error.rs |
| Other Solana Programs | https://github.com/solana-program |

## Jupiter Swap Program Errors

:::note Jupiter Swap Program IDL
You can find the full Swap Program IDL here:
https://solscan.io/account/JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4#anchorProgramIdl
:::

:::info Abnormal Error Rates
If you face high or consistent amounts of errors, please reach out to [Jupiter Support](https://jupiverse.zendesk.com/hc/en-us/requests/new?ticket_form_id=18069133114012&tf_18541841140892=api_or_developer_support).
:::

| Error Code | Error Name | Debug |
| ---------- | ---------- | ----------- |
| 6001 | SlippageToleranceExceeded | Try higher fixed slippage or use [`dynamicSlippage`](/docs/swap-api/send-swap-transaction#how-jupiter-estimates-slippage) |
| 6008 | NotEnoughAccountKeys | Likely modified swap transaction causing missing account keys |
| 6014 | IncorrectTokenProgramID | Likely attempted to take platform fees on a Token2022 token |
| 6017 | ExactOutAmountNotMatched | Similar to slippage |

## DEX Program Errors

In the swap transaction, the DEX in the 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 Support](https://jupiverse.zendesk.com/hc/en-us/requests/new?ticket_form_id=18069133114012&tf_18541841140892=api_or_developer_support).

| Error | Description |
| --- | --- |
| 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. |

## Best Practices

It is important to understand the error codes returned by programs 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.


:::tip Jup.ag as a reference
You can use https://jup.ag/ as a reference to understand how we handle errors on the UI.
:::

| Error Type | Best Practice |
| ---------- | ------------- |
| Slippage exceeding threshold | Show the user the current slippage tolerance and the incurred slippage |
| Insufficient funds | Show the user the current balance of the account and the required balance |
| Non Jupiter Program Errors | Allow the user to retry with a different route and/or exclude the specific DEX from the quote request |
29 changes: 29 additions & 0 deletions docs/api-responses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
sidebar_label: "API Responses"
description: "API responses for the Jupiter API."
title: "API Responses"
displayed_sidebar: docs
---

<head>
<title>API Responses</title>
<meta name="twitter:card" content="summary" />
</head>

In this section, you can find the list of responses that can be returned by the Jupiter API.

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

| Common Codes | Description | Debug |
| --- | --- | --- |
| 200 | Good | Success! |
| 400 | Bad Request | Likely a problem with the request, check the request parameters, syntax, etc. |
| 401 | Unauthorized | Likely a problem with the API key, check if the API key is correct. |
| 404 | Not Found | Likely a broken or invalid endpoint. |
| 429 | Rate Limited | You are being rate limited. Either slow down requests, reduce bursts, or upgrade your plan. |
| 500 | Internal Server Error | Please contact [Jupiter Support](https://jupiverse.zendesk.com/hc/en-us/requests/new?ticket_form_id=18069133114012&tf_18541841140892=api_or_developer_support). |
| 502 | Bad Gateway | Please contact [Jupiter Support](https://jupiverse.zendesk.com/hc/en-us/requests/new?ticket_form_id=18069133114012&tf_18541841140892=api_or_developer_support). |
| 503 | Service Unavailable | Please contact [Jupiter Support](https://jupiverse.zendesk.com/hc/en-us/requests/new?ticket_form_id=18069133114012&tf_18541841140892=api_or_developer_support). |
| 504 | Gateway Timeout | Try disabling any proxies, VPNs, firewalls or other network restrictions and try again. If issue persists, please contact [Jupiter Support](https://jupiverse.zendesk.com/hc/en-us/requests/new?ticket_form_id=18069133114012&tf_18541841140892=api_or_developer_support). |
22 changes: 21 additions & 1 deletion sidebars-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const sidebars = {
},
{
type: 'doc',
id: 'dex-integration',
id: 'api-responses',
},
{
type: 'html',
Expand Down Expand Up @@ -126,6 +126,26 @@ const sidebars = {
type: 'html',
value: '<div class="sidebar-line-break"></div>',
},
{
type: 'category',
label: 'Debugging',
collapsible: false,
collapsed: false,
items: [
{
type: 'doc',
id: 'swap-api/program-errors',
},
{
type: 'doc',
id: 'api-responses',
},
],
},
{
type: 'html',
value: '<div class="sidebar-line-break"></div>',
},
],
perp: [
{
Expand Down