@morpho-dev/router 0.1.7 → 0.1.8

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,19 +1,251 @@
1
1
  import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
- import { Offer, Chain, Errors, Format, LLTV, Mempool, Maturity, Compute } from '@morpho-dev/mempool';
2
+ import { Offer, Errors, Format, Chain, LLTV, Mempool, Compute, Maturity } from '@morpho-dev/mempool';
3
3
  export * from '@morpho-dev/mempool';
4
+ import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
5
+ import { z, ZodError } from 'zod/v4';
4
6
  import * as viem from 'viem';
5
- import { PublicActions, Address, Hex, WalletClient, PublicClient } from 'viem';
7
+ import { Address, Hex, PublicActions, WalletClient, PublicClient } from 'viem';
6
8
  import { PGlite } from '@electric-sql/pglite';
7
9
  import { drizzle } from 'drizzle-orm/node-postgres';
8
10
  import { drizzle as drizzle$1 } from 'drizzle-orm/pglite';
9
11
  import { Pool } from 'pg';
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';
12
+ import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
12
13
  import * as hono_utils_types from 'hono/utils/types';
13
14
  import * as hono from 'hono';
14
15
  import { Context } from 'hono';
15
16
  import * as hono_utils_http_status from 'hono/utils/http-status';
16
- import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
17
+
18
+ declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
19
+
20
+ declare const schemas: {
21
+ readonly get_offers: z.ZodObject<{
22
+ creators: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
23
+ side: z.ZodOptional<z.ZodEnum<{
24
+ buy: "buy";
25
+ sell: "sell";
26
+ }>>;
27
+ chains: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<number[], string>>>;
28
+ loan_tokens: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
29
+ status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
30
+ callback_addresses: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
31
+ min_amount: z.ZodOptional<z.ZodBigInt>;
32
+ max_amount: z.ZodOptional<z.ZodBigInt>;
33
+ min_rate: z.ZodOptional<z.ZodBigInt>;
34
+ max_rate: z.ZodOptional<z.ZodBigInt>;
35
+ min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
36
+ max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
37
+ min_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
38
+ max_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
39
+ collateral_assets: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
40
+ collateral_oracles: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
41
+ collateral_tuple: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
42
+ asset: string;
43
+ oracle: string | undefined;
44
+ lltv: (bigint & _morpho_dev_mempool.Brand<"LLTV">) | undefined;
45
+ }[], string>>>;
46
+ min_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
47
+ max_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
48
+ sort_by: z.ZodOptional<z.ZodEnum<{
49
+ rate: "rate";
50
+ maturity: "maturity";
51
+ expiry: "expiry";
52
+ amount: "amount";
53
+ }>>;
54
+ sort_order: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
55
+ asc: "asc";
56
+ desc: "desc";
57
+ }>>>;
58
+ cursor: z.ZodOptional<z.ZodString>;
59
+ limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
60
+ }, z.core.$strip>;
61
+ readonly match_offers: z.ZodObject<{
62
+ side: z.ZodEnum<{
63
+ buy: "buy";
64
+ sell: "sell";
65
+ }>;
66
+ chain_id: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
67
+ rate: z.ZodOptional<z.ZodBigInt>;
68
+ collaterals: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
69
+ asset: string;
70
+ oracle: string;
71
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
72
+ }[], string>>>;
73
+ maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
74
+ min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
75
+ max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
76
+ loan_token: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
77
+ creator: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
78
+ cursor: z.ZodOptional<z.ZodString>;
79
+ limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
80
+ }, z.core.$strip>;
81
+ };
82
+ type Action = keyof typeof schemas;
83
+ declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
84
+ declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
85
+
86
+ declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
87
+ type OfferStatus = (typeof OfferStatusValues)[number];
88
+ type OfferMetadata = {
89
+ issue: string;
90
+ };
91
+ type RouterOffer = Offer.Offer & {
92
+ consumed: bigint;
93
+ status: OfferStatus;
94
+ metadata?: OfferMetadata;
95
+ };
96
+ type OfferConsumed = {
97
+ id: string;
98
+ chainId: bigint;
99
+ offering: Address;
100
+ nonce: bigint;
101
+ amount: bigint;
102
+ };
103
+ declare const RouterOfferSchema: (parameters?: {
104
+ omitHash?: boolean;
105
+ }) => z.ZodObject<{
106
+ offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
107
+ assets: z.ZodBigInt;
108
+ rate: z.ZodBigInt;
109
+ maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
110
+ expiry: z.ZodNumber;
111
+ start: z.ZodNumber;
112
+ nonce: z.ZodBigInt;
113
+ buy: z.ZodBoolean;
114
+ chainId: z.ZodBigInt;
115
+ loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
116
+ collaterals: z.ZodArray<z.ZodObject<{
117
+ asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
118
+ oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
119
+ lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
120
+ }, z.core.$strip>>;
121
+ callback: z.ZodObject<{
122
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
123
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
124
+ gasLimit: z.ZodBigInt;
125
+ }, z.core.$strip>;
126
+ signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
127
+ createdAt: z.ZodOptional<z.ZodNumber>;
128
+ consumed: z.ZodBigInt;
129
+ status: z.ZodEnum<{
130
+ valid: "valid";
131
+ callback_not_supported: "callback_not_supported";
132
+ callback_error: "callback_error";
133
+ unverified: "unverified";
134
+ }>;
135
+ metadata: z.ZodOptional<z.ZodObject<{
136
+ issue: z.ZodString;
137
+ }, z.core.$strip>>;
138
+ }, z.core.$strip>;
139
+ /**
140
+ * ABI for the Consumed event emitted by the terms contract.
141
+ */
142
+ declare const consumedEvent: {
143
+ readonly type: "event";
144
+ readonly name: "Consumed";
145
+ readonly inputs: readonly [{
146
+ readonly name: "user";
147
+ readonly type: "address";
148
+ readonly indexed: true;
149
+ readonly internalType: "address";
150
+ }, {
151
+ readonly name: "nonce";
152
+ readonly type: "uint256";
153
+ readonly indexed: true;
154
+ readonly internalType: "uint256";
155
+ }, {
156
+ readonly name: "amount";
157
+ readonly type: "uint256";
158
+ readonly indexed: false;
159
+ readonly internalType: "uint256";
160
+ }];
161
+ readonly anonymous: false;
162
+ };
163
+ /**
164
+ * Creates a router offer from a plain object.
165
+ * @throws {InvalidRouterOfferError} If the router offer is invalid.
166
+ * @param input - The router offer to create.
167
+ * @returns The created router offer with its hash.
168
+ */
169
+ declare function from$1(input: Omit<RouterOffer, "hash">): RouterOffer;
170
+ declare namespace from$1 {
171
+ type ErrorType = InvalidRouterOfferError;
172
+ }
173
+ /**
174
+ * Creates a router offer from a snake case object.
175
+ * @throws {InvalidRouterOfferError} If the router offer is invalid.
176
+ * @param input - The router offer to create.
177
+ * @returns The created router offer with its hash.
178
+ */
179
+ declare function fromSnakeCase(input: Format.Snake<Omit<RouterOffer, "hash">>): RouterOffer;
180
+ declare namespace fromSnakeCase {
181
+ type ErrorType = InvalidRouterOfferError;
182
+ }
183
+ /**
184
+ * Converts a router offer to a snake case object.
185
+ * @param offer - The router offer to convert.
186
+ * @returns The converted router offer.
187
+ */
188
+ declare function toSnakeCase(offer: RouterOffer): Format.Snake<RouterOffer>;
189
+ declare function random(): RouterOffer;
190
+ declare function fromConsumedLog(parameters: {
191
+ blockNumber: bigint;
192
+ logIndex: number;
193
+ chainId: number;
194
+ transactionHash: Hex;
195
+ user: Address;
196
+ nonce: bigint;
197
+ amount: bigint;
198
+ }): OfferConsumed;
199
+ declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error> {
200
+ readonly name = "RouterOffer.InvalidRouterOfferError";
201
+ constructor(error: ZodError | Error);
202
+ }
203
+
204
+ type RouterOffer$1_InvalidRouterOfferError = InvalidRouterOfferError;
205
+ declare const RouterOffer$1_InvalidRouterOfferError: typeof InvalidRouterOfferError;
206
+ type RouterOffer$1_OfferConsumed = OfferConsumed;
207
+ type RouterOffer$1_OfferMetadata = OfferMetadata;
208
+ type RouterOffer$1_OfferStatus = OfferStatus;
209
+ declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
210
+ type RouterOffer$1_RouterOffer = RouterOffer;
211
+ declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
212
+ declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
213
+ declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
214
+ declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
215
+ declare const RouterOffer$1_random: typeof random;
216
+ declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
217
+ declare namespace RouterOffer$1 {
218
+ 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 };
219
+ }
220
+
221
+ type OfferResponse = {
222
+ offer: Offer.Offer;
223
+ consumed: bigint;
224
+ status: OfferStatus;
225
+ metadata?: OfferMetadata;
226
+ };
227
+ /**
228
+ * Transforms a RouterOffer to OfferResponse format.
229
+ * @param routerOffer - The router offer to transform.
230
+ * @returns The router offer response with offer as a nested property.
231
+ */
232
+ declare function toResponse(routerOffer: RouterOffer): OfferResponse;
233
+ /**
234
+ * Transforms a OfferResponse to RouterOffer format.
235
+ * @param offerResponse - The router offer response to transform.
236
+ * @returns The router offer with all properties at the top level.
237
+ */
238
+ declare function fromResponse(offerResponse: OfferResponse): RouterOffer;
239
+
240
+ type index$3_OfferResponse = OfferResponse;
241
+ declare const index$3_OpenApi: typeof OpenApi;
242
+ declare const index$3_fromResponse: typeof fromResponse;
243
+ declare const index$3_parse: typeof parse;
244
+ declare const index$3_safeParse: typeof safeParse;
245
+ declare const index$3_toResponse: typeof toResponse;
246
+ declare namespace index$3 {
247
+ 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 };
248
+ }
17
249
 
