@drift-labs/sdk 2.142.0-beta.2 → 2.142.0-beta.3

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.142.0-beta.2
1
+ 2.142.0-beta.3
@@ -1,14 +1,19 @@
1
1
  import { WebSocketDriftClientAccountSubscriber } from './webSocketDriftClientAccountSubscriber';
2
2
  import { OracleInfo } from '../oracles/types';
3
3
  import { Program } from '@coral-xyz/anchor';
4
- import { DelistedMarketSetting, GrpcConfigs, ResubOpts } from './types';
4
+ import { DataAndSlot, DelistedMarketSetting, GrpcConfigs, ResubOpts } from './types';
5
+ import { PerpMarketAccount, SpotMarketAccount } from '../types';
5
6
  export declare class grpcDriftClientAccountSubscriberV2 extends WebSocketDriftClientAccountSubscriber {
6
7
  private grpcConfigs;
7
8
  private perpMarketsSubscriber?;
8
9
  private spotMarketsSubscriber?;
9
10
  private oracleMultiSubscriber?;
11
+ private perpMarketIndexToAccountPubkeyMap;
12
+ private spotMarketIndexToAccountPubkeyMap;
10
13
  constructor(grpcConfigs: GrpcConfigs, program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], shouldFindAllMarketsAndOracles: boolean, delistedMarketSetting: DelistedMarketSetting, resubOpts?: ResubOpts);
11
14
  subscribe(): Promise<boolean>;
15
+ getMarketAccountAndSlot(marketIndex: number): DataAndSlot<PerpMarketAccount> | undefined;
16
+ getSpotMarketAccountAndSlot(marketIndex: number): DataAndSlot<SpotMarketAccount> | undefined;
12
17
  subscribeToPerpMarketAccounts(): Promise<boolean>;
13
18
  subscribeToSpotMarketAccounts(): Promise<boolean>;
14
19
  subscribeToOracles(): Promise<boolean>;
