@morpho-dev/router 0.1.17 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +34 -24
  2. package/dist/cli.js +3140 -2143
  3. package/dist/cli.js.map +1 -1
  4. package/dist/drizzle/VERSION.ts +3 -0
  5. package/dist/drizzle/drizzle.config.ts +18 -0
  6. package/dist/drizzle/index.ts +2 -0
  7. package/dist/drizzle/{router_v1.4/0000_add_obligation_id.sql → router_v1.5/0000_add_block_number_to_liquidity_graph_and_offer_liquidity_pools_relation.sql} +49 -39
  8. package/dist/drizzle/router_v1.5/0001_create_new_relations_to_prepare_new_liquidity_model.sql +55 -0
  9. package/dist/drizzle/router_v1.5/0002_add_new_offer_status_relation.sql +9 -0
  10. package/dist/drizzle/router_v1.5/0003_insert-status-code.sql +1 -0
  11. package/dist/drizzle/router_v1.5/0004_add_index_for_fast_book_lookup.sql +3 -0
  12. package/dist/drizzle/router_v1.5/0005_add_group_consumed_events_table.sql +12 -0
  13. package/dist/drizzle/router_v1.5/0006_add-trigger-for-consumed-events.sql +58 -0
  14. package/dist/drizzle/router_v1.5/0007_update_index_for_fast_book_lookup.sql +5 -0
  15. package/dist/drizzle/router_v1.5/0008_rename_consumed_events_table.sql +8 -0
  16. package/dist/drizzle/{router_v1.4 → router_v1.5}/meta/0000_snapshot.json +83 -27
  17. package/dist/drizzle/{router_v1.4 → router_v1.5}/meta/0001_snapshot.json +459 -27
  18. package/dist/drizzle/router_v1.5/meta/0002_snapshot.json +1463 -0
  19. package/dist/drizzle/router_v1.5/meta/0003_snapshot.json +1463 -0
  20. package/dist/drizzle/router_v1.5/meta/0004_snapshot.json +1569 -0
  21. package/dist/drizzle/router_v1.5/meta/0005_snapshot.json +1664 -0
  22. package/dist/drizzle/router_v1.5/meta/0006_snapshot.json +1664 -0
  23. package/dist/drizzle/router_v1.5/meta/0007_snapshot.json +1752 -0
  24. package/dist/drizzle/router_v1.5/meta/0008_snapshot.json +1752 -0
  25. package/dist/drizzle/router_v1.5/meta/_journal.json +69 -0
  26. package/dist/drizzle/schema.ts +363 -0
  27. package/dist/index.browser.d.cts +909 -159
  28. package/dist/index.browser.d.ts +909 -159
  29. package/dist/index.browser.js +1529 -1037
  30. package/dist/index.browser.js.map +1 -1
  31. package/dist/index.browser.mjs +1522 -1036
  32. package/dist/index.browser.mjs.map +1 -1
  33. package/dist/index.node.d.cts +2718 -912
  34. package/dist/index.node.d.ts +2718 -912
  35. package/dist/index.node.js +6827 -5521
  36. package/dist/index.node.js.map +1 -1
  37. package/dist/index.node.mjs +6816 -5515
  38. package/dist/index.node.mjs.map +1 -1
  39. package/package.json +21 -17
  40. package/dist/drizzle/router_v1.4/0001_update-primary-key-on-link.sql +0 -3
  41. package/dist/drizzle/router_v1.4/meta/_journal.json +0 -20
@@ -1,12 +1,14 @@
1
- import { Hex, Address, AbiEvent, PublicClient, GetLogsReturnType, WalletClient, PublicActions } from 'viem';
2
- import { Chain as Chain$2 } from 'viem/chains';
3
1
  import { PGlite } from '@electric-sql/pglite';
4
2
  import { drizzle } from 'drizzle-orm/node-postgres';
5
3
  import { drizzle as drizzle$1 } from 'drizzle-orm/pglite';
6
4
  import { Pool } from 'pg';
5
+ import { Hex, Address, AbiEvent, PublicClient, GetLogsReturnType, WalletClient, PublicActions } from 'viem';
6
+ import { Chain as Chain$2 } from 'viem/chains';
7
7
  import * as z from 'zod';
8
+ import { OpenAPIDocument } from 'openapi-metadata';
8
9
  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 { Client as Client$3 } from 'openapi-fetch';
11
+ import { StandardMerkleTree } from '@openzeppelin/merkle-tree';
10
12
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
11
13
 
