chain-insights 0.84.1 → 0.85.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/cli.cjs +5 -5
- package/dist/cli.mjs +5 -5
- package/dist/{deployer-screen-e3IbG1Y_.mjs → deployer-screen-BCk6ldOs.mjs} +2 -2
- package/dist/{deployer-screen-e3IbG1Y_.mjs.map → deployer-screen-BCk6ldOs.mjs.map} +1 -1
- package/dist/{deployer-screen-DQw3pC0E.cjs → deployer-screen-BG3Ihrd2.cjs} +1 -1
- package/dist/{exchange-deposit-check-9bGrKwcX.mjs → exchange-deposit-check-CJxDbgI_.mjs} +2 -2
- package/dist/{exchange-deposit-check-9bGrKwcX.mjs.map → exchange-deposit-check-CJxDbgI_.mjs.map} +1 -1
- package/dist/{exchange-deposit-check-ClPd7HQl.cjs → exchange-deposit-check-DhzNC3wD.cjs} +1 -1
- package/dist/mcp-proxy.cjs +3 -3
- package/dist/mcp-proxy.mjs +3 -3
- package/dist/{token-lookup-D-5GBEwF.cjs → token-lookup-BhoDUqiB.cjs} +67 -12
- package/dist/{token-lookup-QpIv77P2.mjs → token-lookup-hpmah4XX.mjs} +68 -13
- package/dist/token-lookup-hpmah4XX.mjs.map +1 -0
- package/docs/mcp-proxy.md +37 -28
- package/package.json +1 -1
- package/skills/chain-insights-cypher/SKILL.md +1 -1
- package/dist/token-lookup-QpIv77P2.mjs.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -648,8 +648,8 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
648
648
|
}
|
|
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-Be9NAuD8.cjs")).then((n) => n.dex_tool_exports);
|
|
651
|
-
const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./token-lookup-
|
|
652
|
-
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await Promise.resolve().then(() => require("./deployer-screen-
|
|
651
|
+
const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./token-lookup-BhoDUqiB.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-BG3Ihrd2.cjs")).then((n) => n.deployer_screen_exports);
|
|
653
653
|
console.log("");
|
|
654
654
|
console.log(formatToolsTable([
|
|
655
655
|
{
|
|
@@ -709,7 +709,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
709
709
|
return;
|
|
710
710
|
}
|
|
711
711
|
if (tool === "meta_token_lookup") {
|
|
712
|
-
const { handleMetaTokenLookup } = await Promise.resolve().then(() => require("./token-lookup-
|
|
712
|
+
const { handleMetaTokenLookup } = await Promise.resolve().then(() => require("./token-lookup-BhoDUqiB.cjs")).then((n) => n.token_lookup_exports);
|
|
713
713
|
const { metaTokenLookupArgs } = await Promise.resolve().then(() => require("./call-args-DXEmPeE-.cjs"));
|
|
714
714
|
const result = await withGraphMcpClient("chain-insights-cli-token-lookup", (client) => handleMetaTokenLookup(metaTokenLookupArgs(args), {
|
|
715
715
|
graphQuery: async (queryArgs) => await client.callTool({
|
|
@@ -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-BG3Ihrd2.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-DhzNC3wD.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
|
@@ -646,8 +646,8 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
646
646
|
}
|
|
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-7BK_gD6H.mjs").then((n) => n.a);
|
|
649
|
-
const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await import("./token-lookup-
|
|
650
|
-
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await import("./deployer-screen-
|
|
649
|
+
const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await import("./token-lookup-hpmah4XX.mjs").then((n) => n.l);
|
|
650
|
+
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await import("./deployer-screen-BCk6ldOs.mjs").then((n) => n.a);
|
|
651
651
|
console.log("");
|
|
652
652
|
console.log(formatToolsTable([
|
|
653
653
|
{
|
|
@@ -707,7 +707,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
707
707
|
return;
|
|
708
708
|
}
|
|
709
709
|
if (tool === "meta_token_lookup") {
|
|
710
|
-
const { handleMetaTokenLookup } = await import("./token-lookup-
|
|
710
|
+
const { handleMetaTokenLookup } = await import("./token-lookup-hpmah4XX.mjs").then((n) => n.l);
|
|
711
711
|
const { metaTokenLookupArgs } = await import("./call-args-CBqbYfOE.mjs");
|
|
712
712
|
const result = await withGraphMcpClient("chain-insights-cli-token-lookup", (client) => handleMetaTokenLookup(metaTokenLookupArgs(args), {
|
|
713
713
|
graphQuery: async (queryArgs) => await client.callTool({
|
|
@@ -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-BCk6ldOs.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-CJxDbgI_.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"],
|
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
|
2
2
|
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 { i as isEpochMs, o as utcText } from "./print-result-IFARsMnL.mjs";
|
|
5
|
-
import { c as refusalOf, s as membersOf } from "./token-lookup-
|
|
5
|
+
import { c as refusalOf, s as membersOf } from "./token-lookup-hpmah4XX.mjs";
|
|
6
6
|
// src/mcp/deployer-screen.ts
|
|
7
7
|
/**
|
|
8
8
|
* aml_deployer_screen: who is behind a token or a wallet, as facts.
|
|
@@ -434,4 +434,4 @@ async function handleAmlDeployerScreen(args, deps) {
|
|
|
434
434
|
}
|
|
435
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 };
|
|
436
436
|
|
|
437
|
-
//# sourceMappingURL=deployer-screen-
|
|
437
|
+
//# sourceMappingURL=deployer-screen-BCk6ldOs.mjs.map
|
|
@@ -1 +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;CAAa;CAAiB;AAAkB;AAgG9F,MAAM,gBAAgB;AACtB,MAAM,eAAe;AAIrB,MAAM,cAAc;AAGpB,MAAM,qBACJ;AAGF,MAAM,yBACJ;AACF,MAAM,cACJ;AACF,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AACX,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAS,kBAAkB,SAAuB;CAChD,IAAI,CAAC,aAAa,KAAK,OAAO,GAC5B,MAAM,IAAI,MAAM,oBAAoB,KAAK,UAAU,OAAO,EAAE,+BAA+B;AAE/F;;AAGA,SAAgB,iBAAiB,SAAiB,QAAuB,SAAiB;CACxF,kBAAkB,OAAO;CACzB,OAAO;EACL,2CAA2C,QAAQ;EACnD;EACA;EACA,WAAW,KAAK;EAChB;EACA;EACA;EACA,UAAU,cAAc,IAAI,aAAa,KAAK,EAAE;CAClD,CAAC,CAAC,KAAK,GAAG;AACZ;AAEA,SAAS,WAAW,OAA8B;CAChD,OAAO,UAAU,WAAW,qBAAqB;AACnD;AAEA,SAAS,aAAa,OAA8B;CAClD,OAAO,UAAU,WACb,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,oEACnD;CAIF,IAAI,QAAuB;CAC3B,IAAI,KAAK,WACP,IAAI;EACF,QAAQ,MAAM,KAAK,UAAU,OAAO;CACtC,QAAQ;EACN,QAAQ;CACV;CAGF,IAAI;CACJ,IAAI;EACF,SAAS,MAAM,KAAK,gBAAgB;GAAE;GAAS,SAAS,sBAAsB,SAAS,KAAK;EAAE,CAAC;CACjG,SAAS,KAAK;EACZ,OAAO,YACL,oCAAoC,KAAK,gBAAgB,GAAG,EAAE,2DAChE;CACF;CACA,MAAM,UAAU,UAAU,MAAM;CAChC,IAAI,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"}
|
|
1
|
+
{"version":3,"file":"deployer-screen-BCk6ldOs.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;CAAa;CAAiB;AAAkB;AAgG9F,MAAM,gBAAgB;AACtB,MAAM,eAAe;AAIrB,MAAM,cAAc;AAGpB,MAAM,qBACJ;AAGF,MAAM,yBACJ;AACF,MA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B,SAAS,SAAS,OAAO;CAC1D,IAAI,aAAa,QACf,OAAO,YACL,oCAAoC,OAAO,QAAQ,2DACrD;CAEF,OAAO,WAAW,OAAO,MAAM;AACjC"}
|
|
@@ -2,7 +2,7 @@ const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
|
2
2
|
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_print_result = require("./print-result-BYppJlUi.cjs");
|
|
5
|
-
const require_token_lookup = require("./token-lookup-
|
|
5
|
+
const require_token_lookup = require("./token-lookup-BhoDUqiB.cjs");
|
|
6
6
|
// src/mcp/deployer-screen.ts
|
|
7
7
|
/**
|
|
8
8
|
* aml_deployer_screen: who is behind a token or a wallet, as facts.
|
|
@@ -5,7 +5,7 @@ import { n as exchangeOfWallet, t as exchangeOfLabels } from "./exchange-registr
|
|
|
5
5
|
import { t as EXCHANGE_OPENING_RULE } from "./exchange-tool-Dc46SJ49.mjs";
|
|
6
6
|
import { t as CEX_ROLES } from "./graph-schema-CRQuKya1.mjs";
|
|
7
7
|
import { i as isEpochMs, o as utcText } from "./print-result-IFARsMnL.mjs";
|
|
8
|
-
import { c as refusalOf, s as membersOf } from "./token-lookup-
|
|
8
|
+
import { c as refusalOf, s as membersOf } from "./token-lookup-hpmah4XX.mjs";
|
|
9
9
|
// src/mcp/exchange-deposit-check.ts
|
|
10
10
|
/**
|
|
11
11
|
* aml_exchange_deposit_check: is this address an exchange deposit, of which
|
|
@@ -389,4 +389,4 @@ async function handleAmlExchangeDepositCheck(args, deps) {
|
|
|
389
389
|
}
|
|
390
390
|
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 };
|
|
391
391
|
|
|
392
|
-
//# sourceMappingURL=exchange-deposit-check-
|
|
392
|
+
//# sourceMappingURL=exchange-deposit-check-CJxDbgI_.mjs.map
|
package/dist/{exchange-deposit-check-9bGrKwcX.mjs.map → exchange-deposit-check-CJxDbgI_.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-deposit-check-9bGrKwcX.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.\n *\n * The exchange model's own guess rides beside them on the node (graph sync\n * layer `inferred`): `inferred_exchange_role`, an `ml:exchange-roles:<model>:\n * <basis>` entry in `inferred_sources`, and the time it was written. It is\n * never a label and never a SWEPT link. A sourced mark always wins; an\n * address with only the guess is answered as inferred, with the model, and\n * `is_deposit` stays false. 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\n/** The one rule for an inferred answer, in the description every host reads and in the skill. */\nexport const EXCHANGE_INFERRED_RULE =\n \"An answer with inferred: true is the exchange model's prediction, not a listed source: report the address as inferred by the model, with its version (inferred_model), never as a confirmed exchange address.\"\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_INFERRED_RULE} ${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\n/** The roles the exchange model infers. */\nexport const INFERRED_EXCHANGE_ROLES = ['deposit', 'hot_wallet'] as const\nexport type InferredExchangeRole = (typeof INFERRED_EXCHANGE_ROLES)[number]\n\n/**\n * Why the model inferred the role, from the suffix of its source entry:\n * `rule` a deposit behind a listed hot wallet, `rule-p` a deposit behind a hot\n * wallet the model inferred, `p-hub` a hot wallet the model inferred.\n */\nexport const INFERRED_BASIS = {\n rule: 'listed_hot_wallet',\n 'rule-p': 'predicted_hot_wallet',\n 'p-hub': 'predicted',\n} as const\nexport type InferredBasis = (typeof INFERRED_BASIS)[keyof typeof INFERRED_BASIS]\n\n/** The prefix of the exchange model's entries in `inferred_sources`. */\nexport const EXCHANGE_MODEL_SOURCE_PREFIX = 'ml:exchange-roles:'\n\nexport interface InferredExchangeMark {\n role: InferredExchangeRole\n model: string\n basis: InferredBasis\n /** ISO time the graph wrote the guess, or null when it carries none. */\n at: string | null\n}\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 /** Set only when no sourced mark exists and the exchange model inferred a role. */\n inferred?: true\n inferred_role?: InferredExchangeRole\n /** The model version, from its `ml:exchange-roles:` source entry. */\n inferred_model?: string\n inferred_basis?: InferredBasis\n inferred_at?: string | null\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, its cex_role and the exchange model's inferred 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, ' +\n 'a.inferred_exchange_role AS inferred_exchange_role, a.inferred_sources AS inferred_sources, ' +\n 'a.inferred_exchange_role_updated_timestamp AS inferred_exchange_role_updated_timestamp 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\n/**\n * The exchange model's mark of a node row, or null. It needs both the role and\n * an `ml:exchange-roles:<model>:<basis>` source entry: a role with no entry of\n * the exchange model is no inferred mark. The model version may hold hyphens,\n * underscores and colons; the basis is the last part.\n */\nexport function inferredExchangeOf(\n row: Record<string, unknown> | undefined\n): InferredExchangeMark | null {\n const role = textOrNull(row?.inferred_exchange_role)?.toLowerCase()\n if (!(INFERRED_EXCHANGE_ROLES as readonly string[]).includes(role ?? '')) return null\n const marks: Array<{ model: string; basis: InferredBasis; suffix: string }> = []\n for (const source of strings(row?.inferred_sources)) {\n const entry = source.trim()\n if (!entry.startsWith(EXCHANGE_MODEL_SOURCE_PREFIX)) continue\n const rest = entry.slice(EXCHANGE_MODEL_SOURCE_PREFIX.length)\n const cut = rest.lastIndexOf(':')\n if (cut <= 0) continue\n const model = rest.slice(0, cut)\n const suffix = rest.slice(cut + 1)\n if (!Object.prototype.hasOwnProperty.call(INFERRED_BASIS, suffix)) continue\n marks.push({ model, basis: INFERRED_BASIS[suffix as keyof typeof INFERRED_BASIS], suffix })\n }\n // The entry that fits the role first: p-hub names a hot wallet, rule and rule-p a deposit.\n const fits = (suffix: string) => (role === 'hot_wallet') === (suffix === 'p-hub')\n const mark = marks.find((m) => fits(m.suffix)) ?? marks[0]\n if (!mark) return null\n const ms = numberOrNull(row?.inferred_exchange_role_updated_timestamp)\n return {\n role: role as InferredExchangeRole,\n model: mark.model,\n basis: mark.basis,\n at: isEpochMs(ms) ? new Date(ms).toISOString() : null,\n }\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 // A sourced mark always wins: the guess is read only for an address with none.\n const guess = role === null && sweeps.length === 0 ? inferredExchangeOf(nodeRow) : null\n const result: Omit<AmlExchangeDepositCheckResult, 'hint'> = {\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 ...(guess\n ? {\n inferred: true as const,\n inferred_role: guess.role,\n inferred_model: guess.model,\n inferred_basis: guess.basis,\n inferred_at: guess.at,\n }\n : {}),\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.inferred && result.inferred_role && result.inferred_model) {\n return inferredHint(result, result.inferred_role, result.inferred_model)\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/** Why the model holds its guess, in reader words. */\nconst INFERRED_BASIS_TEXT: Record<InferredBasis, string> = {\n listed_hot_wallet: 'The model placed it behind a listed exchange hot wallet.',\n predicted_hot_wallet: 'The model placed it behind a hot wallet the model itself inferred, which no listed source names either.',\n predicted: 'The model inferred it from how the address moves money.',\n}\n\n/** The hint of an address with no sourced mark and the exchange model's guess. */\nfunction inferredHint(\n result: Omit<AmlExchangeDepositCheckResult, 'hint'>,\n role: InferredExchangeRole,\n model: string\n): string {\n const { address, network } = result\n const what = role === 'deposit' ? 'an exchange deposit' : 'an exchange hot wallet'\n const basis = result.inferred_basis ? `${INFERRED_BASIS_TEXT[result.inferred_basis]} ` : ''\n const trail =\n role === 'deposit'\n ? 'The graph draws no SWEPT link for it, so no hot wallet is named: name none yourself. '\n : 'A trail that reaches it may have entered an exchange there: say so as inferred, and name no exchange the answer does not name. '\n return (\n `${ANSWER_HINT} Say: \"${address} is ${what}, inferred by model ${model}, on ${network}. ` +\n 'No listed source names it as an exchange address.\" ' +\n `${basis}${trail}` +\n 'Report it as inferred, never as a confirmed exchange address: is_deposit (false) and cex_role (null) are the sourced verdict, and the guess does not change them. ' +\n `${behaviourHint(result)}` +\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,kCAAkC;AAC/C,MAAa,oCACX;AACF,MAAa,mCAAmC;;;;;;;AAOhD,MAAa,6BACX;AAWF,MAAa,yCACX,4zBAMG,GAfA,2BAA2B,kYAeF,iNAA6B;AAC3D,MAAa,yCAAyC;CACpD,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;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U,oBAAoB,OAAO,OAAO;CAC9C,SAAS,KAAK;EACZ,OAAO,YACL,eAAe,mBAAmB,IAAI,UAAU,oBAAqB,IAAc,SACrF;CACF;CACA,MAAM,MAAM,OAAO,OAAO,YAAY,WAAW,OAAO,QAAQ,KAAK,IAAI;CACzE,IAAI,CAAC,cAAc,KAAK,GAAG,GACzB,OAAO,YACL,iJAEF;CAEF,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-CJxDbgI_.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.\n *\n * The exchange model's own guess rides beside them on the node (graph sync\n * layer `inferred`): `inferred_exchange_role`, an `ml:exchange-roles:<model>:\n * <basis>` entry in `inferred_sources`, and the time it was written. It is\n * never a label and never a SWEPT link. A sourced mark always wins; an\n * address with only the guess is answered as inferred, with the model, and\n * `is_deposit` stays false. 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\n/** The one rule for an inferred answer, in the description every host reads and in the skill. */\nexport const EXCHANGE_INFERRED_RULE =\n \"An answer with inferred: true is the exchange model's prediction, not a listed source: report the address as inferred by the model, with its version (inferred_model), never as a confirmed exchange address.\"\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_INFERRED_RULE} ${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\n/** The roles the exchange model infers. */\nexport const INFERRED_EXCHANGE_ROLES = ['deposit', 'hot_wallet'] as const\nexport type InferredExchangeRole = (typeof INFERRED_EXCHANGE_ROLES)[number]\n\n/**\n * Why the model inferred the role, from the suffix of its source entry:\n * `rule` a deposit behind a listed hot wallet, `rule-p` a deposit behind a hot\n * wallet the model inferred, `p-hub` a hot wallet the model inferred.\n */\nexport const INFERRED_BASIS = {\n rule: 'listed_hot_wallet',\n 'rule-p': 'predicted_hot_wallet',\n 'p-hub': 'predicted',\n} as const\nexport type InferredBasis = (typeof INFERRED_BASIS)[keyof typeof INFERRED_BASIS]\n\n/** The prefix of the exchange model's entries in `inferred_sources`. */\nexport const EXCHANGE_MODEL_SOURCE_PREFIX = 'ml:exchange-roles:'\n\nexport interface InferredExchangeMark {\n role: InferredExchangeRole\n model: string\n basis: InferredBasis\n /** ISO time the graph wrote the guess, or null when it carries none. */\n at: string | null\n}\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 /** Set only when no sourced mark exists and the exchange model inferred a role. */\n inferred?: true\n inferred_role?: InferredExchangeRole\n /** The model version, from its `ml:exchange-roles:` source entry. */\n inferred_model?: string\n inferred_basis?: InferredBasis\n inferred_at?: string | null\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, its cex_role and the exchange model's inferred 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, ' +\n 'a.inferred_exchange_role AS inferred_exchange_role, a.inferred_sources AS inferred_sources, ' +\n 'a.inferred_exchange_role_updated_timestamp AS inferred_exchange_role_updated_timestamp 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\n/**\n * The exchange model's mark of a node row, or null. It needs both the role and\n * an `ml:exchange-roles:<model>:<basis>` source entry: a role with no entry of\n * the exchange model is no inferred mark. The model version may hold hyphens,\n * underscores and colons; the basis is the last part.\n */\nexport function inferredExchangeOf(\n row: Record<string, unknown> | undefined\n): InferredExchangeMark | null {\n const role = textOrNull(row?.inferred_exchange_role)?.toLowerCase()\n if (!(INFERRED_EXCHANGE_ROLES as readonly string[]).includes(role ?? '')) return null\n const marks: Array<{ model: string; basis: InferredBasis; suffix: string }> = []\n for (const source of strings(row?.inferred_sources)) {\n const entry = source.trim()\n if (!entry.startsWith(EXCHANGE_MODEL_SOURCE_PREFIX)) continue\n const rest = entry.slice(EXCHANGE_MODEL_SOURCE_PREFIX.length)\n const cut = rest.lastIndexOf(':')\n if (cut <= 0) continue\n const model = rest.slice(0, cut)\n const suffix = rest.slice(cut + 1)\n if (!Object.prototype.hasOwnProperty.call(INFERRED_BASIS, suffix)) continue\n marks.push({ model, basis: INFERRED_BASIS[suffix as keyof typeof INFERRED_BASIS], suffix })\n }\n // The entry that fits the role first: p-hub names a hot wallet, rule and rule-p a deposit.\n const fits = (suffix: string) => (role === 'hot_wallet') === (suffix === 'p-hub')\n const mark = marks.find((m) => fits(m.suffix)) ?? marks[0]\n if (!mark) return null\n const ms = numberOrNull(row?.inferred_exchange_role_updated_timestamp)\n return {\n role: role as InferredExchangeRole,\n model: mark.model,\n basis: mark.basis,\n at: isEpochMs(ms) ? new Date(ms).toISOString() : null,\n }\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 // A sourced mark always wins: the guess is read only for an address with none.\n const guess = role === null && sweeps.length === 0 ? inferredExchangeOf(nodeRow) : null\n const result: Omit<AmlExchangeDepositCheckResult, 'hint'> = {\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 ...(guess\n ? {\n inferred: true as const,\n inferred_role: guess.role,\n inferred_model: guess.model,\n inferred_basis: guess.basis,\n inferred_at: guess.at,\n }\n : {}),\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.inferred && result.inferred_role && result.inferred_model) {\n return inferredHint(result, result.inferred_role, result.inferred_model)\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/** Why the model holds its guess, in reader words. */\nconst INFERRED_BASIS_TEXT: Record<InferredBasis, string> = {\n listed_hot_wallet: 'The model placed it behind a listed exchange hot wallet.',\n predicted_hot_wallet: 'The model placed it behind a hot wallet the model itself inferred, which no listed source names either.',\n predicted: 'The model inferred it from how the address moves money.',\n}\n\n/** The hint of an address with no sourced mark and the exchange model's guess. */\nfunction inferredHint(\n result: Omit<AmlExchangeDepositCheckResult, 'hint'>,\n role: InferredExchangeRole,\n model: string\n): string {\n const { address, network } = result\n const what = role === 'deposit' ? 'an exchange deposit' : 'an exchange hot wallet'\n const basis = result.inferred_basis ? `${INFERRED_BASIS_TEXT[result.inferred_basis]} ` : ''\n const trail =\n role === 'deposit'\n ? 'The graph draws no SWEPT link for it, so no hot wallet is named: name none yourself. '\n : 'A trail that reaches it may have entered an exchange there: say so as inferred, and name no exchange the answer does not name. '\n return (\n `${ANSWER_HINT} Say: \"${address} is ${what}, inferred by model ${model}, on ${network}. ` +\n 'No listed source names it as an exchange address.\" ' +\n `${basis}${trail}` +\n 'Report it as inferred, never as a confirmed exchange address: is_deposit (false) and cex_role (null) are the sourced verdict, and the guess does not change them. ' +\n `${behaviourHint(result)}` +\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,kCAAkC;AAC/C,MAAa,oCACX;AACF,MAAa,mCAAmC;;;;;;;AAOhD,MAAa,6BACX;AAWF,MAAa,yCACX,4zBAMG,GAfA,2BAA2B,kYAeF,iNAA6B;AAC3D,MAAa,yCAAyC;CACpD,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;;AAIA,MAAa,cAAc;;AAK3B,MAAa,0BAA0B,CAAC,WAAW,YAAY;;;;;;AAQ/D,MAAa,iBAAiB;CAC5B,MAAM;CACN,UAAU;CACV,SAAS;AACX;;AAIA,MAAa,+BAA+B;;AAyB5C,MAAa,sBAAsB;AAuEnC,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,4CAA4C,QAAQ;AAKxD;;AAGA,SAAgB,kBAAkB,SAAyB;CACzD,kBAAkB,OAAO;CACzB,OACE,4CAA4C,QAAQ,k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AK,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"}
|
|
@@ -5,7 +5,7 @@ const require_exchange_registry = require("./exchange-registry-CT0rRW__.cjs");
|
|
|
5
5
|
const require_exchange_tool = require("./exchange-tool-B2SMeC5f.cjs");
|
|
6
6
|
const require_graph_schema = require("./graph-schema-CcrYPpSv.cjs");
|
|
7
7
|
const require_print_result = require("./print-result-BYppJlUi.cjs");
|
|
8
|
-
const require_token_lookup = require("./token-lookup-
|
|
8
|
+
const require_token_lookup = require("./token-lookup-BhoDUqiB.cjs");
|
|
9
9
|
// src/mcp/exchange-deposit-check.ts
|
|
10
10
|
/**
|
|
11
11
|
* aml_exchange_deposit_check: is this address an exchange deposit, of which
|
package/dist/mcp-proxy.cjs
CHANGED
|
@@ -13,10 +13,10 @@ const require_action_log = require("./action-log-WMW6xFMx.cjs");
|
|
|
13
13
|
const require_answer_hint = require("./answer-hint-BlYEBq_Y.cjs");
|
|
14
14
|
const require_dex_tool = require("./dex-tool-Be9NAuD8.cjs");
|
|
15
15
|
const require_dex_registry = require("./dex-registry-BhGJUG9_.cjs");
|
|
16
|
-
const require_token_lookup = require("./token-lookup-
|
|
17
|
-
const require_deployer_screen = require("./deployer-screen-
|
|
16
|
+
const require_token_lookup = require("./token-lookup-BhoDUqiB.cjs");
|
|
17
|
+
const require_deployer_screen = require("./deployer-screen-BG3Ihrd2.cjs");
|
|
18
18
|
const require_exchange_tool = require("./exchange-tool-B2SMeC5f.cjs");
|
|
19
|
-
const require_exchange_deposit_check = require("./exchange-deposit-check-
|
|
19
|
+
const require_exchange_deposit_check = require("./exchange-deposit-check-DhzNC3wD.cjs");
|
|
20
20
|
const require_exchange_registry = require("./exchange-registry-CT0rRW__.cjs");
|
|
21
21
|
let node_url = require("node:url");
|
|
22
22
|
let node_path = require("node:path");
|
package/dist/mcp-proxy.mjs
CHANGED
|
@@ -11,10 +11,10 @@ import { r as appendActionLog, t as actionLogSignalsFromResult } from "./action-
|
|
|
11
11
|
import { n as withAnswerHintResult } from "./answer-hint-vOE1O6Lf.mjs";
|
|
12
12
|
import { i as META_DEX_LOOKUP_TOOL, n as META_DEX_LOOKUP_DESCRIPTION, o as handleMetaDexLookup, r as META_DEX_LOOKUP_TITLE, t as META_DEX_LOOKUP_ANNOTATIONS } from "./dex-tool-7BK_gD6H.mjs";
|
|
13
13
|
import { c as loadRegistry } from "./dex-registry-BY67f4Ul.mjs";
|
|
14
|
-
import { a as SYMBOL_MAX, i as META_TOKEN_LOOKUP_TOOL, n as META_TOKEN_LOOKUP_DESCRIPTION, o as handleMetaTokenLookup, r as META_TOKEN_LOOKUP_TITLE, t as META_TOKEN_LOOKUP_ANNOTATIONS } from "./token-lookup-
|
|
15
|
-
import { i as AML_DEPLOYER_SCREEN_TOOL, n as AML_DEPLOYER_SCREEN_DESCRIPTION, o as handleAmlDeployerScreen, r as AML_DEPLOYER_SCREEN_TITLE, t as AML_DEPLOYER_SCREEN_ANNOTATIONS } from "./deployer-screen-
|
|
14
|
+
import { a as SYMBOL_MAX, i as META_TOKEN_LOOKUP_TOOL, n as META_TOKEN_LOOKUP_DESCRIPTION, o as handleMetaTokenLookup, r as META_TOKEN_LOOKUP_TITLE, t as META_TOKEN_LOOKUP_ANNOTATIONS } from "./token-lookup-hpmah4XX.mjs";
|
|
15
|
+
import { i as AML_DEPLOYER_SCREEN_TOOL, n as AML_DEPLOYER_SCREEN_DESCRIPTION, o as handleAmlDeployerScreen, r as AML_DEPLOYER_SCREEN_TITLE, t as AML_DEPLOYER_SCREEN_ANNOTATIONS } from "./deployer-screen-BCk6ldOs.mjs";
|
|
16
16
|
import { a as META_EXCHANGE_LOOKUP_TOOL, i as META_EXCHANGE_LOOKUP_TITLE, n as META_EXCHANGE_LOOKUP_ANNOTATIONS, r as META_EXCHANGE_LOOKUP_DESCRIPTION, s as handleMetaExchangeLookup } from "./exchange-tool-Dc46SJ49.mjs";
|
|
17
|
-
import { i as AML_EXCHANGE_DEPOSIT_CHECK_TOOL, n as AML_EXCHANGE_DEPOSIT_CHECK_DESCRIPTION, o as handleAmlExchangeDepositCheck, r as AML_EXCHANGE_DEPOSIT_CHECK_TITLE, t as AML_EXCHANGE_DEPOSIT_CHECK_ANNOTATIONS } from "./exchange-deposit-check-
|
|
17
|
+
import { i as AML_EXCHANGE_DEPOSIT_CHECK_TOOL, n as AML_EXCHANGE_DEPOSIT_CHECK_DESCRIPTION, o as handleAmlExchangeDepositCheck, r as AML_EXCHANGE_DEPOSIT_CHECK_TITLE, t as AML_EXCHANGE_DEPOSIT_CHECK_ANNOTATIONS } from "./exchange-deposit-check-CJxDbgI_.mjs";
|
|
18
18
|
import { i as loadExchangeRegistry } from "./exchange-registry-CoLgHw6d.mjs";
|
|
19
19
|
import { fileURLToPath } from "node:url";
|
|
20
20
|
import path from "node:path";
|
|
@@ -13,6 +13,11 @@ const require_print_result = require("./print-result-BYppJlUi.cjs");
|
|
|
13
13
|
* symbol or the name, case-insensitively and exactly, and orders the rows
|
|
14
14
|
* verified first, then oldest first. The proxy keeps that order.
|
|
15
15
|
*
|
|
16
|
+
* The read also asks the server how many contracts match. When more match than
|
|
17
|
+
* the 25 listed, a second read brings the newest: a copy of a verified token is
|
|
18
|
+
* made after it, so the oldest 25 alone hide exactly the copies. A server that
|
|
19
|
+
* does not count yet is read the old way, and the answer says the list is a part.
|
|
20
|
+
*
|
|
16
21
|
* Tickers collide on purpose: clones reuse a symbol to borrow its trust. The
|
|
17
22
|
* tool never picks one. The description below is the contract with every
|
|
18
23
|
* host, Claude Desktop chat included, which reads no skill.
|
|
@@ -26,7 +31,7 @@ var token_lookup_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll(
|
|
|
26
31
|
const META_TOKEN_LOOKUP_TOOL = "meta_token_lookup";
|
|
27
32
|
const META_TOKEN_LOOKUP_SCHEMA = "chain-insights.meta-token-lookup.v1";
|
|
28
33
|
const META_TOKEN_LOOKUP_TITLE = "Token by ticker or name";
|
|
29
|
-
const META_TOKEN_LOOKUP_DESCRIPTION = "Call this first when a question names a token by its ticker or name and gives no contract (TCITY, USDG, SPCX). It returns
|
|
34
|
+
const META_TOKEN_LOOKUP_DESCRIPTION = "Call this first when a question names a token by its ticker or name and gives no contract (TCITY, USDG, SPCX). It returns the contracts on the network that carry that symbol, verified first, then oldest first, with the count of all of them and, when more than 25 match, the newest ones too. Tickers collide: never treat the first row as the token. When several match, name them and ask, or pick by the evidence the user gave. Zero candidates means no contract carries the symbol: say so, and do not search the web.";
|
|
30
35
|
const META_TOKEN_LOOKUP_ANNOTATIONS = {
|
|
31
36
|
readOnlyHint: true,
|
|
32
37
|
idempotentHint: true,
|
|
@@ -72,9 +77,14 @@ function textResult(structured) {
|
|
|
72
77
|
isError: false
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
/**
|
|
81
|
+
* The facts Asset read by symbol or by name. `counted` asks the server for the
|
|
82
|
+
* number of contracts that match, on every row. `newest` reads the newest 25
|
|
83
|
+
* instead of verified first, then oldest first. With neither it is the read
|
|
84
|
+
* every server admits.
|
|
85
|
+
*/
|
|
86
|
+
function assetQuery(key, value, form = "plain") {
|
|
87
|
+
return `USE facts MATCH (t:Asset {${key}: "${value}"}) RETURN t.asset_contract AS contract, t.asset_symbol AS symbol, t.name AS name, t.token_standard AS token_standard, t.decimals AS decimals, t.verified AS verified, t.verification_source AS verification_source, t.first_seen_timestamp AS first_seen_timestamp` + (form === "counted" ? ", t.match_count AS match_count" : "") + (form === "newest" ? ` ORDER BY t.first_seen_timestamp DESC LIMIT ${CANDIDATES_MAX}` : ` LIMIT ${ROWS_READ}`);
|
|
78
88
|
}
|
|
79
89
|
/** The topology read of who deployed one contract: the deploying address and the transaction's sender. */
|
|
80
90
|
function creatorQuery(contract) {
|
|
@@ -146,12 +156,12 @@ function candidateOf(row) {
|
|
|
146
156
|
factory: null
|
|
147
157
|
};
|
|
148
158
|
}
|
|
149
|
-
async function readAssets(deps, network, key, value) {
|
|
159
|
+
async function readAssets(deps, network, key, value, form) {
|
|
150
160
|
let answer;
|
|
151
161
|
try {
|
|
152
162
|
answer = await deps.graphQuery({
|
|
153
163
|
network,
|
|
154
|
-
query: assetQuery(key, value)
|
|
164
|
+
query: assetQuery(key, value, form)
|
|
155
165
|
});
|
|
156
166
|
} catch (err) {
|
|
157
167
|
return {
|
|
@@ -225,7 +235,8 @@ async function readCreators(deps, network, candidates) {
|
|
|
225
235
|
}
|
|
226
236
|
const NO_WEB = "Do not search the web and do not guess a contract: a web page is not a contract on this network.";
|
|
227
237
|
function hintFor(result, creatorsNotRead) {
|
|
228
|
-
const { network, query, candidates, matched_on, truncated } = result;
|
|
238
|
+
const { network, query, candidates, matched_on, truncated, matches, newest } = result;
|
|
239
|
+
const later = result.first_seen_after_verified;
|
|
229
240
|
const parts = [require_answer_hint.ANSWER_HINT];
|
|
230
241
|
if (candidates.length === 0) {
|
|
231
242
|
parts.push(`No contract on ${network} carries the symbol or the name "${query}". Say so in one line. ${NO_WEB} Ask the user for the contract if they have one.`);
|
|
@@ -233,7 +244,14 @@ function hintFor(result, creatorsNotRead) {
|
|
|
233
244
|
}
|
|
234
245
|
if (matched_on === "name") parts.push(`No contract carries "${query}" as its symbol; these carry it as their name.`);
|
|
235
246
|
if (candidates.length === 1) parts.push(`One contract on ${network} carries "${query}": ${candidates[0].contract}. Say it is the only one on this network, then read it by this full contract on USE topology.`);
|
|
236
|
-
else
|
|
247
|
+
else {
|
|
248
|
+
if (!truncated) parts.push(`${candidates.length} contracts on ${network} carry "${query}".`);
|
|
249
|
+
else if (matches === null) parts.push(`${candidates.length} contracts on ${network} carry "${query}", and more exist than the ${CANDIDATES_MAX} listed. The list is a part: never give its length as the count, and never say that none exist beyond it.`);
|
|
250
|
+
else parts.push(`${matches} contracts on ${network} carry "${query}". candidates lists ${candidates.length} of them, verified first, then oldest first${newest.length > 0 ? `, and newest lists the ${newest.length} newest that are not among them, newest first` : ""}. The lists are a part: the count is ${matches}, never the number of rows.`);
|
|
251
|
+
parts.push("Tickers collide: never treat the first row as the token. Name them, each contract in full, with its creator and first seen time, and ask which one the user means, or pick one by the evidence the user gave (a creator, a launch date, a price move) and say why.");
|
|
252
|
+
}
|
|
253
|
+
if (later && later.count > 0) parts.push(`${later.at_least ? "At least " : ""}${later.count} of them ${later.count === 1 ? "was" : "were"} first seen after the verified contract ${later.verified_contract}: each took a symbol that a verified token already carried. That is a copy of the name. A copied name alone is not proof of a scam.`);
|
|
254
|
+
if (later && later.at_least) parts.push(`This answer does not list every contract first seen after the verified contract ${later.verified_contract}${matches === null ? ": it lists the oldest only" : ""}. How many were made after it is not known from this answer${later.count === 0 ? ", and a list that shows none does not mean none exist" : ""}. Never answer that none, or no contract, was created after it; say the list holds the oldest contracts and the later ones are not in it.`);
|
|
237
255
|
if (creatorsNotRead) parts.push(`The creators were not read for ${creatorsNotRead}. creator and factory are empty there because the read failed, not because the chain holds none.`);
|
|
238
256
|
parts.push("Write every contract and creator in full, 0x plus 40 hex characters.");
|
|
239
257
|
return parts.join(" ");
|
|
@@ -263,17 +281,25 @@ async function handleMetaTokenLookup(args, deps) {
|
|
|
263
281
|
candidates: [],
|
|
264
282
|
total: 0,
|
|
265
283
|
truncated: false,
|
|
284
|
+
matches: null,
|
|
285
|
+
newest: [],
|
|
286
|
+
first_seen_after_verified: null,
|
|
266
287
|
hint: `${require_answer_hint.ANSWER_HINT} ${address} is a contract address, not a ticker: ${ADDRESS_INPUT_HINT}. Send no token lookup for it.`
|
|
267
288
|
});
|
|
268
289
|
}
|
|
269
290
|
if (unsafeLiteral(symbol)) return errorResult("invalid_symbol: a symbol holds no double quote, backslash or control character. Send the ticker or the name as plain text.");
|
|
270
291
|
const unavailable = await deps.unavailable?.();
|
|
271
292
|
if (unavailable) return errorResult(`No token read was sent: ${unavailable} The lookup has no answer yet, which is not "no contract": try again later, or ask the user for the contract. ${NO_WEB}`);
|
|
293
|
+
let form = "counted";
|
|
272
294
|
let matchedOn = "symbol";
|
|
273
|
-
let read = await readAssets(deps, network, "symbol", symbol);
|
|
295
|
+
let read = await readAssets(deps, network, "symbol", symbol, form);
|
|
296
|
+
if (read.kind === "not_served") {
|
|
297
|
+
form = "plain";
|
|
298
|
+
read = await readAssets(deps, network, "symbol", symbol, form);
|
|
299
|
+
}
|
|
274
300
|
if (read.kind === "rows" && read.rows.length === 0) {
|
|
275
301
|
matchedOn = "name";
|
|
276
|
-
read = await readAssets(deps, network, "name", symbol);
|
|
302
|
+
read = await readAssets(deps, network, "name", symbol, form);
|
|
277
303
|
}
|
|
278
304
|
if (read.kind === "failed") return errorResult(`The token read failed: ${read.text} This is not "no contract": send the same lookup again once, or ask the user for the contract. ${NO_WEB}`);
|
|
279
305
|
if (read.kind === "not_served") return textResult({
|
|
@@ -282,17 +308,46 @@ async function handleMetaTokenLookup(args, deps) {
|
|
|
282
308
|
candidates: [],
|
|
283
309
|
total: 0,
|
|
284
310
|
truncated: false,
|
|
311
|
+
matches: null,
|
|
312
|
+
newest: [],
|
|
313
|
+
first_seen_after_verified: null,
|
|
285
314
|
hint: `${require_answer_hint.ANSWER_HINT} This lookup gave no answer (${read.refusal.code}). That is not "no contract carries ${symbol}": ask the user for the token's contract, 0x plus 40 hex characters. ${NO_WEB}`
|
|
286
315
|
});
|
|
287
316
|
const total = read.rows.length;
|
|
317
|
+
const truncated = total > CANDIDATES_MAX;
|
|
288
318
|
const candidates = read.rows.slice(0, CANDIDATES_MAX).map(candidateOf).filter((candidate) => candidate !== null);
|
|
289
|
-
const
|
|
319
|
+
const counted = form === "counted" ? numberOrNull(read.rows[0]?.match_count) : null;
|
|
320
|
+
const matches = counted !== null && counted >= total ? counted : truncated ? null : total;
|
|
321
|
+
let newestPage = null;
|
|
322
|
+
if (truncated && form === "counted") {
|
|
323
|
+
const page = await readAssets(deps, network, matchedOn, symbol, "newest");
|
|
324
|
+
if (page.kind === "rows") newestPage = page.rows.map(candidateOf).filter((candidate) => candidate !== null);
|
|
325
|
+
}
|
|
326
|
+
const listed = new Set(candidates.map((candidate) => candidate.contract));
|
|
327
|
+
const verified = candidates.filter((candidate) => candidate.verified);
|
|
328
|
+
const anchor = verified.length === 1 && verified[0].first_seen_timestamp !== null ? verified[0] : null;
|
|
329
|
+
const after = (candidate) => anchor !== null && candidate.first_seen_timestamp !== null && candidate.first_seen_timestamp > anchor.first_seen_timestamp;
|
|
330
|
+
let firstSeenAfterVerified = null;
|
|
331
|
+
if (anchor) {
|
|
332
|
+
const pool = !truncated ? candidates : newestPage ?? candidates;
|
|
333
|
+
const reachesBack = !truncated || newestPage !== null && (newestPage.length < CANDIDATES_MAX || newestPage.some((row) => !after(row)));
|
|
334
|
+
firstSeenAfterVerified = {
|
|
335
|
+
verified_contract: anchor.contract,
|
|
336
|
+
count: pool.filter(after).length,
|
|
337
|
+
at_least: !reachesBack
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
const newest = (newestPage ?? []).filter((candidate) => !listed.has(candidate.contract));
|
|
341
|
+
const creatorsNotRead = candidates.length > 0 ? await readCreators(deps, network, [...candidates, ...newest]) : null;
|
|
290
342
|
const result = {
|
|
291
343
|
...base,
|
|
292
344
|
matched_on: candidates.length > 0 ? matchedOn : null,
|
|
293
345
|
candidates,
|
|
294
346
|
total,
|
|
295
|
-
truncated
|
|
347
|
+
truncated,
|
|
348
|
+
matches,
|
|
349
|
+
newest,
|
|
350
|
+
first_seen_after_verified: firstSeenAfterVerified
|
|
296
351
|
};
|
|
297
352
|
return textResult({
|
|
298
353
|
...result,
|
|
@@ -13,6 +13,11 @@ import { i as isEpochMs, o as utcText } from "./print-result-IFARsMnL.mjs";
|
|
|
13
13
|
* symbol or the name, case-insensitively and exactly, and orders the rows
|
|
14
14
|
* verified first, then oldest first. The proxy keeps that order.
|
|
15
15
|
*
|
|
16
|
+
* The read also asks the server how many contracts match. When more match than
|
|
17
|
+
* the 25 listed, a second read brings the newest: a copy of a verified token is
|
|
18
|
+
* made after it, so the oldest 25 alone hide exactly the copies. A server that
|
|
19
|
+
* does not count yet is read the old way, and the answer says the list is a part.
|
|
20
|
+
*
|
|
16
21
|
* Tickers collide on purpose: clones reuse a symbol to borrow its trust. The
|
|
17
22
|
* tool never picks one. The description below is the contract with every
|
|
18
23
|
* host, Claude Desktop chat included, which reads no skill.
|
|
@@ -26,7 +31,7 @@ var token_lookup_exports = /* @__PURE__ */ __exportAll({
|
|
|
26
31
|
const META_TOKEN_LOOKUP_TOOL = "meta_token_lookup";
|
|
27
32
|
const META_TOKEN_LOOKUP_SCHEMA = "chain-insights.meta-token-lookup.v1";
|
|
28
33
|
const META_TOKEN_LOOKUP_TITLE = "Token by ticker or name";
|
|
29
|
-
const META_TOKEN_LOOKUP_DESCRIPTION = "Call this first when a question names a token by its ticker or name and gives no contract (TCITY, USDG, SPCX). It returns
|
|
34
|
+
const META_TOKEN_LOOKUP_DESCRIPTION = "Call this first when a question names a token by its ticker or name and gives no contract (TCITY, USDG, SPCX). It returns the contracts on the network that carry that symbol, verified first, then oldest first, with the count of all of them and, when more than 25 match, the newest ones too. Tickers collide: never treat the first row as the token. When several match, name them and ask, or pick by the evidence the user gave. Zero candidates means no contract carries the symbol: say so, and do not search the web.";
|
|
30
35
|
const META_TOKEN_LOOKUP_ANNOTATIONS = {
|
|
31
36
|
readOnlyHint: true,
|
|
32
37
|
idempotentHint: true,
|
|
@@ -72,9 +77,14 @@ function textResult(structured) {
|
|
|
72
77
|
isError: false
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
/**
|
|
81
|
+
* The facts Asset read by symbol or by name. `counted` asks the server for the
|
|
82
|
+
* number of contracts that match, on every row. `newest` reads the newest 25
|
|
83
|
+
* instead of verified first, then oldest first. With neither it is the read
|
|
84
|
+
* every server admits.
|
|
85
|
+
*/
|
|
86
|
+
function assetQuery(key, value, form = "plain") {
|
|
87
|
+
return `USE facts MATCH (t:Asset {${key}: "${value}"}) RETURN t.asset_contract AS contract, t.asset_symbol AS symbol, t.name AS name, t.token_standard AS token_standard, t.decimals AS decimals, t.verified AS verified, t.verification_source AS verification_source, t.first_seen_timestamp AS first_seen_timestamp` + (form === "counted" ? ", t.match_count AS match_count" : "") + (form === "newest" ? ` ORDER BY t.first_seen_timestamp DESC LIMIT ${CANDIDATES_MAX}` : ` LIMIT ${ROWS_READ}`);
|
|
78
88
|
}
|
|
79
89
|
/** The topology read of who deployed one contract: the deploying address and the transaction's sender. */
|
|
80
90
|
function creatorQuery(contract) {
|
|
@@ -146,12 +156,12 @@ function candidateOf(row) {
|
|
|
146
156
|
factory: null
|
|
147
157
|
};
|
|
148
158
|
}
|
|
149
|
-
async function readAssets(deps, network, key, value) {
|
|
159
|
+
async function readAssets(deps, network, key, value, form) {
|
|
150
160
|
let answer;
|
|
151
161
|
try {
|
|
152
162
|
answer = await deps.graphQuery({
|
|
153
163
|
network,
|
|
154
|
-
query: assetQuery(key, value)
|
|
164
|
+
query: assetQuery(key, value, form)
|
|
155
165
|
});
|
|
156
166
|
} catch (err) {
|
|
157
167
|
return {
|
|
@@ -225,7 +235,8 @@ async function readCreators(deps, network, candidates) {
|
|
|
225
235
|
}
|
|
226
236
|
const NO_WEB = "Do not search the web and do not guess a contract: a web page is not a contract on this network.";
|
|
227
237
|
function hintFor(result, creatorsNotRead) {
|
|
228
|
-
const { network, query, candidates, matched_on, truncated } = result;
|
|
238
|
+
const { network, query, candidates, matched_on, truncated, matches, newest } = result;
|
|
239
|
+
const later = result.first_seen_after_verified;
|
|
229
240
|
const parts = [ANSWER_HINT];
|
|
230
241
|
if (candidates.length === 0) {
|
|
231
242
|
parts.push(`No contract on ${network} carries the symbol or the name "${query}". Say so in one line. ${NO_WEB} Ask the user for the contract if they have one.`);
|
|
@@ -233,7 +244,14 @@ function hintFor(result, creatorsNotRead) {
|
|
|
233
244
|
}
|
|
234
245
|
if (matched_on === "name") parts.push(`No contract carries "${query}" as its symbol; these carry it as their name.`);
|
|
235
246
|
if (candidates.length === 1) parts.push(`One contract on ${network} carries "${query}": ${candidates[0].contract}. Say it is the only one on this network, then read it by this full contract on USE topology.`);
|
|
236
|
-
else
|
|
247
|
+
else {
|
|
248
|
+
if (!truncated) parts.push(`${candidates.length} contracts on ${network} carry "${query}".`);
|
|
249
|
+
else if (matches === null) parts.push(`${candidates.length} contracts on ${network} carry "${query}", and more exist than the ${CANDIDATES_MAX} listed. The list is a part: never give its length as the count, and never say that none exist beyond it.`);
|
|
250
|
+
else parts.push(`${matches} contracts on ${network} carry "${query}". candidates lists ${candidates.length} of them, verified first, then oldest first${newest.length > 0 ? `, and newest lists the ${newest.length} newest that are not among them, newest first` : ""}. The lists are a part: the count is ${matches}, never the number of rows.`);
|
|
251
|
+
parts.push("Tickers collide: never treat the first row as the token. Name them, each contract in full, with its creator and first seen time, and ask which one the user means, or pick one by the evidence the user gave (a creator, a launch date, a price move) and say why.");
|
|
252
|
+
}
|
|
253
|
+
if (later && later.count > 0) parts.push(`${later.at_least ? "At least " : ""}${later.count} of them ${later.count === 1 ? "was" : "were"} first seen after the verified contract ${later.verified_contract}: each took a symbol that a verified token already carried. That is a copy of the name. A copied name alone is not proof of a scam.`);
|
|
254
|
+
if (later && later.at_least) parts.push(`This answer does not list every contract first seen after the verified contract ${later.verified_contract}${matches === null ? ": it lists the oldest only" : ""}. How many were made after it is not known from this answer${later.count === 0 ? ", and a list that shows none does not mean none exist" : ""}. Never answer that none, or no contract, was created after it; say the list holds the oldest contracts and the later ones are not in it.`);
|
|
237
255
|
if (creatorsNotRead) parts.push(`The creators were not read for ${creatorsNotRead}. creator and factory are empty there because the read failed, not because the chain holds none.`);
|
|
238
256
|
parts.push("Write every contract and creator in full, 0x plus 40 hex characters.");
|
|
239
257
|
return parts.join(" ");
|
|
@@ -263,17 +281,25 @@ async function handleMetaTokenLookup(args, deps) {
|
|
|
263
281
|
candidates: [],
|
|
264
282
|
total: 0,
|
|
265
283
|
truncated: false,
|
|
284
|
+
matches: null,
|
|
285
|
+
newest: [],
|
|
286
|
+
first_seen_after_verified: null,
|
|
266
287
|
hint: `${ANSWER_HINT} ${address} is a contract address, not a ticker: ${ADDRESS_INPUT_HINT}. Send no token lookup for it.`
|
|
267
288
|
});
|
|
268
289
|
}
|
|
269
290
|
if (unsafeLiteral(symbol)) return errorResult("invalid_symbol: a symbol holds no double quote, backslash or control character. Send the ticker or the name as plain text.");
|
|
270
291
|
const unavailable = await deps.unavailable?.();
|
|
271
292
|
if (unavailable) return errorResult(`No token read was sent: ${unavailable} The lookup has no answer yet, which is not "no contract": try again later, or ask the user for the contract. ${NO_WEB}`);
|
|
293
|
+
let form = "counted";
|
|
272
294
|
let matchedOn = "symbol";
|
|
273
|
-
let read = await readAssets(deps, network, "symbol", symbol);
|
|
295
|
+
let read = await readAssets(deps, network, "symbol", symbol, form);
|
|
296
|
+
if (read.kind === "not_served") {
|
|
297
|
+
form = "plain";
|
|
298
|
+
read = await readAssets(deps, network, "symbol", symbol, form);
|
|
299
|
+
}
|
|
274
300
|
if (read.kind === "rows" && read.rows.length === 0) {
|
|
275
301
|
matchedOn = "name";
|
|
276
|
-
read = await readAssets(deps, network, "name", symbol);
|
|
302
|
+
read = await readAssets(deps, network, "name", symbol, form);
|
|
277
303
|
}
|
|
278
304
|
if (read.kind === "failed") return errorResult(`The token read failed: ${read.text} This is not "no contract": send the same lookup again once, or ask the user for the contract. ${NO_WEB}`);
|
|
279
305
|
if (read.kind === "not_served") return textResult({
|
|
@@ -282,17 +308,46 @@ async function handleMetaTokenLookup(args, deps) {
|
|
|
282
308
|
candidates: [],
|
|
283
309
|
total: 0,
|
|
284
310
|
truncated: false,
|
|
311
|
+
matches: null,
|
|
312
|
+
newest: [],
|
|
313
|
+
first_seen_after_verified: null,
|
|
285
314
|
hint: `${ANSWER_HINT} This lookup gave no answer (${read.refusal.code}). That is not "no contract carries ${symbol}": ask the user for the token's contract, 0x plus 40 hex characters. ${NO_WEB}`
|
|
286
315
|
});
|
|
287
316
|
const total = read.rows.length;
|
|
317
|
+
const truncated = total > CANDIDATES_MAX;
|
|
288
318
|
const candidates = read.rows.slice(0, CANDIDATES_MAX).map(candidateOf).filter((candidate) => candidate !== null);
|
|
289
|
-
const
|
|
319
|
+
const counted = form === "counted" ? numberOrNull(read.rows[0]?.match_count) : null;
|
|
320
|
+
const matches = counted !== null && counted >= total ? counted : truncated ? null : total;
|
|
321
|
+
let newestPage = null;
|
|
322
|
+
if (truncated && form === "counted") {
|
|
323
|
+
const page = await readAssets(deps, network, matchedOn, symbol, "newest");
|
|
324
|
+
if (page.kind === "rows") newestPage = page.rows.map(candidateOf).filter((candidate) => candidate !== null);
|
|
325
|
+
}
|
|
326
|
+
const listed = new Set(candidates.map((candidate) => candidate.contract));
|
|
327
|
+
const verified = candidates.filter((candidate) => candidate.verified);
|
|
328
|
+
const anchor = verified.length === 1 && verified[0].first_seen_timestamp !== null ? verified[0] : null;
|
|
329
|
+
const after = (candidate) => anchor !== null && candidate.first_seen_timestamp !== null && candidate.first_seen_timestamp > anchor.first_seen_timestamp;
|
|
330
|
+
let firstSeenAfterVerified = null;
|
|
331
|
+
if (anchor) {
|
|
332
|
+
const pool = !truncated ? candidates : newestPage ?? candidates;
|
|
333
|
+
const reachesBack = !truncated || newestPage !== null && (newestPage.length < CANDIDATES_MAX || newestPage.some((row) => !after(row)));
|
|
334
|
+
firstSeenAfterVerified = {
|
|
335
|
+
verified_contract: anchor.contract,
|
|
336
|
+
count: pool.filter(after).length,
|
|
337
|
+
at_least: !reachesBack
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
const newest = (newestPage ?? []).filter((candidate) => !listed.has(candidate.contract));
|
|
341
|
+
const creatorsNotRead = candidates.length > 0 ? await readCreators(deps, network, [...candidates, ...newest]) : null;
|
|
290
342
|
const result = {
|
|
291
343
|
...base,
|
|
292
344
|
matched_on: candidates.length > 0 ? matchedOn : null,
|
|
293
345
|
candidates,
|
|
294
346
|
total,
|
|
295
|
-
truncated
|
|
347
|
+
truncated,
|
|
348
|
+
matches,
|
|
349
|
+
newest,
|
|
350
|
+
first_seen_after_verified: firstSeenAfterVerified
|
|
296
351
|
};
|
|
297
352
|
return textResult({
|
|
298
353
|
...result,
|
|
@@ -301,4 +356,4 @@ async function handleMetaTokenLookup(args, deps) {
|
|
|
301
356
|
}
|
|
302
357
|
export { SYMBOL_MAX as a, refusalOf as c, META_TOKEN_LOOKUP_TOOL as i, token_lookup_exports as l, META_TOKEN_LOOKUP_DESCRIPTION as n, handleMetaTokenLookup as o, META_TOKEN_LOOKUP_TITLE as r, membersOf as s, META_TOKEN_LOOKUP_ANNOTATIONS as t };
|
|
303
358
|
|
|
304
|
-
//# sourceMappingURL=token-lookup-
|
|
359
|
+
//# sourceMappingURL=token-lookup-hpmah4XX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-lookup-hpmah4XX.mjs","names":[],"sources":["../src/mcp/token-lookup.ts"],"sourcesContent":["/**\n * meta_token_lookup: a ticker or a token name becomes its contracts.\n *\n * A local tool of the proxy. It sends one anchored facts read of the Asset\n * lookup by symbol, the same read by name when the symbol answers nothing, and\n * then the creator and the factory of each candidate from topology, one batch\n * member per candidate. Nothing is matched here: the graph server matches the\n * symbol or the name, case-insensitively and exactly, and orders the rows\n * verified first, then oldest first. The proxy keeps that order.\n *\n * The read also asks the server how many contracts match. When more match than\n * the 25 listed, a second read brings the newest: a copy of a verified token is\n * made after it, so the oldest 25 alone hide exactly the copies. A server that\n * does not count yet is read the old way, and the answer says the list is a part.\n *\n * Tickers collide on purpose: clones reuse a symbol to borrow its trust. The\n * tool never picks one. The description below is the contract with every\n * host, Claude Desktop chat included, which reads no skill.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport { isEpochMs, utcText } from './timestamp-text.js'\n\nexport const META_TOKEN_LOOKUP_TOOL = 'meta_token_lookup'\nexport const META_TOKEN_LOOKUP_SCHEMA = 'chain-insights.meta-token-lookup.v1' as const\nexport const META_TOKEN_LOOKUP_TITLE = 'Token by ticker or name'\nexport const META_TOKEN_LOOKUP_DESCRIPTION =\n 'Call this first when a question names a token by its ticker or name and gives no contract ' +\n '(TCITY, USDG, SPCX). It returns the contracts on the network that carry that symbol, ' +\n 'verified first, then oldest first, with the count of all of them and, when more than 25 match, ' +\n 'the newest ones too. Tickers collide: never treat the first row as the token. ' +\n 'When several match, name them and ask, or pick by the evidence the user gave. Zero candidates ' +\n 'means no contract carries the symbol: say so, and do not search the web.'\nexport const META_TOKEN_LOOKUP_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const META_TOKEN_LOOKUP_ARGS = ['network', 'symbol'] as const\n\n/** The candidates returned. The read asks for one more, so a full page says there are more. */\nexport const CANDIDATES_MAX = 25\nexport const ROWS_READ = CANDIDATES_MAX + 1\n/** The graph server admits at most 20 members in one graph_query_batch. */\nexport const CREATOR_BATCH_MAX = 20\nexport const SYMBOL_MAX = 64\n\nexport const ADDRESS_INPUT_HINT = 'an address is already an anchor: read it on USE topology'\n\nexport interface TokenCandidate {\n contract: string\n symbol: string | null\n name: string | null\n token_standard: string | null\n decimals: number | null\n verified: boolean\n verification_source: string | null\n first_seen_timestamp: number | null\n first_seen_timestamp_utc: string | null\n creator: string | null\n factory: string | null\n}\n\nexport interface MetaTokenLookupResult {\n schema: typeof META_TOKEN_LOOKUP_SCHEMA\n network: string\n query: string\n matched_on: 'symbol' | 'name' | null\n candidates: TokenCandidate[]\n /** The rows the server sent, at most 26: 26 means there are more than the 25 returned. */\n total: number\n truncated: boolean\n /** How many contracts carry the key, counted by the server; null when the server does not count. */\n matches: number | null\n /** When more match than the candidates listed: the newest that are not among them, newest first. */\n newest: TokenCandidate[]\n /** With exactly one verified candidate: how many contracts were first seen after it. */\n first_seen_after_verified: { verified_contract: string; count: number; at_least: boolean } | null\n hint: string\n}\n\n/** One graph_query or graph_query_batch reply as the remote client returns it. */\nexport type GraphAnswer = {\n content?: unknown[]\n structuredContent?: unknown\n isError?: boolean\n}\n\nexport interface TokenToolDependencies {\n /** One graph_query through the proxy's remote client, billed as any read. */\n graphQuery: (args: { network: string; query: string }) => Promise<GraphAnswer>\n /** One graph_query_batch through the proxy's remote client, billed as any read. */\n graphQueryBatch: (args: {\n network: string\n queries: Array<{ id: string; query: string }>\n }) => Promise<GraphAnswer>\n /** The reason no read can be sent now, or undefined when the graph is reachable. */\n unavailable?: () => Promise<string | undefined> | string | undefined\n /** The text of a call that threw: payment required, transport. */\n describeFailure: (err: unknown) => string\n}\n\nexport type MetaTokenLookupToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\nconst ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/\nconst CONTRACT_FORM = /^0x[0-9a-f]{40}$/\n// A string literal of the read holds no double quote, no backslash and no\n// control character: the symbol is refused rather than escaped, so the read the\n// server receives is always the read written here.\nfunction unsafeLiteral(text: string): boolean {\n for (const char of text) {\n const code = char.codePointAt(0)!\n if (char === '\"' || char === '\\\\' || code < 0x20 || code === 0x7f) return true\n }\n return false\n}\nconst CODE_PREFIX = /^([a-z][a-z0-9_]*):\\s*/\n// Codes of a read that was stopped, not refused: the same read may answer later.\nconst TRANSIENT_CODE =\n /(timeout|memory_limit|cpu_limit|busy|_failed$|rate_limited|unavailable|too_large|node_error)/\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction errorResult(text: string): MetaTokenLookupToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: MetaTokenLookupResult): MetaTokenLookupToolResult {\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/**\n * The facts Asset read by symbol or by name. `counted` asks the server for the\n * number of contracts that match, on every row. `newest` reads the newest 25\n * instead of verified first, then oldest first. With neither it is the read\n * every server admits.\n */\nexport function assetQuery(\n key: 'symbol' | 'name',\n value: string,\n form: 'plain' | 'counted' | 'newest' = 'plain'\n): string {\n return (\n `USE facts MATCH (t:Asset {${key}: \"${value}\"}) ` +\n 'RETURN t.asset_contract AS contract, t.asset_symbol AS symbol, t.name AS name, ' +\n 't.token_standard AS token_standard, t.decimals AS decimals, t.verified AS verified, ' +\n 't.verification_source AS verification_source, t.first_seen_timestamp AS first_seen_timestamp' +\n (form === 'counted' ? ', t.match_count AS match_count' : '') +\n (form === 'newest'\n ? ` ORDER BY t.first_seen_timestamp DESC LIMIT ${CANDIDATES_MAX}`\n : ` LIMIT ${ROWS_READ}`)\n )\n}\n\n/** The topology read of who deployed one contract: the deploying address and the transaction's sender. */\nexport function creatorQuery(contract: string): string {\n return (\n `USE topology MATCH (f:Address)-[d:DEPLOYED_CONTRACT]->(t:Address {address: \"${contract}\"}) ` +\n 'RETURN f.address AS factory, d.tx_origin AS creator LIMIT 1'\n )\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value : 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_FORM.test(value.trim()) ? value.trim().toLowerCase() : null\n\nfunction verifiedOf(value: unknown): boolean {\n if (typeof value === 'boolean') return value\n if (typeof value === 'number') return value === 1\n if (typeof value === 'string') return ['true', '1'].includes(value.trim().toLowerCase())\n return false\n}\n\nfunction answerText(answer: GraphAnswer): string {\n return (Array.isArray(answer.content) ? answer.content : [])\n .map((block) => (isRecord(block) && typeof block.text === 'string' ? block.text : ''))\n .filter(Boolean)\n .join('\\n')\n .trim()\n}\n\nexport type Refusal = { code: string; text: string; transient: boolean }\n\n/** A graph_query answer that did not answer: its code, its text, and whether the same read may answer later. */\nexport function refusalOf(answer: GraphAnswer): Refusal {\n const text = answerText(answer)\n const detail = isRecord(answer.structuredContent)\n ? answer.structuredContent.error_detail\n : undefined\n const detailCode = isRecord(detail) && typeof detail.code === 'string' ? detail.code : ''\n const detailClass = isRecord(detail) && typeof detail.class === 'string' ? detail.class : ''\n const named = detailCode || CODE_PREFIX.exec(text)?.[1] || ''\n // A refusal that names no class is a stop only when its code says so; a\n // refusal in plain words (\"unknown label Asset\") is a server that lacks the read.\n const transient = detailClass ? detailClass !== 'refused' : TRANSIENT_CODE.test(named)\n const code = named || 'not_served'\n return { code, text: text || `${code}: the graph endpoint refused the read`, transient }\n}\n\n/** The result rows of a graph_query answer, or null when it holds none. */\nfunction rowsOf(answer: GraphAnswer): Array<Record<string, unknown>> | null {\n const facts = isRecord(answer.structuredContent) ? answer.structuredContent.facts : undefined\n const query = isRecord(facts) ? facts.query : undefined\n const results = isRecord(query) ? query.results : undefined\n return Array.isArray(results) ? results.filter(isRecord) : null\n}\n\nexport type Member = { id?: unknown; ok?: unknown; results?: unknown; error?: unknown }\n\n/** The members of a graph_query_batch answer by id. */\nexport function membersOf(answer: GraphAnswer): Map<string, Member> {\n const facts = isRecord(answer.structuredContent) ? answer.structuredContent.facts : undefined\n const queries = isRecord(facts) ? facts.queries : undefined\n const members = new Map<string, Member>()\n if (Array.isArray(queries)) {\n for (const member of queries)\n if (isRecord(member) && typeof member.id === 'string') members.set(member.id, member)\n }\n return members\n}\n\nfunction candidateOf(row: Record<string, unknown>): TokenCandidate | null {\n const contract = textOrNull(row.contract)?.trim().toLowerCase()\n if (!contract) return null\n const firstSeen = numberOrNull(row.first_seen_timestamp)\n return {\n contract,\n symbol: textOrNull(row.symbol),\n name: textOrNull(row.name),\n token_standard: textOrNull(row.token_standard),\n decimals: numberOrNull(row.decimals),\n verified: verifiedOf(row.verified),\n verification_source: textOrNull(row.verification_source),\n first_seen_timestamp: firstSeen,\n first_seen_timestamp_utc: isEpochMs(firstSeen) ? utcText(firstSeen) : null,\n creator: null,\n factory: null,\n }\n}\n\ntype Read =\n | { kind: 'rows'; rows: Array<Record<string, unknown>> }\n | { kind: 'not_served'; refusal: Refusal }\n | { kind: 'failed'; text: string }\n\nasync function readAssets(\n deps: TokenToolDependencies,\n network: string,\n key: 'symbol' | 'name',\n value: string,\n form: 'plain' | 'counted' | 'newest'\n): Promise<Read> {\n let answer: GraphAnswer\n try {\n answer = await deps.graphQuery({ network, query: assetQuery(key, value, form) })\n } catch (err) {\n return { kind: 'failed', text: deps.describeFailure(err) }\n }\n const rows = rowsOf(answer)\n if (answer.isError !== true && rows !== null) return { kind: 'rows', rows }\n const refusal = refusalOf(answer)\n if (answer.isError === true && refusal.transient) return { kind: 'failed', text: refusal.text }\n return { kind: 'not_served', refusal }\n}\n\n/**\n * The creator and the factory of each candidate, written in place. Returns why\n * some creators were not read, or null when every read answered. A read that\n * answered with no row leaves the candidate's creator empty with no note: the\n * graph holds no deployment for it.\n */\nasync function readCreators(\n deps: TokenToolDependencies,\n network: string,\n candidates: TokenCandidate[]\n): Promise<string | null> {\n const contracts = [\n ...new Set(candidates.map((c) => c.contract).filter((c) => CONTRACT_FORM.test(c))),\n ]\n const found = new Map<string, { creator: string | null; factory: string | null }>()\n const reasons: string[] = []\n let unread = candidates.length - candidates.filter((c) => CONTRACT_FORM.test(c.contract)).length\n for (let at = 0; at < contracts.length; at += CREATOR_BATCH_MAX) {\n const chunk = contracts.slice(at, at + CREATOR_BATCH_MAX)\n const queries = chunk.map((contract) => ({\n id: `creator:${contract}`,\n query: creatorQuery(contract),\n }))\n let members = new Map<string, Member>()\n try {\n const answer = await deps.graphQueryBatch({ network, queries })\n members = membersOf(answer)\n if (members.size === 0) {\n reasons.push(\n answer.isError === true ? refusalOf(answer).text : 'the batch answer held no reads'\n )\n }\n } catch (err) {\n reasons.push(deps.describeFailure(err))\n }\n for (const contract of chunk) {\n const member = members.get(`creator:${contract}`)\n if (member?.ok === true && Array.isArray(member.results)) {\n const row = member.results.find(isRecord)\n found.set(contract, {\n creator: row ? addressOrNull(row.creator) : null,\n factory: row ? addressOrNull(row.factory) : null,\n })\n continue\n }\n unread += 1\n if (member && typeof member.error === 'string' && !reasons.includes(member.error))\n reasons.push(member.error)\n }\n }\n for (const candidate of candidates) {\n const read = found.get(candidate.contract)\n if (read) Object.assign(candidate, read)\n }\n if (unread === 0) return null\n return `${unread} of ${candidates.length}${reasons.length > 0 ? `: ${reasons.join('; ')}` : ''}`\n}\n\nconst NO_WEB =\n 'Do not search the web and do not guess a contract: a web page is not a contract on this network.'\n\nfunction hintFor(\n result: Omit<MetaTokenLookupResult, 'hint'>,\n creatorsNotRead: string | null\n): string {\n const { network, query, candidates, matched_on, truncated, matches, newest } = result\n const later = result.first_seen_after_verified\n const parts: string[] = [ANSWER_HINT]\n if (candidates.length === 0) {\n parts.push(\n `No contract on ${network} carries the symbol or the name \"${query}\". Say so in one line. ${NO_WEB} ` +\n 'Ask the user for the contract if they have one.'\n )\n return parts.join(' ')\n }\n if (matched_on === 'name') {\n parts.push(`No contract carries \"${query}\" as its symbol; these carry it as their name.`)\n }\n if (candidates.length === 1) {\n parts.push(\n `One contract on ${network} carries \"${query}\": ${candidates[0]!.contract}. ` +\n 'Say it is the only one on this network, then read it by this full contract on USE topology.'\n )\n } else {\n if (!truncated) {\n parts.push(`${candidates.length} contracts on ${network} carry \"${query}\".`)\n } else if (matches === null) {\n parts.push(\n `${candidates.length} contracts on ${network} carry \"${query}\", and more exist than the ${CANDIDATES_MAX} listed. ` +\n 'The list is a part: never give its length as the count, and never say that none exist beyond it.'\n )\n } else {\n parts.push(\n `${matches} contracts on ${network} carry \"${query}\". candidates lists ${candidates.length} of them, verified first, then oldest first` +\n `${newest.length > 0 ? `, and newest lists the ${newest.length} newest that are not among them, newest first` : ''}. ` +\n `The lists are a part: the count is ${matches}, never the number of rows.`\n )\n }\n parts.push(\n 'Tickers collide: never treat the first row as the token. Name them, each contract in full, ' +\n 'with its creator and first seen time, and ask which one the user means, or pick one by the evidence the user gave ' +\n '(a creator, a launch date, a price move) and say why.'\n )\n }\n if (later && later.count > 0) {\n parts.push(\n `${later.at_least ? 'At least ' : ''}${later.count} of them ${later.count === 1 ? 'was' : 'were'} first seen after the verified contract ${later.verified_contract}: ` +\n 'each took a symbol that a verified token already carried. That is a copy of the name. A copied name alone is not proof of a scam.'\n )\n }\n if (later && later.at_least) {\n parts.push(\n `This answer does not list every contract first seen after the verified contract ${later.verified_contract}` +\n `${matches === null ? ': it lists the oldest only' : ''}. How many were made after it is not known from this answer` +\n `${later.count === 0 ? ', and a list that shows none does not mean none exist' : ''}. ` +\n 'Never answer that none, or no contract, was created after it; say the list holds the oldest contracts and the later ones are not in it.'\n )\n }\n if (creatorsNotRead) {\n parts.push(\n `The creators were not read for ${creatorsNotRead}. creator and factory are empty there because the read failed, ` +\n 'not because the chain holds none.'\n )\n }\n parts.push('Write every contract and creator in full, 0x plus 40 hex characters.')\n return parts.join(' ')\n}\n\n/** meta_token_lookup, {network, symbol}. Every argument is checked before a read is sent. */\nexport async function handleMetaTokenLookup(\n args: unknown,\n deps: TokenToolDependencies\n): Promise<MetaTokenLookupToolResult> {\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 if (typeof record.symbol !== 'string' || record.symbol.trim() === '') {\n return errorResult(\n 'invalid_symbol: symbol is required: the ticker or the name as the user wrote it, for example TCITY'\n )\n }\n const symbol = record.symbol.trim()\n if (symbol.length > SYMBOL_MAX) {\n return errorResult(`invalid_symbol: symbol holds at most ${SYMBOL_MAX} characters`)\n }\n const base = {\n schema: META_TOKEN_LOOKUP_SCHEMA,\n network,\n query: symbol,\n }\n\n if (ADDRESS_FORM.test(symbol)) {\n const address = symbol.toLowerCase()\n return textResult({\n ...base,\n matched_on: null,\n candidates: [],\n total: 0,\n truncated: false,\n matches: null,\n newest: [],\n first_seen_after_verified: null,\n hint: `${ANSWER_HINT} ${address} is a contract address, not a ticker: ${ADDRESS_INPUT_HINT}. Send no token lookup for it.`,\n })\n }\n if (unsafeLiteral(symbol)) {\n return errorResult(\n 'invalid_symbol: a symbol holds no double quote, backslash or control character. Send the ticker or the name as plain text.'\n )\n }\n\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n return errorResult(\n `No token read was sent: ${unavailable} The lookup has no answer yet, which is not \"no contract\": try again later, or ask the user for the contract. ${NO_WEB}`\n )\n }\n\n // A server that does not count refuses the counted read; the plain read is\n // the one every server admits.\n let form: 'counted' | 'plain' = 'counted'\n let matchedOn: 'symbol' | 'name' = 'symbol'\n let read = await readAssets(deps, network, 'symbol', symbol, form)\n if (read.kind === 'not_served') {\n form = 'plain'\n read = await readAssets(deps, network, 'symbol', symbol, form)\n }\n if (read.kind === 'rows' && read.rows.length === 0) {\n matchedOn = 'name'\n read = await readAssets(deps, network, 'name', symbol, form)\n }\n if (read.kind === 'failed') {\n return errorResult(\n `The token read failed: ${read.text} This is not \"no contract\": send the same lookup again once, or ask the user for the contract. ${NO_WEB}`\n )\n }\n if (read.kind === 'not_served') {\n return textResult({\n ...base,\n matched_on: null,\n candidates: [],\n total: 0,\n truncated: false,\n matches: null,\n newest: [],\n first_seen_after_verified: null,\n hint:\n `${ANSWER_HINT} This lookup gave no answer (${read.refusal.code}). ` +\n `That is not \"no contract carries ${symbol}\": ask the user for the token's contract, 0x plus 40 hex characters. ${NO_WEB}`,\n })\n }\n\n const total = read.rows.length\n const truncated = total > CANDIDATES_MAX\n const candidates = read.rows\n .slice(0, CANDIDATES_MAX)\n .map(candidateOf)\n .filter((candidate): candidate is TokenCandidate => candidate !== null)\n const counted = form === 'counted' ? numberOrNull(read.rows[0]?.match_count) : null\n const matches = counted !== null && counted >= total ? counted : truncated ? null : total\n\n // More match than are listed: the newest page. A failed or refused page\n // leaves the answer as the oldest list, which the hint calls a part.\n let newestPage: TokenCandidate[] | null = null\n if (truncated && form === 'counted') {\n const page = await readAssets(deps, network, matchedOn, symbol, 'newest')\n if (page.kind === 'rows') {\n newestPage = page.rows\n .map(candidateOf)\n .filter((candidate): candidate is TokenCandidate => candidate !== null)\n }\n }\n const listed = new Set(candidates.map((candidate) => candidate.contract))\n const verified = candidates.filter((candidate) => candidate.verified)\n const anchor =\n verified.length === 1 && verified[0]!.first_seen_timestamp !== null ? verified[0]! : null\n const after = (candidate: TokenCandidate): boolean =>\n anchor !== null &&\n candidate.first_seen_timestamp !== null &&\n candidate.first_seen_timestamp > anchor.first_seen_timestamp!\n let firstSeenAfterVerified: MetaTokenLookupResult['first_seen_after_verified'] = null\n if (anchor) {\n // Every later contract is known when the lists reach back to the verified\n // one: nothing was cut, or the newest page holds a row that is not later.\n const pool = !truncated ? candidates : (newestPage ?? candidates)\n const reachesBack =\n !truncated ||\n (newestPage !== null &&\n (newestPage.length < CANDIDATES_MAX || newestPage.some((row) => !after(row))))\n firstSeenAfterVerified = {\n verified_contract: anchor.contract,\n count: pool.filter(after).length,\n at_least: !reachesBack,\n }\n }\n const newest = (newestPage ?? []).filter((candidate) => !listed.has(candidate.contract))\n\n const creatorsNotRead =\n candidates.length > 0 ? await readCreators(deps, network, [...candidates, ...newest]) : null\n const result = {\n ...base,\n matched_on: candidates.length > 0 ? matchedOn : null,\n candidates,\n total,\n truncated,\n matches,\n newest,\n first_seen_after_verified: firstSeenAfterVerified,\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EACA,2BAA2B;CAC7B;CACA,OAAO,WAAW;EAAE,GAAG;EAAQ,MAAM,QAAQ,QAAQ,eAAe;CAAE,CAAC;AACzE"}
|
package/docs/mcp-proxy.md
CHANGED
|
@@ -77,23 +77,23 @@ The proxy:
|
|
|
77
77
|
|
|
78
78
|
## Local Tools
|
|
79
79
|
|
|
80
|
-
| Tool
|
|
81
|
-
|
|
|
82
|
-
| `meta_network_capabilities`
|
|
83
|
-
| `meta_schema`
|
|
84
|
-
| `meta_dex_lookup`
|
|
85
|
-
| `meta_token_lookup`
|
|
86
|
-
| `aml_deployer_screen`
|
|
87
|
-
| `meta_exchange_lookup`
|
|
88
|
-
| `aml_exchange_deposit_check
|
|
89
|
-
| `meta_rules`
|
|
90
|
-
| `meta_help`
|
|
91
|
-
| `meta_usage_status`
|
|
92
|
-
| `meta_subscription_status`
|
|
93
|
-
| `wallet_balance`
|
|
94
|
-
| `wallet_topup`
|
|
95
|
-
| `subscription_topup`
|
|
96
|
-
| `graph_expand`
|
|
80
|
+
| Tool | Purpose |
|
|
81
|
+
| ---------------------------- | ------------------------------------------------------------------------------------ |
|
|
82
|
+
| `meta_network_capabilities` | Show the current Chain Insights network/tool support matrix |
|
|
83
|
+
| `meta_schema` | Show the live graph schema of a network: labels, link types, fields, indexes |
|
|
84
|
+
| `meta_dex_lookup` | Turn an exchange name into its factories, routers or manager, pools and first reads |
|
|
85
|
+
| `meta_token_lookup` | Turn a ticker or a token name into every contract that carries it, with its creator |
|
|
86
|
+
| `aml_deployer_screen` | Screen who is behind a token or a wallet: launcher, first funder, labels, facts only |
|
|
87
|
+
| `meta_exchange_lookup` | Turn a centralized exchange name, or one of its wallets, into its listed wallets |
|
|
88
|
+
| `aml_exchange_deposit_check` | Check one address: an exchange deposit, of which exchange, swept into which wallet |
|
|
89
|
+
| `meta_rules` | Read the answer rules when the `chain-insights-cypher` skill is not loaded |
|
|
90
|
+
| `meta_help` | Show Chain Insights tool and workflow guidance |
|
|
91
|
+
| `meta_usage_status` | Check the caller's daily free-tier graph query allowance |
|
|
92
|
+
| `meta_subscription_status` | Check the proven wallet's subscription, today's allowance and pending payments |
|
|
93
|
+
| `wallet_balance` | Show the local payment wallet address, payment network, token, and amount |
|
|
94
|
+
| `wallet_topup` | Show the local payment wallet address and its QR code, with a Claude view |
|
|
95
|
+
| `subscription_topup` | Show the same wallet and its QR code for $CIA and ETH on Robinhood Chain, read-only |
|
|
96
|
+
| `graph_expand` | Expand a node or list a link's transfers in an open picture; called by the view only |
|
|
97
97
|
|
|
98
98
|
`meta_schema` reads the live graph schema of one network: the labels, the link
|
|
99
99
|
types, every property key, the indexes, the fields of an address and of each
|
|
@@ -144,7 +144,16 @@ never picks one.
|
|
|
144
144
|
1. One `graph_query` reads the `Asset` lookup on `USE facts` by symbol. When
|
|
145
145
|
no contract carries the symbol, the same read runs by name. The server
|
|
146
146
|
matches exactly, in any case, and orders the rows verified first, then
|
|
147
|
-
oldest first. The proxy keeps that order.
|
|
147
|
+
oldest first. The proxy keeps that order. The read also asks for
|
|
148
|
+
`match_count`, the number of contracts that carry the key, and the answer
|
|
149
|
+
gives it as `matches`.
|
|
150
|
+
When more match than the 25 listed, one more `graph_query` reads the 25
|
|
151
|
+
newest (`ORDER BY t.first_seen_timestamp DESC`), and the answer lists the
|
|
152
|
+
ones not among the candidates as `newest`. With exactly one verified
|
|
153
|
+
candidate, `first_seen_after_verified` says how many contracts were first
|
|
154
|
+
seen after it: a copy of a verified token is made after it, so the oldest
|
|
155
|
+
25 alone hide the copies. A server that does not count yet is read the
|
|
156
|
+
old way; `matches` is then null and the hint calls the list a part.
|
|
148
157
|
2. One `graph_query_batch` reads, for each candidate, the address that
|
|
149
158
|
deployed it (`factory`) and the sender of that transaction (`creator`) on
|
|
150
159
|
`USE topology`. A batch holds at most 20 reads, so 25 candidates take two.
|
|
@@ -300,16 +309,16 @@ the same check in a terminal.
|
|
|
300
309
|
**A rule a host never loads does not exist for that host.** Each host loads a
|
|
301
310
|
different part of what this package ships:
|
|
302
311
|
|
|
303
|
-
| What a host loads
|
|
304
|
-
|
|
305
|
-
| skill files (`cia setup`)
|
|
306
|
-
| server instructions
|
|
307
|
-
| `meta_rules`
|
|
308
|
-
| tool descriptions
|
|
309
|
-
| result `hint`
|
|
310
|
-
| protocol tool doors
|
|
311
|
-
| token door `meta_token_lookup`
|
|
312
|
-
| exchange doors `meta_exchange_lookup`, `aml_exchange_deposit_check` | yes
|
|
312
|
+
| What a host loads | Claude Code | Desktop Code mode | Codex | Hermes | scout agent | Desktop chat / claude.ai |
|
|
313
|
+
| ------------------------------------------------------------------- | ----------- | ----------------- | ----- | ------ | -------------- | ------------------------ |
|
|
314
|
+
| skill files (`cia setup`) | yes | yes | yes | yes | copied, 2 of 6 | no |
|
|
315
|
+
| server instructions | yes | yes | yes | yes | yes | no (ignored) |
|
|
316
|
+
| `meta_rules` | yes | yes | yes | yes | yes | no (never called) |
|
|
317
|
+
| tool descriptions | yes | yes | yes | yes | yes | yes |
|
|
318
|
+
| result `hint` | yes | yes | yes | yes | yes | yes |
|
|
319
|
+
| protocol tool doors | yes | yes | yes | yes | yes | yes |
|
|
320
|
+
| token door `meta_token_lookup` | yes | yes | yes | yes | yes | yes |
|
|
321
|
+
| exchange doors `meta_exchange_lookup`, `aml_exchange_deposit_check` | yes | yes | yes | yes | yes | yes |
|
|
313
322
|
|
|
314
323
|
The scout agent pins the CLI by version in its image and copies only
|
|
315
324
|
`chain-insights-cypher` and `chain-insights-virtuals` into its project, yet asks
|
package/package.json
CHANGED
|
@@ -565,7 +565,7 @@ A `TRANSFERRED` search over the whole chain, with no address anchor, must name o
|
|
|
565
565
|
|
|
566
566
|
An `asset` that names no token of the graph, or a symbol such as `USDC`, is refused with `anchor_missing` whose fix names the contract: the graph holds no token at that address. That refusal is not a family behind and not a missing anchor: do not ask for an address. Check the contract, all 42 characters in lowercase, and send the same query again with the right one.
|
|
567
567
|
|
|
568
|
-
A token named by its ticker or its name, with no contract (TCITY, USDG): call `meta_token_lookup {network, symbol}` first, before any read. It returns
|
|
568
|
+
A token named by its ticker or its name, with no contract (TCITY, USDG): call `meta_token_lookup {network, symbol}` first, before any read. It returns the contracts on the network that carry that symbol, verified first, then oldest first, each with its creator, and `matches`, the count of all of them. When more match than the 25 listed, `newest` holds the newest ones, and `first_seen_after_verified` counts the contracts first seen after the one verified contract: each of those copied its symbol. A copied name alone is not proof of a scam. The lists are a part: give `matches` as the count, never the number of rows, and never say none exist beyond a list. Tickers collide: a clone copies a symbol on purpose, so never treat the first row as the token. When several come back, name each contract in full with its creator and first seen time, and ask which one the user means, or pick one by the evidence the user gave and say why. Zero candidates is an answer: say no contract on the network carries the symbol, and do not search the web. Then read the chosen contract as the `asset` of the reads above.
|
|
569
569
|
|
|
570
570
|
How to answer from these rows:
|
|
571
571
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-lookup-QpIv77P2.mjs","names":[],"sources":["../src/mcp/token-lookup.ts"],"sourcesContent":["/**\n * meta_token_lookup: a ticker or a token name becomes its contracts.\n *\n * A local tool of the proxy. It sends one anchored facts read of the Asset\n * lookup by symbol, the same read by name when the symbol answers nothing, and\n * then the creator and the factory of each candidate from topology, one batch\n * member per candidate. Nothing is matched here: the graph server matches the\n * symbol or the name, case-insensitively and exactly, and orders the rows\n * verified first, then oldest first. The proxy keeps that order.\n *\n * Tickers collide on purpose: clones reuse a symbol to borrow its trust. The\n * tool never picks one. The description below is the contract with every\n * host, Claude Desktop chat included, which reads no skill.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport { isEpochMs, utcText } from './timestamp-text.js'\n\nexport const META_TOKEN_LOOKUP_TOOL = 'meta_token_lookup'\nexport const META_TOKEN_LOOKUP_SCHEMA = 'chain-insights.meta-token-lookup.v1' as const\nexport const META_TOKEN_LOOKUP_TITLE = 'Token by ticker or name'\nexport const META_TOKEN_LOOKUP_DESCRIPTION =\n 'Call this first when a question names a token by its ticker or name and gives no contract ' +\n '(TCITY, USDG, SPCX). It returns every contract on the network that carries that symbol, ' +\n 'verified first, then oldest first. Tickers collide: never treat the first row as the token. ' +\n 'When several match, name them and ask, or pick by the evidence the user gave. Zero candidates ' +\n 'means no contract carries the symbol: say so, and do not search the web.'\nexport const META_TOKEN_LOOKUP_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const META_TOKEN_LOOKUP_ARGS = ['network', 'symbol'] as const\n\n/** The candidates returned. The read asks for one more, so a full page says there are more. */\nexport const CANDIDATES_MAX = 25\nexport const ROWS_READ = CANDIDATES_MAX + 1\n/** The graph server admits at most 20 members in one graph_query_batch. */\nexport const CREATOR_BATCH_MAX = 20\nexport const SYMBOL_MAX = 64\n\nexport const ADDRESS_INPUT_HINT = 'an address is already an anchor: read it on USE topology'\n\nexport interface TokenCandidate {\n contract: string\n symbol: string | null\n name: string | null\n token_standard: string | null\n decimals: number | null\n verified: boolean\n verification_source: string | null\n first_seen_timestamp: number | null\n first_seen_timestamp_utc: string | null\n creator: string | null\n factory: string | null\n}\n\nexport interface MetaTokenLookupResult {\n schema: typeof META_TOKEN_LOOKUP_SCHEMA\n network: string\n query: string\n matched_on: 'symbol' | 'name' | null\n candidates: TokenCandidate[]\n /** The rows the server sent, at most 26: 26 means there are more than the 25 returned. */\n total: number\n truncated: boolean\n hint: string\n}\n\n/** One graph_query or graph_query_batch reply as the remote client returns it. */\nexport type GraphAnswer = {\n content?: unknown[]\n structuredContent?: unknown\n isError?: boolean\n}\n\nexport interface TokenToolDependencies {\n /** One graph_query through the proxy's remote client, billed as any read. */\n graphQuery: (args: { network: string; query: string }) => Promise<GraphAnswer>\n /** One graph_query_batch through the proxy's remote client, billed as any read. */\n graphQueryBatch: (args: {\n network: string\n queries: Array<{ id: string; query: string }>\n }) => Promise<GraphAnswer>\n /** The reason no read can be sent now, or undefined when the graph is reachable. */\n unavailable?: () => Promise<string | undefined> | string | undefined\n /** The text of a call that threw: payment required, transport. */\n describeFailure: (err: unknown) => string\n}\n\nexport type MetaTokenLookupToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\nconst ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/\nconst CONTRACT_FORM = /^0x[0-9a-f]{40}$/\n// A string literal of the read holds no double quote, no backslash and no\n// control character: the symbol is refused rather than escaped, so the read the\n// server receives is always the read written here.\nfunction unsafeLiteral(text: string): boolean {\n for (const char of text) {\n const code = char.codePointAt(0)!\n if (char === '\"' || char === '\\\\' || code < 0x20 || code === 0x7f) return true\n }\n return false\n}\nconst CODE_PREFIX = /^([a-z][a-z0-9_]*):\\s*/\n// Codes of a read that was stopped, not refused: the same read may answer later.\nconst TRANSIENT_CODE =\n /(timeout|memory_limit|cpu_limit|busy|_failed$|rate_limited|unavailable|too_large|node_error)/\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction errorResult(text: string): MetaTokenLookupToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: MetaTokenLookupResult): MetaTokenLookupToolResult {\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/** The facts Asset read by symbol or by name, in the one shape the graph server admits. */\nexport function assetQuery(key: 'symbol' | 'name', value: string): string {\n return (\n `USE facts MATCH (t:Asset {${key}: \"${value}\"}) ` +\n 'RETURN t.asset_contract AS contract, t.asset_symbol AS symbol, t.name AS name, ' +\n 't.token_standard AS token_standard, t.decimals AS decimals, t.verified AS verified, ' +\n 't.verification_source AS verification_source, t.first_seen_timestamp AS first_seen_timestamp ' +\n `LIMIT ${ROWS_READ}`\n )\n}\n\n/** The topology read of who deployed one contract: the deploying address and the transaction's sender. */\nexport function creatorQuery(contract: string): string {\n return (\n `USE topology MATCH (f:Address)-[d:DEPLOYED_CONTRACT]->(t:Address {address: \"${contract}\"}) ` +\n 'RETURN f.address AS factory, d.tx_origin AS creator LIMIT 1'\n )\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value : 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_FORM.test(value.trim()) ? value.trim().toLowerCase() : null\n\nfunction verifiedOf(value: unknown): boolean {\n if (typeof value === 'boolean') return value\n if (typeof value === 'number') return value === 1\n if (typeof value === 'string') return ['true', '1'].includes(value.trim().toLowerCase())\n return false\n}\n\nfunction answerText(answer: GraphAnswer): string {\n return (Array.isArray(answer.content) ? answer.content : [])\n .map((block) => (isRecord(block) && typeof block.text === 'string' ? block.text : ''))\n .filter(Boolean)\n .join('\\n')\n .trim()\n}\n\nexport type Refusal = { code: string; text: string; transient: boolean }\n\n/** A graph_query answer that did not answer: its code, its text, and whether the same read may answer later. */\nexport function refusalOf(answer: GraphAnswer): Refusal {\n const text = answerText(answer)\n const detail = isRecord(answer.structuredContent)\n ? answer.structuredContent.error_detail\n : undefined\n const detailCode = isRecord(detail) && typeof detail.code === 'string' ? detail.code : ''\n const detailClass = isRecord(detail) && typeof detail.class === 'string' ? detail.class : ''\n const named = detailCode || CODE_PREFIX.exec(text)?.[1] || ''\n // A refusal that names no class is a stop only when its code says so; a\n // refusal in plain words (\"unknown label Asset\") is a server that lacks the read.\n const transient = detailClass ? detailClass !== 'refused' : TRANSIENT_CODE.test(named)\n const code = named || 'not_served'\n return { code, text: text || `${code}: the graph endpoint refused the read`, transient }\n}\n\n/** The result rows of a graph_query answer, or null when it holds none. */\nfunction rowsOf(answer: GraphAnswer): Array<Record<string, unknown>> | null {\n const facts = isRecord(answer.structuredContent) ? answer.structuredContent.facts : undefined\n const query = isRecord(facts) ? facts.query : undefined\n const results = isRecord(query) ? query.results : undefined\n return Array.isArray(results) ? results.filter(isRecord) : null\n}\n\nexport type Member = { id?: unknown; ok?: unknown; results?: unknown; error?: unknown }\n\n/** The members of a graph_query_batch answer by id. */\nexport function membersOf(answer: GraphAnswer): Map<string, Member> {\n const facts = isRecord(answer.structuredContent) ? answer.structuredContent.facts : undefined\n const queries = isRecord(facts) ? facts.queries : undefined\n const members = new Map<string, Member>()\n if (Array.isArray(queries)) {\n for (const member of queries)\n if (isRecord(member) && typeof member.id === 'string') members.set(member.id, member)\n }\n return members\n}\n\nfunction candidateOf(row: Record<string, unknown>): TokenCandidate | null {\n const contract = textOrNull(row.contract)?.trim().toLowerCase()\n if (!contract) return null\n const firstSeen = numberOrNull(row.first_seen_timestamp)\n return {\n contract,\n symbol: textOrNull(row.symbol),\n name: textOrNull(row.name),\n token_standard: textOrNull(row.token_standard),\n decimals: numberOrNull(row.decimals),\n verified: verifiedOf(row.verified),\n verification_source: textOrNull(row.verification_source),\n first_seen_timestamp: firstSeen,\n first_seen_timestamp_utc: isEpochMs(firstSeen) ? utcText(firstSeen) : null,\n creator: null,\n factory: null,\n }\n}\n\ntype Read =\n | { kind: 'rows'; rows: Array<Record<string, unknown>> }\n | { kind: 'not_served'; refusal: Refusal }\n | { kind: 'failed'; text: string }\n\nasync function readAssets(\n deps: TokenToolDependencies,\n network: string,\n key: 'symbol' | 'name',\n value: string\n): Promise<Read> {\n let answer: GraphAnswer\n try {\n answer = await deps.graphQuery({ network, query: assetQuery(key, value) })\n } catch (err) {\n return { kind: 'failed', text: deps.describeFailure(err) }\n }\n const rows = rowsOf(answer)\n if (answer.isError !== true && rows !== null) return { kind: 'rows', rows }\n const refusal = refusalOf(answer)\n if (answer.isError === true && refusal.transient) return { kind: 'failed', text: refusal.text }\n return { kind: 'not_served', refusal }\n}\n\n/**\n * The creator and the factory of each candidate, written in place. Returns why\n * some creators were not read, or null when every read answered. A read that\n * answered with no row leaves the candidate's creator empty with no note: the\n * graph holds no deployment for it.\n */\nasync function readCreators(\n deps: TokenToolDependencies,\n network: string,\n candidates: TokenCandidate[]\n): Promise<string | null> {\n const contracts = [\n ...new Set(candidates.map((c) => c.contract).filter((c) => CONTRACT_FORM.test(c))),\n ]\n const found = new Map<string, { creator: string | null; factory: string | null }>()\n const reasons: string[] = []\n let unread = candidates.length - candidates.filter((c) => CONTRACT_FORM.test(c.contract)).length\n for (let at = 0; at < contracts.length; at += CREATOR_BATCH_MAX) {\n const chunk = contracts.slice(at, at + CREATOR_BATCH_MAX)\n const queries = chunk.map((contract) => ({\n id: `creator:${contract}`,\n query: creatorQuery(contract),\n }))\n let members = new Map<string, Member>()\n try {\n const answer = await deps.graphQueryBatch({ network, queries })\n members = membersOf(answer)\n if (members.size === 0) {\n reasons.push(\n answer.isError === true ? refusalOf(answer).text : 'the batch answer held no reads'\n )\n }\n } catch (err) {\n reasons.push(deps.describeFailure(err))\n }\n for (const contract of chunk) {\n const member = members.get(`creator:${contract}`)\n if (member?.ok === true && Array.isArray(member.results)) {\n const row = member.results.find(isRecord)\n found.set(contract, {\n creator: row ? addressOrNull(row.creator) : null,\n factory: row ? addressOrNull(row.factory) : null,\n })\n continue\n }\n unread += 1\n if (member && typeof member.error === 'string' && !reasons.includes(member.error))\n reasons.push(member.error)\n }\n }\n for (const candidate of candidates) {\n const read = found.get(candidate.contract)\n if (read) Object.assign(candidate, read)\n }\n if (unread === 0) return null\n return `${unread} of ${candidates.length}${reasons.length > 0 ? `: ${reasons.join('; ')}` : ''}`\n}\n\nconst NO_WEB =\n 'Do not search the web and do not guess a contract: a web page is not a contract on this network.'\n\nfunction hintFor(\n result: Omit<MetaTokenLookupResult, 'hint'>,\n creatorsNotRead: string | null\n): string {\n const { network, query, candidates, matched_on, truncated } = result\n const parts: string[] = [ANSWER_HINT]\n if (candidates.length === 0) {\n parts.push(\n `No contract on ${network} carries the symbol or the name \"${query}\". Say so in one line. ${NO_WEB} ` +\n 'Ask the user for the contract if they have one.'\n )\n return parts.join(' ')\n }\n if (matched_on === 'name') {\n parts.push(`No contract carries \"${query}\" as its symbol; these carry it as their name.`)\n }\n if (candidates.length === 1) {\n parts.push(\n `One contract on ${network} carries \"${query}\": ${candidates[0]!.contract}. ` +\n 'Say it is the only one on this network, then read it by this full contract on USE topology.'\n )\n } else {\n parts.push(\n `${candidates.length} contracts on ${network} carry \"${query}\"` +\n `${truncated ? `, and more exist than the ${CANDIDATES_MAX} listed` : ''}. ` +\n 'Tickers collide: never treat the first row as the token. Name them, each contract in full, ' +\n 'with its creator and first seen time, and ask which one the user means, or pick one by the evidence the user gave ' +\n '(a creator, a launch date, a price move) and say why.'\n )\n }\n if (creatorsNotRead) {\n parts.push(\n `The creators were not read for ${creatorsNotRead}. creator and factory are empty there because the read failed, ` +\n 'not because the chain holds none.'\n )\n }\n parts.push('Write every contract and creator in full, 0x plus 40 hex characters.')\n return parts.join(' ')\n}\n\n/** meta_token_lookup, {network, symbol}. Every argument is checked before a read is sent. */\nexport async function handleMetaTokenLookup(\n args: unknown,\n deps: TokenToolDependencies\n): Promise<MetaTokenLookupToolResult> {\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 if (typeof record.symbol !== 'string' || record.symbol.trim() === '') {\n return errorResult(\n 'invalid_symbol: symbol is required: the ticker or the name as the user wrote it, for example TCITY'\n )\n }\n const symbol = record.symbol.trim()\n if (symbol.length > SYMBOL_MAX) {\n return errorResult(`invalid_symbol: symbol holds at most ${SYMBOL_MAX} characters`)\n }\n const base = {\n schema: META_TOKEN_LOOKUP_SCHEMA,\n network,\n query: symbol,\n }\n\n if (ADDRESS_FORM.test(symbol)) {\n const address = symbol.toLowerCase()\n return textResult({\n ...base,\n matched_on: null,\n candidates: [],\n total: 0,\n truncated: false,\n hint: `${ANSWER_HINT} ${address} is a contract address, not a ticker: ${ADDRESS_INPUT_HINT}. Send no token lookup for it.`,\n })\n }\n if (unsafeLiteral(symbol)) {\n return errorResult(\n 'invalid_symbol: a symbol holds no double quote, backslash or control character. Send the ticker or the name as plain text.'\n )\n }\n\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n return errorResult(\n `No token read was sent: ${unavailable} The lookup has no answer yet, which is not \"no contract\": try again later, or ask the user for the contract. ${NO_WEB}`\n )\n }\n\n let matchedOn: 'symbol' | 'name' = 'symbol'\n let read = await readAssets(deps, network, 'symbol', symbol)\n if (read.kind === 'rows' && read.rows.length === 0) {\n matchedOn = 'name'\n read = await readAssets(deps, network, 'name', symbol)\n }\n if (read.kind === 'failed') {\n return errorResult(\n `The token read failed: ${read.text} This is not \"no contract\": send the same lookup again once, or ask the user for the contract. ${NO_WEB}`\n )\n }\n if (read.kind === 'not_served') {\n return textResult({\n ...base,\n matched_on: null,\n candidates: [],\n total: 0,\n truncated: false,\n hint:\n `${ANSWER_HINT} This lookup gave no answer (${read.refusal.code}). ` +\n `That is not \"no contract carries ${symbol}\": ask the user for the token's contract, 0x plus 40 hex characters. ${NO_WEB}`,\n })\n }\n\n const total = read.rows.length\n const candidates = read.rows\n .slice(0, CANDIDATES_MAX)\n .map(candidateOf)\n .filter((candidate): candidate is TokenCandidate => candidate !== null)\n const creatorsNotRead =\n candidates.length > 0 ? await readCreators(deps, network, candidates) : null\n const result = {\n ...base,\n matched_on: candidates.length > 0 ? matchedOn : null,\n candidates,\n total,\n truncated: total > CANDIDATES_MAX,\n }\n return textResult({ ...result, hint: hintFor(result, creatorsNotRead) })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,yBAAyB;AACtC,MAAa,2BAA2B;AACxC,MAAa,0BAA0B;AACvC,MAAa,gCACX;AAKF,MAAa,gCAAgC;CAC3C,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;;AAIA,MAAa,iBAAiB;AAC9B,MAAa,YAAY;;AAEzB,MAAa,oBAAoB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