@acta-markets/ts-sdk 0.0.22-beta → 0.0.24-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/README.md +2 -2
- package/dist/chain/instructions.position.d.ts +1 -0
- package/dist/chain/instructions.position.js +1 -0
- package/dist/cjs/chain/instructions.position.js +1 -0
- package/dist/cjs/generated/errors/actaContract.js +4 -1
- package/dist/cjs/generated/instructions/settlePosition.js +11 -3
- package/dist/cjs/idl/acta_contract.json +11 -1
- package/dist/cjs/idl/hash.js +1 -1
- package/dist/cjs/ws/client.js +68 -10
- package/dist/cjs/ws/flows.js +20 -0
- package/dist/generated/errors/actaContract.d.ts +3 -1
- package/dist/generated/errors/actaContract.js +3 -0
- package/dist/generated/instructions/settlePosition.d.ts +5 -1
- package/dist/generated/instructions/settlePosition.js +11 -3
- package/dist/idl/acta_contract.json +11 -1
- package/dist/idl/hash.d.ts +1 -1
- package/dist/idl/hash.js +1 -1
- package/dist/ws/client.d.ts +35 -6
- package/dist/ws/client.js +69 -11
- package/dist/ws/flows.d.ts +13 -1
- package/dist/ws/flows.js +19 -0
- package/dist/ws/types.d.ts +99 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ Generated by Codama.
|
|
|
8
8
|
|
|
9
9
|
## Package
|
|
10
10
|
|
|
11
|
-
Published package: `@acta-markets/ts-sdk@0.0.
|
|
11
|
+
Published package: `@acta-markets/ts-sdk@0.0.24-beta` (ESM-first, CJS fallback)
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
yarn add @acta-markets/ts-sdk@0.0.
|
|
14
|
+
yarn add @acta-markets/ts-sdk@0.0.24-beta
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Tooling
|
|
@@ -57,6 +57,7 @@ export declare function buildSettlePositionIx(input: {
|
|
|
57
57
|
tokenProgram?: Address<string>;
|
|
58
58
|
underlyingTokenProgram?: Address<string>;
|
|
59
59
|
quoteTokenProgram?: Address<string>;
|
|
60
|
+
flags?: number;
|
|
60
61
|
rpc?: Rpc;
|
|
61
62
|
}): Promise<Instruction>;
|
|
62
63
|
export declare function buildLiquidatePositionIx(input: {
|
|
@@ -175,6 +175,7 @@ export async function buildSettlePositionIx(input) {
|
|
|
175
175
|
makerDestAta: toAddress(input.makerDestAta),
|
|
176
176
|
underlyingTokenProgram,
|
|
177
177
|
quoteTokenProgram,
|
|
178
|
+
flags: input.flags ?? 0,
|
|
178
179
|
}, { programAddress: getActaProgramId() });
|
|
179
180
|
}
|
|
180
181
|
export async function buildLiquidatePositionIx(input) {
|
|
@@ -182,6 +182,7 @@ async function buildSettlePositionIx(input) {
|
|
|
182
182
|
makerDestAta: (0, instructions_shared_1.toAddress)(input.makerDestAta),
|
|
183
183
|
underlyingTokenProgram,
|
|
184
184
|
quoteTokenProgram,
|
|
185
|
+
flags: input.flags ?? 0,
|
|
185
186
|
}, { programAddress: (0, index_1.getActaProgramId)() });
|
|
186
187
|
}
|
|
187
188
|
async function buildLiquidatePositionIx(input) {
|
|
@@ -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__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;
|
|
10
|
+
exports.ACTA_CONTRACT_ERROR__INVALID_UNWRAP_DESTINATION = 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");
|
|
@@ -104,6 +104,8 @@ exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 0x433; // 1075
|
|
|
104
104
|
exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = 0x434; // 1076
|
|
105
105
|
/** OracleNotExpiredYet: Oracle has not expired yet (cannot update price before expiry) */
|
|
106
106
|
exports.ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 0x435; // 1077
|
|
107
|
+
/** InvalidUnwrapDestination: Unwrap SOL destination does not match position taker */
|
|
108
|
+
exports.ACTA_CONTRACT_ERROR__INVALID_UNWRAP_DESTINATION = 0x436; // 1078
|
|
107
109
|
let actaContractErrorMessages;
|
|
108
110
|
if (process.env.NODE_ENV !== "production") {
|
|
109
111
|
actaContractErrorMessages = {
|
|
@@ -123,6 +125,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
123
125
|
[exports.ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID]: `Wrong program ID`,
|
|
124
126
|
[exports.ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT]: `Ed25519 instruction has wrong signature count`,
|
|
125
127
|
[exports.ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP]: `Clock timestamp invalid`,
|
|
128
|
+
[exports.ACTA_CONTRACT_ERROR__INVALID_UNWRAP_DESTINATION]: `Unwrap SOL destination does not match position taker`,
|
|
126
129
|
[exports.ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED]: `Maker PDA already exists`,
|
|
127
130
|
[exports.ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER]: `Caller is not the maker owner`,
|
|
128
131
|
[exports.ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED]: `Maker PDA not found`,
|
|
@@ -22,10 +22,16 @@ function getSettlePositionDiscriminatorBytes() {
|
|
|
22
22
|
return (0, kit_1.getU8Encoder)().encode(exports.SETTLE_POSITION_DISCRIMINATOR);
|
|
23
23
|
}
|
|
24
24
|
function getSettlePositionInstructionDataEncoder() {
|
|
25
|
-
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
|
|
25
|
+
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
|
|
26
|
+
["discriminator", (0, kit_1.getU8Encoder)()],
|
|
27
|
+
["flags", (0, kit_1.getU8Encoder)()],
|
|
28
|
+
]), (value) => ({ ...value, discriminator: exports.SETTLE_POSITION_DISCRIMINATOR }));
|
|
26
29
|
}
|
|
27
30
|
function getSettlePositionInstructionDataDecoder() {
|
|
28
|
-
return (0, kit_1.getStructDecoder)([
|
|
31
|
+
return (0, kit_1.getStructDecoder)([
|
|
32
|
+
["discriminator", (0, kit_1.getU8Decoder)()],
|
|
33
|
+
["flags", (0, kit_1.getU8Decoder)()],
|
|
34
|
+
]);
|
|
29
35
|
}
|
|
30
36
|
function getSettlePositionInstructionDataCodec() {
|
|
31
37
|
return (0, kit_1.combineCodec)(getSettlePositionInstructionDataEncoder(), getSettlePositionInstructionDataDecoder());
|
|
@@ -58,6 +64,8 @@ function getSettlePositionInstruction(input, config) {
|
|
|
58
64
|
},
|
|
59
65
|
};
|
|
60
66
|
const accounts = originalAccounts;
|
|
67
|
+
// Original args.
|
|
68
|
+
const args = { ...input };
|
|
61
69
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, "programId");
|
|
62
70
|
return Object.freeze({
|
|
63
71
|
accounts: [
|
|
@@ -71,7 +79,7 @@ function getSettlePositionInstruction(input, config) {
|
|
|
71
79
|
getAccountMeta(accounts.underlyingTokenProgram),
|
|
72
80
|
getAccountMeta(accounts.quoteTokenProgram),
|
|
73
81
|
],
|
|
74
|
-
data: getSettlePositionInstructionDataEncoder().encode(
|
|
82
|
+
data: getSettlePositionInstructionDataEncoder().encode(args),
|
|
75
83
|
programAddress,
|
|
76
84
|
});
|
|
77
85
|
}
|
|
@@ -751,7 +751,12 @@
|
|
|
751
751
|
]
|
|
752
752
|
}
|
|
753
753
|
],
|
|
754
|
-
"args": [
|
|
754
|
+
"args": [
|
|
755
|
+
{
|
|
756
|
+
"name": "flags",
|
|
757
|
+
"type": "u8"
|
|
758
|
+
}
|
|
759
|
+
],
|
|
755
760
|
"discriminant": {
|
|
756
761
|
"type": "u8",
|
|
757
762
|
"value": 10
|
|
@@ -2317,6 +2322,11 @@
|
|
|
2317
2322
|
"code": 1077,
|
|
2318
2323
|
"name": "OracleNotExpiredYet",
|
|
2319
2324
|
"msg": "Oracle has not expired yet (cannot update price before expiry)"
|
|
2325
|
+
},
|
|
2326
|
+
{
|
|
2327
|
+
"code": 1078,
|
|
2328
|
+
"name": "InvalidUnwrapDestination",
|
|
2329
|
+
"msg": "Unwrap SOL destination does not match position taker"
|
|
2320
2330
|
}
|
|
2321
2331
|
]
|
|
2322
2332
|
}
|
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 = "e2fc8ff5fad4cb5691f27082fae3cc004a9116133c6eb64558905dbb946e3b33";
|
package/dist/cjs/ws/client.js
CHANGED
|
@@ -103,6 +103,7 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
103
103
|
connectionState = "disconnected";
|
|
104
104
|
sessionId = null;
|
|
105
105
|
lastAuthSessionId = null;
|
|
106
|
+
makerPda = null;
|
|
106
107
|
helloSent = false;
|
|
107
108
|
welcomeReceived = false;
|
|
108
109
|
pendingMessages = [];
|
|
@@ -147,6 +148,7 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
147
148
|
this.authRequested = false;
|
|
148
149
|
this.pendingResumeSessionId = null;
|
|
149
150
|
this.lastAuthSessionId = null;
|
|
151
|
+
this.makerPda = null;
|
|
150
152
|
this.shouldReconnect = this.options.autoReconnect;
|
|
151
153
|
this.doConnect();
|
|
152
154
|
}
|
|
@@ -200,6 +202,9 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
200
202
|
getSessionId() {
|
|
201
203
|
return this.sessionId;
|
|
202
204
|
}
|
|
205
|
+
getMakerPda() {
|
|
206
|
+
return this.makerPda;
|
|
207
|
+
}
|
|
203
208
|
async createRfq(request) {
|
|
204
209
|
this.ensureAuthenticated();
|
|
205
210
|
(0, wirePolicy_1.assertWsU64Safe)(request.strike, "strike");
|
|
@@ -340,12 +345,12 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
340
345
|
});
|
|
341
346
|
return requestId;
|
|
342
347
|
}
|
|
343
|
-
/** Maker-only:
|
|
344
|
-
|
|
348
|
+
/** Maker-only: one-shot MM dashboard bootstrap. */
|
|
349
|
+
getMmSummary() {
|
|
345
350
|
this.ensureAuthenticated();
|
|
346
351
|
const requestId = this.nextRequestId();
|
|
347
352
|
this.send({
|
|
348
|
-
type: "
|
|
353
|
+
type: "GetMmSummary",
|
|
349
354
|
data: { request_id: requestId },
|
|
350
355
|
});
|
|
351
356
|
return requestId;
|
|
@@ -400,6 +405,7 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
400
405
|
const data = {
|
|
401
406
|
request_id: requestId,
|
|
402
407
|
active_only: args?.active_only ?? true,
|
|
408
|
+
...(args?.limit !== undefined ? { limit: args.limit } : {}),
|
|
403
409
|
};
|
|
404
410
|
this.send({ type: "GetMyQuotes", data });
|
|
405
411
|
return requestId;
|
|
@@ -496,6 +502,40 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
496
502
|
});
|
|
497
503
|
this.submitQuote(quote);
|
|
498
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* Replace an in-flight quote on the same RFQ. Server treats this as
|
|
507
|
+
* cancel-old + place-new atomically; maker signs the NEW `order_id`.
|
|
508
|
+
*/
|
|
509
|
+
submitReplaceQuote(msg) {
|
|
510
|
+
this.ensureAuthenticated();
|
|
511
|
+
this.send({ type: "ReplaceQuote", data: msg });
|
|
512
|
+
}
|
|
513
|
+
/** Convenience: compute new `order_id`, sign it, and send `ReplaceQuote`. */
|
|
514
|
+
async submitReplaceQuoteSigned(args) {
|
|
515
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.strike, "strike");
|
|
516
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.price, "price");
|
|
517
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.validUntil, "validUntil");
|
|
518
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.nonce, "nonce");
|
|
519
|
+
const msg = await (0, flows_1.buildSignedReplaceQuoteMessage)({
|
|
520
|
+
oldOrderId: args.oldOrderId,
|
|
521
|
+
rfqId: args.rfqId,
|
|
522
|
+
strike: args.strike,
|
|
523
|
+
price: args.price,
|
|
524
|
+
validUntil: args.validUntil,
|
|
525
|
+
nonce: args.nonce,
|
|
526
|
+
orderId: args.orderId,
|
|
527
|
+
makerSigner: args.makerSigner,
|
|
528
|
+
});
|
|
529
|
+
this.submitReplaceQuote(msg);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Send multiple signed quotes in one WS frame. Each entry must already be
|
|
533
|
+
* a fully-built `QuoteMessage` (use `buildSignedQuoteMessage` per quote).
|
|
534
|
+
*/
|
|
535
|
+
submitBatchQuotes(quotes) {
|
|
536
|
+
this.ensureAuthenticated();
|
|
537
|
+
this.send({ type: "BatchQuotes", data: { quotes } });
|
|
538
|
+
}
|
|
499
539
|
cancelQuote(rfqId) {
|
|
500
540
|
this.ensureAuthenticated();
|
|
501
541
|
const requestId = this.nextRequestId();
|
|
@@ -589,6 +629,13 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
589
629
|
this.send({ type: "RemoveChannels", data: { request_id, channels } });
|
|
590
630
|
return request_id;
|
|
591
631
|
}
|
|
632
|
+
/** Query the server's view of this session's subscriptions. Response: `subscriptions` event. */
|
|
633
|
+
getSubscriptions() {
|
|
634
|
+
this.ensureAuthenticated();
|
|
635
|
+
const request_id = this.nextRequestId();
|
|
636
|
+
this.send({ type: "GetSubscriptions", data: { request_id } });
|
|
637
|
+
return request_id;
|
|
638
|
+
}
|
|
592
639
|
ping() {
|
|
593
640
|
if (this.ws?.readyState === WS_OPEN) {
|
|
594
641
|
this.send({ type: "Ping" });
|
|
@@ -683,7 +730,7 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
683
730
|
void this.handleAuthRequest(message.data.challenge);
|
|
684
731
|
break;
|
|
685
732
|
case "AuthSuccess":
|
|
686
|
-
this.handleAuthSuccess(message.data.session_id, message.data.expires_at);
|
|
733
|
+
this.handleAuthSuccess(message.data.session_id, message.data.expires_at, message.data.maker_pda ?? null);
|
|
687
734
|
break;
|
|
688
735
|
case "AuthError":
|
|
689
736
|
this.handleAuthError(message.data.reason, message.data.message);
|
|
@@ -692,6 +739,7 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
692
739
|
this.sessionId = null;
|
|
693
740
|
this.pendingResumeSessionId = null;
|
|
694
741
|
this.lastAuthSessionId = null;
|
|
742
|
+
this.makerPda = null;
|
|
695
743
|
this.startAuthSent = false;
|
|
696
744
|
this.setConnectionState("connecting");
|
|
697
745
|
this.emit("logoutSuccess");
|
|
@@ -739,9 +787,6 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
739
787
|
case "MyCaps":
|
|
740
788
|
this.emit("myCaps", message.data);
|
|
741
789
|
break;
|
|
742
|
-
case "MakerBalances":
|
|
743
|
-
this.emit("makerBalances", message.data);
|
|
744
|
-
break;
|
|
745
790
|
case "MakerPositions":
|
|
746
791
|
this.emit("makerPositions", message.data);
|
|
747
792
|
break;
|
|
@@ -754,6 +799,18 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
754
799
|
case "MyQuotes":
|
|
755
800
|
this.emit("myQuotes", message.data);
|
|
756
801
|
break;
|
|
802
|
+
case "MmSummary":
|
|
803
|
+
this.emit("mmSummary", message.data);
|
|
804
|
+
break;
|
|
805
|
+
case "QuoteRejected":
|
|
806
|
+
this.emit("quoteRejected", message.data);
|
|
807
|
+
break;
|
|
808
|
+
case "BatchQuotesAck":
|
|
809
|
+
this.emit("batchQuotesAck", message.data);
|
|
810
|
+
break;
|
|
811
|
+
case "CancelAllQuotesAck":
|
|
812
|
+
this.emit("cancelAllQuotesAck", message.data);
|
|
813
|
+
break;
|
|
757
814
|
case "MyActiveRfqs":
|
|
758
815
|
this.handleMyActiveRfqs(message.data);
|
|
759
816
|
break;
|
|
@@ -1009,14 +1066,15 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
1009
1066
|
this.send(msg);
|
|
1010
1067
|
}
|
|
1011
1068
|
}
|
|
1012
|
-
handleAuthSuccess(sessionId, expiresAt) {
|
|
1069
|
+
handleAuthSuccess(sessionId, expiresAt, makerPda) {
|
|
1013
1070
|
this.sessionId = sessionId;
|
|
1014
1071
|
this.pendingResumeSessionId = null;
|
|
1015
1072
|
if (expiresAt !== null) {
|
|
1016
1073
|
this.lastAuthSessionId = sessionId;
|
|
1017
1074
|
}
|
|
1075
|
+
this.makerPda = makerPda;
|
|
1018
1076
|
this.setConnectionState("authenticated");
|
|
1019
|
-
this.emit("authenticated", sessionId, expiresAt);
|
|
1077
|
+
this.emit("authenticated", sessionId, expiresAt, makerPda);
|
|
1020
1078
|
if (this.subscribedChannels.size > 0) {
|
|
1021
1079
|
const channels = Array.from(this.subscribedChannels);
|
|
1022
1080
|
const request_id = this.nextRequestId();
|
|
@@ -1100,7 +1158,7 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
1100
1158
|
}
|
|
1101
1159
|
handlePositionUpdated(data) {
|
|
1102
1160
|
this.state.positions.set(data.position.pda, data.position);
|
|
1103
|
-
this.emit("positionUpdated", data.position, data.update_type);
|
|
1161
|
+
this.emit("positionUpdated", data.position, data.update_type, data);
|
|
1104
1162
|
}
|
|
1105
1163
|
handleChainEvent(event) {
|
|
1106
1164
|
this.emit("chainEvent", event);
|
package/dist/cjs/ws/flows.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.buildSignedQuoteMessage = buildSignedQuoteMessage;
|
|
9
|
+
exports.buildSignedReplaceQuoteMessage = buildSignedReplaceQuoteMessage;
|
|
9
10
|
exports.buildSignedQuoteFromRfq = buildSignedQuoteFromRfq;
|
|
10
11
|
exports.buildAcceptQuoteMessage = buildAcceptQuoteMessage;
|
|
11
12
|
const orders_1 = require("../chain/orders");
|
|
@@ -29,6 +30,25 @@ async function buildSignedQuoteMessage(args) {
|
|
|
29
30
|
signature: signatureBase58,
|
|
30
31
|
};
|
|
31
32
|
}
|
|
33
|
+
async function buildSignedReplaceQuoteMessage(args) {
|
|
34
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.strike, "strike");
|
|
35
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.price, "price");
|
|
36
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.validUntil, "validUntil");
|
|
37
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.nonce, "nonce");
|
|
38
|
+
(0, orderId_1.assertOrderId32)(args.oldOrderId);
|
|
39
|
+
(0, orderId_1.assertOrderId32)(args.orderId);
|
|
40
|
+
const { signatureBase58 } = await (0, orders_1.signOrderIdBase58)(args.makerSigner, args.orderId);
|
|
41
|
+
return {
|
|
42
|
+
old_order_id: (0, orderId_1.orderIdToHex)(args.oldOrderId),
|
|
43
|
+
rfq_id: args.rfqId,
|
|
44
|
+
strike: args.strike,
|
|
45
|
+
price: args.price,
|
|
46
|
+
valid_until: args.validUntil,
|
|
47
|
+
nonce: args.nonce,
|
|
48
|
+
order_id: (0, orderId_1.orderIdToHex)(args.orderId),
|
|
49
|
+
signature: signatureBase58,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
32
52
|
function positionTypeToU8(positionType) {
|
|
33
53
|
switch (positionType) {
|
|
34
54
|
case "covered_call":
|
|
@@ -98,7 +98,9 @@ export declare const ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 1075;
|
|
|
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
100
|
export declare const ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 1077;
|
|
101
|
-
|
|
101
|
+
/** InvalidUnwrapDestination: Unwrap SOL destination does not match position taker */
|
|
102
|
+
export declare const ACTA_CONTRACT_ERROR__INVALID_UNWRAP_DESTINATION = 1078;
|
|
103
|
+
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__INVALID_UNWRAP_DESTINATION | 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;
|
|
102
104
|
export declare function getActaContractErrorMessage(code: ActaContractError): string;
|
|
103
105
|
export declare function isActaContractError<TProgramErrorCode extends ActaContractError>(error: unknown, transactionMessage: {
|
|
104
106
|
instructions: Record<number, {
|
|
@@ -99,6 +99,8 @@ export const ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 0x433; // 1075
|
|
|
99
99
|
export const ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = 0x434; // 1076
|
|
100
100
|
/** OracleNotExpiredYet: Oracle has not expired yet (cannot update price before expiry) */
|
|
101
101
|
export const ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 0x435; // 1077
|
|
102
|
+
/** InvalidUnwrapDestination: Unwrap SOL destination does not match position taker */
|
|
103
|
+
export const ACTA_CONTRACT_ERROR__INVALID_UNWRAP_DESTINATION = 0x436; // 1078
|
|
102
104
|
let actaContractErrorMessages;
|
|
103
105
|
if (process.env.NODE_ENV !== "production") {
|
|
104
106
|
actaContractErrorMessages = {
|
|
@@ -118,6 +120,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
118
120
|
[ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID]: `Wrong program ID`,
|
|
119
121
|
[ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT]: `Ed25519 instruction has wrong signature count`,
|
|
120
122
|
[ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP]: `Clock timestamp invalid`,
|
|
123
|
+
[ACTA_CONTRACT_ERROR__INVALID_UNWRAP_DESTINATION]: `Unwrap SOL destination does not match position taker`,
|
|
121
124
|
[ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED]: `Maker PDA already exists`,
|
|
122
125
|
[ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER]: `Caller is not the maker owner`,
|
|
123
126
|
[ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED]: `Maker PDA not found`,
|
|
@@ -23,8 +23,11 @@ export type SettlePositionInstruction<TProgram extends string = typeof ACTA_CONT
|
|
|
23
23
|
]>;
|
|
24
24
|
export type SettlePositionInstructionData = {
|
|
25
25
|
discriminator: number;
|
|
26
|
+
flags: number;
|
|
27
|
+
};
|
|
28
|
+
export type SettlePositionInstructionDataArgs = {
|
|
29
|
+
flags: number;
|
|
26
30
|
};
|
|
27
|
-
export type SettlePositionInstructionDataArgs = {};
|
|
28
31
|
export declare function getSettlePositionInstructionDataEncoder(): FixedSizeEncoder<SettlePositionInstructionDataArgs>;
|
|
29
32
|
export declare function getSettlePositionInstructionDataDecoder(): FixedSizeDecoder<SettlePositionInstructionData>;
|
|
30
33
|
export declare function getSettlePositionInstructionDataCodec(): FixedSizeCodec<SettlePositionInstructionDataArgs, SettlePositionInstructionData>;
|
|
@@ -47,6 +50,7 @@ export type SettlePositionInput<TAccountSettler extends string = string, TAccoun
|
|
|
47
50
|
underlyingTokenProgram: Address<TAccountUnderlyingTokenProgram>;
|
|
48
51
|
/** Token program for quote mint */
|
|
49
52
|
quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
|
|
53
|
+
flags: SettlePositionInstructionDataArgs["flags"];
|
|
50
54
|
};
|
|
51
55
|
export declare function getSettlePositionInstruction<TAccountSettler extends string, TAccountPositionPda extends string, TAccountMarketPda extends string, TAccountPosCollateralAta extends string, TAccountPosSettlementAta extends string, TAccountUserDestAta extends string, TAccountMakerDestAta extends string, TAccountUnderlyingTokenProgram extends string, TAccountQuoteTokenProgram extends string, TProgramAddress extends Address = typeof ACTA_CONTRACT_PROGRAM_ADDRESS>(input: SettlePositionInput<TAccountSettler, TAccountPositionPda, TAccountMarketPda, TAccountPosCollateralAta, TAccountPosSettlementAta, TAccountUserDestAta, TAccountMakerDestAta, TAccountUnderlyingTokenProgram, TAccountQuoteTokenProgram>, config?: {
|
|
52
56
|
programAddress?: TProgramAddress;
|
|
@@ -13,10 +13,16 @@ export function getSettlePositionDiscriminatorBytes() {
|
|
|
13
13
|
return getU8Encoder().encode(SETTLE_POSITION_DISCRIMINATOR);
|
|
14
14
|
}
|
|
15
15
|
export function getSettlePositionInstructionDataEncoder() {
|
|
16
|
-
return transformEncoder(getStructEncoder([
|
|
16
|
+
return transformEncoder(getStructEncoder([
|
|
17
|
+
["discriminator", getU8Encoder()],
|
|
18
|
+
["flags", getU8Encoder()],
|
|
19
|
+
]), (value) => ({ ...value, discriminator: SETTLE_POSITION_DISCRIMINATOR }));
|
|
17
20
|
}
|
|
18
21
|
export function getSettlePositionInstructionDataDecoder() {
|
|
19
|
-
return getStructDecoder([
|
|
22
|
+
return getStructDecoder([
|
|
23
|
+
["discriminator", getU8Decoder()],
|
|
24
|
+
["flags", getU8Decoder()],
|
|
25
|
+
]);
|
|
20
26
|
}
|
|
21
27
|
export function getSettlePositionInstructionDataCodec() {
|
|
22
28
|
return combineCodec(getSettlePositionInstructionDataEncoder(), getSettlePositionInstructionDataDecoder());
|
|
@@ -49,6 +55,8 @@ export function getSettlePositionInstruction(input, config) {
|
|
|
49
55
|
},
|
|
50
56
|
};
|
|
51
57
|
const accounts = originalAccounts;
|
|
58
|
+
// Original args.
|
|
59
|
+
const args = { ...input };
|
|
52
60
|
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
53
61
|
return Object.freeze({
|
|
54
62
|
accounts: [
|
|
@@ -62,7 +70,7 @@ export function getSettlePositionInstruction(input, config) {
|
|
|
62
70
|
getAccountMeta(accounts.underlyingTokenProgram),
|
|
63
71
|
getAccountMeta(accounts.quoteTokenProgram),
|
|
64
72
|
],
|
|
65
|
-
data: getSettlePositionInstructionDataEncoder().encode(
|
|
73
|
+
data: getSettlePositionInstructionDataEncoder().encode(args),
|
|
66
74
|
programAddress,
|
|
67
75
|
});
|
|
68
76
|
}
|
|
@@ -751,7 +751,12 @@
|
|
|
751
751
|
]
|
|
752
752
|
}
|
|
753
753
|
],
|
|
754
|
-
"args": [
|
|
754
|
+
"args": [
|
|
755
|
+
{
|
|
756
|
+
"name": "flags",
|
|
757
|
+
"type": "u8"
|
|
758
|
+
}
|
|
759
|
+
],
|
|
755
760
|
"discriminant": {
|
|
756
761
|
"type": "u8",
|
|
757
762
|
"value": 10
|
|
@@ -2317,6 +2322,11 @@
|
|
|
2317
2322
|
"code": 1077,
|
|
2318
2323
|
"name": "OracleNotExpiredYet",
|
|
2319
2324
|
"msg": "Oracle has not expired yet (cannot update price before expiry)"
|
|
2325
|
+
},
|
|
2326
|
+
{
|
|
2327
|
+
"code": 1078,
|
|
2328
|
+
"name": "InvalidUnwrapDestination",
|
|
2329
|
+
"msg": "Unwrap SOL destination does not match position taker"
|
|
2320
2330
|
}
|
|
2321
2331
|
]
|
|
2322
2332
|
}
|
package/dist/idl/hash.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ACTA_IDL_SHA256 = "
|
|
1
|
+
export declare const ACTA_IDL_SHA256 = "e2fc8ff5fad4cb5691f27082fae3cc004a9116133c6eb64558905dbb946e3b33";
|
package/dist/idl/hash.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ACTA_IDL_SHA256 = "
|
|
1
|
+
export const ACTA_IDL_SHA256 = "e2fc8ff5fad4cb5691f27082fae3cc004a9116133c6eb64558905dbb946e3b33";
|
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,
|
|
5
|
+
import type { ActiveRfqInfo, ChainEventMessage, EarnSummaryData, TokenMarketsInfoData, GlobalStats, MarketDescriptorInfo, MarketInfo, MyActiveRfqInfo, MyActiveRfqsMessage, OrderStatusMessage, PositionInfo, PositionUpdatedMessage, QuoteAcknowledgedMessage, QuoteBestStatusMessage, QuoteCancelledMessage, QuoteMessage, ReplaceQuoteMessage, QuoteRefreshRequestedMessage, QuoteOutbidMessage, QuoteReceivedMessage, QuoteSelectedMessage, QuotesUpdateMessage, RfqBroadcastMessage, RfqClosedMessage, RfqCreatedMessage, RfqSkippedMessage, RfqRequestMessage, RfqAvailableAgainMessage, QuoteExpiredMessage, QuoteFilledMessage, IndicativePricesMessage, IndicativePricesRequestMessage, IndicativePricesResponseMessage, GetIndicativePricesMessage, CancelAllQuotesAckMessage, BatchQuotesAckMessage, QuoteRejectedMessage, MakerMarketsMessage, MakerPositionsMessage, MmSummaryData, MyCapsMessage, MyQuotesMessage, MyTradesMessage, RequestId, ServerError, ServerMessage, SnapshotMessage, StatsDelta, SubscriptionsMessage, TokenInfo, TradeInfo, UuidString, VersionMismatchMessage, WelcomeMessage, WsChannel, InviteRedeemedData, ReferralCodeClaimedData, MyReferralInfoData } 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";
|
|
@@ -56,7 +56,7 @@ export type ActaWsClientEvents = {
|
|
|
56
56
|
connected: () => void;
|
|
57
57
|
welcome: (msg: WelcomeMessage) => void;
|
|
58
58
|
versionMismatch: (msg: VersionMismatchMessage) => void;
|
|
59
|
-
authenticated: (sessionId: string, expiresAt: number | null) => void;
|
|
59
|
+
authenticated: (sessionId: string, expiresAt: number | null, makerPda: string | null) => void;
|
|
60
60
|
authError: (reason: string, message?: string) => void;
|
|
61
61
|
logoutSuccess: () => void;
|
|
62
62
|
disconnected: (code: number, reason: string) => void;
|
|
@@ -110,12 +110,15 @@ export type ActaWsClientEvents = {
|
|
|
110
110
|
quoteCancelled: (msg: QuoteCancelledMessage) => void;
|
|
111
111
|
rfqAvailableAgain: (msg: RfqAvailableAgainMessage) => void;
|
|
112
112
|
quoteExpired: (msg: QuoteExpiredMessage) => void;
|
|
113
|
+
quoteRejected: (msg: QuoteRejectedMessage) => void;
|
|
114
|
+
batchQuotesAck: (msg: BatchQuotesAckMessage) => void;
|
|
115
|
+
cancelAllQuotesAck: (msg: CancelAllQuotesAckMessage) => void;
|
|
113
116
|
indicativePrices: (msg: IndicativePricesMessage) => void;
|
|
114
117
|
indicativePricesRequest: (msg: IndicativePricesRequestMessage) => void;
|
|
115
|
-
makerBalances: (msg: MakerBalancesMessage) => void;
|
|
116
118
|
makerPositions: (msg: MakerPositionsMessage) => void;
|
|
117
119
|
myTrades: (msg: MyTradesMessage) => void;
|
|
118
120
|
myCaps: (msg: MyCapsMessage) => void;
|
|
121
|
+
mmSummary: (msg: MmSummaryData) => void;
|
|
119
122
|
makerMarkets: (msg: MakerMarketsMessage) => void;
|
|
120
123
|
myQuotes: (msg: MyQuotesMessage) => void;
|
|
121
124
|
myActiveRfqs: (msg: MyActiveRfqsMessage) => void;
|
|
@@ -126,7 +129,7 @@ export type ActaWsClientEvents = {
|
|
|
126
129
|
orderConfirmed: (orderId: string, positionPda: string) => void;
|
|
127
130
|
orderFailed: (orderId: string, reason: string) => void;
|
|
128
131
|
tradeExecuted: (trade: TradeInfo, delta?: StatsDelta | null) => void;
|
|
129
|
-
positionUpdated: (position: PositionInfo, updateType: string) => void;
|
|
132
|
+
positionUpdated: (position: PositionInfo, updateType: string, msg: PositionUpdatedMessage) => void;
|
|
130
133
|
marketCreated: (market: MarketInfo) => void;
|
|
131
134
|
marketFinalized: (marketPda: string, settlementPrice: number) => void;
|
|
132
135
|
chainEvent: (event: ChainEventMessage) => void;
|
|
@@ -184,6 +187,7 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
184
187
|
private connectionState;
|
|
185
188
|
private sessionId;
|
|
186
189
|
private lastAuthSessionId;
|
|
190
|
+
private makerPda;
|
|
187
191
|
private helloSent;
|
|
188
192
|
private welcomeReceived;
|
|
189
193
|
private pendingMessages;
|
|
@@ -207,6 +211,7 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
207
211
|
getConnectionState(): ConnectionState;
|
|
208
212
|
isAuthenticated(): boolean;
|
|
209
213
|
getSessionId(): string | null;
|
|
214
|
+
getMakerPda(): string | null;
|
|
210
215
|
createRfq(request: Omit<RfqRequestMessage, "timeout_seconds"> & {
|
|
211
216
|
timeoutSeconds?: number;
|
|
212
217
|
clientRequestId?: string;
|
|
@@ -249,8 +254,8 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
249
254
|
}): RequestId;
|
|
250
255
|
getEarnSummary(): RequestId;
|
|
251
256
|
getTokenMarketsInfo(underlyingMint: string): RequestId;
|
|
252
|
-
/** Maker-only:
|
|
253
|
-
|
|
257
|
+
/** Maker-only: one-shot MM dashboard bootstrap. */
|
|
258
|
+
getMmSummary(): RequestId;
|
|
254
259
|
/** Maker-only: get open positions with optional filters. */
|
|
255
260
|
getMakerPositions(args?: {
|
|
256
261
|
market?: string;
|
|
@@ -279,6 +284,7 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
279
284
|
/** Maker-only: get submitted quotes with status. */
|
|
280
285
|
getMyQuotes(args?: {
|
|
281
286
|
active_only?: boolean;
|
|
287
|
+
limit?: number;
|
|
282
288
|
}): RequestId;
|
|
283
289
|
logout(): void;
|
|
284
290
|
/**
|
|
@@ -311,6 +317,27 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
311
317
|
orderId: Uint8Array;
|
|
312
318
|
makerSigner: SignerLike;
|
|
313
319
|
}): Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* Replace an in-flight quote on the same RFQ. Server treats this as
|
|
322
|
+
* cancel-old + place-new atomically; maker signs the NEW `order_id`.
|
|
323
|
+
*/
|
|
324
|
+
submitReplaceQuote(msg: ReplaceQuoteMessage): void;
|
|
325
|
+
/** Convenience: compute new `order_id`, sign it, and send `ReplaceQuote`. */
|
|
326
|
+
submitReplaceQuoteSigned(args: {
|
|
327
|
+
oldOrderId: Uint8Array;
|
|
328
|
+
rfqId: string;
|
|
329
|
+
strike: number;
|
|
330
|
+
price: number;
|
|
331
|
+
validUntil: number;
|
|
332
|
+
nonce: number;
|
|
333
|
+
orderId: Uint8Array;
|
|
334
|
+
makerSigner: SignerLike;
|
|
335
|
+
}): Promise<void>;
|
|
336
|
+
/**
|
|
337
|
+
* Send multiple signed quotes in one WS frame. Each entry must already be
|
|
338
|
+
* a fully-built `QuoteMessage` (use `buildSignedQuoteMessage` per quote).
|
|
339
|
+
*/
|
|
340
|
+
submitBatchQuotes(quotes: QuoteMessage[]): void;
|
|
314
341
|
cancelQuote(rfqId: string): RequestId;
|
|
315
342
|
subscribe(channels: WsChannel[], opts?: {
|
|
316
343
|
underlying_mints?: string[];
|
|
@@ -327,6 +354,8 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
327
354
|
}): RequestId;
|
|
328
355
|
addChannels(channels: WsChannel[]): RequestId;
|
|
329
356
|
removeChannels(channels: WsChannel[]): RequestId;
|
|
357
|
+
/** Query the server's view of this session's subscriptions. Response: `subscriptions` event. */
|
|
358
|
+
getSubscriptions(): RequestId;
|
|
330
359
|
ping(): void;
|
|
331
360
|
resumeAuth(sessionId: string): void;
|
|
332
361
|
private doConnect;
|
package/dist/ws/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Acta WebSocket client (rfq-server). */
|
|
2
|
-
import { buildSignedQuoteMessage, buildAcceptQuoteMessage } from "./flows";
|
|
2
|
+
import { buildSignedQuoteMessage, buildSignedReplaceQuoteMessage, buildAcceptQuoteMessage, } from "./flows";
|
|
3
3
|
import { assertWsU64Safe, validateQuantityBySizeRule } from "./wirePolicy";
|
|
4
4
|
import { parseReferralCode, ReferralCodeError } from "./referral";
|
|
5
5
|
function toGenericServerError(err) {
|
|
@@ -100,6 +100,7 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
100
100
|
connectionState = "disconnected";
|
|
101
101
|
sessionId = null;
|
|
102
102
|
lastAuthSessionId = null;
|
|
103
|
+
makerPda = null;
|
|
103
104
|
helloSent = false;
|
|
104
105
|
welcomeReceived = false;
|
|
105
106
|
pendingMessages = [];
|
|
@@ -144,6 +145,7 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
144
145
|
this.authRequested = false;
|
|
145
146
|
this.pendingResumeSessionId = null;
|
|
146
147
|
this.lastAuthSessionId = null;
|
|
148
|
+
this.makerPda = null;
|
|
147
149
|
this.shouldReconnect = this.options.autoReconnect;
|
|
148
150
|
this.doConnect();
|
|
149
151
|
}
|
|
@@ -197,6 +199,9 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
197
199
|
getSessionId() {
|
|
198
200
|
return this.sessionId;
|
|
199
201
|
}
|
|
202
|
+
getMakerPda() {
|
|
203
|
+
return this.makerPda;
|
|
204
|
+
}
|
|
200
205
|
async createRfq(request) {
|
|
201
206
|
this.ensureAuthenticated();
|
|
202
207
|
assertWsU64Safe(request.strike, "strike");
|
|
@@ -337,12 +342,12 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
337
342
|
});
|
|
338
343
|
return requestId;
|
|
339
344
|
}
|
|
340
|
-
/** Maker-only:
|
|
341
|
-
|
|
345
|
+
/** Maker-only: one-shot MM dashboard bootstrap. */
|
|
346
|
+
getMmSummary() {
|
|
342
347
|
this.ensureAuthenticated();
|
|
343
348
|
const requestId = this.nextRequestId();
|
|
344
349
|
this.send({
|
|
345
|
-
type: "
|
|
350
|
+
type: "GetMmSummary",
|
|
346
351
|
data: { request_id: requestId },
|
|
347
352
|
});
|
|
348
353
|
return requestId;
|
|
@@ -397,6 +402,7 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
397
402
|
const data = {
|
|
398
403
|
request_id: requestId,
|
|
399
404
|
active_only: args?.active_only ?? true,
|
|
405
|
+
...(args?.limit !== undefined ? { limit: args.limit } : {}),
|
|
400
406
|
};
|
|
401
407
|
this.send({ type: "GetMyQuotes", data });
|
|
402
408
|
return requestId;
|
|
@@ -493,6 +499,40 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
493
499
|
});
|
|
494
500
|
this.submitQuote(quote);
|
|
495
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Replace an in-flight quote on the same RFQ. Server treats this as
|
|
504
|
+
* cancel-old + place-new atomically; maker signs the NEW `order_id`.
|
|
505
|
+
*/
|
|
506
|
+
submitReplaceQuote(msg) {
|
|
507
|
+
this.ensureAuthenticated();
|
|
508
|
+
this.send({ type: "ReplaceQuote", data: msg });
|
|
509
|
+
}
|
|
510
|
+
/** Convenience: compute new `order_id`, sign it, and send `ReplaceQuote`. */
|
|
511
|
+
async submitReplaceQuoteSigned(args) {
|
|
512
|
+
assertWsU64Safe(args.strike, "strike");
|
|
513
|
+
assertWsU64Safe(args.price, "price");
|
|
514
|
+
assertWsU64Safe(args.validUntil, "validUntil");
|
|
515
|
+
assertWsU64Safe(args.nonce, "nonce");
|
|
516
|
+
const msg = await buildSignedReplaceQuoteMessage({
|
|
517
|
+
oldOrderId: args.oldOrderId,
|
|
518
|
+
rfqId: args.rfqId,
|
|
519
|
+
strike: args.strike,
|
|
520
|
+
price: args.price,
|
|
521
|
+
validUntil: args.validUntil,
|
|
522
|
+
nonce: args.nonce,
|
|
523
|
+
orderId: args.orderId,
|
|
524
|
+
makerSigner: args.makerSigner,
|
|
525
|
+
});
|
|
526
|
+
this.submitReplaceQuote(msg);
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Send multiple signed quotes in one WS frame. Each entry must already be
|
|
530
|
+
* a fully-built `QuoteMessage` (use `buildSignedQuoteMessage` per quote).
|
|
531
|
+
*/
|
|
532
|
+
submitBatchQuotes(quotes) {
|
|
533
|
+
this.ensureAuthenticated();
|
|
534
|
+
this.send({ type: "BatchQuotes", data: { quotes } });
|
|
535
|
+
}
|
|
496
536
|
cancelQuote(rfqId) {
|
|
497
537
|
this.ensureAuthenticated();
|
|
498
538
|
const requestId = this.nextRequestId();
|
|
@@ -586,6 +626,13 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
586
626
|
this.send({ type: "RemoveChannels", data: { request_id, channels } });
|
|
587
627
|
return request_id;
|
|
588
628
|
}
|
|
629
|
+
/** Query the server's view of this session's subscriptions. Response: `subscriptions` event. */
|
|
630
|
+
getSubscriptions() {
|
|
631
|
+
this.ensureAuthenticated();
|
|
632
|
+
const request_id = this.nextRequestId();
|
|
633
|
+
this.send({ type: "GetSubscriptions", data: { request_id } });
|
|
634
|
+
return request_id;
|
|
635
|
+
}
|
|
589
636
|
ping() {
|
|
590
637
|
if (this.ws?.readyState === WS_OPEN) {
|
|
591
638
|
this.send({ type: "Ping" });
|
|
@@ -680,7 +727,7 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
680
727
|
void this.handleAuthRequest(message.data.challenge);
|
|
681
728
|
break;
|
|
682
729
|
case "AuthSuccess":
|
|
683
|
-
this.handleAuthSuccess(message.data.session_id, message.data.expires_at);
|
|
730
|
+
this.handleAuthSuccess(message.data.session_id, message.data.expires_at, message.data.maker_pda ?? null);
|
|
684
731
|
break;
|
|
685
732
|
case "AuthError":
|
|
686
733
|
this.handleAuthError(message.data.reason, message.data.message);
|
|
@@ -689,6 +736,7 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
689
736
|
this.sessionId = null;
|
|
690
737
|
this.pendingResumeSessionId = null;
|
|
691
738
|
this.lastAuthSessionId = null;
|
|
739
|
+
this.makerPda = null;
|
|
692
740
|
this.startAuthSent = false;
|
|
693
741
|
this.setConnectionState("connecting");
|
|
694
742
|
this.emit("logoutSuccess");
|
|
@@ -736,9 +784,6 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
736
784
|
case "MyCaps":
|
|
737
785
|
this.emit("myCaps", message.data);
|
|
738
786
|
break;
|
|
739
|
-
case "MakerBalances":
|
|
740
|
-
this.emit("makerBalances", message.data);
|
|
741
|
-
break;
|
|
742
787
|
case "MakerPositions":
|
|
743
788
|
this.emit("makerPositions", message.data);
|
|
744
789
|
break;
|
|
@@ -751,6 +796,18 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
751
796
|
case "MyQuotes":
|
|
752
797
|
this.emit("myQuotes", message.data);
|
|
753
798
|
break;
|
|
799
|
+
case "MmSummary":
|
|
800
|
+
this.emit("mmSummary", message.data);
|
|
801
|
+
break;
|
|
802
|
+
case "QuoteRejected":
|
|
803
|
+
this.emit("quoteRejected", message.data);
|
|
804
|
+
break;
|
|
805
|
+
case "BatchQuotesAck":
|
|
806
|
+
this.emit("batchQuotesAck", message.data);
|
|
807
|
+
break;
|
|
808
|
+
case "CancelAllQuotesAck":
|
|
809
|
+
this.emit("cancelAllQuotesAck", message.data);
|
|
810
|
+
break;
|
|
754
811
|
case "MyActiveRfqs":
|
|
755
812
|
this.handleMyActiveRfqs(message.data);
|
|
756
813
|
break;
|
|
@@ -1006,14 +1063,15 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
1006
1063
|
this.send(msg);
|
|
1007
1064
|
}
|
|
1008
1065
|
}
|
|
1009
|
-
handleAuthSuccess(sessionId, expiresAt) {
|
|
1066
|
+
handleAuthSuccess(sessionId, expiresAt, makerPda) {
|
|
1010
1067
|
this.sessionId = sessionId;
|
|
1011
1068
|
this.pendingResumeSessionId = null;
|
|
1012
1069
|
if (expiresAt !== null) {
|
|
1013
1070
|
this.lastAuthSessionId = sessionId;
|
|
1014
1071
|
}
|
|
1072
|
+
this.makerPda = makerPda;
|
|
1015
1073
|
this.setConnectionState("authenticated");
|
|
1016
|
-
this.emit("authenticated", sessionId, expiresAt);
|
|
1074
|
+
this.emit("authenticated", sessionId, expiresAt, makerPda);
|
|
1017
1075
|
if (this.subscribedChannels.size > 0) {
|
|
1018
1076
|
const channels = Array.from(this.subscribedChannels);
|
|
1019
1077
|
const request_id = this.nextRequestId();
|
|
@@ -1097,7 +1155,7 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
1097
1155
|
}
|
|
1098
1156
|
handlePositionUpdated(data) {
|
|
1099
1157
|
this.state.positions.set(data.position.pda, data.position);
|
|
1100
|
-
this.emit("positionUpdated", data.position, data.update_type);
|
|
1158
|
+
this.emit("positionUpdated", data.position, data.update_type, data);
|
|
1101
1159
|
}
|
|
1102
1160
|
handleChainEvent(event) {
|
|
1103
1161
|
this.emit("chainEvent", event);
|
package/dist/ws/flows.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* - WS wire uses hex string for `order_id` and base58 for signatures
|
|
5
5
|
*/
|
|
6
6
|
import type { Address } from "@solana/addresses";
|
|
7
|
-
import type { AcceptQuoteMessage, QuoteMessage, RfqBroadcastMessage } from "./types";
|
|
7
|
+
import type { AcceptQuoteMessage, QuoteMessage, ReplaceQuoteMessage, RfqBroadcastMessage } from "./types";
|
|
8
8
|
import type { SignerLike } from "../chain/orders";
|
|
9
9
|
export declare function buildSignedQuoteMessage(args: {
|
|
10
10
|
rfqId: string;
|
|
@@ -15,6 +15,18 @@ export declare function buildSignedQuoteMessage(args: {
|
|
|
15
15
|
orderId: Uint8Array;
|
|
16
16
|
makerSigner: SignerLike;
|
|
17
17
|
}): Promise<QuoteMessage>;
|
|
18
|
+
export declare function buildSignedReplaceQuoteMessage(args: {
|
|
19
|
+
/** orderId of the quote being replaced (32 bytes). */
|
|
20
|
+
oldOrderId: Uint8Array;
|
|
21
|
+
rfqId: string;
|
|
22
|
+
strike: number;
|
|
23
|
+
price: number;
|
|
24
|
+
validUntil: number;
|
|
25
|
+
nonce: number;
|
|
26
|
+
/** NEW 32-byte orderId for the replacement quote. */
|
|
27
|
+
orderId: Uint8Array;
|
|
28
|
+
makerSigner: SignerLike;
|
|
29
|
+
}): Promise<ReplaceQuoteMessage>;
|
|
18
30
|
/**
|
|
19
31
|
* Strict maker helper: build a fully-valid quote from a server RFQ broadcast.
|
|
20
32
|
*
|
package/dist/ws/flows.js
CHANGED
|
@@ -24,6 +24,25 @@ export async function buildSignedQuoteMessage(args) {
|
|
|
24
24
|
signature: signatureBase58,
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
export async function buildSignedReplaceQuoteMessage(args) {
|
|
28
|
+
assertWsU64Safe(args.strike, "strike");
|
|
29
|
+
assertWsU64Safe(args.price, "price");
|
|
30
|
+
assertWsU64Safe(args.validUntil, "validUntil");
|
|
31
|
+
assertWsU64Safe(args.nonce, "nonce");
|
|
32
|
+
assertOrderId32(args.oldOrderId);
|
|
33
|
+
assertOrderId32(args.orderId);
|
|
34
|
+
const { signatureBase58 } = await signOrderIdBase58(args.makerSigner, args.orderId);
|
|
35
|
+
return {
|
|
36
|
+
old_order_id: orderIdToHex(args.oldOrderId),
|
|
37
|
+
rfq_id: args.rfqId,
|
|
38
|
+
strike: args.strike,
|
|
39
|
+
price: args.price,
|
|
40
|
+
valid_until: args.validUntil,
|
|
41
|
+
nonce: args.nonce,
|
|
42
|
+
order_id: orderIdToHex(args.orderId),
|
|
43
|
+
signature: signatureBase58,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
27
46
|
function positionTypeToU8(positionType) {
|
|
28
47
|
switch (positionType) {
|
|
29
48
|
case "covered_call":
|
package/dist/ws/types.d.ts
CHANGED
|
@@ -23,10 +23,10 @@ export type MyActiveRfqState = string;
|
|
|
23
23
|
export type HelloFeatureFlag = string;
|
|
24
24
|
/** Values: "covered_call" | "cash_secured_put". */
|
|
25
25
|
export type PositionType = string;
|
|
26
|
-
|
|
27
|
-
export type PositionStatus = string;
|
|
26
|
+
export type PositionStatus = "none" | "open" | "funded" | "liquidated" | "settled";
|
|
28
27
|
/** Values: "pending" | "best" | "outbid" | "filled" | "expired". */
|
|
29
28
|
export type MakerQuoteStatus = string;
|
|
29
|
+
export type QuoteRejectReasonValue = "invalid_strike" | "market_expired" | "quote_expiry_too_short" | "invalid_signature" | "maker_not_registered" | "order_id_mismatch" | "cap_exceeded" | "rfq_not_found" | "rfq_not_active" | "duplicate_order_id";
|
|
30
30
|
/** Values: "expired" | "expiring_soon". */
|
|
31
31
|
export type QuoteRefreshReason = string;
|
|
32
32
|
/** Values: "requested" | "risk_check" | "rfq_accepted". */
|
|
@@ -80,6 +80,12 @@ export type ClientMessage = {
|
|
|
80
80
|
} | {
|
|
81
81
|
type: "Quote";
|
|
82
82
|
data: QuoteMessage;
|
|
83
|
+
} | {
|
|
84
|
+
type: "ReplaceQuote";
|
|
85
|
+
data: ReplaceQuoteMessage;
|
|
86
|
+
} | {
|
|
87
|
+
type: "BatchQuotes";
|
|
88
|
+
data: BatchQuotesMessage;
|
|
83
89
|
} | {
|
|
84
90
|
type: "CancelQuote";
|
|
85
91
|
data: {
|
|
@@ -143,9 +149,6 @@ export type ClientMessage = {
|
|
|
143
149
|
} | {
|
|
144
150
|
type: "GetMarketsForMaker";
|
|
145
151
|
data: GetMarketsForMakerMessage;
|
|
146
|
-
} | {
|
|
147
|
-
type: "GetMakerBalances";
|
|
148
|
-
data: GetMakerBalancesMessage;
|
|
149
152
|
} | {
|
|
150
153
|
type: "GetTokenCaps";
|
|
151
154
|
data: GetTokenCapsMessage;
|
|
@@ -155,6 +158,9 @@ export type ClientMessage = {
|
|
|
155
158
|
} | {
|
|
156
159
|
type: "GetEarnSummary";
|
|
157
160
|
data: GetEarnSummaryMessage;
|
|
161
|
+
} | {
|
|
162
|
+
type: "GetMmSummary";
|
|
163
|
+
data: GetMmSummaryMessage;
|
|
158
164
|
} | {
|
|
159
165
|
type: "GetTokenMarketsInfo";
|
|
160
166
|
data: GetTokenMarketsInfoMessage;
|
|
@@ -270,7 +276,7 @@ export type GetMyActiveRfqsMessage = {
|
|
|
270
276
|
export type GetActiveRfqsMessage = {
|
|
271
277
|
request_id: RequestId;
|
|
272
278
|
};
|
|
273
|
-
export type
|
|
279
|
+
export type GetMmSummaryMessage = {
|
|
274
280
|
request_id: RequestId;
|
|
275
281
|
};
|
|
276
282
|
export type GetSubscriptionsMessage = {
|
|
@@ -290,6 +296,7 @@ export type GetMakerPositionsMessage = {
|
|
|
290
296
|
export type GetMyQuotesMessage = {
|
|
291
297
|
request_id: RequestId;
|
|
292
298
|
active_only?: boolean;
|
|
299
|
+
limit?: WsU32;
|
|
293
300
|
};
|
|
294
301
|
export type GetMarketsForMakerMessage = {
|
|
295
302
|
request_id: RequestId;
|
|
@@ -322,6 +329,22 @@ export type QuoteMessage = {
|
|
|
322
329
|
order_id: OrderIdHex32;
|
|
323
330
|
signature: string;
|
|
324
331
|
};
|
|
332
|
+
export type ReplaceQuoteMessage = {
|
|
333
|
+
/** orderId of the quote being replaced (64-char hex). */
|
|
334
|
+
old_order_id: OrderIdHex32;
|
|
335
|
+
rfq_id: UuidString;
|
|
336
|
+
strike: WsU64;
|
|
337
|
+
price: WsU64;
|
|
338
|
+
valid_until: WsU64;
|
|
339
|
+
nonce: WsU64;
|
|
340
|
+
/** New 32-byte orderId (sha256) encoded as hex (64 chars). */
|
|
341
|
+
order_id: OrderIdHex32;
|
|
342
|
+
/** base58 ed25519 signature over the NEW `order_id`. */
|
|
343
|
+
signature: string;
|
|
344
|
+
};
|
|
345
|
+
export type BatchQuotesMessage = {
|
|
346
|
+
quotes: QuoteMessage[];
|
|
347
|
+
};
|
|
325
348
|
export type MarketDescriptor = {
|
|
326
349
|
chain_id: WsU64;
|
|
327
350
|
program_id: Address<string>;
|
|
@@ -364,6 +387,7 @@ export type ServerMessage = {
|
|
|
364
387
|
data: {
|
|
365
388
|
session_id: string;
|
|
366
389
|
expires_at: WsI64 | null;
|
|
390
|
+
maker_pda?: string | null;
|
|
367
391
|
};
|
|
368
392
|
} | {
|
|
369
393
|
type: "AuthError";
|
|
@@ -422,6 +446,15 @@ export type ServerMessage = {
|
|
|
422
446
|
} | {
|
|
423
447
|
type: "QuoteExpired";
|
|
424
448
|
data: QuoteExpiredMessage;
|
|
449
|
+
} | {
|
|
450
|
+
type: "QuoteRejected";
|
|
451
|
+
data: QuoteRejectedMessage;
|
|
452
|
+
} | {
|
|
453
|
+
type: "BatchQuotesAck";
|
|
454
|
+
data: BatchQuotesAckMessage;
|
|
455
|
+
} | {
|
|
456
|
+
type: "CancelAllQuotesAck";
|
|
457
|
+
data: CancelAllQuotesAckMessage;
|
|
425
458
|
} | {
|
|
426
459
|
type: "ActiveRfqs";
|
|
427
460
|
data: {
|
|
@@ -437,15 +470,15 @@ export type ServerMessage = {
|
|
|
437
470
|
} | {
|
|
438
471
|
type: "MakerMarkets";
|
|
439
472
|
data: MakerMarketsMessage;
|
|
440
|
-
} | {
|
|
441
|
-
type: "MakerBalances";
|
|
442
|
-
data: MakerBalancesMessage;
|
|
443
473
|
} | {
|
|
444
474
|
type: "TokenCaps";
|
|
445
475
|
data: TokenCapsMessage;
|
|
446
476
|
} | {
|
|
447
477
|
type: "MyCaps";
|
|
448
478
|
data: MyCapsMessage;
|
|
479
|
+
} | {
|
|
480
|
+
type: "MmSummary";
|
|
481
|
+
data: MmSummaryData;
|
|
449
482
|
} | {
|
|
450
483
|
type: "Subscriptions";
|
|
451
484
|
data: SubscriptionsMessage;
|
|
@@ -859,6 +892,27 @@ export type QuoteExpiredMessage = {
|
|
|
859
892
|
order_id: OrderIdHex32;
|
|
860
893
|
reason: QuoteExpiredReason;
|
|
861
894
|
};
|
|
895
|
+
export type QuoteRejectedMessage = {
|
|
896
|
+
rfq_id: UuidString;
|
|
897
|
+
order_id: OrderIdHex32;
|
|
898
|
+
reason: QuoteRejectReasonValue;
|
|
899
|
+
message?: string | null;
|
|
900
|
+
};
|
|
901
|
+
export type BatchQuoteResult = {
|
|
902
|
+
status: "acknowledged";
|
|
903
|
+
data: QuoteAcknowledgedMessage;
|
|
904
|
+
} | {
|
|
905
|
+
status: "rejected";
|
|
906
|
+
data: QuoteRejectedMessage;
|
|
907
|
+
};
|
|
908
|
+
export type BatchQuotesAckMessage = {
|
|
909
|
+
results: BatchQuoteResult[];
|
|
910
|
+
};
|
|
911
|
+
export type CancelAllQuotesAckMessage = {
|
|
912
|
+
request_id: RequestId;
|
|
913
|
+
cancelled_count: WsU32;
|
|
914
|
+
cancelled_order_ids: OrderIdHex32[];
|
|
915
|
+
};
|
|
862
916
|
export type MakerPositionsMessage = {
|
|
863
917
|
request_id: RequestId;
|
|
864
918
|
positions: MakerPositionInfo[];
|
|
@@ -867,7 +921,11 @@ export type MakerPositionInfo = {
|
|
|
867
921
|
pda: string;
|
|
868
922
|
market: string;
|
|
869
923
|
underlying_mint: string;
|
|
924
|
+
underlying_symbol: string;
|
|
925
|
+
underlying_decimals: number;
|
|
870
926
|
quote_mint: string;
|
|
927
|
+
quote_symbol: string;
|
|
928
|
+
quote_decimals: number;
|
|
871
929
|
position_type: PositionType;
|
|
872
930
|
status: PositionStatus;
|
|
873
931
|
strike: WsU64;
|
|
@@ -875,10 +933,10 @@ export type MakerPositionInfo = {
|
|
|
875
933
|
price: WsU64;
|
|
876
934
|
/** Net premium amount from on-chain position state (quote token base units). */
|
|
877
935
|
total_premium: WsU64;
|
|
878
|
-
collateral_locked: WsU64;
|
|
879
936
|
created_at: WsU64;
|
|
880
937
|
expiry_ts: WsU64;
|
|
881
938
|
is_otm?: boolean;
|
|
939
|
+
settlement_price?: WsU64 | null;
|
|
882
940
|
};
|
|
883
941
|
export type MyQuotesMessage = {
|
|
884
942
|
request_id: RequestId;
|
|
@@ -888,6 +946,12 @@ export type MakerQuoteInfo = {
|
|
|
888
946
|
rfq_id: UuidString;
|
|
889
947
|
order_id: OrderIdHex32;
|
|
890
948
|
market: string;
|
|
949
|
+
underlying_mint: string;
|
|
950
|
+
underlying_symbol: string;
|
|
951
|
+
underlying_decimals: number;
|
|
952
|
+
quote_mint: string;
|
|
953
|
+
quote_symbol: string;
|
|
954
|
+
quote_decimals: number;
|
|
891
955
|
strike: WsU64;
|
|
892
956
|
price: WsU64;
|
|
893
957
|
quantity: WsU64;
|
|
@@ -895,6 +959,7 @@ export type MakerQuoteInfo = {
|
|
|
895
959
|
/** "pending" | "best" | "outbid" | "filled" | "expired" | "cancelled" */
|
|
896
960
|
status: MakerQuoteStatus;
|
|
897
961
|
created_at: WsU64;
|
|
962
|
+
selected?: boolean | null;
|
|
898
963
|
};
|
|
899
964
|
export type MakerMarketsMessage = {
|
|
900
965
|
request_id: RequestId;
|
|
@@ -915,15 +980,6 @@ export type MarketStats = {
|
|
|
915
980
|
volume_24h: WsU64;
|
|
916
981
|
trades_24h: WsU32;
|
|
917
982
|
};
|
|
918
|
-
export type MakerBalancesMessage = {
|
|
919
|
-
request_id: RequestId;
|
|
920
|
-
balances_by_mint: Record<string, MakerMintBalance>;
|
|
921
|
-
};
|
|
922
|
-
export type MakerMintBalance = {
|
|
923
|
-
total: WsU64;
|
|
924
|
-
locked_as_collateral: WsU64;
|
|
925
|
-
available: WsU64;
|
|
926
|
-
};
|
|
927
983
|
export type GetTokenCapsMessage = {
|
|
928
984
|
request_id: RequestId;
|
|
929
985
|
include_markets?: boolean;
|
|
@@ -982,10 +1038,27 @@ export type MakerNotionalCapInfo = {
|
|
|
982
1038
|
export type MakerBalanceCapInfo = {
|
|
983
1039
|
mint: string;
|
|
984
1040
|
symbol: string;
|
|
1041
|
+
decimals: number;
|
|
985
1042
|
deposited: WsU64;
|
|
986
1043
|
committed: WsU64;
|
|
987
1044
|
available: WsU64;
|
|
988
1045
|
};
|
|
1046
|
+
/** Lightweight caps snapshot attached to owner-direct `PositionUpdated` events. */
|
|
1047
|
+
export type MakerCapsSnapshot = {
|
|
1048
|
+
positions: MakerPositionCapInfo;
|
|
1049
|
+
notional: MakerNotionalCapInfo[];
|
|
1050
|
+
balances: MakerBalanceCapInfo[];
|
|
1051
|
+
};
|
|
1052
|
+
export type MmSummaryData = {
|
|
1053
|
+
request_id: RequestId;
|
|
1054
|
+
maker_pda: string;
|
|
1055
|
+
caps: MyCapsMessage;
|
|
1056
|
+
positions: MakerPositionInfo[];
|
|
1057
|
+
active_quotes: MakerQuoteInfo[];
|
|
1058
|
+
markets: MakerMarketInfo[];
|
|
1059
|
+
tokens: TokenInfo[];
|
|
1060
|
+
computed_at: WsU64;
|
|
1061
|
+
};
|
|
989
1062
|
export type SubscriptionsMessage = {
|
|
990
1063
|
request_id: RequestId;
|
|
991
1064
|
channels: WsChannel[];
|
|
@@ -1176,6 +1249,7 @@ export type TradeExecutedMessage = {
|
|
|
1176
1249
|
export type PositionUpdatedMessage = {
|
|
1177
1250
|
position: PositionInfo;
|
|
1178
1251
|
update_type: PositionUpdateType;
|
|
1252
|
+
caps_snapshot: MakerCapsSnapshot;
|
|
1179
1253
|
};
|
|
1180
1254
|
/** Values: "created" | "funded" | "settled" | "liquidated". */
|
|
1181
1255
|
export type PositionUpdateType = string;
|
|
@@ -1247,6 +1321,12 @@ export type MakerTradeInfo = {
|
|
|
1247
1321
|
id: UuidString;
|
|
1248
1322
|
rfq_id: UuidString;
|
|
1249
1323
|
market_pda: string;
|
|
1324
|
+
underlying_mint: string;
|
|
1325
|
+
underlying_symbol: string;
|
|
1326
|
+
underlying_decimals: number;
|
|
1327
|
+
quote_mint: string;
|
|
1328
|
+
quote_symbol: string;
|
|
1329
|
+
quote_decimals: number;
|
|
1250
1330
|
position_type: PositionType;
|
|
1251
1331
|
taker: string;
|
|
1252
1332
|
strike: WsU64;
|