@morpho-dev/router 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +15 -0
  2. package/dist/drizzle/0000_add-offers-table.sql +37 -0
  3. package/dist/drizzle/0001_create_offer_status_relation.sql +10 -0
  4. package/dist/drizzle/0002_add_created_at_in_offer_status_relation.sql +3 -0
  5. package/dist/drizzle/0003_add-cursor-indices-to-offers.sql +6 -0
  6. package/dist/drizzle/0004_offer-start.sql +1 -0
  7. package/dist/drizzle/0005_rename-price-token-buy.sql +8 -0
  8. package/dist/drizzle/0006_rename-buy.sql +3 -0
  9. package/dist/drizzle/0007_rename-offering.sql +3 -0
  10. package/dist/drizzle/meta/0000_snapshot.json +344 -0
  11. package/dist/drizzle/meta/0001_snapshot.json +426 -0
  12. package/dist/drizzle/meta/0002_snapshot.json +439 -0
  13. package/dist/drizzle/meta/0003_snapshot.json +553 -0
  14. package/dist/drizzle/meta/0004_snapshot.json +559 -0
  15. package/dist/drizzle/meta/0005_snapshot.json +559 -0
  16. package/dist/drizzle/meta/0006_snapshot.json +559 -0
  17. package/dist/drizzle/meta/0007_snapshot.json +559 -0
  18. package/dist/drizzle/meta/_journal.json +62 -0
  19. package/dist/{index.d.cts → index.browser.d.cts} +34 -90
  20. package/dist/{index.d.ts → index.browser.d.ts} +34 -90
  21. package/dist/index.browser.js +1172 -0
  22. package/dist/index.browser.js.map +1 -0
  23. package/dist/index.browser.mjs +1154 -0
  24. package/dist/index.browser.mjs.map +1 -0
  25. package/dist/index.node.d.cts +1342 -0
  26. package/dist/index.node.d.ts +1342 -0
  27. package/dist/{index.js → index.node.js} +2119 -4773
  28. package/dist/index.node.js.map +1 -0
  29. package/dist/{index.mjs → index.node.mjs} +2111 -4774
  30. package/dist/index.node.mjs.map +1 -0
  31. package/package.json +33 -11
  32. package/dist/index.js.map +0 -1
  33. package/dist/index.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { Offer, Errors } from '@morpho-dev/mempool';
2
2
  export * from '@morpho-dev/mempool';
3
3
  import * as viem from 'viem';
4
- import { Address, Account, Hex, PublicClient } from 'viem';
4
+ import { Address, PublicClient } from 'viem';
5
5
  import { Chain as Chain$2 } from 'viem/chains';
6
6
 
7
7
  type Compute<type> = {
@@ -203,94 +203,25 @@ declare class HttpGetOffersFailedError extends Errors.BaseError {
203
203
  });
204
204
  }
205
205
 
