@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.
Files changed (317) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +123 -0
  3. package/README.md +210 -37
  4. package/deployments/deployment-claim-registry-baseSepolia.json +13 -0
  5. package/deployments/deployment-jinn-testnet-faucet-baseSepolia-fast.json +15 -0
  6. package/dist/adapters/claim-registry/abi.d.ts +127 -0
  7. package/dist/adapters/claim-registry/abi.js +93 -0
  8. package/dist/adapters/claim-registry/abi.js.map +1 -0
  9. package/dist/adapters/claim-registry/client.d.ts +89 -0
  10. package/dist/adapters/claim-registry/client.js +205 -0
  11. package/dist/adapters/claim-registry/client.js.map +1 -0
  12. package/dist/adapters/mech/adapter.d.ts +1 -0
  13. package/dist/adapters/mech/adapter.js +75 -41
  14. package/dist/adapters/mech/adapter.js.map +1 -1
  15. package/dist/adapters/mech/contracts.d.ts +2 -0
  16. package/dist/adapters/mech/contracts.js +57 -7
  17. package/dist/adapters/mech/contracts.js.map +1 -1
  18. package/dist/adapters/mech/ipfs.d.ts +8 -0
  19. package/dist/adapters/mech/ipfs.js +12 -0
  20. package/dist/adapters/mech/ipfs.js.map +1 -1
  21. package/dist/adapters/mech/types.d.ts +20 -46
  22. package/dist/adapters/mech/types.js +16 -35
  23. package/dist/adapters/mech/types.js.map +1 -1
  24. package/dist/api/gather-status.d.ts +1 -0
  25. package/dist/api/gather-status.js +33 -1
  26. package/dist/api/gather-status.js.map +1 -1
  27. package/dist/api/portfolio-v0-build.d.ts +81 -0
  28. package/dist/api/portfolio-v0-build.js +141 -0
  29. package/dist/api/portfolio-v0-build.js.map +1 -0
  30. package/dist/api/portfolio-v0-doctor.d.ts +37 -0
  31. package/dist/api/portfolio-v0-doctor.js +123 -0
  32. package/dist/api/portfolio-v0-doctor.js.map +1 -0
  33. package/dist/api/rewards-build.js +1 -1
  34. package/dist/api/rewards-build.js.map +1 -1
  35. package/dist/api/status-build.d.ts +7 -0
  36. package/dist/api/status-build.js +1 -0
  37. package/dist/api/status-build.js.map +1 -1
  38. package/dist/bin/jinn-mcp.d.ts +0 -12
  39. package/dist/bin/jinn-mcp.js +5 -14
  40. package/dist/bin/jinn-mcp.js.map +1 -1
  41. package/dist/build-meta.json +1 -1
  42. package/dist/cli/commands/auth.js +115 -25
  43. package/dist/cli/commands/auth.js.map +1 -1
  44. package/dist/cli/commands/bootstrap.js +1 -0
  45. package/dist/cli/commands/bootstrap.js.map +1 -1
  46. package/dist/cli/commands/doctor.js +130 -14
  47. package/dist/cli/commands/doctor.js.map +1 -1
  48. package/dist/cli/commands/fleet-scale.js +1 -0
  49. package/dist/cli/commands/fleet-scale.js.map +1 -1
  50. package/dist/cli/commands/fund-requirements.js +2 -0
  51. package/dist/cli/commands/fund-requirements.js.map +1 -1
  52. package/dist/cli/commands/intents.d.ts +17 -0
  53. package/dist/cli/commands/intents.js +489 -0
  54. package/dist/cli/commands/intents.js.map +1 -0
  55. package/dist/cli/commands/keys-backup.js +13 -11
  56. package/dist/cli/commands/keys-backup.js.map +1 -1
  57. package/dist/cli/commands/mcp.d.ts +3 -0
  58. package/dist/cli/commands/mcp.js +19 -0
  59. package/dist/cli/commands/mcp.js.map +1 -0
  60. package/dist/cli/commands/plugin-install.js +8 -4
  61. package/dist/cli/commands/plugin-install.js.map +1 -1
  62. package/dist/cli/commands/quickstart.js +60 -4
  63. package/dist/cli/commands/quickstart.js.map +1 -1
  64. package/dist/cli/commands/rewards.js +27 -1
  65. package/dist/cli/commands/rewards.js.map +1 -1
  66. package/dist/cli/commands/submit-intent.js +108 -5
  67. package/dist/cli/commands/submit-intent.js.map +1 -1
  68. package/dist/cli/commands/version.js +1 -0
  69. package/dist/cli/commands/version.js.map +1 -1
  70. package/dist/cli/deployment-digest.js +5 -0
  71. package/dist/cli/deployment-digest.js.map +1 -1
  72. package/dist/cli/execution-context.js +1 -0
  73. package/dist/cli/execution-context.js.map +1 -1
  74. package/dist/cli/index.js +4 -0
  75. package/dist/cli/index.js.map +1 -1
  76. package/dist/cli/intent-registry-access.d.ts +64 -0
  77. package/dist/cli/intent-registry-access.js +187 -0
  78. package/dist/cli/intent-registry-access.js.map +1 -0
  79. package/dist/cli/introspection-context.js +1 -0
  80. package/dist/cli/introspection-context.js.map +1 -1
  81. package/dist/cli/password.d.ts +21 -9
  82. package/dist/cli/password.js +45 -24
  83. package/dist/cli/password.js.map +1 -1
  84. package/dist/config.d.ts +110 -8
  85. package/dist/config.js +41 -12
  86. package/dist/config.js.map +1 -1
  87. package/dist/daemon/creator.d.ts +7 -1
  88. package/dist/daemon/creator.js +38 -3
  89. package/dist/daemon/creator.js.map +1 -1
  90. package/dist/daemon/daemon.d.ts +43 -0
  91. package/dist/daemon/daemon.js +87 -2
  92. package/dist/daemon/daemon.js.map +1 -1
  93. package/dist/earning/bootstrap.d.ts +2 -1
  94. package/dist/earning/bootstrap.js +72 -4
  95. package/dist/earning/bootstrap.js.map +1 -1
  96. package/dist/earning/contracts.d.ts +10 -0
  97. package/dist/earning/contracts.js +24 -0
  98. package/dist/earning/contracts.js.map +1 -1
  99. package/dist/earning/jinn-rewards.d.ts +9 -0
  100. package/dist/earning/jinn-rewards.js +7 -0
  101. package/dist/earning/jinn-rewards.js.map +1 -1
  102. package/dist/intents/prediction-apy-v0-auto.d.ts +11 -0
  103. package/dist/intents/prediction-apy-v0-auto.js +46 -0
  104. package/dist/intents/prediction-apy-v0-auto.js.map +1 -0
  105. package/dist/intents/prediction-apy-v0-template.d.ts +8 -0
  106. package/dist/intents/prediction-apy-v0-template.js +22 -0
  107. package/dist/intents/prediction-apy-v0-template.js.map +1 -0
  108. package/dist/intents/prediction-v0-auto.d.ts +53 -0
  109. package/dist/intents/prediction-v0-auto.js +84 -0
  110. package/dist/intents/prediction-v0-auto.js.map +1 -0
  111. package/dist/intents/prediction-v0-template.d.ts +65 -0
  112. package/dist/intents/prediction-v0-template.js +125 -0
  113. package/dist/intents/prediction-v0-template.js.map +1 -0
  114. package/dist/main.js +149 -1
  115. package/dist/main.js.map +1 -1
  116. package/dist/mcp/operator-server.d.ts +1 -1
  117. package/dist/mcp/operator-server.js +1 -1
  118. package/dist/preflight/claude-auth.d.ts +12 -1
  119. package/dist/preflight/claude-auth.js +21 -3
  120. package/dist/preflight/claude-auth.js.map +1 -1
  121. package/dist/restorer/engine/canonical-json.d.ts +18 -0
  122. package/dist/restorer/engine/canonical-json.js +59 -0
  123. package/dist/restorer/engine/canonical-json.js.map +1 -0
  124. package/dist/restorer/engine/claim.d.ts +69 -0
  125. package/dist/restorer/engine/claim.js +104 -0
  126. package/dist/restorer/engine/claim.js.map +1 -0
  127. package/dist/restorer/engine/delivery.d.ts +52 -0
  128. package/dist/restorer/engine/delivery.js +63 -0
  129. package/dist/restorer/engine/delivery.js.map +1 -0
  130. package/dist/restorer/engine/engine.d.ts +203 -0
  131. package/dist/restorer/engine/engine.js +753 -0
  132. package/dist/restorer/engine/engine.js.map +1 -0
  133. package/dist/restorer/engine/manifest-assembly.d.ts +67 -0
  134. package/dist/restorer/engine/manifest-assembly.js +79 -0
  135. package/dist/restorer/engine/manifest-assembly.js.map +1 -0
  136. package/dist/restorer/engine/packaging.d.ts +87 -0
  137. package/dist/restorer/engine/packaging.js +350 -0
  138. package/dist/restorer/engine/packaging.js.map +1 -0
  139. package/dist/restorer/engine/persistence.d.ts +170 -0
  140. package/dist/restorer/engine/persistence.js +381 -0
  141. package/dist/restorer/engine/persistence.js.map +1 -0
  142. package/dist/restorer/engine/recovery.d.ts +22 -0
  143. package/dist/restorer/engine/recovery.js +24 -0
  144. package/dist/restorer/engine/recovery.js.map +1 -0
  145. package/dist/restorer/engine/registry.d.ts +62 -0
  146. package/dist/restorer/engine/registry.js +73 -0
  147. package/dist/restorer/engine/registry.js.map +1 -0
  148. package/dist/restorer/engine/signing.d.ts +30 -0
  149. package/dist/restorer/engine/signing.js +39 -0
  150. package/dist/restorer/engine/signing.js.map +1 -0
  151. package/dist/restorer/engine/state.d.ts +42 -0
  152. package/dist/restorer/engine/state.js +87 -0
  153. package/dist/restorer/engine/state.js.map +1 -0
  154. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
  155. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js +96 -0
  156. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
  157. package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +101 -0
  158. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +710 -0
  159. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +1 -0
  160. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +137 -0
  161. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js +865 -0
  162. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
  163. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.d.ts +74 -0
  164. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js +74 -0
  165. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
  166. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +97 -0
  167. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +226 -0
  168. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
  169. package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +43 -0
  170. package/dist/restorer/impls/claude-mcp-prediction/index.js +230 -0
  171. package/dist/restorer/impls/claude-mcp-prediction/index.js.map +1 -0
  172. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.d.ts +38 -0
  173. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js +135 -0
  174. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
  175. package/dist/restorer/impls/claude-mcp-prediction/prompt.d.ts +8 -0
  176. package/dist/restorer/impls/claude-mcp-prediction/prompt.js +54 -0
  177. package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +1 -0
  178. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +36 -0
  179. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +137 -0
  180. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
  181. package/dist/restorer/impls/claude-mcp-prediction/types.d.ts +82 -0
  182. package/dist/restorer/impls/claude-mcp-prediction/types.js +6 -0
  183. package/dist/restorer/impls/claude-mcp-prediction/types.js.map +1 -0
  184. package/dist/restorer/impls/legacy-claude/index.d.ts +45 -0
  185. package/dist/restorer/impls/legacy-claude/index.js +71 -0
  186. package/dist/restorer/impls/legacy-claude/index.js.map +1 -0
  187. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
  188. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
  189. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
  190. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.d.ts +49 -0
  191. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js +91 -0
  192. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
  193. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
  194. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
  195. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
  196. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
  197. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
  198. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
  199. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
  200. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
  201. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
  202. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
  203. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
  204. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
  205. package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +43 -0
  206. package/dist/restorer/impls/portfolio-v0-evaluator/index.js +431 -0
  207. package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +1 -0
  208. package/dist/restorer/impls/portfolio-v0-evaluator/score.d.ts +21 -0
  209. package/dist/restorer/impls/portfolio-v0-evaluator/score.js +32 -0
  210. package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +1 -0
  211. package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +32 -0
  212. package/dist/restorer/impls/portfolio-v0-evaluator/types.js +8 -0
  213. package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +1 -0
  214. package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +39 -0
  215. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +98 -0
  216. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +1 -0
  217. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.d.ts +2 -0
  218. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js +7 -0
  219. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
  220. package/dist/restorer/impls/prediction-apy-v0-baseline/types.d.ts +4 -0
  221. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js +2 -0
  222. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +1 -0
  223. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +2 -0
  224. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +7 -0
  225. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
  226. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +39 -0
  227. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +186 -0
  228. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
  229. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.d.ts +9 -0
  230. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js +20 -0
  231. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
  232. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.d.ts +7 -0
  233. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js +2 -0
  234. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
  235. package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +29 -0
  236. package/dist/restorer/impls/prediction-v0-baseline/index.js +94 -0
  237. package/dist/restorer/impls/prediction-v0-baseline/index.js.map +1 -0
  238. package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +8 -0
  239. package/dist/restorer/impls/prediction-v0-baseline/strategy.js +41 -0
  240. package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +1 -0
  241. package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +7 -0
  242. package/dist/restorer/impls/prediction-v0-baseline/types.js +2 -0
  243. package/dist/restorer/impls/prediction-v0-baseline/types.js.map +1 -0
  244. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
  245. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js +66 -0
  246. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
  247. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
  248. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js +23 -0
  249. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
  250. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
  251. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js +13 -0
  252. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
  253. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +7 -0
  254. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +93 -0
  255. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
  256. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
  257. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js +20 -0
  258. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
  259. package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +33 -0
  260. package/dist/restorer/impls/prediction-v0-evaluator/index.js +208 -0
  261. package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +1 -0
  262. package/dist/restorer/impls/prediction-v0-evaluator/score.d.ts +8 -0
  263. package/dist/restorer/impls/prediction-v0-evaluator/score.js +15 -0
  264. package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +1 -0
  265. package/dist/restorer/impls/prediction-v0-evaluator/types.d.ts +7 -0
  266. package/dist/restorer/impls/prediction-v0-evaluator/types.js +2 -0
  267. package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +1 -0
  268. package/dist/restorer/types.d.ts +177 -0
  269. package/dist/restorer/types.js +7 -0
  270. package/dist/restorer/types.js.map +1 -0
  271. package/dist/store/store.d.ts +3 -1
  272. package/dist/store/store.js +3 -0
  273. package/dist/store/store.js.map +1 -1
  274. package/dist/types/desired-state.d.ts +53 -0
  275. package/dist/types/desired-state.js +20 -0
  276. package/dist/types/desired-state.js.map +1 -1
  277. package/dist/types/index.d.ts +4 -1
  278. package/dist/types/index.js +4 -1
  279. package/dist/types/index.js.map +1 -1
  280. package/dist/types/portfolio.d.ts +1000 -0
  281. package/dist/types/portfolio.js +168 -0
  282. package/dist/types/portfolio.js.map +1 -0
  283. package/dist/types/prediction-apy.d.ts +919 -0
  284. package/dist/types/prediction-apy.js +121 -0
  285. package/dist/types/prediction-apy.js.map +1 -0
  286. package/dist/types/prediction.d.ts +925 -0
  287. package/dist/types/prediction.js +140 -0
  288. package/dist/types/prediction.js.map +1 -0
  289. package/dist/venues/aave-v3/addresses.d.ts +6 -0
  290. package/dist/venues/aave-v3/addresses.js +19 -0
  291. package/dist/venues/aave-v3/addresses.js.map +1 -0
  292. package/dist/venues/aave-v3/client.d.ts +81 -0
  293. package/dist/venues/aave-v3/client.js +97 -0
  294. package/dist/venues/aave-v3/client.js.map +1 -0
  295. package/dist/venues/chainlink/client.d.ts +99 -0
  296. package/dist/venues/chainlink/client.js +130 -0
  297. package/dist/venues/chainlink/client.js.map +1 -0
  298. package/dist/venues/chainlink/feeds.d.ts +8 -0
  299. package/dist/venues/chainlink/feeds.js +9 -0
  300. package/dist/venues/chainlink/feeds.js.map +1 -0
  301. package/dist/venues/hyperliquid/account-value.d.ts +30 -0
  302. package/dist/venues/hyperliquid/account-value.js +30 -0
  303. package/dist/venues/hyperliquid/account-value.js.map +1 -0
  304. package/dist/venues/hyperliquid/client.d.ts +63 -0
  305. package/dist/venues/hyperliquid/client.js +135 -0
  306. package/dist/venues/hyperliquid/client.js.map +1 -0
  307. package/dist/venues/hyperliquid/grid.d.ts +36 -0
  308. package/dist/venues/hyperliquid/grid.js +61 -0
  309. package/dist/venues/hyperliquid/grid.js.map +1 -0
  310. package/dist/venues/hyperliquid/types.d.ts +81 -0
  311. package/dist/venues/hyperliquid/types.js +8 -0
  312. package/dist/venues/hyperliquid/types.js.map +1 -0
  313. package/dist/withdraw/run-withdraw-plan.js +2 -0
  314. package/dist/withdraw/run-withdraw-plan.js.map +1 -1
  315. package/docker-compose.yml +44 -0
  316. package/package.json +12 -1
  317. package/skills/jinn-operator/SKILL.md +85 -0
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared types for the portfolio-v0-evaluator.
3
+ *
4
+ * Single source of truth for Check, Verdict, and related types.
5
+ * Import from here instead of declaring locally in each check module.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/restorer/impls/portfolio-v0-evaluator/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,39 @@
1
+ import type { RestorerImpl, RestorationContext, RestorationOutput, ReadyStatus, EnableResult, IntentEnableMetadata } from '../../types.js';
2
+ export interface PredictionApyV0BaselineConfig {
3
+ rpcUrl?: string;
4
+ archiveRpcUrl?: string;
5
+ _testDeps?: {
6
+ twApyBpsOverWindow?: (args: {
7
+ windowEndTs: number;
8
+ twaWindowSeconds: number;
9
+ sampleCount: number;
10
+ pool: `0x${string}`;
11
+ reserve: `0x${string}`;
12
+ }) => Promise<{
13
+ twApyBps: number;
14
+ sampleCount: number;
15
+ }>;
16
+ };
17
+ }
18
+ export declare class PredictionApyV0BaselineImpl implements RestorerImpl {
19
+ private readonly config;
20
+ readonly name = "prediction-apy-v0-baseline";
21
+ readonly version = "1.0.0";
22
+ constructor(config?: PredictionApyV0BaselineConfig);
23
+ supports(ctx: {
24
+ kind: string;
25
+ type?: 'restoration' | 'evaluation';
26
+ }): boolean;
27
+ isReady(): Promise<ReadyStatus>;
28
+ enableMetadata(): IntentEnableMetadata;
29
+ onEnable(_args: Record<string, string | undefined>): Promise<EnableResult>;
30
+ canAttempt(intent: import('../../../types/desired-state.js').DesiredState): Promise<{
31
+ ok: false;
32
+ reason: string;
33
+ } | {
34
+ ok: true;
35
+ reason?: undefined;
36
+ }>;
37
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
38
+ }
39
+ export default PredictionApyV0BaselineImpl;
@@ -0,0 +1,98 @@
1
+ import { writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { createPublicClient, http } from 'viem';
4
+ import { base, baseSepolia, mainnet } from 'viem/chains';
5
+ import { PredictionApyV0IntentSchema } from '../../../types/prediction-apy.js';
6
+ import { twApyBpsOverWindow } from '../../../venues/aave-v3/client.js';
7
+ import { persistencePredict } from './strategy.js';
8
+ function chainForVenue(venue) {
9
+ if (venue === 'aave-v3-base-sepolia')
10
+ return { chain: baseSepolia, chainId: 84532 };
11
+ if (venue === 'aave-v3-mainnet')
12
+ return { chain: mainnet, chainId: 1 };
13
+ return { chain: base, chainId: 8453 };
14
+ }
15
+ export class PredictionApyV0BaselineImpl {
16
+ config;
17
+ name = 'prediction-apy-v0-baseline';
18
+ version = '1.0.0';
19
+ constructor(config = {}) {
20
+ this.config = config;
21
+ }
22
+ supports(ctx) {
23
+ return ctx.kind === 'prediction.apy.v0' && ctx.type !== 'evaluation';
24
+ }
25
+ async isReady() {
26
+ return { ready: true };
27
+ }
28
+ enableMetadata() {
29
+ return {
30
+ description: 'prediction.apy.v0 — submit APY prediction in bps from Aave v3 reserve data.',
31
+ };
32
+ }
33
+ async onEnable(_args) {
34
+ return { status: 'ready' };
35
+ }
36
+ async canAttempt(intent) {
37
+ const parsed = PredictionApyV0IntentSchema.safeParse(intent);
38
+ if (!parsed.success)
39
+ return { ok: false, reason: `Invalid prediction.apy.v0 intent: ${parsed.error.message}` };
40
+ if (Date.now() > parsed.data.window.endTs)
41
+ return { ok: false, reason: 'window already closed' };
42
+ return { ok: true };
43
+ }
44
+ async run(ctx) {
45
+ const parsed = PredictionApyV0IntentSchema.parse(ctx.intent);
46
+ const { venue, pool, reserve } = parsed.spec.oracle;
47
+ const { chain, chainId } = chainForVenue(venue);
48
+ const rpcUrl = this.config.rpcUrl ?? this.config.archiveRpcUrl;
49
+ let twApyBps;
50
+ let sampleCount;
51
+ if (this.config._testDeps?.twApyBpsOverWindow) {
52
+ const result = await this.config._testDeps.twApyBpsOverWindow({
53
+ pool: pool,
54
+ reserve: reserve,
55
+ windowEndTs: parsed.spec.question.resolveTs,
56
+ twaWindowSeconds: parsed.spec.metric.twaWindowSeconds,
57
+ sampleCount: parsed.spec.metric.sampleCount,
58
+ });
59
+ twApyBps = result.twApyBps;
60
+ sampleCount = result.sampleCount;
61
+ }
62
+ else {
63
+ const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
64
+ const actual = await publicClient.getChainId();
65
+ if (actual !== chainId) {
66
+ throw new Error(`oracle venue mismatch: ${venue} expects chain ${chainId}, got ${actual}`);
67
+ }
68
+ const result = await twApyBpsOverWindow({
69
+ publicClient,
70
+ pool: pool,
71
+ reserve: reserve,
72
+ windowEndTs: parsed.spec.question.resolveTs,
73
+ twaWindowSeconds: parsed.spec.metric.twaWindowSeconds,
74
+ sampleCount: parsed.spec.metric.sampleCount,
75
+ });
76
+ twApyBps = result.twApyBps;
77
+ sampleCount = result.sampleCount;
78
+ }
79
+ const prediction = persistencePredict(twApyBps);
80
+ const submittedAt = Date.now();
81
+ writeFileSync(join(ctx.workingDir, 'prediction-apy.json'), JSON.stringify({ ...prediction, submittedAt, twApyBps }, null, 2));
82
+ return {
83
+ venueRef: { name: 'aave-v3' },
84
+ gating: {
85
+ predictedBps: prediction.predictedBps,
86
+ submittedAt: String(submittedAt),
87
+ modelId: prediction.modelId,
88
+ },
89
+ informational: {
90
+ twApyBps,
91
+ sampleCount,
92
+ },
93
+ artifacts: [{ path: 'prediction-apy.json', role: 'prediction_submission' }],
94
+ };
95
+ }
96
+ }
97
+ export default PredictionApyV0BaselineImpl;
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-baseline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAUzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAA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aACZ;YACD,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;SAC5E,CAAC;IACJ,CAAC;CACF;AAED,eAAe,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { StrategyPrediction } from './types.js';
2
+ export declare function persistencePredict(twApyBps: number): StrategyPrediction;
@@ -0,0 +1,7 @@
1
+ export function persistencePredict(twApyBps) {
2
+ return {
3
+ predictedBps: String(Math.round(twApyBps)),
4
+ modelId: 'apy-persistence.v1',
5
+ };
6
+ }
7
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-baseline/strategy.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO,EAAE,oBAAoB;KAC9B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export interface StrategyPrediction {
2
+ predictedBps: string;
3
+ modelId: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-baseline/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import type { PredictionApyV0Intent } from '../../../types/prediction-apy.js';
2
+ export declare function deriveGroundTruthBps(intent: PredictionApyV0Intent, twApyBps: number): string;
@@ -0,0 +1,7 @@
1
+ export function deriveGroundTruthBps(intent, twApyBps) {
2
+ if (intent.spec.metric.type !== 'supply-apy-twa-bps') {
3
+ throw new Error(`unsupported metric: ${intent.spec.metric.type}`);
4
+ }
5
+ return String(Math.round(twApyBps));
6
+ }
7
+ //# sourceMappingURL=canonical-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-metrics.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,MAA6B,EAAE,QAAgB;IAClF,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { RestorerImpl, RestorationContext, RestorationOutput } from '../../types.js';
2
+ import type { DesiredState } from '../../../types/desired-state.js';
3
+ export interface PredictionApyV0EvaluatorConfig {
4
+ evaluatorPk: `0x${string}`;
5
+ evaluatorSafeAddress: `0x${string}`;
6
+ rpcUrl?: string;
7
+ archiveRpcUrl?: string;
8
+ _testDeps?: {
9
+ twApyBpsOverWindow?: (args: {
10
+ windowEndTs: number;
11
+ twaWindowSeconds: number;
12
+ sampleCount: number;
13
+ pool: `0x${string}`;
14
+ reserve: `0x${string}`;
15
+ }) => Promise<{
16
+ twApyBps: number;
17
+ sampleCount: number;
18
+ }>;
19
+ expectedIntentCid?: string;
20
+ };
21
+ }
22
+ export declare class PredictionApyV0Evaluator implements RestorerImpl {
23
+ private readonly config;
24
+ readonly name = "prediction-apy-v0-evaluator";
25
+ readonly version = "1.0.0";
26
+ constructor(config: PredictionApyV0EvaluatorConfig);
27
+ supports(ctx: {
28
+ kind: string;
29
+ type?: 'restoration' | 'evaluation';
30
+ }): boolean;
31
+ canAttempt(intent: DesiredState): Promise<{
32
+ ok: true;
33
+ } | {
34
+ ok: false;
35
+ reason: string;
36
+ }>;
37
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
38
+ }
39
+ export default PredictionApyV0Evaluator;
@@ -0,0 +1,186 @@
1
+ import { writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { createPublicClient, http, keccak256, stringToHex } from 'viem';
4
+ import { base, baseSepolia, mainnet } from 'viem/chains';
5
+ import { privateKeyToAccount } from 'viem/accounts';
6
+ import { PredictionApyV0IntentSchema, PredictionApySubmissionManifestSchema, } from '../../../types/prediction-apy.js';
7
+ import { twApyBpsOverWindow } from '../../../venues/aave-v3/client.js';
8
+ import { deriveGroundTruthBps } from './canonical-metrics.js';
9
+ import { computeScore } from './score.js';
10
+ function parseSubmissionManifest(manifestJson) {
11
+ const raw = JSON.parse(manifestJson);
12
+ const direct = PredictionApySubmissionManifestSchema.safeParse(raw);
13
+ if (direct.success)
14
+ return direct.data;
15
+ const normalized = {
16
+ schemaVersion: 'prediction.apy.v0.submission.v1',
17
+ generatedAt: raw['generatedAt'],
18
+ intent: raw['intent'],
19
+ restorer: raw['restorer'],
20
+ window: raw['window'],
21
+ prediction: {
22
+ predictedBps: String(raw['gating']?.['predictedBps'] ?? ''),
23
+ submittedAt: Number(raw['gating']?.['submittedAt'] ?? 0),
24
+ modelId: String(raw['gating']?.['modelId'] ?? ''),
25
+ },
26
+ signature: raw['signature'],
27
+ };
28
+ return PredictionApySubmissionManifestSchema.parse(normalized);
29
+ }
30
+ function chainForVenue(venue) {
31
+ if (venue === 'aave-v3-base-sepolia')
32
+ return { chain: baseSepolia, chainId: 84532 };
33
+ if (venue === 'aave-v3-mainnet')
34
+ return { chain: mainnet, chainId: 1 };
35
+ return { chain: base, chainId: 8453 };
36
+ }
37
+ export class PredictionApyV0Evaluator {
38
+ config;
39
+ name = 'prediction-apy-v0-evaluator';
40
+ version = '1.0.0';
41
+ constructor(config) {
42
+ this.config = config;
43
+ }
44
+ supports(ctx) {
45
+ return ctx.kind === 'prediction.apy.v0' && ctx.type === 'evaluation';
46
+ }
47
+ async canAttempt(intent) {
48
+ if (intent.spec?.kind !== 'prediction.apy.v0')
49
+ return { ok: false, reason: 'spec.kind is not prediction.apy.v0' };
50
+ if (intent.type !== 'evaluation')
51
+ return { ok: false, reason: 'type is not evaluation' };
52
+ if (typeof intent.context?.['restorationResult'] !== 'string') {
53
+ return { ok: false, reason: 'context.restorationResult required' };
54
+ }
55
+ return { ok: true };
56
+ }
57
+ async run(ctx) {
58
+ const intent = PredictionApyV0IntentSchema.parse(ctx.intent);
59
+ const submission = parseSubmissionManifest(ctx.intent.context['restorationResult']);
60
+ const checks = [];
61
+ const { venue, pool, reserve } = intent.spec.oracle;
62
+ const { chain, chainId } = chainForVenue(venue);
63
+ let twApyBps;
64
+ let sampleCount;
65
+ try {
66
+ if (this.config._testDeps?.twApyBpsOverWindow) {
67
+ const result = await this.config._testDeps.twApyBpsOverWindow({
68
+ pool: pool,
69
+ reserve: reserve,
70
+ windowEndTs: intent.spec.question.resolveTs,
71
+ twaWindowSeconds: intent.spec.metric.twaWindowSeconds,
72
+ sampleCount: intent.spec.metric.sampleCount,
73
+ });
74
+ twApyBps = result.twApyBps;
75
+ sampleCount = result.sampleCount;
76
+ }
77
+ else {
78
+ const rpcUrl = this.config.archiveRpcUrl ?? this.config.rpcUrl;
79
+ const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
80
+ const actual = await publicClient.getChainId();
81
+ if (actual !== chainId) {
82
+ throw new Error(`oracle venue mismatch: ${venue} expects chain ${chainId}, got ${actual}`);
83
+ }
84
+ const result = await twApyBpsOverWindow({
85
+ publicClient,
86
+ pool: pool,
87
+ reserve: reserve,
88
+ windowEndTs: intent.spec.question.resolveTs,
89
+ twaWindowSeconds: intent.spec.metric.twaWindowSeconds,
90
+ sampleCount: intent.spec.metric.sampleCount,
91
+ });
92
+ twApyBps = result.twApyBps;
93
+ sampleCount = result.sampleCount;
94
+ }
95
+ checks.push({ name: 'availability.aave_readable', status: 'PASS' });
96
+ }
97
+ catch (error) {
98
+ checks.push({ name: 'availability.aave_readable', status: 'FAIL', detail: String(error) });
99
+ twApyBps = 0;
100
+ sampleCount = 0;
101
+ }
102
+ if (submission.prediction.submittedAt >= intent.window.startTs &&
103
+ submission.prediction.submittedAt <= intent.window.endTs) {
104
+ checks.push({ name: 'eligibility.submission_within_window', status: 'PASS' });
105
+ }
106
+ else {
107
+ checks.push({ name: 'eligibility.submission_within_window', status: 'FAIL' });
108
+ }
109
+ if (submission.intent.cid === (this.config._testDeps?.expectedIntentCid ?? submission.intent.cid)) {
110
+ checks.push({ name: 'integrity.intent_ref', status: 'PASS' });
111
+ }
112
+ else {
113
+ checks.push({ name: 'integrity.intent_ref', status: 'FAIL' });
114
+ }
115
+ if (intent.spec.metric.toleranceBps > 0) {
116
+ checks.push({ name: 'spec.tolerance_positive', status: 'PASS' });
117
+ }
118
+ else {
119
+ checks.push({ name: 'spec.tolerance_positive', status: 'FAIL' });
120
+ }
121
+ const verdict = deriveVerdict(checks);
122
+ const groundTruthBps = deriveGroundTruthBps(intent, twApyBps);
123
+ const scored = computeScore(verdict, submission.prediction.predictedBps, groundTruthBps, intent.spec.metric.toleranceBps);
124
+ const evaluatorAccount = privateKeyToAccount(this.config.evaluatorPk);
125
+ const baseManifest = {
126
+ schemaVersion: 'prediction.apy.v0.verdict.v1',
127
+ generatedAt: Date.now(),
128
+ intent: submission.intent,
129
+ evaluator: { safeAddress: this.config.evaluatorSafeAddress, agentEoa: evaluatorAccount.address },
130
+ window: intent.window,
131
+ verdict,
132
+ score: scored.score,
133
+ scoreBasis: scored.scoreBasis,
134
+ scoreVersion: scored.scoreVersion,
135
+ oracleReading: {
136
+ pool: pool,
137
+ reserve: reserve,
138
+ sampleCount,
139
+ twaWindowSeconds: intent.spec.metric.twaWindowSeconds,
140
+ resolveTs: intent.spec.question.resolveTs,
141
+ },
142
+ claimed: {
143
+ predictedBps: submission.prediction.predictedBps,
144
+ submittedAt: submission.prediction.submittedAt,
145
+ modelId: submission.prediction.modelId,
146
+ submissionManifestCid: 'inline',
147
+ },
148
+ groundTruth: {
149
+ twApyBps: groundTruthBps,
150
+ errorBps: scored.errorBps,
151
+ },
152
+ checks,
153
+ };
154
+ const hash = keccak256(stringToHex(JSON.stringify(baseManifest)));
155
+ const sig = await evaluatorAccount.sign({ hash });
156
+ const verdictManifest = {
157
+ ...baseManifest,
158
+ signature: { algo: 'secp256k1', signer: evaluatorAccount.address, hash, sig },
159
+ };
160
+ writeFileSync(join(ctx.workingDir, 'verdict.json'), JSON.stringify(verdictManifest, null, 2));
161
+ return {
162
+ venueRef: { name: 'aave-v3' },
163
+ gating: {
164
+ verdict,
165
+ score: scored.score,
166
+ groundTruthBps,
167
+ errorBps: scored.errorBps,
168
+ },
169
+ informational: {
170
+ predictedBps: submission.prediction.predictedBps,
171
+ },
172
+ artifacts: [{ path: 'verdict.json', role: 'evaluation_verdict' }],
173
+ };
174
+ }
175
+ }
176
+ function deriveVerdict(checks) {
177
+ if (checks.some((c) => c.name.startsWith('availability.') && c.status !== 'PASS'))
178
+ return 'INDETERMINATE';
179
+ if (checks.some((c) => c.name.startsWith('eligibility.') && c.status === 'FAIL'))
180
+ return 'REJECTED';
181
+ if (checks.some((c) => (c.name.startsWith('integrity.') || c.name.startsWith('spec.')) && c.status === 'FAIL'))
182
+ return 'FAIL';
183
+ return 'PASS';
184
+ }
185
+ export default PredictionApyV0Evaluator;
186
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-evaluator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,mB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AC;QAE9F,OAAO;YACL,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YAC7B,MAAM,EAAE;gBACN,OAAO;gBACP,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,cAAc;gBACd,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B;YACD,aAAa,EAAE;gBACb,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC,YAAY;aACjD;YACD,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;SAClE,CAAC;IACJ,CAAC;CACF;AAED,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,eAAe,CAAC;IAC1G,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IACpG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9H,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Verdict } from './types.js';
2
+ export declare const SCORE_BASIS: "absolute-error-linear.v1";
3
+ export declare const SCORE_VERSION: "1";
4
+ export declare function computeScore(verdict: Verdict, predictedBps: string, groundTruthBps: string, toleranceBps: number): {
5
+ score: string;
6
+ scoreBasis: typeof SCORE_BASIS;
7
+ scoreVersion: typeof SCORE_VERSION;
8
+ errorBps: string;
9
+ };
@@ -0,0 +1,20 @@
1
+ export const SCORE_BASIS = 'absolute-error-linear.v1';
2
+ export const SCORE_VERSION = '1';
3
+ const SCALE = 1000000000000000000n;
4
+ export function computeScore(verdict, predictedBps, groundTruthBps, toleranceBps) {
5
+ const p = BigInt(predictedBps);
6
+ const g = BigInt(groundTruthBps);
7
+ const err = p > g ? p - g : g - p;
8
+ if (verdict !== 'PASS') {
9
+ return { score: '0', scoreBasis: SCORE_BASIS, scoreVersion: SCORE_VERSION, errorBps: err.toString() };
10
+ }
11
+ const tol = BigInt(toleranceBps);
12
+ if (tol <= 0n)
13
+ throw new Error('toleranceBps must be positive');
14
+ if (err >= tol) {
15
+ return { score: '0', scoreBasis: SCORE_BASIS, scoreVersion: SCORE_VERSION, errorBps: err.toString() };
16
+ }
17
+ const score = ((tol - err) * SCALE) / tol;
18
+ return { score: score.toString(), scoreBasis: SCORE_BASIS, scoreVersion: SCORE_VERSION, errorBps: err.toString() };
19
+ }
20
+ //# sourceMappingURL=score.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-evaluator/score.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,0BAAmC,CAAC;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,GAAY,CAAC;AAC1C,MAAM,KAAK,GAAG,oBAA0B,CAAC;AAEzC,MAAM,UAAU,YAAY,CAC1B,OAAgB,EAChB,YAAoB,EACpB,cAAsB,EACtB,YAAoB;IAEpB,MAAM,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/B,MAAM,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IACxG,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IACjC,IAAI,GAAG,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAChE,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IACxG,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC;IAC1C,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;AACrH,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type CheckStatus = 'PASS' | 'FAIL' | 'SKIP';
2
+ export interface Check {
3
+ name: string;
4
+ status: CheckStatus;
5
+ detail?: string | Record<string, unknown>;
6
+ }
7
+ export type Verdict = 'PASS' | 'FAIL' | 'REJECTED' | 'INDETERMINATE';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-evaluator/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import type { RestorerImpl, RestorationContext, RestorationOutput, ReadyStatus, EnableResult, IntentEnableMetadata } from '../../types.js';
2
+ import { type RoundReading } from '../../../venues/chainlink/client.js';
3
+ export interface PredictionV0BaselineConfig {
4
+ rpcUrl?: string;
5
+ _testDeps?: {
6
+ readChainlink?: (feed: `0x${string}`) => Promise<RoundReading>;
7
+ };
8
+ }
9
+ export declare class PredictionV0BaselineImpl implements RestorerImpl {
10
+ private readonly config;
11
+ readonly name = "prediction-v0-baseline";
12
+ readonly version = "1.0.0";
13
+ constructor(config?: PredictionV0BaselineConfig);
14
+ supports(ctx: {
15
+ kind: string;
16
+ type?: 'restoration' | 'evaluation';
17
+ }): boolean;
18
+ isReady(): Promise<ReadyStatus>;
19
+ enableMetadata(): IntentEnableMetadata;
20
+ onEnable(_args: Record<string, string | undefined>): Promise<EnableResult>;
21
+ canAttempt(intent: import('../../../types/desired-state.js').DesiredState): Promise<{
22
+ ok: true;
23
+ } | {
24
+ ok: false;
25
+ reason: string;
26
+ }>;
27
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
28
+ }
29
+ export default PredictionV0BaselineImpl;
@@ -0,0 +1,94 @@
1
+ /**
2
+ * prediction-v0-baseline — reference RestorerImpl for prediction.v0.
3
+ *
4
+ * §5 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import { writeFileSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ import { createPublicClient, http } from 'viem';
9
+ import { baseSepolia, base } from 'viem/chains';
10
+ import { PredictionV0IntentSchema } from '../../../types/prediction.js';
11
+ import { readChainlinkLatest, scaleToDecimal, } from '../../../venues/chainlink/client.js';
12
+ import { spotCarryPredict } from './strategy.js';
13
+ export class PredictionV0BaselineImpl {
14
+ config;
15
+ name = 'prediction-v0-baseline';
16
+ version = '1.0.0';
17
+ constructor(config = {}) {
18
+ this.config = config;
19
+ }
20
+ supports(ctx) {
21
+ return ctx.kind === 'prediction.v0' && ctx.type !== 'evaluation';
22
+ }
23
+ async isReady() {
24
+ // Zero external deps — prediction.v0 runs against on-chain oracles only.
25
+ return { ready: true };
26
+ }
27
+ enableMetadata() {
28
+ return {
29
+ description: 'prediction.v0 — submit probability predictions against on-chain price feeds. No external credentials required.',
30
+ };
31
+ }
32
+ async onEnable(_args) {
33
+ return { status: 'ready' };
34
+ }
35
+ async canAttempt(intent) {
36
+ const parsed = PredictionV0IntentSchema.safeParse(intent);
37
+ if (!parsed.success)
38
+ return { ok: false, reason: `Invalid prediction.v0 intent: ${parsed.error.message}` };
39
+ if (Date.now() > parsed.data.window.endTs) {
40
+ return { ok: false, reason: 'window already closed' };
41
+ }
42
+ return { ok: true };
43
+ }
44
+ async run(ctx) {
45
+ const { intent, workingDir, log } = ctx;
46
+ const parsed = PredictionV0IntentSchema.parse(intent);
47
+ const { feed, venue } = parsed.spec.oracle;
48
+ log({ level: 'info', msg: 'prediction-v0-baseline: starting', data: { feed, venue } });
49
+ // Read the feed (injection seam for tests)
50
+ const read = this.config._testDeps?.readChainlink;
51
+ let snapshot;
52
+ if (read) {
53
+ snapshot = await read(feed);
54
+ }
55
+ else {
56
+ const expectedChainId = venue === 'chainlink-base' ? 8453 : 84532;
57
+ const chain = venue === 'chainlink-base' ? base : baseSepolia;
58
+ const pc = createPublicClient({ chain, transport: http(this.config.rpcUrl) });
59
+ const actualChainId = await pc.getChainId();
60
+ if (actualChainId !== expectedChainId) {
61
+ throw new Error(`oracle venue mismatch: spec says ${venue} (chainId ${expectedChainId}) but RPC chainId is ${actualChainId}`);
62
+ }
63
+ snapshot = await readChainlinkLatest(feed, pc);
64
+ }
65
+ const currentPrice = scaleToDecimal(snapshot.answer, snapshot.decimals);
66
+ const { probability, modelId } = spotCarryPredict(parsed, currentPrice);
67
+ const submittedAt = Date.now();
68
+ const prediction = { probability, submittedAt, modelId };
69
+ writeFileSync(join(workingDir, 'prediction.json'), JSON.stringify(prediction, null, 2));
70
+ log({ level: 'info', msg: 'prediction-v0-baseline: submitted', data: { currentPrice, probability, modelId } });
71
+ return {
72
+ venueRef: { name: 'chainlink' },
73
+ gating: {
74
+ probability,
75
+ submittedAt: String(submittedAt),
76
+ modelId,
77
+ },
78
+ informational: {
79
+ oracleSnapshot: {
80
+ feed,
81
+ roundId: String(snapshot.roundId),
82
+ answer: String(snapshot.answer),
83
+ updatedAt: snapshot.updatedAt,
84
+ },
85
+ currentPrice,
86
+ },
87
+ artifacts: [
88
+ { path: 'prediction.json', role: 'prediction_submission' },
89
+ ],
90
+ };
91
+ }
92
+ }
93
+ export default PredictionV0BaselineImpl;
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-baseline/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAWhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,mBAAmB,EACnB,cAAc,GAEf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AASjD,MAAM,OAAO,wBAAwB;IAIN;IAHpB,IAAI,GAAG,wBAAwB,CAAC;IAChC,OAAO,GAAG,OAAO,CAAC;IAE3B,YAA6B,SAAqC,EAAE;QAAvC,WAAM,GAAN,MAAM,CAAiC;IAAG,CAAC;IAExE,QAAQ,CAAC,GAA0D;QACjE,OAAO,GAAG,CAAC,IAAI,KAAK,eAAe,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,OAAO;QACX,yEAAyE;QACzE,OAAO,EAAE,KAAK,EAAE,IAA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AI,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QAE/G,OAAO;YACL,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;YAC/B,MAAM,EAAE;gBACN,WAAW;gBACX,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;gBAChC,OAAO;aACR;YACD,aAAa,EAAE;gBACb,cAAc,EAAE;oBACd,IAAI;oBACJ,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;oBACjC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;oBAC/B,SAAS,EAAE,QAAQ,CAAC,SAAS;iBAC9B;gBACD,YAAY;aACb;YACD,SAAS,EAAE;gBACT,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,uBAAuB,EAAE;aAC3D;SACF,CAAC;IACJ,CAAC;CACF;AAED,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Spot-carry baseline — "current state tends to persist."
3
+ *
4
+ * §5.3 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import type { PredictionV0Intent } from '../../../types/prediction.js';
7
+ import type { StrategyPrediction } from './types.js';
8
+ export declare function spotCarryPredict(intent: PredictionV0Intent, currentPrice: string): StrategyPrediction;