@@ -11,6 +11,8 @@ const oracleId_1 = require("../oracles/oracleId");
11
11
  class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber {
12
12
  constructor(grpcConfigs, program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts) {
13
13
  super(program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts);
14
+ this.perpMarketIndexToAccountPubkeyMap = new Map();
15
+ this.spotMarketIndexToAccountPubkeyMap = new Map();
14
16
  this.grpcConfigs = grpcConfigs;
15
17
  }
16
18
  async subscribe() {
@@ -59,8 +61,23 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
59
61
  this.removeInitialData();
60
62
  return true;
61
63
  }
64
+ getMarketAccountAndSlot(marketIndex) {
65
+ var _a;
66
+ return (_a = this.perpMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountData(this.perpMarketIndexToAccountPubkeyMap.get(marketIndex));
67
+ }
68
+ getSpotMarketAccountAndSlot(marketIndex) {
69
+ var _a;
70
+ return (_a = this.spotMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountData(this.spotMarketIndexToAccountPubkeyMap.get(marketIndex));
71
+ }
62
72
  async subscribeToPerpMarketAccounts() {
63
- const perpMarketPubkeys = await Promise.all(this.perpMarketIndexes.map((marketIndex) => (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex)));
73
+ const perpMarketIndexToAccountPubkeys = await Promise.all(this.perpMarketIndexes.map(async (marketIndex) => [
74
+ marketIndex,
75
+ await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex),
76
+ ]));
77
+ for (const [marketIndex, accountPubkey,] of perpMarketIndexToAccountPubkeys) {
78
+ this.perpMarketIndexToAccountPubkeyMap.set(marketIndex, accountPubkey);
79
+ }
80
+ const perpMarketPubkeys = perpMarketIndexToAccountPubkeys.map(([_, accountPubkey]) => accountPubkey);
64
81
  this.perpMarketsSubscriber =
65
82
  await grpcMultiAccountSubscriber_1.grpcMultiAccountSubscriber.create(this.grpcConfigs, 'perpMarket', this.program, undefined, this.resubOpts, undefined, async () => {
66
83
  var _a;
@@ -74,6 +91,9 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
74
91
  console.error('Perp markets resubscribe failed:', e);
75
92
  }
76
93
  });
94
+ for (const data of this.initialPerpMarketAccountData.values()) {
95
+ this.perpMarketsSubscriber.setAccountData(data.pubkey, data);
96
+ }
77
97
  await this.perpMarketsSubscriber.subscribe(perpMarketPubkeys, (_accountId, data) => {
78
98
  this.eventEmitter.emit('perpMarketAccountUpdate', data);
79
99
  this.eventEmitter.emit('update');
@@ -81,7 +101,14 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
81
101
  return true;
82
102
  }
83
103
  async subscribeToSpotMarketAccounts() {
84
- const spotMarketPubkeys = await Promise.all(this.spotMarketIndexes.map((marketIndex) => (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex)));
104
+ const spotMarketIndexToAccountPubkeys = await Promise.all(this.spotMarketIndexes.map(async (marketIndex) => [
105
+ marketIndex,
106
+ await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
107
+ ]));
108
+ for (const [marketIndex, accountPubkey,] of spotMarketIndexToAccountPubkeys) {
109
+ this.spotMarketIndexToAccountPubkeyMap.set(marketIndex, accountPubkey);
110
+ }
111
+ const spotMarketPubkeys = spotMarketIndexToAccountPubkeys.map(([_, accountPubkey]) => accountPubkey);
85
112
  this.spotMarketsSubscriber =
86
113
  await grpcMultiAccountSubscriber_1.grpcMultiAccountSubscriber.create(this.grpcConfigs, 'spotMarket', this.program, undefined, this.resubOpts, undefined, async () => {
87
114
  var _a;
@@ -95,6 +122,9 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
95
122
  console.error('Spot markets resubscribe failed:', e);
96
123
  }
97
124
  });
125
+ for (const data of this.initialSpotMarketAccountData.values()) {
126
+ this.spotMarketsSubscriber.setAccountData(data.pubkey, data);
127
+ }
98
128
  await this.spotMarketsSubscriber.subscribe(spotMarketPubkeys, (_accountId, data) => {
99
129
  this.eventEmitter.emit('spotMarketAccountUpdate', data);
100
130
  this.eventEmitter.emit('update');
@@ -136,6 +166,9 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
136
166
  console.error('Oracle resubscribe failed:', e);
137
167
  }
138
168
  });
169
+ for (const data of this.initialOraclePriceData.entries()) {
170
+ this.oracleMultiSubscriber.setAccountData(new web3_js_1.PublicKey(data[0]), data[1]);
171
+ }
139
172
  await this.oracleMultiSubscriber.subscribe(oraclePubkeys, (accountId, data) => {
140
173
  const source = pubkeyToSource.get(accountId.toBase58());
141
174
  this.eventEmitter.emit('oraclePriceUpdate', accountId, source, data);
@@ -3,7 +3,7 @@
3
3
  import { Program } from '@coral-xyz/anchor';
4
4
  import { Context, PublicKey } from '@solana/web3.js';
5
5
  import { Client } from '../isomorphic/grpc';
6
- import { GrpcConfigs, ResubOpts } from './types';
6
+ import { DataAndSlot, GrpcConfigs, ResubOpts } from './types';
7
7
  export declare class grpcMultiAccountSubscriber<T> {
8
8
  private client;
9
9
  private stream;
@@ -19,8 +19,11 @@ export declare class grpcMultiAccountSubscriber<T> {
19
19
  private receivingData;
20
20
  private subscribedAccounts;
21
21
  private onChangeMap;
22
+ private dataMap;
22
23
  private constructor();
23
24
  static create<U>(grpcConfigs: GrpcConfigs, accountName: string, program: Program, decodeBuffer?: (buffer: Buffer, pubkey?: string) => U, resubOpts?: ResubOpts, clientProp?: Client, onUnsubscribe?: () => Promise<void>): Promise<grpcMultiAccountSubscriber<U>>;
25
+ setAccountData(accountPubkey: PublicKey, data: T, slot?: number): void;
26
+ getAccountData(accountPubkey: PublicKey): DataAndSlot<T> | undefined;
24
27
  subscribe(accounts: PublicKey[], onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void): Promise<void>;
25
28
  addAccounts(accounts: PublicKey[]): Promise<void>;
26
29
  removeAccounts(accounts: PublicKey[]): Promise<void>;
@@ -37,6 +37,7 @@ class grpcMultiAccountSubscriber {
37
37
  this.receivingData = false;
38
38
  this.subscribedAccounts = new Set();
39
39
  this.onChangeMap = new Map();
40
+ this.dataMap = new Map();
40
41
  this.client = client;
41
42
  this.commitmentLevel = commitmentLevel;
42
43
  this.accountName = accountName;
@@ -55,6 +56,12 @@ class grpcMultiAccountSubscriber {
55
56
  (_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : grpc_1.CommitmentLevel.CONFIRMED;
56
57
  return new grpcMultiAccountSubscriber(client, commitmentLevel, accountName, program, decodeBuffer, resubOpts, onUnsubscribe);
57
58
  }
59
+ setAccountData(accountPubkey, data, slot) {
60
+ this.dataMap.set(accountPubkey.toBase58(), { data, slot });
61
+ }
62
+ getAccountData(accountPubkey) {
63
+ return this.dataMap.get(accountPubkey.toBase58());
64
+ }
58
65
  async subscribe(accounts, onChange) {
59
66
  if (this.listenerId != null || this.isUnsubscribing) {
60
67
  return;
@@ -1,14 +1,19 @@
1
1
  import { WebSocketDriftClientAccountSubscriber } from './webSocketDriftClientAccountSubscriber';
2
2
  import { OracleInfo } from '../oracles/types';
3
3
  import { Program } from '@coral-xyz/anchor';
4
- import { DelistedMarketSetting, GrpcConfigs, ResubOpts } from './types';
4
+ import { DataAndSlot, DelistedMarketSetting, GrpcConfigs, ResubOpts } from './types';
5
+ import { PerpMarketAccount, SpotMarketAccount } from '../types';
5
6
  export declare class grpcDriftClientAccountSubscriberV2 extends WebSocketDriftClientAccountSubscriber {
6
7
  private grpcConfigs;
7
8
  private perpMarketsSubscriber?;
8
9
  private spotMarketsSubscriber?;
9
10
  private oracleMultiSubscriber?;
11
+ private perpMarketIndexToAccountPubkeyMap;
12
+ private spotMarketIndexToAccountPubkeyMap;
10
13
  constructor(grpcConfigs: GrpcConfigs, program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], shouldFindAllMarketsAndOracles: boolean, delistedMarketSetting: DelistedMarketSetting, resubOpts?: ResubOpts);
11
14
  subscribe(): Promise<boolean>;
15
+ getMarketAccountAndSlot(marketIndex: number): DataAndSlot<PerpMarketAccount> | undefined;
16
+ getSpotMarketAccountAndSlot(marketIndex: number): DataAndSlot<SpotMarketAccount> | undefined;
12
17
  subscribeToPerpMarketAccounts(): Promise<boolean>;
13
18
  subscribeToSpotMarketAccounts(): Promise<boolean>;
14
19
  subscribeToOracles(): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"grpcDriftClientAccountSubscriberV2.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcDriftClientAccountSubscriberV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAChG,OAAO,EAAE,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAQ5C,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMxE,qBAAa,kCAAmC,SAAQ,qCAAqC;IAC5F,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,qBAAqB,CAAC,CAAgD;IAC9E,OAAO,CAAC,qBAAqB,CAAC,CAAgD;IAC9E,OAAO,CAAC,qBAAqB,CAAC,CAA8C;gBAG3E,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,MAAM,EAAE,EAC3B,iBAAiB,EAAE,MAAM,EAAE,EAC3B,WAAW,EAAE,UAAU,EAAE,EACzB,8BAA8B,EAAE,OAAO,EACvC,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,CAAC,EAAE,SAAS;IAcT,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAiF3B,6BAA6B,IAAI,OAAO,CAAC,OAAO,CAAC;IA0CjD,6BAA6B,IAAI,OAAO,CAAC,OAAO,CAAC;IA0CjD,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAoE/C,sBAAsB,IAAI,OAAO,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,OAAO,CAAC;IA2DjD,6BAA6B,IAAI,OAAO,CAAC,OAAO,CAAC;IA2DjD,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IA2E/C,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAO3C"}
@@ -11,6 +11,8 @@ const oracleId_1 = require("../oracles/oracleId");
11
11
  class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber {
12
12
  constructor(grpcConfigs, program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts) {
13
13
  super(program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts);
14
+ this.perpMarketIndexToAccountPubkeyMap = new Map();
15
+ this.spotMarketIndexToAccountPubkeyMap = new Map();
14
16
  this.grpcConfigs = grpcConfigs;
15
17
  }
16
18
  async subscribe() {
@@ -59,8 +61,23 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
59
61
  this.removeInitialData();
60
62
  return true;
61
63
  }
64
+ getMarketAccountAndSlot(marketIndex) {
65
+ var _a;
66
+ return (_a = this.perpMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountData(this.perpMarketIndexToAccountPubkeyMap.get(marketIndex));
67
+ }
68
+ getSpotMarketAccountAndSlot(marketIndex) {
69
+ var _a;
70
+ return (_a = this.spotMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountData(this.spotMarketIndexToAccountPubkeyMap.get(marketIndex));
71
+ }
62
72
  async subscribeToPerpMarketAccounts() {
63
- const perpMarketPubkeys = await Promise.all(this.perpMarketIndexes.map((marketIndex) => (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex)));
73
+ const perpMarketIndexToAccountPubkeys = await Promise.all(this.perpMarketIndexes.map(async (marketIndex) => [
74
+ marketIndex,
75
+ await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex),
76
+ ]));
77
+ for (const [marketIndex, accountPubkey,] of perpMarketIndexToAccountPubkeys) {
78
+ this.perpMarketIndexToAccountPubkeyMap.set(marketIndex, accountPubkey);
79
+ }
80
+ const perpMarketPubkeys = perpMarketIndexToAccountPubkeys.map(([_, accountPubkey]) => accountPubkey);
64
81
  this.perpMarketsSubscriber =
65
82
  await grpcMultiAccountSubscriber_1.grpcMultiAccountSubscriber.create(this.grpcConfigs, 'perpMarket', this.program, undefined, this.resubOpts, undefined, async () => {
66
83
  var _a;
@@ -74,6 +91,9 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
74
91
  console.error('Perp markets resubscribe failed:', e);
75
92
  }
76
93
  });
94
+ for (const data of this.initialPerpMarketAccountData.values()) {
95
+ this.perpMarketsSubscriber.setAccountData(data.pubkey, data);
96
+ }
77
97
  await this.perpMarketsSubscriber.subscribe(perpMarketPubkeys, (_accountId, data) => {
78
98
  this.eventEmitter.emit('perpMarketAccountUpdate', data);
79
99
  this.eventEmitter.emit('update');
@@ -81,7 +101,14 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
81
101
  return true;
82
102
  }
83
103
  async subscribeToSpotMarketAccounts() {
84
- const spotMarketPubkeys = await Promise.all(this.spotMarketIndexes.map((marketIndex) => (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex)));
104
+ const spotMarketIndexToAccountPubkeys = await Promise.all(this.spotMarketIndexes.map(async (marketIndex) => [
105
+ marketIndex,
106
+ await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
107
+ ]));
108
+ for (const [marketIndex, accountPubkey,] of spotMarketIndexToAccountPubkeys) {
109
+ this.spotMarketIndexToAccountPubkeyMap.set(marketIndex, accountPubkey);
110
+ }
111
+ const spotMarketPubkeys = spotMarketIndexToAccountPubkeys.map(([_, accountPubkey]) => accountPubkey);
85
112
  this.spotMarketsSubscriber =
86
113
  await grpcMultiAccountSubscriber_1.grpcMultiAccountSubscriber.create(this.grpcConfigs, 'spotMarket', this.program, undefined, this.resubOpts, undefined, async () => {
87
114
  var _a;
@@ -95,6 +122,9 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
95
122
  console.error('Spot markets resubscribe failed:', e);
96
123
  }
97
124
  });
125
+ for (const data of this.initialSpotMarketAccountData.values()) {
126
+ this.spotMarketsSubscriber.setAccountData(data.pubkey, data);
127
+ }
98
128
  await this.spotMarketsSubscriber.subscribe(spotMarketPubkeys, (_accountId, data) => {
99
129
  this.eventEmitter.emit('spotMarketAccountUpdate', data);
100
130
  this.eventEmitter.emit('update');
@@ -136,6 +166,9 @@ class grpcDriftClientAccountSubscriberV2 extends webSocketDriftClientAccountSubs
136
166
  console.error('Oracle resubscribe failed:', e);
137
167
  }
138
168
  });
169
+ for (const data of this.initialOraclePriceData.entries()) {
170
+ this.oracleMultiSubscriber.setAccountData(new web3_js_1.PublicKey(data[0]), data[1]);
171
+ }
139
172
  await this.oracleMultiSubscriber.subscribe(oraclePubkeys, (accountId, data) => {
140
173
  const source = pubkeyToSource.get(accountId.toBase58());
141
174
  this.eventEmitter.emit('oraclePriceUpdate', accountId, source, data);
@@ -3,7 +3,7 @@
3
3
  import { Program } from '@coral-xyz/anchor';
4
4
  import { Context, PublicKey } from '@solana/web3.js';
5
5
  import { Client } from '../isomorphic/grpc';
6
- import { GrpcConfigs, ResubOpts } from './types';
6
+ import { DataAndSlot, GrpcConfigs, ResubOpts } from './types';
7
7
  export declare class grpcMultiAccountSubscriber<T> {
8
8
  private client;
9
9
  private stream;
@@ -19,8 +19,11 @@ export declare class grpcMultiAccountSubscriber<T> {
19
19
  private receivingData;
20
20
  private subscribedAccounts;
21
21
  private onChangeMap;
22
+ private dataMap;
22
23
  private constructor();
23
24
  static create<U>(grpcConfigs: GrpcConfigs, accountName: string, program: Program, decodeBuffer?: (buffer: Buffer, pubkey?: string) => U, resubOpts?: ResubOpts, clientProp?: Client, onUnsubscribe?: () => Promise<void>): Promise<grpcMultiAccountSubscriber<U>>;
25
+ setAccountData(accountPubkey: PublicKey, data: T, slot?: number): void;
26
+ getAccountData(accountPubkey: PublicKey): DataAndSlot<T> | undefined;
24
27
  subscribe(accounts: PublicKey[], onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void): Promise<void>;
25
28
  addAccounts(accounts: PublicKey[]): Promise<void>;
26
29
  removeAccounts(accounts: PublicKey[]): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"grpcMultiAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcMultiAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIrD,OAAO,EACN,MAAM,EAMN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAUjD,qBAAa,0BAA0B,CAAC,CAAC;IACxC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAwD;IACtE,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,cAAc,CAAC,CAAyC;IAChE,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,aAAa,CAAC,CAAsB;IAErC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,UAAS;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAgC;IAClD,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,WAAW,CAGf;IAEJ,OAAO;WAkBa,MAAM,CAAC,CAAC,EAC3B,WAAW,EAAE,WAAW,EACxB,WA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E,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCpD,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IA4ClC,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,UAAU;CAIlB"}
@@ -37,6 +37,7 @@ class grpcMultiAccountSubscriber {
37
37
  this.receivingData = false;
38
38
  this.subscribedAccounts = new Set();
39
39
  this.onChangeMap = new Map();
40
+ this.dataMap = new Map();
40
41
  this.client = client;
41
42
  this.commitmentLevel = commitmentLevel;
42
43
  this.accountName = accountName;
@@ -55,6 +56,12 @@ class grpcMultiAccountSubscriber {
55
56
  (_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : grpc_1.CommitmentLevel.CONFIRMED;
56
57
  return new grpcMultiAccountSubscriber(client, commitmentLevel, accountName, program, decodeBuffer, resubOpts, onUnsubscribe);
57
58
  }
59
+ setAccountData(accountPubkey, data, slot) {
60
+ this.dataMap.set(accountPubkey.toBase58(), { data, slot });
61
+ }
62
+ getAccountData(accountPubkey) {
63
+ return this.dataMap.get(accountPubkey.toBase58());
64
+ }
58
65
  async subscribe(accounts, onChange) {
59
66
  if (this.listenerId != null || this.isUnsubscribing) {
60
67
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.142.0-beta.2",
3
+ "version": "2.142.0-beta.3",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -10,78 +10,124 @@ const GRPC_ENDPOINT = process.env.GRPC_ENDPOINT;
10
10
  const TOKEN = process.env.TOKEN;
11
11
 
12
12
  async function initializeGrpcDriftClientV2() {
13
- const connection = new Connection('https://api.mainnet-beta.solana.com');
14
- const wallet = new Wallet(new Keypair());
15
- dotenv.config({ path: '../' });
16
- const config: DriftClientConfig = {
17
- connection,
18
- wallet,
19
- programID: new PublicKey(DRIFT_PROGRAM_ID),
20
- accountSubscription: {
21
- type: 'grpc',
22
- grpcConfigs: {
23
- endpoint: GRPC_ENDPOINT,
24
- token: TOKEN,
25
- commitmentLevel: 'confirmed' as unknown as CommitmentLevel,
26
- channelOptions: {
27
- 'grpc.keepalive_time_ms': 10_000,
28
- 'grpc.keepalive_timeout_ms': 1_000,
29
- 'grpc.keepalive_permit_without_calls': 1,
30
- },
31
- },
32
- driftClientAccountSubscriber: grpcDriftClientAccountSubscriberV2,
33
- },
34
- perpMarketIndexes: [0, 1, 2], // Example market indexes
35
- spotMarketIndexes: [0, 1, 2], // Example market indexes
36
- oracleInfos: [], // Add oracle information if needed
37
- };
13
+ const connection = new Connection('https://api.mainnet-beta.solana.com');
14
+ const wallet = new Wallet(new Keypair());
15
+ dotenv.config({ path: '../' });
16
+ const config: DriftClientConfig = {
17
+ connection,
18
+ wallet,
19
+ programID: new PublicKey(DRIFT_PROGRAM_ID),
20
+ accountSubscription: {
21
+ type: 'grpc',
22
+ grpcConfigs: {
23
+ endpoint: GRPC_ENDPOINT,
24
+ token: TOKEN,
25
+ commitmentLevel: 'confirmed' as unknown as CommitmentLevel,
26
+ channelOptions: {
27
+ 'grpc.keepalive_time_ms': 10_000,
28
+ 'grpc.keepalive_timeout_ms': 1_000,
29
+ 'grpc.keepalive_permit_without_calls': 1,
30
+ },
31
+ },
32
+ driftClientAccountSubscriber: grpcDriftClientAccountSubscriberV2,
33
+ },
34
+ perpMarketIndexes: [0, 1, 2], // Example market indexes
35
+ spotMarketIndexes: [0, 1, 2], // Example market indexes
36
+ oracleInfos: [], // Add oracle information if needed
37
+ };
38
38
 
39
- const driftClient = new DriftClient(config);
39
+ const driftClient = new DriftClient(config);
40
40
 
41
- let perpMarketUpdateCount = 0;
42
- let spotMarketUpdateCount = 0;
43
- let oraclePriceUpdateCount = 0;
44
- let userAccountUpdateCount = 0;
41
+ let perpMarketUpdateCount = 0;
42
+ let spotMarketUpdateCount = 0;
43
+ let oraclePriceUpdateCount = 0;
44
+ let userAccountUpdateCount = 0;
45
45
 
46
- const updatePromise = new Promise<void>((resolve) => {
47
- driftClient.accountSubscriber.eventEmitter.on('perpMarketAccountUpdate', (data) => {
48
- console.log('Perp market account update:', decodeName(data.name));
49
- perpMarketUpdateCount++;
50
- if (perpMarketUpdateCount >= 10 && spotMarketUpdateCount >= 10 && oraclePriceUpdateCount >= 10 && userAccountUpdateCount >= 2) {
51
- resolve();
52
- }
53
- });
46
+ const updatePromise = new Promise<void>((resolve) => {
47
+ driftClient.accountSubscriber.eventEmitter.on(
48
+ 'perpMarketAccountUpdate',
49
+ (data) => {
50
+ console.log('Perp market account update:', decodeName(data.name));
51
+ const perpMarketData = driftClient.getPerpMarketAccount(
52
+ data.marketIndex
53
+ );
54
+ console.log(
55
+ 'Perp market data market index:',
56
+ perpMarketData?.marketIndex
57
+ );
58
+ perpMarketUpdateCount++;
59
+ if (
60
+ perpMarketUpdateCount >= 10 &&
61
+ spotMarketUpdateCount >= 10 &&
62
+ oraclePriceUpdateCount >= 10 &&
63
+ userAccountUpdateCount >= 2
64
+ ) {
65
+ resolve();
66
+ }
67
+ }
68
+ );
54
69
 
55
- driftClient.accountSubscriber.eventEmitter.on('spotMarketAccountUpdate', (data) => {
56
- console.log('Spot market account update:', decodeName(data.name));
57
- spotMarketUpdateCount++;
58
- if (perpMarketUpdateCount >= 10 && spotMarketUpdateCount >= 10 && oraclePriceUpdateCount >= 10 && userAccountUpdateCount >= 2) {
59
- resolve();
60
- }
61
- });
70
+ driftClient.accountSubscriber.eventEmitter.on(
71
+ 'spotMarketAccountUpdate',
72
+ (data) => {
73
+ console.log('Spot market account update:', decodeName(data.name));
74
+ const spotMarketData = driftClient.getSpotMarketAccount(
75
+ data.marketIndex
76
+ );
77
+ console.log(
78
+ 'Spot market data market index:',
79
+ spotMarketData?.marketIndex
80
+ );
81
+ spotMarketUpdateCount++;
82
+ if (
83
+ perpMarketUpdateCount >= 10 &&
84
+ spotMarketUpdateCount >= 10 &&
85
+ oraclePriceUpdateCount >= 10 &&
86
+ userAccountUpdateCount >= 2
87
+ ) {
88
+ resolve();
89
+ }
90
+ }
91
+ );
62
92
 
63
- driftClient.accountSubscriber.eventEmitter.on('oraclePriceUpdate', (data) => {
64
- console.log('Oracle price update:', data.toBase58());
65
- oraclePriceUpdateCount++;
66
- if (perpMarketUpdateCount >= 10 && spotMarketUpdateCount >= 10 && oraclePriceUpdateCount >= 10 && userAccountUpdateCount >= 2) {
67
- resolve();
68
- }
69
- });
93
+ driftClient.accountSubscriber.eventEmitter.on(
94
+ 'oraclePriceUpdate',
95
+ (data) => {
96
+ console.log('Oracle price update:', data.toBase58());
97
+ oraclePriceUpdateCount++;
98
+ if (
99
+ perpMarketUpdateCount >= 10 &&
100
+ spotMarketUpdateCount >= 10 &&
101
+ oraclePriceUpdateCount >= 10 &&
102
+ userAccountUpdateCount >= 2
103
+ ) {
104
+ resolve();
105
+ }
106
+ }
107
+ );
70
108
 
71
- driftClient.accountSubscriber.eventEmitter.on('userAccountUpdate', (data) => {
72
- console.log('User account update:', decodeName(data.name));
73
- userAccountUpdateCount++;
74
- if (perpMarketUpdateCount >= 10 && spotMarketUpdateCount >= 10 && oraclePriceUpdateCount >= 10 && userAccountUpdateCount >= 2) {
75
- resolve();
76
- }
77
- });
78
- });
109
+ driftClient.accountSubscriber.eventEmitter.on(
110
+ 'userAccountUpdate',
111
+ (data) => {
112
+ console.log('User account update:', decodeName(data.name));
113
+ userAccountUpdateCount++;
114
+ if (
115
+ perpMarketUpdateCount >= 10 &&
116
+ spotMarketUpdateCount >= 10 &&
117
+ oraclePriceUpdateCount >= 10 &&
118
+ userAccountUpdateCount >= 2
119
+ ) {
120
+ resolve();
121
+ }
122
+ }
123
+ );
124
+ });
79
125
 
80
- await driftClient.subscribe();
81
- console.log('DriftClient initialized and listening for updates.');
126
+ await driftClient.subscribe();
127
+ console.log('DriftClient initialized and listening for updates.');
82
128
 
83
- await updatePromise;
84
- console.log('Received required number of updates.');
129
+ await updatePromise;
130
+ console.log('Received required number of updates.');
85
131
  }
86
132
 
87
133
  initializeGrpcDriftClientV2().catch(console.error);
@@ -8,7 +8,12 @@ import {
8
8
  getPerpMarketPublicKey,
9
9
  getSpotMarketPublicKey,
10
10
  } from '../addresses/pda';
11
- import { DelistedMarketSetting, GrpcConfigs, ResubOpts } from './types';
11
+ import {
12
+ DataAndSlot,
13
+ DelistedMarketSetting,
14
+ GrpcConfigs,
15
+ ResubOpts,
16
+ } from './types';
12
17
  import { grpcAccountSubscriber } from './grpcAccountSubscriber';
13
18
  import { grpcMultiAccountSubscriber } from './grpcMultiAccountSubscriber';
14
19
  import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types';
@@ -19,6 +24,8 @@ export class grpcDriftClientAccountSubscriberV2 extends WebSocketDriftClientAcco
19
24
  private perpMarketsSubscriber?: grpcMultiAccountSubscriber<PerpMarketAccount>;
20
25
  private spotMarketsSubscriber?: grpcMultiAccountSubscriber<SpotMarketAccount>;
21
26
  private oracleMultiSubscriber?: grpcMultiAccountSubscriber<OraclePriceData>;
27
+ private perpMarketIndexToAccountPubkeyMap = new Map<number, PublicKey>();
28
+ private spotMarketIndexToAccountPubkeyMap = new Map<number, PublicKey>();
22
29
 
23
30
  constructor(
24
31
  grpcConfigs: GrpcConfigs,
@@ -123,11 +130,39 @@ export class grpcDriftClientAccountSubscriberV2 extends WebSocketDriftClientAcco
123
130
  return true;
124
131
  }
125
132
 
133
+ override getMarketAccountAndSlot(
134
+ marketIndex: number
135
+ ): DataAndSlot<PerpMarketAccount> | undefined {
136
+ return this.perpMarketsSubscriber?.getAccountData(
137
+ this.perpMarketIndexToAccountPubkeyMap.get(marketIndex)
138
+ );
139
+ }
140
+
141
+ override getSpotMarketAccountAndSlot(
142
+ marketIndex: number
143
+ ): DataAndSlot<SpotMarketAccount> | undefined {
144
+ return this.spotMarketsSubscriber?.getAccountData(
145
+ this.spotMarketIndexToAccountPubkeyMap.get(marketIndex)
146
+ );
147
+ }
148
+
126
149
  override async subscribeToPerpMarketAccounts(): Promise<boolean> {
127
- const perpMarketPubkeys = await Promise.all(
128
- this.perpMarketIndexes.map((marketIndex) =>
129
- getPerpMarketPublicKey(this.program.programId, marketIndex)
130
- )
150
+ const perpMarketIndexToAccountPubkeys: Array<[number, PublicKey]> =
151
+ await Promise.all(
152
+ this.perpMarketIndexes.map(async (marketIndex) => [
153
+ marketIndex,
154
+ await getPerpMarketPublicKey(this.program.programId, marketIndex),
155
+ ])
156
+ );
157
+ for (const [
158
+ marketIndex,
159
+ accountPubkey,
160
+ ] of perpMarketIndexToAccountPubkeys) {
161
+ this.perpMarketIndexToAccountPubkeyMap.set(marketIndex, accountPubkey);
162
+ }
163
+
164
+ const perpMarketPubkeys = perpMarketIndexToAccountPubkeys.map(
165
+ ([_, accountPubkey]) => accountPubkey
131
166
  );
132
167
 
133
168
  this.perpMarketsSubscriber =
@@ -151,6 +186,11 @@ export class grpcDriftClientAccountSubscriberV2 extends WebSocketDriftClientAcco
151
186
  }
152
187
  }
153
188
  );
189
+
190
+ for (const data of this.initialPerpMarketAccountData.values()) {
191
+ this.perpMarketsSubscriber.setAccountData(data.pubkey, data);
192
+ }
193
+
154
194
  await this.perpMarketsSubscriber.subscribe(
155
195
  perpMarketPubkeys,
156
196
  (_accountId, data) => {
@@ -166,10 +206,22 @@ export class grpcDriftClientAccountSubscriberV2 extends WebSocketDriftClientAcco
166
206
  }
167
207
 
168
208
  override async subscribeToSpotMarketAccounts(): Promise<boolean> {
169
- const spotMarketPubkeys = await Promise.all(
170
- this.spotMarketIndexes.map((marketIndex) =>
171
- getSpotMarketPublicKey(this.program.programId, marketIndex)
172
- )
209
+ const spotMarketIndexToAccountPubkeys: Array<[number, PublicKey]> =
210
+ await Promise.all(
211
+ this.spotMarketIndexes.map(async (marketIndex) => [
212
+ marketIndex,
213
+ await getSpotMarketPublicKey(this.program.programId, marketIndex),
214
+ ])
215
+ );
216
+ for (const [
217
+ marketIndex,
218
+ accountPubkey,
219
+ ] of spotMarketIndexToAccountPubkeys) {
220
+ this.spotMarketIndexToAccountPubkeyMap.set(marketIndex, accountPubkey);
221
+ }
222
+
223
+ const spotMarketPubkeys = spotMarketIndexToAccountPubkeys.map(
224
+ ([_, accountPubkey]) => accountPubkey
173
225
  );
174
226
 
175
227
  this.spotMarketsSubscriber =
@@ -193,6 +245,11 @@ export class grpcDriftClientAccountSubscriberV2 extends WebSocketDriftClientAcco
193
245
  }
194
246
  }
195
247
  );
248
+
249
+ for (const data of this.initialSpotMarketAccountData.values()) {
250
+ this.spotMarketsSubscriber.setAccountData(data.pubkey, data);
251
+ }
252
+
196
253
  await this.spotMarketsSubscriber.subscribe(
197
254
  spotMarketPubkeys,
198
255
  (_accountId, data) => {
@@ -263,6 +320,13 @@ export class grpcDriftClientAccountSubscriberV2 extends WebSocketDriftClientAcco
263
320
  }
264
321
  );
265
322
 
323
+ for (const data of this.initialOraclePriceData.entries()) {
324
+ this.oracleMultiSubscriber.setAccountData(
325
+ new PublicKey(data[0]),
326
+ data[1]
327
+ );
328
+ }
329
+
266
330
  await this.oracleMultiSubscriber.subscribe(
267
331
  oraclePubkeys,
268
332
  (accountId, data) => {
@@ -11,7 +11,7 @@ import {
11
11
  SubscribeUpdate,
12
12
  createClient,
13
13
  } from '../isomorphic/grpc';
14
- import { GrpcConfigs, ResubOpts } from './types';
14
+ import { DataAndSlot, GrpcConfigs, ResubOpts } from './types';
15
15
 
16
16
  interface AccountInfoLike {
17
17
  owner: PublicKey;
@@ -42,6 +42,8 @@ export class grpcMultiAccountSubscriber<T> {
42
42
  (data: T, context: Context, buffer: Buffer) => void
43
43
  >();
44
44
 
45
+ private dataMap = new Map<string, DataAndSlot<T>>();
46
+
45
47
  private constructor(
46
48
  client: Client,
47
49
  commitmentLevel: CommitmentLevel,
@@ -91,6 +93,14 @@ export class grpcMultiAccountSubscriber<T> {
91
93
  );
92
94
  }
93
95
 
96
+ setAccountData(accountPubkey: PublicKey, data: T, slot?: number): void {
97
+ this.dataMap.set(accountPubkey.toBase58(), { data, slot });
98
+ }
99
+
100
+ getAccountData(accountPubkey: PublicKey): DataAndSlot<T> | undefined {
101
+ return this.dataMap.get(accountPubkey.toBase58());
102
+ }
103
+
94
104
  async subscribe(
95
105
  accounts: PublicKey[],
96
106
  onChange: (