206
- type index_Client = Client;
207
- type index_GetParameters = GetParameters;
208
- type index_HttpForbiddenError = HttpForbiddenError;
209
- declare const index_HttpForbiddenError: typeof HttpForbiddenError;
210
- type index_HttpGetOffersFailedError = HttpGetOffersFailedError;
211
- declare const index_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
212
- type index_HttpRateLimitError = HttpRateLimitError;
213
- declare const index_HttpRateLimitError: typeof HttpRateLimitError;
214
- type index_HttpUnauthorizedError = HttpUnauthorizedError;
215
- declare const index_HttpUnauthorizedError: typeof HttpUnauthorizedError;
216
- type index_InvalidUrlError = InvalidUrlError;
217
- declare const index_InvalidUrlError: typeof InvalidUrlError;
218
- type index_MatchParameters = MatchParameters;
219
- type index_RouterClientConfig = RouterClientConfig;
220
- declare const index_connect: typeof connect;
221
- declare const index_get: typeof get;
222
- declare const index_match: typeof match;
223
- declare namespace index {
224
- export { type index_Client as Client, type index_GetParameters as GetParameters, index_HttpForbiddenError as HttpForbiddenError, index_HttpGetOffersFailedError as HttpGetOffersFailedError, index_HttpRateLimitError as HttpRateLimitError, index_HttpUnauthorizedError as HttpUnauthorizedError, index_InvalidUrlError as InvalidUrlError, type index_MatchParameters as MatchParameters, type index_RouterClientConfig as RouterClientConfig, index_connect as connect, index_get as get, index_match as match };
225
- }
226
-
227
- declare const users: Account[];
228
- declare const assetList: readonly ["USDC", "DAI"];
229
- declare const mockAddress: (asset: (typeof assetList)[number]) => `0x${string}`;
230
- declare const assetMethods: readonly ["balanceOf", "allowance"];
231
- type AssetMethod = (typeof assetMethods)[number];
232
- type MethodParameters = {
233
- balanceOf: {
234
- address: Address;
235
- value: bigint;
236
- };
237
- allowance: {
238
- owner: Address;
239
- spender: Address;
240
- value: bigint;
241
- };
242
- };
243
- type MockedAsset = {
244
- address: Address;
245
- set: (slot: Hex | AssetMethod, parameters: Hex | bigint | MethodParameters[AssetMethod]) => Promise<void>;
246
- };
247
- type Mocked = {
248
- name: string;
249
- publicClient: PublicClient;
250
- } & Record<(typeof assetList)[number], MockedAsset>;
251
- declare function mock(name: string): Promise<Mocked>;
252
-
253
- type EVM_AssetMethod = AssetMethod;
254
- type EVM_MethodParameters = MethodParameters;
255
- type EVM_Mocked = Mocked;
256
- type EVM_MockedAsset = MockedAsset;
257
- declare const EVM_assetList: typeof assetList;
258
- declare const EVM_assetMethods: typeof assetMethods;
259
- declare const EVM_mock: typeof mock;
260
- declare const EVM_mockAddress: typeof mockAddress;
261
- declare const EVM_users: typeof users;
262
- declare namespace EVM {
263
- export { type EVM_AssetMethod as AssetMethod, type EVM_MethodParameters as MethodParameters, type EVM_Mocked as Mocked, type EVM_MockedAsset as MockedAsset, EVM_assetList as assetList, EVM_assetMethods as assetMethods, EVM_mock as mock, EVM_mockAddress as mockAddress, EVM_users as users };
264
- }
265
-
266
- declare const LogLevelValues: readonly ["silent", "trace", "debug", "info", "warn", "error", "fatal"];
267
- type LogLevel = (typeof LogLevelValues)[number];
268
- type LogFn = {
269
- <T extends object>(obj: T, msg?: string, ...args: unknown[]): void;
270
- (obj: unknown, msg?: string, ...args: unknown[]): void;
271
- (msg: string, ...args: unknown[]): void;
272
- };
273
- type Logger = {
274
- trace: LogFn;
275
- debug: LogFn;
276
- info: LogFn;
277
- warn: LogFn;
278
- error: LogFn;
279
- fatal: LogFn;
280
- };
281
- declare function defaultLogger(): Logger;
282
- declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
283
- declare function getLogger(): Logger;
284
-
285
- type Logger$1_LogFn = LogFn;
286
- type Logger$1_LogLevel = LogLevel;
287
- declare const Logger$1_LogLevelValues: typeof LogLevelValues;
288
- type Logger$1_Logger = Logger;
289
- declare const Logger$1_defaultLogger: typeof defaultLogger;
290
- declare const Logger$1_getLogger: typeof getLogger;
291
- declare const Logger$1_runWithLogger: typeof runWithLogger;
292
- declare namespace Logger$1 {
293
- 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 };
206
+ type Client$1_Client = Client;
207
+ type Client$1_GetParameters = GetParameters;
208
+ type Client$1_HttpForbiddenError = HttpForbiddenError;
209
+ declare const Client$1_HttpForbiddenError: typeof HttpForbiddenError;
210
+ type Client$1_HttpGetOffersFailedError = HttpGetOffersFailedError;
211
+ declare const Client$1_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
212
+ type Client$1_HttpRateLimitError = HttpRateLimitError;
213
+ declare const Client$1_HttpRateLimitError: typeof HttpRateLimitError;
214
+ type Client$1_HttpUnauthorizedError = HttpUnauthorizedError;
215
+ declare const Client$1_HttpUnauthorizedError: typeof HttpUnauthorizedError;
216
+ type Client$1_InvalidUrlError = InvalidUrlError;
217
+ declare const Client$1_InvalidUrlError: typeof InvalidUrlError;
218
+ type Client$1_MatchParameters = MatchParameters;
219
+ type Client$1_RouterClientConfig = RouterClientConfig;
220
+ declare const Client$1_connect: typeof connect;
221
+ declare const Client$1_get: typeof get;
222
+ declare const Client$1_match: typeof match;
223
+ declare namespace Client$1 {
224
+ export { type Client$1_Client as Client, type Client$1_GetParameters as GetParameters, Client$1_HttpForbiddenError as HttpForbiddenError, Client$1_HttpGetOffersFailedError as HttpGetOffersFailedError, Client$1_HttpRateLimitError as HttpRateLimitError, Client$1_HttpUnauthorizedError as HttpUnauthorizedError, Client$1_InvalidUrlError as InvalidUrlError, type Client$1_MatchParameters as MatchParameters, type Client$1_RouterClientConfig as RouterClientConfig, Client$1_connect as connect, Client$1_get as get, Client$1_match as match };
294
225
  }
295
226
 
296
227
  declare const types: readonly ["offer_created", "offer_matched", "offer_validation"];
