Skip to content

Commit

Permalink
sdk: add autoSlippage options to jupiterClient (#1423)
Browse files Browse the repository at this point in the history
* sdk: add autoSlippage to jupiterClient

* fix getQuote params
  • Loading branch information
lowkeynicc authored Jan 13, 2025
1 parent 6348a36 commit fe8e4c4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sdk/src/jupiter/jupiterClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ export class JupiterClient {
swapMode = 'ExactIn',
onlyDirectRoutes = false,
excludeDexes,
autoSlippage = false,
maxAutoSlippageBps,
usdEstimate,
}: {
inputMint: PublicKey;
outputMint: PublicKey;
Expand All @@ -304,15 +307,23 @@ export class JupiterClient {
swapMode?: SwapMode;
onlyDirectRoutes?: boolean;
excludeDexes?: string[];
autoSlippage?: boolean;
maxAutoSlippageBps?: number;
usdEstimate?: number;
}): Promise<QuoteResponse> {
const params = new URLSearchParams({
inputMint: inputMint.toString(),
outputMint: outputMint.toString(),
amount: amount.toString(),
slippageBps: slippageBps.toString(),
slippageBps: autoSlippage ? '0' : slippageBps.toString(),
swapMode,
onlyDirectRoutes: onlyDirectRoutes.toString(),
maxAccounts: maxAccounts.toString(),
autoSlippage: autoSlippage.toString(),
maxAutoSlippageBps: autoSlippage ? maxAutoSlippageBps.toString() : '0',
autoSlippageCollisionUsdValue: autoSlippage
? usdEstimate.toString()
: '0',
...(excludeDexes && { excludeDexes: excludeDexes.join(',') }),
});
if (swapMode === 'ExactOut') {
Expand Down

0 comments on commit fe8e4c4

Please sign in to comment.