@drift-labs/sdk 2.34.1-beta.3 → 2.34.1-beta.5

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.34.1-beta.3
1
+ 2.34.1-beta.5
package/lib/dlob/DLOB.js CHANGED
@@ -490,18 +490,9 @@ class DLOB {
490
490
  return nodesToFill;
491
491
  }
492
492
  // All bids/asks that can expire
493
- const bidGenerators = [
494
- nodeLists.takingLimit.bid.getGenerator(),
495
- nodeLists.restingLimit.bid.getGenerator(),
496
- nodeLists.floatingLimit.bid.getGenerator(),
497
- nodeLists.market.bid.getGenerator(),
498
- ];
499
- const askGenerators = [
500
- nodeLists.takingLimit.ask.getGenerator(),
501
- nodeLists.restingLimit.ask.getGenerator(),
502
- nodeLists.floatingLimit.ask.getGenerator(),
503
- nodeLists.market.ask.getGenerator(),
504
- ];
493
+ // dont try to expire limit orders with tif as its inefficient use of blockspace
494
+ const bidGenerators = [nodeLists.market.bid.getGenerator()];
495
+ const askGenerators = [nodeLists.market.ask.getGenerator()];
505
496
  for (const bidGenerator of bidGenerators) {
506
497
  for (const bid of bidGenerator) {
507
498
  if ((0, __1.isOrderExpired)(bid.order, ts)) {
@@ -1041,7 +1041,10 @@ class DriftClient {
1041
1041
  }));
1042
1042
  }
1043
1043
  const authority = this.wallet.publicKey;
1044
- const createWSOLTokenAccount = isSolMarket && userTokenAccount.equals(authority);
1044
+ const isFromSubaccount = fromSubAccountId !== null &&
1045
+ fromSubAccountId !== undefined &&
1046
+ !isNaN(fromSubAccountId);
1047
+ const createWSOLTokenAccount = isSolMarket && userTokenAccount.equals(authority) && !isFromSubaccount;
1045
1048
  if (createWSOLTokenAccount) {
1046
1049
  const { ixs: startIxs, signers, pubkey, } = await this.getWrappedSolAccountCreationIxs(amount, true);
1047
1050
  userTokenAccount = pubkey;
@@ -1050,7 +1053,7 @@ class DriftClient {
1050
1053
  });
1051
1054
  signers.forEach((signer) => additionalSigners.push(signer));
1052
1055
  }
1053
- const depositCollateralIx = fromSubAccountId != null
1056
+ const depositCollateralIx = isFromSubaccount
1054
1057
  ? await this.getTransferDepositIx(amount, marketIndex, fromSubAccountId, subAccountId)
1055
1058
  : await this.getDepositInstruction(amount, marketIndex, userTokenAccount, subAccountId, false, false);
1056
1059
  if (subAccountId === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.34.1-beta.3",
3
+ "version": "2.34.1-beta.5",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
package/src/dlob/DLOB.ts CHANGED
@@ -930,18 +930,9 @@ export class DLOB {
930
930
  }
931
931
 
932
932
  // All bids/asks that can expire
933
- const bidGenerators = [
934
- nodeLists.takingLimit.bid.getGenerator(),
935
- nodeLists.restingLimit.bid.getGenerator(),
936
- nodeLists.floatingLimit.bid.getGenerator(),
937
- nodeLists.market.bid.getGenerator(),
938
- ];
939
- const askGenerators = [
940
- nodeLists.takingLimit.ask.getGenerator(),
941
- nodeLists.restingLimit.ask.getGenerator(),
942
- nodeLists.floatingLimit.ask.getGenerator(),
943
- nodeLists.market.ask.getGenerator(),
944
- ];
933
+ // dont try to expire limit orders with tif as its inefficient use of blockspace
934
+ const bidGenerators = [nodeLists.market.bid.getGenerator()];
935
+ const askGenerators = [nodeLists.market.ask.getGenerator()];
945
936
 
946
937
  for (const bidGenerator of bidGenerators) {
947
938
  for (const bid of bidGenerator) {
@@ -1782,8 +1782,13 @@ export class DriftClient {
1782
1782
 
1783
1783
  const authority = this.wallet.publicKey;
1784
1784
 
1785
+ const isFromSubaccount =
1786
+ fromSubAccountId !== null &&
1787
+ fromSubAccountId !== undefined &&
1788
+ !isNaN(fromSubAccountId);
1789
+
1785
1790
  const createWSOLTokenAccount =
1786
- isSolMarket && userTokenAccount.equals(authority);
1791
+ isSolMarket && userTokenAccount.equals(authority) && !isFromSubaccount;
1787
1792
 
1788
1793
  if (createWSOLTokenAccount) {
1789
1794
  const {
@@ -1801,22 +1806,21 @@ export class DriftClient {
1801
1806
  signers.forEach((signer) => additionalSigners.push(signer));
1802
1807
  }
1803
1808
 
1804
- const depositCollateralIx =
1805
- fromSubAccountId != null
1806
- ? await this.getTransferDepositIx(
1807
- amount,
1808
- marketIndex,
1809
- fromSubAccountId,
1810
- subAccountId
1811
- )
1812
- : await this.getDepositInstruction(
1813
- amount,
1814
- marketIndex,
1815
- userTokenAccount,
1816
- subAccountId,
1817
- false,
1818
- false
1819
- );
1809
+ const depositCollateralIx = isFromSubaccount
1810
+ ? await this.getTransferDepositIx(
1811
+ amount,
1812
+ marketIndex,
1813
+ fromSubAccountId,
1814
+ subAccountId
1815
+ )
1816
+ : await this.getDepositInstruction(
1817
+ amount,
1818
+ marketIndex,
1819
+ userTokenAccount,
1820
+ subAccountId,
1821
+ false,
1822
+ false
1823
+ );
1820
1824
 
1821
1825
  if (subAccountId === 0) {
1822
1826
  if (