@oracle-agent/oracle 0.1.0

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 (169) hide show
  1. package/CONTRIBUTING.md +98 -0
  2. package/LICENSE +202 -0
  3. package/README.md +384 -0
  4. package/SECURITY.md +89 -0
  5. package/SETUP.md +235 -0
  6. package/artifacts/inscription/oracle-was-here-preview.png +0 -0
  7. package/artifacts/inscription/oracle-was-here.svg +1 -0
  8. package/artifacts/specialist-packs/oracle-full-crypto.json +273 -0
  9. package/bin/desk-server.mjs +438 -0
  10. package/bin/oracle-data-mcp.mjs +603 -0
  11. package/bin/oracle-init.mjs +423 -0
  12. package/bin/oracle-public-server.mjs +36 -0
  13. package/bin/oracle-route.mjs +254 -0
  14. package/bin/oracle-scan.mjs +192 -0
  15. package/docs/adding-a-chain.md +229 -0
  16. package/docs/architecture.md +135 -0
  17. package/docs/profiles.md +132 -0
  18. package/examples/add-a-chain.mjs +65 -0
  19. package/examples/research-a-token.mjs +70 -0
  20. package/package.json +90 -0
  21. package/profiles/_template/SOUL.md +47 -0
  22. package/profiles/_template/profile.json +22 -0
  23. package/profiles/bitcoin-agent/SOUL.md +31 -0
  24. package/profiles/bitcoin-agent/profile.json +32 -0
  25. package/profiles/hyperliquid-agent/SOUL.md +34 -0
  26. package/profiles/hyperliquid-agent/profile.json +37 -0
  27. package/profiles/oracle/SOUL.md +65 -0
  28. package/profiles/oracle/profile.json +35 -0
  29. package/profiles/polymarket-agent/SOUL.md +35 -0
  30. package/profiles/polymarket-agent/profile.json +34 -0
  31. package/profiles/profile.schema.json +90 -0
  32. package/profiles/protocol-builder/SOUL.md +50 -0
  33. package/profiles/protocol-builder/profile.json +37 -0
  34. package/profiles/robinhood-agent/SOUL.md +45 -0
  35. package/profiles/robinhood-agent/profile.json +39 -0
  36. package/profiles/solana-agent/SOUL.md +37 -0
  37. package/profiles/solana-agent/profile.json +37 -0
  38. package/profiles/stable-agent/SOUL.md +43 -0
  39. package/profiles/stable-agent/profile.json +37 -0
  40. package/public/oracle-console/app.js +272 -0
  41. package/public/oracle-console/bitcoin-wallets.js +206 -0
  42. package/public/oracle-console/index.html +91 -0
  43. package/public/oracle-console/styles.css +239 -0
  44. package/public/oracle-splash/index.html +931 -0
  45. package/scripts/build-inscription.py +230 -0
  46. package/scripts/check-test-count.mjs +105 -0
  47. package/scripts/e2e-hl-markets.mjs +21 -0
  48. package/scripts/e2e-hl-perps.mjs +48 -0
  49. package/scripts/e2e-hypercore-staking.mjs +128 -0
  50. package/scripts/e2e-solana-bitcoin.mjs +183 -0
  51. package/scripts/public-api-scan.mjs +23 -0
  52. package/scripts/secret-scan.mjs +181 -0
  53. package/scripts/verify-v3-venues.mjs +192 -0
  54. package/skills/oracle-best-execution/SKILL.md +127 -0
  55. package/skills/oracle-bitcoin/SKILL.md +53 -0
  56. package/skills/oracle-chain-graphs-telegram-cards/SKILL.md +59 -0
  57. package/skills/oracle-circuit-breaker/SKILL.md +51 -0
  58. package/skills/oracle-contract-research/SKILL.md +55 -0
  59. package/skills/oracle-desk/SKILL.md +58 -0
  60. package/skills/oracle-dex-launch/SKILL.md +38 -0
  61. package/skills/oracle-grants/SKILL.md +69 -0
  62. package/skills/oracle-hypercore-staking/SKILL.md +57 -0
  63. package/skills/oracle-hyperliquid/SKILL.md +56 -0
  64. package/skills/oracle-meme-token-sniper/SKILL.md +73 -0
  65. package/skills/oracle-nft-gacha-launch/SKILL.md +48 -0
  66. package/skills/oracle-nft-mint-gas-war/SKILL.md +63 -0
  67. package/skills/oracle-polymarket/SKILL.md +60 -0
  68. package/skills/oracle-protocol-builder/SKILL.md +38 -0
  69. package/skills/oracle-protocol-security/SKILL.md +60 -0
  70. package/skills/oracle-public-product/SKILL.md +44 -0
  71. package/skills/oracle-receipts/SKILL.md +52 -0
  72. package/skills/oracle-rfq-tokenized-assets/SKILL.md +69 -0
  73. package/skills/oracle-smart-wallet-scanner/SKILL.md +49 -0
  74. package/skills/oracle-solana/SKILL.md +65 -0
  75. package/skills/oracle-solana-nft/SKILL.md +54 -0
  76. package/skills/oracle-token-research/SKILL.md +67 -0
  77. package/src/agent-auth.mjs +191 -0
  78. package/src/approval-guard.mjs +282 -0
  79. package/src/attestation-secret.mjs +88 -0
  80. package/src/audit-log.mjs +196 -0
  81. package/src/auto-slippage.mjs +378 -0
  82. package/src/capability-posture.mjs +125 -0
  83. package/src/chains.mjs +62 -0
  84. package/src/data/catalog.mjs +495 -0
  85. package/src/data/desk-data.mjs +623 -0
  86. package/src/data/http.mjs +200 -0
  87. package/src/data/provider-endpoint.mjs +94 -0
  88. package/src/data/providers/aerodrome.mjs +244 -0
  89. package/src/data/providers/balancer.mjs +208 -0
  90. package/src/data/providers/bitcoin-esplora.mjs +230 -0
  91. package/src/data/providers/bitcoin-meta.mjs +378 -0
  92. package/src/data/providers/blockscout.mjs +14 -0
  93. package/src/data/providers/bridges.mjs +241 -0
  94. package/src/data/providers/cowswap.mjs +501 -0
  95. package/src/data/providers/curve.mjs +200 -0
  96. package/src/data/providers/defillama.mjs +88 -0
  97. package/src/data/providers/dexscreener.mjs +43 -0
  98. package/src/data/providers/evm-rpc.mjs +203 -0
  99. package/src/data/providers/geckoterminal.mjs +34 -0
  100. package/src/data/providers/gmx.mjs +495 -0
  101. package/src/data/providers/hl-info.mjs +102 -0
  102. package/src/data/providers/hl-markets.mjs +210 -0
  103. package/src/data/providers/hl-perps.mjs +382 -0
  104. package/src/data/providers/hl-staking.mjs +352 -0
  105. package/src/data/providers/hl-ws.mjs +119 -0
  106. package/src/data/providers/hyperevm-dex.mjs +49 -0
  107. package/src/data/providers/jupiter.mjs +182 -0
  108. package/src/data/providers/lifi.mjs +150 -0
  109. package/src/data/providers/magiceden-sol.mjs +355 -0
  110. package/src/data/providers/morpho.mjs +173 -0
  111. package/src/data/providers/odos.mjs +155 -0
  112. package/src/data/providers/oneinch.mjs +173 -0
  113. package/src/data/providers/opensea-multichain.mjs +136 -0
  114. package/src/data/providers/opensea-nft.mjs +99 -0
  115. package/src/data/providers/paraswap.mjs +117 -0
  116. package/src/data/providers/pendle.mjs +187 -0
  117. package/src/data/providers/poly-public.mjs +96 -0
  118. package/src/data/providers/poly-ws.mjs +103 -0
  119. package/src/data/providers/rh-agent.mjs +59 -0
  120. package/src/data/providers/satflow.mjs +336 -0
  121. package/src/data/providers/solana-rpc.mjs +186 -0
  122. package/src/data/providers/uniswap-v3.mjs +303 -0
  123. package/src/data/providers/zerox.mjs +166 -0
  124. package/src/data/public-api-scan.mjs +61 -0
  125. package/src/data/quote-placeholder.mjs +31 -0
  126. package/src/exact-integer.mjs +72 -0
  127. package/src/exec-policy.mjs +444 -0
  128. package/src/flags.mjs +15 -0
  129. package/src/fresh-window.mjs +76 -0
  130. package/src/gmx-attestation.mjs +175 -0
  131. package/src/index.mjs +50 -0
  132. package/src/nft-gas-war-guard.mjs +139 -0
  133. package/src/onboarding/agent-keys.mjs +157 -0
  134. package/src/onboarding/index.mjs +18 -0
  135. package/src/onboarding/tiers.mjs +139 -0
  136. package/src/oracle-env.mjs +38 -0
  137. package/src/protocol-execution.mjs +84 -0
  138. package/src/public-api/buzz-integration.mjs +256 -0
  139. package/src/public-api/connect-agent.mjs +397 -0
  140. package/src/public-api/grants.mjs +142 -0
  141. package/src/public-api/http.mjs +374 -0
  142. package/src/public-control/aa-adapter.mjs +402 -0
  143. package/src/public-control/build-registry.mjs +227 -0
  144. package/src/public-control/bundler-client.mjs +372 -0
  145. package/src/public-control/grant-indexer.mjs +296 -0
  146. package/src/public-control/policy-render.mjs +69 -0
  147. package/src/public-control/policy-schema.mjs +318 -0
  148. package/src/public-control/runtime-config.mjs +265 -0
  149. package/src/public-control/session-key-model.mjs +374 -0
  150. package/src/public-control/session-orchestrator.mjs +412 -0
  151. package/src/route-attestation.mjs +132 -0
  152. package/src/router/best-execution.mjs +221 -0
  153. package/src/router/index.mjs +185 -0
  154. package/src/router/prepare-bridge.mjs +288 -0
  155. package/src/router/prepare-route.mjs +341 -0
  156. package/src/router/proposal.mjs +311 -0
  157. package/src/router/risk-classifier.mjs +119 -0
  158. package/src/router/route-sources.mjs +292 -0
  159. package/src/scanner/chains.config.mjs +381 -0
  160. package/src/scanner/contract.mjs +270 -0
  161. package/src/scanner/evm-scanner.mjs +394 -0
  162. package/src/scanner/index.mjs +9 -0
  163. package/src/scanner/v2-venue.mjs +335 -0
  164. package/src/scanner/v3-venue.mjs +290 -0
  165. package/src/scopes.mjs +44 -0
  166. package/src/sell-simulation.mjs +167 -0
  167. package/src/token-transfer-guard.mjs +188 -0
  168. package/src/vault-attestation.mjs +145 -0
  169. package/src/venues.mjs +206 -0
