chain-insights 0.78.0 → 0.80.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/README.md +3 -0
- package/dist/cli.cjs +72 -18
- package/dist/cli.mjs +72 -18
- package/dist/cli.mjs.map +1 -1
- package/dist/deployer-screen-BomgSBcq.cjs +446 -0
- package/dist/deployer-screen-ByQBZEsg.mjs +413 -0
- package/dist/deployer-screen-ByQBZEsg.mjs.map +1 -0
- package/dist/{dex-registry-sPTFuCrP.mjs → dex-registry-BY67f4Ul.mjs} +2 -2
- package/dist/{dex-registry-sPTFuCrP.mjs.map → dex-registry-BY67f4Ul.mjs.map} +1 -1
- package/dist/{dex-registry-DdXOg5On.cjs → dex-registry-BhGJUG9_.cjs} +36 -0
- package/dist/{dex-tool-CDmhhXfk.cjs → dex-tool-B6AymECb.cjs} +2 -2
- package/dist/{dex-tool-D61sIjpq.mjs → dex-tool-CjUZY19i.mjs} +3 -3
- package/dist/dex-tool-CjUZY19i.mjs.map +1 -0
- package/dist/exchange-deposit-check-CMGTPv-T.mjs +209 -0
- package/dist/exchange-deposit-check-CMGTPv-T.mjs.map +1 -0
- package/dist/exchange-deposit-check-hJGDHLz1.cjs +242 -0
- package/dist/exchange-registry-CT0rRW__.cjs +347 -0
- package/dist/exchange-registry-CoLgHw6d.mjs +319 -0
- package/dist/exchange-registry-CoLgHw6d.mjs.map +1 -0
- package/dist/exchange-tool-B2SMeC5f.cjs +218 -0
- package/dist/exchange-tool-Dc46SJ49.mjs +179 -0
- package/dist/exchange-tool-Dc46SJ49.mjs.map +1 -0
- package/dist/{graph-schema-D4LAefGf.mjs → graph-schema-B8KMeX75.mjs} +19 -3
- package/dist/{graph-schema-D4LAefGf.mjs.map → graph-schema-B8KMeX75.mjs.map} +1 -1
- package/dist/{graph-schema-C8Pi6r7c.cjs → graph-schema-D8rHCsBJ.cjs} +23 -1
- package/dist/mcp-proxy.cjs +78 -12
- package/dist/mcp-proxy.d.cts +1 -0
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts +1 -0
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +78 -13
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/{public-tools-DXlZcanX.mjs → public-tools-CU1nukHW.mjs} +171 -10
- package/dist/public-tools-CU1nukHW.mjs.map +1 -0
- package/dist/{public-tools-Cfc1OPNS.cjs → public-tools-yvRiFSry.cjs} +170 -9
- package/dist/{token-lookup-DvgEyqcC.cjs → token-lookup-D-5GBEwF.cjs} +15 -2
- package/dist/{token-lookup-sH2DesLS.mjs → token-lookup-QpIv77P2.mjs} +5 -4
- package/dist/token-lookup-QpIv77P2.mjs.map +1 -0
- package/dist/{tool-visibility-DIpgPULN.cjs → tool-visibility-D8Up081E.cjs} +8 -1
- package/dist/{tool-visibility-Dy3psowS.mjs → tool-visibility-DuTds7V4.mjs} +9 -2
- package/dist/tool-visibility-DuTds7V4.mjs.map +1 -0
- package/docs/contributing.md +5 -2
- package/docs/development.md +5 -2
- package/docs/graph-query-compatibility.md +20 -4
- package/docs/graph-tools.md +22 -8
- package/docs/mcp-proxy.md +111 -5
- package/docs/stability.md +5 -2
- package/package.json +2 -2
- package/registry/README.md +42 -5
- package/registry/exchanges/ethereum.json +920 -0
- package/registry/exchanges/robinhood.json +87 -0
- package/registry/robinhood.json +7 -4
- package/registry/robinhood.md +9 -5
- package/skills/chain-insights-aml-exchange/SKILL.md +134 -0
- package/skills/chain-insights-aml-exchange/agents/openai.yaml +4 -0
- package/skills/chain-insights-cypher/SKILL.md +41 -11
- package/skills/chain-insights-dex/SKILL.md +3 -3
- package/skills/chain-insights-dex-gauge/SKILL.md +2 -0
- package/skills/chain-insights-dex-launchpad/SKILL.md +9 -10
- package/skills/chain-insights-dex-vault/SKILL.md +2 -0
- package/skills/chain-insights-virtuals/SKILL.md +1 -1
- package/dist/dex-tool-D61sIjpq.mjs.map +0 -1
- package/dist/public-tools-DXlZcanX.mjs.map +0 -1
- package/dist/token-lookup-sH2DesLS.mjs.map +0 -1
- package/dist/tool-visibility-Dy3psowS.mjs.map +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
2
|
+
import { t as ANSWER_HINT } from "./answer-hint-vOE1O6Lf.mjs";
|
|
3
|
+
import { d as normalizeDexNetwork, r as DexRegistryError } from "./dex-registry-BY67f4Ul.mjs";
|
|
4
|
+
import { a as matchExchange, n as exchangeOfWallet } from "./exchange-registry-CoLgHw6d.mjs";
|
|
5
|
+
// src/mcp/exchange-tool.ts
|
|
6
|
+
/**
|
|
7
|
+
* meta_exchange_lookup: a centralized exchange's name becomes its wallets.
|
|
8
|
+
*
|
|
9
|
+
* A local tool of the proxy. It matches the name against the exchange lookup
|
|
10
|
+
* file (src/mcp/exchange-registry.ts) and answers from it alone: no graph read,
|
|
11
|
+
* no cost. The file lists every exchange, and only the wallets proven on that
|
|
12
|
+
* network's own data, each with its payer proof and the block it was proven
|
|
13
|
+
* at. An address instead of a name says whose wallet the address is. Whether
|
|
14
|
+
* an address is a deposit, and which hot wallet it swept into, is read from
|
|
15
|
+
* the graph by aml_exchange_deposit_check.
|
|
16
|
+
*
|
|
17
|
+
* The description below is the contract with every host, Claude Desktop chat
|
|
18
|
+
* included, which reads no skill: it carries the rule the skill
|
|
19
|
+
* chain-insights-aml-exchange opens with. tests/host-parity.test.ts holds it to
|
|
20
|
+
* the skill's trigger words.
|
|
21
|
+
*/
|
|
22
|
+
var exchange_tool_exports = /* @__PURE__ */ __exportAll({ handleMetaExchangeLookup: () => handleMetaExchangeLookup });
|
|
23
|
+
/**
|
|
24
|
+
* The rule the exchange skill opens with, carried by both of its doors: where a
|
|
25
|
+
* trail ends, and where an exchange's wallets come from.
|
|
26
|
+
*/
|
|
27
|
+
const EXCHANGE_OPENING_RULE = "Money that reaches an exchange deposit with a SWEPT link entered that exchange there: the trail ends at the deposit, and never walks on past a hot wallet. Take an exchange's wallets from meta_exchange_lookup, never from a guess or a graph search by name.";
|
|
28
|
+
const META_EXCHANGE_LOOKUP_TOOL = "meta_exchange_lookup";
|
|
29
|
+
const META_EXCHANGE_LOOKUP_SCHEMA = "chain-insights.meta-exchange-lookup.v1";
|
|
30
|
+
const META_EXCHANGE_LOOKUP_TITLE = "Centralized exchange by name or address";
|
|
31
|
+
const META_EXCHANGE_LOOKUP_DESCRIPTION = `Call this first when a question names a centralized exchange (Binance, Bitget, Bybit, Coinbase, Gate, KuCoin, MEXC, OKX, ...) and gives no address, or asks which exchange a wallet belongs to. It turns the name into the hot wallets of that exchange on the network, The file lists only wallets proven on that chain's own data, each with its payer proof and the block it was proven at, and its gas wallets; an exchange may list none, and its deposits and hot wallets are still marked in the graph. A misspelling within two letters is taken and named in took_for. Send address instead (0x plus 40 hex, any case) to learn whose hot wallet or gas wallet it is. It reads no graph and costs nothing. ${EXCHANGE_OPENING_RULE} Give a name or an address, not both.`;
|
|
32
|
+
const META_EXCHANGE_LOOKUP_ANNOTATIONS = {
|
|
33
|
+
readOnlyHint: true,
|
|
34
|
+
idempotentHint: true,
|
|
35
|
+
openWorldHint: false
|
|
36
|
+
};
|
|
37
|
+
function isRecord(value) {
|
|
38
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
39
|
+
}
|
|
40
|
+
function errorResult(text) {
|
|
41
|
+
return {
|
|
42
|
+
content: [{
|
|
43
|
+
type: "text",
|
|
44
|
+
text
|
|
45
|
+
}],
|
|
46
|
+
isError: true
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function textResult(structured) {
|
|
50
|
+
return {
|
|
51
|
+
content: [{
|
|
52
|
+
type: "text",
|
|
53
|
+
text: JSON.stringify(structured, null, 2)
|
|
54
|
+
}],
|
|
55
|
+
structuredContent: structured,
|
|
56
|
+
isError: false
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/;
|
|
60
|
+
function walletsOf(entry, role) {
|
|
61
|
+
return entry.wallets.filter((wallet) => wallet.role === role).map(({ address, evidence, proven_at_block }) => ({
|
|
62
|
+
address,
|
|
63
|
+
evidence,
|
|
64
|
+
proven_at_block
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
/** One row of the lookup as the tool returns it. */
|
|
68
|
+
function exchangeMatchOf(entry) {
|
|
69
|
+
return {
|
|
70
|
+
exchange: entry.exchange,
|
|
71
|
+
display: entry.display,
|
|
72
|
+
hot_wallets: walletsOf(entry, "hot_wallet"),
|
|
73
|
+
gas_wallets: walletsOf(entry, "gas_wallet"),
|
|
74
|
+
spenders: walletsOf(entry, "spender")
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const ROLE_WORDS = {
|
|
78
|
+
hot_wallet: "a hot wallet",
|
|
79
|
+
gas_wallet: "a gas wallet",
|
|
80
|
+
spender: "a spender"
|
|
81
|
+
};
|
|
82
|
+
function hintFor(result, name, address) {
|
|
83
|
+
const { network } = result;
|
|
84
|
+
if (address !== null && !result.matched) return `${ANSWER_HINT} ${address} is no wallet the exchange lookup lists for ${network}: the file lists only wallets proven on this chain. The graph marks deposits and hot wallets of every exchange: call aml_exchange_deposit_check {network: "${network}", address: "${address}"} to read its cex_role, its exchange and its SWEPT links.`;
|
|
85
|
+
if (address !== null && result.matched) return `${ANSWER_HINT} Say in one line: "${address} is ${result.took_for} of ${result.matched.display} on ${network}." A trail that reaches it has entered the exchange: end the trail there. Never walk on past a hot wallet.`;
|
|
86
|
+
if (name === null) return `${ANSWER_HINT} These are the exchanges the lookup lists for ${network}. Call meta_exchange_lookup with a name for its wallets.`;
|
|
87
|
+
if (result.matched) {
|
|
88
|
+
const { matched } = result;
|
|
89
|
+
const took = result.took_for ? `Say in one line: "I took ${matched.display} for ${result.took_for}." Ask nothing. ` : "";
|
|
90
|
+
const count = matched.hot_wallets.length;
|
|
91
|
+
const wallets = count === 0 ? `${matched.display} on ${network}: the lookup lists no wallet of it proven on this chain yet; the graph marks its deposits and hot wallets. ` : `${matched.display} on ${network}: ${count} hot wallet${count === 1 ? "" : "s"} proven on this chain. `;
|
|
92
|
+
return `${ANSWER_HINT} ${took}${wallets}A deposit of this exchange has a SWEPT link into its hot wallet. Read SWEPT anchored on the address the trail reached, never on a hot wallet: a hot wallet links to many thousands of deposits. To check one address, call aml_exchange_deposit_check. ${EXCHANGE_OPENING_RULE}`;
|
|
93
|
+
}
|
|
94
|
+
if (result.candidates.length > 0) {
|
|
95
|
+
const names = result.candidates.map((candidate) => `${candidate.display} (${candidate.exchange})`).join(", ");
|
|
96
|
+
return `${ANSWER_HINT} ${result.candidates.length} exchanges fit "${name}": ${names}. Name both or pick one: call meta_exchange_lookup with each id. Never guess one.`;
|
|
97
|
+
}
|
|
98
|
+
return `${ANSWER_HINT} The exchange lookup holds no wallet of "${name}" for ${network}` + (result.listed.length > 0 ? `; it lists ${result.listed.join(", ")}. ` : ". ") + "If the user knows one address of that exchange (a deposit address, or a wallet it paid them from), call aml_exchange_deposit_check with it. Send no graph search by name.";
|
|
99
|
+
}
|
|
100
|
+
/** meta_exchange_lookup, {network, name?, address?}. Every argument is checked before the lookup is read. */
|
|
101
|
+
async function handleMetaExchangeLookup(args, deps) {
|
|
102
|
+
const record = isRecord(args) ? args : {};
|
|
103
|
+
let network;
|
|
104
|
+
try {
|
|
105
|
+
network = normalizeDexNetwork(record.network);
|
|
106
|
+
} catch (err) {
|
|
107
|
+
return errorResult(err.message);
|
|
108
|
+
}
|
|
109
|
+
const rawName = record.name;
|
|
110
|
+
if (rawName !== void 0 && rawName !== null && typeof rawName !== "string") return errorResult("invalid_name: name must be the exchange name as text");
|
|
111
|
+
const name = typeof rawName === "string" && rawName.trim() !== "" ? rawName.trim() : null;
|
|
112
|
+
const rawAddress = record.address;
|
|
113
|
+
if (rawAddress !== void 0 && rawAddress !== null && typeof rawAddress !== "string") return errorResult("invalid_address: address must be 0x plus 40 hex characters");
|
|
114
|
+
const addressText = typeof rawAddress === "string" && rawAddress.trim() !== "" ? rawAddress.trim() : null;
|
|
115
|
+
if (name !== null && addressText !== null) return errorResult("Give a name or an address, not both.");
|
|
116
|
+
if (addressText !== null && !ADDRESS_FORM.test(addressText)) return errorResult("invalid_address: address must be 0x plus 40 hex characters");
|
|
117
|
+
const address = addressText === null ? null : addressText.toLowerCase();
|
|
118
|
+
let loaded;
|
|
119
|
+
try {
|
|
120
|
+
loaded = await deps.loadExchangeRegistry(network);
|
|
121
|
+
} catch (err) {
|
|
122
|
+
return errorResult(err instanceof DexRegistryError ? err.message : `exchange lookup unavailable: ${err.message}`);
|
|
123
|
+
}
|
|
124
|
+
const { document } = loaded;
|
|
125
|
+
const listed = document.rows.map((row) => row.display);
|
|
126
|
+
const base = {
|
|
127
|
+
schema: META_EXCHANGE_LOOKUP_SCHEMA,
|
|
128
|
+
network,
|
|
129
|
+
registry_version: document.registry_version,
|
|
130
|
+
registry_source: loaded.source,
|
|
131
|
+
recorded_on: document.recorded_on
|
|
132
|
+
};
|
|
133
|
+
if (name === null && address === null) {
|
|
134
|
+
const result = {
|
|
135
|
+
...base,
|
|
136
|
+
matched: null,
|
|
137
|
+
candidates: [],
|
|
138
|
+
listed,
|
|
139
|
+
exchanges: document.rows.map((row) => ({
|
|
140
|
+
exchange: row.exchange,
|
|
141
|
+
display: row.display,
|
|
142
|
+
hot_wallets: row.wallets.filter((wallet) => wallet.role === "hot_wallet").length
|
|
143
|
+
}))
|
|
144
|
+
};
|
|
145
|
+
return textResult({
|
|
146
|
+
...result,
|
|
147
|
+
hint: hintFor(result, null, null)
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (address !== null) {
|
|
151
|
+
const owner = exchangeOfWallet(address, document.rows);
|
|
152
|
+
const result = {
|
|
153
|
+
...base,
|
|
154
|
+
matched: owner ? exchangeMatchOf(owner.entry) : null,
|
|
155
|
+
...owner ? { took_for: ROLE_WORDS[owner.wallet.role] } : {},
|
|
156
|
+
candidates: [],
|
|
157
|
+
listed
|
|
158
|
+
};
|
|
159
|
+
return textResult({
|
|
160
|
+
...result,
|
|
161
|
+
hint: hintFor(result, null, address)
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const match = matchExchange(name, document.rows);
|
|
165
|
+
const result = {
|
|
166
|
+
...base,
|
|
167
|
+
matched: match.matched ? exchangeMatchOf(match.matched) : null,
|
|
168
|
+
...match.took_for ? { took_for: match.took_for } : {},
|
|
169
|
+
candidates: match.candidates,
|
|
170
|
+
listed
|
|
171
|
+
};
|
|
172
|
+
return textResult({
|
|
173
|
+
...result,
|
|
174
|
+
hint: hintFor(result, name, null)
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
export { META_EXCHANGE_LOOKUP_TOOL as a, META_EXCHANGE_LOOKUP_TITLE as i, META_EXCHANGE_LOOKUP_ANNOTATIONS as n, exchange_tool_exports as o, META_EXCHANGE_LOOKUP_DESCRIPTION as r, handleMetaExchangeLookup as s, EXCHANGE_OPENING_RULE as t };
|
|
178
|
+
|
|
179
|
+
//# sourceMappingURL=exchange-tool-Dc46SJ49.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exchange-tool-Dc46SJ49.mjs","names":[],"sources":["../src/mcp/exchange-tool.ts"],"sourcesContent":["/**\n * meta_exchange_lookup: a centralized exchange's name becomes its wallets.\n *\n * A local tool of the proxy. It matches the name against the exchange lookup\n * file (src/mcp/exchange-registry.ts) and answers from it alone: no graph read,\n * no cost. The file lists every exchange, and only the wallets proven on that\n * network's own data, each with its payer proof and the block it was proven\n * at. An address instead of a name says whose wallet the address is. Whether\n * an address is a deposit, and which hot wallet it swept into, is read from\n * the graph by aml_exchange_deposit_check.\n *\n * The description below is the contract with every host, Claude Desktop chat\n * included, which reads no skill: it carries the rule the skill\n * chain-insights-aml-exchange opens with. tests/host-parity.test.ts holds it to\n * the skill's trigger words.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport {\n exchangeOfWallet,\n matchExchange,\n type ExchangeCandidate,\n type ExchangeEntry,\n type ExchangeRegistrySource,\n type ExchangeWallet,\n type LoadedExchangeRegistry,\n} from './exchange-registry.js'\n\n/**\n * The rule the exchange skill opens with, carried by both of its doors: where a\n * trail ends, and where an exchange's wallets come from.\n */\nexport const EXCHANGE_OPENING_RULE =\n 'Money that reaches an exchange deposit with a SWEPT link entered that exchange there: the trail ends at the deposit, and never walks on past a hot wallet. ' +\n \"Take an exchange's wallets from meta_exchange_lookup, never from a guess or a graph search by name.\"\n\nexport const META_EXCHANGE_LOOKUP_TOOL = 'meta_exchange_lookup' as const\nexport const META_EXCHANGE_LOOKUP_SCHEMA = 'chain-insights.meta-exchange-lookup.v1' as const\nexport const META_EXCHANGE_LOOKUP_TITLE = 'Centralized exchange by name or address'\nexport const META_EXCHANGE_LOOKUP_DESCRIPTION =\n 'Call this first when a question names a centralized exchange (Binance, Bitget, Bybit, Coinbase, Gate, KuCoin, MEXC, OKX, ...) ' +\n 'and gives no address, or asks which exchange a wallet belongs to. It turns the name into the hot wallets of that exchange on the network, ' +\n \"The file lists only wallets proven on that chain's own data, each with its payer proof and the block it was proven at, and its gas wallets; \" +\n 'an exchange may list none, and its deposits and hot wallets are still marked in the graph. ' +\n 'A misspelling within two letters is taken and named in took_for. Send address instead (0x plus 40 hex, any case) to learn whose hot wallet ' +\n 'or gas wallet it is. It reads no graph and costs nothing. ' +\n `${EXCHANGE_OPENING_RULE} Give a name or an address, not both.`\nexport const META_EXCHANGE_LOOKUP_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const META_EXCHANGE_LOOKUP_ARGS = ['network', 'name', 'address'] as const\n\nexport type WalletRow = Omit<ExchangeWallet, 'role'>\n\nexport interface ExchangeMatch {\n exchange: string\n display: string\n hot_wallets: WalletRow[]\n gas_wallets: WalletRow[]\n spenders: WalletRow[]\n}\n\nexport interface ListedExchange {\n exchange: string\n display: string\n hot_wallets: number\n}\n\nexport interface MetaExchangeLookupResult {\n schema: typeof META_EXCHANGE_LOOKUP_SCHEMA\n network: string\n registry_version: number\n registry_source: ExchangeRegistrySource\n recorded_on: string\n matched: ExchangeMatch | null\n /** A near name hit: the name as typed. An address hit: the role the address holds. */\n took_for?: string\n candidates: ExchangeCandidate[]\n /** Every exchange the lookup lists for the network, by display name. */\n listed: string[]\n /** With no name and no address: every listed exchange, with its id and its hot wallet count. */\n exchanges?: ListedExchange[]\n hint: string\n}\n\nexport interface ExchangeToolDependencies {\n loadExchangeRegistry: (network: string) => Promise<LoadedExchangeRegistry>\n}\n\nexport type MetaExchangeLookupToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction errorResult(text: string): MetaExchangeLookupToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: MetaExchangeLookupResult): MetaExchangeLookupToolResult {\n return {\n content: [{ type: 'text', text: JSON.stringify(structured, null, 2) }],\n structuredContent: structured as unknown as Record<string, unknown>,\n isError: false,\n }\n}\n\nconst ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/\n\nfunction walletsOf(entry: ExchangeEntry, role: ExchangeWallet['role']): WalletRow[] {\n return entry.wallets\n .filter((wallet) => wallet.role === role)\n .map(({ address, evidence, proven_at_block }) => ({ address, evidence, proven_at_block }))\n}\n\n/** One row of the lookup as the tool returns it. */\nexport function exchangeMatchOf(entry: ExchangeEntry): ExchangeMatch {\n return {\n exchange: entry.exchange,\n display: entry.display,\n hot_wallets: walletsOf(entry, 'hot_wallet'),\n gas_wallets: walletsOf(entry, 'gas_wallet'),\n spenders: walletsOf(entry, 'spender'),\n }\n}\n\nconst ROLE_WORDS: Record<ExchangeWallet['role'], string> = {\n hot_wallet: 'a hot wallet',\n gas_wallet: 'a gas wallet',\n spender: 'a spender',\n}\n\nconst NO_SEARCH_BY_NAME = 'Send no graph search by name.'\n\nfunction hintFor(\n result: Omit<MetaExchangeLookupResult, 'hint'>,\n name: string | null,\n address: string | null\n): string {\n const { network } = result\n if (address !== null && !result.matched) {\n return (\n `${ANSWER_HINT} ${address} is no wallet the exchange lookup lists for ${network}: the file lists only wallets proven on this chain. ` +\n `The graph marks deposits and hot wallets of every exchange: call aml_exchange_deposit_check {network: \"${network}\", address: \"${address}\"} ` +\n 'to read its cex_role, its exchange and its SWEPT links.'\n )\n }\n if (address !== null && result.matched) {\n return (\n `${ANSWER_HINT} Say in one line: \"${address} is ${result.took_for} of ${result.matched.display} on ${network}.\" ` +\n 'A trail that reaches it has entered the exchange: end the trail there. Never walk on past a hot wallet.'\n )\n }\n if (name === null) {\n return `${ANSWER_HINT} These are the exchanges the lookup lists for ${network}. Call meta_exchange_lookup with a name for its wallets.`\n }\n if (result.matched) {\n const { matched } = result\n const took = result.took_for\n ? `Say in one line: \"I took ${matched.display} for ${result.took_for}.\" Ask nothing. `\n : ''\n const count = matched.hot_wallets.length\n const wallets =\n count === 0\n ? `${matched.display} on ${network}: the lookup lists no wallet of it proven on this chain yet; the graph marks its deposits and hot wallets. `\n : `${matched.display} on ${network}: ${count} hot wallet${count === 1 ? '' : 's'} proven on this chain. `\n return (\n `${ANSWER_HINT} ${took}${wallets}` +\n 'A deposit of this exchange has a SWEPT link into its hot wallet. Read SWEPT anchored on the address the trail reached, never on a hot wallet: ' +\n 'a hot wallet links to many thousands of deposits. To check one address, call aml_exchange_deposit_check. ' +\n `${EXCHANGE_OPENING_RULE}`\n )\n }\n if (result.candidates.length > 0) {\n const names = result.candidates\n .map((candidate) => `${candidate.display} (${candidate.exchange})`)\n .join(', ')\n return `${ANSWER_HINT} ${result.candidates.length} exchanges fit \"${name}\": ${names}. Name both or pick one: call meta_exchange_lookup with each id. Never guess one.`\n }\n return (\n `${ANSWER_HINT} The exchange lookup holds no wallet of \"${name}\" for ${network}` +\n (result.listed.length > 0 ? `; it lists ${result.listed.join(', ')}. ` : '. ') +\n 'If the user knows one address of that exchange (a deposit address, or a wallet it paid them from), call aml_exchange_deposit_check with it. ' +\n NO_SEARCH_BY_NAME\n )\n}\n\n/** meta_exchange_lookup, {network, name?, address?}. Every argument is checked before the lookup is read. */\nexport async function handleMetaExchangeLookup(\n args: unknown,\n deps: ExchangeToolDependencies\n): Promise<MetaExchangeLookupToolResult> {\n const record = isRecord(args) ? args : {}\n let network: string\n try {\n network = normalizeDexNetwork(record.network)\n } catch (err) {\n return errorResult((err as Error).message)\n }\n const rawName = record.name\n if (rawName !== undefined && rawName !== null && typeof rawName !== 'string') {\n return errorResult('invalid_name: name must be the exchange name as text')\n }\n const name = typeof rawName === 'string' && rawName.trim() !== '' ? rawName.trim() : null\n const rawAddress = record.address\n if (rawAddress !== undefined && rawAddress !== null && typeof rawAddress !== 'string') {\n return errorResult('invalid_address: address must be 0x plus 40 hex characters')\n }\n const addressText =\n typeof rawAddress === 'string' && rawAddress.trim() !== '' ? rawAddress.trim() : null\n if (name !== null && addressText !== null)\n return errorResult('Give a name or an address, not both.')\n if (addressText !== null && !ADDRESS_FORM.test(addressText)) {\n return errorResult('invalid_address: address must be 0x plus 40 hex characters')\n }\n const address = addressText === null ? null : addressText.toLowerCase()\n\n let loaded: LoadedExchangeRegistry\n try {\n loaded = await deps.loadExchangeRegistry(network)\n } catch (err) {\n return errorResult(\n err instanceof DexRegistryError\n ? err.message\n : `exchange lookup unavailable: ${(err as Error).message}`\n )\n }\n const { document } = loaded\n const listed = document.rows.map((row) => row.display)\n const base = {\n schema: META_EXCHANGE_LOOKUP_SCHEMA,\n network,\n registry_version: document.registry_version,\n registry_source: loaded.source,\n recorded_on: document.recorded_on,\n }\n\n if (name === null && address === null) {\n const result = {\n ...base,\n matched: null,\n candidates: [],\n listed,\n exchanges: document.rows.map((row) => ({\n exchange: row.exchange,\n display: row.display,\n hot_wallets: row.wallets.filter((wallet) => wallet.role === 'hot_wallet').length,\n })),\n }\n return textResult({ ...result, hint: hintFor(result, null, null) })\n }\n\n if (address !== null) {\n const owner = exchangeOfWallet(address, document.rows)\n const result = {\n ...base,\n matched: owner ? exchangeMatchOf(owner.entry) : null,\n ...(owner ? { took_for: ROLE_WORDS[owner.wallet.role] } : {}),\n candidates: [],\n listed,\n }\n return textResult({ ...result, hint: hintFor(result, null, address) })\n }\n\n const match = matchExchange(name as string, document.rows)\n const result = {\n ...base,\n matched: match.matched ? exchangeMatchOf(match.matched) : null,\n ...(match.took_for ? { took_for: match.took_for } : {}),\n candidates: match.candidates,\n listed,\n }\n return textResult({ ...result, hint: hintFor(result, name, null) })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,wBACX;AAGF,MAAa,4BAA4B;AACzC,MAAa,8BAA8B;AAC3C,MAAa,6BAA6B;AAC1C,MAAa,mCACX,urBAMG,sBAAsB;AAC3B,MAAa,mCAAmC;CAC9C,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;AA8CA,SAAS,SAAS,OAAkD;CAClE,OAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACrE;AAEA,SAAS,YAAY,MAA4C;CAC/D,OAAO;EAAE,SAAS,CAAC;GAAE,MAAM;GAAQ;EAAK,CAAC;EAAG,SAAS;CAAK;AAC5D;AAEA,SAAS,WAAW,YAAoE;CACtF,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM,KAAK,UAAU,YAAY,MAAM,CAAC;EAAE,CAAC;EACrE,mBAAmB;EACnB,SAAS;CACX;AACF;AAEA,MAAM,eAAe;AAErB,SAAS,UAAU,OAAsB,MAA2C;CAClF,OAAO,MAAM,QACV,QAAQ,WAAW,OAAO,SAAS,IAAI,CAAC,CACxC,KAAK,EAAE,SAAS,UAAU,uBAAuB;EAAE;EAAS;EAAU;CAAgB,EAAE;AAC7F;;AAGA,SAAgB,gBAA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AAY,CAAC;GACb;GACA,WAAW,SAAS,KAAK,KAAK,SAAS;IACrC,UAAU,IAAI;IACd,SAAS,IAAI;IACb,aAAa,IAAI,QAAQ,QAAQ,WAAW,OAAO,SAAS,YAAY,CAAC,CAAC;GAC5E,EAAE;EACJ;EACA,OAAO,WAAW;GAAE,GAAG;GAAQ,MAAM,QAAQ,QAAQ,MAAM,IAAI;EAAE,CAAC;CACpE;CAEA,IAAI,YAAY,MAAM;EACpB,MAAM,QAAQ,iBAAiB,SAAS,SAAS,IAAI;EACrD,MAAM,SAAS;GACb,GAAG;GACH,SAAS,QAAQ,gBAAgB,MAAM,KAAK,IAAI;GAChD,GAAI,QAAQ,EAAE,UAAU,WAAW,MAAM,OAAO,MAAM,IAAI,CAAC;GAC3D,YAAY,CAAC;GACb;EACF;EACA,OAAO,WAAW;GAAE,GAAG;GAAQ,MAAM,QAAQ,QAAQ,MAAM,OAAO;EAAE,CAAC;CACvE;CAEA,MAAM,QAAQ,cAAc,MAAgB,SAAS,IAAI;CACzD,MAAM,SAAS;EACb,GAAG;EACH,SAAS,MAAM,UAAU,gBAAgB,MAAM,OAAO,IAAI;EAC1D,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;EACrD,YAAY,MAAM;EAClB;CACF;CACA,OAAO,WAAW;EAAE,GAAG;EAAQ,MAAM,QAAQ,QAAQ,MAAM,IAAI;CAAE,CAAC;AACpE"}
|
|
@@ -850,8 +850,23 @@ const SAMPLED_LINK_TYPES = [
|
|
|
850
850
|
"SWAPPED",
|
|
851
851
|
"BRIDGED",
|
|
852
852
|
"ADDED_LIQUIDITY",
|
|
853
|
-
"REMOVED_LIQUIDITY"
|
|
853
|
+
"REMOVED_LIQUIDITY",
|
|
854
|
+
"SWEPT"
|
|
854
855
|
];
|
|
856
|
+
/**
|
|
857
|
+
* The values of `cex_role` on an `:Exchange` address: which wallet of its
|
|
858
|
+
* exchange the address is. The labels layer sets it from the exchange label's
|
|
859
|
+
* subtype; `SWEPT` (layer `cex_sweeps`) runs from a `deposit` to the
|
|
860
|
+
* `hot_wallet` it swept into.
|
|
861
|
+
*/
|
|
862
|
+
const CEX_ROLES = [
|
|
863
|
+
"deposit",
|
|
864
|
+
"hot_wallet",
|
|
865
|
+
"cold_wallet",
|
|
866
|
+
"withdrawal"
|
|
867
|
+
];
|
|
868
|
+
/** The note a schema carries when the graph serves `SWEPT` or `cex_role`. */
|
|
869
|
+
const EXCHANGE_SCHEMA_NOTE = `cex_role on an :Exchange address says which wallet of its exchange it is: ${CEX_ROLES.join(", ")}. SWEPT runs from an exchange deposit to the hot wallet it swept into; a trail that reaches it ends there.`;
|
|
855
870
|
const FACTS_TRANSFER_COLUMNS = [
|
|
856
871
|
"tx_id",
|
|
857
872
|
"block_date",
|
|
@@ -1087,6 +1102,7 @@ async function buildGraphSchema(options) {
|
|
|
1087
1102
|
}
|
|
1088
1103
|
const words = [...topology.property_keys, ...Object.values(topology.samples).flat()];
|
|
1089
1104
|
if (words.includes("synced_through_height") || words.includes("pair_key")) remarks.push("synced_through_height and pair_key are sync bookkeeping: never filter or sort on them.");
|
|
1105
|
+
if (topology.link_types.includes("SWEPT") || topology.property_keys.includes("cex_role")) remarks.push(EXCHANGE_SCHEMA_NOTE);
|
|
1090
1106
|
remarks.push("Fields come from a sample of the live graph. A rare field may be missing.");
|
|
1091
1107
|
return {
|
|
1092
1108
|
complete: problems.length === 0,
|
|
@@ -1203,6 +1219,6 @@ async function handleMetaSchema(args, deps) {
|
|
|
1203
1219
|
return errorResult(err instanceof GraphSchemaError ? err.message : deps.describeFailure(err));
|
|
1204
1220
|
}
|
|
1205
1221
|
}
|
|
1206
|
-
export {
|
|
1222
|
+
export { graph_schema_exports as a, GRAPH_EXPAND_DESCRIPTION as c, TRANSFERS_MAX as d, handleGraphExpand as f, META_SCHEMA_TITLE as i, GRAPH_EXPAND_TITLE as l, GraphSchemaError as n, handleMetaSchema as o, META_SCHEMA_DESCRIPTION as r, FLOWS_MAX_OFFSET as s, CEX_ROLES as t, GRAPH_EXPAND_TOOL as u };
|
|
1207
1223
|
|
|
1208
|
-
//# sourceMappingURL=graph-schema-
|
|
1224
|
+
//# sourceMappingURL=graph-schema-B8KMeX75.mjs.map
|