@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.
- package/CONTRIBUTING.md +98 -0
- package/LICENSE +202 -0
- package/README.md +384 -0
- package/SECURITY.md +89 -0
- package/SETUP.md +235 -0
- package/artifacts/inscription/oracle-was-here-preview.png +0 -0
- package/artifacts/inscription/oracle-was-here.svg +1 -0
- package/artifacts/specialist-packs/oracle-full-crypto.json +273 -0
- package/bin/desk-server.mjs +438 -0
- package/bin/oracle-data-mcp.mjs +603 -0
- package/bin/oracle-init.mjs +423 -0
- package/bin/oracle-public-server.mjs +36 -0
- package/bin/oracle-route.mjs +254 -0
- package/bin/oracle-scan.mjs +192 -0
- package/docs/adding-a-chain.md +229 -0
- package/docs/architecture.md +135 -0
- package/docs/profiles.md +132 -0
- package/examples/add-a-chain.mjs +65 -0
- package/examples/research-a-token.mjs +70 -0
- package/package.json +90 -0
- package/profiles/_template/SOUL.md +47 -0
- package/profiles/_template/profile.json +22 -0
- package/profiles/bitcoin-agent/SOUL.md +31 -0
- package/profiles/bitcoin-agent/profile.json +32 -0
- package/profiles/hyperliquid-agent/SOUL.md +34 -0
- package/profiles/hyperliquid-agent/profile.json +37 -0
- package/profiles/oracle/SOUL.md +65 -0
- package/profiles/oracle/profile.json +35 -0
- package/profiles/polymarket-agent/SOUL.md +35 -0
- package/profiles/polymarket-agent/profile.json +34 -0
- package/profiles/profile.schema.json +90 -0
- package/profiles/protocol-builder/SOUL.md +50 -0
- package/profiles/protocol-builder/profile.json +37 -0
- package/profiles/robinhood-agent/SOUL.md +45 -0
- package/profiles/robinhood-agent/profile.json +39 -0
- package/profiles/solana-agent/SOUL.md +37 -0
- package/profiles/solana-agent/profile.json +37 -0
- package/profiles/stable-agent/SOUL.md +43 -0
- package/profiles/stable-agent/profile.json +37 -0
- package/public/oracle-console/app.js +272 -0
- package/public/oracle-console/bitcoin-wallets.js +206 -0
- package/public/oracle-console/index.html +91 -0
- package/public/oracle-console/styles.css +239 -0
- package/public/oracle-splash/index.html +931 -0
- package/scripts/build-inscription.py +230 -0
- package/scripts/check-test-count.mjs +105 -0
- package/scripts/e2e-hl-markets.mjs +21 -0
- package/scripts/e2e-hl-perps.mjs +48 -0
- package/scripts/e2e-hypercore-staking.mjs +128 -0
- package/scripts/e2e-solana-bitcoin.mjs +183 -0
- package/scripts/public-api-scan.mjs +23 -0
- package/scripts/secret-scan.mjs +181 -0
- package/scripts/verify-v3-venues.mjs +192 -0
- package/skills/oracle-best-execution/SKILL.md +127 -0
- package/skills/oracle-bitcoin/SKILL.md +53 -0
- package/skills/oracle-chain-graphs-telegram-cards/SKILL.md +59 -0
- package/skills/oracle-circuit-breaker/SKILL.md +51 -0
- package/skills/oracle-contract-research/SKILL.md +55 -0
- package/skills/oracle-desk/SKILL.md +58 -0
- package/skills/oracle-dex-launch/SKILL.md +38 -0
- package/skills/oracle-grants/SKILL.md +69 -0
- package/skills/oracle-hypercore-staking/SKILL.md +57 -0
- package/skills/oracle-hyperliquid/SKILL.md +56 -0
- package/skills/oracle-meme-token-sniper/SKILL.md +73 -0
- package/skills/oracle-nft-gacha-launch/SKILL.md +48 -0
- package/skills/oracle-nft-mint-gas-war/SKILL.md +63 -0
- package/skills/oracle-polymarket/SKILL.md +60 -0
- package/skills/oracle-protocol-builder/SKILL.md +38 -0
- package/skills/oracle-protocol-security/SKILL.md +60 -0
- package/skills/oracle-public-product/SKILL.md +44 -0
- package/skills/oracle-receipts/SKILL.md +52 -0
- package/skills/oracle-rfq-tokenized-assets/SKILL.md +69 -0
- package/skills/oracle-smart-wallet-scanner/SKILL.md +49 -0
- package/skills/oracle-solana/SKILL.md +65 -0
- package/skills/oracle-solana-nft/SKILL.md +54 -0
- package/skills/oracle-token-research/SKILL.md +67 -0
- package/src/agent-auth.mjs +191 -0
- package/src/approval-guard.mjs +282 -0
- package/src/attestation-secret.mjs +88 -0
- package/src/audit-log.mjs +196 -0
- package/src/auto-slippage.mjs +378 -0
- package/src/capability-posture.mjs +125 -0
- package/src/chains.mjs +62 -0
- package/src/data/catalog.mjs +495 -0
- package/src/data/desk-data.mjs +623 -0
- package/src/data/http.mjs +200 -0
- package/src/data/provider-endpoint.mjs +94 -0
- package/src/data/providers/aerodrome.mjs +244 -0
- package/src/data/providers/balancer.mjs +208 -0
- package/src/data/providers/bitcoin-esplora.mjs +230 -0
- package/src/data/providers/bitcoin-meta.mjs +378 -0
- package/src/data/providers/blockscout.mjs +14 -0
- package/src/data/providers/bridges.mjs +241 -0
- package/src/data/providers/cowswap.mjs +501 -0
- package/src/data/providers/curve.mjs +200 -0
- package/src/data/providers/defillama.mjs +88 -0
- package/src/data/providers/dexscreener.mjs +43 -0
- package/src/data/providers/evm-rpc.mjs +203 -0
- package/src/data/providers/geckoterminal.mjs +34 -0
- package/src/data/providers/gmx.mjs +495 -0
- package/src/data/providers/hl-info.mjs +102 -0
- package/src/data/providers/hl-markets.mjs +210 -0
- package/src/data/providers/hl-perps.mjs +382 -0
- package/src/data/providers/hl-staking.mjs +352 -0
- package/src/data/providers/hl-ws.mjs +119 -0
- package/src/data/providers/hyperevm-dex.mjs +49 -0
- package/src/data/providers/jupiter.mjs +182 -0
- package/src/data/providers/lifi.mjs +150 -0
- package/src/data/providers/magiceden-sol.mjs +355 -0
- package/src/data/providers/morpho.mjs +173 -0
- package/src/data/providers/odos.mjs +155 -0
- package/src/data/providers/oneinch.mjs +173 -0
- package/src/data/providers/opensea-multichain.mjs +136 -0
- package/src/data/providers/opensea-nft.mjs +99 -0
- package/src/data/providers/paraswap.mjs +117 -0
- package/src/data/providers/pendle.mjs +187 -0
- package/src/data/providers/poly-public.mjs +96 -0
- package/src/data/providers/poly-ws.mjs +103 -0
- package/src/data/providers/rh-agent.mjs +59 -0
- package/src/data/providers/satflow.mjs +336 -0
- package/src/data/providers/solana-rpc.mjs +186 -0
- package/src/data/providers/uniswap-v3.mjs +303 -0
- package/src/data/providers/zerox.mjs +166 -0
- package/src/data/public-api-scan.mjs +61 -0
- package/src/data/quote-placeholder.mjs +31 -0
- package/src/exact-integer.mjs +72 -0
- package/src/exec-policy.mjs +444 -0
- package/src/flags.mjs +15 -0
- package/src/fresh-window.mjs +76 -0
- package/src/gmx-attestation.mjs +175 -0
- package/src/index.mjs +50 -0
- package/src/nft-gas-war-guard.mjs +139 -0
- package/src/onboarding/agent-keys.mjs +157 -0
- package/src/onboarding/index.mjs +18 -0
- package/src/onboarding/tiers.mjs +139 -0
- package/src/oracle-env.mjs +38 -0
- package/src/protocol-execution.mjs +84 -0
- package/src/public-api/buzz-integration.mjs +256 -0
- package/src/public-api/connect-agent.mjs +397 -0
- package/src/public-api/grants.mjs +142 -0
- package/src/public-api/http.mjs +374 -0
- package/src/public-control/aa-adapter.mjs +402 -0
- package/src/public-control/build-registry.mjs +227 -0
- package/src/public-control/bundler-client.mjs +372 -0
- package/src/public-control/grant-indexer.mjs +296 -0
- package/src/public-control/policy-render.mjs +69 -0
- package/src/public-control/policy-schema.mjs +318 -0
- package/src/public-control/runtime-config.mjs +265 -0
- package/src/public-control/session-key-model.mjs +374 -0
- package/src/public-control/session-orchestrator.mjs +412 -0
- package/src/route-attestation.mjs +132 -0
- package/src/router/best-execution.mjs +221 -0
- package/src/router/index.mjs +185 -0
- package/src/router/prepare-bridge.mjs +288 -0
- package/src/router/prepare-route.mjs +341 -0
- package/src/router/proposal.mjs +311 -0
- package/src/router/risk-classifier.mjs +119 -0
- package/src/router/route-sources.mjs +292 -0
- package/src/scanner/chains.config.mjs +381 -0
- package/src/scanner/contract.mjs +270 -0
- package/src/scanner/evm-scanner.mjs +394 -0
- package/src/scanner/index.mjs +9 -0
- package/src/scanner/v2-venue.mjs +335 -0
- package/src/scanner/v3-venue.mjs +290 -0
- package/src/scopes.mjs +44 -0
- package/src/sell-simulation.mjs +167 -0
- package/src/token-transfer-guard.mjs +188 -0
- package/src/vault-attestation.mjs +145 -0
- package/src/venues.mjs +206 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-best-execution
|
|
3
|
+
description: Use whenever swapping or bridging. The rule that the highest quote is not the cheapest trade, and how to compare routes honestly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Best execution
|
|
7
|
+
|
|
8
|
+
The biggest `amountOut` is not the best route. Rank on **net received after gas and
|
|
9
|
+
fees**, every time.
|
|
10
|
+
|
|
11
|
+
## Get the comparison
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
best_swap_route { chainId, tokenIn, tokenOut, amountIn, decimalsIn, decimalsOut }
|
|
15
|
+
best_bridge_route { fromChainId, toChainId, tokenIn, tokenOut, amountIn }
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or at a shell:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
oracle-route swap base <tokenIn> <tokenOut> [amountIn]
|
|
22
|
+
oracle-route bridge arbitrum base [token] [amountIn]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Read the result properly
|
|
26
|
+
|
|
27
|
+
Report the winner **and** the runners-up. A user who sees only the winner cannot tell
|
|
28
|
+
whether it won by 0.01% or 3%, and that difference decides whether the route is worth
|
|
29
|
+
any extra risk.
|
|
30
|
+
|
|
31
|
+
Three fields carry most of the meaning:
|
|
32
|
+
|
|
33
|
+
- **`rankedOn`** — `net-of-cost` means gas was accounted for. `gross` means it was
|
|
34
|
+
**not**, and the ordering may be wrong.
|
|
35
|
+
- **`costAccounted`** (per route) — `false` means that route's gas is unknown. It is
|
|
36
|
+
ranked on gross, which **flatters it**. Say so.
|
|
37
|
+
- **`improvementBps`** — `null` means no honest spread exists, usually because the
|
|
38
|
+
top two routes measure cost differently. Do not invent one.
|
|
39
|
+
|
|
40
|
+
## What to say
|
|
41
|
+
|
|
42
|
+
Good: *"ParaSwap nets 1903.88 USDC after $0.01 gas. CoW is 0.01% behind but gasless,
|
|
43
|
+
so on a larger size it likely wins. LI.FI quotes competitively but $4.78 of gas puts
|
|
44
|
+
it 0.5% down."*
|
|
45
|
+
|
|
46
|
+
Bad: *"Best route: LI.FI, 1899 USDC."* — that is the gross number, and it lost.
|
|
47
|
+
|
|
48
|
+
## Preparing the winner
|
|
49
|
+
|
|
50
|
+
`prepare_best_route` compares, then builds the signable artifact for the winner:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
prepare_best_route { chainId, tokenIn, tokenOut, amountIn, taker }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`taker` must be the **real wallet that will sign**. Quoting is anonymous; preparing
|
|
57
|
+
is not. Placeholder and burn addresses are rejected.
|
|
58
|
+
|
|
59
|
+
**Check `artifactKind` before telling the user what to do.** They are not
|
|
60
|
+
interchangeable:
|
|
61
|
+
|
|
62
|
+
- `unsigned-transaction` (LI.FI, ParaSwap, 0x) — sign and **broadcast** it.
|
|
63
|
+
- `typed-data-order` (CoW) — sign the data and **submit it to the CoW API**. There is
|
|
64
|
+
nothing to broadcast. Signing authorizes a solver to settle on your behalf.
|
|
65
|
+
|
|
66
|
+
**Approval comes first, and the spender is not always the destination.** For CoW the
|
|
67
|
+
approval goes to the *vault relayer*, not the settlement contract — approving the
|
|
68
|
+
wrong one produces an order that silently never fills. Read `requiresApproval.spender`
|
|
69
|
+
rather than assuming it equals `destination`.
|
|
70
|
+
|
|
71
|
+
Some venues refuse to build calldata until the approval already exists on-chain
|
|
72
|
+
(ParaSwap does). That surfaces as `failureKind: "approval-required-first"`, which is
|
|
73
|
+
a real ordering constraint, not a bug: approve, then prepare again.
|
|
74
|
+
|
|
75
|
+
If the winner has no prepare path, the result names an `alternative`. Say that the
|
|
76
|
+
winner could not be prepared and what you used instead — do not silently substitute.
|
|
77
|
+
|
|
78
|
+
**Read `driftBps`.** Prepare re-quotes, so this is how far the route moved since the
|
|
79
|
+
comparison. A large negative number means the ranking may no longer hold.
|
|
80
|
+
|
|
81
|
+
## Preparing a bridge
|
|
82
|
+
|
|
83
|
+
`prepare_best_bridge_route` — same idea, different hazards.
|
|
84
|
+
|
|
85
|
+
**`transactions` is always a list.** Some routes need an approval *and* a deposit,
|
|
86
|
+
signed in order. Tell the user how many and that order matters: signing only the
|
|
87
|
+
first leaves funds approved but not bridged.
|
|
88
|
+
|
|
89
|
+
**Two chains are in play.** Every transaction executes on `fromChainId`; the value
|
|
90
|
+
lands on `toChainId`. Report both. A prepared artifact whose transaction chain does
|
|
91
|
+
not match the origin is refused outright (`failureKind: "chain-mismatch"`).
|
|
92
|
+
|
|
93
|
+
**Bridging is not atomic — say so unprompted.** The origin transaction confirming does
|
|
94
|
+
**not** mean funds arrived. Give the `durationSeconds` estimate and tell the user not
|
|
95
|
+
to re-send while pending. This is the single most common bridging panic, and silence
|
|
96
|
+
here causes double-sends.
|
|
97
|
+
|
|
98
|
+
**Across quotes but cannot be prepared** in this build. It often wins on gross because
|
|
99
|
+
its gas is unreported, so expect `failureKind: "no-prepare-path"` with an
|
|
100
|
+
`alternative`. Say the winner could not be prepared and name what you used instead.
|
|
101
|
+
|
|
102
|
+
## Rules
|
|
103
|
+
|
|
104
|
+
**One answer is not a comparison.** If only one source responded, say the route is
|
|
105
|
+
unbenchmarked. `sourcesAnswered` vs `sourcesTried` tells you.
|
|
106
|
+
|
|
107
|
+
**Never present an unknown cost as zero.** A route missing gas data is not free; it
|
|
108
|
+
is unmeasured. Those are different claims and only one of them is true.
|
|
109
|
+
|
|
110
|
+
**Duration is a cost on bridges.** A route saving $2 that takes 30 minutes is not
|
|
111
|
+
strictly better than one costing $2 more that lands in 20 seconds. Surface both and
|
|
112
|
+
let the user choose — do not silently pick for them.
|
|
113
|
+
|
|
114
|
+
**Quotes decay.** Every number here is from a past block. Re-quote immediately before
|
|
115
|
+
preparing, and never carry a minOut computed from a stale quote into a signature.
|
|
116
|
+
|
|
117
|
+
**A comparison is not an execution.** Ranking a route does not prepare, sign, or send
|
|
118
|
+
it. Preparing is a separate step, and signing belongs to the user.
|
|
119
|
+
|
|
120
|
+
## When sources fail
|
|
121
|
+
|
|
122
|
+
Aggregators go down, rate-limit, and get sunset (Odos sunset its public API in
|
|
123
|
+
July 2026). Individual failures are expected and appear in `failed[]`. Two things
|
|
124
|
+
follow:
|
|
125
|
+
|
|
126
|
+
1. Fewer sources means a weaker comparison. Report `sourcesAnswered`, do not hide it.
|
|
127
|
+
2. A failing source is **not** a bad price. Never rank it last — it did not answer.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-bitcoin
|
|
3
|
+
description: Use for Bitcoin L1, Ordinals/runes research, and inscription PSBT preparation. User-wallet signing only.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Bitcoin L1 / Ordinals
|
|
7
|
+
|
|
8
|
+
Bitcoin is a separate signing plane. Do not route it through EVM grants, EVM
|
|
9
|
+
signers, or EVM calldata policy.
|
|
10
|
+
|
|
11
|
+
## What this skill owns
|
|
12
|
+
|
|
13
|
+
- Bitcoin L1 reads through Esplora: tip height, fee rates, address state, UTXOs,
|
|
14
|
+
transactions.
|
|
15
|
+
- Ordinals/runes reads through the Bitcoin metaprotocol data providers.
|
|
16
|
+
- Satflow marketplace research and unsigned PSBT intents for ordinals/runes market
|
|
17
|
+
actions when a Satflow key is configured.
|
|
18
|
+
- Inscription planning and **PSBT preparation** for user-wallet signing.
|
|
19
|
+
|
|
20
|
+
## Inscription flow
|
|
21
|
+
|
|
22
|
+
Default path is self-custodial:
|
|
23
|
+
|
|
24
|
+
1. Collect the inscription content, MIME type, destination address, change address,
|
|
25
|
+
and fee preference.
|
|
26
|
+
2. Check Bitcoin health, fee rates, and the inscription body-size cap.
|
|
27
|
+
3. Estimate commit/reveal cost and UTXO needs before preparing.
|
|
28
|
+
4. Prepare commit/reveal PSBTs or unsigned artifacts.
|
|
29
|
+
5. User signs in Xverse, UniSat, Leather, OKX, Phantom, Magic Eden wallet, or a
|
|
30
|
+
compatible injected Bitcoin wallet.
|
|
31
|
+
6. Broadcast only after explicit user confirmation.
|
|
32
|
+
7. Report commit txid, reveal txid, inscription id when known, and mempool/receipt
|
|
33
|
+
status.
|
|
34
|
+
|
|
35
|
+
## Hard rules
|
|
36
|
+
|
|
37
|
+
- Never request or print a seed, WIF, xprv, or wallet export.
|
|
38
|
+
- Operator WIF/local signing is not part of the public default. If a deployment
|
|
39
|
+
has it, it must be separately armed and still explicit-confirm gated.
|
|
40
|
+
- Inscribe is Bitcoin L1 commit/reveal. Satflow is marketplace inventory/listing,
|
|
41
|
+
not the inscription path.
|
|
42
|
+
- Fee facts are live facts. Re-read fees immediately before prepare.
|
|
43
|
+
- If content exceeds the current cap, refuse and offer compression/splitting.
|
|
44
|
+
- Never claim an inscription landed without a real reveal txid or inscription id.
|
|
45
|
+
|
|
46
|
+
## Review checklist
|
|
47
|
+
|
|
48
|
+
- Content hash and byte length shown before signing.
|
|
49
|
+
- MIME type shown in plain language.
|
|
50
|
+
- Destination and change addresses displayed and user-confirmed.
|
|
51
|
+
- Fee rate, estimated vbytes, and worst-case spend shown.
|
|
52
|
+
- Commit/reveal sequence explained as non-atomic.
|
|
53
|
+
- Mempool status checked after broadcast.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-chain-graphs-telegram-cards
|
|
3
|
+
description: Render per-chain market graphs and Telegram cards for Oracle alerts, including meme launches, HL HIP-3/HIP-4, and Polymarket.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Oracle chain graphs + Telegram cards
|
|
7
|
+
|
|
8
|
+
Use when Oracle needs visual alerts: per-chain scanner cards, meme-token launch
|
|
9
|
+
cards, route-comparison charts, Hyperliquid HIP-3/HIP-4 cards, or Polymarket
|
|
10
|
+
cards.
|
|
11
|
+
|
|
12
|
+
## Surfaces
|
|
13
|
+
|
|
14
|
+
- Per-chain token charts: price, volume, liquidity, market cap, age, and venue.
|
|
15
|
+
- Launch/sniper cards: token, chain, pool, route readiness, sellability, smart-wallet
|
|
16
|
+
overlap, risk status, and prepared-ticket status.
|
|
17
|
+
- Hyperliquid HIP-3 builder-dex cards: dex, market, mark/oracle, funding, OI,
|
|
18
|
+
depth, liquidation/risk notes when account context is provided.
|
|
19
|
+
- Hyperliquid HIP-4 outcome-market cards: event/outcome, bid/ask, depth, edge,
|
|
20
|
+
held-position context when API keys/account reads are configured.
|
|
21
|
+
- Polymarket cards: event, market, Yes/No prices, volume, BBO, resolution-risk
|
|
22
|
+
notes, and prepared order intent only when user auth/API keys are configured.
|
|
23
|
+
|
|
24
|
+
## Data rules
|
|
25
|
+
|
|
26
|
+
- Public/keyless reads are allowed where the venue supports them.
|
|
27
|
+
- API-key surfaces activate only when the user self-hosts and provides their own
|
|
28
|
+
keys. Never ship DEMI keys or assume hosted secrets.
|
|
29
|
+
- A graph is evidence, not authorization. It can trigger a prepared ticket; it
|
|
30
|
+
must not bypass quote freshness, sell-sim, grant caps, or wallet signing.
|
|
31
|
+
- Every card states chain/venue and confidence. Unknown data stays `UNKNOWN`.
|
|
32
|
+
|
|
33
|
+
## Telegram card rules
|
|
34
|
+
|
|
35
|
+
- Send text card and graph as separate messages when the card is long.
|
|
36
|
+
- Avoid markdown traps: no unescaped underscore labels, avoid repeated `$` spans.
|
|
37
|
+
- Keep full contracts/mints visible; never truncate the only identifier.
|
|
38
|
+
- Chart rendering must soft-fail: card still sends if the image fails.
|
|
39
|
+
- No buy/sell buttons unless the recipient has a valid local grant/session.
|
|
40
|
+
|
|
41
|
+
## Graph schema
|
|
42
|
+
|
|
43
|
+
A graph payload should include:
|
|
44
|
+
|
|
45
|
+
- `chainId` / `cluster` / venue
|
|
46
|
+
- token/market id
|
|
47
|
+
- time window and candle interval
|
|
48
|
+
- price/volume/liquidity series or order-book snapshots
|
|
49
|
+
- source/provider and fetched timestamp
|
|
50
|
+
- warnings for stale, sparse, or degraded data
|
|
51
|
+
|
|
52
|
+
## HIP-3 / HIP-4 / Polymarket notes
|
|
53
|
+
|
|
54
|
+
- HIP-3 builder perps require Hyperliquid `perpDexs` and `metaAndAssetCtxs` with
|
|
55
|
+
`dex` selected; core `meta` does not include all builder-dex markets.
|
|
56
|
+
- HIP-4 outcome markets require the configured Hyperliquid/API-key path for user
|
|
57
|
+
account/order actions. Keyless cards can still show public market data.
|
|
58
|
+
- Polymarket public reads work keyless; trading/order placement needs the user's
|
|
59
|
+
CLOB auth/API setup and stays prepared/user-signed.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-circuit-breaker
|
|
3
|
+
description: Use before any repeated, automated, or loop-driven trading action. Mandatory guardrails so a broken loop cannot drain a wallet.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Circuit breakers
|
|
7
|
+
|
|
8
|
+
A loop that trades is a loop that can lose money at machine speed. Every automated
|
|
9
|
+
or repeated action needs these before it runs once.
|
|
10
|
+
|
|
11
|
+
## Mandatory guardrails
|
|
12
|
+
|
|
13
|
+
1. **Max iterations.** A hard count, not a "should converge" argument. Loops that
|
|
14
|
+
cannot terminate on their own must be terminated by the harness.
|
|
15
|
+
2. **Consecutive-failure stop.** N failures in a row halts the loop. A loop that
|
|
16
|
+
retries a failing action forever burns gas to no effect.
|
|
17
|
+
3. **Cumulative spend ceiling** across the whole run, not per action. Twenty
|
|
18
|
+
trades at the per-trade cap can exceed the intended risk by 20x.
|
|
19
|
+
4. **Cooldown between actions.** Prevents a same-block hammer and gives state time
|
|
20
|
+
to settle.
|
|
21
|
+
5. **Kill switch checked immediately before each action**, not once at start. A
|
|
22
|
+
switch read at t=0 and acted on at t=60s is stale.
|
|
23
|
+
6. **Halt on unexpected state.** Balance moved when it shouldn't have? Stop and
|
|
24
|
+
report. Do not "adapt."
|
|
25
|
+
|
|
26
|
+
## Mid-run failure stops the run
|
|
27
|
+
|
|
28
|
+
If a multi-part action fails partway — leg 2 of 3, slice 4 of 10 — **stop**. Do not
|
|
29
|
+
continue to the remaining legs. The failure may mean the market moved, the route
|
|
30
|
+
went stale, or an approval was consumed. Continuing turns one bad fill into
|
|
31
|
+
several.
|
|
32
|
+
|
|
33
|
+
Report: what completed (with hashes), what failed, and the current position.
|
|
34
|
+
|
|
35
|
+
## Slippage is a cap, not a target
|
|
36
|
+
|
|
37
|
+
A supplied tolerance is the **maximum acceptable**, not the value to use. Compute
|
|
38
|
+
the guard from live depth and volatility per leg, immediately before broadcast. If
|
|
39
|
+
the required guard exceeds the cap, **block** — requote or split. Never widen to
|
|
40
|
+
force a fill.
|
|
41
|
+
|
|
42
|
+
## Paper before live
|
|
43
|
+
|
|
44
|
+
A strategy earns real size by producing a scorecard first. Shadow it, measure the
|
|
45
|
+
markout, then size. "It looked right in backtest" is not a scorecard.
|
|
46
|
+
|
|
47
|
+
## The bright line
|
|
48
|
+
|
|
49
|
+
An automated loop may **prepare**. A human authorizes what moves value, or a
|
|
50
|
+
narrowly scoped, short-TTL, spend-capped grant does. There is no third option
|
|
51
|
+
where the loop decides it has permission.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-contract-research
|
|
3
|
+
description: Use when verifying a contract, router, factory, or venue address before trusting it with value.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Contract research
|
|
7
|
+
|
|
8
|
+
The destination allowlist is the highest-leverage control on this desk. Allowlisting
|
|
9
|
+
a spoofed router defeats every other protection. So verification is not a formality.
|
|
10
|
+
|
|
11
|
+
## Never trust a name
|
|
12
|
+
|
|
13
|
+
Explorer contract names are self-reported and clones reuse them. "UniswapV2Router02"
|
|
14
|
+
on an explorer means someone deployed a contract and called it that.
|
|
15
|
+
|
|
16
|
+
Verify instead:
|
|
17
|
+
|
|
18
|
+
1. **Bytecode exists** — `eth_getCode` must return real code. `0x` means nothing is
|
|
19
|
+
deployed. A 2-byte result is an empty stub.
|
|
20
|
+
2. **The protocol's own API or docs** name that address, on that chain, today. For
|
|
21
|
+
aggregators, query their API (e.g. LI.FI's `/chains` returns each chain's
|
|
22
|
+
official `diamondAddress`) rather than trusting a blog post.
|
|
23
|
+
3. **Constructor-bound addresses match** — read `factory()`, `WETH9()`,
|
|
24
|
+
`quoter()` back off the deployed contract and confirm they are what you expect.
|
|
25
|
+
4. **Per chain, separately.** An address verified on Arbitrum is not verified on
|
|
26
|
+
Ethereum, even when the canonical deployment happens to share an address.
|
|
27
|
+
|
|
28
|
+
Record **how and when** you verified, in a comment next to the entry. The audit
|
|
29
|
+
trail has to outlive your session.
|
|
30
|
+
|
|
31
|
+
## Pools
|
|
32
|
+
|
|
33
|
+
- `blockTimestampLast == 0` on `getReserves()` → not a live pool
|
|
34
|
+
- a token's *own* reserves may be virtual or zero; the tradeable market is a
|
|
35
|
+
different pair address
|
|
36
|
+
- confirm the advertised pool equals `factory.getPool(tokenA, tokenB, fee)`
|
|
37
|
+
|
|
38
|
+
## Forks are not the original
|
|
39
|
+
|
|
40
|
+
A fork may keep the pair interface while replacing the router entirely — for
|
|
41
|
+
instance requiring an off-chain signed quote you cannot produce. Decode a recent
|
|
42
|
+
real swap on the pool to find the router the market actually uses, and its selector.
|
|
43
|
+
|
|
44
|
+
A non-standard selector is a signal, not a curiosity.
|
|
45
|
+
|
|
46
|
+
## Approvals
|
|
47
|
+
|
|
48
|
+
Approve the **exact amount**. Never default to unlimited. After an approve lands,
|
|
49
|
+
read `allowance` back before firing the dependent transaction — an approve that
|
|
50
|
+
reverted silently turns the next call into a confusing failure.
|
|
51
|
+
|
|
52
|
+
## Fail closed
|
|
53
|
+
|
|
54
|
+
An unverified chain or venue stays blocked. That is a safe state, not a gap to route
|
|
55
|
+
around. Never allowlist an address you found only from a model's answer.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-desk
|
|
3
|
+
description: Use when routing a crypto request to the right lane or comparing options across chains. The router's operating manual.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Routing the desk
|
|
7
|
+
|
|
8
|
+
## Decide the lane before doing the work
|
|
9
|
+
|
|
10
|
+
Every crypto request gets a routing decision first:
|
|
11
|
+
|
|
12
|
+
1. **Which chain?** If the request names a token but not a chain, resolve the
|
|
13
|
+
token's home chain (DexScreener search via the data plane). Do not guess.
|
|
14
|
+
2. **Which lane owns it?** Venue lanes own their venue. Cross-chain comparison is
|
|
15
|
+
yours.
|
|
16
|
+
3. **Is it multi-chain?** Then quote each option yourself and synthesize. Do not
|
|
17
|
+
ask one venue lane to opine on another's chain.
|
|
18
|
+
4. **Still ambiguous?** Ask. A wrong chain assumption produces confidently wrong
|
|
19
|
+
numbers.
|
|
20
|
+
|
|
21
|
+
## Comparing chains honestly
|
|
22
|
+
|
|
23
|
+
When asked "which is cheaper" or "where should this go," the comparison must be
|
|
24
|
+
like-for-like:
|
|
25
|
+
|
|
26
|
+
- quote the **same notional** on each chain, not the same token amount
|
|
27
|
+
- include **gas in the same unit** (USD), because 0.001 ETH means different things
|
|
28
|
+
on mainnet and an L2
|
|
29
|
+
- include **bridge cost and time** if the funds aren't already there
|
|
30
|
+
- include **price impact at that size**, not the headline mid
|
|
31
|
+
- note **liquidity depth** — the cheapest venue at $100 is often not cheapest at
|
|
32
|
+
$50k
|
|
33
|
+
|
|
34
|
+
A comparison that ignores bridging or impact is a wrong answer dressed as a table.
|
|
35
|
+
|
|
36
|
+
## Capability tiers are not interchangeable
|
|
37
|
+
|
|
38
|
+
The data catalog labels each provider honestly. Respect the label:
|
|
39
|
+
|
|
40
|
+
| Tier | Means |
|
|
41
|
+
|---|---|
|
|
42
|
+
| `read-only` | data only, no execution claim whatsoever |
|
|
43
|
+
| `quote-only` | can price a route; no reviewed transaction builder |
|
|
44
|
+
| `prepare` | returns a policy-bound unsigned transaction |
|
|
45
|
+
| `intent` | returns a typed-data order to sign, not a transaction |
|
|
46
|
+
|
|
47
|
+
**API coverage ≠ execution support ≠ live trading support.** When asked "can we
|
|
48
|
+
trade X," answer with the tier, not yes/no.
|
|
49
|
+
|
|
50
|
+
## Don't invent chain facts
|
|
51
|
+
|
|
52
|
+
If a number did not come from a live read this turn, it is `unknown`. Not "roughly,"
|
|
53
|
+
not "typically." Stale liquidity and stale gas are how people get filled badly.
|
|
54
|
+
|
|
55
|
+
## Synthesis
|
|
56
|
+
|
|
57
|
+
Lead with the recommendation and the number. Then the two or three facts that drove
|
|
58
|
+
it. Then the risk that would change the answer. State confidence explicitly.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-dex-launch
|
|
3
|
+
description: Use when designing, reviewing, or preparing a DEX, AMM pool, router/factory fork, token launch, or liquidity bootstrap.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# DEX / AMM launch builder
|
|
7
|
+
|
|
8
|
+
Use this for launching or auditing token markets, DEX forks, pools, routing surfaces,
|
|
9
|
+
liquidity bootstraps, and trading UIs.
|
|
10
|
+
|
|
11
|
+
## Decide the AMM shape
|
|
12
|
+
|
|
13
|
+
- V2 constant-product pair: factory, router, WETH/wrapped native, fee, LP token.
|
|
14
|
+
- V3 concentrated liquidity: factory, position manager, quoter, router, fee tiers.
|
|
15
|
+
- Stable-swap / Curve-like: pool invariant, amplification, coins, router.
|
|
16
|
+
- Aggregator frontend: quote source, destination allowlist, minOut/deadline guard.
|
|
17
|
+
|
|
18
|
+
Do not bend one adapter to fit another shape. V2, V3, stable-swap, and aggregator
|
|
19
|
+
routes need separate encoders and tests.
|
|
20
|
+
|
|
21
|
+
## Launch checklist
|
|
22
|
+
|
|
23
|
+
1. Verify canonical factory/router/quoter addresses from official sources and live
|
|
24
|
+
functional probes, not names or codesize alone.
|
|
25
|
+
2. Define initial liquidity, starting price, lock/burn policy, and treasury role.
|
|
26
|
+
3. Simulate buy and sell, including exact approval path and round-trip retention.
|
|
27
|
+
4. Enforce nonzero minOut, short deadlines, route attestation, and gas caps.
|
|
28
|
+
5. Record per-chain provenance next to any allowlisted venue address.
|
|
29
|
+
6. Publish honest risk labels: `LIVE`, `UNKNOWN`, `UNAVAILABLE`, or `FAIL`.
|
|
30
|
+
|
|
31
|
+
## Hard rules
|
|
32
|
+
|
|
33
|
+
- No fake TVL, wash-volume instructions, hidden tax switches, or owner-only sell
|
|
34
|
+
bypasses.
|
|
35
|
+
- A successful buy quote does not prove sellability. Test exits first.
|
|
36
|
+
- A router on one chain is not verified on another chain.
|
|
37
|
+
- Preparing a pool deploy is not live support; live support needs simulation,
|
|
38
|
+
allowlist, signer-bound policy, receipt verification, and docs.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-grants
|
|
3
|
+
description: Use when arming, widening, or refusing an agent action against a bound grant. Defines what authorization means on this desk.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Bound grants
|
|
7
|
+
|
|
8
|
+
The model proposes. The owner authorizes. A grant is the authorization.
|
|
9
|
+
|
|
10
|
+
## What a grant is
|
|
11
|
+
|
|
12
|
+
An owner-signed permission with hard bounds:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
chain which chain id, exactly one
|
|
16
|
+
actions read:chain | simulate:tx | prepare:* — never "broadcast:*"
|
|
17
|
+
targets destination allowlist: the addresses value may reach
|
|
18
|
+
maxValueWei spend cap
|
|
19
|
+
maxGasWei gas cap — gas is separate money
|
|
20
|
+
expiresAt unix timestamp; after this the grant is dead
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Your reasoning is not authorization. A convincing argument that an action is safe
|
|
24
|
+
does not widen a grant.
|
|
25
|
+
|
|
26
|
+
## Refusing correctly
|
|
27
|
+
|
|
28
|
+
When an action falls outside the grant, refuse and **name the bound that broke**:
|
|
29
|
+
|
|
30
|
+
> Refused. Grant covers chain 8453; this route settles on 42161.
|
|
31
|
+
|
|
32
|
+
> Refused. Destination 0xabc… is not in the allowlist for chain 8453.
|
|
33
|
+
|
|
34
|
+
> Refused. Grant expired 14 minutes ago.
|
|
35
|
+
|
|
36
|
+
A vague "I can't do that" teaches the user nothing. A specific refusal tells them
|
|
37
|
+
exactly what to change if they still want it.
|
|
38
|
+
|
|
39
|
+
## Fail closed, always
|
|
40
|
+
|
|
41
|
+
An **empty** destination allowlist means *refuse everything*. It never means
|
|
42
|
+
"nothing specified, so allow anything." This inverts under pressure — a partially
|
|
43
|
+
configured chain looks like an unconfigured one. Fail closed.
|
|
44
|
+
|
|
45
|
+
## Gas is separate money
|
|
46
|
+
|
|
47
|
+
A grant that caps `value` but not gas is not capped. Unbounded gas limit or fee
|
|
48
|
+
drains the wallet outside the value ceiling. Both caps or neither is meaningful.
|
|
49
|
+
|
|
50
|
+
## The caps are not negotiable mid-task
|
|
51
|
+
|
|
52
|
+
If a route needs more slippage than the cap allows, the answer is block, requote,
|
|
53
|
+
or split — **not** widen. A cap that yields under pressure is decoration.
|
|
54
|
+
|
|
55
|
+
Likewise a hard ceiling stays hard: a caller-supplied tolerance is a *maximum*, not
|
|
56
|
+
the selected value.
|
|
57
|
+
|
|
58
|
+
## Authorization expires
|
|
59
|
+
|
|
60
|
+
Prefer short TTLs. A permanent broad grant is a hot wallet with extra steps. When a
|
|
61
|
+
grant lapses, the lane returns to reading — that is the system working, not a
|
|
62
|
+
regression to route around.
|
|
63
|
+
|
|
64
|
+
## Re-check at the boundary
|
|
65
|
+
|
|
66
|
+
Validate the grant at **sign time and broadcast time**, not only when the plan was
|
|
67
|
+
made. State can change between planning and execution: a stale check is not a
|
|
68
|
+
check. Reject a guard that is missing, stale, wrong-chain, wrong-venue, or
|
|
69
|
+
over-cap.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-hypercore-staking
|
|
3
|
+
description: Stake, delegate, undelegate, and unstake HYPE on Hyperliquid HyperCore. Prepare-only, user wallet signs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# HyperCore HYPE staking
|
|
7
|
+
|
|
8
|
+
Use when someone asks Oracle to stake HYPE, delegate to a validator, undelegate,
|
|
9
|
+
or unstake back to spot on Hyperliquid.
|
|
10
|
+
|
|
11
|
+
## The four moves, in order
|
|
12
|
+
|
|
13
|
+
HyperCore keeps staking in two buckets. Know which one holds the HYPE before
|
|
14
|
+
preparing anything.
|
|
15
|
+
|
|
16
|
+
| Move | Action | From -> To | Timing |
|
|
17
|
+
|---|---|---|---|
|
|
18
|
+
| Stake | `cDeposit` | spot -> staking balance | instant |
|
|
19
|
+
| Delegate | `tokenDelegate` isUndelegate=false | staking balance -> validator | 1 day validator lockup |
|
|
20
|
+
| Undelegate | `tokenDelegate` isUndelegate=true | validator -> staking balance | instant after lockup |
|
|
21
|
+
| Unstake | `cWithdraw` | staking balance -> spot | 7 day queue |
|
|
22
|
+
|
|
23
|
+
Staking balance earns nothing until it is delegated. "Unstake" almost always
|
|
24
|
+
means two steps: undelegate first, then withdraw.
|
|
25
|
+
|
|
26
|
+
## Flow
|
|
27
|
+
|
|
28
|
+
1. `desk.hl.staking.preflight(user)` - read delegated, undelegated, and pending
|
|
29
|
+
withdrawal balances plus the queue and lockup constants.
|
|
30
|
+
2. `desk.hl.staking.validators()` - pick a validator. Reject jailed ones and
|
|
31
|
+
surface commission before recommending.
|
|
32
|
+
3. Prepare exactly one move:
|
|
33
|
+
- `desk.hl.staking.prepareStake({ amountHype, maxHype })`
|
|
34
|
+
- `desk.hl.staking.prepareDelegate({ validator, amountHype, isUndelegate })`
|
|
35
|
+
- `desk.hl.staking.prepareUnstake({ amountHype })`
|
|
36
|
+
4. Hand back the EIP-712 typed data. The user's wallet signs and submits.
|
|
37
|
+
|
|
38
|
+
## Rules
|
|
39
|
+
|
|
40
|
+
- Amounts are decimal HYPE strings at 8 decimals. `hypeToWei("1.5")` is
|
|
41
|
+
`150000000`. More than 8 decimals is rejected, not rounded.
|
|
42
|
+
- `maxHype` is a hard cap checked before anything is built. No cap, no size
|
|
43
|
+
discipline on an agent path.
|
|
44
|
+
- Never claim a stake happened. These functions return `broadcastReady: false`
|
|
45
|
+
and `requiresUserSignature: true`. There is no submit function in the module
|
|
46
|
+
on purpose.
|
|
47
|
+
- Warn about the 7 day unstaking queue every time you prepare a `cWithdraw`.
|
|
48
|
+
The HYPE is illiquid for the whole queue.
|
|
49
|
+
- Warn about the 1 day validator lockup before a delegate.
|
|
50
|
+
- Check `undelegated` balance before preparing a withdraw. Withdrawing more than
|
|
51
|
+
the undelegated bucket fails on chain, and the failure costs the user a round
|
|
52
|
+
trip.
|
|
53
|
+
|
|
54
|
+
## Verification
|
|
55
|
+
|
|
56
|
+
`npm run e2e:hypercore-staking` hits live validator/delegator reads and asserts
|
|
57
|
+
every prepare path stays unsigned with caps enforced.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oracle-hyperliquid
|
|
3
|
+
description: Use for Hyperliquid perps and spot — funding, books, positions, liquidation distance via the public info API.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hyperliquid
|
|
7
|
+
|
|
8
|
+
Read through Oracle's data plane (`hl-info` provider, public `/info` endpoint). No
|
|
9
|
+
key required for reads.
|
|
10
|
+
|
|
11
|
+
## Ops worth knowing
|
|
12
|
+
|
|
13
|
+
| Need | Op |
|
|
14
|
+
|---|---|
|
|
15
|
+
| all mids | `allMids` |
|
|
16
|
+
| order book | `l2Book` |
|
|
17
|
+
| perp metadata + live ctx | `metaAndAssetCtxs` |
|
|
18
|
+
| spot metadata | `spotMeta` |
|
|
19
|
+
| account state | `clearinghouse` / `userState` |
|
|
20
|
+
| fills | `userFills` |
|
|
21
|
+
| open orders | `openOrders` / `frontendOpenOrders` |
|
|
22
|
+
| candles | `candleSnapshot` |
|
|
23
|
+
|
|
24
|
+
`metaAndAssetCtxs` is the efficient one: it returns funding, open interest, mark and
|
|
25
|
+
oracle price for every asset in a single call. Prefer it over per-asset loops.
|
|
26
|
+
|
|
27
|
+
## The three numbers that matter
|
|
28
|
+
|
|
29
|
+
**Liquidation distance.** In percent. Always state it for a leveraged position. A
|
|
30
|
+
"20x position" is really "a 5% adverse move ends this."
|
|
31
|
+
|
|
32
|
+
**Funding.** Annualize it. A position paying 40% annualized is losing steadily even
|
|
33
|
+
when directionally right. Funding flips sign — check the current rate, not the
|
|
34
|
+
average.
|
|
35
|
+
|
|
36
|
+
**Depth at your size.** The mid is a fiction for anything but the smallest clip.
|
|
37
|
+
Walk the `l2Book` to your notional and quote the real average fill.
|
|
38
|
+
|
|
39
|
+
## Mark vs oracle price
|
|
40
|
+
|
|
41
|
+
Liquidations reference the **oracle** price; PnL references the **mark**. They
|
|
42
|
+
diverge during volatility, which is exactly when it matters. Say which one you used.
|
|
43
|
+
|
|
44
|
+
## Spot and perps are different assets
|
|
45
|
+
|
|
46
|
+
The same ticker exists in both with different liquidity and no automatic
|
|
47
|
+
relationship. Never quote a perp book for a spot question.
|
|
48
|
+
|
|
49
|
+
## Hard rules
|
|
50
|
+
|
|
51
|
+
1. State liquidation distance for every leveraged position — not optional.
|
|
52
|
+
2. Annualize funding, always.
|
|
53
|
+
3. Quote fills from book depth, not the mid.
|
|
54
|
+
4. Never size to "max leverage" without naming the wipeout move.
|
|
55
|
+
5. You prepare; the user's wallet signs.
|
|
56
|
+
6. Receipts or it didn't happen.
|