chain-insights 0.82.0 → 0.83.1
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/dist/apps/claude-view.html +47 -47
- package/dist/cli.cjs +4 -4
- package/dist/cli.mjs +4 -4
- package/dist/{deployer-screen-BomgSBcq.cjs → deployer-screen-DQw3pC0E.cjs} +36 -12
- package/dist/{deployer-screen-ByQBZEsg.mjs → deployer-screen-e3IbG1Y_.mjs} +37 -13
- package/dist/deployer-screen-e3IbG1Y_.mjs.map +1 -0
- package/dist/{exchange-deposit-check-DPU8W3vK.mjs → exchange-deposit-check-B1yebGBt.mjs} +2 -2
- package/dist/{exchange-deposit-check-DPU8W3vK.mjs.map → exchange-deposit-check-B1yebGBt.mjs.map} +1 -1
- package/dist/{exchange-deposit-check-5e5UwqTn.cjs → exchange-deposit-check-B9_fPt3E.cjs} +1 -1
- package/dist/{graph-schema-0eYvShs7.mjs → graph-schema-BZTzy0XV.mjs} +88 -55
- package/dist/graph-schema-BZTzy0XV.mjs.map +1 -0
- package/dist/{graph-schema-DNvmR6iP.cjs → graph-schema-u0TipQPl.cjs} +87 -54
- package/dist/mcp-proxy.cjs +10 -5
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +10 -5
- package/dist/mcp-proxy.mjs.map +1 -1
- package/docs/graph-tools.md +3 -1
- package/docs/mcp-proxy.md +22 -1
- package/package.json +1 -1
- package/dist/deployer-screen-ByQBZEsg.mjs.map +0 -1
- package/dist/graph-schema-0eYvShs7.mjs.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -273,7 +273,7 @@ async function printNetworkCapability(name, opts) {
|
|
|
273
273
|
async function printNetworkSchema(name, opts) {
|
|
274
274
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BdE8LcF-.cjs")).then((n) => n.config_exports);
|
|
275
275
|
const { resolveGraphMcpEndpoint } = await Promise.resolve().then(() => require("./client-Ddk4X9Ko.cjs")).then((n) => n.client_exports);
|
|
276
|
-
const { formatGraphSchemaText, getGraphSchema } = await Promise.resolve().then(() => require("./graph-schema-
|
|
276
|
+
const { formatGraphSchemaText, getGraphSchema } = await Promise.resolve().then(() => require("./graph-schema-u0TipQPl.cjs")).then((n) => n.graph_schema_exports);
|
|
277
277
|
const config = await loadConfig();
|
|
278
278
|
const schema = await getGraphSchema({
|
|
279
279
|
network: name,
|
|
@@ -649,7 +649,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
649
649
|
console.log(formatToolsTable(visibleRemoteTools(tools)));
|
|
650
650
|
const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./dex-tool-BDERiT5t.cjs")).then((n) => n.dex_tool_exports);
|
|
651
651
|
const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./token-lookup-D-5GBEwF.cjs")).then((n) => n.token_lookup_exports);
|
|
652
|
-
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await Promise.resolve().then(() => require("./deployer-screen-
|
|
652
|
+
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await Promise.resolve().then(() => require("./deployer-screen-DQw3pC0E.cjs")).then((n) => n.deployer_screen_exports);
|
|
653
653
|
console.log("");
|
|
654
654
|
console.log(formatToolsTable([
|
|
655
655
|
{
|
|
@@ -727,7 +727,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
727
727
|
return;
|
|
728
728
|
}
|
|
729
729
|
if (tool === "aml_deployer_screen") {
|
|
730
|
-
const { handleAmlDeployerScreen } = await Promise.resolve().then(() => require("./deployer-screen-
|
|
730
|
+
const { handleAmlDeployerScreen } = await Promise.resolve().then(() => require("./deployer-screen-DQw3pC0E.cjs")).then((n) => n.deployer_screen_exports);
|
|
731
731
|
const result = await withGraphMcpClient("chain-insights-cli-deployer-screen", (client) => handleAmlDeployerScreen({
|
|
732
732
|
network: args["network"],
|
|
733
733
|
address: args["address"]
|
|
@@ -755,7 +755,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
755
755
|
return;
|
|
756
756
|
}
|
|
757
757
|
if (tool === "aml_exchange_deposit_check") {
|
|
758
|
-
const { handleAmlExchangeDepositCheck } = await Promise.resolve().then(() => require("./exchange-deposit-check-
|
|
758
|
+
const { handleAmlExchangeDepositCheck } = await Promise.resolve().then(() => require("./exchange-deposit-check-B9_fPt3E.cjs")).then((n) => n.exchange_deposit_check_exports);
|
|
759
759
|
const { loadExchangeRegistry } = await Promise.resolve().then(() => require("./exchange-registry-CT0rRW__.cjs")).then((n) => n.exchange_registry_exports);
|
|
760
760
|
const result = await withGraphMcpClient("chain-insights-cli-exchange-deposit-check", (client) => handleAmlExchangeDepositCheck({
|
|
761
761
|
network: args["network"],
|
package/dist/cli.mjs
CHANGED
|
@@ -271,7 +271,7 @@ async function printNetworkCapability(name, opts) {
|
|
|
271
271
|
async function printNetworkSchema(name, opts) {
|
|
272
272
|
const { loadConfig } = await import("./config-BkLIqOYq.mjs").then((n) => n.t);
|
|
273
273
|
const { resolveGraphMcpEndpoint } = await import("./client-BaHAIidE.mjs").then((n) => n.r);
|
|
274
|
-
const { formatGraphSchemaText, getGraphSchema } = await import("./graph-schema-
|
|
274
|
+
const { formatGraphSchemaText, getGraphSchema } = await import("./graph-schema-BZTzy0XV.mjs").then((n) => n.a);
|
|
275
275
|
const config = await loadConfig();
|
|
276
276
|
const schema = await getGraphSchema({
|
|
277
277
|
network: name,
|
|
@@ -647,7 +647,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
647
647
|
console.log(formatToolsTable(visibleRemoteTools(tools)));
|
|
648
648
|
const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await import("./dex-tool-25510SNo.mjs").then((n) => n.a);
|
|
649
649
|
const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await import("./token-lookup-QpIv77P2.mjs").then((n) => n.l);
|
|
650
|
-
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await import("./deployer-screen-
|
|
650
|
+
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await import("./deployer-screen-e3IbG1Y_.mjs").then((n) => n.a);
|
|
651
651
|
console.log("");
|
|
652
652
|
console.log(formatToolsTable([
|
|
653
653
|
{
|
|
@@ -725,7 +725,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
725
725
|
return;
|
|
726
726
|
}
|
|
727
727
|
if (tool === "aml_deployer_screen") {
|
|
728
|
-
const { handleAmlDeployerScreen } = await import("./deployer-screen-
|
|
728
|
+
const { handleAmlDeployerScreen } = await import("./deployer-screen-e3IbG1Y_.mjs").then((n) => n.a);
|
|
729
729
|
const result = await withGraphMcpClient("chain-insights-cli-deployer-screen", (client) => handleAmlDeployerScreen({
|
|
730
730
|
network: args["network"],
|
|
731
731
|
address: args["address"]
|
|
@@ -753,7 +753,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
753
753
|
return;
|
|
754
754
|
}
|
|
755
755
|
if (tool === "aml_exchange_deposit_check") {
|
|
756
|
-
const { handleAmlExchangeDepositCheck } = await import("./exchange-deposit-check-
|
|
756
|
+
const { handleAmlExchangeDepositCheck } = await import("./exchange-deposit-check-B1yebGBt.mjs").then((n) => n.a);
|
|
757
757
|
const { loadExchangeRegistry } = await import("./exchange-registry-CoLgHw6d.mjs").then((n) => n.r);
|
|
758
758
|
const result = await withGraphMcpClient("chain-insights-cli-exchange-deposit-check", (client) => handleAmlExchangeDepositCheck({
|
|
759
759
|
network: args["network"],
|
|
@@ -15,6 +15,14 @@ const require_token_lookup = require("./token-lookup-D-5GBEwF.cjs");
|
|
|
15
15
|
* of all time and its first inbound bridge deposit;
|
|
16
16
|
* wallet the address as the launcher itself: the same funder and bridge reads.
|
|
17
17
|
*
|
|
18
|
+
* The funder is the launcher's earliest inbound FLOWED_TO. On a lane whose
|
|
19
|
+
* money family lists ROUTED_TO (the three link levels) it is the earliest of
|
|
20
|
+
* its inbound FLOWED_TO and ROUTED_TO from another address: a launcher funded
|
|
21
|
+
* by the proceeds of a swap names the payer of that swap. A self route (the
|
|
22
|
+
* launcher swapped for itself) is never the funder: it spent money the
|
|
23
|
+
* launcher already held, so the search goes on to what paid it in. Any other
|
|
24
|
+
* lane gets the reads of 0.82.0, byte for byte.
|
|
25
|
+
*
|
|
18
26
|
* The token read answers first when it holds a row; the wallet read answers
|
|
19
27
|
* otherwise. The tool returns facts and never a score, a level or a verdict:
|
|
20
28
|
* the description below is the contract with every host, Claude Desktop chat
|
|
@@ -29,7 +37,7 @@ var deployer_screen_exports = /* @__PURE__ */ require_rolldown_runtime.__exportA
|
|
|
29
37
|
const AML_DEPLOYER_SCREEN_TOOL = "aml_deployer_screen";
|
|
30
38
|
const AML_DEPLOYER_SCREEN_SCHEMA = "chain-insights.aml-deployer-screen.v1";
|
|
31
39
|
const AML_DEPLOYER_SCREEN_TITLE = "Deployer screen";
|
|
32
|
-
const AML_DEPLOYER_SCREEN_DESCRIPTION = "Facts only, no score and no verdict: screens who is behind a token or a wallet. For a token contract it returns the creation transaction and the launcher (the wallet that sent it); for a wallet, that wallet as the launcher. Then the launcher's first funder of all time and what kind of wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: launcher_resolved is then false. not_covered lists what the graph cannot see yet.";
|
|
40
|
+
const AML_DEPLOYER_SCREEN_DESCRIPTION = "Facts only, no score and no verdict: screens who is behind a token or a wallet. For a token contract it returns the creation transaction and the launcher (the wallet that sent it); for a wallet, that wallet as the launcher. Then the launcher's first funder of all time and what kind of wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: launcher_resolved is then false. On a lane whose money family lists ROUTED_TO the first funder may have paid through a swap (funded_via swap): it paid, a router and a pool swapped, the launcher got another asset; a swap the launcher made for itself is never its funder. not_covered lists what the graph cannot see yet.";
|
|
33
41
|
const AML_DEPLOYER_SCREEN_ANNOTATIONS = {
|
|
34
42
|
readOnlyHint: true,
|
|
35
43
|
idempotentHint: true,
|
|
@@ -45,6 +53,8 @@ const NOT_COVERED = [
|
|
|
45
53
|
const ADDRESS_INPUT = /^0x[0-9a-fA-F]{40}$/;
|
|
46
54
|
const ADDRESS_READ = /^0x[0-9a-f]{40}$/;
|
|
47
55
|
const FUNDER_READ = "OPTIONAL MATCH (f:Address)-[e:FLOWED_TO]->(l)";
|
|
56
|
+
const LEVELS_FUNDER_READ = "OPTIONAL MATCH (f:Address)-[e:FLOWED_TO|ROUTED_TO]->(l) WHERE f.address <> l.address";
|
|
57
|
+
const LEVELS_FUNDING_COLUMNS = "coalesce(e.bought_usd_sum, e.amount_usd_sum) AS funding_usd, type(e) AS funding_link";
|
|
48
58
|
const BRIDGE_READ = "OPTIONAL MATCH (ch:Chain)-[b:BRIDGED]->(l) WHERE b.kind IN ['TOKEN_DEPOSIT','NATIVE_DEPOSIT']";
|
|
49
59
|
const PARTY_COLUMNS = [
|
|
50
60
|
"labels(l) AS launcher_roles",
|
|
@@ -91,39 +101,45 @@ function assertReadAddress(address) {
|
|
|
91
101
|
if (!ADDRESS_READ.test(address)) throw new Error(`deployer screen: ${JSON.stringify(address)} is not a lowercase 0x address`);
|
|
92
102
|
}
|
|
93
103
|
/** The token read: the address as a contract, its first creation and who sent it. */
|
|
94
|
-
function tokenScreenQuery(address) {
|
|
104
|
+
function tokenScreenQuery(address, shape = "route") {
|
|
95
105
|
assertReadAddress(address);
|
|
96
106
|
return [
|
|
97
107
|
`USE topology MATCH (t:Address {address:'${address}'})<-[c:DEPLOYED_CONTRACT]-(:Address)`,
|
|
98
108
|
"WITH t, c ORDER BY c.block_height LIMIT 1",
|
|
99
109
|
"MATCH (l:Address {address: c.tx_origin})",
|
|
100
|
-
|
|
110
|
+
funderRead(shape),
|
|
101
111
|
"WITH t, c, l, f, e ORDER BY e.first_seen_timestamp LIMIT 1",
|
|
102
112
|
BRIDGE_READ,
|
|
103
113
|
"WITH t, c, l, f, e, ch, b ORDER BY b.first_height LIMIT 1",
|
|
104
|
-
`RETURN ${TOKEN_COLUMNS}, ${
|
|
114
|
+
`RETURN ${TOKEN_COLUMNS}, ${partyColumns(shape)} LIMIT 1`
|
|
105
115
|
].join(" ");
|
|
106
116
|
}
|
|
117
|
+
function funderRead(shape) {
|
|
118
|
+
return shape === "levels" ? LEVELS_FUNDER_READ : FUNDER_READ;
|
|
119
|
+
}
|
|
120
|
+
function partyColumns(shape) {
|
|
121
|
+
return shape === "levels" ? PARTY_COLUMNS.replace("e.amount_usd_sum AS funding_usd", LEVELS_FUNDING_COLUMNS) : PARTY_COLUMNS;
|
|
122
|
+
}
|
|
107
123
|
/** The wallet read: the address as the launcher itself. */
|
|
108
|
-
function walletScreenQuery(address) {
|
|
124
|
+
function walletScreenQuery(address, shape = "route") {
|
|
109
125
|
assertReadAddress(address);
|
|
110
126
|
return [
|
|
111
127
|
`USE topology MATCH (l:Address {address:'${address}'})`,
|
|
112
|
-
|
|
128
|
+
funderRead(shape),
|
|
113
129
|
"WITH l, f, e ORDER BY e.first_seen_timestamp LIMIT 1",
|
|
114
130
|
BRIDGE_READ,
|
|
115
131
|
"WITH l, f, e, ch, b ORDER BY b.first_height LIMIT 1",
|
|
116
|
-
`RETURN l.address AS launcher, ${
|
|
132
|
+
`RETURN l.address AS launcher, ${partyColumns(shape)} LIMIT 1`
|
|
117
133
|
].join(" ");
|
|
118
134
|
}
|
|
119
135
|
/** The one batch the tool sends: members `token` and `wallet`. */
|
|
120
|
-
function deployerScreenQueries(address) {
|
|
136
|
+
function deployerScreenQueries(address, shape = "route") {
|
|
121
137
|
return [{
|
|
122
138
|
id: "token",
|
|
123
|
-
query: tokenScreenQuery(address)
|
|
139
|
+
query: tokenScreenQuery(address, shape)
|
|
124
140
|
}, {
|
|
125
141
|
id: "wallet",
|
|
126
|
-
query: walletScreenQuery(address)
|
|
142
|
+
query: walletScreenQuery(address, shape)
|
|
127
143
|
}];
|
|
128
144
|
}
|
|
129
145
|
function isRecord(value) {
|
|
@@ -236,7 +252,8 @@ function funderOf(row) {
|
|
|
236
252
|
funded_at: fundedAt,
|
|
237
253
|
funded_at_utc: utcOrNull(fundedAt),
|
|
238
254
|
funding_tx_count: numberOrNull(row.funding_tx_count),
|
|
239
|
-
funding_usd: numberOrNull(row.funding_usd)
|
|
255
|
+
funding_usd: numberOrNull(row.funding_usd),
|
|
256
|
+
...row.funding_link === "ROUTED_TO" ? { funded_via: "swap" } : row.funding_link === "FLOWED_TO" ? { funded_via: "transfer" } : {}
|
|
240
257
|
};
|
|
241
258
|
}
|
|
242
259
|
function bridgedInOf(row) {
|
|
@@ -357,6 +374,7 @@ function hintFor(result) {
|
|
|
357
374
|
if (result.input_kind === "wallet" && result.launcher?.roles.some((r) => r === "Contract" || r === "Token")) parts.push("The address is a contract, but the graph holds no creation record for it, so it was screened as a wallet.");
|
|
358
375
|
if (result.launcher_resolved === false) parts.push("The launcher is a bundler: it sends transactions for others, so the person behind the launch is not known from this read.");
|
|
359
376
|
if (!result.first_funder) parts.push("The launcher has no inbound flow in the graph: no first funder.");
|
|
377
|
+
if (result.first_funder?.funded_via === "swap") parts.push("The first funder paid the launcher through a swap: say it paid one asset and the launcher got another, and never name a router or a pool as the funder.");
|
|
360
378
|
parts.push(`not_covered names what the graph cannot see yet (${NOT_COVERED.join(", ")}); say so when it matters.`);
|
|
361
379
|
return parts.join(" ");
|
|
362
380
|
}
|
|
@@ -393,11 +411,17 @@ async function handleAmlDeployerScreen(args, deps) {
|
|
|
393
411
|
const address = raw.toLowerCase();
|
|
394
412
|
const unavailable = await deps.unavailable?.();
|
|
395
413
|
if (unavailable) return errorResult(`No deployer screen read was sent: ${unavailable} There is no answer yet, which is not "not found": try again later.`);
|
|
414
|
+
let shape = "route";
|
|
415
|
+
if (deps.linkShape) try {
|
|
416
|
+
shape = await deps.linkShape(network);
|
|
417
|
+
} catch {
|
|
418
|
+
shape = "route";
|
|
419
|
+
}
|
|
396
420
|
let answer;
|
|
397
421
|
try {
|
|
398
422
|
answer = await deps.graphQueryBatch({
|
|
399
423
|
network,
|
|
400
|
-
queries: deployerScreenQueries(address)
|
|
424
|
+
queries: deployerScreenQueries(address, shape)
|
|
401
425
|
});
|
|
402
426
|
} catch (err) {
|
|
403
427
|
return errorResult(`The deployer screen read failed: ${deps.describeFailure(err)} This is not "not found": send the same screen again once.`);
|
|
@@ -15,6 +15,14 @@ import { c as refusalOf, s as membersOf } from "./token-lookup-QpIv77P2.mjs";
|
|
|
15
15
|
* of all time and its first inbound bridge deposit;
|
|
16
16
|
* wallet the address as the launcher itself: the same funder and bridge reads.
|
|
17
17
|
*
|
|
18
|
+
* The funder is the launcher's earliest inbound FLOWED_TO. On a lane whose
|
|
19
|
+
* money family lists ROUTED_TO (the three link levels) it is the earliest of
|
|
20
|
+
* its inbound FLOWED_TO and ROUTED_TO from another address: a launcher funded
|
|
21
|
+
* by the proceeds of a swap names the payer of that swap. A self route (the
|
|
22
|
+
* launcher swapped for itself) is never the funder: it spent money the
|
|
23
|
+
* launcher already held, so the search goes on to what paid it in. Any other
|
|
24
|
+
* lane gets the reads of 0.82.0, byte for byte.
|
|
25
|
+
*
|
|
18
26
|
* The token read answers first when it holds a row; the wallet read answers
|
|
19
27
|
* otherwise. The tool returns facts and never a score, a level or a verdict:
|
|
20
28
|
* the description below is the contract with every host, Claude Desktop chat
|
|
@@ -29,7 +37,7 @@ var deployer_screen_exports = /* @__PURE__ */ __exportAll({
|
|
|
29
37
|
const AML_DEPLOYER_SCREEN_TOOL = "aml_deployer_screen";
|
|
30
38
|
const AML_DEPLOYER_SCREEN_SCHEMA = "chain-insights.aml-deployer-screen.v1";
|
|
31
39
|
const AML_DEPLOYER_SCREEN_TITLE = "Deployer screen";
|
|
32
|
-
const AML_DEPLOYER_SCREEN_DESCRIPTION = "Facts only, no score and no verdict: screens who is behind a token or a wallet. For a token contract it returns the creation transaction and the launcher (the wallet that sent it); for a wallet, that wallet as the launcher. Then the launcher's first funder of all time and what kind of wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: launcher_resolved is then false. not_covered lists what the graph cannot see yet.";
|
|
40
|
+
const AML_DEPLOYER_SCREEN_DESCRIPTION = "Facts only, no score and no verdict: screens who is behind a token or a wallet. For a token contract it returns the creation transaction and the launcher (the wallet that sent it); for a wallet, that wallet as the launcher. Then the launcher's first funder of all time and what kind of wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: launcher_resolved is then false. On a lane whose money family lists ROUTED_TO the first funder may have paid through a swap (funded_via swap): it paid, a router and a pool swapped, the launcher got another asset; a swap the launcher made for itself is never its funder. not_covered lists what the graph cannot see yet.";
|
|
33
41
|
const AML_DEPLOYER_SCREEN_ANNOTATIONS = {
|
|
34
42
|
readOnlyHint: true,
|
|
35
43
|
idempotentHint: true,
|
|
@@ -45,6 +53,8 @@ const NOT_COVERED = [
|
|
|
45
53
|
const ADDRESS_INPUT = /^0x[0-9a-fA-F]{40}$/;
|
|
46
54
|
const ADDRESS_READ = /^0x[0-9a-f]{40}$/;
|
|
47
55
|
const FUNDER_READ = "OPTIONAL MATCH (f:Address)-[e:FLOWED_TO]->(l)";
|
|
56
|
+
const LEVELS_FUNDER_READ = "OPTIONAL MATCH (f:Address)-[e:FLOWED_TO|ROUTED_TO]->(l) WHERE f.address <> l.address";
|
|
57
|
+
const LEVELS_FUNDING_COLUMNS = "coalesce(e.bought_usd_sum, e.amount_usd_sum) AS funding_usd, type(e) AS funding_link";
|
|
48
58
|
const BRIDGE_READ = "OPTIONAL MATCH (ch:Chain)-[b:BRIDGED]->(l) WHERE b.kind IN ['TOKEN_DEPOSIT','NATIVE_DEPOSIT']";
|
|
49
59
|
const PARTY_COLUMNS = [
|
|
50
60
|
"labels(l) AS launcher_roles",
|
|
@@ -91,39 +101,45 @@ function assertReadAddress(address) {
|
|
|
91
101
|
if (!ADDRESS_READ.test(address)) throw new Error(`deployer screen: ${JSON.stringify(address)} is not a lowercase 0x address`);
|
|
92
102
|
}
|
|
93
103
|
/** The token read: the address as a contract, its first creation and who sent it. */
|
|
94
|
-
function tokenScreenQuery(address) {
|
|
104
|
+
function tokenScreenQuery(address, shape = "route") {
|
|
95
105
|
assertReadAddress(address);
|
|
96
106
|
return [
|
|
97
107
|
`USE topology MATCH (t:Address {address:'${address}'})<-[c:DEPLOYED_CONTRACT]-(:Address)`,
|
|
98
108
|
"WITH t, c ORDER BY c.block_height LIMIT 1",
|
|
99
109
|
"MATCH (l:Address {address: c.tx_origin})",
|
|
100
|
-
|
|
110
|
+
funderRead(shape),
|
|
101
111
|
"WITH t, c, l, f, e ORDER BY e.first_seen_timestamp LIMIT 1",
|
|
102
112
|
BRIDGE_READ,
|
|
103
113
|
"WITH t, c, l, f, e, ch, b ORDER BY b.first_height LIMIT 1",
|
|
104
|
-
`RETURN ${TOKEN_COLUMNS}, ${
|
|
114
|
+
`RETURN ${TOKEN_COLUMNS}, ${partyColumns(shape)} LIMIT 1`
|
|
105
115
|
].join(" ");
|
|
106
116
|
}
|
|
117
|
+
function funderRead(shape) {
|
|
118
|
+
return shape === "levels" ? LEVELS_FUNDER_READ : FUNDER_READ;
|
|
119
|
+
}
|
|
120
|
+
function partyColumns(shape) {
|
|
121
|
+
return shape === "levels" ? PARTY_COLUMNS.replace("e.amount_usd_sum AS funding_usd", LEVELS_FUNDING_COLUMNS) : PARTY_COLUMNS;
|
|
122
|
+
}
|
|
107
123
|
/** The wallet read: the address as the launcher itself. */
|
|
108
|
-
function walletScreenQuery(address) {
|
|
124
|
+
function walletScreenQuery(address, shape = "route") {
|
|
109
125
|
assertReadAddress(address);
|
|
110
126
|
return [
|
|
111
127
|
`USE topology MATCH (l:Address {address:'${address}'})`,
|
|
112
|
-
|
|
128
|
+
funderRead(shape),
|
|
113
129
|
"WITH l, f, e ORDER BY e.first_seen_timestamp LIMIT 1",
|
|
114
130
|
BRIDGE_READ,
|
|
115
131
|
"WITH l, f, e, ch, b ORDER BY b.first_height LIMIT 1",
|
|
116
|
-
`RETURN l.address AS launcher, ${
|
|
132
|
+
`RETURN l.address AS launcher, ${partyColumns(shape)} LIMIT 1`
|
|
117
133
|
].join(" ");
|
|
118
134
|
}
|
|
119
135
|
/** The one batch the tool sends: members `token` and `wallet`. */
|
|
120
|
-
function deployerScreenQueries(address) {
|
|
136
|
+
function deployerScreenQueries(address, shape = "route") {
|
|
121
137
|
return [{
|
|
122
138
|
id: "token",
|
|
123
|
-
query: tokenScreenQuery(address)
|
|
139
|
+
query: tokenScreenQuery(address, shape)
|
|
124
140
|
}, {
|
|
125
141
|
id: "wallet",
|
|
126
|
-
query: walletScreenQuery(address)
|
|
142
|
+
query: walletScreenQuery(address, shape)
|
|
127
143
|
}];
|
|
128
144
|
}
|
|
129
145
|
function isRecord(value) {
|
|
@@ -236,7 +252,8 @@ function funderOf(row) {
|
|
|
236
252
|
funded_at: fundedAt,
|
|
237
253
|
funded_at_utc: utcOrNull(fundedAt),
|
|
238
254
|
funding_tx_count: numberOrNull(row.funding_tx_count),
|
|
239
|
-
funding_usd: numberOrNull(row.funding_usd)
|
|
255
|
+
funding_usd: numberOrNull(row.funding_usd),
|
|
256
|
+
...row.funding_link === "ROUTED_TO" ? { funded_via: "swap" } : row.funding_link === "FLOWED_TO" ? { funded_via: "transfer" } : {}
|
|
240
257
|
};
|
|
241
258
|
}
|
|
242
259
|
function bridgedInOf(row) {
|
|
@@ -357,6 +374,7 @@ function hintFor(result) {
|
|
|
357
374
|
if (result.input_kind === "wallet" && result.launcher?.roles.some((r) => r === "Contract" || r === "Token")) parts.push("The address is a contract, but the graph holds no creation record for it, so it was screened as a wallet.");
|
|
358
375
|
if (result.launcher_resolved === false) parts.push("The launcher is a bundler: it sends transactions for others, so the person behind the launch is not known from this read.");
|
|
359
376
|
if (!result.first_funder) parts.push("The launcher has no inbound flow in the graph: no first funder.");
|
|
377
|
+
if (result.first_funder?.funded_via === "swap") parts.push("The first funder paid the launcher through a swap: say it paid one asset and the launcher got another, and never name a router or a pool as the funder.");
|
|
360
378
|
parts.push(`not_covered names what the graph cannot see yet (${NOT_COVERED.join(", ")}); say so when it matters.`);
|
|
361
379
|
return parts.join(" ");
|
|
362
380
|
}
|
|
@@ -393,11 +411,17 @@ async function handleAmlDeployerScreen(args, deps) {
|
|
|
393
411
|
const address = raw.toLowerCase();
|
|
394
412
|
const unavailable = await deps.unavailable?.();
|
|
395
413
|
if (unavailable) return errorResult(`No deployer screen read was sent: ${unavailable} There is no answer yet, which is not "not found": try again later.`);
|
|
414
|
+
let shape = "route";
|
|
415
|
+
if (deps.linkShape) try {
|
|
416
|
+
shape = await deps.linkShape(network);
|
|
417
|
+
} catch {
|
|
418
|
+
shape = "route";
|
|
419
|
+
}
|
|
396
420
|
let answer;
|
|
397
421
|
try {
|
|
398
422
|
answer = await deps.graphQueryBatch({
|
|
399
423
|
network,
|
|
400
|
-
queries: deployerScreenQueries(address)
|
|
424
|
+
queries: deployerScreenQueries(address, shape)
|
|
401
425
|
});
|
|
402
426
|
} catch (err) {
|
|
403
427
|
return errorResult(`The deployer screen read failed: ${deps.describeFailure(err)} This is not "not found": send the same screen again once.`);
|
|
@@ -410,4 +434,4 @@ async function handleAmlDeployerScreen(args, deps) {
|
|
|
410
434
|
}
|
|
411
435
|
export { deployer_screen_exports as a, AML_DEPLOYER_SCREEN_TOOL as i, AML_DEPLOYER_SCREEN_DESCRIPTION as n, handleAmlDeployerScreen as o, AML_DEPLOYER_SCREEN_TITLE as r, AML_DEPLOYER_SCREEN_ANNOTATIONS as t };
|
|
412
436
|
|
|
413
|
-
//# sourceMappingURL=deployer-screen-
|
|
437
|
+
//# sourceMappingURL=deployer-screen-e3IbG1Y_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployer-screen-e3IbG1Y_.mjs","names":[],"sources":["../src/mcp/deployer-screen.ts"],"sourcesContent":["/**\n * aml_deployer_screen: who is behind a token or a wallet, as facts.\n *\n * A local tool of the proxy. It sends one graph_query_batch with two reads on\n * USE topology, both anchored on the address:\n *\n * token the address as a contract: its first creation (DEPLOYED_CONTRACT),\n * the launcher (the transaction's sender), the launcher's first funder\n * of all time and its first inbound bridge deposit;\n * wallet the address as the launcher itself: the same funder and bridge reads.\n *\n * The funder is the launcher's earliest inbound FLOWED_TO. On a lane whose\n * money family lists ROUTED_TO (the three link levels) it is the earliest of\n * its inbound FLOWED_TO and ROUTED_TO from another address: a launcher funded\n * by the proceeds of a swap names the payer of that swap. A self route (the\n * launcher swapped for itself) is never the funder: it spent money the\n * launcher already held, so the search goes on to what paid it in. Any other\n * lane gets the reads of 0.82.0, byte for byte.\n *\n * The token read answers first when it holds a row; the wallet read answers\n * otherwise. The tool returns facts and never a score, a level or a verdict:\n * the description below is the contract with every host, Claude Desktop chat\n * included, which reads no skill.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport type { SwapLinkShape } from './layer-routing.js'\nimport { isEpochMs, utcText } from './timestamp-text.js'\nimport {\n membersOf,\n refusalOf,\n type GraphAnswer,\n type Member,\n type TokenToolDependencies,\n} from './token-lookup.js'\n\nexport const AML_DEPLOYER_SCREEN_TOOL = 'aml_deployer_screen' as const\nexport const AML_DEPLOYER_SCREEN_SCHEMA = 'chain-insights.aml-deployer-screen.v1' as const\nexport const AML_DEPLOYER_SCREEN_TITLE = 'Deployer screen'\nexport const AML_DEPLOYER_SCREEN_DESCRIPTION =\n 'Facts only, no score and no verdict: screens who is behind a token or a wallet. ' +\n 'For a token contract it returns the creation transaction and the launcher (the wallet that sent it); ' +\n 'for a wallet, that wallet as the launcher. Then the launcher\\'s first funder of all time and what kind of ' +\n 'wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the ' +\n 'funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. ' +\n 'The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; ' +\n 'a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: ' +\n 'launcher_resolved is then false. On a lane whose money family lists ROUTED_TO the first funder may have paid ' +\n 'through a swap (funded_via swap): it paid, a router and a pool swapped, the launcher got another asset; a swap ' +\n 'the launcher made for itself is never its funder. not_covered lists what the graph cannot see yet.'\nexport const AML_DEPLOYER_SCREEN_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const AML_DEPLOYER_SCREEN_ARGS = ['network', 'address'] as const\n\n/** What the two reads cannot see yet, named in every answer. */\nexport const NOT_COVERED = ['exploit_labels', 'ml_labels', 'bridge_sender', 'ethereum_history'] as const\n\nexport type CrimeKind = 'sanctioned' | 'scam' | 'victim' | 'issuer_frozen' | 'risk'\nexport interface Crime {\n kind: CrimeKind\n value: string\n level: string | null\n}\n\nexport interface Party {\n address: string\n roles: string[]\n crime: Crime[]\n first_activity: number | null\n first_activity_utc: string | null\n degree_in: number | null\n degree_out: number | null\n}\n\nexport type FunderKind = 'scam' | 'mixer' | 'exchange' | 'bridge' | 'bundler' | 'launchpad' | 'contract' | 'wallet'\n\nexport interface Funder {\n address: string\n kind: FunderKind\n roles: string[]\n crime: Crime[]\n degree_out: number | null\n first_activity: number | null\n first_activity_utc: string | null\n funded_at: number | null\n funded_at_utc: string | null\n funding_tx_count: number | null\n funding_usd: number | null\n /**\n * On a lane with the levels only: `transfer` when the first money came on\n * FLOWED_TO, `swap` when on ROUTED_TO (the funder paid, the launcher got the\n * bought asset; funding_usd is then what the launcher got).\n */\n funded_via?: 'transfer' | 'swap'\n}\n\nexport interface Creation {\n tx: string | null\n block: number | null\n time: number | null\n time_utc: string | null\n deployer: string | null\n factory: string | null\n mode: 'direct' | 'factory'\n}\n\nexport interface BridgedIn {\n chain: string | null\n bridge: string | null\n kind: string | null\n asset: string | null\n first_block: number | null\n}\n\nexport interface AmlDeployerScreenResult {\n schema: typeof AML_DEPLOYER_SCREEN_SCHEMA\n tool: typeof AML_DEPLOYER_SCREEN_TOOL\n network: string\n input: string\n /** false when the graph holds no node for the address: every fact below is then null. */\n found: boolean\n input_kind: 'token' | 'wallet' | null\n token: { address: string; roles: string[] } | null\n creation: Creation | null\n launcher: Party | null\n launcher_resolved: boolean | null\n first_funder: Funder | null\n bridged_in: BridgedIn | null\n not_covered: string[]\n hint: string\n}\n\nexport type DeployerScreenDependencies = Pick<\n TokenToolDependencies,\n 'graphQueryBatch' | 'unavailable' | 'describeFailure'\n> & {\n /**\n * The lane's graph shape (`meta_network_capabilities`, kept by the proxy).\n * The funder read walks ROUTED_TO only when it answers `levels`; absent,\n * `route` or a read that throws keeps the reads of 0.82.0.\n */\n linkShape?: (network: string) => Promise<SwapLinkShape> | SwapLinkShape\n}\n\nexport type AmlDeployerScreenToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\n// The only address form ever written into a read: 0x and 40 lowercase hex.\nconst ADDRESS_INPUT = /^0x[0-9a-fA-F]{40}$/\nconst ADDRESS_READ = /^0x[0-9a-f]{40}$/\n\n// The funder's first inbound flow and the first inbound bridge deposit of the\n// launcher `l`, and the columns both reads return about them.\nconst FUNDER_READ = 'OPTIONAL MATCH (f:Address)-[e:FLOWED_TO]->(l)'\n// On a lane with the levels: the first money from another address, funds or a\n// swap route; the self route is left out (it spent what the launcher held).\nconst LEVELS_FUNDER_READ =\n 'OPTIONAL MATCH (f:Address)-[e:FLOWED_TO|ROUTED_TO]->(l) WHERE f.address <> l.address'\n// What the launcher got: a route carries it in bought_usd_sum, a FLOWED_TO in\n// amount_usd_sum; and which link it came on.\nconst LEVELS_FUNDING_COLUMNS =\n 'coalesce(e.bought_usd_sum, e.amount_usd_sum) AS funding_usd, type(e) AS funding_link'\nconst BRIDGE_READ =\n \"OPTIONAL MATCH (ch:Chain)-[b:BRIDGED]->(l) WHERE b.kind IN ['TOKEN_DEPOSIT','NATIVE_DEPOSIT']\"\nconst PARTY_COLUMNS = [\n 'labels(l) AS launcher_roles',\n 'l.first_activity_timestamp AS launcher_first_activity',\n 'l.degree_in AS launcher_degree_in',\n 'l.degree_out AS launcher_degree_out',\n 'l.is_sanctioned AS launcher_is_sanctioned',\n 'l.is_scam AS launcher_is_scam',\n 'l.is_victim AS launcher_is_victim',\n 'l.is_issuer_frozen AS launcher_is_issuer_frozen',\n 'l.label_risk_labels AS launcher_risk_labels',\n 'l.label_risk_levels AS launcher_risk_levels',\n 'f.address AS funder',\n 'labels(f) AS funder_roles',\n 'f.degree_out AS funder_degree_out',\n 'f.first_activity_timestamp AS funder_first_activity',\n 'f.is_sanctioned AS funder_is_sanctioned',\n 'f.is_scam AS funder_is_scam',\n 'f.is_victim AS funder_is_victim',\n 'f.is_issuer_frozen AS funder_is_issuer_frozen',\n 'f.label_risk_labels AS funder_risk_labels',\n 'f.label_risk_levels AS funder_risk_levels',\n 'e.first_seen_timestamp AS funded_at',\n 'e.tx_count AS funding_tx_count',\n 'e.amount_usd_sum AS funding_usd',\n 'ch.network AS bridged_chain',\n 'ch.address AS bridged_bridge',\n 'b.kind AS bridged_kind',\n 'b.asset AS bridged_asset',\n 'b.first_height AS bridged_first_block',\n].join(', ')\nconst TOKEN_COLUMNS = [\n 't.address AS token',\n 'labels(t) AS token_roles',\n 'c.tx_origin AS launcher',\n 'c.deployer_address AS deployer',\n 'c.factory_address AS factory',\n 'c.kind AS creation_kind',\n 'c.tx_id AS creation_tx',\n 'c.block_height AS creation_block',\n 'c.block_timestamp AS creation_time',\n].join(', ')\n\nfunction assertReadAddress(address: string): void {\n if (!ADDRESS_READ.test(address)) {\n throw new Error(`deployer screen: ${JSON.stringify(address)} is not a lowercase 0x address`)\n }\n}\n\n/** The token read: the address as a contract, its first creation and who sent it. */\nexport function tokenScreenQuery(address: string, shape: SwapLinkShape = 'route'): string {\n assertReadAddress(address)\n return [\n `USE topology MATCH (t:Address {address:'${address}'})<-[c:DEPLOYED_CONTRACT]-(:Address)`,\n 'WITH t, c ORDER BY c.block_height LIMIT 1',\n 'MATCH (l:Address {address: c.tx_origin})',\n funderRead(shape),\n 'WITH t, c, l, f, e ORDER BY e.first_seen_timestamp LIMIT 1',\n BRIDGE_READ,\n 'WITH t, c, l, f, e, ch, b ORDER BY b.first_height LIMIT 1',\n `RETURN ${TOKEN_COLUMNS}, ${partyColumns(shape)} LIMIT 1`,\n ].join(' ')\n}\n\nfunction funderRead(shape: SwapLinkShape): string {\n return shape === 'levels' ? LEVELS_FUNDER_READ : FUNDER_READ\n}\n\nfunction partyColumns(shape: SwapLinkShape): string {\n return shape === 'levels'\n ? PARTY_COLUMNS.replace('e.amount_usd_sum AS funding_usd', LEVELS_FUNDING_COLUMNS)\n : PARTY_COLUMNS\n}\n\n/** The wallet read: the address as the launcher itself. */\nexport function walletScreenQuery(address: string, shape: SwapLinkShape = 'route'): string {\n assertReadAddress(address)\n return [\n `USE topology MATCH (l:Address {address:'${address}'})`,\n funderRead(shape),\n 'WITH l, f, e ORDER BY e.first_seen_timestamp LIMIT 1',\n BRIDGE_READ,\n 'WITH l, f, e, ch, b ORDER BY b.first_height LIMIT 1',\n `RETURN l.address AS launcher, ${partyColumns(shape)} LIMIT 1`,\n ].join(' ')\n}\n\n/** The one batch the tool sends: members `token` and `wallet`. */\nexport function deployerScreenQueries(\n address: string,\n shape: SwapLinkShape = 'route'\n): Array<{ id: 'token' | 'wallet'; query: string }> {\n return [\n { id: 'token', query: tokenScreenQuery(address, shape) },\n { id: 'wallet', query: walletScreenQuery(address, shape) },\n ]\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value.trim() : null\n\nconst numberOrNull = (value: unknown): number | null => {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)))\n return Number(value)\n return null\n}\n\nconst addressOrNull = (value: unknown): string | null =>\n typeof value === 'string' && ADDRESS_INPUT.test(value.trim()) ? value.trim().toLowerCase() : null\n\nconst utcOrNull = (ms: number | null): string | null => (isEpochMs(ms) ? utcText(ms) : null)\n\n/**\n * A label from a third-party explorer tag source is training data, never served.\n * The graph is not meant to carry one; this drops it if it ever does.\n */\nexport function isServedLabel(value: string): boolean {\n const lower = value.trim().toLowerCase()\n return !(lower.startsWith('etherscan') || lower.startsWith('data:etherscan'))\n}\n\nconst strings = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((v): v is string => typeof v === 'string') : []\n\n/** labels(n) minus Address, with an unserved label dropped. */\nfunction rolesOf(value: unknown): string[] {\n return strings(value).filter((role) => role !== 'Address' && isServedLabel(role))\n}\n\n// The flag of each judgement mark, and the mark's label word served as its value.\nconst FLAG_CRIMES: Array<[CrimeKind, string, string]> = [\n ['sanctioned', 'is_sanctioned', 'Sanctioned'],\n ['scam', 'is_scam', 'Scam'],\n ['victim', 'is_victim', 'Victim'],\n ['issuer_frozen', 'is_issuer_frozen', 'IssuerFrozen'],\n]\n\n/** The flags that are true, then one risk entry per served risk label with its level. */\nfunction crimeOf(row: Record<string, unknown>, prefix: 'launcher' | 'funder'): Crime[] {\n const crime: Crime[] = []\n for (const [kind, flag, value] of FLAG_CRIMES) {\n if (row[`${prefix}_${flag}`] === true) crime.push({ kind, value, level: null })\n }\n const labels = Array.isArray(row[`${prefix}_risk_labels`]) ? (row[`${prefix}_risk_labels`] as unknown[]) : []\n const levels = Array.isArray(row[`${prefix}_risk_levels`]) ? (row[`${prefix}_risk_levels`] as unknown[]) : []\n labels.forEach((label, at) => {\n if (typeof label !== 'string' || label.trim() === '' || !isServedLabel(label)) return\n crime.push({ kind: 'risk', value: label, level: textOrNull(levels[at]) })\n })\n return crime\n}\n\n/** The funder kinds, first match wins; a contract with no role is 'contract', no match is a plain wallet. */\nexport const FUNDER_KIND_RULES: ReadonlyArray<\n readonly [FunderKind, (roles: readonly string[], isScam: boolean) => boolean]\n> = [\n ['scam', (roles, isScam) => isScam || roles.includes('Scam')],\n ['mixer', (roles) => roles.includes('Mixer')],\n ['exchange', (roles) => roles.includes('Exchange')],\n ['bridge', (roles) => roles.includes('Bridge')],\n ['bundler', (roles) => roles.includes('Bundler')],\n ['launchpad', (roles) => roles.includes('Pool') || roles.includes('Protocol')],\n ['contract', (roles) => roles.includes('Contract')],\n]\n\nexport function funderKind(roles: readonly string[], isScam = false): FunderKind {\n return FUNDER_KIND_RULES.find(([, rule]) => rule(roles, isScam))?.[0] ?? 'wallet'\n}\n\nfunction partyOf(row: Record<string, unknown>): Party | null {\n const address = addressOrNull(row.launcher)\n if (!address) return null\n const firstActivity = numberOrNull(row.launcher_first_activity)\n return {\n address,\n roles: rolesOf(row.launcher_roles),\n crime: crimeOf(row, 'launcher'),\n first_activity: firstActivity,\n first_activity_utc: utcOrNull(firstActivity),\n degree_in: numberOrNull(row.launcher_degree_in),\n degree_out: numberOrNull(row.launcher_degree_out),\n }\n}\n\nfunction funderOf(row: Record<string, unknown>): Funder | null {\n const address = addressOrNull(row.funder)\n if (!address) return null\n const roles = rolesOf(row.funder_roles)\n const firstActivity = numberOrNull(row.funder_first_activity)\n const fundedAt = numberOrNull(row.funded_at)\n return {\n address,\n kind: funderKind(roles, row.funder_is_scam === true),\n roles,\n crime: crimeOf(row, 'funder'),\n degree_out: numberOrNull(row.funder_degree_out),\n first_activity: firstActivity,\n first_activity_utc: utcOrNull(firstActivity),\n funded_at: fundedAt,\n funded_at_utc: utcOrNull(fundedAt),\n funding_tx_count: numberOrNull(row.funding_tx_count),\n funding_usd: numberOrNull(row.funding_usd),\n // Only a levels read returns funding_link; a read of before adds no key.\n ...(row.funding_link === 'ROUTED_TO'\n ? { funded_via: 'swap' as const }\n : row.funding_link === 'FLOWED_TO'\n ? { funded_via: 'transfer' as const }\n : {}),\n }\n}\n\nfunction bridgedInOf(row: Record<string, unknown>): BridgedIn | null {\n const chain = textOrNull(row.bridged_chain)\n const kind = textOrNull(row.bridged_kind)\n if (!chain && !kind) return null\n const asset = textOrNull(row.bridged_asset)\n return {\n chain,\n bridge: addressOrNull(row.bridged_bridge) ?? textOrNull(row.bridged_bridge),\n kind,\n asset: addressOrNull(asset) ?? asset,\n first_block: numberOrNull(row.bridged_first_block),\n }\n}\n\nfunction creationOf(row: Record<string, unknown>): Creation {\n const factory = addressOrNull(row.factory)\n const kind = textOrNull(row.creation_kind)\n const time = numberOrNull(row.creation_time)\n return {\n tx: textOrNull(row.creation_tx)?.toLowerCase() ?? null,\n block: numberOrNull(row.creation_block),\n time,\n time_utc: utcOrNull(time),\n deployer: addressOrNull(row.deployer),\n factory,\n mode: kind === 'factory' || (kind !== 'direct' && factory !== null) ? 'factory' : 'direct',\n }\n}\n\n/** The first row of a member that names a launcher, or null when it has none. */\nfunction launcherRow(member: Member | undefined): Record<string, unknown> | null {\n if (!member || !Array.isArray(member.results)) return null\n return member.results.find((row) => isRecord(row) && addressOrNull(row.launcher) !== null) ?? null\n}\n\nconst answered = (member: Member | undefined): boolean =>\n member?.ok === true && Array.isArray(member.results)\n\nfunction memberFailure(id: string, member: Member | undefined): string {\n if (!member) return `the ${id} read is missing from the batch answer`\n return typeof member.error === 'string' && member.error.trim() !== ''\n ? member.error\n : `the ${id} read did not answer`\n}\n\n/** The screen built from the two batch members, or why it cannot be. */\nexport function screenFromMembers(\n network: string,\n input: string,\n members: Map<string, Member>\n): { result: AmlDeployerScreenResult } | { failure: string } {\n const token = members.get('token')\n const wallet = members.get('wallet')\n const base = {\n schema: AML_DEPLOYER_SCREEN_SCHEMA,\n tool: AML_DEPLOYER_SCREEN_TOOL,\n network,\n input,\n not_covered: [...NOT_COVERED] as string[],\n }\n\n // A token read that failed cannot be told from \"not a token\": no fallback.\n if (!answered(token)) return { failure: memberFailure('token', token) }\n const tokenRow = launcherRow(token)\n if (tokenRow) {\n const launcher = partyOf(tokenRow)!\n const result = {\n ...base,\n found: true,\n input_kind: 'token' as const,\n token: {\n address: addressOrNull(tokenRow.token) ?? input,\n roles: rolesOf(tokenRow.token_roles),\n },\n creation: creationOf(tokenRow),\n launcher,\n launcher_resolved: !launcher.roles.includes('Bundler'),\n first_funder: funderOf(tokenRow),\n bridged_in: bridgedInOf(tokenRow),\n }\n return { result: { ...result, hint: hintFor(result) } }\n }\n\n if (!answered(wallet)) return { failure: memberFailure('wallet', wallet) }\n const walletRow = launcherRow(wallet)\n if (walletRow) {\n const launcher = partyOf(walletRow)!\n const result = {\n ...base,\n found: true,\n input_kind: 'wallet' as const,\n token: null,\n creation: null,\n launcher,\n launcher_resolved: !launcher.roles.includes('Bundler'),\n first_funder: funderOf(walletRow),\n bridged_in: bridgedInOf(walletRow),\n }\n return { result: { ...result, hint: hintFor(result) } }\n }\n\n const result = {\n ...base,\n found: false,\n input_kind: null,\n token: null,\n creation: null,\n launcher: null,\n launcher_resolved: null,\n first_funder: null,\n bridged_in: null,\n }\n return { result: { ...result, hint: hintFor(result) } }\n}\n\nconst FACTS_ONLY =\n 'Report these as facts. Give no score, no risk level and no verdict of your own: the user decides.'\n\nfunction hintFor(result: Omit<AmlDeployerScreenResult, 'hint'>): string {\n const parts: string[] = [ANSWER_HINT]\n if (!result.found) {\n parts.push(\n `${result.input} is not in the Chain Insights Graph of ${result.network}: no flow, creation or bridge touches it. ` +\n 'Say so in one line. That is not proof the address is clean, and it is not proof it is a token. ' +\n 'Check the network and the address with the user.'\n )\n return parts.join(' ')\n }\n parts.push(FACTS_ONLY)\n if (result.input_kind === 'wallet' && result.launcher?.roles.some((r) => r === 'Contract' || r === 'Token')) {\n parts.push(\n 'The address is a contract, but the graph holds no creation record for it, so it was screened as a wallet.'\n )\n }\n if (result.launcher_resolved === false) {\n parts.push(\n 'The launcher is a bundler: it sends transactions for others, so the person behind the launch is not known from this read.'\n )\n }\n if (!result.first_funder) parts.push('The launcher has no inbound flow in the graph: no first funder.')\n if (result.first_funder?.funded_via === 'swap') {\n parts.push(\n 'The first funder paid the launcher through a swap: say it paid one asset and the launcher got another, and never name a router or a pool as the funder.'\n )\n }\n parts.push(`not_covered names what the graph cannot see yet (${NOT_COVERED.join(', ')}); say so when it matters.`)\n return parts.join(' ')\n}\n\nfunction errorResult(text: string): AmlDeployerScreenToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: AmlDeployerScreenResult): AmlDeployerScreenToolResult {\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\n/** aml_deployer_screen, {network, address}. Every argument is checked before a read is sent. */\nexport async function handleAmlDeployerScreen(\n args: unknown,\n deps: DeployerScreenDependencies\n): Promise<AmlDeployerScreenToolResult> {\n const record = isRecord(args) ? args : {}\n let network: string\n try {\n network = normalizeDexNetwork(record.network)\n } catch (err) {\n return errorResult(\n err instanceof DexRegistryError ? err.message : `invalid_network: ${(err as Error).message}`\n )\n }\n const raw = typeof record.address === 'string' ? record.address.trim() : ''\n if (!ADDRESS_INPUT.test(raw)) {\n return errorResult(\n 'invalid_address: address is required: a token contract or a wallet, 0x plus 40 hex characters. ' +\n 'A ticker or a name is not an address: call meta_token_lookup first.'\n )\n }\n const address = raw.toLowerCase()\n\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n return errorResult(\n `No deployer screen read was sent: ${unavailable} There is no answer yet, which is not \"not found\": try again later.`\n )\n }\n\n // The lane's shape first: a read that fails keeps the reads of 0.82.0.\n let shape: SwapLinkShape = 'route'\n if (deps.linkShape) {\n try {\n shape = await deps.linkShape(network)\n } catch {\n shape = 'route'\n }\n }\n\n let answer: GraphAnswer\n try {\n answer = await deps.graphQueryBatch({ network, queries: deployerScreenQueries(address, shape) })\n } catch (err) {\n return errorResult(\n `The deployer screen read failed: ${deps.describeFailure(err)} This is not \"not found\": send the same screen again once.`\n )\n }\n const members = membersOf(answer)\n if (members.size === 0) {\n const text = answer.isError === true ? refusalOf(answer).text : 'the batch answer held no reads'\n return errorResult(`The deployer screen read failed: ${text} This is not \"not found\".`)\n }\n const screen = screenFromMembers(network, address, members)\n if ('failure' in screen) {\n return errorResult(\n `The deployer screen read failed: ${screen.failure} This is not \"not found\": send the same screen again once.`\n )\n }\n return textResult(screen.result)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,2BAA2B;AACxC,MAAa,6BAA6B;AAC1C,MAAa,4BAA4B;AACzC,MAAa,kCACX;AAUF,MAAa,kCAAkC;CAC7C,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;;AAIA,MAAa,cAAc;CAAC;CAAkB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I,QAAQ,SAAS,GAEnB,OAAO,YAAY,oCADN,OAAO,YAAY,OAAO,UAAU,MAAM,CAAC,CAAC,OAAO,iCACJ,0BAA0B;CAExF,MAAM,SAAS,kBAAkB,SAAS,SAAS,OAAO;CAC1D,IAAI,aAAa,QACf,OAAO,YACL,oCAAoC,OAAO,QAAQ,2DACrD;CAEF,OAAO,WAAW,OAAO,MAAM;AACjC"}
|
|
@@ -3,7 +3,7 @@ import { t as ANSWER_HINT } from "./answer-hint-vOE1O6Lf.mjs";
|
|
|
3
3
|
import { d as normalizeDexNetwork, r as DexRegistryError } from "./dex-registry-BY67f4Ul.mjs";
|
|
4
4
|
import { n as exchangeOfWallet, t as exchangeOfLabels } from "./exchange-registry-CoLgHw6d.mjs";
|
|
5
5
|
import { t as EXCHANGE_OPENING_RULE } from "./exchange-tool-Dc46SJ49.mjs";
|
|
6
|
-
import { t as CEX_ROLES } from "./graph-schema-
|
|
6
|
+
import { t as CEX_ROLES } from "./graph-schema-BZTzy0XV.mjs";
|
|
7
7
|
import { i as isEpochMs, o as utcText } from "./print-result-IFARsMnL.mjs";
|
|
8
8
|
import { c as refusalOf, s as membersOf } from "./token-lookup-QpIv77P2.mjs";
|
|
9
9
|
// src/mcp/exchange-deposit-check.ts
|
|
@@ -310,4 +310,4 @@ async function handleAmlExchangeDepositCheck(args, deps) {
|
|
|
310
310
|
}
|
|
311
311
|
export { exchange_deposit_check_exports as a, AML_EXCHANGE_DEPOSIT_CHECK_TOOL as i, AML_EXCHANGE_DEPOSIT_CHECK_DESCRIPTION as n, handleAmlExchangeDepositCheck as o, AML_EXCHANGE_DEPOSIT_CHECK_TITLE as r, AML_EXCHANGE_DEPOSIT_CHECK_ANNOTATIONS as t };
|
|
312
312
|
|
|
313
|
-
//# sourceMappingURL=exchange-deposit-check-
|
|
313
|
+
//# sourceMappingURL=exchange-deposit-check-B1yebGBt.mjs.map
|
package/dist/{exchange-deposit-check-DPU8W3vK.mjs.map → exchange-deposit-check-B1yebGBt.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-deposit-check-DPU8W3vK.mjs","names":[],"sources":["../src/mcp/exchange-deposit-check.ts"],"sourcesContent":["/**\n * aml_exchange_deposit_check: is this address an exchange deposit, of which\n * exchange, and into which hot wallet was it swept?\n *\n * A local tool of the proxy. It sends one graph_query_batch with six reads on\n * USE topology, all anchored on the address:\n *\n * node the address: its node labels, its label words and `cex_role`;\n * swept its `SWEPT` links: each hot wallet it swept into, with the sweep\n * count, the USD sum, the paths and the first and last sweep;\n * paid_by how many addresses paid it, and how many of them are exchange\n * wallets;\n * paid how many addresses it paid, and how many of them are exchange\n * wallets;\n * swapped on how many DEX pools it swapped;\n * approved how many spenders it approved.\n *\n * The last four are the behaviour of the address, as counts: what a host needs\n * to say why an address does or does not look like a deposit, without a guess.\n * A behaviour read that fails leaves its counts null; the check still answers.\n *\n * `SWEPT` (layer `cex_sweeps`) is drawn only from an address the deposit rule\n * judged a deposit, and `cex_role` comes from the exchange label's subtype. The\n * graph judges, this tool only reads. The exchange is named from the lookup\n * file (src/mcp/exchange-registry.ts): the hot wallet it swept into, else a\n * label word.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport {\n exchangeOfLabels,\n exchangeOfWallet,\n type ExchangeEntry,\n type LoadedExchangeRegistry,\n} from './exchange-registry.js'\nimport { EXCHANGE_OPENING_RULE } from './exchange-tool.js'\nimport { CEX_ROLES } from './graph-schema.js'\nimport { isEpochMs, utcText } from './timestamp-text.js'\nimport { membersOf, refusalOf, type GraphAnswer, type Member } from './token-lookup.js'\n\nexport const AML_EXCHANGE_DEPOSIT_CHECK_TOOL = 'aml_exchange_deposit_check' as const\nexport const AML_EXCHANGE_DEPOSIT_CHECK_SCHEMA =\n 'chain-insights.aml-exchange-deposit-check.v1' as const\nexport const AML_EXCHANGE_DEPOSIT_CHECK_TITLE = 'Exchange deposit check'\n/**\n * What the graph's deposit rule holds an address to, in the words every host\n * reads. The rule judges; a host that re-judges from payer counts or volume\n * invents a rule (\"a real deposit has many payers\") and gets the reason wrong.\n */\n/** How a deposit address behaves: the answer to \"what makes an address a deposit address\". Every result carries it as deposit_profile. */\nexport const EXCHANGE_DEPOSIT_BEHAVIOUR =\n \"A deposit address is one customer's: everything it sends goes to the wallets of one exchange (a sweep into a hot wallet), few outside addresses ever pay it, it never swaps on a DEX, and it is no token, pool, router or smart account.\"\n\nexport const EXCHANGE_DEPOSIT_PROFILE =\n `${EXCHANGE_DEPOSIT_BEHAVIOUR} ` +\n 'The graph judges that, never you: the verdict is is_deposit, cex_role and swept. Give behaviour and does_not_fit_deposit as the facts behind it, and never set a threshold of your own for payers, volume or sweeps. ' +\n 'With no deposit mark an address is not shown to be a deposit, whoever says it is one; with found false it has no activity on the network, and the claim is unproven there.'\n\nexport const AML_EXCHANGE_DEPOSIT_CHECK_DESCRIPTION =\n 'Checks one address: is it a deposit address of a centralized exchange (Binance, Bitget, Bybit, Coinbase, Gate, KuCoin, MEXC, OKX, ...), ' +\n 'of which exchange, and into which hot wallet was it swept, how many times, by which path and when. ' +\n 'It reads the SWEPT links of the address and its cex_role (deposit, hot_wallet, cold_wallet or withdrawal) on the graph, and its behaviour as counts ' +\n '(how many addresses paid it, how many it paid, how many of each are exchange wallets, the DEX pools it swapped on, the spenders it approved), anchored on the address: ' +\n 'six reads in one batch, billed as any read. Use it when a trail reaches an address that may be an exchange wallet, when the user asks where money entered an exchange, ' +\n 'or when someone says an address is an exchange deposit: a claim is never proof, the answer of this tool is. ' +\n `${EXCHANGE_DEPOSIT_PROFILE} ${EXCHANGE_OPENING_RULE}`\nexport const AML_EXCHANGE_DEPOSIT_CHECK_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const AML_EXCHANGE_DEPOSIT_CHECK_ARGS = ['network', 'address'] as const\n\n/** The most hot wallets one deposit's read returns. */\nexport const SWEPT_LIMIT = 20\n\nexport type CexRole = (typeof CEX_ROLES)[number]\n\nexport interface Sweep {\n hot_wallet: string\n /** The exchange the hot wallet is listed for, or null when the lookup lists it for none. */\n hot_wallet_exchange: string | null\n hot_wallet_role: string | null\n sweep_count: number | null\n amount_usd_sum: number | null\n paths: string[]\n first_seen: number | null\n first_seen_utc: string | null\n last_seen: number | null\n last_seen_utc: string | null\n}\n\n/** The most links one behaviour read counts: a count equal to it means \"this many or more\". */\nexport const BEHAVIOUR_COUNT_CAP = 5000\n\n/**\n * How the address behaves, as counts of its links. A null count is a read that\n * did not answer. The counts take every link, also a dust one: the graph's\n * deposit rule, which ignores dust, is the judge, and these are its evidence.\n */\nexport interface DepositBehaviour {\n /** Addresses that ever paid it. */\n payers: number | null\n /** Of those, exchange wallets (a hot wallet, or another deposit). */\n payers_exchange: number | null\n /** Addresses it ever paid. */\n receivers: number | null\n /** Of those, exchange wallets. */\n receivers_exchange: number | null\n /** DEX pools it swapped on. */\n dex_pools: number | null\n /** Spenders it approved. */\n approvals: number | null\n /** A count equal to this means \"this many or more\". */\n count_cap: typeof BEHAVIOUR_COUNT_CAP\n}\n\nexport interface AmlExchangeDepositCheckResult {\n schema: typeof AML_EXCHANGE_DEPOSIT_CHECK_SCHEMA\n tool: typeof AML_EXCHANGE_DEPOSIT_CHECK_TOOL\n network: string\n address: string\n /** false when the graph holds no node for the address. */\n found: boolean\n /** true when the address carries cex_role deposit or has a SWEPT link. */\n is_deposit: boolean\n cex_role: CexRole | null\n /** The exchange id, from the hot wallet it swept into, else from its label words. */\n exchange: string | null\n exchange_display: string | null\n labels: string[]\n swept: Sweep[]\n /** The behaviour counts; null when the graph holds no node for the address. */\n behaviour: DepositBehaviour | null\n /** What the counts show that a deposit address does not do. Empty for a deposit, and when nothing shows. */\n does_not_fit_deposit: string[]\n /** How any deposit address behaves: the same text in every answer, for a host asked what makes one. */\n deposit_profile: string\n hint: string\n}\n\nexport interface ExchangeDepositCheckDependencies {\n loadExchangeRegistry: (network: string) => Promise<LoadedExchangeRegistry>\n graphQueryBatch: (args: {\n network: string\n queries: Array<{ id: string; query: string }>\n }) => Promise<GraphAnswer>\n unavailable?: () => Promise<string | undefined> | string | undefined\n describeFailure: (err: unknown) => string\n}\n\nexport type AmlExchangeDepositCheckToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\nconst ADDRESS_INPUT = /^0x[0-9a-fA-F]{40}$/\nconst ADDRESS_READ = /^0x[0-9a-f]{40}$/\n\nfunction assertReadAddress(address: string): void {\n if (!ADDRESS_READ.test(address)) {\n throw new Error(\n `exchange deposit check: ${JSON.stringify(address)} is not a lowercase 0x address`\n )\n }\n}\n\n/** The node read: the address, its marks and its cex_role. */\nexport function depositNodeQuery(address: string): string {\n assertReadAddress(address)\n return (\n `USE topology MATCH (a:Address {address: \"${address}\"}) ` +\n 'RETURN a.address AS address, labels(a) AS node_labels, a.labels AS labels, a.cex_role AS cex_role LIMIT 1'\n )\n}\n\n/** The swept read: each hot wallet the address swept into. */\nexport function depositSweptQuery(address: string): string {\n assertReadAddress(address)\n return (\n `USE topology MATCH (a:Address {address: \"${address}\"})-[s:SWEPT]->(h:Address) ` +\n 'RETURN h.address AS hot_wallet, h.labels AS hot_wallet_labels, h.cex_role AS hot_wallet_role, ' +\n 's.sweep_count AS sweep_count, s.amount_usd_sum AS amount_usd_sum, s.paths AS paths, ' +\n `s.first_seen_timestamp AS first_seen_timestamp, s.last_seen_timestamp AS last_seen_timestamp LIMIT ${SWEPT_LIMIT}`\n )\n}\n\n/** The behaviour reads: one count row each, over at most BEHAVIOUR_COUNT_CAP links. */\nexport function depositBehaviourQueries(\n address: string\n): Array<{ id: 'paid_by' | 'paid' | 'swapped' | 'approved'; query: string }> {\n assertReadAddress(address)\n const anchor = `(a:Address {address: \"${address}\"})`\n const exchange = 'sum(CASE WHEN b.is_exchange THEN 1 ELSE 0 END)'\n return [\n {\n id: 'paid_by',\n query:\n `USE topology MATCH ${anchor}<-[:FLOWED_TO]-(b:Address) WITH b LIMIT ${BEHAVIOUR_COUNT_CAP} ` +\n `RETURN count(b) AS payers, ${exchange} AS payers_exchange LIMIT 1`,\n },\n {\n id: 'paid',\n query:\n `USE topology MATCH ${anchor}-[:FLOWED_TO]->(b:Address) WITH b LIMIT ${BEHAVIOUR_COUNT_CAP} ` +\n `RETURN count(b) AS receivers, ${exchange} AS receivers_exchange LIMIT 1`,\n },\n {\n id: 'swapped',\n query:\n `USE topology MATCH ${anchor}-[:SWAPPED]->(b:Address) WITH b LIMIT ${BEHAVIOUR_COUNT_CAP} ` +\n 'RETURN count(b) AS dex_pools LIMIT 1',\n },\n {\n id: 'approved',\n query:\n `USE topology MATCH ${anchor}-[:APPROVED]->(b:Address) WITH b LIMIT ${BEHAVIOUR_COUNT_CAP} ` +\n 'RETURN count(b) AS approvals LIMIT 1',\n },\n ]\n}\n\n/** The one batch the tool sends: members `node`, `swept` and the four behaviour reads. */\nexport function depositCheckQueries(address: string): Array<{ id: string; query: string }> {\n return [\n { id: 'node', query: depositNodeQuery(address) },\n { id: 'swept', query: depositSweptQuery(address) },\n ...depositBehaviourQueries(address),\n ]\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nconst strings = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((v): v is string => typeof v === 'string') : []\n\nconst numberOrNull = (value: unknown): number | null => {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)))\n return Number(value)\n return null\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value.trim() : null\n\nconst addressOrNull = (value: unknown): string | null =>\n typeof value === 'string' && ADDRESS_INPUT.test(value.trim()) ? value.trim().toLowerCase() : null\n\nconst utcOrNull = (ms: number | null): string | null => (isEpochMs(ms) ? utcText(ms) : null)\n\nfunction cexRoleOf(value: unknown): CexRole | null {\n const role = textOrNull(value)?.toLowerCase()\n return (CEX_ROLES as readonly string[]).includes(role ?? '') ? (role as CexRole) : null\n}\n\nconst answered = (member: Member | undefined): boolean =>\n member?.ok === true && Array.isArray(member.results)\n\nconst rowsOf = (member: Member | undefined): Array<Record<string, unknown>> =>\n answered(member) ? (member!.results as unknown[]).filter(isRecord) : []\n\nfunction memberFailure(id: string, member: Member | undefined): string {\n if (!member) return `the ${id} read is missing from the batch answer`\n return typeof member.error === 'string' && member.error.trim() !== ''\n ? member.error\n : `the ${id} read did not answer`\n}\n\n/** The behaviour counts of the batch members; a member that did not answer leaves its counts null. */\nexport function behaviourFromMembers(members: Map<string, Member>): DepositBehaviour {\n const count = (id: string, column: string): number | null =>\n numberOrNull(rowsOf(members.get(id))[0]?.[column])\n return {\n payers: count('paid_by', 'payers'),\n payers_exchange: count('paid_by', 'payers_exchange'),\n receivers: count('paid', 'receivers'),\n receivers_exchange: count('paid', 'receivers_exchange'),\n dex_pools: count('swapped', 'dex_pools'),\n approvals: count('approved', 'approvals'),\n count_cap: BEHAVIOUR_COUNT_CAP,\n }\n}\n\n/** \"5000 or more\" at the cap, else the number. */\nfunction countText(count: number): string {\n return count >= BEHAVIOUR_COUNT_CAP ? `${BEHAVIOUR_COUNT_CAP} or more` : String(count)\n}\n\nconst plural = (count: number, one: string, many: string): string => (count === 1 ? one : many)\n\n/**\n * What the counts show that a deposit address does not do. Only what needs no\n * threshold: a swap, and a payment to an address that is no exchange wallet.\n * How many payers are \"few\" is the graph rule's to say, never this tool's.\n */\nexport function doesNotFitDeposit(behaviour: DepositBehaviour): string[] {\n const facts: string[] = []\n if (behaviour.dex_pools !== null && behaviour.dex_pools > 0) {\n facts.push(\n `it swapped on ${countText(behaviour.dex_pools)} DEX ${plural(behaviour.dex_pools, 'pool', 'pools')}`\n )\n }\n if (behaviour.receivers !== null && behaviour.receivers_exchange !== null) {\n const outside = behaviour.receivers - behaviour.receivers_exchange\n if (outside > 0) {\n // A capped receiver count makes the difference a floor too.\n const atCap = behaviour.receivers >= BEHAVIOUR_COUNT_CAP ? ' or more' : ''\n facts.push(\n `it paid ${outside}${atCap} ${plural(outside, 'address that is', 'addresses that are')} no exchange wallet`\n )\n }\n }\n return facts\n}\n\n/** The counts as one sentence, the read counts only. */\nexport function behaviourText(behaviour: DepositBehaviour): string {\n const parts: string[] = []\n if (behaviour.payers !== null) {\n parts.push(\n `${countText(behaviour.payers)} ${plural(behaviour.payers, 'address', 'addresses')} paid it` +\n (behaviour.payers_exchange !== null\n ? ` (${countText(behaviour.payers_exchange)} of them exchange wallets)`\n : '')\n )\n }\n if (behaviour.receivers !== null) {\n parts.push(\n `it paid ${countText(behaviour.receivers)} ${plural(behaviour.receivers, 'address', 'addresses')}` +\n (behaviour.receivers_exchange !== null\n ? ` (${countText(behaviour.receivers_exchange)} of them exchange wallets)`\n : '')\n )\n }\n if (behaviour.dex_pools !== null) {\n parts.push(\n `it swapped on ${countText(behaviour.dex_pools)} DEX ${plural(behaviour.dex_pools, 'pool', 'pools')}`\n )\n }\n if (behaviour.approvals !== null) {\n parts.push(\n `it approved ${countText(behaviour.approvals)} ${plural(behaviour.approvals, 'spender', 'spenders')}`\n )\n }\n return parts.join(', ')\n}\n\n/** The check built from the batch members and the lookup rows, or why it cannot be. */\nexport function depositCheckFromMembers(\n network: string,\n address: string,\n members: Map<string, Member>,\n rows: ExchangeEntry[]\n): { result: AmlExchangeDepositCheckResult } | { failure: string } {\n const node = members.get('node')\n const swept = members.get('swept')\n if (!answered(node)) return { failure: memberFailure('node', node) }\n if (!answered(swept)) return { failure: memberFailure('swept', swept) }\n\n const nodeRow = rowsOf(node)[0]\n const labels = strings(nodeRow?.labels)\n const sweeps: Sweep[] = []\n let exchange: ExchangeEntry | null = null\n for (const row of rowsOf(swept)) {\n const hot = addressOrNull(row.hot_wallet)\n if (!hot) continue\n const listed =\n exchangeOfWallet(hot, rows)?.entry ?? exchangeOfLabels(strings(row.hot_wallet_labels), rows)\n exchange ??= listed\n const first = numberOrNull(row.first_seen_timestamp)\n const last = numberOrNull(row.last_seen_timestamp)\n sweeps.push({\n hot_wallet: hot,\n hot_wallet_exchange: listed?.exchange ?? null,\n hot_wallet_role: textOrNull(row.hot_wallet_role),\n sweep_count: numberOrNull(row.sweep_count),\n amount_usd_sum: numberOrNull(row.amount_usd_sum),\n paths: strings(row.paths),\n first_seen: first,\n first_seen_utc: utcOrNull(first),\n last_seen: last,\n last_seen_utc: utcOrNull(last),\n })\n }\n sweeps.sort((a, b) => (b.sweep_count ?? 0) - (a.sweep_count ?? 0))\n exchange ??= exchangeOfLabels(labels, rows) ?? exchangeOfWallet(address, rows)?.entry ?? null\n const role = cexRoleOf(nodeRow?.cex_role)\n const found = nodeRow !== undefined || sweeps.length > 0\n const isDeposit = role === 'deposit' || sweeps.length > 0\n const behaviour = behaviourFromMembers(members)\n const result = {\n schema: AML_EXCHANGE_DEPOSIT_CHECK_SCHEMA,\n tool: AML_EXCHANGE_DEPOSIT_CHECK_TOOL,\n network,\n address,\n found,\n is_deposit: isDeposit,\n cex_role: role ?? (sweeps.length > 0 ? ('deposit' as const) : null),\n exchange: exchange?.exchange ?? null,\n exchange_display: exchange?.display ?? null,\n labels,\n swept: sweeps,\n behaviour: found ? behaviour : null,\n does_not_fit_deposit: found && !isDeposit && !role ? doesNotFitDeposit(behaviour) : [],\n deposit_profile: EXCHANGE_DEPOSIT_BEHAVIOUR,\n }\n return { result: { ...result, hint: `${hintFor(result)} ${PROFILE_HINT}` } }\n}\n\n/** Closes every hint: a host asked how a deposit address behaves answers from deposit_profile, not from its own idea of one. */\nconst PROFILE_HINT =\n 'Asked how a deposit address behaves, what makes an address one or what rules one out, answer with deposit_profile.'\n\n/** \" once\", \" 3 times\", or \"\" when the graph gave no count. */\nfunction timesText(count: number | null): string {\n if (count === null) return ''\n return count === 1 ? ' once' : ` ${count} times`\n}\n\nfunction hintFor(result: Omit<AmlExchangeDepositCheckResult, 'hint'>): string {\n const { address, network } = result\n const name = result.exchange_display ?? 'its exchange (name it from labels)'\n if (!result.found) {\n return (\n `${ANSWER_HINT} ${address} is not in the Chain Insights Graph of ${network}: no flow touches it. ` +\n 'Say so in one line, and check the network and the address with the user: name no other network yourself, and say nothing about what the check covers. ' +\n 'A claim that it is an exchange deposit address is unproven on this network: never repeat it as a fact.'\n )\n }\n if (result.is_deposit) {\n const top = result.swept[0]\n const into = top\n ? ` It swept${timesText(top.sweep_count)} into the hot wallet ${top.hot_wallet}` +\n (result.swept.length > 1\n ? `, and into ${result.swept.length - 1} more hot wallets (swept lists them)`\n : '') +\n '.'\n : ' The graph holds no SWEPT link of it yet: its sweeps are not drawn.'\n return (\n `${ANSWER_HINT} Say: \"${address} is a deposit address of ${name} on ${network}.\"${into} ` +\n 'This is where the money entered the exchange: the exchange can name the customer behind the deposit. ' +\n `${behaviourHint(result)}${EXCHANGE_OPENING_RULE}`\n )\n }\n if (result.cex_role) {\n return (\n `${ANSWER_HINT} Say: \"${address} is a ${result.cex_role.replace('_', ' ')} of ${name} on ${network}, not a deposit address.\" ` +\n 'A trail that reaches it has entered the exchange: end the trail there.'\n )\n }\n const misfit =\n result.does_not_fit_deposit.length > 0\n ? `What a deposit address does not do, and this one did: ${result.does_not_fit_deposit.join('; ')}. `\n : 'Its counts alone rule nothing out; the missing mark does: the rule of the graph did not judge it a deposit. '\n return (\n `${ANSWER_HINT} ${address} carries no deposit mark: no SWEPT link and no cex_role. ` +\n 'Say that the graph shows no sweep of it into a listed exchange hot wallet. That is not proof the address belongs to no exchange; ' +\n `its labels and its links say what else it is. ${behaviourHint(result)}${misfit}` +\n 'Give these facts as the reason and no other: set no threshold of your own for payers, volume or sweeps.'\n )\n}\n\n/** \"Its behaviour: ... . \" for a hint, or \"\" when no count was read. */\nfunction behaviourHint(result: Omit<AmlExchangeDepositCheckResult, 'hint'>): string {\n const text = result.behaviour ? behaviourText(result.behaviour) : ''\n return text === '' ? '' : `Its behaviour, as the graph counts it: ${text}. `\n}\n\nfunction errorResult(text: string): AmlExchangeDepositCheckToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: AmlExchangeDepositCheckResult): AmlExchangeDepositCheckToolResult {\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\n/** aml_exchange_deposit_check, {network, address}. Every argument is checked before a read is sent. */\nexport async function handleAmlExchangeDepositCheck(\n args: unknown,\n deps: ExchangeDepositCheckDependencies\n): Promise<AmlExchangeDepositCheckToolResult> {\n const record = isRecord(args) ? args : {}\n let network: string\n try {\n network = normalizeDexNetwork(record.network)\n } catch (err) {\n return errorResult(\n err instanceof DexRegistryError ? err.message : `invalid_network: ${(err as Error).message}`\n )\n }\n const raw = typeof record.address === 'string' ? record.address.trim() : ''\n if (!ADDRESS_INPUT.test(raw)) {\n return errorResult(\n 'invalid_address: address is required: 0x plus 40 hex characters. ' +\n 'An exchange name is not an address: call meta_exchange_lookup for its wallets.'\n )\n }\n const address = raw.toLowerCase()\n\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n return errorResult(\n `No exchange deposit read was sent: ${unavailable} There is no answer yet, which is not \"no deposit\": try again later.`\n )\n }\n\n let rows: ExchangeEntry[] = []\n try {\n rows = (await deps.loadExchangeRegistry(network)).document.rows\n } catch {\n // The lookup only names the exchange; the graph read still answers.\n }\n\n let answer: GraphAnswer\n try {\n answer = await deps.graphQueryBatch({ network, queries: depositCheckQueries(address) })\n } catch (err) {\n return errorResult(\n `The exchange deposit read failed: ${deps.describeFailure(err)} This is not \"no deposit\": send the same check again once.`\n )\n }\n const members = membersOf(answer)\n if (members.size === 0) {\n const text = answer.isError === true ? refusalOf(answer).text : 'the batch answer held no reads'\n return errorResult(`The exchange deposit read failed: ${text} This is not \"no deposit\".`)\n }\n const check = depositCheckFromMembers(network, address, members, rows)\n if ('failure' in check) {\n return errorResult(\n `The exchange deposit read failed: ${check.failure} This is not \"no deposit\": send the same check again once.`\n )\n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EF,MAAM,UAAU,IAAI,YAAY;CAEhC,MAAM,cAAc,MAAM,KAAK,cAAc;CAC7C,IAAI,aACF,OAAO,YACL,sCAAsC,YAAY,qEACpD;CAGF,IAAI,OAAwB,CAAC;CAC7B,IAAI;EACF,QAAQ,MAAM,KAAK,qBAAqB,OAAO,EAAA,CAAG,SAAS;CAC7D,QAAQ,CAER;CAEA,IAAI;CACJ,IAAI;EACF,SAAS,MAAM,KAAK,gBAAgB;GAAE;GAAS,SAAS,oBAAoB,OAAO;EAAE,CAAC;CACxF,SAAS,KAAK;EACZ,OAAO,YACL,qCAAqC,KAAK,gBAAgB,GAAG,EAAE,2DACjE;CACF;CACA,MAAM,UAAU,UAAU,MAAM;CAChC,IAAI,QAAQ,SAAS,GAEnB,OAAO,YAAY,qCADN,OAAO,YAAY,OAAO,UAAU,MAAM,CAAC,CAAC,OAAO,iCACH,2BAA2B;CAE1F,MAAM,QAAQ,wBAAwB,SAAS,SAAS,SAAS,IAAI;CACrE,IAAI,aAAa,OACf,OAAO,YACL,qCAAqC,MAAM,QAAQ,2DACrD;CAEF,OAAO,WAAW,MAAM,MAAM;AAChC"}
|
|
1
|
+
{"version":3,"file":"exchange-deposit-check-B1yebGBt.mjs","names":[],"sources":["../src/mcp/exchange-deposit-check.ts"],"sourcesContent":["/**\n * aml_exchange_deposit_check: is this address an exchange deposit, of which\n * exchange, and into which hot wallet was it swept?\n *\n * A local tool of the proxy. It sends one graph_query_batch with six reads on\n * USE topology, all anchored on the address:\n *\n * node the address: its node labels, its label words and `cex_role`;\n * swept its `SWEPT` links: each hot wallet it swept into, with the sweep\n * count, the USD sum, the paths and the first and last sweep;\n * paid_by how many addresses paid it, and how many of them are exchange\n * wallets;\n * paid how many addresses it paid, and how many of them are exchange\n * wallets;\n * swapped on how many DEX pools it swapped;\n * approved how many spenders it approved.\n *\n * The last four are the behaviour of the address, as counts: what a host needs\n * to say why an address does or does not look like a deposit, without a guess.\n * A behaviour read that fails leaves its counts null; the check still answers.\n *\n * `SWEPT` (layer `cex_sweeps`) is drawn only from an address the deposit rule\n * judged a deposit, and `cex_role` comes from the exchange label's subtype. The\n * graph judges, this tool only reads. The exchange is named from the lookup\n * file (src/mcp/exchange-registry.ts): the hot wallet it swept into, else a\n * label word.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport {\n exchangeOfLabels,\n exchangeOfWallet,\n type ExchangeEntry,\n type LoadedExchangeRegistry,\n} from './exchange-registry.js'\nimport { EXCHANGE_OPENING_RULE } from './exchange-tool.js'\nimport { CEX_ROLES } from './graph-schema.js'\nimport { isEpochMs, utcText } from './timestamp-text.js'\nimport { membersOf, refusalOf, type GraphAnswer, type Member } from './token-lookup.js'\n\nexport const AML_EXCHANGE_DEPOSIT_CHECK_TOOL = 'aml_exchange_deposit_check' as const\nexport const AML_EXCHANGE_DEPOSIT_CHECK_SCHEMA =\n 'chain-insights.aml-exchange-deposit-check.v1' as const\nexport const AML_EXCHANGE_DEPOSIT_CHECK_TITLE = 'Exchange deposit check'\n/**\n * What the graph's deposit rule holds an address to, in the words every host\n * reads. The rule judges; a host that re-judges from payer counts or volume\n * invents a rule (\"a real deposit has many payers\") and gets the reason wrong.\n */\n/** How a deposit address behaves: the answer to \"what makes an address a deposit address\". Every result carries it as deposit_profile. */\nexport const EXCHANGE_DEPOSIT_BEHAVIOUR =\n \"A deposit address is one customer's: everything it sends goes to the wallets of one exchange (a sweep into a hot wallet), few outside addresses ever pay it, it never swaps on a DEX, and it is no token, pool, router or smart account.\"\n\nexport const EXCHANGE_DEPOSIT_PROFILE =\n `${EXCHANGE_DEPOSIT_BEHAVIOUR} ` +\n 'The graph judges that, never you: the verdict is is_deposit, cex_role and swept. Give behaviour and does_not_fit_deposit as the facts behind it, and never set a threshold of your own for payers, volume or sweeps. ' +\n 'With no deposit mark an address is not shown to be a deposit, whoever says it is one; with found false it has no activity on the network, and the claim is unproven there.'\n\nexport const AML_EXCHANGE_DEPOSIT_CHECK_DESCRIPTION =\n 'Checks one address: is it a deposit address of a centralized exchange (Binance, Bitget, Bybit, Coinbase, Gate, KuCoin, MEXC, OKX, ...), ' +\n 'of which exchange, and into which hot wallet was it swept, how many times, by which path and when. ' +\n 'It reads the SWEPT links of the address and its cex_role (deposit, hot_wallet, cold_wallet or withdrawal) on the graph, and its behaviour as counts ' +\n '(how many addresses paid it, how many it paid, how many of each are exchange wallets, the DEX pools it swapped on, the spenders it approved), anchored on the address: ' +\n 'six reads in one batch, billed as any read. Use it when a trail reaches an address that may be an exchange wallet, when the user asks where money entered an exchange, ' +\n 'or when someone says an address is an exchange deposit: a claim is never proof, the answer of this tool is. ' +\n `${EXCHANGE_DEPOSIT_PROFILE} ${EXCHANGE_OPENING_RULE}`\nexport const AML_EXCHANGE_DEPOSIT_CHECK_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const AML_EXCHANGE_DEPOSIT_CHECK_ARGS = ['network', 'address'] as const\n\n/** The most hot wallets one deposit's read returns. */\nexport const SWEPT_LIMIT = 20\n\nexport type CexRole = (typeof CEX_ROLES)[number]\n\nexport interface Sweep {\n hot_wallet: string\n /** The exchange the hot wallet is listed for, or null when the lookup lists it for none. */\n hot_wallet_exchange: string | null\n hot_wallet_role: string | null\n sweep_count: number | null\n amount_usd_sum: number | null\n paths: string[]\n first_seen: number | null\n first_seen_utc: string | null\n last_seen: number | null\n last_seen_utc: string | null\n}\n\n/** The most links one behaviour read counts: a count equal to it means \"this many or more\". */\nexport const BEHAVIOUR_COUNT_CAP = 5000\n\n/**\n * How the address behaves, as counts of its links. A null count is a read that\n * did not answer. The counts take every link, also a dust one: the graph's\n * deposit rule, which ignores dust, is the judge, and these are its evidence.\n */\nexport interface DepositBehaviour {\n /** Addresses that ever paid it. */\n payers: number | null\n /** Of those, exchange wallets (a hot wallet, or another deposit). */\n payers_exchange: number | null\n /** Addresses it ever paid. */\n receivers: number | null\n /** Of those, exchange wallets. */\n receivers_exchange: number | null\n /** DEX pools it swapped on. */\n dex_pools: number | null\n /** Spenders it approved. */\n approvals: number | null\n /** A count equal to this means \"this many or more\". */\n count_cap: typeof BEHAVIOUR_COUNT_CAP\n}\n\nexport interface AmlExchangeDepositCheckResult {\n schema: typeof AML_EXCHANGE_DEPOSIT_CHECK_SCHEMA\n tool: typeof AML_EXCHANGE_DEPOSIT_CHECK_TOOL\n network: string\n address: string\n /** false when the graph holds no node for the address. */\n found: boolean\n /** true when the address carries cex_role deposit or has a SWEPT link. */\n is_deposit: boolean\n cex_role: CexRole | null\n /** The exchange id, from the hot wallet it swept into, else from its label words. */\n exchange: string | null\n exchange_display: string | null\n labels: string[]\n swept: Sweep[]\n /** The behaviour counts; null when the graph holds no node for the address. */\n behaviour: DepositBehaviour | null\n /** What the counts show that a deposit address does not do. Empty for a deposit, and when nothing shows. */\n does_not_fit_deposit: string[]\n /** How any deposit address behaves: the same text in every answer, for a host asked what makes one. */\n deposit_profile: string\n hint: string\n}\n\nexport interface ExchangeDepositCheckDependencies {\n loadExchangeRegistry: (network: string) => Promise<LoadedExchangeRegistry>\n graphQueryBatch: (args: {\n network: string\n queries: Array<{ id: string; query: string }>\n }) => Promise<GraphAnswer>\n unavailable?: () => Promise<string | undefined> | string | undefined\n describeFailure: (err: unknown) => string\n}\n\nexport type AmlExchangeDepositCheckToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\nconst ADDRESS_INPUT = /^0x[0-9a-fA-F]{40}$/\nconst ADDRESS_READ = /^0x[0-9a-f]{40}$/\n\nfunction assertReadAddress(address: string): void {\n if (!ADDRESS_READ.test(address)) {\n throw new Error(\n `exchange deposit check: ${JSON.stringify(address)} is not a lowercase 0x address`\n )\n }\n}\n\n/** The node read: the address, its marks and its cex_role. */\nexport function depositNodeQuery(address: string): string {\n assertReadAddress(address)\n return (\n `USE topology MATCH (a:Address {address: \"${address}\"}) ` +\n 'RETURN a.address AS address, labels(a) AS node_labels, a.labels AS labels, a.cex_role AS cex_role LIMIT 1'\n )\n}\n\n/** The swept read: each hot wallet the address swept into. */\nexport function depositSweptQuery(address: string): string {\n assertReadAddress(address)\n return (\n `USE topology MATCH (a:Address {address: \"${address}\"})-[s:SWEPT]->(h:Address) ` +\n 'RETURN h.address AS hot_wallet, h.labels AS hot_wallet_labels, h.cex_role AS hot_wallet_role, ' +\n 's.sweep_count AS sweep_count, s.amount_usd_sum AS amount_usd_sum, s.paths AS paths, ' +\n `s.first_seen_timestamp AS first_seen_timestamp, s.last_seen_timestamp AS last_seen_timestamp LIMIT ${SWEPT_LIMIT}`\n )\n}\n\n/** The behaviour reads: one count row each, over at most BEHAVIOUR_COUNT_CAP links. */\nexport function depositBehaviourQueries(\n address: string\n): Array<{ id: 'paid_by' | 'paid' | 'swapped' | 'approved'; query: string }> {\n assertReadAddress(address)\n const anchor = `(a:Address {address: \"${address}\"})`\n const exchange = 'sum(CASE WHEN b.is_exchange THEN 1 ELSE 0 END)'\n return [\n {\n id: 'paid_by',\n query:\n `USE topology MATCH ${anchor}<-[:FLOWED_TO]-(b:Address) WITH b LIMIT ${BEHAVIOUR_COUNT_CAP} ` +\n `RETURN count(b) AS payers, ${exchange} AS payers_exchange LIMIT 1`,\n },\n {\n id: 'paid',\n query:\n `USE topology MATCH ${anchor}-[:FLOWED_TO]->(b:Address) WITH b LIMIT ${BEHAVIOUR_COUNT_CAP} ` +\n `RETURN count(b) AS receivers, ${exchange} AS receivers_exchange LIMIT 1`,\n },\n {\n id: 'swapped',\n query:\n `USE topology MATCH ${anchor}-[:SWAPPED]->(b:Address) WITH b LIMIT ${BEHAVIOUR_COUNT_CAP} ` +\n 'RETURN count(b) AS dex_pools LIMIT 1',\n },\n {\n id: 'approved',\n query:\n `USE topology MATCH ${anchor}-[:APPROVED]->(b:Address) WITH b LIMIT ${BEHAVIOUR_COUNT_CAP} ` +\n 'RETURN count(b) AS approvals LIMIT 1',\n },\n ]\n}\n\n/** The one batch the tool sends: members `node`, `swept` and the four behaviour reads. */\nexport function depositCheckQueries(address: string): Array<{ id: string; query: string }> {\n return [\n { id: 'node', query: depositNodeQuery(address) },\n { id: 'swept', query: depositSweptQuery(address) },\n ...depositBehaviourQueries(address),\n ]\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nconst strings = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((v): v is string => typeof v === 'string') : []\n\nconst numberOrNull = (value: unknown): number | null => {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)))\n return Number(value)\n return null\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value.trim() : null\n\nconst addressOrNull = (value: unknown): string | null =>\n typeof value === 'string' && ADDRESS_INPUT.test(value.trim()) ? value.trim().toLowerCase() : null\n\nconst utcOrNull = (ms: number | null): string | null => (isEpochMs(ms) ? utcText(ms) : null)\n\nfunction cexRoleOf(value: unknown): CexRole | null {\n const role = textOrNull(value)?.toLowerCase()\n return (CEX_ROLES as readonly string[]).includes(role ?? '') ? (role as CexRole) : null\n}\n\nconst answered = (member: Member | undefined): boolean =>\n member?.ok === true && Array.isArray(member.results)\n\nconst rowsOf = (member: Member | undefined): Array<Record<string, unknown>> =>\n answered(member) ? (member!.results as unknown[]).filter(isRecord) : []\n\nfunction memberFailure(id: string, member: Member | undefined): string {\n if (!member) return `the ${id} read is missing from the batch answer`\n return typeof member.error === 'string' && member.error.trim() !== ''\n ? member.error\n : `the ${id} read did not answer`\n}\n\n/** The behaviour counts of the batch members; a member that did not answer leaves its counts null. */\nexport function behaviourFromMembers(members: Map<string, Member>): DepositBehaviour {\n const count = (id: string, column: string): number | null =>\n numberOrNull(rowsOf(members.get(id))[0]?.[column])\n return {\n payers: count('paid_by', 'payers'),\n payers_exchange: count('paid_by', 'payers_exchange'),\n receivers: count('paid', 'receivers'),\n receivers_exchange: count('paid', 'receivers_exchange'),\n dex_pools: count('swapped', 'dex_pools'),\n approvals: count('approved', 'approvals'),\n count_cap: BEHAVIOUR_COUNT_CAP,\n }\n}\n\n/** \"5000 or more\" at the cap, else the number. */\nfunction countText(count: number): string {\n return count >= BEHAVIOUR_COUNT_CAP ? `${BEHAVIOUR_COUNT_CAP} or more` : String(count)\n}\n\nconst plural = (count: number, one: string, many: string): string => (count === 1 ? one : many)\n\n/**\n * What the counts show that a deposit address does not do. Only what needs no\n * threshold: a swap, and a payment to an address that is no exchange wallet.\n * How many payers are \"few\" is the graph rule's to say, never this tool's.\n */\nexport function doesNotFitDeposit(behaviour: DepositBehaviour): string[] {\n const facts: string[] = []\n if (behaviour.dex_pools !== null && behaviour.dex_pools > 0) {\n facts.push(\n `it swapped on ${countText(behaviour.dex_pools)} DEX ${plural(behaviour.dex_pools, 'pool', 'pools')}`\n )\n }\n if (behaviour.receivers !== null && behaviour.receivers_exchange !== null) {\n const outside = behaviour.receivers - behaviour.receivers_exchange\n if (outside > 0) {\n // A capped receiver count makes the difference a floor too.\n const atCap = behaviour.receivers >= BEHAVIOUR_COUNT_CAP ? ' or more' : ''\n facts.push(\n `it paid ${outside}${atCap} ${plural(outside, 'address that is', 'addresses that are')} no exchange wallet`\n )\n }\n }\n return facts\n}\n\n/** The counts as one sentence, the read counts only. */\nexport function behaviourText(behaviour: DepositBehaviour): string {\n const parts: string[] = []\n if (behaviour.payers !== null) {\n parts.push(\n `${countText(behaviour.payers)} ${plural(behaviour.payers, 'address', 'addresses')} paid it` +\n (behaviour.payers_exchange !== null\n ? ` (${countText(behaviour.payers_exchange)} of them exchange wallets)`\n : '')\n )\n }\n if (behaviour.receivers !== null) {\n parts.push(\n `it paid ${countText(behaviour.receivers)} ${plural(behaviour.receivers, 'address', 'addresses')}` +\n (behaviour.receivers_exchange !== null\n ? ` (${countText(behaviour.receivers_exchange)} of them exchange wallets)`\n : '')\n )\n }\n if (behaviour.dex_pools !== null) {\n parts.push(\n `it swapped on ${countText(behaviour.dex_pools)} DEX ${plural(behaviour.dex_pools, 'pool', 'pools')}`\n )\n }\n if (behaviour.approvals !== null) {\n parts.push(\n `it approved ${countText(behaviour.approvals)} ${plural(behaviour.approvals, 'spender', 'spenders')}`\n )\n }\n return parts.join(', ')\n}\n\n/** The check built from the batch members and the lookup rows, or why it cannot be. */\nexport function depositCheckFromMembers(\n network: string,\n address: string,\n members: Map<string, Member>,\n rows: ExchangeEntry[]\n): { result: AmlExchangeDepositCheckResult } | { failure: string } {\n const node = members.get('node')\n const swept = members.get('swept')\n if (!answered(node)) return { failure: memberFailure('node', node) }\n if (!answered(swept)) return { failure: memberFailure('swept', swept) }\n\n const nodeRow = rowsOf(node)[0]\n const labels = strings(nodeRow?.labels)\n const sweeps: Sweep[] = []\n let exchange: ExchangeEntry | null = null\n for (const row of rowsOf(swept)) {\n const hot = addressOrNull(row.hot_wallet)\n if (!hot) continue\n const listed =\n exchangeOfWallet(hot, rows)?.entry ?? exchangeOfLabels(strings(row.hot_wallet_labels), rows)\n exchange ??= listed\n const first = numberOrNull(row.first_seen_timestamp)\n const last = numberOrNull(row.last_seen_timestamp)\n sweeps.push({\n hot_wallet: hot,\n hot_wallet_exchange: listed?.exchange ?? null,\n hot_wallet_role: textOrNull(row.hot_wallet_role),\n sweep_count: numberOrNull(row.sweep_count),\n amount_usd_sum: numberOrNull(row.amount_usd_sum),\n paths: strings(row.paths),\n first_seen: first,\n first_seen_utc: utcOrNull(first),\n last_seen: last,\n last_seen_utc: utcOrNull(last),\n })\n }\n sweeps.sort((a, b) => (b.sweep_count ?? 0) - (a.sweep_count ?? 0))\n exchange ??= exchangeOfLabels(labels, rows) ?? exchangeOfWallet(address, rows)?.entry ?? null\n const role = cexRoleOf(nodeRow?.cex_role)\n const found = nodeRow !== undefined || sweeps.length > 0\n const isDeposit = role === 'deposit' || sweeps.length > 0\n const behaviour = behaviourFromMembers(members)\n const result = {\n schema: AML_EXCHANGE_DEPOSIT_CHECK_SCHEMA,\n tool: AML_EXCHANGE_DEPOSIT_CHECK_TOOL,\n network,\n address,\n found,\n is_deposit: isDeposit,\n cex_role: role ?? (sweeps.length > 0 ? ('deposit' as const) : null),\n exchange: exchange?.exchange ?? null,\n exchange_display: exchange?.display ?? null,\n labels,\n swept: sweeps,\n behaviour: found ? behaviour : null,\n does_not_fit_deposit: found && !isDeposit && !role ? doesNotFitDeposit(behaviour) : [],\n deposit_profile: EXCHANGE_DEPOSIT_BEHAVIOUR,\n }\n return { result: { ...result, hint: `${hintFor(result)} ${PROFILE_HINT}` } }\n}\n\n/** Closes every hint: a host asked how a deposit address behaves answers from deposit_profile, not from its own idea of one. */\nconst PROFILE_HINT =\n 'Asked how a deposit address behaves, what makes an address one or what rules one out, answer with deposit_profile.'\n\n/** \" once\", \" 3 times\", or \"\" when the graph gave no count. */\nfunction timesText(count: number | null): string {\n if (count === null) return ''\n return count === 1 ? ' once' : ` ${count} times`\n}\n\nfunction hintFor(result: Omit<AmlExchangeDepositCheckResult, 'hint'>): string {\n const { address, network } = result\n const name = result.exchange_display ?? 'its exchange (name it from labels)'\n if (!result.found) {\n return (\n `${ANSWER_HINT} ${address} is not in the Chain Insights Graph of ${network}: no flow touches it. ` +\n 'Say so in one line, and check the network and the address with the user: name no other network yourself, and say nothing about what the check covers. ' +\n 'A claim that it is an exchange deposit address is unproven on this network: never repeat it as a fact.'\n )\n }\n if (result.is_deposit) {\n const top = result.swept[0]\n const into = top\n ? ` It swept${timesText(top.sweep_count)} into the hot wallet ${top.hot_wallet}` +\n (result.swept.length > 1\n ? `, and into ${result.swept.length - 1} more hot wallets (swept lists them)`\n : '') +\n '.'\n : ' The graph holds no SWEPT link of it yet: its sweeps are not drawn.'\n return (\n `${ANSWER_HINT} Say: \"${address} is a deposit address of ${name} on ${network}.\"${into} ` +\n 'This is where the money entered the exchange: the exchange can name the customer behind the deposit. ' +\n `${behaviourHint(result)}${EXCHANGE_OPENING_RULE}`\n )\n }\n if (result.cex_role) {\n return (\n `${ANSWER_HINT} Say: \"${address} is a ${result.cex_role.replace('_', ' ')} of ${name} on ${network}, not a deposit address.\" ` +\n 'A trail that reaches it has entered the exchange: end the trail there.'\n )\n }\n const misfit =\n result.does_not_fit_deposit.length > 0\n ? `What a deposit address does not do, and this one did: ${result.does_not_fit_deposit.join('; ')}. `\n : 'Its counts alone rule nothing out; the missing mark does: the rule of the graph did not judge it a deposit. '\n return (\n `${ANSWER_HINT} ${address} carries no deposit mark: no SWEPT link and no cex_role. ` +\n 'Say that the graph shows no sweep of it into a listed exchange hot wallet. That is not proof the address belongs to no exchange; ' +\n `its labels and its links say what else it is. ${behaviourHint(result)}${misfit}` +\n 'Give these facts as the reason and no other: set no threshold of your own for payers, volume or sweeps.'\n )\n}\n\n/** \"Its behaviour: ... . \" for a hint, or \"\" when no count was read. */\nfunction behaviourHint(result: Omit<AmlExchangeDepositCheckResult, 'hint'>): string {\n const text = result.behaviour ? behaviourText(result.behaviour) : ''\n return text === '' ? '' : `Its behaviour, as the graph counts it: ${text}. `\n}\n\nfunction errorResult(text: string): AmlExchangeDepositCheckToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: AmlExchangeDepositCheckResult): AmlExchangeDepositCheckToolResult {\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\n/** aml_exchange_deposit_check, {network, address}. Every argument is checked before a read is sent. */\nexport async function handleAmlExchangeDepositCheck(\n args: unknown,\n deps: ExchangeDepositCheckDependencies\n): Promise<AmlExchangeDepositCheckToolResult> {\n const record = isRecord(args) ? args : {}\n let network: string\n try {\n network = normalizeDexNetwork(record.network)\n } catch (err) {\n return errorResult(\n err instanceof DexRegistryError ? err.message : `invalid_network: ${(err as Error).message}`\n )\n }\n const raw = typeof record.address === 'string' ? record.address.trim() : ''\n if (!ADDRESS_INPUT.test(raw)) {\n return errorResult(\n 'invalid_address: address is required: 0x plus 40 hex characters. ' +\n 'An exchange name is not an address: call meta_exchange_lookup for its wallets.'\n )\n }\n const address = raw.toLowerCase()\n\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n return errorResult(\n `No exchange deposit read was sent: ${unavailable} There is no answer yet, which is not \"no deposit\": try again later.`\n )\n }\n\n let rows: ExchangeEntry[] = []\n try {\n rows = (await deps.loadExchangeRegistry(network)).document.rows\n } catch {\n // The lookup only names the exchange; the graph read still answers.\n }\n\n let answer: GraphAnswer\n try {\n answer = await deps.graphQueryBatch({ network, queries: depositCheckQueries(address) })\n } catch (err) {\n return errorResult(\n `The exchange deposit read failed: ${deps.describeFailure(err)} This is not \"no deposit\": send the same check again once.`\n )\n }\n const members = membersOf(answer)\n if (members.size === 0) {\n const text = answer.isError === true ? refusalOf(answer).text : 'the batch answer held no reads'\n return errorResult(`The exchange deposit read failed: ${text} This is not \"no deposit\".`)\n }\n const check = depositCheckFromMembers(network, address, members, rows)\n if ('failure' in check) {\n return errorResult(\n `The exchange deposit read failed: ${check.failure} This is not \"no deposit\": send the same check again once.`\n )\n }\n return textResult(check.result)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,kCAAkC;AAC/C,MAAa,oCACX;AACF,MAAa,mCAAmC;;;;;;;AAOhD,MAAa,6BACX;AAOF,MAAa,yCACX,4zBAMG,GAXA,2BAA2B,kYAWF,GAAG;AACjC,MAAa,yCAAyC;CACpD,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;;AAIA,MAAa,cAAc;;AAmB3B,MAAa,sBAAsB;AAgEnC,MAAM,gBAAgB;AACtB,MAAM,eAAe;AAErB,SAAS,kBAAkB,SAAuB;CAChD,IAAI,CAAC,aAAa,KAAK,OAAO,GAC5B,MAAM,IAAI,MACR,2BAA2B,KAAK,UAAU,OAAO,EAAE,+BACrD;AAEJ;;AAGA,SAAgB,iBAAiB,SAAyB;CACxD,kBAAkB,OAAO;CACzB,OACE,4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,MAAM,QAAQ,wBAAwB,SAAS,SAAS,SAAS,IAAI;CACrE,IAAI,aAAa,OACf,OAAO,YACL,qCAAqC,MAAM,QAAQ,2DACrD;CAEF,OAAO,WAAW,MAAM,MAAM;AAChC"}
|
|
@@ -3,7 +3,7 @@ const require_answer_hint = require("./answer-hint-BlYEBq_Y.cjs");
|
|
|
3
3
|
const require_dex_registry = require("./dex-registry-BhGJUG9_.cjs");
|
|
4
4
|
const require_exchange_registry = require("./exchange-registry-CT0rRW__.cjs");
|
|
5
5
|
const require_exchange_tool = require("./exchange-tool-B2SMeC5f.cjs");
|
|
6
|
-
const require_graph_schema = require("./graph-schema-
|
|
6
|
+
const require_graph_schema = require("./graph-schema-u0TipQPl.cjs");
|
|
7
7
|
const require_print_result = require("./print-result-BYppJlUi.cjs");
|
|
8
8
|
const require_token_lookup = require("./token-lookup-D-5GBEwF.cjs");
|
|
9
9
|
// src/mcp/exchange-deposit-check.ts
|