chain-insights 0.81.1 → 0.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/cli.cjs +6 -6
  2. package/dist/cli.mjs +6 -6
  3. package/dist/{deployer-screen-BomgSBcq.cjs → deployer-screen-DQw3pC0E.cjs} +36 -12
  4. package/dist/{deployer-screen-ByQBZEsg.mjs → deployer-screen-e3IbG1Y_.mjs} +37 -13
  5. package/dist/deployer-screen-e3IbG1Y_.mjs.map +1 -0
  6. package/dist/{dex-tool-DW_hT1Z1.mjs → dex-tool-25510SNo.mjs} +64 -37
  7. package/dist/dex-tool-25510SNo.mjs.map +1 -0
  8. package/dist/{dex-tool-C6eLeZI2.cjs → dex-tool-BDERiT5t.cjs} +63 -36
  9. package/dist/{exchange-deposit-check-DPU8W3vK.mjs → exchange-deposit-check-B1yebGBt.mjs} +2 -2
  10. package/dist/{exchange-deposit-check-DPU8W3vK.mjs.map → exchange-deposit-check-B1yebGBt.mjs.map} +1 -1
  11. package/dist/{exchange-deposit-check-5e5UwqTn.cjs → exchange-deposit-check-B9_fPt3E.cjs} +1 -1
  12. package/dist/{graph-schema-0eYvShs7.mjs → graph-schema-BZTzy0XV.mjs} +88 -55
  13. package/dist/graph-schema-BZTzy0XV.mjs.map +1 -0
  14. package/dist/{graph-schema-DNvmR6iP.cjs → graph-schema-u0TipQPl.cjs} +87 -54
  15. package/dist/mcp-proxy.cjs +12 -7
  16. package/dist/mcp-proxy.d.cts.map +1 -1
  17. package/dist/mcp-proxy.d.mts.map +1 -1
  18. package/dist/mcp-proxy.mjs +12 -7
  19. package/dist/mcp-proxy.mjs.map +1 -1
  20. package/docs/graph-tools.md +10 -1
  21. package/docs/mcp-proxy.md +20 -1
  22. package/package.json +1 -1
  23. package/skills/chain-insights-cypher/SKILL.md +2 -0
  24. package/skills/chain-insights-dex/SKILL.md +8 -0
  25. package/skills/chain-insights-dex/reference.md +15 -2
  26. package/skills/chain-insights-virtuals/SKILL.md +4 -3
  27. package/skills/chain-insights-virtuals/reference.md +38 -0
  28. package/dist/deployer-screen-ByQBZEsg.mjs.map +0 -1
  29. package/dist/dex-tool-DW_hT1Z1.mjs.map +0 -1
  30. package/dist/graph-schema-0eYvShs7.mjs.map +0 -1
