@drift-labs/sdk 2.146.0-beta.0 → 2.146.0-beta.10
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/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +99 -7
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +435 -144
- package/lib/browser/adminClient.d.ts +5 -1
- package/lib/browser/adminClient.js +57 -23
- package/lib/browser/constants/perpMarkets.js +0 -2
- package/lib/browser/decode/user.js +4 -0
- package/lib/browser/driftClient.js +19 -17
- package/lib/browser/driftClientConfig.d.ts +7 -2
- package/lib/browser/idl/drift.json +35 -1
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.js +9 -1
- package/lib/browser/types.d.ts +2 -0
- package/lib/browser/user.js +2 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +99 -7
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +435 -144
- package/lib/node/adminClient.d.ts +5 -1
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +57 -23
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +0 -2
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +4 -0
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +19 -17
- package/lib/node/driftClientConfig.d.ts +7 -2
- package/lib/node/driftClientConfig.d.ts.map +1 -1
- package/lib/node/idl/drift.json +35 -1
- package/lib/node/index.d.ts +4 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +9 -1
- package/lib/node/types.d.ts +2 -0
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +2 -0
- package/package.json +1 -1
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +566 -167
- package/src/adminClient.ts +74 -25
- package/src/constants/perpMarkets.ts +0 -3
- package/src/decode/user.ts +7 -0
- package/src/driftClient.ts +7 -4
- package/src/driftClientConfig.ts +15 -8
- package/src/idl/drift.json +36 -2
- package/src/index.ts +4 -0
- package/src/types.ts +2 -0
- package/src/user.ts +2 -0
|
@@ -22,9 +22,13 @@ export declare class AdminClient extends DriftClient {
|
|
|
22
22
|
initializeOpenbookV2FulfillmentConfig(marketIndex: number, openbookMarket: PublicKey): Promise<TransactionSignature>;
|
|
23
23
|
getInitializeOpenbookV2FulfillmentConfigIx(marketIndex: number, openbookMarket: PublicKey): Promise<TransactionInstruction>;
|
|
24
24
|
initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionSignature>;
|
|
25
|
-
getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string,
|
|
25
|
+
getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number, includeInitAmmCacheIx?: boolean): Promise<TransactionInstruction[]>;
|
|
26
26
|
initializeAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
|
|
27
27
|
getInitializeAmmCacheIx(): Promise<TransactionInstruction>;
|
|
28
|
+
resizeAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
|
|
29
|
+
getResizeAmmCacheIx(): Promise<TransactionInstruction>;
|
|
30
|
+
deleteAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
|
|
31
|
+
getDeleteAmmCacheIx(): Promise<TransactionInstruction>;
|
|
28
32
|
updateInitialAmmCacheInfo(perpMarketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
29
33
|
getUpdateInitialAmmCacheInfoIx(perpMarketIndexes: number[]): Promise<TransactionInstruction>;
|
|
30
34
|
overrideAmmCacheInfo(perpMarketIndex: number, params: {
|
|
@@ -210,7 +210,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
210
210
|
const ammCachePublicKey = (0, pda_1.getAmmCachePublicKey)(this.program.programId);
|
|
211
211
|
const ammCacheAccount = await this.connection.getAccountInfo(ammCachePublicKey);
|
|
212
212
|
const mustInitializeAmmCache = (ammCacheAccount === null || ammCacheAccount === void 0 ? void 0 : ammCacheAccount.data) == null;
|
|
213
|
-
const initializeMarketIxs = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name,
|
|
213
|
+
const initializeMarketIxs = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name, lpPoolId, mustInitializeAmmCache);
|
|
214
214
|
const tx = await this.buildTransaction(initializeMarketIxs);
|
|
215
215
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
216
216
|
while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
|
|
@@ -224,7 +224,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
224
224
|
await this.accountSubscriber.setPerpOracleMap();
|
|
225
225
|
return txSig;
|
|
226
226
|
}
|
|
227
|
-
async getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME,
|
|
227
|
+
async getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0, includeInitAmmCacheIx = false) {
|
|
228
228
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
229
229
|
const ixs = [];
|
|
230
230
|
if (includeInitAmmCacheIx) {
|
|
@@ -257,15 +257,49 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
257
257
|
return await this.program.instruction.initializeAmmCache({
|
|
258
258
|
accounts: {
|
|
259
259
|
state: await this.getStatePublicKey(),
|
|
260
|
-
admin: this.
|
|
261
|
-
? this.
|
|
262
|
-
: this.
|
|
260
|
+
admin: this.useHotWalletAdmin
|
|
261
|
+
? this.wallet.publicKey
|
|
262
|
+
: this.getStateAccount().admin,
|
|
263
263
|
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
264
264
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
265
265
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
266
266
|
},
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
|
+
async resizeAmmCache(txParams) {
|
|
270
|
+
const initializeAmmCacheIx = await this.getResizeAmmCacheIx();
|
|
271
|
+
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
272
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
273
|
+
return txSig;
|
|
274
|
+
}
|
|
275
|
+
async getResizeAmmCacheIx() {
|
|
276
|
+
return await this.program.instruction.resizeAmmCache({
|
|
277
|
+
accounts: {
|
|
278
|
+
state: await this.getStatePublicKey(),
|
|
279
|
+
admin: this.useHotWalletAdmin
|
|
280
|
+
? this.wallet.publicKey
|
|
281
|
+
: this.getStateAccount().admin,
|
|
282
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
283
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
284
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
async deleteAmmCache(txParams) {
|
|
289
|
+
const deleteAmmCacheIx = await this.getDeleteAmmCacheIx();
|
|
290
|
+
const tx = await this.buildTransaction(deleteAmmCacheIx, txParams);
|
|
291
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
292
|
+
return txSig;
|
|
293
|
+
}
|
|
294
|
+
async getDeleteAmmCacheIx() {
|
|
295
|
+
return await this.program.instruction.deleteAmmCache({
|
|
296
|
+
accounts: {
|
|
297
|
+
state: await this.getStatePublicKey(),
|
|
298
|
+
admin: this.getStateAccount().admin,
|
|
299
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
}
|
|
269
303
|
async updateInitialAmmCacheInfo(perpMarketIndexes, txParams) {
|
|
270
304
|
const initializeAmmCacheIx = await this.getUpdateInitialAmmCacheInfoIx(perpMarketIndexes);
|
|
271
305
|
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
@@ -281,9 +315,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
281
315
|
return await this.program.instruction.updateInitialAmmCacheInfo({
|
|
282
316
|
accounts: {
|
|
283
317
|
state: await this.getStatePublicKey(),
|
|
284
|
-
admin: this.
|
|
285
|
-
? this.
|
|
286
|
-
: this.
|
|
318
|
+
admin: this.useHotWalletAdmin
|
|
319
|
+
? this.wallet.publicKey
|
|
320
|
+
: this.getStateAccount().admin,
|
|
287
321
|
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
288
322
|
},
|
|
289
323
|
remainingAccounts,
|
|
@@ -306,9 +340,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
306
340
|
}, params), {
|
|
307
341
|
accounts: {
|
|
308
342
|
state: await this.getStatePublicKey(),
|
|
309
|
-
admin: this.
|
|
310
|
-
? this.
|
|
311
|
-
: this.
|
|
343
|
+
admin: this.useHotWalletAdmin
|
|
344
|
+
? this.wallet.publicKey
|
|
345
|
+
: this.getStateAccount().admin,
|
|
312
346
|
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
313
347
|
},
|
|
314
348
|
});
|
|
@@ -323,9 +357,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
323
357
|
return this.program.instruction.resetAmmCache({
|
|
324
358
|
accounts: {
|
|
325
359
|
state: await this.getStatePublicKey(),
|
|
326
|
-
admin: this.
|
|
327
|
-
? this.
|
|
328
|
-
: this.
|
|
360
|
+
admin: this.useHotWalletAdmin
|
|
361
|
+
? this.wallet.publicKey
|
|
362
|
+
: this.getStateAccount().admin,
|
|
329
363
|
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
330
364
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
331
365
|
},
|
|
@@ -2582,9 +2616,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
2582
2616
|
return await this.program.instruction.updateConstituentPausedOperations(pausedOperations, {
|
|
2583
2617
|
accounts: {
|
|
2584
2618
|
constituent,
|
|
2585
|
-
admin: this.
|
|
2586
|
-
? this.
|
|
2587
|
-
: this.
|
|
2619
|
+
admin: this.useHotWalletAdmin
|
|
2620
|
+
? this.wallet.publicKey
|
|
2621
|
+
: this.getStateAccount().admin,
|
|
2588
2622
|
state: await this.getStatePublicKey(),
|
|
2589
2623
|
},
|
|
2590
2624
|
});
|
|
@@ -2977,9 +3011,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
2977
3011
|
async getUpdatePerpMarketLpPoolFeeTransferScalarIx(marketIndex, lpFeeTransferScalar, lpExchangeFeeExcluscionScalar) {
|
|
2978
3012
|
return this.program.instruction.updatePerpMarketLpPoolFeeTransferScalar(lpFeeTransferScalar !== null && lpFeeTransferScalar !== void 0 ? lpFeeTransferScalar : null, lpExchangeFeeExcluscionScalar !== null && lpExchangeFeeExcluscionScalar !== void 0 ? lpExchangeFeeExcluscionScalar : null, {
|
|
2979
3013
|
accounts: {
|
|
2980
|
-
admin: this.
|
|
2981
|
-
? this.
|
|
2982
|
-
: this.
|
|
3014
|
+
admin: this.useHotWalletAdmin
|
|
3015
|
+
? this.wallet.publicKey
|
|
3016
|
+
: this.getStateAccount().admin,
|
|
2983
3017
|
state: await this.getStatePublicKey(),
|
|
2984
3018
|
perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
2985
3019
|
},
|
|
@@ -2994,9 +3028,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
2994
3028
|
async getUpdatePerpMarketLpPoolPausedOperationsIx(marketIndex, pausedOperations) {
|
|
2995
3029
|
return this.program.instruction.updatePerpMarketLpPoolPausedOperations(pausedOperations, {
|
|
2996
3030
|
accounts: {
|
|
2997
|
-
admin: this.
|
|
2998
|
-
? this.
|
|
2999
|
-
: this.
|
|
3031
|
+
admin: this.useHotWalletAdmin
|
|
3032
|
+
? this.wallet.publicKey
|
|
3033
|
+
: this.getStateAccount().admin,
|
|
3000
3034
|
state: await this.getStatePublicKey(),
|
|
3001
3035
|
perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
3002
3036
|
},
|
|
@@ -1202,8 +1202,6 @@ exports.MainnetPerpMarkets = [
|
|
|
1202
1202
|
oracle: new web3_js_1.PublicKey('GAzR3C5cn7gGVvuqJB57wSYTPWP3n2Lw4mRJRxvTvqYy'),
|
|
1203
1203
|
launchTs: 1747318237000,
|
|
1204
1204
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
1205
|
-
pythFeedId: '0x6d74813ee17291d5be18a355fe4d43fd300d625caea6554d49f740e7d112141e',
|
|
1206
|
-
pythLazerId: 1571,
|
|
1207
1205
|
},
|
|
1208
1206
|
{
|
|
1209
1207
|
fullName: 'PUMP',
|
|
@@ -71,6 +71,8 @@ function decodeUser(buffer) {
|
|
|
71
71
|
const quoteAssetAmount = readSignedBigInt64LE(buffer, offset + 16);
|
|
72
72
|
const lpShares = readUnsignedBigInt64LE(buffer, offset + 64);
|
|
73
73
|
const openOrders = buffer.readUInt8(offset + 94);
|
|
74
|
+
const positionFlag = buffer.readUInt8(offset + 95);
|
|
75
|
+
const isolatedPositionScaledBalance = readUnsignedBigInt64LE(buffer, offset + 96);
|
|
74
76
|
if (baseAssetAmount.eq(numericConstants_1.ZERO) &&
|
|
75
77
|
openOrders === 0 &&
|
|
76
78
|
quoteAssetAmount.eq(numericConstants_1.ZERO) &&
|
|
@@ -117,6 +119,8 @@ function decodeUser(buffer) {
|
|
|
117
119
|
openOrders,
|
|
118
120
|
perLpBase,
|
|
119
121
|
maxMarginRatio,
|
|
122
|
+
isolatedPositionScaledBalance,
|
|
123
|
+
positionFlag,
|
|
120
124
|
});
|
|
121
125
|
}
|
|
122
126
|
const orders = [];
|
|
@@ -89,7 +89,7 @@ class DriftClient {
|
|
|
89
89
|
this._isSubscribed = val;
|
|
90
90
|
}
|
|
91
91
|
constructor(config) {
|
|
92
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
|
|
92
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26;
|
|
93
93
|
this.users = new Map();
|
|
94
94
|
this._isSubscribed = false;
|
|
95
95
|
this.perpMarketLastSlotCache = new Map();
|
|
@@ -180,12 +180,13 @@ class DriftClient {
|
|
|
180
180
|
resubTimeoutMs: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.resubTimeoutMs,
|
|
181
181
|
logResubMessages: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.logResubMessages,
|
|
182
182
|
commitment: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.commitment,
|
|
183
|
+
programUserAccountSubscriber: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.programUserAccountSubscriber,
|
|
183
184
|
};
|
|
184
185
|
this.userStatsAccountSubscriptionConfig = {
|
|
185
186
|
type: 'websocket',
|
|
186
|
-
resubTimeoutMs: (
|
|
187
|
-
logResubMessages: (
|
|
188
|
-
commitment: (
|
|
187
|
+
resubTimeoutMs: (_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.resubTimeoutMs,
|
|
188
|
+
logResubMessages: (_4 = config.accountSubscription) === null || _4 === void 0 ? void 0 : _4.logResubMessages,
|
|
189
|
+
commitment: (_5 = config.accountSubscription) === null || _5 === void 0 ? void 0 : _5.commitment,
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
192
|
if (config.userStats) {
|
|
@@ -207,21 +208,22 @@ class DriftClient {
|
|
|
207
208
|
const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
|
|
208
209
|
config.spotMarketIndexes === undefined &&
|
|
209
210
|
config.oracleInfos === undefined;
|
|
210
|
-
if (((
|
|
211
|
-
this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (
|
|
212
|
-
}
|
|
213
|
-
else if (((
|
|
214
|
-
const accountSubscriberClass = (
|
|
215
|
-
this.accountSubscriber = new accountSubscriberClass(config.accountSubscription.grpcConfigs, this.program, (
|
|
216
|
-
resubTimeoutMs: (
|
|
217
|
-
logResubMessages: (
|
|
211
|
+
if (((_6 = config.accountSubscription) === null || _6 === void 0 ? void 0 : _6.type) === 'polling') {
|
|
212
|
+
this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_7 = config.perpMarketIndexes) !== null && _7 !== void 0 ? _7 : [], (_8 = config.spotMarketIndexes) !== null && _8 !== void 0 ? _8 : [], (_9 = config.oracleInfos) !== null && _9 !== void 0 ? _9 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
|
|
213
|
+
}
|
|
214
|
+
else if (((_10 = config.accountSubscription) === null || _10 === void 0 ? void 0 : _10.type) === 'grpc') {
|
|
215
|
+
const accountSubscriberClass = (_12 = (_11 = config.accountSubscription) === null || _11 === void 0 ? void 0 : _11.driftClientAccountSubscriber) !== null && _12 !== void 0 ? _12 : grpcDriftClientAccountSubscriber_1.grpcDriftClientAccountSubscriber;
|
|
216
|
+
this.accountSubscriber = new accountSubscriberClass(config.accountSubscription.grpcConfigs, this.program, (_13 = config.perpMarketIndexes) !== null && _13 !== void 0 ? _13 : [], (_14 = config.spotMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.oracleInfos) !== null && _15 !== void 0 ? _15 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
217
|
+
resubTimeoutMs: (_16 = config.accountSubscription) === null || _16 === void 0 ? void 0 : _16.resubTimeoutMs,
|
|
218
|
+
logResubMessages: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.logResubMessages,
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
221
|
else {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
const accountSubscriberClass = (_19 = (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.driftClientAccountSubscriber) !== null && _19 !== void 0 ? _19 : webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber;
|
|
223
|
+
this.accountSubscriber = new accountSubscriberClass(this.program, (_20 = config.perpMarketIndexes) !== null && _20 !== void 0 ? _20 : [], (_21 = config.spotMarketIndexes) !== null && _21 !== void 0 ? _21 : [], (_22 = config.oracleInfos) !== null && _22 !== void 0 ? _22 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
224
|
+
resubTimeoutMs: (_23 = config.accountSubscription) === null || _23 === void 0 ? void 0 : _23.resubTimeoutMs,
|
|
225
|
+
logResubMessages: (_24 = config.accountSubscription) === null || _24 === void 0 ? void 0 : _24.logResubMessages,
|
|
226
|
+
}, (_25 = config.accountSubscription) === null || _25 === void 0 ? void 0 : _25.commitment);
|
|
225
227
|
}
|
|
226
228
|
this.eventEmitter = this.accountSubscriber.eventEmitter;
|
|
227
229
|
this.metricsEventEmitter = new events_1.EventEmitter();
|
|
@@ -229,7 +231,7 @@ class DriftClient {
|
|
|
229
231
|
this.enableMetricsEvents = true;
|
|
230
232
|
}
|
|
231
233
|
this.txSender =
|
|
232
|
-
(
|
|
234
|
+
(_26 = config.txSender) !== null && _26 !== void 0 ? _26 : new retryTxSender_1.RetryTxSender({
|
|
233
235
|
connection: this.connection,
|
|
234
236
|
wallet: this.wallet,
|
|
235
237
|
opts: this.opts,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Commitment, ConfirmOptions, Connection, PublicKey, TransactionVersion } from '@solana/web3.js';
|
|
4
|
-
import { IWallet, TxParams } from './types';
|
|
4
|
+
import { IWallet, TxParams, UserAccount } from './types';
|
|
5
5
|
import { OracleInfo } from './oracles/types';
|
|
6
6
|
import { BulkAccountLoader } from './accounts/bulkAccountLoader';
|
|
7
7
|
import { DriftEnv } from './config';
|
|
@@ -14,6 +14,9 @@ import { WebSocketAccountSubscriberV2 } from './accounts/webSocketAccountSubscri
|
|
|
14
14
|
import { grpcDriftClientAccountSubscriberV2 } from './accounts/grpcDriftClientAccountSubscriberV2';
|
|
15
15
|
import { grpcDriftClientAccountSubscriber } from './accounts/grpcDriftClientAccountSubscriber';
|
|
16
16
|
import { grpcMultiUserAccountSubscriber } from './accounts/grpcMultiUserAccountSubscriber';
|
|
17
|
+
import { WebSocketProgramAccountSubscriber } from './accounts/webSocketProgramAccountSubscriber';
|
|
18
|
+
import { WebSocketDriftClientAccountSubscriber } from './accounts/webSocketDriftClientAccountSubscriber';
|
|
19
|
+
import { WebSocketDriftClientAccountSubscriberV2 } from './accounts/webSocketDriftClientAccountSubscriberV2';
|
|
17
20
|
export type DriftClientConfig = {
|
|
18
21
|
connection: Connection;
|
|
19
22
|
wallet: IWallet;
|
|
@@ -56,8 +59,10 @@ export type DriftClientSubscriptionConfig = {
|
|
|
56
59
|
resubTimeoutMs?: number;
|
|
57
60
|
logResubMessages?: boolean;
|
|
58
61
|
commitment?: Commitment;
|
|
62
|
+
programUserAccountSubscriber?: WebSocketProgramAccountSubscriber<UserAccount>;
|
|
59
63
|
perpMarketAccountSubscriber?: new (accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, commitment?: Commitment) => WebSocketAccountSubscriberV2<any> | WebSocketAccountSubscriber<any>;
|
|
60
|
-
|
|
64
|
+
/** If you use V2 here, whatever you pass for perpMarketAccountSubscriber will be ignored and it will use v2 under the hood regardless */
|
|
65
|
+
driftClientAccountSubscriber?: new (program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], shouldFindAllMarketsAndOracles: boolean, delistedMarketSetting: DelistedMarketSetting) => WebSocketDriftClientAccountSubscriber | WebSocketDriftClientAccountSubscriberV2;
|
|
61
66
|
} | {
|
|
62
67
|
type: 'polling';
|
|
63
68
|
accountLoader: BulkAccountLoader;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.145.
|
|
2
|
+
"version": "2.145.1",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -4453,6 +4453,37 @@
|
|
|
4453
4453
|
],
|
|
4454
4454
|
"args": []
|
|
4455
4455
|
},
|
|
4456
|
+
{
|
|
4457
|
+
"name": "resizeAmmCache",
|
|
4458
|
+
"accounts": [
|
|
4459
|
+
{
|
|
4460
|
+
"name": "admin",
|
|
4461
|
+
"isMut": true,
|
|
4462
|
+
"isSigner": true
|
|
4463
|
+
},
|
|
4464
|
+
{
|
|
4465
|
+
"name": "state",
|
|
4466
|
+
"isMut": false,
|
|
4467
|
+
"isSigner": false
|
|
4468
|
+
},
|
|
4469
|
+
{
|
|
4470
|
+
"name": "ammCache",
|
|
4471
|
+
"isMut": true,
|
|
4472
|
+
"isSigner": false
|
|
4473
|
+
},
|
|
4474
|
+
{
|
|
4475
|
+
"name": "rent",
|
|
4476
|
+
"isMut": false,
|
|
4477
|
+
"isSigner": false
|
|
4478
|
+
},
|
|
4479
|
+
{
|
|
4480
|
+
"name": "systemProgram",
|
|
4481
|
+
"isMut": false,
|
|
4482
|
+
"isSigner": false
|
|
4483
|
+
}
|
|
4484
|
+
],
|
|
4485
|
+
"args": []
|
|
4486
|
+
},
|
|
4456
4487
|
{
|
|
4457
4488
|
"name": "updateInitialAmmCacheInfo",
|
|
4458
4489
|
"accounts": [
|
|
@@ -15118,6 +15149,9 @@
|
|
|
15118
15149
|
},
|
|
15119
15150
|
{
|
|
15120
15151
|
"name": "SafeMMOracle"
|
|
15152
|
+
},
|
|
15153
|
+
{
|
|
15154
|
+
"name": "Margin"
|
|
15121
15155
|
}
|
|
15122
15156
|
]
|
|
15123
15157
|
}
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export * from './accounts/webSocketDriftClientAccountSubscriber';
|
|
|
11
11
|
export * from './accounts/webSocketInsuranceFundStakeAccountSubscriber';
|
|
12
12
|
export * from './accounts/webSocketHighLeverageModeConfigAccountSubscriber';
|
|
13
13
|
export { WebSocketAccountSubscriberV2 } from './accounts/webSocketAccountSubscriberV2';
|
|
14
|
+
export { WebSocketProgramAccountSubscriber } from './accounts/webSocketProgramAccountSubscriber';
|
|
15
|
+
export { WebSocketProgramUserAccountSubscriber } from './accounts/websocketProgramUserAccountSubscriber';
|
|
16
|
+
export { WebSocketProgramAccountsSubscriberV2 } from './accounts/webSocketProgramAccountsSubscriberV2';
|
|
17
|
+
export { WebSocketDriftClientAccountSubscriberV2 } from './accounts/webSocketDriftClientAccountSubscriberV2';
|
|
14
18
|
export * from './accounts/bulkAccountLoader';
|
|
15
19
|
export * from './accounts/bulkUserSubscription';
|
|
16
20
|
export * from './accounts/bulkUserStatsSubscription';
|
package/lib/browser/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.pyth = exports.PublicKey = exports.BN = exports.CustomizedCadenceBulkAccountLoader = exports.WebSocketAccountSubscriberV2 = void 0;
|
|
20
|
+
exports.pyth = exports.PublicKey = exports.BN = exports.CustomizedCadenceBulkAccountLoader = exports.WebSocketDriftClientAccountSubscriberV2 = exports.WebSocketProgramAccountsSubscriberV2 = exports.WebSocketProgramUserAccountSubscriber = exports.WebSocketProgramAccountSubscriber = exports.WebSocketAccountSubscriberV2 = void 0;
|
|
21
21
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
22
22
|
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return anchor_1.BN; } });
|
|
23
23
|
const web3_js_1 = require("@solana/web3.js");
|
|
@@ -35,6 +35,14 @@ __exportStar(require("./accounts/webSocketInsuranceFundStakeAccountSubscriber"),
|
|
|
35
35
|
__exportStar(require("./accounts/webSocketHighLeverageModeConfigAccountSubscriber"), exports);
|
|
36
36
|
var webSocketAccountSubscriberV2_1 = require("./accounts/webSocketAccountSubscriberV2");
|
|
37
37
|
Object.defineProperty(exports, "WebSocketAccountSubscriberV2", { enumerable: true, get: function () { return webSocketAccountSubscriberV2_1.WebSocketAccountSubscriberV2; } });
|
|
38
|
+
var webSocketProgramAccountSubscriber_1 = require("./accounts/webSocketProgramAccountSubscriber");
|
|
39
|
+
Object.defineProperty(exports, "WebSocketProgramAccountSubscriber", { enumerable: true, get: function () { return webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber; } });
|
|
40
|
+
var websocketProgramUserAccountSubscriber_1 = require("./accounts/websocketProgramUserAccountSubscriber");
|
|
41
|
+
Object.defineProperty(exports, "WebSocketProgramUserAccountSubscriber", { enumerable: true, get: function () { return websocketProgramUserAccountSubscriber_1.WebSocketProgramUserAccountSubscriber; } });
|
|
42
|
+
var webSocketProgramAccountsSubscriberV2_1 = require("./accounts/webSocketProgramAccountsSubscriberV2");
|
|
43
|
+
Object.defineProperty(exports, "WebSocketProgramAccountsSubscriberV2", { enumerable: true, get: function () { return webSocketProgramAccountsSubscriberV2_1.WebSocketProgramAccountsSubscriberV2; } });
|
|
44
|
+
var webSocketDriftClientAccountSubscriberV2_1 = require("./accounts/webSocketDriftClientAccountSubscriberV2");
|
|
45
|
+
Object.defineProperty(exports, "WebSocketDriftClientAccountSubscriberV2", { enumerable: true, get: function () { return webSocketDriftClientAccountSubscriberV2_1.WebSocketDriftClientAccountSubscriberV2; } });
|
|
38
46
|
__exportStar(require("./accounts/bulkAccountLoader"), exports);
|
|
39
47
|
__exportStar(require("./accounts/bulkUserSubscription"), exports);
|
|
40
48
|
__exportStar(require("./accounts/bulkUserStatsSubscription"), exports);
|
package/lib/browser/types.d.ts
CHANGED
|
@@ -1191,6 +1191,8 @@ export type PerpPosition = {
|
|
|
1191
1191
|
lastBaseAssetAmountPerLp: BN;
|
|
1192
1192
|
lastQuoteAssetAmountPerLp: BN;
|
|
1193
1193
|
perLpBase: number;
|
|
1194
|
+
isolatedPositionScaledBalance: BN;
|
|
1195
|
+
positionFlag: number;
|
|
1194
1196
|
};
|
|
1195
1197
|
export type UserStatsAccount = {
|
|
1196
1198
|
numberOfSubAccounts: number;
|
package/lib/browser/user.js
CHANGED
|
@@ -3,17 +3,75 @@
|
|
|
3
3
|
import { BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import { Commitment, Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
6
|
-
import { AccountInfoBase, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData } from 'gill';
|
|
7
|
-
|
|
6
|
+
import { AccountInfoBase, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, Address } from 'gill';
|
|
7
|
+
/**
|
|
8
|
+
* WebSocketProgramAccountsSubscriberV2
|
|
9
|
+
*
|
|
10
|
+
* High-level overview
|
|
11
|
+
* - WebSocket-first subscriber for Solana program accounts that also layers in
|
|
12
|
+
* targeted polling to detect missed updates reliably.
|
|
13
|
+
* - Emits decoded account updates via the provided `onChange` callback.
|
|
14
|
+
* - Designed to focus extra work on the specific accounts the consumer cares
|
|
15
|
+
* about ("monitored accounts") while keeping baseline WS behavior for the
|
|
16
|
+
* full program subscription.
|
|
17
|
+
*
|
|
18
|
+
* Why polling if this is a WebSocket subscriber?
|
|
19
|
+
* - WS infra can stall, drop, or reorder notifications under network stress or
|
|
20
|
+
* provider hiccups. When that happens, critical account changes can be missed.
|
|
21
|
+
* - To mitigate this, the class accepts a set of accounts (provided via constructor) to monitor
|
|
22
|
+
* and uses light polling to verify whether a WS change was missed.
|
|
23
|
+
* - If polling detects a newer slot with different data than the last seen
|
|
24
|
+
* buffer, a centralized resubscription is triggered to restore a clean stream.
|
|
25
|
+
*
|
|
26
|
+
* Initial fetch (on subscribe)
|
|
27
|
+
* - On `subscribe()`, we first perform a single batched fetch of all monitored
|
|
28
|
+
* accounts ("initial monitor fetch").
|
|
29
|
+
* - Purpose: seed the internal `bufferAndSlotMap` and emit the latest state so
|
|
30
|
+
* consumers have up-to-date data immediately, even before WS events arrive.
|
|
31
|
+
* - This step does not decide resubscription; it only establishes ground truth.
|
|
32
|
+
*
|
|
33
|
+
* Continuous polling (only for monitored accounts)
|
|
34
|
+
* - After seeding, each monitored account is put into a monitoring cycle:
|
|
35
|
+
* 1) If no WS notification for an account is observed for `pollingIntervalMs`,
|
|
36
|
+
* we enqueue it for a batched fetch (buffered for a short window).
|
|
37
|
+
* 2) Once an account enters the "currently polling" set, a shared batch poll
|
|
38
|
+
* runs every `pollingIntervalMs` across all such accounts.
|
|
39
|
+
* 3) If WS notifications resume for an account, that account is removed from
|
|
40
|
+
* the polling set and returns to passive monitoring.
|
|
41
|
+
* - Polling compares the newly fetched buffer with the last stored buffer at a
|
|
42
|
+
* later slot. A difference indicates a missed update; we schedule a single
|
|
43
|
+
* resubscription (coalesced across accounts) to re-sync.
|
|
44
|
+
*
|
|
45
|
+
* Accounts the consumer cares about
|
|
46
|
+
* - Provide accounts up-front via the constructor `accountsToMonitor`, or add
|
|
47
|
+
* them dynamically with `addAccountToMonitor()` and remove with
|
|
48
|
+
* `removeAccountFromMonitor()`.
|
|
49
|
+
* - Only these accounts incur additional polling safeguards; other accounts are
|
|
50
|
+
* still processed from the WS stream normally.
|
|
51
|
+
*
|
|
52
|
+
* Resubscription strategy
|
|
53
|
+
* - Missed updates from any monitored account are coalesced and trigger a single
|
|
54
|
+
* resubscription after a short delay. This avoids rapid churn.
|
|
55
|
+
* - If `resubOpts.resubTimeoutMs` is set, an inactivity timer also performs a
|
|
56
|
+
* batch check of monitored accounts. If a missed update is found, the same
|
|
57
|
+
* centralized resubscription flow is used.
|
|
58
|
+
*
|
|
59
|
+
* Tuning knobs
|
|
60
|
+
* - `setPollingInterval(ms)`: adjust how often monitoring/polling runs
|
|
61
|
+
* (default 30s). Shorter = faster detection, higher RPC load.
|
|
62
|
+
* - Debounced immediate poll (~100ms): batches accounts added to polling right after inactivity.
|
|
63
|
+
* - Batch size for `getMultipleAccounts` is limited to 100, requests are chunked
|
|
64
|
+
* and processed concurrently.
|
|
65
|
+
*/
|
|
66
|
+
export declare class WebSocketProgramAccountsSubscriberV2<T> implements ProgramAccountSubscriber<T> {
|
|
8
67
|
subscriptionName: string;
|
|
9
68
|
accountDiscriminator: string;
|
|
10
|
-
bufferAndSlot?: BufferAndSlot;
|
|
11
69
|
bufferAndSlotMap: Map<string, BufferAndSlot>;
|
|
12
70
|
program: Program;
|
|
13
71
|
decodeBuffer: (accountName: string, ix: Buffer) => T;
|
|
14
72
|
onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void;
|
|
15
73
|
listenerId?: number;
|
|
16
|
-
resubOpts
|
|
74
|
+
resubOpts: ResubOpts;
|
|
17
75
|
isUnsubscribing: boolean;
|
|
18
76
|
timeoutId?: ReturnType<typeof setTimeout>;
|
|
19
77
|
options: {
|
|
@@ -30,25 +88,59 @@ export declare class WebSocketProgramAccountSubscriberV2<T> implements ProgramAc
|
|
|
30
88
|
private lastWsNotificationTime;
|
|
31
89
|
private accountsCurrentlyPolling;
|
|
32
90
|
private batchPollingTimeout?;
|
|
91
|
+
private debouncedImmediatePollTimeout?;
|
|
92
|
+
private debouncedImmediatePollMs;
|
|
93
|
+
private missedChangeDetected;
|
|
94
|
+
private resubscriptionTimeout?;
|
|
95
|
+
private accountsWithMissedUpdates;
|
|
33
96
|
constructor(subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => T, options?: {
|
|
34
97
|
filters: MemcmpFilter[];
|
|
35
98
|
commitment?: Commitment;
|
|
36
99
|
}, resubOpts?: ResubOpts, accountsToMonitor?: PublicKey[]);
|
|
100
|
+
private handleNotificationLoop;
|
|
37
101
|
subscribe(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void): Promise<void>;
|
|
38
102
|
protected setTimeout(): void;
|
|
39
103
|
handleRpcResponse(context: {
|
|
40
104
|
slot: bigint;
|
|
41
|
-
}, accountInfo?: AccountInfoBase & (AccountInfoWithBase58EncodedData | AccountInfoWithBase64EncodedData)): void;
|
|
105
|
+
}, accountId: Address, accountInfo?: AccountInfoBase & (AccountInfoWithBase58EncodedData | AccountInfoWithBase64EncodedData)['data']): void;
|
|
42
106
|
private startMonitoringForAccounts;
|
|
43
107
|
private startMonitoringForAccount;
|
|
44
|
-
private
|
|
108
|
+
private scheduleDebouncedImmediatePoll;
|
|
45
109
|
private startBatchPolling;
|
|
46
110
|
private pollAllAccounts;
|
|
47
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Fetches and populates all monitored accounts data without checking for missed changes
|
|
113
|
+
* This is used during initial subscription to populate data
|
|
114
|
+
*/
|
|
115
|
+
private fetchAndPopulateAllMonitoredAccounts;
|
|
116
|
+
/**
|
|
117
|
+
* Fetches all monitored accounts and checks for missed changes
|
|
118
|
+
* Returns true if a missed change was detected and resubscription is needed
|
|
119
|
+
*/
|
|
120
|
+
private fetchAllMonitoredAccounts;
|
|
121
|
+
private fetchAccountsBatch;
|
|
48
122
|
private clearPollingTimeouts;
|
|
123
|
+
/**
|
|
124
|
+
* Centralized resubscription handler that only resubscribes once after checking all accounts
|
|
125
|
+
*/
|
|
126
|
+
private handleResubscription;
|
|
127
|
+
/**
|
|
128
|
+
* Signal that a missed change was detected and schedule resubscription
|
|
129
|
+
*/
|
|
130
|
+
private signalMissedChange;
|
|
49
131
|
unsubscribe(onResub?: boolean): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Add an account to the monitored set.
|
|
134
|
+
* - Monitored accounts are subject to initial fetch and periodic batch polls
|
|
135
|
+
* if WS notifications are not observed within `pollingIntervalMs`.
|
|
136
|
+
*/
|
|
50
137
|
addAccountToMonitor(accountId: PublicKey): void;
|
|
51
138
|
removeAccountFromMonitor(accountId: PublicKey): void;
|
|
139
|
+
/**
|
|
140
|
+
* Set the monitoring/polling interval for monitored accounts.
|
|
141
|
+
* Shorter intervals detect missed updates sooner but increase RPC load.
|
|
142
|
+
*/
|
|
52
143
|
setPollingInterval(intervalMs: number): void;
|
|
144
|
+
private updateBufferAndHandleChange;
|
|
53
145
|
}
|
|
54
146
|
//# sourceMappingURL=webSocketProgramAccountSubscriberV2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webSocketProgramAccountSubscriberV2.d.ts","sourceRoot":"","sources":["../../../src/accounts/webSocketProgramAccountSubscriberV2.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAkB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EACN,eAAe,EACf,gCAAgC,EAChC,gCAAgC,EAKhC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"webSocketProgramAccountSubscriberV2.d.ts","sourceRoot":"","sources":["../../../src/accounts/webSocketProgramAccountSubscriberV2.ts"],"names":[],"mappings":"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"}
|