@temporalabs/treasury 0.1.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 (55) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +10 -0
  3. package/README.md +153 -0
  4. package/THIRD_PARTY_NOTICES.md +366 -0
  5. package/dist/abi/erc4626.d.ts +243 -0
  6. package/dist/abi/erc4626.js +146 -0
  7. package/dist/abi/erc4626.js.map +1 -0
  8. package/dist/build.d.ts +88 -0
  9. package/dist/build.js +124 -0
  10. package/dist/build.js.map +1 -0
  11. package/dist/client.d.ts +429 -0
  12. package/dist/client.js +248 -0
  13. package/dist/client.js.map +1 -0
  14. package/dist/config/earn.d.ts +47 -0
  15. package/dist/config/earn.js +46 -0
  16. package/dist/config/earn.js.map +1 -0
  17. package/dist/disclosures.d.ts +14 -0
  18. package/dist/disclosures.js +28 -0
  19. package/dist/disclosures.js.map +1 -0
  20. package/dist/index.d.ts +14 -0
  21. package/dist/index.js +10 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/links.d.ts +21 -0
  24. package/dist/links.js +32 -0
  25. package/dist/links.js.map +1 -0
  26. package/dist/mcp/server.d.ts +33 -0
  27. package/dist/mcp/server.js +346 -0
  28. package/dist/mcp/server.js.map +1 -0
  29. package/dist/mcp-server.mjs +56281 -0
  30. package/dist/position.d.ts +142 -0
  31. package/dist/position.js +354 -0
  32. package/dist/position.js.map +1 -0
  33. package/dist/preflight.d.ts +62 -0
  34. package/dist/preflight.js +165 -0
  35. package/dist/preflight.js.map +1 -0
  36. package/dist/quote.d.ts +55 -0
  37. package/dist/quote.js +83 -0
  38. package/dist/quote.js.map +1 -0
  39. package/dist/redact.d.ts +44 -0
  40. package/dist/redact.js +92 -0
  41. package/dist/redact.js.map +1 -0
  42. package/dist/registry-schema.d.ts +127 -0
  43. package/dist/registry-schema.js +124 -0
  44. package/dist/registry-schema.js.map +1 -0
  45. package/dist/registry.d.ts +26 -0
  46. package/dist/registry.js +62 -0
  47. package/dist/registry.js.map +1 -0
  48. package/dist/units.d.ts +8 -0
  49. package/dist/units.js +24 -0
  50. package/dist/units.js.map +1 -0
  51. package/dist/version.d.ts +1 -0
  52. package/dist/version.js +14 -0
  53. package/dist/version.js.map +1 -0
  54. package/package.json +58 -0
  55. package/registry/vaults.json +68 -0
