@usherlabs/cex-broker 0.2.32 → 0.2.33
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/commands/cli.js
CHANGED
|
@@ -315125,6 +315125,7 @@ function buildOrderExecutionTelemetry(context2, order, error) {
|
|
|
315125
315125
|
side: firstString(record?.side, info?.side, context2.side) ?? "unknown",
|
|
315126
315126
|
orderType: firstString(record?.type, info?.type, context2.orderType) ?? "unknown",
|
|
315127
315127
|
orderId: firstString(record?.id, info?.orderId, info?.orderID),
|
|
315128
|
+
orderAuthor: context2.orderAuthor,
|
|
315128
315129
|
clientOrderId: firstString(context2.clientOrderId, record?.clientOrderId, record?.clientOrderID, record?.clientOid, info?.clientOrderId, info?.clientOrderID, info?.clientOid),
|
|
315129
315130
|
idempotencyId: context2.idempotencyId,
|
|
315130
315131
|
makerActionId: context2.makerActionId,
|
|
@@ -315544,6 +315545,7 @@ function buildOrderEventArchiveRow(input) {
|
|
|
315544
315545
|
action,
|
|
315545
315546
|
subscription_type: input.subscriptionType,
|
|
315546
315547
|
order_id: telemetry.orderId,
|
|
315548
|
+
order_author: telemetry.orderAuthor ?? "",
|
|
315547
315549
|
client_order_id: telemetry.clientOrderId,
|
|
315548
315550
|
idempotency_id: telemetry.idempotencyId,
|
|
315549
315551
|
maker_action_id: telemetry.makerActionId,
|
|
@@ -330685,6 +330687,7 @@ var DepositPayloadSchema = exports_external.object({
|
|
|
330685
330687
|
var CallPayloadSchema = exports_external.object({
|
|
330686
330688
|
functionName: exports_external.string().regex(/^[A-Za-z][A-Za-z0-9]*$/),
|
|
330687
330689
|
args: exports_external.preprocess(parseJsonString, exports_external.array(exports_external.unknown())).default([]),
|
|
330690
|
+
orderAuthor: exports_external.string().min(1).optional(),
|
|
330688
330691
|
params: exports_external.preprocess(parseJsonString, exports_external.record(exports_external.string(), exports_external.unknown())).default({})
|
|
330689
330692
|
});
|
|
330690
330693
|
var FetchDepositAddressesPayloadSchema = exports_external.object({
|
|
@@ -330706,12 +330709,14 @@ var marketTypeSchema = exports_external.enum(["spot", "swap", "perp", "future",
|
|
|
330706
330709
|
var unknownParamsSchema = exports_external.preprocess(parseJsonString, exports_external.record(exports_external.string(), exports_external.unknown()));
|
|
330707
330710
|
var CreateOrderPayloadSchema = exports_external.object({
|
|
330708
330711
|
orderType: exports_external.enum(["market", "limit"]).default("limit"),
|
|
330712
|
+
orderIntent: exports_external.enum(["passive_only"]).optional(),
|
|
330709
330713
|
amount: exports_external.coerce.number().positive(),
|
|
330710
330714
|
fromToken: exports_external.string().min(1),
|
|
330711
330715
|
toToken: exports_external.string().min(1),
|
|
330712
330716
|
price: exports_external.coerce.number().positive(),
|
|
330713
330717
|
marketType: marketTypeSchema,
|
|
330714
330718
|
clientOrderId: exports_external.string().min(1).optional(),
|
|
330719
|
+
orderAuthor: exports_external.string().min(1).optional(),
|
|
330715
330720
|
params: exports_external.preprocess(parseJsonString, stringNumberRecordSchema).default({})
|
|
330716
330721
|
});
|
|
330717
330722
|
var GetPerpConfigStatePayloadSchema = exports_external.object({
|
|
@@ -330793,6 +330798,12 @@ function stableGrpcErrorCode(message) {
|
|
|
330793
330798
|
if (message.startsWith("deposit_amount_mismatch:")) {
|
|
330794
330799
|
return grpc2.status.FAILED_PRECONDITION;
|
|
330795
330800
|
}
|
|
330801
|
+
if (message.startsWith("passive_order_unsupported:")) {
|
|
330802
|
+
return grpc2.status.UNIMPLEMENTED;
|
|
330803
|
+
}
|
|
330804
|
+
if (message.startsWith("passive_order_rejected:") || message.startsWith("passive_order_would_cross:")) {
|
|
330805
|
+
return grpc2.status.FAILED_PRECONDITION;
|
|
330806
|
+
}
|
|
330796
330807
|
if (message.startsWith("policy_withdrawal_denied:") || message.startsWith("policy_deposit_denied:")) {
|
|
330797
330808
|
return grpc2.status.PERMISSION_DENIED;
|
|
330798
330809
|
}
|
|
@@ -331459,6 +331470,33 @@ async function handleInternalTransfer(ctx) {
|
|
|
331459
331470
|
|
|
331460
331471
|
// src/handlers/execute-action/orders.ts
|
|
331461
331472
|
var grpc6 = __toESM(require_src3(), 1);
|
|
331473
|
+
|
|
331474
|
+
// src/helpers/passive-order.ts
|
|
331475
|
+
var PASSIVE_ORDER_ERROR_CODES = {
|
|
331476
|
+
unsupported: "passive_order_unsupported",
|
|
331477
|
+
rejected: "passive_order_rejected",
|
|
331478
|
+
wouldCross: "passive_order_would_cross"
|
|
331479
|
+
};
|
|
331480
|
+
function identifiesWouldCross(message) {
|
|
331481
|
+
const normalized = message.toLowerCase();
|
|
331482
|
+
return normalized.includes("would immediately match and take") || /post[\s-]?only\b.*\bwould\b.*\bimmediately\b.*\b(?:execute|fill|match)/.test(normalized) || /post[\s-]?only\b.*\bwould\b.*\b(?:execute|fill|match)\w*\b.*\bimmediately/.test(normalized);
|
|
331483
|
+
}
|
|
331484
|
+
function identifiesUnsupported(message) {
|
|
331485
|
+
const normalized = message.toLowerCase();
|
|
331486
|
+
return /post[\s-]?only\b.*\b(?:not supported|unsupported|does not support)\b/.test(normalized) || /\b(?:not supported|unsupported|does not support)\b.*\bpost[\s-]?only\b/.test(normalized);
|
|
331487
|
+
}
|
|
331488
|
+
function classifyPassiveOrderError(error48) {
|
|
331489
|
+
const message = getErrorMessage(error48);
|
|
331490
|
+
if (error48 instanceof ccxt_default.OrderImmediatelyFillable || identifiesWouldCross(message)) {
|
|
331491
|
+
return PASSIVE_ORDER_ERROR_CODES.wouldCross;
|
|
331492
|
+
}
|
|
331493
|
+
if (error48 instanceof ccxt_default.NotSupported || identifiesUnsupported(message)) {
|
|
331494
|
+
return PASSIVE_ORDER_ERROR_CODES.unsupported;
|
|
331495
|
+
}
|
|
331496
|
+
return PASSIVE_ORDER_ERROR_CODES.rejected;
|
|
331497
|
+
}
|
|
331498
|
+
|
|
331499
|
+
// src/handlers/execute-action/orders.ts
|
|
331462
331500
|
async function handleCreateOrder(ctx) {
|
|
331463
331501
|
const {
|
|
331464
331502
|
call,
|
|
@@ -331483,14 +331521,23 @@ async function handleCreateOrder(ctx) {
|
|
|
331483
331521
|
const orderValue = parsePayloadForAction(ctx, CreateOrderPayloadSchema);
|
|
331484
331522
|
if (orderValue === null)
|
|
331485
331523
|
return;
|
|
331524
|
+
const isPassiveOrder = orderValue.orderIntent === "passive_only";
|
|
331525
|
+
if (isPassiveOrder && orderValue.orderType !== "limit") {
|
|
331526
|
+
return ctx.wrappedCallback({
|
|
331527
|
+
code: grpc6.status.INVALID_ARGUMENT,
|
|
331528
|
+
message: "ValidationError: passive_only order intent requires a limit order"
|
|
331529
|
+
}, null);
|
|
331530
|
+
}
|
|
331486
331531
|
const createOrderParams = {
|
|
331487
331532
|
...orderValue.params,
|
|
331488
331533
|
...orderValue.clientOrderId !== undefined && {
|
|
331489
331534
|
clientOrderId: orderValue.clientOrderId
|
|
331490
|
-
}
|
|
331535
|
+
},
|
|
331536
|
+
...isPassiveOrder && { postOnly: true }
|
|
331491
331537
|
};
|
|
331492
331538
|
let resolvedOrderTelemetry = {};
|
|
331493
331539
|
let marketMetadataHash;
|
|
331540
|
+
let submission = "not_attempted";
|
|
331494
331541
|
try {
|
|
331495
331542
|
if (!broker) {
|
|
331496
331543
|
return ctx.wrappedCallback({
|
|
@@ -331523,7 +331570,9 @@ async function handleCreateOrder(ctx) {
|
|
|
331523
331570
|
brokerObservedTimestamp: submissionTimestamp,
|
|
331524
331571
|
...telemetryIds
|
|
331525
331572
|
});
|
|
331573
|
+
submission = "in_flight";
|
|
331526
331574
|
const order = await broker.createOrder(resolution.symbol, orderValue.orderType, resolution.side, resolution.amountBase ?? orderValue.amount, orderValue.price, createOrderParams);
|
|
331575
|
+
submission = "placed";
|
|
331527
331576
|
const createOrderContext = {
|
|
331528
331577
|
action: "CreateOrder",
|
|
331529
331578
|
cex: cex3,
|
|
@@ -331533,12 +331582,20 @@ async function handleCreateOrder(ctx) {
|
|
|
331533
331582
|
orderType: orderValue.orderType,
|
|
331534
331583
|
requestedQuantity: resolvedOrderTelemetry.requestedQuantity,
|
|
331535
331584
|
requestedNotional: orderValue.amount * orderValue.price,
|
|
331585
|
+
orderAuthor: orderValue.orderAuthor,
|
|
331536
331586
|
brokerObservedTimestamp: submissionTimestamp,
|
|
331537
331587
|
...telemetryIds
|
|
331538
331588
|
};
|
|
331539
331589
|
emitOrderExecutionTelemetryInBackground(otelMetrics, createOrderContext, order);
|
|
331540
331590
|
archiveOrderExecutionInBackground(brokerArchiver, createOrderContext, order, undefined, { marketMetadataHash });
|
|
331541
|
-
ctx.wrappedCallback(null, {
|
|
331591
|
+
ctx.wrappedCallback(null, {
|
|
331592
|
+
result: JSON.stringify({
|
|
331593
|
+
...order,
|
|
331594
|
+
...isPassiveOrder && {
|
|
331595
|
+
passivePlacementOutcome: "accepted_passive"
|
|
331596
|
+
}
|
|
331597
|
+
})
|
|
331598
|
+
});
|
|
331542
331599
|
} catch (error48) {
|
|
331543
331600
|
rethrowArchiveDurabilityError(error48);
|
|
331544
331601
|
safeLogRedactedError("Order Creation failed", error48);
|
|
@@ -331551,10 +331608,18 @@ async function handleCreateOrder(ctx) {
|
|
|
331551
331608
|
orderType: orderValue.orderType,
|
|
331552
331609
|
requestedQuantity: resolvedOrderTelemetry.requestedQuantity ?? orderValue.amount,
|
|
331553
331610
|
requestedNotional: orderValue.amount * orderValue.price,
|
|
331611
|
+
orderAuthor: orderValue.orderAuthor,
|
|
331554
331612
|
...extractOrderTelemetryIds(createOrderParams)
|
|
331555
331613
|
};
|
|
331556
331614
|
emitOrderExecutionTelemetryInBackground(otelMetrics, failedCreateContext, undefined, error48);
|
|
331557
331615
|
archiveOrderExecutionInBackground(brokerArchiver, failedCreateContext, undefined, error48, { marketMetadataHash });
|
|
331616
|
+
if (isPassiveOrder && submission === "in_flight") {
|
|
331617
|
+
const passiveErrorCode = classifyPassiveOrderError(error48);
|
|
331618
|
+
return rejectWithGrpcError(ctx, error48, {
|
|
331619
|
+
message: `${passiveErrorCode}: ${sanitizeErrorDetail(error48)}`,
|
|
331620
|
+
preferStableMessageOnly: true
|
|
331621
|
+
});
|
|
331622
|
+
}
|
|
331558
331623
|
ctx.wrappedCallback({
|
|
331559
331624
|
code: grpc6.status.INTERNAL,
|
|
331560
331625
|
message: `Order Creation failed: ${sanitizeErrorDetail(error48)}`
|
|
@@ -332292,6 +332357,7 @@ async function handleTreasuryCall(ctx) {
|
|
|
332292
332357
|
side: asNonEmptyString(side),
|
|
332293
332358
|
requestedQuantity,
|
|
332294
332359
|
requestedNotional,
|
|
332360
|
+
orderAuthor: callValue.orderAuthor,
|
|
332295
332361
|
brokerObservedTimestamp: submissionTimestamp,
|
|
332296
332362
|
...telemetryIds
|
|
332297
332363
|
};
|
|
@@ -9,6 +9,7 @@ export type OrderTelemetryContext = {
|
|
|
9
9
|
orderType?: string;
|
|
10
10
|
requestedQuantity?: number;
|
|
11
11
|
requestedNotional?: number;
|
|
12
|
+
orderAuthor?: string;
|
|
12
13
|
clientOrderId?: string;
|
|
13
14
|
idempotencyId?: string;
|
|
14
15
|
makerActionId?: string;
|
|
@@ -23,6 +24,7 @@ export type OrderExecutionTelemetry = {
|
|
|
23
24
|
side: string;
|
|
24
25
|
orderType: string;
|
|
25
26
|
orderId?: string;
|
|
27
|
+
orderAuthor?: string;
|
|
26
28
|
clientOrderId?: string;
|
|
27
29
|
idempotencyId?: string;
|
|
28
30
|
makerActionId?: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PASSIVE_ORDER_ERROR_CODES: {
|
|
2
|
+
readonly unsupported: "passive_order_unsupported";
|
|
3
|
+
readonly rejected: "passive_order_rejected";
|
|
4
|
+
readonly wouldCross: "passive_order_would_cross";
|
|
5
|
+
};
|
|
6
|
+
export type PassiveOrderErrorCode = (typeof PASSIVE_ORDER_ERROR_CODES)[keyof typeof PASSIVE_ORDER_ERROR_CODES];
|
|
7
|
+
export declare function classifyPassiveOrderError(error: unknown): PassiveOrderErrorCode;
|
package/dist/index.js
CHANGED
|
@@ -290639,6 +290639,7 @@ function buildOrderExecutionTelemetry(context2, order, error) {
|
|
|
290639
290639
|
side: firstString(record?.side, info?.side, context2.side) ?? "unknown",
|
|
290640
290640
|
orderType: firstString(record?.type, info?.type, context2.orderType) ?? "unknown",
|
|
290641
290641
|
orderId: firstString(record?.id, info?.orderId, info?.orderID),
|
|
290642
|
+
orderAuthor: context2.orderAuthor,
|
|
290642
290643
|
clientOrderId: firstString(context2.clientOrderId, record?.clientOrderId, record?.clientOrderID, record?.clientOid, info?.clientOrderId, info?.clientOrderID, info?.clientOid),
|
|
290643
290644
|
idempotencyId: context2.idempotencyId,
|
|
290644
290645
|
makerActionId: context2.makerActionId,
|
|
@@ -291058,6 +291059,7 @@ function buildOrderEventArchiveRow(input) {
|
|
|
291058
291059
|
action,
|
|
291059
291060
|
subscription_type: input.subscriptionType,
|
|
291060
291061
|
order_id: telemetry.orderId,
|
|
291062
|
+
order_author: telemetry.orderAuthor ?? "",
|
|
291061
291063
|
client_order_id: telemetry.clientOrderId,
|
|
291062
291064
|
idempotency_id: telemetry.idempotencyId,
|
|
291063
291065
|
maker_action_id: telemetry.makerActionId,
|
|
@@ -306199,6 +306201,7 @@ var DepositPayloadSchema = exports_external.object({
|
|
|
306199
306201
|
var CallPayloadSchema = exports_external.object({
|
|
306200
306202
|
functionName: exports_external.string().regex(/^[A-Za-z][A-Za-z0-9]*$/),
|
|
306201
306203
|
args: exports_external.preprocess(parseJsonString, exports_external.array(exports_external.unknown())).default([]),
|
|
306204
|
+
orderAuthor: exports_external.string().min(1).optional(),
|
|
306202
306205
|
params: exports_external.preprocess(parseJsonString, exports_external.record(exports_external.string(), exports_external.unknown())).default({})
|
|
306203
306206
|
});
|
|
306204
306207
|
var FetchDepositAddressesPayloadSchema = exports_external.object({
|
|
@@ -306220,12 +306223,14 @@ var marketTypeSchema = exports_external.enum(["spot", "swap", "perp", "future",
|
|
|
306220
306223
|
var unknownParamsSchema = exports_external.preprocess(parseJsonString, exports_external.record(exports_external.string(), exports_external.unknown()));
|
|
306221
306224
|
var CreateOrderPayloadSchema = exports_external.object({
|
|
306222
306225
|
orderType: exports_external.enum(["market", "limit"]).default("limit"),
|
|
306226
|
+
orderIntent: exports_external.enum(["passive_only"]).optional(),
|
|
306223
306227
|
amount: exports_external.coerce.number().positive(),
|
|
306224
306228
|
fromToken: exports_external.string().min(1),
|
|
306225
306229
|
toToken: exports_external.string().min(1),
|
|
306226
306230
|
price: exports_external.coerce.number().positive(),
|
|
306227
306231
|
marketType: marketTypeSchema,
|
|
306228
306232
|
clientOrderId: exports_external.string().min(1).optional(),
|
|
306233
|
+
orderAuthor: exports_external.string().min(1).optional(),
|
|
306229
306234
|
params: exports_external.preprocess(parseJsonString, stringNumberRecordSchema).default({})
|
|
306230
306235
|
});
|
|
306231
306236
|
var GetPerpConfigStatePayloadSchema = exports_external.object({
|
|
@@ -306307,6 +306312,12 @@ function stableGrpcErrorCode(message) {
|
|
|
306307
306312
|
if (message.startsWith("deposit_amount_mismatch:")) {
|
|
306308
306313
|
return grpc2.status.FAILED_PRECONDITION;
|
|
306309
306314
|
}
|
|
306315
|
+
if (message.startsWith("passive_order_unsupported:")) {
|
|
306316
|
+
return grpc2.status.UNIMPLEMENTED;
|
|
306317
|
+
}
|
|
306318
|
+
if (message.startsWith("passive_order_rejected:") || message.startsWith("passive_order_would_cross:")) {
|
|
306319
|
+
return grpc2.status.FAILED_PRECONDITION;
|
|
306320
|
+
}
|
|
306310
306321
|
if (message.startsWith("policy_withdrawal_denied:") || message.startsWith("policy_deposit_denied:")) {
|
|
306311
306322
|
return grpc2.status.PERMISSION_DENIED;
|
|
306312
306323
|
}
|
|
@@ -306973,6 +306984,33 @@ async function handleInternalTransfer(ctx) {
|
|
|
306973
306984
|
|
|
306974
306985
|
// src/handlers/execute-action/orders.ts
|
|
306975
306986
|
import * as grpc6 from "@grpc/grpc-js";
|
|
306987
|
+
|
|
306988
|
+
// src/helpers/passive-order.ts
|
|
306989
|
+
var PASSIVE_ORDER_ERROR_CODES = {
|
|
306990
|
+
unsupported: "passive_order_unsupported",
|
|
306991
|
+
rejected: "passive_order_rejected",
|
|
306992
|
+
wouldCross: "passive_order_would_cross"
|
|
306993
|
+
};
|
|
306994
|
+
function identifiesWouldCross(message) {
|
|
306995
|
+
const normalized = message.toLowerCase();
|
|
306996
|
+
return normalized.includes("would immediately match and take") || /post[\s-]?only\b.*\bwould\b.*\bimmediately\b.*\b(?:execute|fill|match)/.test(normalized) || /post[\s-]?only\b.*\bwould\b.*\b(?:execute|fill|match)\w*\b.*\bimmediately/.test(normalized);
|
|
306997
|
+
}
|
|
306998
|
+
function identifiesUnsupported(message) {
|
|
306999
|
+
const normalized = message.toLowerCase();
|
|
307000
|
+
return /post[\s-]?only\b.*\b(?:not supported|unsupported|does not support)\b/.test(normalized) || /\b(?:not supported|unsupported|does not support)\b.*\bpost[\s-]?only\b/.test(normalized);
|
|
307001
|
+
}
|
|
307002
|
+
function classifyPassiveOrderError(error48) {
|
|
307003
|
+
const message = getErrorMessage(error48);
|
|
307004
|
+
if (error48 instanceof ccxt_default.OrderImmediatelyFillable || identifiesWouldCross(message)) {
|
|
307005
|
+
return PASSIVE_ORDER_ERROR_CODES.wouldCross;
|
|
307006
|
+
}
|
|
307007
|
+
if (error48 instanceof ccxt_default.NotSupported || identifiesUnsupported(message)) {
|
|
307008
|
+
return PASSIVE_ORDER_ERROR_CODES.unsupported;
|
|
307009
|
+
}
|
|
307010
|
+
return PASSIVE_ORDER_ERROR_CODES.rejected;
|
|
307011
|
+
}
|
|
307012
|
+
|
|
307013
|
+
// src/handlers/execute-action/orders.ts
|
|
306976
307014
|
async function handleCreateOrder(ctx) {
|
|
306977
307015
|
const {
|
|
306978
307016
|
call,
|
|
@@ -306997,14 +307035,23 @@ async function handleCreateOrder(ctx) {
|
|
|
306997
307035
|
const orderValue = parsePayloadForAction(ctx, CreateOrderPayloadSchema);
|
|
306998
307036
|
if (orderValue === null)
|
|
306999
307037
|
return;
|
|
307038
|
+
const isPassiveOrder = orderValue.orderIntent === "passive_only";
|
|
307039
|
+
if (isPassiveOrder && orderValue.orderType !== "limit") {
|
|
307040
|
+
return ctx.wrappedCallback({
|
|
307041
|
+
code: grpc6.status.INVALID_ARGUMENT,
|
|
307042
|
+
message: "ValidationError: passive_only order intent requires a limit order"
|
|
307043
|
+
}, null);
|
|
307044
|
+
}
|
|
307000
307045
|
const createOrderParams = {
|
|
307001
307046
|
...orderValue.params,
|
|
307002
307047
|
...orderValue.clientOrderId !== undefined && {
|
|
307003
307048
|
clientOrderId: orderValue.clientOrderId
|
|
307004
|
-
}
|
|
307049
|
+
},
|
|
307050
|
+
...isPassiveOrder && { postOnly: true }
|
|
307005
307051
|
};
|
|
307006
307052
|
let resolvedOrderTelemetry = {};
|
|
307007
307053
|
let marketMetadataHash;
|
|
307054
|
+
let submission = "not_attempted";
|
|
307008
307055
|
try {
|
|
307009
307056
|
if (!broker) {
|
|
307010
307057
|
return ctx.wrappedCallback({
|
|
@@ -307037,7 +307084,9 @@ async function handleCreateOrder(ctx) {
|
|
|
307037
307084
|
brokerObservedTimestamp: submissionTimestamp,
|
|
307038
307085
|
...telemetryIds
|
|
307039
307086
|
});
|
|
307087
|
+
submission = "in_flight";
|
|
307040
307088
|
const order = await broker.createOrder(resolution.symbol, orderValue.orderType, resolution.side, resolution.amountBase ?? orderValue.amount, orderValue.price, createOrderParams);
|
|
307089
|
+
submission = "placed";
|
|
307041
307090
|
const createOrderContext = {
|
|
307042
307091
|
action: "CreateOrder",
|
|
307043
307092
|
cex: cex3,
|
|
@@ -307047,12 +307096,20 @@ async function handleCreateOrder(ctx) {
|
|
|
307047
307096
|
orderType: orderValue.orderType,
|
|
307048
307097
|
requestedQuantity: resolvedOrderTelemetry.requestedQuantity,
|
|
307049
307098
|
requestedNotional: orderValue.amount * orderValue.price,
|
|
307099
|
+
orderAuthor: orderValue.orderAuthor,
|
|
307050
307100
|
brokerObservedTimestamp: submissionTimestamp,
|
|
307051
307101
|
...telemetryIds
|
|
307052
307102
|
};
|
|
307053
307103
|
emitOrderExecutionTelemetryInBackground(otelMetrics, createOrderContext, order);
|
|
307054
307104
|
archiveOrderExecutionInBackground(brokerArchiver, createOrderContext, order, undefined, { marketMetadataHash });
|
|
307055
|
-
ctx.wrappedCallback(null, {
|
|
307105
|
+
ctx.wrappedCallback(null, {
|
|
307106
|
+
result: JSON.stringify({
|
|
307107
|
+
...order,
|
|
307108
|
+
...isPassiveOrder && {
|
|
307109
|
+
passivePlacementOutcome: "accepted_passive"
|
|
307110
|
+
}
|
|
307111
|
+
})
|
|
307112
|
+
});
|
|
307056
307113
|
} catch (error48) {
|
|
307057
307114
|
rethrowArchiveDurabilityError(error48);
|
|
307058
307115
|
safeLogRedactedError("Order Creation failed", error48);
|
|
@@ -307065,10 +307122,18 @@ async function handleCreateOrder(ctx) {
|
|
|
307065
307122
|
orderType: orderValue.orderType,
|
|
307066
307123
|
requestedQuantity: resolvedOrderTelemetry.requestedQuantity ?? orderValue.amount,
|
|
307067
307124
|
requestedNotional: orderValue.amount * orderValue.price,
|
|
307125
|
+
orderAuthor: orderValue.orderAuthor,
|
|
307068
307126
|
...extractOrderTelemetryIds(createOrderParams)
|
|
307069
307127
|
};
|
|
307070
307128
|
emitOrderExecutionTelemetryInBackground(otelMetrics, failedCreateContext, undefined, error48);
|
|
307071
307129
|
archiveOrderExecutionInBackground(brokerArchiver, failedCreateContext, undefined, error48, { marketMetadataHash });
|
|
307130
|
+
if (isPassiveOrder && submission === "in_flight") {
|
|
307131
|
+
const passiveErrorCode = classifyPassiveOrderError(error48);
|
|
307132
|
+
return rejectWithGrpcError(ctx, error48, {
|
|
307133
|
+
message: `${passiveErrorCode}: ${sanitizeErrorDetail(error48)}`,
|
|
307134
|
+
preferStableMessageOnly: true
|
|
307135
|
+
});
|
|
307136
|
+
}
|
|
307072
307137
|
ctx.wrappedCallback({
|
|
307073
307138
|
code: grpc6.status.INTERNAL,
|
|
307074
307139
|
message: `Order Creation failed: ${sanitizeErrorDetail(error48)}`
|
|
@@ -307806,6 +307871,7 @@ async function handleTreasuryCall(ctx) {
|
|
|
307806
307871
|
side: asNonEmptyString(side),
|
|
307807
307872
|
requestedQuantity,
|
|
307808
307873
|
requestedNotional,
|
|
307874
|
+
orderAuthor: callValue.orderAuthor,
|
|
307809
307875
|
brokerObservedTimestamp: submissionTimestamp,
|
|
307810
307876
|
...telemetryIds
|
|
307811
307877
|
};
|
|
@@ -310185,4 +310251,4 @@ export {
|
|
|
310185
310251
|
CEXBroker as default
|
|
310186
310252
|
};
|
|
310187
310253
|
|
|
310188
|
-
//# debugId=
|
|
310254
|
+
//# debugId=DF7A1B19BD16DBE764756E2164756E21
|