18
250
  declare function fetchBalancesAndAllowances(parameters: {
19
251
  client: Pick<PublicActions, "multicall">;
@@ -186,141 +418,6 @@ declare namespace LiquidityStore$1 {
186
418
  export { type LiquidityStore$1_LiquidityStore as LiquidityStore, create$1 as create, LiquidityStore$1_memory as memory };
187
419
  }
188
420
 
189
- declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
190
- type OfferStatus = (typeof OfferStatusValues)[number];
191
- type OfferMetadata = {
192
- issue: string;
193
- };
194
- type RouterOffer = Offer.Offer & {
195
- consumed: bigint;
196
- status: OfferStatus;
197
- metadata?: OfferMetadata;
198
- };
199
- type OfferConsumed = {
200
- id: string;
201
- chainId: bigint;
202
- offering: Address;
203
- nonce: bigint;
204
- amount: bigint;
205
- };
206
- declare const RouterOfferSchema: (parameters?: {
207
- omitHash?: boolean;
208
- }) => z.ZodObject<{
209
- offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
210
- assets: z.ZodBigInt;
211
- rate: z.ZodBigInt;
212
- maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
213
- expiry: z.ZodNumber;
214
- start: z.ZodNumber;
215
- nonce: z.ZodBigInt;
216
- buy: z.ZodBoolean;
217
- chainId: z.ZodBigInt;
218
- loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
219
- collaterals: z.ZodArray<z.ZodObject<{
220
- asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
221
- oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
222
- lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
223
- }, z.core.$strip>>;
224
- callback: z.ZodObject<{
225
- address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
226
- data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
227
- gasLimit: z.ZodBigInt;
228
- }, z.core.$strip>;
229
- signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
230
- createdAt: z.ZodOptional<z.ZodNumber>;
231
- consumed: z.ZodBigInt;
232
- status: z.ZodEnum<{
233
- valid: "valid";
234
- callback_not_supported: "callback_not_supported";
235
- callback_error: "callback_error";
236
- unverified: "unverified";
237
- }>;
238
- metadata: z.ZodOptional<z.ZodObject<{
239
- issue: z.ZodString;
240
- }, z.core.$strip>>;
241
- }, z.core.$strip>;
242
- /**
243
- * ABI for the Consumed event emitted by the terms contract.
244
- */
245
- declare const consumedEvent: {
246
- readonly type: "event";
247
- readonly name: "Consumed";
248
- readonly inputs: readonly [{
249
- readonly name: "user";
250
- readonly type: "address";
251
- readonly indexed: true;
252
- readonly internalType: "address";
253
- }, {
254
- readonly name: "nonce";
255
- readonly type: "uint256";
256
- readonly indexed: true;
257
- readonly internalType: "uint256";
258
- }, {
259
- readonly name: "amount";
260
- readonly type: "uint256";
261
- readonly indexed: false;
262
- readonly internalType: "uint256";
263
- }];
264
- readonly anonymous: false;
265
- };
266
- /**
267
- * Creates a router offer from a plain object.
268
- * @throws {InvalidRouterOfferError} If the router offer is invalid.
269
- * @param input - The router offer to create.
270
- * @returns The created router offer with its hash.
271
- */
272
- declare function from$1(input: Omit<RouterOffer, "hash">): RouterOffer;
273
- declare namespace from$1 {
274
- type ErrorType = InvalidRouterOfferError;
275
- }
276
- /**
277
- * Creates a router offer from a snake case object.
278
- * @throws {InvalidRouterOfferError} If the router offer is invalid.
279
- * @param input - The router offer to create.
280
- * @returns The created router offer with its hash.
281
- */
282
- declare function fromSnakeCase(input: Format.Snake<Omit<RouterOffer, "hash">>): RouterOffer;
283
- declare namespace fromSnakeCase {
284
- type ErrorType = InvalidRouterOfferError;
285
- }
286
- /**
287
- * Converts a router offer to a snake case object.
288
- * @param offer - The router offer to convert.
289
- * @returns The converted router offer.
290
- */
291
- declare function toSnakeCase(offer: RouterOffer): Format.Snake<RouterOffer>;
292
- declare function random(): RouterOffer;
293
- declare function fromConsumedLog(parameters: {
294
- blockNumber: bigint;
295
- logIndex: number;
296
- chainId: number;
297
- transactionHash: Hex;
298
- user: Address;
299
- nonce: bigint;
300
- amount: bigint;
301
- }): OfferConsumed;
302
- declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error> {
303
- readonly name = "RouterOffer.InvalidRouterOfferError";
304
- constructor(error: ZodError | Error);
305
- }
306
-
307
- type RouterOffer$1_InvalidRouterOfferError = InvalidRouterOfferError;
308
- declare const RouterOffer$1_InvalidRouterOfferError: typeof InvalidRouterOfferError;
309
- type RouterOffer$1_OfferConsumed = OfferConsumed;
310
- type RouterOffer$1_OfferMetadata = OfferMetadata;
311
- type RouterOffer$1_OfferStatus = OfferStatus;
312
- declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
313
- type RouterOffer$1_RouterOffer = RouterOffer;
314
- declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
315
- declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
316
- declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
317
- declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
318
- declare const RouterOffer$1_random: typeof random;
319
- declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
320
- declare namespace RouterOffer$1 {
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
421
  /**
325
422
  * The `OfferStore` is responsible for managing offer data in the database.
326
423
  */
@@ -423,14 +520,14 @@ type PgConfig = {
423
520
  };
424
521
  declare function create(config: PgConfig): OfferStore;
425
522
 
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 };
523
+ type index$2_FindMatchingOffersParams = FindMatchingOffersParams;
524
+ type index$2_GetAllParams = GetAllParams;
525
+ type index$2_GetOffersFilters = GetOffersFilters;
526
+ type index$2_OfferStore = OfferStore;
527
+ type index$2_PgConfig = PgConfig;
528
+ declare const index$2_create: typeof create;
529
+ declare namespace index$2 {
530
+ 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, type index$2_PgConfig as PgConfig, index$2_create as create };
434
531
  }
435
532
 
436
533
  type Name = "mempool_offers" | "consumed_events" | "buy_with_empty_callback_liquidity" | "chain_reorgs";
@@ -499,15 +596,15 @@ declare function createMempoolCollector(parameters: {
499
596
  };
500
597
  }): Collector<"mempool_offers">;
