@drift-labs/sdk 2.159.0-beta.0 → 2.159.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.159.0-beta.0
1
+ 2.159.0-beta.1
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Channel } from '@pythnetwork/pyth-lazer-sdk';
2
+ import { Channel, PriceFeedProperty } from '@pythnetwork/pyth-lazer-sdk';
3
3
  import { DriftEnv } from '../config';
4
4
  /**
5
5
  * Configuration for a group of Pyth Lazer price feeds.
@@ -33,6 +33,7 @@ export declare class PythLazerSubscriber {
33
33
  isUnsubscribing: boolean;
34
34
  marketIndextoPriceFeedIdChunk: Map<number, number[]>;
35
35
  marketIndextoPriceFeedId: Map<number, number>;
36
+ private readonly feedProperties;
36
37
  /**
37
38
  * Creates a new PythLazerSubscriber instance.
38
39
  * @param endpoints - Array of WebSocket endpoint URLs for Pyth Lazer
@@ -41,8 +42,9 @@ export declare class PythLazerSubscriber {
41
42
  * @param env - Drift environment (mainnet-beta, devnet, etc.)
42
43
  * @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
43
44
  * @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
45
+ * @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
44
46
  */
45
- constructor(endpoints: string[], token: string, priceFeedArrays: PythLazerPriceFeedArray[], env?: DriftEnv, resubTimeoutMs?: number, sdkLogging?: boolean);
47
+ constructor(endpoints: string[], token: string, priceFeedArrays: PythLazerPriceFeedArray[], env?: DriftEnv, resubTimeoutMs?: number, sdkLogging?: boolean, feedProperties?: PriceFeedProperty[]);
46
48
  private fetchSymbolsIfNeeded;
47
49
  private filterStableFeeds;
48
50
  /**
@@ -16,8 +16,14 @@ class PythLazerSubscriber {
16
16
  * @param env - Drift environment (mainnet-beta, devnet, etc.)
17
17
  * @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
18
18
  * @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
19
+ * @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
19
20
  */
