@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,381 @@
|
|
|
1
|
+
// Built-in chain configs.
|
|
2
|
+
//
|
|
3
|
+
// This file is the "adding a chain is data" claim made concrete. Each entry is pure
|
|
4
|
+
// configuration -- no chain-specific code -- and `defineEvmScanner` turns it into a
|
|
5
|
+
// working scanner.
|
|
6
|
+
//
|
|
7
|
+
// To add a chain: append an entry, set the RPC env var, done. If you also want
|
|
8
|
+
// routing on it, add verified venues (see CONTRIBUTING for the verification rule:
|
|
9
|
+
// bytecode check plus the protocol's own source, recorded per chain).
|
|
10
|
+
//
|
|
11
|
+
// Venues are intentionally EMPTY here. An address is only useful with provenance,
|
|
12
|
+
// and provenance has to be established per chain by whoever adds it. An empty venue
|
|
13
|
+
// list means the chain is read/research-capable and fail-closed for routing, which
|
|
14
|
+
// is the correct default rather than a gap.
|
|
15
|
+
|
|
16
|
+
import { defineEvmScanner } from "./evm-scanner.mjs";
|
|
17
|
+
import { registerScanner } from "./contract.mjs";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `dexscreenerSlug` is DexScreener's own chain identifier, which is not the chain id
|
|
21
|
+
* and not always the obvious name. Omit it when unknown -- pool discovery then
|
|
22
|
+
* reports UNAVAILABLE instead of silently returning another chain's pools.
|
|
23
|
+
*/
|
|
24
|
+
export const CHAIN_CONFIGS = Object.freeze([
|
|
25
|
+
{
|
|
26
|
+
key: "ethereum",
|
|
27
|
+
chainId: 1,
|
|
28
|
+
name: "Ethereum",
|
|
29
|
+
rpcEnv: ["ETH_RPC_URL", "ETHEREUM_RPC_URL", "MAINNET_RPC_URL"],
|
|
30
|
+
nativeCurrency: { symbol: "ETH", decimals: 18 },
|
|
31
|
+
explorer: "https://etherscan.io",
|
|
32
|
+
dexscreenerSlug: "ethereum",
|
|
33
|
+
venueKind: "uniswap-v3",
|
|
34
|
+
wrappedNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
35
|
+
venues: [
|
|
36
|
+
{
|
|
37
|
+
kind: "quoter",
|
|
38
|
+
address: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
39
|
+
label: "Uniswap V3 QuoterV2",
|
|
40
|
+
verified: {
|
|
41
|
+
method:
|
|
42
|
+
"functional probe, not a codesize check: quoteExactInputSingle returned a " +
|
|
43
|
+
"live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair " +
|
|
44
|
+
"IS a working V3 quoter",
|
|
45
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
46
|
+
date: "2026-07-30",
|
|
47
|
+
chainId: 1,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
kind: "router",
|
|
52
|
+
address: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
|
|
53
|
+
label: "Uniswap V3 SwapRouter02",
|
|
54
|
+
verified: {
|
|
55
|
+
method:
|
|
56
|
+
"eth_getCode returned real bytecode on this chain and the paired quoter " +
|
|
57
|
+
"at the same deployment passed a live functional quote",
|
|
58
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
59
|
+
date: "2026-07-30",
|
|
60
|
+
chainId: 1,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: "optimism",
|
|
67
|
+
chainId: 10,
|
|
68
|
+
name: "OP Mainnet",
|
|
69
|
+
rpcEnv: ["OPTIMISM_RPC_URL", "OP_RPC_URL"],
|
|
70
|
+
nativeCurrency: { symbol: "ETH", decimals: 18 },
|
|
71
|
+
explorer: "https://optimistic.etherscan.io",
|
|
72
|
+
dexscreenerSlug: "optimism",
|
|
73
|
+
venueKind: "uniswap-v3",
|
|
74
|
+
wrappedNative: "0x4200000000000000000000000000000000000006",
|
|
75
|
+
venues: [
|
|
76
|
+
{
|
|
77
|
+
kind: "quoter",
|
|
78
|
+
address: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
79
|
+
label: "Uniswap V3 QuoterV2",
|
|
80
|
+
verified: {
|
|
81
|
+
method:
|
|
82
|
+
"functional probe, not a codesize check: quoteExactInputSingle returned a " +
|
|
83
|
+
"live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair " +
|
|
84
|
+
"IS a working V3 quoter",
|
|
85
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
86
|
+
date: "2026-07-30",
|
|
87
|
+
chainId: 10,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
kind: "router",
|
|
92
|
+
address: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
|
|
93
|
+
label: "Uniswap V3 SwapRouter02",
|
|
94
|
+
verified: {
|
|
95
|
+
method:
|
|
96
|
+
"eth_getCode returned real bytecode on this chain and the paired quoter " +
|
|
97
|
+
"at the same deployment passed a live functional quote",
|
|
98
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
99
|
+
date: "2026-07-30",
|
|
100
|
+
chainId: 10,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
key: "bsc",
|
|
107
|
+
chainId: 56,
|
|
108
|
+
name: "BNB Smart Chain",
|
|
109
|
+
rpcEnv: ["BSC_RPC_URL", "BNB_RPC_URL"],
|
|
110
|
+
nativeCurrency: { symbol: "BNB", decimals: 18 },
|
|
111
|
+
explorer: "https://bscscan.com",
|
|
112
|
+
dexscreenerSlug: "bsc",
|
|
113
|
+
venueKind: "uniswap-v3",
|
|
114
|
+
wrappedNative: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
|
|
115
|
+
venues: [
|
|
116
|
+
{
|
|
117
|
+
kind: "quoter",
|
|
118
|
+
address: "0x78D78E420Da98ad378D7799bE8f4AF69033EB077",
|
|
119
|
+
label: "Uniswap V3 QuoterV2",
|
|
120
|
+
verified: {
|
|
121
|
+
method:
|
|
122
|
+
"functional probe, not a codesize check: quoteExactInputSingle returned a " +
|
|
123
|
+
"live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair " +
|
|
124
|
+
"IS a working V3 quoter",
|
|
125
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
126
|
+
date: "2026-07-30",
|
|
127
|
+
chainId: 56,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
kind: "router",
|
|
132
|
+
address: "0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",
|
|
133
|
+
label: "Uniswap V3 SwapRouter02",
|
|
134
|
+
verified: {
|
|
135
|
+
method:
|
|
136
|
+
"eth_getCode returned real bytecode on this chain and the paired quoter " +
|
|
137
|
+
"at the same deployment passed a live functional quote",
|
|
138
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
139
|
+
date: "2026-07-30",
|
|
140
|
+
chainId: 56,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
key: "polygon",
|
|
147
|
+
chainId: 137,
|
|
148
|
+
name: "Polygon",
|
|
149
|
+
rpcEnv: ["POLYGON_RPC_URL", "POLYGON_RPC"],
|
|
150
|
+
nativeCurrency: { symbol: "POL", decimals: 18 },
|
|
151
|
+
explorer: "https://polygonscan.com",
|
|
152
|
+
dexscreenerSlug: "polygon",
|
|
153
|
+
venueKind: "uniswap-v3",
|
|
154
|
+
wrappedNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
155
|
+
venues: [
|
|
156
|
+
{
|
|
157
|
+
kind: "quoter",
|
|
158
|
+
address: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
159
|
+
label: "Uniswap V3 QuoterV2",
|
|
160
|
+
verified: {
|
|
161
|
+
method:
|
|
162
|
+
"functional probe, not a codesize check: quoteExactInputSingle returned a " +
|
|
163
|
+
"live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair " +
|
|
164
|
+
"IS a working V3 quoter",
|
|
165
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
166
|
+
date: "2026-07-30",
|
|
167
|
+
chainId: 137,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
kind: "router",
|
|
172
|
+
address: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
|
|
173
|
+
label: "Uniswap V3 SwapRouter02",
|
|
174
|
+
verified: {
|
|
175
|
+
method:
|
|
176
|
+
"eth_getCode returned real bytecode on this chain and the paired quoter " +
|
|
177
|
+
"at the same deployment passed a live functional quote",
|
|
178
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
179
|
+
date: "2026-07-30",
|
|
180
|
+
chainId: 137,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
key: "stable",
|
|
187
|
+
chainId: 988,
|
|
188
|
+
name: "Stable Mainnet",
|
|
189
|
+
rpcEnv: ["STABLE_RPC_URL", "STABLE_RPC"],
|
|
190
|
+
// The stablecoin IS the gas token here, 18 decimals native. The same balance
|
|
191
|
+
// also appears as a 6-decimal ERC-20 mirror -- it is ONE balance, never summed.
|
|
192
|
+
nativeCurrency: { symbol: "USDT0", decimals: 18 },
|
|
193
|
+
venues: [],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
key: "hyperevm",
|
|
197
|
+
chainId: 999,
|
|
198
|
+
name: "HyperEVM",
|
|
199
|
+
rpcEnv: ["HYPEREVM_RPC_URL", "HYPER_EVM_RPC"],
|
|
200
|
+
nativeCurrency: { symbol: "HYPE", decimals: 18 },
|
|
201
|
+
dexscreenerSlug: "hyperevm",
|
|
202
|
+
venues: [],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
key: "abstract",
|
|
206
|
+
chainId: 2741,
|
|
207
|
+
name: "Abstract",
|
|
208
|
+
rpcEnv: ["ABSTRACT_RPC_URL", "ABS_RPC_URL"],
|
|
209
|
+
nativeCurrency: { symbol: "ETH", decimals: 18 },
|
|
210
|
+
venues: [],
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
key: "robinhood",
|
|
214
|
+
chainId: 4663,
|
|
215
|
+
name: "Robinhood Chain",
|
|
216
|
+
rpcEnv: ["RH_CHAIN_RPC", "ROBINHOOD_RPC_URL"],
|
|
217
|
+
nativeCurrency: { symbol: "ETH", decimals: 18 },
|
|
218
|
+
venues: [],
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: "base",
|
|
222
|
+
chainId: 8453,
|
|
223
|
+
name: "Base",
|
|
224
|
+
rpcEnv: ["BASE_RPC_URL"],
|
|
225
|
+
nativeCurrency: { symbol: "ETH", decimals: 18 },
|
|
226
|
+
explorer: "https://basescan.org",
|
|
227
|
+
dexscreenerSlug: "base",
|
|
228
|
+
// Base runs the V3 adapter: its V3 pools carry far deeper liquidity than the V2
|
|
229
|
+
// fork, and the chain-specific quoter is verified below. Worth noting how the
|
|
230
|
+
// address was found -- the CANONICAL mainnet quoter address also returns bytecode
|
|
231
|
+
// on Base (2109 bytes), so a codesize check would have waved through the wrong
|
|
232
|
+
// contract. Only the functional probe distinguished them.
|
|
233
|
+
venueKind: "uniswap-v3",
|
|
234
|
+
wrappedNative: "0x4200000000000000000000000000000000000006",
|
|
235
|
+
venues: [
|
|
236
|
+
{
|
|
237
|
+
kind: "quoter",
|
|
238
|
+
address: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",
|
|
239
|
+
label: "Uniswap V3 QuoterV2 (Base)",
|
|
240
|
+
verified: {
|
|
241
|
+
method:
|
|
242
|
+
"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 " +
|
|
243
|
+
"= 1908.44 USDC, a live sane price. The canonical mainnet quoter address " +
|
|
244
|
+
"also has bytecode on Base but does NOT price this pair, which is exactly " +
|
|
245
|
+
"the false positive a codesize-only check accepts",
|
|
246
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
247
|
+
date: "2026-07-30",
|
|
248
|
+
chainId: 8453,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
kind: "router",
|
|
253
|
+
address: "0x2626664c2603336E57B271c5C0b26F421741e481",
|
|
254
|
+
label: "Uniswap V3 SwapRouter02 (Base)",
|
|
255
|
+
verified: {
|
|
256
|
+
method:
|
|
257
|
+
"eth_getCode returned real bytecode and the paired Base quoter passed a " +
|
|
258
|
+
"live functional quote",
|
|
259
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
260
|
+
date: "2026-07-30",
|
|
261
|
+
chainId: 8453,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
// Kept as the V2 reference wiring. Not selected while venueKind is v3, but
|
|
266
|
+
// it documents a verified alternate route and shows both shapes in one place.
|
|
267
|
+
kind: "router-v2",
|
|
268
|
+
address: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
|
|
269
|
+
label: "Uniswap V2 Router02 (Base)",
|
|
270
|
+
verified: {
|
|
271
|
+
method:
|
|
272
|
+
"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC " +
|
|
273
|
+
"round-tripped to 98.75% (2x0.30% fee + impact)",
|
|
274
|
+
source: "https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",
|
|
275
|
+
date: "2026-07-30",
|
|
276
|
+
chainId: 8453,
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
key: "arbitrum",
|
|
283
|
+
chainId: 42161,
|
|
284
|
+
name: "Arbitrum One",
|
|
285
|
+
rpcEnv: ["ARBITRUM_RPC_URL", "ARB_RPC_URL"],
|
|
286
|
+
nativeCurrency: { symbol: "ETH", decimals: 18 },
|
|
287
|
+
explorer: "https://arbiscan.io",
|
|
288
|
+
dexscreenerSlug: "arbitrum",
|
|
289
|
+
venueKind: "uniswap-v3",
|
|
290
|
+
wrappedNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
291
|
+
venues: [
|
|
292
|
+
{
|
|
293
|
+
kind: "quoter",
|
|
294
|
+
address: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
295
|
+
label: "Uniswap V3 QuoterV2",
|
|
296
|
+
verified: {
|
|
297
|
+
method:
|
|
298
|
+
"functional probe, not a codesize check: quoteExactInputSingle returned a " +
|
|
299
|
+
"live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair " +
|
|
300
|
+
"IS a working V3 quoter",
|
|
301
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
302
|
+
date: "2026-07-30",
|
|
303
|
+
chainId: 42161,
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
kind: "router",
|
|
308
|
+
address: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
|
|
309
|
+
label: "Uniswap V3 SwapRouter02",
|
|
310
|
+
verified: {
|
|
311
|
+
method:
|
|
312
|
+
"eth_getCode returned real bytecode on this chain and the paired quoter " +
|
|
313
|
+
"at the same deployment passed a live functional quote",
|
|
314
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
315
|
+
date: "2026-07-30",
|
|
316
|
+
chainId: 42161,
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
key: "avalanche",
|
|
323
|
+
chainId: 43114,
|
|
324
|
+
name: "Avalanche C-Chain",
|
|
325
|
+
rpcEnv: ["AVALANCHE_RPC_URL", "AVAX_RPC_URL"],
|
|
326
|
+
nativeCurrency: { symbol: "AVAX", decimals: 18 },
|
|
327
|
+
explorer: "https://snowtrace.io",
|
|
328
|
+
dexscreenerSlug: "avalanche",
|
|
329
|
+
venueKind: "uniswap-v3",
|
|
330
|
+
wrappedNative: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
|
|
331
|
+
venues: [
|
|
332
|
+
{
|
|
333
|
+
kind: "quoter",
|
|
334
|
+
address: "0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",
|
|
335
|
+
label: "Uniswap V3 QuoterV2",
|
|
336
|
+
verified: {
|
|
337
|
+
method:
|
|
338
|
+
"functional probe, not a codesize check: quoteExactInputSingle returned a " +
|
|
339
|
+
"live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair " +
|
|
340
|
+
"IS a working V3 quoter",
|
|
341
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
342
|
+
date: "2026-07-30",
|
|
343
|
+
chainId: 43114,
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
kind: "router",
|
|
348
|
+
address: "0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",
|
|
349
|
+
label: "Uniswap V3 SwapRouter02",
|
|
350
|
+
verified: {
|
|
351
|
+
method:
|
|
352
|
+
"eth_getCode returned real bytecode on this chain and the paired quoter " +
|
|
353
|
+
"at the same deployment passed a live functional quote",
|
|
354
|
+
source: "scripts/verify-v3-venues.mjs (re-runnable)",
|
|
355
|
+
date: "2026-07-30",
|
|
356
|
+
chainId: 43114,
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
]);
|
|
362
|
+
|
|
363
|
+
/** Register every built-in chain. Idempotent. */
|
|
364
|
+
export function registerBuiltinScanners() {
|
|
365
|
+
return CHAIN_CONFIGS.map((c) => registerScanner(defineEvmScanner(c)));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Register a chain Oracle has never seen.
|
|
370
|
+
*
|
|
371
|
+
* This is the whole point: no code change, no PR to this file required.
|
|
372
|
+
*
|
|
373
|
+
* registerCustomChain({
|
|
374
|
+
* key: "mychain", chainId: 7777, name: "My Chain",
|
|
375
|
+
* rpcEnv: ["MYCHAIN_RPC_URL"],
|
|
376
|
+
* nativeCurrency: { symbol: "MYC", decimals: 18 },
|
|
377
|
+
* });
|
|
378
|
+
*/
|
|
379
|
+
export function registerCustomChain(config) {
|
|
380
|
+
return registerScanner(defineEvmScanner(config));
|
|
381
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// Chain scanner contract.
|
|
2
|
+
//
|
|
3
|
+
// The problem this solves: Oracle knows 11 chains today, and every one of them was
|
|
4
|
+
// wired by hand. Adding the 12th shouldn't mean writing another bespoke integration
|
|
5
|
+
// -- it should mean filling in a config and, at most, one adapter function.
|
|
6
|
+
//
|
|
7
|
+
// So a scanner is defined by DATA (what the chain is) plus a small set of CAPABILITY
|
|
8
|
+
// functions (what we can actually do on it). Anything unimplemented is absent, not
|
|
9
|
+
// faked, and `capabilities()` reports the truth. This mirrors the data catalog's
|
|
10
|
+
// honesty rule: coverage is not capability.
|
|
11
|
+
//
|
|
12
|
+
// Nothing here signs. A scanner's terminal output is an UNSIGNED transaction.
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The capability surface a scanner may implement. Every one is optional; a chain
|
|
16
|
+
* with only `blockNumber` and `resolveToken` is a legitimate, useful scanner.
|
|
17
|
+
*
|
|
18
|
+
* Ordered roughly by how much you need to know about the chain to provide it.
|
|
19
|
+
*/
|
|
20
|
+
export const SCANNER_CAPABILITIES = Object.freeze([
|
|
21
|
+
"blockNumber", // current head
|
|
22
|
+
"nativeBalance", // native token balance for an address
|
|
23
|
+
"tokenBalance", // ERC-20 balance
|
|
24
|
+
"resolveToken", // address or symbol -> { address, symbol, decimals, name }
|
|
25
|
+
"resolvePools", // token -> tradeable pools, with liquidity
|
|
26
|
+
"scanBlocks", // range scan for events (launches, transfers)
|
|
27
|
+
"scoreRisk", // structured risk assessment, honestly labelled
|
|
28
|
+
"quote", // price a route
|
|
29
|
+
"sellSimulation", // can it be sold? round-trip check
|
|
30
|
+
"prepareUnsignedTx", // build a transaction for the USER to sign
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Evidence freshness labels. A scanner must say which one applies to each finding,
|
|
35
|
+
* because "no data" and "data from 40 minutes ago" lead to different decisions and
|
|
36
|
+
* conflating them is how people size against stale reserves.
|
|
37
|
+
*/
|
|
38
|
+
export const EVIDENCE = Object.freeze({
|
|
39
|
+
LIVE: "LIVE", // read this call, from the chain
|
|
40
|
+
CACHED: "CACHED", // read recently, within the stated ttl
|
|
41
|
+
STALE: "STALE", // older than ttl; usable only with the caveat stated
|
|
42
|
+
UNKNOWN: "UNKNOWN", // we tried and could not determine it
|
|
43
|
+
UNAVAILABLE: "UNAVAILABLE", // this chain/provider cannot answer at all
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Risk verdicts. Deliberately coarse: a false sense of precision ("risk 62/100")
|
|
48
|
+
* invites people to trade a number they don't understand.
|
|
49
|
+
*/
|
|
50
|
+
export const RISK = Object.freeze({
|
|
51
|
+
PASS: "PASS", // checks ran and found nothing disqualifying
|
|
52
|
+
CAUTION: "CAUTION", // something real to know before sizing
|
|
53
|
+
FAIL: "FAIL", // disqualifying: do not trade
|
|
54
|
+
UNKNOWN: "UNKNOWN", // could not assess -- NOT the same as PASS
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Validate a chain scanner definition.
|
|
61
|
+
*
|
|
62
|
+
* Fails closed on the things that cause real losses: an unverified venue, a
|
|
63
|
+
* placeholder address, a chain id that doesn't match the RPC, a scanner that claims
|
|
64
|
+
* a capability it didn't implement.
|
|
65
|
+
*
|
|
66
|
+
* @param {object} def
|
|
67
|
+
* @returns {{ok: boolean, errors: string[], warnings: string[]}}
|
|
68
|
+
*/
|
|
69
|
+
export function validateScanner(def = {}) {
|
|
70
|
+
const errors = [];
|
|
71
|
+
const warnings = [];
|
|
72
|
+
|
|
73
|
+
if (!def || typeof def !== "object") {
|
|
74
|
+
return { ok: false, errors: ["definition must be an object"], warnings };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!Number.isInteger(def.chainId) || def.chainId <= 0) {
|
|
78
|
+
errors.push("chainId must be a positive integer");
|
|
79
|
+
}
|
|
80
|
+
if (typeof def.key !== "string" || !/^[a-z][a-z0-9-]*$/.test(def.key || "")) {
|
|
81
|
+
errors.push('key must be a lowercase slug (e.g. "base")');
|
|
82
|
+
}
|
|
83
|
+
if (typeof def.name !== "string" || !def.name.trim()) {
|
|
84
|
+
errors.push("name is required");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// RPC discovery is env-var driven so a public repo never carries endpoints.
|
|
88
|
+
if (!Array.isArray(def.rpcEnv) || def.rpcEnv.length === 0) {
|
|
89
|
+
errors.push("rpcEnv must list at least one environment variable name");
|
|
90
|
+
} else {
|
|
91
|
+
for (const v of def.rpcEnv) {
|
|
92
|
+
if (typeof v !== "string" || !/^[A-Z][A-Z0-9_]*$/.test(v)) {
|
|
93
|
+
errors.push(`rpcEnv entry "${v}" should be an UPPER_SNAKE env var name`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (def.nativeCurrency) {
|
|
99
|
+
const nc = def.nativeCurrency;
|
|
100
|
+
if (typeof nc.symbol !== "string" || !nc.symbol) {
|
|
101
|
+
errors.push("nativeCurrency.symbol is required when nativeCurrency is set");
|
|
102
|
+
}
|
|
103
|
+
if (!Number.isInteger(nc.decimals)) {
|
|
104
|
+
errors.push("nativeCurrency.decimals must be an integer");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Venue addresses: every one must be well-formed AND carry provenance. An
|
|
109
|
+
// allowlisted spoofed router defeats every other control in the system, so
|
|
110
|
+
// "where did this address come from" is required, not documentation.
|
|
111
|
+
for (const [i, v] of (def.venues || []).entries()) {
|
|
112
|
+
const at = `venues[${i}]`;
|
|
113
|
+
if (!v || typeof v !== "object") {
|
|
114
|
+
errors.push(`${at} must be an object`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (!ADDRESS_RE.test(v.address || "")) {
|
|
118
|
+
errors.push(`${at}.address is not a valid 20-byte address`);
|
|
119
|
+
}
|
|
120
|
+
if (/^0x0{40}$/.test(v.address || "")) {
|
|
121
|
+
errors.push(`${at}.address is the zero address -- placeholder left in place?`);
|
|
122
|
+
}
|
|
123
|
+
if (!v.kind) errors.push(`${at}.kind is required (router|quoter|factory|...)`);
|
|
124
|
+
if (!v.verified) {
|
|
125
|
+
errors.push(
|
|
126
|
+
`${at} must record verification: { verified: { method, source, date } }. ` +
|
|
127
|
+
"An unverified venue stays blocked.",
|
|
128
|
+
);
|
|
129
|
+
} else {
|
|
130
|
+
if (!v.verified.method) errors.push(`${at}.verified.method is required`);
|
|
131
|
+
if (!v.verified.source) errors.push(`${at}.verified.source is required`);
|
|
132
|
+
if (!v.verified.date) warnings.push(`${at}.verified.date missing -- add one so staleness is visible`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Capability honesty: declaring a capability you didn't implement is the exact
|
|
137
|
+
// failure mode the data catalog's tier labels exist to prevent.
|
|
138
|
+
const impl = def.capabilities || {};
|
|
139
|
+
for (const name of Object.keys(impl)) {
|
|
140
|
+
if (!SCANNER_CAPABILITIES.includes(name)) {
|
|
141
|
+
errors.push(`unknown capability "${name}"`);
|
|
142
|
+
} else if (typeof impl[name] !== "function") {
|
|
143
|
+
errors.push(`capability "${name}" must be a function`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (Object.keys(impl).length === 0) {
|
|
147
|
+
warnings.push("scanner implements no capabilities -- it can only be registered, not used");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// prepareUnsignedTx without a quote is a footgun: you would be building a
|
|
151
|
+
// transaction with no priced expectation to check the result against.
|
|
152
|
+
if (impl.prepareUnsignedTx && !impl.quote) {
|
|
153
|
+
warnings.push(
|
|
154
|
+
"prepareUnsignedTx without quote: no priced expectation to validate the built tx against",
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
// A chain where you can buy but cannot verify you can sell.
|
|
158
|
+
if (impl.prepareUnsignedTx && !impl.sellSimulation) {
|
|
159
|
+
warnings.push(
|
|
160
|
+
"prepareUnsignedTx without sellSimulation: cannot prove an asset is exitable before buying",
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return { ok: errors.length === 0, errors, warnings };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Wrap a validated definition into a usable scanner.
|
|
169
|
+
*
|
|
170
|
+
* The wrapper's job is to make unimplemented capabilities fail LOUDLY and
|
|
171
|
+
* consistently, rather than each call site inventing its own undefined-check.
|
|
172
|
+
*/
|
|
173
|
+
export function createScanner(def) {
|
|
174
|
+
const { ok, errors, warnings } = validateScanner(def);
|
|
175
|
+
if (!ok) {
|
|
176
|
+
throw new Error(`invalid scanner for ${def?.key ?? "<unknown>"}:\n - ${errors.join("\n - ")}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const impl = def.capabilities || {};
|
|
180
|
+
const supported = SCANNER_CAPABILITIES.filter((c) => typeof impl[c] === "function");
|
|
181
|
+
|
|
182
|
+
const scanner = {
|
|
183
|
+
key: def.key,
|
|
184
|
+
chainId: def.chainId,
|
|
185
|
+
name: def.name,
|
|
186
|
+
rpcEnv: [...def.rpcEnv],
|
|
187
|
+
nativeCurrency: def.nativeCurrency ? { ...def.nativeCurrency } : null,
|
|
188
|
+
explorer: def.explorer || null,
|
|
189
|
+
venues: (def.venues || []).map((v) => ({ ...v })),
|
|
190
|
+
warnings,
|
|
191
|
+
|
|
192
|
+
/** Honest capability report: what this chain can actually do. */
|
|
193
|
+
capabilities() {
|
|
194
|
+
return {
|
|
195
|
+
chainId: def.chainId,
|
|
196
|
+
key: def.key,
|
|
197
|
+
supported: [...supported],
|
|
198
|
+
unsupported: SCANNER_CAPABILITIES.filter((c) => !supported.includes(c)),
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
supports(cap) {
|
|
203
|
+
return supported.includes(cap);
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// Bind each capability; refuse the rest with an actionable message.
|
|
208
|
+
for (const cap of SCANNER_CAPABILITIES) {
|
|
209
|
+
if (supported.includes(cap)) {
|
|
210
|
+
scanner[cap] = async (...args) => impl[cap](...args, { scanner });
|
|
211
|
+
} else {
|
|
212
|
+
scanner[cap] = async () => {
|
|
213
|
+
throw new Error(
|
|
214
|
+
`${def.key} (chain ${def.chainId}) does not implement "${cap}". ` +
|
|
215
|
+
`Supported: ${supported.join(", ") || "none"}. ` +
|
|
216
|
+
"An unimplemented capability is absent, not assumed -- implement it or " +
|
|
217
|
+
"treat this chain as fail-closed for that operation.",
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return Object.freeze(scanner);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** In-memory scanner registry. */
|
|
227
|
+
const REGISTRY = new Map();
|
|
228
|
+
|
|
229
|
+
export function registerScanner(def) {
|
|
230
|
+
const scanner = createScanner(def);
|
|
231
|
+
REGISTRY.set(scanner.chainId, scanner);
|
|
232
|
+
return scanner;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function getScanner(chainId) {
|
|
236
|
+
return REGISTRY.get(Number(chainId)) || null;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export function listScanners() {
|
|
240
|
+
return [...REGISTRY.values()];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function __clearScanners() {
|
|
244
|
+
REGISTRY.clear();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Coverage matrix across registered scanners: which chains can do what.
|
|
249
|
+
*
|
|
250
|
+
* This is what answers "can we trade on X" with a tier instead of a yes/no.
|
|
251
|
+
*/
|
|
252
|
+
export function scannerCoverage() {
|
|
253
|
+
const chains = {};
|
|
254
|
+
for (const s of REGISTRY.values()) {
|
|
255
|
+
chains[s.chainId] = {
|
|
256
|
+
key: s.key,
|
|
257
|
+
name: s.name,
|
|
258
|
+
...s.capabilities(),
|
|
259
|
+
venueCount: s.venues.length,
|
|
260
|
+
// A chain with no verified venue cannot route value, by design.
|
|
261
|
+
failClosed: s.venues.length === 0,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
generatedAt: new Date().toISOString(),
|
|
266
|
+
chainCount: REGISTRY.size,
|
|
267
|
+
capabilities: [...SCANNER_CAPABILITIES],
|
|
268
|
+
chains,
|
|
269
|
+
};
|
|
270
|
+
}
|