@acta-markets/ts-sdk 0.0.19-beta → 0.0.21-beta
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/dist/chain/instructions.market.d.ts +0 -1
- package/dist/chain/instructions.market.js +1 -6
- package/dist/chain/instructions.oracle.d.ts +0 -3
- package/dist/chain/instructions.oracle.js +1 -5
- package/dist/chain/instructions.position.js +8 -16
- package/dist/chain/instructions.shared.d.ts +0 -1
- package/dist/chain/instructions.shared.js +0 -1
- package/dist/cjs/chain/instructions.market.js +0 -5
- package/dist/cjs/chain/instructions.oracle.js +0 -4
- package/dist/cjs/chain/instructions.position.js +8 -16
- package/dist/cjs/chain/instructions.shared.js +1 -2
- package/dist/cjs/generated/errors/actaContract.js +4 -1
- package/dist/cjs/generated/instructions/closeOracle.js +2 -13
- package/dist/cjs/generated/instructions/createMarket.js +1 -10
- package/dist/cjs/generated/instructions/createOracle.js +1 -4
- package/dist/cjs/generated/instructions/depositFundsToPosition.js +5 -11
- package/dist/cjs/generated/instructions/finalizeMarket.js +1 -9
- package/dist/cjs/generated/instructions/updateOraclePrice.js +2 -13
- package/dist/cjs/idl/acta_contract.json +10 -61
- package/dist/cjs/idl/hash.js +1 -1
- package/dist/cjs/ws/apy.js +4 -10
- package/dist/cjs/ws/apy.test.js +37 -1
- package/dist/cjs/ws/client.js +166 -15
- package/dist/generated/errors/actaContract.d.ts +3 -1
- package/dist/generated/errors/actaContract.js +3 -0
- package/dist/generated/instructions/closeOracle.d.ts +5 -10
- package/dist/generated/instructions/closeOracle.js +2 -13
- package/dist/generated/instructions/createMarket.d.ts +11 -21
- package/dist/generated/instructions/createMarket.js +1 -10
- package/dist/generated/instructions/createOracle.d.ts +7 -12
- package/dist/generated/instructions/createOracle.js +1 -4
- package/dist/generated/instructions/depositFundsToPosition.d.ts +9 -14
- package/dist/generated/instructions/depositFundsToPosition.js +5 -11
- package/dist/generated/instructions/finalizeMarket.d.ts +4 -9
- package/dist/generated/instructions/finalizeMarket.js +1 -9
- package/dist/generated/instructions/updateOraclePrice.d.ts +5 -10
- package/dist/generated/instructions/updateOraclePrice.js +2 -13
- package/dist/idl/acta_contract.json +10 -61
- package/dist/idl/hash.d.ts +1 -1
- package/dist/idl/hash.js +1 -1
- package/dist/ws/apy.d.ts +1 -1
- package/dist/ws/apy.js +4 -10
- package/dist/ws/apy.test.js +37 -1
- package/dist/ws/client.d.ts +60 -4
- package/dist/ws/client.js +166 -15
- package/dist/ws/types.d.ts +38 -2
- package/package.json +1 -1
package/dist/ws/apy.test.js
CHANGED
|
@@ -5,7 +5,7 @@ describe("ws apy helpers", () => {
|
|
|
5
5
|
positionType: "covered_call",
|
|
6
6
|
underlyingAmount: 10,
|
|
7
7
|
spotPrice: 150,
|
|
8
|
-
strikePrice: 150, // not used for
|
|
8
|
+
strikePrice: 150, // not used for collateral, kept for API compat
|
|
9
9
|
premiumPerUnderlying: 1.5,
|
|
10
10
|
secondsToExpiry: 7 * 24 * 60 * 60,
|
|
11
11
|
});
|
|
@@ -20,8 +20,44 @@ describe("ws apy helpers", () => {
|
|
|
20
20
|
underlyingAmount: 10,
|
|
21
21
|
grossPremiumPerUnit1e9: 1_500_000_000, // 1.5
|
|
22
22
|
strike1e9: 150_000_000_000, // 150
|
|
23
|
+
spotPrice1e9: 150_000_000_000, // 150 (ATM)
|
|
23
24
|
secondsToExpiry: 7 * 24 * 60 * 60,
|
|
24
25
|
});
|
|
25
26
|
expect(res.premiumNotional).toBeCloseTo(15, 10);
|
|
26
27
|
});
|
|
28
|
+
it("put APR uses spot as collateral (not strike)", () => {
|
|
29
|
+
const spot = 150;
|
|
30
|
+
const strike = 120; // OTM put
|
|
31
|
+
const res = computeApyFromAmounts({
|
|
32
|
+
positionType: "cash_secured_put",
|
|
33
|
+
underlyingAmount: 1,
|
|
34
|
+
spotPrice: spot,
|
|
35
|
+
strikePrice: strike,
|
|
36
|
+
premiumPerUnderlying: 1.5,
|
|
37
|
+
secondsToExpiry: 30 * 24 * 60 * 60,
|
|
38
|
+
});
|
|
39
|
+
// collateral should be spot-based, not strike-based
|
|
40
|
+
expect(res.collateralNotional).toBeCloseTo(spot, 10);
|
|
41
|
+
});
|
|
42
|
+
it("put APR is monotonically decreasing for OTM strikes", () => {
|
|
43
|
+
const spot1e9 = 150_000_000_000; // 150
|
|
44
|
+
const strikes = [140, 130, 120, 110].map(s => s * 1_000_000_000);
|
|
45
|
+
// Premiums decrease with OTM (roughly realistic)
|
|
46
|
+
const premiums = [5, 2.5, 1, 0.3].map(p => p * 1_000_000_000);
|
|
47
|
+
const aprs = strikes.map((strike, i) => {
|
|
48
|
+
const res = computeApyFromScaledPrices({
|
|
49
|
+
positionType: "cash_secured_put",
|
|
50
|
+
underlyingAmount: 1,
|
|
51
|
+
grossPremiumPerUnit1e9: premiums[i],
|
|
52
|
+
strike1e9: strike,
|
|
53
|
+
spotPrice1e9: spot1e9,
|
|
54
|
+
secondsToExpiry: 30 * 24 * 60 * 60,
|
|
55
|
+
});
|
|
56
|
+
return res.apr;
|
|
57
|
+
});
|
|
58
|
+
// Each APR should be less than the previous
|
|
59
|
+
for (let i = 1; i < aprs.length; i++) {
|
|
60
|
+
expect(aprs[i]).toBeLessThan(aprs[i - 1]);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
27
63
|
});
|
package/dist/ws/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { AuthProvider } from "./auth";
|
|
3
3
|
import type { SignerLike } from "../chain/orders";
|
|
4
4
|
import type { Address } from "@solana/addresses";
|
|
5
|
-
import type { ActiveRfqInfo, ChainEventMessage, EarnSummaryData, TokenMarketsInfoData, GlobalStats, MarketDescriptorInfo, MarketInfo, MyActiveRfqInfo, MyActiveRfqsMessage, OrderStatusMessage, PositionInfo, QuoteAcknowledgedMessage, QuoteBestStatusMessage, QuoteCancelledMessage, QuoteMessage, QuoteRefreshRequestedMessage, QuoteOutbidMessage, QuoteReceivedMessage, QuoteSelectedMessage, QuotesUpdateMessage, RfqBroadcastMessage, RfqClosedMessage, RfqCreatedMessage, RfqSkippedMessage, RfqRequestMessage, RfqAvailableAgainMessage, QuoteExpiredMessage, QuoteFilledMessage, IndicativePricesMessage, IndicativePricesRequestMessage, IndicativePricesResponseMessage, GetIndicativePricesMessage, RequestId, ServerError, ServerMessage, SnapshotMessage, StatsDelta, SubscriptionsMessage, TokenInfo, TradeInfo, UuidString, VersionMismatchMessage, WelcomeMessage, WsChannel } from "./types";
|
|
5
|
+
import type { ActiveRfqInfo, ChainEventMessage, EarnSummaryData, TokenMarketsInfoData, GlobalStats, MarketDescriptorInfo, MarketInfo, MyActiveRfqInfo, MyActiveRfqsMessage, OrderStatusMessage, PositionInfo, QuoteAcknowledgedMessage, QuoteBestStatusMessage, QuoteCancelledMessage, QuoteMessage, QuoteRefreshRequestedMessage, QuoteOutbidMessage, QuoteReceivedMessage, QuoteSelectedMessage, QuotesUpdateMessage, RfqBroadcastMessage, RfqClosedMessage, RfqCreatedMessage, RfqSkippedMessage, RfqRequestMessage, RfqAvailableAgainMessage, QuoteExpiredMessage, QuoteFilledMessage, IndicativePricesMessage, IndicativePricesRequestMessage, IndicativePricesResponseMessage, GetIndicativePricesMessage, MakerBalancesMessage, MakerMarketsMessage, MakerPositionsMessage, MyCapsMessage, MyQuotesMessage, MyTradesMessage, RequestId, ServerError, ServerMessage, SnapshotMessage, StatsDelta, SubscriptionsMessage, TokenInfo, TradeInfo, UuidString, VersionMismatchMessage, WelcomeMessage, WsChannel } from "./types";
|
|
6
6
|
export type ConnectionState = "disconnected" | "connecting" | "authenticating" | "authenticated" | "error";
|
|
7
7
|
export type ClientRole = "taker" | "maker";
|
|
8
8
|
export type PendingMessagesOverflowPolicy = "drop_oldest" | "drop_newest" | "throw";
|
|
@@ -88,6 +88,12 @@ export type ActaWsClientEvents = {
|
|
|
88
88
|
earnSummary: (data: EarnSummaryData) => void;
|
|
89
89
|
tokenMarketsInfo: (data: TokenMarketsInfoData) => void;
|
|
90
90
|
subscriptions: (msg: SubscriptionsMessage) => void;
|
|
91
|
+
subscriptionUpdated: (data: {
|
|
92
|
+
request_id: RequestId;
|
|
93
|
+
channels: WsChannel[];
|
|
94
|
+
underlying_mints?: string[];
|
|
95
|
+
quote_mints?: string[];
|
|
96
|
+
}) => void;
|
|
91
97
|
activeRfqs: (rfqs: ActiveRfqInfo[]) => void;
|
|
92
98
|
rfqBroadcast: (rfq: RfqBroadcastMessage) => void;
|
|
93
99
|
rfqSkipped: (msg: RfqSkippedMessage) => void;
|
|
@@ -106,6 +112,12 @@ export type ActaWsClientEvents = {
|
|
|
106
112
|
quoteExpired: (msg: QuoteExpiredMessage) => void;
|
|
107
113
|
indicativePrices: (msg: IndicativePricesMessage) => void;
|
|
108
114
|
indicativePricesRequest: (msg: IndicativePricesRequestMessage) => void;
|
|
115
|
+
makerBalances: (msg: MakerBalancesMessage) => void;
|
|
116
|
+
makerPositions: (msg: MakerPositionsMessage) => void;
|
|
117
|
+
myTrades: (msg: MyTradesMessage) => void;
|
|
118
|
+
myCaps: (msg: MyCapsMessage) => void;
|
|
119
|
+
makerMarkets: (msg: MakerMarketsMessage) => void;
|
|
120
|
+
myQuotes: (msg: MyQuotesMessage) => void;
|
|
109
121
|
myActiveRfqs: (msg: MyActiveRfqsMessage) => void;
|
|
110
122
|
orderStatus: (msg: OrderStatusMessage) => void;
|
|
111
123
|
orderAccepted: (orderId: string) => void;
|
|
@@ -176,8 +188,8 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
176
188
|
private pingTimer;
|
|
177
189
|
private shouldReconnect;
|
|
178
190
|
private subscribedChannels;
|
|
179
|
-
private
|
|
180
|
-
private
|
|
191
|
+
private underlyingMintScope;
|
|
192
|
+
private quoteMintScope;
|
|
181
193
|
private marketDescriptorsByMarket;
|
|
182
194
|
readonly state: ClientState;
|
|
183
195
|
constructor(options: ActaWsClientOptions);
|
|
@@ -233,6 +245,37 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
233
245
|
}): RequestId;
|
|
234
246
|
getEarnSummary(): RequestId;
|
|
235
247
|
getTokenMarketsInfo(underlyingMint: string): RequestId;
|
|
248
|
+
/** Maker-only: get balances per deposited token (total, locked, available). */
|
|
249
|
+
getMakerBalances(): RequestId;
|
|
250
|
+
/** Maker-only: get open positions with optional filters. */
|
|
251
|
+
getMakerPositions(args?: {
|
|
252
|
+
market?: string;
|
|
253
|
+
underlying_mint?: string;
|
|
254
|
+
status?: string[];
|
|
255
|
+
min_expiry_ts?: number;
|
|
256
|
+
}): RequestId;
|
|
257
|
+
/** Maker-only: get trade history with keyset pagination. */
|
|
258
|
+
getMyTrades(args?: {
|
|
259
|
+
limit?: number;
|
|
260
|
+
cursor?: number;
|
|
261
|
+
cursor_id?: string;
|
|
262
|
+
market?: string;
|
|
263
|
+
}): RequestId;
|
|
264
|
+
/** Maker-only: get position, notional, and balance caps. */
|
|
265
|
+
getMyCaps(): RequestId;
|
|
266
|
+
/** Maker-only: get markets where maker has deposits, with optional filters and stats. */
|
|
267
|
+
getMarketsForMaker(args?: {
|
|
268
|
+
underlying_mints?: string[];
|
|
269
|
+
quote_mints?: string[];
|
|
270
|
+
min_expiry_ts?: number;
|
|
271
|
+
max_expiry_ts?: number;
|
|
272
|
+
is_put?: boolean;
|
|
273
|
+
include_stats?: boolean;
|
|
274
|
+
}): RequestId;
|
|
275
|
+
/** Maker-only: get submitted quotes with status. */
|
|
276
|
+
getMyQuotes(args?: {
|
|
277
|
+
active_only?: boolean;
|
|
278
|
+
}): RequestId;
|
|
236
279
|
logout(): void;
|
|
237
280
|
getOrderStatus(orderIdHex: string): RequestId;
|
|
238
281
|
cancelRfq(rfqId: string): RequestId;
|
|
@@ -253,8 +296,21 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
253
296
|
makerSigner: SignerLike;
|
|
254
297
|
}): Promise<void>;
|
|
255
298
|
cancelQuote(rfqId: string): RequestId;
|
|
256
|
-
subscribe(channels: WsChannel[],
|
|
299
|
+
subscribe(channels: WsChannel[], opts?: {
|
|
300
|
+
underlying_mints?: string[];
|
|
301
|
+
quote_mints?: string[];
|
|
302
|
+
}): RequestId;
|
|
257
303
|
unsubscribe(channels: WsChannel[]): RequestId;
|
|
304
|
+
addMints(opts: {
|
|
305
|
+
underlying_mints?: string[];
|
|
306
|
+
quote_mints?: string[];
|
|
307
|
+
}): RequestId;
|
|
308
|
+
removeMints(opts: {
|
|
309
|
+
underlying_mints?: string[];
|
|
310
|
+
quote_mints?: string[];
|
|
311
|
+
}): RequestId;
|
|
312
|
+
addChannels(channels: WsChannel[]): RequestId;
|
|
313
|
+
removeChannels(channels: WsChannel[]): RequestId;
|
|
258
314
|
ping(): void;
|
|
259
315
|
resumeAuth(sessionId: string): void;
|
|
260
316
|
private doConnect;
|
package/dist/ws/client.js
CHANGED
|
@@ -107,8 +107,8 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
107
107
|
pingTimer = null;
|
|
108
108
|
shouldReconnect = true;
|
|
109
109
|
subscribedChannels = new Set(["rfqs"]);
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
underlyingMintScope = null; // null = all
|
|
111
|
+
quoteMintScope = null; // null = all
|
|
112
112
|
marketDescriptorsByMarket = new Map();
|
|
113
113
|
state = {
|
|
114
114
|
stats: null,
|
|
@@ -336,6 +336,70 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
336
336
|
});
|
|
337
337
|
return requestId;
|
|
338
338
|
}
|
|
339
|
+
/** Maker-only: get balances per deposited token (total, locked, available). */
|
|
340
|
+
getMakerBalances() {
|
|
341
|
+
this.ensureAuthenticated();
|
|
342
|
+
const requestId = this.nextRequestId();
|
|
343
|
+
this.send({
|
|
344
|
+
type: "GetMakerBalances",
|
|
345
|
+
data: { request_id: requestId },
|
|
346
|
+
});
|
|
347
|
+
return requestId;
|
|
348
|
+
}
|
|
349
|
+
/** Maker-only: get open positions with optional filters. */
|
|
350
|
+
getMakerPositions(args) {
|
|
351
|
+
this.ensureAuthenticated();
|
|
352
|
+
const requestId = this.nextRequestId();
|
|
353
|
+
const data = {
|
|
354
|
+
request_id: requestId,
|
|
355
|
+
...args,
|
|
356
|
+
};
|
|
357
|
+
this.send({ type: "GetMakerPositions", data });
|
|
358
|
+
return requestId;
|
|
359
|
+
}
|
|
360
|
+
/** Maker-only: get trade history with keyset pagination. */
|
|
361
|
+
getMyTrades(args) {
|
|
362
|
+
this.ensureAuthenticated();
|
|
363
|
+
const requestId = this.nextRequestId();
|
|
364
|
+
const data = {
|
|
365
|
+
request_id: requestId,
|
|
366
|
+
...args,
|
|
367
|
+
};
|
|
368
|
+
this.send({ type: "GetMyTrades", data });
|
|
369
|
+
return requestId;
|
|
370
|
+
}
|
|
371
|
+
/** Maker-only: get position, notional, and balance caps. */
|
|
372
|
+
getMyCaps() {
|
|
373
|
+
this.ensureAuthenticated();
|
|
374
|
+
const requestId = this.nextRequestId();
|
|
375
|
+
this.send({
|
|
376
|
+
type: "GetMyCaps",
|
|
377
|
+
data: { request_id: requestId },
|
|
378
|
+
});
|
|
379
|
+
return requestId;
|
|
380
|
+
}
|
|
381
|
+
/** Maker-only: get markets where maker has deposits, with optional filters and stats. */
|
|
382
|
+
getMarketsForMaker(args) {
|
|
383
|
+
this.ensureAuthenticated();
|
|
384
|
+
const requestId = this.nextRequestId();
|
|
385
|
+
const data = {
|
|
386
|
+
request_id: requestId,
|
|
387
|
+
...args,
|
|
388
|
+
};
|
|
389
|
+
this.send({ type: "GetMarketsForMaker", data });
|
|
390
|
+
return requestId;
|
|
391
|
+
}
|
|
392
|
+
/** Maker-only: get submitted quotes with status. */
|
|
393
|
+
getMyQuotes(args) {
|
|
394
|
+
this.ensureAuthenticated();
|
|
395
|
+
const requestId = this.nextRequestId();
|
|
396
|
+
const data = {
|
|
397
|
+
request_id: requestId,
|
|
398
|
+
active_only: args?.active_only ?? true,
|
|
399
|
+
};
|
|
400
|
+
this.send({ type: "GetMyQuotes", data });
|
|
401
|
+
return requestId;
|
|
402
|
+
}
|
|
339
403
|
logout() {
|
|
340
404
|
this.send({ type: "Logout" });
|
|
341
405
|
}
|
|
@@ -392,21 +456,25 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
392
456
|
});
|
|
393
457
|
return requestId;
|
|
394
458
|
}
|
|
395
|
-
subscribe(channels,
|
|
459
|
+
subscribe(channels, opts) {
|
|
396
460
|
this.ensureAuthenticated();
|
|
397
461
|
const request_id = this.nextRequestId();
|
|
398
462
|
for (const c of channels)
|
|
399
463
|
this.subscribedChannels.add(c);
|
|
400
|
-
if (
|
|
401
|
-
this.
|
|
402
|
-
this.subscribedMarkets = new Set(markets);
|
|
464
|
+
if (opts?.underlying_mints) {
|
|
465
|
+
this.underlyingMintScope = new Set(opts.underlying_mints);
|
|
403
466
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
467
|
+
if (opts?.quote_mints) {
|
|
468
|
+
this.quoteMintScope = new Set(opts.quote_mints);
|
|
469
|
+
}
|
|
470
|
+
const data = { request_id, channels };
|
|
471
|
+
if (this.underlyingMintScope) {
|
|
472
|
+
data.underlying_mints = Array.from(this.underlyingMintScope);
|
|
473
|
+
}
|
|
474
|
+
if (this.quoteMintScope) {
|
|
475
|
+
data.quote_mints = Array.from(this.quoteMintScope);
|
|
476
|
+
}
|
|
477
|
+
this.send({ type: "Subscribe", data });
|
|
410
478
|
return request_id;
|
|
411
479
|
}
|
|
412
480
|
unsubscribe(channels) {
|
|
@@ -420,6 +488,58 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
420
488
|
});
|
|
421
489
|
return request_id;
|
|
422
490
|
}
|
|
491
|
+
addMints(opts) {
|
|
492
|
+
this.ensureAuthenticated();
|
|
493
|
+
const request_id = this.nextRequestId();
|
|
494
|
+
if (opts.underlying_mints) {
|
|
495
|
+
if (!this.underlyingMintScope)
|
|
496
|
+
this.underlyingMintScope = new Set();
|
|
497
|
+
for (const m of opts.underlying_mints)
|
|
498
|
+
this.underlyingMintScope.add(m);
|
|
499
|
+
}
|
|
500
|
+
if (opts.quote_mints) {
|
|
501
|
+
if (!this.quoteMintScope)
|
|
502
|
+
this.quoteMintScope = new Set();
|
|
503
|
+
for (const m of opts.quote_mints)
|
|
504
|
+
this.quoteMintScope.add(m);
|
|
505
|
+
}
|
|
506
|
+
this.send({ type: "AddMints", data: { request_id, ...opts } });
|
|
507
|
+
return request_id;
|
|
508
|
+
}
|
|
509
|
+
removeMints(opts) {
|
|
510
|
+
this.ensureAuthenticated();
|
|
511
|
+
const request_id = this.nextRequestId();
|
|
512
|
+
if (opts.underlying_mints && this.underlyingMintScope) {
|
|
513
|
+
for (const m of opts.underlying_mints)
|
|
514
|
+
this.underlyingMintScope.delete(m);
|
|
515
|
+
if (this.underlyingMintScope.size === 0)
|
|
516
|
+
this.underlyingMintScope = null;
|
|
517
|
+
}
|
|
518
|
+
if (opts.quote_mints && this.quoteMintScope) {
|
|
519
|
+
for (const m of opts.quote_mints)
|
|
520
|
+
this.quoteMintScope.delete(m);
|
|
521
|
+
if (this.quoteMintScope.size === 0)
|
|
522
|
+
this.quoteMintScope = null;
|
|
523
|
+
}
|
|
524
|
+
this.send({ type: "RemoveMints", data: { request_id, ...opts } });
|
|
525
|
+
return request_id;
|
|
526
|
+
}
|
|
527
|
+
addChannels(channels) {
|
|
528
|
+
this.ensureAuthenticated();
|
|
529
|
+
const request_id = this.nextRequestId();
|
|
530
|
+
for (const c of channels)
|
|
531
|
+
this.subscribedChannels.add(c);
|
|
532
|
+
this.send({ type: "AddChannels", data: { request_id, channels } });
|
|
533
|
+
return request_id;
|
|
534
|
+
}
|
|
535
|
+
removeChannels(channels) {
|
|
536
|
+
this.ensureAuthenticated();
|
|
537
|
+
const request_id = this.nextRequestId();
|
|
538
|
+
for (const c of channels)
|
|
539
|
+
this.subscribedChannels.delete(c);
|
|
540
|
+
this.send({ type: "RemoveChannels", data: { request_id, channels } });
|
|
541
|
+
return request_id;
|
|
542
|
+
}
|
|
423
543
|
ping() {
|
|
424
544
|
if (this.ws?.readyState === WS_OPEN) {
|
|
425
545
|
this.send({ type: "Ping" });
|
|
@@ -570,6 +690,21 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
570
690
|
case "MyCaps":
|
|
571
691
|
this.emit("myCaps", message.data);
|
|
572
692
|
break;
|
|
693
|
+
case "MakerBalances":
|
|
694
|
+
this.emit("makerBalances", message.data);
|
|
695
|
+
break;
|
|
696
|
+
case "MakerPositions":
|
|
697
|
+
this.emit("makerPositions", message.data);
|
|
698
|
+
break;
|
|
699
|
+
case "MyTrades":
|
|
700
|
+
this.emit("myTrades", message.data);
|
|
701
|
+
break;
|
|
702
|
+
case "MakerMarkets":
|
|
703
|
+
this.emit("makerMarkets", message.data);
|
|
704
|
+
break;
|
|
705
|
+
case "MyQuotes":
|
|
706
|
+
this.emit("myQuotes", message.data);
|
|
707
|
+
break;
|
|
573
708
|
case "MyActiveRfqs":
|
|
574
709
|
this.handleMyActiveRfqs(message.data);
|
|
575
710
|
break;
|
|
@@ -727,6 +862,18 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
727
862
|
case "UnsubscribeAck":
|
|
728
863
|
this.emit("unsubscribeAck", message.data);
|
|
729
864
|
break;
|
|
865
|
+
case "SubscriptionUpdated":
|
|
866
|
+
{
|
|
867
|
+
const d = message.data;
|
|
868
|
+
// Sync local state from the server's authoritative response.
|
|
869
|
+
this.subscribedChannels = new Set(d.channels);
|
|
870
|
+
this.underlyingMintScope =
|
|
871
|
+
d.underlying_mints != null ? new Set(d.underlying_mints) : null;
|
|
872
|
+
this.quoteMintScope =
|
|
873
|
+
d.quote_mints != null ? new Set(d.quote_mints) : null;
|
|
874
|
+
this.emit("subscriptionUpdated", d);
|
|
875
|
+
}
|
|
876
|
+
break;
|
|
730
877
|
}
|
|
731
878
|
}
|
|
732
879
|
/** Taker-only: request current indicative prices for a market + position_type. */
|
|
@@ -812,9 +959,13 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
812
959
|
if (this.subscribedChannels.size > 0) {
|
|
813
960
|
const channels = Array.from(this.subscribedChannels);
|
|
814
961
|
const request_id = this.nextRequestId();
|
|
815
|
-
const data =
|
|
816
|
-
|
|
817
|
-
|
|
962
|
+
const data = { request_id, channels };
|
|
963
|
+
if (this.underlyingMintScope) {
|
|
964
|
+
data.underlying_mints = Array.from(this.underlyingMintScope);
|
|
965
|
+
}
|
|
966
|
+
if (this.quoteMintScope) {
|
|
967
|
+
data.quote_mints = Array.from(this.quoteMintScope);
|
|
968
|
+
}
|
|
818
969
|
this.send({ type: "Subscribe", data });
|
|
819
970
|
}
|
|
820
971
|
}
|
package/dist/ws/types.d.ts
CHANGED
|
@@ -173,7 +173,8 @@ export type ClientMessage = {
|
|
|
173
173
|
data: {
|
|
174
174
|
request_id: RequestId;
|
|
175
175
|
channels: WsChannel[];
|
|
176
|
-
|
|
176
|
+
underlying_mints?: string[];
|
|
177
|
+
quote_mints?: string[];
|
|
177
178
|
};
|
|
178
179
|
} | {
|
|
179
180
|
type: "Unsubscribe";
|
|
@@ -181,6 +182,32 @@ export type ClientMessage = {
|
|
|
181
182
|
request_id: RequestId;
|
|
182
183
|
channels: WsChannel[];
|
|
183
184
|
};
|
|
185
|
+
} | {
|
|
186
|
+
type: "AddMints";
|
|
187
|
+
data: {
|
|
188
|
+
request_id: RequestId;
|
|
189
|
+
underlying_mints?: string[];
|
|
190
|
+
quote_mints?: string[];
|
|
191
|
+
};
|
|
192
|
+
} | {
|
|
193
|
+
type: "RemoveMints";
|
|
194
|
+
data: {
|
|
195
|
+
request_id: RequestId;
|
|
196
|
+
underlying_mints?: string[];
|
|
197
|
+
quote_mints?: string[];
|
|
198
|
+
};
|
|
199
|
+
} | {
|
|
200
|
+
type: "AddChannels";
|
|
201
|
+
data: {
|
|
202
|
+
request_id: RequestId;
|
|
203
|
+
channels: WsChannel[];
|
|
204
|
+
};
|
|
205
|
+
} | {
|
|
206
|
+
type: "RemoveChannels";
|
|
207
|
+
data: {
|
|
208
|
+
request_id: RequestId;
|
|
209
|
+
channels: WsChannel[];
|
|
210
|
+
};
|
|
184
211
|
};
|
|
185
212
|
export type GetMarketDescriptorsMessage = {
|
|
186
213
|
request_id: RequestId;
|
|
@@ -503,6 +530,14 @@ export type ServerMessage = {
|
|
|
503
530
|
request_id: RequestId;
|
|
504
531
|
unsubscribed: WsChannel[];
|
|
505
532
|
};
|
|
533
|
+
} | {
|
|
534
|
+
type: "SubscriptionUpdated";
|
|
535
|
+
data: {
|
|
536
|
+
request_id: RequestId;
|
|
537
|
+
channels: WsChannel[];
|
|
538
|
+
underlying_mints?: string[];
|
|
539
|
+
quote_mints?: string[];
|
|
540
|
+
};
|
|
506
541
|
};
|
|
507
542
|
export type MarketDescriptorInfo = {
|
|
508
543
|
market: MarketDescriptor;
|
|
@@ -882,7 +917,8 @@ export type MakerBalanceCapInfo = {
|
|
|
882
917
|
export type SubscriptionsMessage = {
|
|
883
918
|
request_id: RequestId;
|
|
884
919
|
channels: WsChannel[];
|
|
885
|
-
|
|
920
|
+
underlying_mints?: string[];
|
|
921
|
+
quote_mints?: string[];
|
|
886
922
|
};
|
|
887
923
|
export type IndicativePricesRequestMessage = {
|
|
888
924
|
request_id: RequestId;
|