@oracle-agent/oracle 0.11.0 → 0.12.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/LICENSE +115 -201
- package/README.md +66 -84
- package/SECURITY.md +37 -12
- package/SETUP.md +207 -272
- package/dist/action-receipts.mjs +1 -0
- package/dist/action-semantics.mjs +1 -0
- package/dist/address-book.mjs +2 -0
- package/dist/bin/desk-server.mjs +14 -0
- package/dist/bin/oracle-data-mcp.mjs +8 -0
- package/dist/bin/oracle-init.mjs +24 -0
- package/dist/bin/oracle-public-server.mjs +5 -0
- package/dist/bin/oracle-route.mjs +22 -0
- package/dist/bin/oracle-scan.mjs +18 -0
- package/dist/bin/oracle-upgrade.mjs +21 -0
- package/dist/bin/oracle.mjs +68 -0
- package/dist/chains.mjs +1 -0
- package/dist/cli/commands/auth.mjs +16 -0
- package/dist/cli/commands/bootstrap.mjs +18 -0
- package/dist/cli/commands/chain.mjs +21 -0
- package/dist/cli/commands/chat.mjs +35 -0
- package/dist/cli/commands/credential.mjs +1 -0
- package/dist/cli/commands/data-mcp.mjs +2 -0
- package/dist/cli/commands/data.mjs +12 -0
- package/dist/cli/commands/doctor.mjs +5 -0
- package/dist/cli/commands/gate.mjs +13 -0
- package/dist/cli/commands/help.mjs +1 -0
- package/dist/cli/commands/init.mjs +3 -0
- package/dist/cli/commands/mcp.mjs +33 -0
- package/dist/cli/commands/model.mjs +44 -0
- package/dist/cli/commands/prepare.mjs +2 -0
- package/dist/cli/commands/public.mjs +3 -0
- package/dist/cli/commands/route.mjs +2 -0
- package/dist/cli/commands/runner.mjs +1 -0
- package/dist/cli/commands/scan.mjs +2 -0
- package/dist/cli/commands/setup.mjs +34 -0
- package/dist/cli/commands/sign.mjs +4 -0
- package/dist/cli/commands/signer.mjs +1 -0
- package/dist/cli/commands/upgrade.mjs +2 -0
- package/dist/cli/commands/vault.mjs +1 -0
- package/dist/cli/commands/version.mjs +2 -0
- package/dist/data/desk-data.mjs +12 -0
- package/dist/index.mjs +17 -0
- package/dist/nft-gas-war-guard.mjs +1 -0
- package/dist/onboarding/harness-configs.mjs +4 -0
- package/dist/portfolio-risk.mjs +1 -0
- package/dist/prepare-envelope.mjs +1 -0
- package/dist/public-control/policy-schema.mjs +1 -0
- package/dist/router/index.mjs +2 -0
- package/dist/scanner/index.mjs +4 -0
- package/dist/signals/index.mjs +1 -0
- package/dist/watch-preferences.mjs +1 -0
- package/package.json +27 -65
- package/public/oracle-splash/index.html +11 -1
- package/CONTRIBUTING.md +0 -98
- package/bin/desk-server.mjs +0 -440
- package/bin/oracle-data-mcp.mjs +0 -1019
- package/bin/oracle-init.mjs +0 -496
- package/bin/oracle-public-server.mjs +0 -36
- package/bin/oracle-route.mjs +0 -254
- package/bin/oracle-scan.mjs +0 -192
- package/bin/oracle-upgrade.mjs +0 -42
- package/bin/oracle.mjs +0 -33
- package/docs/adding-a-chain.md +0 -229
- package/docs/architecture.md +0 -138
- package/docs/cli.md +0 -47
- package/docs/connectors.md +0 -13
- package/docs/oracle-pack-standard.md +0 -29
- package/docs/profiles.md +0 -151
- package/docs/public-surface.md +0 -133
- package/examples/add-a-chain.mjs +0 -65
- package/examples/oracle-pack-template.mjs +0 -38
- package/examples/research-a-token.mjs +0 -70
- package/plugins/oracle-owner-gate/__init__.py +0 -227
- package/plugins/oracle-owner-gate/plugin.yaml +0 -9
- package/profiles/_template/SOUL.md +0 -54
- package/profiles/_template/profile.json +0 -22
- package/profiles/bitcoin-agent/SOUL.md +0 -31
- package/profiles/bitcoin-agent/profile.json +0 -32
- package/profiles/hyperliquid-agent/SOUL.md +0 -34
- package/profiles/hyperliquid-agent/profile.json +0 -37
- package/profiles/oracle/SOUL.md +0 -107
- package/profiles/oracle/profile.json +0 -39
- package/profiles/polymarket-agent/SOUL.md +0 -35
- package/profiles/polymarket-agent/profile.json +0 -34
- package/profiles/profile.schema.json +0 -90
- package/profiles/protocol-builder/SOUL.md +0 -57
- package/profiles/protocol-builder/profile.json +0 -39
- package/profiles/robinhood-agent/SOUL.md +0 -53
- package/profiles/robinhood-agent/profile.json +0 -40
- package/profiles/solana-agent/SOUL.md +0 -37
- package/profiles/solana-agent/profile.json +0 -37
- package/profiles/stable-agent/SOUL.md +0 -43
- package/profiles/stable-agent/profile.json +0 -37
- package/protocols/templates/safe-erc20/SECURITY.md +0 -16
- package/protocols/templates/safe-erc20/foundry.toml +0 -12
- package/protocols/templates/safe-erc20/remappings.txt +0 -2
- package/protocols/templates/safe-erc20/src/SafeERC20.sol +0 -53
- package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +0 -72
- package/scripts/adversarial-bench.mjs +0 -114
- package/scripts/build-inscription.py +0 -230
- package/scripts/check-doc-drift.mjs +0 -123
- package/scripts/check-test-count.mjs +0 -105
- package/scripts/e2e-hl-markets.mjs +0 -21
- package/scripts/e2e-hl-perps.mjs +0 -48
- package/scripts/e2e-hypercore-staking.mjs +0 -128
- package/scripts/e2e-solana-bitcoin.mjs +0 -183
- package/scripts/protocol-template-gate.mjs +0 -15
- package/scripts/public-api-scan.mjs +0 -23
- package/scripts/secret-scan.mjs +0 -181
- package/scripts/verify-v3-venues.mjs +0 -192
- package/skills/balance/SKILL.md +0 -176
- package/skills/oracle-action-semantics/SKILL.md +0 -40
- package/skills/oracle-best-execution/SKILL.md +0 -127
- package/skills/oracle-bitcoin/SKILL.md +0 -53
- package/skills/oracle-chain-graphs-telegram-cards/SKILL.md +0 -59
- package/skills/oracle-chat/SKILL.md +0 -61
- package/skills/oracle-chat/chain.SKILL.md +0 -31
- package/skills/oracle-chat/setup.SKILL.md +0 -37
- package/skills/oracle-circuit-breaker/SKILL.md +0 -51
- package/skills/oracle-contract-research/SKILL.md +0 -55
- package/skills/oracle-desk/SKILL.md +0 -58
- package/skills/oracle-dex-launch/SKILL.md +0 -38
- package/skills/oracle-grants/SKILL.md +0 -69
- package/skills/oracle-hypercore-staking/SKILL.md +0 -57
- package/skills/oracle-hyperliquid/SKILL.md +0 -56
- package/skills/oracle-meme-token-sniper/SKILL.md +0 -73
- package/skills/oracle-multichain-nft-launch/SKILL.md +0 -338
- package/skills/oracle-multichain-token-launch/SKILL.md +0 -300
- package/skills/oracle-nft-gacha-launch/SKILL.md +0 -48
- package/skills/oracle-nft-mint-gas-war/SKILL.md +0 -63
- package/skills/oracle-polymarket/SKILL.md +0 -60
- package/skills/oracle-protocol-builder/SKILL.md +0 -59
- package/skills/oracle-protocol-security/SKILL.md +0 -60
- package/skills/oracle-public-product/SKILL.md +0 -44
- package/skills/oracle-receipts/SKILL.md +0 -52
- package/skills/oracle-rfq-tokenized-assets/SKILL.md +0 -69
- package/skills/oracle-smart-wallet-scanner/SKILL.md +0 -49
- package/skills/oracle-solana/SKILL.md +0 -65
- package/skills/oracle-solana-nft/SKILL.md +0 -54
- package/skills/oracle-token-research/SKILL.md +0 -67
- package/skins/oracle.yaml +0 -56
- package/src/action-receipts.mjs +0 -265
- package/src/action-semantics.mjs +0 -62
- package/src/address-book.mjs +0 -208
- package/src/agent-auth.mjs +0 -206
- package/src/approval-guard.mjs +0 -282
- package/src/attestation-secret.mjs +0 -88
- package/src/audit-log.mjs +0 -196
- package/src/auth/oauth.mjs +0 -672
- package/src/auto-slippage.mjs +0 -378
- package/src/capability-posture.mjs +0 -125
- package/src/chains.mjs +0 -62
- package/src/cli/chain-catalog.mjs +0 -215
- package/src/cli/chain-state.mjs +0 -74
- package/src/cli/commands/auth.mjs +0 -193
- package/src/cli/commands/bootstrap.mjs +0 -87
- package/src/cli/commands/chain.mjs +0 -143
- package/src/cli/commands/chat.mjs +0 -434
- package/src/cli/commands/credential.mjs +0 -9
- package/src/cli/commands/data-mcp.mjs +0 -18
- package/src/cli/commands/data.mjs +0 -75
- package/src/cli/commands/doctor.mjs +0 -136
- package/src/cli/commands/help.mjs +0 -7
- package/src/cli/commands/init.mjs +0 -27
- package/src/cli/commands/mcp.mjs +0 -142
- package/src/cli/commands/model.mjs +0 -99
- package/src/cli/commands/prepare.mjs +0 -12
- package/src/cli/commands/public.mjs +0 -20
- package/src/cli/commands/route.mjs +0 -12
- package/src/cli/commands/runner.mjs +0 -9
- package/src/cli/commands/scan.mjs +0 -12
- package/src/cli/commands/setup.mjs +0 -275
- package/src/cli/commands/sign.mjs +0 -21
- package/src/cli/commands/signer.mjs +0 -9
- package/src/cli/commands/upgrade.mjs +0 -12
- package/src/cli/commands/vault.mjs +0 -9
- package/src/cli/commands/version.mjs +0 -22
- package/src/cli/first-run.mjs +0 -23
- package/src/cli/kernel.mjs +0 -239
- package/src/cli/mcp-targets/chatgpt.mjs +0 -51
- package/src/cli/mcp-targets/claude-code.mjs +0 -39
- package/src/cli/mcp-targets/claude-desktop.mjs +0 -24
- package/src/cli/mcp-targets/codex.mjs +0 -41
- package/src/cli/mcp-targets/shared.mjs +0 -61
- package/src/cli/messaging-platforms.mjs +0 -209
- package/src/cli/model-config.mjs +0 -70
- package/src/cli/operator-dispatch.mjs +0 -258
- package/src/cli/oracle-harness.py +0 -415
- package/src/cli/paths.mjs +0 -83
- package/src/cli/runtime.mjs +0 -351
- package/src/cli/setup-state.mjs +0 -168
- package/src/cli/spawn-child.mjs +0 -43
- package/src/data/catalog.mjs +0 -585
- package/src/data/desk-data.mjs +0 -695
- package/src/data/http.mjs +0 -253
- package/src/data/provider-endpoint.mjs +0 -94
- package/src/data/providers/aerodrome.mjs +0 -245
- package/src/data/providers/balancer.mjs +0 -209
- package/src/data/providers/bitcoin-esplora.mjs +0 -216
- package/src/data/providers/bitcoin-meta.mjs +0 -378
- package/src/data/providers/blockscout.mjs +0 -14
- package/src/data/providers/bridges.mjs +0 -242
- package/src/data/providers/cowswap.mjs +0 -415
- package/src/data/providers/curve.mjs +0 -201
- package/src/data/providers/defillama.mjs +0 -88
- package/src/data/providers/dexscreener.mjs +0 -43
- package/src/data/providers/evm-rpc.mjs +0 -225
- package/src/data/providers/geckoterminal.mjs +0 -34
- package/src/data/providers/gmx.mjs +0 -496
- package/src/data/providers/hl-assets.mjs +0 -165
- package/src/data/providers/hl-info.mjs +0 -108
- package/src/data/providers/hl-markets.mjs +0 -210
- package/src/data/providers/hl-outcome.mjs +0 -61
- package/src/data/providers/hl-perps.mjs +0 -387
- package/src/data/providers/hl-staking.mjs +0 -353
- package/src/data/providers/hl-ws.mjs +0 -119
- package/src/data/providers/hyperevm-dex.mjs +0 -49
- package/src/data/providers/jupiter-venues.mjs +0 -119
- package/src/data/providers/jupiter.mjs +0 -315
- package/src/data/providers/lifi.mjs +0 -151
- package/src/data/providers/magiceden-sol.mjs +0 -406
- package/src/data/providers/morpho.mjs +0 -177
- package/src/data/providers/nft-gallery.mjs +0 -163
- package/src/data/providers/nft-portfolio.mjs +0 -494
- package/src/data/providers/odos.mjs +0 -156
- package/src/data/providers/oneinch.mjs +0 -174
- package/src/data/providers/opensea-multichain.mjs +0 -136
- package/src/data/providers/opensea-nft.mjs +0 -371
- package/src/data/providers/paraswap.mjs +0 -118
- package/src/data/providers/pendle.mjs +0 -188
- package/src/data/providers/poly-clob.mjs +0 -283
- package/src/data/providers/poly-public.mjs +0 -96
- package/src/data/providers/poly-ws.mjs +0 -103
- package/src/data/providers/portfolio-history.mjs +0 -394
- package/src/data/providers/portfolio.mjs +0 -594
- package/src/data/providers/rfq.mjs +0 -15
- package/src/data/providers/rh-agent.mjs +0 -59
- package/src/data/providers/satflow.mjs +0 -341
- package/src/data/providers/signed-material-guard.mjs +0 -108
- package/src/data/providers/solana-rpc.mjs +0 -197
- package/src/data/providers/uniswap-v3.mjs +0 -349
- package/src/data/providers/uniswap-v4.mjs +0 -414
- package/src/data/providers/zerox.mjs +0 -167
- package/src/data/public-api-scan.mjs +0 -61
- package/src/data/quote-placeholder.mjs +0 -31
- package/src/exact-integer.mjs +0 -72
- package/src/exec-policy.mjs +0 -455
- package/src/flags.mjs +0 -15
- package/src/fresh-window.mjs +0 -76
- package/src/gmx-attestation.mjs +0 -176
- package/src/index.mjs +0 -100
- package/src/nft-gas-war-guard.mjs +0 -139
- package/src/onboarding/agent-keys.mjs +0 -161
- package/src/onboarding/harness-configs.mjs +0 -102
- package/src/onboarding/index.mjs +0 -18
- package/src/onboarding/tiers.mjs +0 -139
- package/src/oracle-env.mjs +0 -47
- package/src/portfolio-risk.mjs +0 -170
- package/src/prepare-envelope.mjs +0 -204
- package/src/profile-upgrade.mjs +0 -277
- package/src/protocol-execution.mjs +0 -84
- package/src/protocol-templates/gate.mjs +0 -179
- package/src/protocol-templates/prepare-deploy.mjs +0 -81
- package/src/public-api/buzz-integration.mjs +0 -256
- package/src/public-api/connect-agent.mjs +0 -416
- package/src/public-api/grants.mjs +0 -142
- package/src/public-api/http.mjs +0 -389
- package/src/public-control/aa-adapter.mjs +0 -402
- package/src/public-control/build-registry.mjs +0 -227
- package/src/public-control/bundler-client.mjs +0 -357
- package/src/public-control/grant-indexer.mjs +0 -296
- package/src/public-control/policy-render.mjs +0 -69
- package/src/public-control/policy-schema.mjs +0 -318
- package/src/public-control/runtime-config.mjs +0 -275
- package/src/public-control/session-key-model.mjs +0 -374
- package/src/public-control/session-orchestrator.mjs +0 -412
- package/src/rfq/intent.mjs +0 -180
- package/src/rfq/sources.mjs +0 -181
- package/src/route-attestation.mjs +0 -132
- package/src/router/best-execution.mjs +0 -326
- package/src/router/index.mjs +0 -226
- package/src/router/prepare-bridge.mjs +0 -289
- package/src/router/prepare-route.mjs +0 -398
- package/src/router/proposal.mjs +0 -311
- package/src/router/risk-classifier.mjs +0 -119
- package/src/router/route-sources.mjs +0 -364
- package/src/scanner/chains.config.mjs +0 -430
- package/src/scanner/contract.mjs +0 -270
- package/src/scanner/evm-scanner.mjs +0 -394
- package/src/scanner/index.mjs +0 -9
- package/src/scanner/v2-venue.mjs +0 -335
- package/src/scanner/v3-venue.mjs +0 -290
- package/src/scopes.mjs +0 -44
- package/src/sell-simulation.mjs +0 -167
- package/src/signals/engine.mjs +0 -146
- package/src/signals/index.mjs +0 -1
- package/src/token-transfer-guard.mjs +0 -188
- package/src/tui/app.mjs +0 -438
- package/src/tui/backend.mjs +0 -145
- package/src/tui/format.mjs +0 -272
- package/src/tui/gateway-client.mjs +0 -177
- package/src/tui/input.mjs +0 -501
- package/src/tui/renderer.mjs +0 -443
- package/src/tui/standalone-client.mjs +0 -666
- package/src/tui/theme.mjs +0 -81
- package/src/vault-attestation.mjs +0 -146
- package/src/venues.mjs +0 -206
- package/src/watch-preferences.mjs +0 -85
package/src/tui/theme.mjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
export const THEME = Object.freeze({
|
|
2
|
-
accent: "#B8F0FF",
|
|
3
|
-
prompt: "#B8F0FF",
|
|
4
|
-
banner_title: "#B8F0FF",
|
|
5
|
-
banner_accent: "#91C2D7",
|
|
6
|
-
ui_label: "#A5D9EB",
|
|
7
|
-
banner_text: "#EAF2F8",
|
|
8
|
-
status_bar_strong: "#EAF2F8",
|
|
9
|
-
banner_border: "#455867",
|
|
10
|
-
input_rule: "#455867",
|
|
11
|
-
session_border: "#455867",
|
|
12
|
-
banner_dim: "#60717F",
|
|
13
|
-
status_bar_dim: "#60717F",
|
|
14
|
-
status_bar_bg: "#11161B",
|
|
15
|
-
status_bar_text: "#91A2B1",
|
|
16
|
-
ok: "#7EE7B5",
|
|
17
|
-
error: "#FF7B7B",
|
|
18
|
-
warn: "#F0C674",
|
|
19
|
-
bad: "#FF9B71",
|
|
20
|
-
selection_bg: "#23313B",
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export function hexToRgb(hex) {
|
|
24
|
-
if (typeof hex !== "string") return null;
|
|
25
|
-
const value = hex.startsWith("#") ? hex.slice(1) : hex;
|
|
26
|
-
if (!/^(?:[\da-f]{3}|[\da-f]{6})$/i.test(value)) return null;
|
|
27
|
-
const expanded = value.length === 3
|
|
28
|
-
? [...value].map((character) => character.repeat(2)).join("")
|
|
29
|
-
: value;
|
|
30
|
-
return {
|
|
31
|
-
r: Number.parseInt(expanded.slice(0, 2), 16),
|
|
32
|
-
g: Number.parseInt(expanded.slice(2, 4), 16),
|
|
33
|
-
b: Number.parseInt(expanded.slice(4, 6), 16),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function colorSequence(code, hex, text) {
|
|
38
|
-
const rgb = hexToRgb(hex);
|
|
39
|
-
if (!rgb) return String(text);
|
|
40
|
-
return `\u001B[${code};2;${rgb.r};${rgb.g};${rgb.b}m${String(text)}\u001B[0m`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function createPalette({ color = true } = {}) {
|
|
44
|
-
const enabled = color && !Object.hasOwn(process.env, "NO_COLOR");
|
|
45
|
-
if (!enabled) {
|
|
46
|
-
return Object.freeze({
|
|
47
|
-
fg: (_hex, text) => String(text),
|
|
48
|
-
bg: (_hex, text) => String(text),
|
|
49
|
-
bold: (text) => String(text),
|
|
50
|
-
dim: (text) => String(text),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return Object.freeze({
|
|
54
|
-
fg: (hex, text) => colorSequence(38, hex, text),
|
|
55
|
-
bg: (hex, text) => colorSequence(48, hex, text),
|
|
56
|
-
bold: (text) => `\u001B[1m${String(text)}\u001B[0m`,
|
|
57
|
-
dim: (text) => `\u001B[2m${String(text)}\u001B[0m`,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const defaultPalette = createPalette();
|
|
62
|
-
|
|
63
|
-
export function fg(hex, text) {
|
|
64
|
-
return defaultPalette.fg(hex, text);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function bg(hex, text) {
|
|
68
|
-
return defaultPalette.bg(hex, text);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function bold(text) {
|
|
72
|
-
return defaultPalette.bold(text);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function dim(text) {
|
|
76
|
-
return defaultPalette.dim(text);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function stripAnsi(text) {
|
|
80
|
-
return String(text).replace(/\u001B\[[0-9;]*m/g, "");
|
|
81
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
-
import { Interface, isAddress } from "ethers";
|
|
3
|
-
import { routeCalldataHash } from "./route-attestation.mjs";
|
|
4
|
-
import { resolveAttestationSecret } from "./attestation-secret.mjs";
|
|
5
|
-
import { assertFreshWindow } from "./fresh-window.mjs";
|
|
6
|
-
|
|
7
|
-
const DEFAULT_VAULT_ATTESTATION_TTL_MS = 20_000;
|
|
8
|
-
const ERC20 = new Interface(["function approve(address spender,uint256 amount) returns (bool)"]);
|
|
9
|
-
|
|
10
|
-
function canonicalJson(value) {
|
|
11
|
-
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
12
|
-
if (value && typeof value === "object") {
|
|
13
|
-
return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonicalJson(value[k])}`).join(",")}}`;
|
|
14
|
-
}
|
|
15
|
-
return JSON.stringify(value);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function normalAddress(value, label) {
|
|
19
|
-
const text = String(value || "").trim();
|
|
20
|
-
if (!isAddress(text)) throw new Error(`${label} must be an address`);
|
|
21
|
-
return text.toLowerCase();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function amountString(value, label = "vault amount") {
|
|
25
|
-
try {
|
|
26
|
-
const n = BigInt(String(value));
|
|
27
|
-
if (n <= 0n) throw new Error("nonpositive");
|
|
28
|
-
return n.toString();
|
|
29
|
-
} catch {
|
|
30
|
-
throw new Error(`${label} must be a positive integer string`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function decodeApproveCalldata(data) {
|
|
35
|
-
const hex = String(data || "").toLowerCase();
|
|
36
|
-
if (!hex.startsWith("0x095ea7b3")) throw new Error("approval calldata required");
|
|
37
|
-
const [spender, amount] = ERC20.decodeFunctionData("approve", hex);
|
|
38
|
-
return { spender: normalAddress(spender, "approval spender"), amount: amountString(amount, "approval amount") };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function hmac(secret, payload) {
|
|
42
|
-
return `0x${createHmac("sha256", String(secret)).update(payload).digest("hex")}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function sameSignature(a, b) {
|
|
46
|
-
const left = Buffer.from(String(a || "").replace(/^0x/, ""), "hex");
|
|
47
|
-
const right = Buffer.from(String(b || "").replace(/^0x/, ""), "hex");
|
|
48
|
-
return left.length === right.length && left.length > 0 && timingSafeEqual(left, right);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function attestationSecret(secret) {
|
|
52
|
-
return resolveAttestationSecret(
|
|
53
|
-
secret,
|
|
54
|
-
"ORACLE_ROUTE_ATTESTATION_SECRET",
|
|
55
|
-
"MAD_ROUTE_ATTESTATION_SECRET",
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function unsigned(attestation) {
|
|
60
|
-
const { signature: _signature, ...payload } = attestation;
|
|
61
|
-
return payload;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function createVaultAttestation({
|
|
65
|
-
provider = "morpho",
|
|
66
|
-
chainId,
|
|
67
|
-
action,
|
|
68
|
-
vault,
|
|
69
|
-
asset,
|
|
70
|
-
owner,
|
|
71
|
-
receiver,
|
|
72
|
-
amount,
|
|
73
|
-
data,
|
|
74
|
-
calldataHash,
|
|
75
|
-
minSharesOut,
|
|
76
|
-
maxSharesIn,
|
|
77
|
-
totalAssetsUsd,
|
|
78
|
-
nowMs = Date.now(),
|
|
79
|
-
ttlMs = DEFAULT_VAULT_ATTESTATION_TTL_MS,
|
|
80
|
-
secret,
|
|
81
|
-
} = {}) {
|
|
82
|
-
const normalizedAction = String(action || "").trim().toLowerCase();
|
|
83
|
-
if (!["deposit", "withdraw"].includes(normalizedAction)) throw new Error("vault attestation action must be deposit or withdraw");
|
|
84
|
-
const attestation = {
|
|
85
|
-
mode: "vault-attestation",
|
|
86
|
-
version: 1,
|
|
87
|
-
provider: String(provider || "").trim() || "morpho",
|
|
88
|
-
chainId: Number(chainId),
|
|
89
|
-
action: normalizedAction,
|
|
90
|
-
vault: normalAddress(vault, "vault"),
|
|
91
|
-
asset: normalAddress(asset, "vault asset"),
|
|
92
|
-
owner: normalAddress(owner, "vault owner"),
|
|
93
|
-
receiver: normalAddress(receiver || owner, "vault receiver"),
|
|
94
|
-
amount: amountString(amount),
|
|
95
|
-
calldataHash: data ? routeCalldataHash(data) : calldataHash,
|
|
96
|
-
value: "0",
|
|
97
|
-
issuedAtMs: Number(nowMs),
|
|
98
|
-
expiresAtMs: Number(nowMs) + Number(ttlMs),
|
|
99
|
-
};
|
|
100
|
-
if (!Number.isFinite(attestation.chainId)) throw new Error("vault attestation chainId required");
|
|
101
|
-
if (minSharesOut != null) attestation.minSharesOut = amountString(minSharesOut, "minSharesOut");
|
|
102
|
-
if (maxSharesIn != null) attestation.maxSharesIn = amountString(maxSharesIn, "maxSharesIn");
|
|
103
|
-
if (totalAssetsUsd != null) attestation.totalAssetsUsd = Number(totalAssetsUsd);
|
|
104
|
-
const payload = canonicalJson(attestation);
|
|
105
|
-
return { ...attestation, signature: hmac(attestationSecret(secret), payload) };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function assertVaultAttestation(attestation, tx = {}, { chainId, nowMs = Date.now(), secret } = {}) {
|
|
109
|
-
// Time is a security parameter: an unusable clock must fail CLOSED,
|
|
110
|
-
// otherwise NaN/null/-Infinity silently makes this attestation eternal.
|
|
111
|
-
assertFreshWindow(attestation || {}, nowMs, "vault attestation");
|
|
112
|
-
if (!attestation || attestation.mode !== "vault-attestation") throw new Error("vault attestation required");
|
|
113
|
-
if (Number(attestation.expiresAtMs) <= Number(nowMs)) throw new Error("vault attestation expired");
|
|
114
|
-
const txChainId = Number(chainId ?? tx.chainId);
|
|
115
|
-
if (Number(attestation.chainId) !== txChainId) throw new Error("vault attestation chain mismatch");
|
|
116
|
-
const to = normalAddress(tx.to, "vault tx.to");
|
|
117
|
-
if (normalAddress(attestation.vault, "vault") !== to) throw new Error("vault attestation destination mismatch");
|
|
118
|
-
if (tx.from && normalAddress(attestation.owner, "vault owner") !== normalAddress(tx.from, "vault tx.from")) {
|
|
119
|
-
throw new Error("vault attestation owner mismatch");
|
|
120
|
-
}
|
|
121
|
-
const value = tx.value == null ? "0" : String(BigInt(String(tx.value).startsWith("0x") ? String(tx.value) : String(tx.value)));
|
|
122
|
-
if (value !== "0") throw new Error("vault attestation value mismatch");
|
|
123
|
-
if (attestation.calldataHash !== routeCalldataHash(tx.data || "0x")) throw new Error("vault attestation calldata mismatch");
|
|
124
|
-
const expected = hmac(attestationSecret(secret), canonicalJson(unsigned(attestation)));
|
|
125
|
-
if (!sameSignature(attestation.signature, expected)) throw new Error("vault attestation signature mismatch");
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function assertVaultApprovalAttestation(attestation, tx = {}, guard = {}, { chainId, nowMs = Date.now(), secret } = {}) {
|
|
130
|
-
if (!attestation || attestation.mode !== "vault-attestation") throw new Error("vault attestation required");
|
|
131
|
-
if (String(attestation.action) !== "deposit") throw new Error("vault approval requires deposit attestation");
|
|
132
|
-
assertFreshWindow(attestation, nowMs, "vault approval attestation");
|
|
133
|
-
if (Number(attestation.expiresAtMs) <= Number(nowMs)) throw new Error("vault attestation expired");
|
|
134
|
-
const expected = hmac(attestationSecret(secret), canonicalJson(unsigned(attestation)));
|
|
135
|
-
if (!sameSignature(attestation.signature, expected)) throw new Error("vault attestation signature mismatch");
|
|
136
|
-
const txChainId = Number(tx.chainId ?? chainId);
|
|
137
|
-
if (Number(attestation.chainId) !== txChainId) throw new Error("vault attestation chain mismatch");
|
|
138
|
-
const decoded = decodeApproveCalldata(tx.data);
|
|
139
|
-
if (normalAddress(attestation.asset, "vault asset") !== normalAddress(tx.to, "approval token")) throw new Error("vault attestation asset mismatch");
|
|
140
|
-
if (normalAddress(attestation.vault, "vault") !== decoded.spender) throw new Error("vault attestation spender mismatch");
|
|
141
|
-
if (String(attestation.amount) !== decoded.amount || String(guard.amount) !== decoded.amount) {
|
|
142
|
-
throw new Error("vault attestation amount mismatch");
|
|
143
|
-
}
|
|
144
|
-
if (guard.provider && String(guard.provider) !== String(attestation.provider)) throw new Error("vault attestation provider mismatch");
|
|
145
|
-
return true;
|
|
146
|
-
}
|
package/src/venues.mjs
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
// Per-chain venue registry — the curated, code-reviewed set of contracts the
|
|
2
|
-
// agent wallet is allowed to transact with on each chain. This is how the dest
|
|
3
|
-
// allowlist "just works when you go to a new chain" WITHOUT the footgun of
|
|
4
|
-
// auto-trusting whatever address a tx points at: venues come from THIS vetted
|
|
5
|
-
// map, never from the transaction itself.
|
|
6
|
-
//
|
|
7
|
-
// The policy layer (exec-policy.mjs) unions three sources for the effective
|
|
8
|
-
// destination allowlist on a given chain:
|
|
9
|
-
// 1. MAD_DEST_ALLOWLIST (env; global, applies to every chain)
|
|
10
|
-
// 2. VENUES[chainId] (this file; per-chain known-good contracts)
|
|
11
|
-
// 3. CROSS_CHAIN_VENUES (this file; same address on all chains, e.g. Permit2)
|
|
12
|
-
//
|
|
13
|
-
// To enable trading on a new chain: add its router/quoter/venue addresses here
|
|
14
|
-
// in ONE reviewed edit. After that, trades on that chain pass the allowlist with
|
|
15
|
-
// no per-trade friction. Every address is lowercased; verify each before adding.
|
|
16
|
-
|
|
17
|
-
// Uniswap Permit2 — CREATE2-deployed to the SAME address on every EVM chain.
|
|
18
|
-
// Verified canonical. Safe as a cross-chain constant.
|
|
19
|
-
export const CROSS_CHAIN_VENUES = [
|
|
20
|
-
"0x000000000022d473030f116ddee9f6b43ac78ba3", // Permit2
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
// Per-chain vetted venues. Only entries verified against a trusted source.
|
|
24
|
-
// Empty arrays are intentional: that chain has no approved venues yet, so a
|
|
25
|
-
// value/contract tx there is REFUSED until you add its real venues here.
|
|
26
|
-
export const VENUES = {
|
|
27
|
-
// Robinhood Chain — verified from rhbot server/swap.js SWAP_CONFIG (2026-07-22).
|
|
28
|
-
4663: [
|
|
29
|
-
"0xcaf681a66d020601342297493863e78c959e5cb2", // router
|
|
30
|
-
"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7", // quoter
|
|
31
|
-
"0x1f7d7550b1b028f7571e69a784071f0205fd2efa", // factory
|
|
32
|
-
"0x0bd7d308f8e1639fab988df18a8011f41eacad73", // weth
|
|
33
|
-
"0x5fc5360d0400a0fd4f2af552add042d716f1d168", // usdg
|
|
34
|
-
"0xb477751b76cf82d00a686a1232f5fcd772414af3", // LI.FI diamond on RH (verified via li.quest /chains diamondAddress, 2026-07-23)
|
|
35
|
-
"0xff5cb29241f002ffed2eaa224e3e996d24a6e8d1", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
36
|
-
],
|
|
37
|
-
|
|
38
|
-
// Base (8453) — Uniswap v3. Verified 2026-07-22 against official Uniswap
|
|
39
|
-
// deployments docs (developers.uniswap.org) + on-chain eth_getCode.
|
|
40
|
-
8453: [
|
|
41
|
-
"0x2626664c2603336e57b271c5c0b26f421741e481", // SwapRouter02
|
|
42
|
-
"0x6ff5693b99212da76ad316178a184ab56d299b43", // UniversalRouter
|
|
43
|
-
"0x3d4e44eb1374240ce5f1b871ab261cd16335b76a", // QuoterV2
|
|
44
|
-
"0x33128a8fc17869897dce68ed026d694621f6fdfd", // UniswapV3Factory
|
|
45
|
-
"0x4200000000000000000000000000000000000006", // WETH
|
|
46
|
-
"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", // USDC
|
|
47
|
-
"0xbe6d8f0d05cc4be24d5167a3ef062215be6d18a5", // Aerodrome Slipstream SwapRouter (slipstream README + eth_getCode + live quote, 2026-07-24)
|
|
48
|
-
"0x254cf9e1e6e233aa1ac962cb9b05b2cfeaae15b0", // Aerodrome Slipstream QuoterV2 (slipstream README + eth_getCode + live quote, 2026-07-24)
|
|
49
|
-
"0x5e7bb104d84c7cb9b682aac2f3d509f5f406809a", // Aerodrome Slipstream PoolFactory (slipstream README + eth_getCode, 2026-07-24)
|
|
50
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI canonical diamond (verified via li.quest /chains diamondAddress, 2026-07-23)
|
|
51
|
-
"0x888888888889758f76e7103c6cbf23abbf58f946", // Pendle Router (official deployments + eth_getCode, 2026-07-23)
|
|
52
|
-
"0x3f170631ed9821ca51a59d996ab095162438dc10", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
|
|
53
|
-
"0x4f37a9d177470499a2dd084621020b023fcffc1f", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
54
|
-
"0xc92e8bdf79f0507f65a392b0ab4667716bfe0110", // CoW VaultRelayer (CoW contracts networks.json v1.8.0, 2026-07-24)
|
|
55
|
-
],
|
|
56
|
-
|
|
57
|
-
// Arbitrum One (42161) — Uniswap v3. Verified 2026-07-22 against arbiscan
|
|
58
|
-
// (Uniswap V3: Router 2 label) + swap-router-contracts release + on-chain code.
|
|
59
|
-
42161: [
|
|
60
|
-
"0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", // SwapRouter02
|
|
61
|
-
"0x61ffe014ba17989e743c5f6cb21bf9697530b21e", // QuoterV2
|
|
62
|
-
"0x82af49447d8a07e3bd95bd0d56f35241523fbab1", // WETH
|
|
63
|
-
"0xaf88d065e77c8cc2239327c5edb3a432268e5831", // USDC (native)
|
|
64
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI canonical diamond (verified via li.quest, 2026-07-23) — Leg2 Arb->Stable bridge
|
|
65
|
-
"0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", // USDT0 on Arbitrum (ERC20 approve target for Leg2 bridge)
|
|
66
|
-
"0x888888888889758f76e7103c6cbf23abbf58f946", // Pendle Router (official deployments + eth_getCode, 2026-07-23)
|
|
67
|
-
"0xeaedc32a51c510d35ebc11088fd5ff2b47aacf2e", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
|
|
68
|
-
"0x2191718cd32d02b8e60badffea33e4b5dd9a0a0d", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
69
|
-
"0xc92e8bdf79f0507f65a392b0ab4667716bfe0110", // CoW VaultRelayer (CoW contracts networks.json v1.8.0, 2026-07-24)
|
|
70
|
-
"0x1c3fa76e6e1088bce750f23a5bfcffa1efef6a41", // GMX v2 ExchangeRouter (gmx-synthetics deployments/arbitrum, 2026-07-24)
|
|
71
|
-
"0x7452c558d45f8afc8c83dae62c3f8a5be19c71f6", // GMX v2 Router approval spender (gmx-synthetics deployments/arbitrum, 2026-07-24)
|
|
72
|
-
],
|
|
73
|
-
|
|
74
|
-
// Add verified venues per chain before trading there. Left empty on purpose:
|
|
75
|
-
// an empty chain refuses non-allowlisted destinations (fail-closed by design).
|
|
76
|
-
1: [
|
|
77
|
-
"0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", // Uniswap SwapRouter02
|
|
78
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI canonical diamond (verified via li.quest, 2026-07-23) — ETH->Arb gas bridge
|
|
79
|
-
"0x4cd00e387622c35bddb9b4c962c136462338bc31", // Relay Depository (api.relay.link quote target + Etherscan label, 2026-07-23)
|
|
80
|
-
"0x6a000f20005980200259b80c5102003040001068", // ParaSwap/Velora Augustus V6.2 (Velora docs + priceRoute target, 2026-07-23)
|
|
81
|
-
"0xae563e3f8219521950555f5962419c8919758ea2", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
|
|
82
|
-
"0x45312ea0eff7e09c83cbe249fa1d7598c4c8cd4e", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
83
|
-
"0xc92e8bdf79f0507f65a392b0ab4667716bfe0110", // CoW VaultRelayer (CoW contracts networks.json v1.8.0, 2026-07-24)
|
|
84
|
-
], // Ethereum
|
|
85
|
-
137: [
|
|
86
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
|
|
87
|
-
"0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
88
|
-
], // Polygon
|
|
89
|
-
10: [
|
|
90
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
|
|
91
|
-
"0xe2fa4e1d17725e72dcdafe943ecf45df4b9e285b", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
|
|
92
|
-
"0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
93
|
-
], // Optimism
|
|
94
|
-
56: [
|
|
95
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
|
|
96
|
-
"0xa72c85c258a81761433b4e8da60505fe3dd551cc", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
97
|
-
], // BSC
|
|
98
|
-
43114: [
|
|
99
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
|
|
100
|
-
"0xf39ca6ede9bf7820a952b52f3c94af526bab9015", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
|
|
101
|
-
"0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
102
|
-
"0x8f550e53dfe96c055d5bdb267c21f268fcaf63b2", // GMX v2 ExchangeRouter (gmx-synthetics deployments/avalanche, 2026-07-24)
|
|
103
|
-
"0x820f5ffc5b525cd4d88cd91acf2c28f16530cc68", // GMX v2 Router approval spender (gmx-synthetics deployments/avalanche, 2026-07-24)
|
|
104
|
-
], // Avalanche
|
|
105
|
-
999: [
|
|
106
|
-
"0x0a0758d937d1059c356d4714e57f5df0239bce1a", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
|
|
107
|
-
"0xd2002373543ce3527023c75e7518c274a51ce712", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
108
|
-
], // HyperEVM
|
|
109
|
-
2741: [
|
|
110
|
-
"0x4f8c9056bb8a3616693a76922fa35d53c056e5b3", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
|
|
111
|
-
], // Abstract
|
|
112
|
-
988: [
|
|
113
|
-
"0x026f252016a7c47cdef1f05a3fc9e20c92a49c37", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
|
|
114
|
-
"0xff5cb29241f002ffed2eaa224e3e996d24a6e8d1", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
|
|
115
|
-
"0x817997ca8394e26cce3de3a076a4889b27dbf9de", // WgUSDT (wrapped native USDT0, WETH-style deposit/transfer)
|
|
116
|
-
"0x3dea4be5615974f31624404ef288ba3b36dfeb83", // FEFER/WgUSDT UniV2 pair (raw swap target, verified on-chain)
|
|
117
|
-
"0xeaf7ac0fdf150cdd89340fb762d83848de6a7b83", // FEFER token (approve/transfer for sell-back)
|
|
118
|
-
"0x779ded0c9e1022225f8e0630b35a9b54be713736", // USDT0 canonical (native mirror)
|
|
119
|
-
"0xbc6f7725f08232c151b528bdfcaaf89993ca86ee", // Atomic FEFER raw-pair buyer; deployed by executor, owner verified on-chain (2026-07-23)
|
|
120
|
-
], // Stable
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
// Destinations that can move value according to a market quote. Calldata sent
|
|
124
|
-
// to these contracts must carry a fresh bounded auto-slippage guard through the
|
|
125
|
-
// signer boundary. Tokens, wrappers, quoters, factories, and Permit2 are
|
|
126
|
-
// intentionally excluded because approvals/deposits are not swaps.
|
|
127
|
-
export const SWAP_VENUES = {
|
|
128
|
-
1: [
|
|
129
|
-
"0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", // SwapRouter02
|
|
130
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
|
|
131
|
-
"0x4cd00e387622c35bddb9b4c962c136462338bc31", // Relay Depository
|
|
132
|
-
"0x6a000f20005980200259b80c5102003040001068", // ParaSwap/Velora Augustus V6.2
|
|
133
|
-
"0xae563e3f8219521950555f5962419c8919758ea2", // Balancer v3 Router
|
|
134
|
-
"0x45312ea0eff7e09c83cbe249fa1d7598c4c8cd4e", // Curve RouterNG
|
|
135
|
-
],
|
|
136
|
-
10: [
|
|
137
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
|
|
138
|
-
"0xe2fa4e1d17725e72dcdafe943ecf45df4b9e285b", // Balancer v3 Router
|
|
139
|
-
"0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG
|
|
140
|
-
],
|
|
141
|
-
56: [
|
|
142
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
|
|
143
|
-
"0xa72c85c258a81761433b4e8da60505fe3dd551cc", // Curve RouterNG
|
|
144
|
-
],
|
|
145
|
-
137: [
|
|
146
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
|
|
147
|
-
"0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG
|
|
148
|
-
],
|
|
149
|
-
988: [
|
|
150
|
-
"0x026f252016a7c47cdef1f05a3fc9e20c92a49c37", // LI.FI diamond
|
|
151
|
-
"0xff5cb29241f002ffed2eaa224e3e996d24a6e8d1", // Curve RouterNG
|
|
152
|
-
"0x3dea4be5615974f31624404ef288ba3b36dfeb83", // verified raw V2 pair
|
|
153
|
-
"0xbc6f7725f08232c151b528bdfcaaf89993ca86ee", // atomic raw-pair helper
|
|
154
|
-
],
|
|
155
|
-
999: [
|
|
156
|
-
"0x0a0758d937d1059c356d4714e57f5df0239bce1a", // LI.FI diamond
|
|
157
|
-
"0xd2002373543ce3527023c75e7518c274a51ce712", // Curve RouterNG
|
|
158
|
-
],
|
|
159
|
-
2741: [
|
|
160
|
-
"0x4f8c9056bb8a3616693a76922fa35d53c056e5b3", // LI.FI diamond
|
|
161
|
-
],
|
|
162
|
-
4663: [
|
|
163
|
-
"0xcaf681a66d020601342297493863e78c959e5cb2", // SwapRouter02
|
|
164
|
-
"0xb477751b76cf82d00a686a1232f5fcd772414af3", // LI.FI diamond
|
|
165
|
-
"0xff5cb29241f002ffed2eaa224e3e996d24a6e8d1", // Curve RouterNG
|
|
166
|
-
],
|
|
167
|
-
8453: [
|
|
168
|
-
"0x2626664c2603336e57b271c5c0b26f421741e481", // SwapRouter02
|
|
169
|
-
"0x6ff5693b99212da76ad316178a184ab56d299b43", // UniversalRouter
|
|
170
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
|
|
171
|
-
"0x888888888889758f76e7103c6cbf23abbf58f946", // Pendle Router
|
|
172
|
-
"0x3f170631ed9821ca51a59d996ab095162438dc10", // Balancer v3 Router
|
|
173
|
-
"0x4f37a9d177470499a2dd084621020b023fcffc1f", // Curve RouterNG
|
|
174
|
-
],
|
|
175
|
-
42161: [
|
|
176
|
-
"0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", // SwapRouter02
|
|
177
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
|
|
178
|
-
"0x888888888889758f76e7103c6cbf23abbf58f946", // Pendle Router
|
|
179
|
-
"0xeaedc32a51c510d35ebc11088fd5ff2b47aacf2e", // Balancer v3 Router
|
|
180
|
-
"0x2191718cd32d02b8e60badffea33e4b5dd9a0a0d", // Curve RouterNG
|
|
181
|
-
],
|
|
182
|
-
43114: [
|
|
183
|
-
"0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
|
|
184
|
-
"0xf39ca6ede9bf7820a952b52f3c94af526bab9015", // Balancer v3 Router
|
|
185
|
-
"0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG
|
|
186
|
-
],
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export function isSwapVenue(chainId, address) {
|
|
190
|
-
const target = String(address || "").trim().toLowerCase();
|
|
191
|
-
if (!target) return false;
|
|
192
|
-
return (SWAP_VENUES[Number(chainId)] || []).includes(target);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Known-good destinations for a chain: the union of that chain's vetted venues
|
|
197
|
-
* and the cross-chain constants. Returns a Set of lowercased addresses.
|
|
198
|
-
* @param {number} chainId
|
|
199
|
-
* @returns {Set<string>}
|
|
200
|
-
*/
|
|
201
|
-
export function venuesFor(chainId) {
|
|
202
|
-
const perChain = VENUES[Number(chainId)] || [];
|
|
203
|
-
return new Set(
|
|
204
|
-
[...perChain, ...CROSS_CHAIN_VENUES].map((a) => String(a).trim().toLowerCase()).filter(Boolean)
|
|
205
|
-
);
|
|
206
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/** Notification classes supported by Oracle watches. */
|
|
2
|
-
export const WATCH_CATEGORIES = Object.freeze([
|
|
3
|
-
'price',
|
|
4
|
-
'wallet',
|
|
5
|
-
'risk',
|
|
6
|
-
'execution',
|
|
7
|
-
'security',
|
|
8
|
-
'nft',
|
|
9
|
-
'governance',
|
|
10
|
-
'system',
|
|
11
|
-
]);
|
|
12
|
-
|
|
13
|
-
const CATEGORY_SET = new Set(WATCH_CATEGORIES);
|
|
14
|
-
|
|
15
|
-
function assertCategory(category) {
|
|
16
|
-
if (!CATEGORY_SET.has(category)) {
|
|
17
|
-
throw new TypeError(`Unknown watch category: ${String(category)}`);
|
|
18
|
-
}
|
|
19
|
-
return category;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function subscribedCategories(preferences = {}) {
|
|
23
|
-
const categories = preferences.subscribedCategories ?? [];
|
|
24
|
-
if (!Array.isArray(categories)) {
|
|
25
|
-
throw new TypeError('subscribedCategories must be an array');
|
|
26
|
-
}
|
|
27
|
-
return categories;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** New users receive no category notifications until they explicitly opt in. */
|
|
31
|
-
export function defaultPreferences() {
|
|
32
|
-
return { subscribedCategories: [] };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Return a new preference value with exactly one notification class enabled. */
|
|
36
|
-
export function subscribe(preferences, category) {
|
|
37
|
-
assertCategory(category);
|
|
38
|
-
const current = subscribedCategories(preferences);
|
|
39
|
-
if (current.includes(category)) return { ...preferences, subscribedCategories: [...current] };
|
|
40
|
-
return { ...preferences, subscribedCategories: [...current, category] };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Return a new preference value with the requested notification class disabled. */
|
|
44
|
-
export function unsubscribe(preferences, category) {
|
|
45
|
-
assertCategory(category);
|
|
46
|
-
const current = subscribedCategories(preferences);
|
|
47
|
-
return {
|
|
48
|
-
...preferences,
|
|
49
|
-
subscribedCategories: current.filter((candidate) => candidate !== category),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Create a direct watch. Notifications are opt-in independently for every watch. */
|
|
54
|
-
export function createWatch({ category, notify = false, ...watch } = {}) {
|
|
55
|
-
assertCategory(category);
|
|
56
|
-
if (typeof notify !== 'boolean') throw new TypeError('watch notify must be a boolean');
|
|
57
|
-
return { ...watch, category, notify };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function isMatchingNotifyingWatch(alert, watch) {
|
|
61
|
-
if (!watch || watch.notify !== true || watch.category !== alert.category) return false;
|
|
62
|
-
if (alert.watchId !== undefined && watch.id !== alert.watchId) return false;
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Decide whether an alert may be delivered. This function only describes policy;
|
|
68
|
-
* it performs no scheduling or delivery.
|
|
69
|
-
*/
|
|
70
|
-
export function evaluateAlert(alert, preferences = defaultPreferences(), watch) {
|
|
71
|
-
if (!alert || typeof alert !== 'object') throw new TypeError('alert must be an object');
|
|
72
|
-
assertCategory(alert.category);
|
|
73
|
-
|
|
74
|
-
if (subscribedCategories(preferences).includes(alert.category)) {
|
|
75
|
-
return { deliver: true, reason: 'category-subscribed' };
|
|
76
|
-
}
|
|
77
|
-
if (isMatchingNotifyingWatch(alert, watch)) {
|
|
78
|
-
return { deliver: true, reason: 'watch-opt-in' };
|
|
79
|
-
}
|
|
80
|
-
return { deliver: false, reason: 'not-subscribed' };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function shouldDeliverAlert(alert, preferences, watch) {
|
|
84
|
-
return evaluateAlert(alert, preferences, watch).deliver;
|
|
85
|
-
}
|