@gblin-protocol/mcp-server 0.4.3 → 0.5.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 (63) hide show
  1. package/AGENTS.md +49 -20
  2. package/README.md +110 -11
  3. package/dist/abi.d.ts +27 -0
  4. package/dist/abi.d.ts.map +1 -1
  5. package/dist/abi.js +1 -0
  6. package/dist/abi.js.map +1 -1
  7. package/dist/actions.d.ts +306 -0
  8. package/dist/actions.d.ts.map +1 -0
  9. package/dist/actions.js +740 -0
  10. package/dist/actions.js.map +1 -0
  11. package/dist/auction.d.ts.map +1 -1
  12. package/dist/auction.js +5 -4
  13. package/dist/auction.js.map +1 -1
  14. package/dist/config.d.ts +20 -3
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/config.js +23 -6
  17. package/dist/config.js.map +1 -1
  18. package/dist/helpers.d.ts +6 -0
  19. package/dist/helpers.d.ts.map +1 -1
  20. package/dist/helpers.js +37 -13
  21. package/dist/helpers.js.map +1 -1
  22. package/dist/index.d.ts +3 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +38 -19
  25. package/dist/index.js.map +1 -1
  26. package/dist/output-schemas.d.ts +18 -0
  27. package/dist/output-schemas.d.ts.map +1 -0
  28. package/dist/output-schemas.js +243 -0
  29. package/dist/output-schemas.js.map +1 -0
  30. package/dist/payments.d.ts +170 -0
  31. package/dist/payments.d.ts.map +1 -0
  32. package/dist/payments.js +524 -0
  33. package/dist/payments.js.map +1 -0
  34. package/dist/paywall.d.ts +10 -1
  35. package/dist/paywall.d.ts.map +1 -1
  36. package/dist/paywall.js +1 -1
  37. package/dist/paywall.js.map +1 -1
  38. package/dist/prompts.d.ts +33 -0
  39. package/dist/prompts.d.ts.map +1 -0
  40. package/dist/prompts.js +139 -0
  41. package/dist/prompts.js.map +1 -0
  42. package/dist/receipts.d.ts +2 -1
  43. package/dist/receipts.d.ts.map +1 -1
  44. package/dist/receipts.js +16 -12
  45. package/dist/receipts.js.map +1 -1
  46. package/dist/resources.d.ts +17 -0
  47. package/dist/resources.d.ts.map +1 -0
  48. package/dist/resources.js +146 -0
  49. package/dist/resources.js.map +1 -0
  50. package/dist/shared.d.ts +35 -0
  51. package/dist/shared.d.ts.map +1 -0
  52. package/dist/shared.js +68 -0
  53. package/dist/shared.js.map +1 -0
  54. package/dist/tools.d.ts +106 -19
  55. package/dist/tools.d.ts.map +1 -1
  56. package/dist/tools.js +124 -117
  57. package/dist/tools.js.map +1 -1
  58. package/dist/version.d.ts +2 -0
  59. package/dist/version.d.ts.map +1 -0
  60. package/dist/version.js +3 -0
  61. package/dist/version.js.map +1 -0
  62. package/llms.txt +24 -2
  63. package/package.json +8 -3
