@morpho-dev/router 0.1.12 → 0.1.16
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/README.md +97 -64
- package/dist/cli.js +6041 -0
- package/dist/cli.js.map +1 -0
- package/dist/drizzle/router_v1.4/0000_add_obligation_id.sql +112 -0
- package/dist/drizzle/router_v1.4/0001_update-primary-key-on-link.sql +3 -0
- package/dist/drizzle/{router_v1.1 → router_v1.4}/meta/0000_snapshot.json +305 -265
- package/dist/drizzle/router_v1.4/meta/0001_snapshot.json +972 -0
- package/dist/drizzle/router_v1.4/meta/_journal.json +20 -0
- package/dist/index.browser.d.cts +1384 -603
- package/dist/index.browser.d.ts +1384 -603
- package/dist/index.browser.js +2103 -1343
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +2054 -1322
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +2380 -1328
- package/dist/index.node.d.ts +2380 -1328
- package/dist/index.node.js +5744 -3514
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +5703 -3513
- package/dist/index.node.mjs.map +1 -1
- package/package.json +20 -16
- package/dist/drizzle/router_v1.1/0000_init.sql +0 -103
- package/dist/drizzle/router_v1.1/meta/_journal.json +0 -13
package/dist/index.browser.d.cts
CHANGED
|
@@ -1,34 +1,609 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { z as z$1 } from 'zod/v4';
|
|
2
|
+
import { Hex, Address, AbiEvent, PublicClient, GetLogsReturnType, WalletClient, PublicActions } from 'viem';
|
|
3
|
+
import * as z from 'zod';
|
|
4
|
+
import { Chain as Chain$2 } from 'viem/chains';
|
|
5
|
+
import * as node_modules_zod_openapi_dist_components_CXzxKPFp_js from 'node_modules/zod-openapi/dist/components-CXzxKPFp.js';
|
|
6
|
+
|
|
7
|
+
declare const CollectorHealth: z$1.ZodObject<{
|
|
8
|
+
name: z$1.ZodString;
|
|
9
|
+
chain_id: z$1.ZodNumber;
|
|
10
|
+
block_number: z$1.ZodNullable<z$1.ZodNumber>;
|
|
11
|
+
updated_at: z$1.ZodNullable<z$1.ZodString>;
|
|
12
|
+
lag: z$1.ZodNullable<z$1.ZodNumber>;
|
|
13
|
+
status: z$1.ZodEnum<{
|
|
14
|
+
live: "live";
|
|
15
|
+
lagging: "lagging";
|
|
16
|
+
unknown: "unknown";
|
|
17
|
+
}>;
|
|
18
|
+
}, z$1.core.$strip>;
|
|
19
|
+
declare const ChainHealth: z$1.ZodObject<{
|
|
20
|
+
chain_id: z$1.ZodNumber;
|
|
21
|
+
block_number: z$1.ZodNumber;
|
|
22
|
+
updated_at: z$1.ZodString;
|
|
23
|
+
}, z$1.core.$strip>;
|
|
24
|
+
declare const CollectorsHealthResponse: z$1.ZodObject<{
|
|
25
|
+
collectors: z$1.ZodArray<z$1.ZodObject<{
|
|
26
|
+
name: z$1.ZodString;
|
|
27
|
+
chain_id: z$1.ZodNumber;
|
|
28
|
+
block_number: z$1.ZodNullable<z$1.ZodNumber>;
|
|
29
|
+
updated_at: z$1.ZodNullable<z$1.ZodString>;
|
|
30
|
+
lag: z$1.ZodNullable<z$1.ZodNumber>;
|
|
31
|
+
status: z$1.ZodEnum<{
|
|
32
|
+
live: "live";
|
|
33
|
+
lagging: "lagging";
|
|
34
|
+
unknown: "unknown";
|
|
35
|
+
}>;
|
|
36
|
+
}, z$1.core.$strip>>;
|
|
37
|
+
}, z$1.core.$strip>;
|
|
38
|
+
type CollectorsHealthResponse = z$1.infer<typeof CollectorsHealthResponse>;
|
|
39
|
+
declare const ChainsHealthResponse: z$1.ZodObject<{
|
|
40
|
+
chains: z$1.ZodArray<z$1.ZodObject<{
|
|
41
|
+
chain_id: z$1.ZodNumber;
|
|
42
|
+
block_number: z$1.ZodNumber;
|
|
43
|
+
updated_at: z$1.ZodString;
|
|
44
|
+
}, z$1.core.$strip>>;
|
|
45
|
+
}, z$1.core.$strip>;
|
|
46
|
+
type ChainsHealthResponse = z$1.infer<typeof ChainsHealthResponse>;
|
|
47
|
+
declare const RouterStatusResponse: z$1.ZodObject<{
|
|
48
|
+
status: z$1.ZodEnum<{
|
|
49
|
+
live: "live";
|
|
50
|
+
syncing: "syncing";
|
|
51
|
+
}>;
|
|
52
|
+
}, z$1.core.$strip>;
|
|
53
|
+
type RouterStatusResponse = z$1.infer<typeof RouterStatusResponse>;
|
|
54
|
+
|
|
55
|
+
declare const Oracle: readonly [{
|
|
56
|
+
readonly type: "function";
|
|
57
|
+
readonly name: "price";
|
|
58
|
+
readonly inputs: readonly [];
|
|
59
|
+
readonly outputs: readonly [{
|
|
60
|
+
readonly name: "";
|
|
61
|
+
readonly type: "uint256";
|
|
62
|
+
}];
|
|
63
|
+
readonly stateMutability: "view";
|
|
64
|
+
}];
|
|
65
|
+
declare const ERC4626: readonly [{
|
|
66
|
+
readonly type: "function";
|
|
67
|
+
readonly name: "asset";
|
|
68
|
+
readonly inputs: readonly [];
|
|
69
|
+
readonly outputs: readonly [{
|
|
70
|
+
readonly name: "";
|
|
71
|
+
readonly type: "address";
|
|
72
|
+
}];
|
|
73
|
+
readonly stateMutability: "view";
|
|
74
|
+
}];
|
|
75
|
+
declare const MetaMorphoFactory: readonly [{
|
|
76
|
+
readonly type: "function";
|
|
77
|
+
readonly name: "isMetaMorpho";
|
|
78
|
+
readonly inputs: readonly [{
|
|
79
|
+
readonly name: "target";
|
|
80
|
+
readonly type: "address";
|
|
81
|
+
}];
|
|
82
|
+
readonly outputs: readonly [{
|
|
83
|
+
readonly name: "";
|
|
84
|
+
readonly type: "bool";
|
|
85
|
+
}];
|
|
86
|
+
readonly stateMutability: "view";
|
|
87
|
+
}];
|
|
88
|
+
declare const MetaMorpho: readonly [{
|
|
89
|
+
readonly type: "function";
|
|
90
|
+
readonly name: "withdrawQueue";
|
|
91
|
+
readonly inputs: readonly [{
|
|
92
|
+
readonly name: "index";
|
|
93
|
+
readonly type: "uint256";
|
|
94
|
+
}];
|
|
95
|
+
readonly outputs: readonly [{
|
|
96
|
+
readonly name: "";
|
|
97
|
+
readonly type: "bytes32";
|
|
98
|
+
}];
|
|
99
|
+
readonly stateMutability: "view";
|
|
100
|
+
}, {
|
|
101
|
+
readonly type: "function";
|
|
102
|
+
readonly name: "withdrawQueueLength";
|
|
103
|
+
readonly inputs: readonly [];
|
|
104
|
+
readonly outputs: readonly [{
|
|
105
|
+
readonly name: "";
|
|
106
|
+
readonly type: "uint256";
|
|
107
|
+
}];
|
|
108
|
+
readonly stateMutability: "view";
|
|
109
|
+
}, {
|
|
110
|
+
readonly type: "function";
|
|
111
|
+
readonly name: "maxWithdraw";
|
|
112
|
+
readonly inputs: readonly [{
|
|
113
|
+
readonly name: "owner";
|
|
114
|
+
readonly type: "address";
|
|
115
|
+
}];
|
|
116
|
+
readonly outputs: readonly [{
|
|
117
|
+
readonly name: "";
|
|
118
|
+
readonly type: "uint256";
|
|
119
|
+
}];
|
|
120
|
+
readonly stateMutability: "view";
|
|
121
|
+
}];
|
|
122
|
+
declare const Morpho: readonly [{
|
|
123
|
+
readonly type: "function";
|
|
124
|
+
readonly name: "collateralOf";
|
|
125
|
+
readonly inputs: readonly [{
|
|
126
|
+
readonly name: "";
|
|
127
|
+
readonly type: "address";
|
|
128
|
+
readonly internalType: "address";
|
|
129
|
+
}, {
|
|
130
|
+
readonly name: "";
|
|
131
|
+
readonly type: "bytes32";
|
|
132
|
+
readonly internalType: "bytes32";
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "";
|
|
135
|
+
readonly type: "address";
|
|
136
|
+
readonly internalType: "address";
|
|
137
|
+
}];
|
|
138
|
+
readonly outputs: readonly [{
|
|
139
|
+
readonly name: "";
|
|
140
|
+
readonly type: "uint256";
|
|
141
|
+
readonly internalType: "uint256";
|
|
142
|
+
}];
|
|
143
|
+
readonly stateMutability: "view";
|
|
144
|
+
}, {
|
|
145
|
+
readonly type: "function";
|
|
146
|
+
readonly name: "debtOf";
|
|
147
|
+
readonly inputs: readonly [{
|
|
148
|
+
readonly name: "";
|
|
149
|
+
readonly type: "address";
|
|
150
|
+
readonly internalType: "address";
|
|
151
|
+
}, {
|
|
152
|
+
readonly name: "";
|
|
153
|
+
readonly type: "bytes32";
|
|
154
|
+
readonly internalType: "bytes32";
|
|
155
|
+
}];
|
|
156
|
+
readonly outputs: readonly [{
|
|
157
|
+
readonly name: "";
|
|
158
|
+
readonly type: "uint256";
|
|
159
|
+
readonly internalType: "uint256";
|
|
160
|
+
}];
|
|
161
|
+
readonly stateMutability: "view";
|
|
162
|
+
}, {
|
|
163
|
+
readonly type: "function";
|
|
164
|
+
readonly name: "market";
|
|
165
|
+
readonly inputs: readonly [{
|
|
166
|
+
readonly name: "id";
|
|
167
|
+
readonly type: "bytes32";
|
|
168
|
+
readonly internalType: "Id";
|
|
169
|
+
}];
|
|
170
|
+
readonly outputs: readonly [{
|
|
171
|
+
readonly name: "totalSupplyAssets";
|
|
172
|
+
readonly type: "uint128";
|
|
173
|
+
readonly internalType: "uint128";
|
|
174
|
+
}, {
|
|
175
|
+
readonly name: "totalSupplyShares";
|
|
176
|
+
readonly type: "uint128";
|
|
177
|
+
readonly internalType: "uint128";
|
|
178
|
+
}, {
|
|
179
|
+
readonly name: "totalBorrowAssets";
|
|
180
|
+
readonly type: "uint128";
|
|
181
|
+
readonly internalType: "uint128";
|
|
182
|
+
}, {
|
|
183
|
+
readonly name: "totalBorrowShares";
|
|
184
|
+
readonly type: "uint128";
|
|
185
|
+
readonly internalType: "uint128";
|
|
186
|
+
}, {
|
|
187
|
+
readonly name: "lastUpdate";
|
|
188
|
+
readonly type: "uint128";
|
|
189
|
+
readonly internalType: "uint128";
|
|
190
|
+
}, {
|
|
191
|
+
readonly name: "fee";
|
|
192
|
+
readonly type: "uint128";
|
|
193
|
+
readonly internalType: "uint128";
|
|
194
|
+
}];
|
|
195
|
+
readonly stateMutability: "view";
|
|
196
|
+
}, {
|
|
197
|
+
readonly type: "function";
|
|
198
|
+
readonly name: "position";
|
|
199
|
+
readonly inputs: readonly [{
|
|
200
|
+
readonly name: "id";
|
|
201
|
+
readonly type: "bytes32";
|
|
202
|
+
readonly internalType: "Id";
|
|
203
|
+
}, {
|
|
204
|
+
readonly name: "user";
|
|
205
|
+
readonly type: "address";
|
|
206
|
+
readonly internalType: "address";
|
|
207
|
+
}];
|
|
208
|
+
readonly outputs: readonly [{
|
|
209
|
+
readonly name: "supplyShares";
|
|
210
|
+
readonly type: "uint256";
|
|
211
|
+
readonly internalType: "uint256";
|
|
212
|
+
}, {
|
|
213
|
+
readonly name: "borrowShares";
|
|
214
|
+
readonly type: "uint128";
|
|
215
|
+
readonly internalType: "uint128";
|
|
216
|
+
}, {
|
|
217
|
+
readonly name: "collateral";
|
|
218
|
+
readonly type: "uint128";
|
|
219
|
+
readonly internalType: "uint128";
|
|
220
|
+
}];
|
|
221
|
+
readonly stateMutability: "view";
|
|
222
|
+
}];
|
|
223
|
+
|
|
224
|
+
declare const Abi_ERC4626: typeof ERC4626;
|
|
225
|
+
declare const Abi_MetaMorpho: typeof MetaMorpho;
|
|
226
|
+
declare const Abi_MetaMorphoFactory: typeof MetaMorphoFactory;
|
|
227
|
+
declare const Abi_Morpho: typeof Morpho;
|
|
228
|
+
declare const Abi_Oracle: typeof Oracle;
|
|
229
|
+
declare namespace Abi {
|
|
230
|
+
export { Abi_ERC4626 as ERC4626, Abi_MetaMorpho as MetaMorpho, Abi_MetaMorphoFactory as MetaMorphoFactory, Abi_Morpho as Morpho, Abi_Oracle as Oracle };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
declare enum CallbackType {
|
|
234
|
+
BuyWithEmptyCallback = "buy_with_empty_callback",
|
|
235
|
+
BuyVaultV1Callback = "buy_vault_v1_callback",
|
|
236
|
+
SellERC20Callback = "sell_erc20_callback"
|
|
237
|
+
}
|
|
238
|
+
declare const WhitelistedCallbackAddresses: Record<CallbackType, readonly string[]>;
|
|
239
|
+
declare function decodeBuyVaultV1Callback(data: Hex): Array<{
|
|
240
|
+
vault: Address;
|
|
241
|
+
amount: bigint;
|
|
242
|
+
}>;
|
|
243
|
+
declare function decodeSellERC20Callback(data: Hex): Array<{
|
|
244
|
+
collateral: Address;
|
|
245
|
+
amount: bigint;
|
|
246
|
+
}>;
|
|
247
|
+
declare function encodeBuyVaultV1Callback(parameters: {
|
|
248
|
+
vaults: Address[];
|
|
249
|
+
amounts: bigint[];
|
|
250
|
+
}): Hex;
|
|
251
|
+
declare function encodeSellERC20Callback(parameters: {
|
|
252
|
+
collaterals: Address[];
|
|
253
|
+
amounts: bigint[];
|
|
254
|
+
}): Hex;
|
|
255
|
+
|
|
256
|
+
type Callback_CallbackType = CallbackType;
|
|
257
|
+
declare const Callback_CallbackType: typeof CallbackType;
|
|
258
|
+
declare const Callback_WhitelistedCallbackAddresses: typeof WhitelistedCallbackAddresses;
|
|
259
|
+
declare const Callback_decodeBuyVaultV1Callback: typeof decodeBuyVaultV1Callback;
|
|
260
|
+
declare const Callback_decodeSellERC20Callback: typeof decodeSellERC20Callback;
|
|
261
|
+
declare const Callback_encodeBuyVaultV1Callback: typeof encodeBuyVaultV1Callback;
|
|
262
|
+
declare const Callback_encodeSellERC20Callback: typeof encodeSellERC20Callback;
|
|
263
|
+
declare namespace Callback {
|
|
264
|
+
export { Callback_CallbackType as CallbackType, Callback_WhitelistedCallbackAddresses as WhitelistedCallbackAddresses, Callback_decodeBuyVaultV1Callback as decodeBuyVaultV1Callback, Callback_decodeSellERC20Callback as decodeSellERC20Callback, Callback_encodeBuyVaultV1Callback as encodeBuyVaultV1Callback, Callback_encodeSellERC20Callback as encodeSellERC20Callback };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
type GlobalErrorType<name extends string = "Error"> = Error & {
|
|
268
|
+
name: name;
|
|
12
269
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Base error class inherited by all errors thrown by mempool.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```ts
|
|
275
|
+
* import { Errors } from 'mempool'
|
|
276
|
+
* throw new Errors.BaseError('An error occurred')
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare class BaseError<cause extends Error | undefined = undefined> extends Error {
|
|
280
|
+
details: string;
|
|
281
|
+
shortMessage: string;
|
|
282
|
+
cause: cause;
|
|
283
|
+
name: string;
|
|
284
|
+
constructor(shortMessage: string, options?: {
|
|
285
|
+
cause?: cause | undefined;
|
|
286
|
+
details?: string | undefined;
|
|
287
|
+
metaMessages?: (string | undefined)[] | undefined;
|
|
288
|
+
});
|
|
289
|
+
walk(): Error;
|
|
290
|
+
walk(fn: (err: unknown) => boolean): Error | null;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
type Errors_BaseError<cause extends Error | undefined = undefined> = BaseError<cause>;
|
|
294
|
+
declare const Errors_BaseError: typeof BaseError;
|
|
295
|
+
type Errors_GlobalErrorType<name extends string = "Error"> = GlobalErrorType<name>;
|
|
296
|
+
declare namespace Errors {
|
|
297
|
+
export { Errors_BaseError as BaseError, type Errors_GlobalErrorType as GlobalErrorType };
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** Combines members of an intersection into a readable type. */
|
|
301
|
+
type Compute<type> = {
|
|
302
|
+
[key in keyof type]: type[key];
|
|
303
|
+
} & unknown;
|
|
304
|
+
declare const BrandTypeId: unique symbol;
|
|
305
|
+
type Brand<in out ID extends string | symbol> = {
|
|
306
|
+
readonly [BrandTypeId]: {
|
|
307
|
+
readonly [id in ID]: ID;
|
|
308
|
+
};
|
|
17
309
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
310
|
+
|
|
311
|
+
declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet", "anvil"];
|
|
312
|
+
type ChainName = (typeof chainNames)[number];
|
|
313
|
+
declare const ChainId: {
|
|
314
|
+
ETHEREUM: bigint;
|
|
315
|
+
BASE: bigint;
|
|
316
|
+
"ETHEREUM-VIRTUAL-TESTNET": bigint;
|
|
317
|
+
ANVIL: bigint;
|
|
318
|
+
};
|
|
319
|
+
type Id = (typeof ChainId)[keyof typeof ChainId];
|
|
320
|
+
declare const chainIds: Set<bigint>;
|
|
321
|
+
type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
322
|
+
id: Id;
|
|
323
|
+
name: ChainName;
|
|
324
|
+
whitelistedAssets: Set<Address>;
|
|
325
|
+
morpho: Address;
|
|
326
|
+
morphoBlue: Address;
|
|
327
|
+
mempool: {
|
|
328
|
+
address: Address;
|
|
329
|
+
deploymentBlock: number;
|
|
330
|
+
reindexBuffer: number;
|
|
331
|
+
};
|
|
332
|
+
vaultV1Factory: Record<string, Address>;
|
|
333
|
+
}>;
|
|
334
|
+
declare function getChain(chainId: Id): Chain | undefined;
|
|
335
|
+
declare const getWhitelistedChains: () => Chain[];
|
|
336
|
+
declare const chains: Record<ChainName, Chain>;
|
|
337
|
+
declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(parameters: {
|
|
338
|
+
client: PublicClient;
|
|
339
|
+
contractAddress: Address;
|
|
340
|
+
event?: abiEvent;
|
|
341
|
+
blockNumberGte?: number;
|
|
342
|
+
blockNumberLte?: number;
|
|
343
|
+
order: "asc" | "desc";
|
|
344
|
+
options: {
|
|
345
|
+
maxBatchSize?: number;
|
|
346
|
+
blockWindow?: number;
|
|
347
|
+
};
|
|
348
|
+
}): AsyncGenerator<{
|
|
349
|
+
logs: GetLogsReturnType<abiEvent | undefined>;
|
|
350
|
+
blockNumber: number;
|
|
351
|
+
}, void, void>;
|
|
352
|
+
declare class InvalidBlockRangeError extends BaseError {
|
|
353
|
+
name: string;
|
|
354
|
+
constructor(fromBlock: bigint, toBlock: bigint);
|
|
355
|
+
}
|
|
356
|
+
declare class InvalidBlockWindowError extends BaseError {
|
|
357
|
+
name: string;
|
|
358
|
+
constructor(blockWindow: number);
|
|
359
|
+
}
|
|
360
|
+
declare class InvalidBatchSizeError extends BaseError {
|
|
361
|
+
name: string;
|
|
362
|
+
constructor(maxBatchSize: number);
|
|
363
|
+
}
|
|
364
|
+
declare class MissingBlockNumberError extends BaseError {
|
|
365
|
+
name: string;
|
|
366
|
+
constructor();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
type Chain$1_Chain = Chain;
|
|
370
|
+
declare const Chain$1_ChainId: typeof ChainId;
|
|
371
|
+
type Chain$1_ChainName = ChainName;
|
|
372
|
+
type Chain$1_Id = Id;
|
|
373
|
+
type Chain$1_InvalidBatchSizeError = InvalidBatchSizeError;
|
|
374
|
+
declare const Chain$1_InvalidBatchSizeError: typeof InvalidBatchSizeError;
|
|
375
|
+
type Chain$1_InvalidBlockRangeError = InvalidBlockRangeError;
|
|
376
|
+
declare const Chain$1_InvalidBlockRangeError: typeof InvalidBlockRangeError;
|
|
377
|
+
type Chain$1_InvalidBlockWindowError = InvalidBlockWindowError;
|
|
378
|
+
declare const Chain$1_InvalidBlockWindowError: typeof InvalidBlockWindowError;
|
|
379
|
+
type Chain$1_MissingBlockNumberError = MissingBlockNumberError;
|
|
380
|
+
declare const Chain$1_MissingBlockNumberError: typeof MissingBlockNumberError;
|
|
381
|
+
declare const Chain$1_chainIds: typeof chainIds;
|
|
382
|
+
declare const Chain$1_chainNames: typeof chainNames;
|
|
383
|
+
declare const Chain$1_chains: typeof chains;
|
|
384
|
+
declare const Chain$1_getChain: typeof getChain;
|
|
385
|
+
declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
|
|
386
|
+
declare const Chain$1_streamLogs: typeof streamLogs;
|
|
387
|
+
declare namespace Chain$1 {
|
|
388
|
+
export { type Chain$1_Chain as Chain, Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, type Chain$1_Id as Id, Chain$1_InvalidBatchSizeError as InvalidBatchSizeError, Chain$1_InvalidBlockRangeError as InvalidBlockRangeError, Chain$1_InvalidBlockWindowError as InvalidBlockWindowError, Chain$1_MissingBlockNumberError as MissingBlockNumberError, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains, Chain$1_streamLogs as streamLogs };
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
type LLTV = bigint & Brand<"LLTV">;
|
|
392
|
+
declare const Options: readonly [0.385, 0.5, 0.625, 0.77, 0.86, 0.915, 0.945, 0.965, 0.98];
|
|
393
|
+
type Options = (typeof Options)[number];
|
|
394
|
+
/**
|
|
395
|
+
* Convert a LLTV option or a scaled LLTV to a LLTV.
|
|
396
|
+
* @param lltv - The LLTV option or the scaled LLTV.
|
|
397
|
+
* @returns The LLTV.
|
|
398
|
+
*/
|
|
399
|
+
declare function from$7(lltv: Options | bigint): LLTV;
|
|
400
|
+
declare namespace from$7 {
|
|
401
|
+
type ErrorType = InvalidOptionError$1 | InvalidLLTVError;
|
|
402
|
+
}
|
|
403
|
+
declare class InvalidOptionError$1 extends BaseError {
|
|
404
|
+
readonly name = "LLTV.InvalidOptionError";
|
|
405
|
+
constructor(input: number);
|
|
406
|
+
}
|
|
407
|
+
declare class InvalidLLTVError extends BaseError {
|
|
408
|
+
readonly name = "LLTV.InvalidLLTVError";
|
|
409
|
+
constructor(input: bigint);
|
|
410
|
+
}
|
|
411
|
+
declare const LLTVSchema: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
|
|
412
|
+
|
|
413
|
+
type LLTV$1_InvalidLLTVError = InvalidLLTVError;
|
|
414
|
+
declare const LLTV$1_InvalidLLTVError: typeof InvalidLLTVError;
|
|
415
|
+
type LLTV$1_LLTV = LLTV;
|
|
416
|
+
declare const LLTV$1_LLTVSchema: typeof LLTVSchema;
|
|
417
|
+
type LLTV$1_Options = Options;
|
|
418
|
+
declare namespace LLTV$1 {
|
|
419
|
+
export { LLTV$1_InvalidLLTVError as InvalidLLTVError, InvalidOptionError$1 as InvalidOptionError, type LLTV$1_LLTV as LLTV, LLTV$1_LLTVSchema as LLTVSchema, type LLTV$1_Options as Options, from$7 as from };
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
type Collateral = {
|
|
423
|
+
/** Asset being used as collateral. */
|
|
424
|
+
asset: Address;
|
|
425
|
+
/** Liquidation Loan-to-Value of the collateral. */
|
|
426
|
+
lltv: LLTV;
|
|
427
|
+
/** Oracle contract used to price the collateral. */
|
|
428
|
+
oracle: Address;
|
|
429
|
+
};
|
|
430
|
+
declare const CollateralSchema: z.ZodObject<{
|
|
431
|
+
asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
432
|
+
oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
433
|
+
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
|
|
434
|
+
}, z.core.$strip>;
|
|
435
|
+
declare const CollateralsSchema: z.ZodArray<z.ZodObject<{
|
|
436
|
+
asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
437
|
+
oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
438
|
+
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
|
|
439
|
+
}, z.core.$strip>>;
|
|
440
|
+
declare const from$6: (parameters: from$6.Parameters) => from$6.ReturnType;
|
|
441
|
+
declare namespace from$6 {
|
|
442
|
+
type Parameters = {
|
|
443
|
+
asset: Address;
|
|
444
|
+
lltv: Options | bigint;
|
|
445
|
+
oracle: Address;
|
|
446
|
+
};
|
|
447
|
+
type ReturnType = Collateral;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
type Collateral$1_Collateral = Collateral;
|
|
451
|
+
declare const Collateral$1_CollateralSchema: typeof CollateralSchema;
|
|
452
|
+
declare const Collateral$1_CollateralsSchema: typeof CollateralsSchema;
|
|
453
|
+
declare namespace Collateral$1 {
|
|
454
|
+
export { type Collateral$1_Collateral as Collateral, Collateral$1_CollateralSchema as CollateralSchema, Collateral$1_CollateralsSchema as CollateralsSchema, from$6 as from };
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
type Cursor = {
|
|
458
|
+
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
459
|
+
dir: "asc" | "desc";
|
|
460
|
+
rate?: string;
|
|
461
|
+
maturity?: number;
|
|
462
|
+
expiry?: number;
|
|
463
|
+
assets?: string;
|
|
464
|
+
hash: string;
|
|
465
|
+
page?: number;
|
|
466
|
+
};
|
|
467
|
+
declare function validate(cursor: unknown): cursor is Cursor;
|
|
468
|
+
declare function encode$1(c: Cursor): string;
|
|
469
|
+
declare function decode$1(token?: string): Cursor | null;
|
|
470
|
+
|
|
471
|
+
type Cursor$1_Cursor = Cursor;
|
|
472
|
+
declare const Cursor$1_validate: typeof validate;
|
|
473
|
+
declare namespace Cursor$1 {
|
|
474
|
+
export { type Cursor$1_Cursor as Cursor, decode$1 as decode, encode$1 as encode, Cursor$1_validate as validate };
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** The snake case representation of a type with bigint values stringified. */
|
|
478
|
+
type Snake<T> = SnakeKeys<StringifiedBigint<T>>;
|
|
479
|
+
/** Stringifies bigint values to strings and preserves branded primitives. */
|
|
480
|
+
type StringifiedBigint<T> = [
|
|
481
|
+
T
|
|
482
|
+
] extends [bigint] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? {
|
|
483
|
+
[K in keyof T]: StringifiedBigint<T[K]>;
|
|
484
|
+
} : T;
|
|
485
|
+
/** Key remapping that also preserves branded primitives. */
|
|
486
|
+
type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? {
|
|
487
|
+
[K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]>;
|
|
488
|
+
} : T;
|
|
489
|
+
type ToSnakeCase<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${ToSnakeCase<Tail>}` : `${Lowercase<Head>}_${ToSnakeCase<Uncapitalize<Tail>>}` : S;
|
|
490
|
+
/**
|
|
491
|
+
* Formats object keys to snake case.
|
|
492
|
+
* Preserves ethereum addresses as is.
|
|
493
|
+
* Converts ethereum addresses to checksummed if used as values.
|
|
494
|
+
* Stringifies bigint values to strings.
|
|
495
|
+
*/
|
|
496
|
+
declare function toSnakeCase$1<T>(obj: T): Snake<T>;
|
|
497
|
+
/**
|
|
498
|
+
* Formats a snake case object to its camel case type.
|
|
499
|
+
* Preserves ethereum addresses as is.
|
|
500
|
+
* Converts checksummed ethereum addresses to lowercase if used as values.
|
|
501
|
+
* @warning Does not unstringify bigint values.
|
|
502
|
+
*/
|
|
503
|
+
declare function fromSnakeCase$2<T>(obj: Snake<T>): T;
|
|
504
|
+
|
|
505
|
+
type Format_Snake<T> = Snake<T>;
|
|
506
|
+
declare namespace Format {
|
|
507
|
+
export { type Format_Snake as Snake, fromSnakeCase$2 as fromSnakeCase, toSnakeCase$1 as toSnakeCase };
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Maturity is a number that represents a date in seconds.
|
|
512
|
+
*/
|
|
513
|
+
type Maturity = number & Brand<"Maturity">;
|
|
514
|
+
declare const MaturitySchema: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
|
|
515
|
+
declare const MaturityOptions: {
|
|
516
|
+
readonly end_of_week: () => Maturity;
|
|
517
|
+
readonly end_of_next_week: () => Maturity;
|
|
518
|
+
readonly end_of_month: () => Maturity;
|
|
519
|
+
readonly end_of_next_month: () => Maturity;
|
|
520
|
+
readonly end_of_quarter: () => Maturity;
|
|
521
|
+
readonly end_of_next_quarter: () => Maturity;
|
|
24
522
|
};
|
|
25
|
-
|
|
523
|
+
type MaturityOptions = keyof typeof MaturityOptions;
|
|
524
|
+
/**
|
|
525
|
+
* Creates a maturity from a timestamp in seconds or a maturity option.
|
|
526
|
+
* @throws {InvalidFormatError} If the maturity is in milliseconds.
|
|
527
|
+
* @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
|
|
528
|
+
* @throws {InvalidOptionError} If the maturity is not a valid option.
|
|
529
|
+
*/
|
|
530
|
+
declare function from$5(ts: from$5.Parameters): Maturity;
|
|
531
|
+
declare namespace from$5 {
|
|
532
|
+
type Parameters = number | MaturityOptions;
|
|
533
|
+
type ErrorType = InvalidFormatError | InvalidDateError | InvalidOptionError;
|
|
534
|
+
}
|
|
535
|
+
declare class InvalidFormatError extends BaseError {
|
|
536
|
+
readonly name = "Maturity.InvalidFormatError";
|
|
537
|
+
constructor();
|
|
538
|
+
}
|
|
539
|
+
declare class InvalidDateError extends BaseError {
|
|
540
|
+
readonly name = "Maturity.InvalidDateError";
|
|
541
|
+
constructor(input: number);
|
|
542
|
+
}
|
|
543
|
+
declare class InvalidOptionError extends BaseError {
|
|
544
|
+
readonly name = "Maturity.InvalidOptionError";
|
|
545
|
+
constructor(input: string);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
type Maturity$1_InvalidDateError = InvalidDateError;
|
|
549
|
+
declare const Maturity$1_InvalidDateError: typeof InvalidDateError;
|
|
550
|
+
type Maturity$1_InvalidFormatError = InvalidFormatError;
|
|
551
|
+
declare const Maturity$1_InvalidFormatError: typeof InvalidFormatError;
|
|
552
|
+
type Maturity$1_InvalidOptionError = InvalidOptionError;
|
|
553
|
+
declare const Maturity$1_InvalidOptionError: typeof InvalidOptionError;
|
|
554
|
+
type Maturity$1_Maturity = Maturity;
|
|
555
|
+
type Maturity$1_MaturityOptions = MaturityOptions;
|
|
556
|
+
declare const Maturity$1_MaturitySchema: typeof MaturitySchema;
|
|
557
|
+
declare namespace Maturity$1 {
|
|
558
|
+
export { Maturity$1_InvalidDateError as InvalidDateError, Maturity$1_InvalidFormatError as InvalidFormatError, Maturity$1_InvalidOptionError as InvalidOptionError, type Maturity$1_Maturity as Maturity, type Maturity$1_MaturityOptions as MaturityOptions, Maturity$1_MaturitySchema as MaturitySchema, from$5 as from };
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
type Offer = {
|
|
562
|
+
/** The address that made the offer. */
|
|
563
|
+
readonly offering: Address;
|
|
564
|
+
/** The amount of assets offered. */
|
|
565
|
+
readonly assets: bigint;
|
|
566
|
+
/** The interest rate (with 18 decimals). */
|
|
567
|
+
readonly rate: bigint;
|
|
568
|
+
/** The date at which all interests will be paid. */
|
|
569
|
+
readonly maturity: Maturity;
|
|
570
|
+
/** The date at which the offer will expire. */
|
|
571
|
+
readonly expiry: number;
|
|
572
|
+
/** The date at which the offer will start. */
|
|
573
|
+
readonly start: number;
|
|
574
|
+
/** The nonce. Used for OCO (One-Cancelled-Other) mechanism. */
|
|
575
|
+
readonly nonce: bigint;
|
|
576
|
+
/** The side of the offer. `true` for buy, `false` for sell. */
|
|
577
|
+
readonly buy: boolean;
|
|
578
|
+
/** The chain id where the liquidity for this offer is located. */
|
|
579
|
+
readonly chainId: bigint;
|
|
580
|
+
/** The token that is being borrowed. */
|
|
581
|
+
readonly loanToken: Address;
|
|
582
|
+
/** The exact set of collaterals required to borrow the loan token. */
|
|
583
|
+
readonly collaterals: readonly Collateral[];
|
|
584
|
+
/** The optional callback data to retrieve the maker funds. */
|
|
585
|
+
readonly callback: {
|
|
586
|
+
readonly address: Address;
|
|
587
|
+
readonly data: Hex;
|
|
588
|
+
readonly gasLimit: bigint;
|
|
589
|
+
};
|
|
590
|
+
/** The amount of assets consumed from the offer. */
|
|
591
|
+
consumed: bigint;
|
|
592
|
+
/** The hash of the offer. */
|
|
593
|
+
readonly hash: Hex;
|
|
594
|
+
/** The block number at which the offer was created. */
|
|
595
|
+
readonly blockNumber: number;
|
|
596
|
+
/** The signature of the offer. */
|
|
597
|
+
signature?: Hex;
|
|
598
|
+
};
|
|
599
|
+
declare const OfferHashSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
600
|
+
declare const OfferSchema: (parameters?: {
|
|
26
601
|
omitHash?: boolean;
|
|
27
602
|
}) => z.ZodObject<{
|
|
28
603
|
offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
29
604
|
assets: z.ZodBigInt;
|
|
30
605
|
rate: z.ZodBigInt;
|
|
31
|
-
maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<
|
|
606
|
+
maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
|
|
32
607
|
expiry: z.ZodNumber;
|
|
33
608
|
start: z.ZodNumber;
|
|
34
609
|
nonce: z.ZodBigInt;
|
|
@@ -38,28 +613,150 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
38
613
|
collaterals: z.ZodArray<z.ZodObject<{
|
|
39
614
|
asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
40
615
|
oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
41
|
-
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<
|
|
616
|
+
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
|
|
42
617
|
}, z.core.$strip>>;
|
|
43
618
|
callback: z.ZodObject<{
|
|
44
619
|
address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
45
620
|
data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
46
621
|
gasLimit: z.ZodBigInt;
|
|
47
622
|
}, z.core.$strip>;
|
|
48
|
-
signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
|
|
49
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
50
623
|
consumed: z.ZodBigInt;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
callback_not_supported: "callback_not_supported";
|
|
54
|
-
callback_error: "callback_error";
|
|
55
|
-
unverified: "unverified";
|
|
56
|
-
}>;
|
|
57
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
58
|
-
issue: z.ZodString;
|
|
59
|
-
}, z.core.$strip>>;
|
|
624
|
+
blockNumber: z.ZodNumber;
|
|
625
|
+
signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
|
|
60
626
|
}, z.core.$strip>;
|
|
61
627
|
/**
|
|
62
|
-
*
|
|
628
|
+
* Creates an offer from a plain object.
|
|
629
|
+
* @throws {InvalidOfferError} If the offer is invalid.
|
|
630
|
+
* @param input - The offer to create.
|
|
631
|
+
* @returns The created offer with its hash.
|
|
632
|
+
*/
|
|
633
|
+
declare function from$4(input: Omit<Offer, "hash">): Offer;
|
|
634
|
+
declare namespace from$4 {
|
|
635
|
+
type ErrorType = InvalidOfferError;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Creates an offer from a snake case object.
|
|
639
|
+
* @throws {InvalidOfferError} If the offer is invalid.
|
|
640
|
+
* @param input - The offer to create.
|
|
641
|
+
* @returns The created offer with its hash.
|
|
642
|
+
*/
|
|
643
|
+
declare function fromSnakeCase$1(input: Snake<Omit<Offer, "hash">>): Offer;
|
|
644
|
+
/**
|
|
645
|
+
* Converts an offer to a snake case object.
|
|
646
|
+
* @param offer - The offer to convert.
|
|
647
|
+
* @returns The converted offer.
|
|
648
|
+
*/
|
|
649
|
+
declare function toSnakeCase(offer: Offer): Snake<Offer>;
|
|
650
|
+
/**
|
|
651
|
+
* Generates a random Offer.
|
|
652
|
+
* The returned Offer contains randomly generated values for most fields, such as assets, rate, nonce, and buy flag.
|
|
653
|
+
* Some fields use fixed or deterministic values (e.g., chainId, collaterals, callback).
|
|
654
|
+
* @warning The generated Offer should not be used for production usage.
|
|
655
|
+
* @returns {Offer} A randomly generated Offer object.
|
|
656
|
+
*/
|
|
657
|
+
declare function random$1(): Offer;
|
|
658
|
+
/**
|
|
659
|
+
* Creates an EIP-712 domain object.
|
|
660
|
+
* @param chainId - The chain ID.
|
|
661
|
+
* @returns The EIP-712 domain object.
|
|
662
|
+
*/
|
|
663
|
+
declare const domain: (chainId: bigint) => {
|
|
664
|
+
chainId: bigint;
|
|
665
|
+
verifyingContract: "0x0000000000000000000000000000000000000000";
|
|
666
|
+
};
|
|
667
|
+
/**
|
|
668
|
+
* The EIP-712 types for the offer.
|
|
669
|
+
* @warning The ordering of the types should NEVER be changed. The offer hash is computed based on the order of the types.
|
|
670
|
+
* @returns The EIP-712 types.
|
|
671
|
+
*/
|
|
672
|
+
declare const types: {
|
|
673
|
+
readonly EIP712Domain: readonly [{
|
|
674
|
+
readonly name: "chainId";
|
|
675
|
+
readonly type: "uint256";
|
|
676
|
+
}, {
|
|
677
|
+
readonly name: "verifyingContract";
|
|
678
|
+
readonly type: "address";
|
|
679
|
+
}];
|
|
680
|
+
readonly Offer: readonly [{
|
|
681
|
+
readonly name: "offering";
|
|
682
|
+
readonly type: "address";
|
|
683
|
+
}, {
|
|
684
|
+
readonly name: "assets";
|
|
685
|
+
readonly type: "uint256";
|
|
686
|
+
}, {
|
|
687
|
+
readonly name: "rate";
|
|
688
|
+
readonly type: "uint256";
|
|
689
|
+
}, {
|
|
690
|
+
readonly name: "maturity";
|
|
691
|
+
readonly type: "uint256";
|
|
692
|
+
}, {
|
|
693
|
+
readonly name: "expiry";
|
|
694
|
+
readonly type: "uint256";
|
|
695
|
+
}, {
|
|
696
|
+
readonly name: "nonce";
|
|
697
|
+
readonly type: "uint256";
|
|
698
|
+
}, {
|
|
699
|
+
readonly name: "buy";
|
|
700
|
+
readonly type: "bool";
|
|
701
|
+
}, {
|
|
702
|
+
readonly name: "loanToken";
|
|
703
|
+
readonly type: "address";
|
|
704
|
+
}, {
|
|
705
|
+
readonly name: "collaterals";
|
|
706
|
+
readonly type: "Collateral[]";
|
|
707
|
+
}, {
|
|
708
|
+
readonly name: "callback";
|
|
709
|
+
readonly type: "Callback";
|
|
710
|
+
}];
|
|
711
|
+
readonly Collateral: readonly [{
|
|
712
|
+
readonly name: "asset";
|
|
713
|
+
readonly type: "address";
|
|
714
|
+
}, {
|
|
715
|
+
readonly name: "oracle";
|
|
716
|
+
readonly type: "address";
|
|
717
|
+
}, {
|
|
718
|
+
readonly name: "lltv";
|
|
719
|
+
readonly type: "uint256";
|
|
720
|
+
}];
|
|
721
|
+
readonly Callback: readonly [{
|
|
722
|
+
readonly name: "address";
|
|
723
|
+
readonly type: "address";
|
|
724
|
+
}, {
|
|
725
|
+
readonly name: "data";
|
|
726
|
+
readonly type: "bytes";
|
|
727
|
+
}, {
|
|
728
|
+
readonly name: "gasLimit";
|
|
729
|
+
readonly type: "uint256";
|
|
730
|
+
}];
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* Signs an offer.
|
|
734
|
+
* @throws {Error} If the wallet account is not set.
|
|
735
|
+
* @param offer - The offer to sign.
|
|
736
|
+
* @param wallet - The wallet to sign the offer with.
|
|
737
|
+
* @returns The signed offer.
|
|
738
|
+
*/
|
|
739
|
+
declare function sign(offer: Offer, wallet: WalletClient): Promise<Hex>;
|
|
740
|
+
declare function hash(offer: Omit<Offer, "hash">): Hex;
|
|
741
|
+
/**
|
|
742
|
+
* Calculates the obligation id for an offer based on the smart contract's Obligation struct.
|
|
743
|
+
* The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals (sorted by token address), maturity)).
|
|
744
|
+
* @param offer - The offer to calculate the obligation id for.
|
|
745
|
+
* @returns The obligation id as a 32-byte hex string.
|
|
746
|
+
*/
|
|
747
|
+
declare function obligationId(offer: Offer): Hex;
|
|
748
|
+
declare function encode(offer: Offer): `0x${string}`;
|
|
749
|
+
declare function decode(data: Hex, blockNumber: number | bigint): Offer;
|
|
750
|
+
type OfferConsumed = {
|
|
751
|
+
id: string;
|
|
752
|
+
chainId: bigint;
|
|
753
|
+
offering: Address;
|
|
754
|
+
nonce: bigint;
|
|
755
|
+
amount: bigint;
|
|
756
|
+
blockNumber: number;
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* ABI for the Consumed event emitted by the Obligation contract.
|
|
63
760
|
*/
|
|
64
761
|
declare const consumedEvent: {
|
|
65
762
|
readonly type: "event";
|
|
@@ -82,33 +779,6 @@ declare const consumedEvent: {
|
|
|
82
779
|
}];
|
|
83
780
|
readonly anonymous: false;
|
|
84
781
|
};
|
|
85
|
-
/**
|
|
86
|
-
* Creates a router offer from a plain object.
|
|
87
|
-
* @throws {InvalidRouterOfferError} If the router offer is invalid.
|
|
88
|
-
* @param input - The router offer to create.
|
|
89
|
-
* @returns The created router offer with its hash.
|
|
90
|
-
*/
|
|
91
|
-
declare function from(input: Omit<RouterOffer, "hash">): RouterOffer;
|
|
92
|
-
declare namespace from {
|
|
93
|
-
type ErrorType = InvalidRouterOfferError;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Creates a router offer from a snake case object.
|
|
97
|
-
* @throws {InvalidRouterOfferError} If the router offer is invalid.
|
|
98
|
-
* @param input - The router offer to create.
|
|
99
|
-
* @returns The created router offer with its hash.
|
|
100
|
-
*/
|
|
101
|
-
declare function fromSnakeCase(input: Format.Snake<Omit<RouterOffer, "hash">>): RouterOffer;
|
|
102
|
-
declare namespace fromSnakeCase {
|
|
103
|
-
type ErrorType = InvalidRouterOfferError;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Converts a router offer to a snake case object.
|
|
107
|
-
* @param offer - The router offer to convert.
|
|
108
|
-
* @returns The converted router offer.
|
|
109
|
-
*/
|
|
110
|
-
declare function toSnakeCase(offer: RouterOffer): Format.Snake<RouterOffer>;
|
|
111
|
-
declare function random(): RouterOffer;
|
|
112
782
|
declare function fromConsumedLog(parameters: {
|
|
113
783
|
blockNumber: bigint;
|
|
114
784
|
logIndex: number;
|
|
@@ -118,357 +788,493 @@ declare function fromConsumedLog(parameters: {
|
|
|
118
788
|
nonce: bigint;
|
|
119
789
|
amount: bigint;
|
|
120
790
|
}): OfferConsumed;
|
|
121
|
-
declare class
|
|
122
|
-
readonly name = "
|
|
123
|
-
constructor(error: ZodError | Error);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
type
|
|
131
|
-
declare const
|
|
132
|
-
type
|
|
133
|
-
declare const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
declare const
|
|
137
|
-
declare const
|
|
138
|
-
declare const
|
|
139
|
-
declare const
|
|
140
|
-
declare
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
791
|
+
declare class InvalidOfferError extends BaseError<z.ZodError | Error> {
|
|
792
|
+
readonly name = "Offer.InvalidOfferError";
|
|
793
|
+
constructor(error: z.ZodError | Error);
|
|
794
|
+
}
|
|
795
|
+
declare class AccountNotSetError extends BaseError {
|
|
796
|
+
readonly name = "Offer.AccountNotSetError";
|
|
797
|
+
constructor();
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
type Offer$1_AccountNotSetError = AccountNotSetError;
|
|
801
|
+
declare const Offer$1_AccountNotSetError: typeof AccountNotSetError;
|
|
802
|
+
type Offer$1_InvalidOfferError = InvalidOfferError;
|
|
803
|
+
declare const Offer$1_InvalidOfferError: typeof InvalidOfferError;
|
|
804
|
+
type Offer$1_Offer = Offer;
|
|
805
|
+
type Offer$1_OfferConsumed = OfferConsumed;
|
|
806
|
+
declare const Offer$1_OfferHashSchema: typeof OfferHashSchema;
|
|
807
|
+
declare const Offer$1_OfferSchema: typeof OfferSchema;
|
|
808
|
+
declare const Offer$1_consumedEvent: typeof consumedEvent;
|
|
809
|
+
declare const Offer$1_decode: typeof decode;
|
|
810
|
+
declare const Offer$1_domain: typeof domain;
|
|
811
|
+
declare const Offer$1_encode: typeof encode;
|
|
812
|
+
declare const Offer$1_fromConsumedLog: typeof fromConsumedLog;
|
|
813
|
+
declare const Offer$1_hash: typeof hash;
|
|
814
|
+
declare const Offer$1_obligationId: typeof obligationId;
|
|
815
|
+
declare const Offer$1_sign: typeof sign;
|
|
816
|
+
declare const Offer$1_toSnakeCase: typeof toSnakeCase;
|
|
817
|
+
declare const Offer$1_types: typeof types;
|
|
818
|
+
declare namespace Offer$1 {
|
|
819
|
+
export { Offer$1_AccountNotSetError as AccountNotSetError, Offer$1_InvalidOfferError as InvalidOfferError, type Offer$1_Offer as Offer, type Offer$1_OfferConsumed as OfferConsumed, Offer$1_OfferHashSchema as OfferHashSchema, Offer$1_OfferSchema as OfferSchema, Offer$1_consumedEvent as consumedEvent, Offer$1_decode as decode, Offer$1_domain as domain, Offer$1_encode as encode, from$4 as from, Offer$1_fromConsumedLog as fromConsumedLog, fromSnakeCase$1 as fromSnakeCase, Offer$1_hash as hash, Offer$1_obligationId as obligationId, random$1 as random, Offer$1_sign as sign, Offer$1_toSnakeCase as toSnakeCase, Offer$1_types as types };
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Represents a liquidity pool with a unique ID and amount.
|
|
824
|
+
*/
|
|
825
|
+
type LiquidityPool = {
|
|
826
|
+
id: string;
|
|
827
|
+
amount: bigint;
|
|
149
828
|
};
|
|
829
|
+
/**
|
|
830
|
+
* Represents a hierarchical relationship between two liquidity pools.
|
|
831
|
+
*/
|
|
832
|
+
type LiquidityLink = {
|
|
833
|
+
parentPoolId: string;
|
|
834
|
+
childPoolId: string;
|
|
835
|
+
priority: number;
|
|
836
|
+
};
|
|
837
|
+
/**
|
|
838
|
+
* Represents the connection between an offer and its liquidity pools.
|
|
839
|
+
*/
|
|
840
|
+
type OfferLiquidityPool = {
|
|
841
|
+
offerHash: Offer["hash"];
|
|
842
|
+
poolId: string;
|
|
843
|
+
/**
|
|
844
|
+
* The available capacity/liquidity from this pool for this offer.
|
|
845
|
+
* Meaning varies by pool type:
|
|
846
|
+
* - BuyWithEmptyCallback: Matches allowance amount from pool bellow
|
|
847
|
+
* - SellERC20Callback: Sell Callback/Predeposited -> Maximum debt capacity calculated from collateral (collateralAmount * oraclePrice * lltv)
|
|
848
|
+
* - SellERC20Callback: Existing debt as negative value (reduces available capacity)
|
|
849
|
+
*/
|
|
850
|
+
amount: bigint;
|
|
851
|
+
};
|
|
852
|
+
/**
|
|
853
|
+
* Calculate maximum debt capacity from collateral amount.
|
|
854
|
+
* @param amount - Collateral amount
|
|
855
|
+
* @param oraclePrice - Oracle price (scaled to 36 decimals)
|
|
856
|
+
* @param lltv - Loan-to-value ratio (scaled to 18 decimals)
|
|
857
|
+
* @returns Maximum debt capacity
|
|
858
|
+
*/
|
|
859
|
+
declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
|
|
860
|
+
/**
|
|
861
|
+
* Generate pool ID for balance pools.
|
|
862
|
+
*/
|
|
863
|
+
declare function generateBalancePoolId(parameters: {
|
|
864
|
+
user: Address;
|
|
865
|
+
chainId: bigint;
|
|
866
|
+
token: Address;
|
|
867
|
+
}): string;
|
|
868
|
+
/**
|
|
869
|
+
* Generate pool ID for allowance pools.
|
|
870
|
+
*/
|
|
871
|
+
declare function generateAllowancePoolId(parameters: {
|
|
872
|
+
user: Address;
|
|
873
|
+
chainId: bigint;
|
|
874
|
+
token: Address;
|
|
875
|
+
}): string;
|
|
876
|
+
/**
|
|
877
|
+
* Generate pool ID for sell ERC20 callback pools.
|
|
878
|
+
* Each offer has its own callback pool to prevent liquidity conflicts.
|
|
879
|
+
*/
|
|
880
|
+
declare function generateSellERC20CallbackPoolId(parameters: {
|
|
881
|
+
user: Address;
|
|
882
|
+
chainId: bigint;
|
|
883
|
+
obligationId: Hex;
|
|
884
|
+
token: Address;
|
|
885
|
+
offerHash: Hex;
|
|
886
|
+
}): string;
|
|
887
|
+
/**
|
|
888
|
+
* Generate pool ID for obligation collateral pools.
|
|
889
|
+
* Obligation collateral pools represent collateral already deposited in the obligation.
|
|
890
|
+
* These pools are shared across all offers with the same obligation.
|
|
891
|
+
*/
|
|
892
|
+
declare function generateObligationCollateralPoolId(parameters: {
|
|
893
|
+
user: Address;
|
|
894
|
+
chainId: bigint;
|
|
895
|
+
obligationId: Hex;
|
|
896
|
+
token: Address;
|
|
897
|
+
}): string;
|
|
898
|
+
/**
|
|
899
|
+
* Generate pool ID for buy vault callback pools.
|
|
900
|
+
*/
|
|
901
|
+
declare function generateBuyVaultCallbackPoolId(parameters: {
|
|
902
|
+
user: Address;
|
|
903
|
+
chainId: bigint;
|
|
904
|
+
vault: Address;
|
|
905
|
+
offerHash: Hex;
|
|
906
|
+
}): string;
|
|
907
|
+
/**
|
|
908
|
+
* Generate pool ID for debt pools.
|
|
909
|
+
*/
|
|
910
|
+
declare function generateDebtPoolId(parameters: {
|
|
911
|
+
user: Address;
|
|
912
|
+
chainId: bigint;
|
|
913
|
+
obligationId: Hex;
|
|
914
|
+
}): string;
|
|
915
|
+
/**
|
|
916
|
+
* Generate pool ID for user position in a vault.
|
|
917
|
+
*/
|
|
918
|
+
declare function generateUserVaultPositionPoolId(parameters: {
|
|
919
|
+
user: Address;
|
|
920
|
+
chainId: bigint;
|
|
921
|
+
vault: Address;
|
|
922
|
+
}): string;
|
|
923
|
+
/**
|
|
924
|
+
* Generate pool ID for vault position in a market.
|
|
925
|
+
*/
|
|
926
|
+
declare function generateVaultPositionPoolId(parameters: {
|
|
927
|
+
vault: Address;
|
|
928
|
+
chainId: bigint;
|
|
929
|
+
marketId: string;
|
|
930
|
+
}): string;
|
|
931
|
+
/**
|
|
932
|
+
* Generate pool ID for market total liquidity.
|
|
933
|
+
*/
|
|
934
|
+
declare function generateMarketLiquidityPoolId(parameters: {
|
|
935
|
+
chainId: bigint;
|
|
936
|
+
marketId: string;
|
|
937
|
+
}): string;
|
|
150
938
|
|
|
151
|
-
type
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
minExpiry?: number;
|
|
178
|
-
/** Maximum expiry timestamp (Unix timestamp in seconds) */
|
|
179
|
-
maxExpiry?: number;
|
|
180
|
-
/** Filter by multiple collateral assets (comma-separated) */
|
|
181
|
-
collateralAssets?: string[];
|
|
182
|
-
/** Filter by multiple rate oracles (comma-separated) */
|
|
183
|
-
collateralOracles?: string[];
|
|
184
|
-
/** Filter by collateral combinations */
|
|
185
|
-
collateralTuple?: Array<{
|
|
186
|
-
asset: string;
|
|
187
|
-
oracle?: string;
|
|
188
|
-
lltv?: LLTV.LLTV;
|
|
189
|
-
}>;
|
|
190
|
-
/** Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
|
|
191
|
-
minLltv?: LLTV.LLTV;
|
|
192
|
-
/** Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
|
|
193
|
-
maxLltv?: LLTV.LLTV;
|
|
194
|
-
/** Field to sort results by */
|
|
195
|
-
sortBy?: "rate" | "maturity" | "expiry" | "amount";
|
|
196
|
-
/** Sort direction: asc (ascending) or desc (descending, default) */
|
|
197
|
-
sortOrder?: "asc" | "desc";
|
|
198
|
-
/** Pagination cursor in base64url-encoded format */
|
|
199
|
-
cursor?: string;
|
|
200
|
-
/** Maximum number of offers to return. Defaults to 20. Maximum is 100. */
|
|
201
|
-
limit?: number;
|
|
939
|
+
type Liquidity_LiquidityLink = LiquidityLink;
|
|
940
|
+
type Liquidity_LiquidityPool = LiquidityPool;
|
|
941
|
+
type Liquidity_OfferLiquidityPool = OfferLiquidityPool;
|
|
942
|
+
declare const Liquidity_calculateMaxDebt: typeof calculateMaxDebt;
|
|
943
|
+
declare const Liquidity_generateAllowancePoolId: typeof generateAllowancePoolId;
|
|
944
|
+
declare const Liquidity_generateBalancePoolId: typeof generateBalancePoolId;
|
|
945
|
+
declare const Liquidity_generateBuyVaultCallbackPoolId: typeof generateBuyVaultCallbackPoolId;
|
|
946
|
+
declare const Liquidity_generateDebtPoolId: typeof generateDebtPoolId;
|
|
947
|
+
declare const Liquidity_generateMarketLiquidityPoolId: typeof generateMarketLiquidityPoolId;
|
|
948
|
+
declare const Liquidity_generateObligationCollateralPoolId: typeof generateObligationCollateralPoolId;
|
|
949
|
+
declare const Liquidity_generateSellERC20CallbackPoolId: typeof generateSellERC20CallbackPoolId;
|
|
950
|
+
declare const Liquidity_generateUserVaultPositionPoolId: typeof generateUserVaultPositionPoolId;
|
|
951
|
+
declare const Liquidity_generateVaultPositionPoolId: typeof generateVaultPositionPoolId;
|
|
952
|
+
declare namespace Liquidity {
|
|
953
|
+
export { type Liquidity_LiquidityLink as LiquidityLink, type Liquidity_LiquidityPool as LiquidityPool, type Liquidity_OfferLiquidityPool as OfferLiquidityPool, Liquidity_calculateMaxDebt as calculateMaxDebt, Liquidity_generateAllowancePoolId as generateAllowancePoolId, Liquidity_generateBalancePoolId as generateBalancePoolId, Liquidity_generateBuyVaultCallbackPoolId as generateBuyVaultCallbackPoolId, Liquidity_generateDebtPoolId as generateDebtPoolId, Liquidity_generateMarketLiquidityPoolId as generateMarketLiquidityPoolId, Liquidity_generateObligationCollateralPoolId as generateObligationCollateralPoolId, Liquidity_generateSellERC20CallbackPoolId as generateSellERC20CallbackPoolId, Liquidity_generateUserVaultPositionPoolId as generateUserVaultPositionPoolId, Liquidity_generateVaultPositionPoolId as generateVaultPositionPoolId };
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
type Obligation = {
|
|
957
|
+
/** The chain id where the liquidity for this obligation is located. */
|
|
958
|
+
chainId: Id;
|
|
959
|
+
/** The token that is being borrowed for this obligation. */
|
|
960
|
+
loanToken: Address;
|
|
961
|
+
/** The exact set of collaterals required to borrow the loan token. */
|
|
962
|
+
collaterals: Collateral[];
|
|
963
|
+
/** The maturity of the obligation. */
|
|
964
|
+
maturity: Maturity;
|
|
202
965
|
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
966
|
+
declare const ObligationSchema: z.ZodObject<{
|
|
967
|
+
chainId: z.ZodBigInt;
|
|
968
|
+
loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
969
|
+
collaterals: z.ZodArray<z.ZodObject<{
|
|
970
|
+
asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
971
|
+
oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
972
|
+
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
|
|
973
|
+
}, z.core.$strip>>;
|
|
974
|
+
maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
|
|
975
|
+
}, z.core.$strip>;
|
|
976
|
+
/**
|
|
977
|
+
* Creates an obligation from the given parameters.
|
|
978
|
+
* @constructor
|
|
979
|
+
* @param parameters - {@link from.Parameters}
|
|
980
|
+
* @returns The created obligation. {@link Obligation}
|
|
981
|
+
* @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
|
|
982
|
+
*
|
|
983
|
+
* @example
|
|
984
|
+
* ```ts
|
|
985
|
+
* const obligation = Obligation.from({
|
|
986
|
+
* chainId: 1n,
|
|
987
|
+
* loanToken: privateKeyToAccount(generatePrivateKey()).address,
|
|
988
|
+
* collaterals: [
|
|
989
|
+
* Collateral.from({
|
|
990
|
+
* asset: privateKeyToAccount(generatePrivateKey()).address,
|
|
991
|
+
* oracle: privateKeyToAccount(generatePrivateKey()).address,
|
|
992
|
+
* lltv: 0.965
|
|
993
|
+
* }),
|
|
994
|
+
* ],
|
|
995
|
+
* maturity: Maturity.from("end_of_next_quarter"),
|
|
996
|
+
* });
|
|
997
|
+
* ```
|
|
998
|
+
*/
|
|
999
|
+
declare function from$3(parameters: from$3.Parameters): from$3.ReturnType;
|
|
1000
|
+
declare namespace from$3 {
|
|
1001
|
+
type Parameters = {
|
|
1002
|
+
/** The chain id where the liquidity for this obligation is located. */
|
|
1003
|
+
chainId: Id;
|
|
1004
|
+
/** The token that is being borrowed for this obligation. */
|
|
1005
|
+
loanToken: Address;
|
|
1006
|
+
/** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
|
|
1007
|
+
collaterals: from$6.Parameters[] | readonly from$6.Parameters[];
|
|
1008
|
+
/** The maturity of the obligation. */
|
|
1009
|
+
maturity: from$5.Parameters;
|
|
1010
|
+
};
|
|
1011
|
+
type ReturnType = Obligation;
|
|
1012
|
+
type ErrorType = InvalidObligationError;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Creates an obligation from a snake case object.
|
|
1016
|
+
* @throws If the obligation is invalid. {@link fromSnakeCase.ErrorType}
|
|
1017
|
+
* @param input - {@link fromSnakeCase.Parameters}
|
|
1018
|
+
* @returns The created obligation. {@link fromSnakeCase.ReturnType}
|
|
1019
|
+
*/
|
|
1020
|
+
declare function fromSnakeCase(input: fromSnakeCase.Parameters): fromSnakeCase.ReturnType;
|
|
1021
|
+
declare namespace fromSnakeCase {
|
|
1022
|
+
type Parameters = Snake<Obligation>;
|
|
1023
|
+
type ReturnType = Obligation;
|
|
1024
|
+
type ErrorType = InvalidObligationError;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Calculates the obligation id based on the smart contract's Obligation struct.
|
|
1028
|
+
* The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals, maturity)).
|
|
1029
|
+
* @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
|
|
1030
|
+
* @param obligation - {@link id.Parameters}
|
|
1031
|
+
* @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
|
|
1032
|
+
*
|
|
1033
|
+
* @example
|
|
1034
|
+
* ```ts
|
|
1035
|
+
* const obligation = Obligation.random();
|
|
1036
|
+
* const id = Obligation.id(obligation);
|
|
1037
|
+
* console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
|
|
1038
|
+
* ```
|
|
1039
|
+
*/
|
|
1040
|
+
declare function id(obligation: id.Parameters): id.ReturnType;
|
|
1041
|
+
declare namespace id {
|
|
1042
|
+
type Parameters = Obligation;
|
|
1043
|
+
type ReturnType = Hex;
|
|
1044
|
+
type ErrorType = CollateralsAreNotSortedError;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Generates a random obligation.
|
|
1048
|
+
* @returns A randomly generated obligation. {@link random.ReturnType}
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```ts
|
|
1052
|
+
* const obligation = Obligation.random();
|
|
1053
|
+
* ```
|
|
1054
|
+
*/
|
|
1055
|
+
declare function random(): random.ReturnType;
|
|
1056
|
+
declare namespace random {
|
|
1057
|
+
type ReturnType = Obligation;
|
|
1058
|
+
}
|
|
1059
|
+
declare class InvalidObligationError extends BaseError<z.ZodError | Error> {
|
|
1060
|
+
readonly name = "Obligation.InvalidObligationError";
|
|
1061
|
+
constructor(error: z.ZodError | Error);
|
|
1062
|
+
}
|
|
1063
|
+
declare class CollateralsAreNotSortedError extends BaseError {
|
|
1064
|
+
readonly name = "Obligation.CollateralsAreNotSortedError";
|
|
1065
|
+
constructor();
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
type Obligation$1_CollateralsAreNotSortedError = CollateralsAreNotSortedError;
|
|
1069
|
+
declare const Obligation$1_CollateralsAreNotSortedError: typeof CollateralsAreNotSortedError;
|
|
1070
|
+
type Obligation$1_InvalidObligationError = InvalidObligationError;
|
|
1071
|
+
declare const Obligation$1_InvalidObligationError: typeof InvalidObligationError;
|
|
1072
|
+
type Obligation$1_Obligation = Obligation;
|
|
1073
|
+
declare const Obligation$1_ObligationSchema: typeof ObligationSchema;
|
|
1074
|
+
declare const Obligation$1_fromSnakeCase: typeof fromSnakeCase;
|
|
1075
|
+
declare const Obligation$1_id: typeof id;
|
|
1076
|
+
declare const Obligation$1_random: typeof random;
|
|
1077
|
+
declare namespace Obligation$1 {
|
|
1078
|
+
export { Obligation$1_CollateralsAreNotSortedError as CollateralsAreNotSortedError, Obligation$1_InvalidObligationError as InvalidObligationError, type Obligation$1_Obligation as Obligation, Obligation$1_ObligationSchema as ObligationSchema, from$3 as from, Obligation$1_fromSnakeCase as fromSnakeCase, Obligation$1_id as id, Obligation$1_random as random };
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
type ObligationResponse = Snake<Compute<{
|
|
1082
|
+
/** The obligation id. */
|
|
1083
|
+
id: Hex;
|
|
1084
|
+
} & Obligation>>;
|
|
1085
|
+
/**
|
|
1086
|
+
* Creates an `ObligationResponse` from a `Obligation`.
|
|
1087
|
+
* @constructor
|
|
1088
|
+
* @param obligation - {@link Obligation}
|
|
1089
|
+
* @returns The created `ObligationResponse`. {@link ObligationResponse}
|
|
1090
|
+
*/
|
|
1091
|
+
declare function from$2(obligation: Obligation): ObligationResponse;
|
|
1092
|
+
|
|
1093
|
+
type ObligationResponse$1_ObligationResponse = ObligationResponse;
|
|
1094
|
+
declare namespace ObligationResponse$1 {
|
|
1095
|
+
export { type ObligationResponse$1_ObligationResponse as ObligationResponse, from$2 as from };
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
type OfferResponse = Snake<Offer>;
|
|
1099
|
+
/**
|
|
1100
|
+
* Creates an `OfferResponse` from an `Offer`.
|
|
1101
|
+
* @constructor
|
|
1102
|
+
* @param offer - {@link Offer}
|
|
1103
|
+
* @returns The created `OfferResponse`. {@link OfferResponse}
|
|
1104
|
+
*/
|
|
1105
|
+
declare function from$1(offer: Offer): OfferResponse;
|
|
1106
|
+
|
|
1107
|
+
type OfferResponse$1_OfferResponse = OfferResponse;
|
|
1108
|
+
declare namespace OfferResponse$1 {
|
|
1109
|
+
export { type OfferResponse$1_OfferResponse as OfferResponse, from$1 as from };
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
declare const OpenApi: node_modules_zod_openapi_dist_components_CXzxKPFp_js.OpenAPIObject;
|
|
1113
|
+
|
|
1114
|
+
declare const schemas: {
|
|
1115
|
+
readonly get_offers: z.ZodObject<{
|
|
1116
|
+
side: z.ZodEnum<{
|
|
1117
|
+
buy: "buy";
|
|
1118
|
+
sell: "sell";
|
|
1119
|
+
}>;
|
|
1120
|
+
obligation_id: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
1121
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
1122
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
|
|
1123
|
+
}, z.core.$strip>;
|
|
1124
|
+
readonly get_obligations: z.ZodObject<{
|
|
1125
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
1126
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
|
|
1127
|
+
}, z.core.$strip>;
|
|
232
1128
|
};
|
|
233
|
-
type
|
|
1129
|
+
type Action = keyof typeof schemas;
|
|
1130
|
+
declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
|
|
1131
|
+
declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
|
|
1132
|
+
|
|
1133
|
+
declare const index$1_ChainHealth: typeof ChainHealth;
|
|
1134
|
+
type index$1_ChainsHealthResponse = ChainsHealthResponse;
|
|
1135
|
+
declare const index$1_CollectorHealth: typeof CollectorHealth;
|
|
1136
|
+
type index$1_CollectorsHealthResponse = CollectorsHealthResponse;
|
|
1137
|
+
declare const index$1_OpenApi: typeof OpenApi;
|
|
1138
|
+
type index$1_RouterStatusResponse = RouterStatusResponse;
|
|
1139
|
+
declare const index$1_parse: typeof parse;
|
|
1140
|
+
declare const index$1_safeParse: typeof safeParse;
|
|
1141
|
+
declare namespace index$1 {
|
|
1142
|
+
export { index$1_ChainHealth as ChainHealth, type index$1_ChainsHealthResponse as ChainsHealthResponse, index$1_CollectorHealth as CollectorHealth, type index$1_CollectorsHealthResponse as CollectorsHealthResponse, ObligationResponse$1 as ObligationResponse, OfferResponse$1 as OfferResponse, index$1_OpenApi as OpenApi, type index$1_RouterStatusResponse as RouterStatusResponse, index$1_parse as parse, index$1_safeParse as safeParse };
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
type RouterClientConfig = {
|
|
1146
|
+
/** The URL of the router. */
|
|
234
1147
|
readonly url: URL;
|
|
1148
|
+
/** The default headers to use for each request. */
|
|
235
1149
|
readonly headers: Headers;
|
|
236
1150
|
};
|
|
237
|
-
type Client = Compute<
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
1151
|
+
type Client$1 = Compute<RouterClientConfig & {
|
|
1152
|
+
/**
|
|
1153
|
+
* Get offers from the router.
|
|
1154
|
+
* @param parameters - {@link getOffers.Parameters}
|
|
1155
|
+
* @returns The offers with pagination cursor. {@link getOffers.ReturnType}
|
|
1156
|
+
*
|
|
1157
|
+
* @example
|
|
1158
|
+
* ```ts
|
|
1159
|
+
* const router = RouterClient.connect({ url: "https://router.morpho.dev" });
|
|
1160
|
+
* const { offers, cursor } = await router.getOffers({ side: "buy", obligationId: "0xa1c...d2f" });
|
|
1161
|
+
* console.log(offers);
|
|
1162
|
+
* ```
|
|
1163
|
+
*/
|
|
1164
|
+
getOffers: (parameters: getOffers.Parameters) => Promise<getOffers.ReturnType>;
|
|
1165
|
+
/**
|
|
1166
|
+
* Get obligations from the router.
|
|
1167
|
+
* @param parameters - {@link getObligations.Parameters}
|
|
1168
|
+
* @returns The obligations with pagination cursor. {@link getObligations.ReturnType}
|
|
1169
|
+
*
|
|
1170
|
+
* @example
|
|
1171
|
+
* ```ts
|
|
1172
|
+
* const router = RouterClient.connect({ url: "https://router.morpho.dev" });
|
|
1173
|
+
* const { obligations, cursor } = await router.getObligations();
|
|
1174
|
+
* console.log(obligations);
|
|
1175
|
+
* ```
|
|
1176
|
+
*/
|
|
1177
|
+
getObligations: (parameters?: getObligations.Parameters) => Promise<getObligations.ReturnType>;
|
|
246
1178
|
}>;
|
|
247
|
-
|
|
1179
|
+
type ConnectOptions = {
|
|
1180
|
+
/** The URL of the router to interact with.
|
|
1181
|
+
* @default "https://router.morpho.dev"
|
|
1182
|
+
*/
|
|
248
1183
|
url?: string;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
1184
|
+
/** The API key to use for the router API. */
|
|
1185
|
+
apiKey?: string;
|
|
1186
|
+
/** The default headers to use for each request. */
|
|
1187
|
+
headers?: Headers;
|
|
1188
|
+
};
|
|
255
1189
|
/**
|
|
256
|
-
*
|
|
257
|
-
* @
|
|
1190
|
+
* Creates an instance of a router client.
|
|
1191
|
+
* @constructor
|
|
1192
|
+
* @param options - {@link ConnectOptions}
|
|
1193
|
+
* @returns A Router Client. {@link Client}
|
|
1194
|
+
*
|
|
1195
|
+
* @example
|
|
1196
|
+
* ```typescript
|
|
1197
|
+
* const router = RouterClient.connect({ url: "https://router.morpho.dev" });
|
|
1198
|
+
* ```
|
|
258
1199
|
*/
|
|
259
|
-
declare function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
1200
|
+
declare function connect$1(options?: ConnectOptions): connect$1.ReturnType;
|
|
1201
|
+
declare namespace connect$1 {
|
|
1202
|
+
type ReturnType = Client$1;
|
|
1203
|
+
type ErrorType = InvalidUrlError;
|
|
1204
|
+
}
|
|
1205
|
+
declare function getOffers(config: RouterClientConfig, parameters: getOffers.Parameters): Promise<getOffers.ReturnType>;
|
|
1206
|
+
declare namespace getOffers {
|
|
1207
|
+
type Parameters = {
|
|
1208
|
+
/** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
|
|
1209
|
+
side: "buy" | "sell";
|
|
1210
|
+
/** The offers obligation id */
|
|
1211
|
+
obligationId: Hex;
|
|
1212
|
+
/** Pagination cursor in base64url-encoded format */
|
|
1213
|
+
cursor?: string;
|
|
1214
|
+
/** Maximum number of offers to return. @default 20 */
|
|
1215
|
+
limit?: number;
|
|
1216
|
+
};
|
|
1217
|
+
type ReturnType = {
|
|
1218
|
+
offers: Offer[];
|
|
1219
|
+
/** The pagination cursor. */
|
|
1220
|
+
cursor: string | null;
|
|
1221
|
+
};
|
|
264
1222
|
type ErrorType = GetApiErrorType;
|
|
265
1223
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
1224
|
+
declare function getObligations(config: RouterClientConfig, parameters?: getObligations.Parameters): Promise<getObligations.ReturnType>;
|
|
1225
|
+
declare namespace getObligations {
|
|
1226
|
+
type Parameters = {
|
|
1227
|
+
/** Pagination cursor is a 32-byte hex string. */
|
|
1228
|
+
cursor?: Hex;
|
|
1229
|
+
/** Maximum number of obligations to return. @default 20 */
|
|
1230
|
+
limit?: number;
|
|
1231
|
+
};
|
|
1232
|
+
type ReturnType = {
|
|
1233
|
+
obligations: Obligation[];
|
|
1234
|
+
/** The pagination cursor. */
|
|
1235
|
+
cursor: string | null;
|
|
1236
|
+
};
|
|
275
1237
|
type ErrorType = GetApiErrorType;
|
|
276
1238
|
}
|
|
277
|
-
type GetApiErrorType =
|
|
278
|
-
declare class InvalidUrlError extends
|
|
1239
|
+
type GetApiErrorType = HttpGetApiFailedError | HttpUnauthorizedError | HttpForbiddenError | HttpRateLimitError;
|
|
1240
|
+
declare class InvalidUrlError extends BaseError {
|
|
279
1241
|
name: string;
|
|
280
1242
|
constructor(url: string);
|
|
281
1243
|
}
|
|
282
|
-
declare class HttpUnauthorizedError extends
|
|
1244
|
+
declare class HttpUnauthorizedError extends BaseError {
|
|
283
1245
|
name: string;
|
|
284
1246
|
constructor();
|
|
285
1247
|
}
|
|
286
|
-
declare class HttpForbiddenError extends
|
|
1248
|
+
declare class HttpForbiddenError extends BaseError {
|
|
287
1249
|
name: string;
|
|
288
1250
|
constructor();
|
|
289
1251
|
}
|
|
290
|
-
declare class HttpRateLimitError extends
|
|
1252
|
+
declare class HttpRateLimitError extends BaseError {
|
|
291
1253
|
name: string;
|
|
292
1254
|
constructor();
|
|
293
1255
|
}
|
|
294
|
-
declare class
|
|
1256
|
+
declare class HttpGetApiFailedError extends BaseError {
|
|
295
1257
|
name: string;
|
|
296
1258
|
constructor(message: string, { details }?: {
|
|
297
1259
|
details?: string;
|
|
298
1260
|
});
|
|
299
1261
|
}
|
|
300
1262
|
|
|
301
|
-
type Client$
|
|
302
|
-
type Client$
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
declare const Client$
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
declare const Client$1_get: typeof get;
|
|
317
|
-
declare const Client$1_match: typeof match;
|
|
318
|
-
declare namespace Client$1 {
|
|
319
|
-
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_RouterApiClientConfig as RouterApiClientConfig, Client$1_connect as connect, Client$1_get as get, Client$1_match as match };
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
type LiquidityUserPosition = {
|
|
323
|
-
id: string;
|
|
324
|
-
availableLiquidityQueueId: string;
|
|
325
|
-
user: string;
|
|
326
|
-
chainId: bigint;
|
|
327
|
-
amount: string;
|
|
328
|
-
updatedAt: Date;
|
|
329
|
-
};
|
|
330
|
-
type LiquidityQueue = {
|
|
331
|
-
queueId: string;
|
|
332
|
-
availableLiquidityPoolId: string;
|
|
333
|
-
index: number;
|
|
334
|
-
callbackAmount: string;
|
|
335
|
-
updatedAt: Date;
|
|
336
|
-
};
|
|
337
|
-
type LiquidityPool = {
|
|
338
|
-
id: string;
|
|
339
|
-
amount: string;
|
|
340
|
-
updatedAt: Date;
|
|
341
|
-
};
|
|
342
|
-
type LiquidityQueueWithPool = {
|
|
343
|
-
queue: LiquidityQueue;
|
|
344
|
-
pool: LiquidityPool;
|
|
345
|
-
};
|
|
346
|
-
type Liquidity = {
|
|
347
|
-
userPosition: LiquidityUserPosition;
|
|
348
|
-
queues: LiquidityQueueWithPool[];
|
|
349
|
-
};
|
|
350
|
-
type FetchOptions = {
|
|
351
|
-
batchSize?: number;
|
|
352
|
-
retryAttempts?: number;
|
|
353
|
-
retryDelayMs?: number;
|
|
354
|
-
blockNumber?: number;
|
|
355
|
-
};
|
|
356
|
-
type LiquidityClient = {
|
|
357
|
-
/** Fetch liquidity for buy offers based on wallet token balances and allowances. */
|
|
358
|
-
fetchBuyLiquidity: (parameters: {
|
|
359
|
-
chainId: bigint;
|
|
360
|
-
spender: Address;
|
|
361
|
-
pairs: Array<{
|
|
362
|
-
user: Address;
|
|
363
|
-
loanToken: Address;
|
|
364
|
-
}>;
|
|
365
|
-
options?: FetchOptions;
|
|
366
|
-
}) => Promise<Liquidity[]>;
|
|
367
|
-
/** Fetch liquidity for sell offers based on collateral capacity and existing positions. */
|
|
368
|
-
fetchSellLiquidity: (parameters: {
|
|
369
|
-
chainId: bigint;
|
|
370
|
-
spender: Address;
|
|
371
|
-
morphoAddress: Address;
|
|
372
|
-
offers: Array<Offer.Offer>;
|
|
373
|
-
options?: FetchOptions;
|
|
374
|
-
}) => Promise<Liquidity[]>;
|
|
375
|
-
};
|
|
376
|
-
/**
|
|
377
|
-
* Create a liquidity client with the specified blockchain client.
|
|
378
|
-
*
|
|
379
|
-
* @param config - Configuration containing the blockchain client
|
|
380
|
-
* @returns LiquidityClient
|
|
381
|
-
*/
|
|
382
|
-
declare const create: (config: {
|
|
383
|
-
client: Pick<PublicActions, "multicall">;
|
|
384
|
-
}) => LiquidityClient;
|
|
385
|
-
declare function serialize(liquidity: Liquidity): string;
|
|
386
|
-
|
|
387
|
-
type Liquidity$1_Liquidity = Liquidity;
|
|
388
|
-
type Liquidity$1_LiquidityClient = LiquidityClient;
|
|
389
|
-
type Liquidity$1_LiquidityPool = LiquidityPool;
|
|
390
|
-
type Liquidity$1_LiquidityQueue = LiquidityQueue;
|
|
391
|
-
type Liquidity$1_LiquidityQueueWithPool = LiquidityQueueWithPool;
|
|
392
|
-
type Liquidity$1_LiquidityUserPosition = LiquidityUserPosition;
|
|
393
|
-
declare const Liquidity$1_create: typeof create;
|
|
394
|
-
declare const Liquidity$1_serialize: typeof serialize;
|
|
395
|
-
declare namespace Liquidity$1 {
|
|
396
|
-
export { type Liquidity$1_Liquidity as Liquidity, type Liquidity$1_LiquidityClient as LiquidityClient, 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_create as create, Liquidity$1_serialize as serialize };
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
declare enum CallbackType {
|
|
400
|
-
BuyWithEmptyCallback = "buy_with_empty_callback",
|
|
401
|
-
SellERC20Callback = "sell_erc20_callback"
|
|
402
|
-
}
|
|
403
|
-
declare const WhitelistedCallbackAddresses: Record<CallbackType, readonly string[]>;
|
|
404
|
-
type BuildLiquidityParameters = {
|
|
405
|
-
type: CallbackType.BuyWithEmptyCallback;
|
|
406
|
-
user: Address;
|
|
407
|
-
loanToken: Address;
|
|
408
|
-
chainId: Chain.Id;
|
|
409
|
-
amount: bigint;
|
|
410
|
-
index?: number;
|
|
411
|
-
updatedAt?: Date;
|
|
412
|
-
} | {
|
|
413
|
-
type: CallbackType.SellERC20Callback;
|
|
414
|
-
user: Address;
|
|
415
|
-
termId: string;
|
|
416
|
-
offerHash: string;
|
|
417
|
-
chainId: Chain.Id;
|
|
418
|
-
amount: bigint;
|
|
419
|
-
collaterals: Array<{
|
|
420
|
-
collateralAddress: Address;
|
|
421
|
-
balance: bigint;
|
|
422
|
-
callbackAmount: bigint;
|
|
423
|
-
}>;
|
|
424
|
-
index?: number;
|
|
425
|
-
updatedAt?: Date;
|
|
426
|
-
};
|
|
427
|
-
declare function buildLiquidity(parameters: BuildLiquidityParameters): Liquidity;
|
|
428
|
-
declare function getCallbackIdForOffer(offer: Offer.Offer): string | null;
|
|
429
|
-
declare function decode$1(parameters: {
|
|
430
|
-
type: CallbackType;
|
|
431
|
-
data: Hex;
|
|
432
|
-
}): Array<{
|
|
433
|
-
collateral: Address;
|
|
434
|
-
amount: bigint;
|
|
435
|
-
}>;
|
|
436
|
-
declare function encode$1(parameters: {
|
|
437
|
-
type: CallbackType;
|
|
438
|
-
data: {
|
|
439
|
-
collaterals: Address[];
|
|
440
|
-
amounts: bigint[];
|
|
441
|
-
};
|
|
442
|
-
}): Hex;
|
|
443
|
-
|
|
444
|
-
type Callback_CallbackType = CallbackType;
|
|
445
|
-
declare const Callback_CallbackType: typeof CallbackType;
|
|
446
|
-
declare const Callback_WhitelistedCallbackAddresses: typeof WhitelistedCallbackAddresses;
|
|
447
|
-
declare const Callback_buildLiquidity: typeof buildLiquidity;
|
|
448
|
-
declare const Callback_getCallbackIdForOffer: typeof getCallbackIdForOffer;
|
|
449
|
-
declare namespace Callback {
|
|
450
|
-
export { Callback_CallbackType as CallbackType, Callback_WhitelistedCallbackAddresses as WhitelistedCallbackAddresses, Callback_buildLiquidity as buildLiquidity, decode$1 as decode, encode$1 as encode, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
type Cursor = {
|
|
454
|
-
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
455
|
-
dir: "asc" | "desc";
|
|
456
|
-
rate?: string;
|
|
457
|
-
maturity?: number;
|
|
458
|
-
expiry?: number;
|
|
459
|
-
assets?: string;
|
|
460
|
-
hash: string;
|
|
461
|
-
};
|
|
462
|
-
declare function validate(cursor: unknown): cursor is Cursor;
|
|
463
|
-
declare function encode(c: Cursor): string;
|
|
464
|
-
declare function decode(token?: string): Cursor | null;
|
|
465
|
-
|
|
466
|
-
type Cursor$1_Cursor = Cursor;
|
|
467
|
-
declare const Cursor$1_decode: typeof decode;
|
|
468
|
-
declare const Cursor$1_encode: typeof encode;
|
|
469
|
-
declare const Cursor$1_validate: typeof validate;
|
|
470
|
-
declare namespace Cursor$1 {
|
|
471
|
-
export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
|
|
1263
|
+
type Client$2_ConnectOptions = ConnectOptions;
|
|
1264
|
+
type Client$2_HttpForbiddenError = HttpForbiddenError;
|
|
1265
|
+
declare const Client$2_HttpForbiddenError: typeof HttpForbiddenError;
|
|
1266
|
+
type Client$2_HttpGetApiFailedError = HttpGetApiFailedError;
|
|
1267
|
+
declare const Client$2_HttpGetApiFailedError: typeof HttpGetApiFailedError;
|
|
1268
|
+
type Client$2_HttpRateLimitError = HttpRateLimitError;
|
|
1269
|
+
declare const Client$2_HttpRateLimitError: typeof HttpRateLimitError;
|
|
1270
|
+
type Client$2_HttpUnauthorizedError = HttpUnauthorizedError;
|
|
1271
|
+
declare const Client$2_HttpUnauthorizedError: typeof HttpUnauthorizedError;
|
|
1272
|
+
type Client$2_InvalidUrlError = InvalidUrlError;
|
|
1273
|
+
declare const Client$2_InvalidUrlError: typeof InvalidUrlError;
|
|
1274
|
+
declare const Client$2_getObligations: typeof getObligations;
|
|
1275
|
+
declare const Client$2_getOffers: typeof getOffers;
|
|
1276
|
+
declare namespace Client$2 {
|
|
1277
|
+
export { type Client$1 as Client, type Client$2_ConnectOptions as ConnectOptions, Client$2_HttpForbiddenError as HttpForbiddenError, Client$2_HttpGetApiFailedError as HttpGetApiFailedError, Client$2_HttpRateLimitError as HttpRateLimitError, Client$2_HttpUnauthorizedError as HttpUnauthorizedError, Client$2_InvalidUrlError as InvalidUrlError, connect$1 as connect, Client$2_getObligations as getObligations, Client$2_getOffers as getOffers };
|
|
472
1278
|
}
|
|
473
1279
|
|
|
474
1280
|
/**
|
|
@@ -513,227 +1319,12 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
|
|
|
513
1319
|
* @param run - The function that validates the rule.
|
|
514
1320
|
* @returns The created rule.
|
|
515
1321
|
*/
|
|
516
|
-
declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
|
|
1322
|
+
declare function batch$1<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
|
|
517
1323
|
type MorphoContext = {
|
|
518
|
-
chain: Chain
|
|
1324
|
+
chain: Chain;
|
|
1325
|
+
client: PublicClient;
|
|
519
1326
|
};
|
|
520
|
-
declare function morpho(): (Rule<
|
|
521
|
-
readonly offering: Address;
|
|
522
|
-
readonly assets: bigint;
|
|
523
|
-
readonly rate: bigint;
|
|
524
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
525
|
-
readonly expiry: number;
|
|
526
|
-
readonly nonce: bigint;
|
|
527
|
-
readonly buy: boolean;
|
|
528
|
-
readonly chainId: bigint;
|
|
529
|
-
readonly loanToken: Address;
|
|
530
|
-
readonly start: number;
|
|
531
|
-
readonly collaterals: readonly {
|
|
532
|
-
asset: Address;
|
|
533
|
-
oracle: Address;
|
|
534
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
535
|
-
}[];
|
|
536
|
-
readonly callback: {
|
|
537
|
-
readonly address: Address;
|
|
538
|
-
readonly data: viem.Hex;
|
|
539
|
-
readonly gasLimit: bigint;
|
|
540
|
-
};
|
|
541
|
-
readonly hash: viem.Hex;
|
|
542
|
-
signature?: viem.Hex;
|
|
543
|
-
createdAt?: number;
|
|
544
|
-
}, "chain_id", MorphoContext> | Rule<{
|
|
545
|
-
readonly offering: Address;
|
|
546
|
-
readonly assets: bigint;
|
|
547
|
-
readonly rate: bigint;
|
|
548
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
549
|
-
readonly expiry: number;
|
|
550
|
-
readonly nonce: bigint;
|
|
551
|
-
readonly buy: boolean;
|
|
552
|
-
readonly chainId: bigint;
|
|
553
|
-
readonly loanToken: Address;
|
|
554
|
-
readonly start: number;
|
|
555
|
-
readonly collaterals: readonly {
|
|
556
|
-
asset: Address;
|
|
557
|
-
oracle: Address;
|
|
558
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
559
|
-
}[];
|
|
560
|
-
readonly callback: {
|
|
561
|
-
readonly address: Address;
|
|
562
|
-
readonly data: viem.Hex;
|
|
563
|
-
readonly gasLimit: bigint;
|
|
564
|
-
};
|
|
565
|
-
readonly hash: viem.Hex;
|
|
566
|
-
signature?: viem.Hex;
|
|
567
|
-
createdAt?: number;
|
|
568
|
-
}, "loan_token", MorphoContext> | Rule<{
|
|
569
|
-
readonly offering: Address;
|
|
570
|
-
readonly assets: bigint;
|
|
571
|
-
readonly rate: bigint;
|
|
572
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
573
|
-
readonly expiry: number;
|
|
574
|
-
readonly nonce: bigint;
|
|
575
|
-
readonly buy: boolean;
|
|
576
|
-
readonly chainId: bigint;
|
|
577
|
-
readonly loanToken: Address;
|
|
578
|
-
readonly start: number;
|
|
579
|
-
readonly collaterals: readonly {
|
|
580
|
-
asset: Address;
|
|
581
|
-
oracle: Address;
|
|
582
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
583
|
-
}[];
|
|
584
|
-
readonly callback: {
|
|
585
|
-
readonly address: Address;
|
|
586
|
-
readonly data: viem.Hex;
|
|
587
|
-
readonly gasLimit: bigint;
|
|
588
|
-
};
|
|
589
|
-
readonly hash: viem.Hex;
|
|
590
|
-
signature?: viem.Hex;
|
|
591
|
-
createdAt?: number;
|
|
592
|
-
}, "expiry", MorphoContext> | Rule<{
|
|
593
|
-
readonly offering: Address;
|
|
594
|
-
readonly assets: bigint;
|
|
595
|
-
readonly rate: bigint;
|
|
596
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
597
|
-
readonly expiry: number;
|
|
598
|
-
readonly nonce: bigint;
|
|
599
|
-
readonly buy: boolean;
|
|
600
|
-
readonly chainId: bigint;
|
|
601
|
-
readonly loanToken: Address;
|
|
602
|
-
readonly start: number;
|
|
603
|
-
readonly collaterals: readonly {
|
|
604
|
-
asset: Address;
|
|
605
|
-
oracle: Address;
|
|
606
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
607
|
-
}[];
|
|
608
|
-
readonly callback: {
|
|
609
|
-
readonly address: Address;
|
|
610
|
-
readonly data: viem.Hex;
|
|
611
|
-
readonly gasLimit: bigint;
|
|
612
|
-
};
|
|
613
|
-
readonly hash: viem.Hex;
|
|
614
|
-
signature?: viem.Hex;
|
|
615
|
-
createdAt?: number;
|
|
616
|
-
}, "sell_offers_empty_callback", MorphoContext> | Rule<{
|
|
617
|
-
readonly offering: Address;
|
|
618
|
-
readonly assets: bigint;
|
|
619
|
-
readonly rate: bigint;
|
|
620
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
621
|
-
readonly expiry: number;
|
|
622
|
-
readonly nonce: bigint;
|
|
623
|
-
readonly buy: boolean;
|
|
624
|
-
readonly chainId: bigint;
|
|
625
|
-
readonly loanToken: Address;
|
|
626
|
-
readonly start: number;
|
|
627
|
-
readonly collaterals: readonly {
|
|
628
|
-
asset: Address;
|
|
629
|
-
oracle: Address;
|
|
630
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
631
|
-
}[];
|
|
632
|
-
readonly callback: {
|
|
633
|
-
readonly address: Address;
|
|
634
|
-
readonly data: viem.Hex;
|
|
635
|
-
readonly gasLimit: bigint;
|
|
636
|
-
};
|
|
637
|
-
readonly hash: viem.Hex;
|
|
638
|
-
signature?: viem.Hex;
|
|
639
|
-
createdAt?: number;
|
|
640
|
-
}, "buy_offers_non_empty_callback", MorphoContext> | Rule<{
|
|
641
|
-
readonly offering: Address;
|
|
642
|
-
readonly assets: bigint;
|
|
643
|
-
readonly rate: bigint;
|
|
644
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
645
|
-
readonly expiry: number;
|
|
646
|
-
readonly nonce: bigint;
|
|
647
|
-
readonly buy: boolean;
|
|
648
|
-
readonly chainId: bigint;
|
|
649
|
-
readonly loanToken: Address;
|
|
650
|
-
readonly start: number;
|
|
651
|
-
readonly collaterals: readonly {
|
|
652
|
-
asset: Address;
|
|
653
|
-
oracle: Address;
|
|
654
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
655
|
-
}[];
|
|
656
|
-
readonly callback: {
|
|
657
|
-
readonly address: Address;
|
|
658
|
-
readonly data: viem.Hex;
|
|
659
|
-
readonly gasLimit: bigint;
|
|
660
|
-
};
|
|
661
|
-
readonly hash: viem.Hex;
|
|
662
|
-
signature?: viem.Hex;
|
|
663
|
-
createdAt?: number;
|
|
664
|
-
}, "sell_offers_non_whitelisted_callback", MorphoContext> | Rule<{
|
|
665
|
-
readonly offering: Address;
|
|
666
|
-
readonly assets: bigint;
|
|
667
|
-
readonly rate: bigint;
|
|
668
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
669
|
-
readonly expiry: number;
|
|
670
|
-
readonly nonce: bigint;
|
|
671
|
-
readonly buy: boolean;
|
|
672
|
-
readonly chainId: bigint;
|
|
673
|
-
readonly loanToken: Address;
|
|
674
|
-
readonly start: number;
|
|
675
|
-
readonly collaterals: readonly {
|
|
676
|
-
asset: Address;
|
|
677
|
-
oracle: Address;
|
|
678
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
679
|
-
}[];
|
|
680
|
-
readonly callback: {
|
|
681
|
-
readonly address: Address;
|
|
682
|
-
readonly data: viem.Hex;
|
|
683
|
-
readonly gasLimit: bigint;
|
|
684
|
-
};
|
|
685
|
-
readonly hash: viem.Hex;
|
|
686
|
-
signature?: viem.Hex;
|
|
687
|
-
createdAt?: number;
|
|
688
|
-
}, "sell_offers_callback_data_invalid", MorphoContext> | Rule<{
|
|
689
|
-
readonly offering: Address;
|
|
690
|
-
readonly assets: bigint;
|
|
691
|
-
readonly rate: bigint;
|
|
692
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
693
|
-
readonly expiry: number;
|
|
694
|
-
readonly nonce: bigint;
|
|
695
|
-
readonly buy: boolean;
|
|
696
|
-
readonly chainId: bigint;
|
|
697
|
-
readonly loanToken: Address;
|
|
698
|
-
readonly start: number;
|
|
699
|
-
readonly collaterals: readonly {
|
|
700
|
-
asset: Address;
|
|
701
|
-
oracle: Address;
|
|
702
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
703
|
-
}[];
|
|
704
|
-
readonly callback: {
|
|
705
|
-
readonly address: Address;
|
|
706
|
-
readonly data: viem.Hex;
|
|
707
|
-
readonly gasLimit: bigint;
|
|
708
|
-
};
|
|
709
|
-
readonly hash: viem.Hex;
|
|
710
|
-
signature?: viem.Hex;
|
|
711
|
-
createdAt?: number;
|
|
712
|
-
}, "sell_offers_callback_collateral_invalid", MorphoContext> | Rule<{
|
|
713
|
-
readonly offering: Address;
|
|
714
|
-
readonly assets: bigint;
|
|
715
|
-
readonly rate: bigint;
|
|
716
|
-
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
717
|
-
readonly expiry: number;
|
|
718
|
-
readonly nonce: bigint;
|
|
719
|
-
readonly buy: boolean;
|
|
720
|
-
readonly chainId: bigint;
|
|
721
|
-
readonly loanToken: Address;
|
|
722
|
-
readonly start: number;
|
|
723
|
-
readonly collaterals: readonly {
|
|
724
|
-
asset: Address;
|
|
725
|
-
oracle: Address;
|
|
726
|
-
lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
|
|
727
|
-
}[];
|
|
728
|
-
readonly callback: {
|
|
729
|
-
readonly address: Address;
|
|
730
|
-
readonly data: viem.Hex;
|
|
731
|
-
readonly gasLimit: bigint;
|
|
732
|
-
};
|
|
733
|
-
readonly hash: viem.Hex;
|
|
734
|
-
signature?: viem.Hex;
|
|
735
|
-
createdAt?: number;
|
|
736
|
-
}, "maturity", MorphoContext>)[];
|
|
1327
|
+
declare function morpho(): (Rule<Offer, "chain_id", MorphoContext> | Rule<Offer, "loan_token", MorphoContext> | Rule<Offer, "expiry", MorphoContext> | Rule<Offer, "sell_offers_empty_callback", MorphoContext> | Rule<Offer, "buy_offers_non_empty_callback", MorphoContext> | Rule<Offer, "sell_offers_non_whitelisted_callback", MorphoContext> | Rule<Offer, "sell_offers_callback_data_invalid", MorphoContext> | Rule<Offer, "sell_offers_callback_collateral_invalid", MorphoContext> | Rule<Offer, "buy_offers_callback_data_invalid", MorphoContext> | Rule<Offer, "buy_offers_callback_vault_invalid", MorphoContext> | Rule<Offer, "maturity", MorphoContext>)[];
|
|
737
1328
|
|
|
738
1329
|
type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
|
|
739
1330
|
type ValidationRule_MorphoContext = MorphoContext;
|
|
@@ -742,11 +1333,10 @@ type ValidationRule_RuleNames<Rules extends readonly {
|
|
|
742
1333
|
name: string;
|
|
743
1334
|
}[]> = RuleNames<Rules>;
|
|
744
1335
|
type ValidationRule_Single<T, RuleName extends string, Ctx = void> = Single<T, RuleName, Ctx>;
|
|
745
|
-
declare const ValidationRule_batch: typeof batch;
|
|
746
1336
|
declare const ValidationRule_morpho: typeof morpho;
|
|
747
1337
|
declare const ValidationRule_single: typeof single;
|
|
748
1338
|
declare namespace ValidationRule {
|
|
749
|
-
export { type ValidationRule_Batch as Batch, type ValidationRule_MorphoContext as MorphoContext, type ValidationRule_Rule as Rule, type ValidationRule_RuleNames as RuleNames, type ValidationRule_Single as Single,
|
|
1339
|
+
export { type ValidationRule_Batch as Batch, type ValidationRule_MorphoContext as MorphoContext, type ValidationRule_Rule as Rule, type ValidationRule_RuleNames as RuleNames, type ValidationRule_Single as Single, batch$1 as batch, ValidationRule_morpho as morpho, ValidationRule_single as single };
|
|
750
1340
|
}
|
|
751
1341
|
|
|
752
1342
|
/**
|
|
@@ -788,4 +1378,195 @@ declare namespace Validation {
|
|
|
788
1378
|
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
789
1379
|
}
|
|
790
1380
|
|
|
791
|
-
|
|
1381
|
+
declare function from(parameters: from.Parameters): from.ReturnType;
|
|
1382
|
+
declare namespace from {
|
|
1383
|
+
type Parameters = {
|
|
1384
|
+
/** The viem client to use. */
|
|
1385
|
+
client: WalletClient;
|
|
1386
|
+
/** The mempool address. */
|
|
1387
|
+
mempoolAddress: Address;
|
|
1388
|
+
/** The block window to use for the mempool. Defaults to 100. */
|
|
1389
|
+
blockWindow?: number;
|
|
1390
|
+
};
|
|
1391
|
+
type ReturnType = Client;
|
|
1392
|
+
type ErrorType = null;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
type AddParameters = {
|
|
1396
|
+
offer: Compute<Omit<Offer, "hash" | "createdAt">>;
|
|
1397
|
+
};
|
|
1398
|
+
type GetParameters = {
|
|
1399
|
+
/** The block number to get offers from. */
|
|
1400
|
+
blockNumberGte?: number;
|
|
1401
|
+
/** The block number to get offers to. */
|
|
1402
|
+
blockNumberLte?: number;
|
|
1403
|
+
/** The loan asset to get offers from. */
|
|
1404
|
+
loanToken?: string;
|
|
1405
|
+
/** The order to get offers. Defaults to "desc". */
|
|
1406
|
+
order?: "asc" | "desc";
|
|
1407
|
+
/** The options to get offers from. */
|
|
1408
|
+
options?: {
|
|
1409
|
+
/** The maximum number of offers to return. Defaults to 100. Maximum is 1000. */
|
|
1410
|
+
maxBatchSize?: number;
|
|
1411
|
+
};
|
|
1412
|
+
};
|
|
1413
|
+
type WatchParameters = {
|
|
1414
|
+
/** The async function to get the last synced block number from which to start watching.
|
|
1415
|
+
* This function will be called periodically on each poll. It should be updated by the caller (e.g. using `onOffers` callback) to track the last synced block number.
|
|
1416
|
+
*/
|
|
1417
|
+
lastSyncedBlock: () => Promise<number>;
|
|
1418
|
+
/** The loan asset to watch. */
|
|
1419
|
+
loanToken?: string;
|
|
1420
|
+
/** The callback to call when a new batch of offers is found in the mempool.
|
|
1421
|
+
* @param offers The offers found in the mempool.
|
|
1422
|
+
* @param blockNumber The block number of the last processed offer. Block numbers will always ascend.
|
|
1423
|
+
*/
|
|
1424
|
+
onOffers: (offers: Offer[], blockNumber: number) => Promise<void>;
|
|
1425
|
+
/** The polling configuration. */
|
|
1426
|
+
polling?: {
|
|
1427
|
+
/** The interval in milliseconds to poll for new offers. Defaults to 30000. */
|
|
1428
|
+
interval?: number;
|
|
1429
|
+
/** The maximum number of offers that can be returned in a single batch.
|
|
1430
|
+
* Defaults to 100. Maximum is 1000. */
|
|
1431
|
+
maxBatchSize?: number;
|
|
1432
|
+
};
|
|
1433
|
+
};
|
|
1434
|
+
/**
|
|
1435
|
+
* Mempool client interface.
|
|
1436
|
+
*/
|
|
1437
|
+
type Client = {
|
|
1438
|
+
/**
|
|
1439
|
+
* Add an offer to the mempool.
|
|
1440
|
+
* @returns The created offer with its hash.
|
|
1441
|
+
*/
|
|
1442
|
+
add: (parameters: AddParameters) => Promise<{
|
|
1443
|
+
offer: Offer;
|
|
1444
|
+
txHash: Hex;
|
|
1445
|
+
}>;
|
|
1446
|
+
/** Get offers from the mempool. */
|
|
1447
|
+
get: (parameters?: GetParameters) => AsyncGenerator<{
|
|
1448
|
+
offers: Offer[];
|
|
1449
|
+
/** The block number of the last processed offer. Depends on the `order` parameter, block numbers will ascend or descend. */
|
|
1450
|
+
blockNumber: number;
|
|
1451
|
+
}>;
|
|
1452
|
+
/**
|
|
1453
|
+
* Watch for new offers on a specific chain.
|
|
1454
|
+
* @returns A function to stop watching for new offers.
|
|
1455
|
+
*/
|
|
1456
|
+
watch: (parameters: WatchParameters) => () => boolean;
|
|
1457
|
+
/**
|
|
1458
|
+
* Stream offers from the mempool.
|
|
1459
|
+
* @returns A generator of offers alongside the last block number processed.
|
|
1460
|
+
*/
|
|
1461
|
+
stream: (parameters: Compute<Omit<GetParameters, "options"> & {
|
|
1462
|
+
options: GetParameters["options"] & {
|
|
1463
|
+
blockWindow?: number;
|
|
1464
|
+
};
|
|
1465
|
+
}>) => AsyncGenerator<{
|
|
1466
|
+
offers: Offer[];
|
|
1467
|
+
blockNumber: number;
|
|
1468
|
+
}>;
|
|
1469
|
+
};
|
|
1470
|
+
/**
|
|
1471
|
+
* Client to interact with the Mempool contract on a specific chain.
|
|
1472
|
+
*/
|
|
1473
|
+
declare function connect(parameters: from.Parameters): Client;
|
|
1474
|
+
declare namespace connect {
|
|
1475
|
+
type ErrorType = from.ErrorType;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
type MempoolClient_AddParameters = AddParameters;
|
|
1479
|
+
type MempoolClient_Client = Client;
|
|
1480
|
+
type MempoolClient_GetParameters = GetParameters;
|
|
1481
|
+
type MempoolClient_WatchParameters = WatchParameters;
|
|
1482
|
+
declare const MempoolClient_connect: typeof connect;
|
|
1483
|
+
declare namespace MempoolClient {
|
|
1484
|
+
export { type MempoolClient_AddParameters as AddParameters, type MempoolClient_Client as Client, type MempoolClient_GetParameters as GetParameters, type MempoolClient_WatchParameters as WatchParameters, MempoolClient_connect as connect };
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
declare function max$1(a: bigint, b: bigint): bigint;
|
|
1488
|
+
declare function min(a: bigint, b: bigint): bigint;
|
|
1489
|
+
|
|
1490
|
+
/**
|
|
1491
|
+
* Splits an array into batches of a specified size.
|
|
1492
|
+
* @param array The array to split.
|
|
1493
|
+
* @param batchSize The size of each batch.
|
|
1494
|
+
* @returns An iterator that yields each batch.
|
|
1495
|
+
* @example
|
|
1496
|
+
* ```typescript
|
|
1497
|
+
* const array = [1, 2, 3, 4, 5];
|
|
1498
|
+
* for (const batch of batch(array, 2)) {
|
|
1499
|
+
* console.log(batch);
|
|
1500
|
+
* }
|
|
1501
|
+
* // Output:
|
|
1502
|
+
* // [1, 2]
|
|
1503
|
+
* // [3, 4]
|
|
1504
|
+
* // [5]
|
|
1505
|
+
* ```
|
|
1506
|
+
*/
|
|
1507
|
+
declare function batch<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* Helper function to execute multicall in batches with retry logic.
|
|
1511
|
+
* Abstracts the common pattern of batching calls, retrying, and collecting results.
|
|
1512
|
+
*
|
|
1513
|
+
* @param parameters - Configuration for batched multicall
|
|
1514
|
+
* @returns Promise resolving to flattened array of results
|
|
1515
|
+
*/
|
|
1516
|
+
declare function batchMulticall<TResult>(parameters: {
|
|
1517
|
+
client: Pick<PublicActions, "multicall">;
|
|
1518
|
+
calls: unknown[];
|
|
1519
|
+
batchSize: number;
|
|
1520
|
+
retryAttempts: number;
|
|
1521
|
+
retryDelayMs: number;
|
|
1522
|
+
blockNumber?: bigint;
|
|
1523
|
+
}): Promise<TResult[]>;
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* Transform a polling function into an async generator.
|
|
1527
|
+
* @param fn - The polling function to transform.
|
|
1528
|
+
* @returns An async generator.
|
|
1529
|
+
*/
|
|
1530
|
+
declare function lazy<T>(pollFn: (emit: (value: T) => void, { stop }: {
|
|
1531
|
+
stop: () => void;
|
|
1532
|
+
}) => () => boolean): () => AsyncGenerator<Awaited<NonNullable<T>>, void, unknown>;
|
|
1533
|
+
|
|
1534
|
+
/**
|
|
1535
|
+
* Polls a function at a specified interval.
|
|
1536
|
+
* Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
|
|
1537
|
+
*/
|
|
1538
|
+
declare function poll<data>(fn: ({ unpoll }: {
|
|
1539
|
+
unpoll: () => void;
|
|
1540
|
+
}) => Promise<data | undefined>, { interval }: {
|
|
1541
|
+
interval: number;
|
|
1542
|
+
}): () => boolean;
|
|
1543
|
+
|
|
1544
|
+
declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
|
|
1545
|
+
|
|
1546
|
+
declare function now(): number;
|
|
1547
|
+
declare function max(): number;
|
|
1548
|
+
|
|
1549
|
+
declare const time_max: typeof max;
|
|
1550
|
+
declare const time_now: typeof now;
|
|
1551
|
+
declare namespace time {
|
|
1552
|
+
export { time_max as max, time_now as now };
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
declare function wait(time: number): Promise<unknown>;
|
|
1556
|
+
|
|
1557
|
+
type index_BaseError<cause extends Error | undefined = undefined> = BaseError<cause>;
|
|
1558
|
+
declare const index_BaseError: typeof BaseError;
|
|
1559
|
+
type index_GlobalErrorType<name extends string = "Error"> = GlobalErrorType<name>;
|
|
1560
|
+
type index_Snake<T> = Snake<T>;
|
|
1561
|
+
declare const index_batch: typeof batch;
|
|
1562
|
+
declare const index_batchMulticall: typeof batchMulticall;
|
|
1563
|
+
declare const index_lazy: typeof lazy;
|
|
1564
|
+
declare const index_min: typeof min;
|
|
1565
|
+
declare const index_poll: typeof poll;
|
|
1566
|
+
declare const index_retry: typeof retry;
|
|
1567
|
+
declare const index_wait: typeof wait;
|
|
1568
|
+
declare namespace index {
|
|
1569
|
+
export { index_BaseError as BaseError, type index_GlobalErrorType as GlobalErrorType, type index_Snake as Snake, time as Time, index_batch as batch, index_batchMulticall as batchMulticall, fromSnakeCase$2 as fromSnakeCase, index_lazy as lazy, max$1 as max, index_min as min, index_poll as poll, index_retry as retry, toSnakeCase$1 as toSnakeCase, index_wait as wait };
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
export { Abi, type Brand, BrandTypeId, Callback, Chain$1 as Chain, Collateral$1 as Collateral, type Compute, Cursor$1 as Cursor, Errors, Format, LLTV$1 as LLTV, Liquidity, Maturity$1 as Maturity, MempoolClient as Mempool, Obligation$1 as Obligation, Offer$1 as Offer, index$1 as RouterApi, Client$2 as RouterClient, time as Time, index as Utils, Validation, ValidationRule };
|