@drift-labs/sdk 0.2.0-master.26 → 0.2.0-master.28
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/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +1 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +3 -0
- package/lib/accounts/types.d.ts +2 -0
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +1 -0
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +3 -0
- package/lib/admin.d.ts +5 -2
- package/lib/admin.js +30 -4
- package/lib/clearingHouse.d.ts +3 -0
- package/lib/clearingHouse.js +19 -1
- package/lib/clearingHouseUser.d.ts +11 -9
- package/lib/clearingHouseUser.js +184 -108
- package/lib/config.js +1 -1
- package/lib/dlob/DLOB.d.ts +73 -0
- package/lib/dlob/DLOB.js +557 -0
- package/lib/dlob/DLOBNode.d.ts +52 -0
- package/lib/dlob/DLOBNode.js +82 -0
- package/lib/dlob/NodeList.d.ts +26 -0
- package/lib/dlob/NodeList.js +138 -0
- package/lib/idl/clearing_house.json +123 -203
- package/lib/index.d.ts +5 -0
- package/lib/index.js +5 -0
- package/lib/math/market.d.ts +3 -2
- package/lib/math/market.js +17 -12
- package/lib/math/orders.d.ts +3 -3
- package/lib/math/orders.js +31 -16
- package/lib/math/position.d.ts +3 -3
- package/lib/math/position.js +23 -16
- package/lib/math/repeg.js +8 -0
- package/lib/math/spotBalance.d.ts +3 -0
- package/lib/math/spotBalance.js +18 -1
- package/lib/math/spotPosition.d.ts +5 -1
- package/lib/math/spotPosition.js +16 -1
- package/lib/types.d.ts +25 -24
- package/lib/types.js +9 -3
- package/lib/userMap/userMap.d.ts +25 -0
- package/lib/userMap/userMap.js +73 -0
- package/lib/userMap/userStatsMap.d.ts +19 -0
- package/lib/userMap/userStatsMap.js +68 -0
- package/package.json +6 -3
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +4 -0
- package/src/accounts/types.ts +1 -0
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +6 -0
- package/src/admin.ts +50 -8
- package/src/clearingHouse.ts +30 -1
- package/src/clearingHouseUser.ts +366 -167
- package/src/config.ts +1 -1
- package/src/dlob/DLOB.ts +884 -0
- package/src/dlob/DLOBNode.ts +163 -0
- package/src/dlob/NodeList.ts +185 -0
- package/src/idl/clearing_house.json +123 -203
- package/src/index.ts +5 -0
- package/src/math/market.ts +22 -13
- package/src/math/orders.ts +29 -21
- package/src/math/position.ts +36 -22
- package/src/math/repeg.ts +9 -0
- package/src/math/spotBalance.ts +26 -0
- package/src/math/spotPosition.ts +42 -1
- package/src/types.ts +26 -24
- package/src/userMap/userMap.ts +100 -0
- package/src/userMap/userStatsMap.ts +110 -0
- package/tests/bn/test.ts +2 -3
- package/tests/dlob/helpers.ts +322 -0
- package/tests/dlob/test.ts +2865 -0
- package/my-script/.env +0 -7
- package/my-script/getUserStats.ts +0 -106
- package/my-script/multiConnections.ts +0 -119
- package/my-script/test-regex.ts +0 -11
- package/my-script/utils.ts +0 -52
- package/src/accounts/bulkAccountLoader.js +0 -249
- package/src/accounts/bulkUserStatsSubscription.js +0 -75
- package/src/accounts/bulkUserSubscription.js +0 -75
- package/src/accounts/fetch.js +0 -92
- package/src/accounts/pollingClearingHouseAccountSubscriber.js +0 -465
- package/src/accounts/pollingOracleSubscriber.js +0 -156
- package/src/accounts/pollingTokenAccountSubscriber.js +0 -141
- package/src/accounts/pollingUserAccountSubscriber.js +0 -208
- package/src/accounts/pollingUserStatsAccountSubscriber.js +0 -208
- package/src/accounts/types.js +0 -28
- package/src/accounts/utils.js +0 -7
- package/src/accounts/webSocketAccountSubscriber.js +0 -138
- package/src/accounts/webSocketClearingHouseAccountSubscriber.js +0 -433
- package/src/accounts/webSocketUserAccountSubscriber.js +0 -113
- package/src/accounts/webSocketUserStatsAccountSubsriber.js +0 -113
- package/src/addresses/pda.js +0 -186
- package/src/admin.js +0 -1284
- package/src/assert/assert.js +0 -9
- package/src/clearingHouse.js +0 -3433
- package/src/clearingHouseConfig.js +0 -2
- package/src/clearingHouseUser.js +0 -874
- package/src/clearingHouseUserConfig.js +0 -2
- package/src/clearingHouseUserStats.js +0 -115
- package/src/clearingHouseUserStatsConfig.js +0 -2
- package/src/config.js +0 -80
- package/src/constants/numericConstants.js +0 -48
- package/src/constants/perpMarkets.js +0 -42
- package/src/constants/spotMarkets.js +0 -51
- package/src/events/eventList.js +0 -120
- package/src/events/eventSubscriber.js +0 -202
- package/src/events/fetchLogs.js +0 -117
- package/src/events/pollingLogProvider.js +0 -113
- package/src/events/sort.js +0 -41
- package/src/events/txEventCache.js +0 -74
- package/src/events/types.js +0 -25
- package/src/events/webSocketLogProvider.js +0 -76
- package/src/factory/bigNum.js +0 -393
- package/src/factory/oracleClient.js +0 -20
- package/src/index.js +0 -75
- package/src/math/amm.js +0 -422
- package/src/math/auction.js +0 -42
- package/src/math/conversion.js +0 -12
- package/src/math/funding.js +0 -296
- package/src/math/insurance.js +0 -27
- package/src/math/margin.js +0 -77
- package/src/math/market.js +0 -105
- package/src/math/oracles.js +0 -56
- package/src/math/orders.js +0 -153
- package/src/math/position.js +0 -172
- package/src/math/repeg.js +0 -128
- package/src/math/spotBalance.js +0 -176
- package/src/math/spotMarket.js +0 -8
- package/src/math/spotPosition.js +0 -8
- package/src/math/trade.js +0 -260
- package/src/math/utils.js +0 -27
- package/src/oracles/oracleClientCache.js +0 -20
- package/src/oracles/pythClient.js +0 -81
- package/src/oracles/quoteAssetOracleClient.js +0 -63
- package/src/oracles/switchboardClient.js +0 -101
- package/src/oracles/types.js +0 -2
- package/src/orderParams.js +0 -28
- package/src/serum/serumSubscriber.js +0 -102
- package/src/serum/types.js +0 -2
- package/src/slot/SlotSubscriber.js +0 -86
- package/src/token/index.js +0 -38
- package/src/tokenFaucet.js +0 -323
- package/src/tx/retryTxSender.js +0 -280
- package/src/tx/types.js +0 -2
- package/src/tx/utils.js +0 -18
- package/src/types.js +0 -216
- package/src/userName.js +0 -20
- package/src/util/computeUnits.js +0 -62
- package/src/util/promiseTimeout.js +0 -14
- package/src/util/tps.js +0 -61
- package/src/wallet.js +0 -72
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
39
|
-
exports.WebSocketClearingHouseAccountSubscriber = void 0;
|
|
40
|
-
var types_1 = require("./types");
|
|
41
|
-
var events_1 = require("events");
|
|
42
|
-
var pda_1 = require("../addresses/pda");
|
|
43
|
-
var webSocketAccountSubscriber_1 = require("./webSocketAccountSubscriber");
|
|
44
|
-
var web3_js_1 = require("@solana/web3.js");
|
|
45
|
-
var oracleClientCache_1 = require("../oracles/oracleClientCache");
|
|
46
|
-
var quoteAssetOracleClient_1 = require("../oracles/quoteAssetOracleClient");
|
|
47
|
-
var WebSocketClearingHouseAccountSubscriber = /** @class */ (function () {
|
|
48
|
-
function WebSocketClearingHouseAccountSubscriber(program, perpMarketIndexes, spotMarketIndexes, oracleInfos) {
|
|
49
|
-
this.oracleClientCache = new oracleClientCache_1.OracleClientCache();
|
|
50
|
-
this.perpMarketAccountSubscribers = new Map();
|
|
51
|
-
this.spotMarketAccountSubscribers = new Map();
|
|
52
|
-
this.oracleSubscribers = new Map();
|
|
53
|
-
this.isSubscribing = false;
|
|
54
|
-
this.isSubscribed = false;
|
|
55
|
-
this.program = program;
|
|
56
|
-
this.eventEmitter = new events_1.EventEmitter();
|
|
57
|
-
this.perpMarketIndexes = perpMarketIndexes;
|
|
58
|
-
this.spotMarketIndexes = spotMarketIndexes;
|
|
59
|
-
this.oracleInfos = oracleInfos;
|
|
60
|
-
}
|
|
61
|
-
WebSocketClearingHouseAccountSubscriber.prototype.subscribe = function () {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var statePublicKey;
|
|
64
|
-
var _this = this;
|
|
65
|
-
return __generator(this, function (_a) {
|
|
66
|
-
switch (_a.label) {
|
|
67
|
-
case 0:
|
|
68
|
-
if (this.isSubscribed) {
|
|
69
|
-
return [2 /*return*/, true];
|
|
70
|
-
}
|
|
71
|
-
if (!this.isSubscribing) return [3 /*break*/, 2];
|
|
72
|
-
return [4 /*yield*/, this.subscriptionPromise];
|
|
73
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
74
|
-
case 2:
|
|
75
|
-
this.isSubscribing = true;
|
|
76
|
-
this.subscriptionPromise = new Promise(function (res) {
|
|
77
|
-
_this.subscriptionPromiseResolver = res;
|
|
78
|
-
});
|
|
79
|
-
return [4 /*yield*/, (0, pda_1.getClearingHouseStateAccountPublicKey)(this.program.programId)];
|
|
80
|
-
case 3:
|
|
81
|
-
statePublicKey = _a.sent();
|
|
82
|
-
// create and activate main state account subscription
|
|
83
|
-
this.stateAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('state', this.program, statePublicKey);
|
|
84
|
-
return [4 /*yield*/, this.stateAccountSubscriber.subscribe(function (data) {
|
|
85
|
-
_this.eventEmitter.emit('stateAccountUpdate', data);
|
|
86
|
-
_this.eventEmitter.emit('update');
|
|
87
|
-
})];
|
|
88
|
-
case 4:
|
|
89
|
-
_a.sent();
|
|
90
|
-
// subscribe to market accounts
|
|
91
|
-
return [4 /*yield*/, this.subscribeToMarketAccounts()];
|
|
92
|
-
case 5:
|
|
93
|
-
// subscribe to market accounts
|
|
94
|
-
_a.sent();
|
|
95
|
-
// subscribe to spot market accounts
|
|
96
|
-
return [4 /*yield*/, this.subscribeToSpotMarketAccounts()];
|
|
97
|
-
case 6:
|
|
98
|
-
// subscribe to spot market accounts
|
|
99
|
-
_a.sent();
|
|
100
|
-
// subscribe to oracles
|
|
101
|
-
return [4 /*yield*/, this.subscribeToOracles()];
|
|
102
|
-
case 7:
|
|
103
|
-
// subscribe to oracles
|
|
104
|
-
_a.sent();
|
|
105
|
-
this.eventEmitter.emit('update');
|
|
106
|
-
this.isSubscribing = false;
|
|
107
|
-
this.isSubscribed = true;
|
|
108
|
-
this.subscriptionPromiseResolver(true);
|
|
109
|
-
return [2 /*return*/, true];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
WebSocketClearingHouseAccountSubscriber.prototype.subscribeToMarketAccounts = function () {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
var _i, _a, marketIndex;
|
|
117
|
-
return __generator(this, function (_b) {
|
|
118
|
-
switch (_b.label) {
|
|
119
|
-
case 0:
|
|
120
|
-
_i = 0, _a = this.perpMarketIndexes;
|
|
121
|
-
_b.label = 1;
|
|
122
|
-
case 1:
|
|
123
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
124
|
-
marketIndex = _a[_i];
|
|
125
|
-
return [4 /*yield*/, this.subscribeToMarketAccount(marketIndex)];
|
|
126
|
-
case 2:
|
|
127
|
-
_b.sent();
|
|
128
|
-
_b.label = 3;
|
|
129
|
-
case 3:
|
|
130
|
-
_i++;
|
|
131
|
-
return [3 /*break*/, 1];
|
|
132
|
-
case 4: return [2 /*return*/, true];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
WebSocketClearingHouseAccountSubscriber.prototype.subscribeToMarketAccount = function (marketIndex) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
var marketPublicKey, accountSubscriber;
|
|
140
|
-
var _this = this;
|
|
141
|
-
return __generator(this, function (_a) {
|
|
142
|
-
switch (_a.label) {
|
|
143
|
-
case 0: return [4 /*yield*/, (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex)];
|
|
144
|
-
case 1:
|
|
145
|
-
marketPublicKey = _a.sent();
|
|
146
|
-
accountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('perpMarket', this.program, marketPublicKey);
|
|
147
|
-
return [4 /*yield*/, accountSubscriber.subscribe(function (data) {
|
|
148
|
-
_this.eventEmitter.emit('perpMarketAccountUpdate', data);
|
|
149
|
-
_this.eventEmitter.emit('update');
|
|
150
|
-
})];
|
|
151
|
-
case 2:
|
|
152
|
-
_a.sent();
|
|
153
|
-
this.perpMarketAccountSubscribers.set(marketIndex.toNumber(), accountSubscriber);
|
|
154
|
-
return [2 /*return*/, true];
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
WebSocketClearingHouseAccountSubscriber.prototype.subscribeToSpotMarketAccounts = function () {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
161
|
-
var _i, _a, marketIndex;
|
|
162
|
-
return __generator(this, function (_b) {
|
|
163
|
-
switch (_b.label) {
|
|
164
|
-
case 0:
|
|
165
|
-
_i = 0, _a = this.spotMarketIndexes;
|
|
166
|
-
_b.label = 1;
|
|
167
|
-
case 1:
|
|
168
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
169
|
-
marketIndex = _a[_i];
|
|
170
|
-
return [4 /*yield*/, this.subscribeToSpotMarketAccount(marketIndex)];
|
|
171
|
-
case 2:
|
|
172
|
-
_b.sent();
|
|
173
|
-
_b.label = 3;
|
|
174
|
-
case 3:
|
|
175
|
-
_i++;
|
|
176
|
-
return [3 /*break*/, 1];
|
|
177
|
-
case 4: return [2 /*return*/, true];
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
WebSocketClearingHouseAccountSubscriber.prototype.subscribeToSpotMarketAccount = function (marketIndex) {
|
|
183
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
-
var marketPublicKey, accountSubscriber;
|
|
185
|
-
var _this = this;
|
|
186
|
-
return __generator(this, function (_a) {
|
|
187
|
-
switch (_a.label) {
|
|
188
|
-
case 0: return [4 /*yield*/, (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex)];
|
|
189
|
-
case 1:
|
|
190
|
-
marketPublicKey = _a.sent();
|
|
191
|
-
accountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('spotMarket', this.program, marketPublicKey);
|
|
192
|
-
return [4 /*yield*/, accountSubscriber.subscribe(function (data) {
|
|
193
|
-
_this.eventEmitter.emit('spotMarketAccountUpdate', data);
|
|
194
|
-
_this.eventEmitter.emit('update');
|
|
195
|
-
})];
|
|
196
|
-
case 2:
|
|
197
|
-
_a.sent();
|
|
198
|
-
this.spotMarketAccountSubscribers.set(marketIndex.toNumber(), accountSubscriber);
|
|
199
|
-
return [2 /*return*/, true];
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
WebSocketClearingHouseAccountSubscriber.prototype.subscribeToOracles = function () {
|
|
205
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
-
var _i, _a, oracleInfo;
|
|
207
|
-
return __generator(this, function (_b) {
|
|
208
|
-
switch (_b.label) {
|
|
209
|
-
case 0:
|
|
210
|
-
_i = 0, _a = this.oracleInfos;
|
|
211
|
-
_b.label = 1;
|
|
212
|
-
case 1:
|
|
213
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
214
|
-
oracleInfo = _a[_i];
|
|
215
|
-
if (!!oracleInfo.publicKey.equals(web3_js_1.PublicKey["default"])) return [3 /*break*/, 3];
|
|
216
|
-
return [4 /*yield*/, this.subscribeToOracle(oracleInfo)];
|
|
217
|
-
case 2:
|
|
218
|
-
_b.sent();
|
|
219
|
-
_b.label = 3;
|
|
220
|
-
case 3:
|
|
221
|
-
_i++;
|
|
222
|
-
return [3 /*break*/, 1];
|
|
223
|
-
case 4: return [2 /*return*/, true];
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
WebSocketClearingHouseAccountSubscriber.prototype.subscribeToOracle = function (oracleInfo) {
|
|
229
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
-
var client, accountSubscriber;
|
|
231
|
-
var _this = this;
|
|
232
|
-
return __generator(this, function (_a) {
|
|
233
|
-
switch (_a.label) {
|
|
234
|
-
case 0:
|
|
235
|
-
client = this.oracleClientCache.get(oracleInfo.source, this.program.provider.connection);
|
|
236
|
-
accountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('oracle', this.program, oracleInfo.publicKey, function (buffer) {
|
|
237
|
-
return client.getOraclePriceDataFromBuffer(buffer);
|
|
238
|
-
});
|
|
239
|
-
return [4 /*yield*/, accountSubscriber.subscribe(function (data) {
|
|
240
|
-
_this.eventEmitter.emit('oraclePriceUpdate', oracleInfo.publicKey, data);
|
|
241
|
-
_this.eventEmitter.emit('update');
|
|
242
|
-
})];
|
|
243
|
-
case 1:
|
|
244
|
-
_a.sent();
|
|
245
|
-
this.oracleSubscribers.set(oracleInfo.publicKey.toString(), accountSubscriber);
|
|
246
|
-
return [2 /*return*/, true];
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
WebSocketClearingHouseAccountSubscriber.prototype.unsubscribeFromMarketAccounts = function () {
|
|
252
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
-
var _i, _a, accountSubscriber;
|
|
254
|
-
return __generator(this, function (_b) {
|
|
255
|
-
switch (_b.label) {
|
|
256
|
-
case 0:
|
|
257
|
-
_i = 0, _a = this.perpMarketAccountSubscribers.values();
|
|
258
|
-
_b.label = 1;
|
|
259
|
-
case 1:
|
|
260
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
261
|
-
accountSubscriber = _a[_i];
|
|
262
|
-
return [4 /*yield*/, accountSubscriber.unsubscribe()];
|
|
263
|
-
case 2:
|
|
264
|
-
_b.sent();
|
|
265
|
-
_b.label = 3;
|
|
266
|
-
case 3:
|
|
267
|
-
_i++;
|
|
268
|
-
return [3 /*break*/, 1];
|
|
269
|
-
case 4: return [2 /*return*/];
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
};
|
|
274
|
-
WebSocketClearingHouseAccountSubscriber.prototype.unsubscribeFromSpotMarketAccounts = function () {
|
|
275
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
276
|
-
var _i, _a, accountSubscriber;
|
|
277
|
-
return __generator(this, function (_b) {
|
|
278
|
-
switch (_b.label) {
|
|
279
|
-
case 0:
|
|
280
|
-
_i = 0, _a = this.spotMarketAccountSubscribers.values();
|
|
281
|
-
_b.label = 1;
|
|
282
|
-
case 1:
|
|
283
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
284
|
-
accountSubscriber = _a[_i];
|
|
285
|
-
return [4 /*yield*/, accountSubscriber.unsubscribe()];
|
|
286
|
-
case 2:
|
|
287
|
-
_b.sent();
|
|
288
|
-
_b.label = 3;
|
|
289
|
-
case 3:
|
|
290
|
-
_i++;
|
|
291
|
-
return [3 /*break*/, 1];
|
|
292
|
-
case 4: return [2 /*return*/];
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
};
|
|
297
|
-
WebSocketClearingHouseAccountSubscriber.prototype.unsubscribeFromOracles = function () {
|
|
298
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
299
|
-
var _i, _a, accountSubscriber;
|
|
300
|
-
return __generator(this, function (_b) {
|
|
301
|
-
switch (_b.label) {
|
|
302
|
-
case 0:
|
|
303
|
-
_i = 0, _a = this.oracleSubscribers.values();
|
|
304
|
-
_b.label = 1;
|
|
305
|
-
case 1:
|
|
306
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
307
|
-
accountSubscriber = _a[_i];
|
|
308
|
-
return [4 /*yield*/, accountSubscriber.unsubscribe()];
|
|
309
|
-
case 2:
|
|
310
|
-
_b.sent();
|
|
311
|
-
_b.label = 3;
|
|
312
|
-
case 3:
|
|
313
|
-
_i++;
|
|
314
|
-
return [3 /*break*/, 1];
|
|
315
|
-
case 4: return [2 /*return*/];
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
WebSocketClearingHouseAccountSubscriber.prototype.fetch = function () {
|
|
321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
-
var promises;
|
|
323
|
-
return __generator(this, function (_a) {
|
|
324
|
-
switch (_a.label) {
|
|
325
|
-
case 0:
|
|
326
|
-
if (!this.isSubscribed) {
|
|
327
|
-
return [2 /*return*/];
|
|
328
|
-
}
|
|
329
|
-
promises = [this.stateAccountSubscriber.fetch()]
|
|
330
|
-
.concat(Array.from(this.perpMarketAccountSubscribers.values()).map(function (subscriber) { return subscriber.fetch(); }))
|
|
331
|
-
.concat(Array.from(this.spotMarketAccountSubscribers.values()).map(function (subscriber) { return subscriber.fetch(); }));
|
|
332
|
-
return [4 /*yield*/, Promise.all(promises)];
|
|
333
|
-
case 1:
|
|
334
|
-
_a.sent();
|
|
335
|
-
return [2 /*return*/];
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
};
|
|
340
|
-
WebSocketClearingHouseAccountSubscriber.prototype.unsubscribe = function () {
|
|
341
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
342
|
-
return __generator(this, function (_a) {
|
|
343
|
-
switch (_a.label) {
|
|
344
|
-
case 0:
|
|
345
|
-
if (!this.isSubscribed) {
|
|
346
|
-
return [2 /*return*/];
|
|
347
|
-
}
|
|
348
|
-
return [4 /*yield*/, this.stateAccountSubscriber.unsubscribe()];
|
|
349
|
-
case 1:
|
|
350
|
-
_a.sent();
|
|
351
|
-
return [4 /*yield*/, this.unsubscribeFromMarketAccounts()];
|
|
352
|
-
case 2:
|
|
353
|
-
_a.sent();
|
|
354
|
-
return [4 /*yield*/, this.unsubscribeFromSpotMarketAccounts()];
|
|
355
|
-
case 3:
|
|
356
|
-
_a.sent();
|
|
357
|
-
return [4 /*yield*/, this.unsubscribeFromOracles()];
|
|
358
|
-
case 4:
|
|
359
|
-
_a.sent();
|
|
360
|
-
this.isSubscribed = false;
|
|
361
|
-
return [2 /*return*/];
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
};
|
|
366
|
-
WebSocketClearingHouseAccountSubscriber.prototype.addSpotMarket = function (marketIndex) {
|
|
367
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
368
|
-
return __generator(this, function (_a) {
|
|
369
|
-
if (this.spotMarketAccountSubscribers.has(marketIndex.toNumber())) {
|
|
370
|
-
return [2 /*return*/, true];
|
|
371
|
-
}
|
|
372
|
-
return [2 /*return*/, this.subscribeToSpotMarketAccount(marketIndex)];
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
};
|
|
376
|
-
WebSocketClearingHouseAccountSubscriber.prototype.addPerpMarket = function (marketIndex) {
|
|
377
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
378
|
-
return __generator(this, function (_a) {
|
|
379
|
-
if (this.perpMarketAccountSubscribers.has(marketIndex.toNumber())) {
|
|
380
|
-
return [2 /*return*/, true];
|
|
381
|
-
}
|
|
382
|
-
return [2 /*return*/, this.subscribeToMarketAccount(marketIndex)];
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
};
|
|
386
|
-
WebSocketClearingHouseAccountSubscriber.prototype.addOracle = function (oracleInfo) {
|
|
387
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
388
|
-
return __generator(this, function (_a) {
|
|
389
|
-
if (this.oracleSubscribers.has(oracleInfo.publicKey.toString())) {
|
|
390
|
-
return [2 /*return*/, true];
|
|
391
|
-
}
|
|
392
|
-
if (oracleInfo.publicKey.equals(web3_js_1.PublicKey["default"])) {
|
|
393
|
-
return [2 /*return*/, true];
|
|
394
|
-
}
|
|
395
|
-
return [2 /*return*/, this.subscribeToOracle(oracleInfo)];
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
WebSocketClearingHouseAccountSubscriber.prototype.assertIsSubscribed = function () {
|
|
400
|
-
if (!this.isSubscribed) {
|
|
401
|
-
throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
WebSocketClearingHouseAccountSubscriber.prototype.getStateAccountAndSlot = function () {
|
|
405
|
-
this.assertIsSubscribed();
|
|
406
|
-
return this.stateAccountSubscriber.dataAndSlot;
|
|
407
|
-
};
|
|
408
|
-
WebSocketClearingHouseAccountSubscriber.prototype.getMarketAccountAndSlot = function (marketIndex) {
|
|
409
|
-
this.assertIsSubscribed();
|
|
410
|
-
return this.perpMarketAccountSubscribers.get(marketIndex.toNumber())
|
|
411
|
-
.dataAndSlot;
|
|
412
|
-
};
|
|
413
|
-
WebSocketClearingHouseAccountSubscriber.prototype.getMarketAccountsAndSlots = function () {
|
|
414
|
-
return Array.from(this.perpMarketAccountSubscribers.values()).map(function (subscriber) { return subscriber.dataAndSlot; });
|
|
415
|
-
};
|
|
416
|
-
WebSocketClearingHouseAccountSubscriber.prototype.getSpotMarketAccountAndSlot = function (marketIndex) {
|
|
417
|
-
this.assertIsSubscribed();
|
|
418
|
-
return this.spotMarketAccountSubscribers.get(marketIndex.toNumber())
|
|
419
|
-
.dataAndSlot;
|
|
420
|
-
};
|
|
421
|
-
WebSocketClearingHouseAccountSubscriber.prototype.getOraclePriceDataAndSlot = function (oraclePublicKey) {
|
|
422
|
-
this.assertIsSubscribed();
|
|
423
|
-
if (oraclePublicKey.equals(web3_js_1.PublicKey["default"])) {
|
|
424
|
-
return {
|
|
425
|
-
data: quoteAssetOracleClient_1.QUOTE_ORACLE_PRICE_DATA,
|
|
426
|
-
slot: 0
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
return this.oracleSubscribers.get(oraclePublicKey.toString()).dataAndSlot;
|
|
430
|
-
};
|
|
431
|
-
return WebSocketClearingHouseAccountSubscriber;
|
|
432
|
-
}());
|
|
433
|
-
exports.WebSocketClearingHouseAccountSubscriber = WebSocketClearingHouseAccountSubscriber;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
39
|
-
exports.WebSocketUserAccountSubscriber = void 0;
|
|
40
|
-
var types_1 = require("./types");
|
|
41
|
-
var events_1 = require("events");
|
|
42
|
-
var webSocketAccountSubscriber_1 = require("./webSocketAccountSubscriber");
|
|
43
|
-
var WebSocketUserAccountSubscriber = /** @class */ (function () {
|
|
44
|
-
function WebSocketUserAccountSubscriber(program, userAccountPublicKey) {
|
|
45
|
-
this.isSubscribed = false;
|
|
46
|
-
this.program = program;
|
|
47
|
-
this.userAccountPublicKey = userAccountPublicKey;
|
|
48
|
-
this.eventEmitter = new events_1.EventEmitter();
|
|
49
|
-
}
|
|
50
|
-
WebSocketUserAccountSubscriber.prototype.subscribe = function () {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
-
var _this = this;
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
switch (_a.label) {
|
|
55
|
-
case 0:
|
|
56
|
-
if (this.isSubscribed) {
|
|
57
|
-
return [2 /*return*/, true];
|
|
58
|
-
}
|
|
59
|
-
this.userDataAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('user', this.program, this.userAccountPublicKey);
|
|
60
|
-
return [4 /*yield*/, this.userDataAccountSubscriber.subscribe(function (data) {
|
|
61
|
-
_this.eventEmitter.emit('userAccountUpdate', data);
|
|
62
|
-
_this.eventEmitter.emit('update');
|
|
63
|
-
})];
|
|
64
|
-
case 1:
|
|
65
|
-
_a.sent();
|
|
66
|
-
this.eventEmitter.emit('update');
|
|
67
|
-
this.isSubscribed = true;
|
|
68
|
-
return [2 /*return*/, true];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
WebSocketUserAccountSubscriber.prototype.fetch = function () {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
return __generator(this, function (_a) {
|
|
76
|
-
switch (_a.label) {
|
|
77
|
-
case 0: return [4 /*yield*/, Promise.all([this.userDataAccountSubscriber.fetch()])];
|
|
78
|
-
case 1:
|
|
79
|
-
_a.sent();
|
|
80
|
-
return [2 /*return*/];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
WebSocketUserAccountSubscriber.prototype.unsubscribe = function () {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
switch (_a.label) {
|
|
89
|
-
case 0:
|
|
90
|
-
if (!this.isSubscribed) {
|
|
91
|
-
return [2 /*return*/];
|
|
92
|
-
}
|
|
93
|
-
return [4 /*yield*/, Promise.all([this.userDataAccountSubscriber.unsubscribe()])];
|
|
94
|
-
case 1:
|
|
95
|
-
_a.sent();
|
|
96
|
-
this.isSubscribed = false;
|
|
97
|
-
return [2 /*return*/];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
WebSocketUserAccountSubscriber.prototype.assertIsSubscribed = function () {
|
|
103
|
-
if (!this.isSubscribed) {
|
|
104
|
-
throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
WebSocketUserAccountSubscriber.prototype.getUserAccountAndSlot = function () {
|
|
108
|
-
this.assertIsSubscribed();
|
|
109
|
-
return this.userDataAccountSubscriber.dataAndSlot;
|
|
110
|
-
};
|
|
111
|
-
return WebSocketUserAccountSubscriber;
|
|
112
|
-
}());
|
|
113
|
-
exports.WebSocketUserAccountSubscriber = WebSocketUserAccountSubscriber;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
39
|
-
exports.WebSocketUserStatsAccountSubscriber = void 0;
|
|
40
|
-
var types_1 = require("./types");
|
|
41
|
-
var events_1 = require("events");
|
|
42
|
-
var webSocketAccountSubscriber_1 = require("./webSocketAccountSubscriber");
|
|
43
|
-
var WebSocketUserStatsAccountSubscriber = /** @class */ (function () {
|
|
44
|
-
function WebSocketUserStatsAccountSubscriber(program, userStatsAccountPublicKey) {
|
|
45
|
-
this.isSubscribed = false;
|
|
46
|
-
this.program = program;
|
|
47
|
-
this.userStatsAccountPublicKey = userStatsAccountPublicKey;
|
|
48
|
-
this.eventEmitter = new events_1.EventEmitter();
|
|
49
|
-
}
|
|
50
|
-
WebSocketUserStatsAccountSubscriber.prototype.subscribe = function () {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
-
var _this = this;
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
switch (_a.label) {
|
|
55
|
-
case 0:
|
|
56
|
-
if (this.isSubscribed) {
|
|
57
|
-
return [2 /*return*/, true];
|
|
58
|
-
}
|
|
59
|
-
this.userStatsAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('userStats', this.program, this.userStatsAccountPublicKey);
|
|
60
|
-
return [4 /*yield*/, this.userStatsAccountSubscriber.subscribe(function (data) {
|
|
61
|
-
_this.eventEmitter.emit('userStatsAccountUpdate', data);
|
|
62
|
-
_this.eventEmitter.emit('update');
|
|
63
|
-
})];
|
|
64
|
-
case 1:
|
|
65
|
-
_a.sent();
|
|
66
|
-
this.eventEmitter.emit('update');
|
|
67
|
-
this.isSubscribed = true;
|
|
68
|
-
return [2 /*return*/, true];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
WebSocketUserStatsAccountSubscriber.prototype.fetch = function () {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
return __generator(this, function (_a) {
|
|
76
|
-
switch (_a.label) {
|
|
77
|
-
case 0: return [4 /*yield*/, Promise.all([this.userStatsAccountSubscriber.fetch()])];
|
|
78
|
-
case 1:
|
|
79
|
-
_a.sent();
|
|
80
|
-
return [2 /*return*/];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
WebSocketUserStatsAccountSubscriber.prototype.unsubscribe = function () {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
switch (_a.label) {
|
|
89
|
-
case 0:
|
|
90
|
-
if (!this.isSubscribed) {
|
|
91
|
-
return [2 /*return*/];
|
|
92
|
-
}
|
|
93
|
-
return [4 /*yield*/, Promise.all([this.userStatsAccountSubscriber.unsubscribe()])];
|
|
94
|
-
case 1:
|
|
95
|
-
_a.sent();
|
|
96
|
-
this.isSubscribed = false;
|
|
97
|
-
return [2 /*return*/];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
WebSocketUserStatsAccountSubscriber.prototype.assertIsSubscribed = function () {
|
|
103
|
-
if (!this.isSubscribed) {
|
|
104
|
-
throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
WebSocketUserStatsAccountSubscriber.prototype.getUserStatsAccountAndSlot = function () {
|
|
108
|
-
this.assertIsSubscribed();
|
|
109
|
-
return this.userStatsAccountSubscriber.dataAndSlot;
|
|
110
|
-
};
|
|
111
|
-
return WebSocketUserStatsAccountSubscriber;
|
|
112
|
-
}());
|
|
113
|
-
exports.WebSocketUserStatsAccountSubscriber = WebSocketUserStatsAccountSubscriber;
|