@@ -0,0 +1,429 @@
1
+ import { type HttpTransport, type PublicClient } from "viem";
2
+ export declare const chains: {
3
+ readonly 8453: {
4
+ blockExplorers: {
5
+ readonly default: {
6
+ readonly name: "Basescan";
7
+ readonly url: "https://basescan.org";
8
+ readonly apiUrl: "https://api.basescan.org/api";
9
+ };
10
+ };
11
+ blockTime: 2000;
12
+ contracts: {
13
+ readonly disputeGameFactory: {
14
+ readonly 1: {
15
+ readonly address: "0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e";
16
+ };
17
+ };
18
+ readonly l2OutputOracle: {
19
+ readonly 1: {
20
+ readonly address: "0x56315b90c40730925ec5485cf004d835058518A0";
21
+ };
22
+ };
23
+ readonly multicall3: {
24
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
25
+ readonly blockCreated: 5022;
26
+ };
27
+ readonly portal: {
28
+ readonly 1: {
29
+ readonly address: "0x49048044D57e1C92A77f79988d21Fa8fAF74E97e";
30
+ readonly blockCreated: 17482143;
31
+ };
32
+ };
33
+ readonly l1StandardBridge: {
34
+ readonly 1: {
35
+ readonly address: "0x3154Cf16ccdb4C6d922629664174b904d80F2C35";
36
+ readonly blockCreated: 17482143;
37
+ };
38
+ };
39
+ readonly gasPriceOracle: {
40
+ readonly address: "0x420000000000000000000000000000000000000F";
41
+ };
42
+ readonly l1Block: {
43
+ readonly address: "0x4200000000000000000000000000000000000015";
44
+ };
45
+ readonly l2CrossDomainMessenger: {
46
+ readonly address: "0x4200000000000000000000000000000000000007";
47
+ };
48
+ readonly l2Erc721Bridge: {
49
+ readonly address: "0x4200000000000000000000000000000000000014";
50
+ };
51
+ readonly l2StandardBridge: {
52
+ readonly address: "0x4200000000000000000000000000000000000010";
53
+ };
54
+ readonly l2ToL1MessagePasser: {
55
+ readonly address: "0x4200000000000000000000000000000000000016";
56
+ };
57
+ };
58
+ ensTlds?: readonly string[] | undefined;
59
+ id: 8453;
60
+ name: "Base";
61
+ nativeCurrency: {
62
+ readonly name: "Ether";
63
+ readonly symbol: "ETH";
64
+ readonly decimals: 18;
65
+ };
66
+ experimental_preconfirmationTime?: number | undefined | undefined;
67
+ rpcUrls: {
68
+ readonly default: {
69
+ readonly http: readonly ["https://mainnet.base.org"];
70
+ };
71
+ };
72
+ sourceId: 1;
73
+ supportsTransactionReplacementDetection?: boolean | undefined | undefined;
74
+ testnet?: boolean | undefined | undefined;
75
+ custom?: Record<string, unknown> | undefined;
76
+ extendSchema?: Record<string, unknown> | undefined;
77
+ fees?: import("viem").ChainFees<undefined> | undefined;
78
+ formatters: {
79
+ readonly block: {
80
+ exclude: [] | undefined;
81
+ format: (args: import("viem/chains").OpStackRpcBlock, action?: string | undefined) => {
82
+ baseFeePerGas: bigint | null;
83
+ blobGasUsed: bigint;
84
+ difficulty: bigint;
85
+ excessBlobGas: bigint;
86
+ extraData: import("viem").Hex;
87
+ gasLimit: bigint;
88
+ gasUsed: bigint;
89
+ hash: `0x${string}` | null;
90
+ logsBloom: `0x${string}` | null;
91
+ miner: import("viem").Address;
92
+ mixHash: import("viem").Hash;
93
+ nonce: `0x${string}` | null;
94
+ number: bigint | null;
95
+ parentBeaconBlockRoot?: `0x${string}` | undefined;
96
+ parentHash: import("viem").Hash;
97
+ receiptsRoot: import("viem").Hex;
98
+ sealFields: import("viem").Hex[];
99
+ sha3Uncles: import("viem").Hash;
100
+ size: bigint;
101
+ stateRoot: import("viem").Hash;
102
+ timestamp: bigint;
103
+ totalDifficulty: bigint | null;
104
+ transactions: `0x${string}`[] | import("viem/chains").OpStackTransaction<boolean>[];
105
+ transactionsRoot: import("viem").Hash;
106
+ uncles: import("viem").Hash[];
107
+ withdrawals?: import("viem").Withdrawal[] | undefined | undefined;
108
+ withdrawalsRoot?: `0x${string}` | undefined;
109
+ } & {};
110
+ type: "block";
111
+ };
112
+ readonly transaction: {
113
+ exclude: [] | undefined;
114
+ format: (args: import("viem/chains").OpStackRpcTransaction, action?: string | undefined) => ({
115
+ blockHash: `0x${string}` | null;
116
+ blockNumber: bigint | null;
117
+ blockTimestamp?: bigint | undefined;
118
+ from: import("viem").Address;
119
+ gas: bigint;
120
+ hash: import("viem").Hash;
121
+ input: import("viem").Hex;
122
+ nonce: number;
123
+ r: import("viem").Hex;
124
+ s: import("viem").Hex;
125
+ to: import("viem").Address | null;
126
+ transactionIndex: number | null;
127
+ typeHex: import("viem").Hex | null;
128
+ v: bigint;
129
+ value: bigint;
130
+ yParity: number;
131
+ gasPrice?: undefined | undefined;
132
+ maxFeePerBlobGas?: undefined | undefined;
133
+ maxFeePerGas: bigint;
134
+ maxPriorityFeePerGas: bigint;
135
+ isSystemTx?: boolean;
136
+ mint?: bigint | undefined | undefined;
137
+ sourceHash: import("viem").Hex;
138
+ type: "deposit";
139
+ } | {
140
+ r: import("viem").Hex;
141
+ s: import("viem").Hex;
142
+ v: bigint;
143
+ to: import("viem").Address | null;
144
+ from: import("viem").Address;
145
+ gas: bigint;
146
+ nonce: number;
147
+ value: bigint;
148
+ blockHash: `0x${string}` | null;
149
+ blockNumber: bigint | null;
150
+ blockTimestamp?: bigint | undefined;
151
+ hash: import("viem").Hash;
152
+ input: import("viem").Hex;
153
+ transactionIndex: number | null;
154
+ typeHex: import("viem").Hex | null;
155
+ accessList?: undefined | undefined;
156
+ authorizationList?: undefined | undefined;
157
+ blobVersionedHashes?: undefined | undefined;
158
+ chainId?: number | undefined;
159
+ yParity?: undefined | undefined;
160
+ type: "legacy";
161
+ gasPrice: bigint;
162
+ maxFeePerBlobGas?: undefined | undefined;
163
+ maxFeePerGas?: undefined | undefined;
164
+ maxPriorityFeePerGas?: undefined | undefined;
165
+ isSystemTx?: undefined | undefined;
166
+ mint?: undefined | undefined;
167
+ sourceHash?: undefined | undefined;
168
+ } | {
169
+ blockHash: `0x${string}` | null;
170
+ blockNumber: bigint | null;
171
+ blockTimestamp?: bigint | undefined;
172
+ from: import("viem").Address;
173
+ gas: bigint;
174
+ hash: import("viem").Hash;
175
+ input: import("viem").Hex;
176
+ nonce: number;
177
+ r: import("viem").Hex;
178
+ s: import("viem").Hex;
179
+ to: import("viem").Address | null;
180
+ transactionIndex: number | null;
181
+ typeHex: import("viem").Hex | null;
182
+ v: bigint;
183
+ value: bigint;
184
+ yParity: number;
185
+ accessList: import("viem").AccessList;
186
+ authorizationList?: undefined | undefined;
187
+ blobVersionedHashes?: undefined | undefined;
188
+ chainId: number;
189
+ type: "eip2930";
190
+ gasPrice: bigint;
191
+ maxFeePerBlobGas?: undefined | undefined;
192
+ maxFeePerGas?: undefined | undefined;
193
+ maxPriorityFeePerGas?: undefined | undefined;
194
+ isSystemTx?: undefined | undefined;
195
+ mint?: undefined | undefined;
196
+ sourceHash?: undefined | undefined;
197
+ } | {
198
+ blockHash: `0x${string}` | null;
199
+ blockNumber: bigint | null;
200
+ blockTimestamp?: bigint | undefined;
201
+ from: import("viem").Address;
202
+ gas: bigint;
203
+ hash: import("viem").Hash;
204
+ input: import("viem").Hex;
205
+ nonce: number;
206
+ r: import("viem").Hex;
207
+ s: import("viem").Hex;
208
+ to: import("viem").Address | null;
209
+ transactionIndex: number | null;
210
+ typeHex: import("viem").Hex | null;
211
+ v: bigint;
212
+ value: bigint;
213
+ yParity: number;
214
+ accessList: import("viem").AccessList;
215
+ authorizationList?: undefined | undefined;
216
+ blobVersionedHashes?: undefined | undefined;
217
+ chainId: number;
218
+ type: "eip1559";
219
+ gasPrice?: undefined | undefined;
220
+ maxFeePerBlobGas?: undefined | undefined;
221
+ maxFeePerGas: bigint;
222
+ maxPriorityFeePerGas: bigint;
223
+ isSystemTx?: undefined | undefined;
224
+ mint?: undefined | undefined;
225
+ sourceHash?: undefined | undefined;
226
+ } | {
227
+ blockHash: `0x${string}` | null;
228
+ blockNumber: bigint | null;
229
+ blockTimestamp?: bigint | undefined;
230
+ from: import("viem").Address;
231
+ gas: bigint;
232
+ hash: import("viem").Hash;
233
+ input: import("viem").Hex;
234
+ nonce: number;
235
+ r: import("viem").Hex;
236
+ s: import("viem").Hex;
237
+ to: import("viem").Address | null;
238
+ transactionIndex: number | null;
239
+ typeHex: import("viem").Hex | null;
240
+ v: bigint;
241
+ value: bigint;
242
+ yParity: number;
243
+ accessList: import("viem").AccessList;
244
+ authorizationList?: undefined | undefined;
245
+ blobVersionedHashes: readonly import("viem").Hex[];
246
+ chainId: number;
247
+ type: "eip4844";
248
+ gasPrice?: undefined | undefined;
249
+ maxFeePerBlobGas: bigint;
250
+ maxFeePerGas: bigint;
251
+ maxPriorityFeePerGas: bigint;
252
+ isSystemTx?: undefined | undefined;
253
+ mint?: undefined | undefined;
254
+ sourceHash?: undefined | undefined;
255
+ } | {
256
+ blockHash: `0x${string}` | null;
257
+ blockNumber: bigint | null;
258
+ blockTimestamp?: bigint | undefined;
259
+ from: import("viem").Address;
260
+ gas: bigint;
261
+ hash: import("viem").Hash;
262
+ input: import("viem").Hex;
263
+ nonce: number;
264
+ r: import("viem").Hex;
265
+ s: import("viem").Hex;
266
+ to: import("viem").Address | null;
267
+ transactionIndex: number | null;
268
+ typeHex: import("viem").Hex | null;
269
+ v: bigint;
270
+ value: bigint;
271
+ yParity: number;
272
+ accessList: import("viem").AccessList;
273
+ authorizationList: import("viem").SignedAuthorizationList;
274
+ blobVersionedHashes?: undefined | undefined;
275
+ chainId: number;
276
+ type: "eip7702";
277
+ gasPrice?: undefined | undefined;
278
+ maxFeePerBlobGas?: undefined | undefined;
279
+ maxFeePerGas: bigint;
280
+ maxPriorityFeePerGas: bigint;
281
+ isSystemTx?: undefined | undefined;
282
+ mint?: undefined | undefined;
283
+ sourceHash?: undefined | undefined;
284
+ }) & {};
285
+ type: "transaction";
286
+ };
287
+ readonly transactionReceipt: {
288
+ exclude: [] | undefined;
289
+ format: (args: import("viem/chains").OpStackRpcTransactionReceipt, action?: string | undefined) => {
290
+ blobGasPrice?: bigint | undefined;
291
+ blobGasUsed?: bigint | undefined;
292
+ blockHash: import("viem").Hash;
293
+ blockNumber: bigint;
294
+ blockTimestamp?: bigint | undefined;
295
+ contractAddress: import("viem").Address | null | undefined;
296
+ cumulativeGasUsed: bigint;
297
+ effectiveGasPrice: bigint;
298
+ from: import("viem").Address;
299
+ gasUsed: bigint;
300
+ logs: import("viem").Log<bigint, number, false>[];
301
+ logsBloom: import("viem").Hex;
302
+ root?: `0x${string}` | undefined;
303
+ status: "success" | "reverted";
304
+ to: import("viem").Address | null;
305
+ transactionHash: import("viem").Hash;
306
+ transactionIndex: number;
307
+ type: import("viem").TransactionType;
308
+ depositNonce?: bigint | undefined | undefined;
309
+ depositReceiptVersion?: number | undefined | undefined;
310
+ l1GasPrice: bigint | null;
311
+ l1GasUsed: bigint | null;
312
+ l1Fee: bigint | null;
313
+ l1FeeScalar: number | null;
314
+ } & {};
315
+ type: "transactionReceipt";
316
+ };
317
+ };
318
+ prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
319
+ client: import("viem").Client;
320
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
321
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
322
+ client: import("viem").Client;
323
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
324
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
325
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
326
+ }] | undefined;
327
+ serializers: {
328
+ readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
329
+ };
330
+ verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
331
+ };
332
+ };
333
+ export type SupportedChainId = keyof typeof chains;
334
+ export declare function isSupportedChainId(id: number): id is SupportedChainId;
335
+ /**
336
+ * Read-only client. This module constructs exactly one kind of thing — a public (unsigned)
337
+ * client from an RPC URL. It never constructs a wallet client: the signer is the consumer's,
338
+ * handed in from outside if at all (see `build.ts`, which emits unsigned calls only).
339
+ */
340
+ export type ReadClient = PublicClient<HttpTransport, (typeof chains)[SupportedChainId]>;
341
+ /** The public endpoint used when nothing is configured, and the fallback for event scans. */
342
+ export declare const PUBLIC_RPC: Record<SupportedChainId, string>;
343
+ /**
344
+ * A `fetch` that waits out HTTP 429 instead of failing the tool. Measured 2026-09-14: a free-tier
345
+ * keyed Base RPC answered an `earn_quote` read with 429 and the tool failed outright, because viem's
346
+ * own retries (3, from 150 ms) are spent in under a second. Only a 429 is retried here, up to 5 times,
347
+ * honouring `Retry-After` when present and otherwise backing off from 500 ms, with the sleeps capped at
348
+ * `RATE_LIMIT_WAIT_MS` in total whatever the headers say.
349
+ *
350
+ * The transport's deadline (`RPC_TIMEOUT_MS`, viem's own 10 s) wraps this whole loop and is enforced by
351
+ * ABORT: viem only reports its `TimeoutError` when the fetch throws an abort error, and resolves a value
352
+ * returned after the abort as-is. So the sleep races the abort signal, and on abort the LAST 429 is
353
+ * handed back — the caller then sees the provider's 429, never "The request took too long to respond".
354
+ * Measured 2026-09-17 before this: a keyed provider at its monthly cap answered 429 in 77 ms, the loop
355
+ * slept through the deadline, and a whole live tier read as "the RPC is slow" when the key was out of
356
+ * quota. The deadline itself is NOT raised: a host that accepts and never answers must still fail at
357
+ * 10 s (measured in review: 25.5 s made `earn_status` 2.5× slower on exactly that case).
358
+ *
359
+ * A 429 whose body carries the one measured exhausted-plan sentence is returned at once — it resets
360
+ * next period, not in seconds. ONLY that sentence: a bare /capacity/ also matched Alchemy's per-second
361
+ * throttle body ("exceeded its compute units per second capacity") and a "temporarily at capacity"
362
+ * message, and would have disabled the wait on the exact case it exists for (measured in review).
363
+ * An unrecognised body is waited out and then reported plainly — the safe direction.
364
+ * An unreachable host is deliberately NOT stretched out: that is a fault to report, not a limit to
365
+ * wait for, and `earn_status` must answer quickly when the RPC is down.
366
+ */
367
+ export declare const RATE_LIMIT_WAIT_MS = 15500;
368
+ /** The transport's whole-call deadline — viem's default, set explicitly because the wrapper's design depends on it. */
369
+ export declare const RPC_TIMEOUT_MS = 10000;
370
+ export declare function makeRateLimitedFetch(base?: typeof fetch, sleep?: (ms: number) => Promise<void>): typeof fetch;
371
+ export declare function makePublicClient(chainId: SupportedChainId, rpcUrl: string): ReadClient;
372
+ /**
373
+ * An env value counts as an RPC URL only if it parses as one with an http(s) scheme. Anything else —
374
+ * empty, whitespace, a non-URL, and in particular an UNEXPANDED placeholder like `${TREASURY_RPC_BASE}` —
375
+ * is treated as unset. Measured 2026-09-12: Claude Code forwards the plugin's `.mcp.json` value
376
+ * `${TREASURY_RPC_BASE}` verbatim when the host variable is unset, and with the old `if (v)` test every
377
+ * RPC-touching tool died on "Failed to parse URL from ${TREASURY_RPC_BASE}". `.mcp.json` now also uses
378
+ * `${VAR:-}`, but this guard is what makes the server independent of any host's expansion rules.
379
+ */
380
+ export declare function rpcUrlFromEnvValue(v: string | undefined): string | undefined;
381
+ /**
382
+ * Resolves the RPC URL for a chain from the environment. ⚠️ A keyed provider URL IS a secret: it must
383
+ * never appear in tool output — every error crossing the tool boundary goes through `describeError`
384
+ * (`src/redact.ts`), which strips endpoints. Fallback names after `TREASURY_RPC_BASE`:
385
+ * `BASE_RPC_URL`; the plugin's `.mcp.json` passes only the `TREASURY_*` pair through, so under the
386
+ * packaged path the fallback is unreachable.
387
+ * `TREASURY_LOGS_RPC_BASE`, if set, is preferred for log scans (providers cap eth_getLogs ranges very
388
+ * differently: Alchemy free 10 blocks, Base public 2,000) — see `position.ts`.
389
+ */
390
+ export declare function rpcUrlFromEnv(chainId: SupportedChainId): string;
391
+ /**
392
+ * The endpoint an event scan falls back to when the configured logs RPC cannot cover the range — and
393
+ * the operator's opt-out from it. `TREASURY_LOGS_FALLBACK` unset ⇒ Base's public endpoint; an http(s)
394
+ * URL ⇒ that endpoint; ANY other value — `off`, `none`, `disabled`, a typo — ⇒ no fallback at all, and
395
+ * the scan degrades to a cut-short window as it did before the fallback existed. It exists because the fallback
396
+ * otherwise sends a query to a third party the operator never named, which some
397
+ * deployments cannot accept — and it fails CLOSED for the same reason.
398
+ */
399
+ export declare function logsFallbackUrlFromEnv(chainId: SupportedChainId, logsUrl: string): string | undefined;
400
+ /** RPC to use for eth_getLogs scans: a dedicated one if configured, else the general one. */
401
+ export declare function logsRpcUrlFromEnv(chainId: SupportedChainId): string;
402
+ /**
403
+ * Which environment variable supplied the RPC URL — the NAME only, never the value. A keyed provider
404
+ * URL is a secret, so `earn_status` reports provenance and nothing else. `configured: false` means
405
+ * no variable resolved and the public endpoint is in use (rate-limited, never a failure).
406
+ */
407
+ export declare function rpcSourceForEnv(chainId: SupportedChainId): {
408
+ source: string;
409
+ configured: boolean;
410
+ };
411
+ /**
412
+ * Every RPC secret VALUE this process could be holding — the resolved URLs plus the parts of them
413
+ * that carry the credential (path segments, query values, and a subdomain-keyed provider's first
414
+ * label). Fed to `registerSecretSource` so the redactor masks the literal wherever it appears,
415
+ * including inside a provider's own error body, where no shape rule can reach it.
416
+ *
417
+ * ⚠️ Returns VALUES, and is used only to mask them. It must never be logged or returned by a tool.
418
+ */
419
+ export declare function resolvedRpcSecrets(): string[];
420
+ /**
421
+ * The one sentence a caller needs when the public endpoint is what broke them.
422
+ *
423
+ * 🔴 Measured 2026-09-12 through the installed plugin with no configuration: the deposit pre-flight
424
+ * returns UNRESOLVED 3/3 on `mainnet.base.org` ("RPC Request failed") and NEEDS_APPROVAL 3/3 on a
425
+ * keyed URL. So zero-config can browse vaults and read terms but CANNOT complete a deposit — and the
426
+ * message it fails with reads as "this product is broken" rather than "you need a key". Returns
427
+ * undefined when a keyed RPC resolved, so a real chain fault is never mislabelled as a setup problem.
428
+ */
429
+ export declare function publicRpcHint(chainId: SupportedChainId): string | undefined;