@usherlabs/cex-broker 0.2.31 → 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.
@@ -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,
@@ -315603,6 +315605,7 @@ function buildTransferEventArchiveRow(input) {
315603
315605
  address: transfer.address,
315604
315606
  network: transfer.network,
315605
315607
  external_id: transfer.externalId ?? "",
315608
+ client_withdrawal_id: transfer.clientWithdrawalId ?? "",
315606
315609
  txid: transfer.txid,
315607
315610
  result_index: transfer.resultIndex ?? 0,
315608
315611
  fee_amount: transfer.feeAmount,
@@ -330684,6 +330687,7 @@ var DepositPayloadSchema = exports_external.object({
330684
330687
  var CallPayloadSchema = exports_external.object({
330685
330688
  functionName: exports_external.string().regex(/^[A-Za-z][A-Za-z0-9]*$/),
330686
330689
  args: exports_external.preprocess(parseJsonString, exports_external.array(exports_external.unknown())).default([]),
330690
+ orderAuthor: exports_external.string().min(1).optional(),
330687
330691
  params: exports_external.preprocess(parseJsonString, exports_external.record(exports_external.string(), exports_external.unknown())).default({})
330688
330692
  });
330689
330693
  var FetchDepositAddressesPayloadSchema = exports_external.object({
@@ -330705,12 +330709,14 @@ var marketTypeSchema = exports_external.enum(["spot", "swap", "perp", "future",
330705
330709
  var unknownParamsSchema = exports_external.preprocess(parseJsonString, exports_external.record(exports_external.string(), exports_external.unknown()));
330706
330710
  var CreateOrderPayloadSchema = exports_external.object({
330707
330711
  orderType: exports_external.enum(["market", "limit"]).default("limit"),
330712
+ orderIntent: exports_external.enum(["passive_only"]).optional(),
330708
330713
  amount: exports_external.coerce.number().positive(),
330709
330714
  fromToken: exports_external.string().min(1),
330710
330715
  toToken: exports_external.string().min(1),
330711
330716
  price: exports_external.coerce.number().positive(),
330712
330717
  marketType: marketTypeSchema,
330713
330718
  clientOrderId: exports_external.string().min(1).optional(),
330719
+ orderAuthor: exports_external.string().min(1).optional(),
330714
330720
  params: exports_external.preprocess(parseJsonString, stringNumberRecordSchema).default({})
330715
330721
  });
330716
330722
  var GetPerpConfigStatePayloadSchema = exports_external.object({
@@ -330792,6 +330798,12 @@ function stableGrpcErrorCode(message) {
330792
330798
  if (message.startsWith("deposit_amount_mismatch:")) {
330793
330799
  return grpc2.status.FAILED_PRECONDITION;
330794
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
+ }
330795
330807
  if (message.startsWith("policy_withdrawal_denied:") || message.startsWith("policy_deposit_denied:")) {
330796
330808
  return grpc2.status.PERMISSION_DENIED;
330797
330809
  }
@@ -331458,6 +331470,33 @@ async function handleInternalTransfer(ctx) {
331458
331470
 
331459
331471
  // src/handlers/execute-action/orders.ts
331460
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
331461
331500
  async function handleCreateOrder(ctx) {
331462
331501
  const {
331463
331502
  call,
@@ -331482,14 +331521,23 @@ async function handleCreateOrder(ctx) {
331482
331521
  const orderValue = parsePayloadForAction(ctx, CreateOrderPayloadSchema);
331483
331522
  if (orderValue === null)
331484
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
+ }
331485
331531
  const createOrderParams = {
331486
331532
  ...orderValue.params,
331487
331533
  ...orderValue.clientOrderId !== undefined && {
331488
331534
  clientOrderId: orderValue.clientOrderId
331489
- }
331535
+ },
331536
+ ...isPassiveOrder && { postOnly: true }
331490
331537
  };
331491
331538
  let resolvedOrderTelemetry = {};
331492
331539
  let marketMetadataHash;
331540
+ let submission = "not_attempted";
331493
331541
  try {
331494
331542
  if (!broker) {
331495
331543
  return ctx.wrappedCallback({
@@ -331522,7 +331570,9 @@ async function handleCreateOrder(ctx) {
331522
331570
  brokerObservedTimestamp: submissionTimestamp,
331523
331571
  ...telemetryIds
331524
331572
  });
331573
+ submission = "in_flight";
331525
331574
  const order = await broker.createOrder(resolution.symbol, orderValue.orderType, resolution.side, resolution.amountBase ?? orderValue.amount, orderValue.price, createOrderParams);
331575
+ submission = "placed";
331526
331576
  const createOrderContext = {
331527
331577
  action: "CreateOrder",
331528
331578
  cex: cex3,
@@ -331532,12 +331582,20 @@ async function handleCreateOrder(ctx) {
331532
331582
  orderType: orderValue.orderType,
331533
331583
  requestedQuantity: resolvedOrderTelemetry.requestedQuantity,
331534
331584
  requestedNotional: orderValue.amount * orderValue.price,
331585
+ orderAuthor: orderValue.orderAuthor,
331535
331586
  brokerObservedTimestamp: submissionTimestamp,
331536
331587
  ...telemetryIds
331537
331588
  };
331538
331589
  emitOrderExecutionTelemetryInBackground(otelMetrics, createOrderContext, order);
331539
331590
  archiveOrderExecutionInBackground(brokerArchiver, createOrderContext, order, undefined, { marketMetadataHash });
331540
- ctx.wrappedCallback(null, { result: JSON.stringify({ ...order }) });
331591
+ ctx.wrappedCallback(null, {
331592
+ result: JSON.stringify({
331593
+ ...order,
331594
+ ...isPassiveOrder && {
331595
+ passivePlacementOutcome: "accepted_passive"
331596
+ }
331597
+ })
331598
+ });
331541
331599
  } catch (error48) {
331542
331600
  rethrowArchiveDurabilityError(error48);
331543
331601
  safeLogRedactedError("Order Creation failed", error48);
@@ -331550,10 +331608,18 @@ async function handleCreateOrder(ctx) {
331550
331608
  orderType: orderValue.orderType,
331551
331609
  requestedQuantity: resolvedOrderTelemetry.requestedQuantity ?? orderValue.amount,
331552
331610
  requestedNotional: orderValue.amount * orderValue.price,
331611
+ orderAuthor: orderValue.orderAuthor,
331553
331612
  ...extractOrderTelemetryIds(createOrderParams)
331554
331613
  };
331555
331614
  emitOrderExecutionTelemetryInBackground(otelMetrics, failedCreateContext, undefined, error48);
331556
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
+ }
331557
331623
  ctx.wrappedCallback({
331558
331624
  code: grpc6.status.INTERNAL,
331559
331625
  message: `Order Creation failed: ${sanitizeErrorDetail(error48)}`
@@ -332291,6 +332357,7 @@ async function handleTreasuryCall(ctx) {
332291
332357
  side: asNonEmptyString(side),
332292
332358
  requestedQuantity,
332293
332359
  requestedNotional,
332360
+ orderAuthor: callValue.orderAuthor,
332294
332361
  brokerObservedTimestamp: submissionTimestamp,
332295
332362
  ...telemetryIds
332296
332363
  };
@@ -332403,6 +332470,8 @@ async function handleWithdraw(ctx) {
332403
332470
  message: `travel_rule_denied: ${travelRule.error}`
332404
332471
  }, null);
332405
332472
  }
332473
+ const withdrawOrderId = transferValue.params.withdrawOrderId;
332474
+ const clientWithdrawalId = typeof withdrawOrderId === "string" && withdrawOrderId.length > 0 ? withdrawOrderId : undefined;
332406
332475
  try {
332407
332476
  const transaction = travelRule.mode === "localentity" ? await withdrawViaLocalEntity(broker, {
332408
332477
  code: symbol2,
@@ -332429,6 +332498,7 @@ async function handleWithdraw(ctx) {
332429
332498
  address: normalized.address ?? transferValue.recipientAddress,
332430
332499
  network: normalized.network ?? withdrawNetwork.exchangeNetworkId,
332431
332500
  externalId: normalized.externalId,
332501
+ clientWithdrawalId,
332432
332502
  txid: normalized.txid,
332433
332503
  feeAmount: normalized.feeAmount,
332434
332504
  feeCurrency: normalized.feeCurrency,
@@ -332458,6 +332528,7 @@ async function handleWithdraw(ctx) {
332458
332528
  amount: String(transferValue.amount),
332459
332529
  address: transferValue.recipientAddress,
332460
332530
  network: withdrawNetwork.exchangeNetworkId,
332531
+ clientWithdrawalId,
332461
332532
  errorSummary: getErrorMessage(error48),
332462
332533
  payload: { recipientAddress: transferValue.recipientAddress }
332463
332534
  }
@@ -47,6 +47,7 @@ export type TransferArchiveFields = {
47
47
  address?: string;
48
48
  network?: string;
49
49
  externalId?: string;
50
+ clientWithdrawalId?: string;
50
51
  txid?: string;
51
52
  resultIndex?: number;
52
53
  feeAmount?: string;
@@ -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,
@@ -291117,6 +291119,7 @@ function buildTransferEventArchiveRow(input) {
291117
291119
  address: transfer.address,
291118
291120
  network: transfer.network,
291119
291121
  external_id: transfer.externalId ?? "",
291122
+ client_withdrawal_id: transfer.clientWithdrawalId ?? "",
291120
291123
  txid: transfer.txid,
291121
291124
  result_index: transfer.resultIndex ?? 0,
291122
291125
  fee_amount: transfer.feeAmount,
@@ -306198,6 +306201,7 @@ var DepositPayloadSchema = exports_external.object({
306198
306201
  var CallPayloadSchema = exports_external.object({
306199
306202
  functionName: exports_external.string().regex(/^[A-Za-z][A-Za-z0-9]*$/),
306200
306203
  args: exports_external.preprocess(parseJsonString, exports_external.array(exports_external.unknown())).default([]),
306204
+ orderAuthor: exports_external.string().min(1).optional(),
306201
306205
  params: exports_external.preprocess(parseJsonString, exports_external.record(exports_external.string(), exports_external.unknown())).default({})
306202
306206
  });
306203
306207
  var FetchDepositAddressesPayloadSchema = exports_external.object({
@@ -306219,12 +306223,14 @@ var marketTypeSchema = exports_external.enum(["spot", "swap", "perp", "future",
306219
306223
  var unknownParamsSchema = exports_external.preprocess(parseJsonString, exports_external.record(exports_external.string(), exports_external.unknown()));
306220
306224
  var CreateOrderPayloadSchema = exports_external.object({
306221
306225
  orderType: exports_external.enum(["market", "limit"]).default("limit"),
306226
+ orderIntent: exports_external.enum(["passive_only"]).optional(),
306222
306227
  amount: exports_external.coerce.number().positive(),
306223
306228
  fromToken: exports_external.string().min(1),
306224
306229
  toToken: exports_external.string().min(1),
306225
306230
  price: exports_external.coerce.number().positive(),
306226
306231
  marketType: marketTypeSchema,
306227
306232
  clientOrderId: exports_external.string().min(1).optional(),
306233
+ orderAuthor: exports_external.string().min(1).optional(),
306228
306234
  params: exports_external.preprocess(parseJsonString, stringNumberRecordSchema).default({})
306229
306235
  });
306230
306236
  var GetPerpConfigStatePayloadSchema = exports_external.object({
@@ -306306,6 +306312,12 @@ function stableGrpcErrorCode(message) {
306306
306312
  if (message.startsWith("deposit_amount_mismatch:")) {
306307
306313
  return grpc2.status.FAILED_PRECONDITION;
306308
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
+ }
306309
306321
  if (message.startsWith("policy_withdrawal_denied:") || message.startsWith("policy_deposit_denied:")) {
306310
306322
  return grpc2.status.PERMISSION_DENIED;
306311
306323
  }
@@ -306972,6 +306984,33 @@ async function handleInternalTransfer(ctx) {
306972
306984
 
306973
306985
  // src/handlers/execute-action/orders.ts
306974
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
306975
307014
  async function handleCreateOrder(ctx) {
306976
307015
  const {
306977
307016
  call,
@@ -306996,14 +307035,23 @@ async function handleCreateOrder(ctx) {
306996
307035
  const orderValue = parsePayloadForAction(ctx, CreateOrderPayloadSchema);
306997
307036
  if (orderValue === null)
306998
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
+ }
306999
307045
  const createOrderParams = {
307000
307046
  ...orderValue.params,
307001
307047
  ...orderValue.clientOrderId !== undefined && {
307002
307048
  clientOrderId: orderValue.clientOrderId
307003
- }
307049
+ },
307050
+ ...isPassiveOrder && { postOnly: true }
307004
307051
  };
307005
307052
  let resolvedOrderTelemetry = {};
307006
307053
  let marketMetadataHash;
307054
+ let submission = "not_attempted";
307007
307055
  try {
307008
307056
  if (!broker) {
307009
307057
  return ctx.wrappedCallback({
@@ -307036,7 +307084,9 @@ async function handleCreateOrder(ctx) {
307036
307084
  brokerObservedTimestamp: submissionTimestamp,
307037
307085
  ...telemetryIds
307038
307086
  });
307087
+ submission = "in_flight";
307039
307088
  const order = await broker.createOrder(resolution.symbol, orderValue.orderType, resolution.side, resolution.amountBase ?? orderValue.amount, orderValue.price, createOrderParams);
307089
+ submission = "placed";
307040
307090
  const createOrderContext = {
307041
307091
  action: "CreateOrder",
307042
307092
  cex: cex3,
@@ -307046,12 +307096,20 @@ async function handleCreateOrder(ctx) {
307046
307096
  orderType: orderValue.orderType,
307047
307097
  requestedQuantity: resolvedOrderTelemetry.requestedQuantity,
307048
307098
  requestedNotional: orderValue.amount * orderValue.price,
307099
+ orderAuthor: orderValue.orderAuthor,
307049
307100
  brokerObservedTimestamp: submissionTimestamp,
307050
307101
  ...telemetryIds
307051
307102
  };
307052
307103
  emitOrderExecutionTelemetryInBackground(otelMetrics, createOrderContext, order);
307053
307104
  archiveOrderExecutionInBackground(brokerArchiver, createOrderContext, order, undefined, { marketMetadataHash });
307054
- ctx.wrappedCallback(null, { result: JSON.stringify({ ...order }) });
307105
+ ctx.wrappedCallback(null, {
307106
+ result: JSON.stringify({
307107
+ ...order,
307108
+ ...isPassiveOrder && {
307109
+ passivePlacementOutcome: "accepted_passive"
307110
+ }
307111
+ })
307112
+ });
307055
307113
  } catch (error48) {
307056
307114
  rethrowArchiveDurabilityError(error48);
307057
307115
  safeLogRedactedError("Order Creation failed", error48);
@@ -307064,10 +307122,18 @@ async function handleCreateOrder(ctx) {
307064
307122
  orderType: orderValue.orderType,
307065
307123
  requestedQuantity: resolvedOrderTelemetry.requestedQuantity ?? orderValue.amount,
307066
307124
  requestedNotional: orderValue.amount * orderValue.price,
307125
+ orderAuthor: orderValue.orderAuthor,
307067
307126
  ...extractOrderTelemetryIds(createOrderParams)
307068
307127
  };
307069
307128
  emitOrderExecutionTelemetryInBackground(otelMetrics, failedCreateContext, undefined, error48);
307070
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
+ }
307071
307137
  ctx.wrappedCallback({
307072
307138
  code: grpc6.status.INTERNAL,
307073
307139
  message: `Order Creation failed: ${sanitizeErrorDetail(error48)}`
@@ -307805,6 +307871,7 @@ async function handleTreasuryCall(ctx) {
307805
307871
  side: asNonEmptyString(side),
307806
307872
  requestedQuantity,
307807
307873
  requestedNotional,
307874
+ orderAuthor: callValue.orderAuthor,
307808
307875
  brokerObservedTimestamp: submissionTimestamp,
307809
307876
  ...telemetryIds
307810
307877
  };
@@ -307917,6 +307984,8 @@ async function handleWithdraw(ctx) {
307917
307984
  message: `travel_rule_denied: ${travelRule.error}`
307918
307985
  }, null);
307919
307986
  }
307987
+ const withdrawOrderId = transferValue.params.withdrawOrderId;
307988
+ const clientWithdrawalId = typeof withdrawOrderId === "string" && withdrawOrderId.length > 0 ? withdrawOrderId : undefined;
307920
307989
  try {
307921
307990
  const transaction = travelRule.mode === "localentity" ? await withdrawViaLocalEntity(broker, {
307922
307991
  code: symbol2,
@@ -307943,6 +308012,7 @@ async function handleWithdraw(ctx) {
307943
308012
  address: normalized.address ?? transferValue.recipientAddress,
307944
308013
  network: normalized.network ?? withdrawNetwork.exchangeNetworkId,
307945
308014
  externalId: normalized.externalId,
308015
+ clientWithdrawalId,
307946
308016
  txid: normalized.txid,
307947
308017
  feeAmount: normalized.feeAmount,
307948
308018
  feeCurrency: normalized.feeCurrency,
@@ -307972,6 +308042,7 @@ async function handleWithdraw(ctx) {
307972
308042
  amount: String(transferValue.amount),
307973
308043
  address: transferValue.recipientAddress,
307974
308044
  network: withdrawNetwork.exchangeNetworkId,
308045
+ clientWithdrawalId,
307975
308046
  errorSummary: getErrorMessage(error48),
307976
308047
  payload: { recipientAddress: transferValue.recipientAddress }
307977
308048
  }
@@ -310180,4 +310251,4 @@ export {
310180
310251
  CEXBroker as default
310181
310252
  };
310182
310253
 
310183
- //# debugId=1AF34CD02AB617AA64756E2164756E21
310254
+ //# debugId=DF7A1B19BD16DBE764756E2164756E21