@@ -2539,7 +2539,8 @@ export class DriftClient {
2539
2539
associatedTokenAccount : PublicKey ,
2540
2540
subAccountId ?: number ,
2541
2541
reduceOnly = false ,
2542
- txParams ?: TxParams
2542
+ txParams ?: TxParams ,
2543
+ initSwiftAccount = false
2543
2544
) : Promise < VersionedTransaction | Transaction > {
2544
2545
const instructions = await this . getDepositTxnIx (
2545
2546
amount ,
@@ -2549,7 +2550,24 @@ export class DriftClient {
2549
2550
reduceOnly
2550
2551
) ;
2551
2552
2552
- txParams = { ...( txParams ?? this . txParams ) , computeUnits : 600_000 } ;
2553
+ if ( initSwiftAccount ) {
2554
+ const isSignedMsgUserOrdersAccountInitialized =
2555
+ await this . isSignedMsgUserOrdersAccountInitialized (
2556
+ this . wallet . publicKey
2557
+ ) ;
2558
+
2559
+ if ( ! isSignedMsgUserOrdersAccountInitialized ) {
2560
+ const [ , initializeSignedMsgUserOrdersAccountIx ] =
2561
+ await this . getInitializeSignedMsgUserOrdersAccountIx (
2562
+ this . wallet . publicKey ,
2563
+ 8
2564
+ ) ;
2565
+
2566
+ instructions . push ( initializeSignedMsgUserOrdersAccountIx ) ;
2567
+ }
2568
+ }
2569
+
2570
+ txParams = { ...( txParams ?? this . txParams ) , computeUnits : 800_000 } ;
2553
2571
2554
2572
const tx = await this . buildTransaction ( instructions , txParams ) ;
2555
2573
@@ -2571,15 +2589,17 @@ export class DriftClient {
2571
2589
associatedTokenAccount : PublicKey ,
2572
2590
subAccountId ?: number ,
2573
2591
reduceOnly = false ,
2574
- txParams ?: TxParams
2592
+ txParams ?: TxParams ,
2593
+ initSwiftAccount = false
2575
2594
) : Promise < TransactionSignature > {
2576
2595
const tx = await this . createDepositTxn (
2577
2596
amount ,
2578
2597
marketIndex ,
2579
2598
associatedTokenAccount ,
2580
2599
subAccountId ,
2581
2600
reduceOnly ,
2582
- txParams
2601
+ txParams ,
2602
+ initSwiftAccount
2583
2603
) ;
2584
2604
2585
2605
const { txSig, slot } = await this . sendTransaction ( tx , [ ] , this . opts ) ;
0 commit comments