12
14
  declare const Oracle: readonly [{
@@ -192,7 +194,15 @@ declare enum CallbackType {
192
194
  BuyVaultV1Callback = "buy_vault_v1_callback",
193
195
  SellERC20Callback = "sell_erc20_callback"
194
196
  }
195
- declare const WhitelistedCallbackAddresses: Record<CallbackType, readonly string[]>;
197
+ declare const isEmptyCallback: (offer: Offer) => boolean;
198
+ declare function decode$3(type: CallbackType, data: Hex): {
199
+ vault: Address;
200
+ amount: bigint;
201
+ }[] | {
202
+ collateral: Address;
203
+ amount: bigint;
204
+ }[];
205
+ declare function encode$3(type: CallbackType, data: any): Hex;
196
206
  declare function decodeBuyVaultV1Callback(data: Hex): Array<{
197
207
  vault: Address;
198
208
  amount: bigint;
@@ -212,13 +222,13 @@ declare function encodeSellERC20Callback(parameters: {
212
222
 
213
223
  type Callback_CallbackType = CallbackType;
214
224
  declare const Callback_CallbackType: typeof CallbackType;
215
- declare const Callback_WhitelistedCallbackAddresses: typeof WhitelistedCallbackAddresses;
216
225
  declare const Callback_decodeBuyVaultV1Callback: typeof decodeBuyVaultV1Callback;
217
226
  declare const Callback_decodeSellERC20Callback: typeof decodeSellERC20Callback;
218
227
  declare const Callback_encodeBuyVaultV1Callback: typeof encodeBuyVaultV1Callback;
219
228
  declare const Callback_encodeSellERC20Callback: typeof encodeSellERC20Callback;
229
+ declare const Callback_isEmptyCallback: typeof isEmptyCallback;
220
230
  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 };
231
+ export { Callback_CallbackType as CallbackType, decode$3 as decode, Callback_decodeBuyVaultV1Callback as decodeBuyVaultV1Callback, Callback_decodeSellERC20Callback as decodeSellERC20Callback, encode$3 as encode, Callback_encodeBuyVaultV1Callback as encodeBuyVaultV1Callback, Callback_encodeSellERC20Callback as encodeSellERC20Callback, Callback_isEmptyCallback as isEmptyCallback };
222
232
  }
223
233
 
224
234
  type GlobalErrorType<name extends string = "Error"> = Error & {
@@ -278,7 +288,6 @@ declare const chainIds: Set<bigint>;
278
288
  type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
279
289
  id: Id;
280
290
  name: ChainName;
281
- whitelistedAssets: Set<Address>;
282
291
  morpho: Address;
283
292
  morphoBlue: Address;
284
293
  mempool: {
@@ -286,7 +295,6 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
286
295
  deploymentBlock: number;
287
296
  reindexBuffer: number;
288
297
  };
289
- vaultV1Factory: Record<string, Address>;
290
298
  }>;
291
299
  declare function getChain(chainId: Id): Chain | undefined;
292
300
  declare const getWhitelistedChains: () => Chain[];
@@ -352,8 +360,8 @@ type Options = (typeof Options)[number];
352
360
  * @param lltv - The LLTV option or the scaled LLTV.
353
361
  * @returns The LLTV.
354
362
  */
355
- declare function from$9(lltv: Options | bigint): LLTV;
356
- declare namespace from$9 {
363
+ declare function from$c(lltv: Options | bigint): LLTV;
364
+ declare namespace from$c {
357
365
  type ErrorType = InvalidOptionError$1 | InvalidLLTVError;
358
366
  }
359
367
  declare class InvalidOptionError$1 extends BaseError {
@@ -372,7 +380,7 @@ type LLTV$1_LLTV = LLTV;
372
380
  declare const LLTV$1_LLTVSchema: typeof LLTVSchema;
373
381
  type LLTV$1_Options = Options;
374
382
  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 };
383
+ 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$c as from };
376
384
  }
377
385
 
378
386
  type Collateral = {
@@ -393,8 +401,8 @@ declare const CollateralsSchema: z.ZodArray<z.ZodObject<{
393
401
  oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
394
402
  lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
395
403
  }, z.core.$strip>>;
396
- declare const from$8: (parameters: from$8.Parameters) => from$8.ReturnType;
397
- declare namespace from$8 {
404
+ declare const from$b: (parameters: from$b.Parameters) => from$b.ReturnType;
405
+ declare namespace from$b {
398
406
  type Parameters = {
399
407
  asset: Address;
400
408
  lltv: Options | bigint;
@@ -402,20 +410,39 @@ declare namespace from$8 {
402
410
  };
403
411
  type ReturnType = Collateral;
404
412
  }
413
+ /**
414
+ * Generates a random collateral.
415
+ * @returns A randomly generated collateral. {@link random.ReturnType}
416
+ *
417
+ * @example
418
+ * ```ts
419
+ * const collateral = Collateral.random();
420
+ * ```
421
+ */
422
+ declare function random$3(): random$3.ReturnType;
423
+ declare namespace random$3 {
424
+ type ReturnType = Collateral;
425
+ }
405
426
 
406
427
  type Collateral$1_Collateral = Collateral;
407
428
  declare const Collateral$1_CollateralSchema: typeof CollateralSchema;
408
429
  declare const Collateral$1_CollateralsSchema: typeof CollateralsSchema;
409
430
  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 };
431
+ export { type Collateral$1_Collateral as Collateral, Collateral$1_CollateralSchema as CollateralSchema, Collateral$1_CollateralsSchema as CollateralsSchema, from$b as from, random$3 as random };
411
432
  }
412
433
 
413
434
  /** The snake case representation of a type with bigint values stringified. */
414
- type Snake<T> = SnakeKeys<StringifiedBigint<T>>;
435
+ type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
436
+ /** Make arrays/tuples and object props mutable, deeply. */
437
+ type DeepMutable<T> = T extends (...args: unknown[]) => unknown ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? {
438
+ -readonly [K in keyof R]: DeepMutable<R[K]>;
439
+ } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? {
440
+ -readonly [K in keyof T]: DeepMutable<T[K]>;
441
+ } : T;
415
442
  /** Stringifies bigint values to strings and preserves branded primitives. */
416
443
  type StringifiedBigint<T> = [
417
444
  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 ? {
445
+ ] extends [bigint] ? string : [T] extends [`0x${string}`] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? {
419
446
  [K in keyof T]: StringifiedBigint<T[K]>;
420
447
  } : T;
421
448
  /** Key remapping that also preserves branded primitives. */
@@ -437,10 +464,12 @@ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
437
464
  * @warning Does not unstringify bigint values.
438
465
  */
439
466
  declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
467
+ declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
440
468
 
441
469
  type Format_Snake<T> = Snake<T>;
470
+ declare const Format_stringifyBigint: typeof stringifyBigint;
442
471
  declare namespace Format {
443
- export { type Format_Snake as Snake, fromSnakeCase$3 as fromSnakeCase, toSnakeCase$1 as toSnakeCase };
472
+ export { type Format_Snake as Snake, fromSnakeCase$3 as fromSnakeCase, Format_stringifyBigint as stringifyBigint, toSnakeCase$1 as toSnakeCase };
444
473
  }
445
474
 
446
475
  /**
@@ -448,6 +477,14 @@ declare namespace Format {
448
477
  */
449
478
  type Maturity = number & Brand<"Maturity">;
450
479
  declare const MaturitySchema: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
480
+ declare enum MaturityType {
481
+ EndOfWeek = "end_of_week",
482
+ EndOfNextWeek = "end_of_next_week",
483
+ EndOfMonth = "end_of_month",
484
+ EndOfNextMonth = "end_of_next_month",
485
+ EndOfQuarter = "end_of_quarter",
486
+ EndOfNextQuarter = "end_of_next_quarter"
487
+ }
451
488
  declare const MaturityOptions: {
452
489
  readonly end_of_week: () => Maturity;
453
490
  readonly end_of_next_week: () => Maturity;
@@ -463,8 +500,8 @@ type MaturityOptions = keyof typeof MaturityOptions;
463
500
  * @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
464
501
  * @throws {InvalidOptionError} If the maturity is not a valid option.
465
502
  */
466
- declare function from$7(ts: from$7.Parameters): Maturity;
467
- declare namespace from$7 {
503
+ declare function from$a(ts: from$a.Parameters): Maturity;
504
+ declare namespace from$a {
468
505
  type Parameters = number | MaturityOptions;
469
506
  type ErrorType = InvalidFormatError | InvalidDateError | InvalidOptionError;
470
507
  }
@@ -490,8 +527,10 @@ declare const Maturity$1_InvalidOptionError: typeof InvalidOptionError;
490
527
  type Maturity$1_Maturity = Maturity;
491
528
  type Maturity$1_MaturityOptions = MaturityOptions;
492
529
  declare const Maturity$1_MaturitySchema: typeof MaturitySchema;
530
+ type Maturity$1_MaturityType = MaturityType;
531
+ declare const Maturity$1_MaturityType: typeof MaturityType;
493
532
  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 };
533
+ export { Maturity$1_InvalidDateError as InvalidDateError, Maturity$1_InvalidFormatError as InvalidFormatError, Maturity$1_InvalidOptionError as InvalidOptionError, type Maturity$1_Maturity as Maturity, type Maturity$1_MaturityOptions as MaturityOptions, Maturity$1_MaturitySchema as MaturitySchema, Maturity$1_MaturityType as MaturityType, from$a as from };
495
534
  }
496
535
 
497
536
  type Offer = {
@@ -532,9 +571,15 @@ type Offer = {
532
571
  /** The signature of the offer. */
533
572
  signature?: Hex;
534
573
  };
574
+ declare enum StatusCode {
575
+ VALID = "VALID",
576
+ NOT_ENOUGH_LIQUIDITY = "NOT_ENOUGH_LIQUIDITY"
577
+ }
535
578
  declare const OfferHashSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
536
579
  declare const OfferSchema: (parameters?: {
537
580
  omitHash?: boolean;
581
+ omitConsumed?: boolean;
582
+ omitBlockNumber?: boolean;
538
583
  }) => z.ZodObject<{
539
584
  offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
540
585
  assets: z.ZodBigInt;
@@ -556,8 +601,6 @@ declare const OfferSchema: (parameters?: {
556
601
  data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
557
602
  gasLimit: z.ZodBigInt;
558
603
  }, z.core.$strip>;
559
- consumed: z.ZodBigInt;
560
- blockNumber: z.ZodNumber;
561
604
  signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
562
605
  }, z.core.$strip>;
563
606
  /**
@@ -566,8 +609,8 @@ declare const OfferSchema: (parameters?: {
566
609
  * @param input - The offer to create.
567
610
  * @returns The created offer with its hash.
568
611
  */
569
- declare function from$6(input: Omit<Offer, "hash">): Offer;
570
- declare namespace from$6 {
612
+ declare function from$9(input: Omit<Offer, "hash">): Offer;
613
+ declare namespace from$9 {
571
614
  type ErrorType = InvalidOfferError;
572
615
  }
573
616
  /**
@@ -583,14 +626,35 @@ declare function fromSnakeCase$2(input: Snake<Omit<Offer, "hash">>): Offer;
583
626
  * @returns The converted offer.
584
627
  */
585
628
  declare function toSnakeCase(offer: Offer): Snake<Offer>;
629
+ type RandomConfig = {
630
+ chains?: Chain[];
631
+ loanTokens?: Address[];
632
+ collateralTokens?: Address[];
633
+ assetsDecimals?: Record<Address, number>;
634
+ buy?: boolean;
635
+ assets?: bigint;
636
+ consumed?: bigint;
637
+ offering?: Address;
638
+ maturity?: Maturity;
639
+ start?: number;
640
+ expiry?: number;
641
+ nonce?: bigint;
642
+ rate?: bigint;
643
+ callback?: {
644
+ address: Address;
645
+ data: Hex;
646
+ gasLimit: bigint;
647
+ };
648
+ collaterals?: readonly Collateral[];
649
+ signature?: Hex;
650
+ };
586
651
  /**
587
652
  * Generates a random Offer.
588
- * The returned Offer contains randomly generated values for most fields, such as assets, rate, nonce, and buy flag.
589
- * Some fields use fixed or deterministic values (e.g., chainId, collaterals, callback).
653
+ * The returned Offer contains randomly generated values.
590
654
  * @warning The generated Offer should not be used for production usage.
591
655
  * @returns {Offer} A randomly generated Offer object.
592
656
  */
593
- declare function random$2(): Offer;
657
+ declare function random$2(config?: RandomConfig): Offer;
594
658
  /**
595
659
  * Creates an EIP-712 domain object.
596
660
  * @param chainId - The chain ID.
@@ -666,13 +730,14 @@ declare const types: {
666
730
  }];
667
731
  };
668
732
  /**
669
- * Signs an offer.
733
+ * Signs an array of offers.
670
734
  * @throws {Error} If the wallet account is not set.
671
- * @param offer - The offer to sign.
672
- * @param wallet - The wallet to sign the offer with.
673
- * @returns The signed offer.
735
+ * @param offers - The offers to sign.
736
+ * @param wallet - The wallet to sign the offers with.
737
+ * @returns The signed offers.
674
738
  */
675
- declare function sign(offer: Offer, wallet: WalletClient): Promise<Hex>;
739
+ declare function sign(offers: Offer[], wallet: WalletClient): Promise<Hex>;
740
+ declare function signatureMsg(offers: Offer[]): Hex;
676
741
  declare function hash(offer: Omit<Offer, "hash">): Hex;
677
742
  /**
678
743
  * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
@@ -681,8 +746,8 @@ declare function hash(offer: Omit<Offer, "hash">): Hex;
681
746
  * @returns The obligation id as a 32-byte hex string.
682
747
  */
683
748
  declare function obligationId(offer: Offer): Hex;
684
- declare function encode$1(offer: Offer): `0x${string}`;
685
- declare function decode$1(data: Hex, blockNumber: number | bigint): Offer;
749
+ declare function encode$2(offer: Offer): `0x${string}`;
750
+ declare function decode$2(data: Hex, blockNumber: number | bigint): Offer;
686
751
  type OfferConsumed = {
687
752
  id: string;
688
753
  chainId: bigint;
@@ -741,16 +806,20 @@ type Offer$1_Offer = Offer;
741
806
  type Offer$1_OfferConsumed = OfferConsumed;
742
807
  declare const Offer$1_OfferHashSchema: typeof OfferHashSchema;
743
808
  declare const Offer$1_OfferSchema: typeof OfferSchema;
809
+ type Offer$1_RandomConfig = RandomConfig;
810
+ type Offer$1_StatusCode = StatusCode;
811
+ declare const Offer$1_StatusCode: typeof StatusCode;
744
812
  declare const Offer$1_consumedEvent: typeof consumedEvent;
745
813
  declare const Offer$1_domain: typeof domain;
746
814
  declare const Offer$1_fromConsumedLog: typeof fromConsumedLog;
747
815
  declare const Offer$1_hash: typeof hash;
748
816
  declare const Offer$1_obligationId: typeof obligationId;
749
817
  declare const Offer$1_sign: typeof sign;
818
+ declare const Offer$1_signatureMsg: typeof signatureMsg;
750
819
  declare const Offer$1_toSnakeCase: typeof toSnakeCase;
751
820
  declare const Offer$1_types: typeof types;
752
821
  declare namespace Offer$1 {
753
- 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, 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 };
822
+ export { Offer$1_AccountNotSetError as AccountNotSetError, Offer$1_InvalidOfferError as InvalidOfferError, type Offer$1_Offer as Offer, type Offer$1_OfferConsumed as OfferConsumed, Offer$1_OfferHashSchema as OfferHashSchema, Offer$1_OfferSchema as OfferSchema, type Offer$1_RandomConfig as RandomConfig, Offer$1_StatusCode as StatusCode, Offer$1_consumedEvent as consumedEvent, decode$2 as decode, Offer$1_domain as domain, encode$2 as encode, from$9 as from, Offer$1_fromConsumedLog as fromConsumedLog, fromSnakeCase$2 as fromSnakeCase, Offer$1_hash as hash, Offer$1_obligationId as obligationId, random$2 as random, Offer$1_sign as sign, Offer$1_signatureMsg as signatureMsg, Offer$1_toSnakeCase as toSnakeCase, Offer$1_types as types };
754
823
  }
755
824
 
756
825
  /**
@@ -930,17 +999,17 @@ declare const ObligationSchema: z.ZodObject<{
930
999
  * });
931
1000
  * ```
932
1001
  */
933
- declare function from$5(parameters: from$5.Parameters): from$5.ReturnType;
934
- declare namespace from$5 {
1002
+ declare function from$8(parameters: from$8.Parameters): from$8.ReturnType;
1003
+ declare namespace from$8 {
935
1004
  type Parameters = {
936
1005
  /** The chain id where the liquidity for this obligation is located. */
937
1006
  chainId: Id;
938
1007
  /** The token that is being borrowed for this obligation. */
939
1008
  loanToken: Address;
940
1009
  /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
941
- collaterals: from$8.Parameters[] | readonly from$8.Parameters[];
1010
+ collaterals: from$b.Parameters[] | readonly from$b.Parameters[];
942
1011
  /** The maturity of the obligation. */
943
- maturity: from$7.Parameters;
1012
+ maturity: from$a.Parameters;
944
1013
  };
945
1014
  type ReturnType = Obligation;
946
1015
  type ErrorType = InvalidObligationError;
@@ -1007,7 +1076,7 @@ type Obligation$1_Obligation = Obligation;
1007
1076
  declare const Obligation$1_ObligationSchema: typeof ObligationSchema;
1008
1077
  declare const Obligation$1_id: typeof id;
1009
1078
  declare namespace Obligation$1 {
1010
- 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 };
1079
+ export { Obligation$1_CollateralsAreNotSortedError as CollateralsAreNotSortedError, Obligation$1_InvalidObligationError as InvalidObligationError, type Obligation$1_Obligation as Obligation, Obligation$1_ObligationSchema as ObligationSchema, from$8 as from, fromSnakeCase$1 as fromSnakeCase, Obligation$1_id as id, random$1 as random };
1011
1080
  }
1012
1081
 
1013
1082
  type Quote = {
@@ -1043,8 +1112,8 @@ declare const QuoteSchema: z.ZodObject<{
1043
1112
  * const quote = Quote.from({ obligationId: "0x123", ask: { assets: 100n, rate: 100n }, bid: { assets: 100n, rate: 100n } });
1044
1113
  * ```
1045
1114
  */
1046
- declare function from$4(parameters: from$4.Parameters): from$4.ReturnType;
1047
- declare namespace from$4 {
1115
+ declare function from$7(parameters: from$7.Parameters): from$7.ReturnType;
1116
+ declare namespace from$7 {
1048
1117
  type Parameters = Quote;
1049
1118
  type ReturnType = Quote;
1050
1119
  type ErrorType = InvalidQuoteError;
@@ -1059,7 +1128,7 @@ declare function fromSnakeCase(snake: fromSnakeCase.Parameters): fromSnakeCase.R
1059
1128
  declare namespace fromSnakeCase {
1060
1129
  type Parameters = Snake<Quote>;
1061
1130
  type ReturnType = Quote;
1062
- type ErrorType = from$4.ErrorType;
1131
+ type ErrorType = from$7.ErrorType;
1063
1132
  }
1064
1133
  /**
1065
1134
  * Generates a random quote.
@@ -1074,7 +1143,7 @@ declare function random(): random.ReturnType;
1074
1143
  declare namespace random {
1075
1144
  type Parameters = never;
1076
1145
  type ReturnType = Quote;
1077
- type ErrorType = from$4.ErrorType;
1146
+ type ErrorType = from$7.ErrorType;
1078
1147
  }
1079
1148
  declare class InvalidQuoteError extends BaseError<z.ZodError | Error> {
1080
1149
  readonly name = "Quote.InvalidQuoteError";
@@ -1088,19 +1157,51 @@ declare const Quote$1_QuoteSchema: typeof QuoteSchema;
1088
1157
  declare const Quote$1_fromSnakeCase: typeof fromSnakeCase;
1089
1158
  declare const Quote$1_random: typeof random;
1090
1159
  declare namespace Quote$1 {
1091
- 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 };
1160
+ export { Quote$1_InvalidQuoteError as InvalidQuoteError, type Quote$1_Quote as Quote, Quote$1_QuoteSchema as QuoteSchema, from$7 as from, Quote$1_fromSnakeCase as fromSnakeCase, Quote$1_random as random };
1092
1161
  }
1093
1162
 
1094
- type Indexer = {
1095
- start: () => () => void;
1096
- };
1097
- declare function create$7(params: {
1098
- collectors: Collector[];
1099
- }): Indexer;
1163
+ type Tree = Compute<StandardMerkleTree<[Hex]> & {
1164
+ offers: Offer[];
1165
+ root: Hex;
1166
+ }>;
1167
+ declare const VERSION$1 = 1;
1168
+ /**
1169
+ * Builds a Merkle tree from a list of offers.
1170
+ *
1171
+ * Leaves are the offer `hash` values as `bytes32` and are deterministically
1172
+ * ordered in ascending lexicographic order so that the resulting root is stable
1173
+ * regardless of the input order.
1174
+ *
1175
+ * @param offers - Offers to include in the tree.
1176
+ * @returns A `StandardMerkleTree` of `bytes32` leaves representing the offers.
1177
+ */
1178
+ declare const from$6: (offers: Offer[]) => Tree;
1179
+ /**
1180
+ * Encodes an `Tree` into a Hex string with a version byte prefix and gzipped payload.
1181
+ *
1182
+ * - Layout: `0x{vv}{zip...}` where `{vv}` is one-byte version as two hex chars.
1183
+ * - Payload is gzip(JSON.stringify([root, ...offers])) with bigint stringified.
1184
+ *
1185
+ * @param tree - The offer Merkle tree to encode.
1186
+ * @returns Hex string starting with `0x{vv}` followed by gzipped payload bytes.
1187
+ * @throws Error if the given `root` does not match the offers.
1188
+ */
1189
+ declare const encode$1: (tree: Tree) => Hex;
1190
+ /**
1191
+ * Decodes a Hex string produced by {@link encode} back into an `Tree`.
1192
+ *
1193
+ * - Ensures the first byte version matches {@link VERSION}.
1194
+ * - Decompresses with gunzip, parses JSON, validates offers, and re-checks the root.
1195
+ *
1196
+ * @param encoded - Hex string in the form `0x{vv}{zip...}`.
1197
+ * @returns A validated `Tree` rebuilt from the offers.
1198
+ * @throws Error if the version is invalid or the root does not match the offers.
1199
+ */
1200
+ declare const decode$1: (encoded: Hex) => Tree;
1100
1201
 
1101
- type RouterIndexer_Indexer = Indexer;
1102
- declare namespace RouterIndexer {
1103
- export { type RouterIndexer_Indexer as Indexer, create$7 as create };
1202
+ type Tree$1_Tree = Tree;
1203
+ declare namespace Tree$1 {
1204
+ export { type Tree$1_Tree as Tree, VERSION$1 as VERSION, decode$1 as decode, encode$1 as encode, from$6 as from };
1104
1205
  }
1105
1206
 
1106
1207
  type PgDB = ReturnType<typeof drizzle> & {
@@ -1112,7 +1213,7 @@ type PGLiteDB = ReturnType<typeof drizzle$1> & {
1112
1213
  pool: PGlite;
1113
1214
  };
1114
1215
  type PG = PgDB | PGLiteDB;
1115
- declare function connect$1(parameters: {
1216
+ declare function connect$2(parameters: {
1116
1217
  type: "pg";
1117
1218
  endpoint: string;
1118
1219
  } | {
@@ -1127,7 +1228,7 @@ type PG$1_PgDB = PgDB;
1127
1228
  declare const PG$1_applyMigrations: typeof applyMigrations;
1128
1229
  declare const PG$1_clean: typeof clean;
1129
1230
  declare namespace PG$1 {
1130
- 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$1 as connect };
1231
+ 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 };
1131
1232
  }
1132
1233
 
1133
1234
  type ChainStore = {
@@ -1153,142 +1254,50 @@ type ChainStore = {
1153
1254
  }) => Promise<void>;
1154
1255
  };
1155
1256
  /** Postgres implementation. */
1156
- declare const create$6: (config: {
1257
+ declare const create$8: (config: {
1157
1258
  db: PG;
1158
1259
  }) => ChainStore;
1159
1260
 
1160
1261
  type ChainStore$1_ChainStore = ChainStore;
1161
1262
  declare namespace ChainStore$1 {
1162
- export { type ChainStore$1_ChainStore as ChainStore, create$6 as create };
1163
- }
1164
-
1165
- type CollectorStore = {
1166
- /** Get the latest block number processed by a collector for a given chain alongside the epoch. */
1167
- getBlockNumber: (parameters: {
1168
- collectorName: Name;
1169
- chainId: Id;
1170
- }) => Promise<{
1171
- blockNumber: number;
1172
- epoch: bigint;
1173
- }>;
1174
- /**
1175
- * Get the latest block number processed by all collectors.
1176
- * When a chainId is provided the result is filtered, otherwise all records are returned.
1177
- */
1178
- getBlockNumbers: (parameters?: {
1179
- chainId?: Id;
1180
- }) => Promise<Array<{
1181
- collectorName: Name;
1182
- chainId: Id;
1183
- blockNumber: number;
1184
- epoch: bigint;
1185
- updatedAt: Date;
1186
- }>>;
1187
- /** Save the latest block number processed by a collector for a given chain.*/
1188
- saveBlockNumber: (parameters: {
1189
- collectorName: Name;
1190
- chainId: Id;
1191
- blockNumber: number;
1192
- epoch: bigint;
1193
- }) => Promise<void>;
1194
- };
1195
- /** Postgres implementation. */
1196
- declare const create$5: (config: {
1197
- db: PG;
1198
- }) => CollectorStore;
1199
-
1200
- type CollectorStore$1_CollectorStore = CollectorStore;
1201
- declare namespace CollectorStore$1 {
1202
- export { type CollectorStore$1_CollectorStore as CollectorStore, create$5 as create };
1263
+ export { type ChainStore$1_ChainStore as ChainStore, create$8 as create };
1203
1264
  }
1204
1265
 
1205
- type LiquidityStore = {
1206
- /**
1207
- * Get all liquidity pools.
1208
- * @returns Array of all liquidity pools
1209
- */
1210
- getAllPools: () => Promise<LiquidityPool[]>;
1211
- /**
1212
- * Get all liquidity links.
1213
- * @returns Array of all liquidity links
1266
+ type OfferStoreV2 = {
1267
+ /** Create multiple offer. */
1268
+ create: (offers: Offer[]) => Promise<Hex[]>;
1269
+ /** Delete multiple offers by hashes or block number greater than or equal to the given value.
1270
+ * @returns the number of offers deleted.
1214
1271
  */
1215
- getAllLinks: () => Promise<LiquidityLink[]>;
1216
- /**
1217
- * Get all offer-pool mappings.
1218
- * @returns Array of all offer liquidity pools
1219
- */
1220
- getAllOfferPools: () => Promise<OfferLiquidityPool[]>;
1221
- /**
1222
- * Save or update liquidity data.
1223
- * Accepts flat arrays of pools, links, and offer-pool mappings.
1224
- *
1225
- * Automatically cleans up stale links: for each parent pool being updated,
1226
- * deletes any existing links with priority greater than the maximum priority
1227
- * in the new links. This ensures that when priority-ordered relationships
1228
- * shrink, old links are removed.
1229
- *
1230
- * @param parameters - Object containing arrays of pools, links, and offerPools
1231
- */
1232
- save: (parameters: {
1233
- pools: LiquidityPool[];
1234
- links: LiquidityLink[];
1235
- offerPools: OfferLiquidityPool[];
1236
- }) => Promise<void>;
1237
- };
1238
- /** Postgres implementation. */
1239
- declare const create$4: (config: {
1240
- db: PG;
1241
- }) => LiquidityStore;
1242
-
1243
- type LiquidityStore$1_LiquidityStore = LiquidityStore;
1244
- declare namespace LiquidityStore$1 {
1245
- export { type LiquidityStore$1_LiquidityStore as LiquidityStore, create$4 as create };
1246
- }
1247
-
1248
- /**
1249
- * The `OfferStore` is responsible for managing offer-related data.
1250
- */
1251
- type OfferStore = {
1252
- /** Create a single offer. */
1253
- create: (parameters: {
1254
- offer: Offer;
1255
- }) => Promise<string>;
1256
- /** Create multiple offers. */
1257
- createMany: (parameters: {
1258
- offer: Offer;
1259
- }[]) => Promise<string[]>;
1260
- /** Get all offers with optional filtering, sorting, and pagination. */
1261
- getAll: (params?: GetAllParams) => Promise<{
1272
+ delete: (parameters: {
1273
+ hashes: Hex[];
1274
+ } | {
1275
+ blockNumberGte: number;
1276
+ }) => Promise<number>;
1277
+ /** Get all offers. */
1278
+ get: (parameters?: PaginationParams) => Promise<{
1262
1279
  offers: Offer[];
1263
1280
  nextCursor: string | null;
1264
1281
  }>;
1265
- /** Find offers that match the specified parameters, with cursor pagination. */
1266
- findMatchingOffers: (params: FindMatchingOffersParams & {
1267
- implementation?: "nodejs" | "sql";
1268
- }) => Promise<{
1282
+ /** Get all offers for a given obligation side. */
1283
+ getBook: (parameters: GetBookParams) => Promise<{
1269
1284
  offers: Offer[];
1270
1285
  nextCursor: string | null;
1271
- implementation?: "nodejs" | "sql";
1272
1286
  }>;
1273
- /** Delete an offer by hash. */
1274
- delete: (hash: Offer["hash"]) => Promise<boolean>;
1275
- /** Delete multiple offers by hashes. */
1276
- deleteMany: (hashes: Offer["hash"][]) => Promise<number>;
1277
- /** Delete multiple offers by block number greater than or equal to the given value. */
1278
- deleteManyByBlockNumberGte: (blockNumberGte: number) => Promise<number>;
1279
- /** Update the consumed amount for a set of offers with the same chainId, offering, and nonce. */
1280
- updateConsumedAmount: (parameters: {
1281
- id: string;
1282
- chainId: Offer["chainId"];
1283
- offering: Offer["offering"];
1284
- nonce: Offer["nonce"];
1285
- consumed: bigint;
1287
+ /** Create a new consumed event for a set of offers with the same chainId, offering, and nonce. */
1288
+ createConsumedEvent: (parameters: {
1289
+ eventId: string;
1290
+ chainId: Id;
1291
+ offering: Address;
1292
+ group: bigint;
1293
+ amount: bigint;
1286
1294
  blockNumber: number;
1287
1295
  }) => Promise<void>;
1288
- /** Delete multiple consumed amounts by block number greater than or equal to the given value. */
1289
- deleteManyConsumedAmountsByBlockNumberGte: (blockNumberGte: number) => Promise<number>;
1290
- /** Get all obligations */
1291
- getAllObligations: (parameters?: {
1296
+ /** Delete multiple consumed events by block number greater than or equal to the given value. */
1297
+ deleteConsumedEvents: (blockNumberGte: number) => Promise<number>;
1298
+ /** Get obligations */
1299
+ getObligations: (parameters?: {
1300
+ ids?: Hex[];
1292
1301
  cursor?: string;
1293
1302
  limit?: number;
1294
1303
  }) => Promise<{
@@ -1300,107 +1309,197 @@ type OfferStore = {
1300
1309
  obligationIds: Hex[];
1301
1310
  }) => Promise<Quote[]>;
1302
1311
  };
1303
- type GetOffersFilters = {
1304
- creators?: string[];
1305
- side?: "buy" | "sell";
1306
- chains?: number[];
1307
- loanTokens?: string[];
1308
- callbackAddresses?: string[];
1309
- minAmount?: bigint;
1310
- maxAmount?: bigint;
1311
- minRate?: bigint;
1312
- maxRate?: bigint;
1313
- minMaturity?: number;
1314
- maxMaturity?: number;
1315
- minExpiry?: number;
1316
- maxExpiry?: number;
1317
- collateralAssets?: string[];
1318
- collateralOracles?: string[];
1319
- collateralTuple?: Array<{
1320
- asset: string;
1321
- oracle?: string;
1322
- lltv?: LLTV;
1323
- }>;
1324
- minLltv?: number;
1325
- maxLltv?: number;
1326
- sortBy?: "rate" | "maturity" | "expiry" | "amount";
1327
- sortOrder?: "asc" | "desc";
1312
+ type PaginationParams = {
1313
+ /** Cursor string returned by a previous call, for pagination */
1328
1314
  cursor?: string;
1315
+ /** Page size; defaults to {@link DEFAULT_LIMIT} */
1329
1316
  limit?: number;
1330
1317
  };
1331
- type FindMatchingOffersParams = {
1318
+ type GetBookParams = Compute<{
1332
1319
  /** The side of the offer. */
1333
1320
  side: "buy" | "sell";
1334
1321
  /** The obligationId of the offer. */
1335
1322
  obligationId: Hex;
1336
- /** Cursor string returned by a previous call, for pagination */
1337
- cursor?: string;
1338
- /** Page size; defaults to 20 */
1339
- limit?: number;
1340
- };
1341
- type GetAllParams = {
1342
- query?: GetOffersFilters;
1343
- };
1344
- type PgConfig = {
1345
- /** The database instance to use for operations. */
1346
- db: PG;
1347
- };
1348
- declare function create$3(config: PgConfig): OfferStore;
1349
-
1350
- type OfferStore$1_FindMatchingOffersParams = FindMatchingOffersParams;
1351
- type OfferStore$1_GetAllParams = GetAllParams;
1352
- type OfferStore$1_GetOffersFilters = GetOffersFilters;
1353
- type OfferStore$1_OfferStore = OfferStore;
1354
- type OfferStore$1_PgConfig = PgConfig;
1355
- declare namespace OfferStore$1 {
1356
- 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 };
1357
- }
1323
+ } & PaginationParams>;
1358
1324
 
1359
- type ServicesConfig = {
1360
- chain: Chain;
1361
- rpcUrl: string;
1362
- dbConfig: {
1363
- type: "pg" | "pglite";
1364
- endpoint?: string;
1365
- };
1366
- collectorConfig?: {
1367
- interval?: number;
1368
- maxBatchSize?: number;
1369
- maxBlockNumber?: number;
1370
- };
1325
+ type CollectorHealthStatus = "live" | "lagging" | "unknown";
1326
+ type RouterStatus = "live" | "syncing";
1327
+ type CollectorHealth$1 = {
1328
+ name: Name;
1329
+ chainId: Id;
1330
+ blockNumber: number | null;
1331
+ updatedAt: string | null;
1332
+ lag: number | null;
1333
+ status: CollectorHealthStatus;
1371
1334
  };
1372
- type Services = {
1373
- indexer: Indexer;
1374
- offerStore: OfferStore;
1375
- collectorStore: CollectorStore;
1376
- liquidityStore: LiquidityStore;
1377
- chainStore: ChainStore;
1378
- healthService: HealthService;
1379
- mempoolOffersCollector: Collector<"mempool_offers">;
1380
- consumedEventsCollector: Collector<"consumed_events">;
1381
- buyWithEmptyCallbackLiquidityCollector: Collector<"buy_with_empty_callback_liquidity">;
1382
- buyVaultV1CallbackLiquidityCollector: Collector<"buy_vault_v1_callback_liquidity">;
1383
- sellERC20CallbackLiquidityCollector: Collector<"sell_erc20_callback_liquidity">;
1384
- DB: PG;
1385
- routerApi: RouterApi$1;
1335
+ type ChainHealth$1 = {
1336
+ chainId: Id;
1337
+ blockNumber: number;
1338
+ epoch: string;
1339
+ updatedAt: string;
1386
1340
  };
1387
- declare function from$3(config: ServicesConfig): Services;
1388
- type Stores = ReturnType<typeof createStores>;
1389
- declare function createStores(db: PG): {
1341
+ type HealthService = {
1342
+ getStatus: () => Promise<RouterStatus>;
1343
+ getCollectors: () => Promise<CollectorHealth$1[]>;
1344
+ getChains: () => Promise<ChainHealth$1[]>;
1345
+ };
1346
+ type HealthServiceParameters = {
1390
1347
  collectorStore: CollectorStore;
1391
- offerStore: OfferStore;
1392
- liquidityStore: LiquidityStore;
1393
1348
  chainStore: ChainStore;
1349
+ /** Maximum number of blocks a collector can lag behind its chain before being considered lagging. */
1350
+ maxAllowedLag?: number;
1394
1351
  };
1395
- declare function createWithTransaction<T>(db: PG): (fn: (s: ReturnType<typeof createStores>) => Promise<T>) => Promise<T>;
1396
-
1352
+ /**
1353
+ * Create a health service that exposes collector and chain block numbers.
1354
+ */
1355
+ declare function create$7(parameters: HealthServiceParameters): HealthService;
1356
+
1357
+ type Health_CollectorHealthStatus = CollectorHealthStatus;
1358
+ type Health_HealthService = HealthService;
1359
+ type Health_HealthServiceParameters = HealthServiceParameters;
1360
+ type Health_RouterStatus = RouterStatus;
1361
+ declare namespace Health {
1362
+ 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$7 as create };
1363
+ }
1364
+
1365
+ /**
1366
+ * A validation rule.
1367
+ */
1368
+ type Rule<T, Name extends string = string> = {
1369
+ kind: "single";
1370
+ name: Name;
1371
+ run: Single<T, Name>;
1372
+ } | {
1373
+ kind: "batch";
1374
+ name: Name;
1375
+ run: Batch<T, Name>;
1376
+ };
1377
+ type RuleNames<Rules extends readonly {
1378
+ name: string;
1379
+ }[]> = Rules[number]["name"];
1380
+ /**
1381
+ * A single item validation rule.
1382
+ * @param item - The item to validate.
1383
+ * @returns The issue that was found. If the item is valid, this will be undefined.
1384
+ */
1385
+ type Single<T, RuleName extends string> = (item: T) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
1386
+ /**
1387
+ * A batch item validation rule.
1388
+ * @param items - The items to validate.
1389
+ * @returns A map of the items to the issue that was found.
1390
+ */
1391
+ type Batch<T, RuleName extends string> = (items: T[]) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
1392
+ /**
1393
+ * Create a validation rule iterating over a single item at a time.
1394
+ * @param name - The name of the rule.
1395
+ * @param run - The function that validates the rule.
1396
+ * @returns The created rule.
1397
+ */
1398
+ declare function single<Name extends string, T>(name: Name, run: Single<T, Name>): Rule<T, Name>;
1399
+ /**
1400
+ * Create a validation rule iterating over a batch of items at a time.
1401
+ * @param name - The name of the rule.
1402
+ * @param run - The function that validates the rule.
1403
+ * @returns The created rule.
1404
+ */
1405
+ declare function batch$1<Name extends string, T>(name: Name, run: Batch<T, Name>): Rule<T, Name>;
1406
+ /**
1407
+ * A validation issue.
1408
+ */
1409
+ type Issue<T, RuleName extends string = string> = {
1410
+ /** The name of the rule that caused the issue. */
1411
+ ruleName: RuleName;
1412
+ /** The message of the issue. */
1413
+ message: string;
1414
+ /** The item that was not valid. */
1415
+ item: T;
1416
+ };
1417
+ /**
1418
+ * The result of a validation.
1419
+ */
1420
+ type Result<T, RuleName extends string = string> = {
1421
+ /** The items that were valid. */
1422
+ valid: T[];
1423
+ /** The reports of the failed validations. */
1424
+ issues: Issue<T, RuleName>[];
1425
+ };
1426
+ declare function run<T, Name extends string, Rules extends readonly Rule<T, Name>[]>(parameters: {
1427
+ items: T[];
1428
+ rules: Rules;
1429
+ chunkSize?: number;
1430
+ }): Promise<Result<T, RuleNames<Rules>>>;
1431
+
1432
+ type Gate_Batch<T, RuleName extends string> = Batch<T, RuleName>;
1433
+ type Gate_Issue<T, RuleName extends string = string> = Issue<T, RuleName>;
1434
+ type Gate_Result<T, RuleName extends string = string> = Result<T, RuleName>;
1435
+ type Gate_Rule<T, Name extends string = string> = Rule<T, Name>;
1436
+ type Gate_RuleNames<Rules extends readonly {
1437
+ name: string;
1438
+ }[]> = RuleNames<Rules>;
1439
+ type Gate_Single<T, RuleName extends string> = Single<T, RuleName>;
1440
+ declare const Gate_run: typeof run;
1441
+ declare const Gate_single: typeof single;
1442
+ declare namespace Gate {
1443
+ export { type Gate_Batch as Batch, type Gate_Issue as Issue, type Gate_Result as Result, type Gate_Rule as Rule, type Gate_RuleNames as RuleNames, type Gate_Single as Single, batch$1 as batch, Gate_run as run, Gate_single as single };
1444
+ }
1445
+
1446
+ type Rules$1 = readonly Rule<Offer, string>[];
1447
+ type Gatekeeper = {
1448
+ isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
1449
+ };
1450
+ type GatekeeperParameters = {
1451
+ rules: Rules$1;
1452
+ };
1453
+ declare function create$6(parameters: GatekeeperParameters): Gatekeeper;
1454
+
1455
+ type Gatekeeper$1_Gatekeeper = Gatekeeper;
1456
+ declare namespace Gatekeeper$1 {
1457
+ export { type Gatekeeper$1_Gatekeeper as Gatekeeper, type Rules$1 as Rules, create$6 as create };
1458
+ }
1459
+
1460
+ type ServicesConfig = {
1461
+ DB: PG;
1462
+ chain?: Chain;
1463
+ rpcUrl?: string;
1464
+ collectorConfig?: {
1465
+ interval?: number;
1466
+ maxBatchSize?: number;
1467
+ maxBlockNumber?: number;
1468
+ };
1469
+ gatekeeper?: Gatekeeper;
1470
+ };
1471
+ type Services = {
1472
+ offerStore: OfferStore;
1473
+ offerStoreV2: OfferStoreV2;
1474
+ collectorStore: CollectorStore;
1475
+ liquidityStore: LiquidityStore;
1476
+ chainStore: ChainStore;
1477
+ healthService: HealthService;
1478
+ mempoolOffersCollector?: Collector<"mempool_offers">;
1479
+ consumedEventsCollector?: Collector<"consumed_events">;
1480
+ buyWithEmptyCallbackLiquidityCollector?: Collector<"buy_with_empty_callback_liquidity">;
1481
+ buyVaultV1CallbackLiquidityCollector?: Collector<"buy_vault_v1_callback_liquidity">;
1482
+ sellERC20CallbackLiquidityCollector?: Collector<"sell_erc20_callback_liquidity">;
1483
+ DB: PG;
1484
+ };
1485
+ declare function from$5(config: ServicesConfig): Services;
1486
+ type Stores = ReturnType<typeof createStores>;
1487
+ declare function createStores(db: PG): {
1488
+ collectorStore: CollectorStore;
1489
+ offerStore: OfferStore;
1490
+ offerStoreV2: OfferStoreV2;
1491
+ liquidityStore: LiquidityStore;
1492
+ chainStore: ChainStore;
1493
+ };
1494
+ declare function createWithTransaction<T>(db: PG): (fn: (s: ReturnType<typeof createStores>) => Promise<T>) => Promise<T>;
1495
+
1397
1496
  type Services$1_Services = Services;
1398
1497
  type Services$1_ServicesConfig = ServicesConfig;
1399
1498
  type Services$1_Stores = Stores;
1400
1499
  declare const Services$1_createStores: typeof createStores;
1401
1500
  declare const Services$1_createWithTransaction: typeof createWithTransaction;
1402
1501
  declare namespace Services$1 {
1403
- 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 };
1502
+ 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$5 as from };
1404
1503
  }
1405
1504
 
1406
1505
  declare const names: readonly ["mempool_offers", "consumed_events", "buy_with_empty_callback_liquidity", "buy_vault_v1_callback_liquidity", "sell_erc20_callback_liquidity"];
@@ -1433,7 +1532,7 @@ type CollectParameters<chain extends Chain, collector extends Name> = {
1433
1532
  /** A function to execute database operations in a transaction. */
1434
1533
  withTransaction: <T>(fn: (s: Stores) => Promise<T>) => Promise<T>;
1435
1534
  };
1436
- declare function create$2<name extends Name, chain extends Chain>({ name, collect, client, chain, withTransaction, collectorStore, options, }: {
1535
+ declare function create$5<name extends Name, chain extends Chain>({ name, collect, client, chain, withTransaction, collectorStore, options, }: {
1437
1536
  name: name;
1438
1537
  collect: CollectFn<chain, name>;
1439
1538
  chain: chain;
@@ -1482,6 +1581,7 @@ declare function createBuilder<chain extends Chain = Chain>(parameters: {
1482
1581
  client: PublicClient;
1483
1582
  chain: chain;
1484
1583
  db: PG;
1584
+ gatekeeper: Gatekeeper;
1485
1585
  options: {
1486
1586
  interval: number;
1487
1587
  maxBlockNumber?: number;
@@ -1584,188 +1684,236 @@ declare function fetchUserVaultMarketLiquidity(parameters: {
1584
1684
  links: LiquidityLink[];
1585
1685
  }>;
1586
1686
 
1587
- /**
1588
- * A validation rule.
1589
- */
1590
- type Rule<T, Name extends string = string, Ctx = void> = {
1591
- kind: "single";
1592
- name: Name;
1593
- run: Single<T, Name, Ctx>;
1594
- } | {
1595
- kind: "batch";
1596
- name: Name;
1597
- run: Batch<T, Name, Ctx>;
1598
- };
1599
- type RuleNames<Rules extends readonly {
1600
- name: string;
1601
- }[]> = Rules[number]["name"];
1602
- /**
1603
- * A single item validation rule.
1604
- * @param item - The item to validate.
1605
- * @param ctx - The context of the validation.
1606
- * @returns The issue that was found. If the item is valid, this will be undefined.
1607
- */
1608
- 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>;
1609
- /**
1610
- * A batch item validation rule.
1611
- * @param items - The items to validate.
1612
- * @param ctx - The context of the validation.
1613
- * @returns A map of the items to the issue that was found.
1614
- */
1615
- 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>>;
1616
- /**
1617
- * Create a validation rule iterating over a single item at a time.
1618
- * @param name - The name of the rule.
1619
- * @param run - The function that validates the rule.
1620
- * @returns The created rule.
1621
- */
1622
- declare function single<Name extends string, T, Ctx = void>(name: Name, run: Single<T, Name, Ctx>): Rule<T, Name, Ctx>;
1623
- /**
1624
- * Create a validation rule iterating over a batch of items at a time.
1625
- * @param name - The name of the rule.
1626
- * @param run - The function that validates the rule.
1627
- * @returns The created rule.
1628
- */
1629
- declare function batch$1<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
1630
- type MorphoContext = {
1631
- chain: Chain;
1632
- client: PublicClient;
1687
+ type index$4_Builder<chain extends Chain = Chain> = Builder<chain>;
1688
+ type index$4_CollectFn<chain extends Chain, collector extends Name> = CollectFn<chain, collector>;
1689
+ type index$4_CollectParameters<chain extends Chain, collector extends Name> = CollectParameters<chain, collector>;
1690
+ type index$4_Collector<name extends Name = Name, chain extends Chain = Chain> = Collector<name, chain>;
1691
+ type index$4_Name = Name;
1692
+ declare const index$4_createBuilder: typeof createBuilder;
1693
+ declare const index$4_fetchBalancesAndAllowances: typeof fetchBalancesAndAllowances;
1694
+ declare const index$4_fetchCollateralAndDebt: typeof fetchCollateralAndDebt;
1695
+ declare const index$4_fetchOraclePrices: typeof fetchOraclePrices;
1696
+ declare const index$4_fetchUserVaultMarketLiquidity: typeof fetchUserVaultMarketLiquidity;
1697
+ declare const index$4_names: typeof names;
1698
+ declare const index$4_start: typeof start;
1699
+ declare namespace index$4 {
1700
+ export { type index$4_Builder as Builder, type index$4_CollectFn as CollectFn, type index$4_CollectParameters as CollectParameters, type index$4_Collector as Collector, type index$4_Name as Name, create$5 as create, index$4_createBuilder as createBuilder, index$4_fetchBalancesAndAllowances as fetchBalancesAndAllowances, index$4_fetchCollateralAndDebt as fetchCollateralAndDebt, index$4_fetchOraclePrices as fetchOraclePrices, index$4_fetchUserVaultMarketLiquidity as fetchUserVaultMarketLiquidity, index$4_names as names, index$4_start as start };
1701
+ }
1702
+
1703
+ type CollectorStore = {
1704
+ /** Get the latest block number processed by a collector for a given chain alongside the epoch. */
1705
+ getBlockNumber: (parameters: {
1706
+ collectorName: Name;
1707
+ chainId: Id;
1708
+ }) => Promise<{
1709
+ blockNumber: number;
1710
+ epoch: bigint;
1711
+ }>;
1712
+ /**
1713
+ * Get the latest block number processed by all collectors.
1714
+ * When a chainId is provided the result is filtered, otherwise all records are returned.
1715
+ */
1716
+ getBlockNumbers: (parameters?: {
1717
+ chainId?: Id;
1718
+ }) => Promise<Array<{
1719
+ collectorName: Name;
1720
+ chainId: Id;
1721
+ blockNumber: number;
1722
+ epoch: bigint;
1723
+ updatedAt: Date;
1724
+ }>>;
1725
+ /** Save the latest block number processed by a collector for a given chain.*/
1726
+ saveBlockNumber: (parameters: {
1727
+ collectorName: Name;
1728
+ chainId: Id;
1729
+ blockNumber: number;
1730
+ epoch: bigint;
1731
+ }) => Promise<void>;
1633
1732
  };
1634
- 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>)[];
1733
+ /** Postgres implementation. */
1734
+ declare const create$4: (config: {
1735
+ db: PG;
1736
+ }) => CollectorStore;
1635
1737
 
1636
- type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
1637
- type ValidationRule_MorphoContext = MorphoContext;
1638
- type ValidationRule_Rule<T, Name extends string = string, Ctx = void> = Rule<T, Name, Ctx>;
1639
- type ValidationRule_RuleNames<Rules extends readonly {
1640
- name: string;
1641
- }[]> = RuleNames<Rules>;
1642
- type ValidationRule_Single<T, RuleName extends string, Ctx = void> = Single<T, RuleName, Ctx>;
1643
- declare const ValidationRule_morpho: typeof morpho;
1644
- declare const ValidationRule_single: typeof single;
1645
- declare namespace ValidationRule {
1646
- 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 };
1738
+ type CollectorStore$1_CollectorStore = CollectorStore;
1739
+ declare namespace CollectorStore$1 {
1740
+ export { type CollectorStore$1_CollectorStore as CollectorStore, create$4 as create };
1647
1741
  }
1648
1742
 
1649
- /**
1650
- * A validation issue.
1651
- */
1652
- type Issue<T, RuleName extends string = string> = {
1653
- /** The name of the rule that caused the issue. */
1654
- ruleName: RuleName;
1655
- /** The message of the issue. */
1656
- message: string;
1657
- /** The item that was not valid. */
1658
- item: T;
1659
- };
1660
- /**
1661
- * The result of a validation.
1662
- */
1663
- type Result<T, RuleName extends string = string> = {
1664
- /** The items that were valid. */
1665
- valid: T[];
1666
- /** The reports of the failed validations. */
1667
- issues: Issue<T, RuleName>[];
1743
+ type LiquidityStore = {
1744
+ /**
1745
+ * Get all liquidity pools.
1746
+ * @returns Array of all liquidity pools
1747
+ */
1748
+ getAllPools: () => Promise<LiquidityPool[]>;
1749
+ /**
1750
+ * Get all liquidity links.
1751
+ * @returns Array of all liquidity links
1752
+ */
1753
+ getAllLinks: () => Promise<LiquidityLink[]>;
1754
+ /**
1755
+ * Get all offer-pool mappings.
1756
+ * @returns Array of all offer liquidity pools
1757
+ */
1758
+ getAllOfferPools: () => Promise<OfferLiquidityPool[]>;
1759
+ /**
1760
+ * Save or update liquidity data.
1761
+ * Accepts flat arrays of pools, links, and offer-pool mappings.
1762
+ *
1763
+ * Automatically cleans up stale links: for each parent pool being updated,
1764
+ * deletes any existing links with priority greater than the maximum priority
1765
+ * in the new links. This ensures that when priority-ordered relationships
1766
+ * shrink, old links are removed.
1767
+ *
1768
+ * @param parameters - Object containing arrays of pools, links, and offerPools at a given block number
1769
+ */
1770
+ save: (parameters: {
1771
+ blockNumber: number;
1772
+ pools: LiquidityPool[];
1773
+ links: LiquidityLink[];
1774
+ offerPools: OfferLiquidityPool[];
1775
+ }) => Promise<void>;
1668
1776
  };
1669
- declare function run<T, Name extends string, Rules extends readonly Rule<T, Name, void>[]>(parameters: {
1670
- items: T[];
1671
- rules: Rules;
1672
- chunkSize?: number;
1673
- }): Promise<Result<T, RuleNames<Rules>>>;
1674
- declare function run<T, Ctx, Name extends string, Rules extends readonly Rule<T, Name, Ctx>[]>(parameters: {
1675
- items: T[];
1676
- rules: Rules;
1677
- ctx: Ctx;
1678
- chunkSize?: number;
1679
- }): Promise<Result<T, RuleNames<Rules>>>;
1777
+ /** Postgres implementation. */
1778
+ declare const create$3: (config: {
1779
+ db: PG;
1780
+ }) => LiquidityStore;
1680
1781
 
1681
- type Validation_Issue<T, RuleName extends string = string> = Issue<T, RuleName>;
1682
- type Validation_Result<T, RuleName extends string = string> = Result<T, RuleName>;
1683
- declare const Validation_run: typeof run;
1684
- declare namespace Validation {
1685
- export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
1686
- }
1687
-
1688
- type index$3_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
1689
- type index$3_Builder<chain extends Chain = Chain> = Builder<chain>;
1690
- type index$3_CollectFn<chain extends Chain, collector extends Name> = CollectFn<chain, collector>;
1691
- type index$3_CollectParameters<chain extends Chain, collector extends Name> = CollectParameters<chain, collector>;
1692
- type index$3_Collector<name extends Name = Name, chain extends Chain = Chain> = Collector<name, chain>;
1693
- type index$3_Issue<T, RuleName extends string = string> = Issue<T, RuleName>;
1694
- type index$3_MorphoContext = MorphoContext;
1695
- type index$3_Name = Name;
1696
- type index$3_Result<T, RuleName extends string = string> = Result<T, RuleName>;
1697
- type index$3_Rule<T, Name extends string = string, Ctx = void> = Rule<T, Name, Ctx>;
1698
- type index$3_RuleNames<Rules extends readonly {
1699
- name: string;
1700
- }[]> = RuleNames<Rules>;
1701
- type index$3_Single<T, RuleName extends string, Ctx = void> = Single<T, RuleName, Ctx>;
1702
- declare const index$3_createBuilder: typeof createBuilder;
1703
- declare const index$3_fetchBalancesAndAllowances: typeof fetchBalancesAndAllowances;
1704
- declare const index$3_fetchCollateralAndDebt: typeof fetchCollateralAndDebt;
1705
- declare const index$3_fetchOraclePrices: typeof fetchOraclePrices;
1706
- declare const index$3_fetchUserVaultMarketLiquidity: typeof fetchUserVaultMarketLiquidity;
1707
- declare const index$3_morpho: typeof morpho;
1708
- declare const index$3_names: typeof names;
1709
- declare const index$3_run: typeof run;
1710
- declare const index$3_single: typeof single;
1711
- declare const index$3_start: typeof start;
1712
- declare namespace index$3 {
1713
- 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 };
1782
+ type LiquidityStore$1_LiquidityStore = LiquidityStore;
1783
+ declare namespace LiquidityStore$1 {
1784
+ export { type LiquidityStore$1_LiquidityStore as LiquidityStore, create$3 as create };
1714
1785
  }
1715
1786
 
1716
- type CollectorHealthStatus = "live" | "lagging" | "unknown";
1717
- type RouterStatus = "live" | "syncing";
1718
- type CollectorHealth$1 = {
1719
- name: Name;
1720
- chainId: Id;
1721
- blockNumber: number | null;
1722
- updatedAt: string | null;
1723
- lag: number | null;
1724
- status: CollectorHealthStatus;
1725
- };
1726
- type ChainHealth$1 = {
1727
- chainId: Id;
1728
- blockNumber: number;
1729
- epoch: string;
1730
- updatedAt: string;
1787
+ /**
1788
+ * The `OfferStore` is responsible for managing offer-related data.
1789
+ */
1790
+ type OfferStore = {
1791
+ /** Create a single offer. */
1792
+ create: (parameters: {
1793
+ offer: Offer;
1794
+ }) => Promise<string>;
1795
+ /** Create multiple offers. */
1796
+ createMany: (parameters: {
1797
+ offer: Offer;
1798
+ }[]) => Promise<string[]>;
1799
+ /** Get all offers with optional filtering, sorting, and pagination. */
1800
+ getAll: (params?: GetAllParams) => Promise<{
1801
+ offers: Offer[];
1802
+ nextCursor: string | null;
1803
+ }>;
1804
+ /** Find offers that match the specified parameters, with cursor pagination. */
1805
+ findMatchingOffers: (params: FindMatchingOffersParams & {
1806
+ implementation?: "nodejs" | "sql";
1807
+ }) => Promise<{
1808
+ offers: Offer[];
1809
+ nextCursor: string | null;
1810
+ implementation?: "nodejs" | "sql";
1811
+ }>;
1812
+ /** Delete an offer by hash. */
1813
+ delete: (hash: Offer["hash"]) => Promise<boolean>;
1814
+ /** Delete multiple offers by hashes. */
1815
+ deleteMany: (hashes: Offer["hash"][]) => Promise<number>;
1816
+ /** Delete multiple offers by block number greater than or equal to the given value. */
1817
+ deleteManyByBlockNumberGte: (blockNumberGte: number) => Promise<number>;
1818
+ /** Update the consumed amount for a set of offers with the same chainId, offering, and nonce. */
1819
+ updateConsumedAmount: (parameters: {
1820
+ id: string;
1821
+ chainId: Offer["chainId"];
1822
+ offering: Offer["offering"];
1823
+ nonce: Offer["nonce"];
1824
+ consumed: bigint;
1825
+ blockNumber: number;
1826
+ }) => Promise<void>;
1827
+ /** Delete multiple consumed amounts by block number greater than or equal to the given value. */
1828
+ deleteManyConsumedAmountsByBlockNumberGte: (blockNumberGte: number) => Promise<number>;
1829
+ /** Get all obligations */
1830
+ getAllObligations: (parameters?: {
1831
+ cursor?: string;
1832
+ limit?: number;
1833
+ }) => Promise<{
1834
+ obligations: Obligation[];
1835
+ nextCursor: string | null;
1836
+ }>;
1837
+ /** Get quotes for given obligations. */
1838
+ getQuotes: (parameters: {
1839
+ obligationIds: Hex[];
1840
+ }) => Promise<Quote[]>;
1841
+ /** Get a single obligation by id */
1842
+ getObligation: (id: Hex) => Promise<Obligation | null>;
1731
1843
  };
1732
- type HealthService = {
1733
- getStatus: () => Promise<RouterStatus>;
1734
- getCollectors: () => Promise<CollectorHealth$1[]>;
1735
- getChains: () => Promise<ChainHealth$1[]>;
1844
+ type GetOffersFilters = {
1845
+ creators?: string[];
1846
+ side?: "buy" | "sell";
1847
+ chains?: number[];
1848
+ loanTokens?: string[];
1849
+ callbackAddresses?: string[];
1850
+ minAmount?: bigint;
1851
+ maxAmount?: bigint;
1852
+ minRate?: bigint;
1853
+ maxRate?: bigint;
1854
+ minMaturity?: number;
1855
+ maxMaturity?: number;
1856
+ minExpiry?: number;
1857
+ maxExpiry?: number;
1858
+ collateralAssets?: string[];
1859
+ collateralOracles?: string[];
1860
+ collateralTuple?: Array<{
1861
+ asset: string;
1862
+ oracle?: string;
1863
+ lltv?: LLTV;
1864
+ }>;
1865
+ minLltv?: number;
1866
+ maxLltv?: number;
1867
+ sortBy?: "rate" | "maturity" | "expiry" | "amount";
1868
+ sortOrder?: "asc" | "desc";
1869
+ cursor?: string;
1870
+ limit?: number;
1736
1871
  };
1737
- type HealthServiceParameters = {
1738
- collectorStore: CollectorStore;
1739
- chainStore: ChainStore;
1740
- /** Maximum number of blocks a collector can lag behind its chain before being considered lagging. */
1741
- maxAllowedLag?: number;
1872
+ type FindMatchingOffersParams = {
1873
+ /** The side of the offer. */
1874
+ side: "buy" | "sell";
1875
+ /** The obligationId of the offer. */
1876
+ obligationId: Hex;
1877
+ /** Cursor string returned by a previous call, for pagination */
1878
+ cursor?: string;
1879
+ /** Page size; defaults to 20 */
1880
+ limit?: number;
1742
1881
  };
1743
- /**
1744
- * Create a health service that exposes collector and chain block numbers.
1745
- */
1746
- declare function create$1(parameters: HealthServiceParameters): HealthService;
1882
+ type GetAllParams = {
1883
+ query?: GetOffersFilters;
1884
+ };
1885
+ type PgConfig = {
1886
+ /** The database instance to use for operations. */
1887
+ db: PG;
1888
+ };
1889
+ declare function create$2(config: PgConfig): OfferStore;
1747
1890
 
1748
- type Health_CollectorHealthStatus = CollectorHealthStatus;
1749
- type Health_HealthService = HealthService;
1750
- type Health_HealthServiceParameters = HealthServiceParameters;
1751
- type Health_RouterStatus = RouterStatus;
1752
- declare namespace Health {
1753
- 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 };
1891
+ type OfferStore$1_FindMatchingOffersParams = FindMatchingOffersParams;
1892
+ type OfferStore$1_GetAllParams = GetAllParams;
1893
+ type OfferStore$1_GetOffersFilters = GetOffersFilters;
1894
+ type OfferStore$1_OfferStore = OfferStore;
1895
+ type OfferStore$1_PgConfig = PgConfig;
1896
+ declare namespace OfferStore$1 {
1897
+ 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$2 as create };
1754
1898
  }
1755
1899
 
1756
- type RouterApiConfig = {
1757
- store: OfferStore;
1758
- healthService: HealthService;
1759
- };
1760
1900
  type RouterApi$1 = {
1761
- serve: (parameters: {
1762
- port: number;
1763
- }) => void;
1901
+ serve: () => void;
1902
+ };
1903
+ type ApiConfig = {
1904
+ db: PG;
1905
+ port: number;
1906
+ };
1907
+ declare function from$4(config: ApiConfig): RouterApi$1;
1908
+ type CreateParameters = {
1909
+ offerStore: OfferStore;
1910
+ healthService: HealthService;
1911
+ port: number;
1764
1912
  };
1765
- declare function create(config: RouterApiConfig): RouterApi$1;
1913
+ declare function create$1(params: CreateParameters): RouterApi$1;
1766
1914
 
1767
- declare function getSwaggerJson(): unknown;
1768
- declare function getDocsHtml(): string;
1915
+ declare function getSwaggerJson(): Promise<OpenAPIDocument>;
1916
+ declare function getDocsHtml(): Promise<string>;
1769
1917
 
1770
1918
  declare const LogLevelValues: readonly ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
1771
1919
  type LogLevel = (typeof LogLevelValues)[number];
@@ -1799,116 +1947,596 @@ declare namespace Logger$1 {
1799
1947
  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 };
1800
1948
  }
1801
1949
 
1802
- declare enum STATUS_CODE {
1803
- SUCCESS = 200,
1804
- BAD_REQUEST = 400,
1805
- NOT_FOUND = 404,
1806
- INTERNAL_SERVER_ERROR = 500
1807
- }
1950
+ /**
1951
+ * This file was auto-generated by openapi-typescript.
1952
+ * Do not make direct changes to the file.
1953
+ */
1808
1954
 
1809
- declare function getHealth(healthService: HealthService): Promise<{
1810
- statusCode: STATUS_CODE;
1811
- body: {
1812
- status: "success" | "error";
1813
- meta: {
1814
- timestamp: string;
1955
+ interface paths {
1956
+ "/v1/offers": {
1957
+ parameters: {
1958
+ query?: never;
1959
+ header?: never;
1960
+ path?: never;
1961
+ cookie?: never;
1815
1962
  };
1816
- } & ({
1817
- error: {
1818
- code: string;
1819
- message: string;
1820
- details?: unknown;
1963
+ /**
1964
+ * List all offers
1965
+ * @description Returns a list of offers for a given obligation and side. Offers are sorted by the best rate (depending on the side), their block number (older offers first) and their assets (bigger offers first).
1966
+ */
1967
+ get: {
1968
+ parameters: {
1969
+ query: {
1970
+ /**
1971
+ * @description Maximum number of offers to return.
1972
+ * @example 10
1973
+ */
1974
+ limit?: number;
1975
+ /**
1976
+ * @description Pagination cursor in base64url-encoded format.
1977
+ * @example eyJvZmZzZXQiOjEwMH0
1978
+ */
1979
+ cursor?: string;
1980
+ /**
1981
+ * @description Obligation id used to filter offers.
1982
+ * @example 0x1234567890123456789012345678901234567890123456789012345678901234
1983
+ */
1984
+ obligation_id: string;
1985
+ /** @example buy */
1986
+ side: "buy" | "sell";
1987
+ };
1988
+ header?: never;
1989
+ path?: never;
1990
+ cookie?: never;
1991
+ };
1992
+ requestBody?: never;
1993
+ responses: {
1994
+ /** @description Success */
1995
+ 200: {
1996
+ headers: {
1997
+ [name: string]: unknown;
1998
+ };
1999
+ content: {
2000
+ "application/json": components["schemas"]["OfferListResponse"];
2001
+ };
2002
+ };
2003
+ /** @description Bad Request */
2004
+ 400: {
2005
+ headers: {
2006
+ [name: string]: unknown;
2007
+ };
2008
+ content: {
2009
+ "application/json": components["schemas"]["BadRequestResponse"];
2010
+ };
2011
+ };
2012
+ };
1821
2013
  };
1822
- } | {
1823
- cursor?: string | null;
1824
- data: unknown;
1825
- });
1826
- }>;
1827
- declare function getHealthChains(healthService: HealthService): Promise<{
1828
- statusCode: STATUS_CODE;
1829
- body: {
1830
- status: "success" | "error";
1831
- meta: {
1832
- timestamp: string;
2014
+ put?: never;
2015
+ post?: never;
2016
+ delete?: never;
2017
+ options?: never;
2018
+ head?: never;
2019
+ patch?: never;
2020
+ trace?: never;
2021
+ };
2022
+ "/v1/obligations": {
2023
+ parameters: {
2024
+ query?: never;
2025
+ header?: never;
2026
+ path?: never;
2027
+ cookie?: never;
1833
2028
  };
1834
- } & ({
1835
- error: {
1836
- code: string;
1837
- message: string;
1838
- details?: unknown;
2029
+ /**
2030
+ * List all obligations
2031
+ * @description Returns a list of obligations with their current best ask and bid. Obligations are sorted by their id in ascending order by default.
2032
+ */
2033
+ get: {
2034
+ parameters: {
2035
+ query?: {
2036
+ /** @example 10 */
2037
+ limit?: number;
2038
+ /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
2039
+ cursor?: string;
2040
+ };
2041
+ header?: never;
2042
+ path?: never;
2043
+ cookie?: never;
2044
+ };
2045
+ requestBody?: never;
2046
+ responses: {
2047
+ /** @description Success */
2048
+ 200: {
2049
+ headers: {
2050
+ [name: string]: unknown;
2051
+ };
2052
+ content: {
2053
+ "application/json": components["schemas"]["ObligationListResponse"];
2054
+ };
2055
+ };
2056
+ /** @description Bad Request */
2057
+ 400: {
2058
+ headers: {
2059
+ [name: string]: unknown;
2060
+ };
2061
+ content: {
2062
+ "application/json": components["schemas"]["BadRequestResponse"];
2063
+ };
2064
+ };
2065
+ };
1839
2066
  };
1840
- } | {
1841
- cursor?: string | null;
1842
- data: unknown;
1843
- });
1844
- }>;
1845
- declare function getHealthCollectors(healthService: HealthService): Promise<{
1846
- statusCode: STATUS_CODE;
1847
- body: {
1848
- status: "success" | "error";
1849
- meta: {
1850
- timestamp: string;
2067
+ put?: never;
2068
+ post?: never;
2069
+ delete?: never;
2070
+ options?: never;
2071
+ head?: never;
2072
+ patch?: never;
2073
+ trace?: never;
2074
+ };
2075
+ "/v1/obligations/{obligationId}": {
2076
+ parameters: {
2077
+ query?: never;
2078
+ header?: never;
2079
+ path?: never;
2080
+ cookie?: never;
1851
2081
  };
1852
- } & ({
1853
- error: {
1854
- code: string;
1855
- message: string;
1856
- details?: unknown;
2082
+ /**
2083
+ * Get an obligation
2084
+ * @description Returns an obligation by its id.
2085
+ */
2086
+ get: {
2087
+ parameters: {
2088
+ query?: never;
2089
+ header?: never;
2090
+ path?: never;
2091
+ cookie?: never;
2092
+ };
2093
+ requestBody?: never;
2094
+ responses: {
2095
+ /** @description Success */
2096
+ 200: {
2097
+ headers: {
2098
+ [name: string]: unknown;
2099
+ };
2100
+ content: {
2101
+ "application/json": components["schemas"]["ObligationSingleSuccessResponse"];
2102
+ };
2103
+ };
2104
+ /** @description Bad Request */
2105
+ 400: {
2106
+ headers: {
2107
+ [name: string]: unknown;
2108
+ };
2109
+ content: {
2110
+ "application/json": components["schemas"]["BadRequestResponse"];
2111
+ };
2112
+ };
2113
+ };
1857
2114
  };
1858
- } | {
1859
- cursor?: string | null;
1860
- data: unknown;
1861
- });
1862
- }>;
1863
-
1864
- declare function getObligations(queryParameters: object, store: OfferStore): Promise<{
1865
- statusCode: STATUS_CODE;
1866
- body: {
1867
- status: "success" | "error";
1868
- meta: {
1869
- timestamp: string;
2115
+ put?: never;
2116
+ post?: never;
2117
+ delete?: never;
2118
+ options?: never;
2119
+ head?: never;
2120
+ patch?: never;
2121
+ trace?: never;
2122
+ };
2123
+ "/v1/health": {
2124
+ parameters: {
2125
+ query?: never;
2126
+ header?: never;
2127
+ path?: never;
2128
+ cookie?: never;
1870
2129
  };
1871
- } & ({
1872
- error: {
1873
- code: string;
1874
- message: string;
1875
- details?: unknown;
2130
+ /**
2131
+ * Retrieve global health
2132
+ * @description Returns the aggregated status of the router.
2133
+ */
2134
+ get: {
2135
+ parameters: {
2136
+ query?: never;
2137
+ header?: never;
2138
+ path?: never;
2139
+ cookie?: never;
2140
+ };
2141
+ requestBody?: never;
2142
+ responses: {
2143
+ /** @description Success */
2144
+ 200: {
2145
+ headers: {
2146
+ [name: string]: unknown;
2147
+ };
2148
+ content: {
2149
+ "application/json": components["schemas"]["RouterStatusSuccessResponse"];
2150
+ };
2151
+ };
2152
+ };
1876
2153
  };
1877
- } | {
1878
- cursor?: string | null;
1879
- data: unknown;
1880
- });
1881
- }>;
1882
-
1883
- declare function getOffers(queryParameters: object, store: OfferStore): Promise<{
1884
- statusCode: STATUS_CODE;
1885
- body: {
1886
- status: "success" | "error";
1887
- meta: {
2154
+ put?: never;
2155
+ post?: never;
2156
+ delete?: never;
2157
+ options?: never;
2158
+ head?: never;
2159
+ patch?: never;
2160
+ trace?: never;
2161
+ };
2162
+ "/v1/health/collectors": {
2163
+ parameters: {
2164
+ query?: never;
2165
+ header?: never;
2166
+ path?: never;
2167
+ cookie?: never;
2168
+ };
2169
+ /**
2170
+ * Retrieve collectors health
2171
+ * @description Returns the latest block numbers processed by collectors and their sync status.
2172
+ */
2173
+ get: {
2174
+ parameters: {
2175
+ query?: never;
2176
+ header?: never;
2177
+ path?: never;
2178
+ cookie?: never;
2179
+ };
2180
+ requestBody?: never;
2181
+ responses: {
2182
+ /** @description Success */
2183
+ 200: {
2184
+ headers: {
2185
+ [name: string]: unknown;
2186
+ };
2187
+ content: {
2188
+ "application/json": components["schemas"]["CollectorsHealthSuccessResponse"];
2189
+ };
2190
+ };
2191
+ };
2192
+ };
2193
+ put?: never;
2194
+ post?: never;
2195
+ delete?: never;
2196
+ options?: never;
2197
+ head?: never;
2198
+ patch?: never;
2199
+ trace?: never;
2200
+ };
2201
+ "/v1/health/chains": {
2202
+ parameters: {
2203
+ query?: never;
2204
+ header?: never;
2205
+ path?: never;
2206
+ cookie?: never;
2207
+ };
2208
+ /**
2209
+ * Retrieve chains health
2210
+ * @description Returns the latest block that can be processed by collectors for each chain.
2211
+ */
2212
+ get: {
2213
+ parameters: {
2214
+ query?: never;
2215
+ header?: never;
2216
+ path?: never;
2217
+ cookie?: never;
2218
+ };
2219
+ requestBody?: never;
2220
+ responses: {
2221
+ /** @description Success */
2222
+ 200: {
2223
+ headers: {
2224
+ [name: string]: unknown;
2225
+ };
2226
+ content: {
2227
+ "application/json": components["schemas"]["ChainsHealthSuccessResponse"];
2228
+ };
2229
+ };
2230
+ };
2231
+ };
2232
+ put?: never;
2233
+ post?: never;
2234
+ delete?: never;
2235
+ options?: never;
2236
+ head?: never;
2237
+ patch?: never;
2238
+ trace?: never;
2239
+ };
2240
+ }
2241
+ interface components {
2242
+ schemas: {
2243
+ OfferListResponse: {
2244
+ /** @enum {string} */
2245
+ status: "success";
2246
+ meta: components["schemas"]["Meta"];
2247
+ /** @example eyJvZmZzZXQiOjEwMH0 */
2248
+ cursor: string | null;
2249
+ /**
2250
+ * @description Offers matching the provided filters.
2251
+ * @example [
2252
+ * {
2253
+ * "hash": "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
2254
+ * "offering": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
2255
+ * "assets": "369216000000000000000000",
2256
+ * "rate": "2750000000000000000",
2257
+ * "maturity": 1761922799,
2258
+ * "expiry": 1761922799,
2259
+ * "start": 1761922790,
2260
+ * "nonce": "571380",
2261
+ * "buy": false,
2262
+ * "chain_id": "1",
2263
+ * "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
2264
+ * "collaterals": [
2265
+ * {
2266
+ * "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2267
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
2268
+ * "lltv": "860000000000000000"
2269
+ * }
2270
+ * ],
2271
+ * "callback": {
2272
+ * "address": "0x1111111111111111111111111111111111111111",
2273
+ * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
2274
+ * "gas_limit": "500000"
2275
+ * },
2276
+ * "signature": "0x1234567890123456789012345678901234567890123456789012345678901234123456789012345678901234567890123456789012345678901234567890123400",
2277
+ * "consumed": "0",
2278
+ * "block_number": 2942933377146801
2279
+ * }
2280
+ * ]
2281
+ */
2282
+ data: components["schemas"]["OfferListItemResponse"][];
2283
+ };
2284
+ Meta: {
2285
+ /** @example 2024-01-01T12:00:00.000Z */
1888
2286
  timestamp: string;
1889
2287
  };
1890
- } & ({
1891
- error: {
1892
- code: string;
2288
+ OfferListItemResponse: {
2289
+ /** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
2290
+ hash: string;
2291
+ /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
2292
+ offering: string;
2293
+ /** @example 369216000000000000000000 */
2294
+ assets: string;
2295
+ /** @example 2750000000000000000 */
2296
+ rate: string;
2297
+ /** @example 1761922799 */
2298
+ maturity: number;
2299
+ /** @example 1761922799 */
2300
+ expiry: number;
2301
+ /** @example 1761922790 */
2302
+ start: number;
2303
+ /** @example 571380 */
2304
+ nonce: string;
2305
+ /** @example false */
2306
+ buy: boolean;
2307
+ /** @example 1 */
2308
+ chain_id: string;
2309
+ /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
2310
+ loan_token: string;
2311
+ /**
2312
+ * @example [
2313
+ * {
2314
+ * "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2315
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
2316
+ * "lltv": "860000000000000000"
2317
+ * }
2318
+ * ]
2319
+ */
2320
+ collaterals: components["schemas"]["CollateralResponse"][];
2321
+ /**
2322
+ * @example {
2323
+ * "address": "0x1111111111111111111111111111111111111111",
2324
+ * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
2325
+ * "gas_limit": "500000"
2326
+ * }
2327
+ */
2328
+ callback: components["schemas"]["OfferCallbackResponse"];
2329
+ /** @example 0 */
2330
+ consumed: string;
2331
+ /** @example 2942933377146801 */
2332
+ block_number: number;
2333
+ /** @example 0x1234567890123456789012345678901234567890123456789012345678901234123456789012345678901234567890123456789012345678901234567890123400 */
2334
+ signature: string | null;
2335
+ };
2336
+ CollateralResponse: {
2337
+ /** @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751 */
2338
+ asset: string;
2339
+ /** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
2340
+ oracle: string;
2341
+ /** @example 860000000000000000 */
2342
+ lltv: string;
2343
+ };
2344
+ OfferCallbackResponse: {
2345
+ /** @example 0x1111111111111111111111111111111111111111 */
2346
+ address: string;
2347
+ /** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
2348
+ data: string;
2349
+ /** @example 500000 */
2350
+ gas_limit: string;
2351
+ };
2352
+ BadRequestResponse: {
2353
+ /** @enum {string} */
2354
+ status: "error";
2355
+ error: components["schemas"]["ErrorResponse"];
2356
+ meta: components["schemas"]["Meta"];
2357
+ };
2358
+ ErrorResponse: {
2359
+ /**
2360
+ * @example VALIDATION_ERROR
2361
+ * @enum {string}
2362
+ */
2363
+ code: "VALIDATION_ERROR" | "NOT_FOUND" | "INTERNAL_SERVER_ERROR" | "BAD_REQUEST";
2364
+ /** @example Limit must be greater than 0. */
1893
2365
  message: string;
1894
- details?: unknown;
2366
+ /**
2367
+ * @example [
2368
+ * {
2369
+ * "field": "limit",
2370
+ * "issue": "Limit must be greater than 0."
2371
+ * }
2372
+ * ]
2373
+ */
2374
+ details: Record<string, never>;
1895
2375
  };
1896
- } | {
1897
- cursor?: string | null;
1898
- data: unknown;
1899
- });
1900
- }>;
2376
+ ObligationListResponse: {
2377
+ /** @enum {string} */
2378
+ status: "success";
2379
+ meta: components["schemas"]["Meta"];
2380
+ /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
2381
+ cursor: string | null;
2382
+ /** @description List of obligations with takable offers. */
2383
+ data: components["schemas"]["ObligationResponse"][];
2384
+ };
2385
+ ObligationResponse: {
2386
+ /** @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67 */
2387
+ id: string;
2388
+ /** @example 1 */
2389
+ chain_id: string;
2390
+ /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
2391
+ loan_token: string;
2392
+ collaterals: components["schemas"]["CollateralResponse"][];
2393
+ /** @example 1761922800 */
2394
+ maturity: number;
2395
+ ask: components["schemas"]["AskResponse"];
2396
+ bid: components["schemas"]["BidResponse"];
2397
+ };
2398
+ AskResponse: {
2399
+ /** @example 1000000000000000000 */
2400
+ rate: string;
2401
+ };
2402
+ BidResponse: {
2403
+ /** @example 1000000000000000000 */
2404
+ rate: string;
2405
+ };
2406
+ ObligationSingleSuccessResponse: {
2407
+ /** @enum {string} */
2408
+ status: "success";
2409
+ meta: components["schemas"]["Meta"];
2410
+ /** @example null */
2411
+ cursor: string | null;
2412
+ /** @description Obligation details. */
2413
+ data: components["schemas"]["ObligationResponse"];
2414
+ };
2415
+ RouterStatusSuccessResponse: {
2416
+ /** @enum {string} */
2417
+ status: "success";
2418
+ meta: components["schemas"]["Meta"];
2419
+ /**
2420
+ * @description Aggregated router status.
2421
+ * @example {
2422
+ * "status": "live"
2423
+ * }
2424
+ */
2425
+ data: components["schemas"]["RouterStatusDataResponse"];
2426
+ };
2427
+ RouterStatusDataResponse: {
2428
+ /**
2429
+ * @example live
2430
+ * @enum {string}
2431
+ */
2432
+ status: "live" | "syncing";
2433
+ };
2434
+ CollectorsHealthSuccessResponse: {
2435
+ /** @enum {string} */
2436
+ status: "success";
2437
+ meta: components["schemas"]["Meta"];
2438
+ /**
2439
+ * @description Collectors health details and sync status.
2440
+ * @example [
2441
+ * {
2442
+ * "name": "mempool_offers",
2443
+ * "chain_id": "1",
2444
+ * "block_number": 21345678,
2445
+ * "updated_at": "2024-01-01T12:00:00.000Z",
2446
+ * "lag": 0,
2447
+ * "status": "live"
2448
+ * }
2449
+ * ]
2450
+ */
2451
+ data: components["schemas"]["CollectorHealthResponse"][];
2452
+ };
2453
+ CollectorHealthResponse: {
2454
+ /** @example mempool_offers */
2455
+ name: string;
2456
+ /** @example 1 */
2457
+ chain_id: string;
2458
+ /** @example 21345678 */
2459
+ block_number: number | null;
2460
+ /** @example 2024-01-01T12:00:00.000Z */
2461
+ updated_at: string | null;
2462
+ /** @example 0 */
2463
+ lag: number | null;
2464
+ /**
2465
+ * @example live
2466
+ * @enum {string}
2467
+ */
2468
+ status: "live" | "lagging" | "unknown";
2469
+ };
2470
+ ChainsHealthSuccessResponse: {
2471
+ /** @enum {string} */
2472
+ status: "success";
2473
+ meta: components["schemas"]["Meta"];
2474
+ /**
2475
+ * @description Latest processed block per chain.
2476
+ * @example [
2477
+ * {
2478
+ * "chain_id": "1",
2479
+ * "block_number": 21345678,
2480
+ * "updated_at": "2024-01-01T12:00:00.000Z"
2481
+ * }
2482
+ * ]
2483
+ */
2484
+ data: components["schemas"]["ChainHealthResponse"][];
2485
+ };
2486
+ ChainHealthResponse: {
2487
+ /** @example 1 */
2488
+ chain_id: string;
2489
+ /** @example 21345678 */
2490
+ block_number: number;
2491
+ /** @example 2024-01-01T12:00:00.000Z */
2492
+ updated_at: string;
2493
+ };
2494
+ };
2495
+ responses: never;
2496
+ parameters: never;
2497
+ requestBodies: never;
2498
+ headers: never;
2499
+ pathItems: never;
2500
+ }
1901
2501
 
1902
- declare const index$2_getDocsHtml: typeof getDocsHtml;
1903
- declare const index$2_getHealth: typeof getHealth;
1904
- declare const index$2_getHealthChains: typeof getHealthChains;
1905
- declare const index$2_getHealthCollectors: typeof getHealthCollectors;
1906
- declare const index$2_getObligations: typeof getObligations;
1907
- declare const index$2_getOffers: typeof getOffers;
1908
- declare const index$2_getSwaggerJson: typeof getSwaggerJson;
1909
- declare namespace index$2 {
1910
- export { index$2_getDocsHtml as getDocsHtml, index$2_getHealth as getHealth, index$2_getHealthChains as getHealthChains, index$2_getHealthCollectors as getHealthCollectors, index$2_getObligations as getObligations, index$2_getOffers as getOffers, index$2_getSwaggerJson as getSwaggerJson };
2502
+ declare const API_ERROR_CODES: readonly ["VALIDATION_ERROR", "NOT_FOUND", "INTERNAL_SERVER_ERROR", "BAD_REQUEST"];
2503
+ type APIErrorCode = (typeof API_ERROR_CODES)[number];
2504
+ declare enum STATUS_CODE {
2505
+ SUCCESS = 200,
2506
+ BAD_REQUEST = 400,
2507
+ NOT_FOUND = 404,
2508
+ INTERNAL_SERVER_ERROR = 500
1911
2509
  }
2510
+ type Meta = {
2511
+ timestamp: string;
2512
+ };
2513
+ type ErrorDetail = {
2514
+ code: APIErrorCode;
2515
+ message: string;
2516
+ details?: unknown;
2517
+ };
2518
+ type SuccessPayload<T> = Compute<{
2519
+ statusCode: STATUS_CODE.SUCCESS;
2520
+ body: {
2521
+ status: "success";
2522
+ cursor: string | null;
2523
+ data: T;
2524
+ meta: Meta;
2525
+ };
2526
+ }>;
2527
+ type ErrorPayload<statusCode extends Exclude<STATUS_CODE, STATUS_CODE.SUCCESS> = Exclude<STATUS_CODE, STATUS_CODE.SUCCESS>> = Compute<{
2528
+ statusCode: statusCode;
2529
+ body: {
2530
+ status: "error";
2531
+ meta: Meta;
2532
+ error: ErrorDetail;
2533
+ };
2534
+ }>;
2535
+ type Payload<T> = SuccessPayload<T> | ErrorPayload;
2536
+
2537
+ declare function getHealth(healthService: HealthService): Promise<Payload<paths["/v1/health"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
2538
+ declare function getHealthChains(healthService: HealthService): Promise<Payload<paths["/v1/health/chains"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
2539
+ declare function getHealthCollectors(healthService: HealthService): Promise<Payload<paths["/v1/health/collectors"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
1912
2540
 
1913
2541
  declare const CollectorHealth: z$1.ZodObject<{
1914
2542
  name: z$1.ZodString;
@@ -1954,41 +2582,47 @@ declare const RouterStatusResponse: z$1.ZodObject<{
1954
2582
  }, z$1.core.$strip>;
1955
2583
  type RouterStatusResponse = z$1.infer<typeof RouterStatusResponse>;
1956
2584
 
1957
- type ObligationResponse = Snake<Compute<{
1958
- /** The obligation id. */
1959
- id: Hex;
1960
- } & Obligation & {
1961
- ask: Quote["ask"];
1962
- bid: Quote["bid"];
1963
- }>>;
2585
+ type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
1964
2586
  /**
1965
2587
  * Creates an `ObligationResponse` from a `Obligation`.
1966
2588
  * @constructor
1967
2589
  * @param obligation - {@link Obligation}
1968
2590
  * @returns The created `ObligationResponse`. {@link ObligationResponse}
1969
2591
  */
1970
- declare function from$2(obligation: Obligation, quote: Quote): ObligationResponse;
2592
+ declare function from$3(obligation: Obligation, quote: Quote): ObligationResponse;
1971
2593
 
1972
2594
  type ObligationResponse$1_ObligationResponse = ObligationResponse;
1973
2595
  declare namespace ObligationResponse$1 {
1974
- export { type ObligationResponse$1_ObligationResponse as ObligationResponse, from$2 as from };
2596
+ export { type ObligationResponse$1_ObligationResponse as ObligationResponse, from$3 as from };
1975
2597
  }
1976
2598
 
1977
- type OfferResponse = Snake<Offer>;
2599
+ type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
1978
2600
  /**
1979
2601
  * Creates an `OfferResponse` from an `Offer`.
1980
2602
  * @constructor
1981
2603
  * @param offer - {@link Offer}
1982
2604
  * @returns The created `OfferResponse`. {@link OfferResponse}
1983
2605
  */
1984
- declare function from$1(offer: Offer): OfferResponse;
2606
+ declare function from$2(offer: Offer): OfferResponse;
1985
2607
 
1986
2608
  type OfferResponse$1_OfferResponse = OfferResponse;
1987
2609
  declare namespace OfferResponse$1 {
1988
- export { type OfferResponse$1_OfferResponse as OfferResponse, from$1 as from };
2610
+ export { type OfferResponse$1_OfferResponse as OfferResponse, from$2 as from };
1989
2611
  }
1990
2612
 
1991
- declare const OpenApi: node_modules_zod_openapi_dist_components_CXzxKPFp_js.OpenAPIObject;
2613
+ declare class OffersController {
2614
+ getOffers(): Promise<void>;
2615
+ }
2616
+ declare class HealthController {
2617
+ getRouterStatus(): Promise<void>;
2618
+ getCollectorsHealth(): Promise<void>;
2619
+ getChainsHealth(): Promise<void>;
2620
+ }
2621
+ declare class ObligationsController {
2622
+ getObligations(): Promise<void>;
2623
+ getObligation(): Promise<void>;
2624
+ }
2625
+ declare const OpenApi: () => Promise<OpenAPIDocument>;
1992
2626
 
1993
2627
  declare const schemas: {
1994
2628
  readonly get_offers: z.ZodObject<{
@@ -2004,214 +2638,1234 @@ declare const schemas: {
2004
2638
  cursor: z.ZodOptional<z.ZodString>;
2005
2639
  limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
2006
2640
  }, z.core.$strip>;
2641
+ readonly get_obligation: z.ZodObject<{
2642
+ obligation_id: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
2643
+ }, z.core.$strip>;
2007
2644
  };
2008
2645
  type Action = keyof typeof schemas;
2009
2646
  declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
2010
2647
  declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
2011
2648
 
2649
+ declare function getObligation(params: object, store: OfferStore): Promise<Payload<ObligationResponse>>;
2650
+
2651
+ declare function getObligations$1(queryParameters: object, store: OfferStore): Promise<Payload<ObligationResponse[]>>;
2652
+
2653
+ declare function getOffers$1(queryParameters: object, store: OfferStore): Promise<Payload<OfferResponse[]>>;
2654
+
2655
+ declare const index$3_getDocsHtml: typeof getDocsHtml;
2656
+ declare const index$3_getHealth: typeof getHealth;
2657
+ declare const index$3_getHealthChains: typeof getHealthChains;
2658
+ declare const index$3_getHealthCollectors: typeof getHealthCollectors;
2659
+ declare const index$3_getObligation: typeof getObligation;
2660
+ declare const index$3_getSwaggerJson: typeof getSwaggerJson;
2661
+ declare namespace index$3 {
2662
+ export { index$3_getDocsHtml as getDocsHtml, index$3_getHealth as getHealth, index$3_getHealthChains as getHealthChains, index$3_getHealthCollectors as getHealthCollectors, index$3_getObligation as getObligation, getObligations$1 as getObligations, getOffers$1 as getOffers, index$3_getSwaggerJson as getSwaggerJson };
2663
+ }
2664
+
2665
+ type RouterApi_ApiConfig = ApiConfig;
2012
2666
  declare const RouterApi_ChainHealth: typeof ChainHealth;
2013
2667
  type RouterApi_ChainsHealthResponse = ChainsHealthResponse;
2014
2668
  declare const RouterApi_CollectorHealth: typeof CollectorHealth;
2015
2669
  type RouterApi_CollectorsHealthResponse = CollectorsHealthResponse;
2670
+ type RouterApi_HealthController = HealthController;
2671
+ declare const RouterApi_HealthController: typeof HealthController;
2672
+ type RouterApi_ObligationsController = ObligationsController;
2673
+ declare const RouterApi_ObligationsController: typeof ObligationsController;
2674
+ type RouterApi_OffersController = OffersController;
2675
+ declare const RouterApi_OffersController: typeof OffersController;
2016
2676
  declare const RouterApi_OpenApi: typeof OpenApi;
2017
- type RouterApi_RouterApiConfig = RouterApiConfig;
2018
2677
  type RouterApi_RouterStatusResponse = RouterStatusResponse;
2019
- declare const RouterApi_create: typeof create;
2020
2678
  declare const RouterApi_parse: typeof parse;
2021
2679
  declare const RouterApi_safeParse: typeof safeParse;
2022
2680
  declare namespace RouterApi {
2023
- 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 };
2681
+ export { type RouterApi_ApiConfig as ApiConfig, RouterApi_ChainHealth as ChainHealth, type RouterApi_ChainsHealthResponse as ChainsHealthResponse, RouterApi_CollectorHealth as CollectorHealth, type RouterApi_CollectorsHealthResponse as CollectorsHealthResponse, index$3 as Controllers, RouterApi_HealthController as HealthController, ObligationResponse$1 as ObligationResponse, RouterApi_ObligationsController as ObligationsController, OfferResponse$1 as OfferResponse, RouterApi_OffersController as OffersController, RouterApi_OpenApi as OpenApi, type RouterApi$1 as RouterApi, type RouterApi_RouterStatusResponse as RouterStatusResponse, create$1 as create, from$4 as from, RouterApi_parse as parse, RouterApi_safeParse as safeParse };
2024
2682
  }
2025
2683
 
2026
- type MempoolEVMClientConfig = {
2027
- readonly client: WalletClient;
2028
- readonly mempoolAddress: Address;
2029
- readonly blockWindow: number;
2684
+ type RouterClientConfig = {
2685
+ /** The URL of the router. */
2686
+ readonly url: URL;
2687
+ /** The default headers to use for each request. */
2688
+ readonly headers: Headers;
2689
+ };
2690
+ type Client$1 = Compute<RouterClientConfig & {
2691
+ /**
2692
+ * Get offers from the router.
2693
+ * @param parameters - {@link getOffers.Parameters}
2694
+ * @returns The offers with pagination cursor. {@link getOffers.ReturnType}
2695
+ * @throws If the request fails - {@link getOffers.ErrorType}
2696
+ *
2697
+ * @example
2698
+ * ```ts
2699
+ * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
2700
+ * const { offers, cursor } = await router.getOffers({ side: "buy", obligationId: "0xa1c...d2f" });
2701
+ * console.log(offers);
2702
+ * ```
2703
+ */
2704
+ getOffers: (parameters: getOffers.Parameters) => Promise<getOffers.ReturnType>;
2705
+ /**
2706
+ * Get obligations from the router.
2707
+ * @param parameters - {@link getObligations.Parameters}
2708
+ * @returns The obligations with pagination cursor. {@link getObligations.ReturnType}
2709
+ * @throws If the request fails - {@link getObligations.ErrorType}
2710
+ *
2711
+ * @example
2712
+ * ```ts
2713
+ * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
2714
+ * const { obligations, cursor } = await router.getObligations();
2715
+ * console.log(obligations[0].id()); // 0x123...456
2716
+ * ```
2717
+ */
2718
+ getObligations: (parameters?: getObligations.Parameters) => Promise<getObligations.ReturnType>;
2719
+ }>;
2720
+ type ConnectOptions = {
2721
+ /** The URL of the router to interact with.
2722
+ * @default "https://router.morpho.dev"
2723
+ */
2724
+ url?: string;
2725
+ /** The API key to use for the router API. */
2726
+ apiKey?: string;
2727
+ /** The default headers to use for each request. */
2728
+ headers?: Headers;
2030
2729
  };
2031
- declare function from(parameters: from.Parameters): from.ReturnType;
2032
- declare namespace from {
2033
- type Parameters = {
2034
- /** The viem client to use. */
2035
- client: WalletClient;
2036
- /** The mempool address. */
2037
- mempoolAddress: Address;
2038
- /** The block window to use for the mempool. Defaults to 100. */
2039
- blockWindow?: number;
2040
- };
2041
- type ReturnType = Client;
2042
- type ErrorType = null;
2043
- }
2044
2730
  /**
2045
- * Add an offer to the mempool.
2046
- * @returns The created offer with its hash.
2047
- * @throws WalletAccountNotSetError if the wallet account is not set.
2048
- * @throws ViemClientError if the viem client throws an error.
2049
- * @throws Offer.InvalidOfferError if the offer is invalid.
2731
+ * Creates an instance of a router client.
2732
+ * @constructor
2733
+ * @param parameters - {@link connect.Parameters}
2734
+ * @returns A Router Client. {@link connect.ReturnType}
2735
+ *
2736
+ * @example
2737
+ * ```typescript
2738
+ * const router = RouterClient.connect({ url: "https://router.morpho.dev" });
2739
+ * ```
2050
2740
  */
2051
- declare function add(config: MempoolEVMClientConfig, parameters: AddParameters): Promise<{
2052
- offer: Offer;
2053
- txHash: Hex;
2054
- }>;
2055
- declare namespace add {
2056
- type ErrorType = WalletAccountNotSetError | ViemClientError | InvalidOfferError | ChainIdMismatchError;
2741
+ declare function connect$1(parameters?: connect$1.Parameters): connect$1.ReturnType;
2742
+ declare namespace connect$1 {
2743
+ type Parameters = ConnectOptions;
2744
+ type ReturnType = Client$1;
2745
+ type ErrorType = InvalidUrlError;
2057
2746
  }
2058
- declare function get(config: MempoolEVMClientConfig, parameters?: GetParameters): AsyncGenerator<{
2059
- offers: Offer[];
2060
- blockNumber: number;
2061
- }, void, void>;
2062
- declare namespace get {
2063
- type ErrorType = streamOffersReturnType;
2747
+ declare function getOffers(apiClient: Client$3<paths>, parameters: getOffers.Parameters): Promise<getOffers.ReturnType>;
2748
+ declare namespace getOffers {
2749
+ type Parameters = {
2750
+ /** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
2751
+ side: "buy" | "sell";
2752
+ /** The offers obligation id */
2753
+ obligationId: Hex;
2754
+ /** Pagination cursor in base64url-encoded format */
2755
+ cursor?: string;
2756
+ /** Maximum number of offers to return. @default 20 */
2757
+ limit?: number;
2758
+ };
2759
+ type ReturnType = {
2760
+ offers: Offer[];
2761
+ /** The pagination cursor. */
2762
+ cursor: string | null;
2763
+ };
2764
+ type ErrorType = GetApiErrorType;
2064
2765
  }
2065
- /**
2066
- * Watch for new offers on a specific chain.
2067
- * @returns A function to stop watching for new offers.
2068
- */
2069
- declare function watch(config: MempoolEVMClientConfig, parameters: WatchParameters): () => boolean;
2070
- declare namespace watch {
2071
- type ErrorType = streamOffersReturnType;
2766
+ declare function getObligations(apiClient: Client$3<paths>, parameters?: getObligations.Parameters): Promise<getObligations.ReturnType>;
2767
+ declare namespace getObligations {
2768
+ type Parameters = {
2769
+ /** Pagination cursor is a 32-byte hex string. */
2770
+ cursor?: Hex;
2771
+ /** Maximum number of obligations to return. @default 20 */
2772
+ limit?: number;
2773
+ };
2774
+ type ReturnType = {
2775
+ obligations: Compute<{
2776
+ /** The obligation id. Uses {@link Obligation.id} to calculate the id.*/
2777
+ id: () => Hex;
2778
+ } & Obligation & Omit<Quote, "obligationId">>[];
2779
+ /** The pagination cursor. */
2780
+ cursor: string | null;
2781
+ };
2782
+ type ErrorType = GetApiErrorType;
2072
2783
  }
2073
- type streamOffersReturnType = WalletAccountNotSetError | ChainIdMismatchError;
2074
- declare class WalletAccountNotSetError extends BaseError {
2784
+ type GetApiErrorType = HttpGetApiFailedError | HttpUnauthorizedError | HttpForbiddenError | HttpRateLimitError;
2785
+ declare class InvalidUrlError extends BaseError {
2786
+ name: string;
2787
+ constructor(url: string);
2788
+ }
2789
+ declare class HttpUnauthorizedError extends BaseError {
2075
2790
  name: string;
2076
2791
  constructor();
2077
2792
  }
2078
- declare class ViemClientError extends BaseError {
2793
+ declare class HttpForbiddenError extends BaseError {
2079
2794
  name: string;
2795
+ constructor();
2080
2796
  }
2081
- declare class ChainIdMismatchError extends BaseError {
2797
+ declare class HttpRateLimitError extends BaseError {
2082
2798
  name: string;
2083
- constructor(expected: bigint, actual: bigint);
2799
+ constructor();
2084
2800
  }
2085
-
2086
- type AddParameters = {
2087
- offer: Compute<Omit<Offer, "hash" | "createdAt">>;
2088
- };
2089
- type GetParameters = {
2090
- /** The block number to get offers from. */
2091
- blockNumberGte?: number;
2092
- /** The block number to get offers to. */
2093
- blockNumberLte?: number;
2094
- /** The loan asset to get offers from. */
2095
- loanToken?: string;
2096
- /** The order to get offers. Defaults to "desc". */
2097
- order?: "asc" | "desc";
2098
- /** The options to get offers from. */
2099
- options?: {
2100
- /** The maximum number of offers to return. Defaults to 100. Maximum is 1000. */
2101
- maxBatchSize?: number;
2102
- };
2103
- };
2104
- type WatchParameters = {
2105
- /** The async function to get the last synced block number from which to start watching.
2106
- * 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.
2107
- */
2108
- lastSyncedBlock: () => Promise<number>;
2109
- /** The loan asset to watch. */
2110
- loanToken?: string;
2111
- /** The callback to call when a new batch of offers is found in the mempool.
2112
- * @param offers The offers found in the mempool.
2113
- * @param blockNumber The block number of the last processed offer. Block numbers will always ascend.
2114
- */
2115
- onOffers: (offers: Offer[], blockNumber: number) => Promise<void>;
2116
- /** The polling configuration. */
2117
- polling?: {
2118
- /** The interval in milliseconds to poll for new offers. Defaults to 30000. */
2119
- interval?: number;
2120
- /** The maximum number of offers that can be returned in a single batch.
2121
- * Defaults to 100. Maximum is 1000. */
2122
- maxBatchSize?: number;
2123
- };
2124
- };
2125
- /**
2126
- * Mempool client interface.
2127
- */
2128
- type Client = {
2129
- /**
2130
- * Add an offer to the mempool.
2131
- * @returns The created offer with its hash.
2132
- */
2133
- add: (parameters: AddParameters) => Promise<{
2134
- offer: Offer;
2135
- txHash: Hex;
2136
- }>;
2137
- /** Get offers from the mempool. */
2138
- get: (parameters?: GetParameters) => AsyncGenerator<{
2139
- offers: Offer[];
2140
- /** The block number of the last processed offer. Depends on the `order` parameter, block numbers will ascend or descend. */
2141
- blockNumber: number;
2142
- }>;
2143
- /**
2144
- * Watch for new offers on a specific chain.
2145
- * @returns A function to stop watching for new offers.
2146
- */
2147
- watch: (parameters: WatchParameters) => () => boolean;
2148
- /**
2149
- * Stream offers from the mempool.
2150
- * @returns A generator of offers alongside the last block number processed.
2151
- */
2152
- stream: (parameters: Compute<Omit<GetParameters, "options"> & {
2153
- options: GetParameters["options"] & {
2154
- blockWindow?: number;
2155
- };
2156
- }>) => AsyncGenerator<{
2157
- offers: Offer[];
2158
- blockNumber: number;
2159
- }>;
2160
- };
2161
- /**
2162
- * Client to interact with the Mempool contract on a specific chain.
2163
- */
2164
- declare function connect(parameters: from.Parameters): Client;
2165
- declare namespace connect {
2166
- type ErrorType = from.ErrorType;
2801
+ declare class HttpGetApiFailedError extends BaseError {
2802
+ name: string;
2803
+ constructor(message: string, { details }?: {
2804
+ details?: string;
2805
+ });
2167
2806
  }
2168
2807
 
2169
- type index$1_AddParameters = AddParameters;
2170
- type index$1_ChainIdMismatchError = ChainIdMismatchError;
2171
- declare const index$1_ChainIdMismatchError: typeof ChainIdMismatchError;
2172
- type index$1_Client = Client;
2173
- type index$1_GetParameters = GetParameters;
2174
- type index$1_ViemClientError = ViemClientError;
2175
- declare const index$1_ViemClientError: typeof ViemClientError;
2176
- type index$1_WalletAccountNotSetError = WalletAccountNotSetError;
2177
- declare const index$1_WalletAccountNotSetError: typeof WalletAccountNotSetError;
2178
- type index$1_WatchParameters = WatchParameters;
2179
- declare const index$1_add: typeof add;
2180
- declare const index$1_connect: typeof connect;
2181
- declare const index$1_from: typeof from;
2182
- declare const index$1_get: typeof get;
2183
- declare const index$1_watch: typeof watch;
2184
- declare namespace index$1 {
2185
- 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 };
2808
+ type Client$2_ConnectOptions = ConnectOptions;
2809
+ type Client$2_HttpForbiddenError = HttpForbiddenError;
2810
+ declare const Client$2_HttpForbiddenError: typeof HttpForbiddenError;
2811
+ type Client$2_HttpGetApiFailedError = HttpGetApiFailedError;
2812
+ declare const Client$2_HttpGetApiFailedError: typeof HttpGetApiFailedError;
2813
+ type Client$2_HttpRateLimitError = HttpRateLimitError;
2814
+ declare const Client$2_HttpRateLimitError: typeof HttpRateLimitError;
2815
+ type Client$2_HttpUnauthorizedError = HttpUnauthorizedError;
2816
+ declare const Client$2_HttpUnauthorizedError: typeof HttpUnauthorizedError;
2817
+ type Client$2_InvalidUrlError = InvalidUrlError;
2818
+ declare const Client$2_InvalidUrlError: typeof InvalidUrlError;
2819
+ declare const Client$2_getObligations: typeof getObligations;
2820
+ declare const Client$2_getOffers: typeof getOffers;
2821
+ declare namespace Client$2 {
2822
+ 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 };
2186
2823
  }
2187
2824
 
2188
- declare const VERSION = "router_v1.4";
2189
2825
  declare const obligations: drizzle_orm_pg_core.PgTableWithColumns<{
2190
2826
  name: "obligations";
2191
- schema: "router_v1.4";
2827
+ schema: "router_v1.5";
2192
2828
  columns: {
2193
2829
  obligationId: drizzle_orm_pg_core.PgColumn<{
2194
2830
  name: "obligation_id";
2195
2831
  tableName: "obligations";
2196
2832
  dataType: "string";
2197
- columnType: "PgVarchar";
2833
+ columnType: "PgVarchar";
2834
+ data: string;
2835
+ driverParam: string;
2836
+ notNull: true;
2837
+ hasDefault: false;
2838
+ isPrimaryKey: true;
2839
+ isAutoincrement: false;
2840
+ hasRuntimeDefault: false;
2841
+ enumValues: [string, ...string[]];
2842
+ baseColumn: never;
2843
+ identity: undefined;
2844
+ generated: undefined;
2845
+ }, {}, {
2846
+ length: 66;
2847
+ }>;
2848
+ chainId: drizzle_orm_pg_core.PgColumn<{
2849
+ name: "chain_id";
2850
+ tableName: "obligations";
2851
+ dataType: "bigint";
2852
+ columnType: "PgBigInt64";
2853
+ data: bigint;
2854
+ driverParam: string;
2855
+ notNull: true;
2856
+ hasDefault: false;
2857
+ isPrimaryKey: false;
2858
+ isAutoincrement: false;
2859
+ hasRuntimeDefault: false;
2860
+ enumValues: undefined;
2861
+ baseColumn: never;
2862
+ identity: undefined;
2863
+ generated: undefined;
2864
+ }, {}, {}>;
2865
+ loanToken: drizzle_orm_pg_core.PgColumn<{
2866
+ name: "loan_token";
2867
+ tableName: "obligations";
2868
+ dataType: "string";
2869
+ columnType: "PgVarchar";
2870
+ data: string;
2871
+ driverParam: string;
2872
+ notNull: true;
2873
+ hasDefault: false;
2874
+ isPrimaryKey: false;
2875
+ isAutoincrement: false;
2876
+ hasRuntimeDefault: false;
2877
+ enumValues: [string, ...string[]];
2878
+ baseColumn: never;
2879
+ identity: undefined;
2880
+ generated: undefined;
2881
+ }, {}, {
2882
+ length: 42;
2883
+ }>;
2884
+ maturity: drizzle_orm_pg_core.PgColumn<{
2885
+ name: "maturity";
2886
+ tableName: "obligations";
2887
+ dataType: "number";
2888
+ columnType: "PgInteger";
2889
+ data: number;
2890
+ driverParam: string | number;
2891
+ notNull: true;
2892
+ hasDefault: false;
2893
+ isPrimaryKey: false;
2894
+ isAutoincrement: false;
2895
+ hasRuntimeDefault: false;
2896
+ enumValues: undefined;
2897
+ baseColumn: never;
2898
+ identity: undefined;
2899
+ generated: undefined;
2900
+ }, {}, {}>;
2901
+ };
2902
+ dialect: "pg";
2903
+ }>;
2904
+ declare const groups: drizzle_orm_pg_core.PgTableWithColumns<{
2905
+ name: "groups";
2906
+ schema: "router_v1.5";
2907
+ columns: {
2908
+ chainId: drizzle_orm_pg_core.PgColumn<{
2909
+ name: "chain_id";
2910
+ tableName: "groups";
2911
+ dataType: "bigint";
2912
+ columnType: "PgBigInt64";
2913
+ data: bigint;
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
+ maker: drizzle_orm_pg_core.PgColumn<{
2926
+ name: "maker";
2927
+ tableName: "groups";
2928
+ dataType: "string";
2929
+ columnType: "PgVarchar";
2930
+ data: string;
2931
+ driverParam: string;
2932
+ notNull: true;
2933
+ hasDefault: false;
2934
+ isPrimaryKey: false;
2935
+ isAutoincrement: false;
2936
+ hasRuntimeDefault: false;
2937
+ enumValues: [string, ...string[]];
2938
+ baseColumn: never;
2939
+ identity: undefined;
2940
+ generated: undefined;
2941
+ }, {}, {
2942
+ length: 42;
2943
+ }>;
2944
+ group: drizzle_orm_pg_core.PgColumn<{
2945
+ name: "group";
2946
+ tableName: "groups";
2947
+ dataType: "string";
2948
+ columnType: "PgVarchar";
2949
+ data: string;
2950
+ driverParam: string;
2951
+ notNull: true;
2952
+ hasDefault: false;
2953
+ isPrimaryKey: false;
2954
+ isAutoincrement: false;
2955
+ hasRuntimeDefault: false;
2956
+ enumValues: [string, ...string[]];
2957
+ baseColumn: never;
2958
+ identity: undefined;
2959
+ generated: undefined;
2960
+ }, {}, {
2961
+ length: 66;
2962
+ }>;
2963
+ consumed: drizzle_orm_pg_core.PgColumn<{
2964
+ name: "consumed";
2965
+ tableName: "groups";
2966
+ dataType: "string";
2967
+ columnType: "PgNumeric";
2968
+ data: string;
2969
+ driverParam: string;
2970
+ notNull: true;
2971
+ hasDefault: false;
2972
+ isPrimaryKey: false;
2973
+ isAutoincrement: false;
2974
+ hasRuntimeDefault: false;
2975
+ enumValues: undefined;
2976
+ baseColumn: never;
2977
+ identity: undefined;
2978
+ generated: undefined;
2979
+ }, {}, {}>;
2980
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
2981
+ name: "block_number";
2982
+ tableName: "groups";
2983
+ dataType: "number";
2984
+ columnType: "PgBigInt53";
2985
+ data: number;
2986
+ driverParam: string | number;
2987
+ notNull: true;
2988
+ hasDefault: false;
2989
+ isPrimaryKey: false;
2990
+ isAutoincrement: false;
2991
+ hasRuntimeDefault: false;
2992
+ enumValues: undefined;
2993
+ baseColumn: never;
2994
+ identity: undefined;
2995
+ generated: undefined;
2996
+ }, {}, {}>;
2997
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
2998
+ name: "updated_at";
2999
+ tableName: "groups";
3000
+ dataType: "date";
3001
+ columnType: "PgTimestamp";
3002
+ data: Date;
3003
+ driverParam: string;
3004
+ notNull: true;
3005
+ hasDefault: true;
3006
+ isPrimaryKey: false;
3007
+ isAutoincrement: false;
3008
+ hasRuntimeDefault: false;
3009
+ enumValues: undefined;
3010
+ baseColumn: never;
3011
+ identity: undefined;
3012
+ generated: undefined;
3013
+ }, {}, {}>;
3014
+ };
3015
+ dialect: "pg";
3016
+ }>;
3017
+ declare const consumedEvents: drizzle_orm_pg_core.PgTableWithColumns<{
3018
+ name: "consumed_events";
3019
+ schema: "router_v1.5";
3020
+ columns: {
3021
+ eventId: drizzle_orm_pg_core.PgColumn<{
3022
+ name: "event_id";
3023
+ tableName: "consumed_events";
3024
+ dataType: "string";
3025
+ columnType: "PgVarchar";
3026
+ data: string;
3027
+ driverParam: string;
3028
+ notNull: true;
3029
+ hasDefault: false;
3030
+ isPrimaryKey: true;
3031
+ isAutoincrement: false;
3032
+ hasRuntimeDefault: false;
3033
+ enumValues: [string, ...string[]];
3034
+ baseColumn: never;
3035
+ identity: undefined;
3036
+ generated: undefined;
3037
+ }, {}, {
3038
+ length: 128;
3039
+ }>;
3040
+ chainId: drizzle_orm_pg_core.PgColumn<{
3041
+ name: "chain_id";
3042
+ tableName: "consumed_events";
3043
+ dataType: "bigint";
3044
+ columnType: "PgBigInt64";
3045
+ data: bigint;
3046
+ driverParam: string;
3047
+ notNull: true;
3048
+ hasDefault: false;
3049
+ isPrimaryKey: false;
3050
+ isAutoincrement: false;
3051
+ hasRuntimeDefault: false;
3052
+ enumValues: undefined;
3053
+ baseColumn: never;
3054
+ identity: undefined;
3055
+ generated: undefined;
3056
+ }, {}, {}>;
3057
+ maker: drizzle_orm_pg_core.PgColumn<{
3058
+ name: "maker";
3059
+ tableName: "consumed_events";
3060
+ dataType: "string";
3061
+ columnType: "PgVarchar";
3062
+ data: string;
3063
+ driverParam: string;
3064
+ notNull: true;
3065
+ hasDefault: false;
3066
+ isPrimaryKey: false;
3067
+ isAutoincrement: false;
3068
+ hasRuntimeDefault: false;
3069
+ enumValues: [string, ...string[]];
3070
+ baseColumn: never;
3071
+ identity: undefined;
3072
+ generated: undefined;
3073
+ }, {}, {
3074
+ length: 42;
3075
+ }>;
3076
+ group: drizzle_orm_pg_core.PgColumn<{
3077
+ name: "group";
3078
+ tableName: "consumed_events";
3079
+ dataType: "string";
3080
+ columnType: "PgVarchar";
3081
+ data: string;
3082
+ driverParam: string;
3083
+ notNull: true;
3084
+ hasDefault: false;
3085
+ isPrimaryKey: false;
3086
+ isAutoincrement: false;
3087
+ hasRuntimeDefault: false;
3088
+ enumValues: [string, ...string[]];
3089
+ baseColumn: never;
3090
+ identity: undefined;
3091
+ generated: undefined;
3092
+ }, {}, {
3093
+ length: 66;
3094
+ }>;
3095
+ amount: drizzle_orm_pg_core.PgColumn<{
3096
+ name: "amount";
3097
+ tableName: "consumed_events";
3098
+ dataType: "string";
3099
+ columnType: "PgNumeric";
3100
+ data: string;
3101
+ driverParam: string;
3102
+ notNull: true;
3103
+ hasDefault: false;
3104
+ isPrimaryKey: false;
3105
+ isAutoincrement: false;
3106
+ hasRuntimeDefault: false;
3107
+ enumValues: undefined;
3108
+ baseColumn: never;
3109
+ identity: undefined;
3110
+ generated: undefined;
3111
+ }, {}, {}>;
3112
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
3113
+ name: "block_number";
3114
+ tableName: "consumed_events";
3115
+ dataType: "number";
3116
+ columnType: "PgBigInt53";
3117
+ data: number;
3118
+ driverParam: string | number;
3119
+ notNull: true;
3120
+ hasDefault: false;
3121
+ isPrimaryKey: false;
3122
+ isAutoincrement: false;
3123
+ hasRuntimeDefault: false;
3124
+ enumValues: undefined;
3125
+ baseColumn: never;
3126
+ identity: undefined;
3127
+ generated: undefined;
3128
+ }, {}, {}>;
3129
+ createdAt: drizzle_orm_pg_core.PgColumn<{
3130
+ name: "created_at";
3131
+ tableName: "consumed_events";
3132
+ dataType: "date";
3133
+ columnType: "PgTimestamp";
3134
+ data: Date;
3135
+ driverParam: string;
3136
+ notNull: true;
3137
+ hasDefault: true;
3138
+ isPrimaryKey: false;
3139
+ isAutoincrement: false;
3140
+ hasRuntimeDefault: false;
3141
+ enumValues: undefined;
3142
+ baseColumn: never;
3143
+ identity: undefined;
3144
+ generated: undefined;
3145
+ }, {}, {}>;
3146
+ };
3147
+ dialect: "pg";
3148
+ }>;
3149
+ declare const obligationCollateralsV2: drizzle_orm_pg_core.PgTableWithColumns<{
3150
+ name: "obligation_collaterals_v2";
3151
+ schema: "router_v1.5";
3152
+ columns: {
3153
+ obligationId: drizzle_orm_pg_core.PgColumn<{
3154
+ name: "obligation_id";
3155
+ tableName: "obligation_collaterals_v2";
3156
+ dataType: "string";
3157
+ columnType: "PgVarchar";
3158
+ data: string;
3159
+ driverParam: string;
3160
+ notNull: true;
3161
+ hasDefault: false;
3162
+ isPrimaryKey: false;
3163
+ isAutoincrement: false;
3164
+ hasRuntimeDefault: false;
3165
+ enumValues: [string, ...string[]];
3166
+ baseColumn: never;
3167
+ identity: undefined;
3168
+ generated: undefined;
3169
+ }, {}, {
3170
+ length: 66;
3171
+ }>;
3172
+ asset: drizzle_orm_pg_core.PgColumn<{
3173
+ name: "asset";
3174
+ tableName: "obligation_collaterals_v2";
3175
+ dataType: "string";
3176
+ columnType: "PgVarchar";
3177
+ data: string;
3178
+ driverParam: string;
3179
+ notNull: true;
3180
+ hasDefault: false;
3181
+ isPrimaryKey: false;
3182
+ isAutoincrement: false;
3183
+ hasRuntimeDefault: false;
3184
+ enumValues: [string, ...string[]];
3185
+ baseColumn: never;
3186
+ identity: undefined;
3187
+ generated: undefined;
3188
+ }, {}, {
3189
+ length: 42;
3190
+ }>;
3191
+ oracleChainId: drizzle_orm_pg_core.PgColumn<{
3192
+ name: "oracle_chain_id";
3193
+ tableName: "obligation_collaterals_v2";
3194
+ dataType: "bigint";
3195
+ columnType: "PgBigInt64";
3196
+ data: bigint;
3197
+ driverParam: string;
3198
+ notNull: true;
3199
+ hasDefault: false;
3200
+ isPrimaryKey: false;
3201
+ isAutoincrement: false;
3202
+ hasRuntimeDefault: false;
3203
+ enumValues: undefined;
3204
+ baseColumn: never;
3205
+ identity: undefined;
3206
+ generated: undefined;
3207
+ }, {}, {}>;
3208
+ oracleAddress: drizzle_orm_pg_core.PgColumn<{
3209
+ name: "oracle_address";
3210
+ tableName: "obligation_collaterals_v2";
3211
+ dataType: "string";
3212
+ columnType: "PgVarchar";
3213
+ data: string;
3214
+ driverParam: string;
3215
+ notNull: true;
3216
+ hasDefault: false;
3217
+ isPrimaryKey: false;
3218
+ isAutoincrement: false;
3219
+ hasRuntimeDefault: false;
3220
+ enumValues: [string, ...string[]];
3221
+ baseColumn: never;
3222
+ identity: undefined;
3223
+ generated: undefined;
3224
+ }, {}, {
3225
+ length: 42;
3226
+ }>;
3227
+ lltv: drizzle_orm_pg_core.PgColumn<{
3228
+ name: "lltv";
3229
+ tableName: "obligation_collaterals_v2";
3230
+ dataType: "bigint";
3231
+ columnType: "PgBigInt64";
3232
+ data: bigint;
3233
+ driverParam: string;
3234
+ notNull: true;
3235
+ hasDefault: false;
3236
+ isPrimaryKey: false;
3237
+ isAutoincrement: false;
3238
+ hasRuntimeDefault: false;
3239
+ enumValues: undefined;
3240
+ baseColumn: never;
3241
+ identity: undefined;
3242
+ generated: undefined;
3243
+ }, {}, {}>;
3244
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
3245
+ name: "block_number";
3246
+ tableName: "obligation_collaterals_v2";
3247
+ dataType: "number";
3248
+ columnType: "PgBigInt53";
3249
+ data: number;
3250
+ driverParam: string | number;
3251
+ notNull: true;
3252
+ hasDefault: false;
3253
+ isPrimaryKey: false;
3254
+ isAutoincrement: false;
3255
+ hasRuntimeDefault: false;
3256
+ enumValues: undefined;
3257
+ baseColumn: never;
3258
+ identity: undefined;
3259
+ generated: undefined;
3260
+ }, {}, {}>;
3261
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
3262
+ name: "updated_at";
3263
+ tableName: "obligation_collaterals_v2";
3264
+ dataType: "date";
3265
+ columnType: "PgTimestamp";
3266
+ data: Date;
3267
+ driverParam: string;
3268
+ notNull: true;
3269
+ hasDefault: true;
3270
+ isPrimaryKey: false;
3271
+ isAutoincrement: false;
3272
+ hasRuntimeDefault: false;
3273
+ enumValues: undefined;
3274
+ baseColumn: never;
3275
+ identity: undefined;
3276
+ generated: undefined;
3277
+ }, {}, {}>;
3278
+ };
3279
+ dialect: "pg";
3280
+ }>;
3281
+ declare const oracles: drizzle_orm_pg_core.PgTableWithColumns<{
3282
+ name: "oracles";
3283
+ schema: "router_v1.5";
3284
+ columns: {
3285
+ chainId: drizzle_orm_pg_core.PgColumn<{
3286
+ name: "chain_id";
3287
+ tableName: "oracles";
3288
+ dataType: "bigint";
3289
+ columnType: "PgBigInt64";
3290
+ data: bigint;
3291
+ driverParam: string;
3292
+ notNull: true;
3293
+ hasDefault: false;
3294
+ isPrimaryKey: false;
3295
+ isAutoincrement: false;
3296
+ hasRuntimeDefault: false;
3297
+ enumValues: undefined;
3298
+ baseColumn: never;
3299
+ identity: undefined;
3300
+ generated: undefined;
3301
+ }, {}, {}>;
3302
+ address: drizzle_orm_pg_core.PgColumn<{
3303
+ name: "address";
3304
+ tableName: "oracles";
3305
+ dataType: "string";
3306
+ columnType: "PgVarchar";
3307
+ data: string;
3308
+ driverParam: string;
3309
+ notNull: true;
3310
+ hasDefault: false;
3311
+ isPrimaryKey: false;
3312
+ isAutoincrement: false;
3313
+ hasRuntimeDefault: false;
3314
+ enumValues: [string, ...string[]];
3315
+ baseColumn: never;
3316
+ identity: undefined;
3317
+ generated: undefined;
3318
+ }, {}, {
3319
+ length: 42;
3320
+ }>;
3321
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
3322
+ name: "block_number";
3323
+ tableName: "oracles";
3324
+ dataType: "number";
3325
+ columnType: "PgBigInt53";
3326
+ data: number;
3327
+ driverParam: string | number;
3328
+ notNull: true;
3329
+ hasDefault: false;
3330
+ isPrimaryKey: false;
3331
+ isAutoincrement: false;
3332
+ hasRuntimeDefault: false;
3333
+ enumValues: undefined;
3334
+ baseColumn: never;
3335
+ identity: undefined;
3336
+ generated: undefined;
3337
+ }, {}, {}>;
3338
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
3339
+ name: "updated_at";
3340
+ tableName: "oracles";
3341
+ dataType: "date";
3342
+ columnType: "PgTimestamp";
3343
+ data: Date;
3344
+ driverParam: string;
3345
+ notNull: true;
3346
+ hasDefault: true;
3347
+ isPrimaryKey: false;
3348
+ isAutoincrement: false;
3349
+ hasRuntimeDefault: false;
3350
+ enumValues: undefined;
3351
+ baseColumn: never;
3352
+ identity: undefined;
3353
+ generated: undefined;
3354
+ }, {}, {}>;
3355
+ };
3356
+ dialect: "pg";
3357
+ }>;
3358
+ declare const statusCode: drizzle_orm_pg_core.PgEnum<[StatusCode, ...StatusCode[]]>;
3359
+ declare const status: drizzle_orm_pg_core.PgTableWithColumns<{
3360
+ name: "status";
3361
+ schema: "router_v1.5";
3362
+ columns: {
3363
+ id: drizzle_orm_pg_core.PgColumn<{
3364
+ name: "id";
3365
+ tableName: "status";
3366
+ dataType: "number";
3367
+ columnType: "PgSerial";
3368
+ data: number;
3369
+ driverParam: number;
3370
+ notNull: true;
3371
+ hasDefault: true;
3372
+ isPrimaryKey: true;
3373
+ isAutoincrement: false;
3374
+ hasRuntimeDefault: false;
3375
+ enumValues: undefined;
3376
+ baseColumn: never;
3377
+ identity: undefined;
3378
+ generated: undefined;
3379
+ }, {}, {}>;
3380
+ code: drizzle_orm_pg_core.PgColumn<{
3381
+ name: "code";
3382
+ tableName: "status";
3383
+ dataType: "string";
3384
+ columnType: "PgEnumColumn";
3385
+ data: StatusCode;
3386
+ driverParam: string;
3387
+ notNull: false;
3388
+ hasDefault: false;
3389
+ isPrimaryKey: false;
3390
+ isAutoincrement: false;
3391
+ hasRuntimeDefault: false;
3392
+ enumValues: [StatusCode, ...StatusCode[]];
3393
+ baseColumn: never;
3394
+ identity: undefined;
3395
+ generated: undefined;
3396
+ }, {}, {}>;
3397
+ };
3398
+ dialect: "pg";
3399
+ }>;
3400
+ declare const offersV2: drizzle_orm_pg_core.PgTableWithColumns<{
3401
+ name: "offers_v2";
3402
+ schema: "router_v1.5";
3403
+ columns: {
3404
+ hash: drizzle_orm_pg_core.PgColumn<{
3405
+ name: "hash";
3406
+ tableName: "offers_v2";
3407
+ dataType: "string";
3408
+ columnType: "PgVarchar";
3409
+ data: string;
3410
+ driverParam: string;
3411
+ notNull: true;
3412
+ hasDefault: false;
3413
+ isPrimaryKey: true;
3414
+ isAutoincrement: false;
3415
+ hasRuntimeDefault: false;
3416
+ enumValues: [string, ...string[]];
3417
+ baseColumn: never;
3418
+ identity: undefined;
3419
+ generated: undefined;
3420
+ }, {}, {
3421
+ length: 66;
3422
+ }>;
3423
+ obligationId: drizzle_orm_pg_core.PgColumn<{
3424
+ name: "obligation_id";
3425
+ tableName: "offers_v2";
3426
+ dataType: "string";
3427
+ columnType: "PgVarchar";
3428
+ data: string;
3429
+ driverParam: string;
3430
+ notNull: true;
3431
+ hasDefault: false;
3432
+ isPrimaryKey: false;
3433
+ isAutoincrement: false;
3434
+ hasRuntimeDefault: false;
3435
+ enumValues: [string, ...string[]];
3436
+ baseColumn: never;
3437
+ identity: undefined;
3438
+ generated: undefined;
3439
+ }, {}, {
3440
+ length: 66;
3441
+ }>;
3442
+ assets: drizzle_orm_pg_core.PgColumn<{
3443
+ name: "assets";
3444
+ tableName: "offers_v2";
3445
+ dataType: "string";
3446
+ columnType: "PgNumeric";
3447
+ data: string;
3448
+ driverParam: string;
3449
+ notNull: true;
3450
+ hasDefault: false;
3451
+ isPrimaryKey: false;
3452
+ isAutoincrement: false;
3453
+ hasRuntimeDefault: false;
3454
+ enumValues: undefined;
3455
+ baseColumn: never;
3456
+ identity: undefined;
3457
+ generated: undefined;
3458
+ }, {}, {}>;
3459
+ rate: drizzle_orm_pg_core.PgColumn<{
3460
+ name: "rate";
3461
+ tableName: "offers_v2";
3462
+ dataType: "string";
3463
+ columnType: "PgNumeric";
3464
+ data: string;
3465
+ driverParam: string;
3466
+ notNull: true;
3467
+ hasDefault: false;
3468
+ isPrimaryKey: false;
3469
+ isAutoincrement: false;
3470
+ hasRuntimeDefault: false;
3471
+ enumValues: undefined;
3472
+ baseColumn: never;
3473
+ identity: undefined;
3474
+ generated: undefined;
3475
+ }, {}, {}>;
3476
+ maturity: drizzle_orm_pg_core.PgColumn<{
3477
+ name: "maturity";
3478
+ tableName: "offers_v2";
3479
+ dataType: "number";
3480
+ columnType: "PgInteger";
3481
+ data: number;
3482
+ driverParam: string | number;
3483
+ notNull: true;
3484
+ hasDefault: false;
3485
+ isPrimaryKey: false;
3486
+ isAutoincrement: false;
3487
+ hasRuntimeDefault: false;
3488
+ enumValues: undefined;
3489
+ baseColumn: never;
3490
+ identity: undefined;
3491
+ generated: undefined;
3492
+ }, {}, {}>;
3493
+ expiry: drizzle_orm_pg_core.PgColumn<{
3494
+ name: "expiry";
3495
+ tableName: "offers_v2";
3496
+ dataType: "number";
3497
+ columnType: "PgInteger";
3498
+ data: number;
3499
+ driverParam: string | number;
3500
+ notNull: true;
3501
+ hasDefault: false;
3502
+ isPrimaryKey: false;
3503
+ isAutoincrement: false;
3504
+ hasRuntimeDefault: false;
3505
+ enumValues: undefined;
3506
+ baseColumn: never;
3507
+ identity: undefined;
3508
+ generated: undefined;
3509
+ }, {}, {}>;
3510
+ start: drizzle_orm_pg_core.PgColumn<{
3511
+ name: "start";
3512
+ tableName: "offers_v2";
3513
+ dataType: "number";
3514
+ columnType: "PgInteger";
3515
+ data: number;
3516
+ driverParam: string | number;
3517
+ notNull: true;
3518
+ hasDefault: false;
3519
+ isPrimaryKey: false;
3520
+ isAutoincrement: false;
3521
+ hasRuntimeDefault: false;
3522
+ enumValues: undefined;
3523
+ baseColumn: never;
3524
+ identity: undefined;
3525
+ generated: undefined;
3526
+ }, {}, {}>;
3527
+ groupChainId: drizzle_orm_pg_core.PgColumn<{
3528
+ name: "group_chain_id";
3529
+ tableName: "offers_v2";
3530
+ dataType: "bigint";
3531
+ columnType: "PgBigInt64";
3532
+ data: bigint;
3533
+ driverParam: string;
3534
+ notNull: true;
3535
+ hasDefault: false;
3536
+ isPrimaryKey: false;
3537
+ isAutoincrement: false;
3538
+ hasRuntimeDefault: false;
3539
+ enumValues: undefined;
3540
+ baseColumn: never;
3541
+ identity: undefined;
3542
+ generated: undefined;
3543
+ }, {}, {}>;
3544
+ groupMaker: drizzle_orm_pg_core.PgColumn<{
3545
+ name: "group_maker";
3546
+ tableName: "offers_v2";
3547
+ dataType: "string";
3548
+ columnType: "PgVarchar";
3549
+ data: string;
3550
+ driverParam: string;
3551
+ notNull: true;
3552
+ hasDefault: false;
3553
+ isPrimaryKey: false;
3554
+ isAutoincrement: false;
3555
+ hasRuntimeDefault: false;
3556
+ enumValues: [string, ...string[]];
3557
+ baseColumn: never;
3558
+ identity: undefined;
3559
+ generated: undefined;
3560
+ }, {}, {
3561
+ length: 42;
3562
+ }>;
3563
+ group: drizzle_orm_pg_core.PgColumn<{
3564
+ name: "group_group";
3565
+ tableName: "offers_v2";
3566
+ dataType: "string";
3567
+ columnType: "PgVarchar";
3568
+ data: string;
3569
+ driverParam: string;
3570
+ notNull: true;
3571
+ hasDefault: false;
3572
+ isPrimaryKey: false;
3573
+ isAutoincrement: false;
3574
+ hasRuntimeDefault: false;
3575
+ enumValues: [string, ...string[]];
3576
+ baseColumn: never;
3577
+ identity: undefined;
3578
+ generated: undefined;
3579
+ }, {}, {
3580
+ length: 66;
3581
+ }>;
3582
+ nonce: drizzle_orm_pg_core.PgColumn<{
3583
+ name: "nonce";
3584
+ tableName: "offers_v2";
3585
+ dataType: "string";
3586
+ columnType: "PgVarchar";
3587
+ data: string;
3588
+ driverParam: string;
3589
+ notNull: true;
3590
+ hasDefault: false;
3591
+ isPrimaryKey: false;
3592
+ isAutoincrement: false;
3593
+ hasRuntimeDefault: false;
3594
+ enumValues: [string, ...string[]];
3595
+ baseColumn: never;
3596
+ identity: undefined;
3597
+ generated: undefined;
3598
+ }, {}, {
3599
+ length: 66;
3600
+ }>;
3601
+ buy: drizzle_orm_pg_core.PgColumn<{
3602
+ name: "buy";
3603
+ tableName: "offers_v2";
3604
+ dataType: "boolean";
3605
+ columnType: "PgBoolean";
3606
+ data: boolean;
3607
+ driverParam: boolean;
3608
+ notNull: true;
3609
+ hasDefault: false;
3610
+ isPrimaryKey: false;
3611
+ isAutoincrement: false;
3612
+ hasRuntimeDefault: false;
3613
+ enumValues: undefined;
3614
+ baseColumn: never;
3615
+ identity: undefined;
3616
+ generated: undefined;
3617
+ }, {}, {}>;
3618
+ callbackAddress: drizzle_orm_pg_core.PgColumn<{
3619
+ name: "callback_address";
3620
+ tableName: "offers_v2";
3621
+ dataType: "string";
3622
+ columnType: "PgVarchar";
3623
+ data: string;
3624
+ driverParam: string;
3625
+ notNull: true;
3626
+ hasDefault: false;
3627
+ isPrimaryKey: false;
3628
+ isAutoincrement: false;
3629
+ hasRuntimeDefault: false;
3630
+ enumValues: [string, ...string[]];
3631
+ baseColumn: never;
3632
+ identity: undefined;
3633
+ generated: undefined;
3634
+ }, {}, {
3635
+ length: 42;
3636
+ }>;
3637
+ callbackData: drizzle_orm_pg_core.PgColumn<{
3638
+ name: "callback_data";
3639
+ tableName: "offers_v2";
3640
+ dataType: "string";
3641
+ columnType: "PgText";
3642
+ data: string;
3643
+ driverParam: string;
3644
+ notNull: true;
3645
+ hasDefault: false;
3646
+ isPrimaryKey: false;
3647
+ isAutoincrement: false;
3648
+ hasRuntimeDefault: false;
3649
+ enumValues: [string, ...string[]];
3650
+ baseColumn: never;
3651
+ identity: undefined;
3652
+ generated: undefined;
3653
+ }, {}, {}>;
3654
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
3655
+ name: "block_number";
3656
+ tableName: "offers_v2";
3657
+ dataType: "number";
3658
+ columnType: "PgBigInt53";
3659
+ data: number;
3660
+ driverParam: string | number;
3661
+ notNull: true;
3662
+ hasDefault: false;
3663
+ isPrimaryKey: false;
3664
+ isAutoincrement: false;
3665
+ hasRuntimeDefault: false;
3666
+ enumValues: undefined;
3667
+ baseColumn: never;
3668
+ identity: undefined;
3669
+ generated: undefined;
3670
+ }, {}, {}>;
3671
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
3672
+ name: "updated_at";
3673
+ tableName: "offers_v2";
3674
+ dataType: "date";
3675
+ columnType: "PgTimestamp";
3676
+ data: Date;
3677
+ driverParam: string;
3678
+ notNull: true;
3679
+ hasDefault: true;
3680
+ isPrimaryKey: false;
3681
+ isAutoincrement: false;
3682
+ hasRuntimeDefault: false;
3683
+ enumValues: undefined;
3684
+ baseColumn: never;
3685
+ identity: undefined;
3686
+ generated: undefined;
3687
+ }, {}, {}>;
3688
+ };
3689
+ dialect: "pg";
3690
+ }>;
3691
+ declare const offerStatus: drizzle_orm_pg_core.PgTableWithColumns<{
3692
+ name: "offer_status";
3693
+ schema: "router_v1.5";
3694
+ columns: {
3695
+ offerHash: drizzle_orm_pg_core.PgColumn<{
3696
+ name: "offer_hash";
3697
+ tableName: "offer_status";
3698
+ dataType: "string";
3699
+ columnType: "PgVarchar";
3700
+ data: string;
3701
+ driverParam: string;
3702
+ notNull: true;
3703
+ hasDefault: false;
3704
+ isPrimaryKey: true;
3705
+ isAutoincrement: false;
3706
+ hasRuntimeDefault: false;
3707
+ enumValues: [string, ...string[]];
3708
+ baseColumn: never;
3709
+ identity: undefined;
3710
+ generated: undefined;
3711
+ }, {}, {
3712
+ length: 66;
3713
+ }>;
3714
+ statusId: drizzle_orm_pg_core.PgColumn<{
3715
+ name: "status_id";
3716
+ tableName: "offer_status";
3717
+ dataType: "number";
3718
+ columnType: "PgSerial";
3719
+ data: number;
3720
+ driverParam: number;
3721
+ notNull: true;
3722
+ hasDefault: true;
3723
+ isPrimaryKey: false;
3724
+ isAutoincrement: false;
3725
+ hasRuntimeDefault: false;
3726
+ enumValues: undefined;
3727
+ baseColumn: never;
3728
+ identity: undefined;
3729
+ generated: undefined;
3730
+ }, {}, {}>;
3731
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
3732
+ name: "block_number";
3733
+ tableName: "offer_status";
3734
+ dataType: "number";
3735
+ columnType: "PgBigInt53";
3736
+ data: number;
3737
+ driverParam: string | number;
3738
+ notNull: true;
3739
+ hasDefault: false;
3740
+ isPrimaryKey: false;
3741
+ isAutoincrement: false;
3742
+ hasRuntimeDefault: false;
3743
+ enumValues: undefined;
3744
+ baseColumn: never;
3745
+ identity: undefined;
3746
+ generated: undefined;
3747
+ }, {}, {}>;
3748
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
3749
+ name: "updated_at";
3750
+ tableName: "offer_status";
3751
+ dataType: "date";
3752
+ columnType: "PgTimestamp";
3753
+ data: Date;
3754
+ driverParam: string;
3755
+ notNull: true;
3756
+ hasDefault: true;
3757
+ isPrimaryKey: false;
3758
+ isAutoincrement: false;
3759
+ hasRuntimeDefault: false;
3760
+ enumValues: undefined;
3761
+ baseColumn: never;
3762
+ identity: undefined;
3763
+ generated: undefined;
3764
+ }, {}, {}>;
3765
+ };
3766
+ dialect: "pg";
3767
+ }>;
3768
+ declare const collectors: drizzle_orm_pg_core.PgTableWithColumns<{
3769
+ name: "collectors";
3770
+ schema: "router_v1.5";
3771
+ columns: {
3772
+ chainId: drizzle_orm_pg_core.PgColumn<{
3773
+ name: "chain_id";
3774
+ tableName: "collectors";
3775
+ dataType: "bigint";
3776
+ columnType: "PgBigInt64";
3777
+ data: bigint;
3778
+ driverParam: string;
3779
+ notNull: true;
3780
+ hasDefault: false;
3781
+ isPrimaryKey: false;
3782
+ isAutoincrement: false;
3783
+ hasRuntimeDefault: false;
3784
+ enumValues: undefined;
3785
+ baseColumn: never;
3786
+ identity: undefined;
3787
+ generated: undefined;
3788
+ }, {}, {}>;
3789
+ name: drizzle_orm_pg_core.PgColumn<{
3790
+ name: "name";
3791
+ tableName: "collectors";
3792
+ dataType: "string";
3793
+ columnType: "PgText";
3794
+ data: "mempool_offers" | "consumed_events" | "buy_with_empty_callback_liquidity" | "buy_vault_v1_callback_liquidity" | "sell_erc20_callback_liquidity";
3795
+ driverParam: string;
3796
+ notNull: true;
3797
+ hasDefault: false;
3798
+ isPrimaryKey: false;
3799
+ isAutoincrement: false;
3800
+ hasRuntimeDefault: false;
3801
+ enumValues: [string, ...string[]];
3802
+ baseColumn: never;
3803
+ identity: undefined;
3804
+ generated: undefined;
3805
+ }, {}, {
3806
+ $type: "mempool_offers" | "consumed_events" | "buy_with_empty_callback_liquidity" | "buy_vault_v1_callback_liquidity" | "sell_erc20_callback_liquidity";
3807
+ }>;
3808
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
3809
+ name: "block_number";
3810
+ tableName: "collectors";
3811
+ dataType: "number";
3812
+ columnType: "PgBigInt53";
3813
+ data: number;
3814
+ driverParam: string | number;
3815
+ notNull: true;
3816
+ hasDefault: false;
3817
+ isPrimaryKey: false;
3818
+ isAutoincrement: false;
3819
+ hasRuntimeDefault: false;
3820
+ enumValues: undefined;
3821
+ baseColumn: never;
3822
+ identity: undefined;
3823
+ generated: undefined;
3824
+ }, {}, {}>;
3825
+ epoch: drizzle_orm_pg_core.PgColumn<{
3826
+ name: "epoch";
3827
+ tableName: "collectors";
3828
+ dataType: "string";
3829
+ columnType: "PgNumeric";
2198
3830
  data: string;
2199
3831
  driverParam: string;
2200
3832
  notNull: true;
2201
- hasDefault: false;
2202
- isPrimaryKey: true;
3833
+ hasDefault: true;
3834
+ isPrimaryKey: false;
2203
3835
  isAutoincrement: false;
2204
3836
  hasRuntimeDefault: false;
2205
- enumValues: [string, ...string[]];
3837
+ enumValues: undefined;
2206
3838
  baseColumn: never;
2207
3839
  identity: undefined;
2208
3840
  generated: undefined;
2209
- }, {}, {
2210
- length: 66;
2211
- }>;
3841
+ }, {}, {}>;
3842
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
3843
+ name: "updated_at";
3844
+ tableName: "collectors";
3845
+ dataType: "date";
3846
+ columnType: "PgTimestamp";
3847
+ data: Date;
3848
+ driverParam: string;
3849
+ notNull: true;
3850
+ hasDefault: true;
3851
+ isPrimaryKey: false;
3852
+ isAutoincrement: false;
3853
+ hasRuntimeDefault: false;
3854
+ enumValues: undefined;
3855
+ baseColumn: never;
3856
+ identity: undefined;
3857
+ generated: undefined;
3858
+ }, {}, {}>;
3859
+ };
3860
+ dialect: "pg";
3861
+ }>;
3862
+ declare const chains: drizzle_orm_pg_core.PgTableWithColumns<{
3863
+ name: "chains";
3864
+ schema: "router_v1.5";
3865
+ columns: {
2212
3866
  chainId: drizzle_orm_pg_core.PgColumn<{
2213
3867
  name: "chain_id";
2214
- tableName: "obligations";
3868
+ tableName: "chains";
2215
3869
  dataType: "bigint";
2216
3870
  columnType: "PgBigInt64";
2217
3871
  data: bigint;
@@ -2226,34 +3880,49 @@ declare const obligations: drizzle_orm_pg_core.PgTableWithColumns<{
2226
3880
  identity: undefined;
2227
3881
  generated: undefined;
2228
3882
  }, {}, {}>;
2229
- loanToken: drizzle_orm_pg_core.PgColumn<{
2230
- name: "loan_token";
2231
- tableName: "obligations";
3883
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
3884
+ name: "block_number";
3885
+ tableName: "chains";
3886
+ dataType: "number";
3887
+ columnType: "PgBigInt53";
3888
+ data: number;
3889
+ driverParam: string | number;
3890
+ notNull: true;
3891
+ hasDefault: false;
3892
+ isPrimaryKey: false;
3893
+ isAutoincrement: false;
3894
+ hasRuntimeDefault: false;
3895
+ enumValues: undefined;
3896
+ baseColumn: never;
3897
+ identity: undefined;
3898
+ generated: undefined;
3899
+ }, {}, {}>;
3900
+ epoch: drizzle_orm_pg_core.PgColumn<{
3901
+ name: "epoch";
3902
+ tableName: "chains";
2232
3903
  dataType: "string";
2233
- columnType: "PgVarchar";
3904
+ columnType: "PgNumeric";
2234
3905
  data: string;
2235
3906
  driverParam: string;
2236
3907
  notNull: true;
2237
- hasDefault: false;
3908
+ hasDefault: true;
2238
3909
  isPrimaryKey: false;
2239
3910
  isAutoincrement: false;
2240
3911
  hasRuntimeDefault: false;
2241
- enumValues: [string, ...string[]];
3912
+ enumValues: undefined;
2242
3913
  baseColumn: never;
2243
3914
  identity: undefined;
2244
3915
  generated: undefined;
2245
- }, {}, {
2246
- length: 42;
2247
- }>;
2248
- maturity: drizzle_orm_pg_core.PgColumn<{
2249
- name: "maturity";
2250
- tableName: "obligations";
2251
- dataType: "number";
2252
- columnType: "PgInteger";
2253
- data: number;
2254
- driverParam: string | number;
3916
+ }, {}, {}>;
3917
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
3918
+ name: "updated_at";
3919
+ tableName: "chains";
3920
+ dataType: "date";
3921
+ columnType: "PgTimestamp";
3922
+ data: Date;
3923
+ driverParam: string;
2255
3924
  notNull: true;
2256
- hasDefault: false;
3925
+ hasDefault: true;
2257
3926
  isPrimaryKey: false;
2258
3927
  isAutoincrement: false;
2259
3928
  hasRuntimeDefault: false;
@@ -2267,7 +3936,7 @@ declare const obligations: drizzle_orm_pg_core.PgTableWithColumns<{
2267
3936
  }>;
2268
3937
  declare const offers: drizzle_orm_pg_core.PgTableWithColumns<{
2269
3938
  name: "offers";
2270
- schema: "router_v1.4";
3939
+ schema: "router_v1.5";
2271
3940
  columns: {
2272
3941
  hash: drizzle_orm_pg_core.PgColumn<{
2273
3942
  name: "hash";
@@ -2592,7 +4261,7 @@ declare const offers: drizzle_orm_pg_core.PgTableWithColumns<{
2592
4261
  }>;
2593
4262
  declare const obligationCollaterals: drizzle_orm_pg_core.PgTableWithColumns<{
2594
4263
  name: "obligation_collaterals";
2595
- schema: "router_v1.4";
4264
+ schema: "router_v1.5";
2596
4265
  columns: {
2597
4266
  obligationId: drizzle_orm_pg_core.PgColumn<{
2598
4267
  name: "obligation_id";
@@ -2673,7 +4342,7 @@ declare const obligationCollaterals: drizzle_orm_pg_core.PgTableWithColumns<{
2673
4342
  }>;
2674
4343
  declare const consumed: drizzle_orm_pg_core.PgTableWithColumns<{
2675
4344
  name: "consumed_per_user_and_nonce";
2676
- schema: "router_v1.4";
4345
+ schema: "router_v1.5";
2677
4346
  columns: {
2678
4347
  id: drizzle_orm_pg_core.PgColumn<{
2679
4348
  name: "id";
@@ -2731,159 +4400,14 @@ declare const consumed: drizzle_orm_pg_core.PgTableWithColumns<{
2731
4400
  length: 42;
2732
4401
  }>;
2733
4402
  nonce: drizzle_orm_pg_core.PgColumn<{
2734
- name: "nonce";
2735
- tableName: "consumed_per_user_and_nonce";
2736
- dataType: "bigint";
2737
- columnType: "PgBigInt64";
2738
- data: bigint;
2739
- driverParam: string;
2740
- notNull: true;
2741
- hasDefault: false;
2742
- isPrimaryKey: false;
2743
- isAutoincrement: false;
2744
- hasRuntimeDefault: false;
2745
- enumValues: undefined;
2746
- baseColumn: never;
2747
- identity: undefined;
2748
- generated: undefined;
2749
- }, {}, {}>;
2750
- consumed: drizzle_orm_pg_core.PgColumn<{
2751
- name: "consumed";
2752
- tableName: "consumed_per_user_and_nonce";
2753
- dataType: "string";
2754
- columnType: "PgNumeric";
2755
- data: string;
2756
- driverParam: string;
2757
- notNull: true;
2758
- hasDefault: false;
2759
- isPrimaryKey: false;
2760
- isAutoincrement: false;
2761
- hasRuntimeDefault: false;
2762
- enumValues: undefined;
2763
- baseColumn: never;
2764
- identity: undefined;
2765
- generated: undefined;
2766
- }, {}, {}>;
2767
- blockNumber: drizzle_orm_pg_core.PgColumn<{
2768
- name: "block_number";
2769
- tableName: "consumed_per_user_and_nonce";
2770
- dataType: "number";
2771
- columnType: "PgBigInt53";
2772
- data: number;
2773
- driverParam: string | number;
2774
- notNull: true;
2775
- hasDefault: false;
2776
- isPrimaryKey: false;
2777
- isAutoincrement: false;
2778
- hasRuntimeDefault: false;
2779
- enumValues: undefined;
2780
- baseColumn: never;
2781
- identity: undefined;
2782
- generated: undefined;
2783
- }, {}, {}>;
2784
- createdAt: drizzle_orm_pg_core.PgColumn<{
2785
- name: "created_at";
2786
- tableName: "consumed_per_user_and_nonce";
2787
- dataType: "date";
2788
- columnType: "PgTimestamp";
2789
- data: Date;
2790
- driverParam: string;
2791
- notNull: true;
2792
- hasDefault: true;
2793
- isPrimaryKey: false;
2794
- isAutoincrement: false;
2795
- hasRuntimeDefault: false;
2796
- enumValues: undefined;
2797
- baseColumn: never;
2798
- identity: undefined;
2799
- generated: undefined;
2800
- }, {}, {}>;
2801
- };
2802
- dialect: "pg";
2803
- }>;
2804
- declare const collectors: drizzle_orm_pg_core.PgTableWithColumns<{
2805
- name: "collectors";
2806
- schema: "router_v1.4";
2807
- columns: {
2808
- chainId: drizzle_orm_pg_core.PgColumn<{
2809
- name: "chain_id";
2810
- tableName: "collectors";
2811
- dataType: "bigint";
2812
- columnType: "PgBigInt64";
2813
- data: bigint;
2814
- driverParam: string;
2815
- notNull: true;
2816
- hasDefault: false;
2817
- isPrimaryKey: false;
2818
- isAutoincrement: false;
2819
- hasRuntimeDefault: false;
2820
- enumValues: undefined;
2821
- baseColumn: never;
2822
- identity: undefined;
2823
- generated: undefined;
2824
- }, {}, {}>;
2825
- name: drizzle_orm_pg_core.PgColumn<{
2826
- name: "name";
2827
- tableName: "collectors";
2828
- dataType: "string";
2829
- columnType: "PgText";
2830
- data: "mempool_offers" | "consumed_events" | "buy_with_empty_callback_liquidity" | "buy_vault_v1_callback_liquidity" | "sell_erc20_callback_liquidity";
2831
- driverParam: string;
2832
- notNull: true;
2833
- hasDefault: false;
2834
- isPrimaryKey: false;
2835
- isAutoincrement: false;
2836
- hasRuntimeDefault: false;
2837
- enumValues: [string, ...string[]];
2838
- baseColumn: never;
2839
- identity: undefined;
2840
- generated: undefined;
2841
- }, {}, {
2842
- $type: "mempool_offers" | "consumed_events" | "buy_with_empty_callback_liquidity" | "buy_vault_v1_callback_liquidity" | "sell_erc20_callback_liquidity";
2843
- }>;
2844
- blockNumber: drizzle_orm_pg_core.PgColumn<{
2845
- name: "block_number";
2846
- tableName: "collectors";
2847
- dataType: "number";
2848
- columnType: "PgBigInt53";
2849
- data: number;
2850
- driverParam: string | number;
2851
- notNull: true;
2852
- hasDefault: false;
2853
- isPrimaryKey: false;
2854
- isAutoincrement: false;
2855
- hasRuntimeDefault: false;
2856
- enumValues: undefined;
2857
- baseColumn: never;
2858
- identity: undefined;
2859
- generated: undefined;
2860
- }, {}, {}>;
2861
- epoch: drizzle_orm_pg_core.PgColumn<{
2862
- name: "epoch";
2863
- tableName: "collectors";
2864
- dataType: "string";
2865
- columnType: "PgNumeric";
2866
- data: string;
2867
- driverParam: string;
2868
- notNull: true;
2869
- hasDefault: true;
2870
- isPrimaryKey: false;
2871
- isAutoincrement: false;
2872
- hasRuntimeDefault: false;
2873
- enumValues: undefined;
2874
- baseColumn: never;
2875
- identity: undefined;
2876
- generated: undefined;
2877
- }, {}, {}>;
2878
- updatedAt: drizzle_orm_pg_core.PgColumn<{
2879
- name: "updated_at";
2880
- tableName: "collectors";
2881
- dataType: "date";
2882
- columnType: "PgTimestamp";
2883
- data: Date;
4403
+ name: "nonce";
4404
+ tableName: "consumed_per_user_and_nonce";
4405
+ dataType: "bigint";
4406
+ columnType: "PgBigInt64";
4407
+ data: bigint;
2884
4408
  driverParam: string;
2885
4409
  notNull: true;
2886
- hasDefault: true;
4410
+ hasDefault: false;
2887
4411
  isPrimaryKey: false;
2888
4412
  isAutoincrement: false;
2889
4413
  hasRuntimeDefault: false;
@@ -2892,19 +4416,12 @@ declare const collectors: drizzle_orm_pg_core.PgTableWithColumns<{
2892
4416
  identity: undefined;
2893
4417
  generated: undefined;
2894
4418
  }, {}, {}>;
2895
- };
2896
- dialect: "pg";
2897
- }>;
2898
- declare const chains: drizzle_orm_pg_core.PgTableWithColumns<{
2899
- name: "chains";
2900
- schema: "router_v1.4";
2901
- columns: {
2902
- chainId: drizzle_orm_pg_core.PgColumn<{
2903
- name: "chain_id";
2904
- tableName: "chains";
2905
- dataType: "bigint";
2906
- columnType: "PgBigInt64";
2907
- data: bigint;
4419
+ consumed: drizzle_orm_pg_core.PgColumn<{
4420
+ name: "consumed";
4421
+ tableName: "consumed_per_user_and_nonce";
4422
+ dataType: "string";
4423
+ columnType: "PgNumeric";
4424
+ data: string;
2908
4425
  driverParam: string;
2909
4426
  notNull: true;
2910
4427
  hasDefault: false;
@@ -2918,7 +4435,7 @@ declare const chains: drizzle_orm_pg_core.PgTableWithColumns<{
2918
4435
  }, {}, {}>;
2919
4436
  blockNumber: drizzle_orm_pg_core.PgColumn<{
2920
4437
  name: "block_number";
2921
- tableName: "chains";
4438
+ tableName: "consumed_per_user_and_nonce";
2922
4439
  dataType: "number";
2923
4440
  columnType: "PgBigInt53";
2924
4441
  data: number;
@@ -2933,26 +4450,9 @@ declare const chains: drizzle_orm_pg_core.PgTableWithColumns<{
2933
4450
  identity: undefined;
2934
4451
  generated: undefined;
2935
4452
  }, {}, {}>;
2936
- epoch: drizzle_orm_pg_core.PgColumn<{
2937
- name: "epoch";
2938
- tableName: "chains";
2939
- dataType: "string";
2940
- columnType: "PgNumeric";
2941
- data: string;
2942
- driverParam: string;
2943
- notNull: true;
2944
- hasDefault: true;
2945
- isPrimaryKey: false;
2946
- isAutoincrement: false;
2947
- hasRuntimeDefault: false;
2948
- enumValues: undefined;
2949
- baseColumn: never;
2950
- identity: undefined;
2951
- generated: undefined;
2952
- }, {}, {}>;
2953
- updatedAt: drizzle_orm_pg_core.PgColumn<{
2954
- name: "updated_at";
2955
- tableName: "chains";
4453
+ createdAt: drizzle_orm_pg_core.PgColumn<{
4454
+ name: "created_at";
4455
+ tableName: "consumed_per_user_and_nonce";
2956
4456
  dataType: "date";
2957
4457
  columnType: "PgTimestamp";
2958
4458
  data: Date;
@@ -2972,7 +4472,7 @@ declare const chains: drizzle_orm_pg_core.PgTableWithColumns<{
2972
4472
  }>;
2973
4473
  declare const offerLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
2974
4474
  name: "offer_liquidity_pools";
2975
- schema: "router_v1.4";
4475
+ schema: "router_v1.5";
2976
4476
  columns: {
2977
4477
  offerHash: drizzle_orm_pg_core.PgColumn<{
2978
4478
  name: "offer_hash";
@@ -3029,6 +4529,23 @@ declare const offerLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
3029
4529
  identity: undefined;
3030
4530
  generated: undefined;
3031
4531
  }, {}, {}>;
4532
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
4533
+ name: "block_number";
4534
+ tableName: "offer_liquidity_pools";
4535
+ dataType: "number";
4536
+ columnType: "PgBigInt53";
4537
+ data: number;
4538
+ driverParam: string | number;
4539
+ notNull: true;
4540
+ hasDefault: false;
4541
+ isPrimaryKey: false;
4542
+ isAutoincrement: false;
4543
+ hasRuntimeDefault: false;
4544
+ enumValues: undefined;
4545
+ baseColumn: never;
4546
+ identity: undefined;
4547
+ generated: undefined;
4548
+ }, {}, {}>;
3032
4549
  updatedAt: drizzle_orm_pg_core.PgColumn<{
3033
4550
  name: "updated_at";
3034
4551
  tableName: "offer_liquidity_pools";
@@ -3051,7 +4568,7 @@ declare const offerLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
3051
4568
  }>;
3052
4569
  declare const liquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
3053
4570
  name: "liquidity_pools";
3054
- schema: "router_v1.4";
4571
+ schema: "router_v1.5";
3055
4572
  columns: {
3056
4573
  id: drizzle_orm_pg_core.PgColumn<{
3057
4574
  name: "id";
@@ -3089,6 +4606,23 @@ declare const liquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
3089
4606
  identity: undefined;
3090
4607
  generated: undefined;
3091
4608
  }, {}, {}>;
4609
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
4610
+ name: "block_number";
4611
+ tableName: "liquidity_pools";
4612
+ dataType: "number";
4613
+ columnType: "PgBigInt53";
4614
+ data: number;
4615
+ driverParam: string | number;
4616
+ notNull: true;
4617
+ hasDefault: false;
4618
+ isPrimaryKey: false;
4619
+ isAutoincrement: false;
4620
+ hasRuntimeDefault: false;
4621
+ enumValues: undefined;
4622
+ baseColumn: never;
4623
+ identity: undefined;
4624
+ generated: undefined;
4625
+ }, {}, {}>;
3092
4626
  updatedAt: drizzle_orm_pg_core.PgColumn<{
3093
4627
  name: "updated_at";
3094
4628
  tableName: "liquidity_pools";
@@ -3111,7 +4645,7 @@ declare const liquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
3111
4645
  }>;
3112
4646
  declare const liquidityLinks: drizzle_orm_pg_core.PgTableWithColumns<{
3113
4647
  name: "liquidity_links";
3114
- schema: "router_v1.4";
4648
+ schema: "router_v1.5";
3115
4649
  columns: {
3116
4650
  parentPoolId: drizzle_orm_pg_core.PgColumn<{
3117
4651
  name: "parent_pool_id";
@@ -3168,6 +4702,23 @@ declare const liquidityLinks: drizzle_orm_pg_core.PgTableWithColumns<{
3168
4702
  identity: undefined;
3169
4703
  generated: undefined;
3170
4704
  }, {}, {}>;
4705
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
4706
+ name: "block_number";
4707
+ tableName: "liquidity_links";
4708
+ dataType: "number";
4709
+ columnType: "PgBigInt53";
4710
+ data: number;
4711
+ driverParam: string | number;
4712
+ notNull: true;
4713
+ hasDefault: false;
4714
+ isPrimaryKey: false;
4715
+ isAutoincrement: false;
4716
+ hasRuntimeDefault: false;
4717
+ enumValues: undefined;
4718
+ baseColumn: never;
4719
+ identity: undefined;
4720
+ generated: undefined;
4721
+ }, {}, {}>;
3171
4722
  updatedAt: drizzle_orm_pg_core.PgColumn<{
3172
4723
  name: "updated_at";
3173
4724
  tableName: "liquidity_links";
@@ -3189,18 +4740,28 @@ declare const liquidityLinks: drizzle_orm_pg_core.PgTableWithColumns<{
3189
4740
  dialect: "pg";
3190
4741
  }>;
3191
4742
 
3192
- declare const schema_VERSION: typeof VERSION;
3193
- declare const schema_chains: typeof chains;
3194
- declare const schema_collectors: typeof collectors;
3195
- declare const schema_consumed: typeof consumed;
3196
- declare const schema_liquidityLinks: typeof liquidityLinks;
3197
- declare const schema_liquidityPools: typeof liquidityPools;
3198
- declare const schema_obligationCollaterals: typeof obligationCollaterals;
3199
- declare const schema_obligations: typeof obligations;
3200
- declare const schema_offerLiquidityPools: typeof offerLiquidityPools;
3201
- declare const schema_offers: typeof offers;
3202
- declare namespace schema {
3203
- 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 };
4743
+ declare const VERSION: "router_v1.5";
4744
+
4745
+ declare const index$2_VERSION: typeof VERSION;
4746
+ declare const index$2_chains: typeof chains;
4747
+ declare const index$2_collectors: typeof collectors;
4748
+ declare const index$2_consumed: typeof consumed;
4749
+ declare const index$2_consumedEvents: typeof consumedEvents;
4750
+ declare const index$2_groups: typeof groups;
4751
+ declare const index$2_liquidityLinks: typeof liquidityLinks;
4752
+ declare const index$2_liquidityPools: typeof liquidityPools;
4753
+ declare const index$2_obligationCollaterals: typeof obligationCollaterals;
4754
+ declare const index$2_obligationCollateralsV2: typeof obligationCollateralsV2;
4755
+ declare const index$2_obligations: typeof obligations;
4756
+ declare const index$2_offerLiquidityPools: typeof offerLiquidityPools;
4757
+ declare const index$2_offerStatus: typeof offerStatus;
4758
+ declare const index$2_offers: typeof offers;
4759
+ declare const index$2_offersV2: typeof offersV2;
4760
+ declare const index$2_oracles: typeof oracles;
4761
+ declare const index$2_status: typeof status;
4762
+ declare const index$2_statusCode: typeof statusCode;
4763
+ declare namespace index$2 {
4764
+ export { index$2_VERSION as VERSION, index$2_chains as chains, index$2_collectors as collectors, index$2_consumed as consumed, index$2_consumedEvents as consumedEvents, index$2_groups as groups, index$2_liquidityLinks as liquidityLinks, index$2_liquidityPools as liquidityPools, index$2_obligationCollaterals as obligationCollaterals, index$2_obligationCollateralsV2 as obligationCollateralsV2, index$2_obligations as obligations, index$2_offerLiquidityPools as offerLiquidityPools, index$2_offerStatus as offerStatus, index$2_offers as offers, index$2_offersV2 as offersV2, index$2_oracles as oracles, index$2_status as status, index$2_statusCode as statusCode };
3204
4765
  }
3205
4766
 
3206
4767
  type Cursor = {
@@ -3225,6 +4786,250 @@ declare namespace Cursor$1 {
3225
4786
  export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
3226
4787
  }
3227
4788
 
4789
+ type GateConfig = {
4790
+ callbacks?: CallbackConfig[];
4791
+ maturities?: MaturityType[];
4792
+ };
4793
+ type CallbackConfig = {
4794
+ type: CallbackType.BuyVaultV1Callback;
4795
+ addresses: Address[];
4796
+ vaultFactories: Address[];
4797
+ } | {
4798
+ type: CallbackType.SellERC20Callback;
4799
+ addresses: Address[];
4800
+ } | {
4801
+ type: CallbackType.BuyWithEmptyCallback;
4802
+ };
4803
+ declare function getCallback(chain: ChainName, type: CallbackType.BuyVaultV1Callback): Extract<CallbackConfig, {
4804
+ type: CallbackType.BuyVaultV1Callback;
4805
+ }> | undefined;
4806
+ declare function getCallback(chain: ChainName, type: CallbackType.SellERC20Callback): Extract<CallbackConfig, {
4807
+ type: CallbackType.SellERC20Callback;
4808
+ }> | undefined;
4809
+ declare function getCallback(chain: ChainName, type: CallbackType.BuyWithEmptyCallback): Extract<CallbackConfig, {
4810
+ type: CallbackType.BuyWithEmptyCallback;
4811
+ }> | undefined;
4812
+ declare function getCallback(chain: ChainName, type: CallbackType): CallbackConfig | undefined;
4813
+ /**
4814
+ * Attempts to infer the configured callback type from a callback address on a chain.
4815
+ * Skips the empty callback type as it does not carry addresses.
4816
+ *
4817
+ * @param chain - Chain name for which to infer the callback type
4818
+ * @param address - Callback contract address
4819
+ * @returns The callback type when found, otherwise undefined
4820
+ */
4821
+ declare function getCallbackType(chain: ChainName, address: Address): CallbackType | undefined;
4822
+ /**
4823
+ * Returns the callback addresses for a given chain and callback type, if it exists.
4824
+ * @param chain - Chain name for which to read the validation configuration
4825
+ * @param type - Callback type to retrieve
4826
+ * @returns The matching callback addresses or an empty array if not configured
4827
+ */
4828
+ declare function getCallbackTypeAddresses(chain: ChainName, type: CallbackType): Address[];
4829
+ /**
4830
+ * Returns the list of allowed non-empty callback addresses for a chain.
4831
+ *
4832
+ * @param chain - Chain name
4833
+ * @returns Array of allowed callback addresses (lowercased). Empty when none configured
4834
+ */
4835
+ declare const getCallbackAddresses: (chain: ChainName) => Address[];
4836
+ declare const assets: Record<string, Address[]>;
4837
+ declare const configs: Record<ChainName, GateConfig>;
4838
+
4839
+ type GateConfig$1_CallbackConfig = CallbackConfig;
4840
+ type GateConfig$1_GateConfig = GateConfig;
4841
+ declare const GateConfig$1_assets: typeof assets;
4842
+ declare const GateConfig$1_configs: typeof configs;
4843
+ declare const GateConfig$1_getCallback: typeof getCallback;
4844
+ declare const GateConfig$1_getCallbackAddresses: typeof getCallbackAddresses;
4845
+ declare const GateConfig$1_getCallbackType: typeof getCallbackType;
4846
+ declare const GateConfig$1_getCallbackTypeAddresses: typeof getCallbackTypeAddresses;
4847
+ declare namespace GateConfig$1 {
4848
+ export { type GateConfig$1_CallbackConfig as CallbackConfig, type GateConfig$1_GateConfig as GateConfig, GateConfig$1_assets as assets, GateConfig$1_configs as configs, GateConfig$1_getCallback as getCallback, GateConfig$1_getCallbackAddresses as getCallbackAddresses, GateConfig$1_getCallbackType as getCallbackType, GateConfig$1_getCallbackTypeAddresses as getCallbackTypeAddresses };
4849
+ }
4850
+
4851
+ type ValidityParameters = {
4852
+ chain: Chain;
4853
+ client: PublicClient;
4854
+ };
4855
+ /**
4856
+ * set of rules to validate offers.
4857
+ *
4858
+ * @param parameters - Validity parameters with chain and client
4859
+ * @returns Array of validation rules to evaluate against offers
4860
+ */
4861
+ declare function validity(parameters: ValidityParameters): (Rule<Offer, "sell_erc20_callback_invalid"> | Rule<Offer, "buy_offers_callback_vault_invalid"> | Rule<Offer, "expiry">)[];
4862
+ declare const chain: ({ chain }: {
4863
+ chain: Chain;
4864
+ }) => Rule<Offer, "chain_id">;
4865
+ declare const maturity: ({ maturities }: {
4866
+ maturities: MaturityType[];
4867
+ }) => Rule<Offer, "maturity">;
4868
+ declare const callback: ({ callbacks, allowedAddresses, }: {
4869
+ callbacks: CallbackType[];
4870
+ allowedAddresses: Address[];
4871
+ }) => Rule<Offer, "callback">;
4872
+ /**
4873
+ * A validation rule that checks if the offer's token is allowed.
4874
+ * @param offer - The offer to validate.
4875
+ * @returns The issue that was found. If the offer is valid, this will be undefined.
4876
+ */
4877
+ declare const token: ({ assets }: {
4878
+ assets: Address[];
4879
+ }) => Rule<Offer, "token">;
4880
+
4881
+ type Rules_ValidityParameters = ValidityParameters;
4882
+ declare const Rules_callback: typeof callback;
4883
+ declare const Rules_chain: typeof chain;
4884
+ declare const Rules_maturity: typeof maturity;
4885
+ declare const Rules_token: typeof token;
4886
+ declare const Rules_validity: typeof validity;
4887
+ declare namespace Rules {
4888
+ export { type Rules_ValidityParameters as ValidityParameters, Rules_callback as callback, Rules_chain as chain, Rules_maturity as maturity, Rules_token as token, Rules_validity as validity };
4889
+ }
4890
+
4891
+ type Indexer = {
4892
+ start: () => () => void;
4893
+ };
4894
+ type IndexerConfig = {
4895
+ chain: Chain;
4896
+ rpcUrl: string;
4897
+ db: PG;
4898
+ gatekeeper?: Gatekeeper;
4899
+ interval?: number;
4900
+ maxBatchSize?: number;
4901
+ maxBlockNumber?: number;
4902
+ };
4903
+ declare function from$1(config: IndexerConfig): Indexer;
4904
+ declare function create(params: {
4905
+ collectors: Collector[];
4906
+ }): Indexer;
4907
+
4908
+ type Indexer$1_Indexer = Indexer;
4909
+ type Indexer$1_IndexerConfig = IndexerConfig;
4910
+ declare const Indexer$1_create: typeof create;
4911
+ declare namespace Indexer$1 {
4912
+ export { type Indexer$1_Indexer as Indexer, type Indexer$1_IndexerConfig as IndexerConfig, Indexer$1_create as create, from$1 as from };
4913
+ }
4914
+
4915
+ type MempoolEVMClientConfig = {
4916
+ readonly client: WalletClient;
4917
+ readonly mempoolAddress: Address;
4918
+ readonly blockWindow: number;
4919
+ };
4920
+ declare function from(parameters: from.Parameters): from.ReturnType;
4921
+ declare namespace from {
4922
+ type Parameters = {
4923
+ /** The viem client to use. */
4924
+ client: WalletClient;
4925
+ /** The mempool address. */
4926
+ mempoolAddress: Address;
4927
+ /** The block window to use for the mempool. Defaults to 100. */
4928
+ blockWindow?: number;
4929
+ };
4930
+ type ReturnType = Client;
4931
+ type ErrorType = null;
4932
+ }
4933
+ /**
4934
+ * Add an offer to the mempool.
4935
+ * @returns The created offer with its hash.
4936
+ * @throws WalletAccountNotSetError if the wallet account is not set.
4937
+ * @throws ViemClientError if the viem client throws an error.
4938
+ * @throws Offer.InvalidOfferError if the offer is invalid.
4939
+ */
4940
+ declare function add(config: MempoolEVMClientConfig, offers: AddParameters): Promise<Hex>;
4941
+ declare namespace add {
4942
+ type ErrorType = WalletAccountNotSetError | ViemClientError | InvalidOfferError | ChainIdMismatchError;
4943
+ }
4944
+ declare function get(config: MempoolEVMClientConfig, parameters?: GetParameters): AsyncGenerator<{
4945
+ offers: Offer[];
4946
+ blockNumber: number;
4947
+ }, void, void>;
4948
+ declare namespace get {
4949
+ type ErrorType = streamOffersReturnType;
4950
+ }
4951
+ type streamOffersReturnType = WalletAccountNotSetError | ChainIdMismatchError;
4952
+ declare class WalletAccountNotSetError extends BaseError {
4953
+ name: string;
4954
+ constructor();
4955
+ }
4956
+ declare class ViemClientError extends BaseError {
4957
+ name: string;
4958
+ }
4959
+ declare class ChainIdMismatchError extends BaseError {
4960
+ name: string;
4961
+ constructor(expected: bigint, actual: bigint);
4962
+ }
4963
+
4964
+ type AddParameters = Compute<Omit<Offer, "hash" | "createdAt">[]>;
4965
+ type GetParameters = {
4966
+ /** The block number to get offers from. */
4967
+ blockNumberGte?: number;
4968
+ /** The block number to get offers to. */
4969
+ blockNumberLte?: number;
4970
+ /** The loan asset to get offers from. */
4971
+ loanToken?: string;
4972
+ /** The order to get offers. Defaults to "desc". */
4973
+ order?: "asc" | "desc";
4974
+ /** The options to get offers from. */
4975
+ options?: {
4976
+ /** The maximum number of offers to return. Defaults to 100. Maximum is 1000. */
4977
+ maxBatchSize?: number;
4978
+ };
4979
+ };
4980
+ /**
4981
+ * Mempool client interface.
4982
+ */
4983
+ type Client = {
4984
+ /**
4985
+ * Add an offer to the mempool.
4986
+ * @returns The created offer with its hash.
4987
+ */
4988
+ add: (parameters: AddParameters) => Promise<Hex>;
4989
+ /** Get offers from the mempool. */
4990
+ get: (parameters?: GetParameters) => AsyncGenerator<{
4991
+ offers: Offer[];
4992
+ /** The block number of the last processed offer. Depends on the `order` parameter, block numbers will ascend or descend. */
4993
+ blockNumber: number;
4994
+ }>;
4995
+ /**
4996
+ * Stream offers from the mempool.
4997
+ * @returns A generator of offers alongside the last block number processed.
4998
+ */
4999
+ stream: (parameters: Compute<Omit<GetParameters, "options"> & {
5000
+ options: GetParameters["options"] & {
5001
+ blockWindow?: number;
5002
+ };
5003
+ }>) => AsyncGenerator<{
5004
+ offers: Offer[];
5005
+ blockNumber: number;
5006
+ }>;
5007
+ };
5008
+ /**
5009
+ * Client to interact with the Mempool contract on a specific chain.
5010
+ */
5011
+ declare function connect(parameters: from.Parameters): Client;
5012
+ declare namespace connect {
5013
+ type ErrorType = from.ErrorType;
5014
+ }
5015
+
5016
+ type index$1_AddParameters = AddParameters;
5017
+ type index$1_ChainIdMismatchError = ChainIdMismatchError;
5018
+ declare const index$1_ChainIdMismatchError: typeof ChainIdMismatchError;
5019
+ type index$1_Client = Client;
5020
+ type index$1_GetParameters = GetParameters;
5021
+ type index$1_ViemClientError = ViemClientError;
5022
+ declare const index$1_ViemClientError: typeof ViemClientError;
5023
+ type index$1_WalletAccountNotSetError = WalletAccountNotSetError;
5024
+ declare const index$1_WalletAccountNotSetError: typeof WalletAccountNotSetError;
5025
+ declare const index$1_add: typeof add;
5026
+ declare const index$1_connect: typeof connect;
5027
+ declare const index$1_from: typeof from;
5028
+ declare const index$1_get: typeof get;
5029
+ declare namespace index$1 {
5030
+ 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, index$1_add as add, index$1_connect as connect, index$1_from as from, index$1_get as get };
5031
+ }
5032
+
3228
5033
  declare function max$1(a: bigint, b: bigint): bigint;
3229
5034
  declare function min(a: bigint, b: bigint): bigint;
3230
5035
 
@@ -3305,9 +5110,10 @@ declare const index_lazy: typeof lazy;
3305
5110
  declare const index_min: typeof min;
3306
5111
  declare const index_poll: typeof poll;
3307
5112
  declare const index_retry: typeof retry;
5113
+ declare const index_stringifyBigint: typeof stringifyBigint;
3308
5114
  declare const index_wait: typeof wait;
3309
5115
  declare namespace index {
3310
- 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 };
5116
+ export { index_BaseError as BaseError, type index_GlobalErrorType as GlobalErrorType, type index_Snake as Snake, time as Time, index_batch as batch, index_batchMulticall as batchMulticall, fromSnakeCase$3 as fromSnakeCase, index_lazy as lazy, max$1 as max, index_min as min, index_poll as poll, index_retry as retry, index_stringifyBigint as stringifyBigint, toSnakeCase$1 as toSnakeCase, index_wait as wait };
3311
5117
  }
3312
5118
 
3313
- 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, RouterIndexer, RouterStatusResponse, Services$1 as Services, time as Time, index as Utils, Validation, ValidationRule, parse, safeParse };
5119
+ export { Abi, type Brand, BrandTypeId, Callback, Chain$1 as Chain, ChainHealth, ChainStore$1 as ChainStore, ChainsHealthResponse, Collateral$1 as Collateral, index$4 as Collector, CollectorHealth, CollectorStore$1 as CollectorStore, CollectorsHealthResponse, type Compute, Cursor$1 as Cursor, Errors, Format, GateConfig$1 as GateConfig, Gatekeeper$1 as Gatekeeper, Health, HealthController, Indexer$1 as Indexer, 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, ObligationsController, Offer$1 as Offer, OfferResponse$1 as OfferResponse, OfferStore$1 as OfferStore, OffersController, index$2 as OffersSchema, OpenApi, PG$1 as PG, Quote$1 as Quote, RouterApi, Client$2 as RouterClient, RouterStatusResponse, Rules, Services$1 as Services, time as Time, Tree$1 as Tree, index as Utils, Gate as Validation, parse, safeParse };