package/dist/cli.cjs CHANGED
@@ -273,7 +273,7 @@ async function printNetworkCapability(name, opts) {
273
273
  async function printNetworkSchema(name, opts) {
274
274
  const { loadConfig } = await Promise.resolve().then(() => require("./config-BdE8LcF-.cjs")).then((n) => n.config_exports);
275
275
  const { resolveGraphMcpEndpoint } = await Promise.resolve().then(() => require("./client-Ddk4X9Ko.cjs")).then((n) => n.client_exports);
276
- const { formatGraphSchemaText, getGraphSchema } = await Promise.resolve().then(() => require("./graph-schema-DNvmR6iP.cjs")).then((n) => n.graph_schema_exports);
276
+ const { formatGraphSchemaText, getGraphSchema } = await Promise.resolve().then(() => require("./graph-schema-u0TipQPl.cjs")).then((n) => n.graph_schema_exports);
277
277
  const config = await loadConfig();
278
278
  const schema = await getGraphSchema({
279
279
  network: name,
@@ -647,9 +647,9 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
647
647
  }
648
648
  }
649
649
  console.log(formatToolsTable(visibleRemoteTools(tools)));
650
- const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./dex-tool-C6eLeZI2.cjs")).then((n) => n.dex_tool_exports);
650
+ const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./dex-tool-BDERiT5t.cjs")).then((n) => n.dex_tool_exports);
651
651
  const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./token-lookup-D-5GBEwF.cjs")).then((n) => n.token_lookup_exports);
652
- const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await Promise.resolve().then(() => require("./deployer-screen-BomgSBcq.cjs")).then((n) => n.deployer_screen_exports);
652
+ const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await Promise.resolve().then(() => require("./deployer-screen-DQw3pC0E.cjs")).then((n) => n.deployer_screen_exports);
653
653
  console.log("");
654
654
  console.log(formatToolsTable([
655
655
  {
@@ -693,7 +693,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
693
693
  return;
694
694
  }
695
695
  if (tool === "meta_dex_lookup") {
696
- const { handleMetaDexLookup } = await Promise.resolve().then(() => require("./dex-tool-C6eLeZI2.cjs")).then((n) => n.dex_tool_exports);
696
+ const { handleMetaDexLookup } = await Promise.resolve().then(() => require("./dex-tool-BDERiT5t.cjs")).then((n) => n.dex_tool_exports);
697
697
  const { loadRegistry } = await Promise.resolve().then(() => require("./dex-registry-BhGJUG9_.cjs")).then((n) => n.dex_registry_exports);
698
698
  const { metaDexLookupArgs } = await Promise.resolve().then(() => require("./call-args-DXEmPeE-.cjs"));
699
699
  const result = await withGraphMcpClient("chain-insights-cli-dex-lookup", (client) => handleMetaDexLookup(metaDexLookupArgs(args), {
@@ -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-BomgSBcq.cjs")).then((n) => n.deployer_screen_exports);
730
+ const { handleAmlDeployerScreen } = await Promise.resolve().then(() => require("./deployer-screen-DQw3pC0E.cjs")).then((n) => n.deployer_screen_exports);
731
731
  const result = await withGraphMcpClient("chain-insights-cli-deployer-screen", (client) => handleAmlDeployerScreen({
732
732
  network: args["network"],
733
733
  address: args["address"]
@@ -755,7 +755,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
755
755
  return;
756
756
  }
757
757
  if (tool === "aml_exchange_deposit_check") {
758
- const { handleAmlExchangeDepositCheck } = await Promise.resolve().then(() => require("./exchange-deposit-check-5e5UwqTn.cjs")).then((n) => n.exchange_deposit_check_exports);
758
+ const { handleAmlExchangeDepositCheck } = await Promise.resolve().then(() => require("./exchange-deposit-check-B9_fPt3E.cjs")).then((n) => n.exchange_deposit_check_exports);
759
759
  const { loadExchangeRegistry } = await Promise.resolve().then(() => require("./exchange-registry-CT0rRW__.cjs")).then((n) => n.exchange_registry_exports);
760
760
  const result = await withGraphMcpClient("chain-insights-cli-exchange-deposit-check", (client) => handleAmlExchangeDepositCheck({
761
761
  network: args["network"],
package/dist/cli.mjs CHANGED
@@ -271,7 +271,7 @@ async function printNetworkCapability(name, opts) {
271
271
  async function printNetworkSchema(name, opts) {
272
272
  const { loadConfig } = await import("./config-BkLIqOYq.mjs").then((n) => n.t);
273
273
  const { resolveGraphMcpEndpoint } = await import("./client-BaHAIidE.mjs").then((n) => n.r);
274
- const { formatGraphSchemaText, getGraphSchema } = await import("./graph-schema-0eYvShs7.mjs").then((n) => n.a);
274
+ const { formatGraphSchemaText, getGraphSchema } = await import("./graph-schema-BZTzy0XV.mjs").then((n) => n.a);
275
275
  const config = await loadConfig();
276
276
  const schema = await getGraphSchema({
277
277
  network: name,
@@ -645,9 +645,9 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
645
645
  }
646
646
  }
647
647
  console.log(formatToolsTable(visibleRemoteTools(tools)));
648
- const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await import("./dex-tool-DW_hT1Z1.mjs").then((n) => n.a);
648
+ const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await import("./dex-tool-25510SNo.mjs").then((n) => n.a);
649
649
  const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await import("./token-lookup-QpIv77P2.mjs").then((n) => n.l);
650
- const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await import("./deployer-screen-ByQBZEsg.mjs").then((n) => n.a);
650
+ const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await import("./deployer-screen-e3IbG1Y_.mjs").then((n) => n.a);
651
651
  console.log("");
652
652
  console.log(formatToolsTable([
653
653
  {
@@ -691,7 +691,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
691
691
  return;
692
692
  }
693
693
  if (tool === "meta_dex_lookup") {
694
- const { handleMetaDexLookup } = await import("./dex-tool-DW_hT1Z1.mjs").then((n) => n.a);
694
+ const { handleMetaDexLookup } = await import("./dex-tool-25510SNo.mjs").then((n) => n.a);
695
695
  const { loadRegistry } = await import("./dex-registry-BY67f4Ul.mjs").then((n) => n.s);
696
696
  const { metaDexLookupArgs } = await import("./call-args-CBqbYfOE.mjs");
697
697
  const result = await withGraphMcpClient("chain-insights-cli-dex-lookup", (client) => handleMetaDexLookup(metaDexLookupArgs(args), {
@@ -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-ByQBZEsg.mjs").then((n) => n.a);
728
+ const { handleAmlDeployerScreen } = await import("./deployer-screen-e3IbG1Y_.mjs").then((n) => n.a);
729
729
  const result = await withGraphMcpClient("chain-insights-cli-deployer-screen", (client) => handleAmlDeployerScreen({
730
730
  network: args["network"],
731
731
  address: args["address"]
@@ -753,7 +753,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
753
753
  return;
754
754
  }
755
755
  if (tool === "aml_exchange_deposit_check") {
756
- const { handleAmlExchangeDepositCheck } = await import("./exchange-deposit-check-DPU8W3vK.mjs").then((n) => n.a);
756
+ const { handleAmlExchangeDepositCheck } = await import("./exchange-deposit-check-B1yebGBt.mjs").then((n) => n.a);
757
757
  const { loadExchangeRegistry } = await import("./exchange-registry-CoLgHw6d.mjs").then((n) => n.r);
758
758
  const result = await withGraphMcpClient("chain-insights-cli-exchange-deposit-check", (client) => handleAmlExchangeDepositCheck({
759
759
  network: args["network"],
@@ -15,6 +15,14 @@ const require_token_lookup = require("./token-lookup-D-5GBEwF.cjs");
15
15
  * of all time and its first inbound bridge deposit;
16
16
  * wallet the address as the launcher itself: the same funder and bridge reads.
17
17
  *
18
+ * The funder is the launcher's earliest inbound FLOWED_TO. On a lane whose
19
+ * money family lists ROUTED_TO (the three link levels) it is the earliest of
20
+ * its inbound FLOWED_TO and ROUTED_TO from another address: a launcher funded
21
+ * by the proceeds of a swap names the payer of that swap. A self route (the
22
+ * launcher swapped for itself) is never the funder: it spent money the
23
+ * launcher already held, so the search goes on to what paid it in. Any other
24
+ * lane gets the reads of 0.82.0, byte for byte.
25
+ *
18
26
  * The token read answers first when it holds a row; the wallet read answers
19
27
  * otherwise. The tool returns facts and never a score, a level or a verdict:
20
28
  * the description below is the contract with every host, Claude Desktop chat
@@ -29,7 +37,7 @@ var deployer_screen_exports = /* @__PURE__ */ require_rolldown_runtime.__exportA
29
37
  const AML_DEPLOYER_SCREEN_TOOL = "aml_deployer_screen";
30
38
  const AML_DEPLOYER_SCREEN_SCHEMA = "chain-insights.aml-deployer-screen.v1";
31
39
  const AML_DEPLOYER_SCREEN_TITLE = "Deployer screen";
32
- const AML_DEPLOYER_SCREEN_DESCRIPTION = "Facts only, no score and no verdict: screens who is behind a token or a wallet. For a token contract it returns the creation transaction and the launcher (the wallet that sent it); for a wallet, that wallet as the launcher. Then the launcher's first funder of all time and what kind of wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: launcher_resolved is then false. not_covered lists what the graph cannot see yet.";
40
+ const AML_DEPLOYER_SCREEN_DESCRIPTION = "Facts only, no score and no verdict: screens who is behind a token or a wallet. For a token contract it returns the creation transaction and the launcher (the wallet that sent it); for a wallet, that wallet as the launcher. Then the launcher's first funder of all time and what kind of wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: launcher_resolved is then false. On a lane whose money family lists ROUTED_TO the first funder may have paid through a swap (funded_via swap): it paid, a router and a pool swapped, the launcher got another asset; a swap the launcher made for itself is never its funder. not_covered lists what the graph cannot see yet.";
33
41
  const AML_DEPLOYER_SCREEN_ANNOTATIONS = {
34
42
  readOnlyHint: true,
35
43
  idempotentHint: true,
@@ -45,6 +53,8 @@ const NOT_COVERED = [
45
53
  const ADDRESS_INPUT = /^0x[0-9a-fA-F]{40}$/;
46
54
  const ADDRESS_READ = /^0x[0-9a-f]{40}$/;
47
55
  const FUNDER_READ = "OPTIONAL MATCH (f:Address)-[e:FLOWED_TO]->(l)";
56
+ const LEVELS_FUNDER_READ = "OPTIONAL MATCH (f:Address)-[e:FLOWED_TO|ROUTED_TO]->(l) WHERE f.address <> l.address";
57
+ const LEVELS_FUNDING_COLUMNS = "coalesce(e.bought_usd_sum, e.amount_usd_sum) AS funding_usd, type(e) AS funding_link";
48
58
  const BRIDGE_READ = "OPTIONAL MATCH (ch:Chain)-[b:BRIDGED]->(l) WHERE b.kind IN ['TOKEN_DEPOSIT','NATIVE_DEPOSIT']";
49
59
  const PARTY_COLUMNS = [
50
60
  "labels(l) AS launcher_roles",
@@ -91,39 +101,45 @@ function assertReadAddress(address) {
91
101
  if (!ADDRESS_READ.test(address)) throw new Error(`deployer screen: ${JSON.stringify(address)} is not a lowercase 0x address`);
92
102
  }
93
103
  /** The token read: the address as a contract, its first creation and who sent it. */
94
- function tokenScreenQuery(address) {
104
+ function tokenScreenQuery(address, shape = "route") {
95
105
  assertReadAddress(address);
96
106
  return [
97
107
  `USE topology MATCH (t:Address {address:'${address}'})<-[c:DEPLOYED_CONTRACT]-(:Address)`,
98
108
  "WITH t, c ORDER BY c.block_height LIMIT 1",
99
109
  "MATCH (l:Address {address: c.tx_origin})",
100
- FUNDER_READ,
110
+ funderRead(shape),
101
111
  "WITH t, c, l, f, e ORDER BY e.first_seen_timestamp LIMIT 1",
102
112
  BRIDGE_READ,
103
113
  "WITH t, c, l, f, e, ch, b ORDER BY b.first_height LIMIT 1",
104
- `RETURN ${TOKEN_COLUMNS}, ${PARTY_COLUMNS} LIMIT 1`
114
+ `RETURN ${TOKEN_COLUMNS}, ${partyColumns(shape)} LIMIT 1`
105
115
  ].join(" ");
106
116
  }
117
+ function funderRead(shape) {
118
+ return shape === "levels" ? LEVELS_FUNDER_READ : FUNDER_READ;
119
+ }
120
+ function partyColumns(shape) {
121
+ return shape === "levels" ? PARTY_COLUMNS.replace("e.amount_usd_sum AS funding_usd", LEVELS_FUNDING_COLUMNS) : PARTY_COLUMNS;
122
+ }
107
123
  /** The wallet read: the address as the launcher itself. */
108
- function walletScreenQuery(address) {
124
+ function walletScreenQuery(address, shape = "route") {
109
125
  assertReadAddress(address);
110
126
  return [
111
127
  `USE topology MATCH (l:Address {address:'${address}'})`,
112
- FUNDER_READ,
128
+ funderRead(shape),
113
129
  "WITH l, f, e ORDER BY e.first_seen_timestamp LIMIT 1",
114
130
  BRIDGE_READ,
115
131
  "WITH l, f, e, ch, b ORDER BY b.first_height LIMIT 1",
116
- `RETURN l.address AS launcher, ${PARTY_COLUMNS} LIMIT 1`
132
+ `RETURN l.address AS launcher, ${partyColumns(shape)} LIMIT 1`
117
133
  ].join(" ");
118
134
  }
119
135
  /** The one batch the tool sends: members `token` and `wallet`. */
120
- function deployerScreenQueries(address) {
136
+ function deployerScreenQueries(address, shape = "route") {
121
137
  return [{
122
138
  id: "token",
123
- query: tokenScreenQuery(address)
139
+ query: tokenScreenQuery(address, shape)
124
140
  }, {
125
141
  id: "wallet",
126
- query: walletScreenQuery(address)
142
+ query: walletScreenQuery(address, shape)
127
143
  }];
128
144
  }
129
145
  function isRecord(value) {
@@ -236,7 +252,8 @@ function funderOf(row) {
236
252
  funded_at: fundedAt,
237
253
  funded_at_utc: utcOrNull(fundedAt),
238
254
  funding_tx_count: numberOrNull(row.funding_tx_count),
239
- funding_usd: numberOrNull(row.funding_usd)
255
+ funding_usd: numberOrNull(row.funding_usd),
256
+ ...row.funding_link === "ROUTED_TO" ? { funded_via: "swap" } : row.funding_link === "FLOWED_TO" ? { funded_via: "transfer" } : {}
240
257
  };
241
258
  }
242
259
  function bridgedInOf(row) {
@@ -357,6 +374,7 @@ function hintFor(result) {
357
374
  if (result.input_kind === "wallet" && result.launcher?.roles.some((r) => r === "Contract" || r === "Token")) parts.push("The address is a contract, but the graph holds no creation record for it, so it was screened as a wallet.");
358
375
  if (result.launcher_resolved === false) parts.push("The launcher is a bundler: it sends transactions for others, so the person behind the launch is not known from this read.");
359
376
  if (!result.first_funder) parts.push("The launcher has no inbound flow in the graph: no first funder.");
377
+ if (result.first_funder?.funded_via === "swap") parts.push("The first funder paid the launcher through a swap: say it paid one asset and the launcher got another, and never name a router or a pool as the funder.");
360
378
  parts.push(`not_covered names what the graph cannot see yet (${NOT_COVERED.join(", ")}); say so when it matters.`);
361
379
  return parts.join(" ");
362
380
  }
@@ -393,11 +411,17 @@ async function handleAmlDeployerScreen(args, deps) {
393
411
  const address = raw.toLowerCase();
394
412
  const unavailable = await deps.unavailable?.();
395
413
  if (unavailable) return errorResult(`No deployer screen read was sent: ${unavailable} There is no answer yet, which is not "not found": try again later.`);
414
+ let shape = "route";
415
+ if (deps.linkShape) try {
416
+ shape = await deps.linkShape(network);
417
+ } catch {
418
+ shape = "route";
419
+ }
396
420
  let answer;
397
421
  try {
398
422
  answer = await deps.graphQueryBatch({
399
423
  network,
400
- queries: deployerScreenQueries(address)
424
+ queries: deployerScreenQueries(address, shape)
401
425
  });
402
426
  } catch (err) {
403
427
  return errorResult(`The deployer screen read failed: ${deps.describeFailure(err)} This is not "not found": send the same screen again once.`);
@@ -15,6 +15,14 @@ import { c as refusalOf, s as membersOf } from "./token-lookup-QpIv77P2.mjs";
15
15
  * of all time and its first inbound bridge deposit;
16
16
  * wallet the address as the launcher itself: the same funder and bridge reads.
17
17
  *
18
+ * The funder is the launcher's earliest inbound FLOWED_TO. On a lane whose
19
+ * money family lists ROUTED_TO (the three link levels) it is the earliest of
20
+ * its inbound FLOWED_TO and ROUTED_TO from another address: a launcher funded
21
+ * by the proceeds of a swap names the payer of that swap. A self route (the
22
+ * launcher swapped for itself) is never the funder: it spent money the
23
+ * launcher already held, so the search goes on to what paid it in. Any other
24
+ * lane gets the reads of 0.82.0, byte for byte.
25
+ *
18
26
  * The token read answers first when it holds a row; the wallet read answers
19
27
  * otherwise. The tool returns facts and never a score, a level or a verdict:
20
28
  * the description below is the contract with every host, Claude Desktop chat
@@ -29,7 +37,7 @@ var deployer_screen_exports = /* @__PURE__ */ __exportAll({
29
37
  const AML_DEPLOYER_SCREEN_TOOL = "aml_deployer_screen";
30
38
  const AML_DEPLOYER_SCREEN_SCHEMA = "chain-insights.aml-deployer-screen.v1";
31
39
  const AML_DEPLOYER_SCREEN_TITLE = "Deployer screen";
32
- const AML_DEPLOYER_SCREEN_DESCRIPTION = "Facts only, no score and no verdict: screens who is behind a token or a wallet. For a token contract it returns the creation transaction and the launcher (the wallet that sent it); for a wallet, that wallet as the launcher. Then the launcher's first funder of all time and what kind of wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: launcher_resolved is then false. not_covered lists what the graph cannot see yet.";
40
+ const AML_DEPLOYER_SCREEN_DESCRIPTION = "Facts only, no score and no verdict: screens who is behind a token or a wallet. For a token contract it returns the creation transaction and the launcher (the wallet that sent it); for a wallet, that wallet as the launcher. Then the launcher's first funder of all time and what kind of wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: launcher_resolved is then false. On a lane whose money family lists ROUTED_TO the first funder may have paid through a swap (funded_via swap): it paid, a router and a pool swapped, the launcher got another asset; a swap the launcher made for itself is never its funder. not_covered lists what the graph cannot see yet.";
33
41
  const AML_DEPLOYER_SCREEN_ANNOTATIONS = {
34
42
  readOnlyHint: true,
35
43
  idempotentHint: true,
@@ -45,6 +53,8 @@ const NOT_COVERED = [
45
53
  const ADDRESS_INPUT = /^0x[0-9a-fA-F]{40}$/;
46
54
  const ADDRESS_READ = /^0x[0-9a-f]{40}$/;
47
55
  const FUNDER_READ = "OPTIONAL MATCH (f:Address)-[e:FLOWED_TO]->(l)";
56
+ const LEVELS_FUNDER_READ = "OPTIONAL MATCH (f:Address)-[e:FLOWED_TO|ROUTED_TO]->(l) WHERE f.address <> l.address";
57
+ const LEVELS_FUNDING_COLUMNS = "coalesce(e.bought_usd_sum, e.amount_usd_sum) AS funding_usd, type(e) AS funding_link";
48
58
  const BRIDGE_READ = "OPTIONAL MATCH (ch:Chain)-[b:BRIDGED]->(l) WHERE b.kind IN ['TOKEN_DEPOSIT','NATIVE_DEPOSIT']";
49
59
  const PARTY_COLUMNS = [
50
60
  "labels(l) AS launcher_roles",
@@ -91,39 +101,45 @@ function assertReadAddress(address) {
91
101
  if (!ADDRESS_READ.test(address)) throw new Error(`deployer screen: ${JSON.stringify(address)} is not a lowercase 0x address`);
92
102
  }
93
103
  /** The token read: the address as a contract, its first creation and who sent it. */
94
- function tokenScreenQuery(address) {
104
+ function tokenScreenQuery(address, shape = "route") {
95
105
  assertReadAddress(address);
96
106
  return [
97
107
  `USE topology MATCH (t:Address {address:'${address}'})<-[c:DEPLOYED_CONTRACT]-(:Address)`,
98
108
  "WITH t, c ORDER BY c.block_height LIMIT 1",
99
109
  "MATCH (l:Address {address: c.tx_origin})",
100
- FUNDER_READ,
110
+ funderRead(shape),
101
111
  "WITH t, c, l, f, e ORDER BY e.first_seen_timestamp LIMIT 1",
102
112
  BRIDGE_READ,
103
113
  "WITH t, c, l, f, e, ch, b ORDER BY b.first_height LIMIT 1",
104
- `RETURN ${TOKEN_COLUMNS}, ${PARTY_COLUMNS} LIMIT 1`
114
+ `RETURN ${TOKEN_COLUMNS}, ${partyColumns(shape)} LIMIT 1`
105
115
  ].join(" ");
106
116
  }
117
+ function funderRead(shape) {
118
+ return shape === "levels" ? LEVELS_FUNDER_READ : FUNDER_READ;
119
+ }
120
+ function partyColumns(shape) {
121
+ return shape === "levels" ? PARTY_COLUMNS.replace("e.amount_usd_sum AS funding_usd", LEVELS_FUNDING_COLUMNS) : PARTY_COLUMNS;
122
+ }
107
123
  /** The wallet read: the address as the launcher itself. */
108
- function walletScreenQuery(address) {
124
+ function walletScreenQuery(address, shape = "route") {
109
125
  assertReadAddress(address);
110
126
  return [
111
127
  `USE topology MATCH (l:Address {address:'${address}'})`,
112
- FUNDER_READ,
128
+ funderRead(shape),
113
129
  "WITH l, f, e ORDER BY e.first_seen_timestamp LIMIT 1",
114
130
  BRIDGE_READ,
115
131
  "WITH l, f, e, ch, b ORDER BY b.first_height LIMIT 1",
116
- `RETURN l.address AS launcher, ${PARTY_COLUMNS} LIMIT 1`
132
+ `RETURN l.address AS launcher, ${partyColumns(shape)} LIMIT 1`
117
133
  ].join(" ");
118
134
  }
119
135
  /** The one batch the tool sends: members `token` and `wallet`. */
120
- function deployerScreenQueries(address) {
136
+ function deployerScreenQueries(address, shape = "route") {
121
137
  return [{
122
138
  id: "token",
123
- query: tokenScreenQuery(address)
139
+ query: tokenScreenQuery(address, shape)
124
140
  }, {
125
141
  id: "wallet",
126
- query: walletScreenQuery(address)
142
+ query: walletScreenQuery(address, shape)
127
143
  }];
128
144
  }
129
145
  function isRecord(value) {
@@ -236,7 +252,8 @@ function funderOf(row) {
236
252
  funded_at: fundedAt,
237
253
  funded_at_utc: utcOrNull(fundedAt),
238
254
  funding_tx_count: numberOrNull(row.funding_tx_count),
239
- funding_usd: numberOrNull(row.funding_usd)
255
+ funding_usd: numberOrNull(row.funding_usd),
256
+ ...row.funding_link === "ROUTED_TO" ? { funded_via: "swap" } : row.funding_link === "FLOWED_TO" ? { funded_via: "transfer" } : {}
240
257
  };
241
258
  }
242
259
  function bridgedInOf(row) {
@@ -357,6 +374,7 @@ function hintFor(result) {
357
374
  if (result.input_kind === "wallet" && result.launcher?.roles.some((r) => r === "Contract" || r === "Token")) parts.push("The address is a contract, but the graph holds no creation record for it, so it was screened as a wallet.");
358
375
  if (result.launcher_resolved === false) parts.push("The launcher is a bundler: it sends transactions for others, so the person behind the launch is not known from this read.");
359
376
  if (!result.first_funder) parts.push("The launcher has no inbound flow in the graph: no first funder.");
377
+ if (result.first_funder?.funded_via === "swap") parts.push("The first funder paid the launcher through a swap: say it paid one asset and the launcher got another, and never name a router or a pool as the funder.");
360
378
  parts.push(`not_covered names what the graph cannot see yet (${NOT_COVERED.join(", ")}); say so when it matters.`);
361
379
  return parts.join(" ");
362
380
  }
@@ -393,11 +411,17 @@ async function handleAmlDeployerScreen(args, deps) {
393
411
  const address = raw.toLowerCase();
394
412
  const unavailable = await deps.unavailable?.();
395
413
  if (unavailable) return errorResult(`No deployer screen read was sent: ${unavailable} There is no answer yet, which is not "not found": try again later.`);
414
+ let shape = "route";
415
+ if (deps.linkShape) try {
416
+ shape = await deps.linkShape(network);
417
+ } catch {
418
+ shape = "route";
419
+ }
396
420
  let answer;
397
421
  try {
398
422
  answer = await deps.graphQueryBatch({
399
423
  network,
400
- queries: deployerScreenQueries(address)
424
+ queries: deployerScreenQueries(address, shape)
401
425
  });
402
426
  } catch (err) {
403
427
  return errorResult(`The deployer screen read failed: ${deps.describeFailure(err)} This is not "not found": send the same screen again once.`);
@@ -410,4 +434,4 @@ async function handleAmlDeployerScreen(args, deps) {
410
434
  }
411
435
  export { deployer_screen_exports as a, AML_DEPLOYER_SCREEN_TOOL as i, AML_DEPLOYER_SCREEN_DESCRIPTION as n, handleAmlDeployerScreen as o, AML_DEPLOYER_SCREEN_TITLE as r, AML_DEPLOYER_SCREEN_ANNOTATIONS as t };
412
436
 
413
- //# sourceMappingURL=deployer-screen-ByQBZEsg.mjs.map
437
+ //# sourceMappingURL=deployer-screen-e3IbG1Y_.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployer-screen-e3IbG1Y_.mjs","names":[],"sources":["../src/mcp/deployer-screen.ts"],"sourcesContent":["/**\n * aml_deployer_screen: who is behind a token or a wallet, as facts.\n *\n * A local tool of the proxy. It sends one graph_query_batch with two reads on\n * USE topology, both anchored on the address:\n *\n * token the address as a contract: its first creation (DEPLOYED_CONTRACT),\n * the launcher (the transaction's sender), the launcher's first funder\n * of all time and its first inbound bridge deposit;\n * wallet the address as the launcher itself: the same funder and bridge reads.\n *\n * The funder is the launcher's earliest inbound FLOWED_TO. On a lane whose\n * money family lists ROUTED_TO (the three link levels) it is the earliest of\n * its inbound FLOWED_TO and ROUTED_TO from another address: a launcher funded\n * by the proceeds of a swap names the payer of that swap. A self route (the\n * launcher swapped for itself) is never the funder: it spent money the\n * launcher already held, so the search goes on to what paid it in. Any other\n * lane gets the reads of 0.82.0, byte for byte.\n *\n * The token read answers first when it holds a row; the wallet read answers\n * otherwise. The tool returns facts and never a score, a level or a verdict:\n * the description below is the contract with every host, Claude Desktop chat\n * included, which reads no skill.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport type { SwapLinkShape } from './layer-routing.js'\nimport { isEpochMs, utcText } from './timestamp-text.js'\nimport {\n membersOf,\n refusalOf,\n type GraphAnswer,\n type Member,\n type TokenToolDependencies,\n} from './token-lookup.js'\n\nexport const AML_DEPLOYER_SCREEN_TOOL = 'aml_deployer_screen' as const\nexport const AML_DEPLOYER_SCREEN_SCHEMA = 'chain-insights.aml-deployer-screen.v1' as const\nexport const AML_DEPLOYER_SCREEN_TITLE = 'Deployer screen'\nexport const AML_DEPLOYER_SCREEN_DESCRIPTION =\n 'Facts only, no score and no verdict: screens who is behind a token or a wallet. ' +\n 'For a token contract it returns the creation transaction and the launcher (the wallet that sent it); ' +\n 'for a wallet, that wallet as the launcher. Then the launcher\\'s first funder of all time and what kind of ' +\n 'wallet that funder is (wallet, contract, bridge, bundler, launchpad, exchange, mixer, scam), how many addresses the ' +\n 'funder ever paid, the sanctions, scam, victim and risk labels on each, and the first inbound bridge deposit. ' +\n 'The caller decides. A fresh launcher funded by a wallet that paid few addresses is the pattern to look at; ' +\n 'a funder that paid thousands is shared infrastructure. A launcher that is a bundler hides the real sender: ' +\n 'launcher_resolved is then false. On a lane whose money family lists ROUTED_TO the first funder may have paid ' +\n 'through a swap (funded_via swap): it paid, a router and a pool swapped, the launcher got another asset; a swap ' +\n 'the launcher made for itself is never its funder. not_covered lists what the graph cannot see yet.'\nexport const AML_DEPLOYER_SCREEN_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const AML_DEPLOYER_SCREEN_ARGS = ['network', 'address'] as const\n\n/** What the two reads cannot see yet, named in every answer. */\nexport const NOT_COVERED = ['exploit_labels', 'ml_labels', 'bridge_sender', 'ethereum_history'] as const\n\nexport type CrimeKind = 'sanctioned' | 'scam' | 'victim' | 'issuer_frozen' | 'risk'\nexport interface Crime {\n kind: CrimeKind\n value: string\n level: string | null\n}\n\nexport interface Party {\n address: string\n roles: string[]\n crime: Crime[]\n first_activity: number | null\n first_activity_utc: string | null\n degree_in: number | null\n degree_out: number | null\n}\n\nexport type FunderKind = 'scam' | 'mixer' | 'exchange' | 'bridge' | 'bundler' | 'launchpad' | 'contract' | 'wallet'\n\nexport interface Funder {\n address: string\n kind: FunderKind\n roles: string[]\n crime: Crime[]\n degree_out: number | null\n first_activity: number | null\n first_activity_utc: string | null\n funded_at: number | null\n funded_at_utc: string | null\n funding_tx_count: number | null\n funding_usd: number | null\n /**\n * On a lane with the levels only: `transfer` when the first money came on\n * FLOWED_TO, `swap` when on ROUTED_TO (the funder paid, the launcher got the\n * bought asset; funding_usd is then what the launcher got).\n */\n funded_via?: 'transfer' | 'swap'\n}\n\nexport interface Creation {\n tx: string | null\n block: number | null\n time: number | null\n time_utc: string | null\n deployer: string | null\n factory: string | null\n mode: 'direct' | 'factory'\n}\n\nexport interface BridgedIn {\n chain: string | null\n bridge: string | null\n kind: string | null\n asset: string | null\n first_block: number | null\n}\n\nexport interface AmlDeployerScreenResult {\n schema: typeof AML_DEPLOYER_SCREEN_SCHEMA\n tool: typeof AML_DEPLOYER_SCREEN_TOOL\n network: string\n input: string\n /** false when the graph holds no node for the address: every fact below is then null. */\n found: boolean\n input_kind: 'token' | 'wallet' | null\n token: { address: string; roles: string[] } | null\n creation: Creation | null\n launcher: Party | null\n launcher_resolved: boolean | null\n first_funder: Funder | null\n bridged_in: BridgedIn | null\n not_covered: string[]\n hint: string\n}\n\nexport type DeployerScreenDependencies = Pick<\n TokenToolDependencies,\n 'graphQueryBatch' | 'unavailable' | 'describeFailure'\n> & {\n /**\n * The lane's graph shape (`meta_network_capabilities`, kept by the proxy).\n * The funder read walks ROUTED_TO only when it answers `levels`; absent,\n * `route` or a read that throws keeps the reads of 0.82.0.\n */\n linkShape?: (network: string) => Promise<SwapLinkShape> | SwapLinkShape\n}\n\nexport type AmlDeployerScreenToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\n// The only address form ever written into a read: 0x and 40 lowercase hex.\nconst ADDRESS_INPUT = /^0x[0-9a-fA-F]{40}$/\nconst ADDRESS_READ = /^0x[0-9a-f]{40}$/\n\n// The funder's first inbound flow and the first inbound bridge deposit of the\n// launcher `l`, and the columns both reads return about them.\nconst FUNDER_READ = 'OPTIONAL MATCH (f:Address)-[e:FLOWED_TO]->(l)'\n// On a lane with the levels: the first money from another address, funds or a\n// swap route; the self route is left out (it spent what the launcher held).\nconst LEVELS_FUNDER_READ =\n 'OPTIONAL MATCH (f:Address)-[e:FLOWED_TO|ROUTED_TO]->(l) WHERE f.address <> l.address'\n// What the launcher got: a route carries it in bought_usd_sum, a FLOWED_TO in\n// amount_usd_sum; and which link it came on.\nconst LEVELS_FUNDING_COLUMNS =\n 'coalesce(e.bought_usd_sum, e.amount_usd_sum) AS funding_usd, type(e) AS funding_link'\nconst BRIDGE_READ =\n \"OPTIONAL MATCH (ch:Chain)-[b:BRIDGED]->(l) WHERE b.kind IN ['TOKEN_DEPOSIT','NATIVE_DEPOSIT']\"\nconst PARTY_COLUMNS = [\n 'labels(l) AS launcher_roles',\n 'l.first_activity_timestamp AS launcher_first_activity',\n 'l.degree_in AS launcher_degree_in',\n 'l.degree_out AS launcher_degree_out',\n 'l.is_sanctioned AS launcher_is_sanctioned',\n 'l.is_scam AS launcher_is_scam',\n 'l.is_victim AS launcher_is_victim',\n 'l.is_issuer_frozen AS launcher_is_issuer_frozen',\n 'l.label_risk_labels AS launcher_risk_labels',\n 'l.label_risk_levels AS launcher_risk_levels',\n 'f.address AS funder',\n 'labels(f) AS funder_roles',\n 'f.degree_out AS funder_degree_out',\n 'f.first_activity_timestamp AS funder_first_activity',\n 'f.is_sanctioned AS funder_is_sanctioned',\n 'f.is_scam AS funder_is_scam',\n 'f.is_victim AS funder_is_victim',\n 'f.is_issuer_frozen AS funder_is_issuer_frozen',\n 'f.label_risk_labels AS funder_risk_labels',\n 'f.label_risk_levels AS funder_risk_levels',\n 'e.first_seen_timestamp AS funded_at',\n 'e.tx_count AS funding_tx_count',\n 'e.amount_usd_sum AS funding_usd',\n 'ch.network AS bridged_chain',\n 'ch.address AS bridged_bridge',\n 'b.kind AS bridged_kind',\n 'b.asset AS bridged_asset',\n 'b.first_height AS bridged_first_block',\n].join(', ')\nconst TOKEN_COLUMNS = [\n 't.address AS token',\n 'labels(t) AS token_roles',\n 'c.tx_origin AS launcher',\n 'c.deployer_address AS deployer',\n 'c.factory_address AS factory',\n 'c.kind AS creation_kind',\n 'c.tx_id AS creation_tx',\n 'c.block_height AS creation_block',\n 'c.block_timestamp AS creation_time',\n].join(', ')\n\nfunction assertReadAddress(address: string): void {\n if (!ADDRESS_READ.test(address)) {\n throw new Error(`deployer screen: ${JSON.stringify(address)} is not a lowercase 0x address`)\n }\n}\n\n/** The token read: the address as a contract, its first creation and who sent it. */\nexport function tokenScreenQuery(address: string, shape: SwapLinkShape = 'route'): string {\n assertReadAddress(address)\n return [\n `USE topology MATCH (t:Address {address:'${address}'})<-[c:DEPLOYED_CONTRACT]-(:Address)`,\n 'WITH t, c ORDER BY c.block_height LIMIT 1',\n 'MATCH (l:Address {address: c.tx_origin})',\n funderRead(shape),\n 'WITH t, c, l, f, e ORDER BY e.first_seen_timestamp LIMIT 1',\n BRIDGE_READ,\n 'WITH t, c, l, f, e, ch, b ORDER BY b.first_height LIMIT 1',\n `RETURN ${TOKEN_COLUMNS}, ${partyColumns(shape)} LIMIT 1`,\n ].join(' ')\n}\n\nfunction funderRead(shape: SwapLinkShape): string {\n return shape === 'levels' ? LEVELS_FUNDER_READ : FUNDER_READ\n}\n\nfunction partyColumns(shape: SwapLinkShape): string {\n return shape === 'levels'\n ? PARTY_COLUMNS.replace('e.amount_usd_sum AS funding_usd', LEVELS_FUNDING_COLUMNS)\n : PARTY_COLUMNS\n}\n\n/** The wallet read: the address as the launcher itself. */\nexport function walletScreenQuery(address: string, shape: SwapLinkShape = 'route'): string {\n assertReadAddress(address)\n return [\n `USE topology MATCH (l:Address {address:'${address}'})`,\n funderRead(shape),\n 'WITH l, f, e ORDER BY e.first_seen_timestamp LIMIT 1',\n BRIDGE_READ,\n 'WITH l, f, e, ch, b ORDER BY b.first_height LIMIT 1',\n `RETURN l.address AS launcher, ${partyColumns(shape)} LIMIT 1`,\n ].join(' ')\n}\n\n/** The one batch the tool sends: members `token` and `wallet`. */\nexport function deployerScreenQueries(\n address: string,\n shape: SwapLinkShape = 'route'\n): Array<{ id: 'token' | 'wallet'; query: string }> {\n return [\n { id: 'token', query: tokenScreenQuery(address, shape) },\n { id: 'wallet', query: walletScreenQuery(address, shape) },\n ]\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value.trim() : null\n\nconst numberOrNull = (value: unknown): number | null => {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)))\n return Number(value)\n return null\n}\n\nconst addressOrNull = (value: unknown): string | null =>\n typeof value === 'string' && ADDRESS_INPUT.test(value.trim()) ? value.trim().toLowerCase() : null\n\nconst utcOrNull = (ms: number | null): string | null => (isEpochMs(ms) ? utcText(ms) : null)\n\n/**\n * A label from a third-party explorer tag source is training data, never served.\n * The graph is not meant to carry one; this drops it if it ever does.\n */\nexport function isServedLabel(value: string): boolean {\n const lower = value.trim().toLowerCase()\n return !(lower.startsWith('etherscan') || lower.startsWith('data:etherscan'))\n}\n\nconst strings = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((v): v is string => typeof v === 'string') : []\n\n/** labels(n) minus Address, with an unserved label dropped. */\nfunction rolesOf(value: unknown): string[] {\n return strings(value).filter((role) => role !== 'Address' && isServedLabel(role))\n}\n\n// The flag of each judgement mark, and the mark's label word served as its value.\nconst FLAG_CRIMES: Array<[CrimeKind, string, string]> = [\n ['sanctioned', 'is_sanctioned', 'Sanctioned'],\n ['scam', 'is_scam', 'Scam'],\n ['victim', 'is_victim', 'Victim'],\n ['issuer_frozen', 'is_issuer_frozen', 'IssuerFrozen'],\n]\n\n/** The flags that are true, then one risk entry per served risk label with its level. */\nfunction crimeOf(row: Record<string, unknown>, prefix: 'launcher' | 'funder'): Crime[] {\n const crime: Crime[] = []\n for (const [kind, flag, value] of FLAG_CRIMES) {\n if (row[`${prefix}_${flag}`] === true) crime.push({ kind, value, level: null })\n }\n const labels = Array.isArray(row[`${prefix}_risk_labels`]) ? (row[`${prefix}_risk_labels`] as unknown[]) : []\n const levels = Array.isArray(row[`${prefix}_risk_levels`]) ? (row[`${prefix}_risk_levels`] as unknown[]) : []\n labels.forEach((label, at) => {\n if (typeof label !== 'string' || label.trim() === '' || !isServedLabel(label)) return\n crime.push({ kind: 'risk', value: label, level: textOrNull(levels[at]) })\n })\n return crime\n}\n\n/** The funder kinds, first match wins; a contract with no role is 'contract', no match is a plain wallet. */\nexport const FUNDER_KIND_RULES: ReadonlyArray<\n readonly [FunderKind, (roles: readonly string[], isScam: boolean) => boolean]\n> = [\n ['scam', (roles, isScam) => isScam || roles.includes('Scam')],\n ['mixer', (roles) => roles.includes('Mixer')],\n ['exchange', (roles) => roles.includes('Exchange')],\n ['bridge', (roles) => roles.includes('Bridge')],\n ['bundler', (roles) => roles.includes('Bundler')],\n ['launchpad', (roles) => roles.includes('Pool') || roles.includes('Protocol')],\n ['contract', (roles) => roles.includes('Contract')],\n]\n\nexport function funderKind(roles: readonly string[], isScam = false): FunderKind {\n return FUNDER_KIND_RULES.find(([, rule]) => rule(roles, isScam))?.[0] ?? 'wallet'\n}\n\nfunction partyOf(row: Record<string, unknown>): Party | null {\n const address = addressOrNull(row.launcher)\n if (!address) return null\n const firstActivity = numberOrNull(row.launcher_first_activity)\n return {\n address,\n roles: rolesOf(row.launcher_roles),\n crime: crimeOf(row, 'launcher'),\n first_activity: firstActivity,\n first_activity_utc: utcOrNull(firstActivity),\n degree_in: numberOrNull(row.launcher_degree_in),\n degree_out: numberOrNull(row.launcher_degree_out),\n }\n}\n\nfunction funderOf(row: Record<string, unknown>): Funder | null {\n const address = addressOrNull(row.funder)\n if (!address) return null\n const roles = rolesOf(row.funder_roles)\n const firstActivity = numberOrNull(row.funder_first_activity)\n const fundedAt = numberOrNull(row.funded_at)\n return {\n address,\n kind: funderKind(roles, row.funder_is_scam === true),\n roles,\n crime: crimeOf(row, 'funder'),\n degree_out: numberOrNull(row.funder_degree_out),\n first_activity: firstActivity,\n first_activity_utc: utcOrNull(firstActivity),\n funded_at: fundedAt,\n funded_at_utc: utcOrNull(fundedAt),\n funding_tx_count: numberOrNull(row.funding_tx_count),\n funding_usd: numberOrNull(row.funding_usd),\n // Only a levels read returns funding_link; a read of before adds no key.\n ...(row.funding_link === 'ROUTED_TO'\n ? { funded_via: 'swap' as const }\n : row.funding_link === 'FLOWED_TO'\n ? { funded_via: 'transfer' as const }\n : {}),\n }\n}\n\nfunction bridgedInOf(row: Record<string, unknown>): BridgedIn | null {\n const chain = textOrNull(row.bridged_chain)\n const kind = textOrNull(row.bridged_kind)\n if (!chain && !kind) return null\n const asset = textOrNull(row.bridged_asset)\n return {\n chain,\n bridge: addressOrNull(row.bridged_bridge) ?? textOrNull(row.bridged_bridge),\n kind,\n asset: addressOrNull(asset) ?? asset,\n first_block: numberOrNull(row.bridged_first_block),\n }\n}\n\nfunction creationOf(row: Record<string, unknown>): Creation {\n const factory = addressOrNull(row.factory)\n const kind = textOrNull(row.creation_kind)\n const time = numberOrNull(row.creation_time)\n return {\n tx: textOrNull(row.creation_tx)?.toLowerCase() ?? null,\n block: numberOrNull(row.creation_block),\n time,\n time_utc: utcOrNull(time),\n deployer: addressOrNull(row.deployer),\n factory,\n mode: kind === 'factory' || (kind !== 'direct' && factory !== null) ? 'factory' : 'direct',\n }\n}\n\n/** The first row of a member that names a launcher, or null when it has none. */\nfunction launcherRow(member: Member | undefined): Record<string, unknown> | null {\n if (!member || !Array.isArray(member.results)) return null\n return member.results.find((row) => isRecord(row) && addressOrNull(row.launcher) !== null) ?? null\n}\n\nconst answered = (member: Member | undefined): boolean =>\n member?.ok === true && Array.isArray(member.results)\n\nfunction memberFailure(id: string, member: Member | undefined): string {\n if (!member) return `the ${id} read is missing from the batch answer`\n return typeof member.error === 'string' && member.error.trim() !== ''\n ? member.error\n : `the ${id} read did not answer`\n}\n\n/** The screen built from the two batch members, or why it cannot be. */\nexport function screenFromMembers(\n network: string,\n input: string,\n members: Map<string, Member>\n): { result: AmlDeployerScreenResult } | { failure: string } {\n const token = members.get('token')\n const wallet = members.get('wallet')\n const base = {\n schema: AML_DEPLOYER_SCREEN_SCHEMA,\n tool: AML_DEPLOYER_SCREEN_TOOL,\n network,\n input,\n not_covered: [...NOT_COVERED] as string[],\n }\n\n // A token read that failed cannot be told from \"not a token\": no fallback.\n if (!answered(token)) return { failure: memberFailure('token', token) }\n const tokenRow = launcherRow(token)\n if (tokenRow) {\n const launcher = partyOf(tokenRow)!\n const result = {\n ...base,\n found: true,\n input_kind: 'token' as const,\n token: {\n address: addressOrNull(tokenRow.token) ?? input,\n roles: rolesOf(tokenRow.token_roles),\n },\n creation: creationOf(tokenRow),\n launcher,\n launcher_resolved: !launcher.roles.includes('Bundler'),\n first_funder: funderOf(tokenRow),\n bridged_in: bridgedInOf(tokenRow),\n }\n return { result: { ...result, hint: hintFor(result) } }\n }\n\n if (!answered(wallet)) return { failure: memberFailure('wallet', wallet) }\n const walletRow = launcherRow(wallet)\n if (walletRow) {\n const launcher = partyOf(walletRow)!\n const result = {\n ...base,\n found: true,\n input_kind: 'wallet' as const,\n token: null,\n creation: null,\n launcher,\n launcher_resolved: !launcher.roles.includes('Bundler'),\n first_funder: funderOf(walletRow),\n bridged_in: bridgedInOf(walletRow),\n }\n return { result: { ...result, hint: hintFor(result) } }\n }\n\n const result = {\n ...base,\n found: false,\n input_kind: null,\n token: null,\n creation: null,\n launcher: null,\n launcher_resolved: null,\n first_funder: null,\n bridged_in: null,\n }\n return { result: { ...result, hint: hintFor(result) } }\n}\n\nconst FACTS_ONLY =\n 'Report these as facts. Give no score, no risk level and no verdict of your own: the user decides.'\n\nfunction hintFor(result: Omit<AmlDeployerScreenResult, 'hint'>): string {\n const parts: string[] = [ANSWER_HINT]\n if (!result.found) {\n parts.push(\n `${result.input} is not in the Chain Insights Graph of ${result.network}: no flow, creation or bridge touches it. ` +\n 'Say so in one line. That is not proof the address is clean, and it is not proof it is a token. ' +\n 'Check the network and the address with the user.'\n )\n return parts.join(' ')\n }\n parts.push(FACTS_ONLY)\n if (result.input_kind === 'wallet' && result.launcher?.roles.some((r) => r === 'Contract' || r === 'Token')) {\n parts.push(\n 'The address is a contract, but the graph holds no creation record for it, so it was screened as a wallet.'\n )\n }\n if (result.launcher_resolved === false) {\n parts.push(\n 'The launcher is a bundler: it sends transactions for others, so the person behind the launch is not known from this read.'\n )\n }\n if (!result.first_funder) parts.push('The launcher has no inbound flow in the graph: no first funder.')\n if (result.first_funder?.funded_via === 'swap') {\n parts.push(\n 'The first funder paid the launcher through a swap: say it paid one asset and the launcher got another, and never name a router or a pool as the funder.'\n )\n }\n parts.push(`not_covered names what the graph cannot see yet (${NOT_COVERED.join(', ')}); say so when it matters.`)\n return parts.join(' ')\n}\n\nfunction errorResult(text: string): AmlDeployerScreenToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: AmlDeployerScreenResult): AmlDeployerScreenToolResult {\n return {\n content: [{ type: 'text', text: JSON.stringify(structured, null, 2) }],\n structuredContent: structured as unknown as Record<string, unknown>,\n isError: false,\n }\n}\n\n/** aml_deployer_screen, {network, address}. Every argument is checked before a read is sent. */\nexport async function handleAmlDeployerScreen(\n args: unknown,\n deps: DeployerScreenDependencies\n): Promise<AmlDeployerScreenToolResult> {\n const record = isRecord(args) ? args : {}\n let network: string\n try {\n network = normalizeDexNetwork(record.network)\n } catch (err) {\n return errorResult(\n err instanceof DexRegistryError ? err.message : `invalid_network: ${(err as Error).message}`\n )\n }\n const raw = typeof record.address === 'string' ? record.address.trim() : ''\n if (!ADDRESS_INPUT.test(raw)) {\n return errorResult(\n 'invalid_address: address is required: a token contract or a wallet, 0x plus 40 hex characters. ' +\n 'A ticker or a name is not an address: call meta_token_lookup first.'\n )\n }\n const address = raw.toLowerCase()\n\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n return errorResult(\n `No deployer screen read was sent: ${unavailable} There is no answer yet, which is not \"not found\": try again later.`\n )\n }\n\n // The lane's shape first: a read that fails keeps the reads of 0.82.0.\n let shape: SwapLinkShape = 'route'\n if (deps.linkShape) {\n try {\n shape = await deps.linkShape(network)\n } catch {\n shape = 'route'\n }\n }\n\n let answer: GraphAnswer\n try {\n answer = await deps.graphQueryBatch({ network, queries: deployerScreenQueries(address, shape) })\n } catch (err) {\n return errorResult(\n `The deployer screen read failed: ${deps.describeFailure(err)} This is not \"not found\": send the same screen again once.`\n )\n }\n const members = membersOf(answer)\n if (members.size === 0) {\n const text = answer.isError === true ? refusalOf(answer).text : 'the batch answer held no reads'\n return errorResult(`The deployer screen read failed: ${text} This is not \"not found\".`)\n }\n const screen = screenFromMembers(network, address, members)\n if ('failure' in screen) {\n return errorResult(\n `The deployer screen read failed: ${screen.failure} This is not \"not found\": send the same screen again once.`\n )\n }\n return textResult(screen.result)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,2BAA2B;AACxC,MAAa,6BAA6B;AAC1C,MAAa,4BAA4B;AACzC,MAAa,kCACX;AAUF,MAAa,kCAAkC;CAC7C,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;;AAIA,MAAa,cAAc;CAAC;CAAkB;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;CAC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a,QACf,OAAO,YACL,oCAAoC,OAAO,QAAQ,2DACrD;CAEF,OAAO,WAAW,OAAO,MAAM;AACjC"}
@@ -14,8 +14,14 @@ const SELLER = "<seller address>";
14
14
  const DAY = "<YYYY-MM-DD>";
15
15
  const TX = "<tx_id>";
16
16
  const TOKEN = "<launched token address>";
17
- /** The pools one factory deployed, by lifetime volume (R3). */
18
- function poolsByFactoryQuery(factory, limit = 10) {
17
+ /**
18
+ * The pools one factory deployed, ranked (R3). On the graph of before, by the
19
+ * pool's lifetime volume. On a lane with the levels a pool has no address
20
+ * totals (its transactions are not on FLOWED_TO), so the pools are ranked by
21
+ * the USD sold into each on its SWAPPED links (R3L).
22
+ */
23
+ function poolsByFactoryQuery(factory, limit = 10, shape = "route") {
24
+ if (shape === "levels") return `USE topology MATCH (f:Address {address: "${factory}"})-[:DEPLOYED_CONTRACT]->(p:Pool) MATCH (t:Address)-[s:SWAPPED]->(p) RETURN f.address AS from_address, p.address AS to_address, p.labels AS to_labels, sum(s.sold_usd) AS swapped_usd, sum(s.swap_count) AS swap_count ORDER BY swapped_usd DESC LIMIT ${limit}`;
19
25
  return `USE topology MATCH (f:Address {address: "${factory}"})-[:DEPLOYED_CONTRACT]->(p:Pool) WHERE p.total_volume_usd IS NOT NULL RETURN f.address AS from_address, p.address AS to_address, p.labels AS to_labels, p.total_volume_usd AS total_volume_usd, p.tx_total_count AS tx_total_count ORDER BY p.total_volume_usd DESC LIMIT ${limit}`;
20
26
  }
21
27
  /** The senders of one pool on FLOWED_TO, by lifetime volume (R4, G1). */
@@ -62,12 +68,18 @@ const dayStep = {
62
68
  function startPool(entry, topPool) {
63
69
  return topPool ?? entry.example_pool ?? null;
64
70
  }
65
- function poolsStep(entry) {
71
+ function poolsStep(entry, shape = "route") {
66
72
  const factory = entry.factories.find((address) => entry.roles[address] === "factory");
67
73
  if (!factory) return null;
74
+ const members = entry.factories.filter((a) => entry.roles[a] === "factory").join(", ");
75
+ if (shape === "levels") return {
76
+ step: "Pools of the exchange, by factory",
77
+ why: `The pools ${entry.display} deployed, by the USD sold into each on its SWAPPED links, with its swap count. A pool has no address totals on this lane. A pool nobody swapped in is left out. One batch member per factory: ${members}.`,
78
+ query: poolsByFactoryQuery(factory, 10, "levels")
79
+ };
68
80
  return {
69
81
  step: "Pools of the exchange, by factory",
70
- why: `The pools ${entry.display} deployed, by lifetime volume. One batch member per factory: ${entry.factories.filter((a) => entry.roles[a] === "factory").join(", ")}.`,
82
+ why: `The pools ${entry.display} deployed, by lifetime volume. One batch member per factory: ${members}.`,
71
83
  query: poolsByFactoryQuery(factory)
72
84
  };
73
85
  }
@@ -99,7 +111,7 @@ function levelsRecipeFor(entry, topPool) {
99
111
  const router = entry.routers[0];
100
112
  if (pool) steps.push(poolTraders(pool));
101
113
  else {
102
- const pools = poolsStep(entry);
114
+ const pools = poolsStep(entry, "levels");
103
115
  if (pools) steps.push(pools);
104
116
  }
105
117
  steps.push(routesStep);
@@ -156,7 +168,7 @@ function levelsRecipeFor(entry, topPool) {
156
168
  case "plain":
157
169
  if (pool) steps.push(poolTraders(pool));
158
170
  else {
159
- const pools = poolsStep(entry);
171
+ const pools = poolsStep(entry, "levels");
160
172
  if (pools) steps.push(pools);
161
173
  }
162
174
  steps.push(routesStep);
@@ -289,6 +301,8 @@ function routeRecipeFor(entry, topPool) {
289
301
  * meta_network_capabilities): on a lane whose money family lists ROUTED_TO the
290
302
  * reads name SWAPPED from a trader to the pool and ROUTED_TO for the route; on
291
303
  * any other lane they are the reads of chain-insights 0.81.0, byte for byte.
304
+ * The pool read follows the shape too: on a lane with the levels a pool has no
305
+ * address totals, so its pools are ranked by the USD sold into each on SWAPPED.
292
306
  */
293
307
  var dex_tool_exports = /* @__PURE__ */ __exportAll({
294
308
  META_DEX_LOOKUP_DESCRIPTION: () => META_DEX_LOOKUP_DESCRIPTION,
@@ -299,7 +313,7 @@ var dex_tool_exports = /* @__PURE__ */ __exportAll({
299
313
  const META_DEX_LOOKUP_TOOL = "meta_dex_lookup";
300
314
  const META_DEX_LOOKUP_SCHEMA = "chain-insights.meta-dex-lookup.v1";
301
315
  const META_DEX_LOOKUP_TITLE = "Exchange by name or address";
302
- const META_DEX_LOOKUP_DESCRIPTION = `Call this first when a question names a decentralized exchange, a launchpad or a vault (Aero, Aerodrome, Velodrome, up., Raphael, Topaz, Uniswap, PancakeSwap, Balancer, Curve, Penguin, Virtuals, ...) and gives no address. It turns the name into the exchange's factories, routers or pool manager, its biggest pools, and the first reads to send, with every address in full. A misspelling within two letters is taken and named in took_for. When matched is null the name is not covered: say so, list covered, and send no graph query for the name. Never ask the user for a pool, factory or router address. When the user gives a contract address instead of a name, send it as address (0x plus 40 hex, any case, with no name): the answer is the exchange whose factory, router or manager it is, and took_for names the role it holds. When matched is null no exchange row holds the address: send no read for it. A centralized exchange (Binance, OKX, Bitget) goes to meta_exchange_lookup instead. Give a name or an address, not both. ${LEVEL_RULE} The first reads follow the lane: where it serves ROUTED_TO, the traders of a pool are its SWAPPED links and the route of a trader is ROUTED_TO.`;
316
+ const META_DEX_LOOKUP_DESCRIPTION = `Call this first when a question names a decentralized exchange, a launchpad or a vault (Aero, Aerodrome, Velodrome, up., Raphael, Topaz, Uniswap, PancakeSwap, Balancer, Curve, Penguin, Virtuals, ...) and gives no address. It turns the name into the exchange's factories, routers or pool manager, its biggest pools, and the first reads to send, with every address in full. A misspelling within two letters is taken and named in took_for. When matched is null the name is not covered: say so, list covered, and send no graph query for the name. Never ask the user for a pool, factory or router address. When the user gives a contract address instead of a name, send it as address (0x plus 40 hex, any case, with no name): the answer is the exchange whose factory, router or manager it is, and took_for names the role it holds. When matched is null no exchange row holds the address: send no read for it. A centralized exchange (Binance, OKX, Bitget) goes to meta_exchange_lookup instead. Give a name or an address, not both. ${LEVEL_RULE} The first reads follow the lane: where it serves ROUTED_TO, the traders of a pool are its SWAPPED links and the route of a trader is ROUTED_TO. There each pool carries swapped_usd (the USD sold into it on its SWAPPED links) and swap_count, in place of total_volume_usd and tx_total_count.`;
303
317
  const META_DEX_LOOKUP_ANNOTATIONS = {
304
318
  readOnlyHint: true,
305
319
  idempotentHint: true,
@@ -349,7 +363,7 @@ function contractListQuery(addresses) {
349
363
  return `USE topology MATCH (a:Address) WHERE a.address IN [${addresses.map((a) => `"${a}"`).join(", ")}] RETURN a.address AS address, labels(a) AS node_labels, a.labels AS labels, a.is_contract AS is_contract LIMIT ${addresses.length}`;
350
364
  }
351
365
  /** The anchored reads of one exchange: Head, each contract, and the pools of each factory. */
352
- function lookupQueries(entry, pools) {
366
+ function lookupQueries(entry, pools, shape = "route") {
353
367
  const contracts = Object.keys(entry.roles);
354
368
  const queries = [{
355
369
  id: "head",
@@ -365,7 +379,7 @@ function lookupQueries(entry, pools) {
365
379
  });
366
380
  if (pools) for (const factory of entry.factories.filter((address) => entry.roles[address] === "factory")) queries.push({
367
381
  id: `pools:${factory}`,
368
- query: poolsByFactoryQuery(factory, POOLS_LIMIT)
382
+ query: poolsByFactoryQuery(factory, POOLS_LIMIT, shape)
369
383
  });
370
384
  return queries;
371
385
  }
@@ -381,7 +395,35 @@ function confirmation(row) {
381
395
  };
382
396
  return { confirmed: false };
383
397
  }
384
- function readMatch(entry, members, read) {
398
+ /** The pools of the batch, merged over the factories and ranked by the shape's number. */
399
+ function readPools(members, shape) {
400
+ const byAddress = /* @__PURE__ */ new Map();
401
+ for (const [id, member] of members) {
402
+ if (!id.startsWith("pools:")) continue;
403
+ for (const row of rowsOf(member)) {
404
+ const address = typeof row.to_address === "string" ? row.to_address : null;
405
+ const rank = numberOrNull(shape === "levels" ? row.swapped_usd : row.total_volume_usd);
406
+ if (!address || rank === null || byAddress.has(address)) continue;
407
+ const labels = stringList(row.to_labels);
408
+ byAddress.set(address, {
409
+ rank,
410
+ row: shape === "levels" ? {
411
+ address,
412
+ labels,
413
+ swapped_usd: rank,
414
+ swap_count: numberOrNull(row.swap_count) ?? 0
415
+ } : {
416
+ address,
417
+ labels,
418
+ total_volume_usd: rank,
419
+ tx_total_count: numberOrNull(row.tx_total_count) ?? 0
420
+ }
421
+ });
422
+ }
423
+ }
424
+ return [...byAddress.values()].sort((a, b) => b.rank - a.rank).slice(0, POOLS_LIMIT).map(({ row }) => row);
425
+ }
426
+ function readMatch(entry, members, read, shape) {
385
427
  const notes = [];
386
428
  const contracts = /* @__PURE__ */ new Map();
387
429
  const listed = new Map(rowsOf(members.get("contracts")).map((row) => [String(row.address), row]));
@@ -393,22 +435,7 @@ function readMatch(entry, members, read) {
393
435
  ...confirmation(row)
394
436
  });
395
437
  }
396
- const byAddress = /* @__PURE__ */ new Map();
397
- for (const [id, member] of members) {
398
- if (!id.startsWith("pools:")) continue;
399
- for (const row of rowsOf(member)) {
400
- const address = typeof row.to_address === "string" ? row.to_address : null;
401
- const volume = numberOrNull(row.total_volume_usd);
402
- if (!address || volume === null || byAddress.has(address)) continue;
403
- byAddress.set(address, {
404
- address,
405
- labels: stringList(row.to_labels),
406
- total_volume_usd: volume,
407
- tx_total_count: numberOrNull(row.tx_total_count) ?? 0
408
- });
409
- }
410
- }
411
- const pools = [...byAddress.values()].sort((a, b) => b.total_volume_usd - a.total_volume_usd).slice(0, POOLS_LIMIT);
438
+ const pools = readPools(members, shape);
412
439
  const head = rowsOf(members.get("head"))[0];
413
440
  const families = head ? {
414
441
  behind_money: numberOrNull(column(head, "behind_money", "h")),
@@ -427,7 +454,7 @@ function readMatch(entry, members, read) {
427
454
  }
428
455
  const ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/;
429
456
  /** The hint's last rule on a lane with the levels; the graph of before keeps its 0.81.0 text. */
430
- const LEVELS_HINT = `${LEVEL_RULE} Read families before a whole-chain SWAPPED search: it is sent when behind_dex is at most 100000, and a ROUTED_TO search when behind_money is. Never ask the user for an address.`;
457
+ const LEVELS_HINT = `${LEVEL_RULE} Each pool carries swapped_usd, the USD sold into it on its SWAPPED links, and swap_count, its swaps: say "tokens worth about N USD sold into the pool", never its lifetime volume. Read families before a whole-chain SWAPPED search: it is sent when behind_dex is at most 100000, and a ROUTED_TO search when behind_money is. Never ask the user for an address.`;
431
458
  const ROUTE_HINT = "Read families before a SWAPPED search: it is sent when behind_dex is at most 100000. Never ask the user for an address.";
432
459
  function hintFor(result, name, address = null) {
433
460
  const closing = result.swap_links === "levels" ? LEVELS_HINT : ROUTE_HINT;
@@ -536,10 +563,16 @@ async function handleMetaDexLookup(args, deps) {
536
563
  });
537
564
  }
538
565
  const entry = match.matched;
539
- const queries = lookupQueries(entry, pools);
566
+ const unavailable = await deps.unavailable?.();
567
+ let shape = "route";
568
+ if (!unavailable && deps.linkShape) try {
569
+ shape = await deps.linkShape(network);
570
+ } catch {
571
+ shape = "route";
572
+ }
573
+ const queries = lookupQueries(entry, pools, shape);
540
574
  let members = /* @__PURE__ */ new Map();
541
575
  const notes = [];
542
- const unavailable = await deps.unavailable?.();
543
576
  if (unavailable) notes.push(`No graph read was sent: ${unavailable} The contracts are the reviewed registry rows, not yet confirmed on the graph.`);
544
577
  else try {
545
578
  const answer = await deps.graphQueryBatch({
@@ -554,13 +587,7 @@ async function handleMetaDexLookup(args, deps) {
554
587
  } catch (err) {
555
588
  notes.push(`The graph reads failed: ${deps.describeFailure(err)}`);
556
589
  }
557
- let shape = "route";
558
- if (!unavailable && deps.linkShape) try {
559
- shape = await deps.linkShape(network);
560
- } catch {
561
- shape = "route";
562
- }
563
- const read = readMatch(entry, members, members.size > 0);
590
+ const read = readMatch(entry, members, members.size > 0, shape);
564
591
  notes.push(...read.notes);
565
592
  const contractsOf = (role) => [...read.contracts.values()].filter((contract) => contract.role === role);
566
593
  const topPool = read.pools[0]?.address ?? null;
@@ -592,4 +619,4 @@ async function handleMetaDexLookup(args, deps) {
592
619
  }
593
620
  export { dex_tool_exports as a, META_DEX_LOOKUP_TOOL as i, META_DEX_LOOKUP_DESCRIPTION as n, handleMetaDexLookup as o, META_DEX_LOOKUP_TITLE as r, META_DEX_LOOKUP_ANNOTATIONS as t };
594
621
 
595
- //# sourceMappingURL=dex-tool-DW_hT1Z1.mjs.map
622
+ //# sourceMappingURL=dex-tool-25510SNo.mjs.map