@vtxmacro/cli 2026.9.58 → 2026.9.59
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/bin/vtx-service-bootstrap.js +9 -1
- package/bin/vtx-service-launcher.js +8 -0
- package/bin/vtx.js +151 -40
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ import { fileURLToPath } from "node:url";
|
|
|
16
16
|
// agent-cli-release.json
|
|
17
17
|
var agent_cli_release_default = {
|
|
18
18
|
package_name: "@vtxmacro/cli",
|
|
19
|
-
package_version: "2026.9.
|
|
19
|
+
package_version: "2026.9.59",
|
|
20
20
|
codex_package_name: "@openai/codex",
|
|
21
21
|
codex_version: "0.155.0",
|
|
22
22
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -320,6 +320,14 @@ var runtime_policy_generated_default = {
|
|
|
320
320
|
request_timeout_seconds: 10,
|
|
321
321
|
pool_timeout_seconds: 5
|
|
322
322
|
}
|
|
323
|
+
},
|
|
324
|
+
public_request_priority: {
|
|
325
|
+
trading_reduce: 1,
|
|
326
|
+
trading_reconcile: 2,
|
|
327
|
+
trading_execute: 3,
|
|
328
|
+
trading_analysis: 4,
|
|
329
|
+
ui: 5,
|
|
330
|
+
background: 6
|
|
323
331
|
}
|
|
324
332
|
}
|
|
325
333
|
}
|
|
@@ -203,6 +203,14 @@ var runtime_policy_generated_default = {
|
|
|
203
203
|
request_timeout_seconds: 10,
|
|
204
204
|
pool_timeout_seconds: 5
|
|
205
205
|
}
|
|
206
|
+
},
|
|
207
|
+
public_request_priority: {
|
|
208
|
+
trading_reduce: 1,
|
|
209
|
+
trading_reconcile: 2,
|
|
210
|
+
trading_execute: 3,
|
|
211
|
+
trading_analysis: 4,
|
|
212
|
+
ui: 5,
|
|
213
|
+
background: 6
|
|
206
214
|
}
|
|
207
215
|
}
|
|
208
216
|
}
|
package/bin/vtx.js
CHANGED
|
@@ -77,7 +77,7 @@ var init_agent_cli_release = __esm({
|
|
|
77
77
|
"agent-cli-release.json"() {
|
|
78
78
|
agent_cli_release_default = {
|
|
79
79
|
package_name: "@vtxmacro/cli",
|
|
80
|
-
package_version: "2026.9.
|
|
80
|
+
package_version: "2026.9.59",
|
|
81
81
|
codex_package_name: "@openai/codex",
|
|
82
82
|
codex_version: "0.155.0",
|
|
83
83
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -20661,6 +20661,14 @@ var init_runtime_policy_generated = __esm({
|
|
|
20661
20661
|
request_timeout_seconds: 10,
|
|
20662
20662
|
pool_timeout_seconds: 5
|
|
20663
20663
|
}
|
|
20664
|
+
},
|
|
20665
|
+
public_request_priority: {
|
|
20666
|
+
trading_reduce: 1,
|
|
20667
|
+
trading_reconcile: 2,
|
|
20668
|
+
trading_execute: 3,
|
|
20669
|
+
trading_analysis: 4,
|
|
20670
|
+
ui: 5,
|
|
20671
|
+
background: 6
|
|
20664
20672
|
}
|
|
20665
20673
|
}
|
|
20666
20674
|
}
|
|
@@ -42723,6 +42731,14 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
42723
42731
|
request_timeout_seconds: 10,
|
|
42724
42732
|
pool_timeout_seconds: 5
|
|
42725
42733
|
}
|
|
42734
|
+
},
|
|
42735
|
+
public_request_priority: {
|
|
42736
|
+
trading_reduce: 1,
|
|
42737
|
+
trading_reconcile: 2,
|
|
42738
|
+
trading_execute: 3,
|
|
42739
|
+
trading_analysis: 4,
|
|
42740
|
+
ui: 5,
|
|
42741
|
+
background: 6
|
|
42726
42742
|
}
|
|
42727
42743
|
}
|
|
42728
42744
|
}
|
|
@@ -48664,7 +48680,7 @@ var init_runtime_redaction = __esm({
|
|
|
48664
48680
|
});
|
|
48665
48681
|
|
|
48666
48682
|
// lib/runtime/hyperliquid-public-read.ts
|
|
48667
|
-
var policy, weights, recoveryPolicy, budgets, unpersistedBudgets, cache, pending2, PREFIX, abortError2, checkAbort, wait, storage, loadBudget, saveBudget, withBudgetLock, HyperliquidPublicReadError, getHyperliquidPublicReadBudget, cooldownError, recoveryWaitError, fallbackDelayMs, admit, cooldown, finishHyperliquidRecoveryRequest, assertHyperliquidRecoveryDispatch, cacheTtlMs, eligibleCache, reserveHyperliquidPublicReads, releaseHyperliquidPublicReadReservation, admitHyperliquidExchangeRequest, recordHyperliquidExchangeResponse, readHyperliquidPublicInfo;
|
|
48683
|
+
var policy, weights, recoveryPolicy, budgets, unpersistedBudgets, cache, pending2, PREFIX, priorityRank, createHyperliquidPublicPriorityScope, promoteHyperliquidPublicPriority, abortError2, checkAbort, wait, storage, loadBudget, saveBudget, withBudgetLock, HyperliquidPublicReadError, getHyperliquidPublicReadBudget, cooldownError, recoveryWaitError, fallbackDelayMs, admit, cooldown, finishHyperliquidRecoveryRequest, assertHyperliquidRecoveryDispatch, cacheTtlMs, eligibleCache, reserveHyperliquidPublicReads, releaseHyperliquidPublicReadReservation, admitHyperliquidExchangeRequest, recordHyperliquidExchangeResponse, readHyperliquidPublicInfo;
|
|
48668
48684
|
var init_hyperliquid_public_read = __esm({
|
|
48669
48685
|
"lib/runtime/hyperliquid-public-read.ts"() {
|
|
48670
48686
|
"use strict";
|
|
@@ -48681,6 +48697,13 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48681
48697
|
cache = /* @__PURE__ */ new Map();
|
|
48682
48698
|
pending2 = /* @__PURE__ */ new Map();
|
|
48683
48699
|
PREFIX = "vtx:hl-public-read-budget:v1:";
|
|
48700
|
+
priorityRank = (priority) => runtime_policy_generated_default.exchange.hyperliquid.public_request_priority[priority];
|
|
48701
|
+
createHyperliquidPublicPriorityScope = (priority = "background") => ({ value: priority });
|
|
48702
|
+
promoteHyperliquidPublicPriority = (scope, priority) => {
|
|
48703
|
+
if (priorityRank(priority) >= priorityRank(scope.value)) return;
|
|
48704
|
+
scope.value = priority;
|
|
48705
|
+
scope.followers?.forEach((promote) => promote(priority));
|
|
48706
|
+
};
|
|
48684
48707
|
abortError2 = (signal) => signal?.reason instanceof Error ? signal.reason : new DOMException("Aborted", "AbortError");
|
|
48685
48708
|
checkAbort = (signal) => {
|
|
48686
48709
|
if (signal?.aborted) throw abortError2(signal);
|
|
@@ -48783,7 +48806,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48783
48806
|
recoveryPolicy.fallback_max_seconds * 1e3,
|
|
48784
48807
|
recoveryPolicy.fallback_initial_seconds * 1e3 * 2 ** Math.min(30, Math.max(0, failures - 1)) * (0.5 + Math.random())
|
|
48785
48808
|
);
|
|
48786
|
-
admit = async (apiUrl, requestType, signal, weightOverride, deadlineMs) => {
|
|
48809
|
+
admit = async (apiUrl, requestType, signal, weightOverride, deadlineMs, priority = createHyperliquidPublicPriorityScope()) => {
|
|
48787
48810
|
const key = `${PREFIX}${apiUrl}`;
|
|
48788
48811
|
const weight = weightOverride ?? weights[requestType] ?? policy.default_request_weight;
|
|
48789
48812
|
const ticket = crypto.randomUUID();
|
|
@@ -48803,12 +48826,15 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48803
48826
|
recovery.active = recovery.active.filter((entry) => entry.expiresAt > now);
|
|
48804
48827
|
recovery.queue = recovery.queue.filter((entry) => entry.expiresAt > now);
|
|
48805
48828
|
if (now >= deadline) throw recoveryWaitError(requestType);
|
|
48806
|
-
|
|
48807
|
-
if (
|
|
48829
|
+
const queued = recovery.queue.find((entry) => entry.id === ticket);
|
|
48830
|
+
if (queued) queued.priority = priorityRank(priority.value);
|
|
48831
|
+
else recovery.queue.push({ id: ticket, expiresAt: deadline, priority: priorityRank(priority.value) });
|
|
48832
|
+
const first = recovery.queue.reduce((best, item) => (item.priority ?? priorityRank("background")) < (best.priority ?? priorityRank("background")) ? item : best);
|
|
48833
|
+
if (first.id !== ticket || recovery.active.length >= recovery.concurrency || recovery.nextAt > now) {
|
|
48808
48834
|
saveBudget(key, budget);
|
|
48809
48835
|
return { ready: false, permit: null };
|
|
48810
48836
|
}
|
|
48811
|
-
recovery.queue.
|
|
48837
|
+
recovery.queue = recovery.queue.filter((entry) => entry.id !== ticket);
|
|
48812
48838
|
const expiresAt = now + recoveryPolicy.permit_lease_seconds * 1e3;
|
|
48813
48839
|
recovery.active.push({ id: ticket, expiresAt });
|
|
48814
48840
|
recovery.nextAt = now + recoveryPolicy.recovery_min_spacing_ms;
|
|
@@ -48920,10 +48946,10 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48920
48946
|
releaseHyperliquidPublicReadReservation = async (reservation) => {
|
|
48921
48947
|
reservation.closed = true;
|
|
48922
48948
|
};
|
|
48923
|
-
admitHyperliquidExchangeRequest = async (endpoint, action, signal) => {
|
|
48949
|
+
admitHyperliquidExchangeRequest = async (endpoint, action, signal, priority = "trading_execute") => {
|
|
48924
48950
|
const batchLength = Math.max(0, ...[action.orders, action.cancels, action.modifies].filter(Array.isArray).map((value) => value.length));
|
|
48925
48951
|
const weight = weights.exchange + Math.floor(batchLength / runtime_policy_generated_default.exchange.hyperliquid.read_budget.exchange_action_batch_size);
|
|
48926
|
-
return admit(endpoint.replace(/\/$/, ""), "exchange", signal, weight);
|
|
48952
|
+
return admit(endpoint.replace(/\/$/, ""), "exchange", signal, weight, void 0, createHyperliquidPublicPriorityScope(priority));
|
|
48927
48953
|
};
|
|
48928
48954
|
recordHyperliquidExchangeResponse = async (endpoint, response, permit) => {
|
|
48929
48955
|
if (response.status === 429) await cooldown(endpoint.replace(/\/$/, ""), response.headers.get("Retry-After"));
|
|
@@ -48934,6 +48960,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48934
48960
|
const requestType = String(body.type ?? "info");
|
|
48935
48961
|
const cacheOptions = { ...options, cacheValidUntilMs: options.reservation?.cacheValidUntilMs ?? options.cacheValidUntilMs };
|
|
48936
48962
|
const ttlMs = cacheTtlMs(body, cacheOptions);
|
|
48963
|
+
const priority = options.priorityScope ?? options.reservation?.priorityScope ?? createHyperliquidPublicPriorityScope(options.publicRequestPriority);
|
|
48937
48964
|
const key = `${apiUrl}:${JSON.stringify(body)}`;
|
|
48938
48965
|
checkAbort(options.signal);
|
|
48939
48966
|
const transportPolicy = runtime_policy_generated_default.exchange.hyperliquid.http.public_critical;
|
|
@@ -48977,28 +49004,35 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48977
49004
|
if (existing) return existing;
|
|
48978
49005
|
const running = pending2.get(key);
|
|
48979
49006
|
if (!running) break;
|
|
49007
|
+
promoteHyperliquidPublicPriority(running.priority, priority.value);
|
|
48980
49008
|
setPendingPhase("cache");
|
|
48981
49009
|
await new Promise((resolve13, reject) => {
|
|
48982
|
-
const
|
|
49010
|
+
const promoteOwner = (next) => promoteHyperliquidPublicPriority(running.priority, next);
|
|
49011
|
+
const cleanup = () => {
|
|
48983
49012
|
signal.removeEventListener("abort", aborted2);
|
|
49013
|
+
priority.followers?.delete(promoteOwner);
|
|
49014
|
+
};
|
|
49015
|
+
const aborted2 = () => {
|
|
49016
|
+
cleanup();
|
|
48984
49017
|
reject(abortError2(signal));
|
|
48985
49018
|
};
|
|
49019
|
+
if (running.priority !== priority) (priority.followers ??= /* @__PURE__ */ new Set()).add(promoteOwner);
|
|
48986
49020
|
signal.addEventListener("abort", aborted2, { once: true });
|
|
48987
|
-
running.then(() => {
|
|
48988
|
-
|
|
49021
|
+
running.promise.then(() => {
|
|
49022
|
+
cleanup();
|
|
48989
49023
|
resolve13();
|
|
48990
49024
|
});
|
|
48991
49025
|
});
|
|
48992
49026
|
checkAbort(signal);
|
|
48993
49027
|
}
|
|
48994
|
-
pending2.set(key, new Promise((resolve13) => {
|
|
49028
|
+
pending2.set(key, { promise: new Promise((resolve13) => {
|
|
48995
49029
|
settled = resolve13;
|
|
48996
|
-
}));
|
|
49030
|
+
}), priority });
|
|
48997
49031
|
}
|
|
48998
49032
|
if (options.reservation?.closed) throw new DOMException("Hyperliquid account read was cancelled.", "AbortError");
|
|
48999
49033
|
acquiring = true;
|
|
49000
49034
|
setPendingPhase("admission");
|
|
49001
|
-
permit = await admit(apiUrl, requestType, signal, void 0, deadline);
|
|
49035
|
+
permit = await admit(apiUrl, requestType, signal, void 0, deadline, priority);
|
|
49002
49036
|
acquiring = false;
|
|
49003
49037
|
armDeadline(Math.min(deadline, permit?.expiresAt ?? Infinity));
|
|
49004
49038
|
checkAbort(signal);
|
|
@@ -50853,10 +50887,10 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50853
50887
|
throw error48;
|
|
50854
50888
|
}
|
|
50855
50889
|
};
|
|
50856
|
-
fetchHyperliquidInfoRead = async (apiUrl, body, signal, reservation) => {
|
|
50890
|
+
fetchHyperliquidInfoRead = async (apiUrl, body, signal, reservation, priorityScope) => {
|
|
50857
50891
|
const trace = startRuntimeNetworkDebugTrace({ kind: "exchange", label: `hyperliquid_info:${String(body.type)}`, method: "POST", url: `${apiUrl.replace(/\/$/, "")}/info` });
|
|
50858
50892
|
try {
|
|
50859
|
-
const result2 = await readHyperliquidPublicInfo(apiUrl, body, { signal, reservation });
|
|
50893
|
+
const result2 = await readHyperliquidPublicInfo(apiUrl, body, { signal, reservation, priorityScope });
|
|
50860
50894
|
trace.completeSuccess(200);
|
|
50861
50895
|
return result2;
|
|
50862
50896
|
} catch (error48) {
|
|
@@ -50864,7 +50898,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50864
50898
|
throw error48;
|
|
50865
50899
|
}
|
|
50866
50900
|
};
|
|
50867
|
-
fetchHyperliquidInfoPayload = async (apiUrl, body, signal, reservation) => (await fetchHyperliquidInfoRead(apiUrl, body, signal, reservation)).payload;
|
|
50901
|
+
fetchHyperliquidInfoPayload = async (apiUrl, body, signal, reservation, priorityScope) => (await fetchHyperliquidInfoRead(apiUrl, body, signal, reservation, priorityScope)).payload;
|
|
50868
50902
|
requireHyperliquidApiUrl = (config2) => {
|
|
50869
50903
|
const apiUrl = String(config2.client_runtime_exchange_endpoints?.hyperliquid_api_url || "").trim();
|
|
50870
50904
|
if (!apiUrl) {
|
|
@@ -50944,7 +50978,11 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50944
50978
|
], now)) {
|
|
50945
50979
|
return withAccountStateEvidence(cached2.result, "stale_if_429", cached2.fetchedAtMs, staleIf429MaxAgeMs);
|
|
50946
50980
|
}
|
|
50947
|
-
|
|
50981
|
+
const existingFlight = input.forceRefresh ? void 0 : browserAccountStateInFlight.get(cacheKey);
|
|
50982
|
+
const priority = existingFlight?.priority ?? createHyperliquidPublicPriorityScope(input.publicRequestPriority ?? "ui");
|
|
50983
|
+
promoteHyperliquidPublicPriority(priority, input.publicRequestPriority ?? "ui");
|
|
50984
|
+
input = { ...input, priorityScope: priority };
|
|
50985
|
+
let inFlight = existingFlight?.promise;
|
|
50948
50986
|
if (!inFlight) {
|
|
50949
50987
|
const uncachedInput = input.forceRefresh ? input : (({ signal: _callerSignal, ...sharedInput }) => sharedInput)(input);
|
|
50950
50988
|
inFlight = fetchBrowserAccountStateUncached({
|
|
@@ -50967,7 +51005,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50967
51005
|
}
|
|
50968
51006
|
});
|
|
50969
51007
|
if (!input.forceRefresh) {
|
|
50970
|
-
browserAccountStateInFlight.set(cacheKey, inFlight);
|
|
51008
|
+
browserAccountStateInFlight.set(cacheKey, { promise: inFlight, priority });
|
|
50971
51009
|
}
|
|
50972
51010
|
}
|
|
50973
51011
|
try {
|
|
@@ -51007,6 +51045,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51007
51045
|
{ type: "userDexAbstraction", user: walletAddress }
|
|
51008
51046
|
] : []
|
|
51009
51047
|
], input.signal, { cacheAccountMode: true, cacheValidUntilMs: input.publicReadDeadlineMs });
|
|
51048
|
+
reservation.priorityScope = input.priorityScope;
|
|
51010
51049
|
if (input.onPublicReadPendingChange) {
|
|
51011
51050
|
const pending3 = { cache: 0, admission: 0, transport: 0 };
|
|
51012
51051
|
const reportPending = input.onPublicReadPendingChange;
|
|
@@ -51324,21 +51363,28 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51324
51363
|
let evidenceSource = "live";
|
|
51325
51364
|
let fetchedAtMs = now;
|
|
51326
51365
|
const olderInFlight = browserUserFillsInFlight.get(cacheKey);
|
|
51366
|
+
if (olderInFlight) promoteHyperliquidPublicPriority(olderInFlight.priority, input.publicRequestPriority ?? "ui");
|
|
51327
51367
|
if (input.forceRefresh && olderInFlight) {
|
|
51328
51368
|
try {
|
|
51329
|
-
await waitForSharedBrowserUserFills(olderInFlight, input.signal);
|
|
51369
|
+
await waitForSharedBrowserUserFills(olderInFlight.promise, input.signal);
|
|
51330
51370
|
} catch (error48) {
|
|
51331
51371
|
if (input.signal?.aborted) {
|
|
51332
51372
|
throw error48;
|
|
51333
51373
|
}
|
|
51334
51374
|
}
|
|
51335
51375
|
}
|
|
51336
|
-
|
|
51376
|
+
const existingFlight = browserUserFillsInFlight.get(cacheKey);
|
|
51377
|
+
const priority = existingFlight?.priority ?? createHyperliquidPublicPriorityScope(input.publicRequestPriority ?? "ui");
|
|
51378
|
+
promoteHyperliquidPublicPriority(priority, input.publicRequestPriority ?? "ui");
|
|
51379
|
+
let inFlight = existingFlight?.promise;
|
|
51337
51380
|
if (!inFlight) {
|
|
51338
51381
|
let freshRequest;
|
|
51339
51382
|
freshRequest = fetchHyperliquidInfoPayload(
|
|
51340
51383
|
apiUrl,
|
|
51341
|
-
{ type: "userFills", user: walletAddress }
|
|
51384
|
+
{ type: "userFills", user: walletAddress },
|
|
51385
|
+
void 0,
|
|
51386
|
+
void 0,
|
|
51387
|
+
priority
|
|
51342
51388
|
).then((payload) => {
|
|
51343
51389
|
const providerRowCount2 = Array.isArray(payload) ? payload.length : 0;
|
|
51344
51390
|
const rawFills2 = Array.isArray(payload) ? payload.filter(isPerpFill).map((fill) => ({ ...fill })) : [];
|
|
@@ -51349,12 +51395,12 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51349
51395
|
});
|
|
51350
51396
|
return { fetchedAtMs: Date.now(), rawFills: rawFills2, providerRowCount: providerRowCount2 };
|
|
51351
51397
|
}).finally(() => {
|
|
51352
|
-
if (browserUserFillsInFlight.get(cacheKey) === freshRequest) {
|
|
51398
|
+
if (browserUserFillsInFlight.get(cacheKey)?.promise === freshRequest) {
|
|
51353
51399
|
browserUserFillsInFlight.delete(cacheKey);
|
|
51354
51400
|
}
|
|
51355
51401
|
});
|
|
51356
51402
|
inFlight = freshRequest;
|
|
51357
|
-
browserUserFillsInFlight.set(cacheKey, inFlight);
|
|
51403
|
+
browserUserFillsInFlight.set(cacheKey, { promise: inFlight, priority });
|
|
51358
51404
|
}
|
|
51359
51405
|
try {
|
|
51360
51406
|
const liveResult = await waitForSharedBrowserUserFills(inFlight, input.signal);
|
|
@@ -51386,7 +51432,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51386
51432
|
}
|
|
51387
51433
|
};
|
|
51388
51434
|
};
|
|
51389
|
-
fetchBrowserPositionSnapshot = async (config2, walletAddress, symbol2, signal) => {
|
|
51435
|
+
fetchBrowserPositionSnapshot = async (config2, walletAddress, symbol2, signal, publicRequestPriority = "ui") => {
|
|
51390
51436
|
configureHyperliquidMarketSymbolCasing(config2.client_runtime_hyperliquid_case_sensitive_symbols);
|
|
51391
51437
|
const apiUrl = requireHyperliquidApiUrl(config2);
|
|
51392
51438
|
const normalizedWallet = requireWalletAddress(walletAddress);
|
|
@@ -51399,7 +51445,9 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51399
51445
|
const payload = await fetchHyperliquidInfoPayload(
|
|
51400
51446
|
apiUrl,
|
|
51401
51447
|
payloadBody,
|
|
51402
|
-
signal
|
|
51448
|
+
signal,
|
|
51449
|
+
void 0,
|
|
51450
|
+
createHyperliquidPublicPriorityScope(publicRequestPriority)
|
|
51403
51451
|
);
|
|
51404
51452
|
return parseInfoPositionSnapshot(
|
|
51405
51453
|
dex ? prefixHip3PositionCoins(payload, dex) : payload,
|
|
@@ -51982,6 +52030,7 @@ var init_billing = __esm({
|
|
|
51982
52030
|
async function getExecutionAssetMetadata(exchange, symbol2, options) {
|
|
51983
52031
|
const params = new URLSearchParams();
|
|
51984
52032
|
if (options?.includePrivateContext) params.set("include_private_context", "true");
|
|
52033
|
+
if (options?.publicRequestPriority) params.set("public_request_priority", options.publicRequestPriority);
|
|
51985
52034
|
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
51986
52035
|
const url2 = `${API_URL}/trading/execution-metadata/${encodeURIComponent(exchange)}/${encodeURIComponent(symbol2)}${query}`;
|
|
51987
52036
|
const response = await fetch(url2, {
|
|
@@ -83953,7 +84002,7 @@ var init_hyperliquid_signer = __esm({
|
|
|
83953
84002
|
});
|
|
83954
84003
|
|
|
83955
84004
|
// lib/runtime/hyperliquid-client.ts
|
|
83956
|
-
var HyperliquidExchangeRejectionError, durableMutationAuthorityArgs, assertFreshPreparedExecutionContext, HYPERLIQUID_TERMINAL_ORDER_STATUSES, normalizeSymbol, HYPERLIQUID_NONCE_STORAGE_KEY, HYPERLIQUID_NONCE_LOCK_NAME, lastGeneratedNonce, readBrowserStoredHyperliquidNonce, writeBrowserStoredHyperliquidNonce, browserNonceCoordinator, allocateHyperliquidNonce, generateHyperliquidNonce, roundToSigFigs, normalizeDecimalString, toPlainDecimalString, roundDirectionalDecimalString, formatHyperliquidPerpPriceWire, formatHyperliquidTriggerPriceWire, countSignificantDigits, countDecimalPlaces, validateHyperliquidPerpPriceWire, validateHyperliquidSizeWire, formatSizeWire, inferApiUrl, inferIsTestnet, postHyperliquidInfo, toFiniteNumber, OPEN_ORDER_NUMERIC_STRING, OPEN_ORDER_ID_STRING, parseCanonicalOpenOrderId, parseOpenOrderFiniteNumber, parseOpenOrderPositiveNumber, parseOpenOrderPresentationNumber, readOpenOrderField, firstFiniteNumber2, parseFundingUsdcFromInfoPosition2, isExchangeIsolatedOnly, computeHip3AssetId, getPerpDexIndexMap, buildAssetInfosFromMetaResponse, requireWalletAddress2, assertPositiveInteger, assertPositiveNumber, normalizeOrderSide, normalizeHyperliquidClientOrderId, resolveAssets, findResolvedAsset, normalizeExecutionAssetMetadata, resolveHyperliquidAsset, resolveHyperliquidAssetIndex, fetchBrowserAvailableAssets, fetchBrowserAllMids, fetchBrowserSymbolMidPrice, fetchBrowserOpenOrders, parseCanonicalHyperliquidOrderStatusEvidence, fetchBrowserOrderStatusEvidence, fetchBrowserUserRole, fetchBrowserAccountState2, fetchBrowserPosition, buildHyperliquidOrderWire, buildHyperliquidTriggerOrderWire, signHyperliquidPayload, buildHyperliquidCancelPayload, buildHyperliquidUpdateLeveragePayload, buildHyperliquidMarketOrderPayload, buildHyperliquidTriggerOrderPayload, buildHyperliquidOrderBatchPayload, buildHyperliquidModifyOrderPayload, extractHyperliquidExchangeError, isDefinitiveHyperliquidExchangeResponse, extractDefinitiveHyperliquidOrderId, CANONICAL_POSITIVE_DECIMAL_PATTERN, extractCanonicalHyperliquidOrderStateAcknowledgement, extractCanonicalHyperliquidOrderStateAcknowledgements, extractCanonicalHyperliquidFilledOrderAcknowledgement, extractDefinitiveHyperliquidOrderMemberResults, buildHyperliquidOrderDiagnostics, loadClientExecutionReferenceEvidence, sha256Hex, extractSignedPayloadClientOrderId, extractSignedPayloadMutationCorrelation, assertDurableMutationMatchesSignedAction, submitHyperliquidExchangePayload;
|
|
84005
|
+
var HyperliquidExchangeRejectionError, durableMutationAuthorityArgs, assertFreshPreparedExecutionContext, HYPERLIQUID_TERMINAL_ORDER_STATUSES, normalizeSymbol, HYPERLIQUID_NONCE_STORAGE_KEY, HYPERLIQUID_NONCE_LOCK_NAME, lastGeneratedNonce, readBrowserStoredHyperliquidNonce, writeBrowserStoredHyperliquidNonce, browserNonceCoordinator, allocateHyperliquidNonce, generateHyperliquidNonce, roundToSigFigs, normalizeDecimalString, toPlainDecimalString, roundDirectionalDecimalString, formatHyperliquidPerpPriceWire, formatHyperliquidTriggerPriceWire, countSignificantDigits, countDecimalPlaces, validateHyperliquidPerpPriceWire, validateHyperliquidSizeWire, formatSizeWire, inferApiUrl, inferIsTestnet, postHyperliquidInfo, toFiniteNumber, OPEN_ORDER_NUMERIC_STRING, OPEN_ORDER_ID_STRING, parseCanonicalOpenOrderId, parseOpenOrderFiniteNumber, parseOpenOrderPositiveNumber, parseOpenOrderPresentationNumber, readOpenOrderField, firstFiniteNumber2, parseFundingUsdcFromInfoPosition2, isExchangeIsolatedOnly, computeHip3AssetId, getPerpDexIndexMap, buildAssetInfosFromMetaResponse, requireWalletAddress2, assertPositiveInteger, assertPositiveNumber, normalizeOrderSide, normalizeHyperliquidClientOrderId, resolveAssets, findResolvedAsset, normalizeExecutionAssetMetadata, resolveHyperliquidAsset, resolveHyperliquidAssetIndex, fetchBrowserAvailableAssets, fetchBrowserAllMids, fetchBrowserSymbolMidPrice, fetchBrowserOpenOrders, parseCanonicalHyperliquidOrderStatusEvidence, fetchBrowserOrderStatusEvidence, fetchBrowserUserRole, fetchBrowserAccountState2, fetchBrowserPosition, buildHyperliquidOrderWire, buildHyperliquidTriggerOrderWire, signHyperliquidPayload, buildHyperliquidCancelPayload, buildHyperliquidUpdateLeveragePayload, buildHyperliquidMarketOrderPayload, buildHyperliquidTriggerOrderPayload, buildHyperliquidOrderBatchPayload, buildHyperliquidModifyOrderPayload, extractHyperliquidExchangeError, isDefinitiveHyperliquidExchangeResponse, extractDefinitiveHyperliquidOrderId, CANONICAL_POSITIVE_DECIMAL_PATTERN, extractCanonicalHyperliquidOrderStateAcknowledgement, extractCanonicalHyperliquidOrderStateAcknowledgements, extractCanonicalHyperliquidFilledOrderAcknowledgement, extractDefinitiveHyperliquidOrderMemberResults, buildHyperliquidOrderDiagnostics, loadClientExecutionReferenceEvidence, sha256Hex, extractSignedPayloadClientOrderId, extractSignedPayloadMutationCorrelation, assertDurableMutationMatchesSignedAction, exchangeActionPriority, submitHyperliquidExchangePayload;
|
|
83957
84006
|
var init_hyperliquid_client = __esm({
|
|
83958
84007
|
"lib/runtime/hyperliquid-client.ts"() {
|
|
83959
84008
|
"use strict";
|
|
@@ -84229,7 +84278,7 @@ var init_hyperliquid_client = __esm({
|
|
|
84229
84278
|
url: requestUrl
|
|
84230
84279
|
});
|
|
84231
84280
|
try {
|
|
84232
|
-
const { payload } = await readHyperliquidPublicInfo(apiUrl, body, { signal: input.signal });
|
|
84281
|
+
const { payload } = await readHyperliquidPublicInfo(apiUrl, body, { signal: input.signal, publicRequestPriority: input.publicRequestPriority ?? "ui" });
|
|
84233
84282
|
trace.completeSuccess(200);
|
|
84234
84283
|
return payload;
|
|
84235
84284
|
} catch (error48) {
|
|
@@ -84487,7 +84536,7 @@ var init_hyperliquid_client = __esm({
|
|
|
84487
84536
|
}
|
|
84488
84537
|
}
|
|
84489
84538
|
try {
|
|
84490
|
-
const metadata = await getExecutionAssetMetadata("hyperliquid", symbol2);
|
|
84539
|
+
const metadata = input.publicRequestPriority === "trading_reduce" ? await getExecutionAssetMetadata("hyperliquid", symbol2, { publicRequestPriority: "trading_reduce" }) : await getExecutionAssetMetadata("hyperliquid", symbol2);
|
|
84491
84540
|
return normalizeExecutionAssetMetadata(symbol2, metadata);
|
|
84492
84541
|
} catch (executionMetadataError) {
|
|
84493
84542
|
const assets = await resolveAssets(input);
|
|
@@ -85000,6 +85049,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85000
85049
|
};
|
|
85001
85050
|
};
|
|
85002
85051
|
buildHyperliquidCancelPayload = async (input) => {
|
|
85052
|
+
input = { ...input, publicRequestPriority: input.publicRequestPriority ?? "trading_execute" };
|
|
85003
85053
|
const numericOrderId = typeof input.orderId === "number" ? input.orderId : Number.NaN;
|
|
85004
85054
|
const clientOrderId = typeof input.orderId === "string" ? normalizeHyperliquidClientOrderId(input.orderId) : void 0;
|
|
85005
85055
|
if (clientOrderId == null) {
|
|
@@ -85034,6 +85084,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85034
85084
|
};
|
|
85035
85085
|
};
|
|
85036
85086
|
buildHyperliquidUpdateLeveragePayload = async (input) => {
|
|
85087
|
+
input = { ...input, publicRequestPriority: "trading_execute" };
|
|
85037
85088
|
const apiUrl = inferApiUrl(input);
|
|
85038
85089
|
const asset = await resolveHyperliquidAsset(input);
|
|
85039
85090
|
const { signHyperliquidAction: signHyperliquidAction2 } = await Promise.resolve().then(() => (init_hyperliquid_signer(), hyperliquid_signer_exports));
|
|
@@ -85064,6 +85115,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85064
85115
|
};
|
|
85065
85116
|
};
|
|
85066
85117
|
buildHyperliquidMarketOrderPayload = async (input) => {
|
|
85118
|
+
input = { ...input, publicRequestPriority: input.reduceOnly === true ? "trading_reduce" : "trading_execute" };
|
|
85067
85119
|
assertPositiveNumber(input.size, "Hyperliquid order size");
|
|
85068
85120
|
assertPositiveNumber(input.estimatedPrice, "Hyperliquid estimated price");
|
|
85069
85121
|
const slippage = input.slippage == null ? 0.05 : Number(input.slippage);
|
|
@@ -85080,6 +85132,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85080
85132
|
});
|
|
85081
85133
|
};
|
|
85082
85134
|
buildHyperliquidTriggerOrderPayload = async (input) => {
|
|
85135
|
+
input = { ...input, publicRequestPriority: input.reduceOnly !== false ? "trading_reduce" : "trading_execute" };
|
|
85083
85136
|
const order = await buildHyperliquidTriggerOrderWire({
|
|
85084
85137
|
...input,
|
|
85085
85138
|
limitPrice: input.limitPrice ?? input.triggerPrice
|
|
@@ -85091,6 +85144,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85091
85144
|
});
|
|
85092
85145
|
};
|
|
85093
85146
|
buildHyperliquidOrderBatchPayload = async (input) => {
|
|
85147
|
+
input = { ...input, publicRequestPriority: input.members.some((m) => m.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
|
|
85094
85148
|
if (input.members.length < 2 || input.members.length > 16) {
|
|
85095
85149
|
throw new Error("Hyperliquid TP/SL batch must contain between 2 and 16 orders.");
|
|
85096
85150
|
}
|
|
@@ -85132,6 +85186,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85132
85186
|
});
|
|
85133
85187
|
};
|
|
85134
85188
|
buildHyperliquidModifyOrderPayload = async (input) => {
|
|
85189
|
+
input = { ...input, publicRequestPriority: (input.orderKind === "trigger" ? input.reduceOnly !== false : input.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
|
|
85135
85190
|
const modifyTarget = typeof input.orderId === "string" ? normalizeHyperliquidClientOrderId(input.orderId) : input.orderId;
|
|
85136
85191
|
if (typeof modifyTarget === "number") {
|
|
85137
85192
|
assertPositiveInteger(modifyTarget, "Hyperliquid order id");
|
|
@@ -85613,7 +85668,13 @@ var init_hyperliquid_client = __esm({
|
|
|
85613
85668
|
}
|
|
85614
85669
|
return signedAssetId;
|
|
85615
85670
|
};
|
|
85671
|
+
exchangeActionPriority = (action, requested) => {
|
|
85672
|
+
if (action.type === "cancel" || action.type === "cancelByCloid") return requested === "trading_reduce" ? "trading_reduce" : "trading_execute";
|
|
85673
|
+
const orders = action.type === "order" && Array.isArray(action.orders) ? action.orders : action.type === "modify" ? [action.order] : [];
|
|
85674
|
+
return orders.length > 0 && orders.every((order) => order && typeof order === "object" && order.r === true) ? "trading_reduce" : "trading_execute";
|
|
85675
|
+
};
|
|
85616
85676
|
submitHyperliquidExchangePayload = async (input) => {
|
|
85677
|
+
input = { ...input, publicRequestPriority: exchangeActionPriority(input.payload.action, input.publicRequestPriority) };
|
|
85617
85678
|
if (input.signal?.aborted) {
|
|
85618
85679
|
throw input.signal.reason instanceof Error ? input.signal.reason : new DOMException("The operation was aborted.", "AbortError");
|
|
85619
85680
|
}
|
|
@@ -85788,7 +85849,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85788
85849
|
}
|
|
85789
85850
|
}
|
|
85790
85851
|
try {
|
|
85791
|
-
recoveryPermit = await admitHyperliquidExchangeRequest(apiUrl, input.payload.action, input.signal);
|
|
85852
|
+
recoveryPermit = await admitHyperliquidExchangeRequest(apiUrl, input.payload.action, input.signal, input.publicRequestPriority);
|
|
85792
85853
|
assertFreshPreparedExecutionContext(input.preparedContext);
|
|
85793
85854
|
assertHyperliquidRecoveryDispatch(apiUrl, recoveryPermit, "exchange");
|
|
85794
85855
|
} catch (preparedContextError) {
|
|
@@ -85992,6 +86053,7 @@ var init_hyperliquid_signer_binding = __esm({
|
|
|
85992
86053
|
try {
|
|
85993
86054
|
roleResponse = await fetchBrowserUserRole({
|
|
85994
86055
|
config: input.config ?? null,
|
|
86056
|
+
publicRequestPriority: input.publicRequestPriority ?? "ui",
|
|
85995
86057
|
walletAddress: signerAddress,
|
|
85996
86058
|
signal: input.signal
|
|
85997
86059
|
});
|
|
@@ -86892,6 +86954,7 @@ var init_browser_trading = __esm({
|
|
|
86892
86954
|
signingKey,
|
|
86893
86955
|
walletAddress,
|
|
86894
86956
|
config: input.config ?? null,
|
|
86957
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86895
86958
|
signal: input.signal
|
|
86896
86959
|
});
|
|
86897
86960
|
return signingKey;
|
|
@@ -86903,12 +86966,13 @@ var init_browser_trading = __esm({
|
|
|
86903
86966
|
}
|
|
86904
86967
|
return walletAddress;
|
|
86905
86968
|
};
|
|
86906
|
-
resolveEstimatedPrice = async (config2, symbol2, explicitPrice, signal) => {
|
|
86969
|
+
resolveEstimatedPrice = async (config2, symbol2, explicitPrice, signal, publicRequestPriority = "trading_execute") => {
|
|
86907
86970
|
if (typeof explicitPrice === "number" && Number.isFinite(explicitPrice) && explicitPrice > 0) {
|
|
86908
86971
|
return explicitPrice;
|
|
86909
86972
|
}
|
|
86910
86973
|
const price = await fetchBrowserSymbolMidPrice({
|
|
86911
86974
|
config: config2 ?? null,
|
|
86975
|
+
publicRequestPriority,
|
|
86912
86976
|
symbol: symbol2,
|
|
86913
86977
|
signal
|
|
86914
86978
|
});
|
|
@@ -86916,12 +86980,14 @@ var init_browser_trading = __esm({
|
|
|
86916
86980
|
return price;
|
|
86917
86981
|
};
|
|
86918
86982
|
executeClientLeverageUpdate = async (input) => {
|
|
86983
|
+
input = { ...input, publicRequestPriority: "trading_execute" };
|
|
86919
86984
|
throwIfAborted(input.signal);
|
|
86920
86985
|
const signingKey = await resolveSigningKey(input);
|
|
86921
86986
|
throwIfAborted(input.signal);
|
|
86922
86987
|
const mutation = createExchangeMutationIdentity(false);
|
|
86923
86988
|
const payload = await buildHyperliquidUpdateLeveragePayload({
|
|
86924
86989
|
config: input.config ?? null,
|
|
86990
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86925
86991
|
signingKey,
|
|
86926
86992
|
symbol: input.symbol,
|
|
86927
86993
|
leverage: input.leverage,
|
|
@@ -86930,6 +86996,7 @@ var init_browser_trading = __esm({
|
|
|
86930
86996
|
});
|
|
86931
86997
|
return submitHyperliquidExchangePayload({
|
|
86932
86998
|
config: input.config ?? null,
|
|
86999
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86933
87000
|
payload,
|
|
86934
87001
|
signal: input.signal,
|
|
86935
87002
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -86946,15 +87013,17 @@ var init_browser_trading = __esm({
|
|
|
86946
87013
|
});
|
|
86947
87014
|
};
|
|
86948
87015
|
executeClientMarketOrder = async (input) => {
|
|
87016
|
+
input = { ...input, publicRequestPriority: input.reduceOnly === true ? "trading_reduce" : "trading_execute" };
|
|
86949
87017
|
throwIfAborted(input.signal);
|
|
86950
87018
|
const signingKey = await resolveSigningKey(input);
|
|
86951
87019
|
throwIfAborted(input.signal);
|
|
86952
|
-
const estimatedPrice = await resolveEstimatedPrice(input.config, input.symbol, input.estimatedPrice, input.signal);
|
|
87020
|
+
const estimatedPrice = await resolveEstimatedPrice(input.config, input.symbol, input.estimatedPrice, input.signal, input.publicRequestPriority);
|
|
86953
87021
|
throwIfAborted(input.signal);
|
|
86954
87022
|
assertFreshPreparedContext(input.preparedContext);
|
|
86955
87023
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
86956
87024
|
const payload = await buildHyperliquidMarketOrderPayload({
|
|
86957
87025
|
config: input.config ?? null,
|
|
87026
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86958
87027
|
signingKey,
|
|
86959
87028
|
symbol: input.symbol,
|
|
86960
87029
|
side: input.side,
|
|
@@ -86968,6 +87037,7 @@ var init_browser_trading = __esm({
|
|
|
86968
87037
|
});
|
|
86969
87038
|
return submitHyperliquidExchangePayload({
|
|
86970
87039
|
config: input.config ?? null,
|
|
87040
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86971
87041
|
payload,
|
|
86972
87042
|
signal: input.signal,
|
|
86973
87043
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -86986,12 +87056,14 @@ var init_browser_trading = __esm({
|
|
|
86986
87056
|
});
|
|
86987
87057
|
};
|
|
86988
87058
|
executeClientTriggerOrder = async (input) => {
|
|
87059
|
+
input = { ...input, publicRequestPriority: input.reduceOnly !== false ? "trading_reduce" : "trading_execute" };
|
|
86989
87060
|
throwIfAborted(input.signal);
|
|
86990
87061
|
const signingKey = await resolveSigningKey(input);
|
|
86991
87062
|
throwIfAborted(input.signal);
|
|
86992
87063
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
86993
87064
|
const payload = await buildHyperliquidTriggerOrderPayload({
|
|
86994
87065
|
config: input.config ?? null,
|
|
87066
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86995
87067
|
signingKey,
|
|
86996
87068
|
symbol: input.symbol,
|
|
86997
87069
|
side: input.side,
|
|
@@ -87006,6 +87078,7 @@ var init_browser_trading = __esm({
|
|
|
87006
87078
|
});
|
|
87007
87079
|
return submitHyperliquidExchangePayload({
|
|
87008
87080
|
config: input.config ?? null,
|
|
87081
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87009
87082
|
payload,
|
|
87010
87083
|
signal: input.signal,
|
|
87011
87084
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -87023,12 +87096,14 @@ var init_browser_trading = __esm({
|
|
|
87023
87096
|
});
|
|
87024
87097
|
};
|
|
87025
87098
|
executeClientOrderBatch = async (input) => {
|
|
87099
|
+
input = { ...input, publicRequestPriority: input.members.some((m) => m.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
|
|
87026
87100
|
throwIfAborted(input.signal);
|
|
87027
87101
|
const signingKey = await resolveSigningKey(input);
|
|
87028
87102
|
throwIfAborted(input.signal);
|
|
87029
87103
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
87030
87104
|
const payload = await buildHyperliquidOrderBatchPayload({
|
|
87031
87105
|
config: input.config ?? null,
|
|
87106
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87032
87107
|
signingKey,
|
|
87033
87108
|
symbol: input.symbol,
|
|
87034
87109
|
members: input.members,
|
|
@@ -87037,6 +87112,7 @@ var init_browser_trading = __esm({
|
|
|
87037
87112
|
});
|
|
87038
87113
|
return submitHyperliquidExchangePayload({
|
|
87039
87114
|
config: input.config ?? null,
|
|
87115
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87040
87116
|
payload,
|
|
87041
87117
|
signal: input.signal,
|
|
87042
87118
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -87055,12 +87131,14 @@ var init_browser_trading = __esm({
|
|
|
87055
87131
|
});
|
|
87056
87132
|
};
|
|
87057
87133
|
executeClientModifyOrder = async (input) => {
|
|
87134
|
+
input = { ...input, publicRequestPriority: (input.orderKind === "trigger" ? input.reduceOnly !== false : input.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
|
|
87058
87135
|
throwIfAborted(input.signal);
|
|
87059
87136
|
const signingKey = await resolveSigningKey(input);
|
|
87060
87137
|
throwIfAborted(input.signal);
|
|
87061
87138
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
87062
87139
|
const payload = await buildHyperliquidModifyOrderPayload({
|
|
87063
87140
|
config: input.config ?? null,
|
|
87141
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87064
87142
|
signingKey,
|
|
87065
87143
|
symbol: input.symbol,
|
|
87066
87144
|
orderId: input.orderId,
|
|
@@ -87078,6 +87156,7 @@ var init_browser_trading = __esm({
|
|
|
87078
87156
|
});
|
|
87079
87157
|
return submitHyperliquidExchangePayload({
|
|
87080
87158
|
config: input.config ?? null,
|
|
87159
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87081
87160
|
payload,
|
|
87082
87161
|
signal: input.signal,
|
|
87083
87162
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -87095,12 +87174,14 @@ var init_browser_trading = __esm({
|
|
|
87095
87174
|
});
|
|
87096
87175
|
};
|
|
87097
87176
|
executeClientCancelOrder = async (input) => {
|
|
87177
|
+
input = { ...input, publicRequestPriority: input.publicRequestPriority ?? "trading_execute" };
|
|
87098
87178
|
throwIfAborted(input.signal);
|
|
87099
87179
|
const signingKey = await resolveSigningKey(input);
|
|
87100
87180
|
throwIfAborted(input.signal);
|
|
87101
87181
|
const mutation = createExchangeMutationIdentity(false, input);
|
|
87102
87182
|
const payload = await buildHyperliquidCancelPayload({
|
|
87103
87183
|
config: input.config ?? null,
|
|
87184
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87104
87185
|
signingKey,
|
|
87105
87186
|
symbol: input.symbol,
|
|
87106
87187
|
orderId: input.orderId,
|
|
@@ -87108,6 +87189,7 @@ var init_browser_trading = __esm({
|
|
|
87108
87189
|
});
|
|
87109
87190
|
return submitHyperliquidExchangePayload({
|
|
87110
87191
|
config: input.config ?? null,
|
|
87192
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87111
87193
|
payload,
|
|
87112
87194
|
signal: input.signal,
|
|
87113
87195
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -87125,10 +87207,12 @@ var init_browser_trading = __esm({
|
|
|
87125
87207
|
});
|
|
87126
87208
|
};
|
|
87127
87209
|
executeClientClosePosition = async (input) => {
|
|
87210
|
+
input = { ...input, publicRequestPriority: "trading_reduce" };
|
|
87128
87211
|
throwIfAborted(input.signal);
|
|
87129
87212
|
const profileId = resolveProfileId(input.profileId);
|
|
87130
87213
|
const currentPosition = input.position ?? await fetchBrowserPosition({
|
|
87131
87214
|
config: input.config ?? null,
|
|
87215
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87132
87216
|
walletAddress: requireWalletAddress3(input.walletAddress),
|
|
87133
87217
|
symbol: input.symbol,
|
|
87134
87218
|
signal: input.signal
|
|
@@ -87149,6 +87233,7 @@ var init_browser_trading = __esm({
|
|
|
87149
87233
|
schedulerInstanceId: input.schedulerInstanceId,
|
|
87150
87234
|
walletAddress: input.walletAddress,
|
|
87151
87235
|
config: input.config ?? null,
|
|
87236
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87152
87237
|
signal: input.signal,
|
|
87153
87238
|
signingKey: input.signingKey,
|
|
87154
87239
|
symbol: input.symbol,
|
|
@@ -87394,7 +87479,7 @@ var init_execution_guard_contract = __esm({
|
|
|
87394
87479
|
});
|
|
87395
87480
|
|
|
87396
87481
|
// lib/runtime/runtime-execution.ts
|
|
87397
|
-
var fetchClientRuntimeOpenOrders, createRuntimeId, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, toPositiveNumber, resolveRiskPct, buildTriggerPrice, isConfiguredProtectionRequested, protectiveAction, isExactClientPositionTpslPair, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, recoverJournaledClientProtectiveAttachments, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep3, roundAssetSize, resolvePositionSize, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, verifyNoLiveClientProtectiveTriggers, executeClientRuntimeDecision;
|
|
87482
|
+
var executionReadPriority, fetchClientRuntimeOpenOrders, createRuntimeId, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, toPositiveNumber, resolveRiskPct, buildTriggerPrice, isConfiguredProtectionRequested, protectiveAction, isExactClientPositionTpslPair, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, recoverJournaledClientProtectiveAttachments, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep3, roundAssetSize, resolvePositionSize, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, verifyNoLiveClientProtectiveTriggers, executeClientRuntimeDecision;
|
|
87398
87483
|
var init_runtime_execution = __esm({
|
|
87399
87484
|
"lib/runtime/runtime-execution.ts"() {
|
|
87400
87485
|
"use strict";
|
|
@@ -87410,7 +87495,16 @@ var init_runtime_execution = __esm({
|
|
|
87410
87495
|
init_runtime_redaction();
|
|
87411
87496
|
init_error_surface_contract();
|
|
87412
87497
|
init_runtime_handoff();
|
|
87413
|
-
|
|
87498
|
+
executionReadPriority = (input) => {
|
|
87499
|
+
const context = input.executionContext;
|
|
87500
|
+
const classified = classifyExecutionIntent(
|
|
87501
|
+
input.decision,
|
|
87502
|
+
input.units,
|
|
87503
|
+
signedUnitsFromPosition(context.currentPositionSize, context.lastPrice, context.unitSizeUsdc)
|
|
87504
|
+
);
|
|
87505
|
+
return classified.reduceOnly ? "trading_reduce" : "trading_execute";
|
|
87506
|
+
};
|
|
87507
|
+
fetchClientRuntimeOpenOrders = async (request, publicRequestPriority = "trading_reconcile") => {
|
|
87414
87508
|
const normalizedSymbol = normalizeHyperliquidMarketSymbol(
|
|
87415
87509
|
request.executionContext.symbol
|
|
87416
87510
|
);
|
|
@@ -87419,6 +87513,7 @@ var init_runtime_execution = __esm({
|
|
|
87419
87513
|
}
|
|
87420
87514
|
const dex = getHyperliquidMarketDex(normalizedSymbol);
|
|
87421
87515
|
return fetchBrowserOpenOrders({
|
|
87516
|
+
publicRequestPriority,
|
|
87422
87517
|
config: request.config ?? null,
|
|
87423
87518
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
87424
87519
|
signal: request.signal,
|
|
@@ -88352,10 +88447,11 @@ var init_runtime_execution = __esm({
|
|
|
88352
88447
|
throw new Error("Protective cleanup intent could not be persisted durably.");
|
|
88353
88448
|
}
|
|
88354
88449
|
}
|
|
88355
|
-
const liveOrders = await fetchClientRuntimeOpenOrders(request);
|
|
88450
|
+
const liveOrders = await fetchClientRuntimeOpenOrders(request, "trading_reduce");
|
|
88356
88451
|
const liveOrder = liveOrders.find((order) => String(order.oid) === String(leg.orderId));
|
|
88357
88452
|
if (!liveOrder) {
|
|
88358
88453
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
88454
|
+
publicRequestPriority: "trading_reduce",
|
|
88359
88455
|
config: request.config ?? null,
|
|
88360
88456
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
88361
88457
|
signal: request.signal,
|
|
@@ -88410,6 +88506,7 @@ var init_runtime_execution = __esm({
|
|
|
88410
88506
|
throw new Error("Tracked protective order no longer has its exact authorized shape.");
|
|
88411
88507
|
}
|
|
88412
88508
|
await executeClientCancelOrder({
|
|
88509
|
+
publicRequestPriority: "trading_reduce",
|
|
88413
88510
|
profileId: request.profileId,
|
|
88414
88511
|
runtimeSessionId: request.sessionId || "__missing_runtime_session__",
|
|
88415
88512
|
runtimeLeaseToken: request.runtimeLeaseToken,
|
|
@@ -88524,7 +88621,8 @@ var init_runtime_execution = __esm({
|
|
|
88524
88621
|
request.config ?? {},
|
|
88525
88622
|
String(request.executionContext.walletAddress || "").trim(),
|
|
88526
88623
|
symbol2,
|
|
88527
|
-
request.signal
|
|
88624
|
+
request.signal,
|
|
88625
|
+
"trading_reduce"
|
|
88528
88626
|
);
|
|
88529
88627
|
const livePositionSize = Number(snapshot.size);
|
|
88530
88628
|
const directionMatches = Number.isFinite(livePositionSize) && (isLong ? livePositionSize > 0 : livePositionSize < 0);
|
|
@@ -89016,13 +89114,15 @@ var init_runtime_execution = __esm({
|
|
|
89016
89114
|
request.config ?? {},
|
|
89017
89115
|
walletAddress,
|
|
89018
89116
|
symbol2,
|
|
89019
|
-
request.signal
|
|
89117
|
+
request.signal,
|
|
89118
|
+
"trading_reconcile"
|
|
89020
89119
|
);
|
|
89021
89120
|
const livePositionSize = Number(livePosition.size);
|
|
89022
89121
|
if (!Number.isFinite(livePositionSize)) {
|
|
89023
89122
|
throw new Error("Journaled protective live exposure is unresolved.");
|
|
89024
89123
|
}
|
|
89025
89124
|
const { rawFills, evidence } = await fetchBrowserUserFills({
|
|
89125
|
+
publicRequestPriority: "trading_reconcile",
|
|
89026
89126
|
config: request.config ?? {},
|
|
89027
89127
|
walletAddress,
|
|
89028
89128
|
symbols: [symbol2],
|
|
@@ -89163,6 +89263,7 @@ var init_runtime_execution = __esm({
|
|
|
89163
89263
|
if (openOrder == null) {
|
|
89164
89264
|
try {
|
|
89165
89265
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
89266
|
+
publicRequestPriority: "trading_reconcile",
|
|
89166
89267
|
config: request.config ?? null,
|
|
89167
89268
|
walletAddress,
|
|
89168
89269
|
signal: request.signal,
|
|
@@ -89539,6 +89640,7 @@ var init_runtime_execution = __esm({
|
|
|
89539
89640
|
continue;
|
|
89540
89641
|
}
|
|
89541
89642
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
89643
|
+
publicRequestPriority: "trading_reconcile",
|
|
89542
89644
|
config: request.config ?? null,
|
|
89543
89645
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
89544
89646
|
signal: request.signal,
|
|
@@ -89551,6 +89653,7 @@ var init_runtime_execution = __esm({
|
|
|
89551
89653
|
throw new Error("Pending entry status or shape is unresolved.");
|
|
89552
89654
|
}
|
|
89553
89655
|
const { rawFills, evidence: fillEvidence } = await fetchBrowserUserFills({
|
|
89656
|
+
publicRequestPriority: "trading_reconcile",
|
|
89554
89657
|
config: request.config ?? {},
|
|
89555
89658
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
89556
89659
|
symbols: [symbol2],
|
|
@@ -89660,6 +89763,7 @@ var init_runtime_execution = __esm({
|
|
|
89660
89763
|
}
|
|
89661
89764
|
replacementCleanup = buildVetoedProtectiveReplacementCleanup(replacementReservation);
|
|
89662
89765
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
89766
|
+
publicRequestPriority: "trading_reconcile",
|
|
89663
89767
|
config: request.config ?? null,
|
|
89664
89768
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
89665
89769
|
signal: request.signal,
|
|
@@ -90003,6 +90107,7 @@ var init_runtime_execution = __esm({
|
|
|
90003
90107
|
const [journalLeg] = journalGroup.legs;
|
|
90004
90108
|
try {
|
|
90005
90109
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
90110
|
+
publicRequestPriority: "trading_reconcile",
|
|
90006
90111
|
config: request.config ?? null,
|
|
90007
90112
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
90008
90113
|
signal: request.signal,
|
|
@@ -90157,7 +90262,8 @@ var init_runtime_execution = __esm({
|
|
|
90157
90262
|
request.config ?? {},
|
|
90158
90263
|
walletAddress,
|
|
90159
90264
|
symbol2,
|
|
90160
|
-
request.signal
|
|
90265
|
+
request.signal,
|
|
90266
|
+
"trading_reconcile"
|
|
90161
90267
|
);
|
|
90162
90268
|
livePositionSize = Number(snapshot.size);
|
|
90163
90269
|
} catch (error48) {
|
|
@@ -90280,6 +90386,7 @@ var init_runtime_execution = __esm({
|
|
|
90280
90386
|
}
|
|
90281
90387
|
try {
|
|
90282
90388
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
90389
|
+
publicRequestPriority: "trading_reconcile",
|
|
90283
90390
|
config: request.config ?? null,
|
|
90284
90391
|
walletAddress,
|
|
90285
90392
|
signal: request.signal,
|
|
@@ -91189,6 +91296,7 @@ var init_runtime_execution = __esm({
|
|
|
91189
91296
|
if (shouldRefreshExecutionSnapshot) {
|
|
91190
91297
|
try {
|
|
91191
91298
|
const refreshed = await fetchBrowserAccountState({
|
|
91299
|
+
publicRequestPriority: executionReadPriority(input),
|
|
91192
91300
|
config: input.config ?? {},
|
|
91193
91301
|
walletAddress,
|
|
91194
91302
|
symbol: input.executionContext.symbol,
|
|
@@ -91221,7 +91329,8 @@ var init_runtime_execution = __esm({
|
|
|
91221
91329
|
input.config ?? {},
|
|
91222
91330
|
walletAddress,
|
|
91223
91331
|
input.executionContext.symbol,
|
|
91224
|
-
input.signal
|
|
91332
|
+
input.signal,
|
|
91333
|
+
executionReadPriority(input)
|
|
91225
91334
|
);
|
|
91226
91335
|
const parsedLiveSize = resolvePositionSize({
|
|
91227
91336
|
symbol: input.executionContext.symbol,
|
|
@@ -92121,7 +92230,8 @@ var init_runtime_execution = __esm({
|
|
|
92121
92230
|
input.config ?? {},
|
|
92122
92231
|
String(input.executionContext.walletAddress || "").trim(),
|
|
92123
92232
|
input.executionContext.symbol,
|
|
92124
|
-
input.signal
|
|
92233
|
+
input.signal,
|
|
92234
|
+
"trading_reduce"
|
|
92125
92235
|
);
|
|
92126
92236
|
const livePositionSize = Number(liveSnapshot.size);
|
|
92127
92237
|
const liveDirectionMatches = Number.isFinite(livePositionSize) && (isLong ? livePositionSize > 0 : livePositionSize < 0);
|
|
@@ -93453,6 +93563,7 @@ async function fetchLocalHyperliquidSnapshot(input) {
|
|
|
93453
93563
|
const promptKnobs = objectOrNull3(input.metadata.prompt_knobs) ?? {};
|
|
93454
93564
|
const leverage = requirePositiveNumber2(promptKnobs.leverage ?? input.llmConfig.default_leverage, "leverage");
|
|
93455
93565
|
const accountState = await input.fetchAccountState({
|
|
93566
|
+
publicRequestPriority: "trading_analysis",
|
|
93456
93567
|
config: executionConfig,
|
|
93457
93568
|
walletAddress,
|
|
93458
93569
|
symbol: input.symbol,
|