Problem with the "Jupiter API trading bot" sample

Hello. I am playing with a Jupiter trading bot example described here:
(Create a Solana Trading Bot Using Jupiter API | QuickNode)
Using free endpoints (to try and evaluate before I pay for production stuff)

When I use the predefined pair USDC/Solana, it all works just perfectly.

But when I’m trying to replace USDC with an SPL token address, the Jupiter API always returns 400: Bad Request error when trying to obtain the quote, with any example of an existing SPL token. The “good request” and any “bad request” differ only with the token address.

Here is an example of response with error:

Response {
status: 400,
statusText: ‘Bad Request’,
headers: Headers {
date: ‘Thu, 16 May 2024 18:09:07 GMT’,
‘content-type’: ‘application/json’,
‘content-length’: ‘75’,
connection: ‘keep-alive’,
‘cf-ray’: ‘884d51255958b188-WAW’,
‘cf-cache-status’: ‘DYNAMIC’,
‘access-control-allow-origin’: ‘',
‘access-control-allow-headers’: '
‘access-control-max-age’: ‘86400’,
‘access-control-request-method’: ‘GET, POST, OPTIONS’,
m: ‘’,
vary: ‘Accept-Encoding’,
server: ‘cloudflare’,
‘alt-svc’: ‘h3=“:443”; ma=86400’
body: ReadableStream { locked: false, state: ‘readable’, supportsBYOB: true },
bodyUsed: false, ok: false, redirected: false, type: ‘basic’, url: ‘’ } }

Am I doing something wrong? If I upgrade to paid plans for both QuickNode and Jupiter add-on, should it work well, or the problem is not the free stuff used?

Thanks everybody who can help.

The issue you are encountering is due to the size of your query. Per the docs for the (quote) method, you must account for token decimals. The token you are searching has 6 decimals, so querying 1 unit is actually looking for 0.000001 tokens, and it’s just likely an underflow error.
So if you want to search for the price of 1M tokens, you need to enter 1_000_000_000_000 and query like so:

curl -L '' \
-H 'Accept: application/json'

At the current time that yields 491_290_962 (about 0.5 SOL).

Hope that helps!

Awesome, that worked, thank you for help Aaron!

Now I’m getting another error. Trying to do a swap for that same token, and getting an error on the stage #4 for my transaction (Jupiter Aggrerator v6 Instruction):

Program log: Instruction: SharedAccountsRoute
Program log: panicked at ‘range end index 64 out of range for slice of length 0’, src/

What could that mean?

Here is the full information about the transaction:

Hard to say without seeing your code. My guess would be:

  • you are not using all of the instructions returned from the Jupiter API (you should use all)
  • and/or you may not have initiated one or more necessary token accounts for the swap.

Hi again.

I am using the QuickNode’s trading bot sample mentioned above, just replaced USDC with that token address. It gets quotes without problem, but gives the error on the transaction confirmation step.

I’m not sure what you mean “not have initiated one or more token accounts for the swap”, is there some additional code needed to do that in the trading bot sample, when token of interest is different from USDC?

Solana balance is enough in my wallet, just in case. And tries are sqeezing it quite fast, because commissions are taken independently from the result :frowning:

As stated in the guide, the bot is just illustrative example and not intended for production.

I cannot say for sure if you need additional code without seeing yours. Can you share via a gist or GH repo? If your code is 100% the same as the bot example, except you’ve changed the mint address for one of the tokens here, then it’s possible that you’re are running into some liquidity issues with the smaller token you are trading, but based on your error–I am not convinced that’s the issue.