@morpho-dev/router 0.1.18 → 0.2.1

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 (53) hide show
  1. package/README.md +29 -19
  2. package/dist/chunk-jass6xSI.mjs +13 -0
  3. package/dist/cli.js +6574 -6194
  4. package/dist/drizzle/migrations/0000_setup_single_migration_folder.sql +204 -0
  5. package/dist/drizzle/migrations/0001_add-trigger-for-consumed-events.sql +58 -0
  6. package/dist/drizzle/migrations/0002_insert-status-code.sql +1 -0
  7. package/dist/drizzle/migrations/0003_update-triggers-for-consumed-events.sql +3 -0
  8. package/dist/drizzle/migrations/0004_drop-status-offers-foreign-key-constraint.sql +1 -0
  9. package/dist/drizzle/migrations/0005_add-index-to-boost-group-query-and-offer-hash.sql +1 -0
  10. package/dist/drizzle/migrations/0006_add-callbacks-and-positions-relations.sql +37 -0
  11. package/dist/drizzle/migrations/0008_validation.sql +15 -0
  12. package/dist/drizzle/migrations/0009_add-transfers-table.sql +14 -0
  13. package/dist/drizzle/migrations/0010_add-price.sql +1 -0
  14. package/dist/drizzle/migrations/0011_nullable-callback-amount.sql +1 -0
  15. package/dist/drizzle/migrations/0012_add-position-asset.sql +1 -0
  16. package/dist/drizzle/migrations/0013_remove-depecrated-domains.sql +13 -0
  17. package/dist/drizzle/migrations/0014_rename-offers-v2-into-offers.sql +23 -0
  18. package/dist/drizzle/{router_v1.4 → migrations}/meta/0000_snapshot.json +858 -78
  19. package/dist/drizzle/migrations/meta/0001_snapshot.json +1752 -0
  20. package/dist/drizzle/migrations/meta/0002_snapshot.json +1752 -0
  21. package/dist/drizzle/migrations/meta/0003_snapshot.json +1752 -0
  22. package/dist/drizzle/{router_v1.4/meta/0001_snapshot.json → migrations/meta/0004_snapshot.json} +848 -78
  23. package/dist/drizzle/migrations/meta/0005_snapshot.json +1775 -0
  24. package/dist/drizzle/migrations/meta/0006_snapshot.json +1973 -0
  25. package/dist/drizzle/migrations/meta/0008_snapshot.json +1955 -0
  26. package/dist/drizzle/migrations/meta/0009_snapshot.json +2078 -0
  27. package/dist/drizzle/migrations/meta/0010_snapshot.json +2084 -0
  28. package/dist/drizzle/migrations/meta/0013_snapshot.json +1290 -0
  29. package/dist/drizzle/migrations/meta/0014_snapshot.json +1290 -0
  30. package/dist/drizzle/migrations/meta/_journal.json +104 -0
  31. package/dist/index.browser.d.mts +2794 -0
  32. package/dist/index.browser.d.mts.map +1 -0
  33. package/dist/index.browser.d.ts +2290 -1172
  34. package/dist/index.browser.d.ts.map +1 -0
  35. package/dist/index.browser.js +3820 -2519
  36. package/dist/index.browser.js.map +1 -1
  37. package/dist/index.browser.mjs +3615 -2467
  38. package/dist/index.browser.mjs.map +1 -1
  39. package/dist/index.node.d.mts +4987 -0
  40. package/dist/index.node.d.mts.map +1 -0
  41. package/dist/index.node.d.ts +4423 -2906
  42. package/dist/index.node.d.ts.map +1 -0
  43. package/dist/index.node.js +7810 -6141
  44. package/dist/index.node.js.map +1 -1
  45. package/dist/index.node.mjs +7556 -6102
  46. package/dist/index.node.mjs.map +1 -1
  47. package/package.json +29 -15
  48. package/dist/cli.js.map +0 -1
  49. package/dist/drizzle/router_v1.4/0000_add_obligation_id.sql +0 -112
  50. package/dist/drizzle/router_v1.4/0001_update-primary-key-on-link.sql +0 -3
  51. package/dist/drizzle/router_v1.4/meta/_journal.json +0 -20
  52. package/dist/index.browser.d.cts +0 -1675
  53. package/dist/index.node.d.cts +0 -3471
@@ -1,267 +1,369 @@
1
- import { z as z$1 } from 'zod/v4';
2
- import { Hex, Address, AbiEvent, PublicClient, GetLogsReturnType, WalletClient, PublicActions } from 'viem';
3
- import * as z from 'zod';
4
- import { Chain as Chain$2 } from 'viem/chains';
5
- import * as node_modules_zod_openapi_dist_components_CXzxKPFp_js from 'node_modules/zod-openapi/dist/components-CXzxKPFp.js';
1
+ import { z } from "zod/v4";
2
+ import { AbiEvent, Address, ChainContract, ChainFormatters, GetLogsReturnType, Hex, MulticallParameters, PublicClient, Transport, WalletClient } from "viem";
3
+ import { Chain } from "viem/chains";
4
+ import * as z$1 from "zod";
5
+ import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
6
+ import { OpenAPIDocument } from "openapi-metadata";
7
+ import { Client } from "openapi-fetch";
6
8
 
