@jinn-network/client 0.1.1 → 0.1.2-canary.66834251
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 +213 -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 +3 -0
- package/dist/adapters/mech/adapter.js +177 -51
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +14 -0
- package/dist/adapters/mech/contracts.js +111 -7
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/ipfs.d.ts +36 -4
- package/dist/adapters/mech/ipfs.js +119 -13
- package/dist/adapters/mech/ipfs.js.map +1 -1
- package/dist/adapters/mech/types.d.ts +22 -46
- package/dist/adapters/mech/types.js +16 -35
- package/dist/adapters/mech/types.js.map +1 -1
- package/dist/api/balance-build.js +3 -3
- package/dist/api/balance-build.js.map +1 -1
- package/dist/api/fleet-build.js +35 -40
- package/dist/api/fleet-build.js.map +1 -1
- package/dist/api/gather-status.d.ts +1 -0
- package/dist/api/gather-status.js +185 -4
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/history-build.d.ts +5 -1
- package/dist/api/history-build.js +51 -26
- package/dist/api/history-build.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 +30 -14
- package/dist/api/rewards-build.js.map +1 -1
- package/dist/api/status-build.d.ts +37 -6
- package/dist/api/status-build.js +1 -0
- package/dist/api/status-build.js.map +1 -1
- package/dist/api/status-rollup-build.d.ts +2 -0
- package/dist/api/status-rollup-build.js +27 -0
- package/dist/api/status-rollup-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/balance.js +8 -1
- package/dist/cli/commands/balance.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/fleet.js +10 -1
- package/dist/cli/commands/fleet.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/history.js +25 -6
- package/dist/cli/commands/history.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/logs.js +35 -11
- package/dist/cli/commands/logs.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/status.js +11 -1
- package/dist/cli/commands/status.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/balance-topup-loop.js +32 -4
- package/dist/daemon/balance-topup-loop.js.map +1 -1
- package/dist/daemon/creator.d.ts +7 -1
- package/dist/daemon/creator.js +51 -3
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +43 -0
- package/dist/daemon/daemon.js +110 -3
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/delivery-watcher.d.ts +3 -1
- package/dist/daemon/delivery-watcher.js +19 -1
- package/dist/daemon/delivery-watcher.js.map +1 -1
- package/dist/daemon/restorer.js +27 -0
- package/dist/daemon/restorer.js.map +1 -1
- package/dist/daemon/reward-claim-loop.js +38 -1
- package/dist/daemon/reward-claim-loop.js.map +1 -1
- package/dist/dashboard/index.html +71 -496
- 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/earning/stolas-claim.d.ts +6 -0
- package/dist/earning/stolas-claim.js +7 -0
- package/dist/earning/stolas-claim.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 +154 -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/observability/emit-event.d.ts +12 -0
- package/dist/observability/emit-event.js +27 -0
- package/dist/observability/emit-event.js.map +1 -0
- 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 +754 -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/evaluation-context.d.ts +16 -0
- package/dist/restorer/impls/evaluation-context.js +18 -0
- package/dist/restorer/impls/evaluation-context.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 +101 -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 +6 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +11 -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 +40 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +196 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +7 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js +29 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.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 +13 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +111 -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 +222 -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 +184 -0
- package/dist/restorer/types.js +7 -0
- package/dist/restorer/types.js.map +1 -0
- package/dist/store/store.d.ts +64 -1
- package/dist/store/store.js +226 -4
- 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 +930 -0
- package/dist/types/prediction-apy.js +133 -0
- package/dist/types/prediction-apy.js.map +1 -0
- package/dist/types/prediction.d.ts +926 -0
- package/dist/types/prediction.js +141 -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 +85 -0
- package/dist/venues/aave-v3/client.js +106 -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 +13 -1
- package/skills/jinn-operator/SKILL.md +85 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { resolvePredictionApyV0Template } from './prediction-apy-v0-template.js';
|
|
2
|
+
import { AAVE_V3_USDC } from '../venues/aave-v3/addresses.js';
|
|
3
|
+
export function makePredictionApyV0Generator(config = {}) {
|
|
4
|
+
const venue = config.venue ?? 'aave-v3-base-sepolia';
|
|
5
|
+
const addrs = AAVE_V3_USDC[venue];
|
|
6
|
+
const windowDurationMs = config.windowDurationMs ?? 600_000;
|
|
7
|
+
const resolveGapMs = config.resolveGapMs ?? 300_000;
|
|
8
|
+
const twaWindowSeconds = config.twaWindowSeconds ?? 3_600;
|
|
9
|
+
const sampleCount = config.sampleCount ?? 12;
|
|
10
|
+
const toleranceBps = config.toleranceBps ?? 50;
|
|
11
|
+
return async () => {
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
const startTs = Math.floor(now / windowDurationMs) * windowDurationMs;
|
|
14
|
+
const endTs = startTs + windowDurationMs;
|
|
15
|
+
const resolveTs = endTs + resolveGapMs;
|
|
16
|
+
try {
|
|
17
|
+
const intent = await resolvePredictionApyV0Template({
|
|
18
|
+
id: `pred-apy-v0-auto-${startTs}`,
|
|
19
|
+
description: `Auto-generated prediction.apy.v0 intent for ${addrs.symbol} on ${venue}`,
|
|
20
|
+
window: { startTs, endTs },
|
|
21
|
+
spec: {
|
|
22
|
+
kind: 'prediction.apy.v0',
|
|
23
|
+
oracle: {
|
|
24
|
+
venue,
|
|
25
|
+
pool: addrs.pool,
|
|
26
|
+
reserve: addrs.reserve,
|
|
27
|
+
reserveSymbol: addrs.symbol,
|
|
28
|
+
},
|
|
29
|
+
metric: {
|
|
30
|
+
type: 'supply-apy-twa-bps',
|
|
31
|
+
twaWindowSeconds,
|
|
32
|
+
sampleCount,
|
|
33
|
+
toleranceBps,
|
|
34
|
+
},
|
|
35
|
+
question: { resolveTs },
|
|
36
|
+
},
|
|
37
|
+
eligibility: { maxSubmissionDelayMs: windowDurationMs },
|
|
38
|
+
});
|
|
39
|
+
return intent;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=prediction-apy-v0-auto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction-apy-v0-auto.js","sourceRoot":"","sources":["../../src/intents/prediction-apy-v0-auto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAa9D,MAAM,UAAU,4BAA4B,CAAC,SAAoC,EAAE;IACjF,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,sBAAsB,CAAC;IACrD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC;IAC5D,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,OAAO,CAAC;IACpD,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,KAAK,CAAC;IAC1D,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;IAE/C,OAAO,KAAK,IAAkC,EAAE;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;QACtE,MAAM,KAAK,GAAG,OAAO,GAAG,gBAAgB,CAAC;QACzC,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;QACvC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,8BAA8B,CAAC;gBAClD,EAAE,EAAE,oBAAoB,OAAO,EAAE;gBACjC,WAAW,EAAE,+CAA+C,KAAK,CAAC,MAAM,OAAO,KAAK,EAAE;gBACtF,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;gBAC1B,IAAI,EAAE;oBACJ,IAAI,EAAE,mBAAmB;oBACzB,MAAM,EAAE;wBACN,KAAK;wBACL,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;wBACtB,aAAa,EAAE,KAAK,CAAC,MAAM;qBAC5B;oBACD,MAAM,EAAE;wBACN,IAAI,EAAE,oBAAoB;wBAC1B,gBAAgB;wBAChB,WAAW;wBACX,YAAY;qBACb;oBACD,QAAQ,EAAE,EAAE,SAAS,EAAE;iBACxB;gBACD,WAAW,EAAE,EAAE,oBAAoB,EAAE,gBAAgB,EAAE;aACxD,CAAC,CAAC;YACH,OAAO,MAAiC,CAAC;QAC3C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PredictionApyV0Intent } from '../types/prediction-apy.js';
|
|
2
|
+
export interface PredictionApyTemplateDeps {
|
|
3
|
+
windowDurationMs?: number;
|
|
4
|
+
resolveGapMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const DEFAULT_WINDOW_DURATION_MS = 600000;
|
|
7
|
+
export declare const DEFAULT_RESOLVE_GAP_MS = 300000;
|
|
8
|
+
export declare function resolvePredictionApyV0Template(template: unknown, deps?: PredictionApyTemplateDeps): Promise<PredictionApyV0Intent>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PredictionApyV0IntentSchema, } from '../types/prediction-apy.js';
|
|
2
|
+
export const DEFAULT_WINDOW_DURATION_MS = 600_000;
|
|
3
|
+
export const DEFAULT_RESOLVE_GAP_MS = 300_000;
|
|
4
|
+
export async function resolvePredictionApyV0Template(template, deps = {}) {
|
|
5
|
+
if (typeof template !== 'object' || template === null) {
|
|
6
|
+
throw new Error('resolvePredictionApyV0Template: template must be an object');
|
|
7
|
+
}
|
|
8
|
+
const stub = JSON.parse(JSON.stringify(template));
|
|
9
|
+
const windowMs = deps.windowDurationMs ?? DEFAULT_WINDOW_DURATION_MS;
|
|
10
|
+
const resolveMs = deps.resolveGapMs ?? DEFAULT_RESOLVE_GAP_MS;
|
|
11
|
+
const win = stub['window'];
|
|
12
|
+
if (win && win.startTs === 0) {
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
win.startTs = now;
|
|
15
|
+
win.endTs = now + windowMs;
|
|
16
|
+
const spec = stub['spec'];
|
|
17
|
+
if (spec?.question)
|
|
18
|
+
spec.question.resolveTs = now + windowMs + resolveMs;
|
|
19
|
+
}
|
|
20
|
+
return PredictionApyV0IntentSchema.parse(stub);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=prediction-apy-v0-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction-apy-v0-template.js","sourceRoot":"","sources":["../../src/intents/prediction-apy-v0-template.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,GAE5B,MAAM,4BAA4B,CAAC;AAOpC,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,QAAiB,EACjB,OAAkC,EAAE;IAEpC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAA4B,CAAC;IAC7E,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;IACrE,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,IAAI,sBAAsB,CAAC;IAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAqD,CAAC;IAC/E,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC;QAClB,GAAG,CAAC,KAAK,GAAG,GAAG,GAAG,QAAQ,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAsD,CAAC;QAC/E,IAAI,IAAI,EAAE,QAAQ;YAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,GAAG,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3E,CAAC;IACD,OAAO,2BAA2B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generator for prediction.v0 intents.
|
|
3
|
+
*
|
|
4
|
+
* Produces a fresh DesiredState per hour bucket: reads current Chainlink
|
|
5
|
+
* price, builds a template with the configured threshold sentinel
|
|
6
|
+
* (default "current+0.5%" — coin-flip-ish, slightly biased NO), and resolves
|
|
7
|
+
* it via the shared template helper. Stable ID per hour prevents duplicate
|
|
8
|
+
* posts within a window; the CreatorLoop's SQLite cache guards against
|
|
9
|
+
* restart-replay.
|
|
10
|
+
*
|
|
11
|
+
* Wired in main.ts for testnet-only (jinn-mono-9ew). Operators can opt out
|
|
12
|
+
* with JINN_DISABLE_AUTO_INTENTS=1.
|
|
13
|
+
*/
|
|
14
|
+
import { type PublicClient } from 'viem';
|
|
15
|
+
import type { DesiredState } from '../types/desired-state.js';
|
|
16
|
+
export interface PredictionV0AutoConfig {
|
|
17
|
+
/** Chainlink AggregatorV3 proxy address. Defaults to Base Sepolia ETH/USD. */
|
|
18
|
+
feed: `0x${string}`;
|
|
19
|
+
/** Human-readable feed description embedded in the generated intent. */
|
|
20
|
+
feedDescription: string;
|
|
21
|
+
/** Which chain the feed lives on. */
|
|
22
|
+
venue: 'chainlink-base' | 'chainlink-base-sepolia';
|
|
23
|
+
/**
|
|
24
|
+
* Threshold sentinel to resolve each cycle. Defaults to "current+0.5%" —
|
|
25
|
+
* biases slightly NO, Brier scores land meaningfully around 0.75. Use
|
|
26
|
+
* "current" for a strict coin-flip direction question.
|
|
27
|
+
*/
|
|
28
|
+
thresholdSentinel?: string;
|
|
29
|
+
/** Comparator operator. Default 'GT'. */
|
|
30
|
+
operator?: 'GT' | 'GTE' | 'LT' | 'LTE';
|
|
31
|
+
/**
|
|
32
|
+
* Submission window duration in ms. Default: 600_000 (10 min) to sync with
|
|
33
|
+
* the 15-min fast-test epoch on Base Sepolia. Set to 3_600_000 for 1h
|
|
34
|
+
* mainnet-style windows. Bucket size also uses this value.
|
|
35
|
+
*/
|
|
36
|
+
windowDurationMs?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Gap between window.endTs and resolveTs in ms. Default: 300_000 (5 min).
|
|
39
|
+
* Bounded by schema to ≤ 1h.
|
|
40
|
+
*/
|
|
41
|
+
resolveGapMs?: number;
|
|
42
|
+
/** RPC URL for the publicClient used to read Chainlink. */
|
|
43
|
+
rpcUrl?: string;
|
|
44
|
+
/** Injected publicClient — tests pass a mock; production leaves unset. */
|
|
45
|
+
_publicClient?: PublicClient;
|
|
46
|
+
}
|
|
47
|
+
export type PredictionV0Generator = () => Promise<DesiredState | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Build a generator closure. Calling the closure returns a freshly-resolved
|
|
50
|
+
* DesiredState for the current hour bucket, or null if Chainlink is
|
|
51
|
+
* unreachable (caller skips this tick).
|
|
52
|
+
*/
|
|
53
|
+
export declare function makePredictionV0Generator(config: PredictionV0AutoConfig): PredictionV0Generator;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generator for prediction.v0 intents.
|
|
3
|
+
*
|
|
4
|
+
* Produces a fresh DesiredState per hour bucket: reads current Chainlink
|
|
5
|
+
* price, builds a template with the configured threshold sentinel
|
|
6
|
+
* (default "current+0.5%" — coin-flip-ish, slightly biased NO), and resolves
|
|
7
|
+
* it via the shared template helper. Stable ID per hour prevents duplicate
|
|
8
|
+
* posts within a window; the CreatorLoop's SQLite cache guards against
|
|
9
|
+
* restart-replay.
|
|
10
|
+
*
|
|
11
|
+
* Wired in main.ts for testnet-only (jinn-mono-9ew). Operators can opt out
|
|
12
|
+
* with JINN_DISABLE_AUTO_INTENTS=1.
|
|
13
|
+
*/
|
|
14
|
+
import { createPublicClient, http } from 'viem';
|
|
15
|
+
import { base, baseSepolia } from 'viem/chains';
|
|
16
|
+
import { readChainlinkLatest, scaleToDecimal } from '../venues/chainlink/client.js';
|
|
17
|
+
import { resolvePredictionV0Template } from './prediction-v0-template.js';
|
|
18
|
+
// ── Generator factory ──────────────────────────────────────────────────────────
|
|
19
|
+
/**
|
|
20
|
+
* Build a generator closure. Calling the closure returns a freshly-resolved
|
|
21
|
+
* DesiredState for the current hour bucket, or null if Chainlink is
|
|
22
|
+
* unreachable (caller skips this tick).
|
|
23
|
+
*/
|
|
24
|
+
export function makePredictionV0Generator(config) {
|
|
25
|
+
const threshold = config.thresholdSentinel ?? 'current+0.5%';
|
|
26
|
+
const operator = config.operator ?? 'GT';
|
|
27
|
+
const windowDurationMs = config.windowDurationMs ?? 600_000; // 10 min default (fast-test)
|
|
28
|
+
const resolveGapMs = config.resolveGapMs ?? 300_000; // 5 min default
|
|
29
|
+
// Lazy publicClient construction — reused across calls.
|
|
30
|
+
let publicClient = config._publicClient ?? null;
|
|
31
|
+
const getPublicClient = () => {
|
|
32
|
+
if (publicClient)
|
|
33
|
+
return publicClient;
|
|
34
|
+
const chain = config.venue === 'chainlink-base' ? base : baseSepolia;
|
|
35
|
+
const rpcUrl = config.rpcUrl ?? (config.venue === 'chainlink-base'
|
|
36
|
+
? 'https://mainnet.base.org'
|
|
37
|
+
: 'https://sepolia.base.org');
|
|
38
|
+
publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
39
|
+
return publicClient;
|
|
40
|
+
};
|
|
41
|
+
return async () => {
|
|
42
|
+
// Bucket start = windowDurationMs boundary ≤ now. Stable ID per bucket
|
|
43
|
+
// prevents duplicate posts within the same window.
|
|
44
|
+
const now = Date.now();
|
|
45
|
+
const startTs = Math.floor(now / windowDurationMs) * windowDurationMs;
|
|
46
|
+
const endTs = startTs + windowDurationMs;
|
|
47
|
+
const resolveTs = endTs + resolveGapMs;
|
|
48
|
+
const template = {
|
|
49
|
+
id: `pred-v0-auto-${startTs}`,
|
|
50
|
+
description: `Auto-generated prediction.v0 intent — ${config.feedDescription} ${operator} ${threshold} at ${new Date(resolveTs).toISOString()}`,
|
|
51
|
+
window: { startTs, endTs },
|
|
52
|
+
spec: {
|
|
53
|
+
kind: 'prediction.v0',
|
|
54
|
+
oracle: {
|
|
55
|
+
venue: config.venue,
|
|
56
|
+
feed: config.feed,
|
|
57
|
+
feedDescription: config.feedDescription,
|
|
58
|
+
},
|
|
59
|
+
question: {
|
|
60
|
+
kind: 'threshold',
|
|
61
|
+
operator,
|
|
62
|
+
threshold,
|
|
63
|
+
resolveTs,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
eligibility: { maxSubmissionDelayMs: 60_000 },
|
|
67
|
+
};
|
|
68
|
+
try {
|
|
69
|
+
const intent = await resolvePredictionV0Template(template, {
|
|
70
|
+
readCurrent: async ({ feed }) => {
|
|
71
|
+
const reading = await readChainlinkLatest(feed, getPublicClient());
|
|
72
|
+
return scaleToDecimal(reading.answer, reading.decimals);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
// Return the resolved DesiredState shape (intent is already valid).
|
|
76
|
+
return intent;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Chainlink read failure or schema mismatch — skip this tick, try next.
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=prediction-v0-auto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction-v0-auto.js","sourceRoot":"","sources":["../../src/intents/prediction-v0-auto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAqB,MAAM,MAAM,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAsC1E,kFAAkF;AAElF;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAA8B;IACtE,MAAM,SAAS,GAAG,MAAM,CAAC,iBAAiB,IAAI,cAAc,CAAC;IAC7D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC;IACzC,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,CAAG,6BAA6B;IAC5F,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,OAAO,CAAC,CAAW,gBAAgB;IAE/E,wDAAwD;IACxD,IAAI,YAAY,GAAwB,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AAE,MAAM,CAAC,eAAe;iBACxC;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,WAAW;oBACjB,QAAQ;oBACR,SAAS;oBACT,SAAS;iBACV;aACF;YACD,WAAW,EAAE,EAAE,oBAAoB,EAAE,MAAM,EAAE;SAC9C,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,2BAA2B,CAAC,QAAQ,EAAE;gBACzD,WAAW,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;oBAC9B,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;oBACnE,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,CAAC;aACF,CAAC,CAAC;YACH,oEAAoE;YACpE,OAAO,MAAiC,CAAC;QAC3C,CAAC;QAAC,MAAM,CAAC;YACP,wEAAwE;YACxE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentinel resolution for prediction.v0 intent templates.
|
|
3
|
+
*
|
|
4
|
+
* Two sentinels are supported in template JSON (e.g.,
|
|
5
|
+
* `client/fixtures/prediction-v0-intent.example.json`):
|
|
6
|
+
*
|
|
7
|
+
* 1. window.startTs = 0 → rewritten as Date.now() at call time; the rest of
|
|
8
|
+
* the window (endTs) and resolveTs are computed relative to that.
|
|
9
|
+
*
|
|
10
|
+
* 2. spec.question.threshold = "current[±N[%]]" → read the Chainlink feed
|
|
11
|
+
* named in spec.oracle and substitute an absolute price:
|
|
12
|
+
*
|
|
13
|
+
* "current" → current price exactly
|
|
14
|
+
* "current+0.5%" → current × 1.005
|
|
15
|
+
* "current-2%" → current × 0.98
|
|
16
|
+
* "current+100" → current + 100
|
|
17
|
+
* "current-50" → current - 50
|
|
18
|
+
*
|
|
19
|
+
* The on-chain intent always carries an absolute decimal string; the
|
|
20
|
+
* sentinel is ONLY resolved at post time. Evaluator + restorer impls
|
|
21
|
+
* never see the sentinel form.
|
|
22
|
+
*
|
|
23
|
+
* Exported as a pure function with a `readCurrent` dep so it's trivially
|
|
24
|
+
* unit-testable. Both the `jinn submit-intent --spec-file` path and the
|
|
25
|
+
* future auto-generator (jinn-mono-9ew) call through this helper.
|
|
26
|
+
*/
|
|
27
|
+
import { type PredictionV0Intent } from '../types/prediction.js';
|
|
28
|
+
/** Returns true iff the given value looks like a "current[±N[%]]" sentinel. */
|
|
29
|
+
export declare function isCurrentSentinel(value: unknown): boolean;
|
|
30
|
+
export interface TemplateReaderDeps {
|
|
31
|
+
/**
|
|
32
|
+
* Read the current price of the Chainlink feed referenced in the template.
|
|
33
|
+
* The helper passes `{feed, venue}` so the reader can build the right client.
|
|
34
|
+
* Returns a decimal string (scaled from int256 via scaleToDecimal).
|
|
35
|
+
*/
|
|
36
|
+
readCurrent: (args: {
|
|
37
|
+
feed: `0x${string}`;
|
|
38
|
+
venue: 'chainlink-base' | 'chainlink-base-sepolia';
|
|
39
|
+
}) => Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Window duration when the template uses `window.startTs = 0` (now-relative
|
|
42
|
+
* sentinel). Default: 10 min — syncs with the 15-min fast-test epoch cadence
|
|
43
|
+
* on testnet. Set to 3_600_000 for a 1h window (mainnet-style dogfood).
|
|
44
|
+
*/
|
|
45
|
+
windowDurationMs?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve gap when the template uses `window.startTs = 0`. Default: 5 min.
|
|
48
|
+
* `resolveTs = endTs + resolveGapMs`. Bounded by schema to ≤ 1h.
|
|
49
|
+
*/
|
|
50
|
+
resolveGapMs?: number;
|
|
51
|
+
}
|
|
52
|
+
/** Default window duration for the startTs-sentinel fill. Tuned for fast-test. */
|
|
53
|
+
export declare const DEFAULT_WINDOW_DURATION_MS = 600000;
|
|
54
|
+
/** Default resolve gap for the startTs-sentinel fill. Tuned for fast-test. */
|
|
55
|
+
export declare const DEFAULT_RESOLVE_GAP_MS = 300000;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve all supported sentinels in a raw prediction.v0 template + return a
|
|
58
|
+
* parsed, validated PredictionV0Intent.
|
|
59
|
+
*
|
|
60
|
+
* The template must be the JSON shape of a PredictionV0Intent with optional
|
|
61
|
+
* sentinel values. Callers that build the template from multiple sources
|
|
62
|
+
* (CLI --spec-file + --id + --description) should merge their bits BEFORE
|
|
63
|
+
* calling this helper.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolvePredictionV0Template(template: unknown, deps: TemplateReaderDeps): Promise<PredictionV0Intent>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentinel resolution for prediction.v0 intent templates.
|
|
3
|
+
*
|
|
4
|
+
* Two sentinels are supported in template JSON (e.g.,
|
|
5
|
+
* `client/fixtures/prediction-v0-intent.example.json`):
|
|
6
|
+
*
|
|
7
|
+
* 1. window.startTs = 0 → rewritten as Date.now() at call time; the rest of
|
|
8
|
+
* the window (endTs) and resolveTs are computed relative to that.
|
|
9
|
+
*
|
|
10
|
+
* 2. spec.question.threshold = "current[±N[%]]" → read the Chainlink feed
|
|
11
|
+
* named in spec.oracle and substitute an absolute price:
|
|
12
|
+
*
|
|
13
|
+
* "current" → current price exactly
|
|
14
|
+
* "current+0.5%" → current × 1.005
|
|
15
|
+
* "current-2%" → current × 0.98
|
|
16
|
+
* "current+100" → current + 100
|
|
17
|
+
* "current-50" → current - 50
|
|
18
|
+
*
|
|
19
|
+
* The on-chain intent always carries an absolute decimal string; the
|
|
20
|
+
* sentinel is ONLY resolved at post time. Evaluator + restorer impls
|
|
21
|
+
* never see the sentinel form.
|
|
22
|
+
*
|
|
23
|
+
* Exported as a pure function with a `readCurrent` dep so it's trivially
|
|
24
|
+
* unit-testable. Both the `jinn submit-intent --spec-file` path and the
|
|
25
|
+
* future auto-generator (jinn-mono-9ew) call through this helper.
|
|
26
|
+
*/
|
|
27
|
+
import { PredictionV0IntentSchema, } from '../types/prediction.js';
|
|
28
|
+
// ── Sentinel parsers ──────────────────────────────────────────────────────────
|
|
29
|
+
/**
|
|
30
|
+
* Parse a `current[±N[%]]` sentinel. Returns a function that takes the current
|
|
31
|
+
* price (decimal string) and produces an absolute threshold (decimal string).
|
|
32
|
+
* Throws if the sentinel doesn't match the expected grammar.
|
|
33
|
+
*/
|
|
34
|
+
function parseCurrentSentinel(sentinel) {
|
|
35
|
+
if (sentinel === 'current') {
|
|
36
|
+
return (current) => current;
|
|
37
|
+
}
|
|
38
|
+
const match = sentinel.match(/^current([+-])(\d+(?:\.\d+)?)(%?)$/);
|
|
39
|
+
if (!match) {
|
|
40
|
+
throw new Error(`invalid threshold sentinel: ${JSON.stringify(sentinel)}. ` +
|
|
41
|
+
`Expected "current" or "current±N" or "current±N%" (e.g., "current+0.5%").`);
|
|
42
|
+
}
|
|
43
|
+
const [, sign, numStr, pct] = match;
|
|
44
|
+
const delta = parseFloat(numStr);
|
|
45
|
+
if (!Number.isFinite(delta) || delta < 0) {
|
|
46
|
+
throw new Error(`invalid threshold sentinel magnitude: ${numStr}`);
|
|
47
|
+
}
|
|
48
|
+
return (current) => {
|
|
49
|
+
const curNum = parseFloat(current);
|
|
50
|
+
if (!Number.isFinite(curNum) || curNum < 0) {
|
|
51
|
+
throw new Error(`invalid current price for sentinel resolution: ${current}`);
|
|
52
|
+
}
|
|
53
|
+
const offset = pct ? curNum * (delta / 100) : delta;
|
|
54
|
+
const signed = sign === '+' ? offset : -offset;
|
|
55
|
+
const result = curNum + signed;
|
|
56
|
+
// 4 decimal places is plenty of resolution for price comparisons.
|
|
57
|
+
// Strip trailing zeros for human-readable output.
|
|
58
|
+
return result.toFixed(4).replace(/\.?0+$/, '');
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Returns true iff the given value looks like a "current[±N[%]]" sentinel. */
|
|
62
|
+
export function isCurrentSentinel(value) {
|
|
63
|
+
return typeof value === 'string' && /^current([+-]\d+(\.\d+)?%?)?$/.test(value);
|
|
64
|
+
}
|
|
65
|
+
/** Default window duration for the startTs-sentinel fill. Tuned for fast-test. */
|
|
66
|
+
export const DEFAULT_WINDOW_DURATION_MS = 600_000;
|
|
67
|
+
/** Default resolve gap for the startTs-sentinel fill. Tuned for fast-test. */
|
|
68
|
+
export const DEFAULT_RESOLVE_GAP_MS = 300_000;
|
|
69
|
+
/**
|
|
70
|
+
* Resolve all supported sentinels in a raw prediction.v0 template + return a
|
|
71
|
+
* parsed, validated PredictionV0Intent.
|
|
72
|
+
*
|
|
73
|
+
* The template must be the JSON shape of a PredictionV0Intent with optional
|
|
74
|
+
* sentinel values. Callers that build the template from multiple sources
|
|
75
|
+
* (CLI --spec-file + --id + --description) should merge their bits BEFORE
|
|
76
|
+
* calling this helper.
|
|
77
|
+
*/
|
|
78
|
+
export async function resolvePredictionV0Template(template, deps) {
|
|
79
|
+
if (typeof template !== 'object' || template === null) {
|
|
80
|
+
throw new Error('resolvePredictionV0Template: template must be an object');
|
|
81
|
+
}
|
|
82
|
+
// Shallow clone so we don't mutate caller's input.
|
|
83
|
+
const stub = JSON.parse(JSON.stringify(template));
|
|
84
|
+
// ── (1) window.startTs = 0 → now-relative ──────────────────────────────────
|
|
85
|
+
const windowMs = deps.windowDurationMs ?? DEFAULT_WINDOW_DURATION_MS;
|
|
86
|
+
const resolveMs = deps.resolveGapMs ?? DEFAULT_RESOLVE_GAP_MS;
|
|
87
|
+
const win = stub['window'];
|
|
88
|
+
if (win && win.startTs === 0) {
|
|
89
|
+
const now = Date.now();
|
|
90
|
+
win.startTs = now;
|
|
91
|
+
win.endTs = now + windowMs;
|
|
92
|
+
const spec = stub['spec'];
|
|
93
|
+
if (spec?.question) {
|
|
94
|
+
spec.question.resolveTs = now + windowMs + resolveMs;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// ── (2) spec.question.threshold sentinel → absolute price ──────────────────
|
|
98
|
+
const spec = stub['spec'];
|
|
99
|
+
if (spec?.kind === 'prediction.v0' &&
|
|
100
|
+
spec.question?.kind === 'threshold' &&
|
|
101
|
+
typeof spec.question.threshold === 'string') {
|
|
102
|
+
const t = spec.question.threshold;
|
|
103
|
+
if (isCurrentSentinel(t)) {
|
|
104
|
+
if (!spec.oracle?.feed || !spec.oracle.venue) {
|
|
105
|
+
throw new Error('cannot resolve threshold sentinel: spec.oracle.feed and spec.oracle.venue are required');
|
|
106
|
+
}
|
|
107
|
+
const current = await deps.readCurrent({
|
|
108
|
+
feed: spec.oracle.feed,
|
|
109
|
+
venue: spec.oracle.venue,
|
|
110
|
+
});
|
|
111
|
+
const resolveFn = parseCurrentSentinel(t);
|
|
112
|
+
spec.question.threshold = resolveFn(current);
|
|
113
|
+
}
|
|
114
|
+
else if (t.toLowerCase().startsWith('current')) {
|
|
115
|
+
// Eager error: looks like an intended sentinel but didn't match the grammar.
|
|
116
|
+
// Saves operators from pushing garbage on-chain only to fail at eval time.
|
|
117
|
+
throw new Error(`unknown threshold sentinel: ${JSON.stringify(t)}. ` +
|
|
118
|
+
`Expected "current" or "current±N" or "current±N%" (e.g., "current+0.5%"). ` +
|
|
119
|
+
`If you meant a literal absolute threshold, use a pure decimal string (e.g., "3000").`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Final Zod parse — all refinements (window span, resolveTs offset) enforced.
|
|
123
|
+
return PredictionV0IntentSchema.parse(stub);
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=prediction-v0-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction-v0-template.js","sourceRoot":"","sources":["../../src/intents/prediction-v0-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EACL,wBAAwB,GAEzB,MAAM,wBAAwB,CAAC;AAEhC,iFAAiF;AAEjF;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,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AAI,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -31,6 +31,20 @@ import { MechAdapter } from './adapters/mech/adapter.js';
|
|
|
31
31
|
import { ClaudeRunner } from './runner/claude.js';
|
|
32
32
|
import { Daemon } from './daemon/daemon.js';
|
|
33
33
|
import { createJinnPublicClient, createJinnWalletClient } from './earning/viem-clients.js';
|
|
34
|
+
import { RestorerImplRegistry } from './restorer/engine/registry.js';
|
|
35
|
+
import { LegacyClaudeImpl } from './restorer/impls/legacy-claude/index.js';
|
|
36
|
+
import { ClaudeMcpHyperliquidImpl } from './restorer/impls/claude-mcp-hyperliquid/index.js';
|
|
37
|
+
import { PortfolioV0Evaluator } from './restorer/impls/portfolio-v0-evaluator/index.js';
|
|
38
|
+
import { PredictionV0BaselineImpl } from './restorer/impls/prediction-v0-baseline/index.js';
|
|
39
|
+
import { PredictionV0Evaluator } from './restorer/impls/prediction-v0-evaluator/index.js';
|
|
40
|
+
import { ClaudeMcpPredictionImpl } from './restorer/impls/claude-mcp-prediction/index.js';
|
|
41
|
+
import { PredictionApyV0BaselineImpl } from './restorer/impls/prediction-apy-v0-baseline/index.js';
|
|
42
|
+
import { PredictionApyV0Evaluator } from './restorer/impls/prediction-apy-v0-evaluator/index.js';
|
|
43
|
+
import { ClaimRegistryClient } from './adapters/claim-registry/client.js';
|
|
44
|
+
import { createClients } from './adapters/mech/safe.js';
|
|
45
|
+
import { makePredictionV0Generator } from './intents/prediction-v0-auto.js';
|
|
46
|
+
import { makePredictionApyV0Generator } from './intents/prediction-apy-v0-auto.js';
|
|
47
|
+
import { BASE_SEPOLIA_FEEDS, BASE_FEEDS } from './venues/chainlink/feeds.js';
|
|
34
48
|
dotenvConfig({ path: join(dirname(fileURLToPath(import.meta.url)), '..', '.env') });
|
|
35
49
|
// ── Password (env-only — never in config files) ────────────────────────────
|
|
36
50
|
const PASSWORD = (() => {
|
|
@@ -50,6 +64,7 @@ const CHAIN_CONFIG = getChainConfig(NETWORK_CHAIN, {
|
|
|
50
64
|
testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
|
|
51
65
|
testnetMechDeploymentPath: config.testnetMechDeploymentPath,
|
|
52
66
|
testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
|
|
67
|
+
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
53
68
|
});
|
|
54
69
|
const MARKETPLACE_ADDRESS = CHAIN_CONFIG.mechMarketplace;
|
|
55
70
|
const ROUTER_ADDRESS = (CHAIN_CONFIG.jinnRouter ?? '0xfFa7118A3D820cd4E820010837D65FAfF463181B');
|
|
@@ -106,6 +121,7 @@ async function bootstrap() {
|
|
|
106
121
|
testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
|
|
107
122
|
testnetMechDeploymentPath: config.testnetMechDeploymentPath,
|
|
108
123
|
testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
|
|
124
|
+
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
109
125
|
debug: config.debug,
|
|
110
126
|
masterEthDailyEstimateWei: config.masterEthDailyEstimateWei,
|
|
111
127
|
pollIntervalMs: config.pollIntervalMs,
|
|
@@ -199,7 +215,7 @@ export async function main() {
|
|
|
199
215
|
if (!preflight.ok) {
|
|
200
216
|
emitClaudeBinaryPreflightFailure(preflight.detail, config.claudePath);
|
|
201
217
|
}
|
|
202
|
-
const authContext = detectAuthContext({ cwd: process.cwd() });
|
|
218
|
+
const authContext = detectAuthContext({ cwd: process.cwd(), configuredMode: config.runtimeMode });
|
|
203
219
|
const authProbe = probeClaudeAuth({ context: authContext, cwd: process.cwd() });
|
|
204
220
|
if (!authProbe.authenticated) {
|
|
205
221
|
emitEnvelope({
|
|
@@ -223,15 +239,137 @@ export async function main() {
|
|
|
223
239
|
const masterAccount = deriveMasterSigner(mnemonicForMaster);
|
|
224
240
|
const publicClient = createJinnPublicClient(config.rpcUrl, NETWORK_CHAIN);
|
|
225
241
|
const masterWallet = createJinnWalletClient(config.rpcUrl, NETWORK_CHAIN, masterAccount);
|
|
242
|
+
// ── RestorationEngine wiring ─────────────────────────────────────────────────
|
|
243
|
+
// Build agent viem clients (same creds as MechAdapter uses internally).
|
|
244
|
+
const agentChain = config.network === 'testnet'
|
|
245
|
+
? (await import('viem/chains')).baseSepolia
|
|
246
|
+
: (await import('viem/chains')).base;
|
|
247
|
+
const agentClients = createClients(config.rpcUrl, agentPrivateKey, agentChain);
|
|
248
|
+
// ── Impl registry ────────────────────────────────────────────────────────────
|
|
249
|
+
// Default-disable impls with external dependencies the operator must opt
|
|
250
|
+
// into (see cli/intent-registry-access.ts). The user's
|
|
251
|
+
// `config.restorers.disabled[]` fully overrides this default when present,
|
|
252
|
+
// so `jinn intents enable <kind>` persists the opt-in by writing to that
|
|
253
|
+
// list in ~/.jinn-client/config.json.
|
|
254
|
+
const { DEFAULT_DISABLED_IMPLS, DEFAULT_BY_KIND } = await import('./cli/intent-registry-access.js');
|
|
255
|
+
const implRegistry = new RestorerImplRegistry({
|
|
256
|
+
byKind: { ...DEFAULT_BY_KIND },
|
|
257
|
+
default: 'legacy-claude',
|
|
258
|
+
disabled: [...DEFAULT_DISABLED_IMPLS],
|
|
259
|
+
...(config.restorers ?? {}),
|
|
260
|
+
});
|
|
261
|
+
// legacy-claude: wraps ClaudeRunner; handles spec=undefined (health-check) intents
|
|
262
|
+
implRegistry.register(new LegacyClaudeImpl({
|
|
263
|
+
runner,
|
|
264
|
+
workingDirectory: '/tmp',
|
|
265
|
+
timeoutMs: 300_000,
|
|
266
|
+
daemonApiUrl: `http://127.0.0.1:${config.apiPort}`,
|
|
267
|
+
}));
|
|
268
|
+
// claude-mcp-hyperliquid: portfolio.v0 trader
|
|
269
|
+
implRegistry.register(new ClaudeMcpHyperliquidImpl({
|
|
270
|
+
claudePath: config.claudePath,
|
|
271
|
+
claudeModel: config.claudeModel,
|
|
272
|
+
}));
|
|
273
|
+
// portfolio-v0-evaluator: deterministic verifier — dispatched via type='evaluation' for portfolio.v0 kind
|
|
274
|
+
implRegistry.register(new PortfolioV0Evaluator());
|
|
275
|
+
// prediction-v0-baseline: reference restorer for prediction.v0 intents
|
|
276
|
+
implRegistry.register(new PredictionV0BaselineImpl({
|
|
277
|
+
rpcUrl: config.rpcUrl,
|
|
278
|
+
}));
|
|
279
|
+
// claude-mcp-prediction: opt-in alternative that spawns Claude via MCP.
|
|
280
|
+
// Only chosen when config.restorers.byKind['prediction.v0'] names it.
|
|
281
|
+
// Registered unconditionally so the registry's byKind dispatch can find
|
|
282
|
+
// it when opted-in; baseline stays default via the byKind map above.
|
|
283
|
+
implRegistry.register(new ClaudeMcpPredictionImpl({
|
|
284
|
+
claudePath: config.claudePath,
|
|
285
|
+
claudeModel: config.claudeModel,
|
|
286
|
+
rpcUrl: config.rpcUrl,
|
|
287
|
+
}));
|
|
288
|
+
// prediction-v0-evaluator: deterministic verifier for prediction.v0 evaluation jobs
|
|
289
|
+
implRegistry.register(new PredictionV0Evaluator({
|
|
290
|
+
evaluatorPk: agentPrivateKey,
|
|
291
|
+
evaluatorSafeAddress: safeAddress,
|
|
292
|
+
rpcUrl: config.rpcUrl,
|
|
293
|
+
}));
|
|
294
|
+
implRegistry.register(new PredictionApyV0BaselineImpl({
|
|
295
|
+
rpcUrl: config.rpcUrl,
|
|
296
|
+
archiveRpcUrl: config.archiveRpcUrl,
|
|
297
|
+
}));
|
|
298
|
+
implRegistry.register(new PredictionApyV0Evaluator({
|
|
299
|
+
evaluatorPk: agentPrivateKey,
|
|
300
|
+
evaluatorSafeAddress: safeAddress,
|
|
301
|
+
rpcUrl: config.rpcUrl,
|
|
302
|
+
archiveRpcUrl: config.archiveRpcUrl,
|
|
303
|
+
}));
|
|
304
|
+
console.log(`[main] RestorerImplRegistry: ${implRegistry.list().map(i => i.name).join(', ')}`);
|
|
305
|
+
// ── Engine deps ───────────────────────────────────────────────────────────────
|
|
306
|
+
// Packaging deps: IPFS upload + optional artifact registration (wired in daemon via registerArtifact)
|
|
307
|
+
const packagingDeps = {
|
|
308
|
+
ipfsRegistryUrl: config.ipfsRegistryUrl,
|
|
309
|
+
};
|
|
310
|
+
// Manifest assembly deps: sign manifests with agent EOA private key
|
|
311
|
+
const manifestDeps = {
|
|
312
|
+
ipfsRegistryUrl: config.ipfsRegistryUrl,
|
|
313
|
+
agentEoaPrivateKey: agentPrivateKey,
|
|
314
|
+
safeAddress,
|
|
315
|
+
};
|
|
316
|
+
// Delivery deps: deliver to marketplace + claimDelivery via JinnRouter
|
|
317
|
+
const deliveryDeps = {
|
|
318
|
+
publicClient: agentClients.publicClient,
|
|
319
|
+
walletClient: agentClients.walletClient,
|
|
320
|
+
safeAddress,
|
|
321
|
+
mechContractAddress: mechAddress,
|
|
322
|
+
routerAddress: ROUTER_ADDRESS,
|
|
323
|
+
claimDeliveryVariant: CHAIN_CONFIG.routerClaimDeliveryVersion,
|
|
324
|
+
};
|
|
325
|
+
// Claim deps: use the network default when bundled, with env override for
|
|
326
|
+
// emergency redeploys or custom test deployments.
|
|
327
|
+
const claimRegistryAddress = (process.env['JINN_CLAIM_REGISTRY_ADDRESS']
|
|
328
|
+
?? CHAIN_CONFIG.claimRegistry
|
|
329
|
+
?? '');
|
|
330
|
+
const claimDeps = claimRegistryAddress
|
|
331
|
+
? {
|
|
332
|
+
registryClient: new ClaimRegistryClient(agentClients.publicClient, agentClients.walletClient, claimRegistryAddress, safeAddress),
|
|
333
|
+
marketplaceClaimer: adapter,
|
|
334
|
+
}
|
|
335
|
+
: undefined;
|
|
336
|
+
if (claimRegistryAddress) {
|
|
337
|
+
console.log(`[main] ClaimRegistry: ${claimRegistryAddress}`);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
console.log('[main] ClaimRegistry: not configured (claim step will use NotImplementedError fallback)');
|
|
341
|
+
}
|
|
342
|
+
// ── Auto-intent generators (testnet only, opt-out via env) ─────────────────
|
|
343
|
+
const intentGenerators = [];
|
|
344
|
+
const autoIntentsDisabled = process.env['JINN_DISABLE_AUTO_INTENTS'] === '1';
|
|
345
|
+
if (config.network === 'testnet' && !autoIntentsDisabled) {
|
|
346
|
+
intentGenerators.push(makePredictionV0Generator({
|
|
347
|
+
feed: BASE_SEPOLIA_FEEDS['ETH / USD'],
|
|
348
|
+
feedDescription: 'ETH / USD',
|
|
349
|
+
venue: 'chainlink-base-sepolia',
|
|
350
|
+
rpcUrl: config.rpcUrl,
|
|
351
|
+
}));
|
|
352
|
+
console.log('[main] auto-intent generator enabled: prediction.v0 (testnet, ETH/USD coin-flip+0.5%)');
|
|
353
|
+
if (process.env['JINN_ENABLE_APY_AUTO_INTENTS'] === '1') {
|
|
354
|
+
intentGenerators.push(makePredictionApyV0Generator());
|
|
355
|
+
console.log('[main] auto-intent generator enabled: prediction.apy.v0 (JINN_ENABLE_APY_AUTO_INTENTS=1)');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
else if (config.network === 'mainnet' && !autoIntentsDisabled && BASE_FEEDS['ETH / USD']) {
|
|
359
|
+
// Mainnet opt-in only; default is OFF. Reserved for a future flag.
|
|
360
|
+
}
|
|
226
361
|
const daemon = new Daemon({
|
|
227
362
|
adapter,
|
|
228
363
|
runner,
|
|
229
364
|
desiredStates: config.desiredStates,
|
|
230
365
|
dbPath: config.dbPath,
|
|
366
|
+
pollIntervalMs: config.pollIntervalMs,
|
|
231
367
|
apiPort: config.apiPort,
|
|
232
368
|
peers: config.peers.length > 0 ? config.peers : undefined,
|
|
233
369
|
subgraphUrl: config.subgraphUrl,
|
|
234
370
|
nodeEndpoint: config.nodeEndpoint,
|
|
371
|
+
intentGenerators,
|
|
372
|
+
creatorSafeAddress: safeAddress,
|
|
235
373
|
status: {
|
|
236
374
|
earningDir: config.earningDir,
|
|
237
375
|
rpcUrl: config.rpcUrl,
|
|
@@ -243,6 +381,7 @@ export async function main() {
|
|
|
243
381
|
testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
|
|
244
382
|
testnetMechDeploymentPath: config.testnetMechDeploymentPath,
|
|
245
383
|
testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
|
|
384
|
+
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
246
385
|
},
|
|
247
386
|
rewardClaim: config.rewardClaimIntervalMs > 0
|
|
248
387
|
? {
|
|
@@ -254,6 +393,20 @@ export async function main() {
|
|
|
254
393
|
distributorAddress: CHAIN_CONFIG.distributorAddress,
|
|
255
394
|
}
|
|
256
395
|
: undefined,
|
|
396
|
+
restorationEngine: {
|
|
397
|
+
// TODO(jinn-mono-cy4): RestorationEngineOptions has redundant registry+implRegistry
|
|
398
|
+
// fields. Engine refactor should consolidate to one. Locked in this PR.
|
|
399
|
+
registry: implRegistry,
|
|
400
|
+
paths: {
|
|
401
|
+
workingDirRoot: '/tmp/jinn-engine-working',
|
|
402
|
+
implStateDirRoot: '/tmp/jinn-engine-impl-state',
|
|
403
|
+
},
|
|
404
|
+
claimDeps,
|
|
405
|
+
packagingDeps,
|
|
406
|
+
manifestDeps,
|
|
407
|
+
deliveryDeps,
|
|
408
|
+
implRegistry,
|
|
409
|
+
},
|
|
257
410
|
balanceTopup: config.balanceTopupIntervalMs > 0
|
|
258
411
|
? {
|
|
259
412
|
intervalMs: config.balanceTopupIntervalMs,
|