Skip to content
Merged
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
2 changes: 1 addition & 1 deletion sdk/src/adminClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6043,7 +6043,7 @@ export class AdminClient extends DriftClient {
}

if (!quote) {
throw new Error("Could not fetch Jupiter's quote. Please try again.");
throw new Error('Could not fetch swap quote. Please try again.');
}

const isExactOut = swapMode === 'ExactOut' || quote.swapMode === 'ExactOut';
Expand Down
16 changes: 8 additions & 8 deletions sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5768,15 +5768,15 @@ export class DriftClient {
* @param jupiterClient @deprecated Use swapClient instead. Legacy parameter for backward compatibility
* @param outMarketIndex the market index of the token you're buying
* @param inMarketIndex the market index of the token you're selling
* @param outAssociatedTokenAccount the token account to receive the token being sold on titan or jupiter
* @param outAssociatedTokenAccount the token account to receive the token being sold on the swap provider
* @param inAssociatedTokenAccount the token account to
* @param amount the amount of TokenIn, regardless of swapMode
* @param slippageBps the max slippage passed to titan or jupiter api
* @param swapMode titan or jupiter swapMode (ExactIn or ExactOut), default is ExactIn
* @param route the titan or jupiter route to use for the swap
* @param slippageBps the max slippage passed to the swap provider api
* @param swapMode swap provider swapMode (ExactIn or ExactOut), default is ExactIn
* @param route the swap provider route to use for the swap
* @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
* @param v6 pass in the quote response from Jupiter quote's API (deprecated, use quote instead)
* @param quote pass in the quote response from Jupiter quote's API
* @param v6 pass in the quote response from swap provider quote's API (deprecated, use quote instead)
* @param quote pass in the quote response from swap provider quote's API
* @param txParams
*/
public async swap({
Expand Down Expand Up @@ -6059,7 +6059,7 @@ export class DriftClient {
}

if (!quote) {
throw new Error("Could not fetch Jupiter's quote. Please try again.");
throw new Error('Could not fetch swap quote. Please try again.');
}

const isExactOut = swapMode === 'ExactOut' || quote.swapMode === 'ExactOut';
Expand Down Expand Up @@ -8910,7 +8910,7 @@ export class DriftClient {
}

if (!quote) {
throw new Error("Could not fetch Jupiter's quote. Please try again.");
throw new Error('Could not fetch swap quote. Please try again.');
}

const amountIn = new BN(quote.inAmount);
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/math/superStake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export async function findBestJitoSolSuperStakeIxs({
}

/**
* Finds best Jupiter Swap instructions for a generic lstMint
* Finds best swap instructions for a generic lstMint
*
* Without doing any extra steps like checking if you can get a better rate by staking directly with that LST platform
*/
Expand Down
28 changes: 25 additions & 3 deletions sdk/src/swap/UnifiedSwapClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,29 @@ import {
export type SwapMode = 'ExactIn' | 'ExactOut';
export type SwapClientType = 'jupiter' | 'titan';

export type UnifiedQuoteResponse = JupiterQuoteResponse | TitanQuoteResponse;
/**
* Unified quote response interface that combines properties from both Jupiter and Titan
* This provides a consistent interface while allowing for provider-specific fields
*/
export interface UnifiedQuoteResponse {
// Core properties available in both providers
inputMint: string;
inAmount: string;
outputMint: string;
outAmount: string;
swapMode: SwapMode;
slippageBps: number;
routePlan: Array<{ swapInfo: any; percent: number }>;

// Optional properties that may not be available in all providers
otherAmountThreshold?: string; // Jupiter has this, Titan doesn't
priceImpactPct?: string; // Jupiter provides this, Titan doesn't (we calculate it)
platformFee?: { amount?: string; feeBps?: number }; // Format varies between providers
contextSlot?: number;
timeTaken?: number;
error?: string;
errorCode?: string;
}

export interface SwapQuoteParams {
inputMint: PublicKey;
Expand Down Expand Up @@ -135,7 +157,7 @@ export class UnifiedSwapClient {
): Promise<SwapTransactionResult> {
if (this.clientType === 'jupiter') {
const jupiterClient = this.client as JupiterClient;
// Cast the quote to Jupiter's QuoteResponse type
// Cast the quote to Jupiter's specific QuoteResponse type
const jupiterParams = {
...params,
quote: params.quote as JupiterQuoteResponse,
Expand Down Expand Up @@ -213,7 +235,7 @@ export class UnifiedSwapClient {
}

if (!finalQuote) {
throw new Error("Could not fetch Jupiter's quote. Please try again.");
throw new Error('Could not fetch swap quote. Please try again.');
}

// Get swap transaction and extract instructions
Expand Down
Loading