@usherlabs/cex-broker 0.2.49 → 0.2.50

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.
@@ -335154,6 +335154,24 @@ function selectBrokerAccountForCex(normalizedCex, brokers, metadata) {
335154
335154
  return selectBrokerAccount(brokers[normalizedCex], metadata) ?? undefined;
335155
335155
  }
335156
335156
 
335157
+ // src/helpers/trace-context.ts
335158
+ var TRACE_METADATA_KEY = "x-trace-id";
335159
+ var MAX_TRACE_METADATA_LENGTH = 128;
335160
+ var OTEL_TRACE_ID_PATTERN = /^[0-9a-f]{32}$/;
335161
+ var UUID_V4_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
335162
+ var ZERO_OTEL_TRACE_ID = "00000000000000000000000000000000";
335163
+ function extractTraceId(metadata) {
335164
+ const raw = metadata.get(TRACE_METADATA_KEY)[0];
335165
+ if (typeof raw !== "string" || raw.length > MAX_TRACE_METADATA_LENGTH) {
335166
+ return;
335167
+ }
335168
+ const traceId = raw.trim();
335169
+ if (OTEL_TRACE_ID_PATTERN.test(traceId) && traceId !== ZERO_OTEL_TRACE_ID || UUID_V4_PATTERN.test(traceId)) {
335170
+ return traceId;
335171
+ }
335172
+ return;
335173
+ }
335174
+
335157
335175
  // src/handlers/execute-action/order-book-call.ts
335158
335176
  var grpc4 = __toESM(require_src3(), 1);
