@morpho-dev/router 0.1.18 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +29 -19
  2. package/dist/chunk-jass6xSI.mjs +13 -0
  3. package/dist/cli.js +6574 -6194
  4. package/dist/drizzle/migrations/0000_setup_single_migration_folder.sql +204 -0
  5. package/dist/drizzle/migrations/0001_add-trigger-for-consumed-events.sql +58 -0
  6. package/dist/drizzle/migrations/0002_insert-status-code.sql +1 -0
  7. package/dist/drizzle/migrations/0003_update-triggers-for-consumed-events.sql +3 -0
  8. package/dist/drizzle/migrations/0004_drop-status-offers-foreign-key-constraint.sql +1 -0
  9. package/dist/drizzle/migrations/0005_add-index-to-boost-group-query-and-offer-hash.sql +1 -0
  10. package/dist/drizzle/migrations/0006_add-callbacks-and-positions-relations.sql +37 -0
  11. package/dist/drizzle/migrations/0008_validation.sql +15 -0
  12. package/dist/drizzle/migrations/0009_add-transfers-table.sql +14 -0
  13. package/dist/drizzle/migrations/0010_add-price.sql +1 -0
  14. package/dist/drizzle/migrations/0011_nullable-callback-amount.sql +1 -0
  15. package/dist/drizzle/migrations/0012_add-position-asset.sql +1 -0
  16. package/dist/drizzle/migrations/0013_remove-depecrated-domains.sql +13 -0
  17. package/dist/drizzle/migrations/0014_rename-offers-v2-into-offers.sql +23 -0
  18. package/dist/drizzle/{router_v1.4 → migrations}/meta/0000_snapshot.json +858 -78
  19. package/dist/drizzle/migrations/meta/0001_snapshot.json +1752 -0
  20. package/dist/drizzle/migrations/meta/0002_snapshot.json +1752 -0
  21. package/dist/drizzle/migrations/meta/0003_snapshot.json +1752 -0
  22. package/dist/drizzle/{router_v1.4/meta/0001_snapshot.json → migrations/meta/0004_snapshot.json} +848 -78
  23. package/dist/drizzle/migrations/meta/0005_snapshot.json +1775 -0
  24. package/dist/drizzle/migrations/meta/0006_snapshot.json +1973 -0
  25. package/dist/drizzle/migrations/meta/0008_snapshot.json +1955 -0
  26. package/dist/drizzle/migrations/meta/0009_snapshot.json +2078 -0
  27. package/dist/drizzle/migrations/meta/0010_snapshot.json +2084 -0
  28. package/dist/drizzle/migrations/meta/0013_snapshot.json +1290 -0
  29. package/dist/drizzle/migrations/meta/0014_snapshot.json +1290 -0
  30. package/dist/drizzle/migrations/meta/_journal.json +104 -0
  31. package/dist/index.browser.d.mts +2794 -0
  32. package/dist/index.browser.d.mts.map +1 -0
  33. package/dist/index.browser.d.ts +2290 -1172
  34. package/dist/index.browser.d.ts.map +1 -0
  35. package/dist/index.browser.js +3820 -2519
  36. package/dist/index.browser.js.map +1 -1
  37. package/dist/index.browser.mjs +3615 -2467
  38. package/dist/index.browser.mjs.map +1 -1
  39. package/dist/index.node.d.mts +4987 -0
  40. package/dist/index.node.d.mts.map +1 -0
  41. package/dist/index.node.d.ts +4423 -2906
  42. package/dist/index.node.d.ts.map +1 -0
  43. package/dist/index.node.js +7810 -6141
  44. package/dist/index.node.js.map +1 -1
  45. package/dist/index.node.mjs +7556 -6102
  46. package/dist/index.node.mjs.map +1 -1
  47. package/package.json +29 -15
  48. package/dist/cli.js.map +0 -1
  49. package/dist/drizzle/router_v1.4/0000_add_obligation_id.sql +0 -112
  50. package/dist/drizzle/router_v1.4/0001_update-primary-key-on-link.sql +0 -3
  51. package/dist/drizzle/router_v1.4/meta/_journal.json +0 -20
  52. package/dist/index.browser.d.cts +0 -1675
  53. package/dist/index.node.d.cts +0 -3471
@@ -1,3471 +0,0 @@
1
- import { Hex, Address, AbiEvent, PublicClient, GetLogsReturnType, WalletClient, PublicActions } from 'viem';
2
- import { Chain as Chain$2 } from 'viem/chains';
3
- import { PGlite } from '@electric-sql/pglite';
4
- import { drizzle } from 'drizzle-orm/node-postgres';
5
- import { drizzle as drizzle$1 } from 'drizzle-orm/pglite';
6
- import { Pool } from 'pg';
7
- import * as z from 'zod';
8
- import { z as z$1 } from 'zod/v4';
9
- import * as node_modules_zod_openapi_dist_components_CXzxKPFp_js from 'node_modules/zod-openapi/dist/components-CXzxKPFp.js';
10
- import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
11
-
12
- declare const Oracle: readonly [{
13
- readonly type: "function";
14
- readonly name: "price";
15
- readonly inputs: readonly [];
16
- readonly outputs: readonly [{
17
- readonly name: "";
18
- readonly type: "uint256";
19
- }];
20
- readonly stateMutability: "view";
21
- }];
22
- declare const ERC4626: readonly [{
23
- readonly type: "function";
24
- readonly name: "asset";
25
- readonly inputs: readonly [];
26
- readonly outputs: readonly [{
27
- readonly name: "";
28
- readonly type: "address";
29
- }];
30
- readonly stateMutability: "view";
31
- }];
32
- declare const MetaMorphoFactory: readonly [{
33
- readonly type: "function";
34
- readonly name: "isMetaMorpho";
35
- readonly inputs: readonly [{
36
- readonly name: "target";
37
- readonly type: "address";
38
- }];
39
- readonly outputs: readonly [{
40
- readonly name: "";
41
- readonly type: "bool";
42
- }];
43
- readonly stateMutability: "view";
44
- }];
45
- declare const MetaMorpho: readonly [{
46
- readonly type: "function";
47
- readonly name: "withdrawQueue";
48
- readonly inputs: readonly [{
49
- readonly name: "index";
50
- readonly type: "uint256";
51
- }];
52
- readonly outputs: readonly [{
53
- readonly name: "";
54
- readonly type: "bytes32";
55
- }];
56
- readonly stateMutability: "view";
57
- }, {
58
- readonly type: "function";
59
- readonly name: "withdrawQueueLength";
60
- readonly inputs: readonly [];
61
- readonly outputs: readonly [{
62
- readonly name: "";
63
- readonly type: "uint256";
64
- }];
65
- readonly stateMutability: "view";
66
- }, {
67
- readonly type: "function";
68
- readonly name: "maxWithdraw";
69
- readonly inputs: readonly [{
70
- readonly name: "owner";
71
- readonly type: "address";
72
- }];
73
- readonly outputs: readonly [{
74
- readonly name: "";
75
- readonly type: "uint256";
76
- }];
77
- readonly stateMutability: "view";
78
- }];
79
- declare const Morpho: readonly [{
80
- readonly type: "function";
81
- readonly name: "collateralOf";
82
- readonly inputs: readonly [{
83
- readonly name: "";
84
- readonly type: "address";
85
- readonly internalType: "address";
86
- }, {
87
- readonly name: "";
88
- readonly type: "bytes32";
89
- readonly internalType: "bytes32";
90
- }, {
91
- readonly name: "";
92
- readonly type: "address";
93
- readonly internalType: "address";
94
- }];
95
- readonly outputs: readonly [{
96
- readonly name: "";
97
- readonly type: "uint256";
98
- readonly internalType: "uint256";
99
- }];
100
- readonly stateMutability: "view";
101
- }, {
102
- readonly type: "function";
103
- readonly name: "debtOf";
104
- readonly inputs: readonly [{
105
- readonly name: "";
106
- readonly type: "address";
107
- readonly internalType: "address";
108
- }, {
109
- readonly name: "";
110
- readonly type: "bytes32";
111
- readonly internalType: "bytes32";
112
- }];
113
- readonly outputs: readonly [{
114
- readonly name: "";
115
- readonly type: "uint256";
116
- readonly internalType: "uint256";
117
- }];
118
- readonly stateMutability: "view";
119
- }, {
120
- readonly type: "function";
121
- readonly name: "market";
122
- readonly inputs: readonly [{
123
- readonly name: "id";
124
- readonly type: "bytes32";
125
- readonly internalType: "Id";
126
- }];
127
- readonly outputs: readonly [{
128
- readonly name: "totalSupplyAssets";
129
- readonly type: "uint128";
130
- readonly internalType: "uint128";
131
- }, {
132
- readonly name: "totalSupplyShares";
133
- readonly type: "uint128";
134
- readonly internalType: "uint128";
135
- }, {
136
- readonly name: "totalBorrowAssets";
137
- readonly type: "uint128";
138
- readonly internalType: "uint128";
139
- }, {
140
- readonly name: "totalBorrowShares";
141
- readonly type: "uint128";
142
- readonly internalType: "uint128";
143
- }, {
144
- readonly name: "lastUpdate";
145
- readonly type: "uint128";
146
- readonly internalType: "uint128";
147
- }, {
148
- readonly name: "fee";
149
- readonly type: "uint128";
150
- readonly internalType: "uint128";
151
- }];
152
- readonly stateMutability: "view";
153
- }, {
154
- readonly type: "function";
155
- readonly name: "position";
156
- readonly inputs: readonly [{
157
- readonly name: "id";
158
- readonly type: "bytes32";
159
- readonly internalType: "Id";
160
- }, {
161
- readonly name: "user";
162
- readonly type: "address";
163
- readonly internalType: "address";
164
- }];
165
- readonly outputs: readonly [{
166
- readonly name: "supplyShares";
167
- readonly type: "uint256";
168
- readonly internalType: "uint256";
169
- }, {
170
- readonly name: "borrowShares";
171
- readonly type: "uint128";
172
- readonly internalType: "uint128";
173
- }, {
174
- readonly name: "collateral";
175
- readonly type: "uint128";
176
- readonly internalType: "uint128";
177
- }];
178
- readonly stateMutability: "view";
179
- }];
180
-
181
- declare const Abi_ERC4626: typeof ERC4626;
182
- declare const Abi_MetaMorpho: typeof MetaMorpho;
183
- declare const Abi_MetaMorphoFactory: typeof MetaMorphoFactory;
184
- declare const Abi_Morpho: typeof Morpho;
185
- declare const Abi_Oracle: typeof Oracle;
186
- declare namespace Abi {
187
- export { Abi_ERC4626 as ERC4626, Abi_MetaMorpho as MetaMorpho, Abi_MetaMorphoFactory as MetaMorphoFactory, Abi_Morpho as Morpho, Abi_Oracle as Oracle };
188
- }
189
-
190
- declare enum CallbackType {
191
- BuyWithEmptyCallback = "buy_with_empty_callback",
192
- BuyVaultV1Callback = "buy_vault_v1_callback",
193
- SellERC20Callback = "sell_erc20_callback"
194
- }
195
- declare const WhitelistedCallbackAddresses: Record<CallbackType, readonly string[]>;
196
- declare function decodeBuyVaultV1Callback(data: Hex): Array<{
197
- vault: Address;
198
- amount: bigint;
199
- }>;
200
- declare function decodeSellERC20Callback(data: Hex): Array<{
201
- collateral: Address;
202
- amount: bigint;
203
- }>;
204
- declare function encodeBuyVaultV1Callback(parameters: {
205
- vaults: Address[];
206
- amounts: bigint[];
207
- }): Hex;
208
- declare function encodeSellERC20Callback(parameters: {
209
- collaterals: Address[];
210
- amounts: bigint[];
211
- }): Hex;
212
-
213
- type Callback_CallbackType = CallbackType;
214
- declare const Callback_CallbackType: typeof CallbackType;
215
- declare const Callback_WhitelistedCallbackAddresses: typeof WhitelistedCallbackAddresses;
216
- declare const Callback_decodeBuyVaultV1Callback: typeof decodeBuyVaultV1Callback;
217
- declare const Callback_decodeSellERC20Callback: typeof decodeSellERC20Callback;
218
- declare const Callback_encodeBuyVaultV1Callback: typeof encodeBuyVaultV1Callback;
219
- declare const Callback_encodeSellERC20Callback: typeof encodeSellERC20Callback;
220
- declare namespace Callback {
221
- export { Callback_CallbackType as CallbackType, Callback_WhitelistedCallbackAddresses as WhitelistedCallbackAddresses, Callback_decodeBuyVaultV1Callback as decodeBuyVaultV1Callback, Callback_decodeSellERC20Callback as decodeSellERC20Callback, Callback_encodeBuyVaultV1Callback as encodeBuyVaultV1Callback, Callback_encodeSellERC20Callback as encodeSellERC20Callback };
222
- }
223
-
224
- type GlobalErrorType<name extends string = "Error"> = Error & {
225
- name: name;
226
- };
227
- /**
228
- * Base error class inherited by all errors thrown by mempool.
229
- *
230
- * @example
231
- * ```ts
232
- * import { Errors } from 'mempool'
233
- * throw new Errors.BaseError('An error occurred')
234
- * ```
235
- */
236
- declare class BaseError<cause extends Error | undefined = undefined> extends Error {
237
- details: string;
238
- shortMessage: string;
239
- cause: cause;
240
- name: string;
241
- constructor(shortMessage: string, options?: {
242
- cause?: cause | undefined;
243
- details?: string | undefined;
244
- metaMessages?: (string | undefined)[] | undefined;
245
- });
246
- walk(): Error;
247
- walk(fn: (err: unknown) => boolean): Error | null;
248
- }
249
-
250
- type Errors_BaseError<cause extends Error | undefined = undefined> = BaseError<cause>;
251
- declare const Errors_BaseError: typeof BaseError;
252
- type Errors_GlobalErrorType<name extends string = "Error"> = GlobalErrorType<name>;
253
- declare namespace Errors {
254
- export { Errors_BaseError as BaseError, type Errors_GlobalErrorType as GlobalErrorType };
255
- }
256
-
257
- /** Combines members of an intersection into a readable type. */
258
- type Compute<type> = {
259
- [key in keyof type]: type[key];
260
- } & unknown;
261
- declare const BrandTypeId: unique symbol;
262
- type Brand<in out ID extends string | symbol> = {
263
- readonly [BrandTypeId]: {
264
- readonly [id in ID]: ID;
265
- };
266
- };
267
-
268
- declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet", "anvil"];
269
- type ChainName = (typeof chainNames)[number];
270
- declare const ChainId: {
271
- ETHEREUM: bigint;
272
- BASE: bigint;
273
- "ETHEREUM-VIRTUAL-TESTNET": bigint;
274
- ANVIL: bigint;
275
- };
276
- type Id = (typeof ChainId)[keyof typeof ChainId];
277
- declare const chainIds: Set<bigint>;
278
- type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
279
- id: Id;
280
- name: ChainName;
281
- whitelistedAssets: Set<Address>;
282
- morpho: Address;
283
- morphoBlue: Address;
284
- mempool: {
285
- address: Address;
286
- deploymentBlock: number;
287
- reindexBuffer: number;
288
- };
289
- vaultV1Factory: Record<string, Address>;
290
- }>;
291
- declare function getChain(chainId: Id): Chain | undefined;
292
- declare const getWhitelistedChains: () => Chain[];
293
- declare const chains$1: Record<ChainName, Chain>;
294
- declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(parameters: {
295
- client: PublicClient;
296
- contractAddress: Address;
297
- event?: abiEvent;
298
- blockNumberGte?: number;
299
- blockNumberLte?: number;
300
- order: "asc" | "desc";
301
- options: {
302
- maxBatchSize?: number;
303
- blockWindow?: number;
304
- };
305
- }): AsyncGenerator<{
306
- logs: GetLogsReturnType<abiEvent | undefined>;
307
- blockNumber: number;
308
- }, void, void>;
309
- declare class InvalidBlockRangeError extends BaseError {
310
- name: string;
311
- constructor(fromBlock: bigint, toBlock: bigint);
312
- }
313
- declare class InvalidBlockWindowError extends BaseError {
314
- name: string;
315
- constructor(blockWindow: number);
316
- }
317
- declare class InvalidBatchSizeError extends BaseError {
318
- name: string;
319
- constructor(maxBatchSize: number);
320
- }
321
- declare class MissingBlockNumberError extends BaseError {
322
- name: string;
323
- constructor();
324
- }
325
-
326
- type Chain$1_Chain = Chain;
327
- declare const Chain$1_ChainId: typeof ChainId;
328
- type Chain$1_ChainName = ChainName;
329
- type Chain$1_Id = Id;
330
- type Chain$1_InvalidBatchSizeError = InvalidBatchSizeError;
331
- declare const Chain$1_InvalidBatchSizeError: typeof InvalidBatchSizeError;
332
- type Chain$1_InvalidBlockRangeError = InvalidBlockRangeError;
333
- declare const Chain$1_InvalidBlockRangeError: typeof InvalidBlockRangeError;
334
- type Chain$1_InvalidBlockWindowError = InvalidBlockWindowError;
335
- declare const Chain$1_InvalidBlockWindowError: typeof InvalidBlockWindowError;
336
- type Chain$1_MissingBlockNumberError = MissingBlockNumberError;
337
- declare const Chain$1_MissingBlockNumberError: typeof MissingBlockNumberError;
338
- declare const Chain$1_chainIds: typeof chainIds;
339
- declare const Chain$1_chainNames: typeof chainNames;
340
- declare const Chain$1_getChain: typeof getChain;
341
- declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
342
- declare const Chain$1_streamLogs: typeof streamLogs;
343
- declare namespace Chain$1 {
344
- 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, chains$1 as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains, Chain$1_streamLogs as streamLogs };
345
- }
346
-
347
- type LLTV = bigint & Brand<"LLTV">;
348
- declare const Options: readonly [0.385, 0.5, 0.625, 0.77, 0.86, 0.915, 0.945, 0.965, 0.98];
349
- type Options = (typeof Options)[number];
350
- /**
351
- * Convert a LLTV option or a scaled LLTV to a LLTV.
352
- * @param lltv - The LLTV option or the scaled LLTV.
353
- * @returns The LLTV.
354
- */
355
- declare function from$9(lltv: Options | bigint): LLTV;
356
- declare namespace from$9 {
357
- type ErrorType = InvalidOptionError$1 | InvalidLLTVError;
358
- }
359
- declare class InvalidOptionError$1 extends BaseError {
360
- readonly name = "LLTV.InvalidOptionError";
361
- constructor(input: number);
362
- }
363
- declare class InvalidLLTVError extends BaseError {
364
- readonly name = "LLTV.InvalidLLTVError";
365
- constructor(input: bigint);
366
- }
367
- declare const LLTVSchema: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
368
-
369
- type LLTV$1_InvalidLLTVError = InvalidLLTVError;
370
- declare const LLTV$1_InvalidLLTVError: typeof InvalidLLTVError;
371
- type LLTV$1_LLTV = LLTV;
372
- declare const LLTV$1_LLTVSchema: typeof LLTVSchema;
373
- type LLTV$1_Options = Options;
374
- declare namespace LLTV$1 {
375
- 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 };
376
- }
377
-
378
- type Collateral = {
379
- /** Asset being used as collateral. */
380
- asset: Address;
381
- /** Liquidation Loan-to-Value of the collateral. */
382
- lltv: LLTV;
383
- /** Oracle contract used to price the collateral. */
384
- oracle: Address;
385
- };
386
- declare const CollateralSchema: z.ZodObject<{
387
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
388
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
389
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
390
- }, z.core.$strip>;
391
- declare const CollateralsSchema: z.ZodArray<z.ZodObject<{
392
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
393
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
394
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
395
- }, z.core.$strip>>;
396
- declare const from$8: (parameters: from$8.Parameters) => from$8.ReturnType;
397
- declare namespace from$8 {
398
- type Parameters = {
399
- asset: Address;
400
- lltv: Options | bigint;
401
- oracle: Address;
402
- };
403
- type ReturnType = Collateral;
404
- }
405
-
406
- type Collateral$1_Collateral = Collateral;
407
- declare const Collateral$1_CollateralSchema: typeof CollateralSchema;
408
- declare const Collateral$1_CollateralsSchema: typeof CollateralsSchema;
409
- declare namespace Collateral$1 {
410
- export { type Collateral$1_Collateral as Collateral, Collateral$1_CollateralSchema as CollateralSchema, Collateral$1_CollateralsSchema as CollateralsSchema, from$8 as from };
411
- }
412
-
413
- /** The snake case representation of a type with bigint values stringified. */
414
- type Snake<T> = SnakeKeys<StringifiedBigint<T>>;
415
- /** Stringifies bigint values to strings and preserves branded primitives. */
416
- type StringifiedBigint<T> = [
417
- T
418
- ] extends [bigint] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? {
419
- [K in keyof T]: StringifiedBigint<T[K]>;
420
- } : T;
421
- /** Key remapping that also preserves branded primitives. */
422
- type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? {
423
- [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]>;
424
- } : T;
425
- 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;
426
- /**
427
- * Formats object keys to snake case.
428
- * Preserves ethereum addresses as is.
429
- * Converts ethereum addresses to checksummed if used as values.
430
- * Stringifies bigint values to strings.
431
- */
432
- declare function toSnakeCase$1<T>(obj: T): Snake<T>;
433
- /**
434
- * Formats a snake case object to its camel case type.
435
- * Preserves ethereum addresses as is.
436
- * Converts checksummed ethereum addresses to lowercase if used as values.
437
- * @warning Does not unstringify bigint values.
438
- */
439
- declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
440
-
441
- type Format_Snake<T> = Snake<T>;
442
- declare namespace Format {
443
- export { type Format_Snake as Snake, fromSnakeCase$3 as fromSnakeCase, toSnakeCase$1 as toSnakeCase };
444
- }
445
-
446
- /**
447
- * Maturity is a number that represents a date in seconds.
448
- */
449
- type Maturity = number & Brand<"Maturity">;
450
- declare const MaturitySchema: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
451
- declare const MaturityOptions: {
452
- readonly end_of_week: () => Maturity;
453
- readonly end_of_next_week: () => Maturity;
454
- readonly end_of_month: () => Maturity;
455
- readonly end_of_next_month: () => Maturity;
456
- readonly end_of_quarter: () => Maturity;
457
- readonly end_of_next_quarter: () => Maturity;
458
- };
459
- type MaturityOptions = keyof typeof MaturityOptions;
460
- /**
461
- * Creates a maturity from a timestamp in seconds or a maturity option.
462
- * @throws {InvalidFormatError} If the maturity is in milliseconds.
463
- * @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
464
- * @throws {InvalidOptionError} If the maturity is not a valid option.
465
- */
466
- declare function from$7(ts: from$7.Parameters): Maturity;
467
- declare namespace from$7 {
468
- type Parameters = number | MaturityOptions;
469
- type ErrorType = InvalidFormatError | InvalidDateError | InvalidOptionError;
470
- }
471
- declare class InvalidFormatError extends BaseError {
472
- readonly name = "Maturity.InvalidFormatError";
473
- constructor();
474
- }
475
- declare class InvalidDateError extends BaseError {
476
- readonly name = "Maturity.InvalidDateError";
477
- constructor(input: number);
478
- }
479
- declare class InvalidOptionError extends BaseError {
480
- readonly name = "Maturity.InvalidOptionError";
481
- constructor(input: string);
482
- }
483
-
484
- type Maturity$1_InvalidDateError = InvalidDateError;
485
- declare const Maturity$1_InvalidDateError: typeof InvalidDateError;
486
- type Maturity$1_InvalidFormatError = InvalidFormatError;
487
- declare const Maturity$1_InvalidFormatError: typeof InvalidFormatError;
488
- type Maturity$1_InvalidOptionError = InvalidOptionError;
489
- declare const Maturity$1_InvalidOptionError: typeof InvalidOptionError;
490
- type Maturity$1_Maturity = Maturity;
491
- type Maturity$1_MaturityOptions = MaturityOptions;
492
- declare const Maturity$1_MaturitySchema: typeof MaturitySchema;
493
- declare namespace Maturity$1 {
494
- export { Maturity$1_InvalidDateError as InvalidDateError, Maturity$1_InvalidFormatError as InvalidFormatError, Maturity$1_InvalidOptionError as InvalidOptionError, type Maturity$1_Maturity as Maturity, type Maturity$1_MaturityOptions as MaturityOptions, Maturity$1_MaturitySchema as MaturitySchema, from$7 as from };
495
- }
496
-
497
- type Offer = {
498
- /** The address that made the offer. */
499
- readonly offering: Address;
500
- /** The amount of assets offered. */
501
- readonly assets: bigint;
502
- /** The interest rate (with 18 decimals). */
503
- readonly rate: bigint;
504
- /** The date at which all interests will be paid. */
505
- readonly maturity: Maturity;
506
- /** The date at which the offer will expire. */
507
- readonly expiry: number;
508
- /** The date at which the offer will start. */
509
- readonly start: number;
510
- /** The nonce. Used for OCO (One-Cancelled-Other) mechanism. */
511
- readonly nonce: bigint;
512
- /** The side of the offer. `true` for buy, `false` for sell. */
513
- readonly buy: boolean;
514
- /** The chain id where the liquidity for this offer is located. */
515
- readonly chainId: bigint;
516
- /** The token that is being borrowed. */
517
- readonly loanToken: Address;
518
- /** The exact set of collaterals required to borrow the loan token. */
519
- readonly collaterals: readonly Collateral[];
520
- /** The optional callback data to retrieve the maker funds. */
521
- readonly callback: {
522
- readonly address: Address;
523
- readonly data: Hex;
524
- readonly gasLimit: bigint;
525
- };
526
- /** The amount of assets consumed from the offer. */
527
- consumed: bigint;
528
- /** The hash of the offer. */
529
- readonly hash: Hex;
530
- /** The block number at which the offer was created. */
531
- readonly blockNumber: number;
532
- /** The signature of the offer. */
533
- signature?: Hex;
534
- };
535
- declare const OfferHashSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
536
- declare const OfferSchema: (parameters?: {
537
- omitHash?: boolean;
538
- }) => z.ZodObject<{
539
- offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
540
- assets: z.ZodBigInt;
541
- rate: z.ZodBigInt;
542
- maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
543
- expiry: z.ZodNumber;
544
- start: z.ZodNumber;
545
- nonce: z.ZodBigInt;
546
- buy: z.ZodBoolean;
547
- chainId: z.ZodBigInt;
548
- loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
549
- collaterals: z.ZodArray<z.ZodObject<{
550
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
551
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
552
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
553
- }, z.core.$strip>>;
554
- callback: z.ZodObject<{
555
- address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
556
- data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
557
- gasLimit: z.ZodBigInt;
558
- }, z.core.$strip>;
559
- consumed: z.ZodBigInt;
560
- blockNumber: z.ZodNumber;
561
- signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
562
- }, z.core.$strip>;
563
- /**
564
- * Creates an offer from a plain object.
565
- * @throws {InvalidOfferError} If the offer is invalid.
566
- * @param input - The offer to create.
567
- * @returns The created offer with its hash.
568
- */
569
- declare function from$6(input: Omit<Offer, "hash">): Offer;
570
- declare namespace from$6 {
571
- type ErrorType = InvalidOfferError;
572
- }
573
- /**
574
- * Creates an offer from a snake case object.
575
- * @throws {InvalidOfferError} If the offer is invalid.
576
- * @param input - The offer to create.
577
- * @returns The created offer with its hash.
578
- */
579
- declare function fromSnakeCase$2(input: Snake<Omit<Offer, "hash">>): Offer;
580
- /**
581
- * Converts an offer to a snake case object.
582
- * @param offer - The offer to convert.
583
- * @returns The converted offer.
584
- */
585
- declare function toSnakeCase(offer: Offer): Snake<Offer>;
586
- type RandomConfig = {
587
- chains?: Chain[];
588
- loanTokens?: Address[];
589
- collateralTokens?: Address[];
590
- assetsDecimals?: Record<Address, number>;
591
- buy?: boolean;
592
- assets?: bigint;
593
- consumed?: bigint;
594
- offering?: Address;
595
- maturity?: Maturity;
596
- start?: number;
597
- expiry?: number;
598
- nonce?: bigint;
599
- rate?: bigint;
600
- callback?: {
601
- address: Address;
602
- data: Hex;
603
- gasLimit: bigint;
604
- };
605
- collaterals?: readonly Collateral[];
606
- signature?: Hex;
607
- };
608
- /**
609
- * Generates a random Offer.
610
- * The returned Offer contains randomly generated values.
611
- * @warning The generated Offer should not be used for production usage.
612
- * @returns {Offer} A randomly generated Offer object.
613
- */
614
- declare function random$2(config?: RandomConfig): Offer;
615
- /**
616
- * Creates an EIP-712 domain object.
617
- * @param chainId - The chain ID.
618
- * @returns The EIP-712 domain object.
619
- */
620
- declare const domain: (chainId: bigint) => {
621
- chainId: bigint;
622
- verifyingContract: "0x0000000000000000000000000000000000000000";
623
- };
624
- /**
625
- * The EIP-712 types for the offer.
626
- * @warning The ordering of the types should NEVER be changed. The offer hash is computed based on the order of the types.
627
- * @returns The EIP-712 types.
628
- */
629
- declare const types: {
630
- readonly EIP712Domain: readonly [{
631
- readonly name: "chainId";
632
- readonly type: "uint256";
633
- }, {
634
- readonly name: "verifyingContract";
635
- readonly type: "address";
636
- }];
637
- readonly Offer: readonly [{
638
- readonly name: "offering";
639
- readonly type: "address";
640
- }, {
641
- readonly name: "assets";
642
- readonly type: "uint256";
643
- }, {
644
- readonly name: "rate";
645
- readonly type: "uint256";
646
- }, {
647
- readonly name: "maturity";
648
- readonly type: "uint256";
649
- }, {
650
- readonly name: "expiry";
651
- readonly type: "uint256";
652
- }, {
653
- readonly name: "nonce";
654
- readonly type: "uint256";
655
- }, {
656
- readonly name: "buy";
657
- readonly type: "bool";
658
- }, {
659
- readonly name: "loanToken";
660
- readonly type: "address";
661
- }, {
662
- readonly name: "collaterals";
663
- readonly type: "Collateral[]";
664
- }, {
665
- readonly name: "callback";
666
- readonly type: "Callback";
667
- }];
668
- readonly Collateral: readonly [{
669
- readonly name: "asset";
670
- readonly type: "address";
671
- }, {
672
- readonly name: "oracle";
673
- readonly type: "address";
674
- }, {
675
- readonly name: "lltv";
676
- readonly type: "uint256";
677
- }];
678
- readonly Callback: readonly [{
679
- readonly name: "address";
680
- readonly type: "address";
681
- }, {
682
- readonly name: "data";
683
- readonly type: "bytes";
684
- }, {
685
- readonly name: "gasLimit";
686
- readonly type: "uint256";
687
- }];
688
- };
689
- /**
690
- * Signs an offer.
691
- * @throws {Error} If the wallet account is not set.
692
- * @param offer - The offer to sign.
693
- * @param wallet - The wallet to sign the offer with.
694
- * @returns The signed offer.
695
- */
696
- declare function sign(offer: Offer, wallet: WalletClient): Promise<Hex>;
697
- declare function hash(offer: Omit<Offer, "hash">): Hex;
698
- /**
699
- * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
700
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals (sorted by token address), maturity)).
701
- * @param offer - The offer to calculate the obligation id for.
702
- * @returns The obligation id as a 32-byte hex string.
703
- */
704
- declare function obligationId(offer: Offer): Hex;
705
- declare function encode$1(offer: Offer): `0x${string}`;
706
- declare function decode$1(data: Hex, blockNumber: number | bigint): Offer;
707
- type OfferConsumed = {
708
- id: string;
709
- chainId: bigint;
710
- offering: Address;
711
- nonce: bigint;
712
- amount: bigint;
713
- blockNumber: number;
714
- };
715
- /**
716
- * ABI for the Consumed event emitted by the Obligation contract.
717
- */
718
- declare const consumedEvent: {
719
- readonly type: "event";
720
- readonly name: "Consumed";
721
- readonly inputs: readonly [{
722
- readonly name: "user";
723
- readonly type: "address";
724
- readonly indexed: true;
725
- readonly internalType: "address";
726
- }, {
727
- readonly name: "nonce";
728
- readonly type: "uint256";
729
- readonly indexed: true;
730
- readonly internalType: "uint256";
731
- }, {
732
- readonly name: "amount";
733
- readonly type: "uint256";
734
- readonly indexed: false;
735
- readonly internalType: "uint256";
736
- }];
737
- readonly anonymous: false;
738
- };
739
- declare function fromConsumedLog(parameters: {
740
- blockNumber: bigint;
741
- logIndex: number;
742
- chainId: number;
743
- transactionHash: Hex;
744
- user: Address;
745
- nonce: bigint;
746
- amount: bigint;
747
- }): OfferConsumed;
748
- declare class InvalidOfferError extends BaseError<z.ZodError | Error> {
749
- readonly name = "Offer.InvalidOfferError";
750
- constructor(error: z.ZodError | Error);
751
- }
752
- declare class AccountNotSetError extends BaseError {
753
- readonly name = "Offer.AccountNotSetError";
754
- constructor();
755
- }
756
-
757
- type Offer$1_AccountNotSetError = AccountNotSetError;
758
- declare const Offer$1_AccountNotSetError: typeof AccountNotSetError;
759
- type Offer$1_InvalidOfferError = InvalidOfferError;
760
- declare const Offer$1_InvalidOfferError: typeof InvalidOfferError;
761
- type Offer$1_Offer = Offer;
762
- type Offer$1_OfferConsumed = OfferConsumed;
763
- declare const Offer$1_OfferHashSchema: typeof OfferHashSchema;
764
- declare const Offer$1_OfferSchema: typeof OfferSchema;
765
- type Offer$1_RandomConfig = RandomConfig;
766
- declare const Offer$1_consumedEvent: typeof consumedEvent;
767
- declare const Offer$1_domain: typeof domain;
768
- declare const Offer$1_fromConsumedLog: typeof fromConsumedLog;
769
- declare const Offer$1_hash: typeof hash;
770
- declare const Offer$1_obligationId: typeof obligationId;
771
- declare const Offer$1_sign: typeof sign;
772
- declare const Offer$1_toSnakeCase: typeof toSnakeCase;
773
- declare const Offer$1_types: typeof types;
774
- declare namespace Offer$1 {
775
- export { Offer$1_AccountNotSetError as AccountNotSetError, Offer$1_InvalidOfferError as InvalidOfferError, type Offer$1_Offer as Offer, type Offer$1_OfferConsumed as OfferConsumed, Offer$1_OfferHashSchema as OfferHashSchema, Offer$1_OfferSchema as OfferSchema, type Offer$1_RandomConfig as RandomConfig, Offer$1_consumedEvent as consumedEvent, decode$1 as decode, Offer$1_domain as domain, encode$1 as encode, from$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_toSnakeCase as toSnakeCase, Offer$1_types as types };
776
- }
777
-
778
- /**
779
- * Represents a liquidity pool with a unique ID and amount.
780
- */
781
- type LiquidityPool = {
782
- id: string;
783
- amount: bigint;
784
- };
785
- /**
786
- * Represents a hierarchical relationship between two liquidity pools.
787
- */
788
- type LiquidityLink = {
789
- parentPoolId: string;
790
- childPoolId: string;
791
- priority: number;
792
- };
793
- /**
794
- * Represents the connection between an offer and its liquidity pools.
795
- */
796
- type OfferLiquidityPool = {
797
- offerHash: Offer["hash"];
798
- poolId: string;
799
- /**
800
- * The available capacity/liquidity from this pool for this offer.
801
- * Meaning varies by pool type:
802
- * - BuyWithEmptyCallback: Matches allowance amount from pool bellow
803
- * - SellERC20Callback: Sell Callback/Predeposited -> Maximum debt capacity calculated from collateral (collateralAmount * oraclePrice * lltv)
804
- * - SellERC20Callback: Existing debt as negative value (reduces available capacity)
805
- */
806
- amount: bigint;
807
- };
808
- /**
809
- * Calculate maximum debt capacity from collateral amount.
810
- * @param amount - Collateral amount
811
- * @param oraclePrice - Oracle price (scaled to 36 decimals)
812
- * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
813
- * @returns Maximum debt capacity
814
- */
815
- declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
816
- /**
817
- * Generate pool ID for balance pools.
818
- */
819
- declare function generateBalancePoolId(parameters: {
820
- user: Address;
821
- chainId: bigint;
822
- token: Address;
823
- }): string;
824
- /**
825
- * Generate pool ID for allowance pools.
826
- */
827
- declare function generateAllowancePoolId(parameters: {
828
- user: Address;
829
- chainId: bigint;
830
- token: Address;
831
- }): string;
832
- /**
833
- * Generate pool ID for sell ERC20 callback pools.
834
- * Each offer has its own callback pool to prevent liquidity conflicts.
835
- */
836
- declare function generateSellERC20CallbackPoolId(parameters: {
837
- user: Address;
838
- chainId: bigint;
839
- obligationId: Hex;
840
- token: Address;
841
- offerHash: Hex;
842
- }): string;
843
- /**
844
- * Generate pool ID for obligation collateral pools.
845
- * Obligation collateral pools represent collateral already deposited in the obligation.
846
- * These pools are shared across all offers with the same obligation.
847
- */
848
- declare function generateObligationCollateralPoolId(parameters: {
849
- user: Address;
850
- chainId: bigint;
851
- obligationId: Hex;
852
- token: Address;
853
- }): string;
854
- /**
855
- * Generate pool ID for buy vault callback pools.
856
- */
857
- declare function generateBuyVaultCallbackPoolId(parameters: {
858
- user: Address;
859
- chainId: bigint;
860
- vault: Address;
861
- offerHash: Hex;
862
- }): string;
863
- /**
864
- * Generate pool ID for debt pools.
865
- */
866
- declare function generateDebtPoolId(parameters: {
867
- user: Address;
868
- chainId: bigint;
869
- obligationId: Hex;
870
- }): string;
871
- /**
872
- * Generate pool ID for user position in a vault.
873
- */
874
- declare function generateUserVaultPositionPoolId(parameters: {
875
- user: Address;
876
- chainId: bigint;
877
- vault: Address;
878
- }): string;
879
- /**
880
- * Generate pool ID for vault position in a market.
881
- */
882
- declare function generateVaultPositionPoolId(parameters: {
883
- vault: Address;
884
- chainId: bigint;
885
- marketId: string;
886
- }): string;
887
- /**
888
- * Generate pool ID for market total liquidity.
889
- */
890
- declare function generateMarketLiquidityPoolId(parameters: {
891
- chainId: bigint;
892
- marketId: string;
893
- }): string;
894
-
895
- type Liquidity_LiquidityLink = LiquidityLink;
896
- type Liquidity_LiquidityPool = LiquidityPool;
897
- type Liquidity_OfferLiquidityPool = OfferLiquidityPool;
898
- declare const Liquidity_calculateMaxDebt: typeof calculateMaxDebt;
899
- declare const Liquidity_generateAllowancePoolId: typeof generateAllowancePoolId;
900
- declare const Liquidity_generateBalancePoolId: typeof generateBalancePoolId;
901
- declare const Liquidity_generateBuyVaultCallbackPoolId: typeof generateBuyVaultCallbackPoolId;
902
- declare const Liquidity_generateDebtPoolId: typeof generateDebtPoolId;
903
- declare const Liquidity_generateMarketLiquidityPoolId: typeof generateMarketLiquidityPoolId;
904
- declare const Liquidity_generateObligationCollateralPoolId: typeof generateObligationCollateralPoolId;
905
- declare const Liquidity_generateSellERC20CallbackPoolId: typeof generateSellERC20CallbackPoolId;
906
- declare const Liquidity_generateUserVaultPositionPoolId: typeof generateUserVaultPositionPoolId;
907
- declare const Liquidity_generateVaultPositionPoolId: typeof generateVaultPositionPoolId;
908
- declare namespace Liquidity {
909
- 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 };
910
- }
911
-
912
- type Obligation = {
913
- /** The chain id where the liquidity for this obligation is located. */
914
- chainId: Id;
915
- /** The token that is being borrowed for this obligation. */
916
- loanToken: Address;
917
- /** The exact set of collaterals required to borrow the loan token. */
918
- collaterals: Collateral[];
919
- /** The maturity of the obligation. */
920
- maturity: Maturity;
921
- };
922
- declare const ObligationSchema: z.ZodObject<{
923
- chainId: z.ZodBigInt;
924
- loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
925
- collaterals: z.ZodArray<z.ZodObject<{
926
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
927
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
928
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
929
- }, z.core.$strip>>;
930
- maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
931
- }, z.core.$strip>;
932
- /**
933
- * Creates an obligation from the given parameters.
934
- * @constructor
935
- * @param parameters - {@link from.Parameters}
936
- * @returns The created obligation. {@link Obligation}
937
- * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
938
- *
939
- * @example
940
- * ```ts
941
- * const obligation = Obligation.from({
942
- * chainId: 1n,
943
- * loanToken: privateKeyToAccount(generatePrivateKey()).address,
944
- * collaterals: [
945
- * Collateral.from({
946
- * asset: privateKeyToAccount(generatePrivateKey()).address,
947
- * oracle: privateKeyToAccount(generatePrivateKey()).address,
948
- * lltv: 0.965
949
- * }),
950
- * ],
951
- * maturity: Maturity.from("end_of_next_quarter"),
952
- * });
953
- * ```
954
- */
955
- declare function from$5(parameters: from$5.Parameters): from$5.ReturnType;
956
- declare namespace from$5 {
957
- type Parameters = {
958
- /** The chain id where the liquidity for this obligation is located. */
959
- chainId: Id;
960
- /** The token that is being borrowed for this obligation. */
961
- loanToken: Address;
962
- /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
963
- collaterals: from$8.Parameters[] | readonly from$8.Parameters[];
964
- /** The maturity of the obligation. */
965
- maturity: from$7.Parameters;
966
- };
967
- type ReturnType = Obligation;
968
- type ErrorType = InvalidObligationError;
969
- }
970
- /**
971
- * Creates an obligation from a snake case object.
972
- * @throws If the obligation is invalid. {@link fromSnakeCase.ErrorType}
973
- * @param input - {@link fromSnakeCase.Parameters}
974
- * @returns The created obligation. {@link fromSnakeCase.ReturnType}
975
- */
976
- declare function fromSnakeCase$1(input: fromSnakeCase$1.Parameters): fromSnakeCase$1.ReturnType;
977
- declare namespace fromSnakeCase$1 {
978
- type Parameters = Snake<Obligation>;
979
- type ReturnType = Obligation;
980
- type ErrorType = InvalidObligationError;
981
- }
982
- /**
983
- * Calculates the obligation id based on the smart contract's Obligation struct.
984
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals, maturity)).
985
- * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
986
- * @param obligation - {@link id.Parameters}
987
- * @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
988
- *
989
- * @example
990
- * ```ts
991
- * const obligation = Obligation.random();
992
- * const id = Obligation.id(obligation);
993
- * console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
994
- * ```
995
- */
996
- declare function id(obligation: id.Parameters): id.ReturnType;
997
- declare namespace id {
998
- type Parameters = Obligation;
999
- type ReturnType = Hex;
1000
- type ErrorType = CollateralsAreNotSortedError;
1001
- }
1002
- /**
1003
- * Generates a random obligation.
1004
- * @returns A randomly generated obligation. {@link random.ReturnType}
1005
- *
1006
- * @example
1007
- * ```ts
1008
- * const obligation = Obligation.random();
1009
- * ```
1010
- */
1011
- declare function random$1(): random$1.ReturnType;
1012
- declare namespace random$1 {
1013
- type ReturnType = Obligation;
1014
- }
1015
- declare class InvalidObligationError extends BaseError<z.ZodError | Error> {
1016
- readonly name = "Obligation.InvalidObligationError";
1017
- constructor(error: z.ZodError | Error);
1018
- }
1019
- declare class CollateralsAreNotSortedError extends BaseError {
1020
- readonly name = "Obligation.CollateralsAreNotSortedError";
1021
- constructor();
1022
- }
1023
-
1024
- type Obligation$1_CollateralsAreNotSortedError = CollateralsAreNotSortedError;
1025
- declare const Obligation$1_CollateralsAreNotSortedError: typeof CollateralsAreNotSortedError;
1026
- type Obligation$1_InvalidObligationError = InvalidObligationError;
1027
- declare const Obligation$1_InvalidObligationError: typeof InvalidObligationError;
1028
- type Obligation$1_Obligation = Obligation;
1029
- declare const Obligation$1_ObligationSchema: typeof ObligationSchema;
1030
- declare const Obligation$1_id: typeof id;
1031
- declare namespace Obligation$1 {
1032
- 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 };
1033
- }
1034
-
1035
- type Quote = {
1036
- /** The obligation id. */
1037
- obligationId: Hex;
1038
- ask: {
1039
- /** The highest interest rate the seller will accept to pay for the obligation. (18 decimals). */
1040
- rate: bigint;
1041
- };
1042
- bid: {
1043
- /** The lowest interest rate a buyer is willing to be paid for the obligation. (18 decimals). */
1044
- rate: bigint;
1045
- };
1046
- };
1047
- declare const QuoteSchema: z.ZodObject<{
1048
- obligationId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
1049
- ask: z.ZodObject<{
1050
- rate: z.ZodBigInt;
1051
- }, z.core.$strip>;
1052
- bid: z.ZodObject<{
1053
- rate: z.ZodBigInt;
1054
- }, z.core.$strip>;
1055
- }, z.core.$strip>;
1056
- /**
1057
- * Creates a quote for a given obligation.
1058
- * @constructor
1059
- * @param parameters - {@link from.Parameters}
1060
- * @returns The created quote. {@link Quote}
1061
- * @throws If the quote is invalid. {@link InvalidQuoteError}
1062
- *
1063
- * @example
1064
- * ```ts
1065
- * const quote = Quote.from({ obligationId: "0x123", ask: { assets: 100n, rate: 100n }, bid: { assets: 100n, rate: 100n } });
1066
- * ```
1067
- */
1068
- declare function from$4(parameters: from$4.Parameters): from$4.ReturnType;
1069
- declare namespace from$4 {
1070
- type Parameters = Quote;
1071
- type ReturnType = Quote;
1072
- type ErrorType = InvalidQuoteError;
1073
- }
1074
- /**
1075
- * Creates a quote from a snake case object.
1076
- * @throws If the quote is invalid. {@link InvalidQuoteError}
1077
- * @param snake - {@link fromSnakeCase.Parameters}
1078
- * @returns The created quote. {@link fromSnakeCase.ReturnType}
1079
- */
1080
- declare function fromSnakeCase(snake: fromSnakeCase.Parameters): fromSnakeCase.ReturnType;
1081
- declare namespace fromSnakeCase {
1082
- type Parameters = Snake<Quote>;
1083
- type ReturnType = Quote;
1084
- type ErrorType = from$4.ErrorType;
1085
- }
1086
- /**
1087
- * Generates a random quote.
1088
- * @returns A randomly generated quote. {@link random.ReturnType}
1089
- *
1090
- * @example
1091
- * ```ts
1092
- * const quote = Quote.random();
1093
- * ```
1094
- */
1095
- declare function random(): random.ReturnType;
1096
- declare namespace random {
1097
- type Parameters = never;
1098
- type ReturnType = Quote;
1099
- type ErrorType = from$4.ErrorType;
1100
- }
1101
- declare class InvalidQuoteError extends BaseError<z.ZodError | Error> {
1102
- readonly name = "Quote.InvalidQuoteError";
1103
- constructor(error: z.ZodError | Error);
1104
- }
1105
-
1106
- type Quote$1_InvalidQuoteError = InvalidQuoteError;
1107
- declare const Quote$1_InvalidQuoteError: typeof InvalidQuoteError;
1108
- type Quote$1_Quote = Quote;
1109
- declare const Quote$1_QuoteSchema: typeof QuoteSchema;
1110
- declare const Quote$1_fromSnakeCase: typeof fromSnakeCase;
1111
- declare const Quote$1_random: typeof random;
1112
- declare namespace Quote$1 {
1113
- 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 };
1114
- }
1115
-
1116
- type Indexer = {
1117
- start: () => () => void;
1118
- };
1119
- declare function create$7(params: {
1120
- collectors: Collector[];
1121
- }): Indexer;
1122
-
1123
- type RouterIndexer_Indexer = Indexer;
1124
- declare namespace RouterIndexer {
1125
- export { type RouterIndexer_Indexer as Indexer, create$7 as create };
1126
- }
1127
-
1128
- type PgDB = ReturnType<typeof drizzle> & {
1129
- name: "pg";
1130
- pool: Pool;
1131
- };
1132
- type PGLiteDB = ReturnType<typeof drizzle$1> & {
1133
- name: "pglite";
1134
- pool: PGlite;
1135
- };
1136
- type PG = PgDB | PGLiteDB;
1137
- declare function connect$2(parameters: {
1138
- type: "pg";
1139
- endpoint: string;
1140
- } | {
1141
- type: "pglite";
1142
- }): PG;
1143
- declare function applyMigrations(pg: PG): Promise<void>;
1144
- declare function clean(pg: PG): Promise<void>;
1145
-
1146
- type PG$1_PG = PG;
1147
- type PG$1_PGLiteDB = PGLiteDB;
1148
- type PG$1_PgDB = PgDB;
1149
- declare const PG$1_applyMigrations: typeof applyMigrations;
1150
- declare const PG$1_clean: typeof clean;
1151
- declare namespace PG$1 {
1152
- export { type PG$1_PG as PG, type PG$1_PGLiteDB as PGLiteDB, type PG$1_PgDB as PgDB, PG$1_applyMigrations as applyMigrations, PG$1_clean as clean, connect$2 as connect };
1153
- }
1154
-
1155
- type ChainStore = {
1156
- /** Get the latest block number processed by a given chain alongside its epoch. */
1157
- getBlockNumber: (chainId: Id) => Promise<{
1158
- blockNumber: number;
1159
- epoch: bigint;
1160
- }>;
1161
- /** Get the latest block number processed for all chains, optionally filtered by chain id. */
1162
- getBlockNumbers: (parameters?: {
1163
- chainId?: Id;
1164
- }) => Promise<Array<{
1165
- chainId: Id;
1166
- blockNumber: number;
1167
- epoch: bigint;
1168
- updatedAt: Date;
1169
- }>>;
1170
- /** Save the latest block number processed for a given chain alongside its epoch.*/
1171
- saveBlockNumber: (parameters: {
1172
- chainId: Id;
1173
- blockNumber: number;
1174
- epoch: bigint;
1175
- }) => Promise<void>;
1176
- };
1177
- /** Postgres implementation. */
1178
- declare const create$6: (config: {
1179
- db: PG;
1180
- }) => ChainStore;
1181
-
1182
- type ChainStore$1_ChainStore = ChainStore;
1183
- declare namespace ChainStore$1 {
1184
- export { type ChainStore$1_ChainStore as ChainStore, create$6 as create };
1185
- }
1186
-
1187
- type CollectorStore = {
1188
- /** Get the latest block number processed by a collector for a given chain alongside the epoch. */
1189
- getBlockNumber: (parameters: {
1190
- collectorName: Name;
1191
- chainId: Id;
1192
- }) => Promise<{
1193
- blockNumber: number;
1194
- epoch: bigint;
1195
- }>;
1196
- /**
1197
- * Get the latest block number processed by all collectors.
1198
- * When a chainId is provided the result is filtered, otherwise all records are returned.
1199
- */
1200
- getBlockNumbers: (parameters?: {
1201
- chainId?: Id;
1202
- }) => Promise<Array<{
1203
- collectorName: Name;
1204
- chainId: Id;
1205
- blockNumber: number;
1206
- epoch: bigint;
1207
- updatedAt: Date;
1208
- }>>;
1209
- /** Save the latest block number processed by a collector for a given chain.*/
1210
- saveBlockNumber: (parameters: {
1211
- collectorName: Name;
1212
- chainId: Id;
1213
- blockNumber: number;
1214
- epoch: bigint;
1215
- }) => Promise<void>;
1216
- };
1217
- /** Postgres implementation. */
1218
- declare const create$5: (config: {
1219
- db: PG;
1220
- }) => CollectorStore;
1221
-
1222
- type CollectorStore$1_CollectorStore = CollectorStore;
1223
- declare namespace CollectorStore$1 {
1224
- export { type CollectorStore$1_CollectorStore as CollectorStore, create$5 as create };
1225
- }
1226
-
1227
- type LiquidityStore = {
1228
- /**
1229
- * Get all liquidity pools.
1230
- * @returns Array of all liquidity pools
1231
- */
1232
- getAllPools: () => Promise<LiquidityPool[]>;
1233
- /**
1234
- * Get all liquidity links.
1235
- * @returns Array of all liquidity links
1236
- */
1237
- getAllLinks: () => Promise<LiquidityLink[]>;
1238
- /**
1239
- * Get all offer-pool mappings.
1240
- * @returns Array of all offer liquidity pools
1241
- */
1242
- getAllOfferPools: () => Promise<OfferLiquidityPool[]>;
1243
- /**
1244
- * Save or update liquidity data.
1245
- * Accepts flat arrays of pools, links, and offer-pool mappings.
1246
- *
1247
- * Automatically cleans up stale links: for each parent pool being updated,
1248
- * deletes any existing links with priority greater than the maximum priority
1249
- * in the new links. This ensures that when priority-ordered relationships
1250
- * shrink, old links are removed.
1251
- *
1252
- * @param parameters - Object containing arrays of pools, links, and offerPools
1253
- */
1254
- save: (parameters: {
1255
- pools: LiquidityPool[];
1256
- links: LiquidityLink[];
1257
- offerPools: OfferLiquidityPool[];
1258
- }) => Promise<void>;
1259
- };
1260
- /** Postgres implementation. */
1261
- declare const create$4: (config: {
1262
- db: PG;
1263
- }) => LiquidityStore;
1264
-
1265
- type LiquidityStore$1_LiquidityStore = LiquidityStore;
1266
- declare namespace LiquidityStore$1 {
1267
- export { type LiquidityStore$1_LiquidityStore as LiquidityStore, create$4 as create };
1268
- }
1269
-
1270
- /**
1271
- * The `OfferStore` is responsible for managing offer-related data.
1272
- */
1273
- type OfferStore = {
1274
- /** Create a single offer. */
1275
- create: (parameters: {
1276
- offer: Offer;
1277
- }) => Promise<string>;
1278
- /** Create multiple offers. */
1279
- createMany: (parameters: {
1280
- offer: Offer;
1281
- }[]) => Promise<string[]>;
1282
- /** Get all offers with optional filtering, sorting, and pagination. */
1283
- getAll: (params?: GetAllParams) => Promise<{
1284
- offers: Offer[];
1285
- nextCursor: string | null;
1286
- }>;
1287
- /** Find offers that match the specified parameters, with cursor pagination. */
1288
- findMatchingOffers: (params: FindMatchingOffersParams & {
1289
- implementation?: "nodejs" | "sql";
1290
- }) => Promise<{
1291
- offers: Offer[];
1292
- nextCursor: string | null;
1293
- implementation?: "nodejs" | "sql";
1294
- }>;
1295
- /** Delete an offer by hash. */
1296
- delete: (hash: Offer["hash"]) => Promise<boolean>;
1297
- /** Delete multiple offers by hashes. */
1298
- deleteMany: (hashes: Offer["hash"][]) => Promise<number>;
1299
- /** Delete multiple offers by block number greater than or equal to the given value. */
1300
- deleteManyByBlockNumberGte: (blockNumberGte: number) => Promise<number>;
1301
- /** Update the consumed amount for a set of offers with the same chainId, offering, and nonce. */
1302
- updateConsumedAmount: (parameters: {
1303
- id: string;
1304
- chainId: Offer["chainId"];
1305
- offering: Offer["offering"];
1306
- nonce: Offer["nonce"];
1307
- consumed: bigint;
1308
- blockNumber: number;
1309
- }) => Promise<void>;
1310
- /** Delete multiple consumed amounts by block number greater than or equal to the given value. */
1311
- deleteManyConsumedAmountsByBlockNumberGte: (blockNumberGte: number) => Promise<number>;
1312
- /** Get all obligations */
1313
- getAllObligations: (parameters?: {
1314
- cursor?: string;
1315
- limit?: number;
1316
- }) => Promise<{
1317
- obligations: Obligation[];
1318
- nextCursor: string | null;
1319
- }>;
1320
- /** Get quotes for given obligations. */
1321
- getQuotes: (parameters: {
1322
- obligationIds: Hex[];
1323
- }) => Promise<Quote[]>;
1324
- };
1325
- type GetOffersFilters = {
1326
- creators?: string[];
1327
- side?: "buy" | "sell";
1328
- chains?: number[];
1329
- loanTokens?: string[];
1330
- callbackAddresses?: string[];
1331
- minAmount?: bigint;
1332
- maxAmount?: bigint;
1333
- minRate?: bigint;
1334
- maxRate?: bigint;
1335
- minMaturity?: number;
1336
- maxMaturity?: number;
1337
- minExpiry?: number;
1338
- maxExpiry?: number;
1339
- collateralAssets?: string[];
1340
- collateralOracles?: string[];
1341
- collateralTuple?: Array<{
1342
- asset: string;
1343
- oracle?: string;
1344
- lltv?: LLTV;
1345
- }>;
1346
- minLltv?: number;
1347
- maxLltv?: number;
1348
- sortBy?: "rate" | "maturity" | "expiry" | "amount";
1349
- sortOrder?: "asc" | "desc";
1350
- cursor?: string;
1351
- limit?: number;
1352
- };
1353
- type FindMatchingOffersParams = {
1354
- /** The side of the offer. */
1355
- side: "buy" | "sell";
1356
- /** The obligationId of the offer. */
1357
- obligationId: Hex;
1358
- /** Cursor string returned by a previous call, for pagination */
1359
- cursor?: string;
1360
- /** Page size; defaults to 20 */
1361
- limit?: number;
1362
- };
1363
- type GetAllParams = {
1364
- query?: GetOffersFilters;
1365
- };
1366
- type PgConfig = {
1367
- /** The database instance to use for operations. */
1368
- db: PG;
1369
- };
1370
- declare function create$3(config: PgConfig): OfferStore;
1371
-
1372
- type OfferStore$1_FindMatchingOffersParams = FindMatchingOffersParams;
1373
- type OfferStore$1_GetAllParams = GetAllParams;
1374
- type OfferStore$1_GetOffersFilters = GetOffersFilters;
1375
- type OfferStore$1_OfferStore = OfferStore;
1376
- type OfferStore$1_PgConfig = PgConfig;
1377
- declare namespace OfferStore$1 {
1378
- export { type OfferStore$1_FindMatchingOffersParams as FindMatchingOffersParams, type OfferStore$1_GetAllParams as GetAllParams, type OfferStore$1_GetOffersFilters as GetOffersFilters, type OfferStore$1_OfferStore as OfferStore, type OfferStore$1_PgConfig as PgConfig, create$3 as create };
1379
- }
1380
-
1381
- type ServicesConfig = {
1382
- chain: Chain;
1383
- rpcUrl: string;
1384
- dbConfig: {
1385
- type: "pg" | "pglite";
1386
- endpoint?: string;
1387
- };
1388
- collectorConfig?: {
1389
- interval?: number;
1390
- maxBatchSize?: number;
1391
- maxBlockNumber?: number;
1392
- };
1393
- };
1394
- type Services = {
1395
- indexer: Indexer;
1396
- offerStore: OfferStore;
1397
- collectorStore: CollectorStore;
1398
- liquidityStore: LiquidityStore;
1399
- chainStore: ChainStore;
1400
- healthService: HealthService;
1401
- mempoolOffersCollector: Collector<"mempool_offers">;
1402
- consumedEventsCollector: Collector<"consumed_events">;
1403
- buyWithEmptyCallbackLiquidityCollector: Collector<"buy_with_empty_callback_liquidity">;
1404
- buyVaultV1CallbackLiquidityCollector: Collector<"buy_vault_v1_callback_liquidity">;
1405
- sellERC20CallbackLiquidityCollector: Collector<"sell_erc20_callback_liquidity">;
1406
- DB: PG;
1407
- routerApi: RouterApi$1;
1408
- };
1409
- declare function from$3(config: ServicesConfig): Services;
1410
- type Stores = ReturnType<typeof createStores>;
1411
- declare function createStores(db: PG): {
1412
- collectorStore: CollectorStore;
1413
- offerStore: OfferStore;
1414
- liquidityStore: LiquidityStore;
1415
- chainStore: ChainStore;
1416
- };
1417
- declare function createWithTransaction<T>(db: PG): (fn: (s: ReturnType<typeof createStores>) => Promise<T>) => Promise<T>;
1418
-
1419
- type Services$1_Services = Services;
1420
- type Services$1_ServicesConfig = ServicesConfig;
1421
- type Services$1_Stores = Stores;
1422
- declare const Services$1_createStores: typeof createStores;
1423
- declare const Services$1_createWithTransaction: typeof createWithTransaction;
1424
- declare namespace Services$1 {
1425
- export { type Services$1_Services as Services, type Services$1_ServicesConfig as ServicesConfig, type Services$1_Stores as Stores, Services$1_createStores as createStores, Services$1_createWithTransaction as createWithTransaction, from$3 as from };
1426
- }
1427
-
1428
- declare const names: readonly ["mempool_offers", "consumed_events", "buy_with_empty_callback_liquidity", "buy_vault_v1_callback_liquidity", "sell_erc20_callback_liquidity"];
1429
- type Name = (typeof names)[number];
1430
- /** A general collector interface. */
1431
- type Collector<name extends Name = Name, chain extends Chain = Chain> = {
1432
- /** The name of the collector. */
1433
- readonly name: name;
1434
- /** The chain the collector is running on. */
1435
- readonly chain: chain;
1436
- /** Start collecting data from external sources.
1437
- * @yields The last block number processed by the collector.
1438
- */
1439
- collect: () => AsyncGenerator<number, void, void>;
1440
- };
1441
- /** A collector’s collect function signature */
1442
- type CollectFn<chain extends Chain, collector extends Name> = (parameters: CollectParameters<chain, collector>) => Promise<number>;
1443
- /** Core parameters every collector gets at runtime */
1444
- type CollectParameters<chain extends Chain, collector extends Name> = {
1445
- /** The chain the collector is running on. */
1446
- chain: chain;
1447
- /** A public viem client. */
1448
- client: PublicClient;
1449
- /** The collector name. */
1450
- collector: collector;
1451
- /** The epoch the collector is running on. */
1452
- epoch: bigint;
1453
- /** The last block number processed by the collector. */
1454
- lastBlockNumber: number;
1455
- /** A function to execute database operations in a transaction. */
1456
- withTransaction: <T>(fn: (s: Stores) => Promise<T>) => Promise<T>;
1457
- };
1458
- declare function create$2<name extends Name, chain extends Chain>({ name, collect, client, chain, withTransaction, collectorStore, options, }: {
1459
- name: name;
1460
- collect: CollectFn<chain, name>;
1461
- chain: chain;
1462
- client: PublicClient;
1463
- withTransaction: <T>(fn: (s: Stores) => Promise<T>) => Promise<T>;
1464
- collectorStore: CollectorStore;
1465
- options: {
1466
- interval: number;
1467
- maxBlockNumber?: number;
1468
- };
1469
- }): Collector<name, chain>;
1470
- /** Start a collector.
1471
- * @param collector - The collector to start.
1472
- * @returns A function to stop the collector.
1473
- */
1474
- declare function start(collector: Collector): () => void;
1475
-
1476
- type Builder<chain extends Chain = Chain> = {
1477
- buildMempoolCollector: (parameters: {
1478
- options?: {
1479
- maxBatchSize?: number;
1480
- };
1481
- }) => Collector<"mempool_offers", chain>;
1482
- buildConsumedEventsCollector: (parameters?: {
1483
- options?: {
1484
- maxBatchSize?: number;
1485
- };
1486
- }) => Collector<"consumed_events", chain>;
1487
- buildBuyWithEmptyCallbackLiquidityCollector: (parameters?: {
1488
- options?: {
1489
- maxBatchSize?: number;
1490
- };
1491
- }) => Collector<"buy_with_empty_callback_liquidity", chain>;
1492
- buildSellERC20CallbackLiquidityCollector: (parameters?: {
1493
- options?: {
1494
- maxBatchSize?: number;
1495
- };
1496
- }) => Collector<"sell_erc20_callback_liquidity", chain>;
1497
- buildBuyVaultV1CallbackLiquidityCollector: (parameters?: {
1498
- options?: {
1499
- maxBatchSize?: number;
1500
- };
1501
- }) => Collector<"buy_vault_v1_callback_liquidity", chain>;
1502
- };
1503
- declare function createBuilder<chain extends Chain = Chain>(parameters: {
1504
- client: PublicClient;
1505
- chain: chain;
1506
- db: PG;
1507
- options: {
1508
- interval: number;
1509
- maxBlockNumber?: number;
1510
- };
1511
- }): Builder<chain>;
1512
-
1513
- /**
1514
- * Fetches ERC20 token balances and allowances using multicall.
1515
- * Returns liquidity pools and links.
1516
- *
1517
- * @param parameters - Configuration for the fetch operation including user-token pairs
1518
- * @returns Promise resolving to pools and links arrays
1519
- */
1520
- declare function fetchBalancesAndAllowances(parameters: {
1521
- client: Pick<PublicActions, "multicall">;
1522
- chainId: bigint;
1523
- spender: Address;
1524
- pairs: Array<{
1525
- user: Address;
1526
- token: Address;
1527
- }>;
1528
- options?: {
1529
- batchSize?: number;
1530
- retryAttempts?: number;
1531
- retryDelayMs?: number;
1532
- blockNumber?: number;
1533
- };
1534
- }): Promise<{
1535
- pools: LiquidityPool[];
1536
- links: LiquidityLink[];
1537
- }>;
1538
-
1539
- /**
1540
- * Fetches existing collateral and debt data from Morpho protocol for user-term-collateral combinations.
1541
- * Returns liquidity pools for obligation collateral and debt.
1542
- *
1543
- * @param parameters - Configuration for the fetch operation
1544
- * @returns Promise resolving to pools array (no links for obligation collateral/debt pools)
1545
- */
1546
- declare function fetchCollateralAndDebt(parameters: {
1547
- client: Pick<PublicActions, "multicall">;
1548
- chainId: bigint;
1549
- morphoAddress: Address;
1550
- queries: Array<{
1551
- user: Address;
1552
- obligationId: Hex;
1553
- collateralAssets: Address[];
1554
- }>;
1555
- options?: {
1556
- batchSize?: number;
1557
- retryAttempts?: number;
1558
- retryDelayMs?: number;
1559
- blockNumber?: number;
1560
- };
1561
- }): Promise<{
1562
- pools: LiquidityPool[];
1563
- }>;
1564
-
1565
- /**
1566
- * Fetches prices from multiple oracle contracts using multicall.
1567
- *
1568
- * @param parameters - Configuration for the fetch operation
1569
- * @returns Promise resolving to a Map: oracle address -> price
1570
- */
1571
- declare function fetchOraclePrices(parameters: {
1572
- client: Pick<PublicActions, "multicall">;
1573
- oracles: Address[];
1574
- options?: {
1575
- batchSize?: number;
1576
- retryAttempts?: number;
1577
- retryDelayMs?: number;
1578
- blockNumber?: number;
1579
- };
1580
- }): Promise<Map<Address, bigint>>;
1581
-
1582
- /**
1583
- * Fetches user positions in MetaMorpho vaults, vault positions in Morpho Blue markets, and total market liquidity.
1584
- * Returns liquidity pools for user vault positions, vault positions, and market liquidity, along with hierarchical links.
1585
- *
1586
- * @param parameters - Configuration for the fetch operation
1587
- * @param parameters.chain - The chain configuration containing chainId and Morpho Blue address
1588
- * @param parameters.userVaults - Array of user-vault pairs to query (markets are determined from vault's withdrawQueue)
1589
- * @returns Promise resolving to pools and links arrays
1590
- */
1591
- declare function fetchUserVaultMarketLiquidity(parameters: {
1592
- client: Pick<PublicActions, "multicall">;
1593
- chain: Chain;
1594
- userVaults: Array<{
1595
- user: Address;
1596
- vault: Address;
1597
- }>;
1598
- options?: {
1599
- batchSize?: number;
1600
- retryAttempts?: number;
1601
- retryDelayMs?: number;
1602
- blockNumber?: number;
1603
- };
1604
- }): Promise<{
1605
- pools: LiquidityPool[];
1606
- links: LiquidityLink[];
1607
- }>;
1608
-
1609
- /**
1610
- * A validation rule.
1611
- */
1612
- type Rule<T, Name extends string = string, Ctx = void> = {
1613
- kind: "single";
1614
- name: Name;
1615
- run: Single<T, Name, Ctx>;
1616
- } | {
1617
- kind: "batch";
1618
- name: Name;
1619
- run: Batch<T, Name, Ctx>;
1620
- };
1621
- type RuleNames<Rules extends readonly {
1622
- name: string;
1623
- }[]> = Rules[number]["name"];
1624
- /**
1625
- * A single item validation rule.
1626
- * @param item - The item to validate.
1627
- * @param ctx - The context of the validation.
1628
- * @returns The issue that was found. If the item is valid, this will be undefined.
1629
- */
1630
- type Single<T, RuleName extends string, Ctx = void> = (item: T, ctx: Ctx) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
1631
- /**
1632
- * A batch item validation rule.
1633
- * @param items - The items to validate.
1634
- * @param ctx - The context of the validation.
1635
- * @returns A map of the items to the issue that was found.
1636
- */
1637
- type Batch<T, RuleName extends string, Ctx = void> = (items: T[], ctx: Ctx) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
1638
- /**
1639
- * Create a validation rule iterating over a single item at a time.
1640
- * @param name - The name of the rule.
1641
- * @param run - The function that validates the rule.
1642
- * @returns The created rule.
1643
- */
1644
- declare function single<Name extends string, T, Ctx = void>(name: Name, run: Single<T, Name, Ctx>): Rule<T, Name, Ctx>;
1645
- /**
1646
- * Create a validation rule iterating over a batch of items at a time.
1647
- * @param name - The name of the rule.
1648
- * @param run - The function that validates the rule.
1649
- * @returns The created rule.
1650
- */
1651
- declare function batch$1<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
1652
- type MorphoContext = {
1653
- chain: Chain;
1654
- client: PublicClient;
1655
- };
1656
- declare function morpho(): (Rule<Offer, "chain_id", MorphoContext> | Rule<Offer, "loan_token", MorphoContext> | Rule<Offer, "expiry", MorphoContext> | Rule<Offer, "sell_offers_empty_callback", MorphoContext> | Rule<Offer, "buy_offers_non_empty_callback", MorphoContext> | Rule<Offer, "sell_offers_non_whitelisted_callback", MorphoContext> | Rule<Offer, "sell_offers_callback_data_invalid", MorphoContext> | Rule<Offer, "sell_offers_callback_collateral_invalid", MorphoContext> | Rule<Offer, "buy_offers_callback_data_invalid", MorphoContext> | Rule<Offer, "buy_offers_callback_vault_invalid", MorphoContext> | Rule<Offer, "maturity", MorphoContext>)[];
1657
-
1658
- type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
1659
- type ValidationRule_MorphoContext = MorphoContext;
1660
- type ValidationRule_Rule<T, Name extends string = string, Ctx = void> = Rule<T, Name, Ctx>;
1661
- type ValidationRule_RuleNames<Rules extends readonly {
1662
- name: string;
1663
- }[]> = RuleNames<Rules>;
1664
- type ValidationRule_Single<T, RuleName extends string, Ctx = void> = Single<T, RuleName, Ctx>;
1665
- declare const ValidationRule_morpho: typeof morpho;
1666
- declare const ValidationRule_single: typeof single;
1667
- declare namespace ValidationRule {
1668
- export { type ValidationRule_Batch as Batch, type ValidationRule_MorphoContext as MorphoContext, type ValidationRule_Rule as Rule, type ValidationRule_RuleNames as RuleNames, type ValidationRule_Single as Single, batch$1 as batch, ValidationRule_morpho as morpho, ValidationRule_single as single };
1669
- }
1670
-
1671
- /**
1672
- * A validation issue.
1673
- */
1674
- type Issue<T, RuleName extends string = string> = {
1675
- /** The name of the rule that caused the issue. */
1676
- ruleName: RuleName;
1677
- /** The message of the issue. */
1678
- message: string;
1679
- /** The item that was not valid. */
1680
- item: T;
1681
- };
1682
- /**
1683
- * The result of a validation.
1684
- */
1685
- type Result<T, RuleName extends string = string> = {
1686
- /** The items that were valid. */
1687
- valid: T[];
1688
- /** The reports of the failed validations. */
1689
- issues: Issue<T, RuleName>[];
1690
- };
1691
- declare function run<T, Name extends string, Rules extends readonly Rule<T, Name, void>[]>(parameters: {
1692
- items: T[];
1693
- rules: Rules;
1694
- chunkSize?: number;
1695
- }): Promise<Result<T, RuleNames<Rules>>>;
1696
- declare function run<T, Ctx, Name extends string, Rules extends readonly Rule<T, Name, Ctx>[]>(parameters: {
1697
- items: T[];
1698
- rules: Rules;
1699
- ctx: Ctx;
1700
- chunkSize?: number;
1701
- }): Promise<Result<T, RuleNames<Rules>>>;
1702
-
1703
- type Validation_Issue<T, RuleName extends string = string> = Issue<T, RuleName>;
1704
- type Validation_Result<T, RuleName extends string = string> = Result<T, RuleName>;
1705
- declare const Validation_run: typeof run;
1706
- declare namespace Validation {
1707
- export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
1708
- }
1709
-
1710
- type index$3_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
1711
- type index$3_Builder<chain extends Chain = Chain> = Builder<chain>;
1712
- type index$3_CollectFn<chain extends Chain, collector extends Name> = CollectFn<chain, collector>;
1713
- type index$3_CollectParameters<chain extends Chain, collector extends Name> = CollectParameters<chain, collector>;
1714
- type index$3_Collector<name extends Name = Name, chain extends Chain = Chain> = Collector<name, chain>;
1715
- type index$3_Issue<T, RuleName extends string = string> = Issue<T, RuleName>;
1716
- type index$3_MorphoContext = MorphoContext;
1717
- type index$3_Name = Name;
1718
- type index$3_Result<T, RuleName extends string = string> = Result<T, RuleName>;
1719
- type index$3_Rule<T, Name extends string = string, Ctx = void> = Rule<T, Name, Ctx>;
1720
- type index$3_RuleNames<Rules extends readonly {
1721
- name: string;
1722
- }[]> = RuleNames<Rules>;
1723
- type index$3_Single<T, RuleName extends string, Ctx = void> = Single<T, RuleName, Ctx>;
1724
- declare const index$3_createBuilder: typeof createBuilder;
1725
- declare const index$3_fetchBalancesAndAllowances: typeof fetchBalancesAndAllowances;
1726
- declare const index$3_fetchCollateralAndDebt: typeof fetchCollateralAndDebt;
1727
- declare const index$3_fetchOraclePrices: typeof fetchOraclePrices;
1728
- declare const index$3_fetchUserVaultMarketLiquidity: typeof fetchUserVaultMarketLiquidity;
1729
- declare const index$3_morpho: typeof morpho;
1730
- declare const index$3_names: typeof names;
1731
- declare const index$3_run: typeof run;
1732
- declare const index$3_single: typeof single;
1733
- declare const index$3_start: typeof start;
1734
- declare namespace index$3 {
1735
- export { type index$3_Batch as Batch, type index$3_Builder as Builder, type index$3_CollectFn as CollectFn, type index$3_CollectParameters as CollectParameters, type index$3_Collector as Collector, type index$3_Issue as Issue, type index$3_MorphoContext as MorphoContext, type index$3_Name as Name, type index$3_Result as Result, type index$3_Rule as Rule, type index$3_RuleNames as RuleNames, type index$3_Single as Single, batch$1 as batch, create$2 as create, index$3_createBuilder as createBuilder, index$3_fetchBalancesAndAllowances as fetchBalancesAndAllowances, index$3_fetchCollateralAndDebt as fetchCollateralAndDebt, index$3_fetchOraclePrices as fetchOraclePrices, index$3_fetchUserVaultMarketLiquidity as fetchUserVaultMarketLiquidity, index$3_morpho as morpho, index$3_names as names, index$3_run as run, index$3_single as single, index$3_start as start };
1736
- }
1737
-
1738
- type CollectorHealthStatus = "live" | "lagging" | "unknown";
1739
- type RouterStatus = "live" | "syncing";
1740
- type CollectorHealth$1 = {
1741
- name: Name;
1742
- chainId: Id;
1743
- blockNumber: number | null;
1744
- updatedAt: string | null;
1745
- lag: number | null;
1746
- status: CollectorHealthStatus;
1747
- };
1748
- type ChainHealth$1 = {
1749
- chainId: Id;
1750
- blockNumber: number;
1751
- epoch: string;
1752
- updatedAt: string;
1753
- };
1754
- type HealthService = {
1755
- getStatus: () => Promise<RouterStatus>;
1756
- getCollectors: () => Promise<CollectorHealth$1[]>;
1757
- getChains: () => Promise<ChainHealth$1[]>;
1758
- };
1759
- type HealthServiceParameters = {
1760
- collectorStore: CollectorStore;
1761
- chainStore: ChainStore;
1762
- /** Maximum number of blocks a collector can lag behind its chain before being considered lagging. */
1763
- maxAllowedLag?: number;
1764
- };
1765
- /**
1766
- * Create a health service that exposes collector and chain block numbers.
1767
- */
1768
- declare function create$1(parameters: HealthServiceParameters): HealthService;
1769
-
1770
- type Health_CollectorHealthStatus = CollectorHealthStatus;
1771
- type Health_HealthService = HealthService;
1772
- type Health_HealthServiceParameters = HealthServiceParameters;
1773
- type Health_RouterStatus = RouterStatus;
1774
- declare namespace Health {
1775
- export { type ChainHealth$1 as ChainHealth, type CollectorHealth$1 as CollectorHealth, type Health_CollectorHealthStatus as CollectorHealthStatus, type Health_HealthService as HealthService, type Health_HealthServiceParameters as HealthServiceParameters, type Health_RouterStatus as RouterStatus, create$1 as create };
1776
- }
1777
-
1778
- type RouterApiConfig = {
1779
- store: OfferStore;
1780
- healthService: HealthService;
1781
- };
1782
- type RouterApi$1 = {
1783
- serve: (parameters: {
1784
- port: number;
1785
- }) => void;
1786
- };
1787
- declare function create(config: RouterApiConfig): RouterApi$1;
1788
-
1789
- declare function getSwaggerJson(): unknown;
1790
- declare function getDocsHtml(): string;
1791
-
1792
- declare const LogLevelValues: readonly ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
1793
- type LogLevel = (typeof LogLevelValues)[number];
1794
- type LogEntry = Compute<{
1795
- msg: string;
1796
- } & Record<string, unknown>>;
1797
- type LogFn = (entry: LogEntry) => void;
1798
- type Logger = {
1799
- trace: LogFn;
1800
- debug: LogFn;
1801
- info: LogFn;
1802
- warn: LogFn;
1803
- error: LogFn;
1804
- fatal: LogFn;
1805
- };
1806
- declare function defaultLogger(minLevel?: LogLevel, pretty?: boolean): Logger;
1807
- declare function silentLogger(): Logger;
1808
- declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
1809
- declare function getLogger(): Logger;
1810
-
1811
- type Logger$1_LogEntry = LogEntry;
1812
- type Logger$1_LogFn = LogFn;
1813
- type Logger$1_LogLevel = LogLevel;
1814
- declare const Logger$1_LogLevelValues: typeof LogLevelValues;
1815
- type Logger$1_Logger = Logger;
1816
- declare const Logger$1_defaultLogger: typeof defaultLogger;
1817
- declare const Logger$1_getLogger: typeof getLogger;
1818
- declare const Logger$1_runWithLogger: typeof runWithLogger;
1819
- declare const Logger$1_silentLogger: typeof silentLogger;
1820
- declare namespace Logger$1 {
1821
- export { type Logger$1_LogEntry as LogEntry, type Logger$1_LogFn as LogFn, type Logger$1_LogLevel as LogLevel, Logger$1_LogLevelValues as LogLevelValues, type Logger$1_Logger as Logger, Logger$1_defaultLogger as defaultLogger, Logger$1_getLogger as getLogger, Logger$1_runWithLogger as runWithLogger, Logger$1_silentLogger as silentLogger };
1822
- }
1823
-
1824
- declare enum STATUS_CODE {
1825
- SUCCESS = 200,
1826
- BAD_REQUEST = 400,
1827
- NOT_FOUND = 404,
1828
- INTERNAL_SERVER_ERROR = 500
1829
- }
1830
-
1831
- declare function getHealth(healthService: HealthService): Promise<{
1832
- statusCode: STATUS_CODE;
1833
- body: {
1834
- status: "success" | "error";
1835
- meta: {
1836
- timestamp: string;
1837
- };
1838
- } & ({
1839
- error: {
1840
- code: string;
1841
- message: string;
1842
- details?: unknown;
1843
- };
1844
- } | {
1845
- cursor?: string | null;
1846
- data: unknown;
1847
- });
1848
- }>;
1849
- declare function getHealthChains(healthService: HealthService): Promise<{
1850
- statusCode: STATUS_CODE;
1851
- body: {
1852
- status: "success" | "error";
1853
- meta: {
1854
- timestamp: string;
1855
- };
1856
- } & ({
1857
- error: {
1858
- code: string;
1859
- message: string;
1860
- details?: unknown;
1861
- };
1862
- } | {
1863
- cursor?: string | null;
1864
- data: unknown;
1865
- });
1866
- }>;
1867
- declare function getHealthCollectors(healthService: HealthService): Promise<{
1868
- statusCode: STATUS_CODE;
1869
- body: {
1870
- status: "success" | "error";
1871
- meta: {
1872
- timestamp: string;
1873
- };
1874
- } & ({
1875
- error: {
1876
- code: string;
1877
- message: string;
1878
- details?: unknown;
1879
- };
1880
- } | {
1881
- cursor?: string | null;
1882
- data: unknown;
1883
- });
1884
- }>;
1885
-
1886
- declare function getObligations$1(queryParameters: object, store: OfferStore): Promise<{
1887
- statusCode: STATUS_CODE;
1888
- body: {
1889
- status: "success" | "error";
1890
- meta: {
1891
- timestamp: string;
1892
- };
1893
- } & ({
1894
- error: {
1895
- code: string;
1896
- message: string;
1897
- details?: unknown;
1898
- };
1899
- } | {
1900
- cursor?: string | null;
1901
- data: unknown;
1902
- });
1903
- }>;
1904
-
1905
- declare function getOffers$1(queryParameters: object, store: OfferStore): Promise<{
1906
- statusCode: STATUS_CODE;
1907
- body: {
1908
- status: "success" | "error";
1909
- meta: {
1910
- timestamp: string;
1911
- };
1912
- } & ({
1913
- error: {
1914
- code: string;
1915
- message: string;
1916
- details?: unknown;
1917
- };
1918
- } | {
1919
- cursor?: string | null;
1920
- data: unknown;
1921
- });
1922
- }>;
1923
-
1924
- declare const index$2_getDocsHtml: typeof getDocsHtml;
1925
- declare const index$2_getHealth: typeof getHealth;
1926
- declare const index$2_getHealthChains: typeof getHealthChains;
1927
- declare const index$2_getHealthCollectors: typeof getHealthCollectors;
1928
- declare const index$2_getSwaggerJson: typeof getSwaggerJson;
1929
- declare namespace index$2 {
1930
- export { index$2_getDocsHtml as getDocsHtml, index$2_getHealth as getHealth, index$2_getHealthChains as getHealthChains, index$2_getHealthCollectors as getHealthCollectors, getObligations$1 as getObligations, getOffers$1 as getOffers, index$2_getSwaggerJson as getSwaggerJson };
1931
- }
1932
-
1933
- declare const CollectorHealth: z$1.ZodObject<{
1934
- name: z$1.ZodString;
1935
- chain_id: z$1.ZodNumber;
1936
- block_number: z$1.ZodNullable<z$1.ZodNumber>;
1937
- updated_at: z$1.ZodNullable<z$1.ZodString>;
1938
- lag: z$1.ZodNullable<z$1.ZodNumber>;
1939
- status: z$1.ZodEnum<{
1940
- unknown: "unknown";
1941
- live: "live";
1942
- lagging: "lagging";
1943
- }>;
1944
- }, z$1.core.$strip>;
1945
- declare const ChainHealth: z$1.ZodObject<{
1946
- chain_id: z$1.ZodNumber;
1947
- block_number: z$1.ZodNumber;
1948
- updated_at: z$1.ZodString;
1949
- }, z$1.core.$strip>;
1950
- declare const CollectorsHealthResponse: z$1.ZodArray<z$1.ZodObject<{
1951
- name: z$1.ZodString;
1952
- chain_id: z$1.ZodNumber;
1953
- block_number: z$1.ZodNullable<z$1.ZodNumber>;
1954
- updated_at: z$1.ZodNullable<z$1.ZodString>;
1955
- lag: z$1.ZodNullable<z$1.ZodNumber>;
1956
- status: z$1.ZodEnum<{
1957
- unknown: "unknown";
1958
- live: "live";
1959
- lagging: "lagging";
1960
- }>;
1961
- }, z$1.core.$strip>>;
1962
- type CollectorsHealthResponse = z$1.infer<typeof CollectorsHealthResponse>;
1963
- declare const ChainsHealthResponse: z$1.ZodArray<z$1.ZodObject<{
1964
- chain_id: z$1.ZodNumber;
1965
- block_number: z$1.ZodNumber;
1966
- updated_at: z$1.ZodString;
1967
- }, z$1.core.$strip>>;
1968
- type ChainsHealthResponse = z$1.infer<typeof ChainsHealthResponse>;
1969
- declare const RouterStatusResponse: z$1.ZodObject<{
1970
- status: z$1.ZodEnum<{
1971
- live: "live";
1972
- syncing: "syncing";
1973
- }>;
1974
- }, z$1.core.$strip>;
1975
- type RouterStatusResponse = z$1.infer<typeof RouterStatusResponse>;
1976
-
1977
- type ObligationResponse = Snake<Compute<{
1978
- /** The obligation id. */
1979
- id: Hex;
1980
- } & Obligation & {
1981
- ask: Quote["ask"];
1982
- bid: Quote["bid"];
1983
- }>>;
1984
- /**
1985
- * Creates an `ObligationResponse` from a `Obligation`.
1986
- * @constructor
1987
- * @param obligation - {@link Obligation}
1988
- * @returns The created `ObligationResponse`. {@link ObligationResponse}
1989
- */
1990
- declare function from$2(obligation: Obligation, quote: Quote): ObligationResponse;
1991
-
1992
- type ObligationResponse$1_ObligationResponse = ObligationResponse;
1993
- declare namespace ObligationResponse$1 {
1994
- export { type ObligationResponse$1_ObligationResponse as ObligationResponse, from$2 as from };
1995
- }
1996
-
1997
- type OfferResponse = Snake<Offer>;
1998
- /**
1999
- * Creates an `OfferResponse` from an `Offer`.
2000
- * @constructor
2001
- * @param offer - {@link Offer}
2002
- * @returns The created `OfferResponse`. {@link OfferResponse}
2003
- */
2004
- declare function from$1(offer: Offer): OfferResponse;
2005
-
2006
- type OfferResponse$1_OfferResponse = OfferResponse;
2007
- declare namespace OfferResponse$1 {
2008
- export { type OfferResponse$1_OfferResponse as OfferResponse, from$1 as from };
2009
- }
2010
-
2011
- declare const OpenApi: node_modules_zod_openapi_dist_components_CXzxKPFp_js.OpenAPIObject;
2012
-
2013
- declare const schemas: {
2014
- readonly get_offers: z.ZodObject<{
2015
- side: z.ZodEnum<{
2016
- buy: "buy";
2017
- sell: "sell";
2018
- }>;
2019
- obligation_id: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
2020
- cursor: z.ZodOptional<z.ZodString>;
2021
- limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
2022
- }, z.core.$strip>;
2023
- readonly get_obligations: z.ZodObject<{
2024
- cursor: z.ZodOptional<z.ZodString>;
2025
- limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
2026
- }, z.core.$strip>;
2027
- };
2028
- type Action = keyof typeof schemas;
2029
- declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
2030
- declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
2031
-
2032
- declare const RouterApi_ChainHealth: typeof ChainHealth;
2033
- type RouterApi_ChainsHealthResponse = ChainsHealthResponse;
2034
- declare const RouterApi_CollectorHealth: typeof CollectorHealth;
2035
- type RouterApi_CollectorsHealthResponse = CollectorsHealthResponse;
2036
- declare const RouterApi_OpenApi: typeof OpenApi;
2037
- type RouterApi_RouterApiConfig = RouterApiConfig;
2038
- type RouterApi_RouterStatusResponse = RouterStatusResponse;
2039
- declare const RouterApi_create: typeof create;
2040
- declare const RouterApi_parse: typeof parse;
2041
- declare const RouterApi_safeParse: typeof safeParse;
2042
- declare namespace RouterApi {
2043
- export { RouterApi_ChainHealth as ChainHealth, type RouterApi_ChainsHealthResponse as ChainsHealthResponse, RouterApi_CollectorHealth as CollectorHealth, type RouterApi_CollectorsHealthResponse as CollectorsHealthResponse, index$2 as Controllers, ObligationResponse$1 as ObligationResponse, OfferResponse$1 as OfferResponse, RouterApi_OpenApi as OpenApi, type RouterApi$1 as RouterApi, type RouterApi_RouterApiConfig as RouterApiConfig, type RouterApi_RouterStatusResponse as RouterStatusResponse, RouterApi_create as create, RouterApi_parse as parse, RouterApi_safeParse as safeParse };
2044
- }
2045
-
2046
- type RouterClientConfig = {
2047
- /** The URL of the router. */
2048
- readonly url: URL;
2049
- /** The default headers to use for each request. */
2050
- readonly headers: Headers;
2051
- };
2052
- type Client$1 = Compute<RouterClientConfig & {
2053
- /**
2054
- * Get offers from the router.
2055
- * @param parameters - {@link getOffers.Parameters}
2056
- * @returns The offers with pagination cursor. {@link getOffers.ReturnType}
2057
- *
2058
- * @example
2059
- * ```ts
2060
- * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
2061
- * const { offers, cursor } = await router.getOffers({ side: "buy", obligationId: "0xa1c...d2f" });
2062
- * console.log(offers);
2063
- * ```
2064
- */
2065
- getOffers: (parameters: getOffers.Parameters) => Promise<getOffers.ReturnType>;
2066
- /**
2067
- * Get obligations from the router.
2068
- * @param parameters - {@link getObligations.Parameters}
2069
- * @returns The obligations with pagination cursor. {@link getObligations.ReturnType}
2070
- *
2071
- * @example
2072
- * ```ts
2073
- * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
2074
- * const { obligations, cursor } = await router.getObligations();
2075
- * console.log(obligations);
2076
- * ```
2077
- */
2078
- getObligations: (parameters?: getObligations.Parameters) => Promise<getObligations.ReturnType>;
2079
- }>;
2080
- type ConnectOptions = {
2081
- /** The URL of the router to interact with.
2082
- * @default "https://router.morpho.dev"
2083
- */
2084
- url?: string;
2085
- /** The API key to use for the router API. */
2086
- apiKey?: string;
2087
- /** The default headers to use for each request. */
2088
- headers?: Headers;
2089
- };
2090
- /**
2091
- * Creates an instance of a router client.
2092
- * @constructor
2093
- * @param options - {@link ConnectOptions}
2094
- * @returns A Router Client. {@link Client}
2095
- *
2096
- * @example
2097
- * ```typescript
2098
- * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
2099
- * ```
2100
- */
2101
- declare function connect$1(options?: ConnectOptions): connect$1.ReturnType;
2102
- declare namespace connect$1 {
2103
- type ReturnType = Client$1;
2104
- type ErrorType = InvalidUrlError;
2105
- }
2106
- declare function getOffers(config: RouterClientConfig, parameters: getOffers.Parameters): Promise<getOffers.ReturnType>;
2107
- declare namespace getOffers {
2108
- type Parameters = {
2109
- /** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
2110
- side: "buy" | "sell";
2111
- /** The offers obligation id */
2112
- obligationId: Hex;
2113
- /** Pagination cursor in base64url-encoded format */
2114
- cursor?: string;
2115
- /** Maximum number of offers to return. @default 20 */
2116
- limit?: number;
2117
- };
2118
- type ReturnType = {
2119
- offers: Offer[];
2120
- /** The pagination cursor. */
2121
- cursor: string | null;
2122
- };
2123
- type ErrorType = GetApiErrorType;
2124
- }
2125
- declare function getObligations(config: RouterClientConfig, parameters?: getObligations.Parameters): Promise<getObligations.ReturnType>;
2126
- declare namespace getObligations {
2127
- type Parameters = {
2128
- /** Pagination cursor is a 32-byte hex string. */
2129
- cursor?: Hex;
2130
- /** Maximum number of obligations to return. @default 20 */
2131
- limit?: number;
2132
- };
2133
- type ReturnType = {
2134
- obligations: Compute<{
2135
- /** The obligation id. Uses {@link Obligation.id} to calculate the id.*/
2136
- id: () => Hex;
2137
- } & Obligation & Omit<Quote, "obligationId">>[];
2138
- /** The pagination cursor. */
2139
- cursor: string | null;
2140
- };
2141
- type ErrorType = GetApiErrorType;
2142
- }
2143
- type GetApiErrorType = HttpGetApiFailedError | HttpUnauthorizedError | HttpForbiddenError | HttpRateLimitError;
2144
- declare class InvalidUrlError extends BaseError {
2145
- name: string;
2146
- constructor(url: string);
2147
- }
2148
- declare class HttpUnauthorizedError extends BaseError {
2149
- name: string;
2150
- constructor();
2151
- }
2152
- declare class HttpForbiddenError extends BaseError {
2153
- name: string;
2154
- constructor();
2155
- }
2156
- declare class HttpRateLimitError extends BaseError {
2157
- name: string;
2158
- constructor();
2159
- }
2160
- declare class HttpGetApiFailedError extends BaseError {
2161
- name: string;
2162
- constructor(message: string, { details }?: {
2163
- details?: string;
2164
- });
2165
- }
2166
-
2167
- type Client$2_ConnectOptions = ConnectOptions;
2168
- type Client$2_HttpForbiddenError = HttpForbiddenError;
2169
- declare const Client$2_HttpForbiddenError: typeof HttpForbiddenError;
2170
- type Client$2_HttpGetApiFailedError = HttpGetApiFailedError;
2171
- declare const Client$2_HttpGetApiFailedError: typeof HttpGetApiFailedError;
2172
- type Client$2_HttpRateLimitError = HttpRateLimitError;
2173
- declare const Client$2_HttpRateLimitError: typeof HttpRateLimitError;
2174
- type Client$2_HttpUnauthorizedError = HttpUnauthorizedError;
2175
- declare const Client$2_HttpUnauthorizedError: typeof HttpUnauthorizedError;
2176
- type Client$2_InvalidUrlError = InvalidUrlError;
2177
- declare const Client$2_InvalidUrlError: typeof InvalidUrlError;
2178
- declare const Client$2_getObligations: typeof getObligations;
2179
- declare const Client$2_getOffers: typeof getOffers;
2180
- declare namespace Client$2 {
2181
- 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 };
2182
- }
2183
-
2184
- type MempoolEVMClientConfig = {
2185
- readonly client: WalletClient;
2186
- readonly mempoolAddress: Address;
2187
- readonly blockWindow: number;
2188
- };
2189
- declare function from(parameters: from.Parameters): from.ReturnType;
2190
- declare namespace from {
2191
- type Parameters = {
2192
- /** The viem client to use. */
2193
- client: WalletClient;
2194
- /** The mempool address. */
2195
- mempoolAddress: Address;
2196
- /** The block window to use for the mempool. Defaults to 100. */
2197
- blockWindow?: number;
2198
- };
2199
- type ReturnType = Client;
2200
- type ErrorType = null;
2201
- }
2202
- /**
2203
- * Add an offer to the mempool.
2204
- * @returns The created offer with its hash.
2205
- * @throws WalletAccountNotSetError if the wallet account is not set.
2206
- * @throws ViemClientError if the viem client throws an error.
2207
- * @throws Offer.InvalidOfferError if the offer is invalid.
2208
- */
2209
- declare function add(config: MempoolEVMClientConfig, parameters: AddParameters): Promise<{
2210
- offer: Offer;
2211
- txHash: Hex;
2212
- }>;
2213
- declare namespace add {
2214
- type ErrorType = WalletAccountNotSetError | ViemClientError | InvalidOfferError | ChainIdMismatchError;
2215
- }
2216
- declare function get(config: MempoolEVMClientConfig, parameters?: GetParameters): AsyncGenerator<{
2217
- offers: Offer[];
2218
- blockNumber: number;
2219
- }, void, void>;
2220
- declare namespace get {
2221
- type ErrorType = streamOffersReturnType;
2222
- }
2223
- /**
2224
- * Watch for new offers on a specific chain.
2225
- * @returns A function to stop watching for new offers.
2226
- */
2227
- declare function watch(config: MempoolEVMClientConfig, parameters: WatchParameters): () => boolean;
2228
- declare namespace watch {
2229
- type ErrorType = streamOffersReturnType;
2230
- }
2231
- type streamOffersReturnType = WalletAccountNotSetError | ChainIdMismatchError;
2232
- declare class WalletAccountNotSetError extends BaseError {
2233
- name: string;
2234
- constructor();
2235
- }
2236
- declare class ViemClientError extends BaseError {
2237
- name: string;
2238
- }
2239
- declare class ChainIdMismatchError extends BaseError {
2240
- name: string;
2241
- constructor(expected: bigint, actual: bigint);
2242
- }
2243
-
2244
- type AddParameters = {
2245
- offer: Compute<Omit<Offer, "hash" | "createdAt">>;
2246
- };
2247
- type GetParameters = {
2248
- /** The block number to get offers from. */
2249
- blockNumberGte?: number;
2250
- /** The block number to get offers to. */
2251
- blockNumberLte?: number;
2252
- /** The loan asset to get offers from. */
2253
- loanToken?: string;
2254
- /** The order to get offers. Defaults to "desc". */
2255
- order?: "asc" | "desc";
2256
- /** The options to get offers from. */
2257
- options?: {
2258
- /** The maximum number of offers to return. Defaults to 100. Maximum is 1000. */
2259
- maxBatchSize?: number;
2260
- };
2261
- };
2262
- type WatchParameters = {
2263
- /** The async function to get the last synced block number from which to start watching.
2264
- * This function will be called periodically on each poll. It should be updated by the caller (e.g. using `onOffers` callback) to track the last synced block number.
2265
- */
2266
- lastSyncedBlock: () => Promise<number>;
2267
- /** The loan asset to watch. */
2268
- loanToken?: string;
2269
- /** The callback to call when a new batch of offers is found in the mempool.
2270
- * @param offers The offers found in the mempool.
2271
- * @param blockNumber The block number of the last processed offer. Block numbers will always ascend.
2272
- */
2273
- onOffers: (offers: Offer[], blockNumber: number) => Promise<void>;
2274
- /** The polling configuration. */
2275
- polling?: {
2276
- /** The interval in milliseconds to poll for new offers. Defaults to 30000. */
2277
- interval?: number;
2278
- /** The maximum number of offers that can be returned in a single batch.
2279
- * Defaults to 100. Maximum is 1000. */
2280
- maxBatchSize?: number;
2281
- };
2282
- };
2283
- /**
2284
- * Mempool client interface.
2285
- */
2286
- type Client = {
2287
- /**
2288
- * Add an offer to the mempool.
2289
- * @returns The created offer with its hash.
2290
- */
2291
- add: (parameters: AddParameters) => Promise<{
2292
- offer: Offer;
2293
- txHash: Hex;
2294
- }>;
2295
- /** Get offers from the mempool. */
2296
- get: (parameters?: GetParameters) => AsyncGenerator<{
2297
- offers: Offer[];
2298
- /** The block number of the last processed offer. Depends on the `order` parameter, block numbers will ascend or descend. */
2299
- blockNumber: number;
2300
- }>;
2301
- /**
2302
- * Watch for new offers on a specific chain.
2303
- * @returns A function to stop watching for new offers.
2304
- */
2305
- watch: (parameters: WatchParameters) => () => boolean;
2306
- /**
2307
- * Stream offers from the mempool.
2308
- * @returns A generator of offers alongside the last block number processed.
2309
- */
2310
- stream: (parameters: Compute<Omit<GetParameters, "options"> & {
2311
- options: GetParameters["options"] & {
2312
- blockWindow?: number;
2313
- };
2314
- }>) => AsyncGenerator<{
2315
- offers: Offer[];
2316
- blockNumber: number;
2317
- }>;
2318
- };
2319
- /**
2320
- * Client to interact with the Mempool contract on a specific chain.
2321
- */
2322
- declare function connect(parameters: from.Parameters): Client;
2323
- declare namespace connect {
2324
- type ErrorType = from.ErrorType;
2325
- }
2326
-
2327
- type index$1_AddParameters = AddParameters;
2328
- type index$1_ChainIdMismatchError = ChainIdMismatchError;
2329
- declare const index$1_ChainIdMismatchError: typeof ChainIdMismatchError;
2330
- type index$1_Client = Client;
2331
- type index$1_GetParameters = GetParameters;
2332
- type index$1_ViemClientError = ViemClientError;
2333
- declare const index$1_ViemClientError: typeof ViemClientError;
2334
- type index$1_WalletAccountNotSetError = WalletAccountNotSetError;
2335
- declare const index$1_WalletAccountNotSetError: typeof WalletAccountNotSetError;
2336
- type index$1_WatchParameters = WatchParameters;
2337
- declare const index$1_add: typeof add;
2338
- declare const index$1_connect: typeof connect;
2339
- declare const index$1_from: typeof from;
2340
- declare const index$1_get: typeof get;
2341
- declare const index$1_watch: typeof watch;
2342
- declare namespace index$1 {
2343
- export { type index$1_AddParameters as AddParameters, index$1_ChainIdMismatchError as ChainIdMismatchError, type index$1_Client as Client, type index$1_GetParameters as GetParameters, index$1_ViemClientError as ViemClientError, index$1_WalletAccountNotSetError as WalletAccountNotSetError, type index$1_WatchParameters as WatchParameters, index$1_add as add, index$1_connect as connect, index$1_from as from, index$1_get as get, index$1_watch as watch };
2344
- }
2345
-
2346
- declare const VERSION = "router_v1.4";
2347
- declare const obligations: drizzle_orm_pg_core.PgTableWithColumns<{
2348
- name: "obligations";
2349
- schema: "router_v1.4";
2350
- columns: {
2351
- obligationId: drizzle_orm_pg_core.PgColumn<{
2352
- name: "obligation_id";
2353
- tableName: "obligations";
2354
- dataType: "string";
2355
- columnType: "PgVarchar";
2356
- data: string;
2357
- driverParam: string;
2358
- notNull: true;
2359
- hasDefault: false;
2360
- isPrimaryKey: true;
2361
- isAutoincrement: false;
2362
- hasRuntimeDefault: false;
2363
- enumValues: [string, ...string[]];
2364
- baseColumn: never;
2365
- identity: undefined;
2366
- generated: undefined;
2367
- }, {}, {
2368
- length: 66;
2369
- }>;
2370
- chainId: drizzle_orm_pg_core.PgColumn<{
2371
- name: "chain_id";
2372
- tableName: "obligations";
2373
- dataType: "bigint";
2374
- columnType: "PgBigInt64";
2375
- data: bigint;
2376
- driverParam: string;
2377
- notNull: true;
2378
- hasDefault: false;
2379
- isPrimaryKey: false;
2380
- isAutoincrement: false;
2381
- hasRuntimeDefault: false;
2382
- enumValues: undefined;
2383
- baseColumn: never;
2384
- identity: undefined;
2385
- generated: undefined;
2386
- }, {}, {}>;
2387
- loanToken: drizzle_orm_pg_core.PgColumn<{
2388
- name: "loan_token";
2389
- tableName: "obligations";
2390
- dataType: "string";
2391
- columnType: "PgVarchar";
2392
- data: string;
2393
- driverParam: string;
2394
- notNull: true;
2395
- hasDefault: false;
2396
- isPrimaryKey: false;
2397
- isAutoincrement: false;
2398
- hasRuntimeDefault: false;
2399
- enumValues: [string, ...string[]];
2400
- baseColumn: never;
2401
- identity: undefined;
2402
- generated: undefined;
2403
- }, {}, {
2404
- length: 42;
2405
- }>;
2406
- maturity: drizzle_orm_pg_core.PgColumn<{
2407
- name: "maturity";
2408
- tableName: "obligations";
2409
- dataType: "number";
2410
- columnType: "PgInteger";
2411
- data: number;
2412
- driverParam: string | number;
2413
- notNull: true;
2414
- hasDefault: false;
2415
- isPrimaryKey: false;
2416
- isAutoincrement: false;
2417
- hasRuntimeDefault: false;
2418
- enumValues: undefined;
2419
- baseColumn: never;
2420
- identity: undefined;
2421
- generated: undefined;
2422
- }, {}, {}>;
2423
- };
2424
- dialect: "pg";
2425
- }>;
2426
- declare const offers: drizzle_orm_pg_core.PgTableWithColumns<{
2427
- name: "offers";
2428
- schema: "router_v1.4";
2429
- columns: {
2430
- hash: drizzle_orm_pg_core.PgColumn<{
2431
- name: "hash";
2432
- tableName: "offers";
2433
- dataType: "string";
2434
- columnType: "PgVarchar";
2435
- data: string;
2436
- driverParam: string;
2437
- notNull: true;
2438
- hasDefault: false;
2439
- isPrimaryKey: true;
2440
- isAutoincrement: false;
2441
- hasRuntimeDefault: false;
2442
- enumValues: [string, ...string[]];
2443
- baseColumn: never;
2444
- identity: undefined;
2445
- generated: undefined;
2446
- }, {}, {
2447
- length: 66;
2448
- }>;
2449
- obligationId: drizzle_orm_pg_core.PgColumn<{
2450
- name: "obligation_id";
2451
- tableName: "offers";
2452
- dataType: "string";
2453
- columnType: "PgVarchar";
2454
- data: string;
2455
- driverParam: string;
2456
- notNull: true;
2457
- hasDefault: false;
2458
- isPrimaryKey: false;
2459
- isAutoincrement: false;
2460
- hasRuntimeDefault: false;
2461
- enumValues: [string, ...string[]];
2462
- baseColumn: never;
2463
- identity: undefined;
2464
- generated: undefined;
2465
- }, {}, {
2466
- length: 66;
2467
- }>;
2468
- offering: drizzle_orm_pg_core.PgColumn<{
2469
- name: "offering";
2470
- tableName: "offers";
2471
- dataType: "string";
2472
- columnType: "PgVarchar";
2473
- data: string;
2474
- driverParam: string;
2475
- notNull: true;
2476
- hasDefault: false;
2477
- isPrimaryKey: false;
2478
- isAutoincrement: false;
2479
- hasRuntimeDefault: false;
2480
- enumValues: [string, ...string[]];
2481
- baseColumn: never;
2482
- identity: undefined;
2483
- generated: undefined;
2484
- }, {}, {
2485
- length: 42;
2486
- }>;
2487
- assets: drizzle_orm_pg_core.PgColumn<{
2488
- name: "assets";
2489
- tableName: "offers";
2490
- dataType: "string";
2491
- columnType: "PgNumeric";
2492
- data: string;
2493
- driverParam: string;
2494
- notNull: true;
2495
- hasDefault: false;
2496
- isPrimaryKey: false;
2497
- isAutoincrement: false;
2498
- hasRuntimeDefault: false;
2499
- enumValues: undefined;
2500
- baseColumn: never;
2501
- identity: undefined;
2502
- generated: undefined;
2503
- }, {}, {}>;
2504
- rate: drizzle_orm_pg_core.PgColumn<{
2505
- name: "rate";
2506
- tableName: "offers";
2507
- dataType: "bigint";
2508
- columnType: "PgBigInt64";
2509
- data: bigint;
2510
- driverParam: string;
2511
- notNull: true;
2512
- hasDefault: false;
2513
- isPrimaryKey: false;
2514
- isAutoincrement: false;
2515
- hasRuntimeDefault: false;
2516
- enumValues: undefined;
2517
- baseColumn: never;
2518
- identity: undefined;
2519
- generated: undefined;
2520
- }, {}, {}>;
2521
- maturity: drizzle_orm_pg_core.PgColumn<{
2522
- name: "maturity";
2523
- tableName: "offers";
2524
- dataType: "number";
2525
- columnType: "PgInteger";
2526
- data: number;
2527
- driverParam: string | number;
2528
- notNull: true;
2529
- hasDefault: false;
2530
- isPrimaryKey: false;
2531
- isAutoincrement: false;
2532
- hasRuntimeDefault: false;
2533
- enumValues: undefined;
2534
- baseColumn: never;
2535
- identity: undefined;
2536
- generated: undefined;
2537
- }, {}, {}>;
2538
- expiry: drizzle_orm_pg_core.PgColumn<{
2539
- name: "expiry";
2540
- tableName: "offers";
2541
- dataType: "number";
2542
- columnType: "PgInteger";
2543
- data: number;
2544
- driverParam: string | number;
2545
- notNull: true;
2546
- hasDefault: false;
2547
- isPrimaryKey: false;
2548
- isAutoincrement: false;
2549
- hasRuntimeDefault: false;
2550
- enumValues: undefined;
2551
- baseColumn: never;
2552
- identity: undefined;
2553
- generated: undefined;
2554
- }, {}, {}>;
2555
- start: drizzle_orm_pg_core.PgColumn<{
2556
- name: "start";
2557
- tableName: "offers";
2558
- dataType: "number";
2559
- columnType: "PgInteger";
2560
- data: number;
2561
- driverParam: string | number;
2562
- notNull: true;
2563
- hasDefault: false;
2564
- isPrimaryKey: false;
2565
- isAutoincrement: false;
2566
- hasRuntimeDefault: false;
2567
- enumValues: undefined;
2568
- baseColumn: never;
2569
- identity: undefined;
2570
- generated: undefined;
2571
- }, {}, {}>;
2572
- nonce: drizzle_orm_pg_core.PgColumn<{
2573
- name: "nonce";
2574
- tableName: "offers";
2575
- dataType: "bigint";
2576
- columnType: "PgBigInt64";
2577
- data: bigint;
2578
- driverParam: string;
2579
- notNull: true;
2580
- hasDefault: false;
2581
- isPrimaryKey: false;
2582
- isAutoincrement: false;
2583
- hasRuntimeDefault: false;
2584
- enumValues: undefined;
2585
- baseColumn: never;
2586
- identity: undefined;
2587
- generated: undefined;
2588
- }, {}, {}>;
2589
- buy: drizzle_orm_pg_core.PgColumn<{
2590
- name: "buy";
2591
- tableName: "offers";
2592
- dataType: "boolean";
2593
- columnType: "PgBoolean";
2594
- data: boolean;
2595
- driverParam: boolean;
2596
- notNull: true;
2597
- hasDefault: false;
2598
- isPrimaryKey: false;
2599
- isAutoincrement: false;
2600
- hasRuntimeDefault: false;
2601
- enumValues: undefined;
2602
- baseColumn: never;
2603
- identity: undefined;
2604
- generated: undefined;
2605
- }, {}, {}>;
2606
- chainId: drizzle_orm_pg_core.PgColumn<{
2607
- name: "chain_id";
2608
- tableName: "offers";
2609
- dataType: "bigint";
2610
- columnType: "PgBigInt64";
2611
- data: bigint;
2612
- driverParam: string;
2613
- notNull: true;
2614
- hasDefault: false;
2615
- isPrimaryKey: false;
2616
- isAutoincrement: false;
2617
- hasRuntimeDefault: false;
2618
- enumValues: undefined;
2619
- baseColumn: never;
2620
- identity: undefined;
2621
- generated: undefined;
2622
- }, {}, {}>;
2623
- loanToken: drizzle_orm_pg_core.PgColumn<{
2624
- name: "loan_token";
2625
- tableName: "offers";
2626
- dataType: "string";
2627
- columnType: "PgVarchar";
2628
- data: string;
2629
- driverParam: string;
2630
- notNull: true;
2631
- hasDefault: false;
2632
- isPrimaryKey: false;
2633
- isAutoincrement: false;
2634
- hasRuntimeDefault: false;
2635
- enumValues: [string, ...string[]];
2636
- baseColumn: never;
2637
- identity: undefined;
2638
- generated: undefined;
2639
- }, {}, {
2640
- length: 42;
2641
- }>;
2642
- callbackAddress: drizzle_orm_pg_core.PgColumn<{
2643
- name: "callback_address";
2644
- tableName: "offers";
2645
- dataType: "string";
2646
- columnType: "PgVarchar";
2647
- data: string;
2648
- driverParam: string;
2649
- notNull: true;
2650
- hasDefault: false;
2651
- isPrimaryKey: false;
2652
- isAutoincrement: false;
2653
- hasRuntimeDefault: false;
2654
- enumValues: [string, ...string[]];
2655
- baseColumn: never;
2656
- identity: undefined;
2657
- generated: undefined;
2658
- }, {}, {
2659
- length: 42;
2660
- }>;
2661
- callbackData: drizzle_orm_pg_core.PgColumn<{
2662
- name: "callback_data";
2663
- tableName: "offers";
2664
- dataType: "string";
2665
- columnType: "PgText";
2666
- data: string;
2667
- driverParam: string;
2668
- notNull: true;
2669
- hasDefault: false;
2670
- isPrimaryKey: false;
2671
- isAutoincrement: false;
2672
- hasRuntimeDefault: false;
2673
- enumValues: [string, ...string[]];
2674
- baseColumn: never;
2675
- identity: undefined;
2676
- generated: undefined;
2677
- }, {}, {}>;
2678
- callbackGasLimit: drizzle_orm_pg_core.PgColumn<{
2679
- name: "callback_gas_limit";
2680
- tableName: "offers";
2681
- dataType: "bigint";
2682
- columnType: "PgBigInt64";
2683
- data: bigint;
2684
- driverParam: string;
2685
- notNull: true;
2686
- hasDefault: false;
2687
- isPrimaryKey: false;
2688
- isAutoincrement: false;
2689
- hasRuntimeDefault: false;
2690
- enumValues: undefined;
2691
- baseColumn: never;
2692
- identity: undefined;
2693
- generated: undefined;
2694
- }, {}, {}>;
2695
- signature: drizzle_orm_pg_core.PgColumn<{
2696
- name: "signature";
2697
- tableName: "offers";
2698
- dataType: "string";
2699
- columnType: "PgVarchar";
2700
- data: string;
2701
- driverParam: string;
2702
- notNull: false;
2703
- hasDefault: false;
2704
- isPrimaryKey: false;
2705
- isAutoincrement: false;
2706
- hasRuntimeDefault: false;
2707
- enumValues: [string, ...string[]];
2708
- baseColumn: never;
2709
- identity: undefined;
2710
- generated: undefined;
2711
- }, {}, {
2712
- length: 132;
2713
- }>;
2714
- createdAt: drizzle_orm_pg_core.PgColumn<{
2715
- name: "created_at";
2716
- tableName: "offers";
2717
- dataType: "date";
2718
- columnType: "PgTimestamp";
2719
- data: Date;
2720
- driverParam: string;
2721
- notNull: true;
2722
- hasDefault: true;
2723
- isPrimaryKey: false;
2724
- isAutoincrement: false;
2725
- hasRuntimeDefault: false;
2726
- enumValues: undefined;
2727
- baseColumn: never;
2728
- identity: undefined;
2729
- generated: undefined;
2730
- }, {}, {}>;
2731
- blockNumber: drizzle_orm_pg_core.PgColumn<{
2732
- name: "block_number";
2733
- tableName: "offers";
2734
- dataType: "number";
2735
- columnType: "PgBigInt53";
2736
- data: number;
2737
- driverParam: string | number;
2738
- notNull: true;
2739
- hasDefault: false;
2740
- isPrimaryKey: false;
2741
- isAutoincrement: false;
2742
- hasRuntimeDefault: false;
2743
- enumValues: undefined;
2744
- baseColumn: never;
2745
- identity: undefined;
2746
- generated: undefined;
2747
- }, {}, {}>;
2748
- };
2749
- dialect: "pg";
2750
- }>;
2751
- declare const obligationCollaterals: drizzle_orm_pg_core.PgTableWithColumns<{
2752
- name: "obligation_collaterals";
2753
- schema: "router_v1.4";
2754
- columns: {
2755
- obligationId: drizzle_orm_pg_core.PgColumn<{
2756
- name: "obligation_id";
2757
- tableName: "obligation_collaterals";
2758
- dataType: "string";
2759
- columnType: "PgVarchar";
2760
- data: string;
2761
- driverParam: string;
2762
- notNull: true;
2763
- hasDefault: false;
2764
- isPrimaryKey: false;
2765
- isAutoincrement: false;
2766
- hasRuntimeDefault: false;
2767
- enumValues: [string, ...string[]];
2768
- baseColumn: never;
2769
- identity: undefined;
2770
- generated: undefined;
2771
- }, {}, {
2772
- length: 66;
2773
- }>;
2774
- asset: drizzle_orm_pg_core.PgColumn<{
2775
- name: "asset";
2776
- tableName: "obligation_collaterals";
2777
- dataType: "string";
2778
- columnType: "PgVarchar";
2779
- data: string;
2780
- driverParam: string;
2781
- notNull: true;
2782
- hasDefault: false;
2783
- isPrimaryKey: false;
2784
- isAutoincrement: false;
2785
- hasRuntimeDefault: false;
2786
- enumValues: [string, ...string[]];
2787
- baseColumn: never;
2788
- identity: undefined;
2789
- generated: undefined;
2790
- }, {}, {
2791
- length: 42;
2792
- }>;
2793
- oracle: drizzle_orm_pg_core.PgColumn<{
2794
- name: "oracle";
2795
- tableName: "obligation_collaterals";
2796
- dataType: "string";
2797
- columnType: "PgVarchar";
2798
- data: string;
2799
- driverParam: string;
2800
- notNull: true;
2801
- hasDefault: false;
2802
- isPrimaryKey: false;
2803
- isAutoincrement: false;
2804
- hasRuntimeDefault: false;
2805
- enumValues: [string, ...string[]];
2806
- baseColumn: never;
2807
- identity: undefined;
2808
- generated: undefined;
2809
- }, {}, {
2810
- length: 42;
2811
- }>;
2812
- lltv: drizzle_orm_pg_core.PgColumn<{
2813
- name: "lltv";
2814
- tableName: "obligation_collaterals";
2815
- dataType: "bigint";
2816
- columnType: "PgBigInt64";
2817
- data: bigint;
2818
- driverParam: string;
2819
- notNull: true;
2820
- hasDefault: false;
2821
- isPrimaryKey: false;
2822
- isAutoincrement: false;
2823
- hasRuntimeDefault: false;
2824
- enumValues: undefined;
2825
- baseColumn: never;
2826
- identity: undefined;
2827
- generated: undefined;
2828
- }, {}, {}>;
2829
- };
2830
- dialect: "pg";
2831
- }>;
2832
- declare const consumed: drizzle_orm_pg_core.PgTableWithColumns<{
2833
- name: "consumed_per_user_and_nonce";
2834
- schema: "router_v1.4";
2835
- columns: {
2836
- id: drizzle_orm_pg_core.PgColumn<{
2837
- name: "id";
2838
- tableName: "consumed_per_user_and_nonce";
2839
- dataType: "string";
2840
- columnType: "PgVarchar";
2841
- data: string;
2842
- driverParam: string;
2843
- notNull: true;
2844
- hasDefault: false;
2845
- isPrimaryKey: true;
2846
- isAutoincrement: false;
2847
- hasRuntimeDefault: false;
2848
- enumValues: [string, ...string[]];
2849
- baseColumn: never;
2850
- identity: undefined;
2851
- generated: undefined;
2852
- }, {}, {
2853
- length: 255;
2854
- }>;
2855
- chainId: drizzle_orm_pg_core.PgColumn<{
2856
- name: "chain_id";
2857
- tableName: "consumed_per_user_and_nonce";
2858
- dataType: "bigint";
2859
- columnType: "PgBigInt64";
2860
- data: bigint;
2861
- driverParam: string;
2862
- notNull: true;
2863
- hasDefault: false;
2864
- isPrimaryKey: false;
2865
- isAutoincrement: false;
2866
- hasRuntimeDefault: false;
2867
- enumValues: undefined;
2868
- baseColumn: never;
2869
- identity: undefined;
2870
- generated: undefined;
2871
- }, {}, {}>;
2872
- offering: drizzle_orm_pg_core.PgColumn<{
2873
- name: "offering";
2874
- tableName: "consumed_per_user_and_nonce";
2875
- dataType: "string";
2876
- columnType: "PgVarchar";
2877
- data: string;
2878
- driverParam: string;
2879
- notNull: true;
2880
- hasDefault: false;
2881
- isPrimaryKey: false;
2882
- isAutoincrement: false;
2883
- hasRuntimeDefault: false;
2884
- enumValues: [string, ...string[]];
2885
- baseColumn: never;
2886
- identity: undefined;
2887
- generated: undefined;
2888
- }, {}, {
2889
- length: 42;
2890
- }>;
2891
- nonce: drizzle_orm_pg_core.PgColumn<{
2892
- name: "nonce";
2893
- tableName: "consumed_per_user_and_nonce";
2894
- dataType: "bigint";
2895
- columnType: "PgBigInt64";
2896
- data: bigint;
2897
- driverParam: string;
2898
- notNull: true;
2899
- hasDefault: false;
2900
- isPrimaryKey: false;
2901
- isAutoincrement: false;
2902
- hasRuntimeDefault: false;
2903
- enumValues: undefined;
2904
- baseColumn: never;
2905
- identity: undefined;
2906
- generated: undefined;
2907
- }, {}, {}>;
2908
- consumed: drizzle_orm_pg_core.PgColumn<{
2909
- name: "consumed";
2910
- tableName: "consumed_per_user_and_nonce";
2911
- dataType: "string";
2912
- columnType: "PgNumeric";
2913
- data: string;
2914
- driverParam: string;
2915
- notNull: true;
2916
- hasDefault: false;
2917
- isPrimaryKey: false;
2918
- isAutoincrement: false;
2919
- hasRuntimeDefault: false;
2920
- enumValues: undefined;
2921
- baseColumn: never;
2922
- identity: undefined;
2923
- generated: undefined;
2924
- }, {}, {}>;
2925
- blockNumber: drizzle_orm_pg_core.PgColumn<{
2926
- name: "block_number";
2927
- tableName: "consumed_per_user_and_nonce";
2928
- dataType: "number";
2929
- columnType: "PgBigInt53";
2930
- data: number;
2931
- driverParam: string | number;
2932
- notNull: true;
2933
- hasDefault: false;
2934
- isPrimaryKey: false;
2935
- isAutoincrement: false;
2936
- hasRuntimeDefault: false;
2937
- enumValues: undefined;
2938
- baseColumn: never;
2939
- identity: undefined;
2940
- generated: undefined;
2941
- }, {}, {}>;
2942
- createdAt: drizzle_orm_pg_core.PgColumn<{
2943
- name: "created_at";
2944
- tableName: "consumed_per_user_and_nonce";
2945
- dataType: "date";
2946
- columnType: "PgTimestamp";
2947
- data: Date;
2948
- driverParam: string;
2949
- notNull: true;
2950
- hasDefault: true;
2951
- isPrimaryKey: false;
2952
- isAutoincrement: false;
2953
- hasRuntimeDefault: false;
2954
- enumValues: undefined;
2955
- baseColumn: never;
2956
- identity: undefined;
2957
- generated: undefined;
2958
- }, {}, {}>;
2959
- };
2960
- dialect: "pg";
2961
- }>;
2962
- declare const collectors: drizzle_orm_pg_core.PgTableWithColumns<{
2963
- name: "collectors";
2964
- schema: "router_v1.4";
2965
- columns: {
2966
- chainId: drizzle_orm_pg_core.PgColumn<{
2967
- name: "chain_id";
2968
- tableName: "collectors";
2969
- dataType: "bigint";
2970
- columnType: "PgBigInt64";
2971
- data: bigint;
2972
- driverParam: string;
2973
- notNull: true;
2974
- hasDefault: false;
2975
- isPrimaryKey: false;
2976
- isAutoincrement: false;
2977
- hasRuntimeDefault: false;
2978
- enumValues: undefined;
2979
- baseColumn: never;
2980
- identity: undefined;
2981
- generated: undefined;
2982
- }, {}, {}>;
2983
- name: drizzle_orm_pg_core.PgColumn<{
2984
- name: "name";
2985
- tableName: "collectors";
2986
- dataType: "string";
2987
- columnType: "PgText";
2988
- data: "mempool_offers" | "consumed_events" | "buy_with_empty_callback_liquidity" | "buy_vault_v1_callback_liquidity" | "sell_erc20_callback_liquidity";
2989
- driverParam: string;
2990
- notNull: true;
2991
- hasDefault: false;
2992
- isPrimaryKey: false;
2993
- isAutoincrement: false;
2994
- hasRuntimeDefault: false;
2995
- enumValues: [string, ...string[]];
2996
- baseColumn: never;
2997
- identity: undefined;
2998
- generated: undefined;
2999
- }, {}, {
3000
- $type: "mempool_offers" | "consumed_events" | "buy_with_empty_callback_liquidity" | "buy_vault_v1_callback_liquidity" | "sell_erc20_callback_liquidity";
3001
- }>;
3002
- blockNumber: drizzle_orm_pg_core.PgColumn<{
3003
- name: "block_number";
3004
- tableName: "collectors";
3005
- dataType: "number";
3006
- columnType: "PgBigInt53";
3007
- data: number;
3008
- driverParam: string | number;
3009
- notNull: true;
3010
- hasDefault: false;
3011
- isPrimaryKey: false;
3012
- isAutoincrement: false;
3013
- hasRuntimeDefault: false;
3014
- enumValues: undefined;
3015
- baseColumn: never;
3016
- identity: undefined;
3017
- generated: undefined;
3018
- }, {}, {}>;
3019
- epoch: drizzle_orm_pg_core.PgColumn<{
3020
- name: "epoch";
3021
- tableName: "collectors";
3022
- dataType: "string";
3023
- columnType: "PgNumeric";
3024
- data: string;
3025
- driverParam: string;
3026
- notNull: true;
3027
- hasDefault: true;
3028
- isPrimaryKey: false;
3029
- isAutoincrement: false;
3030
- hasRuntimeDefault: false;
3031
- enumValues: undefined;
3032
- baseColumn: never;
3033
- identity: undefined;
3034
- generated: undefined;
3035
- }, {}, {}>;
3036
- updatedAt: drizzle_orm_pg_core.PgColumn<{
3037
- name: "updated_at";
3038
- tableName: "collectors";
3039
- dataType: "date";
3040
- columnType: "PgTimestamp";
3041
- data: Date;
3042
- driverParam: string;
3043
- notNull: true;
3044
- hasDefault: true;
3045
- isPrimaryKey: false;
3046
- isAutoincrement: false;
3047
- hasRuntimeDefault: false;
3048
- enumValues: undefined;
3049
- baseColumn: never;
3050
- identity: undefined;
3051
- generated: undefined;
3052
- }, {}, {}>;
3053
- };
3054
- dialect: "pg";
3055
- }>;
3056
- declare const chains: drizzle_orm_pg_core.PgTableWithColumns<{
3057
- name: "chains";
3058
- schema: "router_v1.4";
3059
- columns: {
3060
- chainId: drizzle_orm_pg_core.PgColumn<{
3061
- name: "chain_id";
3062
- tableName: "chains";
3063
- dataType: "bigint";
3064
- columnType: "PgBigInt64";
3065
- data: bigint;
3066
- driverParam: string;
3067
- notNull: true;
3068
- hasDefault: false;
3069
- isPrimaryKey: false;
3070
- isAutoincrement: false;
3071
- hasRuntimeDefault: false;
3072
- enumValues: undefined;
3073
- baseColumn: never;
3074
- identity: undefined;
3075
- generated: undefined;
3076
- }, {}, {}>;
3077
- blockNumber: drizzle_orm_pg_core.PgColumn<{
3078
- name: "block_number";
3079
- tableName: "chains";
3080
- dataType: "number";
3081
- columnType: "PgBigInt53";
3082
- data: number;
3083
- driverParam: string | number;
3084
- notNull: true;
3085
- hasDefault: false;
3086
- isPrimaryKey: false;
3087
- isAutoincrement: false;
3088
- hasRuntimeDefault: false;
3089
- enumValues: undefined;
3090
- baseColumn: never;
3091
- identity: undefined;
3092
- generated: undefined;
3093
- }, {}, {}>;
3094
- epoch: drizzle_orm_pg_core.PgColumn<{
3095
- name: "epoch";
3096
- tableName: "chains";
3097
- dataType: "string";
3098
- columnType: "PgNumeric";
3099
- data: string;
3100
- driverParam: string;
3101
- notNull: true;
3102
- hasDefault: true;
3103
- isPrimaryKey: false;
3104
- isAutoincrement: false;
3105
- hasRuntimeDefault: false;
3106
- enumValues: undefined;
3107
- baseColumn: never;
3108
- identity: undefined;
3109
- generated: undefined;
3110
- }, {}, {}>;
3111
- updatedAt: drizzle_orm_pg_core.PgColumn<{
3112
- name: "updated_at";
3113
- tableName: "chains";
3114
- dataType: "date";
3115
- columnType: "PgTimestamp";
3116
- data: Date;
3117
- driverParam: string;
3118
- notNull: true;
3119
- hasDefault: true;
3120
- isPrimaryKey: false;
3121
- isAutoincrement: false;
3122
- hasRuntimeDefault: false;
3123
- enumValues: undefined;
3124
- baseColumn: never;
3125
- identity: undefined;
3126
- generated: undefined;
3127
- }, {}, {}>;
3128
- };
3129
- dialect: "pg";
3130
- }>;
3131
- declare const offerLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
3132
- name: "offer_liquidity_pools";
3133
- schema: "router_v1.4";
3134
- columns: {
3135
- offerHash: drizzle_orm_pg_core.PgColumn<{
3136
- name: "offer_hash";
3137
- tableName: "offer_liquidity_pools";
3138
- dataType: "string";
3139
- columnType: "PgVarchar";
3140
- data: string;
3141
- driverParam: string;
3142
- notNull: true;
3143
- hasDefault: false;
3144
- isPrimaryKey: false;
3145
- isAutoincrement: false;
3146
- hasRuntimeDefault: false;
3147
- enumValues: [string, ...string[]];
3148
- baseColumn: never;
3149
- identity: undefined;
3150
- generated: undefined;
3151
- }, {}, {
3152
- length: 66;
3153
- }>;
3154
- poolId: drizzle_orm_pg_core.PgColumn<{
3155
- name: "pool_id";
3156
- tableName: "offer_liquidity_pools";
3157
- dataType: "string";
3158
- columnType: "PgVarchar";
3159
- data: string;
3160
- driverParam: string;
3161
- notNull: true;
3162
- hasDefault: false;
3163
- isPrimaryKey: false;
3164
- isAutoincrement: false;
3165
- hasRuntimeDefault: false;
3166
- enumValues: [string, ...string[]];
3167
- baseColumn: never;
3168
- identity: undefined;
3169
- generated: undefined;
3170
- }, {}, {
3171
- length: 255;
3172
- }>;
3173
- amount: drizzle_orm_pg_core.PgColumn<{
3174
- name: "amount";
3175
- tableName: "offer_liquidity_pools";
3176
- dataType: "string";
3177
- columnType: "PgNumeric";
3178
- data: string;
3179
- driverParam: string;
3180
- notNull: true;
3181
- hasDefault: false;
3182
- isPrimaryKey: false;
3183
- isAutoincrement: false;
3184
- hasRuntimeDefault: false;
3185
- enumValues: undefined;
3186
- baseColumn: never;
3187
- identity: undefined;
3188
- generated: undefined;
3189
- }, {}, {}>;
3190
- updatedAt: drizzle_orm_pg_core.PgColumn<{
3191
- name: "updated_at";
3192
- tableName: "offer_liquidity_pools";
3193
- dataType: "date";
3194
- columnType: "PgTimestamp";
3195
- data: Date;
3196
- driverParam: string;
3197
- notNull: true;
3198
- hasDefault: true;
3199
- isPrimaryKey: false;
3200
- isAutoincrement: false;
3201
- hasRuntimeDefault: false;
3202
- enumValues: undefined;
3203
- baseColumn: never;
3204
- identity: undefined;
3205
- generated: undefined;
3206
- }, {}, {}>;
3207
- };
3208
- dialect: "pg";
3209
- }>;
3210
- declare const liquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
3211
- name: "liquidity_pools";
3212
- schema: "router_v1.4";
3213
- columns: {
3214
- id: drizzle_orm_pg_core.PgColumn<{
3215
- name: "id";
3216
- tableName: "liquidity_pools";
3217
- dataType: "string";
3218
- columnType: "PgVarchar";
3219
- data: string;
3220
- driverParam: string;
3221
- notNull: true;
3222
- hasDefault: false;
3223
- isPrimaryKey: true;
3224
- isAutoincrement: false;
3225
- hasRuntimeDefault: false;
3226
- enumValues: [string, ...string[]];
3227
- baseColumn: never;
3228
- identity: undefined;
3229
- generated: undefined;
3230
- }, {}, {
3231
- length: 255;
3232
- }>;
3233
- amount: drizzle_orm_pg_core.PgColumn<{
3234
- name: "amount";
3235
- tableName: "liquidity_pools";
3236
- dataType: "string";
3237
- columnType: "PgNumeric";
3238
- data: string;
3239
- driverParam: string;
3240
- notNull: true;
3241
- hasDefault: false;
3242
- isPrimaryKey: false;
3243
- isAutoincrement: false;
3244
- hasRuntimeDefault: false;
3245
- enumValues: undefined;
3246
- baseColumn: never;
3247
- identity: undefined;
3248
- generated: undefined;
3249
- }, {}, {}>;
3250
- updatedAt: drizzle_orm_pg_core.PgColumn<{
3251
- name: "updated_at";
3252
- tableName: "liquidity_pools";
3253
- dataType: "date";
3254
- columnType: "PgTimestamp";
3255
- data: Date;
3256
- driverParam: string;
3257
- notNull: true;
3258
- hasDefault: true;
3259
- isPrimaryKey: false;
3260
- isAutoincrement: false;
3261
- hasRuntimeDefault: false;
3262
- enumValues: undefined;
3263
- baseColumn: never;
3264
- identity: undefined;
3265
- generated: undefined;
3266
- }, {}, {}>;
3267
- };
3268
- dialect: "pg";
3269
- }>;
3270
- declare const liquidityLinks: drizzle_orm_pg_core.PgTableWithColumns<{
3271
- name: "liquidity_links";
3272
- schema: "router_v1.4";
3273
- columns: {
3274
- parentPoolId: drizzle_orm_pg_core.PgColumn<{
3275
- name: "parent_pool_id";
3276
- tableName: "liquidity_links";
3277
- dataType: "string";
3278
- columnType: "PgVarchar";
3279
- data: string;
3280
- driverParam: string;
3281
- notNull: true;
3282
- hasDefault: false;
3283
- isPrimaryKey: false;
3284
- isAutoincrement: false;
3285
- hasRuntimeDefault: false;
3286
- enumValues: [string, ...string[]];
3287
- baseColumn: never;
3288
- identity: undefined;
3289
- generated: undefined;
3290
- }, {}, {
3291
- length: 255;
3292
- }>;
3293
- childPoolId: drizzle_orm_pg_core.PgColumn<{
3294
- name: "child_pool_id";
3295
- tableName: "liquidity_links";
3296
- dataType: "string";
3297
- columnType: "PgVarchar";
3298
- data: string;
3299
- driverParam: string;
3300
- notNull: true;
3301
- hasDefault: false;
3302
- isPrimaryKey: false;
3303
- isAutoincrement: false;
3304
- hasRuntimeDefault: false;
3305
- enumValues: [string, ...string[]];
3306
- baseColumn: never;
3307
- identity: undefined;
3308
- generated: undefined;
3309
- }, {}, {
3310
- length: 255;
3311
- }>;
3312
- priority: drizzle_orm_pg_core.PgColumn<{
3313
- name: "priority";
3314
- tableName: "liquidity_links";
3315
- dataType: "number";
3316
- columnType: "PgInteger";
3317
- data: number;
3318
- driverParam: string | number;
3319
- notNull: true;
3320
- hasDefault: false;
3321
- isPrimaryKey: false;
3322
- isAutoincrement: false;
3323
- hasRuntimeDefault: false;
3324
- enumValues: undefined;
3325
- baseColumn: never;
3326
- identity: undefined;
3327
- generated: undefined;
3328
- }, {}, {}>;
3329
- updatedAt: drizzle_orm_pg_core.PgColumn<{
3330
- name: "updated_at";
3331
- tableName: "liquidity_links";
3332
- dataType: "date";
3333
- columnType: "PgTimestamp";
3334
- data: Date;
3335
- driverParam: string;
3336
- notNull: true;
3337
- hasDefault: true;
3338
- isPrimaryKey: false;
3339
- isAutoincrement: false;
3340
- hasRuntimeDefault: false;
3341
- enumValues: undefined;
3342
- baseColumn: never;
3343
- identity: undefined;
3344
- generated: undefined;
3345
- }, {}, {}>;
3346
- };
3347
- dialect: "pg";
3348
- }>;
3349
-
3350
- declare const schema_VERSION: typeof VERSION;
3351
- declare const schema_chains: typeof chains;
3352
- declare const schema_collectors: typeof collectors;
3353
- declare const schema_consumed: typeof consumed;
3354
- declare const schema_liquidityLinks: typeof liquidityLinks;
3355
- declare const schema_liquidityPools: typeof liquidityPools;
3356
- declare const schema_obligationCollaterals: typeof obligationCollaterals;
3357
- declare const schema_obligations: typeof obligations;
3358
- declare const schema_offerLiquidityPools: typeof offerLiquidityPools;
3359
- declare const schema_offers: typeof offers;
3360
- declare namespace schema {
3361
- export { schema_VERSION as VERSION, schema_chains as chains, schema_collectors as collectors, schema_consumed as consumed, schema_liquidityLinks as liquidityLinks, schema_liquidityPools as liquidityPools, schema_obligationCollaterals as obligationCollaterals, schema_obligations as obligations, schema_offerLiquidityPools as offerLiquidityPools, schema_offers as offers };
3362
- }
3363
-
3364
- type Cursor = {
3365
- sort: "rate" | "maturity" | "expiry" | "amount";
3366
- dir: "asc" | "desc";
3367
- rate?: string;
3368
- maturity?: number;
3369
- expiry?: number;
3370
- assets?: string;
3371
- hash: string;
3372
- page?: number;
3373
- };
3374
- declare function validate(cursor: unknown): cursor is Cursor;
3375
- declare function encode(c: Cursor): string;
3376
- declare function decode(token?: string): Cursor | null;
3377
-
3378
- type Cursor$1_Cursor = Cursor;
3379
- declare const Cursor$1_decode: typeof decode;
3380
- declare const Cursor$1_encode: typeof encode;
3381
- declare const Cursor$1_validate: typeof validate;
3382
- declare namespace Cursor$1 {
3383
- export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
3384
- }
3385
-
3386
- declare function max$1(a: bigint, b: bigint): bigint;
3387
- declare function min(a: bigint, b: bigint): bigint;
3388
-
3389
- /**
3390
- * Splits an array into batches of a specified size.
3391
- * @param array The array to split.
3392
- * @param batchSize The size of each batch.
3393
- * @returns An iterator that yields each batch.
3394
- * @example
3395
- * ```typescript
3396
- * const array = [1, 2, 3, 4, 5];
3397
- * for (const batch of batch(array, 2)) {
3398
- * console.log(batch);
3399
- * }
3400
- * // Output:
3401
- * // [1, 2]
3402
- * // [3, 4]
3403
- * // [5]
3404
- * ```
3405
- */
3406
- declare function batch<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;
3407
-
3408
- /**
3409
- * Helper function to execute multicall in batches with retry logic.
3410
- * Abstracts the common pattern of batching calls, retrying, and collecting results.
3411
- *
3412
- * @param parameters - Configuration for batched multicall
3413
- * @returns Promise resolving to flattened array of results
3414
- */
3415
- declare function batchMulticall<TResult>(parameters: {
3416
- client: Pick<PublicActions, "multicall">;
3417
- calls: unknown[];
3418
- batchSize: number;
3419
- retryAttempts: number;
3420
- retryDelayMs: number;
3421
- blockNumber?: bigint;
3422
- }): Promise<TResult[]>;
3423
-
3424
- /**
3425
- * Transform a polling function into an async generator.
3426
- * @param fn - The polling function to transform.
3427
- * @returns An async generator.
3428
- */
3429
- declare function lazy<T>(pollFn: (emit: (value: T) => void, { stop }: {
3430
- stop: () => void;
3431
- }) => () => boolean): () => AsyncGenerator<Awaited<NonNullable<T>>, void, unknown>;
3432
-
3433
- /**
3434
- * Polls a function at a specified interval.
3435
- * Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
3436
- */
3437
- declare function poll<data>(fn: ({ unpoll }: {
3438
- unpoll: () => void;
3439
- }) => Promise<data | undefined>, { interval }: {
3440
- interval: number;
3441
- }): () => boolean;
3442
-
3443
- declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
3444
-
3445
- declare function now(): number;
3446
- declare function max(): number;
3447
-
3448
- declare const time_max: typeof max;
3449
- declare const time_now: typeof now;
3450
- declare namespace time {
3451
- export { time_max as max, time_now as now };
3452
- }
3453
-
3454
- declare function wait(time: number): Promise<unknown>;
3455
-
3456
- type index_BaseError<cause extends Error | undefined = undefined> = BaseError<cause>;
3457
- declare const index_BaseError: typeof BaseError;
3458
- type index_GlobalErrorType<name extends string = "Error"> = GlobalErrorType<name>;
3459
- type index_Snake<T> = Snake<T>;
3460
- declare const index_batch: typeof batch;
3461
- declare const index_batchMulticall: typeof batchMulticall;
3462
- declare const index_lazy: typeof lazy;
3463
- declare const index_min: typeof min;
3464
- declare const index_poll: typeof poll;
3465
- declare const index_retry: typeof retry;
3466
- declare const index_wait: typeof wait;
3467
- declare namespace index {
3468
- export { index_BaseError as BaseError, type index_GlobalErrorType as GlobalErrorType, type index_Snake as Snake, time as Time, index_batch as batch, index_batchMulticall as batchMulticall, fromSnakeCase$3 as fromSnakeCase, index_lazy as lazy, max$1 as max, index_min as min, index_poll as poll, index_retry as retry, toSnakeCase$1 as toSnakeCase, index_wait as wait };
3469
- }
3470
-
3471
- export { Abi, type Brand, BrandTypeId, Callback, Chain$1 as Chain, ChainHealth, ChainStore$1 as ChainStore, ChainsHealthResponse, Collateral$1 as Collateral, index$3 as Collector, CollectorHealth, CollectorStore$1 as CollectorStore, CollectorsHealthResponse, type Compute, Cursor$1 as Cursor, Errors, Format, Health, LLTV$1 as LLTV, Liquidity, LiquidityStore$1 as LiquidityStore, Logger$1 as Logger, Maturity$1 as Maturity, index$1 as Mempool, Obligation$1 as Obligation, ObligationResponse$1 as ObligationResponse, Offer$1 as Offer, OfferResponse$1 as OfferResponse, OfferStore$1 as OfferStore, schema as OffersSchema, OpenApi, PG$1 as PG, Quote$1 as Quote, RouterApi, Client$2 as RouterClient, RouterIndexer, RouterStatusResponse, Services$1 as Services, time as Time, index as Utils, Validation, ValidationRule, parse, safeParse };