@morpho-dev/router 0.1.3 → 0.1.4
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.
- package/dist/index.browser.d.cts +125 -67
- package/dist/index.browser.d.ts +125 -67
- package/dist/index.browser.js +338 -157
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +338 -159
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +168 -111
- package/dist/index.node.d.ts +168 -111
- package/dist/index.node.js +338 -158
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +338 -160
- package/dist/index.node.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.node.d.ts
CHANGED
|
@@ -1,15 +1,132 @@
|
|
|
1
1
|
import * as _morpho_dev_mempool from '@morpho-dev/mempool';
|
|
2
2
|
import { Offer, Errors, Format, Maturity, LLTV, Compute, Chain } from '@morpho-dev/mempool';
|
|
3
3
|
export * from '@morpho-dev/mempool';
|
|
4
|
+
import * as viem from 'viem';
|
|
5
|
+
import { PublicActions, Address, Hex } from 'viem';
|
|
4
6
|
import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
|
|
5
7
|
import { z, ZodError } from 'zod/v4';
|
|
6
|
-
import * as viem from 'viem';
|
|
7
|
-
import { Address, Hex } from 'viem';
|
|
8
8
|
import * as hono_utils_types from 'hono/utils/types';
|
|
9
9
|
import * as hono from 'hono';
|
|
10
10
|
import { Context } from 'hono';
|
|
11
11
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
12
12
|
|
|
13
|
+
declare function fetchBalancesAndAllowances(parameters: {
|
|
14
|
+
client: Pick<PublicActions, "multicall">;
|
|
15
|
+
spender: Address;
|
|
16
|
+
pairs: Array<{
|
|
17
|
+
user: Address;
|
|
18
|
+
token: Address;
|
|
19
|
+
}>;
|
|
20
|
+
options?: {
|
|
21
|
+
batchSize?: number;
|
|
22
|
+
retryAttempts?: number;
|
|
23
|
+
retryDelayMs?: number;
|
|
24
|
+
blockNumber?: number;
|
|
25
|
+
};
|
|
26
|
+
}): Promise<Map<Address, Map<Address, {
|
|
27
|
+
balance: bigint;
|
|
28
|
+
allowance: bigint;
|
|
29
|
+
}>>>;
|
|
30
|
+
type LiquidityUserPosition = {
|
|
31
|
+
id: string;
|
|
32
|
+
availableLiquidityQueueId: string;
|
|
33
|
+
user: string;
|
|
34
|
+
chainId: bigint;
|
|
35
|
+
amount: string;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
};
|
|
38
|
+
type LiquidityQueue = {
|
|
39
|
+
queueId: string;
|
|
40
|
+
availableLiquidityPoolId: string;
|
|
41
|
+
index: number;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
};
|
|
44
|
+
type LiquidityPool = {
|
|
45
|
+
id: string;
|
|
46
|
+
amount: string;
|
|
47
|
+
updatedAt: Date;
|
|
48
|
+
};
|
|
49
|
+
type LiquidityQueueWithPool = {
|
|
50
|
+
queue: LiquidityQueue;
|
|
51
|
+
pool: LiquidityPool;
|
|
52
|
+
};
|
|
53
|
+
type Liquidity = {
|
|
54
|
+
userPosition: LiquidityUserPosition;
|
|
55
|
+
queues: LiquidityQueueWithPool[];
|
|
56
|
+
};
|
|
57
|
+
declare function fetch(parameters: {
|
|
58
|
+
client: Pick<PublicActions, "multicall">;
|
|
59
|
+
chainId: bigint;
|
|
60
|
+
spender: Address;
|
|
61
|
+
type: CallbackType;
|
|
62
|
+
pairs: Array<{
|
|
63
|
+
user: Address;
|
|
64
|
+
contract: Address;
|
|
65
|
+
}>;
|
|
66
|
+
options?: {
|
|
67
|
+
batchSize?: number;
|
|
68
|
+
retryAttempts?: number;
|
|
69
|
+
retryDelayMs?: number;
|
|
70
|
+
blockNumber?: number;
|
|
71
|
+
};
|
|
72
|
+
}): Promise<Liquidity[]>;
|
|
73
|
+
declare function serialize(liquidity: Liquidity): string;
|
|
74
|
+
|
|
75
|
+
type Liquidity$1_Liquidity = Liquidity;
|
|
76
|
+
type Liquidity$1_LiquidityPool = LiquidityPool;
|
|
77
|
+
type Liquidity$1_LiquidityQueue = LiquidityQueue;
|
|
78
|
+
type Liquidity$1_LiquidityQueueWithPool = LiquidityQueueWithPool;
|
|
79
|
+
type Liquidity$1_LiquidityUserPosition = LiquidityUserPosition;
|
|
80
|
+
declare const Liquidity$1_fetch: typeof fetch;
|
|
81
|
+
declare const Liquidity$1_fetchBalancesAndAllowances: typeof fetchBalancesAndAllowances;
|
|
82
|
+
declare const Liquidity$1_serialize: typeof serialize;
|
|
83
|
+
declare namespace Liquidity$1 {
|
|
84
|
+
export { type Liquidity$1_Liquidity as Liquidity, type Liquidity$1_LiquidityPool as LiquidityPool, type Liquidity$1_LiquidityQueue as LiquidityQueue, type Liquidity$1_LiquidityQueueWithPool as LiquidityQueueWithPool, type Liquidity$1_LiquidityUserPosition as LiquidityUserPosition, Liquidity$1_fetch as fetch, Liquidity$1_fetchBalancesAndAllowances as fetchBalancesAndAllowances, Liquidity$1_serialize as serialize };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare enum CallbackType {
|
|
88
|
+
BuyWithEmptyCallback = "buy_with_empty_callback"
|
|
89
|
+
}
|
|
90
|
+
declare function buildLiquidity(parameters: {
|
|
91
|
+
type: CallbackType;
|
|
92
|
+
user: string;
|
|
93
|
+
contract: string;
|
|
94
|
+
chainId: bigint;
|
|
95
|
+
amount: string | bigint;
|
|
96
|
+
index?: number;
|
|
97
|
+
updatedAt?: Date;
|
|
98
|
+
}): Liquidity;
|
|
99
|
+
declare function getCallbackIdForOffer(offer: Offer.Offer): string | null;
|
|
100
|
+
|
|
101
|
+
type Callback_CallbackType = CallbackType;
|
|
102
|
+
declare const Callback_CallbackType: typeof CallbackType;
|
|
103
|
+
declare const Callback_buildLiquidity: typeof buildLiquidity;
|
|
104
|
+
declare const Callback_getCallbackIdForOffer: typeof getCallbackIdForOffer;
|
|
105
|
+
declare namespace Callback {
|
|
106
|
+
export { Callback_CallbackType as CallbackType, Callback_buildLiquidity as buildLiquidity, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
|
|
107
|
+
}
|
|
108
|
+
|
|
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;
|
|
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;
|
|
121
|
+
|
|
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 };
|
|
128
|
+
}
|
|
129
|
+
|
|
13
130
|
declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
|
|
14
131
|
|
|
15
132
|
declare const schemas: {
|
|
@@ -70,7 +187,6 @@ declare const schemas: {
|
|
|
70
187
|
max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
71
188
|
loan_token: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
72
189
|
creator: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
73
|
-
status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
|
|
74
190
|
cursor: z.ZodOptional<z.ZodString>;
|
|
75
191
|
limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
|
|
76
192
|
}, z.core.$strip>;
|
|
@@ -234,14 +350,14 @@ declare function toResponse(routerOffer: RouterOffer): OfferResponse;
|
|
|
234
350
|
*/
|
|
235
351
|
declare function fromResponse(offerResponse: OfferResponse): RouterOffer;
|
|
236
352
|
|
|
237
|
-
type index$
|
|
238
|
-
declare const index$
|
|
239
|
-
declare const index$
|
|
240
|
-
declare const index$
|
|
241
|
-
declare const index$
|
|
242
|
-
declare const index$
|
|
243
|
-
declare namespace index$
|
|
244
|
-
export { type index$
|
|
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 };
|
|
245
361
|
}
|
|
246
362
|
|
|
247
363
|
type GetParameters = {
|
|
@@ -481,8 +597,6 @@ type FindMatchingOffersParams = {
|
|
|
481
597
|
maxMaturity?: number;
|
|
482
598
|
loanToken?: string;
|
|
483
599
|
creator?: string;
|
|
484
|
-
/** Filter by offer status; if omitted defaults to ["valid"] */
|
|
485
|
-
status?: OfferStatus[];
|
|
486
600
|
/** Cursor string returned by a previous call, for pagination */
|
|
487
601
|
cursor?: string;
|
|
488
602
|
/** Page size; defaults to 20 */
|
|
@@ -500,13 +614,13 @@ declare function memory(parameters: {
|
|
|
500
614
|
filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
|
|
501
615
|
}): OfferStore;
|
|
502
616
|
|
|
503
|
-
type index$
|
|
504
|
-
type index$
|
|
505
|
-
type index$
|
|
506
|
-
type index$
|
|
507
|
-
declare const index$
|
|
508
|
-
declare namespace index$
|
|
509
|
-
export { type index$
|
|
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 };
|
|
510
624
|
}
|
|
511
625
|
|
|
512
626
|
/**
|
|
@@ -605,39 +719,39 @@ declare class BadRequestError extends APIError {
|
|
|
605
719
|
}
|
|
606
720
|
declare function handleZodError(error: z.ZodError): ValidationError;
|
|
607
721
|
|
|
608
|
-
type
|
|
609
|
-
declare const
|
|
610
|
-
type
|
|
611
|
-
declare const
|
|
612
|
-
type
|
|
613
|
-
type
|
|
614
|
-
type
|
|
615
|
-
declare const
|
|
616
|
-
type
|
|
617
|
-
declare const
|
|
618
|
-
type
|
|
619
|
-
declare const
|
|
620
|
-
type
|
|
621
|
-
declare const
|
|
622
|
-
type
|
|
623
|
-
declare const
|
|
624
|
-
type
|
|
625
|
-
declare const
|
|
626
|
-
type
|
|
627
|
-
type
|
|
628
|
-
declare const
|
|
629
|
-
type
|
|
630
|
-
type
|
|
631
|
-
declare const
|
|
632
|
-
declare const
|
|
633
|
-
declare const
|
|
634
|
-
declare const
|
|
635
|
-
declare const
|
|
636
|
-
declare const
|
|
637
|
-
declare const
|
|
638
|
-
declare const
|
|
639
|
-
declare namespace index
|
|
640
|
-
export {
|
|
722
|
+
type index_APIError = APIError;
|
|
723
|
+
declare const index_APIError: typeof APIError;
|
|
724
|
+
type index_BadRequestError = BadRequestError;
|
|
725
|
+
declare const index_BadRequestError: typeof BadRequestError;
|
|
726
|
+
type index_Client = Client;
|
|
727
|
+
type index_GetParameters = GetParameters;
|
|
728
|
+
type index_HttpForbiddenError = HttpForbiddenError;
|
|
729
|
+
declare const index_HttpForbiddenError: typeof HttpForbiddenError;
|
|
730
|
+
type index_HttpGetOffersFailedError = HttpGetOffersFailedError;
|
|
731
|
+
declare const index_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
|
|
732
|
+
type index_HttpRateLimitError = HttpRateLimitError;
|
|
733
|
+
declare const index_HttpRateLimitError: typeof HttpRateLimitError;
|
|
734
|
+
type index_HttpUnauthorizedError = HttpUnauthorizedError;
|
|
735
|
+
declare const index_HttpUnauthorizedError: typeof HttpUnauthorizedError;
|
|
736
|
+
type index_InternalServerError = InternalServerError;
|
|
737
|
+
declare const index_InternalServerError: typeof InternalServerError;
|
|
738
|
+
type index_InvalidUrlError = InvalidUrlError;
|
|
739
|
+
declare const index_InvalidUrlError: typeof InvalidUrlError;
|
|
740
|
+
type index_MatchParameters = MatchParameters;
|
|
741
|
+
type index_NotFoundError = NotFoundError;
|
|
742
|
+
declare const index_NotFoundError: typeof NotFoundError;
|
|
743
|
+
type index_RouterClientConfig = RouterClientConfig;
|
|
744
|
+
type index_ValidationError = ValidationError;
|
|
745
|
+
declare const index_ValidationError: typeof ValidationError;
|
|
746
|
+
declare const index_connect: typeof connect;
|
|
747
|
+
declare const index_error: typeof error;
|
|
748
|
+
declare const index_get: typeof get;
|
|
749
|
+
declare const index_handleZodError: typeof handleZodError;
|
|
750
|
+
declare const index_match: typeof match;
|
|
751
|
+
declare const index_serve: typeof serve;
|
|
752
|
+
declare const index_success: typeof success;
|
|
753
|
+
declare namespace index {
|
|
754
|
+
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 };
|
|
641
755
|
}
|
|
642
756
|
|
|
643
757
|
declare const LogLevelValues: readonly ["silent", "trace", "debug", "info", "warn", "error", "fatal"];
|
|
@@ -672,63 +786,6 @@ declare namespace Logger$1 {
|
|
|
672
786
|
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 };
|
|
673
787
|
}
|
|
674
788
|
|
|
675
|
-
/**
|
|
676
|
-
* Splits an array into batches of a specified size.
|
|
677
|
-
* @param array The array to split.
|
|
678
|
-
* @param batchSize The size of each batch.
|
|
679
|
-
* @returns An iterator that yields each batch.
|
|
680
|
-
* @example
|
|
681
|
-
* ```typescript
|
|
682
|
-
* const array = [1, 2, 3, 4, 5];
|
|
683
|
-
* for (const batch of batch(array, 2)) {
|
|
684
|
-
* console.log(batch);
|
|
685
|
-
* }
|
|
686
|
-
* // Output:
|
|
687
|
-
* // [1, 2]
|
|
688
|
-
* // [3, 4]
|
|
689
|
-
* // [5]
|
|
690
|
-
* ```
|
|
691
|
-
*/
|
|
692
|
-
declare function batch$1<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;
|
|
693
|
-
|
|
694
|
-
type Cursor = {
|
|
695
|
-
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
696
|
-
dir: "asc" | "desc";
|
|
697
|
-
rate?: string;
|
|
698
|
-
maturity?: number;
|
|
699
|
-
expiry?: number;
|
|
700
|
-
assets?: string;
|
|
701
|
-
hash: string;
|
|
702
|
-
};
|
|
703
|
-
declare function validateCursor(cursor: unknown): cursor is Cursor;
|
|
704
|
-
declare function encodeCursor(c: Cursor): string;
|
|
705
|
-
declare function decodeCursor(token?: string): Cursor | null;
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
* Polls a function at a specified interval.
|
|
709
|
-
* Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
|
|
710
|
-
*/
|
|
711
|
-
declare function poll<data>(fn: ({ unpoll }: {
|
|
712
|
-
unpoll: () => void;
|
|
713
|
-
}) => Promise<data | undefined>, { interval }: {
|
|
714
|
-
interval: number;
|
|
715
|
-
}): () => boolean;
|
|
716
|
-
|
|
717
|
-
declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
|
|
718
|
-
|
|
719
|
-
declare function wait(time: number): Promise<unknown>;
|
|
720
|
-
|
|
721
|
-
type index_Cursor = Cursor;
|
|
722
|
-
declare const index_decodeCursor: typeof decodeCursor;
|
|
723
|
-
declare const index_encodeCursor: typeof encodeCursor;
|
|
724
|
-
declare const index_poll: typeof poll;
|
|
725
|
-
declare const index_retry: typeof retry;
|
|
726
|
-
declare const index_validateCursor: typeof validateCursor;
|
|
727
|
-
declare const index_wait: typeof wait;
|
|
728
|
-
declare namespace index {
|
|
729
|
-
export { type index_Cursor as Cursor, batch$1 as batch, index_decodeCursor as decodeCursor, index_encodeCursor as encodeCursor, index_poll as poll, index_retry as retry, index_validateCursor as validateCursor, index_wait as wait };
|
|
730
|
-
}
|
|
731
|
-
|
|
732
789
|
/**
|
|
733
790
|
* A validation rule.
|
|
734
791
|
*/
|
|
@@ -926,4 +983,4 @@ declare namespace Validation {
|
|
|
926
983
|
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
927
984
|
}
|
|
928
985
|
|
|
929
|
-
export { index$
|
|
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 };
|