@drift-labs/sdk 2.42.0-beta.9 → 2.43.0-beta.0

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.42.0-beta.9
1
+ 2.43.0-beta.0
package/bun.lockb CHANGED
Binary file
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Commitment, Connection, PublicKey } from '@solana/web3.js';
4
3
  import { BufferAndSlot } from './types';
5
4
  type AccountToLoad = {
@@ -13,7 +12,7 @@ export declare class BulkAccountLoader {
13
12
  accountsToLoad: Map<string, AccountToLoad>;
14
13
  bufferAndSlotMap: Map<string, BufferAndSlot>;
15
14
  errorCallbacks: Map<string, (e: any) => void>;
16
- intervalId?: NodeJS.Timer;
15
+ intervalId?: ReturnType<typeof setTimeout>;
17
16
  loadPromise?: Promise<void>;
18
17
  loadPromiseResolver: () => void;
19
18
  lastTimeLoadingPromiseCleared: number;
package/lib/config.d.ts CHANGED
@@ -14,6 +14,7 @@ type DriftConfig = {
14
14
  PERP_MARKETS: PerpMarketConfig[];
15
15
  SPOT_MARKETS: SpotMarketConfig[];
16
16
  MARKET_LOOKUP_TABLE: string;
17
+ SERUM_LOOKUP_TABLE?: string;
17
18
  };
18
19
  export type DriftEnv = 'devnet' | 'mainnet-beta';
19
20
  export declare const DRIFT_PROGRAM_ID = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH";
package/lib/config.js CHANGED
@@ -30,6 +30,7 @@ exports.configs = {
30
30
  PERP_MARKETS: perpMarkets_1.MainnetPerpMarkets,
31
31
  SPOT_MARKETS: spotMarkets_1.MainnetSpotMarkets,
32
32
  MARKET_LOOKUP_TABLE: 'D9cnvzswDikQDf53k4HpQ3KJ9y1Fv3HGGDFYMXnK5T6c',
33
+ SERUM_LOOKUP_TABLE: 'GPZkp76cJtNL2mphCvT6FXkJCVPpouidnacckR6rzKDN',
33
34
  },
34
35
  };
35
36
  let currentConfig = exports.configs.devnet;
@@ -151,7 +151,27 @@ exports.DevnetPerpMarkets = [
151
151
  baseAssetSymbol: 'HNT',
152
152
  marketIndex: 14,
153
153
  oracle: new web3_js_1.PublicKey('6Eg8YdfFJQF2HHonzPUBSCCmyUEhrStg9VBLK957sBe6'),
154
- launchTs: 16922949550000,
154
+ launchTs: 1692294955000,
155
+ oracleSource: __1.OracleSource.PYTH,
156
+ },
157
+ {
158
+ fullName: 'INJ',
159
+ category: ['L1', 'Exchange'],
160
+ symbol: 'INJ-PERP',
161
+ baseAssetSymbol: 'INJ',
162
+ marketIndex: 15,
163
+ oracle: new web3_js_1.PublicKey('44uRsNnT35kjkscSu59MxRr9CfkLZWf6gny8bWqUbVxE'),
164
+ launchTs: 1698074659000,
165
+ oracleSource: __1.OracleSource.PYTH,
166
+ },
167
+ {
168
+ fullName: 'LINK',
169
+ category: ['Oracle'],
170
+ symbol: 'LINK-PERP',
171
+ baseAssetSymbol: 'LINK',
172
+ marketIndex: 16,
173
+ oracle: new web3_js_1.PublicKey('9sGidS4qUXS2WvHZFhzw4df1jNd5TvUGZXZVsSjXo7UF'),
174
+ launchTs: 1698074659000,
155
175
  oracleSource: __1.OracleSource.PYTH,
156
176
  },
157
177
  ];
@@ -303,7 +323,27 @@ exports.MainnetPerpMarkets = [
303
323
  baseAssetSymbol: 'HNT',
304
324
  marketIndex: 14,
305
325
  oracle: new web3_js_1.PublicKey('7moA1i5vQUpfDwSpK6Pw9s56ahB7WFGidtbL2ujWrVvm'),
306
- launchTs: 16922949550000,
326
+ launchTs: 1692294955000,
327
+ oracleSource: __1.OracleSource.PYTH,
328
+ },
329
+ {
330
+ fullName: 'INJ',
331
+ category: ['L1', 'Exchange'],
332
+ symbol: 'INJ-PERP',
333
+ baseAssetSymbol: 'INJ',
334
+ marketIndex: 15,
335
+ oracle: new web3_js_1.PublicKey('9EdtbaivHQYA4Nh3XzGR6DwRaoorqXYnmpfsnFhvwuVj'),
336
+ launchTs: 1698074659000,
337
+ oracleSource: __1.OracleSource.PYTH,
338
+ },
339
+ {
340
+ fullName: 'LINK',
341
+ category: ['Oracle'],
342
+ symbol: 'LINK-PERP',
343
+ baseAssetSymbol: 'LINK',
344
+ marketIndex: 16,
345
+ oracle: new web3_js_1.PublicKey('ALdkqQDMfHNg77oCNskfX751kHys4KE7SFuZzuKaN536'),
346
+ launchTs: 1698074659000,
307
347
  oracleSource: __1.OracleSource.PYTH,
308
348
  },
309
349
  ];
@@ -116,9 +116,16 @@ export declare class DriftClient {
116
116
  getNextSubAccountId(): Promise<number>;
117
117
  initializeReferrerName(name: string): Promise<TransactionSignature>;
118
118
  updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>;
119
- updateUserCustomMarginRatio(marginRatio: number, subAccountId?: number): Promise<TransactionSignature>;
119
+ updateUserCustomMarginRatio(updates: {
120
+ marginRatio: number;
121
+ subAccountId: number;
122
+ }[]): Promise<TransactionSignature>;
123
+ getUpdateUserCustomMarginRatioIx(marginRatio: number, subAccountId?: number): Promise<TransactionInstruction>;
120
124
  getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
121
- updateUserMarginTradingEnabled(marginTradingEnabled: boolean, subAccountId?: number): Promise<TransactionSignature>;
125
+ updateUserMarginTradingEnabled(updates: {
126
+ marginTradingEnabled: boolean;
127
+ subAccountId: number;
128
+ }[]): Promise<TransactionSignature>;
122
129
  updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>;
123
130
  fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
124
131
  getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
@@ -522,15 +522,25 @@ class DriftClient {
522
522
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
523
523
  return txSig;
524
524
  }
525
- async updateUserCustomMarginRatio(marginRatio, subAccountId = 0) {
526
- const tx = await this.program.transaction.updateUserCustomMarginRatio(subAccountId, marginRatio, {
525
+ async updateUserCustomMarginRatio(updates) {
526
+ const ixs = await Promise.all(updates.map(async ({ marginRatio, subAccountId }) => {
527
+ const ix = await this.getUpdateUserCustomMarginRatioIx(marginRatio, subAccountId);
528
+ return ix;
529
+ }));
530
+ const tx = await this.buildTransaction(ixs, this.txParams);
531
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
532
+ return txSig;
533
+ }
534
+ async getUpdateUserCustomMarginRatioIx(marginRatio, subAccountId = 0) {
535
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
536
+ await this.addUser(subAccountId, this.wallet.publicKey);
537
+ const ix = this.program.instruction.updateUserCustomMarginRatio(subAccountId, marginRatio, {
527
538
  accounts: {
528
- user: await this.getUserAccountPublicKey(),
539
+ user: userAccountPublicKey,
529
540
  authority: this.wallet.publicKey,
530
541
  },
531
542
  });
532
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
533
- return txSig;
543
+ return ix;
534
544
  }
535
545
  async getUpdateUserMarginTradingEnabledIx(marginTradingEnabled, subAccountId = 0, userAccountPublicKey) {
536
546
  const userAccountPublicKeyToUse = userAccountPublicKey ||
@@ -553,19 +563,11 @@ class DriftClient {
553
563
  remainingAccounts,
554
564
  });
555
565
  }
556
- async updateUserMarginTradingEnabled(marginTradingEnabled, subAccountId = 0) {
557
- const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
558
- await this.addUser(subAccountId, this.wallet.publicKey);
559
- const remainingAccounts = this.getRemainingAccounts({
560
- userAccounts: [this.getUserAccount(subAccountId)],
561
- });
562
- const tx = await this.program.transaction.updateUserMarginTradingEnabled(subAccountId, marginTradingEnabled, {
563
- accounts: {
564
- user: userAccountPublicKey,
565
- authority: this.wallet.publicKey,
566
- },
567
- remainingAccounts,
568
- });
566
+ async updateUserMarginTradingEnabled(updates) {
567
+ const ixs = await Promise.all(updates.map(async ({ marginTradingEnabled, subAccountId }) => {
568
+ return await this.getUpdateUserMarginTradingEnabledIx(marginTradingEnabled, subAccountId);
569
+ }));
570
+ const tx = await this.buildTransaction(ixs, this.txParams);
569
571
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
570
572
  return txSig;
571
573
  }
@@ -80,6 +80,8 @@ class LogParser {
80
80
  }
81
81
  parseEventsFromLogs(event) {
82
82
  const records = [];
83
+ if (!event.logs)
84
+ return records;
83
85
  // @ts-ignore
84
86
  const eventGenerator = this.program._events._eventParser.parseLogs(event.logs, false);
85
87
  let runningEventIndex = 0;