@vtxmacro/cli 2026.10.23 → 2026.10.25
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/exo-harness.ts +4 -0
- package/bin/vtx-mcp.js +5 -1
- package/bin/vtx-service-bootstrap.js +5 -1
- package/bin/vtx-service-launcher.js +4 -0
- package/bin/vtx.js +408 -55
- package/package.json +1 -1
package/bin/exo-harness.ts
CHANGED
|
@@ -1225,6 +1225,10 @@ var runtime_policy_generated_default = {
|
|
|
1225
1225
|
recovery_queue_wait_seconds: 10,
|
|
1226
1226
|
recovery_quiet_seconds: 30
|
|
1227
1227
|
},
|
|
1228
|
+
acknowledgement_lookup: {
|
|
1229
|
+
window_milliseconds: 1e4,
|
|
1230
|
+
poll_milliseconds: 1e3
|
|
1231
|
+
},
|
|
1228
1232
|
http: {
|
|
1229
1233
|
exchange: {
|
|
1230
1234
|
request_timeout_seconds: 10,
|
package/bin/vtx-mcp.js
CHANGED
|
@@ -37,7 +37,7 @@ var init_define_VTX_PI_MODEL_POLICY = __esm({
|
|
|
37
37
|
var agent_cli_release_default;
|
|
38
38
|
var init_agent_cli_release = __esm({
|
|
39
39
|
"agent-cli-release.json"() {
|
|
40
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
40
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.25", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -2462,6 +2462,10 @@ var runtime_policy_generated_default = {
|
|
|
2462
2462
|
recovery_queue_wait_seconds: 10,
|
|
2463
2463
|
recovery_quiet_seconds: 30
|
|
2464
2464
|
},
|
|
2465
|
+
acknowledgement_lookup: {
|
|
2466
|
+
window_milliseconds: 1e4,
|
|
2467
|
+
poll_milliseconds: 1e3
|
|
2468
|
+
},
|
|
2465
2469
|
http: {
|
|
2466
2470
|
exchange: {
|
|
2467
2471
|
request_timeout_seconds: 10,
|
|
@@ -14,7 +14,7 @@ import { dirname as dirname4, relative as relative4, resolve as resolve4 } from
|
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
|
|
16
16
|
// agent-cli-release.json
|
|
17
|
-
var agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
17
|
+
var agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.25", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
18
18
|
|
|
19
19
|
// lib/runtime-policy.generated.json
|
|
20
20
|
var runtime_policy_generated_default = {
|
|
@@ -1169,6 +1169,10 @@ var runtime_policy_generated_default = {
|
|
|
1169
1169
|
recovery_queue_wait_seconds: 10,
|
|
1170
1170
|
recovery_quiet_seconds: 30
|
|
1171
1171
|
},
|
|
1172
|
+
acknowledgement_lookup: {
|
|
1173
|
+
window_milliseconds: 1e4,
|
|
1174
|
+
poll_milliseconds: 1e3
|
|
1175
|
+
},
|
|
1172
1176
|
http: {
|
|
1173
1177
|
exchange: {
|
|
1174
1178
|
request_timeout_seconds: 10,
|
|
@@ -1153,6 +1153,10 @@ var runtime_policy_generated_default = {
|
|
|
1153
1153
|
recovery_queue_wait_seconds: 10,
|
|
1154
1154
|
recovery_quiet_seconds: 30
|
|
1155
1155
|
},
|
|
1156
|
+
acknowledgement_lookup: {
|
|
1157
|
+
window_milliseconds: 1e4,
|
|
1158
|
+
poll_milliseconds: 1e3
|
|
1159
|
+
},
|
|
1156
1160
|
http: {
|
|
1157
1161
|
exchange: {
|
|
1158
1162
|
request_timeout_seconds: 10,
|
package/bin/vtx.js
CHANGED
|
@@ -113,7 +113,7 @@ var init_routing = __esm({
|
|
|
113
113
|
var agent_cli_release_default;
|
|
114
114
|
var init_agent_cli_release = __esm({
|
|
115
115
|
"agent-cli-release.json"() {
|
|
116
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
116
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.25", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
@@ -1273,6 +1273,10 @@ var init_runtime_policy_generated = __esm({
|
|
|
1273
1273
|
recovery_queue_wait_seconds: 10,
|
|
1274
1274
|
recovery_quiet_seconds: 30
|
|
1275
1275
|
},
|
|
1276
|
+
acknowledgement_lookup: {
|
|
1277
|
+
window_milliseconds: 1e4,
|
|
1278
|
+
poll_milliseconds: 1e3
|
|
1279
|
+
},
|
|
1276
1280
|
http: {
|
|
1277
1281
|
exchange: {
|
|
1278
1282
|
request_timeout_seconds: 10,
|
|
@@ -21093,6 +21097,10 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
21093
21097
|
recovery_queue_wait_seconds: 10,
|
|
21094
21098
|
recovery_quiet_seconds: 30
|
|
21095
21099
|
},
|
|
21100
|
+
acknowledgement_lookup: {
|
|
21101
|
+
window_milliseconds: 1e4,
|
|
21102
|
+
poll_milliseconds: 1e3
|
|
21103
|
+
},
|
|
21096
21104
|
http: {
|
|
21097
21105
|
exchange: {
|
|
21098
21106
|
request_timeout_seconds: 10,
|
|
@@ -90355,7 +90363,7 @@ var init_hyperliquid_signer = __esm({
|
|
|
90355
90363
|
});
|
|
90356
90364
|
|
|
90357
90365
|
// lib/runtime/hyperliquid-client.ts
|
|
90358
|
-
var HyperliquidExchangeRejectionError, durableMutationAuthorityArgs, assertFreshPreparedExecutionContext, normalizeSymbol, HYPERLIQUID_NONCE_STORAGE_KEY, HYPERLIQUID_NONCE_LOCK_NAME, lastGeneratedNonce, readBrowserStoredHyperliquidNonce, writeBrowserStoredHyperliquidNonce, browserNonceCoordinator, allocateHyperliquidNonce, hostNonceAllocator, allocateActionNonce, generateHyperliquidNonce, normalizeDecimalString, HYPERLIQUID_PRICE_SIGNIFICANT_FIGURES, HYPERLIQUID_INTEGER_PRICE_MINIMUM, shortestDecimalParts, formatHyperliquidPerpPriceGrid, formatHyperliquidTriggerPriceWire, hyperliquidOrderPriceRounding, formatHyperliquidOrderPriceWire, countSignificantDigits, countDecimalPlaces, validateHyperliquidPerpPriceWire, validateHyperliquidSizeWire, formatSizeWire, inferApiUrl, inferIsTestnet, postHyperliquidInfoRead, postHyperliquidInfo, fetchBrowserHyperliquidInfoPayload, fetchBrowserHyperliquidInfoRead, fetchBrowserHyperliquidInfoText, coerceMarketMaxLeverage, toFiniteNumber, OPEN_ORDER_NUMERIC_STRING, OPEN_ORDER_ID_STRING, parseCanonicalOpenOrderId, parseOpenOrderFiniteNumber, parseOpenOrderNonNegativeNumber, NATIVE_FIRED_TRIGGER_CONDITION, parseOpenOrderPositiveNumber, parseOpenOrderPresentationNumber, readOpenOrderField, firstFiniteNumber, parseFundingUsdcFromInfoPosition, isExchangeIsolatedOnly, resolveLeverageTarget, computeHip3AssetId, getPerpDexIndexMap, buildAssetInfosFromMetaResponse, requireWalletAddress, assertPositiveInteger, assertPositiveNumber, normalizeOrderSide, normalizeHyperliquidClientOrderId, resolveAssets, findResolvedAsset, normalizeExecutionAssetMetadata, resolveHyperliquidAsset, resolveHyperliquidAssetIndex, decimalUnits, quantizeHyperliquidOrderSizeValue, hyperliquidSignedSizeMatchesRequestedSize, finitePositive, readDevicePrivateExecutionContext, quantizeHyperliquidOrderSize, fetchBrowserAvailableAssets, fetchBrowserAllMids, fetchBrowserSymbolMidPrice, fetchBrowserOpenOrders, parseCanonicalHyperliquidOrderStatusEvidence, fetchBrowserOrderStatusEvidence, fetchBrowserUserRole, fetchBrowserAccountState, fetchBrowserPosition, buildHyperliquidOrderWire, buildHyperliquidTriggerOrderWire, signHyperliquidPayload, signHyperliquidPreparedAction, buildHyperliquidCancelPayload, buildHyperliquidUpdateLeveragePayload, buildHyperliquidMarketOrderPayload, buildHyperliquidLimitOrderPayload, buildHyperliquidTriggerOrderPayload, buildHyperliquidOrderBatchPayload, buildHyperliquidModifyOrderPayload, extractHyperliquidExchangeError, resolveHyperliquidTriggerAcknowledgements, resolveHyperliquidModifyAcknowledgement, isDefinitiveHyperliquidExchangeResponse, extractDefinitiveHyperliquidOrderId, CANONICAL_POSITIVE_DECIMAL_PATTERN, extractCanonicalHyperliquidOrderStateAcknowledgement, extractCanonicalHyperliquidOrderStateAcknowledgements, extractCanonicalHyperliquidFilledOrderAcknowledgement, extractDefinitiveHyperliquidOrderMemberResults, buildHyperliquidOrderDiagnostics, loadClientExecutionReferenceEvidence, sha256Hex, extractSignedPayloadClientOrderId, extractSignedPayloadMutationCorrelation, assertDurableMutationMatchesSignedAction, exchangeRejectionReason, exchangeActionPriority, submitHyperliquidExchangePayload;
|
|
90366
|
+
var HyperliquidExchangeRejectionError, durableMutationAuthorityArgs, assertFreshPreparedExecutionContext, normalizeSymbol, HYPERLIQUID_NONCE_STORAGE_KEY, HYPERLIQUID_NONCE_LOCK_NAME, lastGeneratedNonce, readBrowserStoredHyperliquidNonce, writeBrowserStoredHyperliquidNonce, browserNonceCoordinator, allocateHyperliquidNonce, hostNonceAllocator, allocateActionNonce, generateHyperliquidNonce, normalizeDecimalString, HYPERLIQUID_PRICE_SIGNIFICANT_FIGURES, HYPERLIQUID_INTEGER_PRICE_MINIMUM, shortestDecimalParts, formatHyperliquidPerpPriceGrid, formatHyperliquidTriggerPriceWire, hyperliquidOrderPriceRounding, formatHyperliquidOrderPriceWire, countSignificantDigits, countDecimalPlaces, validateHyperliquidPerpPriceWire, validateHyperliquidSizeWire, formatSizeWire, inferApiUrl, inferIsTestnet, postHyperliquidInfoRead, postHyperliquidInfo, fetchBrowserHyperliquidInfoPayload, fetchBrowserHyperliquidInfoRead, fetchBrowserHyperliquidInfoText, coerceMarketMaxLeverage, toFiniteNumber, OPEN_ORDER_NUMERIC_STRING, OPEN_ORDER_ID_STRING, parseCanonicalOpenOrderId, parseOpenOrderFiniteNumber, parseOpenOrderNonNegativeNumber, NATIVE_FIRED_TRIGGER_CONDITION, parseOpenOrderPositiveNumber, parseOpenOrderPresentationNumber, readOpenOrderField, firstFiniteNumber, parseFundingUsdcFromInfoPosition, isExchangeIsolatedOnly, resolveLeverageTarget, computeHip3AssetId, getPerpDexIndexMap, buildAssetInfosFromMetaResponse, requireWalletAddress, assertPositiveInteger, assertPositiveNumber, normalizeOrderSide, normalizeHyperliquidClientOrderId, resolveAssets, findResolvedAsset, normalizeExecutionAssetMetadata, resolveHyperliquidAsset, resolveHyperliquidAssetIndex, decimalUnits, quantizeHyperliquidOrderSizeValue, hyperliquidSignedSizeMatchesRequestedSize, finitePositive, readDevicePrivateExecutionContext, quantizeHyperliquidOrderSize, fetchBrowserAvailableAssets, fetchBrowserAllMids, fetchBrowserSymbolMidPrice, fetchBrowserOpenOrders, parseCanonicalHyperliquidOrderStatusEvidence, fetchBrowserOrderStatusEvidence, fetchBrowserUserRole, fetchBrowserAccountState, fetchBrowserPosition, buildHyperliquidOrderWire, buildHyperliquidTriggerOrderWire, signHyperliquidPayload, signHyperliquidPreparedAction, buildHyperliquidCancelPayload, buildHyperliquidUpdateLeveragePayload, buildHyperliquidMarketOrderPayload, buildHyperliquidLimitOrderPayload, buildHyperliquidTriggerOrderPayload, buildHyperliquidOrderBatchPayload, buildHyperliquidModifyOrderPayload, extractHyperliquidExchangeError, acknowledgementLookupPacing, lookupUntilListed, resolveHyperliquidTriggerAcknowledgements, resolveHyperliquidModifyAcknowledgement, isDefinitiveHyperliquidExchangeResponse, extractDefinitiveHyperliquidOrderId, CANONICAL_POSITIVE_DECIMAL_PATTERN, extractCanonicalHyperliquidOrderStateAcknowledgement, extractCanonicalHyperliquidOrderStateAcknowledgements, extractCanonicalHyperliquidFilledOrderAcknowledgement, extractDefinitiveHyperliquidOrderMemberResults, buildHyperliquidOrderDiagnostics, loadClientExecutionReferenceEvidence, sha256Hex, extractSignedPayloadClientOrderId, extractSignedPayloadMutationCorrelation, assertDurableMutationMatchesSignedAction, exchangeRejectionReason, exchangeActionPriority, submitHyperliquidExchangePayload;
|
|
90359
90367
|
var init_hyperliquid_client = __esm({
|
|
90360
90368
|
"lib/runtime/hyperliquid-client.ts"() {
|
|
90361
90369
|
"use strict";
|
|
@@ -91861,7 +91869,24 @@ var init_hyperliquid_client = __esm({
|
|
|
91861
91869
|
}
|
|
91862
91870
|
return null;
|
|
91863
91871
|
};
|
|
91864
|
-
|
|
91872
|
+
acknowledgementLookupPacing = () => ({
|
|
91873
|
+
windowMs: runtime_policy_generated_default2.exchange.hyperliquid.acknowledgement_lookup.window_milliseconds,
|
|
91874
|
+
pollMs: runtime_policy_generated_default2.exchange.hyperliquid.acknowledgement_lookup.poll_milliseconds,
|
|
91875
|
+
sleep: (ms) => new Promise((resolve14) => {
|
|
91876
|
+
globalThis.setTimeout(resolve14, ms);
|
|
91877
|
+
}),
|
|
91878
|
+
// Monotonic: a wall-clock step must not stretch or cut the window.
|
|
91879
|
+
nowMs: () => globalThis.performance.now()
|
|
91880
|
+
});
|
|
91881
|
+
lookupUntilListed = async (lookup, clientOrderId, pacing) => {
|
|
91882
|
+
const deadline = pacing.nowMs() + pacing.windowMs;
|
|
91883
|
+
for (; ; ) {
|
|
91884
|
+
const evidence = await lookup(clientOrderId);
|
|
91885
|
+
if (evidence.responseStatus !== "unknownOid" || pacing.nowMs() + pacing.pollMs > deadline) return evidence;
|
|
91886
|
+
await pacing.sleep(pacing.pollMs);
|
|
91887
|
+
}
|
|
91888
|
+
};
|
|
91889
|
+
resolveHyperliquidTriggerAcknowledgements = async (payload, action, lookup, pacing = acknowledgementLookupPacing()) => {
|
|
91865
91890
|
if (action.type !== "order" || action.grouping !== "normalTpsl" && action.grouping !== "positionTpsl" || !Array.isArray(action.orders) || payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
91866
91891
|
return payload;
|
|
91867
91892
|
}
|
|
@@ -91883,7 +91908,7 @@ var init_hyperliquid_client = __esm({
|
|
|
91883
91908
|
}
|
|
91884
91909
|
let evidence;
|
|
91885
91910
|
try {
|
|
91886
|
-
evidence = await lookup
|
|
91911
|
+
evidence = await lookupUntilListed(lookup, clientOrderId, pacing);
|
|
91887
91912
|
} catch {
|
|
91888
91913
|
return payload;
|
|
91889
91914
|
}
|
|
@@ -91895,7 +91920,7 @@ var init_hyperliquid_client = __esm({
|
|
|
91895
91920
|
}
|
|
91896
91921
|
return { ...root, response: { ...response, data: { ...data4, statuses: resolved } } };
|
|
91897
91922
|
};
|
|
91898
|
-
resolveHyperliquidModifyAcknowledgement = async (payload, action, lookup) => {
|
|
91923
|
+
resolveHyperliquidModifyAcknowledgement = async (payload, action, lookup, pacing = acknowledgementLookupPacing()) => {
|
|
91899
91924
|
if (action.type !== "modify" || payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
91900
91925
|
return payload;
|
|
91901
91926
|
}
|
|
@@ -91908,7 +91933,7 @@ var init_hyperliquid_client = __esm({
|
|
|
91908
91933
|
}
|
|
91909
91934
|
let evidence;
|
|
91910
91935
|
try {
|
|
91911
|
-
evidence = await lookup
|
|
91936
|
+
evidence = await lookupUntilListed(lookup, clientOrderId, pacing);
|
|
91912
91937
|
} catch {
|
|
91913
91938
|
return payload;
|
|
91914
91939
|
}
|
|
@@ -96303,7 +96328,7 @@ var init_browser_trading = __esm({
|
|
|
96303
96328
|
};
|
|
96304
96329
|
executeClientMarketOrder = async (input) => {
|
|
96305
96330
|
input = { ...input, publicRequestPriority: input.reduceOnly === true ? "trading_reduce" : "trading_execute" };
|
|
96306
|
-
if ((input.positionChildren?.length ?? 0) > 0 && input.protection) {
|
|
96331
|
+
if ((input.positionChildren?.length ?? 0) > 0 && input.protection && !input.protection.native) {
|
|
96307
96332
|
throw new Error("An entry carries either native position children or server-owned protection, not both.");
|
|
96308
96333
|
}
|
|
96309
96334
|
throwIfAborted(input.signal);
|
|
@@ -98348,7 +98373,7 @@ var init_protective_evidence = __esm({
|
|
|
98348
98373
|
});
|
|
98349
98374
|
|
|
98350
98375
|
// lib/runtime/protective-actions.ts
|
|
98351
|
-
var DECIMAL, CLOID, fail2, exactKeys, nonNegativeInteger, decimalString, canonicalTriggerOrder, canonicalProtectiveWireAction, assertProtectiveActionLocallySafe, authorityArgs2, errorCode2, foreignClaimExpiresAtMs, drainLocks, refusedUntil, drainClientProtectiveActions, drainOnce;
|
|
98376
|
+
var DECIMAL, CLOID, fail2, exactKeys, nonNegativeInteger, decimalString, POSITION_ORDER_SIZE, orderSizeString, canonicalTriggerOrder, canonicalProtectiveWireAction, assertProtectiveActionLocallySafe, authorityArgs2, errorCode2, foreignClaimExpiresAtMs, drainLocks, refusedUntil, drainClientProtectiveActions, drainOnce;
|
|
98352
98377
|
var init_protective_actions = __esm({
|
|
98353
98378
|
"lib/runtime/protective-actions.ts"() {
|
|
98354
98379
|
"use strict";
|
|
@@ -98387,6 +98412,8 @@ var init_protective_actions = __esm({
|
|
|
98387
98412
|
if (typeof value !== "string" || !DECIMAL.test(value) || Number(value) <= 0) fail2(`${label2} is invalid.`);
|
|
98388
98413
|
return value;
|
|
98389
98414
|
};
|
|
98415
|
+
POSITION_ORDER_SIZE = "0";
|
|
98416
|
+
orderSizeString = (value) => value === POSITION_ORDER_SIZE ? POSITION_ORDER_SIZE : decimalString(value, "size");
|
|
98390
98417
|
canonicalTriggerOrder = (value) => {
|
|
98391
98418
|
const order = exactKeys(value, ["a", "b", "p", "s", "r", "t", "c"], "order");
|
|
98392
98419
|
const type = exactKeys(order.t, ["trigger"], "order type");
|
|
@@ -98401,7 +98428,7 @@ var init_protective_actions = __esm({
|
|
|
98401
98428
|
a: nonNegativeInteger(order.a, "asset"),
|
|
98402
98429
|
b: order.b,
|
|
98403
98430
|
p: decimalString(order.p, "price"),
|
|
98404
|
-
s:
|
|
98431
|
+
s: orderSizeString(order.s),
|
|
98405
98432
|
r: true,
|
|
98406
98433
|
t: {
|
|
98407
98434
|
trigger: {
|
|
@@ -98419,9 +98446,12 @@ var init_protective_actions = __esm({
|
|
|
98419
98446
|
const action = exactKeys(wire, ["type", "orders", "grouping"], "action");
|
|
98420
98447
|
const orders = Array.isArray(action.orders) ? action.orders.map(canonicalTriggerOrder) : fail2("orders are missing.");
|
|
98421
98448
|
const grouping = action.grouping;
|
|
98422
|
-
|
|
98449
|
+
const positionOrders = orders.filter((order) => order.s === POSITION_ORDER_SIZE);
|
|
98450
|
+
const kinds = orders.map((order) => order.t.trigger.tpsl);
|
|
98451
|
+
if (!(orders.length === 1 && grouping === "na" && positionOrders.length === 0) && !(orders.length === HYPERLIQUID_EXCHANGE_SPECIFICATION.position_tpsl_order_count && grouping === "positionTpsl" && (positionOrders.length === 0 || positionOrders.length === orders.length)) && !(grouping === "positionTpsl" && orders.length === 1 && positionOrders.length === 1)) {
|
|
98423
98452
|
fail2("order grouping is invalid.");
|
|
98424
98453
|
}
|
|
98454
|
+
if (positionOrders.length > 0 && new Set(kinds).size !== kinds.length) fail2("position orders repeat a kind.");
|
|
98425
98455
|
return { type: "order", orders, grouping };
|
|
98426
98456
|
}
|
|
98427
98457
|
if (kind === "modify") {
|
|
@@ -99602,7 +99632,7 @@ var init_protective_entry_cover = __esm({
|
|
|
99602
99632
|
});
|
|
99603
99633
|
|
|
99604
99634
|
// lib/runtime/native-position-protection.ts
|
|
99605
|
-
var nativeProtectionSettings, memberSetting, KINDS, formatTriggerOrNull, nativePositionTriggerPrice, nativeEntryRequest, HALF_UP_DIGIT, roundDecimalHalfUp, nativeTrailingRetracement, nativeAfterFillActions, classifyNativeOrderEnd, isOpenInDirection, nativePlacementGate, nativeStrayOrderDecision, explainAbsentProtectiveOrder;
|
|
99635
|
+
var nativeProtectionSettings, memberSetting, KINDS, formatTriggerOrNull, nativePositionTriggerPrice, nativeEntryRequest, HALF_UP_DIGIT, roundDecimalHalfUp, nativeTrailingRetracement, nativeAfterFillActions, classifyNativeOrderEnd, isOpenInDirection, nativePlacementGate, nativeStrayOrderDecision, FIRED_TRIGGER_CONDITION, closingSide, DECIMAL_PATTERN, decimalUnits2, fractionDigits, nativePlaceCover, nativeRearmDecision, nativeLostStopCrossed, explainAbsentProtectiveOrder, readServerNativeProtectionState;
|
|
99606
99636
|
var init_native_position_protection = __esm({
|
|
99607
99637
|
"lib/runtime/native-position-protection.ts"() {
|
|
99608
99638
|
"use strict";
|
|
@@ -99611,6 +99641,7 @@ var init_native_position_protection = __esm({
|
|
|
99611
99641
|
init_define_VTX_PI_MODEL_POLICY();
|
|
99612
99642
|
init_constants();
|
|
99613
99643
|
init_hyperliquid_client();
|
|
99644
|
+
init_hyperliquid_market_symbol();
|
|
99614
99645
|
init_hyperliquid_order_status();
|
|
99615
99646
|
init_protective_stop_replacement();
|
|
99616
99647
|
nativeProtectionSettings = (resolved) => ({
|
|
@@ -99747,15 +99778,73 @@ var init_native_position_protection = __esm({
|
|
|
99747
99778
|
if (isOpenInDirection(input.position, input.isLong)) return "keep";
|
|
99748
99779
|
return input.positionStateMs > input.placedMs ? "cancel" : "need_reads";
|
|
99749
99780
|
};
|
|
99781
|
+
FIRED_TRIGGER_CONDITION = "Triggered";
|
|
99782
|
+
closingSide = (isLong) => isLong ? "a" : "b";
|
|
99783
|
+
DECIMAL_PATTERN = /^-?\d+(\.\d+)?$/;
|
|
99784
|
+
decimalUnits2 = (value, scale) => {
|
|
99785
|
+
if (!DECIMAL_PATTERN.test(value)) return null;
|
|
99786
|
+
const negative = value.startsWith("-");
|
|
99787
|
+
const [whole, fraction = ""] = (negative ? value.slice(1) : value).split(".");
|
|
99788
|
+
const units = BigInt(`${whole}${fraction.padEnd(scale, "0")}`);
|
|
99789
|
+
return negative ? -units : units;
|
|
99790
|
+
};
|
|
99791
|
+
fractionDigits = (value) => value.includes(".") ? value.split(".")[1].length : 0;
|
|
99792
|
+
nativePlaceCover = (input) => {
|
|
99793
|
+
const market = normalizeHyperliquidMarketSymbol(input.symbol);
|
|
99794
|
+
const own = new Set(input.ownClientOrderIds.map((value) => String(value).trim().toLowerCase()).filter(Boolean));
|
|
99795
|
+
const positionText = String(input.positionSize).replace(/^-/, "");
|
|
99796
|
+
const sized = [];
|
|
99797
|
+
for (const row of input.rows) {
|
|
99798
|
+
if (normalizeHyperliquidMarketSymbol(String(row.coin ?? "")) !== market) continue;
|
|
99799
|
+
if (row.reduceOnly !== true || row.isTrigger !== true) continue;
|
|
99800
|
+
if (String(row.triggerCondition ?? "").trim() === FIRED_TRIGGER_CONDITION) continue;
|
|
99801
|
+
if (String(row.side ?? "").trim().toLowerCase() !== closingSide(input.isLong)) continue;
|
|
99802
|
+
const orderType = String(row.orderType ?? "").toLowerCase();
|
|
99803
|
+
const rowKind = orderType.includes("take profit") ? "tp" : orderType.includes("stop") ? "sl" : null;
|
|
99804
|
+
if (rowKind !== input.kind) continue;
|
|
99805
|
+
if (own.has(String(row.cloid ?? "").trim().toLowerCase())) {
|
|
99806
|
+
return { decision: "adopt", order_id: Number(row.oid) };
|
|
99807
|
+
}
|
|
99808
|
+
const size = String(row.sz ?? "").trim();
|
|
99809
|
+
if (!DECIMAL_PATTERN.test(size)) return { decision: "need_reads" };
|
|
99810
|
+
const wholePosition = row.isPositionTpsl === true && Number(size) === 0;
|
|
99811
|
+
if (!wholePosition && !(Number(size) > 0)) return { decision: "need_reads" };
|
|
99812
|
+
sized.push(wholePosition ? positionText : size);
|
|
99813
|
+
}
|
|
99814
|
+
if (!DECIMAL_PATTERN.test(positionText)) return { decision: "place" };
|
|
99815
|
+
const scale = Math.max(fractionDigits(positionText), ...sized.map(fractionDigits));
|
|
99816
|
+
const position = decimalUnits2(positionText, scale);
|
|
99817
|
+
const covered = sized.reduce((total, size) => total + decimalUnits2(size, scale), BigInt(0));
|
|
99818
|
+
return position > BigInt(0) && covered >= position ? { decision: "covered" } : { decision: "place" };
|
|
99819
|
+
};
|
|
99820
|
+
nativeRearmDecision = (input) => {
|
|
99821
|
+
if (!isOpenInDirection(input.position, input.isLong)) return "retire";
|
|
99822
|
+
if (input.endedMs == null || !(input.positionStateMs > input.endedMs)) return "need_reads";
|
|
99823
|
+
return "rearm";
|
|
99824
|
+
};
|
|
99825
|
+
nativeLostStopCrossed = (input) => {
|
|
99826
|
+
if (input.mark == null || !Number.isFinite(input.mark)) return false;
|
|
99827
|
+
return input.isLong ? input.mark <= input.trigger : input.mark >= input.trigger;
|
|
99828
|
+
};
|
|
99750
99829
|
explainAbsentProtectiveOrder = (input) => {
|
|
99751
99830
|
if (isOpenInDirection(input.position, input.isLong)) return "status_read";
|
|
99752
99831
|
return input.positionStateMs > input.lastSeenRestingMs ? "ended_with_position" : "need_reads";
|
|
99753
99832
|
};
|
|
99833
|
+
readServerNativeProtectionState = (listing) => {
|
|
99834
|
+
const raw = listing?.native_position_protection;
|
|
99835
|
+
if (!raw || typeof raw !== "object") return null;
|
|
99836
|
+
const record5 = raw;
|
|
99837
|
+
const symbols = (value) => Array.isArray(value) && value.every((item) => typeof item === "string") ? value : null;
|
|
99838
|
+
const legacy = symbols(record5.legacy_symbols);
|
|
99839
|
+
const native = symbols(record5.native_symbols);
|
|
99840
|
+
if (typeof record5.enabled !== "boolean" || legacy == null || native == null) return null;
|
|
99841
|
+
return { enabled: record5.enabled, legacySymbols: new Set(legacy), nativeSymbols: new Set(native) };
|
|
99842
|
+
};
|
|
99754
99843
|
}
|
|
99755
99844
|
});
|
|
99756
99845
|
|
|
99757
99846
|
// lib/runtime/native-protection-device.ts
|
|
99758
|
-
var NATIVE_PROTECTION_RECORD_VERSION, nativeProtectionStorage, resolveStorage, setNativeProtectionStorage, recordKey, isMember, readNativeProtectionRecord, writeNativeProtectionRecord, NativeOrderNotSentError, withDispatchBoundary, attempt, errorText, actionOf, isOpenInDirection2, restingOrderIdAt, definitivelyRefused, planNativeOpen, recordEntryChildren, observeMembers, UNKNOWN_ORDER_RESPONSE, resolveUnknownOrderIds, settleNativeProtectionAfterFill, reconcileNativeProtection;
|
|
99847
|
+
var NATIVE_PROTECTION_RECORD_VERSION, nativeProtectionStorage, resolveStorage, setNativeProtectionStorage, recordKey, isMember, readNativeProtectionRecord, writeNativeProtectionRecord, NativeOrderNotSentError, withDispatchBoundary, attempt, notSentRestores, errorText, actionOf, isOpenInDirection2, coverRows, restingOrderIdAt, definitivelyRefused, planNativeOpen, recordEntryChildren, observeMembers, UNKNOWN_ORDER_RESPONSE, resolveUnknownOrderIds, settleNativeProtectionAfterFill, reconcileNativeProtection;
|
|
99759
99848
|
var init_native_protection_device = __esm({
|
|
99760
99849
|
"lib/runtime/native-protection-device.ts"() {
|
|
99761
99850
|
"use strict";
|
|
@@ -99828,12 +99917,35 @@ var init_native_protection_device = __esm({
|
|
|
99828
99917
|
const response = await call();
|
|
99829
99918
|
return definitivelyRefused(response) ? { ok: false, refused: true, error: response } : { ok: true, response };
|
|
99830
99919
|
} catch (error48) {
|
|
99920
|
+
if (io.endsPass?.(error48)) throw error48;
|
|
99831
99921
|
return { ok: false, refused: io.isDefinitiveRefusal(error48), error: error48 };
|
|
99832
99922
|
}
|
|
99833
99923
|
};
|
|
99924
|
+
notSentRestores = async (send, restore) => {
|
|
99925
|
+
try {
|
|
99926
|
+
return await send();
|
|
99927
|
+
} catch (error48) {
|
|
99928
|
+
if (error48 instanceof NativeOrderNotSentError) restore();
|
|
99929
|
+
throw error48;
|
|
99930
|
+
}
|
|
99931
|
+
};
|
|
99834
99932
|
errorText = (error48) => error48 instanceof Error ? error48.message : typeof error48 === "string" ? error48 : "Exchange call failed.";
|
|
99835
99933
|
actionOf = (kind) => kind === "sl" ? "AUTO_SL" : "AUTO_TP";
|
|
99836
99934
|
isOpenInDirection2 = (position, isLong) => isLong ? position > 0 : position < 0;
|
|
99935
|
+
coverRows = (page) => page.map((order) => ({
|
|
99936
|
+
coin: order.coin,
|
|
99937
|
+
side: order.side,
|
|
99938
|
+
sz: String(order.sz),
|
|
99939
|
+
oid: order.oid,
|
|
99940
|
+
orderType: order.order_type,
|
|
99941
|
+
triggerCondition: order.trigger_condition,
|
|
99942
|
+
isTrigger: order.is_trigger,
|
|
99943
|
+
reduceOnly: order.reduce_only,
|
|
99944
|
+
isPositionTpsl: order.is_position_tpsl,
|
|
99945
|
+
// The parsed page carries no client order id: a member's own unnamed order
|
|
99946
|
+
// counts as cover (nothing is placed) until its status read names it.
|
|
99947
|
+
cloid: null
|
|
99948
|
+
}));
|
|
99837
99949
|
restingOrderIdAt = (response, index) => {
|
|
99838
99950
|
const statuses = response?.response?.data?.statuses;
|
|
99839
99951
|
const status = Array.isArray(statuses) ? statuses[index] : void 0;
|
|
@@ -100039,7 +100151,7 @@ var init_native_protection_device = __esm({
|
|
|
100039
100151
|
action: actionOf(step.kind),
|
|
100040
100152
|
status: "failed",
|
|
100041
100153
|
execution_metadata: {
|
|
100042
|
-
reason_code: "protective_modify_rejected",
|
|
100154
|
+
reason_code: outcome2.error instanceof NativeOrderNotSentError ? "protective_modify_not_sent" : "protective_modify_rejected",
|
|
100043
100155
|
trigger_price: step.trigger,
|
|
100044
100156
|
error: errorText(outcome2.error)
|
|
100045
100157
|
}
|
|
@@ -100081,20 +100193,58 @@ var init_native_protection_device = __esm({
|
|
|
100081
100193
|
});
|
|
100082
100194
|
continue;
|
|
100083
100195
|
}
|
|
100196
|
+
const cover = nativePlaceCover({
|
|
100197
|
+
kind: step.kind,
|
|
100198
|
+
isLong: record5.isLong,
|
|
100199
|
+
symbol: symbol2,
|
|
100200
|
+
positionSize: String(position.size),
|
|
100201
|
+
ownClientOrderIds: [],
|
|
100202
|
+
rows: coverRows(page)
|
|
100203
|
+
});
|
|
100204
|
+
if (cover.decision !== "place") {
|
|
100205
|
+
continue;
|
|
100206
|
+
}
|
|
100084
100207
|
const sentAtMs = io.nowMs();
|
|
100085
|
-
const
|
|
100208
|
+
const journaled = {
|
|
100086
100209
|
kind: step.kind,
|
|
100087
|
-
|
|
100088
|
-
|
|
100089
|
-
|
|
100210
|
+
clientOrderId,
|
|
100211
|
+
orderId: null,
|
|
100212
|
+
trigger: step.trigger,
|
|
100213
|
+
placedAtMs: null,
|
|
100214
|
+
sentAtMs,
|
|
100215
|
+
replacedOnce: existing?.replacedOnce ?? false
|
|
100216
|
+
};
|
|
100217
|
+
const before = [...members];
|
|
100218
|
+
if (index >= 0) members[index] = journaled;
|
|
100219
|
+
else members.push(journaled);
|
|
100220
|
+
if (!io.persist({ ...record5, phase: "active", members })) {
|
|
100221
|
+
members.splice(0, members.length, ...before);
|
|
100222
|
+
reports.push({
|
|
100223
|
+
order_id: null,
|
|
100224
|
+
symbol: symbol2,
|
|
100225
|
+
action: actionOf(step.kind),
|
|
100226
|
+
status: "failed",
|
|
100227
|
+
execution_metadata: { reason_code: "protective_lifecycle_persistence_failed", trigger_price: step.trigger }
|
|
100228
|
+
});
|
|
100229
|
+
continue;
|
|
100230
|
+
}
|
|
100231
|
+
const outcome = await notSentRestores(
|
|
100232
|
+
() => attempt(io, () => io.placePositionOrder({
|
|
100233
|
+
kind: step.kind,
|
|
100234
|
+
triggerPrice: Number(step.trigger),
|
|
100235
|
+
clientOrderId
|
|
100236
|
+
})),
|
|
100237
|
+
() => io.persist({ ...record5, phase: "active", members: before })
|
|
100238
|
+
);
|
|
100090
100239
|
if (!outcome.ok && outcome.refused) {
|
|
100240
|
+
members.splice(0, members.length, ...before);
|
|
100091
100241
|
reports.push({
|
|
100092
100242
|
order_id: null,
|
|
100093
100243
|
symbol: symbol2,
|
|
100094
100244
|
action: actionOf(step.kind),
|
|
100095
100245
|
status: "failed",
|
|
100096
100246
|
execution_metadata: {
|
|
100097
|
-
reason_code: "protective_place_rejected",
|
|
100247
|
+
reason_code: outcome.error instanceof NativeOrderNotSentError ? "protective_place_not_sent" : "protective_place_rejected",
|
|
100098
100248
|
trigger_price: step.trigger,
|
|
100099
100249
|
error: errorText(outcome.error)
|
|
100100
100250
|
}
|
|
@@ -100102,16 +100252,11 @@ var init_native_protection_device = __esm({
|
|
|
100102
100252
|
continue;
|
|
100103
100253
|
}
|
|
100104
100254
|
const placed = {
|
|
100105
|
-
|
|
100106
|
-
|
|
100107
|
-
orderId: outcome.ok ? restingOrderIdAt(outcome.response, 0) : null,
|
|
100108
|
-
trigger: step.trigger,
|
|
100109
|
-
placedAtMs: null,
|
|
100110
|
-
sentAtMs,
|
|
100111
|
-
replacedOnce: existing?.replacedOnce ?? false
|
|
100255
|
+
...journaled,
|
|
100256
|
+
orderId: outcome.ok ? restingOrderIdAt(outcome.response, 0) : null
|
|
100112
100257
|
};
|
|
100113
100258
|
if (index >= 0) members[index] = placed;
|
|
100114
|
-
else members.
|
|
100259
|
+
else members[members.length - 1] = placed;
|
|
100115
100260
|
reports.push({
|
|
100116
100261
|
order_id: placed.orderId == null ? null : String(placed.orderId),
|
|
100117
100262
|
symbol: symbol2,
|
|
@@ -100169,6 +100314,7 @@ var init_native_protection_device = __esm({
|
|
|
100169
100314
|
sizeDecimals: input.sizeDecimals
|
|
100170
100315
|
}) : null;
|
|
100171
100316
|
};
|
|
100317
|
+
const kindEnabled = (member) => (member.kind === "sl" ? input.settings.stopLoss : input.settings.takeProfit) != null;
|
|
100172
100318
|
const placeMember = async (args) => {
|
|
100173
100319
|
const gate = nativePlacementGate({
|
|
100174
100320
|
eventMs: args.eventMs,
|
|
@@ -100177,13 +100323,80 @@ var init_native_protection_device = __esm({
|
|
|
100177
100323
|
isLong: record5.isLong
|
|
100178
100324
|
});
|
|
100179
100325
|
if (gate !== "place") return args.member;
|
|
100326
|
+
const cover = nativePlaceCover({
|
|
100327
|
+
kind: args.member.kind,
|
|
100328
|
+
isLong: record5.isLong,
|
|
100329
|
+
symbol: symbol2,
|
|
100330
|
+
positionSize: String(position.size),
|
|
100331
|
+
ownClientOrderIds: [],
|
|
100332
|
+
rows: coverRows(page)
|
|
100333
|
+
});
|
|
100334
|
+
if (cover.decision !== "place") return args.member;
|
|
100180
100335
|
const clientOrderId = clientOrderIdForMutation(io.newMutationId());
|
|
100181
100336
|
const sentAtMs = io.nowMs();
|
|
100182
|
-
const
|
|
100337
|
+
const journaled = {
|
|
100183
100338
|
kind: args.member.kind,
|
|
100184
|
-
|
|
100185
|
-
|
|
100186
|
-
|
|
100339
|
+
clientOrderId,
|
|
100340
|
+
orderId: null,
|
|
100341
|
+
trigger: args.trigger,
|
|
100342
|
+
placedAtMs: null,
|
|
100343
|
+
sentAtMs,
|
|
100344
|
+
replacedOnce: args.replacedOnce
|
|
100345
|
+
};
|
|
100346
|
+
if (!io.persist({
|
|
100347
|
+
...record5,
|
|
100348
|
+
members: [
|
|
100349
|
+
...members,
|
|
100350
|
+
journaled,
|
|
100351
|
+
...observations.slice(args.observationIndex + 1).map((entry) => entry.member)
|
|
100352
|
+
]
|
|
100353
|
+
})) {
|
|
100354
|
+
reports.push({
|
|
100355
|
+
order_id: args.member.orderId == null ? null : String(args.member.orderId),
|
|
100356
|
+
symbol: symbol2,
|
|
100357
|
+
action: actionOf(args.member.kind),
|
|
100358
|
+
status: "failed",
|
|
100359
|
+
execution_metadata: { reason_code: "protective_lifecycle_persistence_failed", trigger_price: args.trigger }
|
|
100360
|
+
});
|
|
100361
|
+
return args.member;
|
|
100362
|
+
}
|
|
100363
|
+
const outcome = await notSentRestores(
|
|
100364
|
+
() => attempt(io, () => io.placePositionOrder({
|
|
100365
|
+
kind: args.member.kind,
|
|
100366
|
+
triggerPrice: Number(args.trigger),
|
|
100367
|
+
clientOrderId
|
|
100368
|
+
})),
|
|
100369
|
+
() => io.persist({
|
|
100370
|
+
...record5,
|
|
100371
|
+
members: [
|
|
100372
|
+
...members,
|
|
100373
|
+
args.member,
|
|
100374
|
+
...observations.slice(args.observationIndex + 1).map((entry) => entry.member)
|
|
100375
|
+
]
|
|
100376
|
+
})
|
|
100377
|
+
);
|
|
100378
|
+
if (!outcome.ok && outcome.error instanceof NativeOrderNotSentError) {
|
|
100379
|
+
io.persist({
|
|
100380
|
+
...record5,
|
|
100381
|
+
members: [
|
|
100382
|
+
...members,
|
|
100383
|
+
args.member,
|
|
100384
|
+
...observations.slice(args.observationIndex + 1).map((entry) => entry.member)
|
|
100385
|
+
]
|
|
100386
|
+
});
|
|
100387
|
+
reports.push({
|
|
100388
|
+
order_id: args.member.orderId == null ? null : String(args.member.orderId),
|
|
100389
|
+
symbol: symbol2,
|
|
100390
|
+
action: actionOf(args.member.kind),
|
|
100391
|
+
status: "failed",
|
|
100392
|
+
execution_metadata: {
|
|
100393
|
+
reason_code: "protective_place_not_sent",
|
|
100394
|
+
trigger_price: args.trigger,
|
|
100395
|
+
error: errorText(outcome.error)
|
|
100396
|
+
}
|
|
100397
|
+
});
|
|
100398
|
+
return args.member;
|
|
100399
|
+
}
|
|
100187
100400
|
const refused = !outcome.ok && outcome.refused;
|
|
100188
100401
|
const placed = {
|
|
100189
100402
|
kind: args.member.kind,
|
|
@@ -100211,7 +100424,7 @@ var init_native_protection_device = __esm({
|
|
|
100211
100424
|
});
|
|
100212
100425
|
return placed;
|
|
100213
100426
|
};
|
|
100214
|
-
for (const { member, row } of observations) {
|
|
100427
|
+
for (const [observationIndex, { member, row }] of observations.entries()) {
|
|
100215
100428
|
if (row) {
|
|
100216
100429
|
const stray = nativeStrayOrderDecision({
|
|
100217
100430
|
placedMs: member.placedAtMs ?? Number.POSITIVE_INFINITY,
|
|
@@ -100257,13 +100470,20 @@ var init_native_protection_device = __esm({
|
|
|
100257
100470
|
members.push(member);
|
|
100258
100471
|
continue;
|
|
100259
100472
|
}
|
|
100260
|
-
if (!positionOpen) continue;
|
|
100473
|
+
if (!positionOpen || !kindEnabled(member)) continue;
|
|
100474
|
+
const neverLandedTrigger = currentTrigger(member);
|
|
100475
|
+
if (neverLandedTrigger == null) {
|
|
100476
|
+
anyResting = true;
|
|
100477
|
+
members.push(member);
|
|
100478
|
+
continue;
|
|
100479
|
+
}
|
|
100261
100480
|
const placed = await placeMember({
|
|
100262
100481
|
member,
|
|
100263
|
-
trigger:
|
|
100482
|
+
trigger: neverLandedTrigger,
|
|
100264
100483
|
replacedOnce: member.replacedOnce,
|
|
100265
100484
|
eventMs: Number.NEGATIVE_INFINITY,
|
|
100266
|
-
reasonCode: "protective_order_never_landed_placed"
|
|
100485
|
+
reasonCode: "protective_order_never_landed_placed",
|
|
100486
|
+
observationIndex
|
|
100267
100487
|
});
|
|
100268
100488
|
members.push(placed);
|
|
100269
100489
|
if (!placed.retiredReason) anyResting = true;
|
|
@@ -100304,6 +100524,27 @@ var init_native_protection_device = __esm({
|
|
|
100304
100524
|
continue;
|
|
100305
100525
|
}
|
|
100306
100526
|
if (end === "fired" || end === "ended_with_position") {
|
|
100527
|
+
const rearm = nativeRearmDecision({
|
|
100528
|
+
position: position.size,
|
|
100529
|
+
positionStateMs: stateMs,
|
|
100530
|
+
endedMs: evidence.statusTimestampMs ?? null,
|
|
100531
|
+
isLong: record5.isLong
|
|
100532
|
+
});
|
|
100533
|
+
if (rearm === "retire" || !kindEnabled(member)) continue;
|
|
100534
|
+
const rearmTrigger = currentTrigger(member);
|
|
100535
|
+
if (rearm === "need_reads" || rearmTrigger == null) {
|
|
100536
|
+
members.push(member);
|
|
100537
|
+
continue;
|
|
100538
|
+
}
|
|
100539
|
+
const rearmed = await placeMember({
|
|
100540
|
+
member,
|
|
100541
|
+
trigger: rearmTrigger,
|
|
100542
|
+
replacedOnce: false,
|
|
100543
|
+
eventMs: evidence.statusTimestampMs ?? Number.POSITIVE_INFINITY,
|
|
100544
|
+
reasonCode: "protective_native_rearmed",
|
|
100545
|
+
observationIndex
|
|
100546
|
+
});
|
|
100547
|
+
members.push(rearmed);
|
|
100307
100548
|
continue;
|
|
100308
100549
|
}
|
|
100309
100550
|
if (end === "lost_permanent" || member.replacedOnce) {
|
|
@@ -100325,13 +100566,41 @@ var init_native_protection_device = __esm({
|
|
|
100325
100566
|
members.push({ ...member, retiredReason: "protective_take_profit_lost" });
|
|
100326
100567
|
continue;
|
|
100327
100568
|
}
|
|
100328
|
-
|
|
100569
|
+
if (!kindEnabled(member)) continue;
|
|
100570
|
+
const trigger = currentTrigger(member);
|
|
100571
|
+
const lostGate = nativePlacementGate({
|
|
100572
|
+
eventMs: evidence.statusTimestampMs ?? Number.POSITIVE_INFINITY,
|
|
100573
|
+
position: position.size,
|
|
100574
|
+
positionStateMs: stateMs,
|
|
100575
|
+
isLong: record5.isLong
|
|
100576
|
+
});
|
|
100577
|
+
if (trigger == null || lostGate !== "place") {
|
|
100578
|
+
members.push(member);
|
|
100579
|
+
continue;
|
|
100580
|
+
}
|
|
100581
|
+
if (nativeLostStopCrossed({ isLong: record5.isLong, trigger: Number(trigger), mark: position.markPrice ?? null })) {
|
|
100582
|
+
members.push({ ...member, retiredReason: "protective_stop_trigger_crossed" });
|
|
100583
|
+
reports.push({
|
|
100584
|
+
order_id: String(member.orderId),
|
|
100585
|
+
symbol: symbol2,
|
|
100586
|
+
action: actionOf(member.kind),
|
|
100587
|
+
status: "failed",
|
|
100588
|
+
execution_metadata: {
|
|
100589
|
+
reason_code: "protective_stop_trigger_crossed",
|
|
100590
|
+
trigger_price: trigger,
|
|
100591
|
+
mark_price: position.markPrice,
|
|
100592
|
+
manual_intervention: true
|
|
100593
|
+
}
|
|
100594
|
+
});
|
|
100595
|
+
continue;
|
|
100596
|
+
}
|
|
100329
100597
|
const replacement = await placeMember({
|
|
100330
100598
|
member,
|
|
100331
100599
|
trigger,
|
|
100332
100600
|
replacedOnce: true,
|
|
100333
100601
|
eventMs: evidence.statusTimestampMs ?? Number.POSITIVE_INFINITY,
|
|
100334
|
-
reasonCode: "protective_stop_replaced"
|
|
100602
|
+
reasonCode: "protective_stop_replaced",
|
|
100603
|
+
observationIndex
|
|
100335
100604
|
});
|
|
100336
100605
|
members.push(replacement);
|
|
100337
100606
|
if (replacement !== member && !replacement.retiredReason) anyResting = true;
|
|
@@ -100380,7 +100649,7 @@ function copiedTargetNow(reconciliation, recordedTarget, actualPosition) {
|
|
|
100380
100649
|
);
|
|
100381
100650
|
return { copiedNow, targetNow, kept: copiedTargetBesideOwnPosition(targetNow, copiedNow, actualPosition) };
|
|
100382
100651
|
}
|
|
100383
|
-
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, _extractOrderResponseStates, createRuntimeId, _extractFilledSize, firstMemberAcknowledgement, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, LOST_LEG_EVIDENCE_MAX_AGE_MS, EPISODE_END_FILL_LOOKBACK_MS, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, executedProtectiveReport, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, attachmentMemberNeverLanded, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, ledgerOrderIdsByClientOrderId, journaledAttachmentNeverLanded, recoverJournaledClientProtectiveAttachments, readClientOrderMutation, readPendingEntryMutation, clientOrderNeverLandsAfterMs, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, liveProtectiveOrderShape, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, nativeSettingsOf, nativeProtectionIo, nativeStorageReport, readNativeRecord, reconcileNativeProtectionForDecision, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep2, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, readServerOrderMarkPrice, serverOrderMetadataRetry, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, unsentDecisionOrderReport, withCapacityTrim, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, decisionLegOf, withExecutionAuditId, executeClientRuntimeDecision, waitForFlipCloseFreshness, maintainClientRuntimeTrailingStops, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, clientRuntimeDecisionSizesOrders, COMMITTED_EXECUTION_REPORTS, COMMITTED_DECISION_ORDER, getCommittedExecutionReports, getCommittedDecisionOrder, withCommittedExecutionReports, executeClientRuntimeDecisionUnlocked, executeClientCopyTradingIntent, _copyCancelOrderId, executeClientCopyTradingOrderAction;
|
|
100652
|
+
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, _extractOrderResponseStates, createRuntimeId, _extractFilledSize, firstMemberAcknowledgement, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, LOST_LEG_EVIDENCE_MAX_AGE_MS, EPISODE_END_FILL_LOOKBACK_MS, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, executedProtectiveReport, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, attachmentMemberNeverLanded, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, ledgerOrderIdsByClientOrderId, journaledAttachmentNeverLanded, recoverJournaledClientProtectiveAttachments, readClientOrderMutation, readPendingEntryMutation, clientOrderNeverLandsAfterMs, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, liveProtectiveOrderShape, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, nativeSettingsOf, nativePassEnded, nativeProtectionIo, nativeStorageReport, readNativeRecord, reconcileNativeProtectionForDecision, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep2, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, readServerOrderMarkPrice, serverOrderMetadataRetry, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionListings, runtimeProtectionListing, resolveServerNativeEntry, SERVER_NATIVE_LEGACY_REFUSAL, isServerNativeLegacyRefusal, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, unsentDecisionOrderReport, withCapacityTrim, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, decisionLegOf, withExecutionAuditId, executeClientRuntimeDecision, waitForFlipCloseFreshness, maintainClientRuntimeTrailingStops, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, clientRuntimeDecisionSizesOrders, COMMITTED_EXECUTION_REPORTS, COMMITTED_DECISION_ORDER, getCommittedExecutionReports, getCommittedDecisionOrder, withCommittedExecutionReports, executeClientRuntimeDecisionUnlocked, executeClientCopyTradingIntent, _copyCancelOrderId, executeClientCopyTradingOrderAction;
|
|
100384
100653
|
var init_runtime_execution = __esm({
|
|
100385
100654
|
"lib/runtime/runtime-execution.ts"() {
|
|
100386
100655
|
"use strict";
|
|
@@ -101071,7 +101340,7 @@ var init_runtime_execution = __esm({
|
|
|
101071
101340
|
if (status != null && status !== HTTP_STATUS.UNAUTHORIZED && status !== HTTP_STATUS.FORBIDDEN) return false;
|
|
101072
101341
|
return normalized.includes("runtime lease required") || normalized.includes("invalid or expired runtime lease") || normalized.includes("runtime lease no longer resolves to an active profile") || normalized.includes("runtime lease does not match the requested runtime session");
|
|
101073
101342
|
};
|
|
101074
|
-
hasClientRuntimeProtectionState = (profileId, symbol2) => readClientProtectiveGroups(String(profileId).trim(), symbol2).length > 0 || hasClientProtectiveGroupReadFailure(String(profileId).trim(), symbol2);
|
|
101343
|
+
hasClientRuntimeProtectionState = (profileId, symbol2) => readClientProtectiveGroups(String(profileId).trim(), symbol2).length > 0 || hasClientProtectiveGroupReadFailure(String(profileId).trim(), symbol2) || readNativeRecord(String(profileId).trim(), symbol2).kind !== "none";
|
|
101075
101344
|
clearClientRuntimeVetoedProtectiveIntent = (input) => {
|
|
101076
101345
|
const profileId = String(input.profileId).trim();
|
|
101077
101346
|
const symbol2 = String(input.symbol).trim();
|
|
@@ -103954,6 +104223,7 @@ var init_runtime_execution = __esm({
|
|
|
103954
104223
|
takeProfitPct: toPositiveNumber(context.takeProfitPct),
|
|
103955
104224
|
takeProfitUsdc: toPositiveNumber(context.takeProfitUsdc)
|
|
103956
104225
|
});
|
|
104226
|
+
nativePassEnded = (request, error48) => Boolean(request.signal?.aborted) || isClientRuntimeWindowHandoffBeforePlanDispatch(error48 instanceof NativeOrderNotSentError ? error48.cause : error48);
|
|
103957
104227
|
nativeProtectionIo = (request, isLong) => {
|
|
103958
104228
|
const symbol2 = request.executionContext.symbol;
|
|
103959
104229
|
const walletAddress = String(request.executionContext.walletAddress || "").trim();
|
|
@@ -103972,6 +104242,12 @@ var init_runtime_execution = __esm({
|
|
|
103972
104242
|
if (!mutationId) throw new Error("Native protective order id is malformed.");
|
|
103973
104243
|
return mutationId;
|
|
103974
104244
|
};
|
|
104245
|
+
const fenced = (call) => withDispatchBoundary(
|
|
104246
|
+
(onDispatched) => call(() => {
|
|
104247
|
+
request.onExchangeOrderDispatched?.("protection");
|
|
104248
|
+
onDispatched();
|
|
104249
|
+
})
|
|
104250
|
+
);
|
|
103975
104251
|
return {
|
|
103976
104252
|
readPosition: async () => {
|
|
103977
104253
|
const snapshot = await fetchBrowserPositionSnapshot(
|
|
@@ -103981,7 +104257,12 @@ var init_runtime_execution = __esm({
|
|
|
103981
104257
|
request.signal,
|
|
103982
104258
|
"trading_reduce"
|
|
103983
104259
|
);
|
|
103984
|
-
return {
|
|
104260
|
+
return {
|
|
104261
|
+
size: snapshot.size,
|
|
104262
|
+
entryPrice: snapshot.entryPrice,
|
|
104263
|
+
stateTimeMs: snapshot.stateTimeMs,
|
|
104264
|
+
markPrice: snapshot.markPrice
|
|
104265
|
+
};
|
|
103985
104266
|
},
|
|
103986
104267
|
readOpenOrders: () => fetchClientRuntimeOpenOrders(request, "trading_reduce"),
|
|
103987
104268
|
readOrderStatus: (orderId) => fetchBrowserOrderStatusEvidence({
|
|
@@ -103991,7 +104272,7 @@ var init_runtime_execution = __esm({
|
|
|
103991
104272
|
signal: request.signal,
|
|
103992
104273
|
orderId
|
|
103993
104274
|
}),
|
|
103994
|
-
placePositionOrder: ({ kind, triggerPrice, clientOrderId }) =>
|
|
104275
|
+
placePositionOrder: ({ kind, triggerPrice, clientOrderId }) => fenced((onExchangeOrderDispatched) => executeClientOrderBatch({
|
|
103995
104276
|
...common,
|
|
103996
104277
|
onExchangeOrderDispatched,
|
|
103997
104278
|
mutationId: mutationOf(clientOrderId),
|
|
@@ -104010,7 +104291,7 @@ var init_runtime_execution = __esm({
|
|
|
104010
104291
|
clientOrderId
|
|
104011
104292
|
}]
|
|
104012
104293
|
})),
|
|
104013
|
-
modifyPositionOrder: ({ orderId, kind, triggerPrice, clientOrderId }) =>
|
|
104294
|
+
modifyPositionOrder: ({ orderId, kind, triggerPrice, clientOrderId }) => fenced((onExchangeOrderDispatched) => executeClientModifyOrder({
|
|
104014
104295
|
...common,
|
|
104015
104296
|
onExchangeOrderDispatched,
|
|
104016
104297
|
mutationId: mutationOf(clientOrderId),
|
|
@@ -104026,7 +104307,7 @@ var init_runtime_execution = __esm({
|
|
|
104026
104307
|
triggerIsMarket: true,
|
|
104027
104308
|
positionOrder: true
|
|
104028
104309
|
})),
|
|
104029
|
-
cancelOrder: (orderId) =>
|
|
104310
|
+
cancelOrder: (orderId) => fenced((onExchangeOrderDispatched) => executeClientCancelOrder({
|
|
104030
104311
|
...common,
|
|
104031
104312
|
onExchangeOrderDispatched,
|
|
104032
104313
|
publicRequestPriority: "trading_reduce",
|
|
@@ -104036,7 +104317,8 @@ var init_runtime_execution = __esm({
|
|
|
104036
104317
|
neverLandsAfterMs: (sentAtMs) => clientOrderNeverLandsAfterMs(request.config, { kind: "absent", ageStartMs: sentAtMs }),
|
|
104037
104318
|
newMutationId: () => createRuntimeId().toLowerCase(),
|
|
104038
104319
|
nowMs: () => Date.now(),
|
|
104039
|
-
persist: (record5) => writeNativeProtectionRecord(String(request.profileId).trim(), symbol2, record5)
|
|
104320
|
+
persist: (record5) => writeNativeProtectionRecord(String(request.profileId).trim(), symbol2, record5),
|
|
104321
|
+
endsPass: (error48) => nativePassEnded(request, error48)
|
|
104040
104322
|
};
|
|
104041
104323
|
};
|
|
104042
104324
|
nativeStorageReport = (symbol2, reasonCode) => ({
|
|
@@ -104091,7 +104373,9 @@ var init_runtime_execution = __esm({
|
|
|
104091
104373
|
}
|
|
104092
104374
|
return reports;
|
|
104093
104375
|
} catch (error48) {
|
|
104094
|
-
if (request
|
|
104376
|
+
if (nativePassEnded(request, error48)) {
|
|
104377
|
+
throw error48 instanceof NativeOrderNotSentError ? error48.cause : error48;
|
|
104378
|
+
}
|
|
104095
104379
|
return [{
|
|
104096
104380
|
...nativeStorageReport(symbol2, "protective_open_orders_unresolved"),
|
|
104097
104381
|
execution_metadata: {
|
|
@@ -105855,10 +106139,9 @@ var init_runtime_execution = __esm({
|
|
|
105855
106139
|
runtimeDeviceId: request.runtimeDeviceId,
|
|
105856
106140
|
schedulerInstanceId: request.schedulerInstanceId
|
|
105857
106141
|
});
|
|
105858
|
-
|
|
105859
|
-
|
|
105860
|
-
|
|
105861
|
-
const cached2 = runtimeProtectionOwners.get(request);
|
|
106142
|
+
runtimeProtectionListings = /* @__PURE__ */ new WeakMap();
|
|
106143
|
+
runtimeProtectionListing = (request) => {
|
|
106144
|
+
const cached2 = runtimeProtectionListings.get(request);
|
|
105862
106145
|
if (cached2) return cached2;
|
|
105863
106146
|
const authority = runtimeProtectionAuthority(request);
|
|
105864
106147
|
const pending3 = listClientProtectiveActions(
|
|
@@ -105867,7 +106150,49 @@ var init_runtime_execution = __esm({
|
|
|
105867
106150
|
authority.runtimeLeaseToken,
|
|
105868
106151
|
authority.runtimeDeviceId,
|
|
105869
106152
|
authority.schedulerInstanceId
|
|
105870
|
-
)
|
|
106153
|
+
);
|
|
106154
|
+
runtimeProtectionListings.set(request, pending3);
|
|
106155
|
+
return pending3;
|
|
106156
|
+
};
|
|
106157
|
+
resolveServerNativeEntry = async (input) => {
|
|
106158
|
+
let state2;
|
|
106159
|
+
try {
|
|
106160
|
+
state2 = readServerNativeProtectionState(await runtimeProtectionListing(input.request));
|
|
106161
|
+
} catch {
|
|
106162
|
+
return null;
|
|
106163
|
+
}
|
|
106164
|
+
if (state2 == null || !state2.enabled) return null;
|
|
106165
|
+
const settings = nativeSettingsOf(input.request.executionContext);
|
|
106166
|
+
if (settings.stopLoss?.trailing) return null;
|
|
106167
|
+
const symbol2 = normalizeHyperliquidMarketSymbol(input.request.executionContext.symbol);
|
|
106168
|
+
const request = nativeEntryRequest({
|
|
106169
|
+
settings,
|
|
106170
|
+
isLong: input.isLong,
|
|
106171
|
+
sizeDecimals: input.request.executionContext.sizeDecimals,
|
|
106172
|
+
referencePrice: input.referencePrice,
|
|
106173
|
+
entrySize: input.entrySize,
|
|
106174
|
+
positionBefore: input.positionBefore,
|
|
106175
|
+
positionHasLegacyLegs: state2.legacySymbols.has(symbol2)
|
|
106176
|
+
});
|
|
106177
|
+
if (request.shape === "legacy_per_entry") return null;
|
|
106178
|
+
return {
|
|
106179
|
+
native: { position_before: String(input.positionBefore) },
|
|
106180
|
+
children: request.shape === "entry_with_position_children" ? request.children.map((child) => ({
|
|
106181
|
+
kind: child.kind,
|
|
106182
|
+
triggerPrice: Number(child.trigger),
|
|
106183
|
+
clientOrderId: clientOrderIdForMutation(createRuntimeId().toLowerCase())
|
|
106184
|
+
})) : []
|
|
106185
|
+
};
|
|
106186
|
+
};
|
|
106187
|
+
SERVER_NATIVE_LEGACY_REFUSAL = "native_protection_legacy_position";
|
|
106188
|
+
isServerNativeLegacyRefusal = (error48) => Boolean(error48 && typeof error48 === "object") && error48.code === SERVER_NATIVE_LEGACY_REFUSAL;
|
|
106189
|
+
runtimeProtectionOwners = /* @__PURE__ */ new WeakMap();
|
|
106190
|
+
resolveRuntimeProtectionOwner = (request) => {
|
|
106191
|
+
if (request.executionMode === "server") return Promise.resolve("server");
|
|
106192
|
+
const cached2 = runtimeProtectionOwners.get(request);
|
|
106193
|
+
if (cached2) return cached2;
|
|
106194
|
+
const authority = runtimeProtectionAuthority(request);
|
|
106195
|
+
const pending3 = runtimeProtectionListing(request).then((listed) => listed.client_protection_owner);
|
|
105871
106196
|
runtimeProtectionOwners.set(request, pending3);
|
|
105872
106197
|
return pending3;
|
|
105873
106198
|
};
|
|
@@ -106595,7 +106920,7 @@ var init_runtime_execution = __esm({
|
|
|
106595
106920
|
const context = input.executionContext;
|
|
106596
106921
|
const profileId = String(input.profileId).trim();
|
|
106597
106922
|
if (input.decision !== "HOLD" && Math.max(0, Math.trunc(input.units)) > 0) return true;
|
|
106598
|
-
if (readClientProtectiveGroups(profileId, context.symbol).some((group) => group.legs.length > 0 || group.attachmentJournal != null) || hasClientProtectiveGroupReadFailure(profileId, context.symbol)) {
|
|
106923
|
+
if (readClientProtectiveGroups(profileId, context.symbol).some((group) => group.legs.length > 0 || group.attachmentJournal != null) || hasClientProtectiveGroupReadFailure(profileId, context.symbol) || readNativeRecord(profileId, context.symbol).kind !== "none") {
|
|
106599
106924
|
return true;
|
|
106600
106925
|
}
|
|
106601
106926
|
const positionSize = Number.isFinite(context.currentPositionSize) ? Number(context.currentPositionSize) : 0;
|
|
@@ -107441,6 +107766,13 @@ var init_runtime_execution = __esm({
|
|
|
107441
107766
|
}
|
|
107442
107767
|
}
|
|
107443
107768
|
const nativeProtection = nativeOpen != null || nativeAddRecord != null;
|
|
107769
|
+
let serverNative = serverOwnedProtection ? await resolveServerNativeEntry({
|
|
107770
|
+
request: input,
|
|
107771
|
+
isLong: classified.side === "buy",
|
|
107772
|
+
referencePrice: executionPrice,
|
|
107773
|
+
entrySize: sizeAsset,
|
|
107774
|
+
positionBefore: targetResolution.closeOpposingPosition ? 0 : currentPositionSize
|
|
107775
|
+
}) : null;
|
|
107444
107776
|
if (localProtection && !nativeProtection) {
|
|
107445
107777
|
entryMutationId ??= createRuntimeId().toLowerCase();
|
|
107446
107778
|
entryClientOrderId = clientOrderIdForMutation(entryMutationId);
|
|
@@ -107535,8 +107867,10 @@ var init_runtime_execution = __esm({
|
|
|
107535
107867
|
protection: {
|
|
107536
107868
|
source: "runtime_config",
|
|
107537
107869
|
requested_entry_size: sizeAsset,
|
|
107538
|
-
is_long: entrySide === "buy"
|
|
107870
|
+
is_long: entrySide === "buy",
|
|
107871
|
+
...serverNative ? { native: serverNative.native } : {}
|
|
107539
107872
|
},
|
|
107873
|
+
...serverNative && serverNative.children.length > 0 ? { positionChildren: serverNative.children } : {},
|
|
107540
107874
|
onSettled: (mutation) => {
|
|
107541
107875
|
settledServerProtectedEntry = mutation;
|
|
107542
107876
|
}
|
|
@@ -107544,7 +107878,15 @@ var init_runtime_execution = __esm({
|
|
|
107544
107878
|
});
|
|
107545
107879
|
try {
|
|
107546
107880
|
try {
|
|
107547
|
-
|
|
107881
|
+
try {
|
|
107882
|
+
marketOrderResponse = await sendEntry();
|
|
107883
|
+
} catch (nativeRefusal) {
|
|
107884
|
+
if (serverNative == null || !isServerNativeLegacyRefusal(nativeRefusal) || entryDispatchBoundaryPassed) {
|
|
107885
|
+
throw nativeRefusal;
|
|
107886
|
+
}
|
|
107887
|
+
serverNative = null;
|
|
107888
|
+
marketOrderResponse = await sendEntry();
|
|
107889
|
+
}
|
|
107548
107890
|
} catch (rejection) {
|
|
107549
107891
|
const retry = await serverOrderMetadataRetry(input, rejection, "entry", entryMutationId);
|
|
107550
107892
|
const retrySize = retry === null ? 0 : quantizeHyperliquidOrderSizeValue(intendedSizeAsset, retry.sizeDecimals, "nearest");
|
|
@@ -107609,7 +107951,7 @@ var init_runtime_execution = __esm({
|
|
|
107609
107951
|
}
|
|
107610
107952
|
const confirmedMarketFill = extractCanonicalHyperliquidFilledOrderAcknowledgement(
|
|
107611
107953
|
// An entry carrying position children is member 0 of its action.
|
|
107612
|
-
nativeOpen != null ? firstMemberAcknowledgement(marketOrderResponse) : marketOrderResponse
|
|
107954
|
+
nativeOpen != null || (serverNative?.children.length ?? 0) > 0 ? firstMemberAcknowledgement(marketOrderResponse) : marketOrderResponse
|
|
107613
107955
|
);
|
|
107614
107956
|
executionReports.push({
|
|
107615
107957
|
order_id: _extractOrderId(marketOrderResponse),
|
|
@@ -107682,6 +108024,10 @@ var init_runtime_execution = __esm({
|
|
|
107682
108024
|
if (nativeProtection) {
|
|
107683
108025
|
const symbol2 = input.executionContext.symbol;
|
|
107684
108026
|
let record5 = nativeOpen != null ? recordEntryChildren(nativeOpen.record, marketOrderResponse) : nativeAddRecord;
|
|
108027
|
+
let keepNativeJournal = false;
|
|
108028
|
+
if (nativeOpen != null && !writeNativeProtectionRecord(nativeProfileId, symbol2, record5)) {
|
|
108029
|
+
executionReports.push(nativeStorageReport(symbol2, "protective_lifecycle_persistence_failed"));
|
|
108030
|
+
}
|
|
107685
108031
|
if (confirmedMarketFill == null) {
|
|
107686
108032
|
executionReports.push({
|
|
107687
108033
|
order_id: _extractOrderId(marketOrderResponse),
|
|
@@ -107704,10 +108050,17 @@ var init_runtime_execution = __esm({
|
|
|
107704
108050
|
if (settled.record != null) record5 = settled.record;
|
|
107705
108051
|
} catch (postEntryProtectionError) {
|
|
107706
108052
|
if (isClientRuntimeLeaseOwnershipError(postEntryProtectionError)) throw postEntryProtectionError;
|
|
107707
|
-
|
|
108053
|
+
if (nativePassEnded(input, postEntryProtectionError)) {
|
|
108054
|
+
keepNativeJournal = true;
|
|
108055
|
+
const cause = postEntryProtectionError instanceof NativeOrderNotSentError ? postEntryProtectionError.cause : postEntryProtectionError;
|
|
108056
|
+
if (isClientRuntimeWindowHandoffBeforePlanDispatch(cause)) throw cause;
|
|
108057
|
+
appendPostEntryProtectionFailure(cause);
|
|
108058
|
+
} else {
|
|
108059
|
+
appendPostEntryProtectionFailure(postEntryProtectionError);
|
|
108060
|
+
}
|
|
107708
108061
|
}
|
|
107709
108062
|
}
|
|
107710
|
-
if (!writeNativeProtectionRecord(nativeProfileId, symbol2, record5)) {
|
|
108063
|
+
if (!keepNativeJournal && !writeNativeProtectionRecord(nativeProfileId, symbol2, record5)) {
|
|
107711
108064
|
executionReports.push(nativeStorageReport(symbol2, "protective_lifecycle_persistence_failed"));
|
|
107712
108065
|
}
|
|
107713
108066
|
}
|