@drift-labs/sdk 2.101.0-beta.3 → 2.101.0-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.101.0-beta.3
1
+ 2.101.0-beta.5
@@ -1,16 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
- import { DataAndSlot, BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types';
4
+ import { BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types';
5
5
  import { Program } from '@coral-xyz/anchor';
6
6
  import { Commitment, Context, KeyedAccountInfo, MemcmpFilter, PublicKey } from '@solana/web3.js';
7
7
  export declare class WebSocketProgramAccountSubscriber<T> implements ProgramAccountSubscriber<T> {
8
8
  subscriptionName: string;
9
9
  accountDiscriminator: string;
10
- dataAndSlot?: DataAndSlot<T> & {
11
- accountId: PublicKey;
12
- };
13
10
  bufferAndSlot?: BufferAndSlot;
11
+ bufferAndSlotMap: Map<string, BufferAndSlot>;
14
12
  program: Program;
15
13
  decodeBuffer: (accountName: string, ix: Buffer) => T;
16
14
  onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void;
@@ -6,6 +6,7 @@ class WebSocketProgramAccountSubscriber {
6
6
  filters: [],
7
7
  }, resubOpts) {
8
8
  var _a;
9
+ this.bufferAndSlotMap = new Map();
9
10
  this.isUnsubscribing = false;
10
11
  this.receivingData = false;
11
12
  this.subscriptionName = subscriptionName;
@@ -69,37 +70,29 @@ class WebSocketProgramAccountSubscriber {
69
70
  if (keyedAccountInfo) {
70
71
  newBuffer = keyedAccountInfo.accountInfo.data;
71
72
  }
72
- if (!this.bufferAndSlot) {
73
- this.bufferAndSlot = {
74
- buffer: newBuffer,
75
- slot: newSlot,
76
- };
73
+ const accountId = keyedAccountInfo.accountId.toBase58();
74
+ const existingBufferAndSlot = this.bufferAndSlotMap.get(accountId);
75
+ if (!existingBufferAndSlot) {
77
76
  if (newBuffer) {
78
- const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
79
- this.dataAndSlot = {
80
- data: account,
77
+ this.bufferAndSlotMap.set(accountId, {
78
+ buffer: newBuffer,
81
79
  slot: newSlot,
82
- accountId: keyedAccountInfo.accountId,
83
- };
80
+ });
81
+ const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
84
82
  this.onChange(keyedAccountInfo.accountId, account, context, newBuffer);
85
83
  }
86
84
  return;
87
85
  }
88
- if (newSlot < this.bufferAndSlot.slot) {
86
+ if (newSlot < existingBufferAndSlot.slot) {
89
87
  return;
90
88
  }
91
- const oldBuffer = this.bufferAndSlot.buffer;
89
+ const oldBuffer = existingBufferAndSlot.buffer;
92
90
  if (newBuffer && (!oldBuffer || !newBuffer.equals(oldBuffer))) {
93
- this.bufferAndSlot = {
91
+ this.bufferAndSlotMap.set(accountId, {
94
92
  buffer: newBuffer,
95
93
  slot: newSlot,
96
- };
94
+ });
97
95
  const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
98
- this.dataAndSlot = {
99
- data: account,
100
- slot: newSlot,
101
- accountId: keyedAccountInfo.accountId,
102
- };
103
96
  this.onChange(keyedAccountInfo.accountId, account, context, newBuffer);
104
97
  }
105
98
  }
@@ -904,6 +904,28 @@ exports.MainnetPerpMarkets = [
904
904
  oracleSource: __1.OracleSource.PYTH_PULL,
905
905
  pythFeedId: '0xf7731dc812590214d3eb4343bfb13d1b4cfa9b1d4e020644b5d5d8e07d60c66c',
906
906
  },
907
+ {
908
+ fullName: 'FWOG',
909
+ category: ['Meme'],
910
+ symbol: 'FWOG-PERP',
911
+ baseAssetSymbol: 'FWOG',
912
+ marketIndex: 54,
913
+ oracle: new web3_js_1.PublicKey('5Z7uvkAsHNN6qqkQkwcKcEPYZqiMbFE9E24p7SpvfSrv'),
914
+ launchTs: 1731443152000,
915
+ oracleSource: __1.OracleSource.PYTH_PULL,
916
+ pythFeedId: '0x656cc2a39dd795bdecb59de810d4f4d1e74c25fe4c42d0bf1c65a38d74df48e9',
917
+ },
918
+ {
919
+ fullName: 'PNUT',
920
+ category: ['Meme'],
921
+ symbol: 'PNUT-PERP',
922
+ baseAssetSymbol: 'PNUT',
923
+ marketIndex: 55,
924
+ oracle: new web3_js_1.PublicKey('5RgXW13Kq1RgCLEsJhhchWt3W4R2XLJnd6KqgZk6dSY7'),
925
+ launchTs: 1731443152000,
926
+ oracleSource: __1.OracleSource.PYTH_PULL,
927
+ pythFeedId: '0x116da895807f81f6b5c5f01b109376e7f6834dc8b51365ab7cdfa66634340e54',
928
+ },
907
929
  ];
908
930
  exports.PerpMarkets = {
909
931
  devnet: exports.DevnetPerpMarkets,
@@ -1,16 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
- import { DataAndSlot, BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types';
4
+ import { BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types';
5
5
  import { Program } from '@coral-xyz/anchor';
6
6
  import { Commitment, Context, KeyedAccountInfo, MemcmpFilter, PublicKey } from '@solana/web3.js';
7
7
  export declare class WebSocketProgramAccountSubscriber<T> implements ProgramAccountSubscriber<T> {
8
8
  subscriptionName: string;
9
9
  accountDiscriminator: string;
10
- dataAndSlot?: DataAndSlot<T> & {
11
- accountId: PublicKey;
12
- };
13
10
  bufferAndSlot?: BufferAndSlot;
11
+ bufferAndSlotMap: Map<string, BufferAndSlot>;
14
12
  program: Program;
15
13
  decodeBuffer: (accountName: string, ix: Buffer) => T;
16
14
  onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void;
@@ -6,6 +6,7 @@ class WebSocketProgramAccountSubscriber {
6
6
  filters: [],
7
7
  }, resubOpts) {
8
8
  var _a;
9
+ this.bufferAndSlotMap = new Map();
9
10
  this.isUnsubscribing = false;
10
11
  this.receivingData = false;
11
12
  this.subscriptionName = subscriptionName;
@@ -69,37 +70,29 @@ class WebSocketProgramAccountSubscriber {
69
70
  if (keyedAccountInfo) {
70
71
  newBuffer = keyedAccountInfo.accountInfo.data;
71
72
  }
72
- if (!this.bufferAndSlot) {
73
- this.bufferAndSlot = {
74
- buffer: newBuffer,
75
- slot: newSlot,
76
- };
73
+ const accountId = keyedAccountInfo.accountId.toBase58();
74
+ const existingBufferAndSlot = this.bufferAndSlotMap.get(accountId);
75
+ if (!existingBufferAndSlot) {
77
76
  if (newBuffer) {
78
- const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
79
- this.dataAndSlot = {
80
- data: account,
77
+ this.bufferAndSlotMap.set(accountId, {
78
+ buffer: newBuffer,
81
79
  slot: newSlot,
82
- accountId: keyedAccountInfo.accountId,
83
- };
80
+ });
81
+ const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
84
82
  this.onChange(keyedAccountInfo.accountId, account, context, newBuffer);
85
83
  }
86
84
  return;
87
85
  }
88
- if (newSlot < this.bufferAndSlot.slot) {
86
+ if (newSlot < existingBufferAndSlot.slot) {
89
87
  return;
90
88
  }
91
- const oldBuffer = this.bufferAndSlot.buffer;
89
+ const oldBuffer = existingBufferAndSlot.buffer;
92
90
  if (newBuffer && (!oldBuffer || !newBuffer.equals(oldBuffer))) {
93
- this.bufferAndSlot = {
91
+ this.bufferAndSlotMap.set(accountId, {
94
92
  buffer: newBuffer,
95
93
  slot: newSlot,
96
- };
94
+ });
97
95
  const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
98
- this.dataAndSlot = {
99
- data: account,
100
- slot: newSlot,
101
- accountId: keyedAccountInfo.accountId,
102
- };
103
96
  this.onChange(keyedAccountInfo.accountId, account, context, newBuffer);
104
97
  }
105
98
  }
@@ -904,6 +904,28 @@ exports.MainnetPerpMarkets = [
904
904
  oracleSource: __1.OracleSource.PYTH_PULL,
905
905
  pythFeedId: '0xf7731dc812590214d3eb4343bfb13d1b4cfa9b1d4e020644b5d5d8e07d60c66c',
906
906
  },
907
+ {
908
+ fullName: 'FWOG',
909
+ category: ['Meme'],
910
+ symbol: 'FWOG-PERP',
911
+ baseAssetSymbol: 'FWOG',
912
+ marketIndex: 54,
913
+ oracle: new web3_js_1.PublicKey('5Z7uvkAsHNN6qqkQkwcKcEPYZqiMbFE9E24p7SpvfSrv'),
914
+ launchTs: 1731443152000,
915
+ oracleSource: __1.OracleSource.PYTH_PULL,
916
+ pythFeedId: '0x656cc2a39dd795bdecb59de810d4f4d1e74c25fe4c42d0bf1c65a38d74df48e9',
917
+ },
918
+ {
919
+ fullName: 'PNUT',
920
+ category: ['Meme'],
921
+ symbol: 'PNUT-PERP',
922
+ baseAssetSymbol: 'PNUT',
923
+ marketIndex: 55,
924
+ oracle: new web3_js_1.PublicKey('5RgXW13Kq1RgCLEsJhhchWt3W4R2XLJnd6KqgZk6dSY7'),
925
+ launchTs: 1731443152000,
926
+ oracleSource: __1.OracleSource.PYTH_PULL,
927
+ pythFeedId: '0x116da895807f81f6b5c5f01b109376e7f6834dc8b51365ab7cdfa66634340e54',
928
+ },
907
929
  ];
908
930
  exports.PerpMarkets = {
909
931
  devnet: exports.DevnetPerpMarkets,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.101.0-beta.3",
3
+ "version": "2.101.0-beta.5",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -1,9 +1,4 @@
1
- import {
2
- DataAndSlot,
3
- BufferAndSlot,
4
- ProgramAccountSubscriber,
5
- ResubOpts,
6
- } from './types';
1
+ import { BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types';
7
2
  import { AnchorProvider, Program } from '@coral-xyz/anchor';
8
3
  import {
9
4
  Commitment,
@@ -19,8 +14,8 @@ export class WebSocketProgramAccountSubscriber<T>
19
14
  {
20
15
  subscriptionName: string;
21
16
  accountDiscriminator: string;
22
- dataAndSlot?: DataAndSlot<T> & { accountId: PublicKey };
23
17
  bufferAndSlot?: BufferAndSlot;
18
+ bufferAndSlotMap: Map<string, BufferAndSlot> = new Map();
24
19
  program: Program;
25
20
  decodeBuffer: (accountName: string, ix: Buffer) => T;
26
21
  onChange: (
@@ -134,39 +129,32 @@ export class WebSocketProgramAccountSubscriber<T>
134
129
  newBuffer = keyedAccountInfo.accountInfo.data;
135
130
  }
136
131
 
137
- if (!this.bufferAndSlot) {
138
- this.bufferAndSlot = {
139
- buffer: newBuffer,
140
- slot: newSlot,
141
- };
132
+ const accountId = keyedAccountInfo.accountId.toBase58();
133
+ const existingBufferAndSlot = this.bufferAndSlotMap.get(accountId);
134
+
135
+ if (!existingBufferAndSlot) {
142
136
  if (newBuffer) {
143
- const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
144
- this.dataAndSlot = {
145
- data: account,
137
+ this.bufferAndSlotMap.set(accountId, {
138
+ buffer: newBuffer,
146
139
  slot: newSlot,
147
- accountId: keyedAccountInfo.accountId,
148
- };
140
+ });
141
+ const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
149
142
  this.onChange(keyedAccountInfo.accountId, account, context, newBuffer);
150
143
  }
151
144
  return;
152
145
  }
153
146
 
154
- if (newSlot < this.bufferAndSlot.slot) {
147
+ if (newSlot < existingBufferAndSlot.slot) {
155
148
  return;
156
149
  }
157
150
 
158
- const oldBuffer = this.bufferAndSlot.buffer;
151
+ const oldBuffer = existingBufferAndSlot.buffer;
159
152
  if (newBuffer && (!oldBuffer || !newBuffer.equals(oldBuffer))) {
160
- this.bufferAndSlot = {
153
+ this.bufferAndSlotMap.set(accountId, {
161
154
  buffer: newBuffer,
162
155
  slot: newSlot,
163
- };
156
+ });
164
157
  const account = this.decodeBuffer(this.accountDiscriminator, newBuffer);
165
- this.dataAndSlot = {
166
- data: account,
167
- slot: newSlot,
168
- accountId: keyedAccountInfo.accountId,
169
- };
170
158
  this.onChange(keyedAccountInfo.accountId, account, context, newBuffer);
171
159
  }
172
160
  }
@@ -984,6 +984,30 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
984
984
  pythFeedId:
985
985
  '0xf7731dc812590214d3eb4343bfb13d1b4cfa9b1d4e020644b5d5d8e07d60c66c',
986
986
  },
987
+ {
988
+ fullName: 'FWOG',
989
+ category: ['Meme'],
990
+ symbol: 'FWOG-PERP',
991
+ baseAssetSymbol: 'FWOG',
992
+ marketIndex: 54,
993
+ oracle: new PublicKey('5Z7uvkAsHNN6qqkQkwcKcEPYZqiMbFE9E24p7SpvfSrv'),
994
+ launchTs: 1731443152000,
995
+ oracleSource: OracleSource.PYTH_PULL,
996
+ pythFeedId:
997
+ '0x656cc2a39dd795bdecb59de810d4f4d1e74c25fe4c42d0bf1c65a38d74df48e9',
998
+ },
999
+ {
1000
+ fullName: 'PNUT',
1001
+ category: ['Meme'],
1002
+ symbol: 'PNUT-PERP',
1003
+ baseAssetSymbol: 'PNUT',
1004
+ marketIndex: 55,
1005
+ oracle: new PublicKey('5RgXW13Kq1RgCLEsJhhchWt3W4R2XLJnd6KqgZk6dSY7'),
1006
+ launchTs: 1731443152000,
1007
+ oracleSource: OracleSource.PYTH_PULL,
1008
+ pythFeedId:
1009
+ '0x116da895807f81f6b5c5f01b109376e7f6834dc8b51365ab7cdfa66634340e54',
1010
+ },
987
1011
  ];
988
1012
 
989
1013
  export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {