chain-insights 0.74.1 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/{action-log-D49Par9P.mjs → action-log-Byv9Ln_6.mjs} +4 -10
- package/dist/{action-log-D49Par9P.mjs.map → action-log-Byv9Ln_6.mjs.map} +1 -1
- package/dist/{action-log-HniMMF7f.cjs → action-log-WMW6xFMx.cjs} +3 -9
- package/dist/{active-Dkf8AB1R.mjs → active-D2aabYRF.mjs} +3 -4
- package/dist/{active-Dkf8AB1R.mjs.map → active-D2aabYRF.mjs.map} +1 -1
- package/dist/{active-Bc13hJIm.cjs → active-q3yViZhc.cjs} +2 -3
- package/dist/answer-hint-BlYEBq_Y.cjs +57 -0
- package/dist/answer-hint-vOE1O6Lf.mjs +48 -0
- package/dist/answer-hint-vOE1O6Lf.mjs.map +1 -0
- package/dist/{buy-_mpdRieG.mjs → buy-B2luUbWF.mjs} +5 -6
- package/dist/{buy-_mpdRieG.mjs.map → buy-B2luUbWF.mjs.map} +1 -1
- package/dist/{buy-97M6dtEu.cjs → buy-DEoGITbT.cjs} +4 -5
- package/dist/{cache-location-CBVzUIxq.cjs → cache-location-C09AE55j.cjs} +2 -3
- package/dist/{cache-location-BO2XkfgI.mjs → cache-location-DxTTqBwk.mjs} +2 -3
- package/dist/{cache-location-BO2XkfgI.mjs.map → cache-location-DxTTqBwk.mjs.map} +1 -1
- package/dist/{call-args-B0oMK1-J.mjs → call-args-CBqbYfOE.mjs} +15 -4
- package/dist/{call-args-B0oMK1-J.mjs.map → call-args-CBqbYfOE.mjs.map} +1 -1
- package/dist/{call-args-C8Gp5gco.cjs → call-args-DXEmPeE-.cjs} +14 -2
- package/dist/{capabilities-DxojbX4D.mjs → capabilities-BRNHcabF.mjs} +5 -11
- package/dist/{capabilities-DxojbX4D.mjs.map → capabilities-BRNHcabF.mjs.map} +1 -1
- package/dist/{capabilities-Ds3320iS.cjs → capabilities-DalimVY2.cjs} +4 -10
- package/dist/{claude-desktop-Jmm4PlBZ.cjs → claude-desktop-3OksQZVE.cjs} +2 -3
- package/dist/{claude-desktop-6jwX0Lux.mjs → claude-desktop-C1SDYAP2.mjs} +2 -3
- package/dist/{claude-desktop-6jwX0Lux.mjs.map → claude-desktop-C1SDYAP2.mjs.map} +1 -1
- package/dist/cli.cjs +95 -76
- package/dist/cli.mjs +94 -75
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-7qOfAdpH.mjs → client-BaHAIidE.mjs} +10 -21
- package/dist/{client-7qOfAdpH.mjs.map → client-BaHAIidE.mjs.map} +1 -1
- package/dist/{client-C9uwHnBS.cjs → client-Ddk4X9Ko.cjs} +9 -20
- package/dist/{config-BxtMoo9c.cjs → config-BdE8LcF-.cjs} +3 -5
- package/dist/{config-9MabJh5R.mjs → config-BkLIqOYq.mjs} +4 -6
- package/dist/{config-9MabJh5R.mjs.map → config-BkLIqOYq.mjs.map} +1 -1
- package/dist/{create-CpfZq2fx.mjs → create-CluDZkuF.mjs} +3 -4
- package/dist/{create-CpfZq2fx.mjs.map → create-CluDZkuF.mjs.map} +1 -1
- package/dist/{create-DdggkF04.cjs → create-DvBumvHn.cjs} +2 -3
- package/dist/{dex-registry-Chs79Ukc.cjs → dex-registry-CZQB2YhU.cjs} +4 -26
- package/dist/{dex-registry-rziydXYq.mjs → dex-registry-D6Xxi_vr.mjs} +5 -27
- package/dist/{dex-registry-rziydXYq.mjs.map → dex-registry-D6Xxi_vr.mjs.map} +1 -1
- package/dist/{dex-tool-DsaAIa-a.mjs → dex-tool-BoAYqhZO.mjs} +13 -67
- package/dist/dex-tool-BoAYqhZO.mjs.map +1 -0
- package/dist/{dex-tool-DLWnff1n.cjs → dex-tool-DsM-pSku.cjs} +17 -77
- package/dist/{format-CSesEBvS.mjs → format-CsnW5M4D.mjs} +2 -3
- package/dist/{format-CSesEBvS.mjs.map → format-CsnW5M4D.mjs.map} +1 -1
- package/dist/{format-DfhRQq4L.cjs → format-DUzmoeaE.cjs} +1 -2
- package/dist/{graph-schema-BGbJumCY.cjs → graph-schema-C8Pi6r7c.cjs} +12 -29
- package/dist/{graph-schema-ClqjzgrM.mjs → graph-schema-D4LAefGf.mjs} +13 -30
- package/dist/graph-schema-D4LAefGf.mjs.map +1 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +0 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/{known-keys-B87ZqOgE.mjs → known-keys-BbuzCZOW.mjs} +4 -7
- package/dist/{known-keys-B87ZqOgE.mjs.map → known-keys-BbuzCZOW.mjs.map} +1 -1
- package/dist/{known-keys-PKZF5GYd.cjs → known-keys-Cy8lKDOA.cjs} +3 -6
- package/dist/mcp-proxy.cjs +83 -57
- package/dist/mcp-proxy.d.cts +2 -2
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts +2 -2
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +81 -56
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/{print-result-Cyqrlx8P.cjs → print-result-BYppJlUi.cjs} +20 -20
- package/dist/{print-result-C3YazZBw.mjs → print-result-IFARsMnL.mjs} +10 -22
- package/dist/print-result-IFARsMnL.mjs.map +1 -0
- package/dist/{public-tools-Bl_l_rKK.cjs → public-tools-Cfc1OPNS.cjs} +16 -21
- package/dist/{public-tools-CQjGt7_q.mjs → public-tools-DXlZcanX.mjs} +16 -21
- package/dist/public-tools-DXlZcanX.mjs.map +1 -0
- package/dist/{quote-DfTut0cx.mjs → quote-41CbMc37.mjs} +2 -3
- package/dist/{quote-DfTut0cx.mjs.map → quote-41CbMc37.mjs.map} +1 -1
- package/dist/{quote-B9sYNOiv.cjs → quote-pFKcSvMv.cjs} +1 -2
- package/dist/{request-timeout-CYmQF8N7.cjs → request-timeout-DxwNijQD.cjs} +1 -2
- package/dist/{request-timeout-lBBe0mGf.mjs → request-timeout-K3ljP0pa.mjs} +2 -3
- package/dist/{request-timeout-lBBe0mGf.mjs.map → request-timeout-K3ljP0pa.mjs.map} +1 -1
- package/dist/{robinhood-CCTMagwM.mjs → robinhood-0NZsA6ZW.mjs} +2 -3
- package/dist/robinhood-0NZsA6ZW.mjs.map +1 -0
- package/dist/{robinhood-ChiT69sc.cjs → robinhood-DumTxvlA.cjs} +1 -2
- package/dist/{rolldown-runtime-8H4AJuhK.mjs → rolldown-runtime-BJohB4LM.mjs} +1 -2
- package/dist/{rolldown-runtime-C0BPl7ul.cjs → rolldown-runtime-BW-eSwOZ.cjs} +1 -2
- package/dist/{rules-BWdbOtHi.mjs → rules-B3w9pCeQ.mjs} +2 -3
- package/dist/{rules-BWdbOtHi.mjs.map → rules-B3w9pCeQ.mjs.map} +1 -1
- package/dist/{rules-BD-cNHMX.cjs → rules-BKwfmNsJ.cjs} +1 -2
- package/dist/{schema-KjZqCHbu.mjs → schema-CKnQsdw9.mjs} +6 -13
- package/dist/{schema-KjZqCHbu.mjs.map → schema-CKnQsdw9.mjs.map} +1 -1
- package/dist/{schema-tX0U0-VI.cjs → schema-CSESfCvA.cjs} +5 -12
- package/dist/{schema-cache-DRObKUvS.mjs → schema-cache-BfKHodDY.mjs} +3 -4
- package/dist/{schema-cache-DRObKUvS.mjs.map → schema-cache-BfKHodDY.mjs.map} +1 -1
- package/dist/{schema-cache-C7v9ml6S.cjs → schema-cache-NLgJmh4X.cjs} +3 -4
- package/dist/{skill-refresh-xYWZ_hua.mjs → skill-refresh-BchIsODN.mjs} +2 -3
- package/dist/{skill-refresh-xYWZ_hua.mjs.map → skill-refresh-BchIsODN.mjs.map} +1 -1
- package/dist/{skill-refresh-Be2D5FrX.cjs → skill-refresh-DaCTxhhy.cjs} +2 -3
- package/dist/{subscription-status-DIuH84fM.mjs → subscription-status-5WfPhSep.mjs} +3 -4
- package/dist/{subscription-status-DIuH84fM.mjs.map → subscription-status-5WfPhSep.mjs.map} +1 -1
- package/dist/{subscription-status-9tMfD90J.cjs → subscription-status-w4zI2KCK.cjs} +2 -3
- package/dist/token-lookup-BJ00JO9A.cjs +342 -0
- package/dist/token-lookup-XnyisLQW.mjs +303 -0
- package/dist/token-lookup-XnyisLQW.mjs.map +1 -0
- package/dist/{tool-visibility-BNwvcuVx.cjs → tool-visibility-DIpgPULN.cjs} +5 -10
- package/dist/{tool-visibility-B6983rxo.mjs → tool-visibility-Dy3psowS.mjs} +6 -11
- package/dist/tool-visibility-Dy3psowS.mjs.map +1 -0
- package/dist/{tools-D9ep9E7Q.mjs → tools-6pZo4h_p.mjs} +6 -21
- package/dist/{tools-D9ep9E7Q.mjs.map → tools-6pZo4h_p.mjs.map} +1 -1
- package/dist/{tools-Cmnq7yip.cjs → tools-DZLizem9.cjs} +5 -20
- package/dist/{topup-B6gZbTmv.mjs → topup--7JTo4UQ.mjs} +6 -7
- package/dist/{topup-B6gZbTmv.mjs.map → topup--7JTo4UQ.mjs.map} +1 -1
- package/dist/{topup-DVTCU2le.cjs → topup-BgI9OcUd.cjs} +5 -6
- package/dist/{topup-server-ShuYSyBY.cjs → topup-server-D9Uk1Th3.cjs} +7 -24
- package/dist/{topup-server-KQDviFXG.mjs → topup-server-DR0HaUcR.mjs} +8 -25
- package/dist/{topup-server-KQDviFXG.mjs.map → topup-server-DR0HaUcR.mjs.map} +1 -1
- package/dist/{topup-server-BcT7DIpd.mjs → topup-server-DlwzFEF1.mjs} +5 -12
- package/dist/{topup-server-BcT7DIpd.mjs.map → topup-server-DlwzFEF1.mjs.map} +1 -1
- package/dist/{topup-server-f4Gx0vji.cjs → topup-server-H1M_7PJK.cjs} +4 -11
- package/dist/{transport-error-D4hmpkqL.mjs → transport-error-68G35VPH.mjs} +3 -4
- package/dist/{transport-error-D4hmpkqL.mjs.map → transport-error-68G35VPH.mjs.map} +1 -1
- package/dist/{transport-error-CgISST8l.cjs → transport-error-DXy1iTpS.cjs} +2 -3
- package/dist/{update-CZDHSi_u.mjs → update-BH8F4cQ2.mjs} +3 -4
- package/dist/{update-CZDHSi_u.mjs.map → update-BH8F4cQ2.mjs.map} +1 -1
- package/dist/{update-DGyRlm3J.cjs → update-DUDdQSEU.cjs} +2 -3
- package/dist/{usage-status-Frot6fPG.mjs → usage-status-BUZgRl4r.mjs} +3 -5
- package/dist/{usage-status-Frot6fPG.mjs.map → usage-status-BUZgRl4r.mjs.map} +1 -1
- package/dist/{usage-status-DonwoLR3.cjs → usage-status-DnV3I3gX.cjs} +2 -4
- package/dist/{wallet-QTo5YCFR.mjs → wallet-B1M0HdQh.mjs} +4 -8
- package/dist/{wallet-QTo5YCFR.mjs.map → wallet-B1M0HdQh.mjs.map} +1 -1
- package/dist/{wallet-CgIAfdxL.cjs → wallet-BubGd_sG.cjs} +3 -7
- package/docs/graph-query-compatibility.md +13 -13
- package/docs/graph-tools.md +22 -22
- package/docs/mcp-proxy.md +35 -1
- package/docs/stability.md +3 -2
- package/package.json +1 -1
- package/skills/chain-insights-cypher/SKILL.md +30 -27
- package/skills/chain-insights-dex/SKILL.md +2 -2
- package/skills/chain-insights-dex/reference.md +1 -1
- package/skills/chain-insights-dex-gauge/SKILL.md +4 -4
- package/skills/chain-insights-dex-launchpad/SKILL.md +2 -2
- package/skills/chain-insights-virtuals/reference.md +5 -5
- package/dist/dex-tool-DsaAIa-a.mjs.map +0 -1
- package/dist/graph-schema-ClqjzgrM.mjs.map +0 -1
- package/dist/print-result-C3YazZBw.mjs.map +0 -1
- package/dist/public-tools-CQjGt7_q.mjs.map +0 -1
- package/dist/robinhood-CCTMagwM.mjs.map +0 -1
- package/dist/tool-visibility-B6983rxo.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -121,20 +121,20 @@ Route by what the question names: an address, a pair with a day, a transaction o
|
|
|
121
121
|
`USE chain` with `Address` reads the balance, the nonce or the kind of one address, now or at a past block with `at_block`. A past block must be at least `chain_admission.at_block_min_depth` blocks below the tip. To find the counterparties of an address, search `USE topology`, then read the pair and one day on `USE facts`.
|
|
122
122
|
A transaction is a chain question: read it on `USE chain` by its `tx_id`. Chain gives its `block_date`; the transfers between a pair on that day are a `USE facts` read. "Every token that moved inside this transaction": read the chain record for `from_address`, `to_address` and `block_date`, then the facts `TRANSFER` rows of that pair on that day and keep the rows whose `tx_id` matches; a `kind` of `internal` is ETH a contract moved while it ran. Tokens the transaction moved between other pairs are not reachable from the hash alone: say so, and name the pairs you did read.
|
|
123
123
|
The layers hand each other keys, and each key keeps its name. Topology gives the pair and the first and last seen time. Facts gives the `tx_id` and the `block_height`. Chain takes an `address`, a `tx_id`, a `block_height` or a `block_hash`, and gives the `block_date` of a transaction or a block.
|
|
124
|
-
A question about the whole chain (recent activity, the biggest senders, a top list) is a `USE topology` search: bound it by time with `f.last_seen_timestamp >= <epoch ms>` on the `
|
|
124
|
+
A question about the whole chain (recent activity, the biggest senders, a top list) is a `USE topology` search: bound it by time with `f.last_seen_timestamp >= <epoch ms>` on the `FLOWED_TO` link, then sort and `LIMIT`. A search has 10 s. Read `Head` first (`USE chain MATCH (h:Head) RETURN h.behind_money, h.behind_dex, h.behind_transfers`, under a second): a `FLOWED_TO` search is sent when `behind_money` is at most 100000; a `SWAPPED`, `ADDED_LIQUIDITY` or `REMOVED_LIQUIDITY` search when `behind_dex` is at most 100000; a `TRANSFERRED` search when `behind_transfers` is at most 100000 (100000 blocks is a few hours: a robinhood block is about a tenth of a second apart from the next). When the family is further behind, the search cannot finish, so do not send it: say which family, how many blocks, and ask for an address. On a server whose Head has no `behind_money`, read `h.graph_blocks_behind` and hold it to the same limit. On a server whose Head has no `behind_transfers`, it serves no `TRANSFERRED` link: send no `TRANSFERRED` search. Never turn the block count into days or hours by head. To say how fresh the data is, give the newest `_utc` time you read on the layer you used: a family's lag counts its slowest layer, and the links of an address and the facts rows are often newer than it. If the server refuses the search with `anchor_missing` or `family_behind`, or stops it with `query_timeout`, it cannot search the whole chain now: say so in one line, name the family the refusal names, and ask for an address or drop the link type that is behind. A narrower window times out the same way, so do not send it again.
|
|
125
125
|
|
|
126
126
|
The graph's layers are grouped into six families, and a family is as fresh as its slowest layer. The family of a link type decides which `Head` lag a whole-chain search on it waits for.
|
|
127
127
|
|
|
128
128
|
| Family | Layers | Link types | `Head` property |
|
|
129
129
|
| ---------------- | ---------------------------------------------- | ------------------------------------------------------------- | ----------------------- |
|
|
130
|
-
| money | `flows`, `operated_by` | `
|
|
130
|
+
| money | `flows`, `operated_by` | `FLOWED_TO`, `OPERATED_BY` | `behind_money` |
|
|
131
131
|
| dex | `dex_swaps`, `dex_liquidity`, `dex_pools` | `SWAPPED`, `ADDED_LIQUIDITY`, `REMOVED_LIQUIDITY` | `behind_dex` |
|
|
132
132
|
| interactions | `approvals`, `bridged`, `contracts`, `authorization` | `APPROVED`, `BRIDGED`, `DEPLOYED_CONTRACT`, `SIGNED_AUTHORIZATION` | `behind_interactions` |
|
|
133
133
|
| smart_accounts | `sponsored`, `bundled`, `signers`, `owners` | `SPONSORED`, `BUNDLED`, `SIGNED_FOR`, `LINKED` | `behind_smart_accounts` |
|
|
134
134
|
| annotations | `labels`, `ml`, `inferred`, `kinds`, `assets` | none | `annotations_fresh` |
|
|
135
135
|
| transfers | `transfers_by_asset` | `TRANSFERRED` | `behind_transfers` |
|
|
136
136
|
|
|
137
|
-
`transfers` is its own family: a `
|
|
137
|
+
`transfers` is its own family: a `FLOWED_TO` search never waits for it, and a `TRANSFERRED` search never waits for `money`.
|
|
138
138
|
|
|
139
139
|
Find the question in this table. Send its first query, once, with the addresses the user gave.
|
|
140
140
|
|
|
@@ -156,6 +156,7 @@ Find the question in this table. Send its first query, once, with the addresses
|
|
|
156
156
|
| Which tokens moved between two addresses? | `topology` | `TRANSFERRED` of the pair, one link per token (see Tokens) |
|
|
157
157
|
| Where did one token go, or come from, in N hops? | `topology` | The guarded walk on `TRANSFERRED` with one `asset` (see Tokens) |
|
|
158
158
|
| The biggest receivers of one token in a window | `topology` | `TRANSFERRED` with one `asset` and `last_seen_timestamp` (see Tokens) |
|
|
159
|
+
| The user names a token by its ticker or name, no contract | none | Call `meta_token_lookup {network, symbol}` first; several candidates are clones, name them and ask |
|
|
159
160
|
| What fields does an Address have? | none | Call `meta_schema {network}`. Send no query. |
|
|
160
161
|
| Recent addresses, biggest senders, any top list of the chain | topology | A search bounded by `f.last_seen_timestamp`, then sort and LIMIT (below). |
|
|
161
162
|
|
|
@@ -166,13 +167,13 @@ A link's `amount_usd_sum` and `tx_count` are the pair's lifetime totals. The tim
|
|
|
166
167
|
Recent activity, newest first:
|
|
167
168
|
|
|
168
169
|
```cypher
|
|
169
|
-
USE topology MATCH (a:Address)-[f:
|
|
170
|
+
USE topology MATCH (a:Address)-[f:FLOWED_TO]->(b:Address) WHERE f.last_seen_timestamp >= 1791244800000 RETURN a.address AS from_address, b.address AS to_address, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, a.labels AS from_labels, b.labels AS to_labels, a.is_exchange AS from_is_exchange, b.is_exchange AS to_is_exchange ORDER BY f.last_seen_timestamp DESC LIMIT 25
|
|
170
171
|
```
|
|
171
172
|
|
|
172
173
|
The biggest senders of the period:
|
|
173
174
|
|
|
174
175
|
```cypher
|
|
175
|
-
USE topology MATCH (a:Address)-[f:
|
|
176
|
+
USE topology MATCH (a:Address)-[f:FLOWED_TO]->(b:Address) WHERE f.last_seen_timestamp >= 1791244800000 RETURN a.address AS sender, sum(f.amount_usd_sum) AS sent_usd, count(*) AS links ORDER BY sent_usd DESC LIMIT 10
|
|
176
177
|
```
|
|
177
178
|
|
|
178
179
|
If the server answers `anchor_missing`, or `query_timeout` on a search bounded only by time, it cannot search the whole chain now. Say: "This server cannot search the whole chain right now. Give me an address, a pair with a day, or a transaction hash." Send no narrower window: it times out the same way, and each try costs the user 10 seconds. If it answers `family_behind`, the refusal names the family that is behind and its link types: drop the link type the server names, or give an address.
|
|
@@ -267,17 +268,17 @@ How to answer:
|
|
|
267
268
|
|
|
268
269
|
## Topology
|
|
269
270
|
|
|
270
|
-
`USE topology` is the address graph: `
|
|
271
|
+
`USE topology` is the address graph: `FLOWED_TO` money flow, swaps, liquidity,
|
|
271
272
|
bridges and the `LINKED` overlay. The server checks these before it runs:
|
|
272
273
|
|
|
273
274
|
- Anchor every pattern on a full address: `{address: "<address>"}` in the node, or `WHERE a.address = "<address>"`. A list of at most 25 addresses is an anchor. An address in `RETURN`, in an `OR` or in a `$parameter` is no anchor.
|
|
274
275
|
- The one read with no anchor is a probe: one node or one hop, no `WHERE`, no `ORDER BY`, no aggregate, and a small `LIMIT`. Its rows are arbitrary: never call them recent, top or biggest.
|
|
275
276
|
- A sort, an aggregate, `DISTINCT`, `collect()` or a filter on a link property needs an anchor on every pattern.
|
|
276
277
|
- End every read with a literal `LIMIT`: at most 5,000 rows, 100 for a probe. A path has at most 5 hops and a query at most 8. The live numbers are in `topology_admission` (`cia network robinhood --json`).
|
|
277
|
-
- Paths use bounded quantifiers such as `-[:
|
|
278
|
+
- Paths use bounded quantifiers such as `-[:FLOWED_TO]-{1,5}`. A `*` range, the legacy path functions, `PROFILE`, writes and `CALL` are refused.
|
|
278
279
|
- Role flags `is_exchange`, `is_scam`, `is_victim`, `is_sanctioned` and `is_issuer_frozen` are absent unless true: use `IS NULL` or `IS NOT NULL`, never `= false`.
|
|
279
280
|
- A kind label sits beside `:Address`: `WHERE a:Contract` or `WHERE a:Account` tests it, as `:Pool` is tested. It is no anchor.
|
|
280
|
-
- A `
|
|
281
|
+
- A `FLOWED_TO` read written without an arrow, `-[f:FLOWED_TO]-`, matches both directions and tells you nothing about which end sent. Return `startNode(f).address AS from_address, endNode(f).address AS to_address`, or send two directed reads, before you call either address the sender: one answer named the receiver as the sender and had to take it back.
|
|
281
282
|
|
|
282
283
|
## Graph searches
|
|
283
284
|
|
|
@@ -287,13 +288,13 @@ Newest links of one address, its receivers. Its newest senders are the same read
|
|
|
287
288
|
|
|
288
289
|
```cypher
|
|
289
290
|
USE topology
|
|
290
|
-
MATCH (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"})-[f:
|
|
291
|
+
MATCH (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"})-[f:FLOWED_TO]->(b:Address) WHERE NOT a:Pool
|
|
291
292
|
RETURN a.address AS from_address, b.address AS to_address, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, a.labels AS from_labels, b.labels AS to_labels, a.is_exchange AS from_is_exchange, b.is_exchange AS to_is_exchange ORDER BY f.last_seen_timestamp DESC LIMIT 25
|
|
292
293
|
```
|
|
293
294
|
|
|
294
295
|
```cypher
|
|
295
296
|
USE topology
|
|
296
|
-
MATCH (b:Address)-[f:
|
|
297
|
+
MATCH (b:Address)-[f:FLOWED_TO]->(a:Address {address: "0x7e3702e9dfaa847f9829a258f1e26fa431160662"}) WHERE NOT a:Pool
|
|
297
298
|
RETURN b.address AS from_address, a.address AS to_address, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, b.labels AS from_labels, a.labels AS to_labels, b.is_exchange AS from_is_exchange, a.is_exchange AS to_is_exchange ORDER BY f.last_seen_timestamp DESC LIMIT 25
|
|
298
299
|
```
|
|
299
300
|
|
|
@@ -305,10 +306,10 @@ asks for.
|
|
|
305
306
|
|
|
306
307
|
```cypher
|
|
307
308
|
USE topology
|
|
308
|
-
MATCH (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"})-[f:
|
|
309
|
+
MATCH (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"})-[f:FLOWED_TO]->(b:Address) WHERE NOT a:Pool
|
|
309
310
|
RETURN a.address AS from_address, b.address AS to_address, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, a.labels AS from_labels, b.labels AS to_labels, a.is_exchange AS from_is_exchange, b.is_exchange AS to_is_exchange ORDER BY f.last_seen_timestamp DESC LIMIT 25
|
|
310
311
|
UNION ALL
|
|
311
|
-
MATCH (c:Address)-[g:
|
|
312
|
+
MATCH (c:Address)-[g:FLOWED_TO]->(d:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"}) WHERE NOT d:Pool
|
|
312
313
|
RETURN c.address AS from_address, d.address AS to_address, g.amount_usd_sum AS amount_usd_sum, g.tx_count AS tx_count, g.first_seen_timestamp AS first_seen_timestamp, g.last_seen_timestamp AS last_seen_timestamp, c.labels AS from_labels, d.labels AS to_labels, c.is_exchange AS from_is_exchange, d.is_exchange AS to_is_exchange ORDER BY g.last_seen_timestamp DESC LIMIT 25
|
|
313
314
|
```
|
|
314
315
|
|
|
@@ -324,7 +325,7 @@ Which exchange an address cashed out to: its receivers that carry the exchange f
|
|
|
324
325
|
|
|
325
326
|
```cypher
|
|
326
327
|
USE topology
|
|
327
|
-
MATCH (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"})-[f:
|
|
328
|
+
MATCH (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"})-[f:FLOWED_TO]->(b:Address) WHERE NOT a:Pool AND b.is_exchange IS NOT NULL
|
|
328
329
|
RETURN a.address AS from_address, b.address AS to_address, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, a.labels AS from_labels, b.labels AS to_labels, a.is_exchange AS from_is_exchange, b.is_exchange AS to_is_exchange ORDER BY f.last_seen_timestamp DESC ORDER BY f.amount_usd_sum DESC LIMIT 25
|
|
329
330
|
```
|
|
330
331
|
|
|
@@ -334,7 +335,7 @@ Route between two addresses, one path. Only `MATCH SHORTEST 1` and `MATCH ANY SH
|
|
|
334
335
|
|
|
335
336
|
```cypher
|
|
336
337
|
USE topology
|
|
337
|
-
MATCH p = SHORTEST 1 (a:Address {address: "0x31a817802ee183eb8b13167ffe24bd28dcc6f30c"} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:
|
|
338
|
+
MATCH p = SHORTEST 1 (a:Address {address: "0x31a817802ee183eb8b13167ffe24bd28dcc6f30c"} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:FLOWED_TO|SWAPPED]-(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,4} ()-[:FLOWED_TO|SWAPPED]-(b:Address {address: "0x7e3702e9dfaa847f9829a258f1e26fa431160662"})
|
|
338
339
|
RETURN [n IN nodes(p) | n.address] AS route
|
|
339
340
|
LIMIT 5
|
|
340
341
|
```
|
|
@@ -343,7 +344,7 @@ Several routes, up to 3 hops, in no set order. Add no `ORDER BY`: it can end in
|
|
|
343
344
|
|
|
344
345
|
```cypher
|
|
345
346
|
USE topology
|
|
346
|
-
MATCH p = (a:Address {address: "0x31a817802ee183eb8b13167ffe24bd28dcc6f30c"} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:
|
|
347
|
+
MATCH p = (a:Address {address: "0x31a817802ee183eb8b13167ffe24bd28dcc6f30c"} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:FLOWED_TO|SWAPPED]-(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,2} ()-[:FLOWED_TO|SWAPPED]-(b:Address {address: "0x7e3702e9dfaa847f9829a258f1e26fa431160662"})
|
|
347
348
|
RETURN [n IN nodes(p) | n.address] AS route, length(p) AS hops LIMIT 5
|
|
348
349
|
```
|
|
349
350
|
|
|
@@ -351,7 +352,7 @@ Where the money went, up to 3 hops out:
|
|
|
351
352
|
|
|
352
353
|
```cypher
|
|
353
354
|
USE topology
|
|
354
|
-
MATCH p = (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:
|
|
355
|
+
MATCH p = (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:FLOWED_TO|SWAPPED]->(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,2} ()-[:FLOWED_TO|SWAPPED]->(b:Address)
|
|
355
356
|
RETURN b.address AS to_address, length(p) AS hops LIMIT 25
|
|
356
357
|
```
|
|
357
358
|
|
|
@@ -359,7 +360,7 @@ Where the money came from, up to 3 hops in:
|
|
|
359
360
|
|
|
360
361
|
```cypher
|
|
361
362
|
USE topology
|
|
362
|
-
MATCH p = (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()<-[:
|
|
363
|
+
MATCH p = (a:Address {address: "0x04911a118f11c75667e4d0dfb8e640af5a353550"} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()<-[:FLOWED_TO|SWAPPED]-(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,2} ()<-[:FLOWED_TO|SWAPPED]-(b:Address)
|
|
363
364
|
RETURN b.address AS from_address, length(p) AS hops LIMIT 25
|
|
364
365
|
```
|
|
365
366
|
|
|
@@ -367,7 +368,7 @@ Counterparties that two addresses share:
|
|
|
367
368
|
|
|
368
369
|
```cypher
|
|
369
370
|
USE topology
|
|
370
|
-
MATCH (a:Address {address: "0x7e3702e9dfaa847f9829a258f1e26fa431160662"})-[:
|
|
371
|
+
MATCH (a:Address {address: "0x7e3702e9dfaa847f9829a258f1e26fa431160662"})-[:FLOWED_TO|SWAPPED]-(c:Address)-[:FLOWED_TO|SWAPPED]-(b:Address {address: "0x31a817802ee183eb8b13167ffe24bd28dcc6f30c"}) WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"] AND NOT c:Pool AND NOT c:Protocol AND NOT c:System AND NOT c.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]
|
|
371
372
|
RETURN DISTINCT c.address AS shared_address LIMIT 25
|
|
372
373
|
```
|
|
373
374
|
|
|
@@ -398,14 +399,14 @@ RETURN b.address AS recipient, s.sold_usd AS sold_usd, s.bought_usd AS bought_us
|
|
|
398
399
|
What a pool is, and who trades through it. A pool is the `:Pool` node label,
|
|
399
400
|
read with `labels(p)`; the `labels` property is a different thing (named
|
|
400
401
|
labels such as a vault), and a pool usually has none. The traders are the
|
|
401
|
-
senders into the pool on `
|
|
402
|
+
senders into the pool on `FLOWED_TO`, ranked by `tx_count`: one read, and that
|
|
402
403
|
is the answer. Add no swap check: `SWAPPED` filtered on `s.pools`, on a list
|
|
403
404
|
of traders or on the pool times out, and a busy trader's swap links time out
|
|
404
405
|
even anchored on that one trader (two answers lost 86 seconds that way).
|
|
405
406
|
|
|
406
407
|
```cypher
|
|
407
408
|
USE topology
|
|
408
|
-
MATCH (b:Address)-[f:
|
|
409
|
+
MATCH (b:Address)-[f:FLOWED_TO]->(p:Address {address: "0xd42a491087a15e5afd51feb3606066cc152d2b09"}) WHERE NOT b:Pool
|
|
409
410
|
RETURN b.address AS from_address, p.address AS to_address, labels(p) AS to_node_labels, f.tx_count AS tx_count, f.amount_usd_sum AS amount_usd_sum, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, b.labels AS from_labels, p.labels AS to_labels, b.is_exchange AS from_is_exchange, p.is_exchange AS to_is_exchange ORDER BY f.tx_count DESC LIMIT 25
|
|
410
411
|
```
|
|
411
412
|
|
|
@@ -413,7 +414,7 @@ Pool trace: who took liquidity out of the pools an address paid into.
|
|
|
413
414
|
|
|
414
415
|
```cypher
|
|
415
416
|
USE topology
|
|
416
|
-
MATCH (a:Address {address: "0x7a31dd32a880827477ab2bbeff47db188c896815"})-[:
|
|
417
|
+
MATCH (a:Address {address: "0x7a31dd32a880827477ab2bbeff47db188c896815"})-[:FLOWED_TO]->(p:Pool)-[r:REMOVED_LIQUIDITY]->(b:Address) WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"] AND b.address <> a.address
|
|
417
418
|
RETURN p.address AS pool, b.address AS receiver, sum(r.usd) AS removed_usd, max(r.receiver_added_usd) AS receiver_added_usd, max(r.receiver_provided) AS receiver_provided LIMIT 25
|
|
418
419
|
```
|
|
419
420
|
|
|
@@ -431,7 +432,7 @@ RETURN c.network AS remote_network, c.address AS endpoint, x.kind AS kind, x.ass
|
|
|
431
432
|
|
|
432
433
|
### Tokens: one link per sender, receiver and token
|
|
433
434
|
|
|
434
|
-
`
|
|
435
|
+
`FLOWED_TO` is the pair's total over every token. `TRANSFERRED` splits that total by token: one link for each sender, receiver and token. `FLOWED_TO` stays the pair total, and the `TRANSFERRED` links of a pair add up to it. A link carries these properties:
|
|
435
436
|
|
|
436
437
|
- `asset`: the token's contract, in lowercase and in full (42 characters), or `native` for the chain's own coin.
|
|
437
438
|
- `asset_key`: bookkeeping, the number the server keeps beside `asset`. Never name a token by it and never copy one into a query: it differs from server to server and changes when a graph is rebuilt. Write `asset` with the full contract; the server turns it into the key itself.
|
|
@@ -474,6 +475,8 @@ A `TRANSFERRED` search over the whole chain, with no address anchor, must name o
|
|
|
474
475
|
|
|
475
476
|
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.
|
|
476
477
|
|
|
478
|
+
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 every contract on the network that carries that symbol, verified first, then oldest first, each with its creator. 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.
|
|
479
|
+
|
|
477
480
|
How to answer from these rows:
|
|
478
481
|
|
|
479
482
|
- Tokens are not dollars. Say "tokens worth about 183 USD", never "sent 183 USD". Head the column "Tokens worth (USD)".
|
|
@@ -484,17 +487,17 @@ How to answer from these rows:
|
|
|
484
487
|
## Pool trace rule
|
|
485
488
|
|
|
486
489
|
`:Pool` is a second label on an `Address`: a pool contract the DEX indexer
|
|
487
|
-
knows, traded or not. A pool with no swap yet is `:Pool` too. A trace that walks out of a pool on `
|
|
490
|
+
knows, traded or not. A pool with no swap yet is `:Pool` too. A trace that walks out of a pool on `FLOWED_TO` lands on every
|
|
488
491
|
trader who used it. Every trace follows this rule:
|
|
489
492
|
|
|
490
493
|
1. Enter a `:Pool` on any edge.
|
|
491
494
|
2. Leave a `:Pool` only on `REMOVED_LIQUIDITY`, to the address the liquidity
|
|
492
495
|
was paid to.
|
|
493
|
-
3. Never leave a `:Pool` on `
|
|
496
|
+
3. Never leave a `:Pool` on `FLOWED_TO`.
|
|
494
497
|
4. Across a swap, follow `SWAPPED` from payer to recipient, between two
|
|
495
498
|
different addresses. Do not walk through the pool.
|
|
496
499
|
|
|
497
|
-
So a walk never starts at a pool and never passes through one. It may end at one. Guard the start with `WHERE NOT a:Pool` and each address in the middle with `WHERE NOT via:Pool`, and follow `
|
|
500
|
+
So a walk never starts at a pool and never passes through one. It may end at one. Guard the start with `WHERE NOT a:Pool` and each address in the middle with `WHERE NOT via:Pool`, and follow `FLOWED_TO|SWAPPED`, as above. Exchange hot wallets end a trace: pass through an address only when `is_exchange IS NULL`.
|
|
498
501
|
|
|
499
502
|
### System guard
|
|
500
503
|
|
|
@@ -541,7 +544,7 @@ MATCH (a:Address) RETURN keys(a) AS keys LIMIT 20
|
|
|
541
544
|
|
|
542
545
|
```cypher
|
|
543
546
|
USE topology
|
|
544
|
-
MATCH ()-[r:
|
|
547
|
+
MATCH ()-[r:FLOWED_TO]->() RETURN keys(r) AS keys LIMIT 5
|
|
545
548
|
```
|
|
546
549
|
|
|
547
550
|
Name another link type to read its keys: `SWAPPED`, `LINKED`, `OPERATED_BY`, `BRIDGED`, `ADDED_LIQUIDITY` or `REMOVED_LIQUIDITY`. The keys of an address and of a link include `network`: it is the query's `network`, computed on every node and link. `synced_through_height` and `pair_key` are bookkeeping: never filter or sort on them.
|
|
@@ -609,7 +612,7 @@ with the arrow reversed, and both go in one `graph_query_batch`:
|
|
|
609
612
|
|
|
610
613
|
```cypher
|
|
611
614
|
USE topology
|
|
612
|
-
MATCH (a:Address {address: "0x9f73873740c799d74741ad2d15cee7fb33572e4a"})-[f:
|
|
615
|
+
MATCH (a:Address {address: "0x9f73873740c799d74741ad2d15cee7fb33572e4a"})-[f:FLOWED_TO]->(b:Address) WHERE NOT a:Pool AND f.first_seen_timestamp <= 1790812799000 AND f.last_seen_timestamp >= 1788220800000
|
|
613
616
|
RETURN a.address AS from_address, b.address AS to_address, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, a.labels AS from_labels, b.labels AS to_labels, a.is_exchange AS from_is_exchange, b.is_exchange AS to_is_exchange ORDER BY f.last_seen_timestamp DESC LIMIT 50
|
|
614
617
|
```
|
|
615
618
|
|
|
@@ -154,11 +154,11 @@ For a `plain` row (Metric, Curve, Trader Joe, Uniswap v3), a swap pays the
|
|
|
154
154
|
pool and the pool pays the buyer:
|
|
155
155
|
|
|
156
156
|
```
|
|
157
|
-
seller ──
|
|
157
|
+
seller ──FLOWED_TO──▶ pool seller ──SWAPPED──▶ buyer
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
1. **Sellers into the pool** (reference R4): the senders of the pool on
|
|
161
|
-
`
|
|
161
|
+
`FLOWED_TO`, ranked by lifetime volume. A seller that is a contract is
|
|
162
162
|
often an aggregator or a router: say "a contract", never "a trader". A
|
|
163
163
|
seller that carries `SelfTrader` is a self-trading contract, such as an
|
|
164
164
|
arbitrage or market-making bot: say so, never "a trader". It trades for
|
|
@@ -32,7 +32,7 @@ this read: the pool trace rule leaves a pool only on `REMOVED_LIQUIDITY`.
|
|
|
32
32
|
|
|
33
33
|
```cypher
|
|
34
34
|
USE topology
|
|
35
|
-
MATCH (s:Address)-[f:
|
|
35
|
+
MATCH (s:Address)-[f:FLOWED_TO]->(p:Address {address: "0x7615926023bb149f36095645c2a81dc367d39750"}) WHERE NOT s:Pool
|
|
36
36
|
RETURN s.address AS from_address, p.address AS to_address, labels(s) AS from_node_labels, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, s.labels AS from_labels, p.labels AS to_labels, s.is_exchange AS from_is_exchange, p.is_exchange AS to_is_exchange ORDER BY f.amount_usd_sum DESC LIMIT 25
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -16,7 +16,7 @@ On a gauge exchange a swap usually goes through the exchange's **router**.
|
|
|
16
16
|
The pool pays the router, and the router pays on in the same transaction:
|
|
17
17
|
|
|
18
18
|
```
|
|
19
|
-
seller ──
|
|
19
|
+
seller ──FLOWED_TO──▶ pool ──▶ router ──▶ buyer
|
|
20
20
|
│
|
|
21
21
|
└── SWAPPED from the seller names the router
|
|
22
22
|
```
|
|
@@ -30,7 +30,7 @@ the router's own transfer in the seller's transaction.
|
|
|
30
30
|
1. **The pool.** Take it from `meta_dex_lookup` (its pools, by lifetime
|
|
31
31
|
volume), or from `chain-insights-dex` (pools by memo factory). The busiest Aero pool is
|
|
32
32
|
`0x7615926023bb149f36095645c2a81dc367d39750`.
|
|
33
|
-
2. **Sellers into the pool** (G1): its senders on `
|
|
33
|
+
2. **Sellers into the pool** (G1): its senders on `FLOWED_TO`, ranked by
|
|
34
34
|
lifetime volume. Most of the biggest are contracts: aggregators,
|
|
35
35
|
routers and liquidity managers. Say "a contract", never "a trader". A
|
|
36
36
|
sender that also adds liquidity to the pool (G6) pays its deposits on
|
|
@@ -76,7 +76,7 @@ End every answer with who to trace next, in one short paragraph:
|
|
|
76
76
|
- for a seller that is a contract, the accounts that paid it: the same read
|
|
77
77
|
with the arrow flipped.
|
|
78
78
|
|
|
79
|
-
Never walk out of the router or the pool on `
|
|
79
|
+
Never walk out of the router or the pool on `FLOWED_TO`: the router has
|
|
80
80
|
thousands of receivers, and the buyer is noise there.
|
|
81
81
|
|
|
82
82
|
## Queries
|
|
@@ -85,7 +85,7 @@ thousands of receivers, and the buyer is noise there.
|
|
|
85
85
|
|
|
86
86
|
```cypher
|
|
87
87
|
USE topology
|
|
88
|
-
MATCH (s:Address)-[f:
|
|
88
|
+
MATCH (s:Address)-[f:FLOWED_TO]->(p:Address {address: "0x7615926023bb149f36095645c2a81dc367d39750"}) WHERE NOT s:Pool
|
|
89
89
|
RETURN s.address AS from_address, p.address AS to_address, labels(s) AS from_node_labels, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, s.labels AS from_labels, p.labels AS to_labels, s.is_exchange AS from_is_exchange, p.is_exchange AS to_is_exchange ORDER BY f.amount_usd_sum DESC LIMIT 25
|
|
90
90
|
```
|
|
91
91
|
|
|
@@ -55,7 +55,7 @@ read: a token launched there, such as Mob, is never the launchpad's name.
|
|
|
55
55
|
## The curve stage
|
|
56
56
|
|
|
57
57
|
3. **Who bought and sold on the curve** (L2): the launched contract's own
|
|
58
|
-
`
|
|
58
|
+
`FLOWED_TO` links, both directions, ranked by transactions. Money in is a
|
|
59
59
|
buy, money out is a payout. On Penguin the token contract is the curve,
|
|
60
60
|
so these are its traders. On the SPCX launchpad and the native-ETH
|
|
61
61
|
launchpad the curve is a contract of its own and a `:Pool`: its traders
|
|
@@ -144,7 +144,7 @@ RETURN f.address AS from_address, t.address AS to_address, labels(t) AS to_node_
|
|
|
144
144
|
|
|
145
145
|
```cypher
|
|
146
146
|
USE topology
|
|
147
|
-
MATCH (t:Address {address: "0xf3b01a81dc8a4216d92e74b40113e9e1b10a4dac"})-[f:
|
|
147
|
+
MATCH (t:Address {address: "0xf3b01a81dc8a4216d92e74b40113e9e1b10a4dac"})-[f:FLOWED_TO]-(b:Address) WHERE NOT t:Pool
|
|
148
148
|
RETURN startNode(f).address AS from_address, endNode(f).address AS to_address, labels(b) AS node_labels, f.tx_count AS tx_count, f.amount_usd_sum AS amount_usd_sum, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp ORDER BY f.tx_count DESC LIMIT 25
|
|
149
149
|
```
|
|
150
150
|
|
|
@@ -34,7 +34,7 @@ ORDER BY r.block_timestamp DESC LIMIT 25
|
|
|
34
34
|
|
|
35
35
|
```cypher
|
|
36
36
|
USE topology
|
|
37
|
-
MATCH (b:Address)-[f:
|
|
37
|
+
MATCH (b:Address)-[f:FLOWED_TO]->(a:Address {address: "<wallet>"}) WHERE NOT b:Pool
|
|
38
38
|
RETURN b.address AS from_address, a.address AS to_address, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count,
|
|
39
39
|
f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp,
|
|
40
40
|
b.labels AS from_labels, a.labels AS to_labels, b.is_exchange AS from_is_exchange, a.is_exchange AS to_is_exchange
|
|
@@ -153,7 +153,7 @@ the same day. It moved VIRTUAL.
|
|
|
153
153
|
|
|
154
154
|
```cypher
|
|
155
155
|
USE topology
|
|
156
|
-
MATCH (p:Address {address: "<starting pool>"})-[f:
|
|
156
|
+
MATCH (p:Address {address: "<starting pool>"})-[f:FLOWED_TO]->(b:Address)
|
|
157
157
|
WHERE NOT b:Protocol AND NOT b.address IN ["0x65050a9b7e5075a2ba5ced7b1b64ee66262c40dc", "0xd4ccbfa37e2f35611b3042e4096ad7a3459bd007", "0xca6395246b4382ba70f886526dd9a9de984f6081", "0x6d80b81d9fc56a7a839b1af9006eb49151961ce7"]
|
|
158
158
|
RETURN p.address AS from_address, b.address AS to_address, f.tx_count AS tx_count,
|
|
159
159
|
f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp
|
|
@@ -164,7 +164,7 @@ ORDER BY f.first_seen_timestamp ASC LIMIT 25
|
|
|
164
164
|
|
|
165
165
|
```cypher
|
|
166
166
|
USE topology
|
|
167
|
-
MATCH (p1:Address {address: "<pool a>"})-[:
|
|
167
|
+
MATCH (p1:Address {address: "<pool a>"})-[:FLOWED_TO]->(w:Address)<-[:FLOWED_TO]-(p2:Address {address: "<pool b>"})
|
|
168
168
|
WHERE NOT w.address IN ["0x65050a9b7e5075a2ba5ced7b1b64ee66262c40dc", "0xca6395246b4382ba70f886526dd9a9de984f6081"]
|
|
169
169
|
RETURN DISTINCT w.address AS shared_buyer LIMIT 25
|
|
170
170
|
```
|
|
@@ -173,7 +173,7 @@ RETURN DISTINCT w.address AS shared_buyer LIMIT 25
|
|
|
173
173
|
|
|
174
174
|
```cypher
|
|
175
175
|
USE topology
|
|
176
|
-
MATCH (s:Address)-[f:
|
|
176
|
+
MATCH (s:Address)-[f:FLOWED_TO]->(b:Address)
|
|
177
177
|
WHERE b.address IN ["<buyer 1>", "<buyer 2>"] AND NOT s:Pool AND NOT s:Protocol AND NOT s:System
|
|
178
178
|
AND NOT s.address IN ["0x65050a9b7e5075a2ba5ced7b1b64ee66262c40dc", "0xca6395246b4382ba70f886526dd9a9de984f6081"]
|
|
179
179
|
RETURN s.address AS funder, count(DISTINCT b.address) AS buyers_funded, sum(f.amount_usd_sum) AS usd
|
|
@@ -187,7 +187,7 @@ airdrops. Weigh the funders that sent value.
|
|
|
187
187
|
|
|
188
188
|
```cypher
|
|
189
189
|
USE topology
|
|
190
|
-
MATCH (a:Address {address: "<creator a>"})<-[:
|
|
190
|
+
MATCH (a:Address {address: "<creator a>"})<-[:FLOWED_TO]-(c:Address)-[:FLOWED_TO]->(b:Address {address: "<creator b>"})
|
|
191
191
|
WHERE NOT c:Pool AND NOT c:Protocol AND NOT c:System AND c.is_exchange IS NULL
|
|
192
192
|
RETURN DISTINCT c.address AS shared_funder LIMIT 25
|
|
193
193
|
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dex-tool-DsaAIa-a.mjs","names":["isRecord"],"sources":["../src/mcp/answer-hint.ts","../src/mcp/dex-recipes.ts","../src/mcp/dex-tool.ts"],"sourcesContent":["/**\n * The two answer rules that still slip in long answers, carried on every\n * graph reply in the result's `hint` field. Claude Code has a Stop hook that\n * reads the answer; Codex and Claude Desktop have no such hook, and in the\n * loop's third prompt set they broke one of these two rules in three of\n * thirteen conversations. The reply is the one thing every host hands the\n * model right before it writes, so the rules ride on it. A `hint` the\n * server already set is kept.\n */\n\nexport const ANSWER_HINT =\n 'Answer: write every address in full (0x plus 40 characters), also when it repeats one named earlier and also when the user asks for shorter ones (name them instead); ' +\n 'a transfer moves tokens, so write \"tokens worth about N USD\", never \"sent N USD\" or a $ figure; ' +\n 'never draw the flows in text, ASCII or Mermaid, the host draws them.'\n\ntype TextBlock = { type: string; text?: string }\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** The structured content with the hint set when the server left it empty. */\nexport function withAnswerHint(structuredContent: unknown): unknown {\n if (!isRecord(structuredContent) || !isRecord(structuredContent.facts)) return structuredContent\n if (typeof structuredContent.hint === 'string' && structuredContent.hint.trim()) return structuredContent\n return { ...structuredContent, hint: ANSWER_HINT }\n}\n\n/** A graph tool result whose structured content and single JSON text block both carry the hint. */\nexport function withAnswerHintResult<T extends { content?: TextBlock[]; structuredContent?: unknown }>(result: T): T {\n const structured = withAnswerHint(result.structuredContent)\n if (structured === result.structuredContent) return result\n const content = result.content ?? []\n const only = content.length === 1 && content[0]?.type === 'text' ? content[0] : null\n let parsed: unknown = undefined\n try {\n parsed = only?.text ? JSON.parse(only.text) : undefined\n } catch {\n parsed = undefined\n }\n const textIsStructured = parsed !== undefined && JSON.stringify(parsed) === JSON.stringify(result.structuredContent)\n return { ...result, structuredContent: structured, content: textIsStructured ? [{ ...only, text: JSON.stringify(structured) }] : content }\n}\n","/**\n * The first reads of each trail type, filled with the addresses of one\n * exchange. meta_dex_lookup returns them, so a host that loads no skill\n * (Claude Desktop chat) still gets the tested reads of\n * skills/chain-insights-dex*. The shapes are the skills' own: R3 and R4 of\n * chain-insights-dex, G1, G4 and G5 of the gauge trail, V1, V3 and V4 of the\n * vault trail, L1 to L3 of the launchpad trail.\n *\n * A value the lookup cannot know (a seller, a day, a transaction) is written\n * as a placeholder in angle brackets, and the step's `why` says where it comes\n * from. Every address the lookup knows is written in full.\n */\n\nimport type { DexEntry, TrailType } from './dex-registry.js'\n\nexport interface RecipeStep {\n step: string\n why: string\n query: string\n}\n\n/** The trail-type skill of each trail, for hosts that load skills. */\nexport const TRAIL_SKILLS: Record<TrailType, string> = {\n plain: 'chain-insights-dex',\n gauge: 'chain-insights-dex-gauge',\n vault: 'chain-insights-dex-vault',\n launchpad: 'chain-insights-dex-launchpad',\n}\n\nconst SELLER = '<seller address>'\nconst DAY = '<YYYY-MM-DD>'\nconst TX = '<tx_id>'\nconst TOKEN = '<launched token address>'\n\n/** The pools one factory deployed, by lifetime volume (R3). */\nexport function poolsByFactoryQuery(factory: string, limit = 10): string {\n return (\n `USE topology MATCH (f:Address {address: \"${factory}\"})-[:DEPLOYED_CONTRACT]->(p:Pool) WHERE p.total_volume_usd IS NOT NULL ` +\n '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 ' +\n `ORDER BY p.total_volume_usd DESC LIMIT ${limit}`\n )\n}\n\n/** The senders of one pool on FLOWS_TO, by lifetime volume (R4, G1). */\nfunction sellersIntoPoolQuery(pool: string): string {\n return (\n `USE topology MATCH (s:Address)-[f:FLOWS_TO]->(p:Address {address: \"${pool}\"}) WHERE NOT s:Pool ` +\n 'RETURN s.address AS from_address, p.address AS to_address, labels(s) AS from_node_labels, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp, s.labels AS from_labels, p.labels AS to_labels, s.is_exchange AS from_is_exchange, p.is_exchange AS to_is_exchange ' +\n 'ORDER BY f.amount_usd_sum DESC LIMIT 25'\n )\n}\n\n/** The payers whose swaps name one contract as the recipient, by sold volume (V4 shape). */\nfunction sellersIntoContractQuery(contract: string): string {\n return (\n `USE topology MATCH (s:Address)-[sw:SWAPPED]->(r:Address {address: \"${contract}\"}) WHERE NOT s:Pool ` +\n 'RETURN s.address AS from_address, r.address AS to_address, labels(s) AS from_node_labels, sw.sold_asset AS sold_asset, sw.bought_asset AS bought_asset, sw.sold_usd AS sold_usd, sw.bought_usd AS bought_usd, sw.swap_count AS swap_count, sw.pools AS pools, sw.last_seen_height AS last_seen_height ' +\n 'ORDER BY sw.sold_usd DESC LIMIT 25'\n )\n}\n\n/** One seller's swaps (R5, G2, V1). */\nfunction sellerSwapsQuery(): string {\n return (\n `USE topology MATCH (s:Address {address: \"${SELLER}\"})-[sw:SWAPPED]->(r:Address) ` +\n 'RETURN s.address AS from_address, r.address AS to_address, labels(r) AS to_node_labels, sw.sold_asset AS sold_asset, sw.bought_asset AS bought_asset, sw.sold_usd AS sold_usd, sw.bought_usd AS bought_usd, sw.swap_count AS swap_count, sw.pools AS pools, sw.last_seen_height AS last_seen_height ' +\n 'ORDER BY sw.swap_count DESC LIMIT 25'\n )\n}\n\n/** The facts SWAP rows of a seller and one recipient on one day (R6, G4, V3). */\nfunction swapRowsQuery(recipient: string): string {\n return (\n `USE facts MATCH (s:Address {address: \"${SELLER}\"})-[x:SWAP]->(r:Address {address: \"${recipient}\"}) WHERE x.block_date = \"${DAY}\" ` +\n 'RETURN x.tx_id AS tx_id, x.block_timestamp AS block_timestamp, x.payer AS payer, x.recipient AS recipient, x.sold_asset_symbol AS sold_asset_symbol, x.sold_usd AS sold_usd, x.bought_asset_symbol AS bought_asset_symbol, x.bought_usd AS bought_usd LIMIT 50'\n )\n}\n\n/** The transfers one router made in one transaction (G5). */\nfunction routerPayoutQuery(router: string): string {\n return (\n `USE facts MATCH (r:Address {address: \"${router}\"})-[t:TRANSFER]->(b:Address) WHERE t.block_date = \"${DAY}\" AND t.tx_id = \"${TX}\" ` +\n 'RETURN r.address AS from_address, b.address AS to_address, t.amount_usd AS amount_usd, t.asset_symbol AS asset_symbol, t.kind AS kind, t.tx_id AS tx_id LIMIT 10'\n )\n}\n\nconst dayStep: RecipeStep = {\n step: 'The day of a swap link',\n why: 'A SWAPPED link carries heights, not times: read the block of its last_seen_height for the day the facts reads need.',\n query:\n 'USE chain MATCH (b:Block {block_height: <last_seen_height>}) RETURN b.block_date, b.block_timestamp',\n}\n\n/**\n * The pool a trail starts from: the busiest pool read, else the registry's\n * example pool, else none.\n */\nfunction startPool(entry: DexEntry, topPool: string | null): string | null {\n return topPool ?? entry.example_pool ?? null\n}\n\nfunction poolsStep(entry: DexEntry): RecipeStep | null {\n const factory = entry.factories.find((address) => entry.roles[address] === 'factory')\n if (!factory) return null\n return {\n step: 'Pools of the exchange, by factory',\n why: `The pools ${entry.display} deployed, by lifetime volume. One batch member per factory: ${entry.factories.filter((a) => entry.roles[a] === 'factory').join(', ')}.`,\n query: poolsByFactoryQuery(factory),\n }\n}\n\n/** The first reads of the exchange's trail type, with its addresses filled in. */\nexport function recipeFor(entry: DexEntry, topPool: string | null): RecipeStep[] {\n const pool = startPool(entry, topPool)\n const steps: RecipeStep[] = []\n switch (entry.trail_type) {\n case 'gauge': {\n const router = entry.routers[0]\n if (router) {\n steps.push({\n step: 'Sellers into the router',\n why: `On ${entry.display} a swap pays the router, and the router pays on. These are the payers whose swaps name the router ${router}; the router is never the buyer.`,\n query: sellersIntoContractQuery(router),\n })\n }\n if (pool) {\n steps.push({\n step: 'Sellers into the busiest pool',\n why: `The senders of ${pool} on FLOWS_TO. A sender that also adds liquidity is a liquidity provider, not a seller.`,\n query: sellersIntoPoolQuery(pool),\n })\n } else {\n const pools = poolsStep(entry)\n if (pools) steps.push(pools)\n }\n if (router) {\n steps.push(dayStep)\n steps.push({\n step: \"A seller's swaps through the router on one day\",\n why: 'Fill the seller from the first step and the day from the block read: each row gives the tx_id of one swap.',\n query: swapRowsQuery(router),\n })\n steps.push({\n step: 'Who the router paid in that transaction',\n why: 'Fill the day and the tx_id: the receiver of the bought asset is the buyer. A pool or a pool manager there is the next leg, not the buyer.',\n query: routerPayoutQuery(router),\n })\n }\n break\n }\n case 'vault': {\n const manager = entry.factories[0]!\n steps.push({\n step: 'The swaps the pool manager settles',\n why: `${entry.display} keeps every pool in one manager, ${manager}. A manager deploys nothing: its pools are the pools of the swaps it settles.`,\n query: sellersIntoContractQuery(manager),\n })\n steps.push({\n step: \"One seller's swaps\",\n why: 'Fill a seller from the first step. A recipient that is the manager is never the buyer: read the facts row past it.',\n query: sellerSwapsQuery(),\n })\n steps.push(dayStep)\n steps.push({\n step: 'The facts SWAP row past the manager',\n why: 'Fill the seller and the day: the recipient column names who the manager paid.',\n query: swapRowsQuery(manager),\n })\n break\n }\n case 'launchpad': {\n const factory = entry.factories[0]!\n steps.push({\n step: 'Launches of the launchpad, newest first',\n why: `The contracts ${factory} created, with the creator of each.`,\n query:\n `USE topology MATCH (f:Address {address: \"${factory}\"})-[d:DEPLOYED_CONTRACT]->(t:Address) ` +\n 'RETURN f.address AS from_address, t.address AS to_address, labels(t) AS to_node_labels, t.labels AS to_labels, d.tx_origin AS creator, d.tx_id AS tx_id, d.block_height AS block_height, d.block_timestamp AS created_timestamp ORDER BY d.block_height DESC LIMIT 25',\n })\n steps.push({\n step: 'Traders on the curve of one launched token',\n why: 'Fill a launched token from the first step.',\n query:\n `USE topology MATCH (t:Address {address: \"${TOKEN}\"})-[f:FLOWS_TO]-(b:Address) WHERE NOT t:Pool ` +\n 'RETURN startNode(f).address AS from_address, endNode(f).address AS to_address, labels(b) AS node_labels, f.tx_count AS tx_count, f.amount_usd_sum AS amount_usd_sum, f.first_seen_timestamp AS first_seen_timestamp, f.last_seen_timestamp AS last_seen_timestamp ORDER BY f.tx_count DESC LIMIT 25',\n })\n steps.push({\n step: 'The first pool of one launched token',\n why: 'The oldest ADDED_LIQUIDITY into a :Pool is the graduation. None means it has not graduated in the graph yet.',\n query:\n `USE topology MATCH (t:Address {address: \"${TOKEN}\"})-[l:ADDED_LIQUIDITY]->(p:Pool) ` +\n 'RETURN t.address AS from_address, p.address AS to_address, p.labels AS to_labels, l.asset AS asset, l.usd AS usd, l.first_seen_height AS first_seen_height ORDER BY l.first_seen_height ASC LIMIT 5',\n })\n break\n }\n case 'plain': {\n if (pool) {\n steps.push({\n step: 'Sellers into the busiest pool',\n why: `The senders of ${pool} on FLOWS_TO, by lifetime volume. A seller that is a contract is often an aggregator or a router: say \"a contract\".`,\n query: sellersIntoPoolQuery(pool),\n })\n } else {\n const pools = poolsStep(entry)\n if (pools) steps.push(pools)\n }\n steps.push({\n step: \"Who a seller's swaps paid\",\n why: 'Fill a seller from the first step. Keep the rows whose pools hold the pool: the recipient is the buyer.',\n query: sellerSwapsQuery(),\n })\n steps.push(dayStep)\n steps.push({\n step: 'The swaps of a seller and a recipient on one day',\n why: 'Fill the seller, the recipient and the day.',\n query: swapRowsQuery('<recipient address>'),\n })\n break\n }\n }\n return steps\n}\n","/**\n * meta_dex_lookup: an exchange's name becomes its addresses.\n *\n * A local tool of the proxy. It matches the name against the exchange registry\n * (src/mcp/dex-registry.ts) at no cost, then sends one graph_query_batch of\n * anchored reads: Head for the family lag, each factory, manager and router by\n * its address, and the pools each factory deployed. Nothing is read by name and\n * nothing is gated on a family lag: a factory deployed months ago is not stale\n * because the swap family is behind. A name that is not covered sends no read.\n *\n * The description below is the contract with every host, Claude Desktop chat\n * included, which reads no skill: it carries the rule the exchange skills open\n * with. tests/host-parity.test.ts holds it to the skills' trigger words.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { recipeFor, TRAIL_SKILLS, type RecipeStep, poolsByFactoryQuery } from './dex-recipes.js'\nimport {\n DexRegistryError,\n matchDex,\n normalizeDexNetwork,\n type DexCandidate,\n type DexEntry,\n type DexMatchResult,\n type LoadedRegistry,\n type RegistrySource,\n type Role,\n type TrailType,\n} from './dex-registry.js'\n\nexport const META_DEX_LOOKUP_TOOL = 'meta_dex_lookup'\nexport const META_DEX_LOOKUP_SCHEMA = 'chain-insights.meta-dex-lookup.v1' as const\nexport const META_DEX_LOOKUP_TITLE = 'Exchange by name or address'\nexport const META_DEX_LOOKUP_DESCRIPTION =\n 'Call this first when a question names a decentralized exchange, a launchpad or a vault ' +\n '(Aero, Aerodrome, Velodrome, up., Raphael, Topaz, Uniswap, PancakeSwap, Balancer, Curve, ' +\n \"Penguin, Virtuals, ...) and gives no address. It turns the name into the exchange's \" +\n 'factories, routers or pool manager, its biggest pools, and the first reads to send, ' +\n 'with every address in full. A misspelling within two letters is taken and named in ' +\n 'took_for. When matched is null the name is not covered: say so, list covered, and send ' +\n 'no graph query for the name. Never ask the user for a pool, factory or router address. ' +\n 'When the user gives a contract address instead of a name, send it as address (0x plus 40 hex, ' +\n 'any case, with no name): the answer is the exchange whose factory, router or manager it is, ' +\n 'and took_for names the role it holds. When matched is null no exchange row holds the address: ' +\n 'send no read for it. Give a name or an address, not both.'\nexport const META_DEX_LOOKUP_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const META_DEX_LOOKUP_ARGS = ['network', 'name', 'address', 'pools'] as const\n\n/** The pools returned per exchange, and per factory read. */\nexport const POOLS_LIMIT = 10\n/** A batch holds at most 20 members; Head and the pool reads take their share. */\nconst CONTRACT_MEMBERS_MAX = 12\n\nexport interface ContractRow {\n address: string\n role: Role\n confirmed: boolean\n confirmed_by?: string\n}\n\nexport interface PoolRow {\n address: string\n labels: string[]\n total_volume_usd: number\n tx_total_count: number\n}\n\nexport interface FamilyLag {\n behind_money: number | null\n behind_dex: number | null\n behind_transfers: number | null\n}\n\nexport interface DexMatch {\n dex: string\n display: string\n trail_type: TrailType\n /** The skill a host with skills loads next. */\n skill: string\n factories: ContractRow[]\n routers: ContractRow[]\n manager: ContractRow | null\n pools: PoolRow[]\n recipe: RecipeStep[]\n}\n\nexport interface CoveredExchange {\n dex: string\n display: string\n trail_type: TrailType\n factories: string[]\n routers: string[]\n}\n\nexport interface MetaDexLookupResult {\n schema: typeof META_DEX_LOOKUP_SCHEMA\n network: string\n registry_version: number\n registry_source: RegistrySource\n matched: DexMatch | null\n /** A near name hit: the name as typed. An address hit: the role it holds and the verification cell. */\n took_for?: string\n candidates: DexCandidate[]\n covered: string[]\n /** With no name: every covered exchange, with its key, trail type and contracts. */\n exchanges?: CoveredExchange[]\n families: FamilyLag | null\n /** What a read could not do: a lane that is not reachable, a member that was refused. */\n notes?: string[]\n hint: string\n}\n\n/** The batch reply as the remote client returns it. */\nexport type BatchAnswer = {\n content?: unknown[]\n structuredContent?: unknown\n isError?: boolean\n}\n\nexport interface DexToolDependencies {\n loadRegistry: (network: string) => Promise<LoadedRegistry>\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<BatchAnswer>\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 MetaDexLookupToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction errorResult(text: string): MetaDexLookupToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\ntype Member = { id?: unknown; ok?: unknown; results?: unknown; error?: unknown }\n\nfunction membersOf(answer: BatchAnswer): 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\nconst rowsOf = (member: Member | undefined): Array<Record<string, unknown>> =>\n member?.ok === true && Array.isArray(member.results) ? member.results.filter(isRecord) : []\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 stringList = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : []\n\n/** A column of a row, read under its alias or as the query wrote it (h.behind_dex). */\nfunction column(row: Record<string, unknown>, name: string, variable: string): unknown {\n return name in row ? row[name] : row[`${variable}.${name}`]\n}\n\nexport const HEAD_QUERY =\n 'USE chain MATCH (h:Head) RETURN h.behind_money, h.behind_dex, h.behind_transfers'\n\nexport function contractQuery(address: string): string {\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.is_contract AS is_contract LIMIT 1'\n )\n}\n\nexport function contractListQuery(addresses: string[]): string {\n return (\n `USE topology MATCH (a:Address) WHERE a.address IN [${addresses.map((a) => `\"${a}\"`).join(', ')}] ` +\n `RETURN a.address AS address, labels(a) AS node_labels, a.labels AS labels, a.is_contract AS is_contract LIMIT ${addresses.length}`\n )\n}\n\n/** The anchored reads of one exchange: Head, each contract, and the pools of each factory. */\nexport function lookupQueries(\n entry: DexEntry,\n pools: boolean\n): Array<{ id: string; query: string }> {\n const contracts = Object.keys(entry.roles)\n const queries: Array<{ id: string; query: string }> = [{ id: 'head', query: HEAD_QUERY }]\n if (contracts.length <= CONTRACT_MEMBERS_MAX) {\n for (const address of contracts)\n queries.push({ id: `contract:${address}`, query: contractQuery(address) })\n } else {\n queries.push({ id: 'contracts', query: contractListQuery(contracts) })\n }\n if (pools) {\n for (const factory of entry.factories.filter((address) => entry.roles[address] === 'factory')) {\n queries.push({ id: `pools:${factory}`, query: poolsByFactoryQuery(factory, POOLS_LIMIT) })\n }\n }\n return queries\n}\n\nfunction confirmation(\n row: Record<string, unknown> | undefined\n): Pick<ContractRow, 'confirmed' | 'confirmed_by'> {\n if (!row) return { confirmed: false }\n if (row.is_contract === true) return { confirmed: true, confirmed_by: 'is_contract' }\n if (stringList(row.node_labels).includes('Contract'))\n return { confirmed: true, confirmed_by: ':Contract' }\n return { confirmed: false }\n}\n\nfunction readMatch(\n entry: DexEntry,\n members: Map<string, Member>,\n read: boolean\n): {\n contracts: Map<string, ContractRow>\n pools: PoolRow[]\n families: FamilyLag | null\n notes: string[]\n} {\n const notes: string[] = []\n const contracts = new Map<string, ContractRow>()\n const listed = new Map(rowsOf(members.get('contracts')).map((row) => [String(row.address), row]))\n for (const [address, role] of Object.entries(entry.roles)) {\n const row = members.has(`contract:${address}`)\n ? rowsOf(members.get(`contract:${address}`))[0]\n : listed.get(address)\n contracts.set(address, { address, role, ...confirmation(row) })\n }\n const byAddress = new Map<string, PoolRow>()\n for (const [id, member] of members) {\n if (!id.startsWith('pools:')) continue\n for (const row of rowsOf(member)) {\n const address = typeof row.to_address === 'string' ? row.to_address : null\n const volume = numberOrNull(row.total_volume_usd)\n if (!address || volume === null || byAddress.has(address)) continue\n byAddress.set(address, {\n address,\n labels: stringList(row.to_labels),\n total_volume_usd: volume,\n tx_total_count: numberOrNull(row.tx_total_count) ?? 0,\n })\n }\n }\n const pools = [...byAddress.values()]\n .sort((a, b) => b.total_volume_usd - a.total_volume_usd)\n .slice(0, POOLS_LIMIT)\n const head = rowsOf(members.get('head'))[0]\n const families: FamilyLag | null = head\n ? {\n behind_money: numberOrNull(column(head, 'behind_money', 'h')),\n behind_dex: numberOrNull(column(head, 'behind_dex', 'h')),\n behind_transfers: numberOrNull(column(head, 'behind_transfers', 'h')),\n }\n : null\n if (read) {\n for (const [id, member] of members) {\n if (member.ok !== true)\n notes.push(\n `${id}: ${typeof member.error === 'string' ? member.error : 'the read was not served'}`\n )\n }\n }\n return { contracts, pools, families, notes }\n}\n\nconst ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/\n\nfunction hintFor(\n result: Omit<MetaDexLookupResult, 'hint'>,\n name: string | null,\n address: string | null = null\n): string {\n if (address !== null && !result.matched) {\n return `${ANSWER_HINT} No exchange row holds ${address}: it is not a registered exchange contract. Send no exchange read for it; read the graph for what the address did.`\n }\n if (address !== null && result.matched) {\n const { matched } = result\n return (\n `${ANSWER_HINT} Say in one line: \"${address} is a ${result.took_for} row of ${matched.display}.\" Ask nothing. ` +\n `Exchange ${matched.display}, trail ${matched.trail_type}: send the first reads of recipe, ` +\n `anchored on the addresses above, and load ${matched.skill} when this host has skills. ` +\n 'Read families before a SWAPPED search: it is sent when behind_dex is at most 100000. Never ask the user for an address.'\n )\n }\n if (name === null) {\n return `${ANSWER_HINT} These are the exchanges the registry covers. Call meta_dex_lookup with a name for its addresses and first reads.`\n }\n if (result.matched) {\n const { matched } = result\n const took = result.took_for\n ? `Say in one line: \"I took ${matched.display} for ${result.took_for}.\" Ask nothing. `\n : ''\n return (\n `${ANSWER_HINT} ${took}Exchange ${matched.display}, trail ${matched.trail_type}: send the first reads of recipe, ` +\n `anchored on the addresses above, and load ${matched.skill} when this host has skills. ` +\n 'Read families before a SWAPPED search: it is sent when behind_dex is at most 100000. Never ask the user for an address.'\n )\n }\n if (result.candidates.length > 0) {\n const names = result.candidates\n .map((candidate) => `${candidate.display} (${candidate.dex})`)\n .join(', ')\n return `${ANSWER_HINT} ${result.candidates.length} rows fit \"${name}\": ${names}. Name both or pick one: call meta_dex_lookup with each key. Never guess one, never ask the user for an address.`\n }\n return `${ANSWER_HINT} ${name} is not covered. Send no query for the name: say so in one line and list the covered exchanges by name.`\n}\n\nfunction textResult(structured: MetaDexLookupResult): MetaDexLookupToolResult {\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/** meta_dex_lookup, {network, name?, address?, pools?}. Every argument is checked before the registry is read. */\nexport async function handleMetaDexLookup(\n args: unknown,\n deps: DexToolDependencies\n): Promise<MetaDexLookupToolResult> {\n const record = isRecord(args) ? args : {}\n let network: string\n try {\n network = normalizeDexNetwork(record.network)\n } catch (err) {\n return errorResult((err as Error).message)\n }\n const rawName = record.name\n if (rawName !== undefined && rawName !== null && typeof rawName !== 'string') {\n return errorResult('invalid_name: name must be the exchange name as text')\n }\n const name = typeof rawName === 'string' && rawName.trim() !== '' ? rawName.trim() : null\n const rawAddress = record.address\n if (rawAddress !== undefined && rawAddress !== null && typeof rawAddress !== 'string') {\n return errorResult('invalid_address: address must be 0x plus 40 hex characters')\n }\n const addressText = typeof rawAddress === 'string' && rawAddress.trim() !== '' ? rawAddress.trim() : null\n if (name !== null && addressText !== null) return errorResult('Give a name or an address, not both.')\n if (addressText !== null && !ADDRESS_FORM.test(addressText)) {\n return errorResult('invalid_address: address must be 0x plus 40 hex characters')\n }\n const address = addressText === null ? null : addressText.toLowerCase()\n const rawPools = record.pools\n if (rawPools !== undefined && rawPools !== null && typeof rawPools !== 'boolean') {\n return errorResult('invalid_pools: pools must be true or false')\n }\n const pools = rawPools !== false\n\n let loaded: LoadedRegistry\n try {\n loaded = await deps.loadRegistry(network)\n } catch (err) {\n return errorResult(\n err instanceof DexRegistryError\n ? err.message\n : `exchange registry unavailable: ${(err as Error).message}`\n )\n }\n const { document } = loaded\n const base = {\n schema: META_DEX_LOOKUP_SCHEMA,\n network,\n registry_version: document.registry_version,\n registry_source: loaded.source,\n }\n\n if (name === null && address === null) {\n const result = {\n ...base,\n matched: null,\n candidates: [],\n covered: document.rows.map((row) => row.display),\n exchanges: document.rows.map((row) => ({\n dex: row.dex,\n display: row.display,\n trail_type: row.trail_type,\n factories: row.factories,\n routers: row.routers,\n })),\n families: null,\n }\n return textResult({ ...result, hint: hintFor(result, null) })\n }\n\n let match: DexMatchResult\n if (address !== null) {\n const holder = document.rows.find((row) => address in row.roles)\n match = {\n matched: holder ?? null,\n ...(holder ? { took_for: `${holder.roles[address]}, served` } : {}),\n candidates: [],\n covered: document.rows.map((row) => row.display),\n }\n } else {\n match = matchDex(name as string, document.rows)\n }\n if (!match.matched) {\n const result = {\n ...base,\n matched: null,\n candidates: match.candidates,\n covered: match.covered,\n families: null,\n }\n return textResult({ ...result, hint: hintFor(result, name, address) })\n }\n\n const entry = match.matched\n const queries = lookupQueries(entry, pools)\n let members = new Map<string, Member>()\n const notes: string[] = []\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n notes.push(\n `No graph read was sent: ${unavailable} The contracts are the reviewed registry rows, not yet confirmed on the graph.`\n )\n } else {\n try {\n const answer = await deps.graphQueryBatch({ network, queries })\n members = membersOf(answer)\n if (answer.isError === true && members.size === 0) {\n const first = Array.isArray(answer.content) ? answer.content[0] : undefined\n notes.push(\n `The graph refused the reads: ${isRecord(first) && typeof first.text === 'string' ? first.text : 'no reason given'}`\n )\n }\n } catch (err) {\n notes.push(`The graph reads failed: ${deps.describeFailure(err)}`)\n }\n }\n const read = readMatch(entry, members, members.size > 0)\n notes.push(...read.notes)\n const contractsOf = (role: Role): ContractRow[] =>\n [...read.contracts.values()].filter((contract) => contract.role === role)\n const topPool = read.pools[0]?.address ?? null\n const matched: DexMatch = {\n dex: entry.dex,\n display: entry.display,\n trail_type: entry.trail_type,\n skill: TRAIL_SKILLS[entry.trail_type],\n factories: contractsOf('factory'),\n routers: contractsOf('router'),\n manager: contractsOf('manager')[0] ?? null,\n pools: read.pools,\n recipe: recipeFor(entry, topPool),\n }\n const result = {\n ...base,\n matched,\n ...(match.took_for ? { took_for: match.took_for } : {}),\n candidates: [],\n covered: match.covered,\n families: read.families,\n ...(notes.length > 0 ? { notes } : {}),\n }\n return textResult({ ...result, hint: hintFor(result, name, address) })\n}\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,cACX;AAMF,SAASA,WAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AAGA,SAAgB,eAAe,mBAAqC;CAClE,IAAI,CAACA,WAAS,iBAAiB,KAAK,CAACA,WAAS,kBAAkB,KAAK,GAAG,OAAO;CAC/E,IAAI,OAAO,kBAAkB,SAAS,YAAY,kBAAkB,KAAK,KAAK,GAAG,OAAO;CACxF,OAAO;EAAE,GAAG;EAAmB,MAAM;CAAY;AACnD;;AAGA,SAAgB,qBAAuF,QAAc;CACnH,MAAM,aAAa,eAAe,OAAO,iBAAiB;CAC1D,IAAI,eAAe,OAAO,mBAAmB,OAAO;CACpD,MAAM,UAAU,OAAO,WAAW,CAAC;CACnC,MAAM,OAAO,QAAQ,WAA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