20
- constructor(endpoints, token, priceFeedArrays, env = 'devnet', resubTimeoutMs = 2000, sdkLogging = false) {
21
+ constructor(endpoints, token, priceFeedArrays, env = 'devnet', resubTimeoutMs = 2000, sdkLogging = false, feedProperties = [
22
+ 'price',
23
+ 'bestAskPrice',
24
+ 'bestBidPrice',
25
+ 'exponent',
26
+ ]) {
21
27
  this.endpoints = endpoints;
22
28
  this.token = token;
23
29
  this.priceFeedArrays = priceFeedArrays;
@@ -33,6 +39,11 @@ class PythLazerSubscriber {
33
39
  this.isUnsubscribing = false;
34
40
  this.marketIndextoPriceFeedIdChunk = new Map();
35
41
  this.marketIndextoPriceFeedId = new Map();
42
+ this.feedProperties = [...feedProperties];
43
+ if (!this.feedProperties.includes('price') ||
44
+ !this.feedProperties.includes('exponent')) {
45
+ throw new Error("feedProperties must include both 'price' and 'exponent' for getPriceFromMarketIndex to work");
46
+ }
36
47
  const markets = perpMarkets_1.PerpMarkets[env].filter((market) => market.pythLazerId !== undefined);
37
48
  this.allSubscribedIds = this.priceFeedArrays
38
49
  .map((array) => array.priceFeedIds)
@@ -171,7 +182,7 @@ class PythLazerSubscriber {
171
182
  type: 'subscribe',
172
183
  subscriptionId,
173
184
  priceFeedIds: filteredFeedIds,
174
- properties: ['price', 'bestAskPrice', 'bestBidPrice', 'exponent'],
185
+ properties: this.feedProperties,
175
186
  formats: ['solana'],
176
187
  deliveryFormat: 'json',
177
188
  channel: (_a = priceFeedArray.channel) !== null && _a !== void 0 ? _a : 'fixed_rate@200ms',
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Channel } from '@pythnetwork/pyth-lazer-sdk';
2
+ import { Channel, PriceFeedProperty } from '@pythnetwork/pyth-lazer-sdk';
3
3
  import { DriftEnv } from '../config';
4
4
  /**
5
5
  * Configuration for a group of Pyth Lazer price feeds.
@@ -33,6 +33,7 @@ export declare class PythLazerSubscriber {
33
33
  isUnsubscribing: boolean;
34
34
  marketIndextoPriceFeedIdChunk: Map<number, number[]>;
35
35
  marketIndextoPriceFeedId: Map<number, number>;
36
+ private readonly feedProperties;
36
37
  /**
37
38
  * Creates a new PythLazerSubscriber instance.
38
39
  * @param endpoints - Array of WebSocket endpoint URLs for Pyth Lazer
@@ -41,8 +42,9 @@ export declare class PythLazerSubscriber {
41
42
  * @param env - Drift environment (mainnet-beta, devnet, etc.)
42
43
  * @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
43
44
  * @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
45
+ * @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
44
46
  */
45
- constructor(endpoints: string[], token: string, priceFeedArrays: PythLazerPriceFeedArray[], env?: DriftEnv, resubTimeoutMs?: number, sdkLogging?: boolean);
47
+ constructor(endpoints: string[], token: string, priceFeedArrays: PythLazerPriceFeedArray[], env?: DriftEnv, resubTimeoutMs?: number, sdkLogging?: boolean, feedProperties?: PriceFeedProperty[]);
46
48
  private fetchSymbolsIfNeeded;
47
49
  private filterStableFeeds;
48
50
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pythLazerSubscriber.d.ts","sourceRoot":"","sources":["../../../src/pyth/pythLazerSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAmB,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,QAAQ,EA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ACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAI/C;;;;OAIG;IACH,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAOhE"}
@@ -16,8 +16,14 @@ class PythLazerSubscriber {
16
16
  * @param env - Drift environment (mainnet-beta, devnet, etc.)
17
17
  * @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
18
18
  * @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
19
+ * @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
19
20
  */
20
- constructor(endpoints, token, priceFeedArrays, env = 'devnet', resubTimeoutMs = 2000, sdkLogging = false) {
21
+ constructor(endpoints, token, priceFeedArrays, env = 'devnet', resubTimeoutMs = 2000, sdkLogging = false, feedProperties = [
22
+ 'price',
23
+ 'bestAskPrice',
24
+ 'bestBidPrice',
25
+ 'exponent',
26
+ ]) {
21
27
  this.endpoints = endpoints;
22
28
  this.token = token;
23
29
  this.priceFeedArrays = priceFeedArrays;
@@ -33,6 +39,11 @@ class PythLazerSubscriber {
33
39
  this.isUnsubscribing = false;
34
40
  this.marketIndextoPriceFeedIdChunk = new Map();
35
41
  this.marketIndextoPriceFeedId = new Map();
42
+ this.feedProperties = [...feedProperties];
43
+ if (!this.feedProperties.includes('price') ||
44
+ !this.feedProperties.includes('exponent')) {
45
+ throw new Error("feedProperties must include both 'price' and 'exponent' for getPriceFromMarketIndex to work");
46
+ }
36
47
  const markets = perpMarkets_1.PerpMarkets[env].filter((market) => market.pythLazerId !== undefined);
37
48
  this.allSubscribedIds = this.priceFeedArrays
38
49
  .map((array) => array.priceFeedIds)
@@ -171,7 +182,7 @@ class PythLazerSubscriber {
171
182
  type: 'subscribe',
172
183
  subscriptionId,
173
184
  priceFeedIds: filteredFeedIds,
174
- properties: ['price', 'bestAskPrice', 'bestBidPrice', 'exponent'],
185
+ properties: this.feedProperties,
175
186
  formats: ['solana'],
176
187
  deliveryFormat: 'json',
177
188
  channel: (_a = priceFeedArray.channel) !== null && _a !== void 0 ? _a : 'fixed_rate@200ms',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.159.0-beta.0",
3
+ "version": "2.159.0-beta.1",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "module": "./lib/browser/index.js",
@@ -1,4 +1,8 @@
1
- import { Channel, PythLazerClient } from '@pythnetwork/pyth-lazer-sdk';
1
+ import {
2
+ Channel,
3
+ PriceFeedProperty,
4
+ PythLazerClient,
5
+ } from '@pythnetwork/pyth-lazer-sdk';
2
6
  import { DriftEnv } from '../config';
3
7
  import { PerpMarkets } from '../constants/perpMarkets';
4
8
 
@@ -39,6 +43,8 @@ export class PythLazerSubscriber {
39
43
  marketIndextoPriceFeedIdChunk: Map<number, number[]> = new Map();
40
44
  marketIndextoPriceFeedId: Map<number, number> = new Map();
41
45
 
46
+ private readonly feedProperties: PriceFeedProperty[];
47
+
42
48
  /**
43
49
  * Creates a new PythLazerSubscriber instance.
44
50
  * @param endpoints - Array of WebSocket endpoint URLs for Pyth Lazer
@@ -47,6 +53,7 @@ export class PythLazerSubscriber {
47
53
  * @param env - Drift environment (mainnet-beta, devnet, etc.)
48
54
  * @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
49
55
  * @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
56
+ * @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
50
57
  */
51
58
  constructor(
52
59
  private endpoints: string[],
@@ -54,8 +61,23 @@ export class PythLazerSubscriber {
54
61
  private priceFeedArrays: PythLazerPriceFeedArray[],
55
62
  env: DriftEnv = 'devnet',
56
63
  private resubTimeoutMs: number = 2000,
57
- private sdkLogging: boolean = false
64
+ private sdkLogging: boolean = false,
65
+ feedProperties: PriceFeedProperty[] = [
66
+ 'price',
67
+ 'bestAskPrice',
68
+ 'bestBidPrice',
69
+ 'exponent',
70
+ ]
58
71
  ) {
72
+ this.feedProperties = [...feedProperties];
73
+ if (
74
+ !this.feedProperties.includes('price') ||
75
+ !this.feedProperties.includes('exponent')
76
+ ) {
77
+ throw new Error(
78
+ "feedProperties must include both 'price' and 'exponent' for getPriceFromMarketIndex to work"
79
+ );
80
+ }
59
81
  const markets = PerpMarkets[env].filter(
60
82
  (market) => market.pythLazerId !== undefined
61
83
  );
@@ -240,7 +262,7 @@ export class PythLazerSubscriber {
240
262
  type: 'subscribe',
241
263
  subscriptionId,
242
264
  priceFeedIds: filteredFeedIds,
243
- properties: ['price', 'bestAskPrice', 'bestBidPrice', 'exponent'],
265
+ properties: this.feedProperties,
244
266
  formats: ['solana'],
245
267
  deliveryFormat: 'json',
246
268
  channel: priceFeedArray.channel ?? ('fixed_rate@200ms' as Channel),