@@ -347,6 +278,19 @@ declare namespace RouterEvent$1 {
347
278
  */
348
279
  declare function batch$1<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;
349
280
 
281
+ type Cursor = {
282
+ sort: "rate" | "maturity" | "expiry" | "amount";
283
+ dir: "asc" | "desc";
284
+ rate?: string;
285
+ maturity?: number;
286
+ expiry?: number;
287
+ assets?: string;
288
+ hash: string;
289
+ };
290
+ declare function validateCursor(cursor: unknown): cursor is Cursor;
291
+ declare function encodeCursor(c: Cursor): string;
292
+ declare function decodeCursor(token?: string): Cursor | null;
293
+
350
294
  /**
351
295
  * Polls a function at a specified interval.
352
296
  * Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
@@ -606,4 +550,4 @@ declare namespace Validation {
606
550
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
607
551
  }
608
552
 
609
- export { Chain$1 as Chain, type Compute, EVM, Logger$1 as Logger, index as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, poll, wait };
553
+ export { Chain$1 as Chain, type Compute, type Cursor, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, decodeCursor, encodeCursor, poll, validateCursor, wait };
@@ -1,7 +1,7 @@
1
1
  import { Offer, Errors } from '@morpho-dev/mempool';
2
2
  export * from '@morpho-dev/mempool';
3
3
  import * as viem from 'viem';
4
- import { Address, Account, Hex, PublicClient } from 'viem';
4
+ import { Address, PublicClient } from 'viem';
5
5
  import { Chain as Chain$2 } from 'viem/chains';
6
6
 
7
7
  type Compute<type> = {
@@ -203,94 +203,25 @@ declare class HttpGetOffersFailedError extends Errors.BaseError {
203
203
  });
204
204
  }
205
205
 
206
- type index_Client = Client;
207
- type index_GetParameters = GetParameters;
208
- type index_HttpForbiddenError = HttpForbiddenError;
209
- declare const index_HttpForbiddenError: typeof HttpForbiddenError;
210
- type index_HttpGetOffersFailedError = HttpGetOffersFailedError;
211
- declare const index_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
212
- type index_HttpRateLimitError = HttpRateLimitError;
213
- declare const index_HttpRateLimitError: typeof HttpRateLimitError;
214
- type index_HttpUnauthorizedError = HttpUnauthorizedError;
215
- declare const index_HttpUnauthorizedError: typeof HttpUnauthorizedError;
216
- type index_InvalidUrlError = InvalidUrlError;
217
- declare const index_InvalidUrlError: typeof InvalidUrlError;
218
- type index_MatchParameters = MatchParameters;
219
- type index_RouterClientConfig = RouterClientConfig;
220
- declare const index_connect: typeof connect;
221
- declare const index_get: typeof get;
222
- declare const index_match: typeof match;
223
- declare namespace index {
224
- export { type index_Client as Client, type index_GetParameters as GetParameters, index_HttpForbiddenError as HttpForbiddenError, index_HttpGetOffersFailedError as HttpGetOffersFailedError, index_HttpRateLimitError as HttpRateLimitError, index_HttpUnauthorizedError as HttpUnauthorizedError, index_InvalidUrlError as InvalidUrlError, type index_MatchParameters as MatchParameters, type index_RouterClientConfig as RouterClientConfig, index_connect as connect, index_get as get, index_match as match };
225
- }
226
-
227
- declare const users: Account[];
228
- declare const assetList: readonly ["USDC", "DAI"];
229
- declare const mockAddress: (asset: (typeof assetList)[number]) => `0x${string}`;
230
- declare const assetMethods: readonly ["balanceOf", "allowance"];
231
- type AssetMethod = (typeof assetMethods)[number];
232
- type MethodParameters = {
233
- balanceOf: {
234
- address: Address;
235
- value: bigint;
236
- };
237
- allowance: {
238
- owner: Address;
239
- spender: Address;
240
- value: bigint;
241
- };
242
- };
243
- type MockedAsset = {
244
- address: Address;
245
- set: (slot: Hex | AssetMethod, parameters: Hex | bigint | MethodParameters[AssetMethod]) => Promise<void>;
246
- };
247
- type Mocked = {
248
- name: string;
249
- publicClient: PublicClient;
250
- } & Record<(typeof assetList)[number], MockedAsset>;
251
- declare function mock(name: string): Promise<Mocked>;
252
-
253
- type EVM_AssetMethod = AssetMethod;
254
- type EVM_MethodParameters = MethodParameters;
255
- type EVM_Mocked = Mocked;
256
- type EVM_MockedAsset = MockedAsset;
257
- declare const EVM_assetList: typeof assetList;
258
- declare const EVM_assetMethods: typeof assetMethods;
259
- declare const EVM_mock: typeof mock;
260
- declare const EVM_mockAddress: typeof mockAddress;
261
- declare const EVM_users: typeof users;
262
- declare namespace EVM {
263
- export { type EVM_AssetMethod as AssetMethod, type EVM_MethodParameters as MethodParameters, type EVM_Mocked as Mocked, type EVM_MockedAsset as MockedAsset, EVM_assetList as assetList, EVM_assetMethods as assetMethods, EVM_mock as mock, EVM_mockAddress as mockAddress, EVM_users as users };
264
- }
265
-
266
- declare const LogLevelValues: readonly ["silent", "trace", "debug", "info", "warn", "error", "fatal"];
267
- type LogLevel = (typeof LogLevelValues)[number];
268
- type LogFn = {
269
- <T extends object>(obj: T, msg?: string, ...args: unknown[]): void;
270
- (obj: unknown, msg?: string, ...args: unknown[]): void;
271
- (msg: string, ...args: unknown[]): void;
272
- };
273
- type Logger = {
274
- trace: LogFn;
275
- debug: LogFn;
276
- info: LogFn;
277
- warn: LogFn;
278
- error: LogFn;
279
- fatal: LogFn;
280
- };
281
- declare function defaultLogger(): Logger;
282
- declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
283
- declare function getLogger(): Logger;
284
-
285
- type Logger$1_LogFn = LogFn;
286
- type Logger$1_LogLevel = LogLevel;
287
- declare const Logger$1_LogLevelValues: typeof LogLevelValues;
288
- type Logger$1_Logger = Logger;
289
- declare const Logger$1_defaultLogger: typeof defaultLogger;
290
- declare const Logger$1_getLogger: typeof getLogger;
291
- declare const Logger$1_runWithLogger: typeof runWithLogger;
292
- declare namespace Logger$1 {
293
- 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 };
206
+ type Client$1_Client = Client;
207
+ type Client$1_GetParameters = GetParameters;
208
+ type Client$1_HttpForbiddenError = HttpForbiddenError;
209
+ declare const Client$1_HttpForbiddenError: typeof HttpForbiddenError;
210
+ type Client$1_HttpGetOffersFailedError = HttpGetOffersFailedError;
211
+ declare const Client$1_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
212
+ type Client$1_HttpRateLimitError = HttpRateLimitError;
213
+ declare const Client$1_HttpRateLimitError: typeof HttpRateLimitError;
214
+ type Client$1_HttpUnauthorizedError = HttpUnauthorizedError;
215
+ declare const Client$1_HttpUnauthorizedError: typeof HttpUnauthorizedError;
216
+ type Client$1_InvalidUrlError = InvalidUrlError;
217
+ declare const Client$1_InvalidUrlError: typeof InvalidUrlError;
218
+ type Client$1_MatchParameters = MatchParameters;
219
+ type Client$1_RouterClientConfig = RouterClientConfig;
220
+ declare const Client$1_connect: typeof connect;
221
+ declare const Client$1_get: typeof get;
222
+ declare const Client$1_match: typeof match;
223
+ declare namespace Client$1 {
224
+ export { type Client$1_Client as Client, type Client$1_GetParameters as GetParameters, Client$1_HttpForbiddenError as HttpForbiddenError, Client$1_HttpGetOffersFailedError as HttpGetOffersFailedError, Client$1_HttpRateLimitError as HttpRateLimitError, Client$1_HttpUnauthorizedError as HttpUnauthorizedError, Client$1_InvalidUrlError as InvalidUrlError, type Client$1_MatchParameters as MatchParameters, type Client$1_RouterClientConfig as RouterClientConfig, Client$1_connect as connect, Client$1_get as get, Client$1_match as match };
294
225
  }
295
226
 
296
227
  declare const types: readonly ["offer_created", "offer_matched", "offer_validation"];
@@ -347,6 +278,19 @@ declare namespace RouterEvent$1 {
347
278
  */
348
279
  declare function batch$1<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;
349
280
 
281
+ type Cursor = {
282
+ sort: "rate" | "maturity" | "expiry" | "amount";
283
+ dir: "asc" | "desc";
284
+ rate?: string;
285
+ maturity?: number;
286
+ expiry?: number;
287
+ assets?: string;
288
+ hash: string;
289
+ };
290
+ declare function validateCursor(cursor: unknown): cursor is Cursor;
291
+ declare function encodeCursor(c: Cursor): string;
292
+ declare function decodeCursor(token?: string): Cursor | null;
293
+
350
294
  /**
351
295
  * Polls a function at a specified interval.
352
296
  * Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
@@ -606,4 +550,4 @@ declare namespace Validation {
606
550
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
607
551
  }
608
552
 
609
- export { Chain$1 as Chain, type Compute, EVM, Logger$1 as Logger, index as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, poll, wait };
553
+ export { Chain$1 as Chain, type Compute, type Cursor, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, decodeCursor, encodeCursor, poll, validateCursor, wait };