@drift-labs/sdk 2.148.0-beta.0 → 2.148.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.148.0-beta.0
1
+ 2.148.0-beta.1
package/bun.lock CHANGED
@@ -1400,4 +1400,4 @@
1400
1400
 
1401
1401
  "@solana/spl-token-metadata/@solana/codecs/@solana/options/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="],
1402
1402
  }
1403
- }
1403
+ }
@@ -17,6 +17,7 @@ export type ConstituentMapConfig = {
17
17
  };
18
18
  lpPoolId?: number;
19
19
  additionalFilters?: MemcmpFilter[];
20
+ decoder?: 'base64' | 'base64+zstd';
20
21
  };
21
22
  export interface ConstituentMapInterface {
22
23
  subscribe(): Promise<void>;
@@ -39,6 +40,7 @@ export declare class ConstituentMap implements ConstituentMapInterface {
39
40
  private constituentIndexToKeyMap;
40
41
  private spotMarketIndexToKeyMap;
41
42
  private lpPoolId;
43
+ private decoder;
42
44
  constructor(config: ConstituentMapConfig);
43
45
  private getFilters;
44
46
  private decode;
@@ -9,7 +9,7 @@ const pda_1 = require("../addresses/pda");
9
9
  const MAX_CONSTITUENT_SIZE_BYTES = 480; // TODO: update this when account is finalized
10
10
  class ConstituentMap {
11
11
  constructor(config) {
12
- var _a;
12
+ var _a, _b;
13
13
  this.constituentMap = new Map();
14
14
  this.constituentIndexToKeyMap = new Map();
15
15
  this.spotMarketIndexToKeyMap = new Map();
@@ -18,6 +18,7 @@ class ConstituentMap {
18
18
  this.commitment = config.subscriptionConfig.commitment;
19
19
  this.connection = config.connection || this.driftClient.connection;
20
20
  this.lpPoolId = (_a = config.lpPoolId) !== null && _a !== void 0 ? _a : 0;
21
+ this.decoder = (_b = config.decoder) !== null && _b !== void 0 ? _b : 'base64+zstd';
21
22
  if (config.subscriptionConfig.type === 'polling') {
22
23
  this.constituentAccountSubscriber =
23
24
  new pollingConstituentAccountSubscriber_1.PollingConstituentAccountSubscriber(this, this.driftClient.program, config.subscriptionConfig.frequency, config.subscriptionConfig.commitment, this.getFilters());
@@ -51,7 +52,7 @@ class ConstituentMap {
51
52
  {
52
53
  commitment: this.commitment,
53
54
  filters: this.getFilters(),
54
- encoding: 'base64+zstd',
55
+ encoding: this.decoder,
55
56
  withContext: true,
56
57
  },
57
58
  ];
@@ -60,10 +61,16 @@ class ConstituentMap {
60
61
  const rpcResponseAndContext = rpcJSONResponse.result;
61
62
  const slot = rpcResponseAndContext.context.slot;
62
63
  const promises = rpcResponseAndContext.value.map(async (programAccount) => {
63
- const compressedUserData = Buffer.from(programAccount.account.data[0], 'base64');
64
- const decoder = new zstddec_1.ZSTDDecoder();
65
- await decoder.init();
66
- const buffer = Buffer.from(decoder.decode(compressedUserData, MAX_CONSTITUENT_SIZE_BYTES));
64
+ let buffer;
65
+ if (this.decoder === 'base64+zstd') {
66
+ const compressedUserData = Buffer.from(programAccount.account.data[0], 'base64');
67
+ const decoder = new zstddec_1.ZSTDDecoder();
68
+ await decoder.init();
69
+ buffer = Buffer.from(decoder.decode(compressedUserData, MAX_CONSTITUENT_SIZE_BYTES));
70
+ }
71
+ else {
72
+ buffer = Buffer.from(programAccount.account.data[0], 'base64');
73
+ }
67
74
  const key = programAccount.pubkey.toString();
68
75
  const currAccountWithSlot = this.getWithSlot(key);
69
76
  if (currAccountWithSlot) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.147.0",
2
+ "version": "2.148.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -17,6 +17,7 @@ export type ConstituentMapConfig = {
17
17
  };
18
18
  lpPoolId?: number;
19
19
  additionalFilters?: MemcmpFilter[];
20
+ decoder?: 'base64' | 'base64+zstd';
20
21
  };
21
22
  export interface ConstituentMapInterface {
22
23
  subscribe(): Promise<void>;
@@ -39,6 +40,7 @@ export declare class ConstituentMap implements ConstituentMapInterface {
39
40
  private constituentIndexToKeyMap;
40
41
  private spotMarketIndexToKeyMap;
41
42
  private lpPoolId;
43
+ private decoder;
42
44
  constructor(config: ConstituentMapConfig);
43
45
  private getFilters;
44
46
  private decode;
@@ -1 +1 @@
1
- {"version":3,"file":"constituentMap.d.ts","sourceRoot":"","sources":["../../../src/constituentMap/constituentMap.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,UAAU,EACV,YAAY,EAGZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAgC,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAO7C,MAAM,MAAM,oBAAoB,GAAG;IAClC,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,kBAAkB,EACf;QACA,IAAI,EAAE,SAAS,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,UAAU,CAAC;KACvB,GACD;QACA,IAAI,EAAE,WAAW,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;KACvB,CAAC;IACL,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,iBAAiB,CAAC,EAAE,YAAY,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACvC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS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when account is finalized
10
10
  class ConstituentMap {
11
11
  constructor(config) {
12
- var _a;
12
+ var _a, _b;
13
13
  this.constituentMap = new Map();
14
14
  this.constituentIndexToKeyMap = new Map();
15
15
  this.spotMarketIndexToKeyMap = new Map();
@@ -18,6 +18,7 @@ class ConstituentMap {
18
18
  this.commitment = config.subscriptionConfig.commitment;
19
19
  this.connection = config.connection || this.driftClient.connection;
20
20
  this.lpPoolId = (_a = config.lpPoolId) !== null && _a !== void 0 ? _a : 0;
21
+ this.decoder = (_b = config.decoder) !== null && _b !== void 0 ? _b : 'base64+zstd';
21
22
  if (config.subscriptionConfig.type === 'polling') {
22
23
  this.constituentAccountSubscriber =
23
24
  new pollingConstituentAccountSubscriber_1.PollingConstituentAccountSubscriber(this, this.driftClient.program, config.subscriptionConfig.frequency, config.subscriptionConfig.commitment, this.getFilters());
@@ -51,7 +52,7 @@ class ConstituentMap {
51
52
  {
52
53
  commitment: this.commitment,
53
54
  filters: this.getFilters(),
54
- encoding: 'base64+zstd',
55
+ encoding: this.decoder,
55
56
  withContext: true,
56
57
  },
57
58
  ];
@@ -60,10 +61,16 @@ class ConstituentMap {
60
61
  const rpcResponseAndContext = rpcJSONResponse.result;
61
62
  const slot = rpcResponseAndContext.context.slot;
62
63
  const promises = rpcResponseAndContext.value.map(async (programAccount) => {
63
- const compressedUserData = Buffer.from(programAccount.account.data[0], 'base64');
64
- const decoder = new zstddec_1.ZSTDDecoder();
65
- await decoder.init();
66
- const buffer = Buffer.from(decoder.decode(compressedUserData, MAX_CONSTITUENT_SIZE_BYTES));
64
+ let buffer;
65
+ if (this.decoder === 'base64+zstd') {
66
+ const compressedUserData = Buffer.from(programAccount.account.data[0], 'base64');
67
+ const decoder = new zstddec_1.ZSTDDecoder();
68
+ await decoder.init();
69
+ buffer = Buffer.from(decoder.decode(compressedUserData, MAX_CONSTITUENT_SIZE_BYTES));
70
+ }
71
+ else {
72
+ buffer = Buffer.from(programAccount.account.data[0], 'base64');
73
+ }
67
74
  const key = programAccount.pubkey.toString();
68
75
  const currAccountWithSlot = this.getWithSlot(key);
69
76
  if (currAccountWithSlot) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.147.0",
2
+ "version": "2.148.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.148.0-beta.0",
3
+ "version": "2.148.0",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "module": "./lib/browser/index.js",
@@ -34,6 +34,7 @@ export type ConstituentMapConfig = {
34
34
  lpPoolId?: number;
35
35
  // potentially use these to filter Constituent accounts
36
36
  additionalFilters?: MemcmpFilter[];
37
+ decoder?: 'base64' | 'base64+zstd';
37
38
  };
38
39
 
39
40
  export interface ConstituentMapInterface {
@@ -65,6 +66,7 @@ export class ConstituentMap implements ConstituentMapInterface {
65
66
  private spotMarketIndexToKeyMap = new Map<number, string>();
66
67
 
67
68
  private lpPoolId: number;
69
+ private decoder: 'base64' | 'base64+zstd';
68
70
 
69
71
  constructor(config: ConstituentMapConfig) {
70
72
  this.driftClient = config.driftClient;
@@ -72,6 +74,7 @@ export class ConstituentMap implements ConstituentMapInterface {
72
74
  this.commitment = config.subscriptionConfig.commitment;
73
75
  this.connection = config.connection || this.driftClient.connection;
74
76
  this.lpPoolId = config.lpPoolId ?? 0;
77
+ this.decoder = config.decoder ?? 'base64+zstd';
75
78
 
76
79
  if (config.subscriptionConfig.type === 'polling') {
77
80
  this.constituentAccountSubscriber =
@@ -129,7 +132,7 @@ export class ConstituentMap implements ConstituentMapInterface {
129
132
  {
130
133
  commitment: this.commitment,
131
134
  filters: this.getFilters(),
132
- encoding: 'base64+zstd',
135
+ encoding: this.decoder,
133
136
  withContext: true,
134
137
  },
135
138
  ];
@@ -146,15 +149,22 @@ export class ConstituentMap implements ConstituentMapInterface {
146
149
 
147
150
  const promises = rpcResponseAndContext.value.map(
148
151
  async (programAccount) => {
149
- const compressedUserData = Buffer.from(
150
- programAccount.account.data[0],
151
- 'base64'
152
- );
153
- const decoder = new ZSTDDecoder();
154
- await decoder.init();
155
- const buffer = Buffer.from(
156
- decoder.decode(compressedUserData, MAX_CONSTITUENT_SIZE_BYTES)
157
- );
152
+ let buffer: Buffer;
153
+
154
+ if (this.decoder === 'base64+zstd') {
155
+ const compressedUserData = Buffer.from(
156
+ programAccount.account.data[0],
157
+ 'base64'
158
+ );
159
+ const decoder = new ZSTDDecoder();
160
+ await decoder.init();
161
+ buffer = Buffer.from(
162
+ decoder.decode(compressedUserData, MAX_CONSTITUENT_SIZE_BYTES)
163
+ );
164
+ } else {
165
+ buffer = Buffer.from(programAccount.account.data[0], 'base64');
166
+ }
167
+
158
168
  const key = programAccount.pubkey.toString();
159
169
  const currAccountWithSlot = this.getWithSlot(key);
160
170
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.147.0",
2
+ "version": "2.148.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {