@drift-labs/sdk 2.84.0-beta.7 → 2.85.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.84.0-beta.7
1
+ 2.85.0-beta.1
@@ -649,7 +649,7 @@ export declare class DriftClient {
649
649
  getOracleDataForSpotMarket(marketIndex: number): OraclePriceData;
650
650
  initializeInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
651
651
  getInitializeInsuranceFundStakeIx(marketIndex: number): Promise<TransactionInstruction>;
652
- getAddInsuranceFundStakeIx(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
652
+ getAddInsuranceFundStakeIx(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey, fromSubAccount?: boolean): Promise<TransactionInstruction>;
653
653
  /**
654
654
  * Add to an insurance fund stake and optionally initialize the account
655
655
  */
@@ -3318,12 +3318,12 @@ class DriftClient {
3318
3318
  },
3319
3319
  });
3320
3320
  }
3321
- async getAddInsuranceFundStakeIx(marketIndex, amount, collateralAccountPublicKey) {
3321
+ async getAddInsuranceFundStakeIx(marketIndex, amount, collateralAccountPublicKey, fromSubAccount) {
3322
3322
  const spotMarket = this.getSpotMarketAccount(marketIndex);
3323
3323
  const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
3324
3324
  const remainingAccounts = this.getRemainingAccounts({
3325
- userAccounts: [this.getUserAccount()],
3326
- useMarketLastSlotCache: true,
3325
+ userAccounts: fromSubAccount ? [this.getUserAccount()] : [],
3326
+ useMarketLastSlotCache: fromSubAccount ? true : false,
3327
3327
  writableSpotMarketIndexes: [marketIndex],
3328
3328
  });
3329
3329
  const ix = this.program.instruction.addInsuranceFundStake(marketIndex, amount, {
@@ -3371,7 +3371,7 @@ class DriftClient {
3371
3371
  const initializeIx = await this.getInitializeInsuranceFundStakeIx(marketIndex);
3372
3372
  addIfStakeIxs.push(initializeIx);
3373
3373
  }
3374
- const addFundsIx = await this.getAddInsuranceFundStakeIx(marketIndex, amount, tokenAccount);
3374
+ const addFundsIx = await this.getAddInsuranceFundStakeIx(marketIndex, amount, tokenAccount, fromSubaccount);
3375
3375
  addIfStakeIxs.push(addFundsIx);
3376
3376
  if (createWSOLTokenAccount) {
3377
3377
  addIfStakeIxs.push((0, spl_token_1.createCloseAccountInstruction)(tokenAccount, this.wallet.publicKey, this.wallet.publicKey, []));
@@ -3384,8 +3384,7 @@ class DriftClient {
3384
3384
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
3385
3385
  const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
3386
3386
  const remainingAccounts = this.getRemainingAccounts({
3387
- userAccounts: [this.getUserAccount()],
3388
- useMarketLastSlotCache: true,
3387
+ userAccounts: [],
3389
3388
  writableSpotMarketIndexes: [marketIndex],
3390
3389
  });
3391
3390
  const ix = await this.program.instruction.requestRemoveInsuranceFundStake(marketIndex, amount, {
@@ -3427,7 +3426,6 @@ class DriftClient {
3427
3426
  return txSig;
3428
3427
  }
3429
3428
  async removeInsuranceFundStake(marketIndex, collateralAccountPublicKey, txParams) {
3430
- var _a, _b;
3431
3429
  const removeIfStakeIxs = [];
3432
3430
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
3433
3431
  const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
@@ -3450,11 +3448,8 @@ class DriftClient {
3450
3448
  removeIfStakeIxs.push(createTokenAccountIx);
3451
3449
  }
3452
3450
  }
3453
- const userAccountExists = !!((_b = (_a = this.getUser()) === null || _a === void 0 ? void 0 : _a.accountSubscriber) === null || _b === void 0 ? void 0 : _b.isSubscribed) &&
3454
- (await this.checkIfAccountExists(this.getUser().userAccountPublicKey));
3455
3451
  const remainingAccounts = this.getRemainingAccounts({
3456
- userAccounts: userAccountExists ? [this.getUserAccount()] : [],
3457
- useMarketLastSlotCache: false,
3452
+ userAccounts: [],
3458
3453
  writableSpotMarketIndexes: [marketIndex],
3459
3454
  });
3460
3455
  const removeStakeIx = await this.program.instruction.removeInsuranceFundStake(marketIndex, {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.83.0",
2
+ "version": "2.84.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.84.0-beta.7",
3
+ "version": "2.85.0-beta.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1527,6 +1527,7 @@ export class DriftClient {
1527
1527
 
1528
1528
  if (params.useMarketLastSlotCache) {
1529
1529
  const lastUserSlot = this.getUserAccountAndSlot()?.slot;
1530
+
1530
1531
  for (const [
1531
1532
  marketIndex,
1532
1533
  slot,
@@ -6306,7 +6307,8 @@ export class DriftClient {
6306
6307
  public async getAddInsuranceFundStakeIx(
6307
6308
  marketIndex: number,
6308
6309
  amount: BN,
6309
- collateralAccountPublicKey: PublicKey
6310
+ collateralAccountPublicKey: PublicKey,
6311
+ fromSubAccount?: boolean
6310
6312
  ): Promise<TransactionInstruction> {
6311
6313
  const spotMarket = this.getSpotMarketAccount(marketIndex);
6312
6314
  const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
@@ -6316,8 +6318,8 @@ export class DriftClient {
6316
6318
  );
6317
6319
 
6318
6320
  const remainingAccounts = this.getRemainingAccounts({
6319
- userAccounts: [this.getUserAccount()],
6320
- useMarketLastSlotCache: true,
6321
+ userAccounts: fromSubAccount ? [this.getUserAccount()] : [],
6322
+ useMarketLastSlotCache: fromSubAccount ? true : false,
6321
6323
  writableSpotMarketIndexes: [marketIndex],
6322
6324
  });
6323
6325
 
@@ -6416,7 +6418,8 @@ export class DriftClient {
6416
6418
  const addFundsIx = await this.getAddInsuranceFundStakeIx(
6417
6419
  marketIndex,
6418
6420
  amount,
6419
- tokenAccount
6421
+ tokenAccount,
6422
+ fromSubaccount
6420
6423
  );
6421
6424
 
6422
6425
  addIfStakeIxs.push(addFundsIx);
@@ -6456,8 +6459,7 @@ export class DriftClient {
6456
6459
  );
6457
6460
 
6458
6461
  const remainingAccounts = this.getRemainingAccounts({
6459
- userAccounts: [this.getUserAccount()],
6460
- useMarketLastSlotCache: true,
6462
+ userAccounts: [],
6461
6463
  writableSpotMarketIndexes: [marketIndex],
6462
6464
  });
6463
6465
 
@@ -6566,13 +6568,8 @@ export class DriftClient {
6566
6568
  }
6567
6569
  }
6568
6570
 
6569
- const userAccountExists =
6570
- !!this.getUser()?.accountSubscriber?.isSubscribed &&
6571
- (await this.checkIfAccountExists(this.getUser().userAccountPublicKey));
6572
-
6573
6571
  const remainingAccounts = this.getRemainingAccounts({
6574
- userAccounts: userAccountExists ? [this.getUserAccount()] : [],
6575
- useMarketLastSlotCache: false,
6572
+ userAccounts: [],
6576
6573
  writableSpotMarketIndexes: [marketIndex],
6577
6574
  });
6578
6575
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.83.0",
2
+ "version": "2.84.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {