@morpho-dev/router 0.2.0 → 0.3.0

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