@agg-build/ui 1.2.7 → 1.2.9
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/{chunk-5FXMHTVR.mjs → chunk-5MDFM2MX.mjs} +1 -1
- package/dist/{chunk-TBKDLNOE.mjs → chunk-5PSAIGOT.mjs} +29 -8
- package/dist/{chunk-WPF47BQQ.mjs → chunk-7JKGAWU5.mjs} +9 -2
- package/dist/{chunk-3RG2K7MV.mjs → chunk-K23CJ5UP.mjs} +666 -148
- package/dist/{chunk-E45WOOMN.mjs → chunk-PFOSEY46.mjs} +22 -8
- package/dist/{chunk-QMWKXDVZ.mjs → chunk-PYKD4W4T.mjs} +18 -12
- package/dist/{chunk-34L7ZKJW.mjs → chunk-QFW5NDJ6.mjs} +7 -10
- package/dist/events.js +55 -23
- package/dist/events.mjs +3 -3
- package/dist/index.js +777 -207
- package/dist/index.mjs +28 -21
- package/dist/modals.js +12 -9
- package/dist/modals.mjs +3 -3
- package/dist/pages.js +740 -184
- package/dist/pages.mjs +6 -6
- package/dist/primitives.js +7 -10
- package/dist/primitives.mjs +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +669 -154
- package/dist/trading.mjs +4 -4
- package/dist/types/primitives/switch-button/switch-button.constants.d.mts +1 -1
- package/dist/types/primitives/switch-button/switch-button.constants.d.ts +1 -1
- package/dist/types/primitives/tooltip/index.d.mts +1 -1
- package/dist/types/primitives/tooltip/index.d.ts +1 -1
- package/dist/types/primitives/tooltip/tooltip.types.d.mts +2 -0
- package/dist/types/primitives/tooltip/tooltip.types.d.ts +2 -0
- package/dist/types/trading/place-order/index.place-order.execution-debug.d.mts +183 -0
- package/dist/types/trading/place-order/index.place-order.execution-debug.d.ts +183 -0
- package/dist/types/trading/place-order/index.place-order.execution-steps.d.mts +72 -0
- package/dist/types/trading/place-order/index.place-order.execution-steps.d.ts +72 -0
- package/package.json +1 -1
package/dist/trading.js
CHANGED
|
@@ -2863,7 +2863,7 @@ var HourglassStartIcon = (_a) => {
|
|
|
2863
2863
|
__spreadProps(__spreadValues(__spreadValues({
|
|
2864
2864
|
width: "16",
|
|
2865
2865
|
height: "16",
|
|
2866
|
-
viewBox: "0 0
|
|
2866
|
+
viewBox: "0 0 10 10",
|
|
2867
2867
|
fill: "none",
|
|
2868
2868
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2869
2869
|
className
|
|
@@ -2873,14 +2873,10 @@ var HourglassStartIcon = (_a) => {
|
|
|
2873
2873
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
2874
2874
|
"path",
|
|
2875
2875
|
{
|
|
2876
|
-
d: "
|
|
2877
|
-
|
|
2878
|
-
strokeWidth: "1.4",
|
|
2879
|
-
strokeLinecap: "round",
|
|
2880
|
-
strokeLinejoin: "round"
|
|
2876
|
+
d: "M8.7324 1.90708C8.80282 1.43542 8.66324 0.95625 8.3499 0.5925C8.03115 0.2225 7.56907 0.0108337 7.08157 0.0108337H2.91907C2.43157 0.0108337 1.96949 0.223334 1.65115 0.593334C1.3374 0.9575 1.19824 1.43667 1.26907 1.90875C1.43824 3.03333 2.05449 4.07458 3.10282 5.01042C2.05407 5.94625 1.43782 6.9875 1.26907 8.11208C1.19824 8.58417 1.33782 9.06333 1.65115 9.4275C1.96949 9.79792 2.43199 10.0096 2.91907 10.0096H7.08157C7.56907 10.0096 8.03115 9.79792 8.3499 9.42792C8.66324 9.06417 8.80282 8.585 8.7324 8.11375C8.56449 6.99292 7.9474 5.95083 6.89657 5.01C7.9474 4.06917 8.56449 3.0275 8.7324 1.90708ZM7.46949 1.83333C7.05949 2.84667 6.19824 3.67583 5.54907 4.1925L5.26157 4.42208C5.10949 4.54292 4.8949 4.54292 4.74282 4.42292L4.44949 4.19C3.80074 3.67708 2.94157 2.85167 2.53074 1.83333C2.47865 1.70458 2.49449 1.55917 2.57157 1.44417C2.64907 1.32958 2.77865 1.26083 2.91699 1.26083H7.08365C7.2224 1.26083 7.35199 1.32917 7.42907 1.44417C7.50657 1.55875 7.52157 1.705 7.46949 1.83333ZM5.0299 3.54083L5.00074 3.56417L4.96657 3.53708C4.53032 3.19208 3.9874 2.69167 3.60365 2.09458H6.39615C6.01115 2.69 5.4674 3.19292 5.03032 3.54125L5.0299 3.54083Z",
|
|
2877
|
+
fill: "currentColor"
|
|
2881
2878
|
}
|
|
2882
|
-
)
|
|
2883
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { d: "M6.75 4.25H9.25L8 5.25L6.75 4.25Z", fill: "currentColor" })
|
|
2879
|
+
)
|
|
2884
2880
|
]
|
|
2885
2881
|
})
|
|
2886
2882
|
);
|
|
@@ -5623,6 +5619,7 @@ var Tooltip = ({
|
|
|
5623
5619
|
side = "top",
|
|
5624
5620
|
delayDuration = 150,
|
|
5625
5621
|
collisionPadding = 12,
|
|
5622
|
+
sideOffset = 0,
|
|
5626
5623
|
classNames,
|
|
5627
5624
|
"aria-label": ariaLabel
|
|
5628
5625
|
}) => {
|
|
@@ -5650,7 +5647,7 @@ var Tooltip = ({
|
|
|
5650
5647
|
TooltipPrimitive.Content,
|
|
5651
5648
|
{
|
|
5652
5649
|
side,
|
|
5653
|
-
sideOffset
|
|
5650
|
+
sideOffset,
|
|
5654
5651
|
collisionPadding,
|
|
5655
5652
|
className: cn(
|
|
5656
5653
|
"group/agg-tooltip",
|
|
@@ -5832,6 +5829,447 @@ var PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES = {
|
|
|
5832
5829
|
inactive: "border-transparent bg-agg-secondary-hover font-agg-normal text-agg-foreground hover:bg-agg-tertiary"
|
|
5833
5830
|
};
|
|
5834
5831
|
|
|
5832
|
+
// src/trading/place-order/index.place-order.execution-steps.ts
|
|
5833
|
+
var import_sdk14 = require("@agg-build/sdk");
|
|
5834
|
+
var WAIT_STEP_TYPES = /* @__PURE__ */ new Set(["_wait", "wait"]);
|
|
5835
|
+
var CHECKING_BALANCE_STEP_TYPES = /* @__PURE__ */ new Set([
|
|
5836
|
+
"check-balance",
|
|
5837
|
+
"check-position",
|
|
5838
|
+
"position-reserve",
|
|
5839
|
+
"position-release"
|
|
5840
|
+
]);
|
|
5841
|
+
var VENUE_BUY_SELL_REGEX = /^(?:buy|sell)-([a-z]+)$/;
|
|
5842
|
+
var VENUE_FINALIZE_REGEX = /^([a-z]+)-finalize$/;
|
|
5843
|
+
var VENUE_NAME_MAP = {
|
|
5844
|
+
kalshi: import_sdk14.Venue.kalshi,
|
|
5845
|
+
polymarket: import_sdk14.Venue.polymarket,
|
|
5846
|
+
limitless: import_sdk14.Venue.limitless,
|
|
5847
|
+
opinion: import_sdk14.Venue.opinion,
|
|
5848
|
+
predict: import_sdk14.Venue.predict,
|
|
5849
|
+
probable: import_sdk14.Venue.probable,
|
|
5850
|
+
myriad: import_sdk14.Venue.myriad,
|
|
5851
|
+
hyperliquid: import_sdk14.Venue.hyperliquid
|
|
5852
|
+
};
|
|
5853
|
+
var parseVenueName = (raw) => VENUE_NAME_MAP[raw];
|
|
5854
|
+
var NON_VENUE_FINALIZE_PREFIXES = /* @__PURE__ */ new Set(["bridge"]);
|
|
5855
|
+
var classifyExecutionStepType = (stepType) => {
|
|
5856
|
+
if (!stepType) return null;
|
|
5857
|
+
if (WAIT_STEP_TYPES.has(stepType)) return null;
|
|
5858
|
+
if (CHECKING_BALANCE_STEP_TYPES.has(stepType)) {
|
|
5859
|
+
return { kind: "checking-balance" };
|
|
5860
|
+
}
|
|
5861
|
+
const buySellMatch = stepType.match(VENUE_BUY_SELL_REGEX);
|
|
5862
|
+
if (buySellMatch) {
|
|
5863
|
+
const venue = parseVenueName(buySellMatch[1]);
|
|
5864
|
+
if (venue) return { kind: "executing-venue", venue };
|
|
5865
|
+
}
|
|
5866
|
+
const finalizeMatch = stepType.match(VENUE_FINALIZE_REGEX);
|
|
5867
|
+
if (finalizeMatch && !NON_VENUE_FINALIZE_PREFIXES.has(finalizeMatch[1])) {
|
|
5868
|
+
const venue = parseVenueName(finalizeMatch[1]);
|
|
5869
|
+
if (venue) return { kind: "executing-venue", venue };
|
|
5870
|
+
}
|
|
5871
|
+
if (stepType === "submit-verify-order-status") {
|
|
5872
|
+
return null;
|
|
5873
|
+
}
|
|
5874
|
+
return { kind: "submitting" };
|
|
5875
|
+
};
|
|
5876
|
+
var buildPhaseTimeline = (dag) => {
|
|
5877
|
+
const timeline = [];
|
|
5878
|
+
const completed = new Set(dag.completedSequences);
|
|
5879
|
+
for (let seq = 1; seq <= dag.totalSteps; seq++) {
|
|
5880
|
+
const stepType = dag.stepTypes[seq];
|
|
5881
|
+
if (!stepType) continue;
|
|
5882
|
+
const classified = classifyExecutionStepType(stepType);
|
|
5883
|
+
if (!classified) continue;
|
|
5884
|
+
const isCompleted = completed.has(seq);
|
|
5885
|
+
const last = timeline[timeline.length - 1];
|
|
5886
|
+
if (last && last.kind === classified.kind && last.venue === classified.venue) {
|
|
5887
|
+
last.lastSeq = seq;
|
|
5888
|
+
last.allCompleted = last.allCompleted && isCompleted;
|
|
5889
|
+
continue;
|
|
5890
|
+
}
|
|
5891
|
+
timeline.push({
|
|
5892
|
+
kind: classified.kind,
|
|
5893
|
+
venue: classified.venue,
|
|
5894
|
+
firstSeq: seq,
|
|
5895
|
+
lastSeq: seq,
|
|
5896
|
+
allCompleted: isCompleted
|
|
5897
|
+
});
|
|
5898
|
+
}
|
|
5899
|
+
return timeline;
|
|
5900
|
+
};
|
|
5901
|
+
var phaseRowId = (phase) => phase.venue ? `${phase.kind}:${phase.venue}` : phase.kind;
|
|
5902
|
+
var phaseRowLabel = (phase, labels) => {
|
|
5903
|
+
switch (phase.kind) {
|
|
5904
|
+
case "finding-route":
|
|
5905
|
+
return labels.findingBestRoute;
|
|
5906
|
+
case "checking-balance":
|
|
5907
|
+
return labels.checkingBalance;
|
|
5908
|
+
case "submitting":
|
|
5909
|
+
return labels.submittingOrderProgress;
|
|
5910
|
+
case "wallet-confirm":
|
|
5911
|
+
return labels.confirmTransactionInWallet;
|
|
5912
|
+
case "executing-venue":
|
|
5913
|
+
return labels.executingOnVenue(getTradingVenueLabel(phase.venue));
|
|
5914
|
+
case "filled":
|
|
5915
|
+
return labels.executionConfirmed;
|
|
5916
|
+
case "failed":
|
|
5917
|
+
return labels.orderFailureTitle;
|
|
5918
|
+
}
|
|
5919
|
+
};
|
|
5920
|
+
var buildSubmissionDisplayRows = ({
|
|
5921
|
+
phase,
|
|
5922
|
+
dagProgress,
|
|
5923
|
+
executionVenue,
|
|
5924
|
+
isAwaitingWalletConfirmation,
|
|
5925
|
+
labels
|
|
5926
|
+
}) => {
|
|
5927
|
+
if (phase === "finding-route") {
|
|
5928
|
+
return [
|
|
5929
|
+
{
|
|
5930
|
+
id: "finding-route",
|
|
5931
|
+
label: labels.findingBestRoute,
|
|
5932
|
+
status: "pending"
|
|
5933
|
+
}
|
|
5934
|
+
];
|
|
5935
|
+
}
|
|
5936
|
+
const rows = [
|
|
5937
|
+
{
|
|
5938
|
+
id: "finding-route",
|
|
5939
|
+
label: labels.findingBestRoute,
|
|
5940
|
+
status: "complete"
|
|
5941
|
+
}
|
|
5942
|
+
];
|
|
5943
|
+
const pushPhase = (phaseEntry, status) => {
|
|
5944
|
+
const id = phaseRowId(phaseEntry);
|
|
5945
|
+
if (rows.some((row) => row.id === id)) return;
|
|
5946
|
+
rows.push({
|
|
5947
|
+
id,
|
|
5948
|
+
label: phaseRowLabel(phaseEntry, labels),
|
|
5949
|
+
status,
|
|
5950
|
+
venue: phaseEntry.venue
|
|
5951
|
+
});
|
|
5952
|
+
};
|
|
5953
|
+
if (dagProgress && dagProgress.totalSteps > 0) {
|
|
5954
|
+
const timeline = buildPhaseTimeline(dagProgress);
|
|
5955
|
+
let activeEmitted = false;
|
|
5956
|
+
for (const entry of timeline) {
|
|
5957
|
+
const id = phaseRowId(entry);
|
|
5958
|
+
const alreadyShown = rows.some((row) => row.id === id);
|
|
5959
|
+
if (entry.allCompleted) {
|
|
5960
|
+
if (alreadyShown) continue;
|
|
5961
|
+
pushPhase(entry, "complete");
|
|
5962
|
+
continue;
|
|
5963
|
+
}
|
|
5964
|
+
if (activeEmitted) break;
|
|
5965
|
+
if (alreadyShown) continue;
|
|
5966
|
+
if (isAwaitingWalletConfirmation && entry.kind === "submitting") {
|
|
5967
|
+
pushPhase({ kind: "wallet-confirm" }, "pending");
|
|
5968
|
+
} else {
|
|
5969
|
+
pushPhase(entry, "pending");
|
|
5970
|
+
}
|
|
5971
|
+
activeEmitted = true;
|
|
5972
|
+
}
|
|
5973
|
+
if (!activeEmitted) {
|
|
5974
|
+
const last = rows[rows.length - 1];
|
|
5975
|
+
if (last && last.id.startsWith("executing-venue")) {
|
|
5976
|
+
last.status = "pending";
|
|
5977
|
+
} else {
|
|
5978
|
+
const fallbackVenue = executionVenue;
|
|
5979
|
+
rows.push({
|
|
5980
|
+
id: fallbackVenue ? `executing-venue:${fallbackVenue}` : "executing-venue",
|
|
5981
|
+
label: phaseRowLabel({ kind: "executing-venue", venue: fallbackVenue }, labels),
|
|
5982
|
+
status: "pending",
|
|
5983
|
+
venue: fallbackVenue
|
|
5984
|
+
});
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
return rows;
|
|
5988
|
+
}
|
|
5989
|
+
if (isAwaitingWalletConfirmation) {
|
|
5990
|
+
pushPhase({ kind: "wallet-confirm" }, "pending");
|
|
5991
|
+
return rows;
|
|
5992
|
+
}
|
|
5993
|
+
if (phase === "submitting") {
|
|
5994
|
+
pushPhase({ kind: "submitting" }, "pending");
|
|
5995
|
+
return rows;
|
|
5996
|
+
}
|
|
5997
|
+
pushPhase({ kind: "submitting" }, "complete");
|
|
5998
|
+
pushPhase({ kind: "executing-venue", venue: executionVenue }, "pending");
|
|
5999
|
+
return rows;
|
|
6000
|
+
};
|
|
6001
|
+
|
|
6002
|
+
// src/trading/place-order/index.place-order.execution-debug.ts
|
|
6003
|
+
var REDACTED = "[redacted]";
|
|
6004
|
+
var SENSITIVE_FIELD_PATTERNS = [
|
|
6005
|
+
"token",
|
|
6006
|
+
"authorization",
|
|
6007
|
+
"cookie",
|
|
6008
|
+
"secret",
|
|
6009
|
+
"signature",
|
|
6010
|
+
"privatekey",
|
|
6011
|
+
"private_key",
|
|
6012
|
+
"accesstoken",
|
|
6013
|
+
"access_token",
|
|
6014
|
+
"refreshtoken",
|
|
6015
|
+
"refresh_token",
|
|
6016
|
+
"jwt",
|
|
6017
|
+
"password",
|
|
6018
|
+
"apikey",
|
|
6019
|
+
"api_key",
|
|
6020
|
+
"email",
|
|
6021
|
+
"headers"
|
|
6022
|
+
];
|
|
6023
|
+
var isSensitiveFieldName = (name) => {
|
|
6024
|
+
const normalized = name.toLowerCase();
|
|
6025
|
+
return SENSITIVE_FIELD_PATTERNS.some((pattern) => normalized.includes(pattern));
|
|
6026
|
+
};
|
|
6027
|
+
var sanitizeExecutionDebugValue = (input) => {
|
|
6028
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
6029
|
+
const walk = (value) => {
|
|
6030
|
+
if (value === null || value === void 0) return value;
|
|
6031
|
+
if (typeof value !== "object") return value;
|
|
6032
|
+
if (ancestors.has(value)) return "[circular]";
|
|
6033
|
+
ancestors.add(value);
|
|
6034
|
+
try {
|
|
6035
|
+
if (Array.isArray(value)) {
|
|
6036
|
+
return value.map((entry) => walk(entry));
|
|
6037
|
+
}
|
|
6038
|
+
if (value instanceof Error) {
|
|
6039
|
+
return {
|
|
6040
|
+
name: value.name,
|
|
6041
|
+
message: value.message,
|
|
6042
|
+
stack: value.stack
|
|
6043
|
+
};
|
|
6044
|
+
}
|
|
6045
|
+
const out = {};
|
|
6046
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
6047
|
+
if (isSensitiveFieldName(key)) {
|
|
6048
|
+
out[key] = REDACTED;
|
|
6049
|
+
continue;
|
|
6050
|
+
}
|
|
6051
|
+
out[key] = walk(raw);
|
|
6052
|
+
}
|
|
6053
|
+
return out;
|
|
6054
|
+
} finally {
|
|
6055
|
+
ancestors.delete(value);
|
|
6056
|
+
}
|
|
6057
|
+
};
|
|
6058
|
+
return walk(input);
|
|
6059
|
+
};
|
|
6060
|
+
var cloneEnvironment = (env) => __spreadProps(__spreadValues({}, env), {
|
|
6061
|
+
packageVersions: env.packageVersions ? __spreadValues({}, env.packageVersions) : void 0
|
|
6062
|
+
});
|
|
6063
|
+
var buildEnvironment = (overrides) => {
|
|
6064
|
+
var _a;
|
|
6065
|
+
const url = typeof window !== "undefined" ? (_a = window.location) == null ? void 0 : _a.href : void 0;
|
|
6066
|
+
const userAgent = typeof navigator !== "undefined" && typeof navigator.userAgent === "string" ? navigator.userAgent : void 0;
|
|
6067
|
+
return __spreadValues({
|
|
6068
|
+
url,
|
|
6069
|
+
userAgent,
|
|
6070
|
+
capturedAt: Date.now()
|
|
6071
|
+
}, overrides);
|
|
6072
|
+
};
|
|
6073
|
+
var generateAttemptId = () => {
|
|
6074
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
6075
|
+
return crypto.randomUUID();
|
|
6076
|
+
}
|
|
6077
|
+
return `attempt-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
6078
|
+
};
|
|
6079
|
+
var createExecutionDebugStore = (initial) => {
|
|
6080
|
+
let attempts = [];
|
|
6081
|
+
let environment = buildEnvironment(initial);
|
|
6082
|
+
const findAttempt = (attemptId) => attempts.find((attempt) => attempt.attemptId === attemptId);
|
|
6083
|
+
const touch = (attempt) => {
|
|
6084
|
+
attempt.updatedAt = Date.now();
|
|
6085
|
+
};
|
|
6086
|
+
return {
|
|
6087
|
+
appendAttempt(input = {}) {
|
|
6088
|
+
var _a, _b;
|
|
6089
|
+
const now = Date.now();
|
|
6090
|
+
const attempt = {
|
|
6091
|
+
attemptId: (_a = input.attemptId) != null ? _a : generateAttemptId(),
|
|
6092
|
+
startedAt: now,
|
|
6093
|
+
updatedAt: now,
|
|
6094
|
+
status: (_b = input.status) != null ? _b : "quoting",
|
|
6095
|
+
quoteId: input.quoteId,
|
|
6096
|
+
orderId: input.orderId,
|
|
6097
|
+
orderIds: input.orderIds,
|
|
6098
|
+
quote: input.quote,
|
|
6099
|
+
selectedRoute: input.selectedRoute,
|
|
6100
|
+
bridge: input.bridge,
|
|
6101
|
+
venueExecution: input.venueExecution,
|
|
6102
|
+
rawEvents: [],
|
|
6103
|
+
normalizedSteps: [],
|
|
6104
|
+
errors: []
|
|
6105
|
+
};
|
|
6106
|
+
attempts = [...attempts, attempt];
|
|
6107
|
+
return attempt;
|
|
6108
|
+
},
|
|
6109
|
+
updateAttempt(attemptId, patch) {
|
|
6110
|
+
const attempt = findAttempt(attemptId);
|
|
6111
|
+
if (!attempt) return;
|
|
6112
|
+
if (patch.status !== void 0) attempt.status = patch.status;
|
|
6113
|
+
if (patch.quoteId !== void 0) attempt.quoteId = patch.quoteId;
|
|
6114
|
+
if (patch.orderId !== void 0) attempt.orderId = patch.orderId;
|
|
6115
|
+
if (patch.orderIds !== void 0) attempt.orderIds = patch.orderIds;
|
|
6116
|
+
if (patch.quote !== void 0) attempt.quote = patch.quote;
|
|
6117
|
+
if (patch.selectedRoute !== void 0) attempt.selectedRoute = patch.selectedRoute;
|
|
6118
|
+
if (patch.bridge !== void 0) attempt.bridge = patch.bridge;
|
|
6119
|
+
if (patch.venueExecution !== void 0) attempt.venueExecution = patch.venueExecution;
|
|
6120
|
+
if (patch.finalStatus !== void 0) attempt.finalStatus = patch.finalStatus;
|
|
6121
|
+
touch(attempt);
|
|
6122
|
+
},
|
|
6123
|
+
appendEvent(attemptId, event) {
|
|
6124
|
+
var _a;
|
|
6125
|
+
const attempt = findAttempt(attemptId);
|
|
6126
|
+
if (!attempt) return;
|
|
6127
|
+
attempt.rawEvents.push({
|
|
6128
|
+
kind: event.kind,
|
|
6129
|
+
label: event.label,
|
|
6130
|
+
data: event.data,
|
|
6131
|
+
timestamp: (_a = event.timestamp) != null ? _a : Date.now()
|
|
6132
|
+
});
|
|
6133
|
+
touch(attempt);
|
|
6134
|
+
},
|
|
6135
|
+
appendError(attemptId, error) {
|
|
6136
|
+
var _a;
|
|
6137
|
+
const attempt = findAttempt(attemptId);
|
|
6138
|
+
if (!attempt) return;
|
|
6139
|
+
attempt.errors.push({
|
|
6140
|
+
message: error.message,
|
|
6141
|
+
name: error.name,
|
|
6142
|
+
code: error.code,
|
|
6143
|
+
stack: error.stack,
|
|
6144
|
+
failedStep: error.failedStep,
|
|
6145
|
+
data: error.data,
|
|
6146
|
+
timestamp: (_a = error.timestamp) != null ? _a : Date.now()
|
|
6147
|
+
});
|
|
6148
|
+
touch(attempt);
|
|
6149
|
+
},
|
|
6150
|
+
setNormalizedSteps(attemptId, steps) {
|
|
6151
|
+
const attempt = findAttempt(attemptId);
|
|
6152
|
+
if (!attempt) return;
|
|
6153
|
+
attempt.normalizedSteps = steps;
|
|
6154
|
+
touch(attempt);
|
|
6155
|
+
},
|
|
6156
|
+
getSnapshot() {
|
|
6157
|
+
return {
|
|
6158
|
+
attempts: attempts.map((attempt) => __spreadProps(__spreadValues({}, attempt), {
|
|
6159
|
+
rawEvents: [...attempt.rawEvents],
|
|
6160
|
+
normalizedSteps: [...attempt.normalizedSteps],
|
|
6161
|
+
errors: [...attempt.errors]
|
|
6162
|
+
})),
|
|
6163
|
+
environment: cloneEnvironment(environment)
|
|
6164
|
+
};
|
|
6165
|
+
},
|
|
6166
|
+
getFailedAttempts() {
|
|
6167
|
+
return attempts.filter(
|
|
6168
|
+
(attempt) => attempt.status === "failed" || attempt.finalStatus === "failed" || attempt.errors.length > 0
|
|
6169
|
+
).map((attempt) => __spreadProps(__spreadValues({}, attempt), {
|
|
6170
|
+
rawEvents: [...attempt.rawEvents],
|
|
6171
|
+
normalizedSteps: [...attempt.normalizedSteps],
|
|
6172
|
+
errors: [...attempt.errors]
|
|
6173
|
+
}));
|
|
6174
|
+
},
|
|
6175
|
+
clear() {
|
|
6176
|
+
attempts = [];
|
|
6177
|
+
environment = buildEnvironment(initial);
|
|
6178
|
+
}
|
|
6179
|
+
};
|
|
6180
|
+
};
|
|
6181
|
+
var writeClipboardLegacy = (text) => {
|
|
6182
|
+
if (typeof document === "undefined") return false;
|
|
6183
|
+
const textarea = document.createElement("textarea");
|
|
6184
|
+
textarea.value = text;
|
|
6185
|
+
textarea.setAttribute("readonly", "");
|
|
6186
|
+
textarea.style.position = "fixed";
|
|
6187
|
+
textarea.style.top = "-1000px";
|
|
6188
|
+
textarea.style.opacity = "0";
|
|
6189
|
+
document.body.appendChild(textarea);
|
|
6190
|
+
try {
|
|
6191
|
+
textarea.select();
|
|
6192
|
+
return document.execCommand("copy");
|
|
6193
|
+
} catch (e) {
|
|
6194
|
+
return false;
|
|
6195
|
+
} finally {
|
|
6196
|
+
document.body.removeChild(textarea);
|
|
6197
|
+
}
|
|
6198
|
+
};
|
|
6199
|
+
var tryWriteClipboard = (text, consoleImpl) => __async(null, null, function* () {
|
|
6200
|
+
var _a;
|
|
6201
|
+
if (typeof navigator !== "undefined" && ((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
6202
|
+
try {
|
|
6203
|
+
yield navigator.clipboard.writeText(text);
|
|
6204
|
+
consoleImpl.info("[agg-execution-debug] Copied execution data to clipboard.");
|
|
6205
|
+
return;
|
|
6206
|
+
} catch (e) {
|
|
6207
|
+
}
|
|
6208
|
+
}
|
|
6209
|
+
if (writeClipboardLegacy(text)) {
|
|
6210
|
+
consoleImpl.info("[agg-execution-debug] Copied execution data to clipboard.");
|
|
6211
|
+
return;
|
|
6212
|
+
}
|
|
6213
|
+
consoleImpl.warn(
|
|
6214
|
+
"[agg-execution-debug] Clipboard copy was blocked by the browser. The JSON is logged below \u2014 right-click the entry and copy."
|
|
6215
|
+
);
|
|
6216
|
+
consoleImpl.log(text);
|
|
6217
|
+
});
|
|
6218
|
+
var installExecutionDebugWindow = ({
|
|
6219
|
+
store,
|
|
6220
|
+
consoleImpl
|
|
6221
|
+
}) => {
|
|
6222
|
+
if (typeof window === "undefined") return () => {
|
|
6223
|
+
};
|
|
6224
|
+
const targetConsole = consoleImpl != null ? consoleImpl : console;
|
|
6225
|
+
const previous = {
|
|
6226
|
+
executionData: window.executionData,
|
|
6227
|
+
getExecutionData: window.getExecutionData,
|
|
6228
|
+
getFailedExecutionData: window.getFailedExecutionData,
|
|
6229
|
+
clearExecutionData: window.clearExecutionData,
|
|
6230
|
+
storeRef: window.__aggExecutionDebugStore
|
|
6231
|
+
};
|
|
6232
|
+
const refresh = () => {
|
|
6233
|
+
window.executionData = sanitizeExecutionDebugValue(store.getSnapshot());
|
|
6234
|
+
};
|
|
6235
|
+
refresh();
|
|
6236
|
+
window.__aggExecutionDebugStore = store;
|
|
6237
|
+
window.getExecutionData = () => {
|
|
6238
|
+
const data = sanitizeExecutionDebugValue(store.getSnapshot());
|
|
6239
|
+
window.executionData = data;
|
|
6240
|
+
void tryWriteClipboard(JSON.stringify(data, null, 2), targetConsole);
|
|
6241
|
+
return data;
|
|
6242
|
+
};
|
|
6243
|
+
window.getFailedExecutionData = () => {
|
|
6244
|
+
const failed = sanitizeExecutionDebugValue({ attempts: store.getFailedAttempts() });
|
|
6245
|
+
void tryWriteClipboard(JSON.stringify(failed, null, 2), targetConsole);
|
|
6246
|
+
return failed;
|
|
6247
|
+
};
|
|
6248
|
+
window.clearExecutionData = () => {
|
|
6249
|
+
store.clear();
|
|
6250
|
+
refresh();
|
|
6251
|
+
};
|
|
6252
|
+
targetConsole.info(
|
|
6253
|
+
"AGG execution debug enabled. Run window.getFailedExecutionData() after a failed order to copy logs."
|
|
6254
|
+
);
|
|
6255
|
+
return () => {
|
|
6256
|
+
if (typeof window === "undefined") return;
|
|
6257
|
+
window.executionData = previous.executionData;
|
|
6258
|
+
window.getExecutionData = previous.getExecutionData;
|
|
6259
|
+
window.getFailedExecutionData = previous.getFailedExecutionData;
|
|
6260
|
+
window.clearExecutionData = previous.clearExecutionData;
|
|
6261
|
+
window.__aggExecutionDebugStore = previous.storeRef;
|
|
6262
|
+
};
|
|
6263
|
+
};
|
|
6264
|
+
var enableExecutionDebugInBrowser = (initial) => {
|
|
6265
|
+
if (typeof window === "undefined") return null;
|
|
6266
|
+
const existing = window.__aggExecutionDebugStore;
|
|
6267
|
+
if (existing) return existing;
|
|
6268
|
+
const store = createExecutionDebugStore(initial);
|
|
6269
|
+
installExecutionDebugWindow({ store });
|
|
6270
|
+
return store;
|
|
6271
|
+
};
|
|
6272
|
+
|
|
5835
6273
|
// src/trading/place-order/index.place-order.utils.ts
|
|
5836
6274
|
var routePriceLabelFormatter = new Intl.NumberFormat("en-US", {
|
|
5837
6275
|
minimumFractionDigits: 0,
|
|
@@ -7019,21 +7457,6 @@ PlaceOrderSuccessView.displayName = "PlaceOrderSuccessView";
|
|
|
7019
7457
|
|
|
7020
7458
|
// src/trading/place-order/index.tsx
|
|
7021
7459
|
var import_jsx_runtime113 = require("react/jsx-runtime");
|
|
7022
|
-
var DEFAULT_STEP_LABELS = {
|
|
7023
|
-
"check-balance": "Checking balance",
|
|
7024
|
-
"check-position": "Checking position",
|
|
7025
|
-
"lane-bridge": "Bridging funds",
|
|
7026
|
-
bridge: "Bridging funds",
|
|
7027
|
-
"bridge-to-user": "Transferring to wallet",
|
|
7028
|
-
"sweep-bridge": "Completing bridge",
|
|
7029
|
-
"submit-order": "Submitting order",
|
|
7030
|
-
"order-bridge-execute": "Executing order",
|
|
7031
|
-
"transfer-to-user": "Transferring to wallet"
|
|
7032
|
-
};
|
|
7033
|
-
var getDefaultStepLabel = (stepType) => {
|
|
7034
|
-
var _a;
|
|
7035
|
-
return (_a = DEFAULT_STEP_LABELS[stepType]) != null ? _a : stepType.replace(/-/g, " ").replace(/^\w/, (c) => c.toUpperCase());
|
|
7036
|
-
};
|
|
7037
7460
|
var resolveRefetchedQuoteData = (result) => {
|
|
7038
7461
|
if (!result || typeof result !== "object" || !("data" in result)) return null;
|
|
7039
7462
|
const data = result.data;
|
|
@@ -7533,7 +7956,6 @@ var renderRouteCard = ({
|
|
|
7533
7956
|
}
|
|
7534
7957
|
);
|
|
7535
7958
|
};
|
|
7536
|
-
var normalizeOrderIdLabelInput2 = (orderId) => orderId.replace(/^#+/, "");
|
|
7537
7959
|
var renderSubmissionSurface = ({
|
|
7538
7960
|
actionLabel,
|
|
7539
7961
|
className,
|
|
@@ -7545,81 +7967,12 @@ var renderSubmissionSurface = ({
|
|
|
7545
7967
|
progressState,
|
|
7546
7968
|
tradingLabels
|
|
7547
7969
|
}) => {
|
|
7548
|
-
const
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
id: "finding-route",
|
|
7555
|
-
label: tradingLabels.findingBestRoute,
|
|
7556
|
-
status: "pending"
|
|
7557
|
-
}
|
|
7558
|
-
]
|
|
7559
|
-
];
|
|
7560
|
-
}
|
|
7561
|
-
const dag = progressState.dagProgress;
|
|
7562
|
-
if (dag && dag.totalSteps > 0) {
|
|
7563
|
-
const steps = [
|
|
7564
|
-
{
|
|
7565
|
-
id: "finding-route",
|
|
7566
|
-
label: tradingLabels.findingBestRoute,
|
|
7567
|
-
status: "complete"
|
|
7568
|
-
}
|
|
7569
|
-
];
|
|
7570
|
-
for (let i = 1; i <= dag.totalSteps; i++) {
|
|
7571
|
-
const isCompleted = dag.completedSequences.includes(i);
|
|
7572
|
-
const isCurrent = i === dag.currentSequence && !isCompleted;
|
|
7573
|
-
const stepType = (_a = dag.stepTypes[i]) != null ? _a : null;
|
|
7574
|
-
const stepLabel = stepType ? getDefaultStepLabel(stepType) : `Step ${i} of ${dag.totalSteps}`;
|
|
7575
|
-
const prev = steps[steps.length - 1];
|
|
7576
|
-
if (prev && prev.label === stepLabel) {
|
|
7577
|
-
if (prev.status === "complete" && !isCompleted) {
|
|
7578
|
-
prev.status = "pending";
|
|
7579
|
-
}
|
|
7580
|
-
continue;
|
|
7581
|
-
}
|
|
7582
|
-
steps.push({
|
|
7583
|
-
id: `dag-step-${i}`,
|
|
7584
|
-
label: stepLabel,
|
|
7585
|
-
status: isCompleted ? "complete" : isCurrent ? "pending" : "pending"
|
|
7586
|
-
});
|
|
7587
|
-
}
|
|
7588
|
-
return [steps];
|
|
7589
|
-
}
|
|
7590
|
-
const baseSteps = [
|
|
7591
|
-
{
|
|
7592
|
-
id: "finding-route",
|
|
7593
|
-
label: tradingLabels.findingBestRoute,
|
|
7594
|
-
status: "complete"
|
|
7595
|
-
},
|
|
7596
|
-
{
|
|
7597
|
-
id: "submitting-order",
|
|
7598
|
-
label: tradingLabels.submittingOrderProgress,
|
|
7599
|
-
status: "complete"
|
|
7600
|
-
}
|
|
7601
|
-
];
|
|
7602
|
-
const submittedOrderId = (_c = progressState.orderId) != null ? _c : (_b = progressState.orderIds) == null ? void 0 : _b[0];
|
|
7603
|
-
if (submittedOrderId) {
|
|
7604
|
-
baseSteps.push({
|
|
7605
|
-
id: "order-submitted",
|
|
7606
|
-
label: tradingLabels.orderSubmittedProgress(normalizeOrderIdLabelInput2(submittedOrderId)),
|
|
7607
|
-
status: "complete"
|
|
7608
|
-
});
|
|
7609
|
-
}
|
|
7610
|
-
return [
|
|
7611
|
-
baseSteps,
|
|
7612
|
-
[
|
|
7613
|
-
{
|
|
7614
|
-
id: "executing-order",
|
|
7615
|
-
label: tradingLabels.executingOnVenue(getTradingVenueLabel(progressState.executionVenue)),
|
|
7616
|
-
status: "pending",
|
|
7617
|
-
venue: progressState.executionVenue
|
|
7618
|
-
}
|
|
7619
|
-
]
|
|
7620
|
-
];
|
|
7621
|
-
};
|
|
7622
|
-
const stepGroups = resolveStepGroups();
|
|
7970
|
+
const displayRows = buildSubmissionDisplayRows({
|
|
7971
|
+
phase: progressState.phase,
|
|
7972
|
+
dagProgress: progressState.dagProgress,
|
|
7973
|
+
executionVenue: progressState.executionVenue,
|
|
7974
|
+
labels: tradingLabels
|
|
7975
|
+
});
|
|
7623
7976
|
return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
7624
7977
|
Card,
|
|
7625
7978
|
{
|
|
@@ -7641,51 +7994,50 @@ var renderSubmissionSurface = ({
|
|
|
7641
7994
|
/* @__PURE__ */ (0, import_jsx_runtime113.jsx)(LoadingGlyph, { enableAnimations, className: "h-4 w-4 text-current" }),
|
|
7642
7995
|
/* @__PURE__ */ (0, import_jsx_runtime113.jsx)("span", { children: actionLabel })
|
|
7643
7996
|
] }),
|
|
7644
|
-
/* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
}
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
}) })
|
|
7997
|
+
/* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
7998
|
+
"div",
|
|
7999
|
+
{
|
|
8000
|
+
className: "agg-order-submission-steps agg-order-submission-group flex flex-col gap-2",
|
|
8001
|
+
"data-testid": "agg-order-submission-steps",
|
|
8002
|
+
children: displayRows.map((step) => {
|
|
8003
|
+
return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(
|
|
8004
|
+
"div",
|
|
8005
|
+
{
|
|
8006
|
+
className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
8007
|
+
"data-status": step.status,
|
|
8008
|
+
children: [
|
|
8009
|
+
step.status === "complete" ? /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
8010
|
+
Icon,
|
|
8011
|
+
{
|
|
8012
|
+
name: "check-circle",
|
|
8013
|
+
size: "small",
|
|
8014
|
+
className: "h-3 w-3 shrink-0 text-agg-primary",
|
|
8015
|
+
"aria-hidden": "true"
|
|
8016
|
+
}
|
|
8017
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
8018
|
+
LoadingGlyph,
|
|
8019
|
+
{
|
|
8020
|
+
enableAnimations,
|
|
8021
|
+
className: "h-3 w-3 shrink-0 text-agg-primary"
|
|
8022
|
+
}
|
|
8023
|
+
),
|
|
8024
|
+
/* @__PURE__ */ (0, import_jsx_runtime113.jsx)("p", { className: "min-w-0 flex-1", children: step.label }),
|
|
8025
|
+
step.venue ? /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
8026
|
+
VenueLogo,
|
|
8027
|
+
{
|
|
8028
|
+
venue: step.venue,
|
|
8029
|
+
size: "small",
|
|
8030
|
+
ariaLabel: getTradingVenueLabel(step.venue),
|
|
8031
|
+
className: "h-4 w-4"
|
|
8032
|
+
}
|
|
8033
|
+
) : null
|
|
8034
|
+
]
|
|
8035
|
+
},
|
|
8036
|
+
step.id
|
|
8037
|
+
);
|
|
8038
|
+
})
|
|
8039
|
+
}
|
|
8040
|
+
)
|
|
7689
8041
|
] })
|
|
7690
8042
|
] })
|
|
7691
8043
|
}
|
|
@@ -7821,6 +8173,7 @@ var PlaceOrder = ({
|
|
|
7821
8173
|
}) => {
|
|
7822
8174
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
|
|
7823
8175
|
const {
|
|
8176
|
+
enableDebug: isExecutionDebugEnabled,
|
|
7824
8177
|
features: { enableAnimations, showFeesBreakdown },
|
|
7825
8178
|
general: { locale }
|
|
7826
8179
|
} = (0, import_hooks29.useSdkUiConfig)();
|
|
@@ -7917,6 +8270,27 @@ var PlaceOrder = ({
|
|
|
7917
8270
|
const [isSplitDetailOpen, setIsSplitDetailOpen] = (0, import_react9.useState)(false);
|
|
7918
8271
|
const [submissionFeedback, setSubmissionFeedback] = (0, import_react9.useState)(null);
|
|
7919
8272
|
const [submissionProgressState, setSubmissionProgressState] = (0, import_react9.useState)(null);
|
|
8273
|
+
const executionDebugStoreRef = (0, import_react9.useRef)(null);
|
|
8274
|
+
const executionDebugAttemptIdRef = (0, import_react9.useRef)(null);
|
|
8275
|
+
(0, import_react9.useEffect)(() => {
|
|
8276
|
+
if (!isExecutionDebugEnabled) {
|
|
8277
|
+
executionDebugStoreRef.current = null;
|
|
8278
|
+
return;
|
|
8279
|
+
}
|
|
8280
|
+
executionDebugStoreRef.current = enableExecutionDebugInBrowser();
|
|
8281
|
+
}, [isExecutionDebugEnabled]);
|
|
8282
|
+
(0, import_react9.useEffect)(() => {
|
|
8283
|
+
if (!isExecutionDebugEnabled) return;
|
|
8284
|
+
const store = executionDebugStoreRef.current;
|
|
8285
|
+
if (!store) return;
|
|
8286
|
+
store.clear();
|
|
8287
|
+
executionDebugAttemptIdRef.current = null;
|
|
8288
|
+
}, [
|
|
8289
|
+
isExecutionDebugEnabled,
|
|
8290
|
+
scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
|
|
8291
|
+
scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
|
|
8292
|
+
scopedSelectedOutcomeId
|
|
8293
|
+
]);
|
|
7920
8294
|
const debouncedAmount = (0, import_hooks29.useDebouncedValue)(internalAmount, 300);
|
|
7921
8295
|
const isSell = (0, import_react9.useMemo)(() => internalTab === "sell", [internalTab]);
|
|
7922
8296
|
const {
|
|
@@ -8176,8 +8550,39 @@ var PlaceOrder = ({
|
|
|
8176
8550
|
selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
|
|
8177
8551
|
]);
|
|
8178
8552
|
(0, import_react9.useEffect)(() => {
|
|
8553
|
+
var _a2, _b2;
|
|
8179
8554
|
const dp = executionProgress.dagProgress;
|
|
8180
8555
|
if (!dp) return;
|
|
8556
|
+
const debugStore = executionDebugStoreRef.current;
|
|
8557
|
+
const debugAttemptId = executionDebugAttemptIdRef.current;
|
|
8558
|
+
if (debugStore && debugAttemptId) {
|
|
8559
|
+
debugStore.appendEvent(debugAttemptId, {
|
|
8560
|
+
kind: "ws_update",
|
|
8561
|
+
label: "dag_progress",
|
|
8562
|
+
data: dp
|
|
8563
|
+
});
|
|
8564
|
+
const normalizedRows = buildSubmissionDisplayRows({
|
|
8565
|
+
phase: "executing",
|
|
8566
|
+
dagProgress: dp,
|
|
8567
|
+
labels: tradingLabels
|
|
8568
|
+
});
|
|
8569
|
+
debugStore.setNormalizedSteps(debugAttemptId, normalizedRows);
|
|
8570
|
+
debugStore.appendEvent(debugAttemptId, {
|
|
8571
|
+
kind: "normalized_steps",
|
|
8572
|
+
data: normalizedRows
|
|
8573
|
+
});
|
|
8574
|
+
if (dp.status === "failed") {
|
|
8575
|
+
debugStore.appendError(debugAttemptId, {
|
|
8576
|
+
message: (_a2 = dp.errorReason) != null ? _a2 : "DAG execution failed",
|
|
8577
|
+
failedStep: (_b2 = dp.currentStepType) != null ? _b2 : void 0,
|
|
8578
|
+
data: { currentSequence: dp.currentSequence, totalSteps: dp.totalSteps }
|
|
8579
|
+
});
|
|
8580
|
+
debugStore.updateAttempt(debugAttemptId, {
|
|
8581
|
+
status: "failed",
|
|
8582
|
+
finalStatus: "failed"
|
|
8583
|
+
});
|
|
8584
|
+
}
|
|
8585
|
+
}
|
|
8181
8586
|
setSubmissionProgressState((prev) => {
|
|
8182
8587
|
if (!prev) return prev;
|
|
8183
8588
|
if (dp.status === "failed") {
|
|
@@ -8193,7 +8598,7 @@ var PlaceOrder = ({
|
|
|
8193
8598
|
}
|
|
8194
8599
|
return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
|
|
8195
8600
|
});
|
|
8196
|
-
}, [executionProgress.dagProgress, tradingLabels
|
|
8601
|
+
}, [executionProgress.dagProgress, tradingLabels]);
|
|
8197
8602
|
(0, import_react9.useEffect)(() => {
|
|
8198
8603
|
const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
|
|
8199
8604
|
if (!(orderIds == null ? void 0 : orderIds.length)) return;
|
|
@@ -8201,6 +8606,17 @@ var PlaceOrder = ({
|
|
|
8201
8606
|
orderIds,
|
|
8202
8607
|
executionProgress.terminalOrderEvents
|
|
8203
8608
|
);
|
|
8609
|
+
const debugStore = executionDebugStoreRef.current;
|
|
8610
|
+
const debugAttemptId = executionDebugAttemptIdRef.current;
|
|
8611
|
+
if (debugStore && debugAttemptId && executionProgress.terminalOrderEvents.length > 0) {
|
|
8612
|
+
debugStore.appendEvent(debugAttemptId, {
|
|
8613
|
+
kind: "terminal_event",
|
|
8614
|
+
data: {
|
|
8615
|
+
aggregateStatus,
|
|
8616
|
+
events: executionProgress.terminalOrderEvents
|
|
8617
|
+
}
|
|
8618
|
+
});
|
|
8619
|
+
}
|
|
8204
8620
|
if (aggregateStatus === "pending") return;
|
|
8205
8621
|
setSubmissionProgressState((prev) => {
|
|
8206
8622
|
var _a2, _b2, _c2;
|
|
@@ -8243,14 +8659,45 @@ var PlaceOrder = ({
|
|
|
8243
8659
|
tradingLabels.orderFailed
|
|
8244
8660
|
]);
|
|
8245
8661
|
(0, import_react9.useEffect)(() => {
|
|
8662
|
+
var _a2, _b2;
|
|
8246
8663
|
if (!submissionProgressState) return;
|
|
8247
8664
|
onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
|
|
8665
|
+
const debugStore = executionDebugStoreRef.current;
|
|
8666
|
+
const debugAttemptId = executionDebugAttemptIdRef.current;
|
|
8667
|
+
if (debugStore && debugAttemptId) {
|
|
8668
|
+
debugStore.appendEvent(debugAttemptId, {
|
|
8669
|
+
kind: "state_change",
|
|
8670
|
+
label: submissionProgressState.phase,
|
|
8671
|
+
data: {
|
|
8672
|
+
phase: submissionProgressState.phase,
|
|
8673
|
+
executionVenue: submissionProgressState.executionVenue,
|
|
8674
|
+
orderIds: submissionProgressState.orderIds,
|
|
8675
|
+
errorMessage: submissionProgressState.errorMessage
|
|
8676
|
+
}
|
|
8677
|
+
});
|
|
8678
|
+
}
|
|
8248
8679
|
if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
|
|
8249
8680
|
(0, import_hooks29.invalidateBalanceQueries)(queryClient);
|
|
8250
8681
|
(0, import_hooks29.invalidatePositionQueries)(queryClient);
|
|
8682
|
+
if (debugStore && debugAttemptId) {
|
|
8683
|
+
debugStore.updateAttempt(debugAttemptId, {
|
|
8684
|
+
status: "succeeded",
|
|
8685
|
+
finalStatus: "succeeded"
|
|
8686
|
+
});
|
|
8687
|
+
}
|
|
8251
8688
|
onSuccess == null ? void 0 : onSuccess(submissionProgressState.summary);
|
|
8252
8689
|
}
|
|
8253
8690
|
if (submissionProgressState.phase === "failed" && submissionProgressState.errorMessage) {
|
|
8691
|
+
if (debugStore && debugAttemptId) {
|
|
8692
|
+
debugStore.appendError(debugAttemptId, {
|
|
8693
|
+
message: submissionProgressState.errorMessage,
|
|
8694
|
+
failedStep: (_b2 = (_a2 = submissionProgressState.dagProgress) == null ? void 0 : _a2.currentStepType) != null ? _b2 : void 0
|
|
8695
|
+
});
|
|
8696
|
+
debugStore.updateAttempt(debugAttemptId, {
|
|
8697
|
+
status: "failed",
|
|
8698
|
+
finalStatus: "failed"
|
|
8699
|
+
});
|
|
8700
|
+
}
|
|
8254
8701
|
onError == null ? void 0 : onError(new Error(submissionProgressState.errorMessage));
|
|
8255
8702
|
}
|
|
8256
8703
|
}, [submissionProgressState, onExecutionStateChange, onSuccess, onError, queryClient]);
|
|
@@ -8424,23 +8871,91 @@ var PlaceOrder = ({
|
|
|
8424
8871
|
};
|
|
8425
8872
|
const handleExecuteQuote = (0, import_react9.useCallback)(
|
|
8426
8873
|
(quoteData) => __async(null, null, function* () {
|
|
8874
|
+
var _a2, _b2, _c2;
|
|
8427
8875
|
const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
|
|
8428
8876
|
if (!quoteId) {
|
|
8429
8877
|
throw new Error(tradingLabels.quoteUnavailable);
|
|
8430
8878
|
}
|
|
8879
|
+
const debugStore = executionDebugStoreRef.current;
|
|
8880
|
+
const venues = (_b2 = (_a2 = quoteData == null ? void 0 : quoteData.fills) == null ? void 0 : _a2.map((fill) => fill.venue).filter(Boolean)) != null ? _b2 : [];
|
|
8881
|
+
const debugAttempt = debugStore == null ? void 0 : debugStore.appendAttempt({
|
|
8882
|
+
status: "executing",
|
|
8883
|
+
quoteId,
|
|
8884
|
+
quote: {
|
|
8885
|
+
request: {
|
|
8886
|
+
venueMarketOutcomeId: scopedSelectedOutcomeId,
|
|
8887
|
+
amount: internalAmount,
|
|
8888
|
+
slippage: internalSlippage,
|
|
8889
|
+
tradeSide: isSell ? "sell" : "buy"
|
|
8890
|
+
},
|
|
8891
|
+
response: smartRoute.data,
|
|
8892
|
+
selectedRoute: quoteData,
|
|
8893
|
+
side: isSell ? "sell" : "buy",
|
|
8894
|
+
marketId: scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
|
|
8895
|
+
eventId: scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
|
|
8896
|
+
outcomeId: scopedSelectedOutcomeId != null ? scopedSelectedOutcomeId : void 0,
|
|
8897
|
+
venues,
|
|
8898
|
+
capturedAt: Date.now()
|
|
8899
|
+
},
|
|
8900
|
+
selectedRoute: quoteData
|
|
8901
|
+
});
|
|
8902
|
+
executionDebugAttemptIdRef.current = (_c2 = debugAttempt == null ? void 0 : debugAttempt.attemptId) != null ? _c2 : null;
|
|
8431
8903
|
if (onPrimaryAction) {
|
|
8904
|
+
debugStore == null ? void 0 : debugStore.appendEvent(debugAttempt.attemptId, {
|
|
8905
|
+
kind: "execute_request",
|
|
8906
|
+
label: "delegated_to_partner",
|
|
8907
|
+
data: { quoteId }
|
|
8908
|
+
});
|
|
8432
8909
|
onPrimaryAction({ quoteId });
|
|
8433
8910
|
return;
|
|
8434
8911
|
}
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8912
|
+
try {
|
|
8913
|
+
const response = yield executeManaged.mutateAsync({ quoteId });
|
|
8914
|
+
if (debugAttempt) {
|
|
8915
|
+
debugStore == null ? void 0 : debugStore.appendEvent(debugAttempt.attemptId, {
|
|
8916
|
+
kind: "execute_response",
|
|
8917
|
+
data: { orderIds: response.orderIds }
|
|
8918
|
+
});
|
|
8919
|
+
debugStore == null ? void 0 : debugStore.updateAttempt(debugAttempt.attemptId, {
|
|
8920
|
+
orderId: response.orderIds[0],
|
|
8921
|
+
orderIds: response.orderIds
|
|
8922
|
+
});
|
|
8923
|
+
}
|
|
8924
|
+
setSubmissionProgressState({
|
|
8925
|
+
executionVenue: resolveExecutionVenueFromQuote(quoteData),
|
|
8926
|
+
orderId: response.orderIds[0],
|
|
8927
|
+
orderIds: response.orderIds,
|
|
8928
|
+
phase: "submitting"
|
|
8929
|
+
});
|
|
8930
|
+
} catch (error) {
|
|
8931
|
+
if (debugAttempt) {
|
|
8932
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
8933
|
+
debugStore == null ? void 0 : debugStore.appendError(debugAttempt.attemptId, {
|
|
8934
|
+
message: err.message,
|
|
8935
|
+
name: err.name,
|
|
8936
|
+
stack: err.stack,
|
|
8937
|
+
failedStep: "execute_request"
|
|
8938
|
+
});
|
|
8939
|
+
debugStore == null ? void 0 : debugStore.updateAttempt(debugAttempt.attemptId, {
|
|
8940
|
+
status: "failed",
|
|
8941
|
+
finalStatus: "failed"
|
|
8942
|
+
});
|
|
8943
|
+
}
|
|
8944
|
+
throw error;
|
|
8945
|
+
}
|
|
8442
8946
|
}),
|
|
8443
|
-
[
|
|
8947
|
+
[
|
|
8948
|
+
executeManaged,
|
|
8949
|
+
internalAmount,
|
|
8950
|
+
internalSlippage,
|
|
8951
|
+
isSell,
|
|
8952
|
+
onPrimaryAction,
|
|
8953
|
+
scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
|
|
8954
|
+
scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
|
|
8955
|
+
scopedSelectedOutcomeId,
|
|
8956
|
+
smartRoute.data,
|
|
8957
|
+
tradingLabels.quoteUnavailable
|
|
8958
|
+
]
|
|
8444
8959
|
);
|
|
8445
8960
|
const handleSkipToSuccess = (0, import_react9.useCallback)(() => {
|
|
8446
8961
|
const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
|