335159
335177
  async function handleOrderBookCall(ctx) {
@@ -336457,6 +336475,15 @@ function isPublicMarketDataAction(action, payload) {
336457
336475
  return false;
336458
336476
  return isOrderBookCallMethod(payload?.method ?? payload?.functionName);
336459
336477
  }
336478
+ function grpcStatusName(error48) {
336479
+ if (!error48) {
336480
+ return "OK";
336481
+ }
336482
+ if (typeof error48.code !== "number") {
336483
+ return "UNKNOWN";
336484
+ }
336485
+ return grpc12.status[error48.code] ?? "UNKNOWN";
336486
+ }
336460
336487
  function createExecuteActionHandler(deps) {
336461
336488
  const {
336462
336489
  policy,
@@ -336473,12 +336500,28 @@ function createExecuteActionHandler(deps) {
336473
336500
  const startTime = Date.now();
336474
336501
  const { action: rawAction, cex: cex3, symbol: symbol2 } = call.request;
336475
336502
  const action = resolveAction(rawAction);
336503
+ const actionName = getActionName(action);
336504
+ const operationalCex = cex3?.trim().toLowerCase() || "unknown";
336505
+ const traceId = extractTraceId(call.metadata);
336506
+ const traceFields = traceId === undefined ? {} : { trace_id: traceId };
336476
336507
  let actionCompleted = false;
336477
336508
  const wrappedCallback = (error48, value) => {
336478
336509
  if (!actionCompleted) {
336479
336510
  actionCompleted = true;
336480
336511
  const latency = Date.now() - startTime;
336481
- const actionName = getActionName(action);
336512
+ const terminalFields = {
336513
+ action: actionName,
336514
+ cex: operationalCex,
336515
+ latency_ms: latency,
336516
+ outcome: error48 ? "error" : "success",
336517
+ grpc_status: grpcStatusName(error48),
336518
+ ...traceFields
336519
+ };
336520
+ if (error48) {
336521
+ log.withMetadata(terminalFields).error("ExecuteAction failed");
336522
+ } else {
336523
+ log.withMetadata(terminalFields).info("ExecuteAction completed");
336524
+ }
336482
336525
  otelMetrics?.recordHistogram("execute_action_duration_ms", latency, {
336483
336526
  action: actionName,
336484
336527
  cex: cex3 || "unknown"
@@ -336499,9 +336542,13 @@ function createExecuteActionHandler(deps) {
336499
336542
  callback(error48, value);
336500
336543
  };
336501
336544
  try {
336502
- log.info(`Request - ExecuteAction:`, { action, cex: cex3, symbol: symbol2 });
336545
+ log.withMetadata({
336546
+ action: actionName,
336547
+ cex: operationalCex,
336548
+ ...traceFields
336549
+ }).info("ExecuteAction started");
336503
336550
  otelMetrics?.recordCounter("execute_action_requests_total", 1, {
336504
- action: getActionName(action),
336551
+ action: actionName,
336505
336552
  cex: cex3 || "unknown"
336506
336553
  });
336507
336554
  if (!authenticateRequest(call, whitelistIps)) {
@@ -336739,6 +336786,9 @@ async function writeSubscribeError(call, isClosed, frame) {
336739
336786
  call.end();
336740
336787
  }
336741
336788
  }
336789
+ function grpcStatusName2(status14) {
336790
+ return typeof status14 === "number" ? grpc13.status[status14] ?? "UNKNOWN" : "UNKNOWN";
336791
+ }
336742
336792
  function getBinanceEventMarketId(event) {
336743
336793
  const value = event.s;
336744
336794
  return typeof value === "string" ? value : null;
@@ -336871,6 +336921,24 @@ function createSubscribeHandler(deps) {
336871
336921
  });
336872
336922
  return async (call) => {
336873
336923
  const subscribeStartTime = Date.now();
336924
+ const request = call.request;
336925
+ const { cex: cex3, symbol: symbol2, type: type2 } = request;
336926
+ const metadata = call.metadata;
336927
+ const traceId = extractTraceId(metadata);
336928
+ const traceFields = traceId === undefined ? {} : { trace_id: traceId };
336929
+ const operationalCex = cex3?.trim().toLowerCase() || "unknown";
336930
+ const operationalSymbol = symbol2?.trim() || "unknown";
336931
+ const subscriptionType2 = resolveSubscriptionType(type2);
336932
+ const subscriptionTypeName = getSubscriptionTypeName(subscriptionType2);
336933
+ const operationalFields = {
336934
+ cex: operationalCex,
336935
+ symbol: operationalSymbol,
336936
+ subscription_type: subscriptionTypeName,
336937
+ ...traceFields
336938
+ };
336939
+ let terminalLogged = false;
336940
+ let terminalOutcome = "completed";
336941
+ let terminalGrpcStatus = "OK";
336874
336942
  let streamClosed = false;
336875
336943
  let ownedBroker = null;
336876
336944
  let ownedBrokerClosePromise;
@@ -336893,12 +336961,41 @@ function createSubscribeHandler(deps) {
336893
336961
  const closeOwnedBrokerOnCallEnd = () => {
336894
336962
  closeOwnedBroker();
336895
336963
  };
336896
- call.once("cancelled", markStreamClosed);
336964
+ const logTerminalOutcome = (outcome) => {
336965
+ if (terminalLogged) {
336966
+ return;
336967
+ }
336968
+ terminalLogged = true;
336969
+ const fields = {
336970
+ ...operationalFields,
336971
+ duration_ms: Date.now() - subscribeStartTime,
336972
+ outcome,
336973
+ grpc_status: outcome === "cancelled" ? "CANCELLED" : terminalGrpcStatus
336974
+ };
336975
+ if (outcome === "error") {
336976
+ log.withMetadata(fields).error("Subscribe failed");
336977
+ } else if (outcome === "cancelled") {
336978
+ log.withMetadata(fields).info("Subscribe cancelled");
336979
+ } else {
336980
+ log.withMetadata(fields).info("Subscribe ended");
336981
+ }
336982
+ };
336983
+ const writeTerminalError = async (frame, status14 = grpc13.status.UNKNOWN) => {
336984
+ terminalOutcome = "error";
336985
+ terminalGrpcStatus = grpcStatusName2(status14);
336986
+ await writeSubscribeError(call, isStreamClosed, frame);
336987
+ };
336988
+ log.withMetadata(operationalFields).info("Subscribe started");
336989
+ call.once("cancelled", () => {
336990
+ terminalGrpcStatus = "CANCELLED";
336991
+ markStreamClosed();
336992
+ logTerminalOutcome("cancelled");
336993
+ });
336897
336994
  call.once("cancelled", closeOwnedBrokerOnCallEnd);
336898
336995
  call.once("error", closeOwnedBrokerOnCallEnd);
336899
336996
  call.once("end", () => {
336900
336997
  markStreamClosed();
336901
- log.info("Subscribe stream ended");
336998
+ logTerminalOutcome(terminalOutcome);
336902
336999
  const duration3 = Date.now() - subscribeStartTime;
336903
337000
  otelMetrics?.recordHistogram("subscribe_duration_ms", duration3, {
336904
337001
  cex: call.request?.cex || "unknown",
@@ -336907,12 +337004,16 @@ function createSubscribeHandler(deps) {
336907
337004
  });
336908
337005
  call.once("error", (error48) => {
336909
337006
  markStreamClosed();
336910
- log.error("Subscribe stream error:", error48);
337007
+ terminalOutcome = "error";
337008
+ terminalGrpcStatus = grpcStatusName2(typeof error48 === "object" && error48 !== null && "code" in error48 ? error48.code : undefined);
337009
+ logTerminalOutcome(call.cancelled ? "cancelled" : "error");
336911
337010
  otelMetrics?.recordCounter("subscribe_errors_total", 1, {
336912
337011
  error_type: error48 instanceof Error ? error48.message : "unknown"
336913
337012
  });
336914
337013
  });
336915
337014
  if (!authenticateRequest(call, whitelistIps)) {
337015
+ terminalOutcome = "error";
337016
+ terminalGrpcStatus = "PERMISSION_DENIED";
336916
337017
  otelMetrics?.recordCounter("subscribe_errors_total", 1, {
336917
337018
  error_type: "permission_denied"
336918
337019
  });
@@ -336923,32 +337024,22 @@ function createSubscribeHandler(deps) {
336923
337024
  call.destroy(new Error("Access denied: Unauthorized IP"));
336924
337025
  return;
336925
337026
  }
336926
- const metadata = call.metadata;
336927
- let subscriptionType2 = SubscriptionType.ORDERBOOK;
336928
337027
  try {
336929
- const request = call.request;
336930
- const { cex: cex3, symbol: symbol2, type: type2, options } = request;
336931
- subscriptionType2 = resolveSubscriptionType(type2);
336932
- log.info(`Request - Subscribe:`, {
336933
- cex: request.cex,
336934
- symbol: request.symbol,
336935
- type: subscriptionType2
336936
- });
336937
- const subscriptionTypeName = getSubscriptionTypeName(subscriptionType2);
337028
+ const { options } = request;
336938
337029
  otelMetrics?.recordCounter("subscribe_requests_total", 1, {
336939
337030
  cex: cex3 || "unknown",
336940
337031
  symbol: symbol2 || "unknown",
336941
337032
  type: subscriptionTypeName
336942
337033
  });
336943
337034
  if (!cex3 || !symbol2) {
336944
- await writeSubscribeError(call, isStreamClosed, {
337035
+ await writeTerminalError({
336945
337036
  data: JSON.stringify({
336946
337037
  error: "cex, symbol, and type are required"
336947
337038
  }),
336948
337039
  timestamp: Date.now(),
336949
337040
  symbol: symbol2 || "",
336950
337041
  type: subscriptionType2
336951
- });
337042
+ }, grpc13.status.INVALID_ARGUMENT);
336952
337043
  return;
336953
337044
  }
336954
337045
  if (isPublicMarketDataSubscription(subscriptionType2)) {
@@ -336977,7 +337068,7 @@ function createSubscribeHandler(deps) {
336977
337068
  } catch (error48) {
336978
337069
  const message = getErrorMessage(error48);
336979
337070
  if (!isStreamClosed()) {
336980
- await writeSubscribeError(call, isStreamClosed, {
337071
+ await writeTerminalError({
336981
337072
  data: JSON.stringify({ error: message }),
336982
337073
  timestamp: Date.now(),
336983
337074
  symbol: symbol2,
@@ -336998,14 +337089,14 @@ function createSubscribeHandler(deps) {
336998
337089
  const selectedBroker = selectedBrokerAccount?.exchange ?? createBroker(normalizedCex, metadata);
336999
337090
  const broker = selectedBroker ?? createPublicBroker(normalizedCex);
337000
337091
  if (!broker) {
337001
- await writeSubscribeError(call, isStreamClosed, {
337092
+ await writeTerminalError({
337002
337093
  data: JSON.stringify({
337003
337094
  error: "Exchange not registered and no API metadata found"
337004
337095
  }),
337005
337096
  timestamp: Date.now(),
337006
337097
  symbol: symbol2,
337007
337098
  type: subscriptionType2
337008
- });
337099
+ }, grpc13.status.NOT_FOUND);
337009
337100
  return;
337010
337101
  }
337011
337102
  if (!selectedBrokerAccount) {
@@ -337033,28 +337124,28 @@ function createSubscribeHandler(deps) {
337033
337124
  if (isBinanceSpotAccountSubscription(normalizedCex, subscriptionType2, options?.marketType)) {
337034
337125
  const accountBroker = selectedBrokerAccount?.exchange ?? selectedBroker;
337035
337126
  if (!accountBroker) {
337036
- await writeSubscribeError(call, isStreamClosed, {
337127
+ await writeTerminalError({
337037
337128
  data: JSON.stringify({
337038
337129
  error: "Binance account subscriptions require API credentials"
337039
337130
  }),
337040
337131
  timestamp: Date.now(),
337041
337132
  symbol: resolvedSymbol,
337042
337133
  type: subscriptionType2
337043
- });
337134
+ }, grpc13.status.FAILED_PRECONDITION);
337044
337135
  return;
337045
337136
  }
337046
337137
  const marketId = subscriptionType2 === SubscriptionType.ORDERS ? await getBinanceMarketId(accountBroker, resolvedSymbol) : undefined;
337047
337138
  let userDataSource;
337048
337139
  if (selectedBrokerAccount) {
337049
337140
  if (!userDataStreamSupervisor) {
337050
- await writeSubscribeError(call, isStreamClosed, {
337141
+ await writeTerminalError({
337051
337142
  data: JSON.stringify({
337052
337143
  error: "Configured account user-data supervisor is unavailable"
337053
337144
  }),
337054
337145
  timestamp: Date.now(),
337055
337146
  symbol: resolvedSymbol,
337056
337147
  type: subscriptionType2
337057
- });
337148
+ }, grpc13.status.FAILED_PRECONDITION);
337058
337149
  return;
337059
337150
  }
337060
337151
  userDataSource = userDataStreamSupervisor.subscribe({
@@ -337077,7 +337168,7 @@ function createSubscribeHandler(deps) {
337077
337168
  } catch (error48) {
337078
337169
  const message = getErrorMessage(error48);
337079
337170
  log.error(`Error fetching balance for ${cex3}:`, error48);
337080
- await writeSubscribeError(call, isStreamClosed, {
337171
+ await writeTerminalError({
337081
337172
  data: JSON.stringify({
337082
337173
  error: `Failed to fetch balance: ${message}`
337083
337174
  }),
@@ -337096,7 +337187,7 @@ function createSubscribeHandler(deps) {
337096
337187
  } catch (error48) {
337097
337188
  log.error(`Error fetching orders for ${resolvedSymbol} on ${cex3}:`, error48);
337098
337189
  const message = getErrorMessage(error48);
337099
- await writeSubscribeError(call, isStreamClosed, {
337190
+ await writeTerminalError({
337100
337191
  data: JSON.stringify({
337101
337192
  error: `Failed to fetch orders: ${message}`
337102
337193
  }),
@@ -337107,26 +337198,27 @@ function createSubscribeHandler(deps) {
337107
337198
  }
337108
337199
  break;
337109
337200
  default:
337110
- await writeSubscribeError(call, isStreamClosed, {
337201
+ await writeTerminalError({
337111
337202
  data: JSON.stringify({ error: "Invalid subscription type" }),
337112
337203
  timestamp: Date.now(),
337113
337204
  symbol: symbol2,
337114
337205
  type: subscriptionType2
337115
- });
337206
+ }, grpc13.status.INVALID_ARGUMENT);
337116
337207
  }
337117
337208
  } catch (error48) {
337118
337209
  log.error("Error in Subscribe stream:", error48);
337119
337210
  const message = getErrorMessage(error48);
337120
- await writeSubscribeError(call, isStreamClosed, {
337211
+ await writeTerminalError({
337121
337212
  data: JSON.stringify({ error: `Internal server error: ${message}` }),
337122
337213
  timestamp: Date.now(),
337123
337214
  symbol: "",
337124
337215
  type: subscriptionType2
337125
- });
337216
+ }, grpc13.status.INTERNAL);
337126
337217
  } finally {
337127
337218
  call.off("cancelled", closeOwnedBrokerOnCallEnd);
337128
337219
  call.off("error", closeOwnedBrokerOnCallEnd);
337129
337220
  await closeOwnedBroker();
337221
+ logTerminalOutcome(call.cancelled ? "cancelled" : terminalOutcome);
337130
337222
  }
337131
337223
  };
337132
337224
  }
@@ -25307,7 +25307,8 @@ var result_schema_default = {
25307
25307
  // src/helpers/market-data-vendor-backfill/manifests.ts
25308
25308
  var LEGACY_CAPABILITY_POLICY_ID = "market-data-vendor-backfill-capabilities/v1";
25309
25309
  var CAPABILITY_POLICY_ID = "market-data-vendor-backfill-capabilities/v2";
25310
- var RESOURCE_POLICY_ID = "market-data-vendor-backfill-resources/v1";
25310
+ var LEGACY_RESOURCE_POLICY_ID = "market-data-vendor-backfill-resources/v1";
25311
+ var RESOURCE_POLICY_ID = "market-data-vendor-backfill-resources/v2";
25311
25312
  var ADAPTER_POLICY_ID = "cryptohftdata-orderbook-adapter/v1";
25312
25313
  var ACQUISITION_POLICY_ID = "cryptohftdata-hourly-acquisition/v1";
25313
25314
  var legacyCapabilityPolicyContent = {
@@ -25344,17 +25345,30 @@ var LEGACY_CAPABILITY_POLICY = Object.freeze({
25344
25345
  var capabilityPolicyContent = {
25345
25346
  ...legacyCapabilityPolicyContent,
25346
25347
  policy_id: CAPABILITY_POLICY_ID,
25347
- profiles: legacyCapabilityPolicyContent.profiles.map((profile) => ({
25348
- ...profile,
25349
- source_policies: ["authoritative_window", "fill_gaps"]
25350
- }))
25348
+ profiles: [
25349
+ ...legacyCapabilityPolicyContent.profiles.map((profile) => ({
25350
+ ...profile,
25351
+ source_policies: ["authoritative_window", "fill_gaps"]
25352
+ })),
25353
+ {
25354
+ exchange: "okx",
25355
+ market_type: "spot",
25356
+ feed: "ORDERBOOK",
25357
+ canonical_trading_pair: "ARB-USDC",
25358
+ provider_exchange_id: "okx_spot",
25359
+ resolved_symbol: "ARB-USDC",
25360
+ construction_modes: ["sampled_top_n_snapshot"],
25361
+ source_policies: ["authoritative_window", "fill_gaps"],
25362
+ max_depth: 400
25363
+ }
25364
+ ]
25351
25365
  };
25352
25366
  var CAPABILITY_POLICY = Object.freeze({
25353
25367
  ...capabilityPolicyContent,
25354
25368
  policy_sha256: jcsSha256(capabilityPolicyContent)
25355
25369
  });
25356
- var resourcePolicyContent = {
25357
- policy_id: RESOURCE_POLICY_ID,
25370
+ var legacyResourcePolicyContent = {
25371
+ policy_id: LEGACY_RESOURCE_POLICY_ID,
25358
25372
  limits: {
25359
25373
  max_files: 1e4,
25360
25374
  max_bytes: 100 * 1024 * 1024 * 1024,
@@ -25368,6 +25382,18 @@ var resourcePolicyContent = {
25368
25382
  max_required_events: 1e5
25369
25383
  }
25370
25384
  };
25385
+ var LEGACY_RESOURCE_POLICY = Object.freeze({
25386
+ ...legacyResourcePolicyContent,
25387
+ policy_sha256: jcsSha256(legacyResourcePolicyContent)
25388
+ });
25389
+ var resourcePolicyContent = {
25390
+ ...legacyResourcePolicyContent,
25391
+ policy_id: RESOURCE_POLICY_ID,
25392
+ request_bounds: {
25393
+ ...legacyResourcePolicyContent.request_bounds,
25394
+ max_window_ms: 31 * 24 * 60 * 60 * 1000
25395
+ }
25396
+ };
25371
25397
  var RESOURCE_POLICY = Object.freeze({
25372
25398
  ...resourcePolicyContent,
25373
25399
  policy_sha256: jcsSha256(resourcePolicyContent)
@@ -25546,7 +25572,11 @@ var backfillRequestCodec = {
25546
25572
  CAPABILITY_POLICY,
25547
25573
  LEGACY_CAPABILITY_POLICY
25548
25574
  ].some((policy) => request.product_pins.capability_policy.policy_id === policy.policy_id && request.product_pins.capability_policy.policy_sha256 === policy.policy_sha256);
25549
- if (!capabilityPolicyMatches || request.product_pins.resource_policy.policy_id !== RESOURCE_POLICY.policy_id || request.product_pins.resource_policy.policy_sha256 !== RESOURCE_POLICY.policy_sha256) {
25575
+ const resourcePolicyMatches = [
25576
+ RESOURCE_POLICY,
25577
+ LEGACY_RESOURCE_POLICY
25578
+ ].some((policy) => request.product_pins.resource_policy.policy_id === policy.policy_id && request.product_pins.resource_policy.policy_sha256 === policy.policy_sha256);
25579
+ if (!capabilityPolicyMatches || !resourcePolicyMatches) {
25550
25580
  throw new Error("request policy pins do not match the effective package policies");
25551
25581
  }
25552
25582
  if (request.required_clock.clock_id !== request.initial_selection.required_clock.clock_id || request.required_clock.clock_sha256 !== request.initial_selection.required_clock.clock_sha256 || request.required_clock.event_count !== request.initial_selection.required_clock.event_count) {
@@ -25661,6 +25691,10 @@ function decodeBackfillRunDocuments(input) {
25661
25691
  return targetTimeMs;
25662
25692
  });
25663
25693
  const capabilityProfile = CAPABILITY_POLICY.profiles.find((profile) => profile.exchange === wire.scope.exchange && profile.market_type === wire.scope.market_type && profile.feed === wire.scope.feed && profile.canonical_trading_pair === wire.scope.trading_pair);
25694
+ const resourcePolicy = [RESOURCE_POLICY, LEGACY_RESOURCE_POLICY].find((policy) => wire.product_pins.resource_policy.policy_id === policy.policy_id && wire.product_pins.resource_policy.policy_sha256 === policy.policy_sha256);
25695
+ if (!resourcePolicy) {
25696
+ throw new Error("request resource policy pin is unsupported");
25697
+ }
25664
25698
  return {
25665
25699
  schemaVersion: BACKFILL_REQUEST_SCHEMA_VERSION,
25666
25700
  requestId: wire.request_id,
@@ -25685,11 +25719,11 @@ function decodeBackfillRunDocuments(input) {
25685
25719
  maxPriorAsOfLagMs: wire.coverage_policy.max_asof_lag_ms,
25686
25720
  sourcePolicy: wire.source_policy,
25687
25721
  budgets: {
25688
- maxFiles: RESOURCE_POLICY.limits.max_files,
25689
- maxBytes: RESOURCE_POLICY.limits.max_bytes,
25690
- maxRows: RESOURCE_POLICY.limits.max_rows,
25691
- maxDurationMs: RESOURCE_POLICY.limits.max_duration_ms,
25692
- maxBoundaryLookbackMs: Math.min(RESOURCE_POLICY.limits.max_boundary_lookback_ms, CAPABILITY_POLICY.acquisition_policy.initialization_lookback_ms)
25722
+ maxFiles: resourcePolicy.limits.max_files,
25723
+ maxBytes: resourcePolicy.limits.max_bytes,
25724
+ maxRows: resourcePolicy.limits.max_rows,
25725
+ maxDurationMs: resourcePolicy.limits.max_duration_ms,
25726
+ maxBoundaryLookbackMs: Math.min(resourcePolicy.limits.max_boundary_lookback_ms, CAPABILITY_POLICY.acquisition_policy.initialization_lookback_ms)
25693
25727
  },
25694
25728
  expectedProduct: {
25695
25729
  packageName: "@usherlabs/cex-broker",
@@ -31766,6 +31800,22 @@ var CRYPTOHFTDATA_OKX_SPOT_ARBUSDT_PROFILE = Object.freeze({
31766
31800
  constructionModes: ["sampled_top_n_snapshot"],
31767
31801
  sourcePolicies: ["authoritative_window", "fill_gaps"]
31768
31802
  });
31803
+ var CRYPTOHFTDATA_OKX_SPOT_ARBUSDC_PROFILE = Object.freeze({
31804
+ profileId: "cryptohftdata/okx_spot/ARB-USDC/v1",
31805
+ exchange: "okx",
31806
+ tradingPair: "ARB-USDC",
31807
+ sourceSymbol: "ARB-USDC",
31808
+ marketType: "spot",
31809
+ providerExchangeId: "okx_spot",
31810
+ historyStartMs: CRYPTOHFTDATA_HISTORY_START_MS,
31811
+ maxDepth: 400,
31812
+ eventTimeUnit: "milliseconds",
31813
+ receivedTimeUnit: "nanoseconds",
31814
+ snapshotGrouping: "event_time_final_update_id_object",
31815
+ sequenceSemantics: "okx_seq_id_prev_seq_id",
31816
+ constructionModes: ["sampled_top_n_snapshot"],
31817
+ sourcePolicies: ["authoritative_window", "fill_gaps"]
31818
+ });
31769
31819
 
31770
31820
  class CryptoHftDataError extends Error {
31771
31821
  reason;
@@ -32511,7 +32561,10 @@ function assertForwarderPreflight(request, resolution, nowMs) {
32511
32561
  }
32512
32562
  }
32513
32563
  function resourcePolicyScopeExceeded(request) {
32514
- return request.depth > RESOURCE_POLICY.request_bounds.max_depth || request.window.endTimeMs - request.window.startTimeMs > RESOURCE_POLICY.request_bounds.max_window_ms || request.requiredClockTargetsMs.length > RESOURCE_POLICY.request_bounds.max_required_events;
32564
+ const policy = [RESOURCE_POLICY, LEGACY_RESOURCE_POLICY].find((candidate) => request.productPins?.resource_policy.policy_id === candidate.policy_id && request.productPins.resource_policy.policy_sha256 === candidate.policy_sha256);
32565
+ if (!policy)
32566
+ return true;
32567
+ return request.depth > policy.request_bounds.max_depth || request.window.endTimeMs - request.window.startTimeMs > policy.request_bounds.max_window_ms || request.requiredClockTargetsMs.length > policy.request_bounds.max_required_events;
32515
32568
  }
32516
32569
  function storedReceiptForSelection(resolution) {
32517
32570
  const receiptId = resolution.selection.receipt_ids[0];
@@ -32802,8 +32855,8 @@ function validateReleaseIdentity(release) {
32802
32855
  return release;
32803
32856
  }
32804
32857
  function bakedReleaseIdentity() {
32805
- const packageVersion = "0.2.49";
32806
- const gitHead = "c1ffe071e7696c5b17c8f058da01d61cb27ec8a4";
32858
+ const packageVersion = "0.2.50";
32859
+ const gitHead = "41dbe7cc296da1c5a7964dca8f418800522f27e5";
32807
32860
  return validateReleaseIdentity({ packageVersion, gitHead });
32808
32861
  }
32809
32862
  function readOptionalEnvironment(environment, name) {
@@ -32827,7 +32880,10 @@ function createBackfillDependenciesFromEnv(environment, sensitiveValues = new Se
32827
32880
  password: clickhousePassword
32828
32881
  })),
32829
32882
  providers: new CryptoHftDataAdapter({
32830
- profiles: [CRYPTOHFTDATA_OKX_SPOT_ARBUSDT_PROFILE]
32883
+ profiles: [
32884
+ CRYPTOHFTDATA_OKX_SPOT_ARBUSDC_PROFILE,
32885
+ CRYPTOHFTDATA_OKX_SPOT_ARBUSDT_PROFILE
32886
+ ]
32831
32887
  }),
32832
32888
  forwarder: createArchiveForwarderClient({
32833
32889
  url: forwarderUrl,
@@ -33034,4 +33090,4 @@ export {
33034
33090
  createBackfillDependenciesFromEnv
33035
33091
  };
33036
33092
 
33037
- //# debugId=793AA74075FC03DE64756E2164756E21
33093
+ //# debugId=7BCBC113F3C0009864756E2164756E21