@@ -0,0 +1,524 @@
1
+ /**
2
+ * GBLIN MCP — paying in GBLIN with a signature (EIP-3009).
3
+ *
4
+ * The vault's share token implements EIP-3009, the same mechanism USDC uses: the holder signs an
5
+ * authorization and anybody can carry it on chain, so the holder never needs ETH for gas. These two
6
+ * tools cover the two halves of that exchange.
7
+ *
8
+ * prepare_gblin_payment → builds the EIP-712 message to sign, the calldata that carries it,
9
+ * and the x402 payment payload for a paid HTTP endpoint.
10
+ * verify_gblin_authorization → checks a signed authorization against the chain before anyone
11
+ * spends gas submitting it.
12
+ * relay_gblin_payment → hands a signed payment and a signed relay fee to GBLIN's relay, which
13
+ * carries both in one transaction for a payer that holds no ETH.
14
+ *
15
+ * Neither tool holds, asks for or transmits a private key. The signature is produced by the caller's
16
+ * own wallet from the typed data returned here.
17
+ *
18
+ * Shapes follow the x402 "exact" scheme so an authorization built here is accepted by any x402
19
+ * facilitator, not only by GBLIN's own endpoints.
20
+ */
21
+ import { randomBytes } from "node:crypto";
22
+ import { encodeFunctionData, formatUnits, getAddress, hashTypedData, isAddress, parseUnits, recoverTypedDataAddress, } from "viem";
23
+ import { ERC20_ABI, GBLIN_ABI } from "./abi.js";
24
+ import { client, getOnChainTimestamp } from "./client.js";
25
+ import { BASE_CHAIN_ID, GBLIN_VAULT } from "./config.js";
26
+ import { getNavUsd } from "./helpers.js";
27
+ /** GBLIN's payment relay: GET quotes the fee, POST carries a signed payment and fee in one transaction. */
28
+ const RELAY_URL = process.env.GBLIN_RELAY_URL ?? "https://gblin.digital/api/relay/gblin";
29
+ /** Seconds an authorization stays valid when the caller does not say otherwise. */
30
+ const DEFAULT_VALIDITY_SECONDS = 600;
31
+ /** Upper bound accepted for the validity window: a long window is a standing claim on the balance. */
32
+ const MAX_VALIDITY_SECONDS = 86_400;
33
+ /** EIP-712 type of an EIP-3009 authorization, identical for both methods. */
34
+ const AUTHORIZATION_TYPE = [
35
+ { name: "from", type: "address" },
36
+ { name: "to", type: "address" },
37
+ { name: "value", type: "uint256" },
38
+ { name: "validAfter", type: "uint256" },
39
+ { name: "validBefore", type: "uint256" },
40
+ { name: "nonce", type: "bytes32" },
41
+ ];
42
+ /** ERC-1271 magic value returned by a contract wallet that accepts a signature. */
43
+ const ERC1271_MAGIC = "0x1626ba7e";
44
+ const ERC1271_ABI = [
45
+ {
46
+ type: "function",
47
+ name: "isValidSignature",
48
+ stateMutability: "view",
49
+ inputs: [
50
+ { name: "hash", type: "bytes32" },
51
+ { name: "signature", type: "bytes" },
52
+ ],
53
+ outputs: [{ name: "", type: "bytes4" }],
54
+ },
55
+ ];
56
+ let domainCache = null;
57
+ /**
58
+ * Reads the EIP-712 domain from the token itself (EIP-5267) instead of assuming it.
59
+ * The domain is part of what a signature commits to: a wrong name or version produces a signature
60
+ * that every verifier rejects, and the failure only shows up at settlement.
61
+ */
62
+ export async function getTokenDomain() {
63
+ if (domainCache)
64
+ return domainCache;
65
+ const [, name, version, chainId, verifyingContract] = (await client.readContract({
66
+ address: GBLIN_VAULT,
67
+ abi: GBLIN_ABI,
68
+ functionName: "eip712Domain",
69
+ }));
70
+ domainCache = {
71
+ name,
72
+ version,
73
+ chainId: Number(chainId),
74
+ verifyingContract: getAddress(verifyingContract),
75
+ };
76
+ return domainCache;
77
+ }
78
+ /**
79
+ * MCP result envelope. The JSON also travels as `structuredContent`, which clients that support it
80
+ * read without parsing text; clients that do not simply ignore the field.
81
+ */
82
+ function paymentResult(payload) {
83
+ return {
84
+ content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
85
+ structuredContent: payload,
86
+ };
87
+ }
88
+ function paymentError(message, hint) {
89
+ return {
90
+ isError: true,
91
+ content: [{ type: "text", text: JSON.stringify({ error: message, hint }, null, 2) }],
92
+ };
93
+ }
94
+ function requireAddress(value, field) {
95
+ if (typeof value !== "string" || !isAddress(value)) {
96
+ throw new Error(`${field} must be a checksummed or lowercase 0x address`);
97
+ }
98
+ return getAddress(value);
99
+ }
100
+ /** Atomic units of GBLIN from either a share amount or a USD amount at the live NAV. */
101
+ async function resolveValue(args) {
102
+ const shares = args.amount_gblin;
103
+ const usd = args.amount_usd;
104
+ if (shares !== undefined && usd !== undefined) {
105
+ throw new Error("Give amount_gblin or amount_usd, not both");
106
+ }
107
+ if (shares !== undefined) {
108
+ const value = parseUnits(String(shares), 18);
109
+ if (value <= 0n)
110
+ throw new Error("amount_gblin must be greater than zero");
111
+ return { value, basis: "amount_gblin" };
112
+ }
113
+ if (usd === undefined)
114
+ throw new Error("Give amount_gblin or amount_usd");
115
+ // A USD amount needs a priceable NAV. When a feed is stale or a basket row cannot be read the vault
116
+ // refuses to price, and the agent should be told what to do rather than handed a revert.
117
+ let navUsd;
118
+ try {
119
+ navUsd = await getNavUsd();
120
+ }
121
+ catch {
122
+ throw new Error("The vault cannot price a share right now (a price feed is stale or a basket row cannot be read), so a USD amount cannot be converted. Pass amount_gblin instead, which needs no price.");
123
+ }
124
+ if (!Number.isFinite(navUsd) || navUsd <= 0) {
125
+ throw new Error("The vault reports no usable NAV right now, so a USD amount cannot be converted. Pass amount_gblin instead, which needs no price.");
126
+ }
127
+ // Convert through the same NAV the rest of the server publishes, then round to whole atomic units.
128
+ const sharesFromUsd = Number(usd) / navUsd;
129
+ if (!Number.isFinite(sharesFromUsd) || sharesFromUsd <= 0)
130
+ throw new Error("amount_usd must be a positive number");
131
+ const value = parseUnits(sharesFromUsd.toFixed(18), 18);
132
+ if (value <= 0n)
133
+ throw new Error("amount_usd is below the smallest share unit");
134
+ return { value, basis: `amount_usd at NAV ${navUsd.toFixed(6)} USD per share` };
135
+ }
136
+ export const PREPARE_PAYMENT_TOOL = {
137
+ name: "prepare_gblin_payment",
138
+ description: "Build a gasless GBLIN payment. The vault's share token implements EIP-3009, so the holder signs an authorization and anybody can carry it on chain: the payer needs no ETH. Returns the EIP-712 message to sign (its domain is read from the token, not assumed), the calldata that carries the signed authorization, and the x402 'exact' payload for paying an HTTP endpoint in GBLIN. Use method 'receive' when paying a known recipient: only that recipient can submit it, so nobody can front-run the transfer. Use 'transfer' for an x402 facilitator, which submits on the seller's behalf. With relay: true it also prepares the fee authorization for relay_gblin_payment, for when nobody else will carry the payment. No private key is requested, held or transmitted: the signature is produced by the caller's own wallet.",
139
+ inputSchema: {
140
+ type: "object",
141
+ properties: {
142
+ from: { type: "string", description: "The payer's address: the wallet that will sign." },
143
+ to: { type: "string", description: "The recipient's address." },
144
+ amount_gblin: { type: "string", description: "Amount in GBLIN shares, e.g. '0.25'. Give this or amount_usd." },
145
+ amount_usd: { type: "string", description: "Amount in USD, converted at the live NAV. Give this or amount_gblin." },
146
+ method: {
147
+ type: "string",
148
+ enum: ["receive", "transfer"],
149
+ description: "'receive' (default) can be submitted only by the recipient; 'transfer' by anyone.",
150
+ },
151
+ valid_for_seconds: {
152
+ type: "number",
153
+ description: `How long the authorization stays valid. Default ${DEFAULT_VALIDITY_SECONDS}, maximum ${MAX_VALIDITY_SECONDS}.`,
154
+ },
155
+ relay: {
156
+ type: "boolean",
157
+ description: "true when nobody else will carry the payment on chain: also prepares the relay fee authorization, paid in GBLIN at the live NAV, for relay_gblin_payment. Forces method 'transfer'.",
158
+ },
159
+ },
160
+ required: ["from", "to"],
161
+ additionalProperties: false,
162
+ },
163
+ annotations: {
164
+ title: "Prepare a gasless GBLIN payment",
165
+ readOnlyHint: true,
166
+ destructiveHint: false,
167
+ idempotentHint: false,
168
+ openWorldHint: true,
169
+ },
170
+ };
171
+ export async function handlePreparePayment(args) {
172
+ try {
173
+ const from = requireAddress(args.from, "from");
174
+ const to = requireAddress(args.to, "to");
175
+ if (from.toLowerCase() === to.toLowerCase())
176
+ throw new Error("from and to are the same address");
177
+ const relay = args.relay === true;
178
+ const method = relay || args.method === "transfer" ? "transfer" : "receive";
179
+ const validity = Math.floor(Number(args.valid_for_seconds ?? DEFAULT_VALIDITY_SECONDS));
180
+ if (!Number.isFinite(validity) || validity <= 0 || validity > MAX_VALIDITY_SECONDS) {
181
+ throw new Error(`valid_for_seconds must be between 1 and ${MAX_VALIDITY_SECONDS}`);
182
+ }
183
+ const [{ value, basis }, domain, now, balance] = await Promise.all([
184
+ resolveValue(args),
185
+ getTokenDomain(),
186
+ getOnChainTimestamp(),
187
+ client.readContract({ address: GBLIN_VAULT, abi: ERC20_ABI, functionName: "balanceOf", args: [from] }),
188
+ ]);
189
+ // A random nonce, as USDC does: it is an identifier, not a counter, so authorizations never queue
190
+ // behind each other and one that is never submitted blocks nothing.
191
+ const nonce = `0x${randomBytes(32).toString("hex")}`;
192
+ const validAfter = 0n;
193
+ const validBefore = now + BigInt(validity);
194
+ const authorization = {
195
+ from,
196
+ to,
197
+ value: value.toString(),
198
+ validAfter: validAfter.toString(),
199
+ validBefore: validBefore.toString(),
200
+ nonce,
201
+ };
202
+ const primaryType = method === "receive" ? "ReceiveWithAuthorization" : "TransferWithAuthorization";
203
+ // With the relay: a second authorization, for the fee, signed by the same payer with its own nonce.
204
+ let relayBlock = null;
205
+ let feeValue = 0n;
206
+ if (relay) {
207
+ const quote = (await fetch(RELAY_URL, { signal: AbortSignal.timeout(15_000) }).then((r) => r.json()).catch(() => null));
208
+ if (!quote?.fee?.units || !quote.fee.recipient)
209
+ throw new Error(`The relay at ${RELAY_URL} did not answer with a fee quote.`);
210
+ if (quote.enabled === false)
211
+ throw new Error("The relay is not accepting payments right now.");
212
+ feeValue = BigInt(quote.fee.units);
213
+ const feeAuthorization = {
214
+ from,
215
+ to: getAddress(quote.fee.recipient),
216
+ value: feeValue.toString(),
217
+ validAfter: validAfter.toString(),
218
+ validBefore: validBefore.toString(),
219
+ nonce: `0x${randomBytes(32).toString("hex")}`,
220
+ };
221
+ const feeTyped = {
222
+ domain,
223
+ types: { TransferWithAuthorization: AUTHORIZATION_TYPE },
224
+ primaryType: "TransferWithAuthorization",
225
+ message: { ...feeAuthorization },
226
+ };
227
+ relayBlock = {
228
+ url: RELAY_URL,
229
+ fee_usd: quote.fee.usd,
230
+ fee_gblin: formatUnits(feeValue, 18),
231
+ fee_authorization: feeAuthorization,
232
+ fee_typed_data: feeTyped,
233
+ fee_digest: hashTypedData({
234
+ domain,
235
+ types: { TransferWithAuthorization: AUTHORIZATION_TYPE },
236
+ primaryType: "TransferWithAuthorization",
237
+ message: feeTyped.message,
238
+ }),
239
+ next: "Sign typed_data and fee_typed_data with the payer's wallet, then call relay_gblin_payment with both authorizations and signatures. Both settle in one transaction or neither does.",
240
+ };
241
+ }
242
+ const typedData = {
243
+ domain,
244
+ types: { [primaryType]: AUTHORIZATION_TYPE },
245
+ primaryType,
246
+ message: {
247
+ from,
248
+ to,
249
+ value: value.toString(),
250
+ validAfter: validAfter.toString(),
251
+ validBefore: validBefore.toString(),
252
+ nonce,
253
+ },
254
+ };
255
+ return paymentResult({
256
+ authorization,
257
+ method,
258
+ typed_data: typedData,
259
+ digest: hashTypedData({
260
+ domain,
261
+ types: { [primaryType]: AUTHORIZATION_TYPE },
262
+ primaryType,
263
+ message: typedData.message,
264
+ }),
265
+ amount: {
266
+ gblin: formatUnits(value, 18),
267
+ atomic_units: value.toString(),
268
+ basis,
269
+ },
270
+ payer_balance: {
271
+ gblin: formatUnits(balance, 18),
272
+ sufficient: balance >= value + feeValue,
273
+ },
274
+ ...(relayBlock ? { relay: relayBlock } : {}),
275
+ next_steps: [
276
+ `Sign typed_data with the wallet of ${from} (eth_signTypedData_v4). The signature never leaves that wallet.`,
277
+ "Pass the signature back to verify_gblin_authorization to check it against the chain before anyone spends gas.",
278
+ method === "receive"
279
+ ? `Only ${to} can submit this one: send the calldata that verify_gblin_authorization returns to the token, from that address.`
280
+ : "Anyone can submit this one: send the calldata that verify_gblin_authorization returns to the token, or hand the x402 payload to a facilitator.",
281
+ ],
282
+ submit: {
283
+ to: GBLIN_VAULT,
284
+ function: method === "receive" ? "receiveWithAuthorization" : "transferWithAuthorization",
285
+ note: "Append the signature: either the 65-byte form split into v, r, s, or the single bytes form. Both are accepted.",
286
+ calldata: "Returned by verify_gblin_authorization once the signature exists and the authorization would settle.",
287
+ },
288
+ x402_payload: {
289
+ note: "Paste the signature into payload.signature. This is the body that goes base64 in the X-PAYMENT header of an endpoint priced in GBLIN.",
290
+ x402Version: 2,
291
+ scheme: "exact",
292
+ network: `eip155:${BASE_CHAIN_ID}`,
293
+ payload: { signature: "0x…", authorization },
294
+ },
295
+ x402_accepts_for_sellers: {
296
+ note: "A seller that wants to be paid in GBLIN publishes this inside the accepts array of its 402 challenge. The extra block is the token's own EIP-712 domain, read from the contract.",
297
+ scheme: "exact",
298
+ network: `eip155:${BASE_CHAIN_ID}`,
299
+ asset: GBLIN_VAULT,
300
+ extra: { name: domain.name, version: domain.version },
301
+ },
302
+ warnings: [
303
+ "An authorization is a bearer claim on the balance until it expires or is used: keep validity short.",
304
+ "The payer needs no ETH; whoever submits the authorization pays the gas.",
305
+ ],
306
+ });
307
+ }
308
+ catch (err) {
309
+ return paymentError(err.message, "Check the addresses and the amount, and that the RPC is reachable.");
310
+ }
311
+ }
312
+ export const RELAY_PAYMENT_TOOL = {
313
+ name: "relay_gblin_payment",
314
+ description: "Have GBLIN's relay carry a signed GBLIN payment on chain for a payer that holds no ETH. Pass the payment and the relay fee, each as { authorization, signature }, both prepared by prepare_gblin_payment with relay: true and signed by the payer's wallet. The relay checks both against the chain, simulates them and submits them in one transaction through Multicall3: either both settle or neither does. The fee is paid in GBLIN at the live NAV. Returns the transaction hash and its outcome. This moves funds: run it only with authorizations the payer meant to sign.",
315
+ inputSchema: {
316
+ type: "object",
317
+ properties: {
318
+ payment: {
319
+ type: "object",
320
+ description: "{ authorization, signature } of the payment, method 'transfer'.",
321
+ properties: { authorization: { type: "object" }, signature: { type: "string", pattern: "^0x[0-9a-fA-F]+$" } },
322
+ required: ["authorization", "signature"],
323
+ },
324
+ fee: {
325
+ type: "object",
326
+ description: "{ authorization, signature } of the relay fee, from prepare_gblin_payment's relay block.",
327
+ properties: { authorization: { type: "object" }, signature: { type: "string", pattern: "^0x[0-9a-fA-F]+$" } },
328
+ required: ["authorization", "signature"],
329
+ },
330
+ },
331
+ required: ["payment", "fee"],
332
+ additionalProperties: false,
333
+ },
334
+ annotations: {
335
+ title: "Relay a gasless GBLIN payment",
336
+ readOnlyHint: false,
337
+ destructiveHint: true,
338
+ idempotentHint: true,
339
+ openWorldHint: true,
340
+ },
341
+ };
342
+ export async function handleRelayPayment(args) {
343
+ try {
344
+ const payment = args.payment;
345
+ const fee = args.fee;
346
+ if (!payment?.authorization || typeof payment.signature !== "string")
347
+ throw new Error("payment must be { authorization, signature }");
348
+ if (!fee?.authorization || typeof fee.signature !== "string")
349
+ throw new Error("fee must be { authorization, signature }");
350
+ const res = await fetch(RELAY_URL, {
351
+ method: "POST",
352
+ headers: { "content-type": "application/json" },
353
+ body: JSON.stringify({ payment, fee }),
354
+ signal: AbortSignal.timeout(45_000),
355
+ });
356
+ const body = (await res.json().catch(() => null));
357
+ if (!body)
358
+ throw new Error(`The relay answered HTTP ${res.status} with no JSON body.`);
359
+ if (!res.ok)
360
+ return paymentError(String(body.error ?? `HTTP ${res.status}`), "Nothing was moved. Fix the cause and sign fresh authorizations if a nonce was consumed.");
361
+ return paymentResult({ relay: RELAY_URL, ...body });
362
+ }
363
+ catch (err) {
364
+ return paymentError(err.message, `Is ${RELAY_URL} reachable from this machine?`);
365
+ }
366
+ }
367
+ export const VERIFY_AUTHORIZATION_TOOL = {
368
+ name: "verify_gblin_authorization",
369
+ description: "Check a signed GBLIN authorization against the chain before spending gas on it. Recovers the signer from the EIP-712 digest (and asks the wallet itself through ERC-1271 when the payer is a contract), then checks the validity window against on-chain time, whether the nonce has already been used or cancelled, and whether the payer still holds the amount. Returns a verdict and the ready calldata when it would settle, the failing reason when it would not. This is the same set of checks an x402 facilitator runs, so a 'would_settle' verdict here means the payment is good to carry.",
370
+ inputSchema: {
371
+ type: "object",
372
+ properties: {
373
+ authorization: {
374
+ type: "object",
375
+ description: "The authorization object: from, to, value, validAfter, validBefore, nonce.",
376
+ additionalProperties: true,
377
+ },
378
+ signature: { type: "string", description: "The signature produced by the payer's wallet, 0x-prefixed." },
379
+ method: {
380
+ type: "string",
381
+ enum: ["receive", "transfer"],
382
+ description: "Which method the signature was produced for. Default 'receive'.",
383
+ },
384
+ },
385
+ required: ["authorization", "signature"],
386
+ additionalProperties: false,
387
+ },
388
+ annotations: {
389
+ title: "Verify a signed GBLIN authorization",
390
+ readOnlyHint: true,
391
+ destructiveHint: false,
392
+ idempotentHint: true,
393
+ openWorldHint: true,
394
+ },
395
+ };
396
+ export async function handleVerifyAuthorization(args) {
397
+ try {
398
+ const raw = (args.authorization ?? {});
399
+ const signature = String(args.signature ?? "");
400
+ if (!/^0x[0-9a-fA-F]+$/.test(signature))
401
+ throw new Error("signature must be 0x-prefixed hex");
402
+ const method = args.method === "transfer" ? "transfer" : "receive";
403
+ const from = requireAddress(raw.from, "authorization.from");
404
+ const to = requireAddress(raw.to, "authorization.to");
405
+ const value = BigInt(String(raw.value));
406
+ const validAfter = BigInt(String(raw.validAfter ?? "0"));
407
+ const validBefore = BigInt(String(raw.validBefore));
408
+ const nonce = String(raw.nonce ?? "");
409
+ if (!/^0x[0-9a-fA-F]{64}$/.test(nonce))
410
+ throw new Error("authorization.nonce must be 32 bytes of hex");
411
+ const primaryType = method === "receive" ? "ReceiveWithAuthorization" : "TransferWithAuthorization";
412
+ const domain = await getTokenDomain();
413
+ const message = {
414
+ from,
415
+ to,
416
+ value: value.toString(),
417
+ validAfter: validAfter.toString(),
418
+ validBefore: validBefore.toString(),
419
+ nonce: nonce,
420
+ };
421
+ const typed = { domain, types: { [primaryType]: AUTHORIZATION_TYPE }, primaryType, message };
422
+ const digest = hashTypedData(typed);
423
+ // The payer may be an ordinary wallet or a contract wallet. Ask the chain which one it is rather
424
+ // than guessing from the signature length: a 65-byte signature can come from either.
425
+ const payerCode = await client.getBytecode({ address: from });
426
+ const payerIsContract = Boolean(payerCode && payerCode !== "0x");
427
+ let signatureValid = false;
428
+ let recoveredSigner = null;
429
+ let signatureCheck;
430
+ if (payerIsContract) {
431
+ signatureCheck = "erc1271";
432
+ try {
433
+ const magic = (await client.readContract({
434
+ address: from,
435
+ abi: ERC1271_ABI,
436
+ functionName: "isValidSignature",
437
+ args: [digest, signature],
438
+ }));
439
+ signatureValid = magic.toLowerCase() === ERC1271_MAGIC;
440
+ }
441
+ catch {
442
+ signatureValid = false;
443
+ }
444
+ }
445
+ else {
446
+ signatureCheck = "ecrecover";
447
+ try {
448
+ recoveredSigner = await recoverTypedDataAddress({ ...typed, signature: signature });
449
+ signatureValid = recoveredSigner.toLowerCase() === from.toLowerCase();
450
+ }
451
+ catch {
452
+ signatureValid = false;
453
+ }
454
+ }
455
+ const [now, used, balance] = await Promise.all([
456
+ getOnChainTimestamp(),
457
+ client.readContract({ address: GBLIN_VAULT, abi: GBLIN_ABI, functionName: "authorizationState", args: [from, nonce] }),
458
+ client.readContract({ address: GBLIN_VAULT, abi: ERC20_ABI, functionName: "balanceOf", args: [from] }),
459
+ ]);
460
+ const checks = {
461
+ signature_valid: signatureValid,
462
+ signature_checked_by: signatureCheck,
463
+ recovered_signer: recoveredSigner,
464
+ not_yet_valid: validAfter > now,
465
+ expired: validBefore <= now,
466
+ nonce_already_used_or_cancelled: used,
467
+ balance_sufficient: balance >= value,
468
+ };
469
+ const failures = [];
470
+ if (!checks.signature_valid) {
471
+ failures.push(payerIsContract
472
+ ? "The payer is a contract wallet and it did not accept this signature (ERC-1271)."
473
+ : "The signature does not recover to the payer. A wrong EIP-712 domain, method or field order gives exactly this.");
474
+ }
475
+ if (checks.not_yet_valid)
476
+ failures.push(`Not valid yet: validAfter is ${validAfter}, chain time is ${now}.`);
477
+ if (checks.expired)
478
+ failures.push(`Expired: validBefore is ${validBefore}, chain time is ${now}.`);
479
+ if (checks.nonce_already_used_or_cancelled)
480
+ failures.push("The nonce has already been used or cancelled; it cannot be replayed.");
481
+ if (!checks.balance_sufficient) {
482
+ failures.push(`The payer holds ${formatUnits(balance, 18)} GBLIN and the authorization is for ${formatUnits(value, 18)}.`);
483
+ }
484
+ const wouldSettle = failures.length === 0;
485
+ const fn = method === "receive" ? "receiveWithAuthorization" : "transferWithAuthorization";
486
+ const compact = signature.length === 132;
487
+ let calldata = null;
488
+ if (wouldSettle && compact) {
489
+ const r = `0x${signature.slice(2, 66)}`;
490
+ const s = `0x${signature.slice(66, 130)}`;
491
+ const v = Number.parseInt(signature.slice(130, 132), 16);
492
+ calldata = encodeFunctionData({
493
+ abi: GBLIN_ABI,
494
+ functionName: fn,
495
+ args: [from, to, value, validAfter, validBefore, nonce, v, r, s],
496
+ });
497
+ }
498
+ return paymentResult({
499
+ would_settle: wouldSettle,
500
+ method,
501
+ digest,
502
+ checks,
503
+ failures,
504
+ amount: { gblin: formatUnits(value, 18), atomic_units: value.toString() },
505
+ submit: wouldSettle
506
+ ? {
507
+ to: GBLIN_VAULT,
508
+ function: fn,
509
+ calldata,
510
+ who_may_submit: method === "receive" ? to : "anyone",
511
+ gas_hint: 120_000,
512
+ note: calldata
513
+ ? "Send this calldata to the token. The payer spends no ETH."
514
+ : "The signature is not the 65-byte form, so the v/r/s calldata was not built; submit it through the bytes overload.",
515
+ }
516
+ : null,
517
+ source: "GBLIN EIP-3009 authorization verifier — EIP-712 domain read from the token, state read from Base",
518
+ });
519
+ }
520
+ catch (err) {
521
+ return paymentError(err.message, "Check the authorization fields and the signature encoding.");
522
+ }
523
+ }
524
+ //# sourceMappingURL=payments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments.js","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,uBAAuB,GAGxB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,2GAA2G;AAC3G,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,uCAAuC,CAAC;AAEzF,mFAAmF;AACnF,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,sGAAsG;AACtG,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAEpC,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG;IACzB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;IAC/B,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACvC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;CAC1B,CAAC;AAEX,mFAAmF;AACnF,MAAM,aAAa,GAAG,YAAY,CAAC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,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,KAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;aACxE,CAAC,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC;YACnB,YAAY,EAAE,WAAW;YACzB,MAAM;YACN,MAAM;YACN,MAAM;YACN,QAAQ;YACR,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE;YACzE,MAAM,EAAE,WAAW;gBACjB,CAAC,CAAC;oBACE,EAAE,EAAE,WAAW;oBACf,QAAQ,EAAE,EAAE;oBACZ,QAAQ;oBACR,cAAc,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;oBACpD,QAAQ,EAAE,OAAO;oBACjB,IAAI,EAAE,QAAQ;wBACZ,CAAC,CAAC,2DAA2D;wBAC7D,CAAC,CAAC,mHAAmH;iBACxH;gBACH,CAAC,CAAC,IAAI;YACR,MAAM,EAAE,kGAAkG;SAC3G,CAAC,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,YAAY,CAAE,GAAa,CAAC,OAAO,EAAE,4DAA4D,CAAC,CAAC;IAC5G,CAAC;AACH,CAAC"}
package/dist/paywall.d.ts CHANGED
@@ -35,7 +35,16 @@ export interface PaywallDef {
35
35
  * attestation exposes that agent to GBLIN and drives PAID calls to the
36
36
  * /api/x402/attestation minting endpoint on the webapp (adoption flywheel).
37
37
  */
38
- export declare const TOOL_PRICES: Record<string, PaywallDef>;
38
+ export declare const TOOL_PRICES: {
39
+ get_market_risk_regime: {
40
+ priceUsdc: string;
41
+ priceLabel: string;
42
+ };
43
+ analyze_treasury_health: {
44
+ priceUsdc: string;
45
+ priceLabel: string;
46
+ };
47
+ };
39
48
  declare const PaymentProofSchema: z.ZodObject<{
40
49
  signature: z.ZodString;
41
50
  payer: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"paywall.d.ts","sourceRoot":"","sources":["../src/paywall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAOlD,CAAC;AAIF,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;EAQtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAa9D;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,IAE9B,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC,CA0DlD"}
1
+ {"version":3,"file":"paywall.d.ts","sourceRoot":"","sources":["../src/paywall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW;;;;;;;;;CAOc,CAAC;AAIvC,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;EAQtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAa9D;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,IAE9B,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC,CA0DlD"}
package/dist/paywall.js CHANGED
@@ -43,7 +43,7 @@ export const TOOL_PRICES = {
43
43
  // swap_gblin_to_usdc_jit and invest_usdc_to_gblin are FREE:
44
44
  // they are the core transport layer — paywalling them creates a chicken-and-egg
45
45
  // problem (agent needs USDC to pay for the tool that gives them USDC).
46
- // Revenue from those flows comes from the on-chain protocol fee (0.05% of every mint, paid as shares).
46
+ // Revenue from those flows comes from the on-chain protocol fee on every mint, paid as shares.
47
47
  };
48
48
  // ─── Payment proof schema ─────────────────────────────────────────────────────
49
49
  const PaymentProofSchema = z.object({
@@ -1 +1 @@
1
- {"version":3,"file":"paywall.js","sourceRoot":"","sources":["../src/paywall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,iFAAiF;AAEjF,MAAM,SAAS,GAAG,4CAAqD,CAAC;AACxE,wEAAwE;AACxE,uEAAuE;AACvE,MAAM,WAAW,GACf,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,mCAAmC,CAAC;AAE1E,gDAAgD;AAChD,uDAAuD;AACvD,MAAM,iBAAiB,GAAG,4CAA4C,CAAC;AAWvE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAA+B;IACrD,sBAAsB,EAAG,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE;IACnF,uBAAuB,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE;IACnF,4DAA4D;IAC5D,gFAAgF;IAChF,uEAAuE;IACvE,uGAAuG;CACxG,CAA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CAAC,CACvD,CAAC;YACF,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,aAAa,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,iCAAiC,EAAE,CAAC,CAAC;QACtG,CAAC;QAED,kBAAkB;QAClB,IAAI,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;YACxC,OAAO,aAAa,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,yCAAyC,EAAE,CAAC,CAAC;QAC9G,CAAC;QAED,8DAA8D;QAC9D,2EAA2E;QAC3E,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC;QAElD,8BAA8B;QAC9B,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * GBLIN MCP — prompts.
3
+ *
4
+ * Ready-made workflows built only from this server's own tools. Each one states its rule before the
5
+ * steps, so the decision an agent reaches can be audited afterwards against the rule it was given.
6
+ */
7
+ export interface PromptArgument {
8
+ name: string;
9
+ description: string;
10
+ required: boolean;
11
+ }
12
+ export interface PromptDefinition {
13
+ name: string;
14
+ title: string;
15
+ description: string;
16
+ arguments: PromptArgument[];
17
+ }
18
+ export declare const PROMPT_DEFINITIONS: PromptDefinition[];
19
+ type Args = Record<string, unknown>;
20
+ declare function message(text: string): {
21
+ messages: {
22
+ role: "user";
23
+ content: {
24
+ type: "text";
25
+ text: string;
26
+ };
27
+ }[];
28
+ };
29
+ export declare function getPrompt(name: string, args?: Args): (ReturnType<typeof message> & {
30
+ description: string;
31
+ }) | null;
32
+ export {};
33
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EA4ChD,CAAC;AAEF,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAOpC,iBAAS,OAAO,CAAC,IAAI,EAAE,MAAM;;;;;;;;EAE5B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAAS,GAAG,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CA2FtH"}