501
598
 
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 };
599
+ type index$1_Collector<name extends Name = Name> = Collector<name>;
600
+ type index$1_Name = Name;
601
+ declare const index$1_createBuyWithEmptyCallbackLiquidityCollector: typeof createBuyWithEmptyCallbackLiquidityCollector;
602
+ declare const index$1_createChainReorgsCollector: typeof createChainReorgsCollector;
603
+ declare const index$1_createConsumedEventsCollector: typeof createConsumedEventsCollector;
604
+ declare const index$1_createMempoolCollector: typeof createMempoolCollector;
605
+ declare const index$1_start: typeof start;
606
+ declare namespace index$1 {
607
+ export { type index$1_Collector as Collector, type index$1_Name as Name, index$1_createBuyWithEmptyCallbackLiquidityCollector as createBuyWithEmptyCallbackLiquidityCollector, index$1_createChainReorgsCollector as createChainReorgsCollector, index$1_createConsumedEventsCollector as createConsumedEventsCollector, index$1_createMempoolCollector as createMempoolCollector, index$1_start as start };
511
608
  }
512
609
 
513
610
  type Cursor = {
@@ -531,414 +628,36 @@ declare namespace Cursor$1 {
531
628
  export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
532
629
  }
533
630
 
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
-
602
- type OfferResponse = {
603
- offer: Offer.Offer;
604
- consumed: bigint;
605
- status: OfferStatus;
606
- metadata?: OfferMetadata;
631
+ declare const LogLevelValues: readonly ["silent", "trace", "debug", "info", "warn", "error", "fatal"];
632
+ type LogLevel = (typeof LogLevelValues)[number];
633
+ type LogEntry = Compute<{
634
+ msg: string;
635
+ } & Record<string, unknown>>;
636
+ type LogFn = (entry: LogEntry) => void;
637
+ type Logger = {
638
+ trace: LogFn;
639
+ debug: LogFn;
640
+ info: LogFn;
641
+ warn: LogFn;
642
+ error: LogFn;
643
+ fatal: LogFn;
607
644
  };
608
- /**
609
- * Transforms a RouterOffer to OfferResponse format.
610
- * @param routerOffer - The router offer to transform.
611
- * @returns The router offer response with offer as a nested property.
612
- */
613
- declare function toResponse(routerOffer: RouterOffer): OfferResponse;
614
- /**
615
- * Transforms a OfferResponse to RouterOffer format.
616
- * @param offerResponse - The router offer response to transform.
617
- * @returns The router offer with all properties at the top level.
618
- */
619
- declare function fromResponse(offerResponse: OfferResponse): RouterOffer;
645
+ declare function defaultLogger(minLevel?: LogLevel): Logger;
646
+ declare function silentLogger(): Logger;
647
+ declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
648
+ declare function getLogger(): Logger;
620
649
 
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 };
629
- }
630
-
631
- type GetParameters = {
632
- /** Filter by multiple creator addresses (comma-separated) */
633
- creators?: string[];
634
- /** Filter by offer type: buy offers or sell offers */
635
- side?: "buy" | "sell";
636
- /** Filter by multiple blockchain networks (comma-separated chain IDs) */
637
- chains?: number[];
638
- /** Filter by multiple loan assets (comma-separated) */
639
- loanTokens?: string[];
640
- /** Filter by multiple statuses (comma-separated) */
641
- status?: OfferStatus[];
642
- /** Filter by multiple callback addresses (comma-separated) */
643
- callbackAddresses?: string[];
644
- /** Minimum amount of assets in the offer */
645
- minAmount?: bigint;
646
- /** Maximum amount of assets in the offer */
647
- maxAmount?: bigint;
648
- /** Minimum rate per asset (in wei) */
649
- minRate?: bigint;
650
- /** Maximum rate per asset (in wei) */
651
- maxRate?: bigint;
652
- /** Minimum maturity timestamp (Unix timestamp in seconds) */
653
- minMaturity?: Maturity.Maturity;
654
- /** Maximum maturity timestamp (Unix timestamp in seconds) */
655
- maxMaturity?: Maturity.Maturity;
656
- /** Minimum expiry timestamp (Unix timestamp in seconds) */
657
- minExpiry?: number;
658
- /** Maximum expiry timestamp (Unix timestamp in seconds) */
659
- maxExpiry?: number;
660
- /** Filter by multiple collateral assets (comma-separated) */
661
- collateralAssets?: string[];
662
- /** Filter by multiple rate oracles (comma-separated) */
663
- collateralOracles?: string[];
664
- /** Filter by collateral combinations */
665
- collateralTuple?: Array<{
666
- asset: string;
667
- oracle?: string;
668
- lltv?: LLTV.LLTV;
669
- }>;
670
- /** Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
671
- minLltv?: LLTV.LLTV;
672
- /** Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
673
- maxLltv?: LLTV.LLTV;
674
- /** Field to sort results by */
675
- sortBy?: "rate" | "maturity" | "expiry" | "amount";
676
- /** Sort direction: asc (ascending) or desc (descending, default) */
677
- sortOrder?: "asc" | "desc";
678
- /** Pagination cursor in base64url-encoded format */
679
- cursor?: string;
680
- /** Maximum number of offers to return. Defaults to 20. Maximum is 100. */
681
- limit?: number;
682
- };
683
- type MatchParameters = {
684
- /** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
685
- side: "buy" | "sell";
686
- /** The blockchain network chain ID */
687
- chainId: number;
688
- /** Rate per asset (in wei) for matching offers */
689
- rate?: bigint;
690
- /** Collateral requirements */
691
- collaterals?: Array<{
692
- asset: string;
693
- oracle: string;
694
- lltv: LLTV.LLTV;
695
- }>;
696
- /** Exact maturity timestamp (Unix timestamp in seconds) */
697
- maturity?: Maturity.Maturity;
698
- /** Minimum maturity timestamp (Unix timestamp in seconds, inclusive) */
699
- minMaturity?: Maturity.Maturity;
700
- /** Maximum maturity timestamp (Unix timestamp in seconds, inclusive) */
701
- maxMaturity?: Maturity.Maturity;
702
- /** The loan asset address to match against */
703
- loanToken?: string;
704
- /** Filter by a specific offer creator address */
705
- creator?: string;
706
- /** Filter by multiple statuses (comma-separated) */
707
- status?: OfferStatus[];
708
- /** Pagination cursor in base64url-encoded format */
709
- cursor?: string;
710
- /** Maximum number of offers to return. Defaults to 20. Maximum is 100. */
711
- limit?: number;
712
- };
713
- type RouterClientConfig = {
714
- readonly url: URL;
715
- readonly headers: Headers;
716
- };
717
- type Client = Compute<RouterClientConfig & {
718
- get: (parameters: GetParameters) => Promise<{
719
- cursor: string | null;
720
- offers: OfferResponse[];
721
- }>;
722
- match: (parameters: MatchParameters) => Promise<{
723
- cursor: string | null;
724
- offers: OfferResponse[];
725
- }>;
726
- }>;
727
- declare function connect(opts?: {
728
- url?: string;
729
- apiKey?: string;
730
- headers?: Headers;
731
- }): Client;
732
- declare namespace connect {
733
- type ErrorType = InvalidUrlError;
734
- }
735
- /**
736
- * Get offers from the router.
737
- * @returns The offers with pagination cursor.
738
- */
739
- declare function get(config: RouterClientConfig, parameters: GetParameters): Promise<{
740
- cursor: string | null;
741
- offers: OfferResponse[];
742
- }>;
743
- declare namespace get {
744
- type ErrorType = GetApiErrorType;
745
- }
746
- /**
747
- * Match offers from the router.
748
- * @returns The matched offers with pagination cursor.
749
- */
750
- declare function match(config: RouterClientConfig, parameters: MatchParameters): Promise<{
751
- cursor: string | null;
752
- offers: OfferResponse[];
753
- }>;
754
- declare namespace match {
755
- type ErrorType = GetApiErrorType;
756
- }
757
- type GetApiErrorType = HttpGetOffersFailedError | HttpUnauthorizedError | HttpForbiddenError | HttpRateLimitError;
758
- declare class InvalidUrlError extends Errors.BaseError {
759
- name: string;
760
- constructor(url: string);
761
- }
762
- declare class HttpUnauthorizedError extends Errors.BaseError {
763
- name: string;
764
- constructor();
765
- }
766
- declare class HttpForbiddenError extends Errors.BaseError {
767
- name: string;
768
- constructor();
769
- }
770
- declare class HttpRateLimitError extends Errors.BaseError {
771
- name: string;
772
- constructor();
773
- }
774
- declare class HttpGetOffersFailedError extends Errors.BaseError {
775
- name: string;
776
- constructor(message: string, { details }?: {
777
- details?: string;
778
- });
779
- }
780
-
781
- /**
782
- * Start a local router server.
783
- * @example
784
- * ```ts
785
- * import { Router } from "@morpho-dev/router";
786
- * await Router.serve(); // local router server running on http://localhost:8081
787
- * ```
788
- */
789
- declare function serve(parameters: {
790
- port: number;
791
- store: OfferStore;
792
- }): Promise<void>;
793
- declare function error(error: unknown, c: Context): Response & hono.TypedResponse<{
794
- statusCode: number;
795
- body: string;
796
- }, hono_utils_http_status.ContentfulStatusCode, "json">;
797
- declare function success<T>(c: Context, { data, cursor, }: {
798
- data: T | T[];
799
- cursor?: string | null;
800
- }): Response & hono.TypedResponse<{
801
- status: string;
802
- cursor: string | null | undefined;
803
- data: T | T[];
804
- meta: {
805
- timestamp: string;
806
- };
807
- } extends hono_utils_types.JSONValue ? { [K in keyof {
808
- status: string;
809
- cursor: string | null | undefined;
810
- data: T | T[];
811
- meta: {
812
- timestamp: string;
813
- };
814
- } as ({
815
- status: string;
816
- cursor: string | null | undefined;
817
- data: T | T[];
818
- meta: {
819
- timestamp: string;
820
- };
821
- }[K] extends infer T_1 ? T_1 extends {
822
- status: string;
823
- cursor: string | null | undefined;
824
- data: T | T[];
825
- meta: {
826
- timestamp: string;
827
- };
828
- }[K] ? T_1 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) extends true ? never : K]: boolean extends ({
829
- status: string;
830
- cursor: string | null | undefined;
831
- data: T | T[];
832
- meta: {
833
- timestamp: string;
834
- };
835
- }[K] extends infer T_2 ? T_2 extends {
836
- status: string;
837
- cursor: string | null | undefined;
838
- data: T | T[];
839
- meta: {
840
- timestamp: string;
841
- };
842
- }[K] ? T_2 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) ? hono_utils_types.JSONParsed<{
843
- status: string;
844
- cursor: string | null | undefined;
845
- data: T | T[];
846
- meta: {
847
- timestamp: string;
848
- };
849
- }[K]> | undefined : hono_utils_types.JSONParsed<{
850
- status: string;
851
- cursor: string | null | undefined;
852
- data: T | T[];
853
- meta: {
854
- timestamp: string;
855
- };
856
- }[K]>; } : never, hono_utils_http_status.ContentfulStatusCode, "json">;
857
- declare class APIError extends Error {
858
- statusCode: number;
859
- code: string;
860
- details?: unknown | undefined;
861
- constructor(statusCode: number, message: string, code: string, details?: unknown | undefined);
862
- }
863
- declare class ValidationError extends APIError {
864
- constructor(message: string, details?: unknown);
865
- }
866
- declare class NotFoundError extends APIError {
867
- constructor(message: string);
868
- }
869
- declare class InternalServerError extends APIError {
870
- constructor(message?: string);
871
- }
872
- declare class BadRequestError extends APIError {
873
- constructor(message?: string, details?: unknown);
874
- }
875
- declare function handleZodError(error: z.ZodError): ValidationError;
876
-
877
- type index_APIError = APIError;
878
- declare const index_APIError: typeof APIError;
879
- type index_BadRequestError = BadRequestError;
880
- declare const index_BadRequestError: typeof BadRequestError;
881
- type index_Client = Client;
882
- type index_GetParameters = GetParameters;
883
- type index_HttpForbiddenError = HttpForbiddenError;
884
- declare const index_HttpForbiddenError: typeof HttpForbiddenError;
885
- type index_HttpGetOffersFailedError = HttpGetOffersFailedError;
886
- declare const index_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
887
- type index_HttpRateLimitError = HttpRateLimitError;
888
- declare const index_HttpRateLimitError: typeof HttpRateLimitError;
889
- type index_HttpUnauthorizedError = HttpUnauthorizedError;
890
- declare const index_HttpUnauthorizedError: typeof HttpUnauthorizedError;
891
- type index_InternalServerError = InternalServerError;
892
- declare const index_InternalServerError: typeof InternalServerError;
893
- type index_InvalidUrlError = InvalidUrlError;
894
- declare const index_InvalidUrlError: typeof InvalidUrlError;
895
- type index_MatchParameters = MatchParameters;
896
- type index_NotFoundError = NotFoundError;
897
- declare const index_NotFoundError: typeof NotFoundError;
898
- type index_RouterClientConfig = RouterClientConfig;
899
- type index_ValidationError = ValidationError;
900
- declare const index_ValidationError: typeof ValidationError;
901
- declare const index_connect: typeof connect;
902
- declare const index_error: typeof error;
903
- declare const index_get: typeof get;
904
- declare const index_handleZodError: typeof handleZodError;
905
- declare const index_match: typeof match;
906
- declare const index_serve: typeof serve;
907
- declare const index_success: typeof success;
908
- declare namespace index {
909
- export { index_APIError as APIError, index_BadRequestError as BadRequestError, 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_InternalServerError as InternalServerError, index_InvalidUrlError as InvalidUrlError, type index_MatchParameters as MatchParameters, index_NotFoundError as NotFoundError, type index_RouterClientConfig as RouterClientConfig, index_ValidationError as ValidationError, index_connect as connect, index_error as error, index_get as get, index_handleZodError as handleZodError, index_match as match, index_serve as serve, index_success as success };
910
- }
911
-
912
- declare const LogLevelValues: readonly ["silent", "trace", "debug", "info", "warn", "error", "fatal"];
913
- type LogLevel = (typeof LogLevelValues)[number];
914
- type LogFn = {
915
- <T extends object>(obj: T, msg?: string, ...args: unknown[]): void;
916
- (obj: unknown, msg?: string, ...args: unknown[]): void;
917
- (msg: string, ...args: unknown[]): void;
918
- };
919
- type Logger = {
920
- trace: LogFn;
921
- debug: LogFn;
922
- info: LogFn;
923
- warn: LogFn;
924
- error: LogFn;
925
- fatal: LogFn;
926
- };
927
- declare function defaultLogger(minLevel?: LogLevel): Logger;
928
- declare function silentLogger(): Logger;
929
- declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
930
- declare function getLogger(): Logger;
931
-
932
- type Logger$1_LogFn = LogFn;
933
- type Logger$1_LogLevel = LogLevel;
934
- declare const Logger$1_LogLevelValues: typeof LogLevelValues;
935
- type Logger$1_Logger = Logger;
936
- declare const Logger$1_defaultLogger: typeof defaultLogger;
937
- declare const Logger$1_getLogger: typeof getLogger;
938
- declare const Logger$1_runWithLogger: typeof runWithLogger;
939
- declare const Logger$1_silentLogger: typeof silentLogger;
940
- declare namespace Logger$1 {
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 };
650
+ type Logger$1_LogEntry = LogEntry;
651
+ type Logger$1_LogFn = LogFn;
652
+ type Logger$1_LogLevel = LogLevel;
653
+ declare const Logger$1_LogLevelValues: typeof LogLevelValues;
654
+ type Logger$1_Logger = Logger;
655
+ declare const Logger$1_defaultLogger: typeof defaultLogger;
656
+ declare const Logger$1_getLogger: typeof getLogger;
657
+ declare const Logger$1_runWithLogger: typeof runWithLogger;
658
+ declare const Logger$1_silentLogger: typeof silentLogger;
659
+ declare namespace Logger$1 {
660
+ export { type Logger$1_LogEntry as LogEntry, type Logger$1_LogFn as LogFn, type Logger$1_LogLevel as LogLevel, Logger$1_LogLevelValues as LogLevelValues, type Logger$1_Logger as Logger, Logger$1_defaultLogger as defaultLogger, Logger$1_getLogger as getLogger, Logger$1_runWithLogger as runWithLogger, Logger$1_silentLogger as silentLogger };
942
661
  }
943
662
 
944
663
  declare const VERSION = "offers_v1.1";
@@ -1599,7 +1318,146 @@ declare const collectorBlockNumbers: drizzle_orm_pg_core.PgTableWithColumns<{
1599
1318
  name: "block_number";
1600
1319
  tableName: "collector_block_numbers";
1601
1320
  dataType: "number";
1602
- columnType: "PgBigInt53";
1321
+ columnType: "PgBigInt53";
1322
+ data: number;
1323
+ driverParam: string | number;
1324
+ notNull: true;
1325
+ hasDefault: false;
1326
+ isPrimaryKey: false;
1327
+ isAutoincrement: false;
1328
+ hasRuntimeDefault: false;
1329
+ enumValues: undefined;
1330
+ baseColumn: never;
1331
+ identity: undefined;
1332
+ generated: undefined;
1333
+ }, {}, {}>;
1334
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
1335
+ name: "updated_at";
1336
+ tableName: "collector_block_numbers";
1337
+ dataType: "date";
1338
+ columnType: "PgTimestamp";
1339
+ data: Date;
1340
+ driverParam: string;
1341
+ notNull: true;
1342
+ hasDefault: true;
1343
+ isPrimaryKey: false;
1344
+ isAutoincrement: false;
1345
+ hasRuntimeDefault: false;
1346
+ enumValues: undefined;
1347
+ baseColumn: never;
1348
+ identity: undefined;
1349
+ generated: undefined;
1350
+ }, {}, {}>;
1351
+ };
1352
+ dialect: "pg";
1353
+ }>;
1354
+ declare const availableLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
1355
+ name: "available_liquidity_pools";
1356
+ schema: "offers_v1.1";
1357
+ columns: {
1358
+ id: drizzle_orm_pg_core.PgColumn<{
1359
+ name: "id";
1360
+ tableName: "available_liquidity_pools";
1361
+ dataType: "string";
1362
+ columnType: "PgVarchar";
1363
+ data: string;
1364
+ driverParam: string;
1365
+ notNull: true;
1366
+ hasDefault: false;
1367
+ isPrimaryKey: true;
1368
+ isAutoincrement: false;
1369
+ hasRuntimeDefault: false;
1370
+ enumValues: [string, ...string[]];
1371
+ baseColumn: never;
1372
+ identity: undefined;
1373
+ generated: undefined;
1374
+ }, {}, {
1375
+ length: 255;
1376
+ }>;
1377
+ amount: drizzle_orm_pg_core.PgColumn<{
1378
+ name: "amount";
1379
+ tableName: "available_liquidity_pools";
1380
+ dataType: "string";
1381
+ columnType: "PgNumeric";
1382
+ data: string;
1383
+ driverParam: string;
1384
+ notNull: true;
1385
+ hasDefault: false;
1386
+ isPrimaryKey: false;
1387
+ isAutoincrement: false;
1388
+ hasRuntimeDefault: false;
1389
+ enumValues: undefined;
1390
+ baseColumn: never;
1391
+ identity: undefined;
1392
+ generated: undefined;
1393
+ }, {}, {}>;
1394
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
1395
+ name: "updated_at";
1396
+ tableName: "available_liquidity_pools";
1397
+ dataType: "date";
1398
+ columnType: "PgTimestamp";
1399
+ data: Date;
1400
+ driverParam: string;
1401
+ notNull: true;
1402
+ hasDefault: true;
1403
+ isPrimaryKey: false;
1404
+ isAutoincrement: false;
1405
+ hasRuntimeDefault: false;
1406
+ enumValues: undefined;
1407
+ baseColumn: never;
1408
+ identity: undefined;
1409
+ generated: undefined;
1410
+ }, {}, {}>;
1411
+ };
1412
+ dialect: "pg";
1413
+ }>;
1414
+ declare const availableLiquidityQueues: drizzle_orm_pg_core.PgTableWithColumns<{
1415
+ name: "available_liquidity_queues";
1416
+ schema: "offers_v1.1";
1417
+ columns: {
1418
+ queueId: drizzle_orm_pg_core.PgColumn<{
1419
+ name: "queue_id";
1420
+ tableName: "available_liquidity_queues";
1421
+ dataType: "string";
1422
+ columnType: "PgVarchar";
1423
+ data: string;
1424
+ driverParam: string;
1425
+ notNull: true;
1426
+ hasDefault: false;
1427
+ isPrimaryKey: false;
1428
+ isAutoincrement: false;
1429
+ hasRuntimeDefault: false;
1430
+ enumValues: [string, ...string[]];
1431
+ baseColumn: never;
1432
+ identity: undefined;
1433
+ generated: undefined;
1434
+ }, {}, {
1435
+ length: 255;
1436
+ }>;
1437
+ availableLiquidityPoolId: drizzle_orm_pg_core.PgColumn<{
1438
+ name: "available_liquidity_pool_id";
1439
+ tableName: "available_liquidity_queues";
1440
+ dataType: "string";
1441
+ columnType: "PgVarchar";
1442
+ data: string;
1443
+ driverParam: string;
1444
+ notNull: true;
1445
+ hasDefault: false;
1446
+ isPrimaryKey: false;
1447
+ isAutoincrement: false;
1448
+ hasRuntimeDefault: false;
1449
+ enumValues: [string, ...string[]];
1450
+ baseColumn: never;
1451
+ identity: undefined;
1452
+ generated: undefined;
1453
+ }, {}, {
1454
+ length: 255;
1455
+ }>;
1456
+ index: drizzle_orm_pg_core.PgColumn<{
1457
+ name: "index";
1458
+ tableName: "available_liquidity_queues";
1459
+ dataType: "number";
1460
+ columnType: "PgInteger";
1603
1461
  data: number;
1604
1462
  driverParam: string | number;
1605
1463
  notNull: true;
@@ -1614,7 +1472,7 @@ declare const collectorBlockNumbers: drizzle_orm_pg_core.PgTableWithColumns<{
1614
1472
  }, {}, {}>;
1615
1473
  updatedAt: drizzle_orm_pg_core.PgColumn<{
1616
1474
  name: "updated_at";
1617
- tableName: "collector_block_numbers";
1475
+ tableName: "available_liquidity_queues";
1618
1476
  dataType: "date";
1619
1477
  columnType: "PgTimestamp";
1620
1478
  data: Date;
@@ -1632,13 +1490,13 @@ declare const collectorBlockNumbers: drizzle_orm_pg_core.PgTableWithColumns<{
1632
1490
  };
1633
1491
  dialect: "pg";
1634
1492
  }>;
1635
- declare const availableLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
1636
- name: "available_liquidity_pools";
1493
+ declare const userPositions: drizzle_orm_pg_core.PgTableWithColumns<{
1494
+ name: "user_positions";
1637
1495
  schema: "offers_v1.1";
1638
1496
  columns: {
1639
1497
  id: drizzle_orm_pg_core.PgColumn<{
1640
1498
  name: "id";
1641
- tableName: "available_liquidity_pools";
1499
+ tableName: "user_positions";
1642
1500
  dataType: "string";
1643
1501
  columnType: "PgVarchar";
1644
1502
  data: string;
@@ -1655,11 +1513,11 @@ declare const availableLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
1655
1513
  }, {}, {
1656
1514
  length: 255;
1657
1515
  }>;
1658
- amount: drizzle_orm_pg_core.PgColumn<{
1659
- name: "amount";
1660
- tableName: "available_liquidity_pools";
1516
+ availableLiquidityQueueId: drizzle_orm_pg_core.PgColumn<{
1517
+ name: "available_liquidity_queue_id";
1518
+ tableName: "user_positions";
1661
1519
  dataType: "string";
1662
- columnType: "PgNumeric";
1520
+ columnType: "PgVarchar";
1663
1521
  data: string;
1664
1522
  driverParam: string;
1665
1523
  notNull: true;
@@ -1667,38 +1525,16 @@ declare const availableLiquidityPools: drizzle_orm_pg_core.PgTableWithColumns<{
1667
1525
  isPrimaryKey: false;
1668
1526
  isAutoincrement: false;
1669
1527
  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;
1528
+ enumValues: [string, ...string[]];
1688
1529
  baseColumn: never;
1689
1530
  identity: undefined;
1690
1531
  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";
1532
+ }, {}, {
1533
+ length: 255;
1534
+ }>;
1535
+ user: drizzle_orm_pg_core.PgColumn<{
1536
+ name: "user";
1537
+ tableName: "user_positions";
1702
1538
  dataType: "string";
1703
1539
  columnType: "PgVarchar";
1704
1540
  data: string;
@@ -1715,32 +1551,30 @@ declare const availableLiquidityQueues: drizzle_orm_pg_core.PgTableWithColumns<{
1715
1551
  }, {}, {
1716
1552
  length: 255;
1717
1553
  }>;
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;
1554
+ chainId: drizzle_orm_pg_core.PgColumn<{
1555
+ name: "chain_id";
1556
+ tableName: "user_positions";
1557
+ dataType: "bigint";
1558
+ columnType: "PgBigInt64";
1559
+ data: bigint;
1724
1560
  driverParam: string;
1725
1561
  notNull: true;
1726
1562
  hasDefault: false;
1727
1563
  isPrimaryKey: false;
1728
1564
  isAutoincrement: false;
1729
1565
  hasRuntimeDefault: false;
1730
- enumValues: [string, ...string[]];
1566
+ enumValues: undefined;
1731
1567
  baseColumn: never;
1732
1568
  identity: undefined;
1733
1569
  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;
1570
+ }, {}, {}>;
1571
+ amount: drizzle_orm_pg_core.PgColumn<{
1572
+ name: "amount";
1573
+ tableName: "user_positions";
1574
+ dataType: "string";
1575
+ columnType: "PgNumeric";
1576
+ data: string;
1577
+ driverParam: string;
1744
1578
  notNull: true;
1745
1579
  hasDefault: false;
1746
1580
  isPrimaryKey: false;
@@ -1753,7 +1587,7 @@ declare const availableLiquidityQueues: drizzle_orm_pg_core.PgTableWithColumns<{
1753
1587
  }, {}, {}>;
1754
1588
  updatedAt: drizzle_orm_pg_core.PgColumn<{
1755
1589
  name: "updated_at";
1756
- tableName: "available_liquidity_queues";
1590
+ tableName: "user_positions";
1757
1591
  dataType: "date";
1758
1592
  columnType: "PgTimestamp";
1759
1593
  data: Date;
@@ -1769,135 +1603,301 @@ declare const availableLiquidityQueues: drizzle_orm_pg_core.PgTableWithColumns<{
1769
1603
  generated: undefined;
1770
1604
  }, {}, {}>;
1771
1605
  };
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
- }, {}, {}>;
1606
+ dialect: "pg";
1607
+ }>;
1608
+
1609
+ declare const schema_VERSION: typeof VERSION;
1610
+ declare const schema_availableLiquidityPools: typeof availableLiquidityPools;
1611
+ declare const schema_availableLiquidityQueues: typeof availableLiquidityQueues;
1612
+ declare const schema_collectorBlockNumbers: typeof collectorBlockNumbers;
1613
+ declare const schema_consumed: typeof consumed;
1614
+ declare const schema_offerCollaterals: typeof offerCollaterals;
1615
+ declare const schema_offerStatus: typeof offerStatus;
1616
+ declare const schema_offers: typeof offers;
1617
+ declare const schema_userPositions: typeof userPositions;
1618
+ declare namespace schema {
1619
+ 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 };
1620
+ }
1621
+
1622
+ type GetParameters = {
1623
+ /** Filter by multiple creator addresses (comma-separated) */
1624
+ creators?: string[];
1625
+ /** Filter by offer type: buy offers or sell offers */
1626
+ side?: "buy" | "sell";
1627
+ /** Filter by multiple blockchain networks (comma-separated chain IDs) */
1628
+ chains?: number[];
1629
+ /** Filter by multiple loan assets (comma-separated) */
1630
+ loanTokens?: string[];
1631
+ /** Filter by multiple statuses (comma-separated) */
1632
+ status?: OfferStatus[];
1633
+ /** Filter by multiple callback addresses (comma-separated) */
1634
+ callbackAddresses?: string[];
1635
+ /** Minimum amount of assets in the offer */
1636
+ minAmount?: bigint;
1637
+ /** Maximum amount of assets in the offer */
1638
+ maxAmount?: bigint;
1639
+ /** Minimum rate per asset (in wei) */
1640
+ minRate?: bigint;
1641
+ /** Maximum rate per asset (in wei) */
1642
+ maxRate?: bigint;
1643
+ /** Minimum maturity timestamp (Unix timestamp in seconds) */
1644
+ minMaturity?: Maturity.Maturity;
1645
+ /** Maximum maturity timestamp (Unix timestamp in seconds) */
1646
+ maxMaturity?: Maturity.Maturity;
1647
+ /** Minimum expiry timestamp (Unix timestamp in seconds) */
1648
+ minExpiry?: number;
1649
+ /** Maximum expiry timestamp (Unix timestamp in seconds) */
1650
+ maxExpiry?: number;
1651
+ /** Filter by multiple collateral assets (comma-separated) */
1652
+ collateralAssets?: string[];
1653
+ /** Filter by multiple rate oracles (comma-separated) */
1654
+ collateralOracles?: string[];
1655
+ /** Filter by collateral combinations */
1656
+ collateralTuple?: Array<{
1657
+ asset: string;
1658
+ oracle?: string;
1659
+ lltv?: LLTV.LLTV;
1660
+ }>;
1661
+ /** Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
1662
+ minLltv?: LLTV.LLTV;
1663
+ /** Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
1664
+ maxLltv?: LLTV.LLTV;
1665
+ /** Field to sort results by */
1666
+ sortBy?: "rate" | "maturity" | "expiry" | "amount";
1667
+ /** Sort direction: asc (ascending) or desc (descending, default) */
1668
+ sortOrder?: "asc" | "desc";
1669
+ /** Pagination cursor in base64url-encoded format */
1670
+ cursor?: string;
1671
+ /** Maximum number of offers to return. Defaults to 20. Maximum is 100. */
1672
+ limit?: number;
1673
+ };
1674
+ type MatchParameters = {
1675
+ /** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
1676
+ side: "buy" | "sell";
1677
+ /** The blockchain network chain ID */
1678
+ chainId: number;
1679
+ /** Rate per asset (in wei) for matching offers */
1680
+ rate?: bigint;
1681
+ /** Collateral requirements */
1682
+ collaterals?: Array<{
1683
+ asset: string;
1684
+ oracle: string;
1685
+ lltv: LLTV.LLTV;
1686
+ }>;
1687
+ /** Exact maturity timestamp (Unix timestamp in seconds) */
1688
+ maturity?: Maturity.Maturity;
1689
+ /** Minimum maturity timestamp (Unix timestamp in seconds, inclusive) */
1690
+ minMaturity?: Maturity.Maturity;
1691
+ /** Maximum maturity timestamp (Unix timestamp in seconds, inclusive) */
1692
+ maxMaturity?: Maturity.Maturity;
1693
+ /** The loan asset address to match against */
1694
+ loanToken?: string;
1695
+ /** Filter by a specific offer creator address */
1696
+ creator?: string;
1697
+ /** Filter by multiple statuses (comma-separated) */
1698
+ status?: OfferStatus[];
1699
+ /** Pagination cursor in base64url-encoded format */
1700
+ cursor?: string;
1701
+ /** Maximum number of offers to return. Defaults to 20. Maximum is 100. */
1702
+ limit?: number;
1703
+ };
1704
+ type RouterClientConfig = {
1705
+ readonly url: URL;
1706
+ readonly headers: Headers;
1707
+ };
1708
+ type Client = Compute<RouterClientConfig & {
1709
+ get: (parameters: GetParameters) => Promise<{
1710
+ cursor: string | null;
1711
+ offers: OfferResponse[];
1712
+ }>;
1713
+ match: (parameters: MatchParameters) => Promise<{
1714
+ cursor: string | null;
1715
+ offers: OfferResponse[];
1716
+ }>;
1717
+ }>;
1718
+ declare function connect(opts?: {
1719
+ url?: string;
1720
+ apiKey?: string;
1721
+ headers?: Headers;
1722
+ }): Client;
1723
+ declare namespace connect {
1724
+ type ErrorType = InvalidUrlError;
1725
+ }
1726
+ /**
1727
+ * Get offers from the router.
1728
+ * @returns The offers with pagination cursor.
1729
+ */
1730
+ declare function get(config: RouterClientConfig, parameters: GetParameters): Promise<{
1731
+ cursor: string | null;
1732
+ offers: OfferResponse[];
1733
+ }>;
1734
+ declare namespace get {
1735
+ type ErrorType = GetApiErrorType;
1736
+ }
1737
+ /**
1738
+ * Match offers from the router.
1739
+ * @returns The matched offers with pagination cursor.
1740
+ */
1741
+ declare function match(config: RouterClientConfig, parameters: MatchParameters): Promise<{
1742
+ cursor: string | null;
1743
+ offers: OfferResponse[];
1744
+ }>;
1745
+ declare namespace match {
1746
+ type ErrorType = GetApiErrorType;
1747
+ }
1748
+ type GetApiErrorType = HttpGetOffersFailedError | HttpUnauthorizedError | HttpForbiddenError | HttpRateLimitError;
1749
+ declare class InvalidUrlError extends Errors.BaseError {
1750
+ name: string;
1751
+ constructor(url: string);
1752
+ }
1753
+ declare class HttpUnauthorizedError extends Errors.BaseError {
1754
+ name: string;
1755
+ constructor();
1756
+ }
1757
+ declare class HttpForbiddenError extends Errors.BaseError {
1758
+ name: string;
1759
+ constructor();
1760
+ }
1761
+ declare class HttpRateLimitError extends Errors.BaseError {
1762
+ name: string;
1763
+ constructor();
1764
+ }
1765
+ declare class HttpGetOffersFailedError extends Errors.BaseError {
1766
+ name: string;
1767
+ constructor(message: string, { details }?: {
1768
+ details?: string;
1769
+ });
1770
+ }
1771
+
1772
+ /**
1773
+ * Start a local router server.
1774
+ * @example
1775
+ * ```ts
1776
+ * import { Router } from "@morpho-dev/router";
1777
+ * await Router.serve(); // local router server running on http://localhost:8081
1778
+ * ```
1779
+ */
1780
+ declare function serve(parameters: {
1781
+ port: number;
1782
+ store: OfferStore;
1783
+ }): Promise<void>;
1784
+ declare function error(error: unknown, c: Context): Response & hono.TypedResponse<{
1785
+ statusCode: number;
1786
+ body: string;
1787
+ }, hono_utils_http_status.ContentfulStatusCode, "json">;
1788
+ declare function success<T>(c: Context, { data, cursor, }: {
1789
+ data: T | T[];
1790
+ cursor?: string | null;
1791
+ }): Response & hono.TypedResponse<{
1792
+ status: string;
1793
+ cursor: string | null | undefined;
1794
+ data: T | T[];
1795
+ meta: {
1796
+ timestamp: string;
1797
+ };
1798
+ } extends hono_utils_types.JSONValue ? { [K in keyof {
1799
+ status: string;
1800
+ cursor: string | null | undefined;
1801
+ data: T | T[];
1802
+ meta: {
1803
+ timestamp: string;
1886
1804
  };
1887
- dialect: "pg";
1888
- }>;
1805
+ } as ({
1806
+ status: string;
1807
+ cursor: string | null | undefined;
1808
+ data: T | T[];
1809
+ meta: {
1810
+ timestamp: string;
1811
+ };
1812
+ }[K] extends infer T_1 ? T_1 extends {
1813
+ status: string;
1814
+ cursor: string | null | undefined;
1815
+ data: T | T[];
1816
+ meta: {
1817
+ timestamp: string;
1818
+ };
1819
+ }[K] ? T_1 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) extends true ? never : K]: boolean extends ({
1820
+ status: string;
1821
+ cursor: string | null | undefined;
1822
+ data: T | T[];
1823
+ meta: {
1824
+ timestamp: string;
1825
+ };
1826
+ }[K] extends infer T_2 ? T_2 extends {
1827
+ status: string;
1828
+ cursor: string | null | undefined;
1829
+ data: T | T[];
1830
+ meta: {
1831
+ timestamp: string;
1832
+ };
1833
+ }[K] ? T_2 extends hono_utils_types.InvalidJSONValue ? true : false : never : never) ? hono_utils_types.JSONParsed<{
1834
+ status: string;
1835
+ cursor: string | null | undefined;
1836
+ data: T | T[];
1837
+ meta: {
1838
+ timestamp: string;
1839
+ };
1840
+ }[K]> | undefined : hono_utils_types.JSONParsed<{
1841
+ status: string;
1842
+ cursor: string | null | undefined;
1843
+ data: T | T[];
1844
+ meta: {
1845
+ timestamp: string;
1846
+ };
1847
+ }[K]>; } : never, hono_utils_http_status.ContentfulStatusCode, "json">;
1848
+ declare class APIError extends Error {
1849
+ statusCode: number;
1850
+ code: string;
1851
+ details?: unknown | undefined;
1852
+ constructor(statusCode: number, message: string, code: string, details?: unknown | undefined);
1853
+ }
1854
+ declare class ValidationError extends APIError {
1855
+ constructor(message: string, details?: unknown);
1856
+ }
1857
+ declare class NotFoundError extends APIError {
1858
+ constructor(message: string);
1859
+ }
1860
+ declare class InternalServerError extends APIError {
1861
+ constructor(message?: string);
1862
+ }
1863
+ declare class BadRequestError extends APIError {
1864
+ constructor(message?: string, details?: unknown);
1865
+ }
1866
+ declare function handleZodError(error: z.ZodError): ValidationError;
1889
1867
 
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 };
1868
+ type index_APIError = APIError;
1869
+ declare const index_APIError: typeof APIError;
1870
+ type index_BadRequestError = BadRequestError;
1871
+ declare const index_BadRequestError: typeof BadRequestError;
1872
+ type index_Client = Client;
1873
+ type index_GetParameters = GetParameters;
1874
+ type index_HttpForbiddenError = HttpForbiddenError;
1875
+ declare const index_HttpForbiddenError: typeof HttpForbiddenError;
1876
+ type index_HttpGetOffersFailedError = HttpGetOffersFailedError;
1877
+ declare const index_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
1878
+ type index_HttpRateLimitError = HttpRateLimitError;
1879
+ declare const index_HttpRateLimitError: typeof HttpRateLimitError;
1880
+ type index_HttpUnauthorizedError = HttpUnauthorizedError;
1881
+ declare const index_HttpUnauthorizedError: typeof HttpUnauthorizedError;
1882
+ type index_InternalServerError = InternalServerError;
1883
+ declare const index_InternalServerError: typeof InternalServerError;
1884
+ type index_InvalidUrlError = InvalidUrlError;
1885
+ declare const index_InvalidUrlError: typeof InvalidUrlError;
1886
+ type index_MatchParameters = MatchParameters;
1887
+ type index_NotFoundError = NotFoundError;
1888
+ declare const index_NotFoundError: typeof NotFoundError;
1889
+ type index_RouterClientConfig = RouterClientConfig;
1890
+ type index_ValidationError = ValidationError;
1891
+ declare const index_ValidationError: typeof ValidationError;
1892
+ declare const index_connect: typeof connect;
1893
+ declare const index_error: typeof error;
1894
+ declare const index_get: typeof get;
1895
+ declare const index_handleZodError: typeof handleZodError;
1896
+ declare const index_match: typeof match;
1897
+ declare const index_serve: typeof serve;
1898
+ declare const index_success: typeof success;
1899
+ declare namespace index {
1900
+ export { index_APIError as APIError, index_BadRequestError as BadRequestError, 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_InternalServerError as InternalServerError, index_InvalidUrlError as InvalidUrlError, type index_MatchParameters as MatchParameters, index_NotFoundError as NotFoundError, type index_RouterClientConfig as RouterClientConfig, index_ValidationError as ValidationError, index_connect as connect, index_error as error, index_get as get, index_handleZodError as handleZodError, index_match as match, index_serve as serve, index_success as success };
1901
1901
  }
1902
1902
 
1903
1903
  type config = {
@@ -1917,7 +1917,7 @@ type Services = {
1917
1917
  buyWithEmptyCallbackLiquidityCollector: Collector<"buy_with_empty_callback_liquidity">;
1918
1918
  DB: PG;
1919
1919
  };
1920
- declare const from: (config: config) => Promise<Services>;
1920
+ declare function from(config: config): Services;
1921
1921
 
1922
1922
  type Services$1_Services = Services;
1923
1923
  type Services$1_config = config;
@@ -2123,4 +2123,4 @@ declare namespace Validation {
2123
2123
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
2124
2124
  }
2125
2125
 
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 };
2126
+ export { index$3 as ApiSchema, Callback, index$1 as Collector, CollectorBlockStore$1 as CollectorBlockStore, Cursor$1 as Cursor, Liquidity$1 as Liquidity, LiquidityStore$1 as LiquidityStore, Logger$1 as Logger, index$2 as OfferStore, schema as OffersSchema, PG$1 as PG, index as Router, RouterOffer$1 as RouterOffer, Services$1 as Services, Validation, ValidationRule };