@drift-labs/sdk 2.95.0-beta.17 → 2.95.0-beta.19

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.95.0-beta.17
1
+ 2.95.0-beta.19
@@ -82,7 +82,9 @@ class WebSocketDriftClientAccountSubscriber {
82
82
  if (!this.initialPerpMarketAccountData) {
83
83
  const perpMarketPublicKeys = this.perpMarketIndexes.map((marketIndex) => (0, pda_1.getPerpMarketPublicKeySync)(this.program.programId, marketIndex));
84
84
  const perpMarketAccountInfos = await connection.getMultipleAccountsInfo(perpMarketPublicKeys);
85
- this.initialPerpMarketAccountData = new Map(perpMarketAccountInfos.map((accountInfo) => {
85
+ this.initialPerpMarketAccountData = new Map(perpMarketAccountInfos
86
+ .filter((accountInfo) => !!accountInfo.data)
87
+ .map((accountInfo) => {
86
88
  const perpMarket = this.program.coder.accounts.decode('PerpMarket', accountInfo.data);
87
89
  return [perpMarket.marketIndex, perpMarket];
88
90
  }));
@@ -90,13 +92,17 @@ class WebSocketDriftClientAccountSubscriber {
90
92
  if (!this.initialSpotMarketAccountData) {
91
93
  const spotMarketPublicKeys = this.spotMarketIndexes.map((marketIndex) => (0, pda_1.getSpotMarketPublicKeySync)(this.program.programId, marketIndex));
92
94
  const spotMarketAccountInfos = await connection.getMultipleAccountsInfo(spotMarketPublicKeys);
93
- this.initialSpotMarketAccountData = new Map(spotMarketAccountInfos.map((accountInfo) => {
95
+ this.initialSpotMarketAccountData = new Map(spotMarketAccountInfos
96
+ .filter((accountInfo) => !!accountInfo.data)
97
+ .map((accountInfo) => {
94
98
  const spotMarket = this.program.coder.accounts.decode('SpotMarket', accountInfo.data);
95
99
  return [spotMarket.marketIndex, spotMarket];
96
100
  }));
97
101
  }
98
102
  const oracleAccountInfos = await connection.getMultipleAccountsInfo(this.oracleInfos.map((oracleInfo) => oracleInfo.publicKey));
99
- this.initialOraclePriceData = new Map(this.oracleInfos.map((oracleInfo, i) => {
103
+ this.initialOraclePriceData = new Map(this.oracleInfos
104
+ .filter((_, i) => !!oracleAccountInfos[i])
105
+ .map((oracleInfo, i) => {
100
106
  const oracleClient = this.oracleClientCache.get(oracleInfo.source, connection, this.program);
101
107
  const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(oracleAccountInfos[i].data);
102
108
  return [oracleInfo.publicKey.toString(), oraclePriceData];
@@ -1725,10 +1725,14 @@ class DriftClient {
1725
1725
  writablePerpMarketIndexes: [marketIndex],
1726
1726
  writableSpotMarketIndexes: [numericConstants_1.QUOTE_SPOT_MARKET_INDEX],
1727
1727
  });
1728
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
1728
1729
  return await this.program.instruction.settleExpiredMarket(marketIndex, {
1729
1730
  accounts: {
1730
1731
  state: await this.getStatePublicKey(),
1731
- authority: this.wallet.publicKey,
1732
+ admin: this.isSubscribed
1733
+ ? this.getStateAccount().admin
1734
+ : this.wallet.publicKey,
1735
+ perpMarket: perpMarketPublicKey,
1732
1736
  },
1733
1737
  remainingAccounts,
1734
1738
  });
@@ -1606,15 +1606,20 @@
1606
1606
  {
1607
1607
  "name": "settleExpiredMarket",
1608
1608
  "accounts": [
1609
+ {
1610
+ "name": "admin",
1611
+ "isMut": false,
1612
+ "isSigner": true
1613
+ },
1609
1614
  {
1610
1615
  "name": "state",
1611
1616
  "isMut": false,
1612
1617
  "isSigner": false
1613
1618
  },
1614
1619
  {
1615
- "name": "authority",
1616
- "isMut": false,
1617
- "isSigner": true
1620
+ "name": "perpMarket",
1621
+ "isMut": true,
1622
+ "isSigner": false
1618
1623
  }
1619
1624
  ],
1620
1625
  "args": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.95.0-beta.17",
3
+ "version": "2.95.0-beta.19",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -174,13 +174,15 @@ export class WebSocketDriftClientAccountSubscriber
174
174
  perpMarketPublicKeys
175
175
  );
176
176
  this.initialPerpMarketAccountData = new Map(
177
- perpMarketAccountInfos.map((accountInfo) => {
178
- const perpMarket = this.program.coder.accounts.decode(
179
- 'PerpMarket',
180
- accountInfo.data
181
- );
182
- return [perpMarket.marketIndex, perpMarket];
183
- })
177
+ perpMarketAccountInfos
178
+ .filter((accountInfo) => !!accountInfo.data)
179
+ .map((accountInfo) => {
180
+ const perpMarket = this.program.coder.accounts.decode(
181
+ 'PerpMarket',
182
+ accountInfo.data
183
+ );
184
+ return [perpMarket.marketIndex, perpMarket];
185
+ })
184
186
  );
185
187
  }
186
188
 
@@ -192,13 +194,15 @@ export class WebSocketDriftClientAccountSubscriber
192
194
  spotMarketPublicKeys
193
195
  );
194
196
  this.initialSpotMarketAccountData = new Map(
195
- spotMarketAccountInfos.map((accountInfo) => {
196
- const spotMarket = this.program.coder.accounts.decode(
197
- 'SpotMarket',
198
- accountInfo.data
199
- );
200
- return [spotMarket.marketIndex, spotMarket];
201
- })
197
+ spotMarketAccountInfos
198
+ .filter((accountInfo) => !!accountInfo.data)
199
+ .map((accountInfo) => {
200
+ const spotMarket = this.program.coder.accounts.decode(
201
+ 'SpotMarket',
202
+ accountInfo.data
203
+ );
204
+ return [spotMarket.marketIndex, spotMarket];
205
+ })
202
206
  );
203
207
  }
204
208
 
@@ -206,17 +210,19 @@ export class WebSocketDriftClientAccountSubscriber
206
210
  this.oracleInfos.map((oracleInfo) => oracleInfo.publicKey)
207
211
  );
208
212
  this.initialOraclePriceData = new Map(
209
- this.oracleInfos.map((oracleInfo, i) => {
210
- const oracleClient = this.oracleClientCache.get(
211
- oracleInfo.source,
212
- connection,
213
- this.program
214
- );
215
- const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(
216
- oracleAccountInfos[i].data
217
- );
218
- return [oracleInfo.publicKey.toString(), oraclePriceData];
219
- })
213
+ this.oracleInfos
214
+ .filter((_, i) => !!oracleAccountInfos[i])
215
+ .map((oracleInfo, i) => {
216
+ const oracleClient = this.oracleClientCache.get(
217
+ oracleInfo.source,
218
+ connection,
219
+ this.program
220
+ );
221
+ const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(
222
+ oracleAccountInfos[i].data
223
+ );
224
+ return [oracleInfo.publicKey.toString(), oraclePriceData];
225
+ })
220
226
  );
221
227
  }
222
228
 
@@ -3223,11 +3223,18 @@ export class DriftClient {
3223
3223
  writablePerpMarketIndexes: [marketIndex],
3224
3224
  writableSpotMarketIndexes: [QUOTE_SPOT_MARKET_INDEX],
3225
3225
  });
3226
+ const perpMarketPublicKey = await getPerpMarketPublicKey(
3227
+ this.program.programId,
3228
+ marketIndex
3229
+ );
3226
3230
 
3227
3231
  return await this.program.instruction.settleExpiredMarket(marketIndex, {
3228
3232
  accounts: {
3229
3233
  state: await this.getStatePublicKey(),
3230
- authority: this.wallet.publicKey,
3234
+ admin: this.isSubscribed
3235
+ ? this.getStateAccount().admin
3236
+ : this.wallet.publicKey,
3237
+ perpMarket: perpMarketPublicKey,
3231
3238
  },
3232
3239
  remainingAccounts,
3233
3240
  });
@@ -1606,15 +1606,20 @@
1606
1606
  {
1607
1607
  "name": "settleExpiredMarket",
1608
1608
  "accounts": [
1609
+ {
1610
+ "name": "admin",
1611
+ "isMut": false,
1612
+ "isSigner": true
1613
+ },
1609
1614
  {
1610
1615
  "name": "state",
1611
1616
  "isMut": false,
1612
1617
  "isSigner": false
1613
1618
  },
1614
1619
  {
1615
- "name": "authority",
1616
- "isMut": false,
1617
- "isSigner": true
1620
+ "name": "perpMarket",
1621
+ "isMut": true,
1622
+ "isSigner": false
1618
1623
  }
1619
1624
  ],
1620
1625
  "args": [