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

dexes and excludeDexes are not stringified correctly in query params #21

Open
yamen opened this issue Dec 24, 2023 · 0 comments
Open

dexes and excludeDexes are not stringified correctly in query params #21

yamen opened this issue Dec 24, 2023 · 0 comments

Comments

@yamen
Copy link

yamen commented Dec 24, 2023

Issue

Array-based query strings such as dexes and excludeDexes are serialised using repeating parameters (eg dexes=Openbook&dexes=Saber) instead of as comma separated strings as expected by the server.

Reproduce

Call with for eg:

{
  inputMint: 'So11111111111111111111111111111111111111112',
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: 100000000000,
  excludeDexes: [ 'Openbook', 'Whirlpool' ]
}

The following will be used as the query parameter:

inputMint=So11111111111111111111111111111111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=100000000000&excludeDexes=Openbook&excludeDexes=Whirlpool

Which will result in the dexes not actually being exlcuded in the resulting quote.

Fix

Overriding the client can fix this as a hack:

const jupiterClient = createJupiterApiClient({
  basePath: JUPITER_API_URL,
  queryParamsStringify: (params) => {
    if (params['excludeDexes']) {
      params['excludeDexes'] = (params['excludeDexes'] as string[]).join(',');
    }
    if (params['dexes']) {
      params['dexes'] = (params['dexes'] as string[]).join(',');
    }
    return querystring(params);
  }
});

But this should ideally be fixed in the runtime where the query string generator can prefer concatenating arrays with commas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant