@morpho-dev/router 0.1.2 → 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 +132 -149
- package/dist/index.browser.d.ts +132 -149
- package/dist/index.browser.js +355 -302
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +355 -303
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +175 -193
- package/dist/index.node.d.ts +175 -193
- package/dist/index.node.js +355 -303
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +355 -304
- package/dist/index.node.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.browser.d.cts
CHANGED
|
@@ -2,9 +2,126 @@ 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
4
|
import * as viem from 'viem';
|
|
5
|
-
import { Address, Hex
|
|
5
|
+
import { PublicActions, Address, Hex } from 'viem';
|
|
6
6
|
import { z, ZodError } from 'zod/v4';
|
|
7
7
|
|
|
8
|
+
declare function fetchBalancesAndAllowances(parameters: {
|
|
9
|
+
client: Pick<PublicActions, "multicall">;
|
|
10
|
+
spender: Address;
|
|
11
|
+
pairs: Array<{
|
|
12
|
+
user: Address;
|
|
13
|
+
token: Address;
|
|
14
|
+
}>;
|
|
15
|
+
options?: {
|
|
16
|
+
batchSize?: number;
|
|
17
|
+
retryAttempts?: number;
|
|
18
|
+
retryDelayMs?: number;
|
|
19
|
+
blockNumber?: number;
|
|
20
|
+
};
|
|
21
|
+
}): Promise<Map<Address, Map<Address, {
|
|
22
|
+
balance: bigint;
|
|
23
|
+
allowance: bigint;
|
|
24
|
+
}>>>;
|
|
25
|
+
type LiquidityUserPosition = {
|
|
26
|
+
id: string;
|
|
27
|
+
availableLiquidityQueueId: string;
|
|
28
|
+
user: string;
|
|
29
|
+
chainId: bigint;
|
|
30
|
+
amount: string;
|
|
31
|
+
updatedAt: Date;
|
|
32
|
+
};
|
|
33
|
+
type LiquidityQueue = {
|
|
34
|
+
queueId: string;
|
|
35
|
+
availableLiquidityPoolId: string;
|
|
36
|
+
index: number;
|
|
37
|
+
updatedAt: Date;
|
|
38
|
+
};
|
|
39
|
+
type LiquidityPool = {
|
|
40
|
+
id: string;
|
|
41
|
+
amount: string;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
};
|
|
44
|
+
type LiquidityQueueWithPool = {
|
|
45
|
+
queue: LiquidityQueue;
|
|
46
|
+
pool: LiquidityPool;
|
|
47
|
+
};
|
|
48
|
+
type Liquidity = {
|
|
49
|
+
userPosition: LiquidityUserPosition;
|
|
50
|
+
queues: LiquidityQueueWithPool[];
|
|
51
|
+
};
|
|
52
|
+
declare function fetch(parameters: {
|
|
53
|
+
client: Pick<PublicActions, "multicall">;
|
|
54
|
+
chainId: bigint;
|
|
55
|
+
spender: Address;
|
|
56
|
+
type: CallbackType;
|
|
57
|
+
pairs: Array<{
|
|
58
|
+
user: Address;
|
|
59
|
+
contract: Address;
|
|
60
|
+
}>;
|
|
61
|
+
options?: {
|
|
62
|
+
batchSize?: number;
|
|
63
|
+
retryAttempts?: number;
|
|
64
|
+
retryDelayMs?: number;
|
|
65
|
+
blockNumber?: number;
|
|
66
|
+
};
|
|
67
|
+
}): Promise<Liquidity[]>;
|
|
68
|
+
declare function serialize(liquidity: Liquidity): string;
|
|
69
|
+
|
|
70
|
+
type Liquidity$1_Liquidity = Liquidity;
|
|
71
|
+
type Liquidity$1_LiquidityPool = LiquidityPool;
|
|
72
|
+
type Liquidity$1_LiquidityQueue = LiquidityQueue;
|
|
73
|
+
type Liquidity$1_LiquidityQueueWithPool = LiquidityQueueWithPool;
|
|
74
|
+
type Liquidity$1_LiquidityUserPosition = LiquidityUserPosition;
|
|
75
|
+
declare const Liquidity$1_fetch: typeof fetch;
|
|
76
|
+
declare const Liquidity$1_fetchBalancesAndAllowances: typeof fetchBalancesAndAllowances;
|
|
77
|
+
declare const Liquidity$1_serialize: typeof serialize;
|
|
78
|
+
declare namespace Liquidity$1 {
|
|
79
|
+
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 };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare enum CallbackType {
|
|
83
|
+
BuyWithEmptyCallback = "buy_with_empty_callback"
|
|
84
|
+
}
|
|
85
|
+
declare function buildLiquidity(parameters: {
|
|
86
|
+
type: CallbackType;
|
|
87
|
+
user: string;
|
|
88
|
+
contract: string;
|
|
89
|
+
chainId: bigint;
|
|
90
|
+
amount: string | bigint;
|
|
91
|
+
index?: number;
|
|
92
|
+
updatedAt?: Date;
|
|
93
|
+
}): Liquidity;
|
|
94
|
+
declare function getCallbackIdForOffer(offer: Offer.Offer): string | null;
|
|
95
|
+
|
|
96
|
+
type Callback_CallbackType = CallbackType;
|
|
97
|
+
declare const Callback_CallbackType: typeof CallbackType;
|
|
98
|
+
declare const Callback_buildLiquidity: typeof buildLiquidity;
|
|
99
|
+
declare const Callback_getCallbackIdForOffer: typeof getCallbackIdForOffer;
|
|
100
|
+
declare namespace Callback {
|
|
101
|
+
export { Callback_CallbackType as CallbackType, Callback_buildLiquidity as buildLiquidity, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type Cursor = {
|
|
105
|
+
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
106
|
+
dir: "asc" | "desc";
|
|
107
|
+
rate?: string;
|
|
108
|
+
maturity?: number;
|
|
109
|
+
expiry?: number;
|
|
110
|
+
assets?: string;
|
|
111
|
+
hash: string;
|
|
112
|
+
};
|
|
113
|
+
declare function validate(cursor: unknown): cursor is Cursor;
|
|
114
|
+
declare function encode(c: Cursor): string;
|
|
115
|
+
declare function decode(token?: string): Cursor | null;
|
|
116
|
+
|
|
117
|
+
type Cursor$1_Cursor = Cursor;
|
|
118
|
+
declare const Cursor$1_decode: typeof decode;
|
|
119
|
+
declare const Cursor$1_encode: typeof encode;
|
|
120
|
+
declare const Cursor$1_validate: typeof validate;
|
|
121
|
+
declare namespace Cursor$1 {
|
|
122
|
+
export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
|
|
123
|
+
}
|
|
124
|
+
|
|
8
125
|
declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
|
|
9
126
|
type OfferStatus = (typeof OfferStatusValues)[number];
|
|
10
127
|
type OfferMetadata = {
|
|
@@ -88,8 +205,8 @@ declare const consumedEvent: {
|
|
|
88
205
|
* @param input - The router offer to create.
|
|
89
206
|
* @returns The created router offer with its hash.
|
|
90
207
|
*/
|
|
91
|
-
declare function from
|
|
92
|
-
declare namespace from
|
|
208
|
+
declare function from(input: Omit<RouterOffer, "hash">): RouterOffer;
|
|
209
|
+
declare namespace from {
|
|
93
210
|
type ErrorType = InvalidRouterOfferError;
|
|
94
211
|
}
|
|
95
212
|
/**
|
|
@@ -132,12 +249,13 @@ declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
|
|
|
132
249
|
type RouterOffer$1_RouterOffer = RouterOffer;
|
|
133
250
|
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
|
|
134
251
|
declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
|
|
252
|
+
declare const RouterOffer$1_from: typeof from;
|
|
135
253
|
declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
|
|
136
254
|
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
|
|
137
255
|
declare const RouterOffer$1_random: typeof random;
|
|
138
256
|
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
|
|
139
257
|
declare namespace RouterOffer$1 {
|
|
140
|
-
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,
|
|
258
|
+
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferConsumed as OfferConsumed, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_consumedEvent as consumedEvent, RouterOffer$1_from as from, RouterOffer$1_fromConsumedLog as fromConsumedLog, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
141
259
|
}
|
|
142
260
|
|
|
143
261
|
type OfferResponse = {
|
|
@@ -405,8 +523,6 @@ type FindMatchingOffersParams = {
|
|
|
405
523
|
maxMaturity?: number;
|
|
406
524
|
loanToken?: string;
|
|
407
525
|
creator?: string;
|
|
408
|
-
/** Filter by offer status; if omitted defaults to ["valid"] */
|
|
409
|
-
status?: OfferStatus[];
|
|
410
526
|
/** Cursor string returned by a previous call, for pagination */
|
|
411
527
|
cursor?: string;
|
|
412
528
|
/** Page size; defaults to 20 */
|
|
@@ -424,96 +540,13 @@ declare function memory(parameters: {
|
|
|
424
540
|
filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
|
|
425
541
|
}): OfferStore;
|
|
426
542
|
|
|
427
|
-
type
|
|
428
|
-
type
|
|
429
|
-
type
|
|
430
|
-
type
|
|
431
|
-
declare const
|
|
432
|
-
declare namespace index$1 {
|
|
433
|
-
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 };
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
declare const types: readonly ["offer_created", "offer_consumed", "offer_validation"];
|
|
437
|
-
type Type = (typeof types)[number];
|
|
438
|
-
type BaseEvent<type extends Type = Type> = {
|
|
439
|
-
readonly id: string;
|
|
440
|
-
readonly type: type;
|
|
441
|
-
};
|
|
442
|
-
type RouterEvent<type extends Type = Type> = type extends "offer_consumed" ? Compute<BaseEvent<type> & {
|
|
443
|
-
readonly offerConsumed: OfferConsumed;
|
|
444
|
-
}> : type extends "offer_created" | "offer_validation" ? Compute<BaseEvent<type> & {
|
|
445
|
-
readonly offer: Offer.Offer;
|
|
446
|
-
}> : never;
|
|
447
|
-
/**
|
|
448
|
-
* Creates a RouterEvent with a deterministic id.
|
|
449
|
-
*/
|
|
450
|
-
declare function from<T extends Type = Type>(base: Omit<RouterEvent<T>, "id" | "type"> & {
|
|
451
|
-
type: T;
|
|
452
|
-
}): Compute<RouterEvent<T>>;
|
|
453
|
-
|
|
454
|
-
type RouterEvent$1_RouterEvent<type extends Type = Type> = RouterEvent<type>;
|
|
455
|
-
type RouterEvent$1_Type = Type;
|
|
456
|
-
declare const RouterEvent$1_from: typeof from;
|
|
457
|
-
declare const RouterEvent$1_types: typeof types;
|
|
458
|
-
declare namespace RouterEvent$1 {
|
|
459
|
-
export { type RouterEvent$1_RouterEvent as RouterEvent, type RouterEvent$1_Type as Type, RouterEvent$1_from as from, RouterEvent$1_types as types };
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Splits an array into batches of a specified size.
|
|
464
|
-
* @param array The array to split.
|
|
465
|
-
* @param batchSize The size of each batch.
|
|
466
|
-
* @returns An iterator that yields each batch.
|
|
467
|
-
* @example
|
|
468
|
-
* ```typescript
|
|
469
|
-
* const array = [1, 2, 3, 4, 5];
|
|
470
|
-
* for (const batch of batch(array, 2)) {
|
|
471
|
-
* console.log(batch);
|
|
472
|
-
* }
|
|
473
|
-
* // Output:
|
|
474
|
-
* // [1, 2]
|
|
475
|
-
* // [3, 4]
|
|
476
|
-
* // [5]
|
|
477
|
-
* ```
|
|
478
|
-
*/
|
|
479
|
-
declare function batch$1<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;
|
|
480
|
-
|
|
481
|
-
type Cursor = {
|
|
482
|
-
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
483
|
-
dir: "asc" | "desc";
|
|
484
|
-
rate?: string;
|
|
485
|
-
maturity?: number;
|
|
486
|
-
expiry?: number;
|
|
487
|
-
assets?: string;
|
|
488
|
-
hash: string;
|
|
489
|
-
};
|
|
490
|
-
declare function validateCursor(cursor: unknown): cursor is Cursor;
|
|
491
|
-
declare function encodeCursor(c: Cursor): string;
|
|
492
|
-
declare function decodeCursor(token?: string): Cursor | null;
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Polls a function at a specified interval.
|
|
496
|
-
* Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
|
|
497
|
-
*/
|
|
498
|
-
declare function poll<data>(fn: ({ unpoll }: {
|
|
499
|
-
unpoll: () => void;
|
|
500
|
-
}) => Promise<data | undefined>, { interval }: {
|
|
501
|
-
interval: number;
|
|
502
|
-
}): () => boolean;
|
|
503
|
-
|
|
504
|
-
declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
|
|
505
|
-
|
|
506
|
-
declare function wait(time: number): Promise<unknown>;
|
|
507
|
-
|
|
508
|
-
type index_Cursor = Cursor;
|
|
509
|
-
declare const index_decodeCursor: typeof decodeCursor;
|
|
510
|
-
declare const index_encodeCursor: typeof encodeCursor;
|
|
511
|
-
declare const index_poll: typeof poll;
|
|
512
|
-
declare const index_retry: typeof retry;
|
|
513
|
-
declare const index_validateCursor: typeof validateCursor;
|
|
514
|
-
declare const index_wait: typeof wait;
|
|
543
|
+
type index_FindMatchingOffersParams = FindMatchingOffersParams;
|
|
544
|
+
type index_GetAllParams = GetAllParams;
|
|
545
|
+
type index_GetOffersFilters = GetOffersFilters;
|
|
546
|
+
type index_OfferStore = OfferStore;
|
|
547
|
+
declare const index_memory: typeof memory;
|
|
515
548
|
declare namespace index {
|
|
516
|
-
export { type
|
|
549
|
+
export { type index_FindMatchingOffersParams as FindMatchingOffersParams, type index_GetAllParams as GetAllParams, type index_GetOffersFilters as GetOffersFilters, type index_OfferStore as OfferStore, index_memory as memory };
|
|
517
550
|
}
|
|
518
551
|
|
|
519
552
|
/**
|
|
@@ -560,11 +593,9 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
|
|
|
560
593
|
*/
|
|
561
594
|
declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
|
|
562
595
|
type MorphoContext = {
|
|
563
|
-
|
|
596
|
+
chain: Chain.Chain;
|
|
564
597
|
};
|
|
565
|
-
declare function morpho(
|
|
566
|
-
whitelistedChains: Chain.Chain[];
|
|
567
|
-
}): (Rule<{
|
|
598
|
+
declare function morpho(): (Rule<{
|
|
568
599
|
readonly offering: Address;
|
|
569
600
|
readonly assets: bigint;
|
|
570
601
|
readonly rate: bigint;
|
|
@@ -660,55 +691,7 @@ declare function morpho(parameters: {
|
|
|
660
691
|
readonly hash: viem.Hex;
|
|
661
692
|
signature?: viem.Hex;
|
|
662
693
|
createdAt?: number;
|
|
663
|
-
}, "empty_callback", MorphoContext>
|
|
664
|
-
readonly offering: Address;
|
|
665
|
-
readonly assets: bigint;
|
|
666
|
-
readonly rate: bigint;
|
|
667
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
668
|
-
readonly expiry: number;
|
|
669
|
-
readonly nonce: bigint;
|
|
670
|
-
readonly buy: boolean;
|
|
671
|
-
readonly chainId: bigint;
|
|
672
|
-
readonly loanToken: Address;
|
|
673
|
-
readonly start: number;
|
|
674
|
-
readonly collaterals: readonly {
|
|
675
|
-
asset: Address;
|
|
676
|
-
oracle: Address;
|
|
677
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
678
|
-
}[];
|
|
679
|
-
readonly callback: {
|
|
680
|
-
readonly address: Address;
|
|
681
|
-
readonly data: viem.Hex;
|
|
682
|
-
readonly gasLimit: bigint;
|
|
683
|
-
};
|
|
684
|
-
readonly hash: viem.Hex;
|
|
685
|
-
signature?: viem.Hex;
|
|
686
|
-
createdAt?: number;
|
|
687
|
-
}, "sell_offers_empty_callback", MorphoContext> | Rule<{
|
|
688
|
-
readonly offering: Address;
|
|
689
|
-
readonly assets: bigint;
|
|
690
|
-
readonly rate: bigint;
|
|
691
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
692
|
-
readonly expiry: number;
|
|
693
|
-
readonly nonce: bigint;
|
|
694
|
-
readonly buy: boolean;
|
|
695
|
-
readonly chainId: bigint;
|
|
696
|
-
readonly loanToken: Address;
|
|
697
|
-
readonly start: number;
|
|
698
|
-
readonly collaterals: readonly {
|
|
699
|
-
asset: Address;
|
|
700
|
-
oracle: Address;
|
|
701
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
702
|
-
}[];
|
|
703
|
-
readonly callback: {
|
|
704
|
-
readonly address: Address;
|
|
705
|
-
readonly data: viem.Hex;
|
|
706
|
-
readonly gasLimit: bigint;
|
|
707
|
-
};
|
|
708
|
-
readonly hash: viem.Hex;
|
|
709
|
-
signature?: viem.Hex;
|
|
710
|
-
createdAt?: number;
|
|
711
|
-
}, "buy_offers_empty_callback", MorphoContext>)[];
|
|
694
|
+
}, "empty_callback", MorphoContext>)[];
|
|
712
695
|
|
|
713
696
|
type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
|
|
714
697
|
type ValidationRule_MorphoContext = MorphoContext;
|
|
@@ -763,4 +746,4 @@ declare namespace Validation {
|
|
|
763
746
|
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
764
747
|
}
|
|
765
748
|
|
|
766
|
-
export {
|
|
749
|
+
export { Callback, Cursor$1 as Cursor, Liquidity$1 as Liquidity, index as OfferStore, Client$1 as Router, RouterOffer$1 as RouterOffer, Validation, ValidationRule };
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -2,9 +2,126 @@ 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
4
|
import * as viem from 'viem';
|
|
5
|
-
import { Address, Hex
|
|
5
|
+
import { PublicActions, Address, Hex } from 'viem';
|
|
6
6
|
import { z, ZodError } from 'zod/v4';
|
|
7
7
|
|
|
8
|
+
declare function fetchBalancesAndAllowances(parameters: {
|
|
9
|
+
client: Pick<PublicActions, "multicall">;
|
|
10
|
+
spender: Address;
|
|
11
|
+
pairs: Array<{
|
|
12
|
+
user: Address;
|
|
13
|
+
token: Address;
|
|
14
|
+
}>;
|
|
15
|
+
options?: {
|
|
16
|
+
batchSize?: number;
|
|
17
|
+
retryAttempts?: number;
|
|
18
|
+
retryDelayMs?: number;
|
|
19
|
+
blockNumber?: number;
|
|
20
|
+
};
|
|
21
|
+
}): Promise<Map<Address, Map<Address, {
|
|
22
|
+
balance: bigint;
|
|
23
|
+
allowance: bigint;
|
|
24
|
+
}>>>;
|
|
25
|
+
type LiquidityUserPosition = {
|
|
26
|
+
id: string;
|
|
27
|
+
availableLiquidityQueueId: string;
|
|
28
|
+
user: string;
|
|
29
|
+
chainId: bigint;
|
|
30
|
+
amount: string;
|
|
31
|
+
updatedAt: Date;
|
|
32
|
+
};
|
|
33
|
+
type LiquidityQueue = {
|
|
34
|
+
queueId: string;
|
|
35
|
+
availableLiquidityPoolId: string;
|
|
36
|
+
index: number;
|
|
37
|
+
updatedAt: Date;
|
|
38
|
+
};
|
|
39
|
+
type LiquidityPool = {
|
|
40
|
+
id: string;
|
|
41
|
+
amount: string;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
};
|
|
44
|
+
type LiquidityQueueWithPool = {
|
|
45
|
+
queue: LiquidityQueue;
|
|
46
|
+
pool: LiquidityPool;
|
|
47
|
+
};
|
|
48
|
+
type Liquidity = {
|
|
49
|
+
userPosition: LiquidityUserPosition;
|
|
50
|
+
queues: LiquidityQueueWithPool[];
|
|
51
|
+
};
|
|
52
|
+
declare function fetch(parameters: {
|
|
53
|
+
client: Pick<PublicActions, "multicall">;
|
|
54
|
+
chainId: bigint;
|
|
55
|
+
spender: Address;
|
|
56
|
+
type: CallbackType;
|
|
57
|
+
pairs: Array<{
|
|
58
|
+
user: Address;
|
|
59
|
+
contract: Address;
|
|
60
|
+
}>;
|
|
61
|
+
options?: {
|
|
62
|
+
batchSize?: number;
|
|
63
|
+
retryAttempts?: number;
|
|
64
|
+
retryDelayMs?: number;
|
|
65
|
+
blockNumber?: number;
|
|
66
|
+
};
|
|
67
|
+
}): Promise<Liquidity[]>;
|
|
68
|
+
declare function serialize(liquidity: Liquidity): string;
|
|
69
|
+
|
|
70
|
+
type Liquidity$1_Liquidity = Liquidity;
|
|
71
|
+
type Liquidity$1_LiquidityPool = LiquidityPool;
|
|
72
|
+
type Liquidity$1_LiquidityQueue = LiquidityQueue;
|
|
73
|
+
type Liquidity$1_LiquidityQueueWithPool = LiquidityQueueWithPool;
|
|
74
|
+
type Liquidity$1_LiquidityUserPosition = LiquidityUserPosition;
|
|
75
|
+
declare const Liquidity$1_fetch: typeof fetch;
|
|
76
|
+
declare const Liquidity$1_fetchBalancesAndAllowances: typeof fetchBalancesAndAllowances;
|
|
77
|
+
declare const Liquidity$1_serialize: typeof serialize;
|
|
78
|
+
declare namespace Liquidity$1 {
|
|
79
|
+
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 };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare enum CallbackType {
|
|
83
|
+
BuyWithEmptyCallback = "buy_with_empty_callback"
|
|
84
|
+
}
|
|
85
|
+
declare function buildLiquidity(parameters: {
|
|
86
|
+
type: CallbackType;
|
|
87
|
+
user: string;
|
|
88
|
+
contract: string;
|
|
89
|
+
chainId: bigint;
|
|
90
|
+
amount: string | bigint;
|
|
91
|
+
index?: number;
|
|
92
|
+
updatedAt?: Date;
|
|
93
|
+
}): Liquidity;
|
|
94
|
+
declare function getCallbackIdForOffer(offer: Offer.Offer): string | null;
|
|
95
|
+
|
|
96
|
+
type Callback_CallbackType = CallbackType;
|
|
97
|
+
declare const Callback_CallbackType: typeof CallbackType;
|
|
98
|
+
declare const Callback_buildLiquidity: typeof buildLiquidity;
|
|
99
|
+
declare const Callback_getCallbackIdForOffer: typeof getCallbackIdForOffer;
|
|
100
|
+
declare namespace Callback {
|
|
101
|
+
export { Callback_CallbackType as CallbackType, Callback_buildLiquidity as buildLiquidity, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type Cursor = {
|
|
105
|
+
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
106
|
+
dir: "asc" | "desc";
|
|
107
|
+
rate?: string;
|
|
108
|
+
maturity?: number;
|
|
109
|
+
expiry?: number;
|
|
110
|
+
assets?: string;
|
|
111
|
+
hash: string;
|
|
112
|
+
};
|
|
113
|
+
declare function validate(cursor: unknown): cursor is Cursor;
|
|
114
|
+
declare function encode(c: Cursor): string;
|
|
115
|
+
declare function decode(token?: string): Cursor | null;
|
|
116
|
+
|
|
117
|
+
type Cursor$1_Cursor = Cursor;
|
|
118
|
+
declare const Cursor$1_decode: typeof decode;
|
|
119
|
+
declare const Cursor$1_encode: typeof encode;
|
|
120
|
+
declare const Cursor$1_validate: typeof validate;
|
|
121
|
+
declare namespace Cursor$1 {
|
|
122
|
+
export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
|
|
123
|
+
}
|
|
124
|
+
|
|
8
125
|
declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
|
|
9
126
|
type OfferStatus = (typeof OfferStatusValues)[number];
|
|
10
127
|
type OfferMetadata = {
|
|
@@ -88,8 +205,8 @@ declare const consumedEvent: {
|
|
|
88
205
|
* @param input - The router offer to create.
|
|
89
206
|
* @returns The created router offer with its hash.
|
|
90
207
|
*/
|
|
91
|
-
declare function from
|
|
92
|
-
declare namespace from
|
|
208
|
+
declare function from(input: Omit<RouterOffer, "hash">): RouterOffer;
|
|
209
|
+
declare namespace from {
|
|
93
210
|
type ErrorType = InvalidRouterOfferError;
|
|
94
211
|
}
|
|
95
212
|
/**
|
|
@@ -132,12 +249,13 @@ declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
|
|
|
132
249
|
type RouterOffer$1_RouterOffer = RouterOffer;
|
|
133
250
|
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
|
|
134
251
|
declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
|
|
252
|
+
declare const RouterOffer$1_from: typeof from;
|
|
135
253
|
declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
|
|
136
254
|
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
|
|
137
255
|
declare const RouterOffer$1_random: typeof random;
|
|
138
256
|
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
|
|
139
257
|
declare namespace RouterOffer$1 {
|
|
140
|
-
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,
|
|
258
|
+
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferConsumed as OfferConsumed, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_consumedEvent as consumedEvent, RouterOffer$1_from as from, RouterOffer$1_fromConsumedLog as fromConsumedLog, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
141
259
|
}
|
|
142
260
|
|
|
143
261
|
type OfferResponse = {
|
|
@@ -405,8 +523,6 @@ type FindMatchingOffersParams = {
|
|
|
405
523
|
maxMaturity?: number;
|
|
406
524
|
loanToken?: string;
|
|
407
525
|
creator?: string;
|
|
408
|
-
/** Filter by offer status; if omitted defaults to ["valid"] */
|
|
409
|
-
status?: OfferStatus[];
|
|
410
526
|
/** Cursor string returned by a previous call, for pagination */
|
|
411
527
|
cursor?: string;
|
|
412
528
|
/** Page size; defaults to 20 */
|
|
@@ -424,96 +540,13 @@ declare function memory(parameters: {
|
|
|
424
540
|
filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
|
|
425
541
|
}): OfferStore;
|
|
426
542
|
|
|
427
|
-
type
|
|
428
|
-
type
|
|
429
|
-
type
|
|
430
|
-
type
|
|
431
|
-
declare const
|
|
432
|
-
declare namespace index$1 {
|
|
433
|
-
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 };
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
declare const types: readonly ["offer_created", "offer_consumed", "offer_validation"];
|
|
437
|
-
type Type = (typeof types)[number];
|
|
438
|
-
type BaseEvent<type extends Type = Type> = {
|
|
439
|
-
readonly id: string;
|
|
440
|
-
readonly type: type;
|
|
441
|
-
};
|
|
442
|
-
type RouterEvent<type extends Type = Type> = type extends "offer_consumed" ? Compute<BaseEvent<type> & {
|
|
443
|
-
readonly offerConsumed: OfferConsumed;
|
|
444
|
-
}> : type extends "offer_created" | "offer_validation" ? Compute<BaseEvent<type> & {
|
|
445
|
-
readonly offer: Offer.Offer;
|
|
446
|
-
}> : never;
|
|
447
|
-
/**
|
|
448
|
-
* Creates a RouterEvent with a deterministic id.
|
|
449
|
-
*/
|
|
450
|
-
declare function from<T extends Type = Type>(base: Omit<RouterEvent<T>, "id" | "type"> & {
|
|
451
|
-
type: T;
|
|
452
|
-
}): Compute<RouterEvent<T>>;
|
|
453
|
-
|
|
454
|
-
type RouterEvent$1_RouterEvent<type extends Type = Type> = RouterEvent<type>;
|
|
455
|
-
type RouterEvent$1_Type = Type;
|
|
456
|
-
declare const RouterEvent$1_from: typeof from;
|
|
457
|
-
declare const RouterEvent$1_types: typeof types;
|
|
458
|
-
declare namespace RouterEvent$1 {
|
|
459
|
-
export { type RouterEvent$1_RouterEvent as RouterEvent, type RouterEvent$1_Type as Type, RouterEvent$1_from as from, RouterEvent$1_types as types };
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Splits an array into batches of a specified size.
|
|
464
|
-
* @param array The array to split.
|
|
465
|
-
* @param batchSize The size of each batch.
|
|
466
|
-
* @returns An iterator that yields each batch.
|
|
467
|
-
* @example
|
|
468
|
-
* ```typescript
|
|
469
|
-
* const array = [1, 2, 3, 4, 5];
|
|
470
|
-
* for (const batch of batch(array, 2)) {
|
|
471
|
-
* console.log(batch);
|
|
472
|
-
* }
|
|
473
|
-
* // Output:
|
|
474
|
-
* // [1, 2]
|
|
475
|
-
* // [3, 4]
|
|
476
|
-
* // [5]
|
|
477
|
-
* ```
|
|
478
|
-
*/
|
|
479
|
-
declare function batch$1<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;
|
|
480
|
-
|
|
481
|
-
type Cursor = {
|
|
482
|
-
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
483
|
-
dir: "asc" | "desc";
|
|
484
|
-
rate?: string;
|
|
485
|
-
maturity?: number;
|
|
486
|
-
expiry?: number;
|
|
487
|
-
assets?: string;
|
|
488
|
-
hash: string;
|
|
489
|
-
};
|
|
490
|
-
declare function validateCursor(cursor: unknown): cursor is Cursor;
|
|
491
|
-
declare function encodeCursor(c: Cursor): string;
|
|
492
|
-
declare function decodeCursor(token?: string): Cursor | null;
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Polls a function at a specified interval.
|
|
496
|
-
* Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
|
|
497
|
-
*/
|
|
498
|
-
declare function poll<data>(fn: ({ unpoll }: {
|
|
499
|
-
unpoll: () => void;
|
|
500
|
-
}) => Promise<data | undefined>, { interval }: {
|
|
501
|
-
interval: number;
|
|
502
|
-
}): () => boolean;
|
|
503
|
-
|
|
504
|
-
declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
|
|
505
|
-
|
|
506
|
-
declare function wait(time: number): Promise<unknown>;
|
|
507
|
-
|
|
508
|
-
type index_Cursor = Cursor;
|
|
509
|
-
declare const index_decodeCursor: typeof decodeCursor;
|
|
510
|
-
declare const index_encodeCursor: typeof encodeCursor;
|
|
511
|
-
declare const index_poll: typeof poll;
|
|
512
|
-
declare const index_retry: typeof retry;
|
|
513
|
-
declare const index_validateCursor: typeof validateCursor;
|
|
514
|
-
declare const index_wait: typeof wait;
|
|
543
|
+
type index_FindMatchingOffersParams = FindMatchingOffersParams;
|
|
544
|
+
type index_GetAllParams = GetAllParams;
|
|
545
|
+
type index_GetOffersFilters = GetOffersFilters;
|
|
546
|
+
type index_OfferStore = OfferStore;
|
|
547
|
+
declare const index_memory: typeof memory;
|
|
515
548
|
declare namespace index {
|
|
516
|
-
export { type
|
|
549
|
+
export { type index_FindMatchingOffersParams as FindMatchingOffersParams, type index_GetAllParams as GetAllParams, type index_GetOffersFilters as GetOffersFilters, type index_OfferStore as OfferStore, index_memory as memory };
|
|
517
550
|
}
|
|
518
551
|
|
|
519
552
|
/**
|
|
@@ -560,11 +593,9 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
|
|
|
560
593
|
*/
|
|
561
594
|
declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
|
|
562
595
|
type MorphoContext = {
|
|
563
|
-
|
|
596
|
+
chain: Chain.Chain;
|
|
564
597
|
};
|
|
565
|
-
declare function morpho(
|
|
566
|
-
whitelistedChains: Chain.Chain[];
|
|
567
|
-
}): (Rule<{
|
|
598
|
+
declare function morpho(): (Rule<{
|
|
568
599
|
readonly offering: Address;
|
|
569
600
|
readonly assets: bigint;
|
|
570
601
|
readonly rate: bigint;
|
|
@@ -660,55 +691,7 @@ declare function morpho(parameters: {
|
|
|
660
691
|
readonly hash: viem.Hex;
|
|
661
692
|
signature?: viem.Hex;
|
|
662
693
|
createdAt?: number;
|
|
663
|
-
}, "empty_callback", MorphoContext>
|
|
664
|
-
readonly offering: Address;
|
|
665
|
-
readonly assets: bigint;
|
|
666
|
-
readonly rate: bigint;
|
|
667
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
668
|
-
readonly expiry: number;
|
|
669
|
-
readonly nonce: bigint;
|
|
670
|
-
readonly buy: boolean;
|
|
671
|
-
readonly chainId: bigint;
|
|
672
|
-
readonly loanToken: Address;
|
|
673
|
-
readonly start: number;
|
|
674
|
-
readonly collaterals: readonly {
|
|
675
|
-
asset: Address;
|
|
676
|
-
oracle: Address;
|
|
677
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
678
|
-
}[];
|
|
679
|
-
readonly callback: {
|
|
680
|
-
readonly address: Address;
|
|
681
|
-
readonly data: viem.Hex;
|
|
682
|
-
readonly gasLimit: bigint;
|
|
683
|
-
};
|
|
684
|
-
readonly hash: viem.Hex;
|
|
685
|
-
signature?: viem.Hex;
|
|
686
|
-
createdAt?: number;
|
|
687
|
-
}, "sell_offers_empty_callback", MorphoContext> | Rule<{
|
|
688
|
-
readonly offering: Address;
|
|
689
|
-
readonly assets: bigint;
|
|
690
|
-
readonly rate: bigint;
|
|
691
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
692
|
-
readonly expiry: number;
|
|
693
|
-
readonly nonce: bigint;
|
|
694
|
-
readonly buy: boolean;
|
|
695
|
-
readonly chainId: bigint;
|
|
696
|
-
readonly loanToken: Address;
|
|
697
|
-
readonly start: number;
|
|
698
|
-
readonly collaterals: readonly {
|
|
699
|
-
asset: Address;
|
|
700
|
-
oracle: Address;
|
|
701
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
702
|
-
}[];
|
|
703
|
-
readonly callback: {
|
|
704
|
-
readonly address: Address;
|
|
705
|
-
readonly data: viem.Hex;
|
|
706
|
-
readonly gasLimit: bigint;
|
|
707
|
-
};
|
|
708
|
-
readonly hash: viem.Hex;
|
|
709
|
-
signature?: viem.Hex;
|
|
710
|
-
createdAt?: number;
|
|
711
|
-
}, "buy_offers_empty_callback", MorphoContext>)[];
|
|
694
|
+
}, "empty_callback", MorphoContext>)[];
|
|
712
695
|
|
|
713
696
|
type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
|
|
714
697
|
type ValidationRule_MorphoContext = MorphoContext;
|
|
@@ -763,4 +746,4 @@ declare namespace Validation {
|
|
|
763
746
|
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
764
747
|
}
|
|
765
748
|
|
|
766
|
-
export {
|
|
749
|
+
export { Callback, Cursor$1 as Cursor, Liquidity$1 as Liquidity, index as OfferStore, Client$1 as Router, RouterOffer$1 as RouterOffer, Validation, ValidationRule };
|