hookr-sdk 0.2.1 → 1.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 (68) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/LICENSE +21 -0
  3. package/MIGRATING.md +89 -0
  4. package/README.md +308 -105
  5. package/dist/core/abi.d.ts +10930 -0
  6. package/dist/core/abi.js +455 -0
  7. package/dist/core/advisories.d.ts +184 -0
  8. package/dist/core/advisories.js +291 -0
  9. package/dist/core/client.d.ts +55 -0
  10. package/dist/core/client.js +107 -0
  11. package/dist/core/generated.d.ts +14295 -0
  12. package/dist/core/generated.js +1058 -0
  13. package/dist/core/index.d.ts +17 -0
  14. package/dist/core/index.js +17 -0
  15. package/dist/core/launch.d.ts +200 -0
  16. package/dist/core/launch.js +427 -0
  17. package/dist/core/pair.d.ts +64 -0
  18. package/dist/core/pair.js +136 -0
  19. package/dist/core/params.d.ts +415 -0
  20. package/dist/core/params.js +1235 -0
  21. package/dist/core/policies.d.ts +136 -0
  22. package/dist/core/policies.js +125 -0
  23. package/dist/core/proofs.d.ts +25 -0
  24. package/dist/core/proofs.js +118 -0
  25. package/dist/core/quotes.d.ts +185 -0
  26. package/dist/core/quotes.js +550 -0
  27. package/dist/core/referrals.d.ts +32 -0
  28. package/dist/core/referrals.js +36 -0
  29. package/dist/core/registry.d.ts +357 -0
  30. package/dist/core/registry.js +378 -0
  31. package/dist/core/rules.d.ts +675 -0
  32. package/dist/core/rules.js +1049 -0
  33. package/dist/core/schema.d.ts +358 -0
  34. package/dist/core/schema.js +105 -0
  35. package/dist/core/stocks.generated.d.ts +11 -0
  36. package/dist/core/stocks.generated.js +1228 -0
  37. package/dist/core/vault.d.ts +59 -0
  38. package/dist/core/vault.js +112 -0
  39. package/dist/core/wallet.d.ts +142 -0
  40. package/dist/core/wallet.js +304 -0
  41. package/dist/deployments.d.ts +8 -0
  42. package/dist/deployments.js +26 -0
  43. package/dist/index.d.ts +42 -15
  44. package/dist/index.js +40 -15
  45. package/dist/releases.d.ts +219 -0
  46. package/dist/releases.js +365 -0
  47. package/dist/wallet-cap.d.ts +159 -0
  48. package/dist/wallet-cap.js +234 -0
  49. package/package.json +46 -10
  50. package/provenance.json +31 -0
  51. package/dist/abi.d.ts +0 -6404
  52. package/dist/abi.js +0 -8300
  53. package/dist/chain.d.ts +0 -87
  54. package/dist/chain.js +0 -86
  55. package/dist/claims.d.ts +0 -32
  56. package/dist/claims.js +0 -31
  57. package/dist/fees.d.ts +0 -59
  58. package/dist/fees.js +0 -142
  59. package/dist/links.d.ts +0 -48
  60. package/dist/links.js +0 -93
  61. package/dist/market.d.ts +0 -264
  62. package/dist/market.js +0 -310
  63. package/dist/reads.d.ts +0 -136
  64. package/dist/reads.js +0 -219
  65. package/dist/rules.d.ts +0 -84
  66. package/dist/rules.js +0 -296
  67. package/dist/swap.d.ts +0 -108
  68. package/dist/swap.js +0 -144
