File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1738,6 +1738,24 @@ export class DriftClient {
1738
1738
return ix ;
1739
1739
}
1740
1740
1741
+ /**
1742
+ * Checks if a Swift User Orders account exists for the given authority.
1743
+ * The account pubkey is derived using the program ID and authority as seeds.
1744
+ * Makes an RPC call to check if the account exists on-chain.
1745
+ *
1746
+ * @param authority The authority public key to check for
1747
+ * @returns Promise that resolves to true if the account exists, false otherwise
1748
+ */
1749
+ public async isSwiftUserOrdersAccountInitialized (
1750
+ authority : PublicKey
1751
+ ) : Promise < boolean > {
1752
+ const swiftUserOrdersAccountPublicKey = getSwiftUserAccountPublicKey (
1753
+ this . program . programId ,
1754
+ authority
1755
+ ) ;
1756
+ return this . checkIfAccountExists ( swiftUserOrdersAccountPublicKey ) ;
1757
+ }
1758
+
1741
1759
public async reclaimRent (
1742
1760
subAccountId = 0 ,
1743
1761
txParams ?: TxParams
@@ -2530,6 +2548,18 @@ export class DriftClient {
2530
2548
referrerInfo
2531
2549
) ;
2532
2550
2551
+ const isSwiftUserOrdersAccountInitialized =
2552
+ await this . isSwiftUserOrdersAccountInitialized ( this . wallet . publicKey ) ;
2553
+
2554
+ if ( ! isSwiftUserOrdersAccountInitialized ) {
2555
+ ixs . push (
2556
+ await this . getInitializeSwiftUserOrdersAccountIx (
2557
+ this . wallet . publicKey ,
2558
+ 8
2559
+ )
2560
+ ) ;
2561
+ }
2562
+
2533
2563
const spotMarket = this . getSpotMarketAccount ( marketIndex ) ;
2534
2564
2535
2565
const isSolMarket = spotMarket . mint . equals ( WRAPPED_SOL_MINT ) ;
You can’t perform that action at this time.
0 commit comments