@acta-markets/ts-sdk 0.0.20-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/cjs/generated/errors/actaContract.js +4 -1
- package/dist/cjs/idl/acta_contract.json +5 -0
- package/dist/cjs/idl/hash.js +1 -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/idl/acta_contract.json +5 -0
- package/dist/idl/hash.d.ts +1 -1
- package/dist/idl/hash.js +1 -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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://github.com/codama-idl/codama
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = exports.ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = exports.ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY = exports.ACTA_CONTRACT_ERROR__UNAUTHORIZED = exports.ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP = exports.ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID = exports.ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS = exports.ACTA_CONTRACT_ERROR__MINT_MISMATCH = exports.ACTA_CONTRACT_ERROR__MATH_OVERFLOW = exports.ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA = exports.ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH = exports.ACTA_CONTRACT_ERROR__SIGNER_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORDER_ID = exports.ACTA_CONTRACT_ERROR__CANNOT_LIQUIDATE_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_ITM = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN = exports.ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE = exports.ACTA_CONTRACT_ERROR__ORACLE_INACTIVE = exports.ACTA_CONTRACT_ERROR__ORACLE_STALE = exports.ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY = exports.ACTA_CONTRACT_ERROR__MARKET_EXPIRED = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED = exports.ACTA_CONTRACT_ERROR__MARKET_FINALIZED = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED = exports.ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED = exports.ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT = exports.ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_PDA = exports.ACTA_CONTRACT_ERROR__INVALID_OWNER = exports.ACTA_CONTRACT_ERROR__NOT_SIGNED = void 0;
|
|
10
|
+
exports.ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = exports.ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = exports.ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY = exports.ACTA_CONTRACT_ERROR__UNAUTHORIZED = exports.ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP = exports.ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID = exports.ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS = exports.ACTA_CONTRACT_ERROR__MINT_MISMATCH = exports.ACTA_CONTRACT_ERROR__MATH_OVERFLOW = exports.ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA = exports.ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH = exports.ACTA_CONTRACT_ERROR__SIGNER_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORDER_ID = exports.ACTA_CONTRACT_ERROR__CANNOT_LIQUIDATE_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_ITM = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN = exports.ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE = exports.ACTA_CONTRACT_ERROR__ORACLE_INACTIVE = exports.ACTA_CONTRACT_ERROR__ORACLE_STALE = exports.ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY = exports.ACTA_CONTRACT_ERROR__MARKET_EXPIRED = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED = exports.ACTA_CONTRACT_ERROR__MARKET_FINALIZED = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED = exports.ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED = exports.ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT = exports.ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_PDA = exports.ACTA_CONTRACT_ERROR__INVALID_OWNER = exports.ACTA_CONTRACT_ERROR__NOT_SIGNED = void 0;
|
|
11
11
|
exports.getActaContractErrorMessage = getActaContractErrorMessage;
|
|
12
12
|
exports.isActaContractError = isActaContractError;
|
|
13
13
|
const kit_1 = require("@solana/kit");
|
|
@@ -102,6 +102,8 @@ exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 0x432; // 1074
|
|
|
102
102
|
exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 0x433; // 1075
|
|
103
103
|
/** MarketNotExpired: Market has not expired yet */
|
|
104
104
|
exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = 0x434; // 1076
|
|
105
|
+
/** OracleNotExpiredYet: Oracle has not expired yet (cannot update price before expiry) */
|
|
106
|
+
exports.ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 0x435; // 1077
|
|
105
107
|
let actaContractErrorMessages;
|
|
106
108
|
if (process.env.NODE_ENV !== "production") {
|
|
107
109
|
actaContractErrorMessages = {
|
|
@@ -138,6 +140,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
138
140
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS]: `Oracle is still linked to active markets`,
|
|
139
141
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_INACTIVE]: `Oracle inactive`,
|
|
140
142
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE]: `Oracle price invalid (zero or negative)`,
|
|
143
|
+
[exports.ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET]: `Oracle has not expired yet (cannot update price before expiry)`,
|
|
141
144
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED]: `Oracle source fields are locked after first update`,
|
|
142
145
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_STALE]: `Oracle price is stale (updated_at before expiry)`,
|
|
143
146
|
[exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED]: `Position already funded by maker`,
|
|
@@ -2312,6 +2312,11 @@
|
|
|
2312
2312
|
"code": 1076,
|
|
2313
2313
|
"name": "MarketNotExpired",
|
|
2314
2314
|
"msg": "Market has not expired yet"
|
|
2315
|
+
},
|
|
2316
|
+
{
|
|
2317
|
+
"code": 1077,
|
|
2318
|
+
"name": "OracleNotExpiredYet",
|
|
2319
|
+
"msg": "Oracle has not expired yet (cannot update price before expiry)"
|
|
2315
2320
|
}
|
|
2316
2321
|
]
|
|
2317
2322
|
}
|
package/dist/cjs/idl/hash.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ACTA_IDL_SHA256 = void 0;
|
|
4
|
-
exports.ACTA_IDL_SHA256 = "
|
|
4
|
+
exports.ACTA_IDL_SHA256 = "2ccf0a77f682ff60b8201e2bca7f4bd026500a2fb9637d46dad7a8de3b2ee313";
|
package/dist/cjs/ws/client.js
CHANGED
|
@@ -110,8 +110,8 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
110
110
|
pingTimer = null;
|
|
111
111
|
shouldReconnect = true;
|
|
112
112
|
subscribedChannels = new Set(["rfqs"]);
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
underlyingMintScope = null; // null = all
|
|
114
|
+
quoteMintScope = null; // null = all
|
|
115
115
|
marketDescriptorsByMarket = new Map();
|
|
116
116
|
state = {
|
|
117
117
|
stats: null,
|
|
@@ -339,6 +339,70 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
339
339
|
});
|
|
340
340
|
return requestId;
|
|
341
341
|
}
|
|
342
|
+
/** Maker-only: get balances per deposited token (total, locked, available). */
|
|
343
|
+
getMakerBalances() {
|
|
344
|
+
this.ensureAuthenticated();
|
|
345
|
+
const requestId = this.nextRequestId();
|
|
346
|
+
this.send({
|
|
347
|
+
type: "GetMakerBalances",
|
|
348
|
+
data: { request_id: requestId },
|
|
349
|
+
});
|
|
350
|
+
return requestId;
|
|
351
|
+
}
|
|
352
|
+
/** Maker-only: get open positions with optional filters. */
|
|
353
|
+
getMakerPositions(args) {
|
|
354
|
+
this.ensureAuthenticated();
|
|
355
|
+
const requestId = this.nextRequestId();
|
|
356
|
+
const data = {
|
|
357
|
+
request_id: requestId,
|
|
358
|
+
...args,
|
|
359
|
+
};
|
|
360
|
+
this.send({ type: "GetMakerPositions", data });
|
|
361
|
+
return requestId;
|
|
362
|
+
}
|
|
363
|
+
/** Maker-only: get trade history with keyset pagination. */
|
|
364
|
+
getMyTrades(args) {
|
|
365
|
+
this.ensureAuthenticated();
|
|
366
|
+
const requestId = this.nextRequestId();
|
|
367
|
+
const data = {
|
|
368
|
+
request_id: requestId,
|
|
369
|
+
...args,
|
|
370
|
+
};
|
|
371
|
+
this.send({ type: "GetMyTrades", data });
|
|
372
|
+
return requestId;
|
|
373
|
+
}
|
|
374
|
+
/** Maker-only: get position, notional, and balance caps. */
|
|
375
|
+
getMyCaps() {
|
|
376
|
+
this.ensureAuthenticated();
|
|
377
|
+
const requestId = this.nextRequestId();
|
|
378
|
+
this.send({
|
|
379
|
+
type: "GetMyCaps",
|
|
380
|
+
data: { request_id: requestId },
|
|
381
|
+
});
|
|
382
|
+
return requestId;
|
|
383
|
+
}
|
|
384
|
+
/** Maker-only: get markets where maker has deposits, with optional filters and stats. */
|
|
385
|
+
getMarketsForMaker(args) {
|
|
386
|
+
this.ensureAuthenticated();
|
|
387
|
+
const requestId = this.nextRequestId();
|
|
388
|
+
const data = {
|
|
389
|
+
request_id: requestId,
|
|
390
|
+
...args,
|
|
391
|
+
};
|
|
392
|
+
this.send({ type: "GetMarketsForMaker", data });
|
|
393
|
+
return requestId;
|
|
394
|
+
}
|
|
395
|
+
/** Maker-only: get submitted quotes with status. */
|
|
396
|
+
getMyQuotes(args) {
|
|
397
|
+
this.ensureAuthenticated();
|
|
398
|
+
const requestId = this.nextRequestId();
|
|
399
|
+
const data = {
|
|
400
|
+
request_id: requestId,
|
|
401
|
+
active_only: args?.active_only ?? true,
|
|
402
|
+
};
|
|
403
|
+
this.send({ type: "GetMyQuotes", data });
|
|
404
|
+
return requestId;
|
|
405
|
+
}
|
|
342
406
|
logout() {
|
|
343
407
|
this.send({ type: "Logout" });
|
|
344
408
|
}
|
|
@@ -395,21 +459,25 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
395
459
|
});
|
|
396
460
|
return requestId;
|
|
397
461
|
}
|
|
398
|
-
subscribe(channels,
|
|
462
|
+
subscribe(channels, opts) {
|
|
399
463
|
this.ensureAuthenticated();
|
|
400
464
|
const request_id = this.nextRequestId();
|
|
401
465
|
for (const c of channels)
|
|
402
466
|
this.subscribedChannels.add(c);
|
|
403
|
-
if (
|
|
404
|
-
this.
|
|
405
|
-
this.subscribedMarkets = new Set(markets);
|
|
467
|
+
if (opts?.underlying_mints) {
|
|
468
|
+
this.underlyingMintScope = new Set(opts.underlying_mints);
|
|
406
469
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
470
|
+
if (opts?.quote_mints) {
|
|
471
|
+
this.quoteMintScope = new Set(opts.quote_mints);
|
|
472
|
+
}
|
|
473
|
+
const data = { request_id, channels };
|
|
474
|
+
if (this.underlyingMintScope) {
|
|
475
|
+
data.underlying_mints = Array.from(this.underlyingMintScope);
|
|
476
|
+
}
|
|
477
|
+
if (this.quoteMintScope) {
|
|
478
|
+
data.quote_mints = Array.from(this.quoteMintScope);
|
|
479
|
+
}
|
|
480
|
+
this.send({ type: "Subscribe", data });
|
|
413
481
|
return request_id;
|
|
414
482
|
}
|
|
415
483
|
unsubscribe(channels) {
|
|
@@ -423,6 +491,58 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
423
491
|
});
|
|
424
492
|
return request_id;
|
|
425
493
|
}
|
|
494
|
+
addMints(opts) {
|
|
495
|
+
this.ensureAuthenticated();
|
|
496
|
+
const request_id = this.nextRequestId();
|
|
497
|
+
if (opts.underlying_mints) {
|
|
498
|
+
if (!this.underlyingMintScope)
|
|
499
|
+
this.underlyingMintScope = new Set();
|
|
500
|
+
for (const m of opts.underlying_mints)
|
|
501
|
+
this.underlyingMintScope.add(m);
|
|
502
|
+
}
|
|
503
|
+
if (opts.quote_mints) {
|
|
504
|
+
if (!this.quoteMintScope)
|
|
505
|
+
this.quoteMintScope = new Set();
|
|
506
|
+
for (const m of opts.quote_mints)
|
|
507
|
+
this.quoteMintScope.add(m);
|
|
508
|
+
}
|
|
509
|
+
this.send({ type: "AddMints", data: { request_id, ...opts } });
|
|
510
|
+
return request_id;
|
|
511
|
+
}
|
|
512
|
+
removeMints(opts) {
|
|
513
|
+
this.ensureAuthenticated();
|
|
514
|
+
const request_id = this.nextRequestId();
|
|
515
|
+
if (opts.underlying_mints && this.underlyingMintScope) {
|
|
516
|
+
for (const m of opts.underlying_mints)
|
|
517
|
+
this.underlyingMintScope.delete(m);
|
|
518
|
+
if (this.underlyingMintScope.size === 0)
|
|
519
|
+
this.underlyingMintScope = null;
|
|
520
|
+
}
|
|
521
|
+
if (opts.quote_mints && this.quoteMintScope) {
|
|
522
|
+
for (const m of opts.quote_mints)
|
|
523
|
+
this.quoteMintScope.delete(m);
|
|
524
|
+
if (this.quoteMintScope.size === 0)
|
|
525
|
+
this.quoteMintScope = null;
|
|
526
|
+
}
|
|
527
|
+
this.send({ type: "RemoveMints", data: { request_id, ...opts } });
|
|
528
|
+
return request_id;
|
|
529
|
+
}
|
|
530
|
+
addChannels(channels) {
|
|
531
|
+
this.ensureAuthenticated();
|
|
532
|
+
const request_id = this.nextRequestId();
|
|
533
|
+
for (const c of channels)
|
|
534
|
+
this.subscribedChannels.add(c);
|
|
535
|
+
this.send({ type: "AddChannels", data: { request_id, channels } });
|
|
536
|
+
return request_id;
|
|
537
|
+
}
|
|
538
|
+
removeChannels(channels) {
|
|
539
|
+
this.ensureAuthenticated();
|
|
540
|
+
const request_id = this.nextRequestId();
|
|
541
|
+
for (const c of channels)
|
|
542
|
+
this.subscribedChannels.delete(c);
|
|
543
|
+
this.send({ type: "RemoveChannels", data: { request_id, channels } });
|
|
544
|
+
return request_id;
|
|
545
|
+
}
|
|
426
546
|
ping() {
|
|
427
547
|
if (this.ws?.readyState === WS_OPEN) {
|
|
428
548
|
this.send({ type: "Ping" });
|
|
@@ -573,6 +693,21 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
573
693
|
case "MyCaps":
|
|
574
694
|
this.emit("myCaps", message.data);
|
|
575
695
|
break;
|
|
696
|
+
case "MakerBalances":
|
|
697
|
+
this.emit("makerBalances", message.data);
|
|
698
|
+
break;
|
|
699
|
+
case "MakerPositions":
|
|
700
|
+
this.emit("makerPositions", message.data);
|
|
701
|
+
break;
|
|
702
|
+
case "MyTrades":
|
|
703
|
+
this.emit("myTrades", message.data);
|
|
704
|
+
break;
|
|
705
|
+
case "MakerMarkets":
|
|
706
|
+
this.emit("makerMarkets", message.data);
|
|
707
|
+
break;
|
|
708
|
+
case "MyQuotes":
|
|
709
|
+
this.emit("myQuotes", message.data);
|
|
710
|
+
break;
|
|
576
711
|
case "MyActiveRfqs":
|
|
577
712
|
this.handleMyActiveRfqs(message.data);
|
|
578
713
|
break;
|
|
@@ -730,6 +865,18 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
730
865
|
case "UnsubscribeAck":
|
|
731
866
|
this.emit("unsubscribeAck", message.data);
|
|
732
867
|
break;
|
|
868
|
+
case "SubscriptionUpdated":
|
|
869
|
+
{
|
|
870
|
+
const d = message.data;
|
|
871
|
+
// Sync local state from the server's authoritative response.
|
|
872
|
+
this.subscribedChannels = new Set(d.channels);
|
|
873
|
+
this.underlyingMintScope =
|
|
874
|
+
d.underlying_mints != null ? new Set(d.underlying_mints) : null;
|
|
875
|
+
this.quoteMintScope =
|
|
876
|
+
d.quote_mints != null ? new Set(d.quote_mints) : null;
|
|
877
|
+
this.emit("subscriptionUpdated", d);
|
|
878
|
+
}
|
|
879
|
+
break;
|
|
733
880
|
}
|
|
734
881
|
}
|
|
735
882
|
/** Taker-only: request current indicative prices for a market + position_type. */
|
|
@@ -815,9 +962,13 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
815
962
|
if (this.subscribedChannels.size > 0) {
|
|
816
963
|
const channels = Array.from(this.subscribedChannels);
|
|
817
964
|
const request_id = this.nextRequestId();
|
|
818
|
-
const data =
|
|
819
|
-
|
|
820
|
-
|
|
965
|
+
const data = { request_id, channels };
|
|
966
|
+
if (this.underlyingMintScope) {
|
|
967
|
+
data.underlying_mints = Array.from(this.underlyingMintScope);
|
|
968
|
+
}
|
|
969
|
+
if (this.quoteMintScope) {
|
|
970
|
+
data.quote_mints = Array.from(this.quoteMintScope);
|
|
971
|
+
}
|
|
821
972
|
this.send({ type: "Subscribe", data });
|
|
822
973
|
}
|
|
823
974
|
}
|
|
@@ -96,7 +96,9 @@ export declare const ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 1074;
|
|
|
96
96
|
export declare const ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 1075;
|
|
97
97
|
/** MarketNotExpired: Market has not expired yet */
|
|
98
98
|
export declare const ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = 1076;
|
|
99
|
-
|
|
99
|
+
/** OracleNotExpiredYet: Oracle has not expired yet (cannot update price before expiry) */
|
|
100
|
+
export declare const ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 1077;
|
|
101
|
+
export type ActaContractError = typeof ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED | typeof ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED | typeof ACTA_CONTRACT_ERROR__CANNOT_LIQUIDATE_FUNDED | typeof ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT | typeof ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS | typeof ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT | typeof ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA | typeof ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA | typeof ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT | typeof ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE | typeof ACTA_CONTRACT_ERROR__INVALID_ORDER_ID | typeof ACTA_CONTRACT_ERROR__INVALID_OWNER | typeof ACTA_CONTRACT_ERROR__INVALID_PDA | typeof ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID | typeof ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT | typeof ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP | typeof ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED | typeof ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER | typeof ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED | typeof ACTA_CONTRACT_ERROR__MARKET_EXPIRED | typeof ACTA_CONTRACT_ERROR__MARKET_FINALIZED | typeof ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY | typeof ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED | typeof ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED | typeof ACTA_CONTRACT_ERROR__MATH_OVERFLOW | typeof ACTA_CONTRACT_ERROR__MINT_MISMATCH | typeof ACTA_CONTRACT_ERROR__NOT_SIGNED | typeof ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED | typeof ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY | typeof ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH | typeof ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS | typeof ACTA_CONTRACT_ERROR__ORACLE_INACTIVE | typeof ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE | typeof ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET | typeof ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED | typeof ACTA_CONTRACT_ERROR__ORACLE_STALE | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_ITM | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN | typeof ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH | typeof ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH | typeof ACTA_CONTRACT_ERROR__SIGNER_MISMATCH | typeof ACTA_CONTRACT_ERROR__UNAUTHORIZED;
|
|
100
102
|
export declare function getActaContractErrorMessage(code: ActaContractError): string;
|
|
101
103
|
export declare function isActaContractError<TProgramErrorCode extends ActaContractError>(error: unknown, transactionMessage: {
|
|
102
104
|
instructions: Record<number, {
|
|
@@ -97,6 +97,8 @@ export const ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 0x432; // 1074
|
|
|
97
97
|
export const ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 0x433; // 1075
|
|
98
98
|
/** MarketNotExpired: Market has not expired yet */
|
|
99
99
|
export const ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = 0x434; // 1076
|
|
100
|
+
/** OracleNotExpiredYet: Oracle has not expired yet (cannot update price before expiry) */
|
|
101
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 0x435; // 1077
|
|
100
102
|
let actaContractErrorMessages;
|
|
101
103
|
if (process.env.NODE_ENV !== "production") {
|
|
102
104
|
actaContractErrorMessages = {
|
|
@@ -133,6 +135,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
133
135
|
[ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS]: `Oracle is still linked to active markets`,
|
|
134
136
|
[ACTA_CONTRACT_ERROR__ORACLE_INACTIVE]: `Oracle inactive`,
|
|
135
137
|
[ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE]: `Oracle price invalid (zero or negative)`,
|
|
138
|
+
[ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET]: `Oracle has not expired yet (cannot update price before expiry)`,
|
|
136
139
|
[ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED]: `Oracle source fields are locked after first update`,
|
|
137
140
|
[ACTA_CONTRACT_ERROR__ORACLE_STALE]: `Oracle price is stale (updated_at before expiry)`,
|
|
138
141
|
[ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED]: `Position already funded by maker`,
|
|
@@ -2312,6 +2312,11 @@
|
|
|
2312
2312
|
"code": 1076,
|
|
2313
2313
|
"name": "MarketNotExpired",
|
|
2314
2314
|
"msg": "Market has not expired yet"
|
|
2315
|
+
},
|
|
2316
|
+
{
|
|
2317
|
+
"code": 1077,
|
|
2318
|
+
"name": "OracleNotExpiredYet",
|
|
2319
|
+
"msg": "Oracle has not expired yet (cannot update price before expiry)"
|
|
2315
2320
|
}
|
|
2316
2321
|
]
|
|
2317
2322
|
}
|
package/dist/idl/hash.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ACTA_IDL_SHA256 = "
|
|
1
|
+
export declare const ACTA_IDL_SHA256 = "2ccf0a77f682ff60b8201e2bca7f4bd026500a2fb9637d46dad7a8de3b2ee313";
|
package/dist/idl/hash.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ACTA_IDL_SHA256 = "
|
|
1
|
+
export const ACTA_IDL_SHA256 = "2ccf0a77f682ff60b8201e2bca7f4bd026500a2fb9637d46dad7a8de3b2ee313";
|
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;
|