From 1ecdfee4d5cb59e784c1a9b0aba801231fa775f5 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 29 Feb 2024 12:01:31 +0100 Subject: [PATCH] Added handling for unstaking with no subaccount (#915) --- sdk/src/driftClient.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdk/src/driftClient.ts b/sdk/src/driftClient.ts index 6dc1ae158..8888715ba 100644 --- a/sdk/src/driftClient.ts +++ b/sdk/src/driftClient.ts @@ -6183,9 +6183,13 @@ export class DriftClient { } } + const userAccountExists = !!this.getUser()?.accountSubscriber?.isSubscribed && (await this.checkIfAccountExists( + this.getUser().userAccountPublicKey + )); + const remainingAccounts = this.getRemainingAccounts({ - userAccounts: [this.getUserAccount()], - useMarketLastSlotCache: true, + userAccounts: userAccountExists ? [this.getUserAccount()] : [], + useMarketLastSlotCache: false, writableSpotMarketIndexes: [marketIndex], });