@morpho-dev/router 0.0.17 → 0.0.19

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 (32) hide show
  1. package/dist/index.browser.d.cts +139 -12
  2. package/dist/index.browser.d.ts +139 -12
  3. package/dist/index.browser.js +533 -92
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.browser.mjs +534 -89
  6. package/dist/index.browser.mjs.map +1 -1
  7. package/dist/index.node.d.cts +132 -750
  8. package/dist/index.node.d.ts +132 -750
  9. package/dist/index.node.js +895 -1302
  10. package/dist/index.node.js.map +1 -1
  11. package/dist/index.node.mjs +894 -1291
  12. package/dist/index.node.mjs.map +1 -1
  13. package/package.json +3 -12
  14. package/dist/drizzle/0000_add-offers-table.sql +0 -37
  15. package/dist/drizzle/0001_create_offer_status_relation.sql +0 -10
  16. package/dist/drizzle/0002_add_created_at_in_offer_status_relation.sql +0 -3
  17. package/dist/drizzle/0003_add-cursor-indices-to-offers.sql +0 -6
  18. package/dist/drizzle/0004_offer-start.sql +0 -1
  19. package/dist/drizzle/0005_rename-price-token-buy.sql +0 -8
  20. package/dist/drizzle/0006_rename-buy.sql +0 -3
  21. package/dist/drizzle/0007_rename-offering.sql +0 -3
  22. package/dist/drizzle/0008_add-consumed-relation.sql +0 -10
  23. package/dist/drizzle/meta/0000_snapshot.json +0 -344
  24. package/dist/drizzle/meta/0001_snapshot.json +0 -426
  25. package/dist/drizzle/meta/0002_snapshot.json +0 -439
  26. package/dist/drizzle/meta/0003_snapshot.json +0 -553
  27. package/dist/drizzle/meta/0004_snapshot.json +0 -559
  28. package/dist/drizzle/meta/0005_snapshot.json +0 -559
  29. package/dist/drizzle/meta/0006_snapshot.json +0 -559
  30. package/dist/drizzle/meta/0007_snapshot.json +0 -559
  31. package/dist/drizzle/meta/0008_snapshot.json +0 -635
  32. package/dist/drizzle/meta/_journal.json +0 -69
@@ -1,19 +1,13 @@
1
1
  import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
- import { Compute, Offer, Errors, Format } from '@morpho-dev/mempool';
2
+ import { Compute, Offer, Errors, Format, Maturity, LLTV } from '@morpho-dev/mempool';
3
3
  export * from '@morpho-dev/mempool';
4
4
  import * as viem from 'viem';
5
- import { Address, Account, Hex, PublicClient } from 'viem';
5
+ import { Address, Hex, Account, PublicClient } from 'viem';
6
6
  import { Chain as Chain$2 } from 'viem/chains';
7
7
  import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
8
8
  import * as zod_v4 from 'zod/v4';
9
9
  import { z, ZodError } from 'zod/v4';
10
10
  import * as zod_v4_core from 'zod/v4/core';
11
- import { PGlite } from '@electric-sql/pglite';
12
- import { drizzle } from 'drizzle-orm/node-postgres';
13
- import { drizzle as drizzle$1 } from 'drizzle-orm/pglite';
14
- import { Pool } from 'pg';
15
- export * from 'drizzle-orm';
16
- import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
17
11
 
18
12
  declare const chainNames: readonly ["ethereum", "base"];
19
13
  type ChainName = (typeof chainNames)[number];
@@ -60,19 +54,19 @@ declare const schemas: {
60
54
  max_amount: z.ZodOptional<z.ZodBigInt>;
61
55
  min_rate: z.ZodOptional<z.ZodBigInt>;
62
56
  max_rate: z.ZodOptional<z.ZodBigInt>;
63
- min_maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
64
- max_maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
65
- min_expiry: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
66
- max_expiry: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
57
+ min_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
58
+ max_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
59
+ min_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
60
+ max_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
67
61
  collateral_assets: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
68
62
  collateral_oracles: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
69
63
  collateral_tuple: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
70
64
  asset: string;
71
65
  oracle: string | undefined;
72
- lltv: number | undefined;
66
+ lltv: (bigint & _morpho_dev_mempool.Brand<"LLTV">) | undefined;
73
67
  }[], string>>>;
74
- min_lltv: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
75
- max_lltv: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
68
+ min_lltv: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, number>>>;
69
+ max_lltv: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, number>>>;
76
70
  sort_by: z.ZodOptional<z.ZodEnum<{
77
71
  rate: "rate";
78
72
  maturity: "maturity";
@@ -96,11 +90,11 @@ declare const schemas: {
96
90
  collaterals: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
97
91
  asset: string;
98
92
  oracle: string;
99
- lltv: bigint;
93
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
100
94
  }[], string>>>;
101
- maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
102
- min_maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
103
- max_maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
95
+ maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
96
+ min_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
97
+ max_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
104
98
  loan_token: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
105
99
  creator: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
106
100
  status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
@@ -110,7 +104,7 @@ declare const schemas: {
110
104
  };
111
105
  type Action = keyof typeof schemas;
112
106
  declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
113
- declare function safeParse<A extends Action>(action: A, query: unknown): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
107
+ declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
114
108
 
115
109
  declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
116
110
  type OfferStatus = (typeof OfferStatusValues)[number];
@@ -224,14 +218,14 @@ declare function toResponse(routerOffer: RouterOffer): OfferResponse;
224
218
  */
225
219
  declare function fromResponse(offerResponse: OfferResponse): RouterOffer;
226
220
 
227
- type index$1_OfferResponse = OfferResponse;
228
- declare const index$1_OpenApi: typeof OpenApi;
229
- declare const index$1_fromResponse: typeof fromResponse;
230
- declare const index$1_parse: typeof parse;
231
- declare const index$1_safeParse: typeof safeParse;
232
- declare const index$1_toResponse: typeof toResponse;
233
- declare namespace index$1 {
234
- export { type index$1_OfferResponse as OfferResponse, index$1_OpenApi as OpenApi, index$1_fromResponse as fromResponse, index$1_parse as parse, index$1_safeParse as safeParse, index$1_toResponse as toResponse };
221
+ type index$3_OfferResponse = OfferResponse;
222
+ declare const index$3_OpenApi: typeof OpenApi;
223
+ declare const index$3_fromResponse: typeof fromResponse;
224
+ declare const index$3_parse: typeof parse;
225
+ declare const index$3_safeParse: typeof safeParse;
226
+ declare const index$3_toResponse: typeof toResponse;
227
+ declare namespace index$3 {
228
+ export { type index$3_OfferResponse as OfferResponse, index$3_OpenApi as OpenApi, index$3_fromResponse as fromResponse, index$3_parse as parse, index$3_safeParse as safeParse, index$3_toResponse as toResponse };
235
229
  }
236
230
 
237
231
  type GetParameters = {
@@ -256,9 +250,9 @@ type GetParameters = {
256
250
  /** Maximum rate per asset (in wei) */
257
251
  maxRate?: bigint;
258
252
  /** Minimum maturity timestamp (Unix timestamp in seconds) */
259
- minMaturity?: number;
253
+ minMaturity?: Maturity.Maturity;
260
254
  /** Maximum maturity timestamp (Unix timestamp in seconds) */
261
- maxMaturity?: number;
255
+ maxMaturity?: Maturity.Maturity;
262
256
  /** Minimum expiry timestamp (Unix timestamp in seconds) */
263
257
  minExpiry?: number;
264
258
  /** Maximum expiry timestamp (Unix timestamp in seconds) */
@@ -271,12 +265,12 @@ type GetParameters = {
271
265
  collateralTuple?: Array<{
272
266
  asset: string;
273
267
  oracle?: string;
274
- lltv?: number;
268
+ lltv?: LLTV.LLTV;
275
269
  }>;
276
270
  /** Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
277
- minLltv?: number;
271
+ minLltv?: LLTV.LLTV;
278
272
  /** Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
279
- maxLltv?: number;
273
+ maxLltv?: LLTV.LLTV;
280
274
  /** Field to sort results by */
281
275
  sortBy?: "rate" | "maturity" | "expiry" | "amount";
282
276
  /** Sort direction: asc (ascending) or desc (descending, default) */
@@ -297,14 +291,14 @@ type MatchParameters = {
297
291
  collaterals?: Array<{
298
292
  asset: string;
299
293
  oracle: string;
300
- lltv: bigint;
294
+ lltv: LLTV.LLTV;
301
295
  }>;
302
296
  /** Exact maturity timestamp (Unix timestamp in seconds) */
303
- maturity?: number;
297
+ maturity?: Maturity.Maturity;
304
298
  /** Minimum maturity timestamp (Unix timestamp in seconds, inclusive) */
305
- minMaturity?: number;
299
+ minMaturity?: Maturity.Maturity;
306
300
  /** Maximum maturity timestamp (Unix timestamp in seconds, inclusive) */
307
- maxMaturity?: number;
301
+ maxMaturity?: Maturity.Maturity;
308
302
  /** The loan asset address to match against */
309
303
  loanToken?: string;
310
304
  /** Filter by a specific offer creator address */
@@ -383,31 +377,49 @@ declare class HttpGetOffersFailedError extends Errors.BaseError {
383
377
  });
384
378
  }
385
379
 
386
- type PgDB = ReturnType<typeof drizzle> & {
387
- name: "pg";
388
- pool: Pool;
389
- };
390
- type PGLiteDB = ReturnType<typeof drizzle$1> & {
391
- name: "pglite";
392
- pool: PGlite;
380
+ /**
381
+ * The `OfferStore` is responsible for managing offer data in the database.
382
+ */
383
+ type OfferStore = {
384
+ /** Create a single offer in the database. */
385
+ create: (parameters: {
386
+ offer: Offer.Offer;
387
+ status: OfferStatus;
388
+ metadata?: OfferMetadata;
389
+ }) => Promise<string>;
390
+ /** Create multiple offers in the database. */
391
+ createMany: (parameters: {
392
+ offer: Offer.Offer;
393
+ status: OfferStatus;
394
+ metadata?: OfferMetadata;
395
+ }[]) => Promise<string[]>;
396
+ /** Get all offers from the database with optional filtering, sorting, and pagination. */
397
+ getAll: (params?: GetAllParams) => Promise<{
398
+ offers: RouterOffer[];
399
+ nextCursor: string | null;
400
+ }>;
401
+ /** Find offers that match the specified parameters, with cursor pagination. */
402
+ findMatchingOffers: (params: FindMatchingOffersParams) => Promise<{
403
+ offers: RouterOffer[];
404
+ nextCursor: string | null;
405
+ }>;
406
+ /** Delete an offer and its associated collaterals by hash. */
407
+ delete: (hash: Offer.Offer["hash"]) => Promise<boolean>;
408
+ /** Delete multiple offers and their associated collaterals by hashes. */
409
+ deleteMany: (hashes: Offer.Offer["hash"][]) => Promise<number>;
410
+ /** Update the status of an offer. */
411
+ updateStatus: (parameters: {
412
+ offerHash: Offer.Offer["hash"];
413
+ status: OfferStatus;
414
+ metadata?: OfferMetadata;
415
+ }) => Promise<void>;
416
+ updateConsumedAmount: (parameters: {
417
+ chainId: Offer.Offer["chainId"];
418
+ offering: Offer.Offer["offering"];
419
+ nonce: Offer.Offer["nonce"];
420
+ consumed: bigint;
421
+ }) => Promise<void>;
393
422
  };
394
- type DB = PgDB | PGLiteDB;
395
- declare function create$1({ type, endpoint, }: {
396
- type?: "pg" | "pglite";
397
- endpoint?: string;
398
- }): DB;
399
- declare function applyMigrations(db: DB): Promise<void>;
400
- declare function applyMigrationsPostgres(db: DB): Promise<void>;
401
- declare function clean(db: DB): Promise<void>;
402
-
403
- type OfferDB_DB = DB;
404
- declare const OfferDB_applyMigrations: typeof applyMigrations;
405
- declare const OfferDB_applyMigrationsPostgres: typeof applyMigrationsPostgres;
406
- declare const OfferDB_clean: typeof clean;
407
- declare namespace OfferDB {
408
- export { type OfferDB_DB as DB, OfferDB_applyMigrations as applyMigrations, OfferDB_applyMigrationsPostgres as applyMigrationsPostgres, OfferDB_clean as clean, create$1 as create };
409
- }
410
-
411
423
  type GetOffersFilters = {
412
424
  creators?: string[];
413
425
  side?: "buy" | "sell";
@@ -419,8 +431,8 @@ type GetOffersFilters = {
419
431
  maxAmount?: bigint;
420
432
  minRate?: bigint;
421
433
  maxRate?: bigint;
422
- minMaturity?: number;
423
- maxMaturity?: number;
434
+ minMaturity?: Maturity.Maturity;
435
+ maxMaturity?: Maturity.Maturity;
424
436
  minExpiry?: number;
425
437
  maxExpiry?: number;
426
438
  collateralAssets?: string[];
@@ -428,27 +440,27 @@ type GetOffersFilters = {
428
440
  collateralTuple?: Array<{
429
441
  asset: string;
430
442
  oracle?: string;
431
- lltv?: number;
443
+ lltv?: LLTV.LLTV;
432
444
  }>;
433
- minLltv?: number;
434
- maxLltv?: number;
445
+ minLltv?: LLTV.LLTV;
446
+ maxLltv?: LLTV.LLTV;
435
447
  sortBy?: "rate" | "maturity" | "expiry" | "amount";
436
448
  sortOrder?: "asc" | "desc";
437
449
  cursor?: string;
438
450
  limit?: number;
439
451
  };
440
- interface FindMatchingOffersParams {
452
+ type FindMatchingOffersParams = {
441
453
  side: "buy" | "sell";
442
454
  chainId: number;
443
455
  rate?: bigint;
444
456
  collaterals?: Array<{
445
457
  asset: string;
446
458
  oracle: string;
447
- lltv: bigint;
459
+ lltv: LLTV.LLTV;
448
460
  }>;
449
- maturity?: number;
450
- minMaturity?: number;
451
- maxMaturity?: number;
461
+ maturity?: Maturity.Maturity;
462
+ minMaturity?: Maturity.Maturity;
463
+ maxMaturity?: Maturity.Maturity;
452
464
  loanToken?: string;
453
465
  creator?: string;
454
466
  /** Filter by offer status; if omitted defaults to ["valid"] */
@@ -457,671 +469,28 @@ interface FindMatchingOffersParams {
457
469
  cursor?: string;
458
470
  /** Page size; defaults to 20 */
459
471
  limit?: number;
460
- }
461
- interface GetAllParams {
472
+ };
473
+ type GetAllParams = {
462
474
  query?: GetOffersFilters;
463
- }
464
- type OfferRepositoryConfig = {
465
- /** The database instance to use for operations. */
466
- db: DB;
467
475
  };
468
- /**
469
- * The `OfferRepository` is responsible for managing offer data in the database.
470
- */
471
- type OfferRepository = {
472
- /** Create a single offer in the database. */
473
- create: (parameters: {
474
- offer: Offer.Offer;
475
- status: OfferStatus;
476
- metadata?: OfferMetadata;
477
- }) => Promise<string>;
478
- /** Create multiple offers in the database. */
479
- createMany: (parameters: {
480
- offer: Offer.Offer;
476
+
477
+ declare function memory(parameters: {
478
+ offers: Map<Hex, Offer.Offer & {
481
479
  status: OfferStatus;
482
480
  metadata?: OfferMetadata;
483
- }[]) => Promise<string[]>;
484
- /** Get all offers from the database with optional filtering, sorting, and pagination. */
485
- getAll: (params?: GetAllParams) => Promise<{
486
- offers: RouterOffer[];
487
- nextCursor: string | null;
488
481
  }>;
489
- /** Find offers that match the specified parameters, with cursor pagination. */
490
- findMatchingOffers: (params: FindMatchingOffersParams) => Promise<{
491
- offers: RouterOffer[];
492
- nextCursor: string | null;
493
- }>;
494
- /** Delete an offer and its associated collaterals by hash. */
495
- delete: (hash: Offer.Offer["hash"]) => Promise<boolean>;
496
- /** Delete multiple offers and their associated collaterals by hashes. */
497
- deleteMany: (hashes: Offer.Offer["hash"][]) => Promise<number>;
498
- /** Update the status of an offer. */
499
- updateStatus: (parameters: {
500
- offerHash: Offer.Offer["hash"];
501
- status: OfferStatus;
502
- metadata?: OfferMetadata;
503
- }) => Promise<void>;
504
- updateConsumedAmount: (parameters: {
505
- chainId: Offer.Offer["chainId"];
506
- offering: Offer.Offer["offering"];
507
- nonce: Offer.Offer["nonce"];
508
- consumed: bigint;
509
- }) => Promise<void>;
510
- };
511
- /**
512
- * Creates a new OfferRepository instance.
513
- */
514
- declare function create(config: OfferRepositoryConfig): OfferRepository;
515
- type TestOfferRepository = OfferRepository;
516
- declare function createTest(): TestOfferRepository;
482
+ filled: Map<ChainId, Map<Address, Map<bigint, bigint>>>;
483
+ }): OfferStore;
517
484
 
518
- type OfferRepository$1_FindMatchingOffersParams = FindMatchingOffersParams;
519
- type OfferRepository$1_GetAllParams = GetAllParams;
520
- type OfferRepository$1_GetOffersFilters = GetOffersFilters;
521
- type OfferRepository$1_OfferRepository = OfferRepository;
522
- type OfferRepository$1_OfferRepositoryConfig = OfferRepositoryConfig;
523
- type OfferRepository$1_TestOfferRepository = TestOfferRepository;
524
- declare const OfferRepository$1_create: typeof create;
525
- declare const OfferRepository$1_createTest: typeof createTest;
526
- declare namespace OfferRepository$1 {
527
- export { type OfferRepository$1_FindMatchingOffersParams as FindMatchingOffersParams, type OfferRepository$1_GetAllParams as GetAllParams, type OfferRepository$1_GetOffersFilters as GetOffersFilters, type OfferRepository$1_OfferRepository as OfferRepository, type OfferRepository$1_OfferRepositoryConfig as OfferRepositoryConfig, type OfferRepository$1_TestOfferRepository as TestOfferRepository, OfferRepository$1_create as create, OfferRepository$1_createTest as createTest };
485
+ type index$2_FindMatchingOffersParams = FindMatchingOffersParams;
486
+ type index$2_GetAllParams = GetAllParams;
487
+ type index$2_GetOffersFilters = GetOffersFilters;
488
+ type index$2_OfferStore = OfferStore;
489
+ declare const index$2_memory: typeof memory;
490
+ declare namespace index$2 {
491
+ export { type index$2_FindMatchingOffersParams as FindMatchingOffersParams, type index$2_GetAllParams as GetAllParams, type index$2_GetOffersFilters as GetOffersFilters, type index$2_OfferStore as OfferStore, index$2_memory as memory };
528
492
  }
529
493
 
530
- declare const offers: drizzle_orm_pg_core.PgTableWithColumns<{
531
- name: "offers";
532
- schema: undefined;
533
- columns: {
534
- hash: drizzle_orm_pg_core.PgColumn<{
535
- name: "hash";
536
- tableName: "offers";
537
- dataType: "string";
538
- columnType: "PgVarchar";
539
- data: string;
540
- driverParam: string;
541
- notNull: true;
542
- hasDefault: false;
543
- isPrimaryKey: true;
544
- isAutoincrement: false;
545
- hasRuntimeDefault: false;
546
- enumValues: [string, ...string[]];
547
- baseColumn: never;
548
- identity: undefined;
549
- generated: undefined;
550
- }, {}, {
551
- length: 66;
552
- }>;
553
- offering: drizzle_orm_pg_core.PgColumn<{
554
- name: "offering";
555
- tableName: "offers";
556
- dataType: "string";
557
- columnType: "PgVarchar";
558
- data: string;
559
- driverParam: string;
560
- notNull: true;
561
- hasDefault: false;
562
- isPrimaryKey: false;
563
- isAutoincrement: false;
564
- hasRuntimeDefault: false;
565
- enumValues: [string, ...string[]];
566
- baseColumn: never;
567
- identity: undefined;
568
- generated: undefined;
569
- }, {}, {
570
- length: 42;
571
- }>;
572
- assets: drizzle_orm_pg_core.PgColumn<{
573
- name: "assets";
574
- tableName: "offers";
575
- dataType: "bigint";
576
- columnType: "PgBigInt64";
577
- data: bigint;
578
- driverParam: string;
579
- notNull: true;
580
- hasDefault: false;
581
- isPrimaryKey: false;
582
- isAutoincrement: false;
583
- hasRuntimeDefault: false;
584
- enumValues: undefined;
585
- baseColumn: never;
586
- identity: undefined;
587
- generated: undefined;
588
- }, {}, {}>;
589
- rate: drizzle_orm_pg_core.PgColumn<{
590
- name: "rate";
591
- tableName: "offers";
592
- dataType: "bigint";
593
- columnType: "PgBigInt64";
594
- data: bigint;
595
- driverParam: string;
596
- notNull: true;
597
- hasDefault: false;
598
- isPrimaryKey: false;
599
- isAutoincrement: false;
600
- hasRuntimeDefault: false;
601
- enumValues: undefined;
602
- baseColumn: never;
603
- identity: undefined;
604
- generated: undefined;
605
- }, {}, {}>;
606
- maturity: drizzle_orm_pg_core.PgColumn<{
607
- name: "maturity";
608
- tableName: "offers";
609
- dataType: "number";
610
- columnType: "PgInteger";
611
- data: number;
612
- driverParam: string | number;
613
- notNull: true;
614
- hasDefault: false;
615
- isPrimaryKey: false;
616
- isAutoincrement: false;
617
- hasRuntimeDefault: false;
618
- enumValues: undefined;
619
- baseColumn: never;
620
- identity: undefined;
621
- generated: undefined;
622
- }, {}, {}>;
623
- expiry: drizzle_orm_pg_core.PgColumn<{
624
- name: "expiry";
625
- tableName: "offers";
626
- dataType: "number";
627
- columnType: "PgInteger";
628
- data: number;
629
- driverParam: string | number;
630
- notNull: true;
631
- hasDefault: false;
632
- isPrimaryKey: false;
633
- isAutoincrement: false;
634
- hasRuntimeDefault: false;
635
- enumValues: undefined;
636
- baseColumn: never;
637
- identity: undefined;
638
- generated: undefined;
639
- }, {}, {}>;
640
- start: drizzle_orm_pg_core.PgColumn<{
641
- name: "start";
642
- tableName: "offers";
643
- dataType: "number";
644
- columnType: "PgInteger";
645
- data: number;
646
- driverParam: string | number;
647
- notNull: true;
648
- hasDefault: false;
649
- isPrimaryKey: false;
650
- isAutoincrement: false;
651
- hasRuntimeDefault: false;
652
- enumValues: undefined;
653
- baseColumn: never;
654
- identity: undefined;
655
- generated: undefined;
656
- }, {}, {}>;
657
- nonce: drizzle_orm_pg_core.PgColumn<{
658
- name: "nonce";
659
- tableName: "offers";
660
- dataType: "bigint";
661
- columnType: "PgBigInt64";
662
- data: bigint;
663
- driverParam: string;
664
- notNull: true;
665
- hasDefault: false;
666
- isPrimaryKey: false;
667
- isAutoincrement: false;
668
- hasRuntimeDefault: false;
669
- enumValues: undefined;
670
- baseColumn: never;
671
- identity: undefined;
672
- generated: undefined;
673
- }, {}, {}>;
674
- buy: drizzle_orm_pg_core.PgColumn<{
675
- name: "buy";
676
- tableName: "offers";
677
- dataType: "boolean";
678
- columnType: "PgBoolean";
679
- data: boolean;
680
- driverParam: boolean;
681
- notNull: true;
682
- hasDefault: false;
683
- isPrimaryKey: false;
684
- isAutoincrement: false;
685
- hasRuntimeDefault: false;
686
- enumValues: undefined;
687
- baseColumn: never;
688
- identity: undefined;
689
- generated: undefined;
690
- }, {}, {}>;
691
- chainId: drizzle_orm_pg_core.PgColumn<{
692
- name: "chain_id";
693
- tableName: "offers";
694
- dataType: "bigint";
695
- columnType: "PgBigInt64";
696
- data: bigint;
697
- driverParam: string;
698
- notNull: true;
699
- hasDefault: false;
700
- isPrimaryKey: false;
701
- isAutoincrement: false;
702
- hasRuntimeDefault: false;
703
- enumValues: undefined;
704
- baseColumn: never;
705
- identity: undefined;
706
- generated: undefined;
707
- }, {}, {}>;
708
- loanToken: drizzle_orm_pg_core.PgColumn<{
709
- name: "loan_token";
710
- tableName: "offers";
711
- dataType: "string";
712
- columnType: "PgVarchar";
713
- data: string;
714
- driverParam: string;
715
- notNull: true;
716
- hasDefault: false;
717
- isPrimaryKey: false;
718
- isAutoincrement: false;
719
- hasRuntimeDefault: false;
720
- enumValues: [string, ...string[]];
721
- baseColumn: never;
722
- identity: undefined;
723
- generated: undefined;
724
- }, {}, {
725
- length: 42;
726
- }>;
727
- callbackAddress: drizzle_orm_pg_core.PgColumn<{
728
- name: "callback_address";
729
- tableName: "offers";
730
- dataType: "string";
731
- columnType: "PgVarchar";
732
- data: string;
733
- driverParam: string;
734
- notNull: true;
735
- hasDefault: false;
736
- isPrimaryKey: false;
737
- isAutoincrement: false;
738
- hasRuntimeDefault: false;
739
- enumValues: [string, ...string[]];
740
- baseColumn: never;
741
- identity: undefined;
742
- generated: undefined;
743
- }, {}, {
744
- length: 42;
745
- }>;
746
- callbackData: drizzle_orm_pg_core.PgColumn<{
747
- name: "callback_data";
748
- tableName: "offers";
749
- dataType: "string";
750
- columnType: "PgText";
751
- data: string;
752
- driverParam: string;
753
- notNull: true;
754
- hasDefault: false;
755
- isPrimaryKey: false;
756
- isAutoincrement: false;
757
- hasRuntimeDefault: false;
758
- enumValues: [string, ...string[]];
759
- baseColumn: never;
760
- identity: undefined;
761
- generated: undefined;
762
- }, {}, {}>;
763
- callbackGasLimit: drizzle_orm_pg_core.PgColumn<{
764
- name: "callback_gas_limit";
765
- tableName: "offers";
766
- dataType: "bigint";
767
- columnType: "PgBigInt64";
768
- data: bigint;
769
- driverParam: string;
770
- notNull: true;
771
- hasDefault: false;
772
- isPrimaryKey: false;
773
- isAutoincrement: false;
774
- hasRuntimeDefault: false;
775
- enumValues: undefined;
776
- baseColumn: never;
777
- identity: undefined;
778
- generated: undefined;
779
- }, {}, {}>;
780
- signature: drizzle_orm_pg_core.PgColumn<{
781
- name: "signature";
782
- tableName: "offers";
783
- dataType: "string";
784
- columnType: "PgVarchar";
785
- data: string;
786
- driverParam: string;
787
- notNull: false;
788
- hasDefault: false;
789
- isPrimaryKey: false;
790
- isAutoincrement: false;
791
- hasRuntimeDefault: false;
792
- enumValues: [string, ...string[]];
793
- baseColumn: never;
794
- identity: undefined;
795
- generated: undefined;
796
- }, {}, {
797
- length: 132;
798
- }>;
799
- createdAt: drizzle_orm_pg_core.PgColumn<{
800
- name: "created_at";
801
- tableName: "offers";
802
- dataType: "date";
803
- columnType: "PgTimestamp";
804
- data: Date;
805
- driverParam: string;
806
- notNull: true;
807
- hasDefault: true;
808
- isPrimaryKey: false;
809
- isAutoincrement: false;
810
- hasRuntimeDefault: false;
811
- enumValues: undefined;
812
- baseColumn: never;
813
- identity: undefined;
814
- generated: undefined;
815
- }, {}, {}>;
816
- };
817
- dialect: "pg";
818
- }>;
819
- declare const offerCollaterals: drizzle_orm_pg_core.PgTableWithColumns<{
820
- name: "offer_collaterals";
821
- schema: undefined;
822
- columns: {
823
- id: drizzle_orm_pg_core.PgColumn<{
824
- name: "id";
825
- tableName: "offer_collaterals";
826
- dataType: "number";
827
- columnType: "PgSerial";
828
- data: number;
829
- driverParam: number;
830
- notNull: true;
831
- hasDefault: true;
832
- isPrimaryKey: true;
833
- isAutoincrement: false;
834
- hasRuntimeDefault: false;
835
- enumValues: undefined;
836
- baseColumn: never;
837
- identity: undefined;
838
- generated: undefined;
839
- }, {}, {}>;
840
- offerHash: drizzle_orm_pg_core.PgColumn<{
841
- name: "offer_hash";
842
- tableName: "offer_collaterals";
843
- dataType: "string";
844
- columnType: "PgVarchar";
845
- data: string;
846
- driverParam: string;
847
- notNull: true;
848
- hasDefault: false;
849
- isPrimaryKey: false;
850
- isAutoincrement: false;
851
- hasRuntimeDefault: false;
852
- enumValues: [string, ...string[]];
853
- baseColumn: never;
854
- identity: undefined;
855
- generated: undefined;
856
- }, {}, {
857
- length: 66;
858
- }>;
859
- asset: drizzle_orm_pg_core.PgColumn<{
860
- name: "asset";
861
- tableName: "offer_collaterals";
862
- dataType: "string";
863
- columnType: "PgVarchar";
864
- data: string;
865
- driverParam: string;
866
- notNull: true;
867
- hasDefault: false;
868
- isPrimaryKey: false;
869
- isAutoincrement: false;
870
- hasRuntimeDefault: false;
871
- enumValues: [string, ...string[]];
872
- baseColumn: never;
873
- identity: undefined;
874
- generated: undefined;
875
- }, {}, {
876
- length: 42;
877
- }>;
878
- oracle: drizzle_orm_pg_core.PgColumn<{
879
- name: "oracle";
880
- tableName: "offer_collaterals";
881
- dataType: "string";
882
- columnType: "PgVarchar";
883
- data: string;
884
- driverParam: string;
885
- notNull: true;
886
- hasDefault: false;
887
- isPrimaryKey: false;
888
- isAutoincrement: false;
889
- hasRuntimeDefault: false;
890
- enumValues: [string, ...string[]];
891
- baseColumn: never;
892
- identity: undefined;
893
- generated: undefined;
894
- }, {}, {
895
- length: 42;
896
- }>;
897
- lltv: drizzle_orm_pg_core.PgColumn<{
898
- name: "lltv";
899
- tableName: "offer_collaterals";
900
- dataType: "bigint";
901
- columnType: "PgBigInt64";
902
- data: bigint;
903
- driverParam: string;
904
- notNull: true;
905
- hasDefault: false;
906
- isPrimaryKey: false;
907
- isAutoincrement: false;
908
- hasRuntimeDefault: false;
909
- enumValues: undefined;
910
- baseColumn: never;
911
- identity: undefined;
912
- generated: undefined;
913
- }, {}, {}>;
914
- };
915
- dialect: "pg";
916
- }>;
917
- declare const offerStatus: drizzle_orm_pg_core.PgTableWithColumns<{
918
- name: "offer_status";
919
- schema: undefined;
920
- columns: {
921
- id: drizzle_orm_pg_core.PgColumn<{
922
- name: "id";
923
- tableName: "offer_status";
924
- dataType: "number";
925
- columnType: "PgSerial";
926
- data: number;
927
- driverParam: number;
928
- notNull: true;
929
- hasDefault: true;
930
- isPrimaryKey: true;
931
- isAutoincrement: false;
932
- hasRuntimeDefault: false;
933
- enumValues: undefined;
934
- baseColumn: never;
935
- identity: undefined;
936
- generated: undefined;
937
- }, {}, {}>;
938
- offerHash: drizzle_orm_pg_core.PgColumn<{
939
- name: "offer_hash";
940
- tableName: "offer_status";
941
- dataType: "string";
942
- columnType: "PgVarchar";
943
- data: string;
944
- driverParam: string;
945
- notNull: true;
946
- hasDefault: false;
947
- isPrimaryKey: false;
948
- isAutoincrement: false;
949
- hasRuntimeDefault: false;
950
- enumValues: [string, ...string[]];
951
- baseColumn: never;
952
- identity: undefined;
953
- generated: undefined;
954
- }, {}, {
955
- length: 66;
956
- }>;
957
- status: drizzle_orm_pg_core.PgColumn<{
958
- name: "status";
959
- tableName: "offer_status";
960
- dataType: "string";
961
- columnType: "PgText";
962
- data: "valid" | "callback_not_supported" | "callback_error" | "unverified";
963
- driverParam: string;
964
- notNull: true;
965
- hasDefault: false;
966
- isPrimaryKey: false;
967
- isAutoincrement: false;
968
- hasRuntimeDefault: false;
969
- enumValues: [string, ...string[]];
970
- baseColumn: never;
971
- identity: undefined;
972
- generated: undefined;
973
- }, {}, {
974
- $type: "valid" | "callback_not_supported" | "callback_error" | "unverified";
975
- }>;
976
- metadata: drizzle_orm_pg_core.PgColumn<{
977
- name: "metadata";
978
- tableName: "offer_status";
979
- dataType: "json";
980
- columnType: "PgJsonb";
981
- data: unknown;
982
- driverParam: unknown;
983
- notNull: false;
984
- hasDefault: false;
985
- isPrimaryKey: false;
986
- isAutoincrement: false;
987
- hasRuntimeDefault: false;
988
- enumValues: undefined;
989
- baseColumn: never;
990
- identity: undefined;
991
- generated: undefined;
992
- }, {}, {}>;
993
- createdAt: drizzle_orm_pg_core.PgColumn<{
994
- name: "created_at";
995
- tableName: "offer_status";
996
- dataType: "date";
997
- columnType: "PgTimestamp";
998
- data: Date;
999
- driverParam: string;
1000
- notNull: true;
1001
- hasDefault: true;
1002
- isPrimaryKey: false;
1003
- isAutoincrement: false;
1004
- hasRuntimeDefault: false;
1005
- enumValues: undefined;
1006
- baseColumn: never;
1007
- identity: undefined;
1008
- generated: undefined;
1009
- }, {}, {}>;
1010
- };
1011
- dialect: "pg";
1012
- }>;
1013
- declare const consumed: drizzle_orm_pg_core.PgTableWithColumns<{
1014
- name: "consumed_per_user_and_nonce";
1015
- schema: undefined;
1016
- columns: {
1017
- id: drizzle_orm_pg_core.PgColumn<{
1018
- name: "id";
1019
- tableName: "consumed_per_user_and_nonce";
1020
- dataType: "number";
1021
- columnType: "PgSerial";
1022
- data: number;
1023
- driverParam: number;
1024
- notNull: true;
1025
- hasDefault: true;
1026
- isPrimaryKey: true;
1027
- isAutoincrement: false;
1028
- hasRuntimeDefault: false;
1029
- enumValues: undefined;
1030
- baseColumn: never;
1031
- identity: undefined;
1032
- generated: undefined;
1033
- }, {}, {}>;
1034
- chainId: drizzle_orm_pg_core.PgColumn<{
1035
- name: "chain_id";
1036
- tableName: "consumed_per_user_and_nonce";
1037
- dataType: "bigint";
1038
- columnType: "PgBigInt64";
1039
- data: bigint;
1040
- driverParam: string;
1041
- notNull: true;
1042
- hasDefault: false;
1043
- isPrimaryKey: false;
1044
- isAutoincrement: false;
1045
- hasRuntimeDefault: false;
1046
- enumValues: undefined;
1047
- baseColumn: never;
1048
- identity: undefined;
1049
- generated: undefined;
1050
- }, {}, {}>;
1051
- offering: drizzle_orm_pg_core.PgColumn<{
1052
- name: "offering";
1053
- tableName: "consumed_per_user_and_nonce";
1054
- dataType: "string";
1055
- columnType: "PgVarchar";
1056
- data: string;
1057
- driverParam: string;
1058
- notNull: true;
1059
- hasDefault: false;
1060
- isPrimaryKey: false;
1061
- isAutoincrement: false;
1062
- hasRuntimeDefault: false;
1063
- enumValues: [string, ...string[]];
1064
- baseColumn: never;
1065
- identity: undefined;
1066
- generated: undefined;
1067
- }, {}, {
1068
- length: 42;
1069
- }>;
1070
- nonce: drizzle_orm_pg_core.PgColumn<{
1071
- name: "nonce";
1072
- tableName: "consumed_per_user_and_nonce";
1073
- dataType: "bigint";
1074
- columnType: "PgBigInt64";
1075
- data: bigint;
1076
- driverParam: string;
1077
- notNull: true;
1078
- hasDefault: false;
1079
- isPrimaryKey: false;
1080
- isAutoincrement: false;
1081
- hasRuntimeDefault: false;
1082
- enumValues: undefined;
1083
- baseColumn: never;
1084
- identity: undefined;
1085
- generated: undefined;
1086
- }, {}, {}>;
1087
- consumed: drizzle_orm_pg_core.PgColumn<{
1088
- name: "consumed";
1089
- tableName: "consumed_per_user_and_nonce";
1090
- dataType: "bigint";
1091
- columnType: "PgBigInt64";
1092
- data: bigint;
1093
- driverParam: string;
1094
- notNull: true;
1095
- hasDefault: false;
1096
- isPrimaryKey: false;
1097
- isAutoincrement: false;
1098
- hasRuntimeDefault: false;
1099
- enumValues: undefined;
1100
- baseColumn: never;
1101
- identity: undefined;
1102
- generated: undefined;
1103
- }, {}, {}>;
1104
- createdAt: drizzle_orm_pg_core.PgColumn<{
1105
- name: "created_at";
1106
- tableName: "consumed_per_user_and_nonce";
1107
- dataType: "date";
1108
- columnType: "PgTimestamp";
1109
- data: Date;
1110
- driverParam: string;
1111
- notNull: true;
1112
- hasDefault: true;
1113
- isPrimaryKey: false;
1114
- isAutoincrement: false;
1115
- hasRuntimeDefault: false;
1116
- enumValues: undefined;
1117
- baseColumn: never;
1118
- identity: undefined;
1119
- generated: undefined;
1120
- }, {}, {}>;
1121
- };
1122
- dialect: "pg";
1123
- }>;
1124
-
1125
494
  /**
1126
495
  * Start a local router server.
1127
496
  * @example
@@ -1132,29 +501,29 @@ declare const consumed: drizzle_orm_pg_core.PgTableWithColumns<{
1132
501
  */
1133
502
  declare function serve(parameters: {
1134
503
  port: number;
1135
- store?: OfferRepository;
504
+ store?: OfferStore;
1136
505
  }): Promise<void>;
1137
506
 
1138
- type index_Client = Client;
1139
- type index_GetParameters = GetParameters;
1140
- type index_HttpForbiddenError = HttpForbiddenError;
1141
- declare const index_HttpForbiddenError: typeof HttpForbiddenError;
1142
- type index_HttpGetOffersFailedError = HttpGetOffersFailedError;
1143
- declare const index_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
1144
- type index_HttpRateLimitError = HttpRateLimitError;
1145
- declare const index_HttpRateLimitError: typeof HttpRateLimitError;
1146
- type index_HttpUnauthorizedError = HttpUnauthorizedError;
1147
- declare const index_HttpUnauthorizedError: typeof HttpUnauthorizedError;
1148
- type index_InvalidUrlError = InvalidUrlError;
1149
- declare const index_InvalidUrlError: typeof InvalidUrlError;
1150
- type index_MatchParameters = MatchParameters;
1151
- type index_RouterClientConfig = RouterClientConfig;
1152
- declare const index_connect: typeof connect;
1153
- declare const index_get: typeof get;
1154
- declare const index_match: typeof match;
1155
- declare const index_serve: typeof serve;
1156
- declare namespace index {
1157
- export { type index_Client as Client, type index_GetParameters as GetParameters, index_HttpForbiddenError as HttpForbiddenError, index_HttpGetOffersFailedError as HttpGetOffersFailedError, index_HttpRateLimitError as HttpRateLimitError, index_HttpUnauthorizedError as HttpUnauthorizedError, index_InvalidUrlError as InvalidUrlError, type index_MatchParameters as MatchParameters, type index_RouterClientConfig as RouterClientConfig, index_connect as connect, index_get as get, index_match as match, index_serve as serve };
507
+ type index$1_Client = Client;
508
+ type index$1_GetParameters = GetParameters;
509
+ type index$1_HttpForbiddenError = HttpForbiddenError;
510
+ declare const index$1_HttpForbiddenError: typeof HttpForbiddenError;
511
+ type index$1_HttpGetOffersFailedError = HttpGetOffersFailedError;
512
+ declare const index$1_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
513
+ type index$1_HttpRateLimitError = HttpRateLimitError;
514
+ declare const index$1_HttpRateLimitError: typeof HttpRateLimitError;
515
+ type index$1_HttpUnauthorizedError = HttpUnauthorizedError;
516
+ declare const index$1_HttpUnauthorizedError: typeof HttpUnauthorizedError;
517
+ type index$1_InvalidUrlError = InvalidUrlError;
518
+ declare const index$1_InvalidUrlError: typeof InvalidUrlError;
519
+ type index$1_MatchParameters = MatchParameters;
520
+ type index$1_RouterClientConfig = RouterClientConfig;
521
+ declare const index$1_connect: typeof connect;
522
+ declare const index$1_get: typeof get;
523
+ declare const index$1_match: typeof match;
524
+ declare const index$1_serve: typeof serve;
525
+ declare namespace index$1 {
526
+ export { type index$1_Client as Client, type index$1_GetParameters as GetParameters, index$1_HttpForbiddenError as HttpForbiddenError, index$1_HttpGetOffersFailedError as HttpGetOffersFailedError, index$1_HttpRateLimitError as HttpRateLimitError, index$1_HttpUnauthorizedError as HttpUnauthorizedError, index$1_InvalidUrlError as InvalidUrlError, type index$1_MatchParameters as MatchParameters, type index$1_RouterClientConfig as RouterClientConfig, index$1_connect as connect, index$1_get as get, index$1_match as match, index$1_serve as serve };
1158
527
  }
1159
528
 
1160
529
  declare const users: Account[];
@@ -1303,8 +672,21 @@ declare function poll<data>(fn: ({ unpoll }: {
1303
672
  interval: number;
1304
673
  }): () => boolean;
1305
674
 
675
+ declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
676
+
1306
677
  declare function wait(time: number): Promise<unknown>;
1307
678
 
679
+ type index_Cursor = Cursor;
680
+ declare const index_decodeCursor: typeof decodeCursor;
681
+ declare const index_encodeCursor: typeof encodeCursor;
682
+ declare const index_poll: typeof poll;
683
+ declare const index_retry: typeof retry;
684
+ declare const index_validateCursor: typeof validateCursor;
685
+ declare const index_wait: typeof wait;
686
+ declare namespace index {
687
+ export { type index_Cursor as Cursor, batch$1 as batch, index_decodeCursor as decodeCursor, index_encodeCursor as encodeCursor, index_poll as poll, index_retry as retry, index_validateCursor as validateCursor, index_wait as wait };
688
+ }
689
+
1308
690
  /**
1309
691
  * A validation rule.
1310
692
  */
@@ -1552,4 +934,4 @@ declare namespace Validation {
1552
934
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
1553
935
  }
1554
936
 
1555
- export { index$1 as ApiSchema, Chain$1 as Chain, type Cursor, EVM, Logger$1 as Logger, OfferDB, OfferRepository$1 as OfferRepository, index as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, consumed, decodeCursor, encodeCursor, offerCollaterals, offerStatus, offers, poll, validateCursor, wait };
937
+ export { index$3 as ApiSchema, Chain$1 as Chain, EVM, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };