@@ -5756,6 +5756,7 @@ export class DriftClient {
57565756 /**
57575757 * Swap tokens in drift account using titan or jupiter
57585758 * @param swapClient swap client to find routes and instructions (Titan or Jupiter)
5759+ * @param jupiterClient @deprecated Use swapClient instead. Legacy parameter for backward compatibility
57595760 * @param outMarketIndex the market index of the token you're buying
57605761 * @param inMarketIndex the market index of the token you're selling
57615762 * @param outAssociatedTokenAccount the token account to receive the token being sold on titan or jupiter
@@ -5771,6 +5772,7 @@ export class DriftClient {
57715772 */
57725773 public async swap ( {
57735774 swapClient,
5775+ jupiterClient,
57745776 outMarketIndex,
57755777 inMarketIndex,
57765778 outAssociatedTokenAccount,
@@ -5784,7 +5786,9 @@ export class DriftClient {
57845786 quote,
57855787 onlyDirectRoutes = false ,
57865788 } : {
5787- swapClient : UnifiedSwapClient | SwapClient ;
5789+ swapClient ?: UnifiedSwapClient | SwapClient ;
5790+ /** @deprecated Use swapClient instead. Legacy parameter for backward compatibility */
5791+ jupiterClient ?: JupiterClient ;
57885792 outMarketIndex : number ;
57895793 inMarketIndex : number ;
57905794 outAssociatedTokenAccount ?: PublicKey ;
@@ -5800,15 +5804,22 @@ export class DriftClient {
58005804 } ;
58015805 quote ?: QuoteResponse ;
58025806 } ) : Promise < TransactionSignature > {
5807+ // Handle backward compatibility: use jupiterClient if swapClient is not provided
5808+ const clientToUse = swapClient || jupiterClient ;
5809+
5810+ if ( ! clientToUse ) {
5811+ throw new Error ( 'Either swapClient or jupiterClient must be provided' ) ;
5812+ }
5813+
58035814 let res : {
58045815 ixs : TransactionInstruction [ ] ;
58055816 lookupTables : AddressLookupTableAccount [ ] ;
58065817 } ;
58075818
58085819 // Use unified SwapClient if available
5809- if ( swapClient instanceof UnifiedSwapClient ) {
5820+ if ( clientToUse instanceof UnifiedSwapClient ) {
58105821 res = await this . getSwapIxV2 ( {
5811- swapClient,
5822+ swapClient : clientToUse ,
58125823 outMarketIndex,
58135824 inMarketIndex,
58145825 outAssociatedTokenAccount,
@@ -5821,9 +5832,9 @@ export class DriftClient {
58215832 quote,
58225833 v6,
58235834 } ) ;
5824- } else if ( swapClient instanceof TitanClient ) {
5835+ } else if ( clientToUse instanceof TitanClient ) {
58255836 res = await this . getTitanSwapIx ( {
5826- titanClient : swapClient ,
5837+ titanClient : clientToUse ,
58275838 outMarketIndex,
58285839 inMarketIndex,
58295840 outAssociatedTokenAccount,
@@ -5834,10 +5845,10 @@ export class DriftClient {
58345845 onlyDirectRoutes,
58355846 reduceOnly,
58365847 } ) ;
5837- } else if ( swapClient instanceof JupiterClient ) {
5848+ } else if ( clientToUse instanceof JupiterClient ) {
58385849 const quoteToUse = quote ?? v6 ?. quote ;
58395850 res = await this . getJupiterSwapIxV6 ( {
5840- jupiterClient : swapClient ,
5851+ jupiterClient : clientToUse ,
58415852 outMarketIndex,
58425853 inMarketIndex,
58435854 outAssociatedTokenAccount,
0 commit comments