@morpho-dev/router 0.1.6 → 0.1.7

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.
@@ -1,14 +1,19 @@
1
1
  import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
- import { Offer, Errors, Format, Maturity, LLTV, Compute, Chain } from '@morpho-dev/mempool';
2
+ import { Offer, Chain, Errors, Format, LLTV, Mempool, Maturity, Compute } from '@morpho-dev/mempool';
3
3
  export * from '@morpho-dev/mempool';
4
4
  import * as viem from 'viem';
5
- import { PublicActions, Address, Hex } from 'viem';
6
- import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
5
+ import { PublicActions, Address, Hex, WalletClient, PublicClient } from 'viem';
6
+ import { PGlite } from '@electric-sql/pglite';
7
+ import { drizzle } from 'drizzle-orm/node-postgres';
8
+ import { drizzle as drizzle$1 } from 'drizzle-orm/pglite';
9
+ import { Pool } from 'pg';
7
10
  import { z, ZodError } from 'zod/v4';
11
+ import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
8
12
  import * as hono_utils_types from 'hono/utils/types';
9
13
  import * as hono from 'hono';
10
14
  import { Context } from 'hono';
11
15
  import * as hono_utils_http_status from 'hono/utils/http-status';
16
+ import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
12
17
 
13
18
  declare function fetchBalancesAndAllowances(parameters: {
14
19
  client: Pick<PublicActions, "multicall">;
@@ -106,94 +111,80 @@ declare namespace Callback {
106
111
  export { Callback_CallbackType as CallbackType, Callback_buildLiquidity as buildLiquidity, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
107
112
  }
108
113
 
109
- type Cursor = {
110
- sort: "rate" | "maturity" | "expiry" | "amount";
111
- dir: "asc" | "desc";
112
- rate?: string;
113
- maturity?: number;
114
- expiry?: number;
115
- assets?: string;
116
- hash: string;
114
+ type PgDB = ReturnType<typeof drizzle> & {
115
+ name: "pg";
116
+ pool: Pool;
117
117
  };
118
- declare function validate(cursor: unknown): cursor is Cursor;
119
- declare function encode(c: Cursor): string;
120
- declare function decode(token?: string): Cursor | null;
118
+ type PGLiteDB = ReturnType<typeof drizzle$1> & {
119
+ name: "pglite";
120
+ pool: PGlite;
121
+ };
122
+ type PG = PgDB | PGLiteDB;
123
+ declare function connect$1(parameters: {
124
+ type: "pg";
125
+ endpoint: string;
126
+ } | {
127
+ type: "pglite";
128
+ }): PG;
129
+ declare function applyMigrations(pg: PG): Promise<void>;
130
+ declare function clean(pg: PG): Promise<void>;
121
131
 
122
- type Cursor$1_Cursor = Cursor;
123
- declare const Cursor$1_decode: typeof decode;
124
- declare const Cursor$1_encode: typeof encode;
125
- declare const Cursor$1_validate: typeof validate;
126
- declare namespace Cursor$1 {
127
- export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
132
+ type PG$1_PG = PG;
133
+ type PG$1_PGLiteDB = PGLiteDB;
134
+ type PG$1_PgDB = PgDB;
135
+ declare const PG$1_applyMigrations: typeof applyMigrations;
136
+ declare const PG$1_clean: typeof clean;
137
+ declare namespace PG$1 {
138
+ 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 };
128
139
  }
129
140
 
130
- declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
141
+ type CollectorBlockStore = {
142
+ /** Get the latest block number processed by a collector for a given chain. */
143
+ getBlockNumber: (parameters: {
144
+ collectorName: Name;
145
+ chainId: Chain.Id;
146
+ }) => Promise<number>;
147
+ /** Save the latest block number processed by a collector for a given chain. */
148
+ saveBlockNumber: (parameters: {
149
+ collectorName: Name;
150
+ chainId: Chain.Id;
151
+ blockNumber: number;
152
+ }) => Promise<void>;
153
+ };
154
+ /** Postgres implementation. */
155
+ declare const create$2: (config: {
156
+ db: PG;
157
+ }) => CollectorBlockStore;
158
+ declare function memory$1(): CollectorBlockStore;
131
159
 
132
- declare const schemas: {
133
- readonly get_offers: z.ZodObject<{
134
- creators: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
135
- side: z.ZodOptional<z.ZodEnum<{
136
- buy: "buy";
137
- sell: "sell";
138
- }>>;
139
- chains: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<number[], string>>>;
140
- loan_tokens: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
141
- status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
142
- callback_addresses: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
143
- min_amount: z.ZodOptional<z.ZodBigInt>;
144
- max_amount: z.ZodOptional<z.ZodBigInt>;
145
- min_rate: z.ZodOptional<z.ZodBigInt>;
146
- max_rate: z.ZodOptional<z.ZodBigInt>;
147
- min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
148
- max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
149
- min_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
150
- max_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
151
- collateral_assets: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
152
- collateral_oracles: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
153
- collateral_tuple: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
154
- asset: string;
155
- oracle: string | undefined;
156
- lltv: (bigint & _morpho_dev_mempool.Brand<"LLTV">) | undefined;
157
- }[], string>>>;
158
- min_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
159
- max_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
160
- sort_by: z.ZodOptional<z.ZodEnum<{
161
- amount: "amount";
162
- rate: "rate";
163
- maturity: "maturity";
164
- expiry: "expiry";
165
- }>>;
166
- sort_order: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
167
- asc: "asc";
168
- desc: "desc";
169
- }>>>;
170
- cursor: z.ZodOptional<z.ZodString>;
171
- limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
172
- }, z.core.$strip>;
173
- readonly match_offers: z.ZodObject<{
174
- side: z.ZodEnum<{
175
- buy: "buy";
176
- sell: "sell";
177
- }>;
178
- chain_id: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
179
- rate: z.ZodOptional<z.ZodBigInt>;
180
- collaterals: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
181
- asset: string;
182
- oracle: string;
183
- lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
184
- }[], string>>>;
185
- maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
186
- min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
187
- max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
188
- loan_token: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
189
- creator: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
190
- cursor: z.ZodOptional<z.ZodString>;
191
- limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
192
- }, z.core.$strip>;
160
+ type CollectorBlockStore$1_CollectorBlockStore = CollectorBlockStore;
161
+ declare namespace CollectorBlockStore$1 {
162
+ export { type CollectorBlockStore$1_CollectorBlockStore as CollectorBlockStore, create$2 as create, memory$1 as memory };
163
+ }
164
+
165
+ type LiquidityStore = {
166
+ /** Get a liquidity entry by user position id, including queues and pools. */
167
+ getByUserPositionId: (parameters: {
168
+ userPositionId: string;
169
+ }) => Promise<Liquidity | null>;
170
+ /** Get all liquidity entries, grouped by user position, including queues and pools. */
171
+ getAll: () => Promise<Liquidity[]>;
172
+ /** Save or update a liquidity entry (transactional upsert across all three tables). */
173
+ save: (parameters: {
174
+ liquidity: Liquidity;
175
+ }) => Promise<void>;
193
176
  };
194
- type Action = keyof typeof schemas;
195
- declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
196
- declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
177
+ /** Postgres implementation. */
178
+ declare const create$1: (config: {
179
+ db: PG;
180
+ }) => LiquidityStore;
181
+ declare function memory(): LiquidityStore;
182
+
183
+ type LiquidityStore$1_LiquidityStore = LiquidityStore;
184
+ declare const LiquidityStore$1_memory: typeof memory;
185
+ declare namespace LiquidityStore$1 {
186
+ export { type LiquidityStore$1_LiquidityStore as LiquidityStore, create$1 as create, LiquidityStore$1_memory as memory };
187
+ }
197
188
 
198
189
  declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
199
190
  type OfferStatus = (typeof OfferStatusValues)[number];
@@ -278,8 +269,8 @@ declare const consumedEvent: {
278
269
  * @param input - The router offer to create.
279
270
  * @returns The created router offer with its hash.
280
271
  */
281
- declare function from(input: Omit<RouterOffer, "hash">): RouterOffer;
282
- declare namespace from {
272
+ declare function from$1(input: Omit<RouterOffer, "hash">): RouterOffer;
273
+ declare namespace from$1 {
283
274
  type ErrorType = InvalidRouterOfferError;
284
275
  }
285
276
  /**
@@ -322,15 +313,292 @@ declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
322
313
  type RouterOffer$1_RouterOffer = RouterOffer;
323
314
  declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
324
315
  declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
325
- declare const RouterOffer$1_from: typeof from;
326
316
  declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
327
317
  declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
328
318
  declare const RouterOffer$1_random: typeof random;
329
319
  declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
330
320
  declare namespace RouterOffer$1 {
331
- export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferConsumed as OfferConsumed, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_consumedEvent as consumedEvent, RouterOffer$1_from as from, RouterOffer$1_fromConsumedLog as fromConsumedLog, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
321
+ export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferConsumed as OfferConsumed, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_consumedEvent as consumedEvent, from$1 as from, RouterOffer$1_fromConsumedLog as fromConsumedLog, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
322
+ }
323
+
324
+ /**
325
+ * The `OfferStore` is responsible for managing offer data in the database.
326
+ */
327
+ type OfferStore = {
328
+ /** Create a single offer in the database. */
329
+ create: (parameters: {
330
+ offer: Offer.Offer;
331
+ status: OfferStatus;
332
+ metadata?: OfferMetadata;
333
+ }) => Promise<string>;
334
+ /** Create multiple offers in the database. */
335
+ createMany: (parameters: {
336
+ offer: Offer.Offer;
337
+ status: OfferStatus;
338
+ metadata?: OfferMetadata;
339
+ }[]) => Promise<string[]>;
340
+ /** Get all offers from the database with optional filtering, sorting, and pagination. */
341
+ getAll: (params?: GetAllParams) => Promise<{
342
+ offers: RouterOffer[];
343
+ nextCursor: string | null;
344
+ }>;
345
+ /** Find offers that match the specified parameters, with cursor pagination. */
346
+ findMatchingOffers: (params: FindMatchingOffersParams) => Promise<{
347
+ offers: RouterOffer[];
348
+ nextCursor: string | null;
349
+ }>;
350
+ /** Delete an offer and its associated collaterals by hash. */
351
+ delete: (hash: Offer.Offer["hash"]) => Promise<boolean>;
352
+ /** Delete multiple offers and their associated collaterals by hashes. */
353
+ deleteMany: (hashes: Offer.Offer["hash"][]) => Promise<number>;
354
+ /** Update the status of an offer. */
355
+ updateStatus: (parameters: {
356
+ offerHash: Offer.Offer["hash"];
357
+ status: OfferStatus;
358
+ metadata?: OfferMetadata;
359
+ }) => Promise<void>;
360
+ updateConsumedAmount: (parameters: {
361
+ id: string;
362
+ chainId: Offer.Offer["chainId"];
363
+ offering: Offer.Offer["offering"];
364
+ nonce: Offer.Offer["nonce"];
365
+ consumed: bigint;
366
+ }) => Promise<void>;
367
+ };
368
+ type GetOffersFilters = {
369
+ creators?: string[];
370
+ side?: "buy" | "sell";
371
+ chains?: number[];
372
+ loanTokens?: string[];
373
+ status?: OfferStatus[];
374
+ callbackAddresses?: string[];
375
+ minAmount?: bigint;
376
+ maxAmount?: bigint;
377
+ minRate?: bigint;
378
+ maxRate?: bigint;
379
+ minMaturity?: number;
380
+ maxMaturity?: number;
381
+ minExpiry?: number;
382
+ maxExpiry?: number;
383
+ collateralAssets?: string[];
384
+ collateralOracles?: string[];
385
+ collateralTuple?: Array<{
386
+ asset: string;
387
+ oracle?: string;
388
+ lltv?: LLTV.LLTV;
389
+ }>;
390
+ minLltv?: number;
391
+ maxLltv?: number;
392
+ sortBy?: "rate" | "maturity" | "expiry" | "amount";
393
+ sortOrder?: "asc" | "desc";
394
+ cursor?: string;
395
+ limit?: number;
396
+ };
397
+ type FindMatchingOffersParams = {
398
+ side: "buy" | "sell";
399
+ chainId: number;
400
+ rate?: bigint;
401
+ collaterals?: Array<{
402
+ asset: string;
403
+ oracle: string;
404
+ lltv: LLTV.LLTV;
405
+ }>;
406
+ maturity?: number;
407
+ minMaturity?: number;
408
+ maxMaturity?: number;
409
+ loanToken?: string;
410
+ creator?: string;
411
+ /** Cursor string returned by a previous call, for pagination */
412
+ cursor?: string;
413
+ /** Page size; defaults to 20 */
414
+ limit?: number;
415
+ };
416
+ type GetAllParams = {
417
+ query?: GetOffersFilters;
418
+ };
419
+
420
+ type PgConfig = {
421
+ /** The database instance to use for operations. */
422
+ db: PG;
423
+ };
424
+ declare function create(config: PgConfig): OfferStore;
425
+
426
+ type index$3_FindMatchingOffersParams = FindMatchingOffersParams;
427
+ type index$3_GetAllParams = GetAllParams;
428
+ type index$3_GetOffersFilters = GetOffersFilters;
429
+ type index$3_OfferStore = OfferStore;
430
+ type index$3_PgConfig = PgConfig;
431
+ declare const index$3_create: typeof create;
432
+ declare namespace index$3 {
433
+ export { type index$3_FindMatchingOffersParams as FindMatchingOffersParams, type index$3_GetAllParams as GetAllParams, type index$3_GetOffersFilters as GetOffersFilters, type index$3_OfferStore as OfferStore, type index$3_PgConfig as PgConfig, index$3_create as create };
434
+ }
435
+
436
+ type Name = "mempool_offers" | "consumed_events" | "buy_with_empty_callback_liquidity" | "chain_reorgs";
437
+ /** A general collector interface. */
438
+ type Collector<name extends Name = Name> = {
439
+ /** The name of the collector. */
440
+ name: name;
441
+ /** Start collecting data from external sources.
442
+ * @yields The last block number processed by the collector.
443
+ */
444
+ collect: () => AsyncGenerator<number, void, void>;
445
+ /** The last block number processed by the collector. */
446
+ lastSyncedBlock: () => Promise<number>;
447
+ /** The callback to call when a reorg is detected. */
448
+ onReorg(lastFinalizedBlockNumber: number): void;
449
+ };
450
+ /** Start a collector.
451
+ * @param collector - The collector to start.
452
+ * @returns A function to stop the collector.
453
+ */
454
+ declare function start(collector: Collector): () => void;
455
+
456
+ declare function createBuyWithEmptyCallbackLiquidityCollector(params: {
457
+ client: WalletClient;
458
+ offerStore: OfferStore;
459
+ collectorBlockStore: CollectorBlockStore;
460
+ liquidityStore: LiquidityStore;
461
+ chain: Chain.Chain;
462
+ options?: {
463
+ maxBatchSize?: number;
464
+ interval?: number;
465
+ };
466
+ }): Collector<"buy_with_empty_callback_liquidity">;
467
+
468
+ declare function createChainReorgsCollector(parameters: {
469
+ client: PublicClient;
470
+ subscribers: Collector[];
471
+ collectorStore: CollectorBlockStore;
472
+ chain: Chain.Chain;
473
+ options?: {
474
+ maxBatchSize?: number;
475
+ interval?: number;
476
+ };
477
+ }): Collector<"chain_reorgs">;
478
+
479
+ declare function createConsumedEventsCollector(parameters: {
480
+ client: PublicClient;
481
+ contractAddress: Address;
482
+ offerStore: OfferStore;
483
+ collectorBlockStore: CollectorBlockStore;
484
+ chainId: Chain.Id;
485
+ options?: {
486
+ maxBatchSize?: number;
487
+ interval?: number;
488
+ };
489
+ }): Collector<"consumed_events">;
490
+
491
+ declare function createMempoolCollector(parameters: {
492
+ mempool: Mempool.Client;
493
+ offerStore: OfferStore;
494
+ collectorBlockStore: CollectorBlockStore;
495
+ chain: Chain.Chain;
496
+ options?: {
497
+ maxBatchSize?: number;
498
+ interval?: number;
499
+ };
500
+ }): Collector<"mempool_offers">;
501
+
502
+ type index$2_Collector<name extends Name = Name> = Collector<name>;
503
+ type index$2_Name = Name;
504
+ declare const index$2_createBuyWithEmptyCallbackLiquidityCollector: typeof createBuyWithEmptyCallbackLiquidityCollector;
505
+ declare const index$2_createChainReorgsCollector: typeof createChainReorgsCollector;
506
+ declare const index$2_createConsumedEventsCollector: typeof createConsumedEventsCollector;
507
+ declare const index$2_createMempoolCollector: typeof createMempoolCollector;
508
+ declare const index$2_start: typeof start;
509
+ declare namespace index$2 {
510
+ export { type index$2_Collector as Collector, type index$2_Name as Name, index$2_createBuyWithEmptyCallbackLiquidityCollector as createBuyWithEmptyCallbackLiquidityCollector, index$2_createChainReorgsCollector as createChainReorgsCollector, index$2_createConsumedEventsCollector as createConsumedEventsCollector, index$2_createMempoolCollector as createMempoolCollector, index$2_start as start };
511
+ }
512
+
513
+ type Cursor = {
514
+ sort: "rate" | "maturity" | "expiry" | "amount";
515
+ dir: "asc" | "desc";
516
+ rate?: string;
517
+ maturity?: number;
518
+ expiry?: number;
519
+ assets?: string;
520
+ hash: string;
521
+ };
522
+ declare function validate(cursor: unknown): cursor is Cursor;
523
+ declare function encode(c: Cursor): string;
524
+ declare function decode(token?: string): Cursor | null;
525
+
526
+ type Cursor$1_Cursor = Cursor;
527
+ declare const Cursor$1_decode: typeof decode;
528
+ declare const Cursor$1_encode: typeof encode;
529
+ declare const Cursor$1_validate: typeof validate;
530
+ declare namespace Cursor$1 {
531
+ export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
332
532
  }
333
533
 
534
+ declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
535
+
536
+ declare const schemas: {
537
+ readonly get_offers: z.ZodObject<{
538
+ creators: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
539
+ side: z.ZodOptional<z.ZodEnum<{
540
+ buy: "buy";
541
+ sell: "sell";
542
+ }>>;
543
+ chains: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<number[], string>>>;
544
+ loan_tokens: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
545
+ status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
546
+ callback_addresses: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
547
+ min_amount: z.ZodOptional<z.ZodBigInt>;
548
+ max_amount: z.ZodOptional<z.ZodBigInt>;
549
+ min_rate: z.ZodOptional<z.ZodBigInt>;
550
+ max_rate: z.ZodOptional<z.ZodBigInt>;
551
+ min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
552
+ max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
553
+ min_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
554
+ max_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
555
+ collateral_assets: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
556
+ collateral_oracles: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
557
+ collateral_tuple: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
558
+ asset: string;
559
+ oracle: string | undefined;
560
+ lltv: (bigint & _morpho_dev_mempool.Brand<"LLTV">) | undefined;
561
+ }[], string>>>;
562
+ min_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
563
+ max_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
564
+ sort_by: z.ZodOptional<z.ZodEnum<{
565
+ amount: "amount";
566
+ rate: "rate";
567
+ maturity: "maturity";
568
+ expiry: "expiry";
569
+ }>>;
570
+ sort_order: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
571
+ asc: "asc";
572
+ desc: "desc";
573
+ }>>>;
574
+ cursor: z.ZodOptional<z.ZodString>;
575
+ limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
576
+ }, z.core.$strip>;
577
+ readonly match_offers: z.ZodObject<{
578
+ side: z.ZodEnum<{
579
+ buy: "buy";
580
+ sell: "sell";
581
+ }>;
582
+ chain_id: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
583
+ rate: z.ZodOptional<z.ZodBigInt>;
584
+ collaterals: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
585
+ asset: string;
586
+ oracle: string;
587
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
588
+ }[], string>>>;
589
+ maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
590
+ min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
591
+ max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
592
+ loan_token: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
593
+ creator: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
594
+ cursor: z.ZodOptional<z.ZodString>;
595
+ limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
596
+ }, z.core.$strip>;
597
+ };
598
+ type Action = keyof typeof schemas;
599
+ declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
600
+ declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
601
+
334
602
  type OfferResponse = {
335
603
  offer: Offer.Offer;
336
604
  consumed: bigint;
@@ -350,14 +618,14 @@ declare function toResponse(routerOffer: RouterOffer): OfferResponse;
350
618
  */
351
619
  declare function fromResponse(offerResponse: OfferResponse): RouterOffer;
352
620
 
353
- type index$2_OfferResponse = OfferResponse;
354
- declare const index$2_OpenApi: typeof OpenApi;
355
- declare const index$2_fromResponse: typeof fromResponse;
356
- declare const index$2_parse: typeof parse;
357
- declare const index$2_safeParse: typeof safeParse;
358
- declare const index$2_toResponse: typeof toResponse;
359
- declare namespace index$2 {
360
- export { type index$2_OfferResponse as OfferResponse, index$2_OpenApi as OpenApi, index$2_fromResponse as fromResponse, index$2_parse as parse, index$2_safeParse as safeParse, index$2_toResponse as toResponse };
621
+ type index$1_OfferResponse = OfferResponse;
622
+ declare const index$1_OpenApi: typeof OpenApi;
623
+ declare const index$1_fromResponse: typeof fromResponse;
624
+ declare const index$1_parse: typeof parse;
625
+ declare const index$1_safeParse: typeof safeParse;
626
+ declare const index$1_toResponse: typeof toResponse;
627
+ declare namespace index$1 {
628
+ 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 };
361
629
  }
362
630
 
363
631
  type GetParameters = {
@@ -510,119 +778,6 @@ declare class HttpGetOffersFailedError extends Errors.BaseError {
510
778
  });
511
779
  }
512
780
 
513
- /**
514
- * The `OfferStore` is responsible for managing offer data in the database.
515
- */
516
- type OfferStore = {
517
- /** Create a single offer in the database. */
518
- create: (parameters: {
519
- offer: Offer.Offer;
520
- status: OfferStatus;
521
- metadata?: OfferMetadata;
522
- }) => Promise<string>;
523
- /** Create multiple offers in the database. */
524
- createMany: (parameters: {
525
- offer: Offer.Offer;
526
- status: OfferStatus;
527
- metadata?: OfferMetadata;
528
- }[]) => Promise<string[]>;
529
- /** Get all offers from the database with optional filtering, sorting, and pagination. */
530
- getAll: (params?: GetAllParams) => Promise<{
531
- offers: RouterOffer[];
532
- nextCursor: string | null;
533
- }>;
534
- /** Find offers that match the specified parameters, with cursor pagination. */
535
- findMatchingOffers: (params: FindMatchingOffersParams) => Promise<{
536
- offers: RouterOffer[];
537
- nextCursor: string | null;
538
- }>;
539
- /** Delete an offer and its associated collaterals by hash. */
540
- delete: (hash: Offer.Offer["hash"]) => Promise<boolean>;
541
- /** Delete multiple offers and their associated collaterals by hashes. */
542
- deleteMany: (hashes: Offer.Offer["hash"][]) => Promise<number>;
543
- /** Update the status of an offer. */
544
- updateStatus: (parameters: {
545
- offerHash: Offer.Offer["hash"];
546
- status: OfferStatus;
547
- metadata?: OfferMetadata;
548
- }) => Promise<void>;
549
- updateConsumedAmount: (parameters: {
550
- id: string;
551
- chainId: Offer.Offer["chainId"];
552
- offering: Offer.Offer["offering"];
553
- nonce: Offer.Offer["nonce"];
554
- consumed: bigint;
555
- }) => Promise<void>;
556
- };
557
- type GetOffersFilters = {
558
- creators?: string[];
559
- side?: "buy" | "sell";
560
- chains?: number[];
561
- loanTokens?: string[];
562
- status?: OfferStatus[];
563
- callbackAddresses?: string[];
564
- minAmount?: bigint;
565
- maxAmount?: bigint;
566
- minRate?: bigint;
567
- maxRate?: bigint;
568
- minMaturity?: number;
569
- maxMaturity?: number;
570
- minExpiry?: number;
571
- maxExpiry?: number;
572
- collateralAssets?: string[];
573
- collateralOracles?: string[];
574
- collateralTuple?: Array<{
575
- asset: string;
576
- oracle?: string;
577
- lltv?: LLTV.LLTV;
578
- }>;
579
- minLltv?: number;
580
- maxLltv?: number;
581
- sortBy?: "rate" | "maturity" | "expiry" | "amount";
582
- sortOrder?: "asc" | "desc";
583
- cursor?: string;
584
- limit?: number;
585
- };
586
- type FindMatchingOffersParams = {
587
- side: "buy" | "sell";
588
- chainId: number;
589
- rate?: bigint;
590
- collaterals?: Array<{
591
- asset: string;
592
- oracle: string;
593
- lltv: LLTV.LLTV;
594
- }>;
595
- maturity?: number;
596
- minMaturity?: number;
597
- maxMaturity?: number;
598
- loanToken?: string;
599
- creator?: string;
600
- /** Cursor string returned by a previous call, for pagination */
601
- cursor?: string;
602
- /** Page size; defaults to 20 */
603
- limit?: number;
604
- };
605
- type GetAllParams = {
606
- query?: GetOffersFilters;
607
- };
608
-
609
- declare function memory(parameters: {
610
- offers: Map<Hex, Offer.Offer & {
611
- status: OfferStatus;
612
- metadata?: OfferMetadata;
613
- }>;
614
- filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
615
- }): OfferStore;
616
-
617
- type index$1_FindMatchingOffersParams = FindMatchingOffersParams;
618
- type index$1_GetAllParams = GetAllParams;
619
- type index$1_GetOffersFilters = GetOffersFilters;
620
- type index$1_OfferStore = OfferStore;
621
- declare const index$1_memory: typeof memory;
622
- declare namespace index$1 {
623
- export { type index$1_FindMatchingOffersParams as FindMatchingOffersParams, type index$1_GetAllParams as GetAllParams, type index$1_GetOffersFilters as GetOffersFilters, type index$1_OfferStore as OfferStore, index$1_memory as memory };
624
- }
625
-
626
781
  /**
627
782
  * Start a local router server.
628
783
  * @example
@@ -633,7 +788,7 @@ declare namespace index$1 {
633
788
  */
634
789
  declare function serve(parameters: {
635
790
  port: number;
636
- store?: OfferStore;
791
+ store: OfferStore;
637
792
  }): Promise<void>;
638
793
  declare function error(error: unknown, c: Context): Response & hono.TypedResponse<{
639
794
  statusCode: number;
@@ -786,6 +941,991 @@ declare namespace Logger$1 {
786
941
  export { 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 };
787
942
  }
788
943
 
944
+ declare const VERSION = "offers_v1.1";
945
+ declare const offers: drizzle_orm_pg_core.PgTableWithColumns<{
946
+ name: "offers";
947
+ schema: "offers_v1.1";
948
+ columns: {
949
+ hash: drizzle_orm_pg_core.PgColumn<{
950
+ name: "hash";
951
+ tableName: "offers";
952
+ dataType: "string";
953
+ columnType: "PgVarchar";
954
+ data: string;
955
+ driverParam: string;
956
+ notNull: true;
957
+ hasDefault: false;
958
+ isPrimaryKey: true;
959
+ isAutoincrement: false;
960
+ hasRuntimeDefault: false;
961
+ enumValues: [string, ...string[]];
962
+ baseColumn: never;
963
+ identity: undefined;
964
+ generated: undefined;
965
+ }, {}, {
966
+ length: 66;
967
+ }>;
968
+ offering: drizzle_orm_pg_core.PgColumn<{
969
+ name: "offering";
970
+ tableName: "offers";
971
+ dataType: "string";
972
+ columnType: "PgVarchar";
973
+ data: string;
974
+ driverParam: string;
975
+ notNull: true;
976
+ hasDefault: false;
977
+ isPrimaryKey: false;
978
+ isAutoincrement: false;
979
+ hasRuntimeDefault: false;
980
+ enumValues: [string, ...string[]];
981
+ baseColumn: never;
982
+ identity: undefined;
983
+ generated: undefined;
984
+ }, {}, {
985
+ length: 42;
986
+ }>;
987
+ assets: drizzle_orm_pg_core.PgColumn<{
988
+ name: "assets";
989
+ tableName: "offers";
990
+ dataType: "string";
991
+ columnType: "PgNumeric";
992
+ data: string;
993
+ driverParam: string;
994
+ notNull: true;
995
+ hasDefault: false;
996
+ isPrimaryKey: false;
997
+ isAutoincrement: false;
998
+ hasRuntimeDefault: false;
999
+ enumValues: undefined;
1000
+ baseColumn: never;
1001
+ identity: undefined;
1002
+ generated: undefined;
1003
+ }, {}, {}>;
1004
+ rate: drizzle_orm_pg_core.PgColumn<{
1005
+ name: "rate";
1006
+ tableName: "offers";
1007
+ dataType: "bigint";
1008
+ columnType: "PgBigInt64";
1009
+ data: bigint;
1010
+ driverParam: string;
1011
+ notNull: true;
1012
+ hasDefault: false;
1013
+ isPrimaryKey: false;
1014
+ isAutoincrement: false;
1015
+ hasRuntimeDefault: false;
1016
+ enumValues: undefined;
1017
+ baseColumn: never;
1018
+ identity: undefined;
1019
+ generated: undefined;
1020
+ }, {}, {}>;
1021
+ maturity: drizzle_orm_pg_core.PgColumn<{
1022
+ name: "maturity";
1023
+ tableName: "offers";
1024
+ dataType: "number";
1025
+ columnType: "PgInteger";
1026
+ data: number;
1027
+ driverParam: string | number;
1028
+ notNull: true;
1029
+ hasDefault: false;
1030
+ isPrimaryKey: false;
1031
+ isAutoincrement: false;
1032
+ hasRuntimeDefault: false;
1033
+ enumValues: undefined;
1034
+ baseColumn: never;
1035
+ identity: undefined;
1036
+ generated: undefined;
1037
+ }, {}, {}>;
1038
+ expiry: drizzle_orm_pg_core.PgColumn<{
1039
+ name: "expiry";
1040
+ tableName: "offers";
1041
+ dataType: "number";
1042
+ columnType: "PgInteger";
1043
+ data: number;
1044
+ driverParam: string | number;
1045
+ notNull: true;
1046
+ hasDefault: false;
1047
+ isPrimaryKey: false;
1048
+ isAutoincrement: false;
1049
+ hasRuntimeDefault: false;
1050
+ enumValues: undefined;
1051
+ baseColumn: never;
1052
+ identity: undefined;
1053
+ generated: undefined;
1054
+ }, {}, {}>;
1055
+ start: drizzle_orm_pg_core.PgColumn<{
1056
+ name: "start";
1057
+ tableName: "offers";
1058
+ dataType: "number";
1059
+ columnType: "PgInteger";
1060
+ data: number;
1061
+ driverParam: string | number;
1062
+ notNull: true;
1063
+ hasDefault: false;
1064
+ isPrimaryKey: false;
1065
+ isAutoincrement: false;
1066
+ hasRuntimeDefault: false;
1067
+ enumValues: undefined;
1068
+ baseColumn: never;
1069
+ identity: undefined;
1070
+ generated: undefined;
1071
+ }, {}, {}>;
1072
+ nonce: drizzle_orm_pg_core.PgColumn<{
1073
+ name: "nonce";
1074
+ tableName: "offers";
1075
+ dataType: "bigint";
1076
+ columnType: "PgBigInt64";
1077
+ data: bigint;
1078
+ driverParam: string;
1079
+ notNull: true;
1080
+ hasDefault: false;
1081
+ isPrimaryKey: false;
1082
+ isAutoincrement: false;
1083
+ hasRuntimeDefault: false;
1084
+ enumValues: undefined;
1085
+ baseColumn: never;
1086
+ identity: undefined;
1087
+ generated: undefined;
1088
+ }, {}, {}>;
1089
+ buy: drizzle_orm_pg_core.PgColumn<{
1090
+ name: "buy";
1091
+ tableName: "offers";
1092
+ dataType: "boolean";
1093
+ columnType: "PgBoolean";
1094
+ data: boolean;
1095
+ driverParam: boolean;
1096
+ notNull: true;
1097
+ hasDefault: false;
1098
+ isPrimaryKey: false;
1099
+ isAutoincrement: false;
1100
+ hasRuntimeDefault: false;
1101
+ enumValues: undefined;
1102
+ baseColumn: never;
1103
+ identity: undefined;
1104
+ generated: undefined;
1105
+ }, {}, {}>;
1106
+ chainId: drizzle_orm_pg_core.PgColumn<{
1107
+ name: "chain_id";
1108
+ tableName: "offers";
1109
+ dataType: "bigint";
1110
+ columnType: "PgBigInt64";
1111
+ data: bigint;
1112
+ driverParam: string;
1113
+ notNull: true;
1114
+ hasDefault: false;
1115
+ isPrimaryKey: false;
1116
+ isAutoincrement: false;
1117
+ hasRuntimeDefault: false;
1118
+ enumValues: undefined;
1119
+ baseColumn: never;
1120
+ identity: undefined;
1121
+ generated: undefined;
1122
+ }, {}, {}>;
1123
+ loanToken: drizzle_orm_pg_core.PgColumn<{
1124
+ name: "loan_token";
1125
+ tableName: "offers";
1126
+ dataType: "string";
1127
+ columnType: "PgVarchar";
1128
+ data: string;
1129
+ driverParam: string;
1130
+ notNull: true;
1131
+ hasDefault: false;
1132
+ isPrimaryKey: false;
1133
+ isAutoincrement: false;
1134
+ hasRuntimeDefault: false;
1135
+ enumValues: [string, ...string[]];
1136
+ baseColumn: never;
1137
+ identity: undefined;
1138
+ generated: undefined;
1139
+ }, {}, {
1140
+ length: 42;
1141
+ }>;
1142
+ callbackAddress: drizzle_orm_pg_core.PgColumn<{
1143
+ name: "callback_address";
1144
+ tableName: "offers";
1145
+ dataType: "string";
1146
+ columnType: "PgVarchar";
1147
+ data: string;
1148
+ driverParam: string;
1149
+ notNull: true;
1150
+ hasDefault: false;
1151
+ isPrimaryKey: false;
1152
+ isAutoincrement: false;
1153
+ hasRuntimeDefault: false;
1154
+ enumValues: [string, ...string[]];
1155
+ baseColumn: never;
1156
+ identity: undefined;
1157
+ generated: undefined;
1158
+ }, {}, {
1159
+ length: 42;
1160
+ }>;
1161
+ callbackData: drizzle_orm_pg_core.PgColumn<{
1162
+ name: "callback_data";
1163
+ tableName: "offers";
1164
+ dataType: "string";
1165
+ columnType: "PgText";
1166
+ data: string;
1167
+ driverParam: string;
1168
+ notNull: true;
1169
+ hasDefault: false;
1170
+ isPrimaryKey: false;
1171
+ isAutoincrement: false;
1172
+ hasRuntimeDefault: false;
1173
+ enumValues: [string, ...string[]];
1174
+ baseColumn: never;
1175
+ identity: undefined;
1176
+ generated: undefined;
1177
+ }, {}, {}>;
1178
+ callbackGasLimit: drizzle_orm_pg_core.PgColumn<{
1179
+ name: "callback_gas_limit";
1180
+ tableName: "offers";
1181
+ dataType: "bigint";
1182
+ columnType: "PgBigInt64";
1183
+ data: bigint;
1184
+ driverParam: string;
1185
+ notNull: true;
1186
+ hasDefault: false;
1187
+ isPrimaryKey: false;
1188
+ isAutoincrement: false;
1189
+ hasRuntimeDefault: false;
1190
+ enumValues: undefined;
1191
+ baseColumn: never;
1192
+ identity: undefined;
1193
+ generated: undefined;
1194
+ }, {}, {}>;
1195
+ signature: drizzle_orm_pg_core.PgColumn<{
1196
+ name: "signature";
1197
+ tableName: "offers";
1198
+ dataType: "string";
1199
+ columnType: "PgVarchar";
1200
+ data: string;
1201
+ driverParam: string;
1202
+ notNull: false;
1203
+ hasDefault: false;
1204
+ isPrimaryKey: false;
1205
+ isAutoincrement: false;
1206
+ hasRuntimeDefault: false;
1207
+ enumValues: [string, ...string[]];
1208
+ baseColumn: never;
1209
+ identity: undefined;
1210
+ generated: undefined;
1211
+ }, {}, {
1212
+ length: 132;
1213
+ }>;
1214
+ callbackId: drizzle_orm_pg_core.PgColumn<{
1215
+ name: "callback_id";
1216
+ tableName: "offers";
1217
+ dataType: "string";
1218
+ columnType: "PgVarchar";
1219
+ data: string;
1220
+ driverParam: string;
1221
+ notNull: false;
1222
+ hasDefault: false;
1223
+ isPrimaryKey: false;
1224
+ isAutoincrement: false;
1225
+ hasRuntimeDefault: false;
1226
+ enumValues: [string, ...string[]];
1227
+ baseColumn: never;
1228
+ identity: undefined;
1229
+ generated: undefined;
1230
+ }, {}, {
1231
+ length: 256;
1232
+ }>;
1233
+ createdAt: drizzle_orm_pg_core.PgColumn<{
1234
+ name: "created_at";
1235
+ tableName: "offers";
1236
+ dataType: "date";
1237
+ columnType: "PgTimestamp";
1238
+ data: Date;
1239
+ driverParam: string;
1240
+ notNull: true;
1241
+ hasDefault: true;
1242
+ isPrimaryKey: false;
1243
+ isAutoincrement: false;
1244
+ hasRuntimeDefault: false;
1245
+ enumValues: undefined;
1246
+ baseColumn: never;
1247
+ identity: undefined;
1248
+ generated: undefined;
1249
+ }, {}, {}>;
1250
+ };
1251
+ dialect: "pg";
1252
+ }>;
1253
+ declare const offerCollaterals: drizzle_orm_pg_core.PgTableWithColumns<{
1254
+ name: "offer_collaterals";
1255
+ schema: "offers_v1.1";
1256
+ columns: {
1257
+ id: drizzle_orm_pg_core.PgColumn<{
1258
+ name: "id";
1259
+ tableName: "offer_collaterals";
1260
+ dataType: "number";
1261
+ columnType: "PgSerial";
1262
+ data: number;
1263
+ driverParam: number;
1264
+ notNull: true;
1265
+ hasDefault: true;
1266
+ isPrimaryKey: true;
1267
+ isAutoincrement: false;
1268
+ hasRuntimeDefault: false;
1269
+ enumValues: undefined;
1270
+ baseColumn: never;
1271
+ identity: undefined;
1272
+ generated: undefined;
1273
+ }, {}, {}>;
1274
+ offerHash: drizzle_orm_pg_core.PgColumn<{
1275
+ name: "offer_hash";
1276
+ tableName: "offer_collaterals";
1277
+ dataType: "string";
1278
+ columnType: "PgVarchar";
1279
+ data: string;
1280
+ driverParam: string;
1281
+ notNull: true;
1282
+ hasDefault: false;
1283
+ isPrimaryKey: false;
1284
+ isAutoincrement: false;
1285
+ hasRuntimeDefault: false;
1286
+ enumValues: [string, ...string[]];
1287
+ baseColumn: never;
1288
+ identity: undefined;
1289
+ generated: undefined;
1290
+ }, {}, {
1291
+ length: 66;
1292
+ }>;
1293
+ asset: drizzle_orm_pg_core.PgColumn<{
1294
+ name: "asset";
1295
+ tableName: "offer_collaterals";
1296
+ dataType: "string";
1297
+ columnType: "PgVarchar";
1298
+ data: string;
1299
+ driverParam: string;
1300
+ notNull: true;
1301
+ hasDefault: false;
1302
+ isPrimaryKey: false;
1303
+ isAutoincrement: false;
1304
+ hasRuntimeDefault: false;
1305
+ enumValues: [string, ...string[]];
1306
+ baseColumn: never;
1307
+ identity: undefined;
1308
+ generated: undefined;
1309
+ }, {}, {
1310
+ length: 42;
1311
+ }>;
1312
+ oracle: drizzle_orm_pg_core.PgColumn<{
1313
+ name: "oracle";
1314
+ tableName: "offer_collaterals";
1315
+ dataType: "string";
1316
+ columnType: "PgVarchar";
1317
+ data: string;
1318
+ driverParam: string;
1319
+ notNull: true;
1320
+ hasDefault: false;
1321
+ isPrimaryKey: false;
1322
+ isAutoincrement: false;
1323
+ hasRuntimeDefault: false;
1324
+ enumValues: [string, ...string[]];
1325
+ baseColumn: never;
1326
+ identity: undefined;
1327
+ generated: undefined;
1328
+ }, {}, {
1329
+ length: 42;
1330
+ }>;
1331
+ lltv: drizzle_orm_pg_core.PgColumn<{
1332
+ name: "lltv";
1333
+ tableName: "offer_collaterals";
1334
+ dataType: "bigint";
1335
+ columnType: "PgBigInt64";
1336
+ data: bigint;
1337
+ driverParam: string;
1338
+ notNull: true;
1339
+ hasDefault: false;
1340
+ isPrimaryKey: false;
1341
+ isAutoincrement: false;
1342
+ hasRuntimeDefault: false;
1343
+ enumValues: undefined;
1344
+ baseColumn: never;
1345
+ identity: undefined;
1346
+ generated: undefined;
1347
+ }, {}, {}>;
1348
+ };
1349
+ dialect: "pg";
1350
+ }>;
1351
+ declare const offerStatus: drizzle_orm_pg_core.PgTableWithColumns<{
1352
+ name: "offer_status";
1353
+ schema: "offers_v1.1";
1354
+ columns: {
1355
+ id: drizzle_orm_pg_core.PgColumn<{
1356
+ name: "id";
1357
+ tableName: "offer_status";
1358
+ dataType: "number";
1359
+ columnType: "PgSerial";
1360
+ data: number;
1361
+ driverParam: number;
1362
+ notNull: true;
1363
+ hasDefault: true;
1364
+ isPrimaryKey: true;
1365
+ isAutoincrement: false;
1366
+ hasRuntimeDefault: false;
1367
+ enumValues: undefined;
1368
+ baseColumn: never;
1369
+ identity: undefined;
1370
+ generated: undefined;
1371
+ }, {}, {}>;
1372
+ offerHash: drizzle_orm_pg_core.PgColumn<{
1373
+ name: "offer_hash";
1374
+ tableName: "offer_status";
1375
+ dataType: "string";
1376
+ columnType: "PgVarchar";
1377
+ data: string;
1378
+ driverParam: string;
1379
+ notNull: true;
1380
+ hasDefault: false;
1381
+ isPrimaryKey: false;
1382
+ isAutoincrement: false;
1383
+ hasRuntimeDefault: false;
1384
+ enumValues: [string, ...string[]];
1385
+ baseColumn: never;
1386
+ identity: undefined;
1387
+ generated: undefined;
1388
+ }, {}, {
1389
+ length: 66;
1390
+ }>;
1391
+ status: drizzle_orm_pg_core.PgColumn<{
1392
+ name: "status";
1393
+ tableName: "offer_status";
1394
+ dataType: "string";
1395
+ columnType: "PgText";
1396
+ data: "valid" | "callback_not_supported" | "callback_error" | "unverified";
1397
+ driverParam: string;
1398
+ notNull: true;
1399
+ hasDefault: false;
1400
+ isPrimaryKey: false;
1401
+ isAutoincrement: false;
1402
+ hasRuntimeDefault: false;
1403
+ enumValues: [string, ...string[]];
1404
+ baseColumn: never;
1405
+ identity: undefined;
1406
+ generated: undefined;
1407
+ }, {}, {
1408
+ $type: "valid" | "callback_not_supported" | "callback_error" | "unverified";
1409
+ }>;
1410
+ metadata: drizzle_orm_pg_core.PgColumn<{
1411
+ name: "metadata";
1412
+ tableName: "offer_status";
1413
+ dataType: "json";
1414
+ columnType: "PgJsonb";
1415
+ data: unknown;
1416
+ driverParam: unknown;
1417
+ notNull: false;
1418
+ hasDefault: false;
1419
+ isPrimaryKey: false;
1420
+ isAutoincrement: false;
1421
+ hasRuntimeDefault: false;
1422
+ enumValues: undefined;
1423
+ baseColumn: never;
1424
+ identity: undefined;
1425
+ generated: undefined;
1426
+ }, {}, {}>;
1427
+ createdAt: drizzle_orm_pg_core.PgColumn<{
1428
+ name: "created_at";
1429
+ tableName: "offer_status";
1430
+ dataType: "date";
1431
+ columnType: "PgTimestamp";
1432
+ data: Date;
1433
+ driverParam: string;
1434
+ notNull: true;
1435
+ hasDefault: true;
1436
+ isPrimaryKey: false;
1437
+ isAutoincrement: false;
1438
+ hasRuntimeDefault: false;
1439
+ enumValues: undefined;
1440
+ baseColumn: never;
1441
+ identity: undefined;
1442
+ generated: undefined;
1443
+ }, {}, {}>;
1444
+ };
1445
+ dialect: "pg";
1446
+ }>;
1447
+ declare const consumed: drizzle_orm_pg_core.PgTableWithColumns<{
1448
+ name: "consumed_per_user_and_nonce";
1449
+ schema: "offers_v1.1";
1450
+ columns: {
1451
+ id: drizzle_orm_pg_core.PgColumn<{
1452
+ name: "id";
1453
+ tableName: "consumed_per_user_and_nonce";
1454
+ dataType: "string";
1455
+ columnType: "PgVarchar";
1456
+ data: string;
1457
+ driverParam: string;
1458
+ notNull: true;
1459
+ hasDefault: false;
1460
+ isPrimaryKey: true;
1461
+ isAutoincrement: false;
1462
+ hasRuntimeDefault: false;
1463
+ enumValues: [string, ...string[]];
1464
+ baseColumn: never;
1465
+ identity: undefined;
1466
+ generated: undefined;
1467
+ }, {}, {
1468
+ length: 255;
1469
+ }>;
1470
+ chainId: drizzle_orm_pg_core.PgColumn<{
1471
+ name: "chain_id";
1472
+ tableName: "consumed_per_user_and_nonce";
1473
+ dataType: "bigint";
1474
+ columnType: "PgBigInt64";
1475
+ data: bigint;
1476
+ driverParam: string;
1477
+ notNull: true;
1478
+ hasDefault: false;
1479
+ isPrimaryKey: false;
1480
+ isAutoincrement: false;
1481
+ hasRuntimeDefault: false;
1482
+ enumValues: undefined;
1483
+ baseColumn: never;
1484
+ identity: undefined;
1485
+ generated: undefined;
1486
+ }, {}, {}>;
1487
+ offering: drizzle_orm_pg_core.PgColumn<{
1488
+ name: "offering";
1489
+ tableName: "consumed_per_user_and_nonce";
1490
+ dataType: "string";
1491
+ columnType: "PgVarchar";
1492
+ data: string;
1493
+ driverParam: string;
1494
+ notNull: true;
1495
+ hasDefault: false;
1496
+ isPrimaryKey: false;
1497
+ isAutoincrement: false;
1498
+ hasRuntimeDefault: false;
1499
+ enumValues: [string, ...string[]];
1500
+ baseColumn: never;
1501
+ identity: undefined;
1502
+ generated: undefined;
1503
+ }, {}, {
1504
+ length: 42;
1505
+ }>;
1506
+ nonce: drizzle_orm_pg_core.PgColumn<{
1507
+ name: "nonce";
1508
+ tableName: "consumed_per_user_and_nonce";
1509
+ dataType: "bigint";
1510
+ columnType: "PgBigInt64";
1511
+ data: bigint;
1512
+ driverParam: string;
1513
+ notNull: true;
1514
+ hasDefault: false;
1515
+ isPrimaryKey: false;
1516
+ isAutoincrement: false;
1517
+ hasRuntimeDefault: false;
1518
+ enumValues: undefined;
1519
+ baseColumn: never;
1520
+ identity: undefined;
1521
+ generated: undefined;
1522
+ }, {}, {}>;
1523
+ consumed: drizzle_orm_pg_core.PgColumn<{
1524
+ name: "consumed";
1525
+ tableName: "consumed_per_user_and_nonce";
1526
+ dataType: "string";
1527
+ columnType: "PgNumeric";
1528
+ data: string;
1529
+ driverParam: string;
1530
+ notNull: true;
1531
+ hasDefault: false;
1532
+ isPrimaryKey: false;
1533
+ isAutoincrement: false;
1534
+ hasRuntimeDefault: false;
1535
+ enumValues: undefined;
1536
+ baseColumn: never;
1537
+ identity: undefined;
1538
+ generated: undefined;
1539
+ }, {}, {}>;
1540
+ createdAt: drizzle_orm_pg_core.PgColumn<{
1541
+ name: "created_at";
1542
+ tableName: "consumed_per_user_and_nonce";
1543
+ dataType: "date";
1544
+ columnType: "PgTimestamp";
1545
+ data: Date;
1546
+ driverParam: string;
1547
+ notNull: true;
1548
+ hasDefault: true;
1549
+ isPrimaryKey: false;
1550
+ isAutoincrement: false;
1551
+ hasRuntimeDefault: false;
1552
+ enumValues: undefined;
1553
+ baseColumn: never;
1554
+ identity: undefined;
1555
+ generated: undefined;
1556
+ }, {}, {}>;
1557
+ };
1558
+ dialect: "pg";
1559
+ }>;
1560
+ declare const collectorBlockNumbers: drizzle_orm_pg_core.PgTableWithColumns<{
1561
+ name: "collector_block_numbers";
1562
+ schema: "offers_v1.1";
1563
+ columns: {
1564
+ chainId: drizzle_orm_pg_core.PgColumn<{
1565
+ name: "chain_id";
1566
+ tableName: "collector_block_numbers";
1567
+ dataType: "bigint";
1568
+ columnType: "PgBigInt64";
1569
+ data: bigint;
1570
+ driverParam: string;
1571
+ notNull: true;
1572
+ hasDefault: false;
1573
+ isPrimaryKey: false;
1574
+ isAutoincrement: false;
1575
+ hasRuntimeDefault: false;
1576
+ enumValues: undefined;
1577
+ baseColumn: never;
1578
+ identity: undefined;
1579
+ generated: undefined;
1580
+ }, {}, {}>;
1581
+ name: drizzle_orm_pg_core.PgColumn<{
1582
+ name: "name";
1583
+ tableName: "collector_block_numbers";
1584
+ dataType: "string";
1585
+ columnType: "PgText";
1586
+ data: string;
1587
+ driverParam: string;
1588
+ notNull: true;
1589
+ hasDefault: false;
1590
+ isPrimaryKey: false;
1591
+ isAutoincrement: false;
1592
+ hasRuntimeDefault: false;
1593
+ enumValues: [string, ...string[]];
1594
+ baseColumn: never;
1595
+ identity: undefined;
1596
+ generated: undefined;
1597
+ }, {}, {}>;
1598
+ blockNumber: drizzle_orm_pg_core.PgColumn<{
1599
+ name: "block_number";
1600
+ tableName: "collector_block_numbers";
1601
+ dataType: "number";
1602
+ columnType: "PgBigInt53";
1603
+ data: number;
1604
+ driverParam: string | number;
1605
+ notNull: true;
1606
+ hasDefault: false;
1607
+ isPrimaryKey: false;
1608
+ isAutoincrement: false;
1609
+ hasRuntimeDefault: false;
1610
+ enumValues: undefined;
1611
+ baseColumn: never;
1612
+ identity: undefined;
1613
+ generated: undefined;
1614
+ }, {}, {}>;
1615
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
1616
+ name: "updated_at";
1617
+ tableName: "collector_block_numbers";
1618
+ dataType: "date";
1619
+ columnType: "PgTimestamp";
1620
+ data: Date;
1621
+ driverParam: string;
1622
+ notNull: true;
1623
+ hasDefault: true;
1624
+ isPrimaryKey: false;
1625
+ isAutoincrement: false;
1626
+ hasRuntimeDefault: false;
1627
+ enumValues: undefined;
1628
+ baseColumn: never;
1629
+ identity: undefined;
1630
+ generated: undefined;
1631
+ }, {}, {}>;
1632
+ };
1633
+ dialect: "pg";
1634
+ }>;
1635
+ declare const availableLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
1636
+ name: "available_liquidity_pools";
1637
+ schema: "offers_v1.1";
1638
+ columns: {
1639
+ id: drizzle_orm_pg_core.PgColumn<{
1640
+ name: "id";
1641
+ tableName: "available_liquidity_pools";
1642
+ dataType: "string";
1643
+ columnType: "PgVarchar";
1644
+ data: string;
1645
+ driverParam: string;
1646
+ notNull: true;
1647
+ hasDefault: false;
1648
+ isPrimaryKey: true;
1649
+ isAutoincrement: false;
1650
+ hasRuntimeDefault: false;
1651
+ enumValues: [string, ...string[]];
1652
+ baseColumn: never;
1653
+ identity: undefined;
1654
+ generated: undefined;
1655
+ }, {}, {
1656
+ length: 255;
1657
+ }>;
1658
+ amount: drizzle_orm_pg_core.PgColumn<{
1659
+ name: "amount";
1660
+ tableName: "available_liquidity_pools";
1661
+ dataType: "string";
1662
+ columnType: "PgNumeric";
1663
+ data: string;
1664
+ driverParam: string;
1665
+ notNull: true;
1666
+ hasDefault: false;
1667
+ isPrimaryKey: false;
1668
+ isAutoincrement: false;
1669
+ hasRuntimeDefault: false;
1670
+ enumValues: undefined;
1671
+ baseColumn: never;
1672
+ identity: undefined;
1673
+ generated: undefined;
1674
+ }, {}, {}>;
1675
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
1676
+ name: "updated_at";
1677
+ tableName: "available_liquidity_pools";
1678
+ dataType: "date";
1679
+ columnType: "PgTimestamp";
1680
+ data: Date;
1681
+ driverParam: string;
1682
+ notNull: true;
1683
+ hasDefault: true;
1684
+ isPrimaryKey: false;
1685
+ isAutoincrement: false;
1686
+ hasRuntimeDefault: false;
1687
+ enumValues: undefined;
1688
+ baseColumn: never;
1689
+ identity: undefined;
1690
+ generated: undefined;
1691
+ }, {}, {}>;
1692
+ };
1693
+ dialect: "pg";
1694
+ }>;
1695
+ declare const availableLiquidityQueues: drizzle_orm_pg_core.PgTableWithColumns<{
1696
+ name: "available_liquidity_queues";
1697
+ schema: "offers_v1.1";
1698
+ columns: {
1699
+ queueId: drizzle_orm_pg_core.PgColumn<{
1700
+ name: "queue_id";
1701
+ tableName: "available_liquidity_queues";
1702
+ dataType: "string";
1703
+ columnType: "PgVarchar";
1704
+ data: string;
1705
+ driverParam: string;
1706
+ notNull: true;
1707
+ hasDefault: false;
1708
+ isPrimaryKey: false;
1709
+ isAutoincrement: false;
1710
+ hasRuntimeDefault: false;
1711
+ enumValues: [string, ...string[]];
1712
+ baseColumn: never;
1713
+ identity: undefined;
1714
+ generated: undefined;
1715
+ }, {}, {
1716
+ length: 255;
1717
+ }>;
1718
+ availableLiquidityPoolId: drizzle_orm_pg_core.PgColumn<{
1719
+ name: "available_liquidity_pool_id";
1720
+ tableName: "available_liquidity_queues";
1721
+ dataType: "string";
1722
+ columnType: "PgVarchar";
1723
+ data: string;
1724
+ driverParam: string;
1725
+ notNull: true;
1726
+ hasDefault: false;
1727
+ isPrimaryKey: false;
1728
+ isAutoincrement: false;
1729
+ hasRuntimeDefault: false;
1730
+ enumValues: [string, ...string[]];
1731
+ baseColumn: never;
1732
+ identity: undefined;
1733
+ generated: undefined;
1734
+ }, {}, {
1735
+ length: 255;
1736
+ }>;
1737
+ index: drizzle_orm_pg_core.PgColumn<{
1738
+ name: "index";
1739
+ tableName: "available_liquidity_queues";
1740
+ dataType: "number";
1741
+ columnType: "PgInteger";
1742
+ data: number;
1743
+ driverParam: string | number;
1744
+ notNull: true;
1745
+ hasDefault: false;
1746
+ isPrimaryKey: false;
1747
+ isAutoincrement: false;
1748
+ hasRuntimeDefault: false;
1749
+ enumValues: undefined;
1750
+ baseColumn: never;
1751
+ identity: undefined;
1752
+ generated: undefined;
1753
+ }, {}, {}>;
1754
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
1755
+ name: "updated_at";
1756
+ tableName: "available_liquidity_queues";
1757
+ dataType: "date";
1758
+ columnType: "PgTimestamp";
1759
+ data: Date;
1760
+ driverParam: string;
1761
+ notNull: true;
1762
+ hasDefault: true;
1763
+ isPrimaryKey: false;
1764
+ isAutoincrement: false;
1765
+ hasRuntimeDefault: false;
1766
+ enumValues: undefined;
1767
+ baseColumn: never;
1768
+ identity: undefined;
1769
+ generated: undefined;
1770
+ }, {}, {}>;
1771
+ };
1772
+ dialect: "pg";
1773
+ }>;
1774
+ declare const userPositions: drizzle_orm_pg_core.PgTableWithColumns<{
1775
+ name: "user_positions";
1776
+ schema: "offers_v1.1";
1777
+ columns: {
1778
+ id: drizzle_orm_pg_core.PgColumn<{
1779
+ name: "id";
1780
+ tableName: "user_positions";
1781
+ dataType: "string";
1782
+ columnType: "PgVarchar";
1783
+ data: string;
1784
+ driverParam: string;
1785
+ notNull: true;
1786
+ hasDefault: false;
1787
+ isPrimaryKey: true;
1788
+ isAutoincrement: false;
1789
+ hasRuntimeDefault: false;
1790
+ enumValues: [string, ...string[]];
1791
+ baseColumn: never;
1792
+ identity: undefined;
1793
+ generated: undefined;
1794
+ }, {}, {
1795
+ length: 255;
1796
+ }>;
1797
+ availableLiquidityQueueId: drizzle_orm_pg_core.PgColumn<{
1798
+ name: "available_liquidity_queue_id";
1799
+ tableName: "user_positions";
1800
+ dataType: "string";
1801
+ columnType: "PgVarchar";
1802
+ data: string;
1803
+ driverParam: string;
1804
+ notNull: true;
1805
+ hasDefault: false;
1806
+ isPrimaryKey: false;
1807
+ isAutoincrement: false;
1808
+ hasRuntimeDefault: false;
1809
+ enumValues: [string, ...string[]];
1810
+ baseColumn: never;
1811
+ identity: undefined;
1812
+ generated: undefined;
1813
+ }, {}, {
1814
+ length: 255;
1815
+ }>;
1816
+ user: drizzle_orm_pg_core.PgColumn<{
1817
+ name: "user";
1818
+ tableName: "user_positions";
1819
+ dataType: "string";
1820
+ columnType: "PgVarchar";
1821
+ data: string;
1822
+ driverParam: string;
1823
+ notNull: true;
1824
+ hasDefault: false;
1825
+ isPrimaryKey: false;
1826
+ isAutoincrement: false;
1827
+ hasRuntimeDefault: false;
1828
+ enumValues: [string, ...string[]];
1829
+ baseColumn: never;
1830
+ identity: undefined;
1831
+ generated: undefined;
1832
+ }, {}, {
1833
+ length: 255;
1834
+ }>;
1835
+ chainId: drizzle_orm_pg_core.PgColumn<{
1836
+ name: "chain_id";
1837
+ tableName: "user_positions";
1838
+ dataType: "bigint";
1839
+ columnType: "PgBigInt64";
1840
+ data: bigint;
1841
+ driverParam: string;
1842
+ notNull: true;
1843
+ hasDefault: false;
1844
+ isPrimaryKey: false;
1845
+ isAutoincrement: false;
1846
+ hasRuntimeDefault: false;
1847
+ enumValues: undefined;
1848
+ baseColumn: never;
1849
+ identity: undefined;
1850
+ generated: undefined;
1851
+ }, {}, {}>;
1852
+ amount: drizzle_orm_pg_core.PgColumn<{
1853
+ name: "amount";
1854
+ tableName: "user_positions";
1855
+ dataType: "string";
1856
+ columnType: "PgNumeric";
1857
+ data: string;
1858
+ driverParam: string;
1859
+ notNull: true;
1860
+ hasDefault: false;
1861
+ isPrimaryKey: false;
1862
+ isAutoincrement: false;
1863
+ hasRuntimeDefault: false;
1864
+ enumValues: undefined;
1865
+ baseColumn: never;
1866
+ identity: undefined;
1867
+ generated: undefined;
1868
+ }, {}, {}>;
1869
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
1870
+ name: "updated_at";
1871
+ tableName: "user_positions";
1872
+ dataType: "date";
1873
+ columnType: "PgTimestamp";
1874
+ data: Date;
1875
+ driverParam: string;
1876
+ notNull: true;
1877
+ hasDefault: true;
1878
+ isPrimaryKey: false;
1879
+ isAutoincrement: false;
1880
+ hasRuntimeDefault: false;
1881
+ enumValues: undefined;
1882
+ baseColumn: never;
1883
+ identity: undefined;
1884
+ generated: undefined;
1885
+ }, {}, {}>;
1886
+ };
1887
+ dialect: "pg";
1888
+ }>;
1889
+
1890
+ declare const schema_VERSION: typeof VERSION;
1891
+ declare const schema_availableLiquidityPools: typeof availableLiquidityPools;
1892
+ declare const schema_availableLiquidityQueues: typeof availableLiquidityQueues;
1893
+ declare const schema_collectorBlockNumbers: typeof collectorBlockNumbers;
1894
+ declare const schema_consumed: typeof consumed;
1895
+ declare const schema_offerCollaterals: typeof offerCollaterals;
1896
+ declare const schema_offerStatus: typeof offerStatus;
1897
+ declare const schema_offers: typeof offers;
1898
+ declare const schema_userPositions: typeof userPositions;
1899
+ declare namespace schema {
1900
+ export { schema_VERSION as VERSION, schema_availableLiquidityPools as availableLiquidityPools, schema_availableLiquidityQueues as availableLiquidityQueues, schema_collectorBlockNumbers as collectorBlockNumbers, schema_consumed as consumed, schema_offerCollaterals as offerCollaterals, schema_offerStatus as offerStatus, schema_offers as offers, schema_userPositions as userPositions };
1901
+ }
1902
+
1903
+ type config = {
1904
+ chain: Chain.Chain;
1905
+ rpcUrl: string;
1906
+ dbConfig: {
1907
+ type: "pg" | "pglite";
1908
+ endpoint?: string;
1909
+ };
1910
+ };
1911
+ type Services = {
1912
+ offerStore: OfferStore;
1913
+ collectorBlockStore: CollectorBlockStore;
1914
+ liquidityStore: LiquidityStore;
1915
+ mempoolOffersCollector: Collector<"mempool_offers">;
1916
+ consumedEventsCollector: Collector<"consumed_events">;
1917
+ buyWithEmptyCallbackLiquidityCollector: Collector<"buy_with_empty_callback_liquidity">;
1918
+ DB: PG;
1919
+ };
1920
+ declare const from: (config: config) => Promise<Services>;
1921
+
1922
+ type Services$1_Services = Services;
1923
+ type Services$1_config = config;
1924
+ declare const Services$1_from: typeof from;
1925
+ declare namespace Services$1 {
1926
+ export { type Services$1_Services as Services, type Services$1_config as config, Services$1_from as from };
1927
+ }
1928
+
789
1929
  /**
790
1930
  * A validation rule.
791
1931
  */
@@ -983,4 +2123,4 @@ declare namespace Validation {
983
2123
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
984
2124
  }
985
2125
 
986
- export { index$2 as ApiSchema, Callback, Cursor$1 as Cursor, Liquidity$1 as Liquidity, Logger$1 as Logger, index$1 as OfferStore, index as Router, RouterOffer$1 as RouterOffer, Validation, ValidationRule };
2126
+ export { index$1 as ApiSchema, Callback, index$2 as Collector, CollectorBlockStore$1 as CollectorBlockStore, Cursor$1 as Cursor, Liquidity$1 as Liquidity, LiquidityStore$1 as LiquidityStore, Logger$1 as Logger, index$3 as OfferStore, schema as OffersSchema, PG$1 as PG, index as Router, RouterOffer$1 as RouterOffer, Services$1 as Services, Validation, ValidationRule };