7
- declare const CollectorHealth: z$1.ZodObject<{
8
- name: z$1.ZodString;
9
- chain_id: z$1.ZodNumber;
10
- block_number: z$1.ZodNullable<z$1.ZodNumber>;
11
- updated_at: z$1.ZodNullable<z$1.ZodString>;
12
- lag: z$1.ZodNullable<z$1.ZodNumber>;
13
- status: z$1.ZodEnum<{
14
- live: "live";
15
- lagging: "lagging";
16
- unknown: "unknown";
17
- }>;
18
- }, z$1.core.$strip>;
19
- declare const ChainHealth: z$1.ZodObject<{
20
- chain_id: z$1.ZodNumber;
21
- block_number: z$1.ZodNumber;
22
- updated_at: z$1.ZodString;
23
- }, z$1.core.$strip>;
24
- declare const CollectorsHealthResponse: z$1.ZodArray<z$1.ZodObject<{
25
- name: z$1.ZodString;
26
- chain_id: z$1.ZodNumber;
27
- block_number: z$1.ZodNullable<z$1.ZodNumber>;
28
- updated_at: z$1.ZodNullable<z$1.ZodString>;
29
- lag: z$1.ZodNullable<z$1.ZodNumber>;
30
- status: z$1.ZodEnum<{
31
- live: "live";
32
- lagging: "lagging";
33
- unknown: "unknown";
34
- }>;
35
- }, z$1.core.$strip>>;
36
- type CollectorsHealthResponse = z$1.infer<typeof CollectorsHealthResponse>;
37
- declare const ChainsHealthResponse: z$1.ZodArray<z$1.ZodObject<{
38
- chain_id: z$1.ZodNumber;
39
- block_number: z$1.ZodNumber;
40
- updated_at: z$1.ZodString;
41
- }, z$1.core.$strip>>;
42
- type ChainsHealthResponse = z$1.infer<typeof ChainsHealthResponse>;
43
- declare const RouterStatusResponse: z$1.ZodObject<{
44
- status: z$1.ZodEnum<{
45
- live: "live";
46
- syncing: "syncing";
47
- }>;
48
- }, z$1.core.$strip>;
49
- type RouterStatusResponse = z$1.infer<typeof RouterStatusResponse>;
50
-
51
- declare const Oracle: readonly [{
52
- readonly type: "function";
53
- readonly name: "price";
54
- readonly inputs: readonly [];
55
- readonly outputs: readonly [{
56
- readonly name: "";
57
- readonly type: "uint256";
58
- }];
59
- readonly stateMutability: "view";
9
+ //#region rolldown:runtime
10
+ declare namespace BookResponse_d_exports {
11
+ export { BookLevelResponse, from$13 as from };
12
+ }
13
+ type BookLevelResponse = {
14
+ rate: string;
15
+ assets: string;
16
+ count: number;
17
+ };
18
+ declare function from$13(level: {
19
+ rate: bigint;
20
+ assets: bigint;
21
+ count: number;
22
+ }): BookLevelResponse;
23
+ //#endregion
24
+ //#region src/api/Schema/health.d.ts
25
+ declare const CollectorHealth: z.ZodObject<{
26
+ name: z.ZodString;
27
+ chain_id: z.ZodNumber;
28
+ block_number: z.ZodNullable<z.ZodNumber>;
29
+ updated_at: z.ZodNullable<z.ZodString>;
30
+ lag: z.ZodNullable<z.ZodNumber>;
31
+ status: z.ZodEnum<{
32
+ live: "live";
33
+ lagging: "lagging";
34
+ unknown: "unknown";
35
+ }>;
36
+ }, z.core.$strip>;
37
+ declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
38
+ name: z.ZodString;
39
+ chain_id: z.ZodNumber;
40
+ block_number: z.ZodNullable<z.ZodNumber>;
41
+ updated_at: z.ZodNullable<z.ZodString>;
42
+ lag: z.ZodNullable<z.ZodNumber>;
43
+ status: z.ZodEnum<{
44
+ live: "live";
45
+ lagging: "lagging";
46
+ unknown: "unknown";
47
+ }>;
48
+ }, z.core.$strip>>;
49
+ declare const ChainHealth: z.ZodObject<{
50
+ chain_id: z.ZodNumber;
51
+ local_block_number: z.ZodNumber;
52
+ remote_block_number: z.ZodNullable<z.ZodNumber>;
53
+ updated_at: z.ZodString;
54
+ }, z.core.$strip>;
55
+ declare const ChainsHealthResponse: z.ZodArray<z.ZodObject<{
56
+ chain_id: z.ZodNumber;
57
+ local_block_number: z.ZodNumber;
58
+ remote_block_number: z.ZodNullable<z.ZodNumber>;
59
+ updated_at: z.ZodString;
60
+ }, z.core.$strip>>;
61
+ declare const RouterStatusResponse: z.ZodObject<{
62
+ status: z.ZodEnum<{
63
+ live: "live";
64
+ syncing: "syncing";
65
+ }>;
66
+ }, z.core.$strip>;
67
+ type CollectorsHealthResponse = z.infer<typeof CollectorsHealthResponse>;
68
+ type ChainsHealthResponse = z.infer<typeof ChainsHealthResponse>;
69
+ type RouterStatusResponse = z.infer<typeof RouterStatusResponse>;
70
+ //#endregion
71
+ //#region src/core/Abi/MetaMorpho.d.ts
72
+ declare const MetaMorpho: readonly [{
73
+ readonly name: "balanceOf";
74
+ readonly type: "function";
75
+ readonly stateMutability: "view";
76
+ readonly inputs: readonly [{
77
+ readonly type: "address";
78
+ readonly name: "account";
79
+ }];
80
+ readonly outputs: readonly [{
81
+ readonly type: "uint256";
82
+ }];
83
+ }, {
84
+ readonly name: "DECIMALS_OFFSET";
85
+ readonly type: "function";
86
+ readonly stateMutability: "view";
87
+ readonly inputs: readonly [];
88
+ readonly outputs: readonly [{
89
+ readonly type: "uint8";
90
+ }];
91
+ }, {
92
+ readonly name: "totalAssets";
93
+ readonly type: "function";
94
+ readonly stateMutability: "view";
95
+ readonly inputs: readonly [];
96
+ readonly outputs: readonly [{
97
+ readonly type: "uint256";
98
+ }];
99
+ }, {
100
+ readonly name: "totalSupply";
101
+ readonly type: "function";
102
+ readonly stateMutability: "view";
103
+ readonly inputs: readonly [];
104
+ readonly outputs: readonly [{
105
+ readonly type: "uint256";
106
+ }];
107
+ }, {
108
+ readonly name: "maxWithdraw";
109
+ readonly type: "function";
110
+ readonly stateMutability: "view";
111
+ readonly inputs: readonly [{
112
+ readonly type: "address";
113
+ readonly name: "owner";
114
+ }];
115
+ readonly outputs: readonly [{
116
+ readonly type: "uint256";
117
+ readonly name: "assets";
118
+ }];
119
+ }, {
120
+ readonly name: "asset";
121
+ readonly type: "function";
122
+ readonly stateMutability: "view";
123
+ readonly inputs: readonly [];
124
+ readonly outputs: readonly [{
125
+ readonly type: "address";
126
+ }];
127
+ }, {
128
+ readonly name: "Transfer";
129
+ readonly type: "event";
130
+ readonly inputs: readonly [{
131
+ readonly type: "address";
132
+ readonly name: "from";
133
+ readonly indexed: true;
134
+ }, {
135
+ readonly type: "address";
136
+ readonly name: "to";
137
+ readonly indexed: true;
138
+ }, {
139
+ readonly type: "uint256";
140
+ readonly name: "value";
141
+ }];
142
+ }, {
143
+ readonly name: "withdrawQueue";
144
+ readonly type: "function";
145
+ readonly stateMutability: "view";
146
+ readonly inputs: readonly [{
147
+ readonly type: "uint256";
148
+ readonly name: "index";
149
+ }];
150
+ readonly outputs: readonly [{
151
+ readonly type: "bytes32";
152
+ }];
153
+ }, {
154
+ readonly name: "withdrawQueueLength";
155
+ readonly type: "function";
156
+ readonly stateMutability: "view";
157
+ readonly inputs: readonly [];
158
+ readonly outputs: readonly [{
159
+ readonly type: "uint256";
160
+ }];
60
161
  }];
61
- declare const ERC4626: readonly [{
62
- readonly type: "function";
162
+ type MetaMorpho = typeof MetaMorpho;
163
+ //#endregion
164
+ //#region src/core/Abi/MetaMorphoFactory.d.ts
165
+ declare const MetaMorphoFactory: readonly [{
166
+ readonly name: "CreateMetaMorpho";
167
+ readonly type: "event";
168
+ readonly inputs: readonly [{
169
+ readonly type: "address";
170
+ readonly name: "metaMorpho";
171
+ readonly indexed: true;
172
+ }, {
173
+ readonly type: "address";
174
+ readonly name: "caller";
175
+ readonly indexed: true;
176
+ }, {
177
+ readonly type: "address";
178
+ readonly name: "initialOwner";
179
+ }, {
180
+ readonly type: "uint256";
181
+ readonly name: "initialTimelock";
182
+ }, {
183
+ readonly type: "address";
63
184
  readonly name: "asset";
64
- readonly inputs: readonly [];
65
- readonly outputs: readonly [{
66
- readonly name: "";
67
- readonly type: "address";
68
- }];
69
- readonly stateMutability: "view";
185
+ readonly indexed: true;
186
+ }, {
187
+ readonly type: "string";
188
+ readonly name: "name";
189
+ }, {
190
+ readonly type: "string";
191
+ readonly name: "symbol";
192
+ }, {
193
+ readonly type: "bytes32";
194
+ readonly name: "salt";
195
+ }];
196
+ }, {
197
+ readonly name: "isMetaMorpho";
198
+ readonly type: "function";
199
+ readonly stateMutability: "view";
200
+ readonly inputs: readonly [{
201
+ readonly type: "address";
202
+ }];
203
+ readonly outputs: readonly [{
204
+ readonly type: "bool";
205
+ }];
70
206
  }];
71
- declare const MetaMorphoFactory: readonly [{
72
- readonly type: "function";
73
- readonly name: "isMetaMorpho";
74
- readonly inputs: readonly [{
75
- readonly name: "target";
76
- readonly type: "address";
77
- }];
78
- readonly outputs: readonly [{
79
- readonly name: "";
80
- readonly type: "bool";
81
- }];
82
- readonly stateMutability: "view";
207
+ type MetaMorphoFactory = typeof MetaMorphoFactory;
208
+ declare namespace index_d_exports {
209
+ export { ERC4626, MetaMorpho, MetaMorphoFactory, Morpho, Oracle$1 as Oracle };
210
+ }
211
+ declare const Oracle$1: readonly [{
212
+ readonly type: "function";
213
+ readonly name: "price";
214
+ readonly inputs: readonly [];
215
+ readonly outputs: readonly [{
216
+ readonly name: "";
217
+ readonly type: "uint256";
218
+ }];
219
+ readonly stateMutability: "view";
83
220
  }];
84
- declare const MetaMorpho: readonly [{
85
- readonly type: "function";
86
- readonly name: "withdrawQueue";
87
- readonly inputs: readonly [{
88
- readonly name: "index";
89
- readonly type: "uint256";
90
- }];
91
- readonly outputs: readonly [{
92
- readonly name: "";
93
- readonly type: "bytes32";
94
- }];
95
- readonly stateMutability: "view";
96
- }, {
97
- readonly type: "function";
98
- readonly name: "withdrawQueueLength";
99
- readonly inputs: readonly [];
100
- readonly outputs: readonly [{
101
- readonly name: "";
102
- readonly type: "uint256";
103
- }];
104
- readonly stateMutability: "view";
105
- }, {
106
- readonly type: "function";
107
- readonly name: "maxWithdraw";
108
- readonly inputs: readonly [{
109
- readonly name: "owner";
110
- readonly type: "address";
111
- }];
112
- readonly outputs: readonly [{
113
- readonly name: "";
114
- readonly type: "uint256";
115
- }];
116
- readonly stateMutability: "view";
221
+ declare const ERC4626: readonly [{
222
+ readonly type: "function";
223
+ readonly name: "asset";
224
+ readonly inputs: readonly [];
225
+ readonly outputs: readonly [{
226
+ readonly name: "";
227
+ readonly type: "address";
228
+ }];
229
+ readonly stateMutability: "view";
117
230
  }];
118
231
  declare const Morpho: readonly [{
119
- readonly type: "function";
120
- readonly name: "collateralOf";
121
- readonly inputs: readonly [{
122
- readonly name: "";
123
- readonly type: "address";
124
- readonly internalType: "address";
125
- }, {
126
- readonly name: "";
127
- readonly type: "bytes32";
128
- readonly internalType: "bytes32";
129
- }, {
130
- readonly name: "";
131
- readonly type: "address";
132
- readonly internalType: "address";
133
- }];
134
- readonly outputs: readonly [{
135
- readonly name: "";
136
- readonly type: "uint256";
137
- readonly internalType: "uint256";
138
- }];
139
- readonly stateMutability: "view";
232
+ readonly type: "function";
233
+ readonly name: "collateralOf";
234
+ readonly inputs: readonly [{
235
+ readonly name: "";
236
+ readonly type: "address";
237
+ readonly internalType: "address";
238
+ }, {
239
+ readonly name: "";
240
+ readonly type: "bytes32";
241
+ readonly internalType: "bytes32";
242
+ }, {
243
+ readonly name: "";
244
+ readonly type: "address";
245
+ readonly internalType: "address";
246
+ }];
247
+ readonly outputs: readonly [{
248
+ readonly name: "";
249
+ readonly type: "uint256";
250
+ readonly internalType: "uint256";
251
+ }];
252
+ readonly stateMutability: "view";
140
253
  }, {
141
- readonly type: "function";
142
- readonly name: "debtOf";
143
- readonly inputs: readonly [{
144
- readonly name: "";
145
- readonly type: "address";
146
- readonly internalType: "address";
147
- }, {
148
- readonly name: "";
149
- readonly type: "bytes32";
150
- readonly internalType: "bytes32";
151
- }];
152
- readonly outputs: readonly [{
153
- readonly name: "";
154
- readonly type: "uint256";
155
- readonly internalType: "uint256";
156
- }];
157
- readonly stateMutability: "view";
254
+ readonly type: "function";
255
+ readonly name: "debtOf";
256
+ readonly inputs: readonly [{
257
+ readonly name: "";
258
+ readonly type: "address";
259
+ readonly internalType: "address";
260
+ }, {
261
+ readonly name: "";
262
+ readonly type: "bytes32";
263
+ readonly internalType: "bytes32";
264
+ }];
265
+ readonly outputs: readonly [{
266
+ readonly name: "";
267
+ readonly type: "uint256";
268
+ readonly internalType: "uint256";
269
+ }];
270
+ readonly stateMutability: "view";
158
271
  }, {
159
- readonly type: "function";
160
- readonly name: "market";
161
- readonly inputs: readonly [{
162
- readonly name: "id";
163
- readonly type: "bytes32";
164
- readonly internalType: "Id";
165
- }];
166
- readonly outputs: readonly [{
167
- readonly name: "totalSupplyAssets";
168
- readonly type: "uint128";
169
- readonly internalType: "uint128";
170
- }, {
171
- readonly name: "totalSupplyShares";
172
- readonly type: "uint128";
173
- readonly internalType: "uint128";
174
- }, {
175
- readonly name: "totalBorrowAssets";
176
- readonly type: "uint128";
177
- readonly internalType: "uint128";
178
- }, {
179
- readonly name: "totalBorrowShares";
180
- readonly type: "uint128";
181
- readonly internalType: "uint128";
182
- }, {
183
- readonly name: "lastUpdate";
184
- readonly type: "uint128";
185
- readonly internalType: "uint128";
186
- }, {
187
- readonly name: "fee";
188
- readonly type: "uint128";
189
- readonly internalType: "uint128";
190
- }];
191
- readonly stateMutability: "view";
272
+ readonly type: "function";
273
+ readonly name: "market";
274
+ readonly inputs: readonly [{
275
+ readonly name: "id";
276
+ readonly type: "bytes32";
277
+ readonly internalType: "Id";
278
+ }];
279
+ readonly outputs: readonly [{
280
+ readonly name: "totalSupplyAssets";
281
+ readonly type: "uint128";
282
+ readonly internalType: "uint128";
283
+ }, {
284
+ readonly name: "totalSupplyShares";
285
+ readonly type: "uint128";
286
+ readonly internalType: "uint128";
287
+ }, {
288
+ readonly name: "totalBorrowAssets";
289
+ readonly type: "uint128";
290
+ readonly internalType: "uint128";
291
+ }, {
292
+ readonly name: "totalBorrowShares";
293
+ readonly type: "uint128";
294
+ readonly internalType: "uint128";
295
+ }, {
296
+ readonly name: "lastUpdate";
297
+ readonly type: "uint128";
298
+ readonly internalType: "uint128";
299
+ }, {
300
+ readonly name: "fee";
301
+ readonly type: "uint128";
302
+ readonly internalType: "uint128";
303
+ }];
304
+ readonly stateMutability: "view";
192
305
  }, {
193
- readonly type: "function";
194
- readonly name: "position";
195
- readonly inputs: readonly [{
196
- readonly name: "id";
197
- readonly type: "bytes32";
198
- readonly internalType: "Id";
199
- }, {
200
- readonly name: "user";
201
- readonly type: "address";
202
- readonly internalType: "address";
203
- }];
204
- readonly outputs: readonly [{
205
- readonly name: "supplyShares";
206
- readonly type: "uint256";
207
- readonly internalType: "uint256";
208
- }, {
209
- readonly name: "borrowShares";
210
- readonly type: "uint128";
211
- readonly internalType: "uint128";
212
- }, {
213
- readonly name: "collateral";
214
- readonly type: "uint128";
215
- readonly internalType: "uint128";
216
- }];
217
- readonly stateMutability: "view";
306
+ readonly type: "function";
307
+ readonly name: "position";
308
+ readonly inputs: readonly [{
309
+ readonly name: "id";
310
+ readonly type: "bytes32";
311
+ readonly internalType: "Id";
312
+ }, {
313
+ readonly name: "user";
314
+ readonly type: "address";
315
+ readonly internalType: "address";
316
+ }];
317
+ readonly outputs: readonly [{
318
+ readonly name: "supplyShares";
319
+ readonly type: "uint256";
320
+ readonly internalType: "uint256";
321
+ }, {
322
+ readonly name: "borrowShares";
323
+ readonly type: "uint128";
324
+ readonly internalType: "uint128";
325
+ }, {
326
+ readonly name: "collateral";
327
+ readonly type: "uint128";
328
+ readonly internalType: "uint128";
329
+ }];
330
+ readonly stateMutability: "view";
218
331
  }];
219
-
220
- declare const Abi_ERC4626: typeof ERC4626;
221
- declare const Abi_MetaMorpho: typeof MetaMorpho;
222
- declare const Abi_MetaMorphoFactory: typeof MetaMorphoFactory;
223
- declare const Abi_Morpho: typeof Morpho;
224
- declare const Abi_Oracle: typeof Oracle;
225
- declare namespace Abi {
226
- export { Abi_ERC4626 as ERC4626, Abi_MetaMorpho as MetaMorpho, Abi_MetaMorphoFactory as MetaMorphoFactory, Abi_Morpho as Morpho, Abi_Oracle as Oracle };
332
+ declare namespace Callback_d_exports {
333
+ export { CallbackType, decode$3 as decode, decodeBuyVaultV1Callback, decodeSellERC20Callback, encode$3 as encode, encodeBuyVaultV1Callback, encodeSellERC20Callback, isEmptyCallback };
227
334
  }
228
-
229
335
  declare enum CallbackType {
230
- BuyWithEmptyCallback = "buy_with_empty_callback",
231
- BuyVaultV1Callback = "buy_vault_v1_callback",
232
- SellERC20Callback = "sell_erc20_callback"
336
+ BuyWithEmptyCallback = "buy_with_empty_callback",
337
+ BuyVaultV1Callback = "buy_vault_v1_callback",
338
+ SellERC20Callback = "sell_erc20_callback",
233
339
  }
234
- declare const WhitelistedCallbackAddresses: Record<CallbackType, readonly string[]>;
340
+ declare const isEmptyCallback: (offer: Offer) => boolean;
341
+ declare function decode$3(type: CallbackType, data: Hex): {
342
+ contract: Address;
343
+ amount: bigint;
344
+ }[];
345
+ declare function encode$3(type: CallbackType, data: any): Hex;
235
346
  declare function decodeBuyVaultV1Callback(data: Hex): Array<{
236
- vault: Address;
237
- amount: bigint;
347
+ contract: Address;
348
+ amount: bigint;
238
349
  }>;
239
350
  declare function decodeSellERC20Callback(data: Hex): Array<{
240
- collateral: Address;
241
- amount: bigint;
351
+ contract: Address;
352
+ amount: bigint;
242
353
  }>;
243
354
  declare function encodeBuyVaultV1Callback(parameters: {
244
- vaults: Address[];
245
- amounts: bigint[];
355
+ vaults: Address[];
356
+ amounts: bigint[];
246
357
  }): Hex;
247
358
  declare function encodeSellERC20Callback(parameters: {
248
- collaterals: Address[];
249
- amounts: bigint[];
359
+ collaterals: Address[];
360
+ amounts: bigint[];
250
361
  }): Hex;
251
-
252
- type Callback_CallbackType = CallbackType;
253
- declare const Callback_CallbackType: typeof CallbackType;
254
- declare const Callback_WhitelistedCallbackAddresses: typeof WhitelistedCallbackAddresses;
255
- declare const Callback_decodeBuyVaultV1Callback: typeof decodeBuyVaultV1Callback;
256
- declare const Callback_decodeSellERC20Callback: typeof decodeSellERC20Callback;
257
- declare const Callback_encodeBuyVaultV1Callback: typeof encodeBuyVaultV1Callback;
258
- declare const Callback_encodeSellERC20Callback: typeof encodeSellERC20Callback;
259
- declare namespace Callback {
260
- export { Callback_CallbackType as CallbackType, Callback_WhitelistedCallbackAddresses as WhitelistedCallbackAddresses, Callback_decodeBuyVaultV1Callback as decodeBuyVaultV1Callback, Callback_decodeSellERC20Callback as decodeSellERC20Callback, Callback_encodeBuyVaultV1Callback as encodeBuyVaultV1Callback, Callback_encodeSellERC20Callback as encodeSellERC20Callback };
362
+ declare namespace Errors_d_exports {
363
+ export { BaseError, GlobalErrorType, ReorgError };
261
364
  }
262
-
263
365
  type GlobalErrorType<name extends string = "Error"> = Error & {
264
- name: name;
366
+ name: name;
265
367
  };
266
368
  /**
267
369
  * Base error class inherited by all errors thrown by mempool.
@@ -273,117 +375,94 @@ type GlobalErrorType<name extends string = "Error"> = Error & {
273
375
  * ```
274
376
  */
275
377
  declare class BaseError<cause extends Error | undefined = undefined> extends Error {
276
- details: string;
277
- shortMessage: string;
278
- cause: cause;
279
- name: string;
280
- constructor(shortMessage: string, options?: {
281
- cause?: cause | undefined;
282
- details?: string | undefined;
283
- metaMessages?: (string | undefined)[] | undefined;
284
- });
285
- walk(): Error;
286
- walk(fn: (err: unknown) => boolean): Error | null;
378
+ details: string;
379
+ shortMessage: string;
380
+ cause: cause;
381
+ name: string;
382
+ constructor(shortMessage: string, options?: {
383
+ cause?: cause | undefined;
384
+ details?: string | undefined;
385
+ metaMessages?: (string | undefined)[] | undefined;
386
+ });
387
+ walk(): Error;
388
+ walk(fn: (err: unknown) => boolean): Error | null;
287
389
  }
288
-
289
- type Errors_BaseError<cause extends Error | undefined = undefined> = BaseError<cause>;
290
- declare const Errors_BaseError: typeof BaseError;
291
- type Errors_GlobalErrorType<name extends string = "Error"> = GlobalErrorType<name>;
292
- declare namespace Errors {
293
- export { Errors_BaseError as BaseError, type Errors_GlobalErrorType as GlobalErrorType };
390
+ declare class ReorgError extends BaseError {
391
+ name: string;
392
+ constructor(blockNumber: number);
294
393
  }
295
-
296
- /** Combines members of an intersection into a readable type. */
297
- type Compute<type> = {
298
- [key in keyof type]: type[key];
299
- } & unknown;
300
- declare const BrandTypeId: unique symbol;
301
- type Brand<in out ID extends string | symbol> = {
302
- readonly [BrandTypeId]: {
303
- readonly [id in ID]: ID;
394
+ declare namespace Chain_d_exports {
395
+ export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name, chainIds, chainNames, chains$1 as chains, getChain, getWhitelistedChains, streamLogs };
396
+ }
397
+ type Chain$1 = Compute<Chain<ChainFormatters, {
398
+ morpho: ChainContract;
399
+ morphoBlue: ChainContract;
400
+ mempool: ChainContract;
401
+ vaults: {
402
+ factories: {
403
+ v1_0: ChainContract;
404
+ v1_1: ChainContract;
304
405
  };
305
- };
306
-
307
- declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet", "anvil"];
308
- type ChainName = (typeof chainNames)[number];
406
+ };
407
+ }> & {
408
+ id: Id;
409
+ name: Name;
410
+ }>;
309
411
  declare const ChainId: {
310
- ETHEREUM: bigint;
311
- BASE: bigint;
312
- "ETHEREUM-VIRTUAL-TESTNET": bigint;
313
- ANVIL: bigint;
412
+ readonly ETHEREUM: 1;
413
+ readonly BASE: 8453;
414
+ readonly "ETHEREUM-VIRTUAL-TESTNET": 109111114;
415
+ readonly ANVIL: 505050505;
314
416
  };
315
- type Id = (typeof ChainId)[keyof typeof ChainId];
316
- declare const chainIds: Set<bigint>;
317
- type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
318
- id: Id;
319
- name: ChainName;
320
- whitelistedAssets: Set<Address>;
321
- morpho: Address;
322
- morphoBlue: Address;
323
- mempool: {
324
- address: Address;
325
- deploymentBlock: number;
326
- reindexBuffer: number;
327
- };
328
- vaultV1Factory: Record<string, Address>;
329
- }>;
330
- declare function getChain(chainId: Id): Chain | undefined;
331
- declare const getWhitelistedChains: () => Chain[];
332
- declare const chains: Record<ChainName, Chain>;
417
+ type Name = Lowercase<keyof typeof ChainId>;
418
+ declare const chainNames: readonly Name[];
419
+ type Id = (typeof ChainId)[Uppercase<Name>];
420
+ declare const chainIds: readonly Id[];
421
+ declare function getChain(chainId: Id): Chain$1 | undefined;
422
+ declare const getWhitelistedChains: () => Chain$1[];
423
+ declare const chains$1: Record<Lowercase<Name>, Chain$1>;
333
424
  declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(parameters: {
334
- client: PublicClient;
335
- contractAddress: Address;
336
- event?: abiEvent;
337
- blockNumberGte?: number;
338
- blockNumberLte?: number;
339
- order: "asc" | "desc";
340
- options: {
341
- maxBatchSize?: number;
342
- blockWindow?: number;
343
- };
425
+ client: PublicClient;
426
+ contractAddress?: Address;
427
+ event?: abiEvent;
428
+ blockNumberGte?: number;
429
+ blockNumberLte?: number;
430
+ order: "asc" | "desc";
431
+ options: {
432
+ maxBatchSize?: number;
433
+ blockWindow?: number;
434
+ };
344
435
  }): AsyncGenerator<{
345
- logs: GetLogsReturnType<abiEvent | undefined>;
346
- blockNumber: number;
436
+ logs: GetLogsReturnType<abiEvent | undefined>;
437
+ blockNumber: number;
347
438
  }, void, void>;
348
439
  declare class InvalidBlockRangeError extends BaseError {
349
- name: string;
350
- constructor(fromBlock: bigint, toBlock: bigint);
440
+ name: string;
441
+ constructor(fromBlock: bigint, toBlock: bigint);
351
442
  }
352
443
  declare class InvalidBlockWindowError extends BaseError {
353
- name: string;
354
- constructor(blockWindow: number);
444
+ name: string;
445
+ constructor(blockWindow: number);
355
446
  }
356
447
  declare class InvalidBatchSizeError extends BaseError {
357
- name: string;
358
- constructor(maxBatchSize: number);
448
+ name: string;
449
+ constructor(maxBatchSize: number);
359
450
  }
360
451
  declare class MissingBlockNumberError extends BaseError {
361
- name: string;
362
- constructor();
452
+ name: string;
453
+ constructor();
363
454
  }
364
-
365
- type Chain$1_Chain = Chain;
366
- declare const Chain$1_ChainId: typeof ChainId;
367
- type Chain$1_ChainName = ChainName;
368
- type Chain$1_Id = Id;
369
- type Chain$1_InvalidBatchSizeError = InvalidBatchSizeError;
370
- declare const Chain$1_InvalidBatchSizeError: typeof InvalidBatchSizeError;
371
- type Chain$1_InvalidBlockRangeError = InvalidBlockRangeError;
372
- declare const Chain$1_InvalidBlockRangeError: typeof InvalidBlockRangeError;
373
- type Chain$1_InvalidBlockWindowError = InvalidBlockWindowError;
374
- declare const Chain$1_InvalidBlockWindowError: typeof InvalidBlockWindowError;
375
- type Chain$1_MissingBlockNumberError = MissingBlockNumberError;
376
- declare const Chain$1_MissingBlockNumberError: typeof MissingBlockNumberError;
377
- declare const Chain$1_chainIds: typeof chainIds;
378
- declare const Chain$1_chainNames: typeof chainNames;
379
- declare const Chain$1_chains: typeof chains;
380
- declare const Chain$1_getChain: typeof getChain;
381
- declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
382
- declare const Chain$1_streamLogs: typeof streamLogs;
383
- declare namespace Chain$1 {
384
- export { type Chain$1_Chain as Chain, Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, type Chain$1_Id as Id, Chain$1_InvalidBatchSizeError as InvalidBatchSizeError, Chain$1_InvalidBlockRangeError as InvalidBlockRangeError, Chain$1_InvalidBlockWindowError as InvalidBlockWindowError, Chain$1_MissingBlockNumberError as MissingBlockNumberError, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains, Chain$1_streamLogs as streamLogs };
455
+ //#endregion
456
+ //#region src/core/types.d.ts
457
+ /** Combines members of an intersection into a readable type. */
458
+ type Compute<type> = { [key in keyof type]: type[key] } & unknown;
459
+ declare const BrandTypeId: unique symbol;
460
+ type Brand<in out ID extends string | symbol> = {
461
+ readonly [BrandTypeId]: { readonly [id in ID]: ID };
462
+ };
463
+ declare namespace LLTV_d_exports {
464
+ export { InvalidLLTVError, InvalidOptionError$1 as InvalidOptionError, LLTV, LLTVSchema, Options, from$12 as from };
385
465
  }
386
-
387
466
  type LLTV = bigint & Brand<"LLTV">;
388
467
  declare const Options: readonly [0.385, 0.5, 0.625, 0.77, 0.86, 0.915, 0.945, 0.965, 0.98];
389
468
  type Options = (typeof Options)[number];
@@ -392,76 +471,161 @@ type Options = (typeof Options)[number];
392
471
  * @param lltv - The LLTV option or the scaled LLTV.
393
472
  * @returns The LLTV.
394
473
  */
395
- declare function from$8(lltv: Options | bigint): LLTV;
396
- declare namespace from$8 {
397
- type ErrorType = InvalidOptionError$1 | InvalidLLTVError;
474
+ declare function from$12(lltv: Options | bigint): LLTV;
475
+ declare namespace from$12 {
476
+ type ErrorType = InvalidOptionError$1 | InvalidLLTVError;
398
477
  }
399
478
  declare class InvalidOptionError$1 extends BaseError {
400
- readonly name = "LLTV.InvalidOptionError";
401
- constructor(input: number);
479
+ readonly name = "LLTV.InvalidOptionError";
480
+ constructor(input: number);
402
481
  }
403
482
  declare class InvalidLLTVError extends BaseError {
404
- readonly name = "LLTV.InvalidLLTVError";
405
- constructor(input: bigint);
483
+ readonly name = "LLTV.InvalidLLTVError";
484
+ constructor(input: bigint);
406
485
  }
407
- declare const LLTVSchema: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
408
-
409
- type LLTV$1_InvalidLLTVError = InvalidLLTVError;
410
- declare const LLTV$1_InvalidLLTVError: typeof InvalidLLTVError;
411
- type LLTV$1_LLTV = LLTV;
412
- declare const LLTV$1_LLTVSchema: typeof LLTVSchema;
413
- type LLTV$1_Options = Options;
414
- declare namespace LLTV$1 {
415
- export { LLTV$1_InvalidLLTVError as InvalidLLTVError, InvalidOptionError$1 as InvalidOptionError, type LLTV$1_LLTV as LLTV, LLTV$1_LLTVSchema as LLTVSchema, type LLTV$1_Options as Options, from$8 as from };
486
+ declare const LLTVSchema: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
487
+ declare namespace Collateral_d_exports {
488
+ export { Collateral, CollateralSchema, CollateralsSchema, from$11 as from, random$3 as random };
416
489
  }
417
-
418
490
  type Collateral = {
419
- /** Asset being used as collateral. */
491
+ /** Asset being used as collateral. */
492
+ asset: Address;
493
+ /** Liquidation Loan-to-Value of the collateral. */
494
+ lltv: LLTV;
495
+ /** Oracle contract used to price the collateral. */
496
+ oracle: Address;
497
+ };
498
+ declare const CollateralSchema: z$1.ZodObject<{
499
+ asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
500
+ oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
501
+ lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
502
+ }, z$1.core.$strip>;
503
+ declare const CollateralsSchema: z$1.ZodArray<z$1.ZodObject<{
504
+ asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
505
+ oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
506
+ lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
507
+ }, z$1.core.$strip>>;
508
+ declare const from$11: (parameters: from$11.Parameters) => from$11.ReturnType;
509
+ declare namespace from$11 {
510
+ type Parameters = {
420
511
  asset: Address;
421
- /** Liquidation Loan-to-Value of the collateral. */
422
- lltv: LLTV;
423
- /** Oracle contract used to price the collateral. */
512
+ lltv: Options | bigint;
424
513
  oracle: Address;
425
- };
426
- declare const CollateralSchema: z.ZodObject<{
427
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
428
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
429
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
430
- }, z.core.$strip>;
431
- declare const CollateralsSchema: z.ZodArray<z.ZodObject<{
432
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
433
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
434
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
435
- }, z.core.$strip>>;
436
- declare const from$7: (parameters: from$7.Parameters) => from$7.ReturnType;
437
- declare namespace from$7 {
438
- type Parameters = {
439
- asset: Address;
440
- lltv: Options | bigint;
441
- oracle: Address;
442
- };
443
- type ReturnType = Collateral;
514
+ };
515
+ type ReturnType = Collateral;
444
516
  }
445
-
446
- type Collateral$1_Collateral = Collateral;
447
- declare const Collateral$1_CollateralSchema: typeof CollateralSchema;
448
- declare const Collateral$1_CollateralsSchema: typeof CollateralsSchema;
449
- declare namespace Collateral$1 {
450
- export { type Collateral$1_Collateral as Collateral, Collateral$1_CollateralSchema as CollateralSchema, Collateral$1_CollateralsSchema as CollateralsSchema, from$7 as from };
517
+ /**
518
+ * Generates a random collateral.
519
+ * @returns A randomly generated collateral. {@link random.ReturnType}
520
+ *
521
+ * @example
522
+ * ```ts
523
+ * const collateral = Collateral.random();
524
+ * ```
525
+ */
526
+ declare function random$3(): random$3.ReturnType;
527
+ declare namespace random$3 {
528
+ type ReturnType = Collateral;
529
+ }
530
+ declare namespace ERC4626_d_exports {
531
+ export { DenominatorIsZeroError, convertToAssets, convertToShares, decimalsOffset };
532
+ }
533
+ /**
534
+ * Calculate the decimals offset used by the ERC4626 implementation.
535
+ * @param parameters - {@link decimalsOffset.Parameters}.
536
+ * @returns The decimals offset.
537
+ *
538
+ * @example
539
+ * ```ts
540
+ * const decimalsOffset = decimalsOffset({ underlyingDecimals: 6 });
541
+ * // decimalsOffset = 12
542
+ * ```
543
+ */
544
+ declare function decimalsOffset(parameters: decimalsOffset.Parameters): number;
545
+ declare namespace decimalsOffset {
546
+ type Parameters = {
547
+ /** The number of decimals of the underlying asset. */
548
+ underlyingDecimals: number;
549
+ };
550
+ type ReturnType = number;
551
+ }
552
+ /**
553
+ * Convert shares to assets.
554
+ * @throws If the denominator is 0. {@link DenominatorIsZeroError}
555
+ * @param parameters - {@link convertToAssets.Parameters}.
556
+ * @returns The amount of assets.
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * const assets = convertToAssets(100n, { totalAssets: 1000n, totalSupply: 1000n, decimalsOffset: 18 });
561
+ * // assets = 100n
562
+ * ```
563
+ */
564
+ declare function convertToAssets(parameters: convertToAssets.Parameters): convertToAssets.ReturnType;
565
+ declare namespace convertToAssets {
566
+ type Parameters = {
567
+ /** The amount of shares to convert. */
568
+ shares: bigint;
569
+ /** Total amount of assets in the vault. */
570
+ totalAssets: bigint;
571
+ /** Total amount of shares in the vault. */
572
+ totalSupply: bigint;
573
+ /**
574
+ * OpenZeppelin decimals offset used by the ERC4626 implementation.
575
+ * Calculated to be `max(0, 18 - underlyingDecimals)` at construction, so the initial conversion rate maximizes
576
+ * precision between shares and assets.
577
+ */
578
+ decimalsOffset: number;
579
+ };
580
+ type ReturnType = bigint;
581
+ type ErrorType = DenominatorIsZeroError;
582
+ }
583
+ /**
584
+ * Convert assets to shares.
585
+ * @throws If the denominator is 0. {@link DenominatorIsZeroError}
586
+ * @param parameters - {@link convertToShares.Parameters}.
587
+ * @returns The amount of shares.
588
+ *
589
+ * @example
590
+ * ```ts
591
+ * const shares = convertToShares(100n, { totalAssets: 1000n, totalSupply: 1000n, decimalsOffset: 12 });
592
+ * // shares = 100n
593
+ * ```
594
+ */
595
+ declare function convertToShares(parameters: convertToShares.Parameters): convertToShares.ReturnType;
596
+ declare namespace convertToShares {
597
+ type Parameters = {
598
+ /** The amount of assets to convert. */
599
+ assets: bigint;
600
+ /** Total amount of assets in the vault. */
601
+ totalAssets: bigint;
602
+ /** Total amount of shares in the vault. */
603
+ totalSupply: bigint;
604
+ /**
605
+ * OpenZeppelin decimals offset used by the ERC4626 implementation.
606
+ * Calculated to be `max(0, 18 - underlyingDecimals)` at construction, so the initial conversion rate maximizes
607
+ * precision between shares and assets.
608
+ */
609
+ decimalsOffset: number;
610
+ };
611
+ type ReturnType = bigint;
612
+ type ErrorType = DenominatorIsZeroError;
613
+ }
614
+ declare class DenominatorIsZeroError extends BaseError {
615
+ readonly name = "ERC4626.DenominatorIsZeroError";
616
+ constructor();
617
+ }
618
+ declare namespace Format_d_exports {
619
+ export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
451
620
  }
452
-
453
621
  /** The snake case representation of a type with bigint values stringified. */
454
- type Snake<T> = SnakeKeys<StringifiedBigint<T>>;
622
+ type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
623
+ /** Make arrays/tuples and object props mutable, deeply. */
624
+ type DeepMutable<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? { -readonly [K in keyof R]: DeepMutable<R[K]> } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? { -readonly [K in keyof T]: DeepMutable<T[K]> } : T;
455
625
  /** Stringifies bigint values to strings and preserves branded primitives. */
456
- type StringifiedBigint<T> = [
457
- T
458
- ] extends [bigint] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? {
459
- [K in keyof T]: StringifiedBigint<T[K]>;
460
- } : T;
626
+ type StringifiedBigint<T> = [T] extends [bigint] ? string : [T] extends [`0x${string}`] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? { [K in keyof T]: StringifiedBigint<T[K]> } : T;
461
627
  /** Key remapping that also preserves branded primitives. */
462
- type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? {
463
- [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]>;
464
- } : T;
628
+ type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? { [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]> } : T;
465
629
  type ToSnakeCase<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${ToSnakeCase<Tail>}` : `${Lowercase<Head>}_${ToSnakeCase<Uncapitalize<Tail>>}` : S;
466
630
  /**
467
631
  * Formats object keys to snake case.
@@ -477,24 +641,30 @@ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
477
641
  * @warning Does not unstringify bigint values.
478
642
  */
479
643
  declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
480
-
481
- type Format_Snake<T> = Snake<T>;
482
- declare namespace Format {
483
- export { type Format_Snake as Snake, fromSnakeCase$3 as fromSnakeCase, toSnakeCase$1 as toSnakeCase };
644
+ declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
645
+ declare namespace Maturity_d_exports {
646
+ export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$10 as from };
484
647
  }
485
-
486
648
  /**
487
649
  * Maturity is a number that represents a date in seconds.
488
650
  */
489
651
  type Maturity = number & Brand<"Maturity">;
490
- declare const MaturitySchema: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
652
+ declare const MaturitySchema: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
653
+ declare enum MaturityType {
654
+ EndOfWeek = "end_of_week",
655
+ EndOfNextWeek = "end_of_next_week",
656
+ EndOfMonth = "end_of_month",
657
+ EndOfNextMonth = "end_of_next_month",
658
+ EndOfQuarter = "end_of_quarter",
659
+ EndOfNextQuarter = "end_of_next_quarter",
660
+ }
491
661
  declare const MaturityOptions: {
492
- readonly end_of_week: () => Maturity;
493
- readonly end_of_next_week: () => Maturity;
494
- readonly end_of_month: () => Maturity;
495
- readonly end_of_next_month: () => Maturity;
496
- readonly end_of_quarter: () => Maturity;
497
- readonly end_of_next_quarter: () => Maturity;
662
+ readonly end_of_week: () => Maturity;
663
+ readonly end_of_next_week: () => Maturity;
664
+ readonly end_of_month: () => Maturity;
665
+ readonly end_of_next_month: () => Maturity;
666
+ readonly end_of_quarter: () => Maturity;
667
+ readonly end_of_next_quarter: () => Maturity;
498
668
  };
499
669
  type MaturityOptions = keyof typeof MaturityOptions;
500
670
  /**
@@ -503,112 +673,117 @@ type MaturityOptions = keyof typeof MaturityOptions;
503
673
  * @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
504
674
  * @throws {InvalidOptionError} If the maturity is not a valid option.
505
675
  */
506
- declare function from$6(ts: from$6.Parameters): Maturity;
507
- declare namespace from$6 {
508
- type Parameters = number | MaturityOptions;
509
- type ErrorType = InvalidFormatError | InvalidDateError | InvalidOptionError;
676
+ declare function from$10(ts: from$10.Parameters): Maturity;
677
+ declare namespace from$10 {
678
+ type Parameters = number | MaturityOptions;
679
+ type ErrorType = InvalidFormatError | InvalidDateError | InvalidOptionError;
510
680
  }
511
681
  declare class InvalidFormatError extends BaseError {
512
- readonly name = "Maturity.InvalidFormatError";
513
- constructor();
682
+ readonly name = "Maturity.InvalidFormatError";
683
+ constructor();
514
684
  }
515
685
  declare class InvalidDateError extends BaseError {
516
- readonly name = "Maturity.InvalidDateError";
517
- constructor(input: number);
686
+ readonly name = "Maturity.InvalidDateError";
687
+ constructor(input: number);
518
688
  }
519
689
  declare class InvalidOptionError extends BaseError {
520
- readonly name = "Maturity.InvalidOptionError";
521
- constructor(input: string);
690
+ readonly name = "Maturity.InvalidOptionError";
691
+ constructor(input: string);
522
692
  }
523
-
524
- type Maturity$1_InvalidDateError = InvalidDateError;
525
- declare const Maturity$1_InvalidDateError: typeof InvalidDateError;
526
- type Maturity$1_InvalidFormatError = InvalidFormatError;
527
- declare const Maturity$1_InvalidFormatError: typeof InvalidFormatError;
528
- type Maturity$1_InvalidOptionError = InvalidOptionError;
529
- declare const Maturity$1_InvalidOptionError: typeof InvalidOptionError;
530
- type Maturity$1_Maturity = Maturity;
531
- type Maturity$1_MaturityOptions = MaturityOptions;
532
- declare const Maturity$1_MaturitySchema: typeof MaturitySchema;
533
- declare namespace Maturity$1 {
534
- export { Maturity$1_InvalidDateError as InvalidDateError, Maturity$1_InvalidFormatError as InvalidFormatError, Maturity$1_InvalidOptionError as InvalidOptionError, type Maturity$1_Maturity as Maturity, type Maturity$1_MaturityOptions as MaturityOptions, Maturity$1_MaturitySchema as MaturitySchema, from$6 as from };
693
+ declare namespace Offer_d_exports {
694
+ export { AccountNotSetError, InvalidOfferError, Offer, OfferConsumed, OfferHashSchema, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$2 as decode, domain, encode$2 as encode, from$9 as from, fromSnakeCase$2 as fromSnakeCase, hash, obligationId, random$2 as random, sign, signatureMsg, toSnakeCase, types };
535
695
  }
536
-
537
696
  type Offer = {
538
- /** The address that made the offer. */
539
- readonly offering: Address;
540
- /** The amount of assets offered. */
541
- readonly assets: bigint;
542
- /** The interest rate (with 18 decimals). */
543
- readonly rate: bigint;
544
- /** The date at which all interests will be paid. */
545
- readonly maturity: Maturity;
546
- /** The date at which the offer will expire. */
547
- readonly expiry: number;
548
- /** The date at which the offer will start. */
549
- readonly start: number;
550
- /** The nonce. Used for OCO (One-Cancelled-Other) mechanism. */
551
- readonly nonce: bigint;
552
- /** The side of the offer. `true` for buy, `false` for sell. */
553
- readonly buy: boolean;
554
- /** The chain id where the liquidity for this offer is located. */
555
- readonly chainId: bigint;
556
- /** The token that is being borrowed. */
557
- readonly loanToken: Address;
558
- /** The exact set of collaterals required to borrow the loan token. */
559
- readonly collaterals: readonly Collateral[];
560
- /** The optional callback data to retrieve the maker funds. */
561
- readonly callback: {
562
- readonly address: Address;
563
- readonly data: Hex;
564
- readonly gasLimit: bigint;
565
- };
566
- /** The amount of assets consumed from the offer. */
567
- consumed: bigint;
568
- /** The hash of the offer. */
569
- readonly hash: Hex;
570
- /** The block number at which the offer was created. */
571
- readonly blockNumber: number;
572
- /** The signature of the offer. */
573
- signature?: Hex;
697
+ /** The address that made the offer. */
698
+ readonly offering: Address;
699
+ /** The amount of assets offered. */
700
+ readonly assets: bigint;
701
+ /**
702
+ * The amount of assets that can be taken from the offer. takeable = min(max - consumed, available)
703
+ * Where available is the total amount of assets retrievable from offering positions.
704
+ */
705
+ readonly takeable: bigint;
706
+ /** The interest rate (with 18 decimals). */
707
+ readonly rate: bigint;
708
+ /** The date at which all interests will be paid. */
709
+ readonly maturity: Maturity;
710
+ /** The date at which the offer will expire. */
711
+ readonly expiry: number;
712
+ /** The date at which the offer will start. */
713
+ readonly start: number;
714
+ /** The nonce. Used for OCO (One-Cancelled-Other) mechanism. */
715
+ readonly nonce: bigint;
716
+ /** The side of the offer. `true` for buy, `false` for sell. */
717
+ readonly buy: boolean;
718
+ /** The chain id where the liquidity for this offer is located. */
719
+ readonly chainId: Id;
720
+ /** The token that is being borrowed. */
721
+ readonly loanToken: Address;
722
+ /** The exact set of collaterals required to borrow the loan token. */
723
+ readonly collaterals: readonly Collateral[];
724
+ /** The optional callback data to retrieve the maker funds. */
725
+ readonly callback: {
726
+ readonly address: Address;
727
+ readonly data: Hex;
728
+ readonly gasLimit: bigint;
729
+ };
730
+ /** The amount of assets consumed from the offer. */
731
+ consumed: bigint;
732
+ /** The hash of the offer. */
733
+ readonly hash: Hex;
734
+ /** The block number at which the offer was created. */
735
+ readonly blockNumber: number;
736
+ /** The signature of the offer. */
737
+ signature?: Hex;
738
+ };
739
+ declare enum Status {
740
+ VALID = "VALID",
741
+ SIMULATION_ERROR = "SIMULATION_ERROR",
742
+ }
743
+ type Validation = {
744
+ offerHash: Hex;
745
+ status: Status;
574
746
  };
575
- declare const OfferHashSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
747
+ declare const OfferHashSchema: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
576
748
  declare const OfferSchema: (parameters?: {
577
- omitHash?: boolean;
578
- }) => z.ZodObject<{
579
- offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
580
- assets: z.ZodBigInt;
581
- rate: z.ZodBigInt;
582
- maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
583
- expiry: z.ZodNumber;
584
- start: z.ZodNumber;
585
- nonce: z.ZodBigInt;
586
- buy: z.ZodBoolean;
587
- chainId: z.ZodBigInt;
588
- loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
589
- collaterals: z.ZodArray<z.ZodObject<{
590
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
591
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
592
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
593
- }, z.core.$strip>>;
594
- callback: z.ZodObject<{
595
- address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
596
- data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
597
- gasLimit: z.ZodBigInt;
598
- }, z.core.$strip>;
599
- consumed: z.ZodBigInt;
600
- blockNumber: z.ZodNumber;
601
- signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
602
- }, z.core.$strip>;
749
+ omitHash?: boolean;
750
+ }) => z$1.ZodObject<{
751
+ offering: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
752
+ assets: z$1.ZodBigInt;
753
+ rate: z$1.ZodBigInt;
754
+ maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
755
+ expiry: z$1.ZodNumber;
756
+ start: z$1.ZodNumber;
757
+ nonce: z$1.ZodBigInt;
758
+ buy: z$1.ZodBoolean;
759
+ chainId: z$1.ZodNumber;
760
+ loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
761
+ collaterals: z$1.ZodArray<z$1.ZodObject<{
762
+ asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
763
+ oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
764
+ lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
765
+ }, z$1.core.$strip>>;
766
+ callback: z$1.ZodObject<{
767
+ address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
768
+ data: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
769
+ gasLimit: z$1.ZodBigInt;
770
+ }, z$1.core.$strip>;
771
+ signature: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
772
+ consumed: z$1.ZodOptional<z$1.ZodBigInt>;
773
+ takeable: z$1.ZodOptional<z$1.ZodBigInt>;
774
+ blockNumber: z$1.ZodOptional<z$1.ZodNumber>;
775
+ }, z$1.core.$strip>;
603
776
  /**
604
777
  * Creates an offer from a plain object.
605
778
  * @throws {InvalidOfferError} If the offer is invalid.
606
779
  * @param input - The offer to create.
607
780
  * @returns The created offer with its hash.
608
781
  */
609
- declare function from$5(input: Omit<Offer, "hash">): Offer;
610
- declare namespace from$5 {
611
- type ErrorType = InvalidOfferError;
782
+ declare function from$9(input: Compute<Omit<Offer, "chainId" | "hash"> & {
783
+ chainId: number;
784
+ }>): Offer;
785
+ declare namespace from$9 {
786
+ type ErrorType = InvalidOfferError;
612
787
  }
613
788
  /**
614
789
  * Creates an offer from a snake case object.
@@ -616,7 +791,9 @@ declare namespace from$5 {
616
791
  * @param input - The offer to create.
617
792
  * @returns The created offer with its hash.
618
793
  */
619
- declare function fromSnakeCase$2(input: Snake<Omit<Offer, "hash">>): Offer;
794
+ declare function fromSnakeCase$2(input: Snake<Omit<Offer, "chainId" | "hash"> & {
795
+ chainId: number;
796
+ }>): Offer;
620
797
  /**
621
798
  * Converts an offer to a snake case object.
622
799
  * @param offer - The offer to convert.
@@ -624,26 +801,28 @@ declare function fromSnakeCase$2(input: Snake<Omit<Offer, "hash">>): Offer;
624
801
  */
625
802
  declare function toSnakeCase(offer: Offer): Snake<Offer>;
626
803
  type RandomConfig = {
627
- chains?: Chain[];
628
- loanTokens?: Address[];
629
- collateralTokens?: Address[];
630
- assetsDecimals?: Record<Address, number>;
631
- buy?: boolean;
632
- assets?: bigint;
633
- consumed?: bigint;
634
- offering?: Address;
635
- maturity?: Maturity;
636
- start?: number;
637
- expiry?: number;
638
- nonce?: bigint;
639
- rate?: bigint;
640
- callback?: {
641
- address: Address;
642
- data: Hex;
643
- gasLimit: bigint;
644
- };
645
- collaterals?: readonly Collateral[];
646
- signature?: Hex;
804
+ chains?: Chain$1[];
805
+ loanTokens?: Address[];
806
+ collateralTokens?: Address[];
807
+ assetsDecimals?: Record<Address, number>;
808
+ buy?: boolean;
809
+ assets?: bigint;
810
+ consumed?: bigint;
811
+ takeable?: bigint;
812
+ offering?: Address;
813
+ maturity?: Maturity;
814
+ start?: number;
815
+ expiry?: number;
816
+ nonce?: bigint;
817
+ rate?: bigint;
818
+ callback?: {
819
+ address: Address;
820
+ data: Hex;
821
+ gasLimit: bigint;
822
+ };
823
+ collaterals?: readonly Collateral[];
824
+ signature?: Hex;
825
+ blockNumber?: number;
647
826
  };
648
827
  /**
649
828
  * Generates a random Offer.
@@ -657,9 +836,9 @@ declare function random$2(config?: RandomConfig): Offer;
657
836
  * @param chainId - The chain ID.
658
837
  * @returns The EIP-712 domain object.
659
838
  */
660
- declare const domain: (chainId: bigint) => {
661
- chainId: bigint;
662
- verifyingContract: "0x0000000000000000000000000000000000000000";
839
+ declare const domain: (chainId: number) => {
840
+ chainId: bigint;
841
+ verifyingContract: "0x0000000000000000000000000000000000000000";
663
842
  };
664
843
  /**
665
844
  * The EIP-712 types for the offer.
@@ -667,73 +846,74 @@ declare const domain: (chainId: bigint) => {
667
846
  * @returns The EIP-712 types.
668
847
  */
669
848
  declare const types: {
670
- readonly EIP712Domain: readonly [{
671
- readonly name: "chainId";
672
- readonly type: "uint256";
673
- }, {
674
- readonly name: "verifyingContract";
675
- readonly type: "address";
676
- }];
677
- readonly Offer: readonly [{
678
- readonly name: "offering";
679
- readonly type: "address";
680
- }, {
681
- readonly name: "assets";
682
- readonly type: "uint256";
683
- }, {
684
- readonly name: "rate";
685
- readonly type: "uint256";
686
- }, {
687
- readonly name: "maturity";
688
- readonly type: "uint256";
689
- }, {
690
- readonly name: "expiry";
691
- readonly type: "uint256";
692
- }, {
693
- readonly name: "nonce";
694
- readonly type: "uint256";
695
- }, {
696
- readonly name: "buy";
697
- readonly type: "bool";
698
- }, {
699
- readonly name: "loanToken";
700
- readonly type: "address";
701
- }, {
702
- readonly name: "collaterals";
703
- readonly type: "Collateral[]";
704
- }, {
705
- readonly name: "callback";
706
- readonly type: "Callback";
707
- }];
708
- readonly Collateral: readonly [{
709
- readonly name: "asset";
710
- readonly type: "address";
711
- }, {
712
- readonly name: "oracle";
713
- readonly type: "address";
714
- }, {
715
- readonly name: "lltv";
716
- readonly type: "uint256";
717
- }];
718
- readonly Callback: readonly [{
719
- readonly name: "address";
720
- readonly type: "address";
721
- }, {
722
- readonly name: "data";
723
- readonly type: "bytes";
724
- }, {
725
- readonly name: "gasLimit";
726
- readonly type: "uint256";
727
- }];
849
+ readonly EIP712Domain: readonly [{
850
+ readonly name: "chainId";
851
+ readonly type: "uint256";
852
+ }, {
853
+ readonly name: "verifyingContract";
854
+ readonly type: "address";
855
+ }];
856
+ readonly Offer: readonly [{
857
+ readonly name: "offering";
858
+ readonly type: "address";
859
+ }, {
860
+ readonly name: "assets";
861
+ readonly type: "uint256";
862
+ }, {
863
+ readonly name: "rate";
864
+ readonly type: "uint256";
865
+ }, {
866
+ readonly name: "maturity";
867
+ readonly type: "uint256";
868
+ }, {
869
+ readonly name: "expiry";
870
+ readonly type: "uint256";
871
+ }, {
872
+ readonly name: "nonce";
873
+ readonly type: "uint256";
874
+ }, {
875
+ readonly name: "buy";
876
+ readonly type: "bool";
877
+ }, {
878
+ readonly name: "loanToken";
879
+ readonly type: "address";
880
+ }, {
881
+ readonly name: "collaterals";
882
+ readonly type: "Collateral[]";
883
+ }, {
884
+ readonly name: "callback";
885
+ readonly type: "Callback";
886
+ }];
887
+ readonly Collateral: readonly [{
888
+ readonly name: "asset";
889
+ readonly type: "address";
890
+ }, {
891
+ readonly name: "oracle";
892
+ readonly type: "address";
893
+ }, {
894
+ readonly name: "lltv";
895
+ readonly type: "uint256";
896
+ }];
897
+ readonly Callback: readonly [{
898
+ readonly name: "address";
899
+ readonly type: "address";
900
+ }, {
901
+ readonly name: "data";
902
+ readonly type: "bytes";
903
+ }, {
904
+ readonly name: "gasLimit";
905
+ readonly type: "uint256";
906
+ }];
728
907
  };
729
908
  /**
730
- * Signs an offer.
909
+ * Signs an array of offers.
731
910
  * @throws {Error} If the wallet account is not set.
732
- * @param offer - The offer to sign.
733
- * @param wallet - The wallet to sign the offer with.
734
- * @returns The signed offer.
911
+ * @param offers - The offers to sign.
912
+ * @param wallet - The wallet to sign the offers with.
913
+ * @returns The signed offers.
735
914
  */
736
- declare function sign(offer: Offer, wallet: WalletClient): Promise<Hex>;
915
+ declare function sign(offers: Offer[], wallet: WalletClient): Promise<Hex>;
916
+ declare function signatureMsg(offers: Offer[]): Hex;
737
917
  declare function hash(offer: Omit<Offer, "hash">): Hex;
738
918
  /**
739
919
  * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
@@ -742,108 +922,91 @@ declare function hash(offer: Omit<Offer, "hash">): Hex;
742
922
  * @returns The obligation id as a 32-byte hex string.
743
923
  */
744
924
  declare function obligationId(offer: Offer): Hex;
745
- declare function encode$1(offer: Offer): `0x${string}`;
746
- declare function decode$1(data: Hex, blockNumber: number | bigint): Offer;
925
+ declare function encode$2(offer: Offer): `0x${string}`;
926
+ declare function decode$2(data: Hex, blockNumber: number | bigint): Offer;
747
927
  type OfferConsumed = {
748
- id: string;
749
- chainId: bigint;
750
- offering: Address;
751
- nonce: bigint;
752
- amount: bigint;
753
- blockNumber: number;
928
+ id: string;
929
+ chainId: Id;
930
+ offering: Address;
931
+ nonce: bigint;
932
+ amount: bigint;
933
+ blockNumber: number;
754
934
  };
755
935
  /**
756
936
  * ABI for the Consumed event emitted by the Obligation contract.
757
937
  */
758
938
  declare const consumedEvent: {
759
- readonly type: "event";
760
- readonly name: "Consumed";
761
- readonly inputs: readonly [{
762
- readonly name: "user";
763
- readonly type: "address";
764
- readonly indexed: true;
765
- readonly internalType: "address";
766
- }, {
767
- readonly name: "nonce";
768
- readonly type: "uint256";
769
- readonly indexed: true;
770
- readonly internalType: "uint256";
771
- }, {
772
- readonly name: "amount";
773
- readonly type: "uint256";
774
- readonly indexed: false;
775
- readonly internalType: "uint256";
776
- }];
777
- readonly anonymous: false;
939
+ readonly type: "event";
940
+ readonly name: "Consumed";
941
+ readonly inputs: readonly [{
942
+ readonly name: "user";
943
+ readonly type: "address";
944
+ readonly indexed: true;
945
+ readonly internalType: "address";
946
+ }, {
947
+ readonly name: "nonce";
948
+ readonly type: "uint256";
949
+ readonly indexed: true;
950
+ readonly internalType: "uint256";
951
+ }, {
952
+ readonly name: "amount";
953
+ readonly type: "uint256";
954
+ readonly indexed: false;
955
+ readonly internalType: "uint256";
956
+ }];
957
+ readonly anonymous: false;
778
958
  };
779
- declare function fromConsumedLog(parameters: {
780
- blockNumber: bigint;
781
- logIndex: number;
782
- chainId: number;
783
- transactionHash: Hex;
784
- user: Address;
785
- nonce: bigint;
786
- amount: bigint;
787
- }): OfferConsumed;
788
- declare class InvalidOfferError extends BaseError<z.ZodError | Error> {
789
- readonly name = "Offer.InvalidOfferError";
790
- constructor(error: z.ZodError | Error);
959
+ declare class InvalidOfferError extends BaseError<z$1.ZodError | Error> {
960
+ readonly name = "Offer.InvalidOfferError";
961
+ constructor(error: z$1.ZodError | Error);
962
+ /**
963
+ * Formats ZodError issues into a human-readable string with line breaks.
964
+ * @example
965
+ * "- 'assets': too small, expected >= 0
966
+ * - 'start': must be before expiry"
967
+ */
968
+ static formatDetails(error: z$1.ZodError | Error): string;
969
+ /**
970
+ * Returns the formatted human-readable message.
971
+ */
972
+ get formattedMessage(): string;
791
973
  }
792
974
  declare class AccountNotSetError extends BaseError {
793
- readonly name = "Offer.AccountNotSetError";
794
- constructor();
975
+ readonly name = "Offer.AccountNotSetError";
976
+ constructor();
795
977
  }
796
-
797
- type Offer$1_AccountNotSetError = AccountNotSetError;
798
- declare const Offer$1_AccountNotSetError: typeof AccountNotSetError;
799
- type Offer$1_InvalidOfferError = InvalidOfferError;
800
- declare const Offer$1_InvalidOfferError: typeof InvalidOfferError;
801
- type Offer$1_Offer = Offer;
802
- type Offer$1_OfferConsumed = OfferConsumed;
803
- declare const Offer$1_OfferHashSchema: typeof OfferHashSchema;
804
- declare const Offer$1_OfferSchema: typeof OfferSchema;
805
- type Offer$1_RandomConfig = RandomConfig;
806
- declare const Offer$1_consumedEvent: typeof consumedEvent;
807
- declare const Offer$1_domain: typeof domain;
808
- declare const Offer$1_fromConsumedLog: typeof fromConsumedLog;
809
- declare const Offer$1_hash: typeof hash;
810
- declare const Offer$1_obligationId: typeof obligationId;
811
- declare const Offer$1_sign: typeof sign;
812
- declare const Offer$1_toSnakeCase: typeof toSnakeCase;
813
- declare const Offer$1_types: typeof types;
814
- declare namespace Offer$1 {
815
- export { Offer$1_AccountNotSetError as AccountNotSetError, Offer$1_InvalidOfferError as InvalidOfferError, type Offer$1_Offer as Offer, type Offer$1_OfferConsumed as OfferConsumed, Offer$1_OfferHashSchema as OfferHashSchema, Offer$1_OfferSchema as OfferSchema, type Offer$1_RandomConfig as RandomConfig, Offer$1_consumedEvent as consumedEvent, decode$1 as decode, Offer$1_domain as domain, encode$1 as encode, from$5 as from, Offer$1_fromConsumedLog as fromConsumedLog, fromSnakeCase$2 as fromSnakeCase, Offer$1_hash as hash, Offer$1_obligationId as obligationId, random$2 as random, Offer$1_sign as sign, Offer$1_toSnakeCase as toSnakeCase, Offer$1_types as types };
978
+ declare namespace Liquidity_d_exports {
979
+ export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateBuyVaultCallbackPoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateSellERC20CallbackPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
816
980
  }
817
-
818
981
  /**
819
982
  * Represents a liquidity pool with a unique ID and amount.
820
983
  */
821
984
  type LiquidityPool = {
822
- id: string;
823
- amount: bigint;
985
+ id: string;
986
+ amount: bigint;
824
987
  };
825
988
  /**
826
989
  * Represents a hierarchical relationship between two liquidity pools.
827
990
  */
828
991
  type LiquidityLink = {
829
- parentPoolId: string;
830
- childPoolId: string;
831
- priority: number;
992
+ parentPoolId: string;
993
+ childPoolId: string;
994
+ priority: number;
832
995
  };
833
996
  /**
834
997
  * Represents the connection between an offer and its liquidity pools.
835
998
  */
836
999
  type OfferLiquidityPool = {
837
- offerHash: Offer["hash"];
838
- poolId: string;
839
- /**
840
- * The available capacity/liquidity from this pool for this offer.
841
- * Meaning varies by pool type:
842
- * - BuyWithEmptyCallback: Matches allowance amount from pool bellow
843
- * - SellERC20Callback: Sell Callback/Predeposited -> Maximum debt capacity calculated from collateral (collateralAmount * oraclePrice * lltv)
844
- * - SellERC20Callback: Existing debt as negative value (reduces available capacity)
845
- */
846
- amount: bigint;
1000
+ offerHash: Offer["hash"];
1001
+ poolId: string;
1002
+ /**
1003
+ * The available capacity/liquidity from this pool for this offer.
1004
+ * Meaning varies by pool type:
1005
+ * - BuyWithEmptyCallback: Matches allowance amount from pool bellow
1006
+ * - SellERC20Callback: Sell Callback/Predeposited -> Maximum debt capacity calculated from collateral (collateralAmount * oraclePrice * lltv)
1007
+ * - SellERC20Callback: Existing debt as negative value (reduces available capacity)
1008
+ */
1009
+ amount: bigint;
847
1010
  };
848
1011
  /**
849
1012
  * Calculate maximum debt capacity from collateral amount.
@@ -857,28 +1020,28 @@ declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: big
857
1020
  * Generate pool ID for balance pools.
858
1021
  */
859
1022
  declare function generateBalancePoolId(parameters: {
860
- user: Address;
861
- chainId: bigint;
862
- token: Address;
1023
+ user: Address;
1024
+ chainId: Id;
1025
+ token: Address;
863
1026
  }): string;
864
1027
  /**
865
1028
  * Generate pool ID for allowance pools.
866
1029
  */
867
1030
  declare function generateAllowancePoolId(parameters: {
868
- user: Address;
869
- chainId: bigint;
870
- token: Address;
1031
+ user: Address;
1032
+ chainId: Id;
1033
+ token: Address;
871
1034
  }): string;
872
1035
  /**
873
1036
  * Generate pool ID for sell ERC20 callback pools.
874
1037
  * Each offer has its own callback pool to prevent liquidity conflicts.
875
1038
  */
876
1039
  declare function generateSellERC20CallbackPoolId(parameters: {
877
- user: Address;
878
- chainId: bigint;
879
- obligationId: Hex;
880
- token: Address;
881
- offerHash: Hex;
1040
+ user: Address;
1041
+ chainId: Id;
1042
+ obligationId: Hex;
1043
+ token: Address;
1044
+ offerHash: Hex;
882
1045
  }): string;
883
1046
  /**
884
1047
  * Generate pool ID for obligation collateral pools.
@@ -886,89 +1049,74 @@ declare function generateSellERC20CallbackPoolId(parameters: {
886
1049
  * These pools are shared across all offers with the same obligation.
887
1050
  */
888
1051
  declare function generateObligationCollateralPoolId(parameters: {
889
- user: Address;
890
- chainId: bigint;
891
- obligationId: Hex;
892
- token: Address;
1052
+ user: Address;
1053
+ chainId: Id;
1054
+ obligationId: Hex;
1055
+ token: Address;
893
1056
  }): string;
894
1057
  /**
895
1058
  * Generate pool ID for buy vault callback pools.
896
1059
  */
897
1060
  declare function generateBuyVaultCallbackPoolId(parameters: {
898
- user: Address;
899
- chainId: bigint;
900
- vault: Address;
901
- offerHash: Hex;
1061
+ user: Address;
1062
+ chainId: Id;
1063
+ vault: Address;
1064
+ offerHash: Hex;
902
1065
  }): string;
903
1066
  /**
904
1067
  * Generate pool ID for debt pools.
905
1068
  */
906
1069
  declare function generateDebtPoolId(parameters: {
907
- user: Address;
908
- chainId: bigint;
909
- obligationId: Hex;
1070
+ user: Address;
1071
+ chainId: Id;
1072
+ obligationId: Hex;
910
1073
  }): string;
911
1074
  /**
912
1075
  * Generate pool ID for user position in a vault.
913
1076
  */
914
1077
  declare function generateUserVaultPositionPoolId(parameters: {
915
- user: Address;
916
- chainId: bigint;
917
- vault: Address;
1078
+ user: Address;
1079
+ chainId: Id;
1080
+ vault: Address;
918
1081
  }): string;
919
1082
  /**
920
1083
  * Generate pool ID for vault position in a market.
921
1084
  */
922
1085
  declare function generateVaultPositionPoolId(parameters: {
923
- vault: Address;
924
- chainId: bigint;
925
- marketId: string;
1086
+ vault: Address;
1087
+ chainId: Id;
1088
+ marketId: string;
926
1089
  }): string;
927
1090
  /**
928
1091
  * Generate pool ID for market total liquidity.
929
1092
  */
930
1093
  declare function generateMarketLiquidityPoolId(parameters: {
931
- chainId: bigint;
932
- marketId: string;
1094
+ chainId: Id;
1095
+ marketId: string;
933
1096
  }): string;
934
-
935
- type Liquidity_LiquidityLink = LiquidityLink;
936
- type Liquidity_LiquidityPool = LiquidityPool;
937
- type Liquidity_OfferLiquidityPool = OfferLiquidityPool;
938
- declare const Liquidity_calculateMaxDebt: typeof calculateMaxDebt;
939
- declare const Liquidity_generateAllowancePoolId: typeof generateAllowancePoolId;
940
- declare const Liquidity_generateBalancePoolId: typeof generateBalancePoolId;
941
- declare const Liquidity_generateBuyVaultCallbackPoolId: typeof generateBuyVaultCallbackPoolId;
942
- declare const Liquidity_generateDebtPoolId: typeof generateDebtPoolId;
943
- declare const Liquidity_generateMarketLiquidityPoolId: typeof generateMarketLiquidityPoolId;
944
- declare const Liquidity_generateObligationCollateralPoolId: typeof generateObligationCollateralPoolId;
945
- declare const Liquidity_generateSellERC20CallbackPoolId: typeof generateSellERC20CallbackPoolId;
946
- declare const Liquidity_generateUserVaultPositionPoolId: typeof generateUserVaultPositionPoolId;
947
- declare const Liquidity_generateVaultPositionPoolId: typeof generateVaultPositionPoolId;
948
- declare namespace Liquidity {
949
- export { type Liquidity_LiquidityLink as LiquidityLink, type Liquidity_LiquidityPool as LiquidityPool, type Liquidity_OfferLiquidityPool as OfferLiquidityPool, Liquidity_calculateMaxDebt as calculateMaxDebt, Liquidity_generateAllowancePoolId as generateAllowancePoolId, Liquidity_generateBalancePoolId as generateBalancePoolId, Liquidity_generateBuyVaultCallbackPoolId as generateBuyVaultCallbackPoolId, Liquidity_generateDebtPoolId as generateDebtPoolId, Liquidity_generateMarketLiquidityPoolId as generateMarketLiquidityPoolId, Liquidity_generateObligationCollateralPoolId as generateObligationCollateralPoolId, Liquidity_generateSellERC20CallbackPoolId as generateSellERC20CallbackPoolId, Liquidity_generateUserVaultPositionPoolId as generateUserVaultPositionPoolId, Liquidity_generateVaultPositionPoolId as generateVaultPositionPoolId };
1097
+ declare namespace Obligation_d_exports {
1098
+ export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$8 as from, fromSnakeCase$1 as fromSnakeCase, id, random$1 as random };
950
1099
  }
951
-
952
1100
  type Obligation = {
953
- /** The chain id where the liquidity for this obligation is located. */
954
- chainId: Id;
955
- /** The token that is being borrowed for this obligation. */
956
- loanToken: Address;
957
- /** The exact set of collaterals required to borrow the loan token. */
958
- collaterals: Collateral[];
959
- /** The maturity of the obligation. */
960
- maturity: Maturity;
1101
+ /** The chain id where the liquidity for this obligation is located. */
1102
+ chainId: Id;
1103
+ /** The token that is being borrowed for this obligation. */
1104
+ loanToken: Address;
1105
+ /** The exact set of collaterals required to borrow the loan token. */
1106
+ collaterals: Collateral[];
1107
+ /** The maturity of the obligation. */
1108
+ maturity: Maturity;
961
1109
  };
962
- declare const ObligationSchema: z.ZodObject<{
963
- chainId: z.ZodBigInt;
964
- loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
965
- collaterals: z.ZodArray<z.ZodObject<{
966
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
967
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
968
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
969
- }, z.core.$strip>>;
970
- maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
971
- }, z.core.$strip>;
1110
+ declare const ObligationSchema: z$1.ZodObject<{
1111
+ chainId: z$1.ZodNumber;
1112
+ loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1113
+ collaterals: z$1.ZodArray<z$1.ZodObject<{
1114
+ asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1115
+ oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1116
+ lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
1117
+ }, z$1.core.$strip>>;
1118
+ maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1119
+ }, z$1.core.$strip>;
972
1120
  /**
973
1121
  * Creates an obligation from the given parameters.
974
1122
  * @constructor
@@ -979,7 +1127,7 @@ declare const ObligationSchema: z.ZodObject<{
979
1127
  * @example
980
1128
  * ```ts
981
1129
  * const obligation = Obligation.from({
982
- * chainId: 1n,
1130
+ * chainId: 1,
983
1131
  * loanToken: privateKeyToAccount(generatePrivateKey()).address,
984
1132
  * collaterals: [
985
1133
  * Collateral.from({
@@ -992,20 +1140,20 @@ declare const ObligationSchema: z.ZodObject<{
992
1140
  * });
993
1141
  * ```
994
1142
  */
995
- declare function from$4(parameters: from$4.Parameters): from$4.ReturnType;
996
- declare namespace from$4 {
997
- type Parameters = {
998
- /** The chain id where the liquidity for this obligation is located. */
999
- chainId: Id;
1000
- /** The token that is being borrowed for this obligation. */
1001
- loanToken: Address;
1002
- /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
1003
- collaterals: from$7.Parameters[] | readonly from$7.Parameters[];
1004
- /** The maturity of the obligation. */
1005
- maturity: from$6.Parameters;
1006
- };
1007
- type ReturnType = Obligation;
1008
- type ErrorType = InvalidObligationError;
1143
+ declare function from$8(parameters: from$8.Parameters): from$8.ReturnType;
1144
+ declare namespace from$8 {
1145
+ type Parameters = {
1146
+ /** The chain id where the liquidity for this obligation is located. */
1147
+ chainId: number;
1148
+ /** The token that is being borrowed for this obligation. */
1149
+ loanToken: Address;
1150
+ /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
1151
+ collaterals: from$11.Parameters[] | readonly from$11.Parameters[];
1152
+ /** The maturity of the obligation. */
1153
+ maturity: from$10.Parameters;
1154
+ };
1155
+ type ReturnType = Obligation;
1156
+ type ErrorType = InvalidObligationError;
1009
1157
  }
1010
1158
  /**
1011
1159
  * Creates an obligation from a snake case object.
@@ -1015,9 +1163,11 @@ declare namespace from$4 {
1015
1163
  */
1016
1164
  declare function fromSnakeCase$1(input: fromSnakeCase$1.Parameters): fromSnakeCase$1.ReturnType;
1017
1165
  declare namespace fromSnakeCase$1 {
1018
- type Parameters = Snake<Obligation>;
1019
- type ReturnType = Obligation;
1020
- type ErrorType = InvalidObligationError;
1166
+ type Parameters = Snake<Omit<Obligation, "chainId"> & {
1167
+ chainId: number;
1168
+ }>;
1169
+ type ReturnType = Obligation;
1170
+ type ErrorType = InvalidObligationError;
1021
1171
  }
1022
1172
  /**
1023
1173
  * Calculates the obligation id based on the smart contract's Obligation struct.
@@ -1035,9 +1185,9 @@ declare namespace fromSnakeCase$1 {
1035
1185
  */
1036
1186
  declare function id(obligation: id.Parameters): id.ReturnType;
1037
1187
  declare namespace id {
1038
- type Parameters = Obligation;
1039
- type ReturnType = Hex;
1040
- type ErrorType = CollateralsAreNotSortedError;
1188
+ type Parameters = Obligation;
1189
+ type ReturnType = Hex;
1190
+ type ErrorType = CollateralsAreNotSortedError;
1041
1191
  }
1042
1192
  /**
1043
1193
  * Generates a random obligation.
@@ -1050,49 +1200,150 @@ declare namespace id {
1050
1200
  */
1051
1201
  declare function random$1(): random$1.ReturnType;
1052
1202
  declare namespace random$1 {
1053
- type ReturnType = Obligation;
1203
+ type ReturnType = Obligation;
1054
1204
  }
1055
- declare class InvalidObligationError extends BaseError<z.ZodError | Error> {
1056
- readonly name = "Obligation.InvalidObligationError";
1057
- constructor(error: z.ZodError | Error);
1205
+ declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
1206
+ readonly name = "Obligation.InvalidObligationError";
1207
+ constructor(error: z$1.ZodError | Error);
1058
1208
  }
1059
1209
  declare class CollateralsAreNotSortedError extends BaseError {
1060
- readonly name = "Obligation.CollateralsAreNotSortedError";
1061
- constructor();
1210
+ readonly name = "Obligation.CollateralsAreNotSortedError";
1211
+ constructor();
1062
1212
  }
1063
-
1064
- type Obligation$1_CollateralsAreNotSortedError = CollateralsAreNotSortedError;
1065
- declare const Obligation$1_CollateralsAreNotSortedError: typeof CollateralsAreNotSortedError;
1066
- type Obligation$1_InvalidObligationError = InvalidObligationError;
1067
- declare const Obligation$1_InvalidObligationError: typeof InvalidObligationError;
1068
- type Obligation$1_Obligation = Obligation;
1069
- declare const Obligation$1_ObligationSchema: typeof ObligationSchema;
1070
- declare const Obligation$1_id: typeof id;
1071
- declare namespace Obligation$1 {
1072
- export { Obligation$1_CollateralsAreNotSortedError as CollateralsAreNotSortedError, Obligation$1_InvalidObligationError as InvalidObligationError, type Obligation$1_Obligation as Obligation, Obligation$1_ObligationSchema as ObligationSchema, from$4 as from, fromSnakeCase$1 as fromSnakeCase, Obligation$1_id as id, random$1 as random };
1213
+ declare namespace Oracle_d_exports {
1214
+ export { Conversion, Oracle, from$7 as from };
1215
+ }
1216
+ /**
1217
+ * An oracle contract that provides price information for assets.
1218
+ */
1219
+ type Oracle = {
1220
+ /** The chain id where the oracle is deployed. */
1221
+ readonly chainId: Id;
1222
+ /** The address of the oracle contract. */
1223
+ readonly address: Address;
1224
+ /** The price returned by the oracle (in the oracle's native units), null if no price available. */
1225
+ readonly price: bigint | null;
1226
+ /** The block number at which the price was fetched. */
1227
+ readonly blockNumber: number;
1228
+ };
1229
+ /**
1230
+ * Create an Oracle from a plain object.
1231
+ * @param data - The data to create the oracle from.
1232
+ * @returns The created oracle.
1233
+ */
1234
+ declare function from$7(data: from$7.Parameters): from$7.ReturnType;
1235
+ declare namespace from$7 {
1236
+ type Parameters = {
1237
+ chainId: Id;
1238
+ address: Address;
1239
+ price: string | null;
1240
+ blockNumber: number;
1241
+ };
1242
+ type ReturnType = Oracle;
1243
+ }
1244
+ /**
1245
+ * Conversion utilities for converting between collateral and loan token amounts
1246
+ * using oracle prices and LLTV
1247
+ */
1248
+ declare namespace Conversion {
1249
+ /**
1250
+ * Converts a collateral amount to loan token
1251
+ * Uses the formula: (amount * price / 10^36) * lltv / 10^18
1252
+ *
1253
+ * @param amount - The collateral amount to convert
1254
+ * @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
1255
+ * @returns The equivalent loan token amount
1256
+ */
1257
+ function collateralToLoan(amount: bigint, params: {
1258
+ price: bigint;
1259
+ lltv: bigint;
1260
+ }): bigint;
1261
+ /**
1262
+ * Converts a loan token amount to collateral
1263
+ * Uses the inverse formula: (amount * 10^36 / price) * 10^18 / lltv
1264
+ * Returns 0n if price or lltv is zero (invalid conversion).
1265
+ *
1266
+ * @param amount - The loan token amount to convert
1267
+ * @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
1268
+ * @returns The equivalent collateral amount, or 0n if conversion is invalid
1269
+ */
1270
+ function loanToCollateral(amount: bigint, params: {
1271
+ price: bigint;
1272
+ lltv: bigint;
1273
+ }): bigint;
1274
+ }
1275
+ declare namespace Position_d_exports {
1276
+ export { Position, Type, from$6 as from };
1277
+ }
1278
+ type Position = {
1279
+ /** The chain id. */
1280
+ chainId: Id;
1281
+ /** The contract address from which the position is called.
1282
+ * While balances are obviously tracked on ERC20 contracts, we prefer to track which contract is called to know the balance.
1283
+ * For example, when depositing into a vault, we would specify the vault contract address as the contract not the underlying vault's ERC20 token address.
1284
+ */
1285
+ contract: Address;
1286
+ /** The user address. */
1287
+ user: Address;
1288
+ /** The type of position. */
1289
+ type: Type;
1290
+ /** The balance of the position. */
1291
+ balance?: bigint;
1292
+ /** The underlying asset of the position.
1293
+ * For ERC20 positions, this equals the contract address.
1294
+ * For vault positions, this is the vault's underlying asset.
1295
+ */
1296
+ asset?: Address;
1297
+ /** The block number at which the position was last updated. */
1298
+ blockNumber: number;
1299
+ };
1300
+ declare enum Type {
1301
+ ERC20 = "erc20",
1302
+ VAULT_V1 = "vault_v1",
1303
+ }
1304
+ /**
1305
+ * @constructor
1306
+ * Creates a Position.
1307
+ * @param parameters - {@link from.Parameters}
1308
+ * @returns The created Position. {@link from.ReturnType}
1309
+ */
1310
+ declare function from$6(parameters: from$6.Parameters): from$6.ReturnType;
1311
+ declare namespace from$6 {
1312
+ type Parameters = {
1313
+ chainId: Id;
1314
+ contract: Address;
1315
+ user: Address;
1316
+ type: Type;
1317
+ balance?: bigint;
1318
+ asset?: Address;
1319
+ blockNumber: number;
1320
+ };
1321
+ type ReturnType = Position;
1322
+ }
1323
+ declare namespace Quote_d_exports {
1324
+ export { InvalidQuoteError, Quote, QuoteSchema, from$5 as from, fromSnakeCase, random };
1073
1325
  }
1074
-
1075
1326
  type Quote = {
1076
- /** The obligation id. */
1077
- obligationId: Hex;
1078
- ask: {
1079
- /** The highest interest rate the seller will accept to pay for the obligation. (18 decimals). */
1080
- rate: bigint;
1081
- };
1082
- bid: {
1083
- /** The lowest interest rate a buyer is willing to be paid for the obligation. (18 decimals). */
1084
- rate: bigint;
1085
- };
1327
+ /** The obligation id. */
1328
+ obligationId: Hex;
1329
+ ask: {
1330
+ /** The highest interest rate the seller will accept to pay for the obligation. (18 decimals). */
1331
+ rate: bigint;
1332
+ };
1333
+ bid: {
1334
+ /** The lowest interest rate a buyer is willing to be paid for the obligation. (18 decimals). */
1335
+ rate: bigint;
1336
+ };
1086
1337
  };
1087
- declare const QuoteSchema: z.ZodObject<{
1088
- obligationId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
1089
- ask: z.ZodObject<{
1090
- rate: z.ZodBigInt;
1091
- }, z.core.$strip>;
1092
- bid: z.ZodObject<{
1093
- rate: z.ZodBigInt;
1094
- }, z.core.$strip>;
1095
- }, z.core.$strip>;
1338
+ declare const QuoteSchema: z$1.ZodObject<{
1339
+ obligationId: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1340
+ ask: z$1.ZodObject<{
1341
+ rate: z$1.ZodBigInt;
1342
+ }, z$1.core.$strip>;
1343
+ bid: z$1.ZodObject<{
1344
+ rate: z$1.ZodBigInt;
1345
+ }, z$1.core.$strip>;
1346
+ }, z$1.core.$strip>;
1096
1347
  /**
1097
1348
  * Creates a quote for a given obligation.
1098
1349
  * @constructor
@@ -1105,11 +1356,11 @@ declare const QuoteSchema: z.ZodObject<{
1105
1356
  * const quote = Quote.from({ obligationId: "0x123", ask: { assets: 100n, rate: 100n }, bid: { assets: 100n, rate: 100n } });
1106
1357
  * ```
1107
1358
  */
1108
- declare function from$3(parameters: from$3.Parameters): from$3.ReturnType;
1109
- declare namespace from$3 {
1110
- type Parameters = Quote;
1111
- type ReturnType = Quote;
1112
- type ErrorType = InvalidQuoteError;
1359
+ declare function from$5(parameters: from$5.Parameters): from$5.ReturnType;
1360
+ declare namespace from$5 {
1361
+ type Parameters = Quote;
1362
+ type ReturnType = Quote;
1363
+ type ErrorType = InvalidQuoteError;
1113
1364
  }
1114
1365
  /**
1115
1366
  * Creates a quote from a snake case object.
@@ -1119,9 +1370,9 @@ declare namespace from$3 {
1119
1370
  */
1120
1371
  declare function fromSnakeCase(snake: fromSnakeCase.Parameters): fromSnakeCase.ReturnType;
1121
1372
  declare namespace fromSnakeCase {
1122
- type Parameters = Snake<Quote>;
1123
- type ReturnType = Quote;
1124
- type ErrorType = from$3.ErrorType;
1373
+ type Parameters = Snake<Quote>;
1374
+ type ReturnType = Quote;
1375
+ type ErrorType = from$5.ErrorType;
1125
1376
  }
1126
1377
  /**
1127
1378
  * Generates a random quote.
@@ -1134,32 +1385,848 @@ declare namespace fromSnakeCase {
1134
1385
  */
1135
1386
  declare function random(): random.ReturnType;
1136
1387
  declare namespace random {
1137
- type Parameters = never;
1138
- type ReturnType = Quote;
1139
- type ErrorType = from$3.ErrorType;
1388
+ type Parameters = never;
1389
+ type ReturnType = Quote;
1390
+ type ErrorType = from$5.ErrorType;
1140
1391
  }
1141
- declare class InvalidQuoteError extends BaseError<z.ZodError | Error> {
1142
- readonly name = "Quote.InvalidQuoteError";
1143
- constructor(error: z.ZodError | Error);
1392
+ declare class InvalidQuoteError extends BaseError<z$1.ZodError | Error> {
1393
+ readonly name = "Quote.InvalidQuoteError";
1394
+ constructor(error: z$1.ZodError | Error);
1144
1395
  }
1145
-
1146
- type Quote$1_InvalidQuoteError = InvalidQuoteError;
1147
- declare const Quote$1_InvalidQuoteError: typeof InvalidQuoteError;
1148
- type Quote$1_Quote = Quote;
1149
- declare const Quote$1_QuoteSchema: typeof QuoteSchema;
1150
- declare const Quote$1_fromSnakeCase: typeof fromSnakeCase;
1151
- declare const Quote$1_random: typeof random;
1152
- declare namespace Quote$1 {
1153
- export { Quote$1_InvalidQuoteError as InvalidQuoteError, type Quote$1_Quote as Quote, Quote$1_QuoteSchema as QuoteSchema, from$3 as from, Quote$1_fromSnakeCase as fromSnakeCase, Quote$1_random as random };
1396
+ declare namespace Transfer_d_exports {
1397
+ export { Transfer, from$4 as from };
1154
1398
  }
1399
+ type Transfer = {
1400
+ id: string;
1401
+ chainId: Id;
1402
+ contract: Address;
1403
+ from: Address;
1404
+ to: Address;
1405
+ value: bigint;
1406
+ blockNumber: number;
1407
+ };
1408
+ /**
1409
+ * @constructor
1410
+ *
1411
+ * Creates a {@link Transfer}.
1412
+ * @param parameters - {@link from.Parameters}
1413
+ * @returns The created Transfer. {@link from.ReturnType}
1414
+ *
1415
+ * @example
1416
+ * ```ts
1417
+ * const transfer = Transfer.from({ id: "1", chainId: 1, contract: "0x123", from: "0x456", to: "0x789", value: 100n, blockNumber: 100n });
1418
+ * ```
1419
+ */
1420
+ declare function from$4(parameters: from$4.Parameters): from$4.ReturnType;
1421
+ declare namespace from$4 {
1422
+ type Parameters = {
1423
+ id: string;
1424
+ chainId: Id;
1425
+ contract: Address;
1426
+ from: Address;
1427
+ to: Address;
1428
+ value: bigint;
1429
+ blockNumber: number;
1430
+ };
1431
+ type ReturnType = Transfer;
1432
+ }
1433
+ declare namespace Tree_d_exports {
1434
+ export { Tree, VERSION, decode$1 as decode, encode$1 as encode, from$3 as from };
1435
+ }
1436
+ type Tree = Compute<StandardMerkleTree<[Hex]> & {
1437
+ offers: Offer[];
1438
+ root: Hex;
1439
+ }>;
1440
+ declare const VERSION = 1;
1441
+ /**
1442
+ * Builds a Merkle tree from a list of offers.
1443
+ *
1444
+ * Leaves are the offer `hash` values as `bytes32` and are deterministically
1445
+ * ordered in ascending lexicographic order so that the resulting root is stable
1446
+ * regardless of the input order.
1447
+ *
1448
+ * @param offers - Offers to include in the tree.
1449
+ * @returns A `StandardMerkleTree` of `bytes32` leaves representing the offers.
1450
+ */
1451
+ declare const from$3: (offers: Offer[]) => Tree;
1452
+ /**
1453
+ * Encodes an `Tree` into a Hex string with a version byte prefix and gzipped payload.
1454
+ *
1455
+ * - Layout: `0x{vv}{zip...}` where `{vv}` is one-byte version as two hex chars.
1456
+ * - Payload is gzip(JSON.stringify([root, ...offers])) with bigint stringified.
1457
+ *
1458
+ * @param tree - The offer Merkle tree to encode.
1459
+ * @returns Hex string starting with `0x{vv}` followed by gzipped payload bytes.
1460
+ * @throws Error if the given `root` does not match the offers.
1461
+ */
1462
+ declare const encode$1: (tree: Tree) => Hex;
1463
+ /**
1464
+ * Decodes a Hex string produced by {@link encode} back into an `Tree`.
1465
+ *
1466
+ * - Ensures the first byte version matches {@link VERSION}.
1467
+ * - Decompresses with gunzip, parses JSON, validates offers, and re-checks the root.
1468
+ *
1469
+ * @param encoded - Hex string in the form `0x{vv}{zip...}`.
1470
+ * @returns A validated `Tree` rebuilt from the offers.
1471
+ * @throws Error if the version is invalid or the root does not match the offers.
1472
+ */
1473
+ declare const decode$1: (encoded: Hex) => Tree;
1474
+ //#endregion
1475
+ //#region src/api/Schema/generated/swagger.d.ts
1476
+ /**
1477
+ * This file was auto-generated by openapi-typescript.
1478
+ * Do not make direct changes to the file.
1479
+ */
1155
1480
 
1156
- type ObligationResponse = Snake<Compute<{
1157
- /** The obligation id. */
1158
- id: Hex;
1159
- } & Obligation & {
1160
- ask: Quote["ask"];
1161
- bid: Quote["bid"];
1162
- }>>;
1481
+ interface paths {
1482
+ "/v1/books/{obligationId}/{side}": {
1483
+ parameters: {
1484
+ query?: never;
1485
+ header?: never;
1486
+ path?: never;
1487
+ cookie?: never;
1488
+ };
1489
+ /**
1490
+ * Get aggregated book
1491
+ * @description Returns aggregated book data for a given obligation and side. Offers are grouped by rate with summed takeable amounts. Book levels are sorted by rate (ascending for buy side, descending for sell side).
1492
+ */
1493
+ get: {
1494
+ parameters: {
1495
+ query?: {
1496
+ /**
1497
+ * @description Maximum number of rate levels to return.
1498
+ * @example 10
1499
+ */
1500
+ limit?: number;
1501
+ /**
1502
+ * @description Pagination cursor in base64url-encoded format.
1503
+ * @example eyJvZmZzZXQiOjEwMH0
1504
+ */
1505
+ cursor?: string;
1506
+ };
1507
+ header?: never;
1508
+ path?: never;
1509
+ cookie?: never;
1510
+ };
1511
+ requestBody?: never;
1512
+ responses: {
1513
+ /** @description Success */
1514
+ 200: {
1515
+ headers: {
1516
+ [name: string]: unknown;
1517
+ };
1518
+ content: {
1519
+ "application/json": components["schemas"]["BookListResponse"];
1520
+ };
1521
+ };
1522
+ /** @description Bad Request */
1523
+ 400: {
1524
+ headers: {
1525
+ [name: string]: unknown;
1526
+ };
1527
+ content: {
1528
+ "application/json": components["schemas"]["BadRequestResponse"];
1529
+ };
1530
+ };
1531
+ };
1532
+ };
1533
+ put?: never;
1534
+ post?: never;
1535
+ delete?: never;
1536
+ options?: never;
1537
+ head?: never;
1538
+ patch?: never;
1539
+ trace?: never;
1540
+ };
1541
+ "/v1/offers": {
1542
+ parameters: {
1543
+ query?: never;
1544
+ header?: never;
1545
+ path?: never;
1546
+ cookie?: never;
1547
+ };
1548
+ /**
1549
+ * List all offers
1550
+ * @description Returns offers. Provide either `obligation_id` + `side` (order book) or `offering` (by maker).
1551
+ */
1552
+ get: {
1553
+ parameters: {
1554
+ query?: {
1555
+ /**
1556
+ * @description Maximum number of offers to return.
1557
+ * @example 10
1558
+ */
1559
+ limit?: number;
1560
+ /**
1561
+ * @description Pagination cursor in base64url-encoded format.
1562
+ * @example eyJvZmZzZXQiOjEwMH0
1563
+ */
1564
+ cursor?: string;
1565
+ /**
1566
+ * @description Maker address to filter offers by. Alternative to obligation_id + side.
1567
+ * @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401
1568
+ */
1569
+ offering?: string;
1570
+ /**
1571
+ * @description Obligation id used to filter offers. Required when not using offering.
1572
+ * @example 0x1234567890123456789012345678901234567890123456789012345678901234
1573
+ */
1574
+ obligation_id?: string;
1575
+ /**
1576
+ * @description Side of the offer. Required when using obligation_id.
1577
+ * @example buy
1578
+ */
1579
+ side?: "buy" | "sell";
1580
+ };
1581
+ header?: never;
1582
+ path?: never;
1583
+ cookie?: never;
1584
+ };
1585
+ requestBody?: never;
1586
+ responses: {
1587
+ /** @description Success */
1588
+ 200: {
1589
+ headers: {
1590
+ [name: string]: unknown;
1591
+ };
1592
+ content: {
1593
+ "application/json": components["schemas"]["OfferListResponse"];
1594
+ };
1595
+ };
1596
+ /** @description Bad Request */
1597
+ 400: {
1598
+ headers: {
1599
+ [name: string]: unknown;
1600
+ };
1601
+ content: {
1602
+ "application/json": components["schemas"]["BadRequestResponse"];
1603
+ };
1604
+ };
1605
+ };
1606
+ };
1607
+ put?: never;
1608
+ post?: never;
1609
+ delete?: never;
1610
+ options?: never;
1611
+ head?: never;
1612
+ patch?: never;
1613
+ trace?: never;
1614
+ };
1615
+ "/v1/obligations": {
1616
+ parameters: {
1617
+ query?: never;
1618
+ header?: never;
1619
+ path?: never;
1620
+ cookie?: never;
1621
+ };
1622
+ /**
1623
+ * List all obligations
1624
+ * @description Returns a list of obligations with their current best ask and bid. Obligations are sorted by their id in ascending order by default.
1625
+ */
1626
+ get: {
1627
+ parameters: {
1628
+ query?: {
1629
+ /** @example 10 */
1630
+ limit?: number;
1631
+ /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
1632
+ cursor?: string;
1633
+ };
1634
+ header?: never;
1635
+ path?: never;
1636
+ cookie?: never;
1637
+ };
1638
+ requestBody?: never;
1639
+ responses: {
1640
+ /** @description Success */
1641
+ 200: {
1642
+ headers: {
1643
+ [name: string]: unknown;
1644
+ };
1645
+ content: {
1646
+ "application/json": components["schemas"]["ObligationListResponse"];
1647
+ };
1648
+ };
1649
+ /** @description Bad Request */
1650
+ 400: {
1651
+ headers: {
1652
+ [name: string]: unknown;
1653
+ };
1654
+ content: {
1655
+ "application/json": components["schemas"]["BadRequestResponse"];
1656
+ };
1657
+ };
1658
+ };
1659
+ };
1660
+ put?: never;
1661
+ post?: never;
1662
+ delete?: never;
1663
+ options?: never;
1664
+ head?: never;
1665
+ patch?: never;
1666
+ trace?: never;
1667
+ };
1668
+ "/v1/obligations/{obligationId}": {
1669
+ parameters: {
1670
+ query?: never;
1671
+ header?: never;
1672
+ path?: never;
1673
+ cookie?: never;
1674
+ };
1675
+ /**
1676
+ * Get an obligation
1677
+ * @description Returns an obligation by its id.
1678
+ */
1679
+ get: {
1680
+ parameters: {
1681
+ query?: never;
1682
+ header?: never;
1683
+ path?: never;
1684
+ cookie?: never;
1685
+ };
1686
+ requestBody?: never;
1687
+ responses: {
1688
+ /** @description Success */
1689
+ 200: {
1690
+ headers: {
1691
+ [name: string]: unknown;
1692
+ };
1693
+ content: {
1694
+ "application/json": components["schemas"]["ObligationSingleSuccessResponse"];
1695
+ };
1696
+ };
1697
+ /** @description Bad Request */
1698
+ 400: {
1699
+ headers: {
1700
+ [name: string]: unknown;
1701
+ };
1702
+ content: {
1703
+ "application/json": components["schemas"]["BadRequestResponse"];
1704
+ };
1705
+ };
1706
+ };
1707
+ };
1708
+ put?: never;
1709
+ post?: never;
1710
+ delete?: never;
1711
+ options?: never;
1712
+ head?: never;
1713
+ patch?: never;
1714
+ trace?: never;
1715
+ };
1716
+ "/v1/health": {
1717
+ parameters: {
1718
+ query?: never;
1719
+ header?: never;
1720
+ path?: never;
1721
+ cookie?: never;
1722
+ };
1723
+ /**
1724
+ * Retrieve global health
1725
+ * @description Returns the aggregated status of the router.
1726
+ */
1727
+ get: {
1728
+ parameters: {
1729
+ query?: never;
1730
+ header?: never;
1731
+ path?: never;
1732
+ cookie?: never;
1733
+ };
1734
+ requestBody?: never;
1735
+ responses: {
1736
+ /** @description Success */
1737
+ 200: {
1738
+ headers: {
1739
+ [name: string]: unknown;
1740
+ };
1741
+ content: {
1742
+ "application/json": components["schemas"]["RouterStatusSuccessResponse"];
1743
+ };
1744
+ };
1745
+ };
1746
+ };
1747
+ put?: never;
1748
+ post?: never;
1749
+ delete?: never;
1750
+ options?: never;
1751
+ head?: never;
1752
+ patch?: never;
1753
+ trace?: never;
1754
+ };
1755
+ "/v1/health/collectors": {
1756
+ parameters: {
1757
+ query?: never;
1758
+ header?: never;
1759
+ path?: never;
1760
+ cookie?: never;
1761
+ };
1762
+ /**
1763
+ * Retrieve collectors health
1764
+ * @description Returns the latest block numbers processed by collectors and their sync status.
1765
+ */
1766
+ get: {
1767
+ parameters: {
1768
+ query?: never;
1769
+ header?: never;
1770
+ path?: never;
1771
+ cookie?: never;
1772
+ };
1773
+ requestBody?: never;
1774
+ responses: {
1775
+ /** @description Success */
1776
+ 200: {
1777
+ headers: {
1778
+ [name: string]: unknown;
1779
+ };
1780
+ content: {
1781
+ "application/json": components["schemas"]["CollectorsHealthSuccessResponse"];
1782
+ };
1783
+ };
1784
+ };
1785
+ };
1786
+ put?: never;
1787
+ post?: never;
1788
+ delete?: never;
1789
+ options?: never;
1790
+ head?: never;
1791
+ patch?: never;
1792
+ trace?: never;
1793
+ };
1794
+ "/v1/health/chains": {
1795
+ parameters: {
1796
+ query?: never;
1797
+ header?: never;
1798
+ path?: never;
1799
+ cookie?: never;
1800
+ };
1801
+ /**
1802
+ * Retrieve chains health
1803
+ * @description Returns the latest block that can be processed by collectors for each chain.
1804
+ */
1805
+ get: {
1806
+ parameters: {
1807
+ query?: never;
1808
+ header?: never;
1809
+ path?: never;
1810
+ cookie?: never;
1811
+ };
1812
+ requestBody?: never;
1813
+ responses: {
1814
+ /** @description Success */
1815
+ 200: {
1816
+ headers: {
1817
+ [name: string]: unknown;
1818
+ };
1819
+ content: {
1820
+ "application/json": components["schemas"]["ChainsHealthSuccessResponse"];
1821
+ };
1822
+ };
1823
+ };
1824
+ };
1825
+ put?: never;
1826
+ post?: never;
1827
+ delete?: never;
1828
+ options?: never;
1829
+ head?: never;
1830
+ patch?: never;
1831
+ trace?: never;
1832
+ };
1833
+ "/v1/validate": {
1834
+ parameters: {
1835
+ query?: never;
1836
+ header?: never;
1837
+ path?: never;
1838
+ cookie?: never;
1839
+ };
1840
+ get?: never;
1841
+ put?: never;
1842
+ /**
1843
+ * Validate offers
1844
+ * @description Validates offers against router validation rules. Returns validation status for each offer.
1845
+ *
1846
+ * **Available validation rules:**
1847
+ * - **parse_error**: Returns when an offer fails to parse due to invalid format or missing required fields
1848
+ * - **chain_ids**: Validates that offer chain is one of: [109111114]
1849
+ * - **maturity**: Validates that offer maturity is one of: [end_of_month, end_of_next_month]
1850
+ * - **callback**: Validates callbacks: buy empty callback is allowed; sell offers must use a non-empty callback; non-empty callbacks must target one of [0x3333333333333333333333333333333333333333, 0x4444444444444444444444444444444444444444, 0x1111111111111111111111111111111111111111, 0x2222222222222222222222222222222222222222]
1851
+ * - **token**: Validates that offer loan token and collateral tokens are in the allowed assets list
1852
+ */
1853
+ post: {
1854
+ parameters: {
1855
+ query?: never;
1856
+ header?: never;
1857
+ path?: never;
1858
+ cookie?: never;
1859
+ };
1860
+ requestBody?: {
1861
+ content: {
1862
+ "application/json": components["schemas"]["ValidateOffersRequest"];
1863
+ };
1864
+ };
1865
+ responses: {
1866
+ /** @description Success */
1867
+ 200: {
1868
+ headers: {
1869
+ [name: string]: unknown;
1870
+ };
1871
+ content: {
1872
+ "application/json": components["schemas"]["ValidateOffersListResponse"];
1873
+ };
1874
+ };
1875
+ /** @description Bad Request */
1876
+ 400: {
1877
+ headers: {
1878
+ [name: string]: unknown;
1879
+ };
1880
+ content: {
1881
+ "application/json": components["schemas"]["BadRequestResponse"];
1882
+ };
1883
+ };
1884
+ };
1885
+ };
1886
+ delete?: never;
1887
+ options?: never;
1888
+ head?: never;
1889
+ patch?: never;
1890
+ trace?: never;
1891
+ };
1892
+ }
1893
+ interface components {
1894
+ schemas: {
1895
+ BookListResponse: {
1896
+ meta: components["schemas"]["Meta"];
1897
+ /** @example eyJvZmZzZXQiOjEwMH0 */
1898
+ cursor: string | null;
1899
+ /** @description Aggregated book levels grouped by rate. */
1900
+ data: components["schemas"]["BookLevelResponse"][];
1901
+ };
1902
+ Meta: {
1903
+ /** @example 2024-01-01T12:00:00.000Z */
1904
+ timestamp: string;
1905
+ };
1906
+ BookLevelResponse: {
1907
+ /** @example 2750000000000000000 */
1908
+ rate: string;
1909
+ /** @example 369216000000000000000000 */
1910
+ assets: string;
1911
+ /** @example 5 */
1912
+ count: number;
1913
+ };
1914
+ BadRequestResponse: {
1915
+ error: components["schemas"]["ErrorResponse"];
1916
+ meta: components["schemas"]["Meta"];
1917
+ };
1918
+ ErrorResponse: {
1919
+ /**
1920
+ * @example VALIDATION_ERROR
1921
+ * @enum {string}
1922
+ */
1923
+ code: "VALIDATION_ERROR" | "NOT_FOUND" | "INTERNAL_SERVER_ERROR" | "BAD_REQUEST";
1924
+ /** @example Limit must be greater than 0. */
1925
+ message: string;
1926
+ /**
1927
+ * @example [
1928
+ * {
1929
+ * "field": "limit",
1930
+ * "issue": "Limit must be greater than 0."
1931
+ * }
1932
+ * ]
1933
+ */
1934
+ details: Record<string, never>;
1935
+ };
1936
+ OfferListResponse: {
1937
+ meta: components["schemas"]["Meta"];
1938
+ /** @example eyJvZmZzZXQiOjEwMH0 */
1939
+ cursor: string | null;
1940
+ /**
1941
+ * @description Offers matching the provided filters.
1942
+ * @example [
1943
+ * {
1944
+ * "hash": "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
1945
+ * "offering": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
1946
+ * "assets": "369216000000000000000000",
1947
+ * "rate": "2750000000000000000",
1948
+ * "maturity": 1761922799,
1949
+ * "expiry": 1761922799,
1950
+ * "start": 1761922790,
1951
+ * "nonce": "571380",
1952
+ * "buy": false,
1953
+ * "chain_id": 1,
1954
+ * "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
1955
+ * "collaterals": [
1956
+ * {
1957
+ * "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
1958
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
1959
+ * "lltv": "860000000000000000"
1960
+ * }
1961
+ * ],
1962
+ * "callback": {
1963
+ * "address": "0x1111111111111111111111111111111111111111",
1964
+ * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
1965
+ * "gas_limit": "500000"
1966
+ * },
1967
+ * "signature": "0x1234567890123456789012345678901234567890123456789012345678901234123456789012345678901234567890123456789012345678901234567890123400",
1968
+ * "consumed": "0",
1969
+ * "takeable": "369216000000000000000000",
1970
+ * "block_number": 2942933377146801
1971
+ * }
1972
+ * ]
1973
+ */
1974
+ data: components["schemas"]["OfferListItemResponse"][];
1975
+ };
1976
+ OfferListItemResponse: {
1977
+ /** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
1978
+ hash: string;
1979
+ /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
1980
+ offering: string;
1981
+ /** @example 369216000000000000000000 */
1982
+ assets: string;
1983
+ /** @example 2750000000000000000 */
1984
+ rate: string;
1985
+ /** @example 1761922799 */
1986
+ maturity: number;
1987
+ /** @example 1761922799 */
1988
+ expiry: number;
1989
+ /** @example 1761922790 */
1990
+ start: number;
1991
+ /** @example 571380 */
1992
+ nonce: string;
1993
+ /** @example false */
1994
+ buy: boolean;
1995
+ /** @example 1 */
1996
+ chain_id: number;
1997
+ /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
1998
+ loan_token: string;
1999
+ /**
2000
+ * @example [
2001
+ * {
2002
+ * "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2003
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
2004
+ * "lltv": "860000000000000000"
2005
+ * }
2006
+ * ]
2007
+ */
2008
+ collaterals: components["schemas"]["CollateralResponse"][];
2009
+ /**
2010
+ * @example {
2011
+ * "address": "0x1111111111111111111111111111111111111111",
2012
+ * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
2013
+ * "gas_limit": "500000"
2014
+ * }
2015
+ */
2016
+ callback: components["schemas"]["OfferCallbackResponse"];
2017
+ /** @example 369216000000000000000000 */
2018
+ takeable: string;
2019
+ /** @example 0 */
2020
+ consumed: string;
2021
+ /** @example 2942933377146801 */
2022
+ block_number: number;
2023
+ /** @example 0x1234567890123456789012345678901234567890123456789012345678901234123456789012345678901234567890123456789012345678901234567890123400 */
2024
+ signature: string | null;
2025
+ };
2026
+ CollateralResponse: {
2027
+ /** @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751 */
2028
+ asset: string;
2029
+ /** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
2030
+ oracle: string;
2031
+ /** @example 860000000000000000 */
2032
+ lltv: string;
2033
+ };
2034
+ OfferCallbackResponse: {
2035
+ /** @example 0x1111111111111111111111111111111111111111 */
2036
+ address: string;
2037
+ /** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
2038
+ data: string;
2039
+ /** @example 500000 */
2040
+ gas_limit: string;
2041
+ };
2042
+ ObligationListResponse: {
2043
+ meta: components["schemas"]["Meta"];
2044
+ /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
2045
+ cursor: string | null;
2046
+ /** @description List of obligations with takable offers. */
2047
+ data: components["schemas"]["ObligationResponse"][];
2048
+ };
2049
+ ObligationResponse: {
2050
+ /** @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67 */
2051
+ id: string;
2052
+ /** @example 1 */
2053
+ chain_id: number;
2054
+ /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
2055
+ loan_token: string;
2056
+ collaterals: components["schemas"]["CollateralResponse"][];
2057
+ /** @example 1761922800 */
2058
+ maturity: number;
2059
+ ask: components["schemas"]["AskResponse"];
2060
+ bid: components["schemas"]["BidResponse"];
2061
+ };
2062
+ AskResponse: {
2063
+ /** @example 1000000000000000000 */
2064
+ rate: string;
2065
+ };
2066
+ BidResponse: {
2067
+ /** @example 1000000000000000000 */
2068
+ rate: string;
2069
+ };
2070
+ ObligationSingleSuccessResponse: {
2071
+ meta: components["schemas"]["Meta"];
2072
+ /** @example null */
2073
+ cursor: string | null;
2074
+ /** @description Obligation details. */
2075
+ data: components["schemas"]["ObligationResponse"];
2076
+ };
2077
+ RouterStatusSuccessResponse: {
2078
+ meta: components["schemas"]["Meta"];
2079
+ /**
2080
+ * @description Aggregated router status.
2081
+ * @example {
2082
+ * "status": "live"
2083
+ * }
2084
+ */
2085
+ data: components["schemas"]["RouterStatusDataResponse"];
2086
+ };
2087
+ RouterStatusDataResponse: {
2088
+ /**
2089
+ * @example live
2090
+ * @enum {string}
2091
+ */
2092
+ status: "live" | "syncing";
2093
+ };
2094
+ CollectorsHealthSuccessResponse: {
2095
+ meta: components["schemas"]["Meta"];
2096
+ /**
2097
+ * @description Collectors health details and sync status.
2098
+ * @example [
2099
+ * {
2100
+ * "name": "offers",
2101
+ * "chain_id": 1,
2102
+ * "block_number": 21345678,
2103
+ * "updated_at": "2024-01-01T12:00:00.000Z",
2104
+ * "lag": 0,
2105
+ * "status": "live"
2106
+ * }
2107
+ * ]
2108
+ */
2109
+ data: components["schemas"]["CollectorHealthResponse"][];
2110
+ };
2111
+ CollectorHealthResponse: {
2112
+ /** @example offers */
2113
+ name: string;
2114
+ /** @example 1 */
2115
+ chain_id: number;
2116
+ /** @example 21345678 */
2117
+ block_number: number | null;
2118
+ /** @example 2024-01-01T12:00:00.000Z */
2119
+ updated_at: string | null;
2120
+ /** @example 0 */
2121
+ lag: number | null;
2122
+ /**
2123
+ * @example live
2124
+ * @enum {string}
2125
+ */
2126
+ status: "live" | "lagging" | "unknown";
2127
+ };
2128
+ ChainsHealthSuccessResponse: {
2129
+ meta: components["schemas"]["Meta"];
2130
+ /**
2131
+ * @description Latest processed block per chain.
2132
+ * @example [
2133
+ * {
2134
+ * "chain_id": 1,
2135
+ * "local_block_number": 21345678,
2136
+ * "remote_block_number": 21345690,
2137
+ * "updated_at": "2024-01-01T12:00:00.000Z"
2138
+ * }
2139
+ * ]
2140
+ */
2141
+ data: components["schemas"]["ChainHealthResponse"][];
2142
+ };
2143
+ ChainHealthResponse: {
2144
+ /** @example 1 */
2145
+ chain_id: number;
2146
+ /** @example 21345678 */
2147
+ local_block_number: number;
2148
+ /** @example 21345690 */
2149
+ remote_block_number: number | null;
2150
+ /** @example 2024-01-01T12:00:00.000Z */
2151
+ updated_at: string;
2152
+ };
2153
+ ValidateOffersRequest: {
2154
+ /** @description Array of offers in snake_case format. Mutually exclusive with 'calldata'. */
2155
+ offers?: components["schemas"]["ValidateOfferRequest"][];
2156
+ /**
2157
+ * @description Encoded tree calldata as a hex string (0x-prefixed). Mutually exclusive with 'offers'.
2158
+ * @example 0x01...
2159
+ */
2160
+ calldata?: string;
2161
+ };
2162
+ ValidateOfferRequest: {
2163
+ /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
2164
+ offering: string;
2165
+ /** @example 369216000000000000000000 */
2166
+ assets: string;
2167
+ /** @example 2750000000000000000 */
2168
+ rate: string;
2169
+ /** @example 1761922799 */
2170
+ maturity: number;
2171
+ /** @example 1761922799 */
2172
+ expiry: number;
2173
+ /** @example 1761922790 */
2174
+ start: number;
2175
+ /** @example 571380 */
2176
+ nonce: string;
2177
+ /** @example false */
2178
+ buy: boolean;
2179
+ /** @example 1 */
2180
+ chain_id: number;
2181
+ /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
2182
+ loan_token: string;
2183
+ /**
2184
+ * @example [
2185
+ * {
2186
+ * "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2187
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
2188
+ * "lltv": "860000000000000000"
2189
+ * }
2190
+ * ]
2191
+ */
2192
+ collaterals: components["schemas"]["CollateralResponse"][];
2193
+ /**
2194
+ * @example {
2195
+ * "address": "0x1111111111111111111111111111111111111111",
2196
+ * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
2197
+ * "gas_limit": "500000"
2198
+ * }
2199
+ */
2200
+ callback: components["schemas"]["OfferCallbackResponse"];
2201
+ };
2202
+ ValidateOffersListResponse: {
2203
+ meta: components["schemas"]["Meta"];
2204
+ /** @example null */
2205
+ cursor: string | null;
2206
+ /** @description Validation results for each offer. */
2207
+ data: components["schemas"]["ValidateOfferResultResponse"][];
2208
+ };
2209
+ ValidateOfferResultResponse: {
2210
+ /** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
2211
+ offer_hash: string;
2212
+ /** @example false */
2213
+ valid: boolean;
2214
+ /** @example parse_error */
2215
+ rule: string | null;
2216
+ /** @example Invalid offer. 'offering': invalid address */
2217
+ message: string | null;
2218
+ };
2219
+ };
2220
+ responses: never;
2221
+ parameters: never;
2222
+ requestBodies: never;
2223
+ headers: never;
2224
+ pathItems: never;
2225
+ }
2226
+ declare namespace ObligationResponse_d_exports {
2227
+ export { ObligationResponse, from$2 as from };
2228
+ }
2229
+ type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
1163
2230
  /**
1164
2231
  * Creates an `ObligationResponse` from a `Obligation`.
1165
2232
  * @constructor
@@ -1167,13 +2234,10 @@ type ObligationResponse = Snake<Compute<{
1167
2234
  * @returns The created `ObligationResponse`. {@link ObligationResponse}
1168
2235
  */
1169
2236
  declare function from$2(obligation: Obligation, quote: Quote): ObligationResponse;
1170
-
1171
- type ObligationResponse$1_ObligationResponse = ObligationResponse;
1172
- declare namespace ObligationResponse$1 {
1173
- export { type ObligationResponse$1_ObligationResponse as ObligationResponse, from$2 as from };
2237
+ declare namespace OfferResponse_d_exports {
2238
+ export { OfferResponse, from$1 as from };
1174
2239
  }
1175
-
1176
- type OfferResponse = Snake<Offer>;
2240
+ type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
1177
2241
  /**
1178
2242
  * Creates an `OfferResponse` from an `Offer`.
1179
2243
  * @constructor
@@ -1181,415 +2245,473 @@ type OfferResponse = Snake<Offer>;
1181
2245
  * @returns The created `OfferResponse`. {@link OfferResponse}
1182
2246
  */
1183
2247
  declare function from$1(offer: Offer): OfferResponse;
1184
-
1185
- type OfferResponse$1_OfferResponse = OfferResponse;
1186
- declare namespace OfferResponse$1 {
1187
- export { type OfferResponse$1_OfferResponse as OfferResponse, from$1 as from };
2248
+ //#endregion
2249
+ //#region src/api/Schema/openapi.d.ts
2250
+ declare class BooksController {
2251
+ getBook(): Promise<void>;
1188
2252
  }
1189
-
1190
- declare const OpenApi: node_modules_zod_openapi_dist_components_CXzxKPFp_js.OpenAPIObject;
1191
-
2253
+ declare class ValidateController {
2254
+ validateOffers(): Promise<void>;
2255
+ }
2256
+ declare class OffersController {
2257
+ getOffers(): Promise<void>;
2258
+ }
2259
+ declare class HealthController {
2260
+ getRouterStatus(): Promise<void>;
2261
+ getCollectorsHealth(): Promise<void>;
2262
+ getChainsHealth(): Promise<void>;
2263
+ }
2264
+ declare class ObligationsController {
2265
+ getObligations(): Promise<void>;
2266
+ getObligation(): Promise<void>;
2267
+ }
2268
+ type RuleInfo = {
2269
+ name: string;
2270
+ description: string;
2271
+ };
2272
+ type OpenApiOptions = {
2273
+ rules?: RuleInfo[];
2274
+ };
2275
+ declare const OpenApi: (options?: OpenApiOptions) => Promise<OpenAPIDocument>;
2276
+ //#endregion
2277
+ //#region src/api/Schema/requests.d.ts
1192
2278
  declare const schemas: {
1193
- readonly get_offers: z.ZodObject<{
1194
- side: z.ZodEnum<{
1195
- buy: "buy";
1196
- sell: "sell";
1197
- }>;
1198
- obligation_id: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
1199
- cursor: z.ZodOptional<z.ZodString>;
1200
- limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
1201
- }, z.core.$strip>;
1202
- readonly get_obligations: z.ZodObject<{
1203
- cursor: z.ZodOptional<z.ZodString>;
1204
- limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
1205
- }, z.core.$strip>;
2279
+ readonly get_offers: z$1.ZodObject<{
2280
+ side: z$1.ZodOptional<z$1.ZodEnum<{
2281
+ buy: "buy";
2282
+ sell: "sell";
2283
+ }>>;
2284
+ obligation_id: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
2285
+ offering: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
2286
+ cursor: z$1.ZodOptional<z$1.ZodString>;
2287
+ limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
2288
+ }, z$1.core.$strip>;
2289
+ readonly get_obligations: z$1.ZodObject<{
2290
+ cursor: z$1.ZodOptional<z$1.ZodString>;
2291
+ limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
2292
+ }, z$1.core.$strip>;
2293
+ readonly get_obligation: z$1.ZodObject<{
2294
+ obligation_id: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
2295
+ }, z$1.core.$strip>;
2296
+ readonly get_book: z$1.ZodObject<{
2297
+ obligation_id: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
2298
+ side: z$1.ZodEnum<{
2299
+ buy: "buy";
2300
+ sell: "sell";
2301
+ }>;
2302
+ cursor: z$1.ZodOptional<z$1.ZodString>;
2303
+ limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
2304
+ }, z$1.core.$strip>;
2305
+ readonly validate_offers: z$1.ZodObject<{
2306
+ offers: z$1.ZodAny;
2307
+ calldata: z$1.ZodOptional<z$1.ZodString>;
2308
+ }, z$1.core.$strip>;
1206
2309
  };
1207
2310
  type Action = keyof typeof schemas;
1208
- declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
1209
- declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
1210
-
1211
- declare const index$1_ChainHealth: typeof ChainHealth;
1212
- type index$1_ChainsHealthResponse = ChainsHealthResponse;
1213
- declare const index$1_CollectorHealth: typeof CollectorHealth;
1214
- type index$1_CollectorsHealthResponse = CollectorsHealthResponse;
1215
- declare const index$1_OpenApi: typeof OpenApi;
1216
- type index$1_RouterStatusResponse = RouterStatusResponse;
1217
- declare const index$1_parse: typeof parse;
1218
- declare const index$1_safeParse: typeof safeParse;
1219
- declare namespace index$1 {
1220
- export { index$1_ChainHealth as ChainHealth, type index$1_ChainsHealthResponse as ChainsHealthResponse, index$1_CollectorHealth as CollectorHealth, type index$1_CollectorsHealthResponse as CollectorsHealthResponse, ObligationResponse$1 as ObligationResponse, OfferResponse$1 as OfferResponse, index$1_OpenApi as OpenApi, type index$1_RouterStatusResponse as RouterStatusResponse, index$1_parse as parse, index$1_safeParse as safeParse };
2311
+ declare function parse<A extends Action>(action: A, query: unknown): z$1.infer<(typeof schemas)[A]>;
2312
+ declare function safeParse<A extends Action>(action: A, query: unknown, error?: z$1.core.$ZodErrorMap<z$1.core.$ZodIssue>): z$1.ZodSafeParseResult<z$1.infer<(typeof schemas)[A]>>;
2313
+ declare namespace index_d_exports$1 {
2314
+ export { BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, OpenApiOptions, RouterStatusResponse, RuleInfo, ValidateController, parse, safeParse };
2315
+ }
2316
+ declare namespace Client_d_exports {
2317
+ export { Client$2 as Client, ConnectOptions, HttpForbiddenError, HttpGetApiFailedError, HttpRateLimitError, HttpUnauthorizedError, InvalidUrlError, connect$1 as connect, getObligations, getOffers };
1221
2318
  }
1222
-
1223
2319
  type RouterClientConfig = {
1224
- /** The URL of the router. */
1225
- readonly url: URL;
1226
- /** The default headers to use for each request. */
1227
- readonly headers: Headers;
2320
+ /** The URL of the router. */
2321
+ readonly url: URL;
2322
+ /** The default headers to use for each request. */
2323
+ readonly headers: Headers;
1228
2324
  };
1229
- type Client$1 = Compute<RouterClientConfig & {
1230
- /**
1231
- * Get offers from the router.
1232
- * @param parameters - {@link getOffers.Parameters}
1233
- * @returns The offers with pagination cursor. {@link getOffers.ReturnType}
1234
- *
1235
- * @example
1236
- * ```ts
1237
- * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
1238
- * const { offers, cursor } = await router.getOffers({ side: "buy", obligationId: "0xa1c...d2f" });
1239
- * console.log(offers);
1240
- * ```
1241
- */
1242
- getOffers: (parameters: getOffers.Parameters) => Promise<getOffers.ReturnType>;
1243
- /**
1244
- * Get obligations from the router.
1245
- * @param parameters - {@link getObligations.Parameters}
1246
- * @returns The obligations with pagination cursor. {@link getObligations.ReturnType}
1247
- *
1248
- * @example
1249
- * ```ts
1250
- * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
1251
- * const { obligations, cursor } = await router.getObligations();
1252
- * console.log(obligations);
1253
- * ```
1254
- */
1255
- getObligations: (parameters?: getObligations.Parameters) => Promise<getObligations.ReturnType>;
2325
+ type Client$2 = Compute<RouterClientConfig & {
2326
+ /**
2327
+ * Get offers from the router.
2328
+ * @param parameters - {@link getOffers.Parameters}
2329
+ * @returns The offers with pagination cursor. {@link getOffers.ReturnType}
2330
+ * @throws If the request fails - {@link getOffers.ErrorType}
2331
+ *
2332
+ * @example
2333
+ * ```ts
2334
+ * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
2335
+ * const { offers, cursor } = await router.getOffers({ side: "buy", obligationId: "0xa1c...d2f" });
2336
+ * console.log(offers);
2337
+ * ```
2338
+ */
2339
+ getOffers: (parameters: getOffers.Parameters) => Promise<getOffers.ReturnType>;
2340
+ /**
2341
+ * Get obligations from the router.
2342
+ * @param parameters - {@link getObligations.Parameters}
2343
+ * @returns The obligations with pagination cursor. {@link getObligations.ReturnType}
2344
+ * @throws If the request fails - {@link getObligations.ErrorType}
2345
+ *
2346
+ * @example
2347
+ * ```ts
2348
+ * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
2349
+ * const { obligations, cursor } = await router.getObligations();
2350
+ * console.log(obligations[0].id()); // 0x123...456
2351
+ * ```
2352
+ */
2353
+ getObligations: (parameters?: getObligations.Parameters) => Promise<getObligations.ReturnType>;
1256
2354
  }>;
1257
2355
  type ConnectOptions = {
1258
- /** The URL of the router to interact with.
1259
- * @default "https://router.morpho.dev"
1260
- */
1261
- url?: string;
1262
- /** The API key to use for the router API. */
1263
- apiKey?: string;
1264
- /** The default headers to use for each request. */
1265
- headers?: Headers;
2356
+ /** The URL of the router to interact with.
2357
+ * @default "https://router.morpho.dev"
2358
+ */
2359
+ url?: string;
2360
+ /** The API key to use for the router API. */
2361
+ apiKey?: string;
2362
+ /** The default headers to use for each request. */
2363
+ headers?: Headers;
1266
2364
  };
1267
2365
  /**
1268
2366
  * Creates an instance of a router client.
1269
2367
  * @constructor
1270
- * @param options - {@link ConnectOptions}
1271
- * @returns A Router Client. {@link Client}
2368
+ * @param parameters - {@link connect.Parameters}
2369
+ * @returns A Router Client. {@link connect.ReturnType}
1272
2370
  *
1273
2371
  * @example
1274
2372
  * ```typescript
1275
2373
  * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
1276
2374
  * ```
1277
2375
  */
1278
- declare function connect$1(options?: ConnectOptions): connect$1.ReturnType;
2376
+ declare function connect$1(parameters?: connect$1.Parameters): connect$1.ReturnType;
1279
2377
  declare namespace connect$1 {
1280
- type ReturnType = Client$1;
1281
- type ErrorType = InvalidUrlError;
2378
+ type Parameters = ConnectOptions;
2379
+ type ReturnType = Client$2;
2380
+ type ErrorType = InvalidUrlError;
1282
2381
  }
1283
- declare function getOffers(config: RouterClientConfig, parameters: getOffers.Parameters): Promise<getOffers.ReturnType>;
2382
+ declare function getOffers(apiClient: Client<paths>, parameters: getOffers.Parameters): Promise<getOffers.ReturnType>;
1284
2383
  declare namespace getOffers {
1285
- type Parameters = {
1286
- /** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
1287
- side: "buy" | "sell";
1288
- /** The offers obligation id */
1289
- obligationId: Hex;
1290
- /** Pagination cursor in base64url-encoded format */
1291
- cursor?: string;
1292
- /** Maximum number of offers to return. @default 20 */
1293
- limit?: number;
1294
- };
1295
- type ReturnType = {
1296
- offers: Offer[];
1297
- /** The pagination cursor. */
1298
- cursor: string | null;
1299
- };
1300
- type ErrorType = GetApiErrorType;
2384
+ type Parameters = {
2385
+ /** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
2386
+ side: "buy" | "sell";
2387
+ /** The offers obligation id */
2388
+ obligationId: Hex;
2389
+ /** Pagination cursor in base64url-encoded format */
2390
+ cursor?: string;
2391
+ /** Maximum number of offers to return. @default 20 */
2392
+ limit?: number;
2393
+ };
2394
+ type ReturnType = {
2395
+ offers: Offer[];
2396
+ /** The pagination cursor. */
2397
+ cursor: string | null;
2398
+ };
2399
+ type ErrorType = GetApiErrorType;
1301
2400
  }
1302
- declare function getObligations(config: RouterClientConfig, parameters?: getObligations.Parameters): Promise<getObligations.ReturnType>;
2401
+ declare function getObligations(apiClient: Client<paths>, parameters?: getObligations.Parameters): Promise<getObligations.ReturnType>;
1303
2402
  declare namespace getObligations {
1304
- type Parameters = {
1305
- /** Pagination cursor is a 32-byte hex string. */
1306
- cursor?: Hex;
1307
- /** Maximum number of obligations to return. @default 20 */
1308
- limit?: number;
1309
- };
1310
- type ReturnType = {
1311
- obligations: Compute<{
1312
- /** The obligation id. Uses {@link Obligation.id} to calculate the id.*/
1313
- id: () => Hex;
1314
- } & Obligation & Omit<Quote, "obligationId">>[];
1315
- /** The pagination cursor. */
1316
- cursor: string | null;
1317
- };
1318
- type ErrorType = GetApiErrorType;
2403
+ type Parameters = {
2404
+ /** Pagination cursor is a 32-byte hex string. */
2405
+ cursor?: Hex;
2406
+ /** Maximum number of obligations to return. @default 20 */
2407
+ limit?: number;
2408
+ };
2409
+ type ReturnType = {
2410
+ obligations: Compute<{
2411
+ /** The obligation id. Uses {@link Obligation.id} to calculate the id.*/
2412
+ id: () => Hex;
2413
+ } & Obligation & Omit<Quote, "obligationId">>[];
2414
+ /** The pagination cursor. */
2415
+ cursor: string | null;
2416
+ };
2417
+ type ErrorType = GetApiErrorType;
1319
2418
  }
1320
2419
  type GetApiErrorType = HttpGetApiFailedError | HttpUnauthorizedError | HttpForbiddenError | HttpRateLimitError;
1321
2420
  declare class InvalidUrlError extends BaseError {
1322
- name: string;
1323
- constructor(url: string);
2421
+ name: string;
2422
+ constructor(url: string);
1324
2423
  }
1325
2424
  declare class HttpUnauthorizedError extends BaseError {
1326
- name: string;
1327
- constructor();
2425
+ name: string;
2426
+ constructor();
1328
2427
  }
1329
2428
  declare class HttpForbiddenError extends BaseError {
1330
- name: string;
1331
- constructor();
2429
+ name: string;
2430
+ constructor();
1332
2431
  }
1333
2432
  declare class HttpRateLimitError extends BaseError {
1334
- name: string;
1335
- constructor();
2433
+ name: string;
2434
+ constructor();
1336
2435
  }
1337
2436
  declare class HttpGetApiFailedError extends BaseError {
1338
- name: string;
1339
- constructor(message: string, { details }?: {
1340
- details?: string;
1341
- });
2437
+ name: string;
2438
+ constructor(message: string, {
2439
+ details
2440
+ }?: {
2441
+ details?: string;
2442
+ });
1342
2443
  }
1343
-
1344
- type Client$2_ConnectOptions = ConnectOptions;
1345
- type Client$2_HttpForbiddenError = HttpForbiddenError;
1346
- declare const Client$2_HttpForbiddenError: typeof HttpForbiddenError;
1347
- type Client$2_HttpGetApiFailedError = HttpGetApiFailedError;
1348
- declare const Client$2_HttpGetApiFailedError: typeof HttpGetApiFailedError;
1349
- type Client$2_HttpRateLimitError = HttpRateLimitError;
1350
- declare const Client$2_HttpRateLimitError: typeof HttpRateLimitError;
1351
- type Client$2_HttpUnauthorizedError = HttpUnauthorizedError;
1352
- declare const Client$2_HttpUnauthorizedError: typeof HttpUnauthorizedError;
1353
- type Client$2_InvalidUrlError = InvalidUrlError;
1354
- declare const Client$2_InvalidUrlError: typeof InvalidUrlError;
1355
- declare const Client$2_getObligations: typeof getObligations;
1356
- declare const Client$2_getOffers: typeof getOffers;
1357
- declare namespace Client$2 {
1358
- export { type Client$1 as Client, type Client$2_ConnectOptions as ConnectOptions, Client$2_HttpForbiddenError as HttpForbiddenError, Client$2_HttpGetApiFailedError as HttpGetApiFailedError, Client$2_HttpRateLimitError as HttpRateLimitError, Client$2_HttpUnauthorizedError as HttpUnauthorizedError, Client$2_InvalidUrlError as InvalidUrlError, connect$1 as connect, Client$2_getObligations as getObligations, Client$2_getOffers as getOffers };
2444
+ declare namespace Cursor_d_exports {
2445
+ export { Cursor, decode, encode, validate };
2446
+ }
2447
+ type Cursor = {
2448
+ sort: "rate" | "maturity" | "expiry" | "amount";
2449
+ dir: "asc" | "desc";
2450
+ rate?: string;
2451
+ maturity?: number;
2452
+ expiry?: number;
2453
+ assets?: string;
2454
+ hash: string;
2455
+ page?: number;
2456
+ };
2457
+ declare function validate(cursor: unknown): cursor is Cursor;
2458
+ declare function encode(c: Cursor): string;
2459
+ declare function decode(token?: string): Cursor | null;
2460
+ declare namespace Gate_d_exports {
2461
+ export { Batch, Issue, Result, Rule, RuleNames, Single, batch$1 as batch, run, single };
1359
2462
  }
1360
-
1361
2463
  /**
1362
2464
  * A validation rule.
1363
2465
  */
1364
- type Rule<T, Name extends string = string, Ctx = void> = {
1365
- kind: "single";
1366
- name: Name;
1367
- run: Single<T, Name, Ctx>;
2466
+ type Rule<T, Name$1 extends string = string> = {
2467
+ kind: "single";
2468
+ name: Name$1;
2469
+ description: string;
2470
+ run: Single<T, Name$1>;
1368
2471
  } | {
1369
- kind: "batch";
1370
- name: Name;
1371
- run: Batch<T, Name, Ctx>;
2472
+ kind: "batch";
2473
+ name: Name$1;
2474
+ description: string;
2475
+ run: Batch<T, Name$1>;
1372
2476
  };
1373
- type RuleNames<Rules extends readonly {
1374
- name: string;
1375
- }[]> = Rules[number]["name"];
2477
+ type RuleNames<Rules$1 extends readonly {
2478
+ name: string;
2479
+ }[]> = Rules$1[number]["name"];
1376
2480
  /**
1377
2481
  * A single item validation rule.
1378
2482
  * @param item - The item to validate.
1379
- * @param ctx - The context of the validation.
1380
2483
  * @returns The issue that was found. If the item is valid, this will be undefined.
1381
2484
  */
1382
- type Single<T, RuleName extends string, Ctx = void> = (item: T, ctx: Ctx) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
2485
+ type Single<T, RuleName extends string> = (item: T) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
1383
2486
  /**
1384
2487
  * A batch item validation rule.
1385
2488
  * @param items - The items to validate.
1386
- * @param ctx - The context of the validation.
1387
2489
  * @returns A map of the items to the issue that was found.
1388
2490
  */
1389
- type Batch<T, RuleName extends string, Ctx = void> = (items: T[], ctx: Ctx) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
2491
+ type Batch<T, RuleName extends string> = (items: T[]) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
1390
2492
  /**
1391
2493
  * Create a validation rule iterating over a single item at a time.
1392
2494
  * @param name - The name of the rule.
2495
+ * @param description - A human-readable description of the rule.
1393
2496
  * @param run - The function that validates the rule.
1394
2497
  * @returns The created rule.
1395
2498
  */
1396
- declare function single<Name extends string, T, Ctx = void>(name: Name, run: Single<T, Name, Ctx>): Rule<T, Name, Ctx>;
2499
+ declare function single<Name$1 extends string, T>(name: Name$1, description: string, run: Single<T, Name$1>): Rule<T, Name$1>;
1397
2500
  /**
1398
2501
  * Create a validation rule iterating over a batch of items at a time.
1399
2502
  * @param name - The name of the rule.
2503
+ * @param description - A human-readable description of the rule.
1400
2504
  * @param run - The function that validates the rule.
1401
2505
  * @returns The created rule.
1402
2506
  */
1403
- declare function batch$1<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
1404
- type MorphoContext = {
1405
- chain: Chain;
1406
- client: PublicClient;
1407
- };
1408
- declare function morpho(): (Rule<Offer, "chain_id", MorphoContext> | Rule<Offer, "loan_token", MorphoContext> | Rule<Offer, "expiry", MorphoContext> | Rule<Offer, "sell_offers_empty_callback", MorphoContext> | Rule<Offer, "buy_offers_non_empty_callback", MorphoContext> | Rule<Offer, "sell_offers_non_whitelisted_callback", MorphoContext> | Rule<Offer, "sell_offers_callback_data_invalid", MorphoContext> | Rule<Offer, "sell_offers_callback_collateral_invalid", MorphoContext> | Rule<Offer, "buy_offers_callback_data_invalid", MorphoContext> | Rule<Offer, "buy_offers_callback_vault_invalid", MorphoContext> | Rule<Offer, "maturity", MorphoContext>)[];
1409
-
1410
- type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
1411
- type ValidationRule_MorphoContext = MorphoContext;
1412
- type ValidationRule_Rule<T, Name extends string = string, Ctx = void> = Rule<T, Name, Ctx>;
1413
- type ValidationRule_RuleNames<Rules extends readonly {
1414
- name: string;
1415
- }[]> = RuleNames<Rules>;
1416
- type ValidationRule_Single<T, RuleName extends string, Ctx = void> = Single<T, RuleName, Ctx>;
1417
- declare const ValidationRule_morpho: typeof morpho;
1418
- declare const ValidationRule_single: typeof single;
1419
- declare namespace ValidationRule {
1420
- export { type ValidationRule_Batch as Batch, type ValidationRule_MorphoContext as MorphoContext, type ValidationRule_Rule as Rule, type ValidationRule_RuleNames as RuleNames, type ValidationRule_Single as Single, batch$1 as batch, ValidationRule_morpho as morpho, ValidationRule_single as single };
1421
- }
1422
-
2507
+ declare function batch$1<Name$1 extends string, T>(name: Name$1, description: string, run: Batch<T, Name$1>): Rule<T, Name$1>;
1423
2508
  /**
1424
2509
  * A validation issue.
1425
2510
  */
1426
2511
  type Issue<T, RuleName extends string = string> = {
1427
- /** The name of the rule that caused the issue. */
1428
- ruleName: RuleName;
1429
- /** The message of the issue. */
1430
- message: string;
1431
- /** The item that was not valid. */
1432
- item: T;
2512
+ /** The name of the rule that caused the issue. */
2513
+ ruleName: RuleName;
2514
+ /** The message of the issue. */
2515
+ message: string;
2516
+ /** The item that was not valid. */
2517
+ item: T;
1433
2518
  };
1434
2519
  /**
1435
2520
  * The result of a validation.
1436
2521
  */
1437
2522
  type Result<T, RuleName extends string = string> = {
1438
- /** The items that were valid. */
1439
- valid: T[];
1440
- /** The reports of the failed validations. */
1441
- issues: Issue<T, RuleName>[];
2523
+ /** The items that were valid. */
2524
+ valid: T[];
2525
+ /** The reports of the failed validations. */
2526
+ issues: Issue<T, RuleName>[];
1442
2527
  };
1443
- declare function run<T, Name extends string, Rules extends readonly Rule<T, Name, void>[]>(parameters: {
1444
- items: T[];
1445
- rules: Rules;
1446
- chunkSize?: number;
1447
- }): Promise<Result<T, RuleNames<Rules>>>;
1448
- declare function run<T, Ctx, Name extends string, Rules extends readonly Rule<T, Name, Ctx>[]>(parameters: {
1449
- items: T[];
1450
- rules: Rules;
1451
- ctx: Ctx;
1452
- chunkSize?: number;
1453
- }): Promise<Result<T, RuleNames<Rules>>>;
1454
-
1455
- type Validation_Issue<T, RuleName extends string = string> = Issue<T, RuleName>;
1456
- type Validation_Result<T, RuleName extends string = string> = Result<T, RuleName>;
1457
- declare const Validation_run: typeof run;
1458
- declare namespace Validation {
1459
- export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
2528
+ declare function run<T, Name$1 extends string, Rules$1 extends readonly Rule<T, Name$1>[]>(parameters: {
2529
+ items: T[];
2530
+ rules: Rules$1;
2531
+ chunkSize?: number;
2532
+ }): Promise<Result<T, RuleNames<Rules$1>>>;
2533
+ declare namespace GateConfig_d_exports {
2534
+ export { CallbackConfig, GateConfig, assets$1 as assets, configs, getCallback, getCallbackAddresses, getCallbackType, getCallbackTypeAddresses };
1460
2535
  }
1461
-
2536
+ type GateConfig = {
2537
+ callbacks?: CallbackConfig[];
2538
+ maturities?: MaturityType[];
2539
+ };
2540
+ type CallbackConfig = {
2541
+ type: CallbackType.BuyVaultV1Callback;
2542
+ addresses: Address[];
2543
+ vaultFactories: Address[];
2544
+ } | {
2545
+ type: CallbackType.SellERC20Callback;
2546
+ addresses: Address[];
2547
+ } | {
2548
+ type: CallbackType.BuyWithEmptyCallback;
2549
+ };
2550
+ declare function getCallback(chain: Name, type: CallbackType.BuyVaultV1Callback): Extract<CallbackConfig, {
2551
+ type: CallbackType.BuyVaultV1Callback;
2552
+ }> | undefined;
2553
+ declare function getCallback(chain: Name, type: CallbackType.SellERC20Callback): Extract<CallbackConfig, {
2554
+ type: CallbackType.SellERC20Callback;
2555
+ }> | undefined;
2556
+ declare function getCallback(chain: Name, type: CallbackType.BuyWithEmptyCallback): Extract<CallbackConfig, {
2557
+ type: CallbackType.BuyWithEmptyCallback;
2558
+ }> | undefined;
2559
+ declare function getCallback(chain: Name, type: CallbackType): CallbackConfig | undefined;
2560
+ /**
2561
+ * Attempts to infer the configured callback type from a callback address on a chain.
2562
+ * Skips the empty callback type as it does not carry addresses.
2563
+ *
2564
+ * @param chain - Chain name for which to infer the callback type
2565
+ * @param address - Callback contract address
2566
+ * @returns The callback type when found, otherwise undefined
2567
+ */
2568
+ declare function getCallbackType(chain: Name, address: Address): CallbackType | undefined;
2569
+ /**
2570
+ * Returns the callback addresses for a given chain and callback type, if it exists.
2571
+ * @param chain - Chain name for which to read the validation configuration
2572
+ * @param type - Callback type to retrieve
2573
+ * @returns The matching callback addresses or an empty array if not configured
2574
+ */
2575
+ declare function getCallbackTypeAddresses(chain: Name, type: CallbackType): Address[];
2576
+ /**
2577
+ * Returns the list of allowed non-empty callback addresses for a chain.
2578
+ *
2579
+ * @param chain - Chain name
2580
+ * @returns Array of allowed callback addresses (lowercased). Empty when none configured
2581
+ */
2582
+ declare const getCallbackAddresses: (chain: Name) => Address[];
2583
+ declare const assets$1: Record<string, Address[]>;
2584
+ declare const configs: Record<Name, GateConfig>;
2585
+ declare namespace Gatekeeper_d_exports {
2586
+ export { Gatekeeper, Rules, create };
2587
+ }
2588
+ type Rules = readonly Rule<Offer, string>[];
2589
+ type Gatekeeper = {
2590
+ rules: Rules;
2591
+ isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
2592
+ };
2593
+ type GatekeeperParameters = {
2594
+ rules: Rules;
2595
+ };
2596
+ declare function create(parameters: GatekeeperParameters): Gatekeeper;
2597
+ //#endregion
2598
+ //#region src/gatekeeper/morphoRules.d.ts
2599
+ declare const morphoRules: (chains: Chain$1[]) => (Rule<Offer, "chain_ids"> | Rule<Offer, "maturity"> | Rule<Offer, "callback"> | Rule<Offer, "token">)[];
2600
+ declare namespace Rules_d_exports {
2601
+ export { ValidityParameters, callback, chains, maturity, token, validity };
2602
+ }
2603
+ type ValidityParameters = {
2604
+ client: PublicClient<Transport, Chain$1>;
2605
+ };
2606
+ /**
2607
+ * set of rules to validate offers.
2608
+ *
2609
+ * @param parameters - Validity parameters with chain and client
2610
+ * @returns Array of validation rules to evaluate against offers
2611
+ */
2612
+ declare function validity(parameters: ValidityParameters): (Rule<Offer, "expiry"> | Rule<Offer, "sell_erc20_callback_invalid"> | Rule<Offer, "buy_offers_callback_vault_invalid">)[];
2613
+ declare const chains: ({
2614
+ chains
2615
+ }: {
2616
+ chains: Chain$1[];
2617
+ }) => Rule<Offer, "chain_ids">;
2618
+ declare const maturity: ({
2619
+ maturities
2620
+ }: {
2621
+ maturities: MaturityType[];
2622
+ }) => Rule<Offer, "maturity">;
2623
+ declare const callback: ({
2624
+ callbacks,
2625
+ allowedAddresses
2626
+ }: {
2627
+ callbacks: CallbackType[];
2628
+ allowedAddresses: Address[];
2629
+ }) => Rule<Offer, "callback">;
2630
+ /**
2631
+ * A validation rule that checks if the offer's token is allowed.
2632
+ * @param offer - The offer to validate.
2633
+ * @returns The issue that was found. If the offer is valid, this will be undefined.
2634
+ */
2635
+ declare const token: ({
2636
+ assets
2637
+ }: {
2638
+ assets: Address[];
2639
+ }) => Rule<Offer, "token">;
2640
+ //#endregion
2641
+ //#region src/mempool/MempoolEVMClient.d.ts
1462
2642
  declare function from(parameters: from.Parameters): from.ReturnType;
1463
2643
  declare namespace from {
1464
- type Parameters = {
1465
- /** The viem client to use. */
1466
- client: WalletClient;
1467
- /** The mempool address. */
1468
- mempoolAddress: Address;
1469
- /** The block window to use for the mempool. Defaults to 100. */
1470
- blockWindow?: number;
1471
- };
1472
- type ReturnType = Client;
1473
- type ErrorType = null;
2644
+ type Parameters = {
2645
+ /** The viem client to use. */
2646
+ client: WalletClient;
2647
+ /** The mempool address. */
2648
+ mempoolAddress: Address;
2649
+ /** The block window to use for the mempool. Defaults to 100. */
2650
+ blockWindow?: number;
2651
+ };
2652
+ type ReturnType = Client$1;
2653
+ type ErrorType = null;
1474
2654
  }
1475
-
1476
- type AddParameters = {
1477
- offer: Compute<Omit<Offer, "hash" | "createdAt">>;
1478
- };
2655
+ declare namespace MempoolClient_d_exports {
2656
+ export { AddParameters, Client$1 as Client, GetParameters, connect };
2657
+ }
2658
+ type AddParameters = Compute<Omit<Offer, "hash" | "createdAt">[]>;
1479
2659
  type GetParameters = {
1480
- /** The block number to get offers from. */
1481
- blockNumberGte?: number;
1482
- /** The block number to get offers to. */
1483
- blockNumberLte?: number;
1484
- /** The loan asset to get offers from. */
1485
- loanToken?: string;
1486
- /** The order to get offers. Defaults to "desc". */
1487
- order?: "asc" | "desc";
1488
- /** The options to get offers from. */
1489
- options?: {
1490
- /** The maximum number of offers to return. Defaults to 100. Maximum is 1000. */
1491
- maxBatchSize?: number;
1492
- };
1493
- };
1494
- type WatchParameters = {
1495
- /** The async function to get the last synced block number from which to start watching.
1496
- * This function will be called periodically on each poll. It should be updated by the caller (e.g. using `onOffers` callback) to track the last synced block number.
1497
- */
1498
- lastSyncedBlock: () => Promise<number>;
1499
- /** The loan asset to watch. */
1500
- loanToken?: string;
1501
- /** The callback to call when a new batch of offers is found in the mempool.
1502
- * @param offers The offers found in the mempool.
1503
- * @param blockNumber The block number of the last processed offer. Block numbers will always ascend.
1504
- */
1505
- onOffers: (offers: Offer[], blockNumber: number) => Promise<void>;
1506
- /** The polling configuration. */
1507
- polling?: {
1508
- /** The interval in milliseconds to poll for new offers. Defaults to 30000. */
1509
- interval?: number;
1510
- /** The maximum number of offers that can be returned in a single batch.
1511
- * Defaults to 100. Maximum is 1000. */
1512
- maxBatchSize?: number;
1513
- };
2660
+ /** The block number to get offers from. */
2661
+ blockNumberGte?: number;
2662
+ /** The block number to get offers to. */
2663
+ blockNumberLte?: number;
2664
+ /** The loan asset to get offers from. */
2665
+ loanToken?: string;
2666
+ /** The order to get offers. Defaults to "desc". */
2667
+ order?: "asc" | "desc";
2668
+ /** The options to get offers from. */
2669
+ options?: {
2670
+ /** The maximum number of offers to return. Defaults to 100. Maximum is 1000. */
2671
+ maxBatchSize?: number;
2672
+ };
1514
2673
  };
1515
2674
  /**
1516
2675
  * Mempool client interface.
1517
2676
  */
1518
- type Client = {
1519
- /**
1520
- * Add an offer to the mempool.
1521
- * @returns The created offer with its hash.
1522
- */
1523
- add: (parameters: AddParameters) => Promise<{
1524
- offer: Offer;
1525
- txHash: Hex;
1526
- }>;
1527
- /** Get offers from the mempool. */
1528
- get: (parameters?: GetParameters) => AsyncGenerator<{
1529
- offers: Offer[];
1530
- /** The block number of the last processed offer. Depends on the `order` parameter, block numbers will ascend or descend. */
1531
- blockNumber: number;
1532
- }>;
1533
- /**
1534
- * Watch for new offers on a specific chain.
1535
- * @returns A function to stop watching for new offers.
1536
- */
1537
- watch: (parameters: WatchParameters) => () => boolean;
1538
- /**
1539
- * Stream offers from the mempool.
1540
- * @returns A generator of offers alongside the last block number processed.
1541
- */
1542
- stream: (parameters: Compute<Omit<GetParameters, "options"> & {
1543
- options: GetParameters["options"] & {
1544
- blockWindow?: number;
1545
- };
1546
- }>) => AsyncGenerator<{
1547
- offers: Offer[];
1548
- blockNumber: number;
1549
- }>;
2677
+ type Client$1 = {
2678
+ /**
2679
+ * Add an offer to the mempool.
2680
+ * @returns The created offer with its hash.
2681
+ */
2682
+ add: (parameters: AddParameters) => Promise<Hex>;
2683
+ /** Get offers from the mempool. */
2684
+ get: (parameters?: GetParameters) => AsyncGenerator<{
2685
+ offers: Offer[];
2686
+ /** The block number of the last processed offer. Depends on the `order` parameter, block numbers will ascend or descend. */
2687
+ blockNumber: number;
2688
+ }>;
2689
+ /**
2690
+ * Stream offers from the mempool.
2691
+ * @returns A generator of offers alongside the last block number processed.
2692
+ */
2693
+ stream: (parameters: Compute<Omit<GetParameters, "options"> & {
2694
+ options: GetParameters["options"] & {
2695
+ blockWindow?: number;
2696
+ };
2697
+ }>) => AsyncGenerator<{
2698
+ offers: Offer[];
2699
+ blockNumber: number;
2700
+ }>;
1550
2701
  };
1551
2702
  /**
1552
2703
  * Client to interact with the Mempool contract on a specific chain.
1553
2704
  */
1554
- declare function connect(parameters: from.Parameters): Client;
2705
+ declare function connect(parameters: from.Parameters): Client$1;
1555
2706
  declare namespace connect {
1556
- type ErrorType = from.ErrorType;
1557
- }
1558
-
1559
- type MempoolClient_AddParameters = AddParameters;
1560
- type MempoolClient_Client = Client;
1561
- type MempoolClient_GetParameters = GetParameters;
1562
- type MempoolClient_WatchParameters = WatchParameters;
1563
- declare const MempoolClient_connect: typeof connect;
1564
- declare namespace MempoolClient {
1565
- export { type MempoolClient_AddParameters as AddParameters, type MempoolClient_Client as Client, type MempoolClient_GetParameters as GetParameters, type MempoolClient_WatchParameters as WatchParameters, MempoolClient_connect as connect };
2707
+ type ErrorType = from.ErrorType;
1566
2708
  }
1567
-
1568
- type Cursor = {
1569
- sort: "rate" | "maturity" | "expiry" | "amount";
1570
- dir: "asc" | "desc";
1571
- rate?: string;
1572
- maturity?: number;
1573
- expiry?: number;
1574
- assets?: string;
1575
- hash: string;
1576
- page?: number;
1577
- };
1578
- declare function validate(cursor: unknown): cursor is Cursor;
1579
- declare function encode(c: Cursor): string;
1580
- declare function decode(token?: string): Cursor | null;
1581
-
1582
- type Cursor$1_Cursor = Cursor;
1583
- declare const Cursor$1_decode: typeof decode;
1584
- declare const Cursor$1_encode: typeof encode;
1585
- declare const Cursor$1_validate: typeof validate;
1586
- declare namespace Cursor$1 {
1587
- export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
1588
- }
1589
-
2709
+ //#endregion
2710
+ //#region src/utils/BigMath.d.ts
1590
2711
  declare function max$1(a: bigint, b: bigint): bigint;
1591
2712
  declare function min(a: bigint, b: bigint): bigint;
1592
-
2713
+ //#endregion
2714
+ //#region src/utils/batch.d.ts
1593
2715
  /**
1594
2716
  * Splits an array into batches of a specified size.
1595
2717
  * @param array The array to split.
@@ -1607,8 +2729,9 @@ declare function min(a: bigint, b: bigint): bigint;
1607
2729
  * // [5]
1608
2730
  * ```
1609
2731
  */
1610
- declare function batch<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;
1611
-
2732
+ declare function batch<T>(array: T[] | readonly T[], batchSize: number): Generator<T[], void, unknown>;
2733
+ //#endregion
2734
+ //#region src/utils/batchMulticall.d.ts
1612
2735
  /**
1613
2736
  * Helper function to execute multicall in batches with retry logic.
1614
2737
  * Abstracts the common pattern of batching calls, retrying, and collecting results.
@@ -1617,59 +2740,54 @@ declare function batch<T>(array: Array<T>, batchSize: number): Generator<T[], vo
1617
2740
  * @returns Promise resolving to flattened array of results
1618
2741
  */
1619
2742
  declare function batchMulticall<TResult>(parameters: {
1620
- client: Pick<PublicActions, "multicall">;
1621
- calls: unknown[];
1622
- batchSize: number;
1623
- retryAttempts: number;
1624
- retryDelayMs: number;
1625
- blockNumber?: bigint;
2743
+ client: PublicClient<Transport, Chain$1>;
2744
+ calls: MulticallParameters["contracts"];
2745
+ batchSize: number;
2746
+ retryAttempts: number;
2747
+ retryDelayMs: number;
2748
+ blockNumber?: bigint;
1626
2749
  }): Promise<TResult[]>;
1627
-
2750
+ //#endregion
2751
+ //#region src/utils/lazy.d.ts
1628
2752
  /**
1629
2753
  * Transform a polling function into an async generator.
1630
2754
  * @param fn - The polling function to transform.
1631
2755
  * @returns An async generator.
1632
2756
  */
1633
- declare function lazy<T>(pollFn: (emit: (value: T) => void, { stop }: {
1634
- stop: () => void;
2757
+ declare function lazy<T>(pollFn: (emit: (value: T) => void, {
2758
+ stop
2759
+ }: {
2760
+ stop: () => void;
1635
2761
  }) => () => boolean): () => AsyncGenerator<Awaited<NonNullable<T>>, void, unknown>;
1636
-
2762
+ //#endregion
2763
+ //#region src/utils/poll.d.ts
1637
2764
  /**
1638
2765
  * Polls a function at a specified interval.
1639
2766
  * Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
1640
2767
  */
1641
- declare function poll<data>(fn: ({ unpoll }: {
1642
- unpoll: () => void;
1643
- }) => Promise<data | undefined>, { interval }: {
1644
- interval: number;
2768
+ declare function poll<data>(fn: ({
2769
+ unpoll
2770
+ }: {
2771
+ unpoll: () => void;
2772
+ }) => Promise<data | undefined>, {
2773
+ interval
2774
+ }: {
2775
+ interval: () => Promise<number>;
1645
2776
  }): () => boolean;
1646
-
2777
+ //#endregion
2778
+ //#region src/utils/retry.d.ts
1647
2779
  declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
1648
-
2780
+ declare namespace time_d_exports {
2781
+ export { max, now };
2782
+ }
1649
2783
  declare function now(): number;
1650
2784
  declare function max(): number;
1651
-
1652
- declare const time_max: typeof max;
1653
- declare const time_now: typeof now;
1654
- declare namespace time {
1655
- export { time_max as max, time_now as now };
1656
- }
1657
-
2785
+ //#endregion
2786
+ //#region src/utils/wait.d.ts
1658
2787
  declare function wait(time: number): Promise<unknown>;
1659
-
1660
- type index_BaseError<cause extends Error | undefined = undefined> = BaseError<cause>;
1661
- declare const index_BaseError: typeof BaseError;
1662
- type index_GlobalErrorType<name extends string = "Error"> = GlobalErrorType<name>;
1663
- type index_Snake<T> = Snake<T>;
1664
- declare const index_batch: typeof batch;
1665
- declare const index_batchMulticall: typeof batchMulticall;
1666
- declare const index_lazy: typeof lazy;
1667
- declare const index_min: typeof min;
1668
- declare const index_poll: typeof poll;
1669
- declare const index_retry: typeof retry;
1670
- declare const index_wait: typeof wait;
1671
- declare namespace index {
1672
- export { index_BaseError as BaseError, type index_GlobalErrorType as GlobalErrorType, type index_Snake as Snake, time as Time, index_batch as batch, index_batchMulticall as batchMulticall, fromSnakeCase$3 as fromSnakeCase, index_lazy as lazy, max$1 as max, index_min as min, index_poll as poll, index_retry as retry, toSnakeCase$1 as toSnakeCase, index_wait as wait };
2788
+ declare namespace index_d_exports$2 {
2789
+ export { BaseError, GlobalErrorType, ReorgError, Snake, time_d_exports as Time, batch, batchMulticall, fromSnakeCase$3 as fromSnakeCase, lazy, max$1 as max, min, poll, retry, stringifyBigint, toSnakeCase$1 as toSnakeCase, wait };
1673
2790
  }
1674
-
1675
- export { Abi, type Brand, BrandTypeId, Callback, Chain$1 as Chain, Collateral$1 as Collateral, type Compute, Cursor$1 as Cursor, Errors, Format, LLTV$1 as LLTV, Liquidity, Maturity$1 as Maturity, MempoolClient as Mempool, Obligation$1 as Obligation, Offer$1 as Offer, Quote$1 as Quote, index$1 as RouterApi, Client$2 as RouterClient, time as Time, index as Utils, Validation, ValidationRule };
2791
+ //#endregion
2792
+ export { index_d_exports as Abi, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, Collateral_d_exports as Collateral, Compute, Cursor_d_exports as Cursor, ERC4626_d_exports as ERC4626, Errors_d_exports as Errors, Format_d_exports as Format, GateConfig_d_exports as GateConfig, Gatekeeper_d_exports as Gatekeeper, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Maturity_d_exports as Maturity, MempoolClient_d_exports as Mempool, Obligation_d_exports as Obligation, Offer_d_exports as Offer, Oracle_d_exports as Oracle, Position_d_exports as Position, Quote_d_exports as Quote, index_d_exports$1 as RouterApi, Client_d_exports as RouterClient, Rules_d_exports as Rules, time_d_exports as Time, Transfer_d_exports as Transfer, Tree_d_exports as Tree, index_d_exports$2 as Utils, Gate_d_exports as Validation, morphoRules };
2793
+ //# sourceMappingURL=index.browser.d.ts.map