@@ -0,0 +1,98 @@
1
+ # Contributing to Oracle
2
+
3
+ Thanks for looking. Oracle is a control plane for money movement, so the review
4
+ bar is about safety and honesty more than style.
5
+
6
+ ## Before you start
7
+
8
+ Run the suite:
9
+
10
+ ```bash
11
+ npm install
12
+ npm test
13
+ ```
14
+
15
+ 391 tests, all green. If they aren't green on a clean checkout, that's a bug —
16
+ please report it.
17
+
18
+ ## The one rule that matters
19
+
20
+ **The public plane may never reach a private key or a house signer.**
21
+
22
+ Oracle ships the data plane, the policy plane, and the control plane. It does not
23
+ ship the executor. A PR that imports signer or keystore code into public modules
24
+ will fail `test/custody-boundary.test.mjs`, and the fix is not to edit the
25
+ forbidden list.
26
+
27
+ If your feature seems to need a key, restructure it: build an unsigned
28
+ transaction or a typed-data intent and hand it back to the caller to sign.
29
+
30
+ ## What we want
31
+
32
+ - **Real bugs, fixed at the class level.** Reproduce it, point at the line, fix
33
+ every sibling call path — not just the one that was reported.
34
+ - **New chains and providers.** This is the most useful contribution. See below.
35
+ - **Honest capability tiers.** If a provider can only quote, mark it
36
+ `quote-only`. Do not mark it `prepare` because a prepare function exists but
37
+ was never validated against a live route.
38
+ - **Tests that assert invariants**, not snapshots. `assert` that a minimum output
39
+ is enforced; don't freeze today's provider list into an equality check.
40
+ - **Guards recomputed before signing.** A quote-time check that isn't re-verified
41
+ at broadcast is decoration.
42
+
43
+ ## What gets rejected
44
+
45
+ - A signer, private key, or house-custody path in the public tree.
46
+ - A destination allowlist that defaults to permissive, or an empty allowlist read
47
+ as "allow all."
48
+ - Slippage widened past the 100 bps cap to make a trade go through. Block,
49
+ requote, or split instead.
50
+ - A claim of execution support with no live prepare/simulate evidence.
51
+ - Secrets in code, tests, fixtures, or docs — including a real wallet address as
52
+ a default `from` for quotes. Use `src/data/quote-placeholder.mjs`.
53
+ - "It worked when I ran it" with no test.
54
+
55
+ ## Adding a provider
56
+
57
+ 1. Create `src/data/providers/<name>.mjs`.
58
+ 2. Export a `health()` plus the ops you actually implement.
59
+ 3. Register it in `src/data/catalog.mjs` with truthful `chainIds`, `auth`, `ops`,
60
+ and `execution` tier.
61
+ 4. Add a test with a mocked transport. Do not require a live network for CI.
62
+ 5. If it needs a key, the health check must report
63
+ `{ ok: false, configured: false }` rather than throwing.
64
+
65
+ ## Adding a chain
66
+
67
+ 1. Add an entry to `CHAINS` in `src/chains.mjs` with its `rpcEnv` names.
68
+ 2. Verify every router/venue address on-chain (`eth_getCode` must return real
69
+ bytecode) before adding it to `src/venues.mjs`.
70
+ 3. Comment each venue addition with how you verified it and when.
71
+ 4. An unverified chain stays fail-closed. That is a safe state, not a gap.
72
+
73
+ Never allowlist a router you found only in a blog post or a model's answer. The
74
+ destination allowlist is the highest-leverage control in the system.
75
+
76
+ ## Commits and PRs
77
+
78
+ Conventional prefixes: `fix:`, `feat:`, `refactor:`, `docs:`, `test:`, `chore:`.
79
+
80
+ In the PR body, state:
81
+
82
+ - what broke or what's new
83
+ - how you verified it (paste the real command output)
84
+ - whether anything touches the custody boundary
85
+
86
+ Small, reviewable PRs get merged. A 3000-line PR mixing a refactor with a policy
87
+ change will sit.
88
+
89
+ ## Style
90
+
91
+ - ES modules, Node 20+, no build step.
92
+ - No new runtime dependency without a reason in the PR description.
93
+ - Comments explain *why*, not *what*. If a line encodes a hard-won fact — a
94
+ provider's unit quirk, a revert cause — say so, and say how it was learned.
95
+
96
+ ## License
97
+
98
+ Contributions are accepted under [Apache-2.0](LICENSE).
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Oracle Agent contributors
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,384 @@
1
+ # Oracle
2
+
3
+ **Prepare-only multichain agent control plane.** Policy-bounded intents; your wallet signs.
4
+
5
+ Specialist agent profiles, real protocol intents, self-custody by default,
6
+ receipts or it didn't happen.
7
+
8
+ Built for [Hermes](https://github.com/NousResearch/hermes-agent), the
9
+ open-source agent runtime from [Nous Research](https://nousresearch.com).
10
+
11
+ Oracle itself makes **no model calls and needs no API key**. It is the tool layer
12
+ an agent drives. Bring whatever model your Hermes is already using.
13
+
14
+ The **public package is prepare-only**: it never takes a private key and never
15
+ broadcasts. Owner-local signer modules may exist in a private tree for operator
16
+ deployments; they are excluded from the npm artifact and from every public
17
+ entrypoint.
18
+
19
+ ---
20
+
21
+ ## What Oracle is
22
+
23
+ Most "AI crypto agent" projects give a model a hot wallet and hope. Oracle does
24
+ the opposite: the model *proposes*, the owner *authorizes*, and the policy layer
25
+ decides what may even be asked.
26
+
27
+ Three properties define it:
28
+
29
+ 1. **Self-custody by default.** The public package never accepts your private
30
+ key. It builds unsigned transactions and typed-data intents; your wallet
31
+ signs them.
32
+ 2. **Bound grants.** A grant is a signed, scoped, expiring permission: max
33
+ value, chain, venue, destination allowlist, TTL. Oracle canonicalizes it,
34
+ renders it for review, and refuses to prepare anything outside it. Runtime
35
+ enforcement is the wallet's or smart account's job — this package never
36
+ signs, so it cannot be the thing that stops a transaction.
37
+ 3. **Receipts or it didn't happen.** A claim without a transaction hash, a
38
+ receipt, and a balance delta is not a result.
39
+
40
+ Default posture is `DISARMED`.
41
+
42
+ ## Why it's different
43
+
44
+ The differentiators are **policy, custody, and receipts** — not a smarter chat
45
+ loop.
46
+
47
+ | | Typical agent | Oracle |
48
+ |---|---|---|
49
+ | Custody | house wallet holds keys | user signs, no house custody |
50
+ | Authority | prompt-level "be careful" | signed grant: chain, spend, targets, TTL — enforced by your wallet, not by us |
51
+ | Destinations | whatever the model emits | reviewed per-chain allowlist, fail-closed |
52
+ | Slippage | fixed % | live guard recomputed per leg, hard 100 bps cap |
53
+ | Proof | model says "done" | hash + receipt + balance delta or it failed |
54
+ | Surface | swap only | swaps, bridges, perps, vaults, yield, NFTs, intents |
55
+
56
+ ## Architecture
57
+
58
+ ```
59
+ you
60
+ |
61
+ Task
62
+ |
63
+ oracle <- routes, never authorizes custody
64
+ |
65
+ +------+------+------+------+------+------+------+
66
+ | | | | | | | |
67
+ poly hyper robin solana bitcoin stable protocol
68
+ market liquid hood builder
69
+ ```
70
+
71
+ Each lane is a Hermes **profile**: its own system prompt, skills, memory, and
72
+ sessions. The `oracle` lane routes intent to the right specialist. Adding a lane
73
+ is adding a directory.
74
+
75
+ Three planes, and the boundary between them is mechanically enforced:
76
+
77
+ - **Data plane** (public) — read/quote across chains and protocols. No keys.
78
+ - **Policy plane** (public) — destination allowlists, slippage guards, route and
79
+ vault attestations, grant schema. Holds no keys; constrains what a signer may
80
+ be asked to do.
81
+ - **Exec plane** (owner-local source only) - signing and broadcast modules exist
82
+ for private operator deployments, but are excluded from every public package
83
+ entrypoint and from the npm artifact.
84
+
85
+ `test/custody-boundary.test.mjs` walks the import graph and fails if any public
86
+ module reaches wallet key material or a house signer. The split is a test, not a
87
+ promise.
88
+
89
+ ## Coverage
90
+
91
+ **11 EVM chains** built in: Ethereum, Optimism, BNB, Polygon, Stable, HyperEVM,
92
+ Abstract, Robinhood Chain, Base, Arbitrum, Avalanche. Plus Solana and Bitcoin L1
93
+ lanes. Solana covers Jupiter quote/prepare, SPL account research, live
94
+ simulation of the prepared swap, and Magic Eden NFT reads with unsigned
95
+ buy/list/mint tickets. Bitcoin covers Esplora fee/UTXO reads, Ordinals/runes
96
+ research, Satflow PSBT intents, and inscription PSBT preparation. Hyperliquid
97
+ adds HyperCore HYPE staking: validator reads plus EIP-712 stake, delegate,
98
+ undelegate, and unstake preparation. User wallets sign.
99
+
100
+ **Any other EVM chain is config, not code:**
101
+
102
+ ```js
103
+ import { registerCustomChain } from "@oracle-agent/oracle/scanner";
104
+
105
+ registerCustomChain({
106
+ key: "mychain",
107
+ chainId: 7777,
108
+ name: "My Chain",
109
+ rpcEnv: ["MYCHAIN_RPC_URL"],
110
+ nativeCurrency: { symbol: "MYC", decimals: 18 },
111
+ });
112
+ ```
113
+
114
+ That chain immediately has block reads, balances, on-chain token resolution, log
115
+ scanning, and structural risk checks. See
116
+ [`docs/adding-a-chain.md`](docs/adding-a-chain.md).
117
+
118
+ ```bash
119
+ oracle-scan chains # coverage matrix
120
+ oracle-scan token base 0x8335...2913 # on-chain identity
121
+ oracle-scan pools base 0x4200...0006 # pools ranked by liquidity
122
+ oracle-scan risk base 0x8335...2913 # structural checks + sell simulation
123
+ oracle-scan sell base 0x8335...2913 # round trip: can you actually exit?
124
+ ```
125
+
126
+ **7 of 11 chains ship verified venues** — Ethereum, Optimism, BNB, Polygon, Base,
127
+ Arbitrum, Avalanche — so they have all 10 capabilities including live quotes,
128
+ round-trip sell simulation, and unsigned swap preparation. The remaining four
129
+ (Stable, HyperEVM, Abstract, Robinhood) are at 7 and **fail-closed for routing
130
+ value** until someone verifies a venue: read and research work, moving money does
131
+ not. That is a safe default, not a gap.
132
+
133
+ Every venue address was verified **functionally, not by codesize** — a re-runnable
134
+ prober (`scripts/verify-v3-venues.mjs`) asks each candidate to price a pair with a
135
+ known answer. This matters: the canonical QuoterV2 address also has bytecode on
136
+ Base, but does not price that chain's pairs. A codesize check would have
137
+ allowlisted the wrong contract.
138
+
139
+ **30+ providers** in the read/quote catalog:
140
+
141
+ | Class | Providers |
142
+ |---|---|
143
+ | Chain / explorer | EVM JSON-RPC, Blockscout, Solana RPC, Bitcoin Esplora |
144
+ | Market data | DexScreener, GeckoTerminal, DeFiLlama |
145
+ | DEX / aggregator | Uniswap V3, Aerodrome, Curve, Balancer, LI.FI, ParaSwap, Odos, 0x, 1inch |
146
+ | Intents | CoW Protocol |
147
+ | Perps / lending / yield | GMX v2, Morpho, Pendle |
148
+ | Bridges | Across, Hop, Relay |
149
+ | Venues | Hyperliquid (incl. HyperCore staking), Polymarket |
150
+ | NFT | OpenSea, Satflow, Magic Eden (Solana) |
151
+
152
+ Every provider and every scanner capability declares an honest tier —
153
+ `read-only`, `quote-only`, `prepare`, or `intent`. **API coverage is not execution
154
+ support**, and the catalog says which is which. A chain with no verified venue is
155
+ fail-closed for routing value: read and research work, moving money does not. That
156
+ is a safe default, not a gap.
157
+
158
+ ## Capability pack
159
+
160
+ Oracle's default pack is deliberately broad but disarmed:
161
+
162
+ - **Trader** — best-execution route comparison, quote/prepare, simulation, and
163
+ receipt checks; no set-and-forget custody.
164
+ - **Builder** — protocol, NFT, gacha, DEX, and launchpad scaffolds with unsigned
165
+ deploy/admin transactions.
166
+ - **Analyzer** — token, contract, venue, portfolio, market, and risk research with
167
+ evidence labels.
168
+ - **On-chain scanner** — chain-config scanners for tokens, pools, launches,
169
+ risk, exits, and smart-wallet boards.
170
+ - **Meme-token sniper** — fast launch/liquidity monitoring across configured
171
+ chains, guarded by identity checks, sell-sim/reverse-route proof, caps, and
172
+ unsigned user-wallet tickets.
173
+ - **Per-chain graphs + Telegram cards** — charted scanner alerts, route cards,
174
+ meme-launch cards, Hyperliquid HIP-3/HIP-4 cards, and Polymarket cards. User
175
+ API-key actions activate only when self-hosted keys are configured.
176
+ - **NFT mint gas-war limits** — public mint bots enforce chain-bound gas caps,
177
+ per-unit fee caps, and optional priority-fee caps before returning unsigned
178
+ mint transactions. Import `validateNftMintGasWar` from the package root or
179
+ `@oracle-agent/oracle/nft-gas-war`.
180
+ - **Cross-chain RFQ + tokenized assets** — RFQ/intent venues are compared across
181
+ supported chains where configured, and tokenized Robinhood-style assets can be
182
+ bought only after exact contract, venue, route, and sellability checks.
183
+ - **Solana** — SPL accounts, Jupiter quotes, unsigned swap transactions, and
184
+ simulation.
185
+ - **Bitcoin** — L1 reads, Ordinals/runes, Satflow PSBT intents, and inscription
186
+ PSBT preparation.
187
+
188
+ Every money-moving path stays prepare/simulate first. Signing and broadcast are
189
+ wallet/grant actions, not model authority. Meme-token sniping defaults to fast
190
+ scan + prepared ticket; blind broadcast requires a separate capped local signer
191
+ loop and explicit opt-in. NFT mint bots must also honor gas-war caps before any
192
+ wallet-signable transaction is returned. RFQ and tokenized-asset routes are
193
+ capability-labeled per chain; unconfigured venues stay unavailable instead of faked.
194
+
195
+ ## Install
196
+
197
+ The npm package is intentionally unpublished while release hardening is in
198
+ progress. Install from source:
199
+
200
+ ```bash
201
+ git clone https://github.com/demi-hl/oracle.git
202
+ cd oracle
203
+ npm install
204
+ npm test
205
+ ```
206
+
207
+ **→ [SETUP.md](./SETUP.md) covers public data credentials and the separate
208
+ owner-local source lane.** The short version:
209
+
210
+ - Reads and quotes need **no keys**.
211
+ - The public package exposes no signer, key vault, or broadcast path.
212
+ - User wallets authorize prepared actions outside the public data plane.
213
+ - The source-only operator signer is not a public API and is not shipped to npm.
214
+
215
+ Run the read-only data plane:
216
+
217
+ ```bash
218
+ npm run start:data
219
+ npm run health
220
+ ```
221
+
222
+ Run the public console (wallet connect, grant editor, receipts):
223
+
224
+ ```bash
225
+ npm run start:public
226
+ # http://127.0.0.1:8799/
227
+ ```
228
+
229
+ ## Model providers
230
+
231
+ Oracle is a library. Drive it with Claude, GPT, Gemini, Grok, a local model, or
232
+ a plain script — the tools are ordinary functions plus an MCP server:
233
+
234
+ ```bash
235
+ npx oracle-data-mcp # works with any MCP client
236
+ ```
237
+
238
+ It is better under [Hermes](https://claude-code.nousresearch.com/docs), because
239
+ a trading stack is several workloads with opposite needs and **per-profile
240
+ routing** gives each its own model, tools, and key scope: cheap wide context for
241
+ research, a fast model for execution where latency is money, the strongest model
242
+ for risk review, something small for unattended crons. The research profile can
243
+ hold no signing key at all.
244
+
245
+ Oracle's own pre-release audit ran four model lineages — Grok 4.5, Opus 5,
246
+ Fable 5, GPT-5.6 — and **each found a critical bug the others missed**. One
247
+ model reviewing its own work would have shipped three of them.
248
+
249
+
250
+ ## Agent profiles
251
+
252
+ Oracle ships an installable 8-lane mesh for Hermes:
253
+
254
+ ```bash
255
+ oracle-init # dry run -- shows exactly what it would do
256
+ oracle-init --apply # create profiles, install SOULs + skills, wire MCP
257
+ ```
258
+
259
+ Lanes: `oracle` (router), `polymarket-agent`, `hyperliquid-agent`,
260
+ `robinhood-agent`, `solana-agent`, `bitcoin-agent`, `stable-agent`,
261
+ `protocol-builder`, plus `_template` for your own. Details in
262
+ [`docs/profiles.md`](docs/profiles.md).
263
+
264
+ Every lane installs **DISARMED**. No lane requests a broadcast or signing action —
265
+ only read, simulate, and prepare — and a test enforces that so widening custody
266
+ can't pass review quietly. An existing `SOUL.md` is never overwritten without
267
+ `--force`, and `--force` writes a timestamped backup first.
268
+
269
+ No Oracle account, no Oracle API key, no separate model billing. Oracle inherits
270
+ whichever provider your Hermes already uses (Anthropic, OpenAI, Nous Portal, xAI,
271
+ a local GGUF — anything Hermes supports).
272
+
273
+ **Why "built for Hermes" and not just "works anywhere":** Oracle's read plane is
274
+ an MCP server, so any MCP client can call it. But the *mesh* — per-lane memory,
275
+ skills, sessions, and separate model choice per specialist — is Hermes profile
276
+ machinery. You can use Oracle from any agent; you get the architecture in the
277
+ diagram above from Hermes.
278
+
279
+ ## Best-execution routing
280
+
281
+ The highest quote is not the cheapest swap. Oracle ranks on **net received after
282
+ gas and fees**, comparing every available source in parallel:
283
+
284
+ ```bash
285
+ oracle-route swap base 0x4200...0006 0x8335...2913 # WETH -> USDC
286
+ oracle-route bridge arbitrum base # ETH across chains
287
+ ```
288
+
289
+ ```
290
+ source net out gross cost
291
+ * paraswap 1,903.880867 1,903.893053 $0.01
292
+ cow 1,903.693798 1,903.693798 gasless (solver)
293
+ lifi 1,894.432632 1,899.20966 $4.78
294
+ ```
295
+
296
+ Sources: **LI.FI, CoW, ParaSwap, 0x, 1inch** for swaps · **LI.FI, Relay, Across**
297
+ for bridges. 0x and 1inch activate when their API key is present; the rest need
298
+ none.
299
+
300
+ Why net matters:
301
+
302
+ - **Gas is part of the price.** A route quoting 0.2% more but costing $14 more in
303
+ gas loses on a $500 swap and wins on a $50k one. The crossover depends on trade
304
+ size, so any fixed preference is wrong on one side of it.
305
+ - **Intents can beat AMMs.** CoW's solver pays the gas, so a slightly lower gross
306
+ quote often wins on net — the case naive ranking always gets backwards.
307
+ - **Sources disagree about what they mean.** Some report gas in USD, some in native
308
+ wei, some not at all. Oracle normalizes, and marks what was measured.
309
+
310
+ **Unknown cost is never scored as zero.** A source that does not report gas is
311
+ ranked on gross and flagged, because scoring an unknown as free is how the worst
312
+ route wins a comparison. When the top two routes measure cost differently, Oracle
313
+ quotes **no spread at all** rather than a number that compares different things.
314
+
315
+ Then prepare the winner in one step:
316
+
317
+ ```bash
318
+ oracle-route prepare base <tokenIn> <tokenOut> <yourWallet>
319
+ ```
320
+
321
+ You get back an **unsigned transaction** (LI.FI, ParaSwap, 0x) or **EIP-712 typed
322
+ data** for an off-chain order (CoW). `artifactKind` says which — they need different
323
+ wallet actions, and one is not broadcast at all. Prepare **re-quotes** and reports
324
+ `driftBps` against the comparison, because a minimum computed from a stale quote is
325
+ not a minimum.
326
+
327
+ Bridges prepare too:
328
+
329
+ ```bash
330
+ oracle-route prepare-bridge arbitrum base <yourWallet>
331
+ ```
332
+
333
+ Bridge artifacts are always a **list** of transactions — some routes need an approval
334
+ and a deposit signed in order, and signing only the first leaves funds approved but
335
+ not bridged. Both chains are reported, and a transaction whose chain does not match
336
+ the origin is refused. Oracle states plainly that **bridging is not atomic**: the
337
+ origin transaction confirming does not mean funds arrived.
338
+
339
+ Routing never signs. `taker` must be the real wallet; placeholder addresses are
340
+ rejected, since quoting is anonymous but preparing is not. Signing happens in
341
+ the user's wallet or in a separately operated source-only execution lane.
342
+
343
+ Individual source failures degrade the comparison by one source instead of breaking
344
+ it — verified in practice when Odos sunset their public API mid-development
345
+ (HTTP 410); the router kept ranking and the provider was marked `unavailable`.
346
+
347
+ ## Examples
348
+
349
+ ```bash
350
+ node examples/add-a-chain.mjs # register an unseen chain, no code
351
+ node examples/research-a-token.mjs # honest token research on live data
352
+ ```
353
+
354
+ ## MCP
355
+
356
+ Oracle exposes its read plane over the Model Context Protocol, so any MCP client
357
+ (Hermes, Claude Code, others) can use it:
358
+
359
+ ```bash
360
+ oracle-data-mcp
361
+ ```
362
+
363
+ ## Security
364
+
365
+ - Oracle never receives private keys.
366
+ - The router can propose, simulate, explain, and draft. It cannot authorize.
367
+ - Public modules may not import signer or executor code (enforced by test).
368
+ - Destination allowlists are per-chain and fail-closed: an empty allowlist
369
+ refuses everything rather than allowing everything.
370
+ - Report vulnerabilities per [SECURITY.md](SECURITY.md). Please do not open a
371
+ public issue for a live exploit.
372
+
373
+ ## What Oracle is not
374
+
375
+ - Not an autonomous trader. There is no "set and forget."
376
+ - Not custodial. If a design needs your key on our server, that design is wrong.
377
+ - Not a guarantee. Crypto execution carries real risk; read the code you run.
378
+
379
+ ## License
380
+
381
+ [Apache-2.0](LICENSE).
382
+
383
+ The code is open source. The **Oracle** name and marks are reserved; please
384
+ don't imply endorsement by an official deployment when shipping a fork.