@@ -0,0 +1,357 @@
1
+ import { type Abi, type Hex } from "viem";
2
+ import { type Address, type Call, type DeploymentManifest, type Hash } from "./schema.js";
3
+ import { type Caps } from "./rules.js";
4
+ /** IHookrRegistry.Kind. */
5
+ export declare const ADMISSION_KIND: {
6
+ readonly RULES: 0;
7
+ readonly ADVISORY: 1;
8
+ };
9
+ /** HookrTypes phase bits an advisory may run in. */
10
+ export declare const PHASE: {
11
+ readonly BEFORE_SWAP: 1;
12
+ readonly AFTER_SWAP: 2;
13
+ };
14
+ /** IHookrRegistry.Admission: an immutable, codehash-pinned module admission for one root. */
15
+ export interface Admission {
16
+ kind: 0 | 1;
17
+ implementation: Address;
18
+ codeHash: Hash;
19
+ schemaHash: Hash;
20
+ caps: Caps;
21
+ gasLimit: number;
22
+ phaseMask: number;
23
+ feeOnly: boolean;
24
+ failOpen: boolean;
25
+ }
26
+ /** A timelocked HookrRegistry operation: the kind and the arguments its executing function re-derives. */
27
+ export type RegistryOperation = {
28
+ kind: "SET_LAUNCHER";
29
+ launcher: Address;
30
+ active: boolean;
31
+ } | {
32
+ kind: "SET_QUOTE";
33
+ asset: Address;
34
+ active: boolean;
35
+ }
36
+ /**
37
+ * Admits a whole quote class (`enableQuoteClassOf`): every contract whose runtime codehash is `codeHash` becomes a
38
+ * quote for new pools, the way every Robinhood stock token shares one BeaconProxy runtime
39
+ * (`ROBINHOOD_STOCK_QUOTE_CLASS`). `witness` is a deployed member the registry checks the hash against, when queued
40
+ * and when executed. Withdrawing a class is the immediate brake `buildExcludeQuoteClass`, not an operation.
41
+ */
42
+ | {
43
+ kind: "SET_QUOTE_CLASS";
44
+ witness: Address;
45
+ codeHash: Hash;
46
+ }
47
+ /**
48
+ * Opens new markets to any quote that holds code and is not an EIP-7702 delegated account (`allowOpenQuotes`), the
49
+ * rule the live launchpads apply. Closing them is the immediate brake `buildStopOpenQuotes`.
50
+ */
51
+ | {
52
+ kind: "OPEN_QUOTES";
53
+ }
54
+ /** `codeHash` is the root's runtime codehash; registration refuses any other runtime. */
55
+ | {
56
+ kind: "REGISTER_ROOT";
57
+ root: Address;
58
+ codeHash: Hash;
59
+ } | {
60
+ kind: "RETIRE_ROOT";
61
+ root: Address;
62
+ } | {
63
+ kind: "REOPEN_ROOT";
64
+ root: Address;
65
+ }
66
+ /** `codeHash` is the factory's runtime codehash; activation is refused while the factory is active. */
67
+ | {
68
+ kind: "SET_ROOT_FACTORY";
69
+ factory: Address;
70
+ codeHash: Hash;
71
+ active: boolean;
72
+ }
73
+ /**
74
+ * `root` is a root, or an active root factory admitting a pair advisory (kind ADVISORY) for the pair roots it
75
+ * deploys (`factoryAdmission`). The registry refuses a factory scope before SET_ROOT_FACTORY executes.
76
+ */
77
+ | {
78
+ kind: "ADMIT";
79
+ root: Address;
80
+ admission: Admission;
81
+ } | {
82
+ kind: "TRANSFER_OWNER";
83
+ nextOwner: Address;
84
+ } | {
85
+ kind: "SET_GUARDIAN";
86
+ guardian: Address;
87
+ } | {
88
+ kind: "RESUME_NEW_MARKETS";
89
+ };
90
+ export type RegistryOperationKind = RegistryOperation["kind"];
91
+ /**
92
+ * The quote-admission surface of HookrRegistry: the two timelocked operations (a quote class by
93
+ * runtime codehash, open quotes), their two immediate brakes (owner or guardian), the reads and the events. Written
94
+ * from its compiled ABI; `test/quote-admission.test.ts` pins every item to it (`test/fixtures`) and to the
95
+ * generated ABI once the packet carries them. Their kind constants are private in the registry: keccak256 of the name.
96
+ */
97
+ export declare const QUOTE_ADMISSION_ABI: readonly [{
98
+ readonly name: "enableQuoteClassOf";
99
+ readonly type: "function";
100
+ readonly stateMutability: "nonpayable";
101
+ readonly inputs: readonly [{
102
+ readonly type: "address";
103
+ readonly name: "witness";
104
+ }, {
105
+ readonly type: "bytes32";
106
+ readonly name: "codeHash";
107
+ }];
108
+ readonly outputs: readonly [];
109
+ }, {
110
+ readonly name: "excludeQuoteClassNow";
111
+ readonly type: "function";
112
+ readonly stateMutability: "nonpayable";
113
+ readonly inputs: readonly [{
114
+ readonly type: "bytes32";
115
+ readonly name: "codeHash";
116
+ }];
117
+ readonly outputs: readonly [];
118
+ }, {
119
+ readonly name: "allowOpenQuotes";
120
+ readonly type: "function";
121
+ readonly stateMutability: "nonpayable";
122
+ readonly inputs: readonly [];
123
+ readonly outputs: readonly [];
124
+ }, {
125
+ readonly name: "stopOpenQuotesNow";
126
+ readonly type: "function";
127
+ readonly stateMutability: "nonpayable";
128
+ readonly inputs: readonly [];
129
+ readonly outputs: readonly [];
130
+ }, {
131
+ readonly name: "curatedQuote";
132
+ readonly type: "function";
133
+ readonly stateMutability: "view";
134
+ readonly inputs: readonly [{
135
+ readonly type: "address";
136
+ readonly name: "asset";
137
+ }];
138
+ readonly outputs: readonly [{
139
+ readonly type: "bool";
140
+ }];
141
+ }, {
142
+ readonly name: "quoteState";
143
+ readonly type: "function";
144
+ readonly stateMutability: "view";
145
+ readonly inputs: readonly [];
146
+ readonly outputs: readonly [{
147
+ readonly type: "bool";
148
+ readonly name: "openQuotes";
149
+ }, {
150
+ readonly type: "uint48";
151
+ readonly name: "openQuotesStoppedAt";
152
+ }, {
153
+ readonly type: "bytes32[]";
154
+ readonly name: "classes";
155
+ }];
156
+ }, {
157
+ readonly name: "QuoteClassSet";
158
+ readonly type: "event";
159
+ readonly inputs: readonly [{
160
+ readonly type: "bytes32";
161
+ readonly name: "codeHash";
162
+ readonly indexed: true;
163
+ }, {
164
+ readonly type: "address";
165
+ readonly name: "witness";
166
+ readonly indexed: true;
167
+ }, {
168
+ readonly type: "bool";
169
+ readonly name: "active";
170
+ }];
171
+ }, {
172
+ readonly name: "QuoteClassExcluded";
173
+ readonly type: "event";
174
+ readonly inputs: readonly [{
175
+ readonly type: "bytes32";
176
+ readonly name: "codeHash";
177
+ readonly indexed: true;
178
+ }, {
179
+ readonly type: "address";
180
+ readonly name: "by";
181
+ readonly indexed: true;
182
+ }];
183
+ }, {
184
+ readonly name: "OpenQuotesSet";
185
+ readonly type: "event";
186
+ readonly inputs: readonly [{
187
+ readonly type: "bool";
188
+ readonly name: "open";
189
+ }, {
190
+ readonly type: "address";
191
+ readonly name: "by";
192
+ readonly indexed: true;
193
+ }];
194
+ }, {
195
+ readonly name: "QuoteClassActive";
196
+ readonly type: "error";
197
+ readonly inputs: readonly [{
198
+ readonly type: "bytes32";
199
+ readonly name: "codeHash";
200
+ }];
201
+ }, {
202
+ readonly name: "OpenQuotesActive";
203
+ readonly type: "error";
204
+ readonly inputs: readonly [];
205
+ }, {
206
+ readonly name: "QueuedBeforeBrake";
207
+ readonly type: "error";
208
+ readonly inputs: readonly [{
209
+ readonly type: "bytes32";
210
+ readonly name: "operation";
211
+ }];
212
+ }];
213
+ /** The two quote-admission operations by kind name, and the function each executes with. */
214
+ export declare const QUOTE_ADMISSION_OPERATIONS: {
215
+ readonly SET_QUOTE_CLASS: "enableQuoteClassOf";
216
+ readonly OPEN_QUOTES: "allowOpenQuotes";
217
+ };
218
+ /**
219
+ * Whether `abi` (by default the packet's generated HookrRegistry ABI) carries every quote-admission item with the exact
220
+ * signature. The operations, brakes and reads below refuse an ABI without them, so nothing can build a call the
221
+ * release does not have; a caller that targets another registry build passes that build's ABI.
222
+ */
223
+ export declare function registryHasQuoteAdmission(abi?: Abi): boolean;
224
+ /** Whether `abi` carries the function a quote-admission operation executes with. */
225
+ export declare function registryHasOperation(kind: keyof typeof QUOTE_ADMISSION_OPERATIONS, abi?: Abi): boolean;
226
+ /** A quote class's runtime codehash: nonzero and never the empty-code hash. */
227
+ export declare function quoteClassHash(value: unknown): Hash;
228
+ /** keccak256 of each kind name, as the registry's public constants. */
229
+ export declare const REGISTRY_KINDS: Record<RegistryOperationKind, Hash>;
230
+ /**
231
+ * `queue(kind, arguments)` inputs for an operation, with the canonical ABI arguments. `abi` is the registry build's ABI
232
+ * (default: the packet's); a kind whose executing function it lacks is refused.
233
+ */
234
+ export declare function encodeRegistryOperation(op: RegistryOperation, abi?: Abi): {
235
+ kind: Hash;
236
+ arguments: Hex;
237
+ };
238
+ /**
239
+ * Decodes an `OperationQueued(kind, arguments)` into the operation it will execute. Refuses an unknown kind and any
240
+ * non-canonical argument encoding, as HookrRegistry.queue does.
241
+ */
242
+ export declare function decodeRegistryOperation(kind: Hash, args: Hex, abi?: Abi): RegistryOperation;
243
+ /** HookrRegistry.operationHash: keccak256(abi.encode(chainId, registry, kind, arguments)). */
244
+ export declare function registryOperationHash(chainId: bigint, registry: Address, kind: Hash, args: Hex): Hash;
245
+ /** Owner call that queues `op`; it executes after the registry delay with `buildRegistryExecute`. */
246
+ export declare function buildRegistryQueue(m: DeploymentManifest, op: RegistryOperation, abi?: Abi): Call;
247
+ /** Owner call that executes a matured `op`: the same arguments the queue committed to. */
248
+ export declare function buildRegistryExecute(m: DeploymentManifest, op: RegistryOperation, abi?: Abi): Call;
249
+ /**
250
+ * Brake (owner or guardian, immediate): withdraws quote class `codeHash` from new pools and refuses every admission of
251
+ * it queued until now. Existing pools keep the quote they bound; a catalog entry for the same asset still qualifies it.
252
+ */
253
+ export declare function buildExcludeQuoteClass(m: DeploymentManifest, codeHash: Hash, abi?: Abi): Call;
254
+ /**
255
+ * Brake (owner or guardian, immediate): turns open quotes off for new pools and refuses every opening queued until
256
+ * now. The catalog, the admitted classes and native ETH still qualify; existing pools keep their quote.
257
+ */
258
+ export declare function buildStopOpenQuotes(m: DeploymentManifest, abi?: Abi): Call;
259
+ /** HookrRegistry.quoteState: whether open quotes are on, the last brake that stopped them and the admitted classes. */
260
+ export interface QuoteState {
261
+ openQuotes: boolean;
262
+ /** Unix seconds of the last `stopOpenQuotesNow`; zero when never braked. */
263
+ openQuotesStoppedAt: number;
264
+ /** Runtime codehash of every admitted quote class, in the registry's order. */
265
+ classes: Hash[];
266
+ }
267
+ /** `quoteState()` calldata. */
268
+ export declare function encodeQuoteStateCall(): Hex;
269
+ /** Decodes a `quoteState()` result. */
270
+ export declare function decodeQuoteState(data: Hex): QuoteState;
271
+ /** `curatedQuote(asset)` calldata: native ETH, a catalog asset or a class member, never an open quote. */
272
+ export declare function encodeCuratedQuoteCall(asset: Address): Hex;
273
+ /** Decodes a `curatedQuote(asset)` result. */
274
+ export declare function decodeCuratedQuote(data: Hex): boolean;
275
+ /**
276
+ * Refuses an admission HookrRegistry would refuse on its own terms (the checks that do not read chain state).
277
+ * A Rules admission runs both phases, never fails open and carries exactly `RULES_GAS_LIMIT` gas.
278
+ */
279
+ export declare function checkAdmission(a: Admission): void;
280
+ /**
281
+ * A HookrRules admission: both phases, fail-closed, exactly RULES_GAS_LIMIT gas, and the Rules' schema id
282
+ * (`schemaHash`, RULES_CONFIG_SCHEMA_HASH, the keccak256 of RulesConfig's type string since r26; omitted, it is that
283
+ * id). Any other id is refused: HookrLane checks each admission's schemaHash against the Rules' own
284
+ * configSchemaHash(), so a Rules admitted under another id could never serve a lane pool.
285
+ */
286
+ export declare function rulesAdmission(p: {
287
+ implementation: Address;
288
+ codeHash: Hash;
289
+ schemaHash?: Hash;
290
+ caps: Caps;
291
+ feeOnly: boolean;
292
+ }): Admission;
293
+ /**
294
+ * An advisory admission. `caps` is the advisory's admitted maximum; every pool that binds it reserves that maximum
295
+ * out of its caps (`poolCapsFor`).
296
+ */
297
+ export declare function advisoryAdmission(p: {
298
+ implementation: Address;
299
+ codeHash: Hash;
300
+ schemaHash: Hash;
301
+ caps: Caps;
302
+ gasLimit: number;
303
+ phaseMask: number;
304
+ feeOnly: boolean;
305
+ failOpen: boolean;
306
+ }): Admission;
307
+ /**
308
+ * A pair-advisory admission for a root factory: kind ADVISORY, surcharge cap `maxLpFeePips`, BEFORE_SWAP, fee-only,
309
+ * no quote take, fail closed unless `failOpen`. HookrRootFactory deploys a root naming the advisory only when the
310
+ * root's advisory cap and gas are at most these and the advisory's runtime codehash is `codeHash`; a fail-open root
311
+ * additionally needs a fail-open admission (the rule HookrRoot applies when it binds a fail-open advisory).
312
+ */
313
+ export declare function pairAdvisoryAdmission(p: {
314
+ implementation: Address;
315
+ codeHash: Hash;
316
+ schemaHash: Hash;
317
+ maxLpFeePips: number;
318
+ gasLimit: number;
319
+ failOpen?: boolean;
320
+ }): Admission;
321
+ /** The timelocked ADMIT of a pair advisory scoped to root factory `factory`. */
322
+ export declare function factoryAdmission(factory: Address, admission: Admission): RegistryOperation;
323
+ /**
324
+ * The checks HookrRootFactory.deploy runs on a pair root's advisory against its factory admission (read with
325
+ * `admission(factory, advisory)`) and the advisory's current runtime codehash. A fail-open root charges its full cap
326
+ * whenever the advisory fails, so it needs an admission that is fail-open, fee-only and without a quote take.
327
+ */
328
+ export declare function checkPairRootAdmission(params: {
329
+ advisory: Address;
330
+ advisoryCapPips: number;
331
+ advisoryGasLimit: number;
332
+ advisoryFailOpen?: boolean;
333
+ }, admitted: Admission, advisoryCodeHash: Hash): void;
334
+ /**
335
+ * Brake (owner or guardian, immediate): permanently withdraws root factory `factory`'s admissions of the given pair
336
+ * advisories. Deployed pair roots keep their advisory; `rootStatus` then reads them as unverified.
337
+ */
338
+ export declare function buildRevokeFactoryAdmissions(m: DeploymentManifest, factory: Address, implementations: readonly Address[]): Call;
339
+ /** HookrRegistry.rootStatus: the advisory a root factory recorded for `root` and whether the root is verified. */
340
+ export interface RootStatus {
341
+ advisory: Address;
342
+ verified: boolean;
343
+ }
344
+ /** `rootStatus(root)` calldata. */
345
+ export declare function encodeRootStatusCall(root: Address): Hex;
346
+ /**
347
+ * Decodes a `rootStatus(root)` result. `verified` is true for a registered root whose advisory, if any, is still
348
+ * admitted for its factory with an unchanged runtime codehash; gate pair roots on it.
349
+ */
350
+ export declare function decodeRootStatus(data: Hex): RootStatus;
351
+ /**
352
+ * Whether `code` is an EIP-7702 delegation designator (0xef0100 || target). The registry, the treasury and every
353
+ * HookrGoverned contract refuse such an account as owner, nominee or guardian.
354
+ */
355
+ export declare function isDelegatedCode(code: Hex | undefined): boolean;
356
+ /** Refuses an owner, nominee or guardian account whose code (from eth_getCode) is an EIP-7702 delegation. */
357
+ export declare function checkUndelegated(account: Address, code: Hex | undefined): Address;