@drift-labs/sdk 2.67.0-beta.4 → 2.67.0-beta.6
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 +1 -1
- package/lib/accounts/pollingDriftClientAccountSubscriber.d.ts +2 -2
- package/lib/accounts/pollingDriftClientAccountSubscriber.js +8 -4
- package/lib/accounts/types.d.ts +2 -0
- package/lib/accounts/webSocketDriftClientAccountSubscriber.d.ts +2 -2
- package/lib/adminClient.js +2 -0
- package/package.json +1 -1
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +10 -6
- package/src/accounts/types.ts +2 -0
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +2 -2
- package/src/adminClient.ts +2 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.67.0-beta.
|
|
1
|
+
2.67.0-beta.6
|
|
@@ -50,8 +50,8 @@ export declare class PollingDriftClientAccountSubscriber implements DriftClientA
|
|
|
50
50
|
addPerpMarket(marketIndex: number): Promise<boolean>;
|
|
51
51
|
addOracle(oracleInfo: OracleInfo): Promise<boolean>;
|
|
52
52
|
private pauseForOracleToBeAdded;
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
setPerpOracleMap(): Promise<void>;
|
|
54
|
+
setSpotOracleMap(): Promise<void>;
|
|
55
55
|
assertIsSubscribed(): void;
|
|
56
56
|
getStateAccountAndSlot(): DataAndSlot<StateAccount>;
|
|
57
57
|
getMarketAccountAndSlot(marketIndex: number): DataAndSlot<PerpMarketAccount> | undefined;
|
|
@@ -249,13 +249,17 @@ class PollingDriftClientAccountSubscriber {
|
|
|
249
249
|
}
|
|
250
250
|
async addOracle(oracleInfo) {
|
|
251
251
|
if (oracleInfo.publicKey.equals(web3_js_1.PublicKey.default) ||
|
|
252
|
-
this.
|
|
252
|
+
this.oracles.has(oracleInfo.publicKey.toBase58())) {
|
|
253
253
|
return true;
|
|
254
254
|
}
|
|
255
|
-
this.addOracleToPoll(oracleInfo);
|
|
256
255
|
const oracleString = oracleInfo.publicKey.toBase58();
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
// this func can be called multiple times before the first pauseForOracleToBeAdded finishes
|
|
257
|
+
// avoid adding to oraclesToPoll multiple time
|
|
258
|
+
if (!this.oraclesToPoll.has(oracleString)) {
|
|
259
|
+
this.addOracleToPoll(oracleInfo);
|
|
260
|
+
const oracleToPoll = this.oraclesToPoll.get(oracleString);
|
|
261
|
+
await this.addOracleToAccountLoader(oracleToPoll);
|
|
262
|
+
}
|
|
259
263
|
await this.pauseForOracleToBeAdded(3, oracleString);
|
|
260
264
|
return true;
|
|
261
265
|
}
|
package/lib/accounts/types.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export interface DriftClientAccountSubscriber {
|
|
|
41
41
|
addPerpMarket(marketIndex: number): Promise<boolean>;
|
|
42
42
|
addSpotMarket(marketIndex: number): Promise<boolean>;
|
|
43
43
|
addOracle(oracleInfo: OracleInfo): Promise<boolean>;
|
|
44
|
+
setPerpOracleMap(): Promise<void>;
|
|
45
|
+
setSpotOracleMap(): Promise<void>;
|
|
44
46
|
getStateAccountAndSlot(): DataAndSlot<StateAccount>;
|
|
45
47
|
getMarketAccountAndSlot(marketIndex: number): DataAndSlot<PerpMarketAccount> | undefined;
|
|
46
48
|
getMarketAccountsAndSlots(): DataAndSlot<PerpMarketAccount>[];
|
|
@@ -44,8 +44,8 @@ export declare class WebSocketDriftClientAccountSubscriber implements DriftClien
|
|
|
44
44
|
addSpotMarket(marketIndex: number): Promise<boolean>;
|
|
45
45
|
addPerpMarket(marketIndex: number): Promise<boolean>;
|
|
46
46
|
addOracle(oracleInfo: OracleInfo): Promise<boolean>;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
setPerpOracleMap(): Promise<void>;
|
|
48
|
+
setSpotOracleMap(): Promise<void>;
|
|
49
49
|
assertIsSubscribed(): void;
|
|
50
50
|
getStateAccountAndSlot(): DataAndSlot<StateAccount>;
|
|
51
51
|
getMarketAccountAndSlot(marketIndex: number): DataAndSlot<PerpMarketAccount> | undefined;
|
package/lib/adminClient.js
CHANGED
|
@@ -88,6 +88,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
88
88
|
source: oracleSource,
|
|
89
89
|
publicKey: oracle,
|
|
90
90
|
});
|
|
91
|
+
await this.accountSubscriber.setSpotOracleMap();
|
|
91
92
|
return txSig;
|
|
92
93
|
}
|
|
93
94
|
async initializeSerumFulfillmentConfig(marketIndex, serumMarket, serumProgram) {
|
|
@@ -156,6 +157,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
156
157
|
source: oracleSource,
|
|
157
158
|
publicKey: priceOracle,
|
|
158
159
|
});
|
|
160
|
+
await this.accountSubscriber.setPerpOracleMap();
|
|
159
161
|
return txSig;
|
|
160
162
|
}
|
|
161
163
|
async deleteInitializedPerpMarket(marketIndex) {
|
package/package.json
CHANGED
|
@@ -396,15 +396,19 @@ export class PollingDriftClientAccountSubscriber
|
|
|
396
396
|
async addOracle(oracleInfo: OracleInfo): Promise<boolean> {
|
|
397
397
|
if (
|
|
398
398
|
oracleInfo.publicKey.equals(PublicKey.default) ||
|
|
399
|
-
this.
|
|
399
|
+
this.oracles.has(oracleInfo.publicKey.toBase58())
|
|
400
400
|
) {
|
|
401
401
|
return true;
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
this.addOracleToPoll(oracleInfo);
|
|
405
404
|
const oracleString = oracleInfo.publicKey.toBase58();
|
|
406
|
-
|
|
407
|
-
|
|
405
|
+
// this func can be called multiple times before the first pauseForOracleToBeAdded finishes
|
|
406
|
+
// avoid adding to oraclesToPoll multiple time
|
|
407
|
+
if (!this.oraclesToPoll.has(oracleString)) {
|
|
408
|
+
this.addOracleToPoll(oracleInfo);
|
|
409
|
+
const oracleToPoll = this.oraclesToPoll.get(oracleString);
|
|
410
|
+
await this.addOracleToAccountLoader(oracleToPoll);
|
|
411
|
+
}
|
|
408
412
|
|
|
409
413
|
await this.pauseForOracleToBeAdded(3, oracleString);
|
|
410
414
|
|
|
@@ -428,7 +432,7 @@ export class PollingDriftClientAccountSubscriber
|
|
|
428
432
|
console.log(`Pausing to find oracle ${oracle} failed`);
|
|
429
433
|
}
|
|
430
434
|
|
|
431
|
-
|
|
435
|
+
async setPerpOracleMap() {
|
|
432
436
|
const perpMarkets = this.getMarketAccountsAndSlots();
|
|
433
437
|
for (const perpMarket of perpMarkets) {
|
|
434
438
|
const perpMarketAccount = perpMarket.data;
|
|
@@ -444,7 +448,7 @@ export class PollingDriftClientAccountSubscriber
|
|
|
444
448
|
}
|
|
445
449
|
}
|
|
446
450
|
|
|
447
|
-
|
|
451
|
+
async setSpotOracleMap() {
|
|
448
452
|
const spotMarkets = this.getSpotMarketAccountsAndSlots();
|
|
449
453
|
for (const spotMarket of spotMarkets) {
|
|
450
454
|
const spotMarketAccount = spotMarket.data;
|
package/src/accounts/types.ts
CHANGED
|
@@ -58,6 +58,8 @@ export interface DriftClientAccountSubscriber {
|
|
|
58
58
|
addPerpMarket(marketIndex: number): Promise<boolean>;
|
|
59
59
|
addSpotMarket(marketIndex: number): Promise<boolean>;
|
|
60
60
|
addOracle(oracleInfo: OracleInfo): Promise<boolean>;
|
|
61
|
+
setPerpOracleMap(): Promise<void>;
|
|
62
|
+
setSpotOracleMap(): Promise<void>;
|
|
61
63
|
|
|
62
64
|
getStateAccountAndSlot(): DataAndSlot<StateAccount>;
|
|
63
65
|
getMarketAccountAndSlot(
|
|
@@ -311,7 +311,7 @@ export class WebSocketDriftClientAccountSubscriber
|
|
|
311
311
|
return this.subscribeToOracle(oracleInfo);
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
async setPerpOracleMap() {
|
|
315
315
|
const perpMarkets = this.getMarketAccountsAndSlots();
|
|
316
316
|
for (const perpMarket of perpMarkets) {
|
|
317
317
|
if (!perpMarket) {
|
|
@@ -330,7 +330,7 @@ export class WebSocketDriftClientAccountSubscriber
|
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
|
|
333
|
+
async setSpotOracleMap() {
|
|
334
334
|
const spotMarkets = this.getSpotMarketAccountsAndSlots();
|
|
335
335
|
for (const spotMarket of spotMarkets) {
|
|
336
336
|
if (!spotMarket) {
|
package/src/adminClient.ts
CHANGED
|
@@ -144,6 +144,7 @@ export class AdminClient extends DriftClient {
|
|
|
144
144
|
source: oracleSource,
|
|
145
145
|
publicKey: oracle,
|
|
146
146
|
});
|
|
147
|
+
await this.accountSubscriber.setSpotOracleMap();
|
|
147
148
|
|
|
148
149
|
return txSig;
|
|
149
150
|
}
|
|
@@ -283,6 +284,7 @@ export class AdminClient extends DriftClient {
|
|
|
283
284
|
source: oracleSource,
|
|
284
285
|
publicKey: priceOracle,
|
|
285
286
|
});
|
|
287
|
+
await this.accountSubscriber.setPerpOracleMap();
|
|
286
288
|
|
|
287
289
|
return txSig;
|
|
288
290
|
}
|