@acta-markets/ts-sdk 0.0.22-beta → 0.0.23-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chain/instructions.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 +41 -0
- 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 +24 -1
- package/dist/ws/client.js +42 -1
- package/dist/ws/flows.d.ts +13 -1
- package/dist/ws/flows.js +19 -0
- package/dist/ws/types.d.ts +22 -0
- package/package.json +1 -1
|
@@ -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
|
@@ -496,6 +496,40 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
496
496
|
});
|
|
497
497
|
this.submitQuote(quote);
|
|
498
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Replace an in-flight quote on the same RFQ. Server treats this as
|
|
501
|
+
* cancel-old + place-new atomically; maker signs the NEW `order_id`.
|
|
502
|
+
*/
|
|
503
|
+
submitReplaceQuote(msg) {
|
|
504
|
+
this.ensureAuthenticated();
|
|
505
|
+
this.send({ type: "ReplaceQuote", data: msg });
|
|
506
|
+
}
|
|
507
|
+
/** Convenience: compute new `order_id`, sign it, and send `ReplaceQuote`. */
|
|
508
|
+
async submitReplaceQuoteSigned(args) {
|
|
509
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.strike, "strike");
|
|
510
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.price, "price");
|
|
511
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.validUntil, "validUntil");
|
|
512
|
+
(0, wirePolicy_1.assertWsU64Safe)(args.nonce, "nonce");
|
|
513
|
+
const msg = await (0, flows_1.buildSignedReplaceQuoteMessage)({
|
|
514
|
+
oldOrderId: args.oldOrderId,
|
|
515
|
+
rfqId: args.rfqId,
|
|
516
|
+
strike: args.strike,
|
|
517
|
+
price: args.price,
|
|
518
|
+
validUntil: args.validUntil,
|
|
519
|
+
nonce: args.nonce,
|
|
520
|
+
orderId: args.orderId,
|
|
521
|
+
makerSigner: args.makerSigner,
|
|
522
|
+
});
|
|
523
|
+
this.submitReplaceQuote(msg);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Send multiple signed quotes in one WS frame. Each entry must already be
|
|
527
|
+
* a fully-built `QuoteMessage` (use `buildSignedQuoteMessage` per quote).
|
|
528
|
+
*/
|
|
529
|
+
submitBatchQuotes(quotes) {
|
|
530
|
+
this.ensureAuthenticated();
|
|
531
|
+
this.send({ type: "BatchQuotes", data: { quotes } });
|
|
532
|
+
}
|
|
499
533
|
cancelQuote(rfqId) {
|
|
500
534
|
this.ensureAuthenticated();
|
|
501
535
|
const requestId = this.nextRequestId();
|
|
@@ -589,6 +623,13 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
589
623
|
this.send({ type: "RemoveChannels", data: { request_id, channels } });
|
|
590
624
|
return request_id;
|
|
591
625
|
}
|
|
626
|
+
/** Query the server's view of this session's subscriptions. Response: `subscriptions` event. */
|
|
627
|
+
getSubscriptions() {
|
|
628
|
+
this.ensureAuthenticated();
|
|
629
|
+
const request_id = this.nextRequestId();
|
|
630
|
+
this.send({ type: "GetSubscriptions", data: { request_id } });
|
|
631
|
+
return request_id;
|
|
632
|
+
}
|
|
592
633
|
ping() {
|
|
593
634
|
if (this.ws?.readyState === WS_OPEN) {
|
|
594
635
|
this.send({ type: "Ping" });
|
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, MakerBalancesMessage, MakerMarketsMessage, MakerPositionsMessage, MyCapsMessage, MyQuotesMessage, MyTradesMessage, RequestId, ServerError, ServerMessage, SnapshotMessage, StatsDelta, SubscriptionsMessage, TokenInfo, TradeInfo, UuidString, VersionMismatchMessage, WelcomeMessage, WsChannel, InviteRedeemedData, ReferralCodeClaimedData, MyReferralInfoData } from "./types";
|
|
5
|
+
import type { ActiveRfqInfo, ChainEventMessage, EarnSummaryData, TokenMarketsInfoData, GlobalStats, MarketDescriptorInfo, MarketInfo, MyActiveRfqInfo, MyActiveRfqsMessage, OrderStatusMessage, PositionInfo, QuoteAcknowledgedMessage, QuoteBestStatusMessage, QuoteCancelledMessage, QuoteMessage, ReplaceQuoteMessage, 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, 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";
|
|
@@ -311,6 +311,27 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
311
311
|
orderId: Uint8Array;
|
|
312
312
|
makerSigner: SignerLike;
|
|
313
313
|
}): Promise<void>;
|
|
314
|
+
/**
|
|
315
|
+
* Replace an in-flight quote on the same RFQ. Server treats this as
|
|
316
|
+
* cancel-old + place-new atomically; maker signs the NEW `order_id`.
|
|
317
|
+
*/
|
|
318
|
+
submitReplaceQuote(msg: ReplaceQuoteMessage): void;
|
|
319
|
+
/** Convenience: compute new `order_id`, sign it, and send `ReplaceQuote`. */
|
|
320
|
+
submitReplaceQuoteSigned(args: {
|
|
321
|
+
oldOrderId: Uint8Array;
|
|
322
|
+
rfqId: string;
|
|
323
|
+
strike: number;
|
|
324
|
+
price: number;
|
|
325
|
+
validUntil: number;
|
|
326
|
+
nonce: number;
|
|
327
|
+
orderId: Uint8Array;
|
|
328
|
+
makerSigner: SignerLike;
|
|
329
|
+
}): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Send multiple signed quotes in one WS frame. Each entry must already be
|
|
332
|
+
* a fully-built `QuoteMessage` (use `buildSignedQuoteMessage` per quote).
|
|
333
|
+
*/
|
|
334
|
+
submitBatchQuotes(quotes: QuoteMessage[]): void;
|
|
314
335
|
cancelQuote(rfqId: string): RequestId;
|
|
315
336
|
subscribe(channels: WsChannel[], opts?: {
|
|
316
337
|
underlying_mints?: string[];
|
|
@@ -327,6 +348,8 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
|
|
|
327
348
|
}): RequestId;
|
|
328
349
|
addChannels(channels: WsChannel[]): RequestId;
|
|
329
350
|
removeChannels(channels: WsChannel[]): RequestId;
|
|
351
|
+
/** Query the server's view of this session's subscriptions. Response: `subscriptions` event. */
|
|
352
|
+
getSubscriptions(): RequestId;
|
|
330
353
|
ping(): void;
|
|
331
354
|
resumeAuth(sessionId: string): void;
|
|
332
355
|
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) {
|
|
@@ -493,6 +493,40 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
493
493
|
});
|
|
494
494
|
this.submitQuote(quote);
|
|
495
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* Replace an in-flight quote on the same RFQ. Server treats this as
|
|
498
|
+
* cancel-old + place-new atomically; maker signs the NEW `order_id`.
|
|
499
|
+
*/
|
|
500
|
+
submitReplaceQuote(msg) {
|
|
501
|
+
this.ensureAuthenticated();
|
|
502
|
+
this.send({ type: "ReplaceQuote", data: msg });
|
|
503
|
+
}
|
|
504
|
+
/** Convenience: compute new `order_id`, sign it, and send `ReplaceQuote`. */
|
|
505
|
+
async submitReplaceQuoteSigned(args) {
|
|
506
|
+
assertWsU64Safe(args.strike, "strike");
|
|
507
|
+
assertWsU64Safe(args.price, "price");
|
|
508
|
+
assertWsU64Safe(args.validUntil, "validUntil");
|
|
509
|
+
assertWsU64Safe(args.nonce, "nonce");
|
|
510
|
+
const msg = await buildSignedReplaceQuoteMessage({
|
|
511
|
+
oldOrderId: args.oldOrderId,
|
|
512
|
+
rfqId: args.rfqId,
|
|
513
|
+
strike: args.strike,
|
|
514
|
+
price: args.price,
|
|
515
|
+
validUntil: args.validUntil,
|
|
516
|
+
nonce: args.nonce,
|
|
517
|
+
orderId: args.orderId,
|
|
518
|
+
makerSigner: args.makerSigner,
|
|
519
|
+
});
|
|
520
|
+
this.submitReplaceQuote(msg);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Send multiple signed quotes in one WS frame. Each entry must already be
|
|
524
|
+
* a fully-built `QuoteMessage` (use `buildSignedQuoteMessage` per quote).
|
|
525
|
+
*/
|
|
526
|
+
submitBatchQuotes(quotes) {
|
|
527
|
+
this.ensureAuthenticated();
|
|
528
|
+
this.send({ type: "BatchQuotes", data: { quotes } });
|
|
529
|
+
}
|
|
496
530
|
cancelQuote(rfqId) {
|
|
497
531
|
this.ensureAuthenticated();
|
|
498
532
|
const requestId = this.nextRequestId();
|
|
@@ -586,6 +620,13 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
586
620
|
this.send({ type: "RemoveChannels", data: { request_id, channels } });
|
|
587
621
|
return request_id;
|
|
588
622
|
}
|
|
623
|
+
/** Query the server's view of this session's subscriptions. Response: `subscriptions` event. */
|
|
624
|
+
getSubscriptions() {
|
|
625
|
+
this.ensureAuthenticated();
|
|
626
|
+
const request_id = this.nextRequestId();
|
|
627
|
+
this.send({ type: "GetSubscriptions", data: { request_id } });
|
|
628
|
+
return request_id;
|
|
629
|
+
}
|
|
589
630
|
ping() {
|
|
590
631
|
if (this.ws?.readyState === WS_OPEN) {
|
|
591
632
|
this.send({ type: "Ping" });
|
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
|
@@ -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: {
|
|
@@ -322,6 +328,22 @@ export type QuoteMessage = {
|
|
|
322
328
|
order_id: OrderIdHex32;
|
|
323
329
|
signature: string;
|
|
324
330
|
};
|
|
331
|
+
export type ReplaceQuoteMessage = {
|
|
332
|
+
/** orderId of the quote being replaced (64-char hex). */
|
|
333
|
+
old_order_id: OrderIdHex32;
|
|
334
|
+
rfq_id: UuidString;
|
|
335
|
+
strike: WsU64;
|
|
336
|
+
price: WsU64;
|
|
337
|
+
valid_until: WsU64;
|
|
338
|
+
nonce: WsU64;
|
|
339
|
+
/** New 32-byte orderId (sha256) encoded as hex (64 chars). */
|
|
340
|
+
order_id: OrderIdHex32;
|
|
341
|
+
/** base58 ed25519 signature over the NEW `order_id`. */
|
|
342
|
+
signature: string;
|
|
343
|
+
};
|
|
344
|
+
export type BatchQuotesMessage = {
|
|
345
|
+
quotes: QuoteMessage[];
|
|
346
|
+
};
|
|
325
347
|
export type MarketDescriptor = {
|
|
326
348
|
chain_id: WsU64;
|
|
327
349
|
program_id: Address<string>;
|