@jinn-network/client 0.1.1 → 0.1.2-canary.d6e72dfd
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/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +123 -0
- package/README.md +210 -37
- package/deployments/deployment-claim-registry-baseSepolia.json +13 -0
- package/deployments/deployment-jinn-testnet-faucet-baseSepolia-fast.json +15 -0
- package/dist/adapters/claim-registry/abi.d.ts +127 -0
- package/dist/adapters/claim-registry/abi.js +93 -0
- package/dist/adapters/claim-registry/abi.js.map +1 -0
- package/dist/adapters/claim-registry/client.d.ts +89 -0
- package/dist/adapters/claim-registry/client.js +205 -0
- package/dist/adapters/claim-registry/client.js.map +1 -0
- package/dist/adapters/mech/adapter.d.ts +1 -0
- package/dist/adapters/mech/adapter.js +75 -41
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +2 -0
- package/dist/adapters/mech/contracts.js +57 -7
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/ipfs.d.ts +8 -0
- package/dist/adapters/mech/ipfs.js +12 -0
- package/dist/adapters/mech/ipfs.js.map +1 -1
- package/dist/adapters/mech/types.d.ts +20 -46
- package/dist/adapters/mech/types.js +16 -35
- package/dist/adapters/mech/types.js.map +1 -1
- package/dist/api/gather-status.d.ts +1 -0
- package/dist/api/gather-status.js +33 -1
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/portfolio-v0-build.d.ts +81 -0
- package/dist/api/portfolio-v0-build.js +141 -0
- package/dist/api/portfolio-v0-build.js.map +1 -0
- package/dist/api/portfolio-v0-doctor.d.ts +37 -0
- package/dist/api/portfolio-v0-doctor.js +123 -0
- package/dist/api/portfolio-v0-doctor.js.map +1 -0
- package/dist/api/rewards-build.js +1 -1
- package/dist/api/rewards-build.js.map +1 -1
- package/dist/api/status-build.d.ts +7 -0
- package/dist/api/status-build.js +1 -0
- package/dist/api/status-build.js.map +1 -1
- package/dist/bin/jinn-mcp.d.ts +0 -12
- package/dist/bin/jinn-mcp.js +5 -14
- package/dist/bin/jinn-mcp.js.map +1 -1
- package/dist/build-meta.json +1 -1
- package/dist/cli/commands/auth.js +115 -25
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/bootstrap.js +1 -0
- package/dist/cli/commands/bootstrap.js.map +1 -1
- package/dist/cli/commands/doctor.js +130 -14
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/fleet-scale.js +1 -0
- package/dist/cli/commands/fleet-scale.js.map +1 -1
- package/dist/cli/commands/fund-requirements.js +2 -0
- package/dist/cli/commands/fund-requirements.js.map +1 -1
- package/dist/cli/commands/intents.d.ts +17 -0
- package/dist/cli/commands/intents.js +489 -0
- package/dist/cli/commands/intents.js.map +1 -0
- package/dist/cli/commands/keys-backup.js +13 -11
- package/dist/cli/commands/keys-backup.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts +3 -0
- package/dist/cli/commands/mcp.js +19 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/plugin-install.js +8 -4
- package/dist/cli/commands/plugin-install.js.map +1 -1
- package/dist/cli/commands/quickstart.js +60 -4
- package/dist/cli/commands/quickstart.js.map +1 -1
- package/dist/cli/commands/rewards.js +27 -1
- package/dist/cli/commands/rewards.js.map +1 -1
- package/dist/cli/commands/submit-intent.js +108 -5
- package/dist/cli/commands/submit-intent.js.map +1 -1
- package/dist/cli/commands/version.js +1 -0
- package/dist/cli/commands/version.js.map +1 -1
- package/dist/cli/deployment-digest.js +5 -0
- package/dist/cli/deployment-digest.js.map +1 -1
- package/dist/cli/execution-context.js +1 -0
- package/dist/cli/execution-context.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/intent-registry-access.d.ts +64 -0
- package/dist/cli/intent-registry-access.js +187 -0
- package/dist/cli/intent-registry-access.js.map +1 -0
- package/dist/cli/introspection-context.js +1 -0
- package/dist/cli/introspection-context.js.map +1 -1
- package/dist/cli/password.d.ts +21 -9
- package/dist/cli/password.js +45 -24
- package/dist/cli/password.js.map +1 -1
- package/dist/config.d.ts +110 -8
- package/dist/config.js +41 -12
- package/dist/config.js.map +1 -1
- package/dist/daemon/creator.d.ts +7 -1
- package/dist/daemon/creator.js +38 -3
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +43 -0
- package/dist/daemon/daemon.js +87 -2
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/earning/bootstrap.d.ts +2 -1
- package/dist/earning/bootstrap.js +72 -4
- package/dist/earning/bootstrap.js.map +1 -1
- package/dist/earning/contracts.d.ts +10 -0
- package/dist/earning/contracts.js +24 -0
- package/dist/earning/contracts.js.map +1 -1
- package/dist/earning/jinn-rewards.d.ts +9 -0
- package/dist/earning/jinn-rewards.js +7 -0
- package/dist/earning/jinn-rewards.js.map +1 -1
- package/dist/intents/prediction-apy-v0-auto.d.ts +11 -0
- package/dist/intents/prediction-apy-v0-auto.js +46 -0
- package/dist/intents/prediction-apy-v0-auto.js.map +1 -0
- package/dist/intents/prediction-apy-v0-template.d.ts +8 -0
- package/dist/intents/prediction-apy-v0-template.js +22 -0
- package/dist/intents/prediction-apy-v0-template.js.map +1 -0
- package/dist/intents/prediction-v0-auto.d.ts +53 -0
- package/dist/intents/prediction-v0-auto.js +84 -0
- package/dist/intents/prediction-v0-auto.js.map +1 -0
- package/dist/intents/prediction-v0-template.d.ts +65 -0
- package/dist/intents/prediction-v0-template.js +125 -0
- package/dist/intents/prediction-v0-template.js.map +1 -0
- package/dist/main.js +149 -1
- package/dist/main.js.map +1 -1
- package/dist/mcp/operator-server.d.ts +1 -1
- package/dist/mcp/operator-server.js +1 -1
- package/dist/preflight/claude-auth.d.ts +12 -1
- package/dist/preflight/claude-auth.js +21 -3
- package/dist/preflight/claude-auth.js.map +1 -1
- package/dist/restorer/engine/canonical-json.d.ts +18 -0
- package/dist/restorer/engine/canonical-json.js +59 -0
- package/dist/restorer/engine/canonical-json.js.map +1 -0
- package/dist/restorer/engine/claim.d.ts +69 -0
- package/dist/restorer/engine/claim.js +104 -0
- package/dist/restorer/engine/claim.js.map +1 -0
- package/dist/restorer/engine/delivery.d.ts +52 -0
- package/dist/restorer/engine/delivery.js +63 -0
- package/dist/restorer/engine/delivery.js.map +1 -0
- package/dist/restorer/engine/engine.d.ts +203 -0
- package/dist/restorer/engine/engine.js +753 -0
- package/dist/restorer/engine/engine.js.map +1 -0
- package/dist/restorer/engine/manifest-assembly.d.ts +67 -0
- package/dist/restorer/engine/manifest-assembly.js +79 -0
- package/dist/restorer/engine/manifest-assembly.js.map +1 -0
- package/dist/restorer/engine/packaging.d.ts +87 -0
- package/dist/restorer/engine/packaging.js +350 -0
- package/dist/restorer/engine/packaging.js.map +1 -0
- package/dist/restorer/engine/persistence.d.ts +170 -0
- package/dist/restorer/engine/persistence.js +381 -0
- package/dist/restorer/engine/persistence.js.map +1 -0
- package/dist/restorer/engine/recovery.d.ts +22 -0
- package/dist/restorer/engine/recovery.js +24 -0
- package/dist/restorer/engine/recovery.js.map +1 -0
- package/dist/restorer/engine/registry.d.ts +62 -0
- package/dist/restorer/engine/registry.js +73 -0
- package/dist/restorer/engine/registry.js.map +1 -0
- package/dist/restorer/engine/signing.d.ts +30 -0
- package/dist/restorer/engine/signing.js +39 -0
- package/dist/restorer/engine/signing.js.map +1 -0
- package/dist/restorer/engine/state.d.ts +42 -0
- package/dist/restorer/engine/state.js +87 -0
- package/dist/restorer/engine/state.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js +96 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +101 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +710 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +137 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js +865 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.d.ts +74 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js +74 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +97 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +226 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +43 -0
- package/dist/restorer/impls/claude-mcp-prediction/index.js +230 -0
- package/dist/restorer/impls/claude-mcp-prediction/index.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.d.ts +38 -0
- package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js +135 -0
- package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/prompt.d.ts +8 -0
- package/dist/restorer/impls/claude-mcp-prediction/prompt.js +54 -0
- package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +36 -0
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +137 -0
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/types.d.ts +82 -0
- package/dist/restorer/impls/claude-mcp-prediction/types.js +6 -0
- package/dist/restorer/impls/claude-mcp-prediction/types.js.map +1 -0
- package/dist/restorer/impls/legacy-claude/index.d.ts +45 -0
- package/dist/restorer/impls/legacy-claude/index.js +71 -0
- package/dist/restorer/impls/legacy-claude/index.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.d.ts +49 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js +91 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +43 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/index.js +431 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/score.d.ts +21 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/score.js +32 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +32 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/types.js +8 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +39 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +98 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.d.ts +2 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js +7 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/types.d.ts +4 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/types.js +2 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +2 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +7 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +39 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +186 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/score.d.ts +9 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js +20 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/types.d.ts +7 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js +2 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +29 -0
- package/dist/restorer/impls/prediction-v0-baseline/index.js +94 -0
- package/dist/restorer/impls/prediction-v0-baseline/index.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +8 -0
- package/dist/restorer/impls/prediction-v0-baseline/strategy.js +41 -0
- package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +7 -0
- package/dist/restorer/impls/prediction-v0-baseline/types.js +2 -0
- package/dist/restorer/impls/prediction-v0-baseline/types.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
- package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js +66 -0
- package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js +23 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js +13 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +7 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +93 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js +20 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +33 -0
- package/dist/restorer/impls/prediction-v0-evaluator/index.js +208 -0
- package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/score.d.ts +8 -0
- package/dist/restorer/impls/prediction-v0-evaluator/score.js +15 -0
- package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/types.d.ts +7 -0
- package/dist/restorer/impls/prediction-v0-evaluator/types.js +2 -0
- package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +1 -0
- package/dist/restorer/types.d.ts +177 -0
- package/dist/restorer/types.js +7 -0
- package/dist/restorer/types.js.map +1 -0
- package/dist/store/store.d.ts +3 -1
- package/dist/store/store.js +3 -0
- package/dist/store/store.js.map +1 -1
- package/dist/types/desired-state.d.ts +53 -0
- package/dist/types/desired-state.js +20 -0
- package/dist/types/desired-state.js.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.js +4 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/portfolio.d.ts +1000 -0
- package/dist/types/portfolio.js +168 -0
- package/dist/types/portfolio.js.map +1 -0
- package/dist/types/prediction-apy.d.ts +919 -0
- package/dist/types/prediction-apy.js +121 -0
- package/dist/types/prediction-apy.js.map +1 -0
- package/dist/types/prediction.d.ts +925 -0
- package/dist/types/prediction.js +140 -0
- package/dist/types/prediction.js.map +1 -0
- package/dist/venues/aave-v3/addresses.d.ts +6 -0
- package/dist/venues/aave-v3/addresses.js +19 -0
- package/dist/venues/aave-v3/addresses.js.map +1 -0
- package/dist/venues/aave-v3/client.d.ts +81 -0
- package/dist/venues/aave-v3/client.js +97 -0
- package/dist/venues/aave-v3/client.js.map +1 -0
- package/dist/venues/chainlink/client.d.ts +99 -0
- package/dist/venues/chainlink/client.js +130 -0
- package/dist/venues/chainlink/client.js.map +1 -0
- package/dist/venues/chainlink/feeds.d.ts +8 -0
- package/dist/venues/chainlink/feeds.js +9 -0
- package/dist/venues/chainlink/feeds.js.map +1 -0
- package/dist/venues/hyperliquid/account-value.d.ts +30 -0
- package/dist/venues/hyperliquid/account-value.js +30 -0
- package/dist/venues/hyperliquid/account-value.js.map +1 -0
- package/dist/venues/hyperliquid/client.d.ts +63 -0
- package/dist/venues/hyperliquid/client.js +135 -0
- package/dist/venues/hyperliquid/client.js.map +1 -0
- package/dist/venues/hyperliquid/grid.d.ts +36 -0
- package/dist/venues/hyperliquid/grid.js +61 -0
- package/dist/venues/hyperliquid/grid.js.map +1 -0
- package/dist/venues/hyperliquid/types.d.ts +81 -0
- package/dist/venues/hyperliquid/types.js +8 -0
- package/dist/venues/hyperliquid/types.js.map +1 -0
- package/dist/withdraw/run-withdraw-plan.js +2 -0
- package/dist/withdraw/run-withdraw-plan.js.map +1 -1
- package/docker-compose.yml +44 -0
- package/package.json +12 -1
- package/skills/jinn-operator/SKILL.md +85 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified account-value helper.
|
|
3
|
+
*
|
|
4
|
+
* Returns a single equity figure that sums perps margin + spot USDC. This
|
|
5
|
+
* matches HL's `portfolio` endpoint `accountValueHistory` (which also
|
|
6
|
+
* reports the unified view), so restorer-claimed equity and evaluator-
|
|
7
|
+
* rederived grid points compare cleanly.
|
|
8
|
+
*
|
|
9
|
+
* Non-USDC spot tokens are NOT valued in v0 — their midprice lookup and
|
|
10
|
+
* safety semantics are out of scope for the first cut of portfolio.v0.
|
|
11
|
+
*/
|
|
12
|
+
export async function getUnifiedAccountValue(hlClient, user) {
|
|
13
|
+
const [clearinghouseState, spotClearinghouseState] = await Promise.all([
|
|
14
|
+
hlClient.clearinghouseState(user),
|
|
15
|
+
hlClient.spotClearinghouseState(user),
|
|
16
|
+
]);
|
|
17
|
+
const perpsAccountValue = clearinghouseState.marginSummary.accountValue;
|
|
18
|
+
const usdcBalance = spotClearinghouseState.balances.find((b) => b.coin === 'USDC');
|
|
19
|
+
const spotUsdc = usdcBalance ? usdcBalance.total : '0';
|
|
20
|
+
const total = parseFloat(perpsAccountValue) + parseFloat(spotUsdc);
|
|
21
|
+
const accountValue = String(total);
|
|
22
|
+
return {
|
|
23
|
+
accountValue,
|
|
24
|
+
perpsAccountValue,
|
|
25
|
+
spotUsdc,
|
|
26
|
+
clearinghouseState,
|
|
27
|
+
spotClearinghouseState,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=account-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-value.js","sourceRoot":"","sources":["../../../src/venues/hyperliquid/account-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAyBH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,QAAsB,EACtB,IAAY;IAEZ,MAAM,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACrE,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACjC,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC;KACtC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,aAAa,CAAC,YAAY,CAAC;IACxE,MAAM,WAAW,GAAG,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IAEvD,MAAM,KAAK,GAAG,UAAU,CAAC,iBAAiB,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnE,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAEnC,OAAO;QACL,YAAY;QACZ,iBAAiB;QACjB,QAAQ;QACR,kBAAkB;QAClB,sBAAsB;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only Hyperliquid public API client.
|
|
3
|
+
*
|
|
4
|
+
* All endpoints are POST /info with a JSON body. No authentication required.
|
|
5
|
+
* This client is intentionally read-only — write paths are out of scope.
|
|
6
|
+
*/
|
|
7
|
+
import type { HlAllMidsResponse, HlClearinghouseState, HlMetaResponse, HlPeriodData, HlPortfolioPeriod, HlPortfolioResponse, HlSpotClearinghouseState, HlUserFills, HlUserFillsByTimeResult } from './types.js';
|
|
8
|
+
export declare const HL_MAINNET_BASE_URL = "https://api.hyperliquid.xyz";
|
|
9
|
+
export declare const HL_TESTNET_BASE_URL = "https://api.hyperliquid-testnet.xyz";
|
|
10
|
+
export declare class HyperliquidClient {
|
|
11
|
+
readonly baseUrl: string;
|
|
12
|
+
readonly timeoutMs: number;
|
|
13
|
+
constructor(baseUrl?: string, timeoutMs?: number);
|
|
14
|
+
private post;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current clearinghouse (margin) state for a user.
|
|
17
|
+
* This reflects the LIVE state — there is no historical point-in-time lookup.
|
|
18
|
+
*/
|
|
19
|
+
clearinghouseState(user: string): Promise<HlClearinghouseState>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the current spot (non-perps) clearinghouse state for a user.
|
|
22
|
+
* Includes USDC and other spot token balances.
|
|
23
|
+
*/
|
|
24
|
+
spotClearinghouseState(user: string): Promise<HlSpotClearinghouseState>;
|
|
25
|
+
/**
|
|
26
|
+
* Returns recent fills for a user, in descending time order.
|
|
27
|
+
*/
|
|
28
|
+
userFills(user: string): Promise<HlUserFills>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns fills for a user in ascending time order, with optional pagination.
|
|
31
|
+
*
|
|
32
|
+
* The HL API silently clamps `startTime` to its retention horizon (typically
|
|
33
|
+
* ~30 days). When clamping occurs the first fill's `.time` will be greater
|
|
34
|
+
* than the requested `startTime`. This method detects that and sets
|
|
35
|
+
* `result.startTimeClamped = true`.
|
|
36
|
+
*
|
|
37
|
+
* @param user Ethereum address of the account.
|
|
38
|
+
* @param startTime Start of the window in epoch milliseconds.
|
|
39
|
+
* @param endTime Optional end of the window in epoch milliseconds.
|
|
40
|
+
* @param aggregateByTime Passed directly to the API (default false).
|
|
41
|
+
*/
|
|
42
|
+
userFillsByTime(user: string, startTime: number, endTime?: number, aggregateByTime?: boolean): Promise<HlUserFillsByTimeResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Returns historical account-value snapshots (~140-minute grid) for a user.
|
|
45
|
+
*
|
|
46
|
+
* The response is an array of [periodName, periodData] tuples where period
|
|
47
|
+
* is one of "day", "week", "month", "allTime".
|
|
48
|
+
*/
|
|
49
|
+
portfolio(user: string): Promise<HlPortfolioResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Fetches the portfolio response and extracts a specific period bucket.
|
|
52
|
+
* Returns null if the period is not present in the response.
|
|
53
|
+
*/
|
|
54
|
+
portfolioPeriod(user: string, period: HlPortfolioPeriod): Promise<HlPeriodData | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the universe of perpetual markets (metadata).
|
|
57
|
+
*/
|
|
58
|
+
meta(): Promise<HlMetaResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns current mid prices for all assets.
|
|
61
|
+
*/
|
|
62
|
+
allMids(): Promise<HlAllMidsResponse>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only Hyperliquid public API client.
|
|
3
|
+
*
|
|
4
|
+
* All endpoints are POST /info with a JSON body. No authentication required.
|
|
5
|
+
* This client is intentionally read-only — write paths are out of scope.
|
|
6
|
+
*/
|
|
7
|
+
export const HL_MAINNET_BASE_URL = 'https://api.hyperliquid.xyz';
|
|
8
|
+
export const HL_TESTNET_BASE_URL = 'https://api.hyperliquid-testnet.xyz';
|
|
9
|
+
export class HyperliquidClient {
|
|
10
|
+
baseUrl;
|
|
11
|
+
timeoutMs;
|
|
12
|
+
constructor(baseUrl = HL_MAINNET_BASE_URL, timeoutMs = 15_000) {
|
|
13
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
14
|
+
this.timeoutMs = timeoutMs;
|
|
15
|
+
}
|
|
16
|
+
// -------------------------------------------------------------------------
|
|
17
|
+
// Private helpers
|
|
18
|
+
// -------------------------------------------------------------------------
|
|
19
|
+
async post(body) {
|
|
20
|
+
const url = `${this.baseUrl}/info`;
|
|
21
|
+
const ac = new AbortController();
|
|
22
|
+
const t = setTimeout(() => ac.abort(), this.timeoutMs);
|
|
23
|
+
try {
|
|
24
|
+
const res = await fetch(url, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: { 'Content-Type': 'application/json' },
|
|
27
|
+
body: JSON.stringify(body),
|
|
28
|
+
signal: ac.signal,
|
|
29
|
+
});
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
const excerpt = await res.text().then((t) => t.slice(0, 200));
|
|
32
|
+
throw new Error(`Hyperliquid API error: HTTP ${res.status} ${res.statusText} — ${excerpt}`);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return (await res.json());
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
throw new Error(`Hyperliquid API error: could not parse JSON response from ${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (err instanceof Error && err.name === 'AbortError') {
|
|
43
|
+
throw new Error(`Hyperliquid API timeout after ${this.timeoutMs}ms calling ${url}`);
|
|
44
|
+
}
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
clearTimeout(t);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// -------------------------------------------------------------------------
|
|
52
|
+
// Public endpoints
|
|
53
|
+
// -------------------------------------------------------------------------
|
|
54
|
+
/**
|
|
55
|
+
* Returns the current clearinghouse (margin) state for a user.
|
|
56
|
+
* This reflects the LIVE state — there is no historical point-in-time lookup.
|
|
57
|
+
*/
|
|
58
|
+
async clearinghouseState(user) {
|
|
59
|
+
return this.post({ type: 'clearinghouseState', user });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the current spot (non-perps) clearinghouse state for a user.
|
|
63
|
+
* Includes USDC and other spot token balances.
|
|
64
|
+
*/
|
|
65
|
+
async spotClearinghouseState(user) {
|
|
66
|
+
return this.post({ type: 'spotClearinghouseState', user });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns recent fills for a user, in descending time order.
|
|
70
|
+
*/
|
|
71
|
+
async userFills(user) {
|
|
72
|
+
return this.post({ type: 'userFills', user });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns fills for a user in ascending time order, with optional pagination.
|
|
76
|
+
*
|
|
77
|
+
* The HL API silently clamps `startTime` to its retention horizon (typically
|
|
78
|
+
* ~30 days). When clamping occurs the first fill's `.time` will be greater
|
|
79
|
+
* than the requested `startTime`. This method detects that and sets
|
|
80
|
+
* `result.startTimeClamped = true`.
|
|
81
|
+
*
|
|
82
|
+
* @param user Ethereum address of the account.
|
|
83
|
+
* @param startTime Start of the window in epoch milliseconds.
|
|
84
|
+
* @param endTime Optional end of the window in epoch milliseconds.
|
|
85
|
+
* @param aggregateByTime Passed directly to the API (default false).
|
|
86
|
+
*/
|
|
87
|
+
async userFillsByTime(user, startTime, endTime, aggregateByTime = false) {
|
|
88
|
+
const body = {
|
|
89
|
+
type: 'userFillsByTime',
|
|
90
|
+
user,
|
|
91
|
+
startTime,
|
|
92
|
+
aggregateByTime,
|
|
93
|
+
};
|
|
94
|
+
if (endTime !== undefined) {
|
|
95
|
+
body['endTime'] = endTime;
|
|
96
|
+
}
|
|
97
|
+
const fills = await this.post(body);
|
|
98
|
+
// Clamp detection: if the first fill's time is strictly greater than the
|
|
99
|
+
// requested startTime, HL quietly moved the window forward to its retention
|
|
100
|
+
// horizon. An empty result is NOT treated as clamped — we can't tell.
|
|
101
|
+
const startTimeClamped = fills.length > 0 && fills[0] !== undefined && fills[0].time > startTime;
|
|
102
|
+
return { fills, startTimeClamped };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns historical account-value snapshots (~140-minute grid) for a user.
|
|
106
|
+
*
|
|
107
|
+
* The response is an array of [periodName, periodData] tuples where period
|
|
108
|
+
* is one of "day", "week", "month", "allTime".
|
|
109
|
+
*/
|
|
110
|
+
async portfolio(user) {
|
|
111
|
+
return this.post({ type: 'portfolio', user });
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Fetches the portfolio response and extracts a specific period bucket.
|
|
115
|
+
* Returns null if the period is not present in the response.
|
|
116
|
+
*/
|
|
117
|
+
async portfolioPeriod(user, period) {
|
|
118
|
+
const response = await this.portfolio(user);
|
|
119
|
+
const entry = response.find(([name]) => name === period);
|
|
120
|
+
return entry ? entry[1] : null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Returns the universe of perpetual markets (metadata).
|
|
124
|
+
*/
|
|
125
|
+
async meta() {
|
|
126
|
+
return this.post({ type: 'meta' });
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Returns current mid prices for all assets.
|
|
130
|
+
*/
|
|
131
|
+
async allMids() {
|
|
132
|
+
return this.post({ type: 'allMids' });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/venues/hyperliquid/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,MAAM,CAAC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,qCAAqC,CAAC;AAEzE,MAAM,OAAO,iBAAiB;IACnB,OAAO,CAAS;IAChB,SAAS,CAAS;IAE3B,YAAY,UAAkB,mBAAmB,EAAE,YAAoB,MAAM;QAC3E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAEpE,KAAK,CAAC,IAAI,CAAI,IAA6B;Q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AK,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC;QAE1E,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAsB,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe,CAAC,IAAY,EAAE,MAAyB;QAC3D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,IAAI,CAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,IAAI,CAAoB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portfolio grid bracketing helper.
|
|
3
|
+
*
|
|
4
|
+
* Hyperliquid's `portfolio` endpoint returns `accountValueHistory` on a
|
|
5
|
+
* rolling ~140-minute grid. Given a target timestamp, this module finds the
|
|
6
|
+
* two grid points immediately before and after it — the "bracket" — which
|
|
7
|
+
* the evaluator uses to verify pre-snapshot account value.
|
|
8
|
+
*
|
|
9
|
+
* This module is pure (no I/O). Pass in the grid and a target; get back a
|
|
10
|
+
* bracket or null if bracketing is not possible.
|
|
11
|
+
*/
|
|
12
|
+
import type { HlGridPoint } from './types.js';
|
|
13
|
+
export interface GridBracket {
|
|
14
|
+
/** The last grid point at or before targetTs. */
|
|
15
|
+
before: HlGridPoint;
|
|
16
|
+
/** The first grid point strictly after targetTs. */
|
|
17
|
+
after: HlGridPoint;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Given an `accountValueHistory` array and a target timestamp, returns the two
|
|
21
|
+
* grid points that bracket the target.
|
|
22
|
+
*
|
|
23
|
+
* - If `targetTs` is exactly on a grid point, that point is returned as
|
|
24
|
+
* `before` and the next point is `after`.
|
|
25
|
+
* - Returns `null` when:
|
|
26
|
+
* - The grid is empty.
|
|
27
|
+
* - `targetTs` is before all grid points (no `before` candidate).
|
|
28
|
+
* - `targetTs` is at or after the last grid point (no `after` candidate).
|
|
29
|
+
*
|
|
30
|
+
* The input array does not need to be sorted — this function sorts by timestamp
|
|
31
|
+
* before searching.
|
|
32
|
+
*
|
|
33
|
+
* @param history Array of [timestamp_ms, value_str] grid points.
|
|
34
|
+
* @param targetTs Target timestamp in epoch milliseconds.
|
|
35
|
+
*/
|
|
36
|
+
export declare function bracketGridPoints(history: HlGridPoint[], targetTs: number): GridBracket | null;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portfolio grid bracketing helper.
|
|
3
|
+
*
|
|
4
|
+
* Hyperliquid's `portfolio` endpoint returns `accountValueHistory` on a
|
|
5
|
+
* rolling ~140-minute grid. Given a target timestamp, this module finds the
|
|
6
|
+
* two grid points immediately before and after it — the "bracket" — which
|
|
7
|
+
* the evaluator uses to verify pre-snapshot account value.
|
|
8
|
+
*
|
|
9
|
+
* This module is pure (no I/O). Pass in the grid and a target; get back a
|
|
10
|
+
* bracket or null if bracketing is not possible.
|
|
11
|
+
*/
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Core helper
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Given an `accountValueHistory` array and a target timestamp, returns the two
|
|
17
|
+
* grid points that bracket the target.
|
|
18
|
+
*
|
|
19
|
+
* - If `targetTs` is exactly on a grid point, that point is returned as
|
|
20
|
+
* `before` and the next point is `after`.
|
|
21
|
+
* - Returns `null` when:
|
|
22
|
+
* - The grid is empty.
|
|
23
|
+
* - `targetTs` is before all grid points (no `before` candidate).
|
|
24
|
+
* - `targetTs` is at or after the last grid point (no `after` candidate).
|
|
25
|
+
*
|
|
26
|
+
* The input array does not need to be sorted — this function sorts by timestamp
|
|
27
|
+
* before searching.
|
|
28
|
+
*
|
|
29
|
+
* @param history Array of [timestamp_ms, value_str] grid points.
|
|
30
|
+
* @param targetTs Target timestamp in epoch milliseconds.
|
|
31
|
+
*/
|
|
32
|
+
export function bracketGridPoints(history, targetTs) {
|
|
33
|
+
if (history.length === 0)
|
|
34
|
+
return null;
|
|
35
|
+
// Sort ascending by timestamp.
|
|
36
|
+
const sorted = [...history].sort((a, b) => a[0] - b[0]);
|
|
37
|
+
// Find the last point with timestamp <= targetTs.
|
|
38
|
+
let beforeIdx = -1;
|
|
39
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
40
|
+
if (sorted[i][0] <= targetTs) {
|
|
41
|
+
beforeIdx = i;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (beforeIdx === -1) {
|
|
48
|
+
// Target is before all grid points.
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const afterIdx = beforeIdx + 1;
|
|
52
|
+
if (afterIdx >= sorted.length) {
|
|
53
|
+
// Target is at or after the last grid point — no after candidate.
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
before: sorted[beforeIdx],
|
|
58
|
+
after: sorted[afterIdx],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingUR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
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hyperliquid public REST API response shapes.
|
|
3
|
+
*
|
|
4
|
+
* Only fields we actively use are typed precisely; complex/variable sub-objects
|
|
5
|
+
* are left as `unknown` to avoid over-modelling a rapidly-changing API.
|
|
6
|
+
*/
|
|
7
|
+
/** A fill record returned by userFills / userFillsByTime. */
|
|
8
|
+
export interface HlFill {
|
|
9
|
+
coin: string;
|
|
10
|
+
px: string;
|
|
11
|
+
sz: string;
|
|
12
|
+
side: 'A' | 'B';
|
|
13
|
+
time: number;
|
|
14
|
+
startPosition: string;
|
|
15
|
+
dir: string;
|
|
16
|
+
closedPnl: string;
|
|
17
|
+
hash: string;
|
|
18
|
+
oid: number;
|
|
19
|
+
crossed: boolean;
|
|
20
|
+
fee: string;
|
|
21
|
+
tid: number;
|
|
22
|
+
feeToken: string;
|
|
23
|
+
twapId: number | null;
|
|
24
|
+
}
|
|
25
|
+
export interface HlMarginSummary {
|
|
26
|
+
accountValue: string;
|
|
27
|
+
totalNtlPos: string;
|
|
28
|
+
totalRawUsd: string;
|
|
29
|
+
totalMarginUsed: string;
|
|
30
|
+
}
|
|
31
|
+
export interface HlClearinghouseState {
|
|
32
|
+
marginSummary: HlMarginSummary;
|
|
33
|
+
crossMarginSummary: HlMarginSummary;
|
|
34
|
+
crossMaintenanceMarginUsed: string;
|
|
35
|
+
withdrawable: string;
|
|
36
|
+
assetPositions: unknown[];
|
|
37
|
+
time: number;
|
|
38
|
+
}
|
|
39
|
+
export interface HlSpotBalance {
|
|
40
|
+
coin: string;
|
|
41
|
+
token: number;
|
|
42
|
+
total: string;
|
|
43
|
+
hold: string;
|
|
44
|
+
entryNtl: string;
|
|
45
|
+
}
|
|
46
|
+
export interface HlSpotClearinghouseState {
|
|
47
|
+
balances: HlSpotBalance[];
|
|
48
|
+
}
|
|
49
|
+
export type HlUserFills = HlFill[];
|
|
50
|
+
export interface HlUserFillsByTimeResult {
|
|
51
|
+
fills: HlFill[];
|
|
52
|
+
/** True when the API silently clamped startTime to its retention horizon. */
|
|
53
|
+
startTimeClamped: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* [timestamp_ms, value_str] tuple as returned in accountValueHistory.
|
|
57
|
+
*/
|
|
58
|
+
export type HlGridPoint = [number, string];
|
|
59
|
+
export interface HlPeriodData {
|
|
60
|
+
accountValueHistory: HlGridPoint[];
|
|
61
|
+
pnlHistory: HlGridPoint[];
|
|
62
|
+
vlm: string;
|
|
63
|
+
}
|
|
64
|
+
export type HlPortfolioPeriod = 'day' | 'week' | 'month' | 'allTime' | 'perpDay' | 'perpWeek' | 'perpMonth' | 'perpAllTime';
|
|
65
|
+
/**
|
|
66
|
+
* portfolio response is an array of [periodName, periodData] tuples.
|
|
67
|
+
* e.g. [["day", {...}], ["week", {...}], ...]
|
|
68
|
+
*/
|
|
69
|
+
export type HlPortfolioResponse = [string, HlPeriodData][];
|
|
70
|
+
export interface HlPerpMeta {
|
|
71
|
+
name: string;
|
|
72
|
+
szDecimals: number;
|
|
73
|
+
maxLeverage: number;
|
|
74
|
+
marginTableId: number;
|
|
75
|
+
isDelisted?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface HlMetaResponse {
|
|
78
|
+
universe: HlPerpMeta[];
|
|
79
|
+
}
|
|
80
|
+
/** Map from asset name to mid-price string. */
|
|
81
|
+
export type HlAllMidsResponse = Record<string, string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hyperliquid public REST API response shapes.
|
|
3
|
+
*
|
|
4
|
+
* Only fields we actively use are typed precisely; complex/variable sub-objects
|
|
5
|
+
* are left as `unknown` to avoid over-modelling a rapidly-changing API.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/venues/hyperliquid/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -41,6 +41,7 @@ export function resolveWithdrawTokenAddress(chain, config) {
|
|
|
41
41
|
testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
|
|
42
42
|
testnetMechDeploymentPath: config.testnetMechDeploymentPath,
|
|
43
43
|
testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
|
|
44
|
+
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
44
45
|
}).olasToken);
|
|
45
46
|
}
|
|
46
47
|
export async function estimateNativeTransferCostWei(publicClient) {
|
|
@@ -192,6 +193,7 @@ export async function runWithdrawPlan(options) {
|
|
|
192
193
|
testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
|
|
193
194
|
testnetMechDeploymentPath: config.testnetMechDeploymentPath,
|
|
194
195
|
testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
|
|
196
|
+
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
195
197
|
});
|
|
196
198
|
if (chainId !== chainConfig.chainId) {
|
|
197
199
|
throw new Error(`RPC chainId ${chainId} does not match expected ${chainConfig.chainId} for ${chain}.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-withdraw-plan.js","sourceRoot":"","sources":["../../src/withdraw/run-withdraw-plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GAIT,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAA2B,MAAM,4BAA4B,CAAC;AACrH,OAAO,EACL,4BAA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AK;YACd,YAAY;YACZ,QAAQ;YACR,KAAK;YACL,EAAE;YACF,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,GAAG;YACH,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,IAAI,8BAA8B,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3C,MAAM,eAAe,CAAC;YACpB,YAAY;YACZ,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,KAAK;YACd,aAAa;YACb,YAAY;YACZ,aAAa;YACb,YAAY;YACZ,EAAE;YACF,MAAM;YACN,GAAG;SACJ,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
# Jinn Client - Docker Operator Environment
|
|
4
|
+
#
|
|
5
|
+
# QUICK START:
|
|
6
|
+
# 1. Create a .env file in this directory with your password:
|
|
7
|
+
# echo "JINN_PASSWORD=your-secure-password" > .env
|
|
8
|
+
#
|
|
9
|
+
# 2. (REQUIRED ONCE) Authenticate Claude for Docker:
|
|
10
|
+
# On your host machine (where you have a browser), run:
|
|
11
|
+
# claude setup-token
|
|
12
|
+
# This opens OAuth in the browser and gives you a long-lived sk-* token.
|
|
13
|
+
# Add it to your .env file:
|
|
14
|
+
# echo "CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-..." >> .env
|
|
15
|
+
#
|
|
16
|
+
# 3. Start the daemon in the background:
|
|
17
|
+
# docker compose up -d
|
|
18
|
+
|
|
19
|
+
services:
|
|
20
|
+
jinn-daemon:
|
|
21
|
+
image: ghcr.io/jinn-network/client:latest
|
|
22
|
+
container_name: jinn-daemon
|
|
23
|
+
restart: unless-stopped
|
|
24
|
+
env_file:
|
|
25
|
+
- .env
|
|
26
|
+
# Optional explicitly defined defaults if .env is missing them
|
|
27
|
+
environment:
|
|
28
|
+
- JINN_NETWORK=${JINN_NETWORK:-testnet}
|
|
29
|
+
- JINN_POLL_INTERVAL_MS=${JINN_POLL_INTERVAL_MS:-5000}
|
|
30
|
+
- CLAUDE_CODE_OAUTH_TOKEN=${CLAUDE_CODE_OAUTH_TOKEN:-}
|
|
31
|
+
ports:
|
|
32
|
+
- "7331:7331"
|
|
33
|
+
volumes:
|
|
34
|
+
# Persistent daemon state: database, keystore, and earning progress
|
|
35
|
+
- jinn-data:/data
|
|
36
|
+
# Persistent authentication state: stores Claude's OAuth token
|
|
37
|
+
- jinn-claude-state:/root/.claude
|
|
38
|
+
command: ["run"]
|
|
39
|
+
|
|
40
|
+
volumes:
|
|
41
|
+
jinn-data:
|
|
42
|
+
name: jinn-data-volume
|
|
43
|
+
jinn-claude-state:
|
|
44
|
+
name: jinn-claude-auth-volume
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jinn-network/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-canary.d6e72dfd",
|
|
4
4
|
"description": "Jinn protocol client — headless daemon for the restoration training loop",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "yarn@4.13.0",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"node": ">=20"
|
|
15
15
|
},
|
|
16
16
|
"bin": {
|
|
17
|
+
"client": "./dist/bin/jinn.js",
|
|
17
18
|
"jinn": "./dist/bin/jinn.js",
|
|
18
19
|
"jinn-mcp": "./dist/bin/jinn-mcp.js"
|
|
19
20
|
},
|
|
@@ -23,6 +24,9 @@
|
|
|
23
24
|
"dist/",
|
|
24
25
|
"deployments/",
|
|
25
26
|
"skills/",
|
|
27
|
+
"docker-compose.yml",
|
|
28
|
+
"CONTRIBUTING.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
26
30
|
"README.md",
|
|
27
31
|
"LICENSE"
|
|
28
32
|
],
|
|
@@ -31,19 +35,25 @@
|
|
|
31
35
|
},
|
|
32
36
|
"scripts": {
|
|
33
37
|
"jinn": "tsx src/bin/jinn.ts",
|
|
38
|
+
"dev": "yarn build && node dist/bin/jinn.js",
|
|
34
39
|
"build": "tsc && chmod +x dist/bin/jinn.js dist/bin/jinn-mcp.js && mkdir -p dist/dashboard && cp src/dashboard/index.html dist/dashboard/index.html && node scripts/write-dist-build-meta.mjs",
|
|
35
40
|
"typecheck": "tsc --noEmit",
|
|
36
41
|
"test": "vitest run",
|
|
37
42
|
"test:watch": "vitest",
|
|
43
|
+
"test:claude-prediction": "yarn build && JINN_TEST_CLAUDE_PREDICTION=1 vitest run test/restorer/impls/claude-mcp-prediction/isolation.test.ts",
|
|
38
44
|
"prepublishOnly": "yarn build && yarn test",
|
|
39
45
|
"pack:smoke": "yarn pack -o jinn-client.tgz && node scripts/smoke-test-pack.mjs",
|
|
40
46
|
"release:operator-gate": "yarn staking && yarn e2e",
|
|
41
47
|
"setup:testnet-acceptance-operator": "node scripts/setup-testnet-acceptance-operator-docker.mjs",
|
|
48
|
+
"setup:testnet-acceptance-operator:docker": "node scripts/setup-testnet-acceptance-operator-docker.mjs",
|
|
42
49
|
"setup:testnet-acceptance-operator:host": "node scripts/setup-testnet-acceptance-operator.mjs",
|
|
43
50
|
"release:testnet-acceptance": "node scripts/testnet-acceptance-docker.mjs",
|
|
51
|
+
"release:testnet-acceptance:docker": "node scripts/testnet-acceptance-docker.mjs",
|
|
44
52
|
"release:testnet-acceptance:host": "node scripts/testnet-acceptance.mjs",
|
|
45
53
|
"status": "tsx scripts/status.ts",
|
|
46
54
|
"e2e": "tsx scripts/e2e-validate.ts",
|
|
55
|
+
"e2e-portfolio-v0": "tsx scripts/e2e-portfolio-v0.ts",
|
|
56
|
+
"e2e:prediction": "cd ../contracts && yarn compile && cd ../client && tsx scripts/e2e-prediction-v0.ts",
|
|
47
57
|
"staking": "tsx scripts/staking-validate.ts",
|
|
48
58
|
"stolas": "tsx scripts/stolas-validate.ts",
|
|
49
59
|
"withdraw": "tsx scripts/withdraw.ts"
|
|
@@ -53,6 +63,7 @@
|
|
|
53
63
|
"@hono/node-server": "^1.19.12",
|
|
54
64
|
"@jinn-network/mech-client-ts": "^0.0.6",
|
|
55
65
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
66
|
+
"@msgpack/msgpack": "^3.0.0",
|
|
56
67
|
"@safe-global/protocol-kit": "^6.1.2",
|
|
57
68
|
"@safe-global/types-kit": "^3.0.0",
|
|
58
69
|
"@scure/bip32": "^1.7.0",
|