Skip to content

Commit c376b72

Browse files
authored
Update swap client type and verbiage (#2009)
* Update swap client type and verbiage * prettify * prettify
1 parent 1be30c8 commit c376b72

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

sdk/src/adminClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6043,7 +6043,7 @@ export class AdminClient extends DriftClient {
60436043
}
60446044

60456045
if (!quote) {
6046-
throw new Error("Could not fetch Jupiter's quote. Please try again.");
6046+
throw new Error('Could not fetch swap quote. Please try again.');
60476047
}
60486048

60496049
const isExactOut = swapMode === 'ExactOut' || quote.swapMode === 'ExactOut';

sdk/src/driftClient.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5768,15 +5768,15 @@ export class DriftClient {
57685768
* @param jupiterClient @deprecated Use swapClient instead. Legacy parameter for backward compatibility
57695769
* @param outMarketIndex the market index of the token you're buying
57705770
* @param inMarketIndex the market index of the token you're selling
5771-
* @param outAssociatedTokenAccount the token account to receive the token being sold on titan or jupiter
5771+
* @param outAssociatedTokenAccount the token account to receive the token being sold on the swap provider
57725772
* @param inAssociatedTokenAccount the token account to
57735773
* @param amount the amount of TokenIn, regardless of swapMode
5774-
* @param slippageBps the max slippage passed to titan or jupiter api
5775-
* @param swapMode titan or jupiter swapMode (ExactIn or ExactOut), default is ExactIn
5776-
* @param route the titan or jupiter route to use for the swap
5774+
* @param slippageBps the max slippage passed to the swap provider api
5775+
* @param swapMode swap provider swapMode (ExactIn or ExactOut), default is ExactIn
5776+
* @param route the swap provider route to use for the swap
57775777
* @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
5778-
* @param v6 pass in the quote response from Jupiter quote's API (deprecated, use quote instead)
5779-
* @param quote pass in the quote response from Jupiter quote's API
5778+
* @param v6 pass in the quote response from swap provider quote's API (deprecated, use quote instead)
5779+
* @param quote pass in the quote response from swap provider quote's API
57805780
* @param txParams
57815781
*/
57825782
public async swap({
@@ -6059,7 +6059,7 @@ export class DriftClient {
60596059
}
60606060

60616061
if (!quote) {
6062-
throw new Error("Could not fetch Jupiter's quote. Please try again.");
6062+
throw new Error('Could not fetch swap quote. Please try again.');
60636063
}
60646064

60656065
const isExactOut = swapMode === 'ExactOut' || quote.swapMode === 'ExactOut';
@@ -8910,7 +8910,7 @@ export class DriftClient {
89108910
}
89118911

89128912
if (!quote) {
8913-
throw new Error("Could not fetch Jupiter's quote. Please try again.");
8913+
throw new Error('Could not fetch swap quote. Please try again.');
89148914
}
89158915

89168916
const amountIn = new BN(quote.inAmount);

sdk/src/math/superStake.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export async function findBestJitoSolSuperStakeIxs({
223223
}
224224

225225
/**
226-
* Finds best Jupiter Swap instructions for a generic lstMint
226+
* Finds best swap instructions for a generic lstMint
227227
*
228228
* Without doing any extra steps like checking if you can get a better rate by staking directly with that LST platform
229229
*/

sdk/src/swap/UnifiedSwapClient.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,29 @@ import {
2020
export type SwapMode = 'ExactIn' | 'ExactOut';
2121
export type SwapClientType = 'jupiter' | 'titan';
2222

23-
export type UnifiedQuoteResponse = JupiterQuoteResponse | TitanQuoteResponse;
23+
/**
24+
* Unified quote response interface that combines properties from both Jupiter and Titan
25+
* This provides a consistent interface while allowing for provider-specific fields
26+
*/
27+
export interface UnifiedQuoteResponse {
28+
// Core properties available in both providers
29+
inputMint: string;
30+
inAmount: string;
31+
outputMint: string;
32+
outAmount: string;
33+
swapMode: SwapMode;
34+
slippageBps: number;
35+
routePlan: Array<{ swapInfo: any; percent: number }>;
36+
37+
// Optional properties that may not be available in all providers
38+
otherAmountThreshold?: string; // Jupiter has this, Titan doesn't
39+
priceImpactPct?: string; // Jupiter provides this, Titan doesn't (we calculate it)
40+
platformFee?: { amount?: string; feeBps?: number }; // Format varies between providers
41+
contextSlot?: number;
42+
timeTaken?: number;
43+
error?: string;
44+
errorCode?: string;
45+
}
2446

2547
export interface SwapQuoteParams {
2648
inputMint: PublicKey;
@@ -135,7 +157,7 @@ export class UnifiedSwapClient {
135157
): Promise<SwapTransactionResult> {
136158
if (this.clientType === 'jupiter') {
137159
const jupiterClient = this.client as JupiterClient;
138-
// Cast the quote to Jupiter's QuoteResponse type
160+
// Cast the quote to Jupiter's specific QuoteResponse type
139161
const jupiterParams = {
140162
...params,
141163
quote: params.quote as JupiterQuoteResponse,
@@ -213,7 +235,7 @@ export class UnifiedSwapClient {
213235
}
214236

215237
if (!finalQuote) {
216-
throw new Error("Could not fetch Jupiter's quote. Please try again.");
238+
throw new Error('Could not fetch swap quote. Please try again.');
217239
}
218240

219241
// Get swap transaction and extract instructions

0 commit comments

Comments
 (0)