@vtxmacro/cli 2026.9.57 → 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 +198 -48
- 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;
|
|
@@ -48958,6 +48985,17 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48958
48985
|
let outcome = "cancelled";
|
|
48959
48986
|
let settled;
|
|
48960
48987
|
let acquiring = false;
|
|
48988
|
+
let observedRateLimit;
|
|
48989
|
+
let pendingPhase = null;
|
|
48990
|
+
const setPendingPhase = (next) => {
|
|
48991
|
+
if (next === pendingPhase) return;
|
|
48992
|
+
const previous = pendingPhase;
|
|
48993
|
+
pendingPhase = next;
|
|
48994
|
+
try {
|
|
48995
|
+
options.reservation?.onPendingPhaseChange?.(previous, next);
|
|
48996
|
+
} catch {
|
|
48997
|
+
}
|
|
48998
|
+
};
|
|
48961
48999
|
try {
|
|
48962
49000
|
checkAbort(signal);
|
|
48963
49001
|
if (ttlMs) {
|
|
@@ -48966,26 +49004,35 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48966
49004
|
if (existing) return existing;
|
|
48967
49005
|
const running = pending2.get(key);
|
|
48968
49006
|
if (!running) break;
|
|
49007
|
+
promoteHyperliquidPublicPriority(running.priority, priority.value);
|
|
49008
|
+
setPendingPhase("cache");
|
|
48969
49009
|
await new Promise((resolve13, reject) => {
|
|
48970
|
-
const
|
|
49010
|
+
const promoteOwner = (next) => promoteHyperliquidPublicPriority(running.priority, next);
|
|
49011
|
+
const cleanup = () => {
|
|
48971
49012
|
signal.removeEventListener("abort", aborted2);
|
|
49013
|
+
priority.followers?.delete(promoteOwner);
|
|
49014
|
+
};
|
|
49015
|
+
const aborted2 = () => {
|
|
49016
|
+
cleanup();
|
|
48972
49017
|
reject(abortError2(signal));
|
|
48973
49018
|
};
|
|
49019
|
+
if (running.priority !== priority) (priority.followers ??= /* @__PURE__ */ new Set()).add(promoteOwner);
|
|
48974
49020
|
signal.addEventListener("abort", aborted2, { once: true });
|
|
48975
|
-
running.then(() => {
|
|
48976
|
-
|
|
49021
|
+
running.promise.then(() => {
|
|
49022
|
+
cleanup();
|
|
48977
49023
|
resolve13();
|
|
48978
49024
|
});
|
|
48979
49025
|
});
|
|
48980
49026
|
checkAbort(signal);
|
|
48981
49027
|
}
|
|
48982
|
-
pending2.set(key, new Promise((resolve13) => {
|
|
49028
|
+
pending2.set(key, { promise: new Promise((resolve13) => {
|
|
48983
49029
|
settled = resolve13;
|
|
48984
|
-
}));
|
|
49030
|
+
}), priority });
|
|
48985
49031
|
}
|
|
48986
49032
|
if (options.reservation?.closed) throw new DOMException("Hyperliquid account read was cancelled.", "AbortError");
|
|
48987
49033
|
acquiring = true;
|
|
48988
|
-
|
|
49034
|
+
setPendingPhase("admission");
|
|
49035
|
+
permit = await admit(apiUrl, requestType, signal, void 0, deadline, priority);
|
|
48989
49036
|
acquiring = false;
|
|
48990
49037
|
armDeadline(Math.min(deadline, permit?.expiresAt ?? Infinity));
|
|
48991
49038
|
checkAbort(signal);
|
|
@@ -49001,6 +49048,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
49001
49048
|
signal.addEventListener("abort", transportAborted, { once: true });
|
|
49002
49049
|
});
|
|
49003
49050
|
const transport = (async () => {
|
|
49051
|
+
setPendingPhase("transport");
|
|
49004
49052
|
const received = await fetch(`${apiUrl}/info`, {
|
|
49005
49053
|
method: "POST",
|
|
49006
49054
|
headers: { "Content-Type": "application/json" },
|
|
@@ -49009,8 +49057,9 @@ var init_hyperliquid_public_read = __esm({
|
|
|
49009
49057
|
});
|
|
49010
49058
|
checkAbort(signal);
|
|
49011
49059
|
if (received.status === 429) {
|
|
49060
|
+
observedRateLimit = new HyperliquidPublicReadError("public_rate_limited", "Hyperliquid public API returned HTTP 429.", requestType, 429);
|
|
49012
49061
|
await cooldown(apiUrl, received.headers.get("Retry-After"));
|
|
49013
|
-
throw
|
|
49062
|
+
throw observedRateLimit;
|
|
49014
49063
|
}
|
|
49015
49064
|
const receivedPayload = await received.json().catch((error48) => {
|
|
49016
49065
|
if (error48 instanceof SyntaxError) return {};
|
|
@@ -49021,6 +49070,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
49021
49070
|
})();
|
|
49022
49071
|
({ response, payload } = await Promise.race([transport, aborted2]));
|
|
49023
49072
|
} finally {
|
|
49073
|
+
setPendingPhase(null);
|
|
49024
49074
|
if (transportAborted) signal.removeEventListener("abort", transportAborted);
|
|
49025
49075
|
}
|
|
49026
49076
|
if (!response.ok) {
|
|
@@ -49038,6 +49088,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
49038
49088
|
}
|
|
49039
49089
|
return result2;
|
|
49040
49090
|
} catch (error48) {
|
|
49091
|
+
if (observedRateLimit) throw observedRateLimit;
|
|
49041
49092
|
if (options.signal?.aborted) {
|
|
49042
49093
|
outcome = "cancelled";
|
|
49043
49094
|
throw abortError2(options.signal);
|
|
@@ -49048,6 +49099,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
49048
49099
|
if (error48 instanceof Error && (error48.name === "TimeoutError" || error48.name === "AbortError")) throw new HyperliquidPublicReadError("public_timeout", "Hyperliquid public request timed out.", requestType);
|
|
49049
49100
|
throw error48;
|
|
49050
49101
|
} finally {
|
|
49102
|
+
setPendingPhase(null);
|
|
49051
49103
|
clearTimeout(timer);
|
|
49052
49104
|
options.signal?.removeEventListener("abort", callerAborted);
|
|
49053
49105
|
controller.abort();
|
|
@@ -50155,7 +50207,7 @@ var init_network_debug = __esm({
|
|
|
50155
50207
|
});
|
|
50156
50208
|
|
|
50157
50209
|
// lib/runtime/hyperliquid-account-state-adapter.ts
|
|
50158
|
-
var unsupportedUserActiveAssetCache, MAX_UNSUPPORTED_USER_ACTIVE_ASSET_CACHE_KEYS, UNSUPPORTED_USER_ACTIVE_ASSET_STORAGE_KEY, USER_FILLS_CACHE_STORAGE_PREFIX, ACCOUNT_STATE_CACHE_STORAGE_PREFIX, browserUserFillsCache, browserUserFillsInFlight, HYPERLIQUID_USER_FILLS_PROVIDER_PAGE_CAP, browserAccountStateCache, browserAccountStateInFlight, UNSUPPORTED_USER_ACTIVE_ASSET_DETAIL_PATTERNS, unsupportedUserActiveAssetCacheHydrated, hydrateUnsupportedUserActiveAssetCache, persistUnsupportedUserActiveAssetCache, toPositiveFinite, toFinite, firstFiniteNumber, parseFundingUsdcFromInfoPosition, buildActiveAssetCacheKey, buildUserFillsCacheKey, buildUserFillsStorageKey, buildAccountStateCacheKey, buildAccountStateStorageKey, hasActiveInfoRateLimitCooldown, requireNonNegativeConfigSeconds, requireAccountStateCacheConfig, requireUserFillsCacheConfig, normalizeFillSymbol, buildSymbolFilter, filterFillsBySymbols, readBrowserUserFillsCache, writeBrowserUserFillsCache, cloneBrowserAccountStateResult, withAccountStateEvidence, readBrowserAccountStateCache, writeBrowserAccountStateCache, isRateLimitError, createAbortError, waitForSharedBrowserRequest, waitForSharedBrowserUserFills, getBrowserActiveAssetTypeCandidates, normalizeHyperliquidErrorDetail, isUnsupportedUserActiveAssetError, rememberUnsupportedUserActiveAssetKey, parseInfoPositions, requireFinitePromptMetric, requirePromptClearinghouseState, requirePromptSpotState, normalizePerpDexName, listConfiguredPerpDexs, listPerpDexsForAccountState, prefixHip3PositionCoins, aggregateClearinghouseResponses, hasCompletePerpDexAccountMetrics, normalizeBrowserFillToTradeHistory, isPerpFill,
|
|
50210
|
+
var unsupportedUserActiveAssetCache, MAX_UNSUPPORTED_USER_ACTIVE_ASSET_CACHE_KEYS, UNSUPPORTED_USER_ACTIVE_ASSET_STORAGE_KEY, USER_FILLS_CACHE_STORAGE_PREFIX, ACCOUNT_STATE_CACHE_STORAGE_PREFIX, browserUserFillsCache, browserUserFillsInFlight, HYPERLIQUID_USER_FILLS_PROVIDER_PAGE_CAP, browserAccountStateCache, browserAccountStateInFlight, UNSUPPORTED_USER_ACTIVE_ASSET_DETAIL_PATTERNS, unsupportedUserActiveAssetCacheHydrated, hydrateUnsupportedUserActiveAssetCache, persistUnsupportedUserActiveAssetCache, toPositiveFinite, toFinite, firstFiniteNumber, parseFundingUsdcFromInfoPosition, buildActiveAssetCacheKey, buildUserFillsCacheKey, buildUserFillsStorageKey, buildAccountStateCacheKey, buildAccountStateStorageKey, hasActiveInfoRateLimitCooldown, requireNonNegativeConfigSeconds, requireAccountStateCacheConfig, requireUserFillsCacheConfig, normalizeFillSymbol, buildSymbolFilter, filterFillsBySymbols, readBrowserUserFillsCache, writeBrowserUserFillsCache, cloneBrowserAccountStateResult, withAccountStateEvidence, readBrowserAccountStateCache, writeBrowserAccountStateCache, isRateLimitError, createAbortError, waitForSharedBrowserRequest, waitForSharedBrowserUserFills, getBrowserActiveAssetTypeCandidates, normalizeHyperliquidErrorDetail, isUnsupportedUserActiveAssetError, rememberUnsupportedUserActiveAssetKey, parseInfoPositions, requireFinitePromptMetric, requirePromptClearinghouseState, requirePromptSpotState, normalizePerpDexName, listConfiguredPerpDexs, listPerpDexsForAccountState, prefixHip3PositionCoins, aggregateClearinghouseResponses, hasCompletePerpDexAccountMetrics, normalizeBrowserFillToTradeHistory, isPerpFill, settleAccountReads, fetchHyperliquidInfoRead, fetchHyperliquidInfoPayload, requireHyperliquidApiUrl, requireWalletAddress, parseInfoPositionSnapshot, fetchBrowserAccountState, fetchBrowserAccountStateUncached, fetchBrowserUserFills, fetchBrowserPositionSnapshot;
|
|
50159
50211
|
var init_hyperliquid_account_state_adapter = __esm({
|
|
50160
50212
|
"lib/runtime/hyperliquid-account-state-adapter.ts"() {
|
|
50161
50213
|
"use strict";
|
|
@@ -50823,23 +50875,22 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50823
50875
|
}
|
|
50824
50876
|
return true;
|
|
50825
50877
|
};
|
|
50826
|
-
|
|
50878
|
+
settleAccountReads = async (reads, controller) => {
|
|
50827
50879
|
try {
|
|
50828
50880
|
return await Promise.all(reads);
|
|
50829
50881
|
} catch (error48) {
|
|
50830
|
-
|
|
50831
|
-
|
|
50832
|
-
|
|
50833
|
-
|
|
50834
|
-
}
|
|
50882
|
+
controller.abort(error48);
|
|
50883
|
+
const settled = await Promise.allSettled(reads);
|
|
50884
|
+
for (const result2 of settled) {
|
|
50885
|
+
if (result2.status === "rejected" && result2.reason instanceof HyperliquidPublicReadError && result2.reason.code === "public_rate_limited") throw result2.reason;
|
|
50835
50886
|
}
|
|
50836
50887
|
throw error48;
|
|
50837
50888
|
}
|
|
50838
50889
|
};
|
|
50839
|
-
fetchHyperliquidInfoRead = async (apiUrl, body, signal, reservation) => {
|
|
50890
|
+
fetchHyperliquidInfoRead = async (apiUrl, body, signal, reservation, priorityScope) => {
|
|
50840
50891
|
const trace = startRuntimeNetworkDebugTrace({ kind: "exchange", label: `hyperliquid_info:${String(body.type)}`, method: "POST", url: `${apiUrl.replace(/\/$/, "")}/info` });
|
|
50841
50892
|
try {
|
|
50842
|
-
const result2 = await readHyperliquidPublicInfo(apiUrl, body, { signal, reservation });
|
|
50893
|
+
const result2 = await readHyperliquidPublicInfo(apiUrl, body, { signal, reservation, priorityScope });
|
|
50843
50894
|
trace.completeSuccess(200);
|
|
50844
50895
|
return result2;
|
|
50845
50896
|
} catch (error48) {
|
|
@@ -50847,7 +50898,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50847
50898
|
throw error48;
|
|
50848
50899
|
}
|
|
50849
50900
|
};
|
|
50850
|
-
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;
|
|
50851
50902
|
requireHyperliquidApiUrl = (config2) => {
|
|
50852
50903
|
const apiUrl = String(config2.client_runtime_exchange_endpoints?.hyperliquid_api_url || "").trim();
|
|
50853
50904
|
if (!apiUrl) {
|
|
@@ -50927,7 +50978,11 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50927
50978
|
], now)) {
|
|
50928
50979
|
return withAccountStateEvidence(cached2.result, "stale_if_429", cached2.fetchedAtMs, staleIf429MaxAgeMs);
|
|
50929
50980
|
}
|
|
50930
|
-
|
|
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;
|
|
50931
50986
|
if (!inFlight) {
|
|
50932
50987
|
const uncachedInput = input.forceRefresh ? input : (({ signal: _callerSignal, ...sharedInput }) => sharedInput)(input);
|
|
50933
50988
|
inFlight = fetchBrowserAccountStateUncached({
|
|
@@ -50950,7 +51005,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50950
51005
|
}
|
|
50951
51006
|
});
|
|
50952
51007
|
if (!input.forceRefresh) {
|
|
50953
|
-
browserAccountStateInFlight.set(cacheKey, inFlight);
|
|
51008
|
+
browserAccountStateInFlight.set(cacheKey, { promise: inFlight, priority });
|
|
50954
51009
|
}
|
|
50955
51010
|
}
|
|
50956
51011
|
try {
|
|
@@ -50990,6 +51045,27 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50990
51045
|
{ type: "userDexAbstraction", user: walletAddress }
|
|
50991
51046
|
] : []
|
|
50992
51047
|
], input.signal, { cacheAccountMode: true, cacheValidUntilMs: input.publicReadDeadlineMs });
|
|
51048
|
+
reservation.priorityScope = input.priorityScope;
|
|
51049
|
+
if (input.onPublicReadPendingChange) {
|
|
51050
|
+
const pending3 = { cache: 0, admission: 0, transport: 0 };
|
|
51051
|
+
const reportPending = input.onPublicReadPendingChange;
|
|
51052
|
+
reservation.onPendingPhaseChange = (previous, next) => {
|
|
51053
|
+
if (previous) pending3[previous] -= 1;
|
|
51054
|
+
if (next) pending3[next] += 1;
|
|
51055
|
+
reportPending({ ...pending3 });
|
|
51056
|
+
};
|
|
51057
|
+
try {
|
|
51058
|
+
reportPending({ ...pending3 });
|
|
51059
|
+
} catch {
|
|
51060
|
+
}
|
|
51061
|
+
}
|
|
51062
|
+
const parentSignal = input.signal;
|
|
51063
|
+
const readController = new AbortController();
|
|
51064
|
+
const cancelReads = () => readController.abort(parentSignal?.reason);
|
|
51065
|
+
parentSignal?.addEventListener("abort", cancelReads, { once: true });
|
|
51066
|
+
if (parentSignal?.aborted) cancelReads();
|
|
51067
|
+
input = { ...input, signal: readController.signal };
|
|
51068
|
+
const awaitAccountReads = (reads) => settleAccountReads(reads, readController);
|
|
50993
51069
|
try {
|
|
50994
51070
|
const userFeesPromise = input.includeEffectiveTakerRate === true ? (async () => ({
|
|
50995
51071
|
...await readHyperliquidPublicInfo(apiUrl, { type: "userFees", user: walletAddress }, { signal: input.signal, reservation }).catch((error48) => {
|
|
@@ -51239,6 +51315,8 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51239
51315
|
}
|
|
51240
51316
|
};
|
|
51241
51317
|
} finally {
|
|
51318
|
+
parentSignal?.removeEventListener("abort", cancelReads);
|
|
51319
|
+
readController.abort();
|
|
51242
51320
|
await releaseHyperliquidPublicReadReservation(reservation);
|
|
51243
51321
|
}
|
|
51244
51322
|
};
|
|
@@ -51285,21 +51363,28 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51285
51363
|
let evidenceSource = "live";
|
|
51286
51364
|
let fetchedAtMs = now;
|
|
51287
51365
|
const olderInFlight = browserUserFillsInFlight.get(cacheKey);
|
|
51366
|
+
if (olderInFlight) promoteHyperliquidPublicPriority(olderInFlight.priority, input.publicRequestPriority ?? "ui");
|
|
51288
51367
|
if (input.forceRefresh && olderInFlight) {
|
|
51289
51368
|
try {
|
|
51290
|
-
await waitForSharedBrowserUserFills(olderInFlight, input.signal);
|
|
51369
|
+
await waitForSharedBrowserUserFills(olderInFlight.promise, input.signal);
|
|
51291
51370
|
} catch (error48) {
|
|
51292
51371
|
if (input.signal?.aborted) {
|
|
51293
51372
|
throw error48;
|
|
51294
51373
|
}
|
|
51295
51374
|
}
|
|
51296
51375
|
}
|
|
51297
|
-
|
|
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;
|
|
51298
51380
|
if (!inFlight) {
|
|
51299
51381
|
let freshRequest;
|
|
51300
51382
|
freshRequest = fetchHyperliquidInfoPayload(
|
|
51301
51383
|
apiUrl,
|
|
51302
|
-
{ type: "userFills", user: walletAddress }
|
|
51384
|
+
{ type: "userFills", user: walletAddress },
|
|
51385
|
+
void 0,
|
|
51386
|
+
void 0,
|
|
51387
|
+
priority
|
|
51303
51388
|
).then((payload) => {
|
|
51304
51389
|
const providerRowCount2 = Array.isArray(payload) ? payload.length : 0;
|
|
51305
51390
|
const rawFills2 = Array.isArray(payload) ? payload.filter(isPerpFill).map((fill) => ({ ...fill })) : [];
|
|
@@ -51310,12 +51395,12 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51310
51395
|
});
|
|
51311
51396
|
return { fetchedAtMs: Date.now(), rawFills: rawFills2, providerRowCount: providerRowCount2 };
|
|
51312
51397
|
}).finally(() => {
|
|
51313
|
-
if (browserUserFillsInFlight.get(cacheKey) === freshRequest) {
|
|
51398
|
+
if (browserUserFillsInFlight.get(cacheKey)?.promise === freshRequest) {
|
|
51314
51399
|
browserUserFillsInFlight.delete(cacheKey);
|
|
51315
51400
|
}
|
|
51316
51401
|
});
|
|
51317
51402
|
inFlight = freshRequest;
|
|
51318
|
-
browserUserFillsInFlight.set(cacheKey, inFlight);
|
|
51403
|
+
browserUserFillsInFlight.set(cacheKey, { promise: inFlight, priority });
|
|
51319
51404
|
}
|
|
51320
51405
|
try {
|
|
51321
51406
|
const liveResult = await waitForSharedBrowserUserFills(inFlight, input.signal);
|
|
@@ -51347,7 +51432,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51347
51432
|
}
|
|
51348
51433
|
};
|
|
51349
51434
|
};
|
|
51350
|
-
fetchBrowserPositionSnapshot = async (config2, walletAddress, symbol2, signal) => {
|
|
51435
|
+
fetchBrowserPositionSnapshot = async (config2, walletAddress, symbol2, signal, publicRequestPriority = "ui") => {
|
|
51351
51436
|
configureHyperliquidMarketSymbolCasing(config2.client_runtime_hyperliquid_case_sensitive_symbols);
|
|
51352
51437
|
const apiUrl = requireHyperliquidApiUrl(config2);
|
|
51353
51438
|
const normalizedWallet = requireWalletAddress(walletAddress);
|
|
@@ -51360,7 +51445,9 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
51360
51445
|
const payload = await fetchHyperliquidInfoPayload(
|
|
51361
51446
|
apiUrl,
|
|
51362
51447
|
payloadBody,
|
|
51363
|
-
signal
|
|
51448
|
+
signal,
|
|
51449
|
+
void 0,
|
|
51450
|
+
createHyperliquidPublicPriorityScope(publicRequestPriority)
|
|
51364
51451
|
);
|
|
51365
51452
|
return parseInfoPositionSnapshot(
|
|
51366
51453
|
dex ? prefixHip3PositionCoins(payload, dex) : payload,
|
|
@@ -51943,6 +52030,7 @@ var init_billing = __esm({
|
|
|
51943
52030
|
async function getExecutionAssetMetadata(exchange, symbol2, options) {
|
|
51944
52031
|
const params = new URLSearchParams();
|
|
51945
52032
|
if (options?.includePrivateContext) params.set("include_private_context", "true");
|
|
52033
|
+
if (options?.publicRequestPriority) params.set("public_request_priority", options.publicRequestPriority);
|
|
51946
52034
|
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
51947
52035
|
const url2 = `${API_URL}/trading/execution-metadata/${encodeURIComponent(exchange)}/${encodeURIComponent(symbol2)}${query}`;
|
|
51948
52036
|
const response = await fetch(url2, {
|
|
@@ -83914,7 +84002,7 @@ var init_hyperliquid_signer = __esm({
|
|
|
83914
84002
|
});
|
|
83915
84003
|
|
|
83916
84004
|
// lib/runtime/hyperliquid-client.ts
|
|
83917
|
-
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;
|
|
83918
84006
|
var init_hyperliquid_client = __esm({
|
|
83919
84007
|
"lib/runtime/hyperliquid-client.ts"() {
|
|
83920
84008
|
"use strict";
|
|
@@ -84190,7 +84278,7 @@ var init_hyperliquid_client = __esm({
|
|
|
84190
84278
|
url: requestUrl
|
|
84191
84279
|
});
|
|
84192
84280
|
try {
|
|
84193
|
-
const { payload } = await readHyperliquidPublicInfo(apiUrl, body, { signal: input.signal });
|
|
84281
|
+
const { payload } = await readHyperliquidPublicInfo(apiUrl, body, { signal: input.signal, publicRequestPriority: input.publicRequestPriority ?? "ui" });
|
|
84194
84282
|
trace.completeSuccess(200);
|
|
84195
84283
|
return payload;
|
|
84196
84284
|
} catch (error48) {
|
|
@@ -84448,7 +84536,7 @@ var init_hyperliquid_client = __esm({
|
|
|
84448
84536
|
}
|
|
84449
84537
|
}
|
|
84450
84538
|
try {
|
|
84451
|
-
const metadata = await getExecutionAssetMetadata("hyperliquid", symbol2);
|
|
84539
|
+
const metadata = input.publicRequestPriority === "trading_reduce" ? await getExecutionAssetMetadata("hyperliquid", symbol2, { publicRequestPriority: "trading_reduce" }) : await getExecutionAssetMetadata("hyperliquid", symbol2);
|
|
84452
84540
|
return normalizeExecutionAssetMetadata(symbol2, metadata);
|
|
84453
84541
|
} catch (executionMetadataError) {
|
|
84454
84542
|
const assets = await resolveAssets(input);
|
|
@@ -84961,6 +85049,7 @@ var init_hyperliquid_client = __esm({
|
|
|
84961
85049
|
};
|
|
84962
85050
|
};
|
|
84963
85051
|
buildHyperliquidCancelPayload = async (input) => {
|
|
85052
|
+
input = { ...input, publicRequestPriority: input.publicRequestPriority ?? "trading_execute" };
|
|
84964
85053
|
const numericOrderId = typeof input.orderId === "number" ? input.orderId : Number.NaN;
|
|
84965
85054
|
const clientOrderId = typeof input.orderId === "string" ? normalizeHyperliquidClientOrderId(input.orderId) : void 0;
|
|
84966
85055
|
if (clientOrderId == null) {
|
|
@@ -84995,6 +85084,7 @@ var init_hyperliquid_client = __esm({
|
|
|
84995
85084
|
};
|
|
84996
85085
|
};
|
|
84997
85086
|
buildHyperliquidUpdateLeveragePayload = async (input) => {
|
|
85087
|
+
input = { ...input, publicRequestPriority: "trading_execute" };
|
|
84998
85088
|
const apiUrl = inferApiUrl(input);
|
|
84999
85089
|
const asset = await resolveHyperliquidAsset(input);
|
|
85000
85090
|
const { signHyperliquidAction: signHyperliquidAction2 } = await Promise.resolve().then(() => (init_hyperliquid_signer(), hyperliquid_signer_exports));
|
|
@@ -85025,6 +85115,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85025
85115
|
};
|
|
85026
85116
|
};
|
|
85027
85117
|
buildHyperliquidMarketOrderPayload = async (input) => {
|
|
85118
|
+
input = { ...input, publicRequestPriority: input.reduceOnly === true ? "trading_reduce" : "trading_execute" };
|
|
85028
85119
|
assertPositiveNumber(input.size, "Hyperliquid order size");
|
|
85029
85120
|
assertPositiveNumber(input.estimatedPrice, "Hyperliquid estimated price");
|
|
85030
85121
|
const slippage = input.slippage == null ? 0.05 : Number(input.slippage);
|
|
@@ -85041,6 +85132,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85041
85132
|
});
|
|
85042
85133
|
};
|
|
85043
85134
|
buildHyperliquidTriggerOrderPayload = async (input) => {
|
|
85135
|
+
input = { ...input, publicRequestPriority: input.reduceOnly !== false ? "trading_reduce" : "trading_execute" };
|
|
85044
85136
|
const order = await buildHyperliquidTriggerOrderWire({
|
|
85045
85137
|
...input,
|
|
85046
85138
|
limitPrice: input.limitPrice ?? input.triggerPrice
|
|
@@ -85052,6 +85144,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85052
85144
|
});
|
|
85053
85145
|
};
|
|
85054
85146
|
buildHyperliquidOrderBatchPayload = async (input) => {
|
|
85147
|
+
input = { ...input, publicRequestPriority: input.members.some((m) => m.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
|
|
85055
85148
|
if (input.members.length < 2 || input.members.length > 16) {
|
|
85056
85149
|
throw new Error("Hyperliquid TP/SL batch must contain between 2 and 16 orders.");
|
|
85057
85150
|
}
|
|
@@ -85093,6 +85186,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85093
85186
|
});
|
|
85094
85187
|
};
|
|
85095
85188
|
buildHyperliquidModifyOrderPayload = async (input) => {
|
|
85189
|
+
input = { ...input, publicRequestPriority: (input.orderKind === "trigger" ? input.reduceOnly !== false : input.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
|
|
85096
85190
|
const modifyTarget = typeof input.orderId === "string" ? normalizeHyperliquidClientOrderId(input.orderId) : input.orderId;
|
|
85097
85191
|
if (typeof modifyTarget === "number") {
|
|
85098
85192
|
assertPositiveInteger(modifyTarget, "Hyperliquid order id");
|
|
@@ -85574,7 +85668,13 @@ var init_hyperliquid_client = __esm({
|
|
|
85574
85668
|
}
|
|
85575
85669
|
return signedAssetId;
|
|
85576
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
|
+
};
|
|
85577
85676
|
submitHyperliquidExchangePayload = async (input) => {
|
|
85677
|
+
input = { ...input, publicRequestPriority: exchangeActionPriority(input.payload.action, input.publicRequestPriority) };
|
|
85578
85678
|
if (input.signal?.aborted) {
|
|
85579
85679
|
throw input.signal.reason instanceof Error ? input.signal.reason : new DOMException("The operation was aborted.", "AbortError");
|
|
85580
85680
|
}
|
|
@@ -85749,7 +85849,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85749
85849
|
}
|
|
85750
85850
|
}
|
|
85751
85851
|
try {
|
|
85752
|
-
recoveryPermit = await admitHyperliquidExchangeRequest(apiUrl, input.payload.action, input.signal);
|
|
85852
|
+
recoveryPermit = await admitHyperliquidExchangeRequest(apiUrl, input.payload.action, input.signal, input.publicRequestPriority);
|
|
85753
85853
|
assertFreshPreparedExecutionContext(input.preparedContext);
|
|
85754
85854
|
assertHyperliquidRecoveryDispatch(apiUrl, recoveryPermit, "exchange");
|
|
85755
85855
|
} catch (preparedContextError) {
|
|
@@ -85953,6 +86053,7 @@ var init_hyperliquid_signer_binding = __esm({
|
|
|
85953
86053
|
try {
|
|
85954
86054
|
roleResponse = await fetchBrowserUserRole({
|
|
85955
86055
|
config: input.config ?? null,
|
|
86056
|
+
publicRequestPriority: input.publicRequestPriority ?? "ui",
|
|
85956
86057
|
walletAddress: signerAddress,
|
|
85957
86058
|
signal: input.signal
|
|
85958
86059
|
});
|
|
@@ -86853,6 +86954,7 @@ var init_browser_trading = __esm({
|
|
|
86853
86954
|
signingKey,
|
|
86854
86955
|
walletAddress,
|
|
86855
86956
|
config: input.config ?? null,
|
|
86957
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86856
86958
|
signal: input.signal
|
|
86857
86959
|
});
|
|
86858
86960
|
return signingKey;
|
|
@@ -86864,12 +86966,13 @@ var init_browser_trading = __esm({
|
|
|
86864
86966
|
}
|
|
86865
86967
|
return walletAddress;
|
|
86866
86968
|
};
|
|
86867
|
-
resolveEstimatedPrice = async (config2, symbol2, explicitPrice, signal) => {
|
|
86969
|
+
resolveEstimatedPrice = async (config2, symbol2, explicitPrice, signal, publicRequestPriority = "trading_execute") => {
|
|
86868
86970
|
if (typeof explicitPrice === "number" && Number.isFinite(explicitPrice) && explicitPrice > 0) {
|
|
86869
86971
|
return explicitPrice;
|
|
86870
86972
|
}
|
|
86871
86973
|
const price = await fetchBrowserSymbolMidPrice({
|
|
86872
86974
|
config: config2 ?? null,
|
|
86975
|
+
publicRequestPriority,
|
|
86873
86976
|
symbol: symbol2,
|
|
86874
86977
|
signal
|
|
86875
86978
|
});
|
|
@@ -86877,12 +86980,14 @@ var init_browser_trading = __esm({
|
|
|
86877
86980
|
return price;
|
|
86878
86981
|
};
|
|
86879
86982
|
executeClientLeverageUpdate = async (input) => {
|
|
86983
|
+
input = { ...input, publicRequestPriority: "trading_execute" };
|
|
86880
86984
|
throwIfAborted(input.signal);
|
|
86881
86985
|
const signingKey = await resolveSigningKey(input);
|
|
86882
86986
|
throwIfAborted(input.signal);
|
|
86883
86987
|
const mutation = createExchangeMutationIdentity(false);
|
|
86884
86988
|
const payload = await buildHyperliquidUpdateLeveragePayload({
|
|
86885
86989
|
config: input.config ?? null,
|
|
86990
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86886
86991
|
signingKey,
|
|
86887
86992
|
symbol: input.symbol,
|
|
86888
86993
|
leverage: input.leverage,
|
|
@@ -86891,6 +86996,7 @@ var init_browser_trading = __esm({
|
|
|
86891
86996
|
});
|
|
86892
86997
|
return submitHyperliquidExchangePayload({
|
|
86893
86998
|
config: input.config ?? null,
|
|
86999
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86894
87000
|
payload,
|
|
86895
87001
|
signal: input.signal,
|
|
86896
87002
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -86907,15 +87013,17 @@ var init_browser_trading = __esm({
|
|
|
86907
87013
|
});
|
|
86908
87014
|
};
|
|
86909
87015
|
executeClientMarketOrder = async (input) => {
|
|
87016
|
+
input = { ...input, publicRequestPriority: input.reduceOnly === true ? "trading_reduce" : "trading_execute" };
|
|
86910
87017
|
throwIfAborted(input.signal);
|
|
86911
87018
|
const signingKey = await resolveSigningKey(input);
|
|
86912
87019
|
throwIfAborted(input.signal);
|
|
86913
|
-
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);
|
|
86914
87021
|
throwIfAborted(input.signal);
|
|
86915
87022
|
assertFreshPreparedContext(input.preparedContext);
|
|
86916
87023
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
86917
87024
|
const payload = await buildHyperliquidMarketOrderPayload({
|
|
86918
87025
|
config: input.config ?? null,
|
|
87026
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86919
87027
|
signingKey,
|
|
86920
87028
|
symbol: input.symbol,
|
|
86921
87029
|
side: input.side,
|
|
@@ -86929,6 +87037,7 @@ var init_browser_trading = __esm({
|
|
|
86929
87037
|
});
|
|
86930
87038
|
return submitHyperliquidExchangePayload({
|
|
86931
87039
|
config: input.config ?? null,
|
|
87040
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86932
87041
|
payload,
|
|
86933
87042
|
signal: input.signal,
|
|
86934
87043
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -86947,12 +87056,14 @@ var init_browser_trading = __esm({
|
|
|
86947
87056
|
});
|
|
86948
87057
|
};
|
|
86949
87058
|
executeClientTriggerOrder = async (input) => {
|
|
87059
|
+
input = { ...input, publicRequestPriority: input.reduceOnly !== false ? "trading_reduce" : "trading_execute" };
|
|
86950
87060
|
throwIfAborted(input.signal);
|
|
86951
87061
|
const signingKey = await resolveSigningKey(input);
|
|
86952
87062
|
throwIfAborted(input.signal);
|
|
86953
87063
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
86954
87064
|
const payload = await buildHyperliquidTriggerOrderPayload({
|
|
86955
87065
|
config: input.config ?? null,
|
|
87066
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86956
87067
|
signingKey,
|
|
86957
87068
|
symbol: input.symbol,
|
|
86958
87069
|
side: input.side,
|
|
@@ -86967,6 +87078,7 @@ var init_browser_trading = __esm({
|
|
|
86967
87078
|
});
|
|
86968
87079
|
return submitHyperliquidExchangePayload({
|
|
86969
87080
|
config: input.config ?? null,
|
|
87081
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86970
87082
|
payload,
|
|
86971
87083
|
signal: input.signal,
|
|
86972
87084
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -86984,12 +87096,14 @@ var init_browser_trading = __esm({
|
|
|
86984
87096
|
});
|
|
86985
87097
|
};
|
|
86986
87098
|
executeClientOrderBatch = async (input) => {
|
|
87099
|
+
input = { ...input, publicRequestPriority: input.members.some((m) => m.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
|
|
86987
87100
|
throwIfAborted(input.signal);
|
|
86988
87101
|
const signingKey = await resolveSigningKey(input);
|
|
86989
87102
|
throwIfAborted(input.signal);
|
|
86990
87103
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
86991
87104
|
const payload = await buildHyperliquidOrderBatchPayload({
|
|
86992
87105
|
config: input.config ?? null,
|
|
87106
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
86993
87107
|
signingKey,
|
|
86994
87108
|
symbol: input.symbol,
|
|
86995
87109
|
members: input.members,
|
|
@@ -86998,6 +87112,7 @@ var init_browser_trading = __esm({
|
|
|
86998
87112
|
});
|
|
86999
87113
|
return submitHyperliquidExchangePayload({
|
|
87000
87114
|
config: input.config ?? null,
|
|
87115
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87001
87116
|
payload,
|
|
87002
87117
|
signal: input.signal,
|
|
87003
87118
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -87016,12 +87131,14 @@ var init_browser_trading = __esm({
|
|
|
87016
87131
|
});
|
|
87017
87132
|
};
|
|
87018
87133
|
executeClientModifyOrder = async (input) => {
|
|
87134
|
+
input = { ...input, publicRequestPriority: (input.orderKind === "trigger" ? input.reduceOnly !== false : input.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
|
|
87019
87135
|
throwIfAborted(input.signal);
|
|
87020
87136
|
const signingKey = await resolveSigningKey(input);
|
|
87021
87137
|
throwIfAborted(input.signal);
|
|
87022
87138
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
87023
87139
|
const payload = await buildHyperliquidModifyOrderPayload({
|
|
87024
87140
|
config: input.config ?? null,
|
|
87141
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87025
87142
|
signingKey,
|
|
87026
87143
|
symbol: input.symbol,
|
|
87027
87144
|
orderId: input.orderId,
|
|
@@ -87039,6 +87156,7 @@ var init_browser_trading = __esm({
|
|
|
87039
87156
|
});
|
|
87040
87157
|
return submitHyperliquidExchangePayload({
|
|
87041
87158
|
config: input.config ?? null,
|
|
87159
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87042
87160
|
payload,
|
|
87043
87161
|
signal: input.signal,
|
|
87044
87162
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -87056,12 +87174,14 @@ var init_browser_trading = __esm({
|
|
|
87056
87174
|
});
|
|
87057
87175
|
};
|
|
87058
87176
|
executeClientCancelOrder = async (input) => {
|
|
87177
|
+
input = { ...input, publicRequestPriority: input.publicRequestPriority ?? "trading_execute" };
|
|
87059
87178
|
throwIfAborted(input.signal);
|
|
87060
87179
|
const signingKey = await resolveSigningKey(input);
|
|
87061
87180
|
throwIfAborted(input.signal);
|
|
87062
87181
|
const mutation = createExchangeMutationIdentity(false, input);
|
|
87063
87182
|
const payload = await buildHyperliquidCancelPayload({
|
|
87064
87183
|
config: input.config ?? null,
|
|
87184
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87065
87185
|
signingKey,
|
|
87066
87186
|
symbol: input.symbol,
|
|
87067
87187
|
orderId: input.orderId,
|
|
@@ -87069,6 +87189,7 @@ var init_browser_trading = __esm({
|
|
|
87069
87189
|
});
|
|
87070
87190
|
return submitHyperliquidExchangePayload({
|
|
87071
87191
|
config: input.config ?? null,
|
|
87192
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87072
87193
|
payload,
|
|
87073
87194
|
signal: input.signal,
|
|
87074
87195
|
mutationScope: resolveProfileId(input.profileId),
|
|
@@ -87086,10 +87207,12 @@ var init_browser_trading = __esm({
|
|
|
87086
87207
|
});
|
|
87087
87208
|
};
|
|
87088
87209
|
executeClientClosePosition = async (input) => {
|
|
87210
|
+
input = { ...input, publicRequestPriority: "trading_reduce" };
|
|
87089
87211
|
throwIfAborted(input.signal);
|
|
87090
87212
|
const profileId = resolveProfileId(input.profileId);
|
|
87091
87213
|
const currentPosition = input.position ?? await fetchBrowserPosition({
|
|
87092
87214
|
config: input.config ?? null,
|
|
87215
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87093
87216
|
walletAddress: requireWalletAddress3(input.walletAddress),
|
|
87094
87217
|
symbol: input.symbol,
|
|
87095
87218
|
signal: input.signal
|
|
@@ -87110,6 +87233,7 @@ var init_browser_trading = __esm({
|
|
|
87110
87233
|
schedulerInstanceId: input.schedulerInstanceId,
|
|
87111
87234
|
walletAddress: input.walletAddress,
|
|
87112
87235
|
config: input.config ?? null,
|
|
87236
|
+
publicRequestPriority: input.publicRequestPriority,
|
|
87113
87237
|
signal: input.signal,
|
|
87114
87238
|
signingKey: input.signingKey,
|
|
87115
87239
|
symbol: input.symbol,
|
|
@@ -87355,7 +87479,7 @@ var init_execution_guard_contract = __esm({
|
|
|
87355
87479
|
});
|
|
87356
87480
|
|
|
87357
87481
|
// lib/runtime/runtime-execution.ts
|
|
87358
|
-
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;
|
|
87359
87483
|
var init_runtime_execution = __esm({
|
|
87360
87484
|
"lib/runtime/runtime-execution.ts"() {
|
|
87361
87485
|
"use strict";
|
|
@@ -87371,7 +87495,16 @@ var init_runtime_execution = __esm({
|
|
|
87371
87495
|
init_runtime_redaction();
|
|
87372
87496
|
init_error_surface_contract();
|
|
87373
87497
|
init_runtime_handoff();
|
|
87374
|
-
|
|
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") => {
|
|
87375
87508
|
const normalizedSymbol = normalizeHyperliquidMarketSymbol(
|
|
87376
87509
|
request.executionContext.symbol
|
|
87377
87510
|
);
|
|
@@ -87380,6 +87513,7 @@ var init_runtime_execution = __esm({
|
|
|
87380
87513
|
}
|
|
87381
87514
|
const dex = getHyperliquidMarketDex(normalizedSymbol);
|
|
87382
87515
|
return fetchBrowserOpenOrders({
|
|
87516
|
+
publicRequestPriority,
|
|
87383
87517
|
config: request.config ?? null,
|
|
87384
87518
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
87385
87519
|
signal: request.signal,
|
|
@@ -88313,10 +88447,11 @@ var init_runtime_execution = __esm({
|
|
|
88313
88447
|
throw new Error("Protective cleanup intent could not be persisted durably.");
|
|
88314
88448
|
}
|
|
88315
88449
|
}
|
|
88316
|
-
const liveOrders = await fetchClientRuntimeOpenOrders(request);
|
|
88450
|
+
const liveOrders = await fetchClientRuntimeOpenOrders(request, "trading_reduce");
|
|
88317
88451
|
const liveOrder = liveOrders.find((order) => String(order.oid) === String(leg.orderId));
|
|
88318
88452
|
if (!liveOrder) {
|
|
88319
88453
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
88454
|
+
publicRequestPriority: "trading_reduce",
|
|
88320
88455
|
config: request.config ?? null,
|
|
88321
88456
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
88322
88457
|
signal: request.signal,
|
|
@@ -88371,6 +88506,7 @@ var init_runtime_execution = __esm({
|
|
|
88371
88506
|
throw new Error("Tracked protective order no longer has its exact authorized shape.");
|
|
88372
88507
|
}
|
|
88373
88508
|
await executeClientCancelOrder({
|
|
88509
|
+
publicRequestPriority: "trading_reduce",
|
|
88374
88510
|
profileId: request.profileId,
|
|
88375
88511
|
runtimeSessionId: request.sessionId || "__missing_runtime_session__",
|
|
88376
88512
|
runtimeLeaseToken: request.runtimeLeaseToken,
|
|
@@ -88485,7 +88621,8 @@ var init_runtime_execution = __esm({
|
|
|
88485
88621
|
request.config ?? {},
|
|
88486
88622
|
String(request.executionContext.walletAddress || "").trim(),
|
|
88487
88623
|
symbol2,
|
|
88488
|
-
request.signal
|
|
88624
|
+
request.signal,
|
|
88625
|
+
"trading_reduce"
|
|
88489
88626
|
);
|
|
88490
88627
|
const livePositionSize = Number(snapshot.size);
|
|
88491
88628
|
const directionMatches = Number.isFinite(livePositionSize) && (isLong ? livePositionSize > 0 : livePositionSize < 0);
|
|
@@ -88977,13 +89114,15 @@ var init_runtime_execution = __esm({
|
|
|
88977
89114
|
request.config ?? {},
|
|
88978
89115
|
walletAddress,
|
|
88979
89116
|
symbol2,
|
|
88980
|
-
request.signal
|
|
89117
|
+
request.signal,
|
|
89118
|
+
"trading_reconcile"
|
|
88981
89119
|
);
|
|
88982
89120
|
const livePositionSize = Number(livePosition.size);
|
|
88983
89121
|
if (!Number.isFinite(livePositionSize)) {
|
|
88984
89122
|
throw new Error("Journaled protective live exposure is unresolved.");
|
|
88985
89123
|
}
|
|
88986
89124
|
const { rawFills, evidence } = await fetchBrowserUserFills({
|
|
89125
|
+
publicRequestPriority: "trading_reconcile",
|
|
88987
89126
|
config: request.config ?? {},
|
|
88988
89127
|
walletAddress,
|
|
88989
89128
|
symbols: [symbol2],
|
|
@@ -89124,6 +89263,7 @@ var init_runtime_execution = __esm({
|
|
|
89124
89263
|
if (openOrder == null) {
|
|
89125
89264
|
try {
|
|
89126
89265
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
89266
|
+
publicRequestPriority: "trading_reconcile",
|
|
89127
89267
|
config: request.config ?? null,
|
|
89128
89268
|
walletAddress,
|
|
89129
89269
|
signal: request.signal,
|
|
@@ -89500,6 +89640,7 @@ var init_runtime_execution = __esm({
|
|
|
89500
89640
|
continue;
|
|
89501
89641
|
}
|
|
89502
89642
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
89643
|
+
publicRequestPriority: "trading_reconcile",
|
|
89503
89644
|
config: request.config ?? null,
|
|
89504
89645
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
89505
89646
|
signal: request.signal,
|
|
@@ -89512,6 +89653,7 @@ var init_runtime_execution = __esm({
|
|
|
89512
89653
|
throw new Error("Pending entry status or shape is unresolved.");
|
|
89513
89654
|
}
|
|
89514
89655
|
const { rawFills, evidence: fillEvidence } = await fetchBrowserUserFills({
|
|
89656
|
+
publicRequestPriority: "trading_reconcile",
|
|
89515
89657
|
config: request.config ?? {},
|
|
89516
89658
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
89517
89659
|
symbols: [symbol2],
|
|
@@ -89621,6 +89763,7 @@ var init_runtime_execution = __esm({
|
|
|
89621
89763
|
}
|
|
89622
89764
|
replacementCleanup = buildVetoedProtectiveReplacementCleanup(replacementReservation);
|
|
89623
89765
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
89766
|
+
publicRequestPriority: "trading_reconcile",
|
|
89624
89767
|
config: request.config ?? null,
|
|
89625
89768
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
89626
89769
|
signal: request.signal,
|
|
@@ -89964,6 +90107,7 @@ var init_runtime_execution = __esm({
|
|
|
89964
90107
|
const [journalLeg] = journalGroup.legs;
|
|
89965
90108
|
try {
|
|
89966
90109
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
90110
|
+
publicRequestPriority: "trading_reconcile",
|
|
89967
90111
|
config: request.config ?? null,
|
|
89968
90112
|
walletAddress: String(request.executionContext.walletAddress || "").trim(),
|
|
89969
90113
|
signal: request.signal,
|
|
@@ -90118,7 +90262,8 @@ var init_runtime_execution = __esm({
|
|
|
90118
90262
|
request.config ?? {},
|
|
90119
90263
|
walletAddress,
|
|
90120
90264
|
symbol2,
|
|
90121
|
-
request.signal
|
|
90265
|
+
request.signal,
|
|
90266
|
+
"trading_reconcile"
|
|
90122
90267
|
);
|
|
90123
90268
|
livePositionSize = Number(snapshot.size);
|
|
90124
90269
|
} catch (error48) {
|
|
@@ -90241,6 +90386,7 @@ var init_runtime_execution = __esm({
|
|
|
90241
90386
|
}
|
|
90242
90387
|
try {
|
|
90243
90388
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
90389
|
+
publicRequestPriority: "trading_reconcile",
|
|
90244
90390
|
config: request.config ?? null,
|
|
90245
90391
|
walletAddress,
|
|
90246
90392
|
signal: request.signal,
|
|
@@ -91150,6 +91296,7 @@ var init_runtime_execution = __esm({
|
|
|
91150
91296
|
if (shouldRefreshExecutionSnapshot) {
|
|
91151
91297
|
try {
|
|
91152
91298
|
const refreshed = await fetchBrowserAccountState({
|
|
91299
|
+
publicRequestPriority: executionReadPriority(input),
|
|
91153
91300
|
config: input.config ?? {},
|
|
91154
91301
|
walletAddress,
|
|
91155
91302
|
symbol: input.executionContext.symbol,
|
|
@@ -91182,7 +91329,8 @@ var init_runtime_execution = __esm({
|
|
|
91182
91329
|
input.config ?? {},
|
|
91183
91330
|
walletAddress,
|
|
91184
91331
|
input.executionContext.symbol,
|
|
91185
|
-
input.signal
|
|
91332
|
+
input.signal,
|
|
91333
|
+
executionReadPriority(input)
|
|
91186
91334
|
);
|
|
91187
91335
|
const parsedLiveSize = resolvePositionSize({
|
|
91188
91336
|
symbol: input.executionContext.symbol,
|
|
@@ -92082,7 +92230,8 @@ var init_runtime_execution = __esm({
|
|
|
92082
92230
|
input.config ?? {},
|
|
92083
92231
|
String(input.executionContext.walletAddress || "").trim(),
|
|
92084
92232
|
input.executionContext.symbol,
|
|
92085
|
-
input.signal
|
|
92233
|
+
input.signal,
|
|
92234
|
+
"trading_reduce"
|
|
92086
92235
|
);
|
|
92087
92236
|
const livePositionSize = Number(liveSnapshot.size);
|
|
92088
92237
|
const liveDirectionMatches = Number.isFinite(livePositionSize) && (isLong ? livePositionSize > 0 : livePositionSize < 0);
|
|
@@ -93414,6 +93563,7 @@ async function fetchLocalHyperliquidSnapshot(input) {
|
|
|
93414
93563
|
const promptKnobs = objectOrNull3(input.metadata.prompt_knobs) ?? {};
|
|
93415
93564
|
const leverage = requirePositiveNumber2(promptKnobs.leverage ?? input.llmConfig.default_leverage, "leverage");
|
|
93416
93565
|
const accountState = await input.fetchAccountState({
|
|
93566
|
+
publicRequestPriority: "trading_analysis",
|
|
93417
93567
|
config: executionConfig,
|
|
93418
93568
|
walletAddress,
|
|
93419
93569
|
symbol: input.symbol,
|