@morpho-dev/router 0.1.18 → 0.2.1
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 +29 -19
- package/dist/chunk-jass6xSI.mjs +13 -0
- package/dist/cli.js +6574 -6194
- package/dist/drizzle/migrations/0000_setup_single_migration_folder.sql +204 -0
- package/dist/drizzle/migrations/0001_add-trigger-for-consumed-events.sql +58 -0
- package/dist/drizzle/migrations/0002_insert-status-code.sql +1 -0
- package/dist/drizzle/migrations/0003_update-triggers-for-consumed-events.sql +3 -0
- package/dist/drizzle/migrations/0004_drop-status-offers-foreign-key-constraint.sql +1 -0
- package/dist/drizzle/migrations/0005_add-index-to-boost-group-query-and-offer-hash.sql +1 -0
- package/dist/drizzle/migrations/0006_add-callbacks-and-positions-relations.sql +37 -0
- package/dist/drizzle/migrations/0008_validation.sql +15 -0
- package/dist/drizzle/migrations/0009_add-transfers-table.sql +14 -0
- package/dist/drizzle/migrations/0010_add-price.sql +1 -0
- package/dist/drizzle/migrations/0011_nullable-callback-amount.sql +1 -0
- package/dist/drizzle/migrations/0012_add-position-asset.sql +1 -0
- package/dist/drizzle/migrations/0013_remove-depecrated-domains.sql +13 -0
- package/dist/drizzle/migrations/0014_rename-offers-v2-into-offers.sql +23 -0
- package/dist/drizzle/{router_v1.4 → migrations}/meta/0000_snapshot.json +858 -78
- package/dist/drizzle/migrations/meta/0001_snapshot.json +1752 -0
- package/dist/drizzle/migrations/meta/0002_snapshot.json +1752 -0
- package/dist/drizzle/migrations/meta/0003_snapshot.json +1752 -0
- package/dist/drizzle/{router_v1.4/meta/0001_snapshot.json → migrations/meta/0004_snapshot.json} +848 -78
- package/dist/drizzle/migrations/meta/0005_snapshot.json +1775 -0
- package/dist/drizzle/migrations/meta/0006_snapshot.json +1973 -0
- package/dist/drizzle/migrations/meta/0008_snapshot.json +1955 -0
- package/dist/drizzle/migrations/meta/0009_snapshot.json +2078 -0
- package/dist/drizzle/migrations/meta/0010_snapshot.json +2084 -0
- package/dist/drizzle/migrations/meta/0013_snapshot.json +1290 -0
- package/dist/drizzle/migrations/meta/0014_snapshot.json +1290 -0
- package/dist/drizzle/migrations/meta/_journal.json +104 -0
- package/dist/index.browser.d.mts +2794 -0
- package/dist/index.browser.d.mts.map +1 -0
- package/dist/index.browser.d.ts +2290 -1172
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +3820 -2519
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +3615 -2467
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.mts +4987 -0
- package/dist/index.node.d.mts.map +1 -0
- package/dist/index.node.d.ts +4423 -2906
- package/dist/index.node.d.ts.map +1 -0
- package/dist/index.node.js +7810 -6141
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +7556 -6102
- package/dist/index.node.mjs.map +1 -1
- package/package.json +29 -15
- package/dist/cli.js.map +0 -1
- package/dist/drizzle/router_v1.4/0000_add_obligation_id.sql +0 -112
- package/dist/drizzle/router_v1.4/0001_update-primary-key-on-link.sql +0 -3
- package/dist/drizzle/router_v1.4/meta/_journal.json +0 -20
- package/dist/index.browser.d.cts +0 -1675
- package/dist/index.node.d.cts +0 -3471
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,267 +1,369 @@
|
|
|
1
|
-
import { z
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { AbiEvent, Address, ChainContract, ChainFormatters, GetLogsReturnType, Hex, MulticallParameters, PublicClient, Transport, WalletClient } from "viem";
|
|
3
|
+
import { Chain } from "viem/chains";
|
|
4
|
+
import * as z$1 from "zod";
|
|
5
|
+
import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
|
|
6
|
+
import { OpenAPIDocument } from "openapi-metadata";
|
|
7
|
+
import { Client } from "openapi-fetch";
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
9
|
+
//#region rolldown:runtime
|
|
10
|
+
declare namespace BookResponse_d_exports {
|
|
11
|
+
export { BookLevelResponse, from$13 as from };
|
|
12
|
+
}
|
|
13
|
+
type BookLevelResponse = {
|
|
14
|
+
rate: string;
|
|
15
|
+
assets: string;
|
|
16
|
+
count: number;
|
|
17
|
+
};
|
|
18
|
+
declare function from$13(level: {
|
|
19
|
+
rate: bigint;
|
|
20
|
+
assets: bigint;
|
|
21
|
+
count: number;
|
|
22
|
+
}): BookLevelResponse;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/api/Schema/health.d.ts
|
|
25
|
+
declare const CollectorHealth: z.ZodObject<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
chain_id: z.ZodNumber;
|
|
28
|
+
block_number: z.ZodNullable<z.ZodNumber>;
|
|
29
|
+
updated_at: z.ZodNullable<z.ZodString>;
|
|
30
|
+
lag: z.ZodNullable<z.ZodNumber>;
|
|
31
|
+
status: z.ZodEnum<{
|
|
32
|
+
live: "live";
|
|
33
|
+
lagging: "lagging";
|
|
34
|
+
unknown: "unknown";
|
|
35
|
+
}>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
chain_id: z.ZodNumber;
|
|
40
|
+
block_number: z.ZodNullable<z.ZodNumber>;
|
|
41
|
+
updated_at: z.ZodNullable<z.ZodString>;
|
|
42
|
+
lag: z.ZodNullable<z.ZodNumber>;
|
|
43
|
+
status: z.ZodEnum<{
|
|
44
|
+
live: "live";
|
|
45
|
+
lagging: "lagging";
|
|
46
|
+
unknown: "unknown";
|
|
47
|
+
}>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
declare const ChainHealth: z.ZodObject<{
|
|
50
|
+
chain_id: z.ZodNumber;
|
|
51
|
+
local_block_number: z.ZodNumber;
|
|
52
|
+
remote_block_number: z.ZodNullable<z.ZodNumber>;
|
|
53
|
+
updated_at: z.ZodString;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
declare const ChainsHealthResponse: z.ZodArray<z.ZodObject<{
|
|
56
|
+
chain_id: z.ZodNumber;
|
|
57
|
+
local_block_number: z.ZodNumber;
|
|
58
|
+
remote_block_number: z.ZodNullable<z.ZodNumber>;
|
|
59
|
+
updated_at: z.ZodString;
|
|
60
|
+
}, z.core.$strip>>;
|
|
61
|
+
declare const RouterStatusResponse: z.ZodObject<{
|
|
62
|
+
status: z.ZodEnum<{
|
|
63
|
+
live: "live";
|
|
64
|
+
syncing: "syncing";
|
|
65
|
+
}>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
type CollectorsHealthResponse = z.infer<typeof CollectorsHealthResponse>;
|
|
68
|
+
type ChainsHealthResponse = z.infer<typeof ChainsHealthResponse>;
|
|
69
|
+
type RouterStatusResponse = z.infer<typeof RouterStatusResponse>;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/core/Abi/MetaMorpho.d.ts
|
|
72
|
+
declare const MetaMorpho: readonly [{
|
|
73
|
+
readonly name: "balanceOf";
|
|
74
|
+
readonly type: "function";
|
|
75
|
+
readonly stateMutability: "view";
|
|
76
|
+
readonly inputs: readonly [{
|
|
77
|
+
readonly type: "address";
|
|
78
|
+
readonly name: "account";
|
|
79
|
+
}];
|
|
80
|
+
readonly outputs: readonly [{
|
|
81
|
+
readonly type: "uint256";
|
|
82
|
+
}];
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "DECIMALS_OFFSET";
|
|
85
|
+
readonly type: "function";
|
|
86
|
+
readonly stateMutability: "view";
|
|
87
|
+
readonly inputs: readonly [];
|
|
88
|
+
readonly outputs: readonly [{
|
|
89
|
+
readonly type: "uint8";
|
|
90
|
+
}];
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "totalAssets";
|
|
93
|
+
readonly type: "function";
|
|
94
|
+
readonly stateMutability: "view";
|
|
95
|
+
readonly inputs: readonly [];
|
|
96
|
+
readonly outputs: readonly [{
|
|
97
|
+
readonly type: "uint256";
|
|
98
|
+
}];
|
|
99
|
+
}, {
|
|
100
|
+
readonly name: "totalSupply";
|
|
101
|
+
readonly type: "function";
|
|
102
|
+
readonly stateMutability: "view";
|
|
103
|
+
readonly inputs: readonly [];
|
|
104
|
+
readonly outputs: readonly [{
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
}];
|
|
107
|
+
}, {
|
|
108
|
+
readonly name: "maxWithdraw";
|
|
109
|
+
readonly type: "function";
|
|
110
|
+
readonly stateMutability: "view";
|
|
111
|
+
readonly inputs: readonly [{
|
|
112
|
+
readonly type: "address";
|
|
113
|
+
readonly name: "owner";
|
|
114
|
+
}];
|
|
115
|
+
readonly outputs: readonly [{
|
|
116
|
+
readonly type: "uint256";
|
|
117
|
+
readonly name: "assets";
|
|
118
|
+
}];
|
|
119
|
+
}, {
|
|
120
|
+
readonly name: "asset";
|
|
121
|
+
readonly type: "function";
|
|
122
|
+
readonly stateMutability: "view";
|
|
123
|
+
readonly inputs: readonly [];
|
|
124
|
+
readonly outputs: readonly [{
|
|
125
|
+
readonly type: "address";
|
|
126
|
+
}];
|
|
127
|
+
}, {
|
|
128
|
+
readonly name: "Transfer";
|
|
129
|
+
readonly type: "event";
|
|
130
|
+
readonly inputs: readonly [{
|
|
131
|
+
readonly type: "address";
|
|
132
|
+
readonly name: "from";
|
|
133
|
+
readonly indexed: true;
|
|
134
|
+
}, {
|
|
135
|
+
readonly type: "address";
|
|
136
|
+
readonly name: "to";
|
|
137
|
+
readonly indexed: true;
|
|
138
|
+
}, {
|
|
139
|
+
readonly type: "uint256";
|
|
140
|
+
readonly name: "value";
|
|
141
|
+
}];
|
|
142
|
+
}, {
|
|
143
|
+
readonly name: "withdrawQueue";
|
|
144
|
+
readonly type: "function";
|
|
145
|
+
readonly stateMutability: "view";
|
|
146
|
+
readonly inputs: readonly [{
|
|
147
|
+
readonly type: "uint256";
|
|
148
|
+
readonly name: "index";
|
|
149
|
+
}];
|
|
150
|
+
readonly outputs: readonly [{
|
|
151
|
+
readonly type: "bytes32";
|
|
152
|
+
}];
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "withdrawQueueLength";
|
|
155
|
+
readonly type: "function";
|
|
156
|
+
readonly stateMutability: "view";
|
|
157
|
+
readonly inputs: readonly [];
|
|
158
|
+
readonly outputs: readonly [{
|
|
159
|
+
readonly type: "uint256";
|
|
160
|
+
}];
|
|
60
161
|
}];
|
|
61
|
-
|
|
62
|
-
|
|
162
|
+
type MetaMorpho = typeof MetaMorpho;
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/core/Abi/MetaMorphoFactory.d.ts
|
|
165
|
+
declare const MetaMorphoFactory: readonly [{
|
|
166
|
+
readonly name: "CreateMetaMorpho";
|
|
167
|
+
readonly type: "event";
|
|
168
|
+
readonly inputs: readonly [{
|
|
169
|
+
readonly type: "address";
|
|
170
|
+
readonly name: "metaMorpho";
|
|
171
|
+
readonly indexed: true;
|
|
172
|
+
}, {
|
|
173
|
+
readonly type: "address";
|
|
174
|
+
readonly name: "caller";
|
|
175
|
+
readonly indexed: true;
|
|
176
|
+
}, {
|
|
177
|
+
readonly type: "address";
|
|
178
|
+
readonly name: "initialOwner";
|
|
179
|
+
}, {
|
|
180
|
+
readonly type: "uint256";
|
|
181
|
+
readonly name: "initialTimelock";
|
|
182
|
+
}, {
|
|
183
|
+
readonly type: "address";
|
|
63
184
|
readonly name: "asset";
|
|
64
|
-
readonly
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
readonly
|
|
185
|
+
readonly indexed: true;
|
|
186
|
+
}, {
|
|
187
|
+
readonly type: "string";
|
|
188
|
+
readonly name: "name";
|
|
189
|
+
}, {
|
|
190
|
+
readonly type: "string";
|
|
191
|
+
readonly name: "symbol";
|
|
192
|
+
}, {
|
|
193
|
+
readonly type: "bytes32";
|
|
194
|
+
readonly name: "salt";
|
|
195
|
+
}];
|
|
196
|
+
}, {
|
|
197
|
+
readonly name: "isMetaMorpho";
|
|
198
|
+
readonly type: "function";
|
|
199
|
+
readonly stateMutability: "view";
|
|
200
|
+
readonly inputs: readonly [{
|
|
201
|
+
readonly type: "address";
|
|
202
|
+
}];
|
|
203
|
+
readonly outputs: readonly [{
|
|
204
|
+
readonly type: "bool";
|
|
205
|
+
}];
|
|
70
206
|
}];
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
207
|
+
type MetaMorphoFactory = typeof MetaMorphoFactory;
|
|
208
|
+
declare namespace index_d_exports {
|
|
209
|
+
export { ERC4626, MetaMorpho, MetaMorphoFactory, Morpho, Oracle$1 as Oracle };
|
|
210
|
+
}
|
|
211
|
+
declare const Oracle$1: readonly [{
|
|
212
|
+
readonly type: "function";
|
|
213
|
+
readonly name: "price";
|
|
214
|
+
readonly inputs: readonly [];
|
|
215
|
+
readonly outputs: readonly [{
|
|
216
|
+
readonly name: "";
|
|
217
|
+
readonly type: "uint256";
|
|
218
|
+
}];
|
|
219
|
+
readonly stateMutability: "view";
|
|
83
220
|
}];
|
|
84
|
-
declare const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
readonly type: "bytes32";
|
|
94
|
-
}];
|
|
95
|
-
readonly stateMutability: "view";
|
|
96
|
-
}, {
|
|
97
|
-
readonly type: "function";
|
|
98
|
-
readonly name: "withdrawQueueLength";
|
|
99
|
-
readonly inputs: readonly [];
|
|
100
|
-
readonly outputs: readonly [{
|
|
101
|
-
readonly name: "";
|
|
102
|
-
readonly type: "uint256";
|
|
103
|
-
}];
|
|
104
|
-
readonly stateMutability: "view";
|
|
105
|
-
}, {
|
|
106
|
-
readonly type: "function";
|
|
107
|
-
readonly name: "maxWithdraw";
|
|
108
|
-
readonly inputs: readonly [{
|
|
109
|
-
readonly name: "owner";
|
|
110
|
-
readonly type: "address";
|
|
111
|
-
}];
|
|
112
|
-
readonly outputs: readonly [{
|
|
113
|
-
readonly name: "";
|
|
114
|
-
readonly type: "uint256";
|
|
115
|
-
}];
|
|
116
|
-
readonly stateMutability: "view";
|
|
221
|
+
declare const ERC4626: readonly [{
|
|
222
|
+
readonly type: "function";
|
|
223
|
+
readonly name: "asset";
|
|
224
|
+
readonly inputs: readonly [];
|
|
225
|
+
readonly outputs: readonly [{
|
|
226
|
+
readonly name: "";
|
|
227
|
+
readonly type: "address";
|
|
228
|
+
}];
|
|
229
|
+
readonly stateMutability: "view";
|
|
117
230
|
}];
|
|
118
231
|
declare const Morpho: readonly [{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
232
|
+
readonly type: "function";
|
|
233
|
+
readonly name: "collateralOf";
|
|
234
|
+
readonly inputs: readonly [{
|
|
235
|
+
readonly name: "";
|
|
236
|
+
readonly type: "address";
|
|
237
|
+
readonly internalType: "address";
|
|
238
|
+
}, {
|
|
239
|
+
readonly name: "";
|
|
240
|
+
readonly type: "bytes32";
|
|
241
|
+
readonly internalType: "bytes32";
|
|
242
|
+
}, {
|
|
243
|
+
readonly name: "";
|
|
244
|
+
readonly type: "address";
|
|
245
|
+
readonly internalType: "address";
|
|
246
|
+
}];
|
|
247
|
+
readonly outputs: readonly [{
|
|
248
|
+
readonly name: "";
|
|
249
|
+
readonly type: "uint256";
|
|
250
|
+
readonly internalType: "uint256";
|
|
251
|
+
}];
|
|
252
|
+
readonly stateMutability: "view";
|
|
140
253
|
}, {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
254
|
+
readonly type: "function";
|
|
255
|
+
readonly name: "debtOf";
|
|
256
|
+
readonly inputs: readonly [{
|
|
257
|
+
readonly name: "";
|
|
258
|
+
readonly type: "address";
|
|
259
|
+
readonly internalType: "address";
|
|
260
|
+
}, {
|
|
261
|
+
readonly name: "";
|
|
262
|
+
readonly type: "bytes32";
|
|
263
|
+
readonly internalType: "bytes32";
|
|
264
|
+
}];
|
|
265
|
+
readonly outputs: readonly [{
|
|
266
|
+
readonly name: "";
|
|
267
|
+
readonly type: "uint256";
|
|
268
|
+
readonly internalType: "uint256";
|
|
269
|
+
}];
|
|
270
|
+
readonly stateMutability: "view";
|
|
158
271
|
}, {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
272
|
+
readonly type: "function";
|
|
273
|
+
readonly name: "market";
|
|
274
|
+
readonly inputs: readonly [{
|
|
275
|
+
readonly name: "id";
|
|
276
|
+
readonly type: "bytes32";
|
|
277
|
+
readonly internalType: "Id";
|
|
278
|
+
}];
|
|
279
|
+
readonly outputs: readonly [{
|
|
280
|
+
readonly name: "totalSupplyAssets";
|
|
281
|
+
readonly type: "uint128";
|
|
282
|
+
readonly internalType: "uint128";
|
|
283
|
+
}, {
|
|
284
|
+
readonly name: "totalSupplyShares";
|
|
285
|
+
readonly type: "uint128";
|
|
286
|
+
readonly internalType: "uint128";
|
|
287
|
+
}, {
|
|
288
|
+
readonly name: "totalBorrowAssets";
|
|
289
|
+
readonly type: "uint128";
|
|
290
|
+
readonly internalType: "uint128";
|
|
291
|
+
}, {
|
|
292
|
+
readonly name: "totalBorrowShares";
|
|
293
|
+
readonly type: "uint128";
|
|
294
|
+
readonly internalType: "uint128";
|
|
295
|
+
}, {
|
|
296
|
+
readonly name: "lastUpdate";
|
|
297
|
+
readonly type: "uint128";
|
|
298
|
+
readonly internalType: "uint128";
|
|
299
|
+
}, {
|
|
300
|
+
readonly name: "fee";
|
|
301
|
+
readonly type: "uint128";
|
|
302
|
+
readonly internalType: "uint128";
|
|
303
|
+
}];
|
|
304
|
+
readonly stateMutability: "view";
|
|
192
305
|
}, {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
306
|
+
readonly type: "function";
|
|
307
|
+
readonly name: "position";
|
|
308
|
+
readonly inputs: readonly [{
|
|
309
|
+
readonly name: "id";
|
|
310
|
+
readonly type: "bytes32";
|
|
311
|
+
readonly internalType: "Id";
|
|
312
|
+
}, {
|
|
313
|
+
readonly name: "user";
|
|
314
|
+
readonly type: "address";
|
|
315
|
+
readonly internalType: "address";
|
|
316
|
+
}];
|
|
317
|
+
readonly outputs: readonly [{
|
|
318
|
+
readonly name: "supplyShares";
|
|
319
|
+
readonly type: "uint256";
|
|
320
|
+
readonly internalType: "uint256";
|
|
321
|
+
}, {
|
|
322
|
+
readonly name: "borrowShares";
|
|
323
|
+
readonly type: "uint128";
|
|
324
|
+
readonly internalType: "uint128";
|
|
325
|
+
}, {
|
|
326
|
+
readonly name: "collateral";
|
|
327
|
+
readonly type: "uint128";
|
|
328
|
+
readonly internalType: "uint128";
|
|
329
|
+
}];
|
|
330
|
+
readonly stateMutability: "view";
|
|
218
331
|
}];
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
declare const Abi_MetaMorpho: typeof MetaMorpho;
|
|
222
|
-
declare const Abi_MetaMorphoFactory: typeof MetaMorphoFactory;
|
|
223
|
-
declare const Abi_Morpho: typeof Morpho;
|
|
224
|
-
declare const Abi_Oracle: typeof Oracle;
|
|
225
|
-
declare namespace Abi {
|
|
226
|
-
export { Abi_ERC4626 as ERC4626, Abi_MetaMorpho as MetaMorpho, Abi_MetaMorphoFactory as MetaMorphoFactory, Abi_Morpho as Morpho, Abi_Oracle as Oracle };
|
|
332
|
+
declare namespace Callback_d_exports {
|
|
333
|
+
export { CallbackType, decode$3 as decode, decodeBuyVaultV1Callback, decodeSellERC20Callback, encode$3 as encode, encodeBuyVaultV1Callback, encodeSellERC20Callback, isEmptyCallback };
|
|
227
334
|
}
|
|
228
|
-
|
|
229
335
|
declare enum CallbackType {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
336
|
+
BuyWithEmptyCallback = "buy_with_empty_callback",
|
|
337
|
+
BuyVaultV1Callback = "buy_vault_v1_callback",
|
|
338
|
+
SellERC20Callback = "sell_erc20_callback",
|
|
233
339
|
}
|
|
234
|
-
declare const
|
|
340
|
+
declare const isEmptyCallback: (offer: Offer) => boolean;
|
|
341
|
+
declare function decode$3(type: CallbackType, data: Hex): {
|
|
342
|
+
contract: Address;
|
|
343
|
+
amount: bigint;
|
|
344
|
+
}[];
|
|
345
|
+
declare function encode$3(type: CallbackType, data: any): Hex;
|
|
235
346
|
declare function decodeBuyVaultV1Callback(data: Hex): Array<{
|
|
236
|
-
|
|
237
|
-
|
|
347
|
+
contract: Address;
|
|
348
|
+
amount: bigint;
|
|
238
349
|
}>;
|
|
239
350
|
declare function decodeSellERC20Callback(data: Hex): Array<{
|
|
240
|
-
|
|
241
|
-
|
|
351
|
+
contract: Address;
|
|
352
|
+
amount: bigint;
|
|
242
353
|
}>;
|
|
243
354
|
declare function encodeBuyVaultV1Callback(parameters: {
|
|
244
|
-
|
|
245
|
-
|
|
355
|
+
vaults: Address[];
|
|
356
|
+
amounts: bigint[];
|
|
246
357
|
}): Hex;
|
|
247
358
|
declare function encodeSellERC20Callback(parameters: {
|
|
248
|
-
|
|
249
|
-
|
|
359
|
+
collaterals: Address[];
|
|
360
|
+
amounts: bigint[];
|
|
250
361
|
}): Hex;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
declare const Callback_CallbackType: typeof CallbackType;
|
|
254
|
-
declare const Callback_WhitelistedCallbackAddresses: typeof WhitelistedCallbackAddresses;
|
|
255
|
-
declare const Callback_decodeBuyVaultV1Callback: typeof decodeBuyVaultV1Callback;
|
|
256
|
-
declare const Callback_decodeSellERC20Callback: typeof decodeSellERC20Callback;
|
|
257
|
-
declare const Callback_encodeBuyVaultV1Callback: typeof encodeBuyVaultV1Callback;
|
|
258
|
-
declare const Callback_encodeSellERC20Callback: typeof encodeSellERC20Callback;
|
|
259
|
-
declare namespace Callback {
|
|
260
|
-
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 };
|
|
362
|
+
declare namespace Errors_d_exports {
|
|
363
|
+
export { BaseError, GlobalErrorType, ReorgError };
|
|
261
364
|
}
|
|
262
|
-
|
|
263
365
|
type GlobalErrorType<name extends string = "Error"> = Error & {
|
|
264
|
-
|
|
366
|
+
name: name;
|
|
265
367
|
};
|
|
266
368
|
/**
|
|
267
369
|
* Base error class inherited by all errors thrown by mempool.
|
|
@@ -273,117 +375,94 @@ type GlobalErrorType<name extends string = "Error"> = Error & {
|
|
|
273
375
|
* ```
|
|
274
376
|
*/
|
|
275
377
|
declare class BaseError<cause extends Error | undefined = undefined> extends Error {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
378
|
+
details: string;
|
|
379
|
+
shortMessage: string;
|
|
380
|
+
cause: cause;
|
|
381
|
+
name: string;
|
|
382
|
+
constructor(shortMessage: string, options?: {
|
|
383
|
+
cause?: cause | undefined;
|
|
384
|
+
details?: string | undefined;
|
|
385
|
+
metaMessages?: (string | undefined)[] | undefined;
|
|
386
|
+
});
|
|
387
|
+
walk(): Error;
|
|
388
|
+
walk(fn: (err: unknown) => boolean): Error | null;
|
|
287
389
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
type Errors_GlobalErrorType<name extends string = "Error"> = GlobalErrorType<name>;
|
|
292
|
-
declare namespace Errors {
|
|
293
|
-
export { Errors_BaseError as BaseError, type Errors_GlobalErrorType as GlobalErrorType };
|
|
390
|
+
declare class ReorgError extends BaseError {
|
|
391
|
+
name: string;
|
|
392
|
+
constructor(blockNumber: number);
|
|
294
393
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
394
|
+
declare namespace Chain_d_exports {
|
|
395
|
+
export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name, chainIds, chainNames, chains$1 as chains, getChain, getWhitelistedChains, streamLogs };
|
|
396
|
+
}
|
|
397
|
+
type Chain$1 = Compute<Chain<ChainFormatters, {
|
|
398
|
+
morpho: ChainContract;
|
|
399
|
+
morphoBlue: ChainContract;
|
|
400
|
+
mempool: ChainContract;
|
|
401
|
+
vaults: {
|
|
402
|
+
factories: {
|
|
403
|
+
v1_0: ChainContract;
|
|
404
|
+
v1_1: ChainContract;
|
|
304
405
|
};
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
406
|
+
};
|
|
407
|
+
}> & {
|
|
408
|
+
id: Id;
|
|
409
|
+
name: Name;
|
|
410
|
+
}>;
|
|
309
411
|
declare const ChainId: {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
412
|
+
readonly ETHEREUM: 1;
|
|
413
|
+
readonly BASE: 8453;
|
|
414
|
+
readonly "ETHEREUM-VIRTUAL-TESTNET": 109111114;
|
|
415
|
+
readonly ANVIL: 505050505;
|
|
314
416
|
};
|
|
315
|
-
type
|
|
316
|
-
declare const
|
|
317
|
-
type
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
morphoBlue: Address;
|
|
323
|
-
mempool: {
|
|
324
|
-
address: Address;
|
|
325
|
-
deploymentBlock: number;
|
|
326
|
-
reindexBuffer: number;
|
|
327
|
-
};
|
|
328
|
-
vaultV1Factory: Record<string, Address>;
|
|
329
|
-
}>;
|
|
330
|
-
declare function getChain(chainId: Id): Chain | undefined;
|
|
331
|
-
declare const getWhitelistedChains: () => Chain[];
|
|
332
|
-
declare const chains: Record<ChainName, Chain>;
|
|
417
|
+
type Name = Lowercase<keyof typeof ChainId>;
|
|
418
|
+
declare const chainNames: readonly Name[];
|
|
419
|
+
type Id = (typeof ChainId)[Uppercase<Name>];
|
|
420
|
+
declare const chainIds: readonly Id[];
|
|
421
|
+
declare function getChain(chainId: Id): Chain$1 | undefined;
|
|
422
|
+
declare const getWhitelistedChains: () => Chain$1[];
|
|
423
|
+
declare const chains$1: Record<Lowercase<Name>, Chain$1>;
|
|
333
424
|
declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(parameters: {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
425
|
+
client: PublicClient;
|
|
426
|
+
contractAddress?: Address;
|
|
427
|
+
event?: abiEvent;
|
|
428
|
+
blockNumberGte?: number;
|
|
429
|
+
blockNumberLte?: number;
|
|
430
|
+
order: "asc" | "desc";
|
|
431
|
+
options: {
|
|
432
|
+
maxBatchSize?: number;
|
|
433
|
+
blockWindow?: number;
|
|
434
|
+
};
|
|
344
435
|
}): AsyncGenerator<{
|
|
345
|
-
|
|
346
|
-
|
|
436
|
+
logs: GetLogsReturnType<abiEvent | undefined>;
|
|
437
|
+
blockNumber: number;
|
|
347
438
|
}, void, void>;
|
|
348
439
|
declare class InvalidBlockRangeError extends BaseError {
|
|
349
|
-
|
|
350
|
-
|
|
440
|
+
name: string;
|
|
441
|
+
constructor(fromBlock: bigint, toBlock: bigint);
|
|
351
442
|
}
|
|
352
443
|
declare class InvalidBlockWindowError extends BaseError {
|
|
353
|
-
|
|
354
|
-
|
|
444
|
+
name: string;
|
|
445
|
+
constructor(blockWindow: number);
|
|
355
446
|
}
|
|
356
447
|
declare class InvalidBatchSizeError extends BaseError {
|
|
357
|
-
|
|
358
|
-
|
|
448
|
+
name: string;
|
|
449
|
+
constructor(maxBatchSize: number);
|
|
359
450
|
}
|
|
360
451
|
declare class MissingBlockNumberError extends BaseError {
|
|
361
|
-
|
|
362
|
-
|
|
452
|
+
name: string;
|
|
453
|
+
constructor();
|
|
363
454
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
type
|
|
368
|
-
|
|
369
|
-
type
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
declare
|
|
373
|
-
|
|
374
|
-
declare const Chain$1_InvalidBlockWindowError: typeof InvalidBlockWindowError;
|
|
375
|
-
type Chain$1_MissingBlockNumberError = MissingBlockNumberError;
|
|
376
|
-
declare const Chain$1_MissingBlockNumberError: typeof MissingBlockNumberError;
|
|
377
|
-
declare const Chain$1_chainIds: typeof chainIds;
|
|
378
|
-
declare const Chain$1_chainNames: typeof chainNames;
|
|
379
|
-
declare const Chain$1_chains: typeof chains;
|
|
380
|
-
declare const Chain$1_getChain: typeof getChain;
|
|
381
|
-
declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
|
|
382
|
-
declare const Chain$1_streamLogs: typeof streamLogs;
|
|
383
|
-
declare namespace Chain$1 {
|
|
384
|
-
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 };
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/core/types.d.ts
|
|
457
|
+
/** Combines members of an intersection into a readable type. */
|
|
458
|
+
type Compute<type> = { [key in keyof type]: type[key] } & unknown;
|
|
459
|
+
declare const BrandTypeId: unique symbol;
|
|
460
|
+
type Brand<in out ID extends string | symbol> = {
|
|
461
|
+
readonly [BrandTypeId]: { readonly [id in ID]: ID };
|
|
462
|
+
};
|
|
463
|
+
declare namespace LLTV_d_exports {
|
|
464
|
+
export { InvalidLLTVError, InvalidOptionError$1 as InvalidOptionError, LLTV, LLTVSchema, Options, from$12 as from };
|
|
385
465
|
}
|
|
386
|
-
|
|
387
466
|
type LLTV = bigint & Brand<"LLTV">;
|
|
388
467
|
declare const Options: readonly [0.385, 0.5, 0.625, 0.77, 0.86, 0.915, 0.945, 0.965, 0.98];
|
|
389
468
|
type Options = (typeof Options)[number];
|
|
@@ -392,76 +471,161 @@ type Options = (typeof Options)[number];
|
|
|
392
471
|
* @param lltv - The LLTV option or the scaled LLTV.
|
|
393
472
|
* @returns The LLTV.
|
|
394
473
|
*/
|
|
395
|
-
declare function from$
|
|
396
|
-
declare namespace from$
|
|
397
|
-
|
|
474
|
+
declare function from$12(lltv: Options | bigint): LLTV;
|
|
475
|
+
declare namespace from$12 {
|
|
476
|
+
type ErrorType = InvalidOptionError$1 | InvalidLLTVError;
|
|
398
477
|
}
|
|
399
478
|
declare class InvalidOptionError$1 extends BaseError {
|
|
400
|
-
|
|
401
|
-
|
|
479
|
+
readonly name = "LLTV.InvalidOptionError";
|
|
480
|
+
constructor(input: number);
|
|
402
481
|
}
|
|
403
482
|
declare class InvalidLLTVError extends BaseError {
|
|
404
|
-
|
|
405
|
-
|
|
483
|
+
readonly name = "LLTV.InvalidLLTVError";
|
|
484
|
+
constructor(input: bigint);
|
|
406
485
|
}
|
|
407
|
-
declare const LLTVSchema: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
declare const LLTV$1_InvalidLLTVError: typeof InvalidLLTVError;
|
|
411
|
-
type LLTV$1_LLTV = LLTV;
|
|
412
|
-
declare const LLTV$1_LLTVSchema: typeof LLTVSchema;
|
|
413
|
-
type LLTV$1_Options = Options;
|
|
414
|
-
declare namespace LLTV$1 {
|
|
415
|
-
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$8 as from };
|
|
486
|
+
declare const LLTVSchema: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
487
|
+
declare namespace Collateral_d_exports {
|
|
488
|
+
export { Collateral, CollateralSchema, CollateralsSchema, from$11 as from, random$3 as random };
|
|
416
489
|
}
|
|
417
|
-
|
|
418
490
|
type Collateral = {
|
|
419
|
-
|
|
491
|
+
/** Asset being used as collateral. */
|
|
492
|
+
asset: Address;
|
|
493
|
+
/** Liquidation Loan-to-Value of the collateral. */
|
|
494
|
+
lltv: LLTV;
|
|
495
|
+
/** Oracle contract used to price the collateral. */
|
|
496
|
+
oracle: Address;
|
|
497
|
+
};
|
|
498
|
+
declare const CollateralSchema: z$1.ZodObject<{
|
|
499
|
+
asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
500
|
+
oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
501
|
+
lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
502
|
+
}, z$1.core.$strip>;
|
|
503
|
+
declare const CollateralsSchema: z$1.ZodArray<z$1.ZodObject<{
|
|
504
|
+
asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
505
|
+
oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
506
|
+
lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
507
|
+
}, z$1.core.$strip>>;
|
|
508
|
+
declare const from$11: (parameters: from$11.Parameters) => from$11.ReturnType;
|
|
509
|
+
declare namespace from$11 {
|
|
510
|
+
type Parameters = {
|
|
420
511
|
asset: Address;
|
|
421
|
-
|
|
422
|
-
lltv: LLTV;
|
|
423
|
-
/** Oracle contract used to price the collateral. */
|
|
512
|
+
lltv: Options | bigint;
|
|
424
513
|
oracle: Address;
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
428
|
-
oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
429
|
-
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
|
|
430
|
-
}, z.core.$strip>;
|
|
431
|
-
declare const CollateralsSchema: z.ZodArray<z.ZodObject<{
|
|
432
|
-
asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
433
|
-
oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
434
|
-
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<LLTV, bigint>>;
|
|
435
|
-
}, z.core.$strip>>;
|
|
436
|
-
declare const from$7: (parameters: from$7.Parameters) => from$7.ReturnType;
|
|
437
|
-
declare namespace from$7 {
|
|
438
|
-
type Parameters = {
|
|
439
|
-
asset: Address;
|
|
440
|
-
lltv: Options | bigint;
|
|
441
|
-
oracle: Address;
|
|
442
|
-
};
|
|
443
|
-
type ReturnType = Collateral;
|
|
514
|
+
};
|
|
515
|
+
type ReturnType = Collateral;
|
|
444
516
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
517
|
+
/**
|
|
518
|
+
* Generates a random collateral.
|
|
519
|
+
* @returns A randomly generated collateral. {@link random.ReturnType}
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```ts
|
|
523
|
+
* const collateral = Collateral.random();
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
declare function random$3(): random$3.ReturnType;
|
|
527
|
+
declare namespace random$3 {
|
|
528
|
+
type ReturnType = Collateral;
|
|
529
|
+
}
|
|
530
|
+
declare namespace ERC4626_d_exports {
|
|
531
|
+
export { DenominatorIsZeroError, convertToAssets, convertToShares, decimalsOffset };
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Calculate the decimals offset used by the ERC4626 implementation.
|
|
535
|
+
* @param parameters - {@link decimalsOffset.Parameters}.
|
|
536
|
+
* @returns The decimals offset.
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* ```ts
|
|
540
|
+
* const decimalsOffset = decimalsOffset({ underlyingDecimals: 6 });
|
|
541
|
+
* // decimalsOffset = 12
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
declare function decimalsOffset(parameters: decimalsOffset.Parameters): number;
|
|
545
|
+
declare namespace decimalsOffset {
|
|
546
|
+
type Parameters = {
|
|
547
|
+
/** The number of decimals of the underlying asset. */
|
|
548
|
+
underlyingDecimals: number;
|
|
549
|
+
};
|
|
550
|
+
type ReturnType = number;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Convert shares to assets.
|
|
554
|
+
* @throws If the denominator is 0. {@link DenominatorIsZeroError}
|
|
555
|
+
* @param parameters - {@link convertToAssets.Parameters}.
|
|
556
|
+
* @returns The amount of assets.
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```ts
|
|
560
|
+
* const assets = convertToAssets(100n, { totalAssets: 1000n, totalSupply: 1000n, decimalsOffset: 18 });
|
|
561
|
+
* // assets = 100n
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
declare function convertToAssets(parameters: convertToAssets.Parameters): convertToAssets.ReturnType;
|
|
565
|
+
declare namespace convertToAssets {
|
|
566
|
+
type Parameters = {
|
|
567
|
+
/** The amount of shares to convert. */
|
|
568
|
+
shares: bigint;
|
|
569
|
+
/** Total amount of assets in the vault. */
|
|
570
|
+
totalAssets: bigint;
|
|
571
|
+
/** Total amount of shares in the vault. */
|
|
572
|
+
totalSupply: bigint;
|
|
573
|
+
/**
|
|
574
|
+
* OpenZeppelin decimals offset used by the ERC4626 implementation.
|
|
575
|
+
* Calculated to be `max(0, 18 - underlyingDecimals)` at construction, so the initial conversion rate maximizes
|
|
576
|
+
* precision between shares and assets.
|
|
577
|
+
*/
|
|
578
|
+
decimalsOffset: number;
|
|
579
|
+
};
|
|
580
|
+
type ReturnType = bigint;
|
|
581
|
+
type ErrorType = DenominatorIsZeroError;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Convert assets to shares.
|
|
585
|
+
* @throws If the denominator is 0. {@link DenominatorIsZeroError}
|
|
586
|
+
* @param parameters - {@link convertToShares.Parameters}.
|
|
587
|
+
* @returns The amount of shares.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```ts
|
|
591
|
+
* const shares = convertToShares(100n, { totalAssets: 1000n, totalSupply: 1000n, decimalsOffset: 12 });
|
|
592
|
+
* // shares = 100n
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
declare function convertToShares(parameters: convertToShares.Parameters): convertToShares.ReturnType;
|
|
596
|
+
declare namespace convertToShares {
|
|
597
|
+
type Parameters = {
|
|
598
|
+
/** The amount of assets to convert. */
|
|
599
|
+
assets: bigint;
|
|
600
|
+
/** Total amount of assets in the vault. */
|
|
601
|
+
totalAssets: bigint;
|
|
602
|
+
/** Total amount of shares in the vault. */
|
|
603
|
+
totalSupply: bigint;
|
|
604
|
+
/**
|
|
605
|
+
* OpenZeppelin decimals offset used by the ERC4626 implementation.
|
|
606
|
+
* Calculated to be `max(0, 18 - underlyingDecimals)` at construction, so the initial conversion rate maximizes
|
|
607
|
+
* precision between shares and assets.
|
|
608
|
+
*/
|
|
609
|
+
decimalsOffset: number;
|
|
610
|
+
};
|
|
611
|
+
type ReturnType = bigint;
|
|
612
|
+
type ErrorType = DenominatorIsZeroError;
|
|
613
|
+
}
|
|
614
|
+
declare class DenominatorIsZeroError extends BaseError {
|
|
615
|
+
readonly name = "ERC4626.DenominatorIsZeroError";
|
|
616
|
+
constructor();
|
|
617
|
+
}
|
|
618
|
+
declare namespace Format_d_exports {
|
|
619
|
+
export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
|
|
451
620
|
}
|
|
452
|
-
|
|
453
621
|
/** The snake case representation of a type with bigint values stringified. */
|
|
454
|
-
type Snake<T> = SnakeKeys<StringifiedBigint<T
|
|
622
|
+
type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
|
|
623
|
+
/** Make arrays/tuples and object props mutable, deeply. */
|
|
624
|
+
type DeepMutable<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? { -readonly [K in keyof R]: DeepMutable<R[K]> } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? { -readonly [K in keyof T]: DeepMutable<T[K]> } : T;
|
|
455
625
|
/** Stringifies bigint values to strings and preserves branded primitives. */
|
|
456
|
-
type StringifiedBigint<T> = [
|
|
457
|
-
T
|
|
458
|
-
] 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 ? {
|
|
459
|
-
[K in keyof T]: StringifiedBigint<T[K]>;
|
|
460
|
-
} : T;
|
|
626
|
+
type StringifiedBigint<T> = [T] extends [bigint] ? string : [T] extends [`0x${string}`] ? 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 ? { [K in keyof T]: StringifiedBigint<T[K]> } : T;
|
|
461
627
|
/** Key remapping that also preserves branded primitives. */
|
|
462
|
-
type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? {
|
|
463
|
-
[K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]>;
|
|
464
|
-
} : T;
|
|
628
|
+
type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? { [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]> } : T;
|
|
465
629
|
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;
|
|
466
630
|
/**
|
|
467
631
|
* Formats object keys to snake case.
|
|
@@ -477,24 +641,30 @@ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
|
|
|
477
641
|
* @warning Does not unstringify bigint values.
|
|
478
642
|
*/
|
|
479
643
|
declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
export { type Format_Snake as Snake, fromSnakeCase$3 as fromSnakeCase, toSnakeCase$1 as toSnakeCase };
|
|
644
|
+
declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
|
|
645
|
+
declare namespace Maturity_d_exports {
|
|
646
|
+
export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$10 as from };
|
|
484
647
|
}
|
|
485
|
-
|
|
486
648
|
/**
|
|
487
649
|
* Maturity is a number that represents a date in seconds.
|
|
488
650
|
*/
|
|
489
651
|
type Maturity = number & Brand<"Maturity">;
|
|
490
|
-
declare const MaturitySchema: z.ZodPipe<z.ZodNumber, z.ZodTransform<Maturity, number>>;
|
|
652
|
+
declare const MaturitySchema: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
|
|
653
|
+
declare enum MaturityType {
|
|
654
|
+
EndOfWeek = "end_of_week",
|
|
655
|
+
EndOfNextWeek = "end_of_next_week",
|
|
656
|
+
EndOfMonth = "end_of_month",
|
|
657
|
+
EndOfNextMonth = "end_of_next_month",
|
|
658
|
+
EndOfQuarter = "end_of_quarter",
|
|
659
|
+
EndOfNextQuarter = "end_of_next_quarter",
|
|
660
|
+
}
|
|
491
661
|
declare const MaturityOptions: {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
662
|
+
readonly end_of_week: () => Maturity;
|
|
663
|
+
readonly end_of_next_week: () => Maturity;
|
|
664
|
+
readonly end_of_month: () => Maturity;
|
|
665
|
+
readonly end_of_next_month: () => Maturity;
|
|
666
|
+
readonly end_of_quarter: () => Maturity;
|
|
667
|
+
readonly end_of_next_quarter: () => Maturity;
|
|
498
668
|
};
|
|
499
669
|
type MaturityOptions = keyof typeof MaturityOptions;
|
|
500
670
|
/**
|
|
@@ -503,112 +673,117 @@ type MaturityOptions = keyof typeof MaturityOptions;
|
|
|
503
673
|
* @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
|
|
504
674
|
* @throws {InvalidOptionError} If the maturity is not a valid option.
|
|
505
675
|
*/
|
|
506
|
-
declare function from$
|
|
507
|
-
declare namespace from$
|
|
508
|
-
|
|
509
|
-
|
|
676
|
+
declare function from$10(ts: from$10.Parameters): Maturity;
|
|
677
|
+
declare namespace from$10 {
|
|
678
|
+
type Parameters = number | MaturityOptions;
|
|
679
|
+
type ErrorType = InvalidFormatError | InvalidDateError | InvalidOptionError;
|
|
510
680
|
}
|
|
511
681
|
declare class InvalidFormatError extends BaseError {
|
|
512
|
-
|
|
513
|
-
|
|
682
|
+
readonly name = "Maturity.InvalidFormatError";
|
|
683
|
+
constructor();
|
|
514
684
|
}
|
|
515
685
|
declare class InvalidDateError extends BaseError {
|
|
516
|
-
|
|
517
|
-
|
|
686
|
+
readonly name = "Maturity.InvalidDateError";
|
|
687
|
+
constructor(input: number);
|
|
518
688
|
}
|
|
519
689
|
declare class InvalidOptionError extends BaseError {
|
|
520
|
-
|
|
521
|
-
|
|
690
|
+
readonly name = "Maturity.InvalidOptionError";
|
|
691
|
+
constructor(input: string);
|
|
522
692
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
declare const Maturity$1_InvalidDateError: typeof InvalidDateError;
|
|
526
|
-
type Maturity$1_InvalidFormatError = InvalidFormatError;
|
|
527
|
-
declare const Maturity$1_InvalidFormatError: typeof InvalidFormatError;
|
|
528
|
-
type Maturity$1_InvalidOptionError = InvalidOptionError;
|
|
529
|
-
declare const Maturity$1_InvalidOptionError: typeof InvalidOptionError;
|
|
530
|
-
type Maturity$1_Maturity = Maturity;
|
|
531
|
-
type Maturity$1_MaturityOptions = MaturityOptions;
|
|
532
|
-
declare const Maturity$1_MaturitySchema: typeof MaturitySchema;
|
|
533
|
-
declare namespace Maturity$1 {
|
|
534
|
-
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$6 as from };
|
|
693
|
+
declare namespace Offer_d_exports {
|
|
694
|
+
export { AccountNotSetError, InvalidOfferError, Offer, OfferConsumed, OfferHashSchema, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$2 as decode, domain, encode$2 as encode, from$9 as from, fromSnakeCase$2 as fromSnakeCase, hash, obligationId, random$2 as random, sign, signatureMsg, toSnakeCase, types };
|
|
535
695
|
}
|
|
536
|
-
|
|
537
696
|
type Offer = {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
readonly
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
697
|
+
/** The address that made the offer. */
|
|
698
|
+
readonly offering: Address;
|
|
699
|
+
/** The amount of assets offered. */
|
|
700
|
+
readonly assets: bigint;
|
|
701
|
+
/**
|
|
702
|
+
* The amount of assets that can be taken from the offer. takeable = min(max - consumed, available)
|
|
703
|
+
* Where available is the total amount of assets retrievable from offering positions.
|
|
704
|
+
*/
|
|
705
|
+
readonly takeable: bigint;
|
|
706
|
+
/** The interest rate (with 18 decimals). */
|
|
707
|
+
readonly rate: bigint;
|
|
708
|
+
/** The date at which all interests will be paid. */
|
|
709
|
+
readonly maturity: Maturity;
|
|
710
|
+
/** The date at which the offer will expire. */
|
|
711
|
+
readonly expiry: number;
|
|
712
|
+
/** The date at which the offer will start. */
|
|
713
|
+
readonly start: number;
|
|
714
|
+
/** The nonce. Used for OCO (One-Cancelled-Other) mechanism. */
|
|
715
|
+
readonly nonce: bigint;
|
|
716
|
+
/** The side of the offer. `true` for buy, `false` for sell. */
|
|
717
|
+
readonly buy: boolean;
|
|
718
|
+
/** The chain id where the liquidity for this offer is located. */
|
|
719
|
+
readonly chainId: Id;
|
|
720
|
+
/** The token that is being borrowed. */
|
|
721
|
+
readonly loanToken: Address;
|
|
722
|
+
/** The exact set of collaterals required to borrow the loan token. */
|
|
723
|
+
readonly collaterals: readonly Collateral[];
|
|
724
|
+
/** The optional callback data to retrieve the maker funds. */
|
|
725
|
+
readonly callback: {
|
|
726
|
+
readonly address: Address;
|
|
727
|
+
readonly data: Hex;
|
|
728
|
+
readonly gasLimit: bigint;
|
|
729
|
+
};
|
|
730
|
+
/** The amount of assets consumed from the offer. */
|
|
731
|
+
consumed: bigint;
|
|
732
|
+
/** The hash of the offer. */
|
|
733
|
+
readonly hash: Hex;
|
|
734
|
+
/** The block number at which the offer was created. */
|
|
735
|
+
readonly blockNumber: number;
|
|
736
|
+
/** The signature of the offer. */
|
|
737
|
+
signature?: Hex;
|
|
738
|
+
};
|
|
739
|
+
declare enum Status {
|
|
740
|
+
VALID = "VALID",
|
|
741
|
+
SIMULATION_ERROR = "SIMULATION_ERROR",
|
|
742
|
+
}
|
|
743
|
+
type Validation = {
|
|
744
|
+
offerHash: Hex;
|
|
745
|
+
status: Status;
|
|
574
746
|
};
|
|
575
|
-
declare const OfferHashSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
747
|
+
declare const OfferHashSchema: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
576
748
|
declare const OfferSchema: (parameters?: {
|
|
577
|
-
|
|
578
|
-
}) => z.ZodObject<{
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
749
|
+
omitHash?: boolean;
|
|
750
|
+
}) => z$1.ZodObject<{
|
|
751
|
+
offering: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
752
|
+
assets: z$1.ZodBigInt;
|
|
753
|
+
rate: z$1.ZodBigInt;
|
|
754
|
+
maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
|
|
755
|
+
expiry: z$1.ZodNumber;
|
|
756
|
+
start: z$1.ZodNumber;
|
|
757
|
+
nonce: z$1.ZodBigInt;
|
|
758
|
+
buy: z$1.ZodBoolean;
|
|
759
|
+
chainId: z$1.ZodNumber;
|
|
760
|
+
loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
761
|
+
collaterals: z$1.ZodArray<z$1.ZodObject<{
|
|
762
|
+
asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
763
|
+
oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
764
|
+
lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
765
|
+
}, z$1.core.$strip>>;
|
|
766
|
+
callback: z$1.ZodObject<{
|
|
767
|
+
address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
768
|
+
data: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
769
|
+
gasLimit: z$1.ZodBigInt;
|
|
770
|
+
}, z$1.core.$strip>;
|
|
771
|
+
signature: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
|
|
772
|
+
consumed: z$1.ZodOptional<z$1.ZodBigInt>;
|
|
773
|
+
takeable: z$1.ZodOptional<z$1.ZodBigInt>;
|
|
774
|
+
blockNumber: z$1.ZodOptional<z$1.ZodNumber>;
|
|
775
|
+
}, z$1.core.$strip>;
|
|
603
776
|
/**
|
|
604
777
|
* Creates an offer from a plain object.
|
|
605
778
|
* @throws {InvalidOfferError} If the offer is invalid.
|
|
606
779
|
* @param input - The offer to create.
|
|
607
780
|
* @returns The created offer with its hash.
|
|
608
781
|
*/
|
|
609
|
-
declare function from$
|
|
610
|
-
|
|
611
|
-
|
|
782
|
+
declare function from$9(input: Compute<Omit<Offer, "chainId" | "hash"> & {
|
|
783
|
+
chainId: number;
|
|
784
|
+
}>): Offer;
|
|
785
|
+
declare namespace from$9 {
|
|
786
|
+
type ErrorType = InvalidOfferError;
|
|
612
787
|
}
|
|
613
788
|
/**
|
|
614
789
|
* Creates an offer from a snake case object.
|
|
@@ -616,7 +791,9 @@ declare namespace from$5 {
|
|
|
616
791
|
* @param input - The offer to create.
|
|
617
792
|
* @returns The created offer with its hash.
|
|
618
793
|
*/
|
|
619
|
-
declare function fromSnakeCase$2(input: Snake<Omit<Offer, "hash"
|
|
794
|
+
declare function fromSnakeCase$2(input: Snake<Omit<Offer, "chainId" | "hash"> & {
|
|
795
|
+
chainId: number;
|
|
796
|
+
}>): Offer;
|
|
620
797
|
/**
|
|
621
798
|
* Converts an offer to a snake case object.
|
|
622
799
|
* @param offer - The offer to convert.
|
|
@@ -624,26 +801,28 @@ declare function fromSnakeCase$2(input: Snake<Omit<Offer, "hash">>): Offer;
|
|
|
624
801
|
*/
|
|
625
802
|
declare function toSnakeCase(offer: Offer): Snake<Offer>;
|
|
626
803
|
type RandomConfig = {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
804
|
+
chains?: Chain$1[];
|
|
805
|
+
loanTokens?: Address[];
|
|
806
|
+
collateralTokens?: Address[];
|
|
807
|
+
assetsDecimals?: Record<Address, number>;
|
|
808
|
+
buy?: boolean;
|
|
809
|
+
assets?: bigint;
|
|
810
|
+
consumed?: bigint;
|
|
811
|
+
takeable?: bigint;
|
|
812
|
+
offering?: Address;
|
|
813
|
+
maturity?: Maturity;
|
|
814
|
+
start?: number;
|
|
815
|
+
expiry?: number;
|
|
816
|
+
nonce?: bigint;
|
|
817
|
+
rate?: bigint;
|
|
818
|
+
callback?: {
|
|
819
|
+
address: Address;
|
|
820
|
+
data: Hex;
|
|
821
|
+
gasLimit: bigint;
|
|
822
|
+
};
|
|
823
|
+
collaterals?: readonly Collateral[];
|
|
824
|
+
signature?: Hex;
|
|
825
|
+
blockNumber?: number;
|
|
647
826
|
};
|
|
648
827
|
/**
|
|
649
828
|
* Generates a random Offer.
|
|
@@ -657,9 +836,9 @@ declare function random$2(config?: RandomConfig): Offer;
|
|
|
657
836
|
* @param chainId - The chain ID.
|
|
658
837
|
* @returns The EIP-712 domain object.
|
|
659
838
|
*/
|
|
660
|
-
declare const domain: (chainId:
|
|
661
|
-
|
|
662
|
-
|
|
839
|
+
declare const domain: (chainId: number) => {
|
|
840
|
+
chainId: bigint;
|
|
841
|
+
verifyingContract: "0x0000000000000000000000000000000000000000";
|
|
663
842
|
};
|
|
664
843
|
/**
|
|
665
844
|
* The EIP-712 types for the offer.
|
|
@@ -667,73 +846,74 @@ declare const domain: (chainId: bigint) => {
|
|
|
667
846
|
* @returns The EIP-712 types.
|
|
668
847
|
*/
|
|
669
848
|
declare const types: {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
849
|
+
readonly EIP712Domain: readonly [{
|
|
850
|
+
readonly name: "chainId";
|
|
851
|
+
readonly type: "uint256";
|
|
852
|
+
}, {
|
|
853
|
+
readonly name: "verifyingContract";
|
|
854
|
+
readonly type: "address";
|
|
855
|
+
}];
|
|
856
|
+
readonly Offer: readonly [{
|
|
857
|
+
readonly name: "offering";
|
|
858
|
+
readonly type: "address";
|
|
859
|
+
}, {
|
|
860
|
+
readonly name: "assets";
|
|
861
|
+
readonly type: "uint256";
|
|
862
|
+
}, {
|
|
863
|
+
readonly name: "rate";
|
|
864
|
+
readonly type: "uint256";
|
|
865
|
+
}, {
|
|
866
|
+
readonly name: "maturity";
|
|
867
|
+
readonly type: "uint256";
|
|
868
|
+
}, {
|
|
869
|
+
readonly name: "expiry";
|
|
870
|
+
readonly type: "uint256";
|
|
871
|
+
}, {
|
|
872
|
+
readonly name: "nonce";
|
|
873
|
+
readonly type: "uint256";
|
|
874
|
+
}, {
|
|
875
|
+
readonly name: "buy";
|
|
876
|
+
readonly type: "bool";
|
|
877
|
+
}, {
|
|
878
|
+
readonly name: "loanToken";
|
|
879
|
+
readonly type: "address";
|
|
880
|
+
}, {
|
|
881
|
+
readonly name: "collaterals";
|
|
882
|
+
readonly type: "Collateral[]";
|
|
883
|
+
}, {
|
|
884
|
+
readonly name: "callback";
|
|
885
|
+
readonly type: "Callback";
|
|
886
|
+
}];
|
|
887
|
+
readonly Collateral: readonly [{
|
|
888
|
+
readonly name: "asset";
|
|
889
|
+
readonly type: "address";
|
|
890
|
+
}, {
|
|
891
|
+
readonly name: "oracle";
|
|
892
|
+
readonly type: "address";
|
|
893
|
+
}, {
|
|
894
|
+
readonly name: "lltv";
|
|
895
|
+
readonly type: "uint256";
|
|
896
|
+
}];
|
|
897
|
+
readonly Callback: readonly [{
|
|
898
|
+
readonly name: "address";
|
|
899
|
+
readonly type: "address";
|
|
900
|
+
}, {
|
|
901
|
+
readonly name: "data";
|
|
902
|
+
readonly type: "bytes";
|
|
903
|
+
}, {
|
|
904
|
+
readonly name: "gasLimit";
|
|
905
|
+
readonly type: "uint256";
|
|
906
|
+
}];
|
|
728
907
|
};
|
|
729
908
|
/**
|
|
730
|
-
* Signs an
|
|
909
|
+
* Signs an array of offers.
|
|
731
910
|
* @throws {Error} If the wallet account is not set.
|
|
732
|
-
* @param
|
|
733
|
-
* @param wallet - The wallet to sign the
|
|
734
|
-
* @returns The signed
|
|
911
|
+
* @param offers - The offers to sign.
|
|
912
|
+
* @param wallet - The wallet to sign the offers with.
|
|
913
|
+
* @returns The signed offers.
|
|
735
914
|
*/
|
|
736
|
-
declare function sign(
|
|
915
|
+
declare function sign(offers: Offer[], wallet: WalletClient): Promise<Hex>;
|
|
916
|
+
declare function signatureMsg(offers: Offer[]): Hex;
|
|
737
917
|
declare function hash(offer: Omit<Offer, "hash">): Hex;
|
|
738
918
|
/**
|
|
739
919
|
* Calculates the obligation id for an offer based on the smart contract's Obligation struct.
|
|
@@ -742,108 +922,91 @@ declare function hash(offer: Omit<Offer, "hash">): Hex;
|
|
|
742
922
|
* @returns The obligation id as a 32-byte hex string.
|
|
743
923
|
*/
|
|
744
924
|
declare function obligationId(offer: Offer): Hex;
|
|
745
|
-
declare function encode$
|
|
746
|
-
declare function decode$
|
|
925
|
+
declare function encode$2(offer: Offer): `0x${string}`;
|
|
926
|
+
declare function decode$2(data: Hex, blockNumber: number | bigint): Offer;
|
|
747
927
|
type OfferConsumed = {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
928
|
+
id: string;
|
|
929
|
+
chainId: Id;
|
|
930
|
+
offering: Address;
|
|
931
|
+
nonce: bigint;
|
|
932
|
+
amount: bigint;
|
|
933
|
+
blockNumber: number;
|
|
754
934
|
};
|
|
755
935
|
/**
|
|
756
936
|
* ABI for the Consumed event emitted by the Obligation contract.
|
|
757
937
|
*/
|
|
758
938
|
declare const consumedEvent: {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
939
|
+
readonly type: "event";
|
|
940
|
+
readonly name: "Consumed";
|
|
941
|
+
readonly inputs: readonly [{
|
|
942
|
+
readonly name: "user";
|
|
943
|
+
readonly type: "address";
|
|
944
|
+
readonly indexed: true;
|
|
945
|
+
readonly internalType: "address";
|
|
946
|
+
}, {
|
|
947
|
+
readonly name: "nonce";
|
|
948
|
+
readonly type: "uint256";
|
|
949
|
+
readonly indexed: true;
|
|
950
|
+
readonly internalType: "uint256";
|
|
951
|
+
}, {
|
|
952
|
+
readonly name: "amount";
|
|
953
|
+
readonly type: "uint256";
|
|
954
|
+
readonly indexed: false;
|
|
955
|
+
readonly internalType: "uint256";
|
|
956
|
+
}];
|
|
957
|
+
readonly anonymous: false;
|
|
778
958
|
};
|
|
779
|
-
declare
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
959
|
+
declare class InvalidOfferError extends BaseError<z$1.ZodError | Error> {
|
|
960
|
+
readonly name = "Offer.InvalidOfferError";
|
|
961
|
+
constructor(error: z$1.ZodError | Error);
|
|
962
|
+
/**
|
|
963
|
+
* Formats ZodError issues into a human-readable string with line breaks.
|
|
964
|
+
* @example
|
|
965
|
+
* "- 'assets': too small, expected >= 0
|
|
966
|
+
* - 'start': must be before expiry"
|
|
967
|
+
*/
|
|
968
|
+
static formatDetails(error: z$1.ZodError | Error): string;
|
|
969
|
+
/**
|
|
970
|
+
* Returns the formatted human-readable message.
|
|
971
|
+
*/
|
|
972
|
+
get formattedMessage(): string;
|
|
791
973
|
}
|
|
792
974
|
declare class AccountNotSetError extends BaseError {
|
|
793
|
-
|
|
794
|
-
|
|
975
|
+
readonly name = "Offer.AccountNotSetError";
|
|
976
|
+
constructor();
|
|
795
977
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
declare const Offer$1_AccountNotSetError: typeof AccountNotSetError;
|
|
799
|
-
type Offer$1_InvalidOfferError = InvalidOfferError;
|
|
800
|
-
declare const Offer$1_InvalidOfferError: typeof InvalidOfferError;
|
|
801
|
-
type Offer$1_Offer = Offer;
|
|
802
|
-
type Offer$1_OfferConsumed = OfferConsumed;
|
|
803
|
-
declare const Offer$1_OfferHashSchema: typeof OfferHashSchema;
|
|
804
|
-
declare const Offer$1_OfferSchema: typeof OfferSchema;
|
|
805
|
-
type Offer$1_RandomConfig = RandomConfig;
|
|
806
|
-
declare const Offer$1_consumedEvent: typeof consumedEvent;
|
|
807
|
-
declare const Offer$1_domain: typeof domain;
|
|
808
|
-
declare const Offer$1_fromConsumedLog: typeof fromConsumedLog;
|
|
809
|
-
declare const Offer$1_hash: typeof hash;
|
|
810
|
-
declare const Offer$1_obligationId: typeof obligationId;
|
|
811
|
-
declare const Offer$1_sign: typeof sign;
|
|
812
|
-
declare const Offer$1_toSnakeCase: typeof toSnakeCase;
|
|
813
|
-
declare const Offer$1_types: typeof types;
|
|
814
|
-
declare namespace Offer$1 {
|
|
815
|
-
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, type Offer$1_RandomConfig as RandomConfig, Offer$1_consumedEvent as consumedEvent, decode$1 as decode, Offer$1_domain as domain, encode$1 as encode, from$5 as from, Offer$1_fromConsumedLog as fromConsumedLog, fromSnakeCase$2 as fromSnakeCase, Offer$1_hash as hash, Offer$1_obligationId as obligationId, random$2 as random, Offer$1_sign as sign, Offer$1_toSnakeCase as toSnakeCase, Offer$1_types as types };
|
|
978
|
+
declare namespace Liquidity_d_exports {
|
|
979
|
+
export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateBuyVaultCallbackPoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateSellERC20CallbackPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
|
|
816
980
|
}
|
|
817
|
-
|
|
818
981
|
/**
|
|
819
982
|
* Represents a liquidity pool with a unique ID and amount.
|
|
820
983
|
*/
|
|
821
984
|
type LiquidityPool = {
|
|
822
|
-
|
|
823
|
-
|
|
985
|
+
id: string;
|
|
986
|
+
amount: bigint;
|
|
824
987
|
};
|
|
825
988
|
/**
|
|
826
989
|
* Represents a hierarchical relationship between two liquidity pools.
|
|
827
990
|
*/
|
|
828
991
|
type LiquidityLink = {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
992
|
+
parentPoolId: string;
|
|
993
|
+
childPoolId: string;
|
|
994
|
+
priority: number;
|
|
832
995
|
};
|
|
833
996
|
/**
|
|
834
997
|
* Represents the connection between an offer and its liquidity pools.
|
|
835
998
|
*/
|
|
836
999
|
type OfferLiquidityPool = {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
1000
|
+
offerHash: Offer["hash"];
|
|
1001
|
+
poolId: string;
|
|
1002
|
+
/**
|
|
1003
|
+
* The available capacity/liquidity from this pool for this offer.
|
|
1004
|
+
* Meaning varies by pool type:
|
|
1005
|
+
* - BuyWithEmptyCallback: Matches allowance amount from pool bellow
|
|
1006
|
+
* - SellERC20Callback: Sell Callback/Predeposited -> Maximum debt capacity calculated from collateral (collateralAmount * oraclePrice * lltv)
|
|
1007
|
+
* - SellERC20Callback: Existing debt as negative value (reduces available capacity)
|
|
1008
|
+
*/
|
|
1009
|
+
amount: bigint;
|
|
847
1010
|
};
|
|
848
1011
|
/**
|
|
849
1012
|
* Calculate maximum debt capacity from collateral amount.
|
|
@@ -857,28 +1020,28 @@ declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: big
|
|
|
857
1020
|
* Generate pool ID for balance pools.
|
|
858
1021
|
*/
|
|
859
1022
|
declare function generateBalancePoolId(parameters: {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
1023
|
+
user: Address;
|
|
1024
|
+
chainId: Id;
|
|
1025
|
+
token: Address;
|
|
863
1026
|
}): string;
|
|
864
1027
|
/**
|
|
865
1028
|
* Generate pool ID for allowance pools.
|
|
866
1029
|
*/
|
|
867
1030
|
declare function generateAllowancePoolId(parameters: {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1031
|
+
user: Address;
|
|
1032
|
+
chainId: Id;
|
|
1033
|
+
token: Address;
|
|
871
1034
|
}): string;
|
|
872
1035
|
/**
|
|
873
1036
|
* Generate pool ID for sell ERC20 callback pools.
|
|
874
1037
|
* Each offer has its own callback pool to prevent liquidity conflicts.
|
|
875
1038
|
*/
|
|
876
1039
|
declare function generateSellERC20CallbackPoolId(parameters: {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1040
|
+
user: Address;
|
|
1041
|
+
chainId: Id;
|
|
1042
|
+
obligationId: Hex;
|
|
1043
|
+
token: Address;
|
|
1044
|
+
offerHash: Hex;
|
|
882
1045
|
}): string;
|
|
883
1046
|
/**
|
|
884
1047
|
* Generate pool ID for obligation collateral pools.
|
|
@@ -886,89 +1049,74 @@ declare function generateSellERC20CallbackPoolId(parameters: {
|
|
|
886
1049
|
* These pools are shared across all offers with the same obligation.
|
|
887
1050
|
*/
|
|
888
1051
|
declare function generateObligationCollateralPoolId(parameters: {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1052
|
+
user: Address;
|
|
1053
|
+
chainId: Id;
|
|
1054
|
+
obligationId: Hex;
|
|
1055
|
+
token: Address;
|
|
893
1056
|
}): string;
|
|
894
1057
|
/**
|
|
895
1058
|
* Generate pool ID for buy vault callback pools.
|
|
896
1059
|
*/
|
|
897
1060
|
declare function generateBuyVaultCallbackPoolId(parameters: {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
1061
|
+
user: Address;
|
|
1062
|
+
chainId: Id;
|
|
1063
|
+
vault: Address;
|
|
1064
|
+
offerHash: Hex;
|
|
902
1065
|
}): string;
|
|
903
1066
|
/**
|
|
904
1067
|
* Generate pool ID for debt pools.
|
|
905
1068
|
*/
|
|
906
1069
|
declare function generateDebtPoolId(parameters: {
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
1070
|
+
user: Address;
|
|
1071
|
+
chainId: Id;
|
|
1072
|
+
obligationId: Hex;
|
|
910
1073
|
}): string;
|
|
911
1074
|
/**
|
|
912
1075
|
* Generate pool ID for user position in a vault.
|
|
913
1076
|
*/
|
|
914
1077
|
declare function generateUserVaultPositionPoolId(parameters: {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
1078
|
+
user: Address;
|
|
1079
|
+
chainId: Id;
|
|
1080
|
+
vault: Address;
|
|
918
1081
|
}): string;
|
|
919
1082
|
/**
|
|
920
1083
|
* Generate pool ID for vault position in a market.
|
|
921
1084
|
*/
|
|
922
1085
|
declare function generateVaultPositionPoolId(parameters: {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1086
|
+
vault: Address;
|
|
1087
|
+
chainId: Id;
|
|
1088
|
+
marketId: string;
|
|
926
1089
|
}): string;
|
|
927
1090
|
/**
|
|
928
1091
|
* Generate pool ID for market total liquidity.
|
|
929
1092
|
*/
|
|
930
1093
|
declare function generateMarketLiquidityPoolId(parameters: {
|
|
931
|
-
|
|
932
|
-
|
|
1094
|
+
chainId: Id;
|
|
1095
|
+
marketId: string;
|
|
933
1096
|
}): string;
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
type Liquidity_LiquidityPool = LiquidityPool;
|
|
937
|
-
type Liquidity_OfferLiquidityPool = OfferLiquidityPool;
|
|
938
|
-
declare const Liquidity_calculateMaxDebt: typeof calculateMaxDebt;
|
|
939
|
-
declare const Liquidity_generateAllowancePoolId: typeof generateAllowancePoolId;
|
|
940
|
-
declare const Liquidity_generateBalancePoolId: typeof generateBalancePoolId;
|
|
941
|
-
declare const Liquidity_generateBuyVaultCallbackPoolId: typeof generateBuyVaultCallbackPoolId;
|
|
942
|
-
declare const Liquidity_generateDebtPoolId: typeof generateDebtPoolId;
|
|
943
|
-
declare const Liquidity_generateMarketLiquidityPoolId: typeof generateMarketLiquidityPoolId;
|
|
944
|
-
declare const Liquidity_generateObligationCollateralPoolId: typeof generateObligationCollateralPoolId;
|
|
945
|
-
declare const Liquidity_generateSellERC20CallbackPoolId: typeof generateSellERC20CallbackPoolId;
|
|
946
|
-
declare const Liquidity_generateUserVaultPositionPoolId: typeof generateUserVaultPositionPoolId;
|
|
947
|
-
declare const Liquidity_generateVaultPositionPoolId: typeof generateVaultPositionPoolId;
|
|
948
|
-
declare namespace Liquidity {
|
|
949
|
-
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 };
|
|
1097
|
+
declare namespace Obligation_d_exports {
|
|
1098
|
+
export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$8 as from, fromSnakeCase$1 as fromSnakeCase, id, random$1 as random };
|
|
950
1099
|
}
|
|
951
|
-
|
|
952
1100
|
type Obligation = {
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1101
|
+
/** The chain id where the liquidity for this obligation is located. */
|
|
1102
|
+
chainId: Id;
|
|
1103
|
+
/** The token that is being borrowed for this obligation. */
|
|
1104
|
+
loanToken: Address;
|
|
1105
|
+
/** The exact set of collaterals required to borrow the loan token. */
|
|
1106
|
+
collaterals: Collateral[];
|
|
1107
|
+
/** The maturity of the obligation. */
|
|
1108
|
+
maturity: Maturity;
|
|
961
1109
|
};
|
|
962
|
-
declare const ObligationSchema: z.ZodObject<{
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}, z.core.$strip>;
|
|
1110
|
+
declare const ObligationSchema: z$1.ZodObject<{
|
|
1111
|
+
chainId: z$1.ZodNumber;
|
|
1112
|
+
loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
1113
|
+
collaterals: z$1.ZodArray<z$1.ZodObject<{
|
|
1114
|
+
asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
1115
|
+
oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
1116
|
+
lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
1117
|
+
}, z$1.core.$strip>>;
|
|
1118
|
+
maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
|
|
1119
|
+
}, z$1.core.$strip>;
|
|
972
1120
|
/**
|
|
973
1121
|
* Creates an obligation from the given parameters.
|
|
974
1122
|
* @constructor
|
|
@@ -979,7 +1127,7 @@ declare const ObligationSchema: z.ZodObject<{
|
|
|
979
1127
|
* @example
|
|
980
1128
|
* ```ts
|
|
981
1129
|
* const obligation = Obligation.from({
|
|
982
|
-
* chainId:
|
|
1130
|
+
* chainId: 1,
|
|
983
1131
|
* loanToken: privateKeyToAccount(generatePrivateKey()).address,
|
|
984
1132
|
* collaterals: [
|
|
985
1133
|
* Collateral.from({
|
|
@@ -992,20 +1140,20 @@ declare const ObligationSchema: z.ZodObject<{
|
|
|
992
1140
|
* });
|
|
993
1141
|
* ```
|
|
994
1142
|
*/
|
|
995
|
-
declare function from$
|
|
996
|
-
declare namespace from$
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1143
|
+
declare function from$8(parameters: from$8.Parameters): from$8.ReturnType;
|
|
1144
|
+
declare namespace from$8 {
|
|
1145
|
+
type Parameters = {
|
|
1146
|
+
/** The chain id where the liquidity for this obligation is located. */
|
|
1147
|
+
chainId: number;
|
|
1148
|
+
/** The token that is being borrowed for this obligation. */
|
|
1149
|
+
loanToken: Address;
|
|
1150
|
+
/** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
|
|
1151
|
+
collaterals: from$11.Parameters[] | readonly from$11.Parameters[];
|
|
1152
|
+
/** The maturity of the obligation. */
|
|
1153
|
+
maturity: from$10.Parameters;
|
|
1154
|
+
};
|
|
1155
|
+
type ReturnType = Obligation;
|
|
1156
|
+
type ErrorType = InvalidObligationError;
|
|
1009
1157
|
}
|
|
1010
1158
|
/**
|
|
1011
1159
|
* Creates an obligation from a snake case object.
|
|
@@ -1015,9 +1163,11 @@ declare namespace from$4 {
|
|
|
1015
1163
|
*/
|
|
1016
1164
|
declare function fromSnakeCase$1(input: fromSnakeCase$1.Parameters): fromSnakeCase$1.ReturnType;
|
|
1017
1165
|
declare namespace fromSnakeCase$1 {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1166
|
+
type Parameters = Snake<Omit<Obligation, "chainId"> & {
|
|
1167
|
+
chainId: number;
|
|
1168
|
+
}>;
|
|
1169
|
+
type ReturnType = Obligation;
|
|
1170
|
+
type ErrorType = InvalidObligationError;
|
|
1021
1171
|
}
|
|
1022
1172
|
/**
|
|
1023
1173
|
* Calculates the obligation id based on the smart contract's Obligation struct.
|
|
@@ -1035,9 +1185,9 @@ declare namespace fromSnakeCase$1 {
|
|
|
1035
1185
|
*/
|
|
1036
1186
|
declare function id(obligation: id.Parameters): id.ReturnType;
|
|
1037
1187
|
declare namespace id {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1188
|
+
type Parameters = Obligation;
|
|
1189
|
+
type ReturnType = Hex;
|
|
1190
|
+
type ErrorType = CollateralsAreNotSortedError;
|
|
1041
1191
|
}
|
|
1042
1192
|
/**
|
|
1043
1193
|
* Generates a random obligation.
|
|
@@ -1050,49 +1200,150 @@ declare namespace id {
|
|
|
1050
1200
|
*/
|
|
1051
1201
|
declare function random$1(): random$1.ReturnType;
|
|
1052
1202
|
declare namespace random$1 {
|
|
1053
|
-
|
|
1203
|
+
type ReturnType = Obligation;
|
|
1054
1204
|
}
|
|
1055
|
-
declare class InvalidObligationError extends BaseError<z.ZodError | Error> {
|
|
1056
|
-
|
|
1057
|
-
|
|
1205
|
+
declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
|
|
1206
|
+
readonly name = "Obligation.InvalidObligationError";
|
|
1207
|
+
constructor(error: z$1.ZodError | Error);
|
|
1058
1208
|
}
|
|
1059
1209
|
declare class CollateralsAreNotSortedError extends BaseError {
|
|
1060
|
-
|
|
1061
|
-
|
|
1210
|
+
readonly name = "Obligation.CollateralsAreNotSortedError";
|
|
1211
|
+
constructor();
|
|
1062
1212
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1213
|
+
declare namespace Oracle_d_exports {
|
|
1214
|
+
export { Conversion, Oracle, from$7 as from };
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* An oracle contract that provides price information for assets.
|
|
1218
|
+
*/
|
|
1219
|
+
type Oracle = {
|
|
1220
|
+
/** The chain id where the oracle is deployed. */
|
|
1221
|
+
readonly chainId: Id;
|
|
1222
|
+
/** The address of the oracle contract. */
|
|
1223
|
+
readonly address: Address;
|
|
1224
|
+
/** The price returned by the oracle (in the oracle's native units), null if no price available. */
|
|
1225
|
+
readonly price: bigint | null;
|
|
1226
|
+
/** The block number at which the price was fetched. */
|
|
1227
|
+
readonly blockNumber: number;
|
|
1228
|
+
};
|
|
1229
|
+
/**
|
|
1230
|
+
* Create an Oracle from a plain object.
|
|
1231
|
+
* @param data - The data to create the oracle from.
|
|
1232
|
+
* @returns The created oracle.
|
|
1233
|
+
*/
|
|
1234
|
+
declare function from$7(data: from$7.Parameters): from$7.ReturnType;
|
|
1235
|
+
declare namespace from$7 {
|
|
1236
|
+
type Parameters = {
|
|
1237
|
+
chainId: Id;
|
|
1238
|
+
address: Address;
|
|
1239
|
+
price: string | null;
|
|
1240
|
+
blockNumber: number;
|
|
1241
|
+
};
|
|
1242
|
+
type ReturnType = Oracle;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Conversion utilities for converting between collateral and loan token amounts
|
|
1246
|
+
* using oracle prices and LLTV
|
|
1247
|
+
*/
|
|
1248
|
+
declare namespace Conversion {
|
|
1249
|
+
/**
|
|
1250
|
+
* Converts a collateral amount to loan token
|
|
1251
|
+
* Uses the formula: (amount * price / 10^36) * lltv / 10^18
|
|
1252
|
+
*
|
|
1253
|
+
* @param amount - The collateral amount to convert
|
|
1254
|
+
* @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
|
|
1255
|
+
* @returns The equivalent loan token amount
|
|
1256
|
+
*/
|
|
1257
|
+
function collateralToLoan(amount: bigint, params: {
|
|
1258
|
+
price: bigint;
|
|
1259
|
+
lltv: bigint;
|
|
1260
|
+
}): bigint;
|
|
1261
|
+
/**
|
|
1262
|
+
* Converts a loan token amount to collateral
|
|
1263
|
+
* Uses the inverse formula: (amount * 10^36 / price) * 10^18 / lltv
|
|
1264
|
+
* Returns 0n if price or lltv is zero (invalid conversion).
|
|
1265
|
+
*
|
|
1266
|
+
* @param amount - The loan token amount to convert
|
|
1267
|
+
* @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
|
|
1268
|
+
* @returns The equivalent collateral amount, or 0n if conversion is invalid
|
|
1269
|
+
*/
|
|
1270
|
+
function loanToCollateral(amount: bigint, params: {
|
|
1271
|
+
price: bigint;
|
|
1272
|
+
lltv: bigint;
|
|
1273
|
+
}): bigint;
|
|
1274
|
+
}
|
|
1275
|
+
declare namespace Position_d_exports {
|
|
1276
|
+
export { Position, Type, from$6 as from };
|
|
1277
|
+
}
|
|
1278
|
+
type Position = {
|
|
1279
|
+
/** The chain id. */
|
|
1280
|
+
chainId: Id;
|
|
1281
|
+
/** The contract address from which the position is called.
|
|
1282
|
+
* While balances are obviously tracked on ERC20 contracts, we prefer to track which contract is called to know the balance.
|
|
1283
|
+
* For example, when depositing into a vault, we would specify the vault contract address as the contract not the underlying vault's ERC20 token address.
|
|
1284
|
+
*/
|
|
1285
|
+
contract: Address;
|
|
1286
|
+
/** The user address. */
|
|
1287
|
+
user: Address;
|
|
1288
|
+
/** The type of position. */
|
|
1289
|
+
type: Type;
|
|
1290
|
+
/** The balance of the position. */
|
|
1291
|
+
balance?: bigint;
|
|
1292
|
+
/** The underlying asset of the position.
|
|
1293
|
+
* For ERC20 positions, this equals the contract address.
|
|
1294
|
+
* For vault positions, this is the vault's underlying asset.
|
|
1295
|
+
*/
|
|
1296
|
+
asset?: Address;
|
|
1297
|
+
/** The block number at which the position was last updated. */
|
|
1298
|
+
blockNumber: number;
|
|
1299
|
+
};
|
|
1300
|
+
declare enum Type {
|
|
1301
|
+
ERC20 = "erc20",
|
|
1302
|
+
VAULT_V1 = "vault_v1",
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* @constructor
|
|
1306
|
+
* Creates a Position.
|
|
1307
|
+
* @param parameters - {@link from.Parameters}
|
|
1308
|
+
* @returns The created Position. {@link from.ReturnType}
|
|
1309
|
+
*/
|
|
1310
|
+
declare function from$6(parameters: from$6.Parameters): from$6.ReturnType;
|
|
1311
|
+
declare namespace from$6 {
|
|
1312
|
+
type Parameters = {
|
|
1313
|
+
chainId: Id;
|
|
1314
|
+
contract: Address;
|
|
1315
|
+
user: Address;
|
|
1316
|
+
type: Type;
|
|
1317
|
+
balance?: bigint;
|
|
1318
|
+
asset?: Address;
|
|
1319
|
+
blockNumber: number;
|
|
1320
|
+
};
|
|
1321
|
+
type ReturnType = Position;
|
|
1322
|
+
}
|
|
1323
|
+
declare namespace Quote_d_exports {
|
|
1324
|
+
export { InvalidQuoteError, Quote, QuoteSchema, from$5 as from, fromSnakeCase, random };
|
|
1073
1325
|
}
|
|
1074
|
-
|
|
1075
1326
|
type Quote = {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1327
|
+
/** The obligation id. */
|
|
1328
|
+
obligationId: Hex;
|
|
1329
|
+
ask: {
|
|
1330
|
+
/** The highest interest rate the seller will accept to pay for the obligation. (18 decimals). */
|
|
1331
|
+
rate: bigint;
|
|
1332
|
+
};
|
|
1333
|
+
bid: {
|
|
1334
|
+
/** The lowest interest rate a buyer is willing to be paid for the obligation. (18 decimals). */
|
|
1335
|
+
rate: bigint;
|
|
1336
|
+
};
|
|
1086
1337
|
};
|
|
1087
|
-
declare const QuoteSchema: z.ZodObject<{
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
}, z.core.$strip>;
|
|
1338
|
+
declare const QuoteSchema: z$1.ZodObject<{
|
|
1339
|
+
obligationId: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
1340
|
+
ask: z$1.ZodObject<{
|
|
1341
|
+
rate: z$1.ZodBigInt;
|
|
1342
|
+
}, z$1.core.$strip>;
|
|
1343
|
+
bid: z$1.ZodObject<{
|
|
1344
|
+
rate: z$1.ZodBigInt;
|
|
1345
|
+
}, z$1.core.$strip>;
|
|
1346
|
+
}, z$1.core.$strip>;
|
|
1096
1347
|
/**
|
|
1097
1348
|
* Creates a quote for a given obligation.
|
|
1098
1349
|
* @constructor
|
|
@@ -1105,11 +1356,11 @@ declare const QuoteSchema: z.ZodObject<{
|
|
|
1105
1356
|
* const quote = Quote.from({ obligationId: "0x123", ask: { assets: 100n, rate: 100n }, bid: { assets: 100n, rate: 100n } });
|
|
1106
1357
|
* ```
|
|
1107
1358
|
*/
|
|
1108
|
-
declare function from$
|
|
1109
|
-
declare namespace from$
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1359
|
+
declare function from$5(parameters: from$5.Parameters): from$5.ReturnType;
|
|
1360
|
+
declare namespace from$5 {
|
|
1361
|
+
type Parameters = Quote;
|
|
1362
|
+
type ReturnType = Quote;
|
|
1363
|
+
type ErrorType = InvalidQuoteError;
|
|
1113
1364
|
}
|
|
1114
1365
|
/**
|
|
1115
1366
|
* Creates a quote from a snake case object.
|
|
@@ -1119,9 +1370,9 @@ declare namespace from$3 {
|
|
|
1119
1370
|
*/
|
|
1120
1371
|
declare function fromSnakeCase(snake: fromSnakeCase.Parameters): fromSnakeCase.ReturnType;
|
|
1121
1372
|
declare namespace fromSnakeCase {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1373
|
+
type Parameters = Snake<Quote>;
|
|
1374
|
+
type ReturnType = Quote;
|
|
1375
|
+
type ErrorType = from$5.ErrorType;
|
|
1125
1376
|
}
|
|
1126
1377
|
/**
|
|
1127
1378
|
* Generates a random quote.
|
|
@@ -1134,32 +1385,848 @@ declare namespace fromSnakeCase {
|
|
|
1134
1385
|
*/
|
|
1135
1386
|
declare function random(): random.ReturnType;
|
|
1136
1387
|
declare namespace random {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1388
|
+
type Parameters = never;
|
|
1389
|
+
type ReturnType = Quote;
|
|
1390
|
+
type ErrorType = from$5.ErrorType;
|
|
1140
1391
|
}
|
|
1141
|
-
declare class InvalidQuoteError extends BaseError<z.ZodError | Error> {
|
|
1142
|
-
|
|
1143
|
-
|
|
1392
|
+
declare class InvalidQuoteError extends BaseError<z$1.ZodError | Error> {
|
|
1393
|
+
readonly name = "Quote.InvalidQuoteError";
|
|
1394
|
+
constructor(error: z$1.ZodError | Error);
|
|
1144
1395
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
declare const Quote$1_InvalidQuoteError: typeof InvalidQuoteError;
|
|
1148
|
-
type Quote$1_Quote = Quote;
|
|
1149
|
-
declare const Quote$1_QuoteSchema: typeof QuoteSchema;
|
|
1150
|
-
declare const Quote$1_fromSnakeCase: typeof fromSnakeCase;
|
|
1151
|
-
declare const Quote$1_random: typeof random;
|
|
1152
|
-
declare namespace Quote$1 {
|
|
1153
|
-
export { Quote$1_InvalidQuoteError as InvalidQuoteError, type Quote$1_Quote as Quote, Quote$1_QuoteSchema as QuoteSchema, from$3 as from, Quote$1_fromSnakeCase as fromSnakeCase, Quote$1_random as random };
|
|
1396
|
+
declare namespace Transfer_d_exports {
|
|
1397
|
+
export { Transfer, from$4 as from };
|
|
1154
1398
|
}
|
|
1399
|
+
type Transfer = {
|
|
1400
|
+
id: string;
|
|
1401
|
+
chainId: Id;
|
|
1402
|
+
contract: Address;
|
|
1403
|
+
from: Address;
|
|
1404
|
+
to: Address;
|
|
1405
|
+
value: bigint;
|
|
1406
|
+
blockNumber: number;
|
|
1407
|
+
};
|
|
1408
|
+
/**
|
|
1409
|
+
* @constructor
|
|
1410
|
+
*
|
|
1411
|
+
* Creates a {@link Transfer}.
|
|
1412
|
+
* @param parameters - {@link from.Parameters}
|
|
1413
|
+
* @returns The created Transfer. {@link from.ReturnType}
|
|
1414
|
+
*
|
|
1415
|
+
* @example
|
|
1416
|
+
* ```ts
|
|
1417
|
+
* const transfer = Transfer.from({ id: "1", chainId: 1, contract: "0x123", from: "0x456", to: "0x789", value: 100n, blockNumber: 100n });
|
|
1418
|
+
* ```
|
|
1419
|
+
*/
|
|
1420
|
+
declare function from$4(parameters: from$4.Parameters): from$4.ReturnType;
|
|
1421
|
+
declare namespace from$4 {
|
|
1422
|
+
type Parameters = {
|
|
1423
|
+
id: string;
|
|
1424
|
+
chainId: Id;
|
|
1425
|
+
contract: Address;
|
|
1426
|
+
from: Address;
|
|
1427
|
+
to: Address;
|
|
1428
|
+
value: bigint;
|
|
1429
|
+
blockNumber: number;
|
|
1430
|
+
};
|
|
1431
|
+
type ReturnType = Transfer;
|
|
1432
|
+
}
|
|
1433
|
+
declare namespace Tree_d_exports {
|
|
1434
|
+
export { Tree, VERSION, decode$1 as decode, encode$1 as encode, from$3 as from };
|
|
1435
|
+
}
|
|
1436
|
+
type Tree = Compute<StandardMerkleTree<[Hex]> & {
|
|
1437
|
+
offers: Offer[];
|
|
1438
|
+
root: Hex;
|
|
1439
|
+
}>;
|
|
1440
|
+
declare const VERSION = 1;
|
|
1441
|
+
/**
|
|
1442
|
+
* Builds a Merkle tree from a list of offers.
|
|
1443
|
+
*
|
|
1444
|
+
* Leaves are the offer `hash` values as `bytes32` and are deterministically
|
|
1445
|
+
* ordered in ascending lexicographic order so that the resulting root is stable
|
|
1446
|
+
* regardless of the input order.
|
|
1447
|
+
*
|
|
1448
|
+
* @param offers - Offers to include in the tree.
|
|
1449
|
+
* @returns A `StandardMerkleTree` of `bytes32` leaves representing the offers.
|
|
1450
|
+
*/
|
|
1451
|
+
declare const from$3: (offers: Offer[]) => Tree;
|
|
1452
|
+
/**
|
|
1453
|
+
* Encodes an `Tree` into a Hex string with a version byte prefix and gzipped payload.
|
|
1454
|
+
*
|
|
1455
|
+
* - Layout: `0x{vv}{zip...}` where `{vv}` is one-byte version as two hex chars.
|
|
1456
|
+
* - Payload is gzip(JSON.stringify([root, ...offers])) with bigint stringified.
|
|
1457
|
+
*
|
|
1458
|
+
* @param tree - The offer Merkle tree to encode.
|
|
1459
|
+
* @returns Hex string starting with `0x{vv}` followed by gzipped payload bytes.
|
|
1460
|
+
* @throws Error if the given `root` does not match the offers.
|
|
1461
|
+
*/
|
|
1462
|
+
declare const encode$1: (tree: Tree) => Hex;
|
|
1463
|
+
/**
|
|
1464
|
+
* Decodes a Hex string produced by {@link encode} back into an `Tree`.
|
|
1465
|
+
*
|
|
1466
|
+
* - Ensures the first byte version matches {@link VERSION}.
|
|
1467
|
+
* - Decompresses with gunzip, parses JSON, validates offers, and re-checks the root.
|
|
1468
|
+
*
|
|
1469
|
+
* @param encoded - Hex string in the form `0x{vv}{zip...}`.
|
|
1470
|
+
* @returns A validated `Tree` rebuilt from the offers.
|
|
1471
|
+
* @throws Error if the version is invalid or the root does not match the offers.
|
|
1472
|
+
*/
|
|
1473
|
+
declare const decode$1: (encoded: Hex) => Tree;
|
|
1474
|
+
//#endregion
|
|
1475
|
+
//#region src/api/Schema/generated/swagger.d.ts
|
|
1476
|
+
/**
|
|
1477
|
+
* This file was auto-generated by openapi-typescript.
|
|
1478
|
+
* Do not make direct changes to the file.
|
|
1479
|
+
*/
|
|
1155
1480
|
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1481
|
+
interface paths {
|
|
1482
|
+
"/v1/books/{obligationId}/{side}": {
|
|
1483
|
+
parameters: {
|
|
1484
|
+
query?: never;
|
|
1485
|
+
header?: never;
|
|
1486
|
+
path?: never;
|
|
1487
|
+
cookie?: never;
|
|
1488
|
+
};
|
|
1489
|
+
/**
|
|
1490
|
+
* Get aggregated book
|
|
1491
|
+
* @description Returns aggregated book data for a given obligation and side. Offers are grouped by rate with summed takeable amounts. Book levels are sorted by rate (ascending for buy side, descending for sell side).
|
|
1492
|
+
*/
|
|
1493
|
+
get: {
|
|
1494
|
+
parameters: {
|
|
1495
|
+
query?: {
|
|
1496
|
+
/**
|
|
1497
|
+
* @description Maximum number of rate levels to return.
|
|
1498
|
+
* @example 10
|
|
1499
|
+
*/
|
|
1500
|
+
limit?: number;
|
|
1501
|
+
/**
|
|
1502
|
+
* @description Pagination cursor in base64url-encoded format.
|
|
1503
|
+
* @example eyJvZmZzZXQiOjEwMH0
|
|
1504
|
+
*/
|
|
1505
|
+
cursor?: string;
|
|
1506
|
+
};
|
|
1507
|
+
header?: never;
|
|
1508
|
+
path?: never;
|
|
1509
|
+
cookie?: never;
|
|
1510
|
+
};
|
|
1511
|
+
requestBody?: never;
|
|
1512
|
+
responses: {
|
|
1513
|
+
/** @description Success */
|
|
1514
|
+
200: {
|
|
1515
|
+
headers: {
|
|
1516
|
+
[name: string]: unknown;
|
|
1517
|
+
};
|
|
1518
|
+
content: {
|
|
1519
|
+
"application/json": components["schemas"]["BookListResponse"];
|
|
1520
|
+
};
|
|
1521
|
+
};
|
|
1522
|
+
/** @description Bad Request */
|
|
1523
|
+
400: {
|
|
1524
|
+
headers: {
|
|
1525
|
+
[name: string]: unknown;
|
|
1526
|
+
};
|
|
1527
|
+
content: {
|
|
1528
|
+
"application/json": components["schemas"]["BadRequestResponse"];
|
|
1529
|
+
};
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
};
|
|
1533
|
+
put?: never;
|
|
1534
|
+
post?: never;
|
|
1535
|
+
delete?: never;
|
|
1536
|
+
options?: never;
|
|
1537
|
+
head?: never;
|
|
1538
|
+
patch?: never;
|
|
1539
|
+
trace?: never;
|
|
1540
|
+
};
|
|
1541
|
+
"/v1/offers": {
|
|
1542
|
+
parameters: {
|
|
1543
|
+
query?: never;
|
|
1544
|
+
header?: never;
|
|
1545
|
+
path?: never;
|
|
1546
|
+
cookie?: never;
|
|
1547
|
+
};
|
|
1548
|
+
/**
|
|
1549
|
+
* List all offers
|
|
1550
|
+
* @description Returns offers. Provide either `obligation_id` + `side` (order book) or `offering` (by maker).
|
|
1551
|
+
*/
|
|
1552
|
+
get: {
|
|
1553
|
+
parameters: {
|
|
1554
|
+
query?: {
|
|
1555
|
+
/**
|
|
1556
|
+
* @description Maximum number of offers to return.
|
|
1557
|
+
* @example 10
|
|
1558
|
+
*/
|
|
1559
|
+
limit?: number;
|
|
1560
|
+
/**
|
|
1561
|
+
* @description Pagination cursor in base64url-encoded format.
|
|
1562
|
+
* @example eyJvZmZzZXQiOjEwMH0
|
|
1563
|
+
*/
|
|
1564
|
+
cursor?: string;
|
|
1565
|
+
/**
|
|
1566
|
+
* @description Maker address to filter offers by. Alternative to obligation_id + side.
|
|
1567
|
+
* @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401
|
|
1568
|
+
*/
|
|
1569
|
+
offering?: string;
|
|
1570
|
+
/**
|
|
1571
|
+
* @description Obligation id used to filter offers. Required when not using offering.
|
|
1572
|
+
* @example 0x1234567890123456789012345678901234567890123456789012345678901234
|
|
1573
|
+
*/
|
|
1574
|
+
obligation_id?: string;
|
|
1575
|
+
/**
|
|
1576
|
+
* @description Side of the offer. Required when using obligation_id.
|
|
1577
|
+
* @example buy
|
|
1578
|
+
*/
|
|
1579
|
+
side?: "buy" | "sell";
|
|
1580
|
+
};
|
|
1581
|
+
header?: never;
|
|
1582
|
+
path?: never;
|
|
1583
|
+
cookie?: never;
|
|
1584
|
+
};
|
|
1585
|
+
requestBody?: never;
|
|
1586
|
+
responses: {
|
|
1587
|
+
/** @description Success */
|
|
1588
|
+
200: {
|
|
1589
|
+
headers: {
|
|
1590
|
+
[name: string]: unknown;
|
|
1591
|
+
};
|
|
1592
|
+
content: {
|
|
1593
|
+
"application/json": components["schemas"]["OfferListResponse"];
|
|
1594
|
+
};
|
|
1595
|
+
};
|
|
1596
|
+
/** @description Bad Request */
|
|
1597
|
+
400: {
|
|
1598
|
+
headers: {
|
|
1599
|
+
[name: string]: unknown;
|
|
1600
|
+
};
|
|
1601
|
+
content: {
|
|
1602
|
+
"application/json": components["schemas"]["BadRequestResponse"];
|
|
1603
|
+
};
|
|
1604
|
+
};
|
|
1605
|
+
};
|
|
1606
|
+
};
|
|
1607
|
+
put?: never;
|
|
1608
|
+
post?: never;
|
|
1609
|
+
delete?: never;
|
|
1610
|
+
options?: never;
|
|
1611
|
+
head?: never;
|
|
1612
|
+
patch?: never;
|
|
1613
|
+
trace?: never;
|
|
1614
|
+
};
|
|
1615
|
+
"/v1/obligations": {
|
|
1616
|
+
parameters: {
|
|
1617
|
+
query?: never;
|
|
1618
|
+
header?: never;
|
|
1619
|
+
path?: never;
|
|
1620
|
+
cookie?: never;
|
|
1621
|
+
};
|
|
1622
|
+
/**
|
|
1623
|
+
* List all obligations
|
|
1624
|
+
* @description Returns a list of obligations with their current best ask and bid. Obligations are sorted by their id in ascending order by default.
|
|
1625
|
+
*/
|
|
1626
|
+
get: {
|
|
1627
|
+
parameters: {
|
|
1628
|
+
query?: {
|
|
1629
|
+
/** @example 10 */
|
|
1630
|
+
limit?: number;
|
|
1631
|
+
/** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
|
|
1632
|
+
cursor?: string;
|
|
1633
|
+
};
|
|
1634
|
+
header?: never;
|
|
1635
|
+
path?: never;
|
|
1636
|
+
cookie?: never;
|
|
1637
|
+
};
|
|
1638
|
+
requestBody?: never;
|
|
1639
|
+
responses: {
|
|
1640
|
+
/** @description Success */
|
|
1641
|
+
200: {
|
|
1642
|
+
headers: {
|
|
1643
|
+
[name: string]: unknown;
|
|
1644
|
+
};
|
|
1645
|
+
content: {
|
|
1646
|
+
"application/json": components["schemas"]["ObligationListResponse"];
|
|
1647
|
+
};
|
|
1648
|
+
};
|
|
1649
|
+
/** @description Bad Request */
|
|
1650
|
+
400: {
|
|
1651
|
+
headers: {
|
|
1652
|
+
[name: string]: unknown;
|
|
1653
|
+
};
|
|
1654
|
+
content: {
|
|
1655
|
+
"application/json": components["schemas"]["BadRequestResponse"];
|
|
1656
|
+
};
|
|
1657
|
+
};
|
|
1658
|
+
};
|
|
1659
|
+
};
|
|
1660
|
+
put?: never;
|
|
1661
|
+
post?: never;
|
|
1662
|
+
delete?: never;
|
|
1663
|
+
options?: never;
|
|
1664
|
+
head?: never;
|
|
1665
|
+
patch?: never;
|
|
1666
|
+
trace?: never;
|
|
1667
|
+
};
|
|
1668
|
+
"/v1/obligations/{obligationId}": {
|
|
1669
|
+
parameters: {
|
|
1670
|
+
query?: never;
|
|
1671
|
+
header?: never;
|
|
1672
|
+
path?: never;
|
|
1673
|
+
cookie?: never;
|
|
1674
|
+
};
|
|
1675
|
+
/**
|
|
1676
|
+
* Get an obligation
|
|
1677
|
+
* @description Returns an obligation by its id.
|
|
1678
|
+
*/
|
|
1679
|
+
get: {
|
|
1680
|
+
parameters: {
|
|
1681
|
+
query?: never;
|
|
1682
|
+
header?: never;
|
|
1683
|
+
path?: never;
|
|
1684
|
+
cookie?: never;
|
|
1685
|
+
};
|
|
1686
|
+
requestBody?: never;
|
|
1687
|
+
responses: {
|
|
1688
|
+
/** @description Success */
|
|
1689
|
+
200: {
|
|
1690
|
+
headers: {
|
|
1691
|
+
[name: string]: unknown;
|
|
1692
|
+
};
|
|
1693
|
+
content: {
|
|
1694
|
+
"application/json": components["schemas"]["ObligationSingleSuccessResponse"];
|
|
1695
|
+
};
|
|
1696
|
+
};
|
|
1697
|
+
/** @description Bad Request */
|
|
1698
|
+
400: {
|
|
1699
|
+
headers: {
|
|
1700
|
+
[name: string]: unknown;
|
|
1701
|
+
};
|
|
1702
|
+
content: {
|
|
1703
|
+
"application/json": components["schemas"]["BadRequestResponse"];
|
|
1704
|
+
};
|
|
1705
|
+
};
|
|
1706
|
+
};
|
|
1707
|
+
};
|
|
1708
|
+
put?: never;
|
|
1709
|
+
post?: never;
|
|
1710
|
+
delete?: never;
|
|
1711
|
+
options?: never;
|
|
1712
|
+
head?: never;
|
|
1713
|
+
patch?: never;
|
|
1714
|
+
trace?: never;
|
|
1715
|
+
};
|
|
1716
|
+
"/v1/health": {
|
|
1717
|
+
parameters: {
|
|
1718
|
+
query?: never;
|
|
1719
|
+
header?: never;
|
|
1720
|
+
path?: never;
|
|
1721
|
+
cookie?: never;
|
|
1722
|
+
};
|
|
1723
|
+
/**
|
|
1724
|
+
* Retrieve global health
|
|
1725
|
+
* @description Returns the aggregated status of the router.
|
|
1726
|
+
*/
|
|
1727
|
+
get: {
|
|
1728
|
+
parameters: {
|
|
1729
|
+
query?: never;
|
|
1730
|
+
header?: never;
|
|
1731
|
+
path?: never;
|
|
1732
|
+
cookie?: never;
|
|
1733
|
+
};
|
|
1734
|
+
requestBody?: never;
|
|
1735
|
+
responses: {
|
|
1736
|
+
/** @description Success */
|
|
1737
|
+
200: {
|
|
1738
|
+
headers: {
|
|
1739
|
+
[name: string]: unknown;
|
|
1740
|
+
};
|
|
1741
|
+
content: {
|
|
1742
|
+
"application/json": components["schemas"]["RouterStatusSuccessResponse"];
|
|
1743
|
+
};
|
|
1744
|
+
};
|
|
1745
|
+
};
|
|
1746
|
+
};
|
|
1747
|
+
put?: never;
|
|
1748
|
+
post?: never;
|
|
1749
|
+
delete?: never;
|
|
1750
|
+
options?: never;
|
|
1751
|
+
head?: never;
|
|
1752
|
+
patch?: never;
|
|
1753
|
+
trace?: never;
|
|
1754
|
+
};
|
|
1755
|
+
"/v1/health/collectors": {
|
|
1756
|
+
parameters: {
|
|
1757
|
+
query?: never;
|
|
1758
|
+
header?: never;
|
|
1759
|
+
path?: never;
|
|
1760
|
+
cookie?: never;
|
|
1761
|
+
};
|
|
1762
|
+
/**
|
|
1763
|
+
* Retrieve collectors health
|
|
1764
|
+
* @description Returns the latest block numbers processed by collectors and their sync status.
|
|
1765
|
+
*/
|
|
1766
|
+
get: {
|
|
1767
|
+
parameters: {
|
|
1768
|
+
query?: never;
|
|
1769
|
+
header?: never;
|
|
1770
|
+
path?: never;
|
|
1771
|
+
cookie?: never;
|
|
1772
|
+
};
|
|
1773
|
+
requestBody?: never;
|
|
1774
|
+
responses: {
|
|
1775
|
+
/** @description Success */
|
|
1776
|
+
200: {
|
|
1777
|
+
headers: {
|
|
1778
|
+
[name: string]: unknown;
|
|
1779
|
+
};
|
|
1780
|
+
content: {
|
|
1781
|
+
"application/json": components["schemas"]["CollectorsHealthSuccessResponse"];
|
|
1782
|
+
};
|
|
1783
|
+
};
|
|
1784
|
+
};
|
|
1785
|
+
};
|
|
1786
|
+
put?: never;
|
|
1787
|
+
post?: never;
|
|
1788
|
+
delete?: never;
|
|
1789
|
+
options?: never;
|
|
1790
|
+
head?: never;
|
|
1791
|
+
patch?: never;
|
|
1792
|
+
trace?: never;
|
|
1793
|
+
};
|
|
1794
|
+
"/v1/health/chains": {
|
|
1795
|
+
parameters: {
|
|
1796
|
+
query?: never;
|
|
1797
|
+
header?: never;
|
|
1798
|
+
path?: never;
|
|
1799
|
+
cookie?: never;
|
|
1800
|
+
};
|
|
1801
|
+
/**
|
|
1802
|
+
* Retrieve chains health
|
|
1803
|
+
* @description Returns the latest block that can be processed by collectors for each chain.
|
|
1804
|
+
*/
|
|
1805
|
+
get: {
|
|
1806
|
+
parameters: {
|
|
1807
|
+
query?: never;
|
|
1808
|
+
header?: never;
|
|
1809
|
+
path?: never;
|
|
1810
|
+
cookie?: never;
|
|
1811
|
+
};
|
|
1812
|
+
requestBody?: never;
|
|
1813
|
+
responses: {
|
|
1814
|
+
/** @description Success */
|
|
1815
|
+
200: {
|
|
1816
|
+
headers: {
|
|
1817
|
+
[name: string]: unknown;
|
|
1818
|
+
};
|
|
1819
|
+
content: {
|
|
1820
|
+
"application/json": components["schemas"]["ChainsHealthSuccessResponse"];
|
|
1821
|
+
};
|
|
1822
|
+
};
|
|
1823
|
+
};
|
|
1824
|
+
};
|
|
1825
|
+
put?: never;
|
|
1826
|
+
post?: never;
|
|
1827
|
+
delete?: never;
|
|
1828
|
+
options?: never;
|
|
1829
|
+
head?: never;
|
|
1830
|
+
patch?: never;
|
|
1831
|
+
trace?: never;
|
|
1832
|
+
};
|
|
1833
|
+
"/v1/validate": {
|
|
1834
|
+
parameters: {
|
|
1835
|
+
query?: never;
|
|
1836
|
+
header?: never;
|
|
1837
|
+
path?: never;
|
|
1838
|
+
cookie?: never;
|
|
1839
|
+
};
|
|
1840
|
+
get?: never;
|
|
1841
|
+
put?: never;
|
|
1842
|
+
/**
|
|
1843
|
+
* Validate offers
|
|
1844
|
+
* @description Validates offers against router validation rules. Returns validation status for each offer.
|
|
1845
|
+
*
|
|
1846
|
+
* **Available validation rules:**
|
|
1847
|
+
* - **parse_error**: Returns when an offer fails to parse due to invalid format or missing required fields
|
|
1848
|
+
* - **chain_ids**: Validates that offer chain is one of: [109111114]
|
|
1849
|
+
* - **maturity**: Validates that offer maturity is one of: [end_of_month, end_of_next_month]
|
|
1850
|
+
* - **callback**: Validates callbacks: buy empty callback is allowed; sell offers must use a non-empty callback; non-empty callbacks must target one of [0x3333333333333333333333333333333333333333, 0x4444444444444444444444444444444444444444, 0x1111111111111111111111111111111111111111, 0x2222222222222222222222222222222222222222]
|
|
1851
|
+
* - **token**: Validates that offer loan token and collateral tokens are in the allowed assets list
|
|
1852
|
+
*/
|
|
1853
|
+
post: {
|
|
1854
|
+
parameters: {
|
|
1855
|
+
query?: never;
|
|
1856
|
+
header?: never;
|
|
1857
|
+
path?: never;
|
|
1858
|
+
cookie?: never;
|
|
1859
|
+
};
|
|
1860
|
+
requestBody?: {
|
|
1861
|
+
content: {
|
|
1862
|
+
"application/json": components["schemas"]["ValidateOffersRequest"];
|
|
1863
|
+
};
|
|
1864
|
+
};
|
|
1865
|
+
responses: {
|
|
1866
|
+
/** @description Success */
|
|
1867
|
+
200: {
|
|
1868
|
+
headers: {
|
|
1869
|
+
[name: string]: unknown;
|
|
1870
|
+
};
|
|
1871
|
+
content: {
|
|
1872
|
+
"application/json": components["schemas"]["ValidateOffersListResponse"];
|
|
1873
|
+
};
|
|
1874
|
+
};
|
|
1875
|
+
/** @description Bad Request */
|
|
1876
|
+
400: {
|
|
1877
|
+
headers: {
|
|
1878
|
+
[name: string]: unknown;
|
|
1879
|
+
};
|
|
1880
|
+
content: {
|
|
1881
|
+
"application/json": components["schemas"]["BadRequestResponse"];
|
|
1882
|
+
};
|
|
1883
|
+
};
|
|
1884
|
+
};
|
|
1885
|
+
};
|
|
1886
|
+
delete?: never;
|
|
1887
|
+
options?: never;
|
|
1888
|
+
head?: never;
|
|
1889
|
+
patch?: never;
|
|
1890
|
+
trace?: never;
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
interface components {
|
|
1894
|
+
schemas: {
|
|
1895
|
+
BookListResponse: {
|
|
1896
|
+
meta: components["schemas"]["Meta"];
|
|
1897
|
+
/** @example eyJvZmZzZXQiOjEwMH0 */
|
|
1898
|
+
cursor: string | null;
|
|
1899
|
+
/** @description Aggregated book levels grouped by rate. */
|
|
1900
|
+
data: components["schemas"]["BookLevelResponse"][];
|
|
1901
|
+
};
|
|
1902
|
+
Meta: {
|
|
1903
|
+
/** @example 2024-01-01T12:00:00.000Z */
|
|
1904
|
+
timestamp: string;
|
|
1905
|
+
};
|
|
1906
|
+
BookLevelResponse: {
|
|
1907
|
+
/** @example 2750000000000000000 */
|
|
1908
|
+
rate: string;
|
|
1909
|
+
/** @example 369216000000000000000000 */
|
|
1910
|
+
assets: string;
|
|
1911
|
+
/** @example 5 */
|
|
1912
|
+
count: number;
|
|
1913
|
+
};
|
|
1914
|
+
BadRequestResponse: {
|
|
1915
|
+
error: components["schemas"]["ErrorResponse"];
|
|
1916
|
+
meta: components["schemas"]["Meta"];
|
|
1917
|
+
};
|
|
1918
|
+
ErrorResponse: {
|
|
1919
|
+
/**
|
|
1920
|
+
* @example VALIDATION_ERROR
|
|
1921
|
+
* @enum {string}
|
|
1922
|
+
*/
|
|
1923
|
+
code: "VALIDATION_ERROR" | "NOT_FOUND" | "INTERNAL_SERVER_ERROR" | "BAD_REQUEST";
|
|
1924
|
+
/** @example Limit must be greater than 0. */
|
|
1925
|
+
message: string;
|
|
1926
|
+
/**
|
|
1927
|
+
* @example [
|
|
1928
|
+
* {
|
|
1929
|
+
* "field": "limit",
|
|
1930
|
+
* "issue": "Limit must be greater than 0."
|
|
1931
|
+
* }
|
|
1932
|
+
* ]
|
|
1933
|
+
*/
|
|
1934
|
+
details: Record<string, never>;
|
|
1935
|
+
};
|
|
1936
|
+
OfferListResponse: {
|
|
1937
|
+
meta: components["schemas"]["Meta"];
|
|
1938
|
+
/** @example eyJvZmZzZXQiOjEwMH0 */
|
|
1939
|
+
cursor: string | null;
|
|
1940
|
+
/**
|
|
1941
|
+
* @description Offers matching the provided filters.
|
|
1942
|
+
* @example [
|
|
1943
|
+
* {
|
|
1944
|
+
* "hash": "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
|
|
1945
|
+
* "offering": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
|
|
1946
|
+
* "assets": "369216000000000000000000",
|
|
1947
|
+
* "rate": "2750000000000000000",
|
|
1948
|
+
* "maturity": 1761922799,
|
|
1949
|
+
* "expiry": 1761922799,
|
|
1950
|
+
* "start": 1761922790,
|
|
1951
|
+
* "nonce": "571380",
|
|
1952
|
+
* "buy": false,
|
|
1953
|
+
* "chain_id": 1,
|
|
1954
|
+
* "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
|
|
1955
|
+
* "collaterals": [
|
|
1956
|
+
* {
|
|
1957
|
+
* "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
|
|
1958
|
+
* "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
|
|
1959
|
+
* "lltv": "860000000000000000"
|
|
1960
|
+
* }
|
|
1961
|
+
* ],
|
|
1962
|
+
* "callback": {
|
|
1963
|
+
* "address": "0x1111111111111111111111111111111111111111",
|
|
1964
|
+
* "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
|
|
1965
|
+
* "gas_limit": "500000"
|
|
1966
|
+
* },
|
|
1967
|
+
* "signature": "0x1234567890123456789012345678901234567890123456789012345678901234123456789012345678901234567890123456789012345678901234567890123400",
|
|
1968
|
+
* "consumed": "0",
|
|
1969
|
+
* "takeable": "369216000000000000000000",
|
|
1970
|
+
* "block_number": 2942933377146801
|
|
1971
|
+
* }
|
|
1972
|
+
* ]
|
|
1973
|
+
*/
|
|
1974
|
+
data: components["schemas"]["OfferListItemResponse"][];
|
|
1975
|
+
};
|
|
1976
|
+
OfferListItemResponse: {
|
|
1977
|
+
/** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
|
|
1978
|
+
hash: string;
|
|
1979
|
+
/** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
1980
|
+
offering: string;
|
|
1981
|
+
/** @example 369216000000000000000000 */
|
|
1982
|
+
assets: string;
|
|
1983
|
+
/** @example 2750000000000000000 */
|
|
1984
|
+
rate: string;
|
|
1985
|
+
/** @example 1761922799 */
|
|
1986
|
+
maturity: number;
|
|
1987
|
+
/** @example 1761922799 */
|
|
1988
|
+
expiry: number;
|
|
1989
|
+
/** @example 1761922790 */
|
|
1990
|
+
start: number;
|
|
1991
|
+
/** @example 571380 */
|
|
1992
|
+
nonce: string;
|
|
1993
|
+
/** @example false */
|
|
1994
|
+
buy: boolean;
|
|
1995
|
+
/** @example 1 */
|
|
1996
|
+
chain_id: number;
|
|
1997
|
+
/** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
|
|
1998
|
+
loan_token: string;
|
|
1999
|
+
/**
|
|
2000
|
+
* @example [
|
|
2001
|
+
* {
|
|
2002
|
+
* "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
|
|
2003
|
+
* "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
|
|
2004
|
+
* "lltv": "860000000000000000"
|
|
2005
|
+
* }
|
|
2006
|
+
* ]
|
|
2007
|
+
*/
|
|
2008
|
+
collaterals: components["schemas"]["CollateralResponse"][];
|
|
2009
|
+
/**
|
|
2010
|
+
* @example {
|
|
2011
|
+
* "address": "0x1111111111111111111111111111111111111111",
|
|
2012
|
+
* "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
|
|
2013
|
+
* "gas_limit": "500000"
|
|
2014
|
+
* }
|
|
2015
|
+
*/
|
|
2016
|
+
callback: components["schemas"]["OfferCallbackResponse"];
|
|
2017
|
+
/** @example 369216000000000000000000 */
|
|
2018
|
+
takeable: string;
|
|
2019
|
+
/** @example 0 */
|
|
2020
|
+
consumed: string;
|
|
2021
|
+
/** @example 2942933377146801 */
|
|
2022
|
+
block_number: number;
|
|
2023
|
+
/** @example 0x1234567890123456789012345678901234567890123456789012345678901234123456789012345678901234567890123456789012345678901234567890123400 */
|
|
2024
|
+
signature: string | null;
|
|
2025
|
+
};
|
|
2026
|
+
CollateralResponse: {
|
|
2027
|
+
/** @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751 */
|
|
2028
|
+
asset: string;
|
|
2029
|
+
/** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
2030
|
+
oracle: string;
|
|
2031
|
+
/** @example 860000000000000000 */
|
|
2032
|
+
lltv: string;
|
|
2033
|
+
};
|
|
2034
|
+
OfferCallbackResponse: {
|
|
2035
|
+
/** @example 0x1111111111111111111111111111111111111111 */
|
|
2036
|
+
address: string;
|
|
2037
|
+
/** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
|
|
2038
|
+
data: string;
|
|
2039
|
+
/** @example 500000 */
|
|
2040
|
+
gas_limit: string;
|
|
2041
|
+
};
|
|
2042
|
+
ObligationListResponse: {
|
|
2043
|
+
meta: components["schemas"]["Meta"];
|
|
2044
|
+
/** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
|
|
2045
|
+
cursor: string | null;
|
|
2046
|
+
/** @description List of obligations with takable offers. */
|
|
2047
|
+
data: components["schemas"]["ObligationResponse"][];
|
|
2048
|
+
};
|
|
2049
|
+
ObligationResponse: {
|
|
2050
|
+
/** @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67 */
|
|
2051
|
+
id: string;
|
|
2052
|
+
/** @example 1 */
|
|
2053
|
+
chain_id: number;
|
|
2054
|
+
/** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
|
|
2055
|
+
loan_token: string;
|
|
2056
|
+
collaterals: components["schemas"]["CollateralResponse"][];
|
|
2057
|
+
/** @example 1761922800 */
|
|
2058
|
+
maturity: number;
|
|
2059
|
+
ask: components["schemas"]["AskResponse"];
|
|
2060
|
+
bid: components["schemas"]["BidResponse"];
|
|
2061
|
+
};
|
|
2062
|
+
AskResponse: {
|
|
2063
|
+
/** @example 1000000000000000000 */
|
|
2064
|
+
rate: string;
|
|
2065
|
+
};
|
|
2066
|
+
BidResponse: {
|
|
2067
|
+
/** @example 1000000000000000000 */
|
|
2068
|
+
rate: string;
|
|
2069
|
+
};
|
|
2070
|
+
ObligationSingleSuccessResponse: {
|
|
2071
|
+
meta: components["schemas"]["Meta"];
|
|
2072
|
+
/** @example null */
|
|
2073
|
+
cursor: string | null;
|
|
2074
|
+
/** @description Obligation details. */
|
|
2075
|
+
data: components["schemas"]["ObligationResponse"];
|
|
2076
|
+
};
|
|
2077
|
+
RouterStatusSuccessResponse: {
|
|
2078
|
+
meta: components["schemas"]["Meta"];
|
|
2079
|
+
/**
|
|
2080
|
+
* @description Aggregated router status.
|
|
2081
|
+
* @example {
|
|
2082
|
+
* "status": "live"
|
|
2083
|
+
* }
|
|
2084
|
+
*/
|
|
2085
|
+
data: components["schemas"]["RouterStatusDataResponse"];
|
|
2086
|
+
};
|
|
2087
|
+
RouterStatusDataResponse: {
|
|
2088
|
+
/**
|
|
2089
|
+
* @example live
|
|
2090
|
+
* @enum {string}
|
|
2091
|
+
*/
|
|
2092
|
+
status: "live" | "syncing";
|
|
2093
|
+
};
|
|
2094
|
+
CollectorsHealthSuccessResponse: {
|
|
2095
|
+
meta: components["schemas"]["Meta"];
|
|
2096
|
+
/**
|
|
2097
|
+
* @description Collectors health details and sync status.
|
|
2098
|
+
* @example [
|
|
2099
|
+
* {
|
|
2100
|
+
* "name": "offers",
|
|
2101
|
+
* "chain_id": 1,
|
|
2102
|
+
* "block_number": 21345678,
|
|
2103
|
+
* "updated_at": "2024-01-01T12:00:00.000Z",
|
|
2104
|
+
* "lag": 0,
|
|
2105
|
+
* "status": "live"
|
|
2106
|
+
* }
|
|
2107
|
+
* ]
|
|
2108
|
+
*/
|
|
2109
|
+
data: components["schemas"]["CollectorHealthResponse"][];
|
|
2110
|
+
};
|
|
2111
|
+
CollectorHealthResponse: {
|
|
2112
|
+
/** @example offers */
|
|
2113
|
+
name: string;
|
|
2114
|
+
/** @example 1 */
|
|
2115
|
+
chain_id: number;
|
|
2116
|
+
/** @example 21345678 */
|
|
2117
|
+
block_number: number | null;
|
|
2118
|
+
/** @example 2024-01-01T12:00:00.000Z */
|
|
2119
|
+
updated_at: string | null;
|
|
2120
|
+
/** @example 0 */
|
|
2121
|
+
lag: number | null;
|
|
2122
|
+
/**
|
|
2123
|
+
* @example live
|
|
2124
|
+
* @enum {string}
|
|
2125
|
+
*/
|
|
2126
|
+
status: "live" | "lagging" | "unknown";
|
|
2127
|
+
};
|
|
2128
|
+
ChainsHealthSuccessResponse: {
|
|
2129
|
+
meta: components["schemas"]["Meta"];
|
|
2130
|
+
/**
|
|
2131
|
+
* @description Latest processed block per chain.
|
|
2132
|
+
* @example [
|
|
2133
|
+
* {
|
|
2134
|
+
* "chain_id": 1,
|
|
2135
|
+
* "local_block_number": 21345678,
|
|
2136
|
+
* "remote_block_number": 21345690,
|
|
2137
|
+
* "updated_at": "2024-01-01T12:00:00.000Z"
|
|
2138
|
+
* }
|
|
2139
|
+
* ]
|
|
2140
|
+
*/
|
|
2141
|
+
data: components["schemas"]["ChainHealthResponse"][];
|
|
2142
|
+
};
|
|
2143
|
+
ChainHealthResponse: {
|
|
2144
|
+
/** @example 1 */
|
|
2145
|
+
chain_id: number;
|
|
2146
|
+
/** @example 21345678 */
|
|
2147
|
+
local_block_number: number;
|
|
2148
|
+
/** @example 21345690 */
|
|
2149
|
+
remote_block_number: number | null;
|
|
2150
|
+
/** @example 2024-01-01T12:00:00.000Z */
|
|
2151
|
+
updated_at: string;
|
|
2152
|
+
};
|
|
2153
|
+
ValidateOffersRequest: {
|
|
2154
|
+
/** @description Array of offers in snake_case format. Mutually exclusive with 'calldata'. */
|
|
2155
|
+
offers?: components["schemas"]["ValidateOfferRequest"][];
|
|
2156
|
+
/**
|
|
2157
|
+
* @description Encoded tree calldata as a hex string (0x-prefixed). Mutually exclusive with 'offers'.
|
|
2158
|
+
* @example 0x01...
|
|
2159
|
+
*/
|
|
2160
|
+
calldata?: string;
|
|
2161
|
+
};
|
|
2162
|
+
ValidateOfferRequest: {
|
|
2163
|
+
/** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
2164
|
+
offering: string;
|
|
2165
|
+
/** @example 369216000000000000000000 */
|
|
2166
|
+
assets: string;
|
|
2167
|
+
/** @example 2750000000000000000 */
|
|
2168
|
+
rate: string;
|
|
2169
|
+
/** @example 1761922799 */
|
|
2170
|
+
maturity: number;
|
|
2171
|
+
/** @example 1761922799 */
|
|
2172
|
+
expiry: number;
|
|
2173
|
+
/** @example 1761922790 */
|
|
2174
|
+
start: number;
|
|
2175
|
+
/** @example 571380 */
|
|
2176
|
+
nonce: string;
|
|
2177
|
+
/** @example false */
|
|
2178
|
+
buy: boolean;
|
|
2179
|
+
/** @example 1 */
|
|
2180
|
+
chain_id: number;
|
|
2181
|
+
/** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
|
|
2182
|
+
loan_token: string;
|
|
2183
|
+
/**
|
|
2184
|
+
* @example [
|
|
2185
|
+
* {
|
|
2186
|
+
* "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
|
|
2187
|
+
* "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
|
|
2188
|
+
* "lltv": "860000000000000000"
|
|
2189
|
+
* }
|
|
2190
|
+
* ]
|
|
2191
|
+
*/
|
|
2192
|
+
collaterals: components["schemas"]["CollateralResponse"][];
|
|
2193
|
+
/**
|
|
2194
|
+
* @example {
|
|
2195
|
+
* "address": "0x1111111111111111111111111111111111111111",
|
|
2196
|
+
* "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
|
|
2197
|
+
* "gas_limit": "500000"
|
|
2198
|
+
* }
|
|
2199
|
+
*/
|
|
2200
|
+
callback: components["schemas"]["OfferCallbackResponse"];
|
|
2201
|
+
};
|
|
2202
|
+
ValidateOffersListResponse: {
|
|
2203
|
+
meta: components["schemas"]["Meta"];
|
|
2204
|
+
/** @example null */
|
|
2205
|
+
cursor: string | null;
|
|
2206
|
+
/** @description Validation results for each offer. */
|
|
2207
|
+
data: components["schemas"]["ValidateOfferResultResponse"][];
|
|
2208
|
+
};
|
|
2209
|
+
ValidateOfferResultResponse: {
|
|
2210
|
+
/** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
|
|
2211
|
+
offer_hash: string;
|
|
2212
|
+
/** @example false */
|
|
2213
|
+
valid: boolean;
|
|
2214
|
+
/** @example parse_error */
|
|
2215
|
+
rule: string | null;
|
|
2216
|
+
/** @example Invalid offer. 'offering': invalid address */
|
|
2217
|
+
message: string | null;
|
|
2218
|
+
};
|
|
2219
|
+
};
|
|
2220
|
+
responses: never;
|
|
2221
|
+
parameters: never;
|
|
2222
|
+
requestBodies: never;
|
|
2223
|
+
headers: never;
|
|
2224
|
+
pathItems: never;
|
|
2225
|
+
}
|
|
2226
|
+
declare namespace ObligationResponse_d_exports {
|
|
2227
|
+
export { ObligationResponse, from$2 as from };
|
|
2228
|
+
}
|
|
2229
|
+
type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
|
|
1163
2230
|
/**
|
|
1164
2231
|
* Creates an `ObligationResponse` from a `Obligation`.
|
|
1165
2232
|
* @constructor
|
|
@@ -1167,13 +2234,10 @@ type ObligationResponse = Snake<Compute<{
|
|
|
1167
2234
|
* @returns The created `ObligationResponse`. {@link ObligationResponse}
|
|
1168
2235
|
*/
|
|
1169
2236
|
declare function from$2(obligation: Obligation, quote: Quote): ObligationResponse;
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
declare namespace ObligationResponse$1 {
|
|
1173
|
-
export { type ObligationResponse$1_ObligationResponse as ObligationResponse, from$2 as from };
|
|
2237
|
+
declare namespace OfferResponse_d_exports {
|
|
2238
|
+
export { OfferResponse, from$1 as from };
|
|
1174
2239
|
}
|
|
1175
|
-
|
|
1176
|
-
type OfferResponse = Snake<Offer>;
|
|
2240
|
+
type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
|
|
1177
2241
|
/**
|
|
1178
2242
|
* Creates an `OfferResponse` from an `Offer`.
|
|
1179
2243
|
* @constructor
|
|
@@ -1181,415 +2245,473 @@ type OfferResponse = Snake<Offer>;
|
|
|
1181
2245
|
* @returns The created `OfferResponse`. {@link OfferResponse}
|
|
1182
2246
|
*/
|
|
1183
2247
|
declare function from$1(offer: Offer): OfferResponse;
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
declare
|
|
1187
|
-
|
|
2248
|
+
//#endregion
|
|
2249
|
+
//#region src/api/Schema/openapi.d.ts
|
|
2250
|
+
declare class BooksController {
|
|
2251
|
+
getBook(): Promise<void>;
|
|
1188
2252
|
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
2253
|
+
declare class ValidateController {
|
|
2254
|
+
validateOffers(): Promise<void>;
|
|
2255
|
+
}
|
|
2256
|
+
declare class OffersController {
|
|
2257
|
+
getOffers(): Promise<void>;
|
|
2258
|
+
}
|
|
2259
|
+
declare class HealthController {
|
|
2260
|
+
getRouterStatus(): Promise<void>;
|
|
2261
|
+
getCollectorsHealth(): Promise<void>;
|
|
2262
|
+
getChainsHealth(): Promise<void>;
|
|
2263
|
+
}
|
|
2264
|
+
declare class ObligationsController {
|
|
2265
|
+
getObligations(): Promise<void>;
|
|
2266
|
+
getObligation(): Promise<void>;
|
|
2267
|
+
}
|
|
2268
|
+
type RuleInfo = {
|
|
2269
|
+
name: string;
|
|
2270
|
+
description: string;
|
|
2271
|
+
};
|
|
2272
|
+
type OpenApiOptions = {
|
|
2273
|
+
rules?: RuleInfo[];
|
|
2274
|
+
};
|
|
2275
|
+
declare const OpenApi: (options?: OpenApiOptions) => Promise<OpenAPIDocument>;
|
|
2276
|
+
//#endregion
|
|
2277
|
+
//#region src/api/Schema/requests.d.ts
|
|
1192
2278
|
declare const schemas: {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
2279
|
+
readonly get_offers: z$1.ZodObject<{
|
|
2280
|
+
side: z$1.ZodOptional<z$1.ZodEnum<{
|
|
2281
|
+
buy: "buy";
|
|
2282
|
+
sell: "sell";
|
|
2283
|
+
}>>;
|
|
2284
|
+
obligation_id: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
|
|
2285
|
+
offering: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
|
|
2286
|
+
cursor: z$1.ZodOptional<z$1.ZodString>;
|
|
2287
|
+
limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
|
|
2288
|
+
}, z$1.core.$strip>;
|
|
2289
|
+
readonly get_obligations: z$1.ZodObject<{
|
|
2290
|
+
cursor: z$1.ZodOptional<z$1.ZodString>;
|
|
2291
|
+
limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
|
|
2292
|
+
}, z$1.core.$strip>;
|
|
2293
|
+
readonly get_obligation: z$1.ZodObject<{
|
|
2294
|
+
obligation_id: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
2295
|
+
}, z$1.core.$strip>;
|
|
2296
|
+
readonly get_book: z$1.ZodObject<{
|
|
2297
|
+
obligation_id: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
2298
|
+
side: z$1.ZodEnum<{
|
|
2299
|
+
buy: "buy";
|
|
2300
|
+
sell: "sell";
|
|
2301
|
+
}>;
|
|
2302
|
+
cursor: z$1.ZodOptional<z$1.ZodString>;
|
|
2303
|
+
limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
|
|
2304
|
+
}, z$1.core.$strip>;
|
|
2305
|
+
readonly validate_offers: z$1.ZodObject<{
|
|
2306
|
+
offers: z$1.ZodAny;
|
|
2307
|
+
calldata: z$1.ZodOptional<z$1.ZodString>;
|
|
2308
|
+
}, z$1.core.$strip>;
|
|
1206
2309
|
};
|
|
1207
2310
|
type Action = keyof typeof schemas;
|
|
1208
|
-
declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
|
|
1209
|
-
declare function safeParse<A extends Action>(action: A, query: unknown, error?: z.core.$ZodErrorMap<z.core.$ZodIssue>): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
declare
|
|
1214
|
-
|
|
1215
|
-
declare const index$1_OpenApi: typeof OpenApi;
|
|
1216
|
-
type index$1_RouterStatusResponse = RouterStatusResponse;
|
|
1217
|
-
declare const index$1_parse: typeof parse;
|
|
1218
|
-
declare const index$1_safeParse: typeof safeParse;
|
|
1219
|
-
declare namespace index$1 {
|
|
1220
|
-
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 };
|
|
2311
|
+
declare function parse<A extends Action>(action: A, query: unknown): z$1.infer<(typeof schemas)[A]>;
|
|
2312
|
+
declare function safeParse<A extends Action>(action: A, query: unknown, error?: z$1.core.$ZodErrorMap<z$1.core.$ZodIssue>): z$1.ZodSafeParseResult<z$1.infer<(typeof schemas)[A]>>;
|
|
2313
|
+
declare namespace index_d_exports$1 {
|
|
2314
|
+
export { BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, OpenApiOptions, RouterStatusResponse, RuleInfo, ValidateController, parse, safeParse };
|
|
2315
|
+
}
|
|
2316
|
+
declare namespace Client_d_exports {
|
|
2317
|
+
export { Client$2 as Client, ConnectOptions, HttpForbiddenError, HttpGetApiFailedError, HttpRateLimitError, HttpUnauthorizedError, InvalidUrlError, connect$1 as connect, getObligations, getOffers };
|
|
1221
2318
|
}
|
|
1222
|
-
|
|
1223
2319
|
type RouterClientConfig = {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
2320
|
+
/** The URL of the router. */
|
|
2321
|
+
readonly url: URL;
|
|
2322
|
+
/** The default headers to use for each request. */
|
|
2323
|
+
readonly headers: Headers;
|
|
1228
2324
|
};
|
|
1229
|
-
type Client$
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
2325
|
+
type Client$2 = Compute<RouterClientConfig & {
|
|
2326
|
+
/**
|
|
2327
|
+
* Get offers from the router.
|
|
2328
|
+
* @param parameters - {@link getOffers.Parameters}
|
|
2329
|
+
* @returns The offers with pagination cursor. {@link getOffers.ReturnType}
|
|
2330
|
+
* @throws If the request fails - {@link getOffers.ErrorType}
|
|
2331
|
+
*
|
|
2332
|
+
* @example
|
|
2333
|
+
* ```ts
|
|
2334
|
+
* const router = RouterClient.connect({ url: "https://router.morpho.dev" });
|
|
2335
|
+
* const { offers, cursor } = await router.getOffers({ side: "buy", obligationId: "0xa1c...d2f" });
|
|
2336
|
+
* console.log(offers);
|
|
2337
|
+
* ```
|
|
2338
|
+
*/
|
|
2339
|
+
getOffers: (parameters: getOffers.Parameters) => Promise<getOffers.ReturnType>;
|
|
2340
|
+
/**
|
|
2341
|
+
* Get obligations from the router.
|
|
2342
|
+
* @param parameters - {@link getObligations.Parameters}
|
|
2343
|
+
* @returns The obligations with pagination cursor. {@link getObligations.ReturnType}
|
|
2344
|
+
* @throws If the request fails - {@link getObligations.ErrorType}
|
|
2345
|
+
*
|
|
2346
|
+
* @example
|
|
2347
|
+
* ```ts
|
|
2348
|
+
* const router = RouterClient.connect({ url: "https://router.morpho.dev" });
|
|
2349
|
+
* const { obligations, cursor } = await router.getObligations();
|
|
2350
|
+
* console.log(obligations[0].id()); // 0x123...456
|
|
2351
|
+
* ```
|
|
2352
|
+
*/
|
|
2353
|
+
getObligations: (parameters?: getObligations.Parameters) => Promise<getObligations.ReturnType>;
|
|
1256
2354
|
}>;
|
|
1257
2355
|
type ConnectOptions = {
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
2356
|
+
/** The URL of the router to interact with.
|
|
2357
|
+
* @default "https://router.morpho.dev"
|
|
2358
|
+
*/
|
|
2359
|
+
url?: string;
|
|
2360
|
+
/** The API key to use for the router API. */
|
|
2361
|
+
apiKey?: string;
|
|
2362
|
+
/** The default headers to use for each request. */
|
|
2363
|
+
headers?: Headers;
|
|
1266
2364
|
};
|
|
1267
2365
|
/**
|
|
1268
2366
|
* Creates an instance of a router client.
|
|
1269
2367
|
* @constructor
|
|
1270
|
-
* @param
|
|
1271
|
-
* @returns A Router Client. {@link
|
|
2368
|
+
* @param parameters - {@link connect.Parameters}
|
|
2369
|
+
* @returns A Router Client. {@link connect.ReturnType}
|
|
1272
2370
|
*
|
|
1273
2371
|
* @example
|
|
1274
2372
|
* ```typescript
|
|
1275
2373
|
* const router = RouterClient.connect({ url: "https://router.morpho.dev" });
|
|
1276
2374
|
* ```
|
|
1277
2375
|
*/
|
|
1278
|
-
declare function connect$1(
|
|
2376
|
+
declare function connect$1(parameters?: connect$1.Parameters): connect$1.ReturnType;
|
|
1279
2377
|
declare namespace connect$1 {
|
|
1280
|
-
|
|
1281
|
-
|
|
2378
|
+
type Parameters = ConnectOptions;
|
|
2379
|
+
type ReturnType = Client$2;
|
|
2380
|
+
type ErrorType = InvalidUrlError;
|
|
1282
2381
|
}
|
|
1283
|
-
declare function getOffers(
|
|
2382
|
+
declare function getOffers(apiClient: Client<paths>, parameters: getOffers.Parameters): Promise<getOffers.ReturnType>;
|
|
1284
2383
|
declare namespace getOffers {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
2384
|
+
type Parameters = {
|
|
2385
|
+
/** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
|
|
2386
|
+
side: "buy" | "sell";
|
|
2387
|
+
/** The offers obligation id */
|
|
2388
|
+
obligationId: Hex;
|
|
2389
|
+
/** Pagination cursor in base64url-encoded format */
|
|
2390
|
+
cursor?: string;
|
|
2391
|
+
/** Maximum number of offers to return. @default 20 */
|
|
2392
|
+
limit?: number;
|
|
2393
|
+
};
|
|
2394
|
+
type ReturnType = {
|
|
2395
|
+
offers: Offer[];
|
|
2396
|
+
/** The pagination cursor. */
|
|
2397
|
+
cursor: string | null;
|
|
2398
|
+
};
|
|
2399
|
+
type ErrorType = GetApiErrorType;
|
|
1301
2400
|
}
|
|
1302
|
-
declare function getObligations(
|
|
2401
|
+
declare function getObligations(apiClient: Client<paths>, parameters?: getObligations.Parameters): Promise<getObligations.ReturnType>;
|
|
1303
2402
|
declare namespace getObligations {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
2403
|
+
type Parameters = {
|
|
2404
|
+
/** Pagination cursor is a 32-byte hex string. */
|
|
2405
|
+
cursor?: Hex;
|
|
2406
|
+
/** Maximum number of obligations to return. @default 20 */
|
|
2407
|
+
limit?: number;
|
|
2408
|
+
};
|
|
2409
|
+
type ReturnType = {
|
|
2410
|
+
obligations: Compute<{
|
|
2411
|
+
/** The obligation id. Uses {@link Obligation.id} to calculate the id.*/
|
|
2412
|
+
id: () => Hex;
|
|
2413
|
+
} & Obligation & Omit<Quote, "obligationId">>[];
|
|
2414
|
+
/** The pagination cursor. */
|
|
2415
|
+
cursor: string | null;
|
|
2416
|
+
};
|
|
2417
|
+
type ErrorType = GetApiErrorType;
|
|
1319
2418
|
}
|
|
1320
2419
|
type GetApiErrorType = HttpGetApiFailedError | HttpUnauthorizedError | HttpForbiddenError | HttpRateLimitError;
|
|
1321
2420
|
declare class InvalidUrlError extends BaseError {
|
|
1322
|
-
|
|
1323
|
-
|
|
2421
|
+
name: string;
|
|
2422
|
+
constructor(url: string);
|
|
1324
2423
|
}
|
|
1325
2424
|
declare class HttpUnauthorizedError extends BaseError {
|
|
1326
|
-
|
|
1327
|
-
|
|
2425
|
+
name: string;
|
|
2426
|
+
constructor();
|
|
1328
2427
|
}
|
|
1329
2428
|
declare class HttpForbiddenError extends BaseError {
|
|
1330
|
-
|
|
1331
|
-
|
|
2429
|
+
name: string;
|
|
2430
|
+
constructor();
|
|
1332
2431
|
}
|
|
1333
2432
|
declare class HttpRateLimitError extends BaseError {
|
|
1334
|
-
|
|
1335
|
-
|
|
2433
|
+
name: string;
|
|
2434
|
+
constructor();
|
|
1336
2435
|
}
|
|
1337
2436
|
declare class HttpGetApiFailedError extends BaseError {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
2437
|
+
name: string;
|
|
2438
|
+
constructor(message: string, {
|
|
2439
|
+
details
|
|
2440
|
+
}?: {
|
|
2441
|
+
details?: string;
|
|
2442
|
+
});
|
|
1342
2443
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
declare
|
|
1357
|
-
declare
|
|
1358
|
-
|
|
2444
|
+
declare namespace Cursor_d_exports {
|
|
2445
|
+
export { Cursor, decode, encode, validate };
|
|
2446
|
+
}
|
|
2447
|
+
type Cursor = {
|
|
2448
|
+
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
2449
|
+
dir: "asc" | "desc";
|
|
2450
|
+
rate?: string;
|
|
2451
|
+
maturity?: number;
|
|
2452
|
+
expiry?: number;
|
|
2453
|
+
assets?: string;
|
|
2454
|
+
hash: string;
|
|
2455
|
+
page?: number;
|
|
2456
|
+
};
|
|
2457
|
+
declare function validate(cursor: unknown): cursor is Cursor;
|
|
2458
|
+
declare function encode(c: Cursor): string;
|
|
2459
|
+
declare function decode(token?: string): Cursor | null;
|
|
2460
|
+
declare namespace Gate_d_exports {
|
|
2461
|
+
export { Batch, Issue, Result, Rule, RuleNames, Single, batch$1 as batch, run, single };
|
|
1359
2462
|
}
|
|
1360
|
-
|
|
1361
2463
|
/**
|
|
1362
2464
|
* A validation rule.
|
|
1363
2465
|
*/
|
|
1364
|
-
type Rule<T, Name extends string = string
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
2466
|
+
type Rule<T, Name$1 extends string = string> = {
|
|
2467
|
+
kind: "single";
|
|
2468
|
+
name: Name$1;
|
|
2469
|
+
description: string;
|
|
2470
|
+
run: Single<T, Name$1>;
|
|
1368
2471
|
} | {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
2472
|
+
kind: "batch";
|
|
2473
|
+
name: Name$1;
|
|
2474
|
+
description: string;
|
|
2475
|
+
run: Batch<T, Name$1>;
|
|
1372
2476
|
};
|
|
1373
|
-
type RuleNames<Rules extends readonly {
|
|
1374
|
-
|
|
1375
|
-
}[]> = Rules[number]["name"];
|
|
2477
|
+
type RuleNames<Rules$1 extends readonly {
|
|
2478
|
+
name: string;
|
|
2479
|
+
}[]> = Rules$1[number]["name"];
|
|
1376
2480
|
/**
|
|
1377
2481
|
* A single item validation rule.
|
|
1378
2482
|
* @param item - The item to validate.
|
|
1379
|
-
* @param ctx - The context of the validation.
|
|
1380
2483
|
* @returns The issue that was found. If the item is valid, this will be undefined.
|
|
1381
2484
|
*/
|
|
1382
|
-
type Single<T, RuleName extends string
|
|
2485
|
+
type Single<T, RuleName extends string> = (item: T) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
|
|
1383
2486
|
/**
|
|
1384
2487
|
* A batch item validation rule.
|
|
1385
2488
|
* @param items - The items to validate.
|
|
1386
|
-
* @param ctx - The context of the validation.
|
|
1387
2489
|
* @returns A map of the items to the issue that was found.
|
|
1388
2490
|
*/
|
|
1389
|
-
type Batch<T, RuleName extends string
|
|
2491
|
+
type Batch<T, RuleName extends string> = (items: T[]) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
|
|
1390
2492
|
/**
|
|
1391
2493
|
* Create a validation rule iterating over a single item at a time.
|
|
1392
2494
|
* @param name - The name of the rule.
|
|
2495
|
+
* @param description - A human-readable description of the rule.
|
|
1393
2496
|
* @param run - The function that validates the rule.
|
|
1394
2497
|
* @returns The created rule.
|
|
1395
2498
|
*/
|
|
1396
|
-
declare function single<Name extends string, T
|
|
2499
|
+
declare function single<Name$1 extends string, T>(name: Name$1, description: string, run: Single<T, Name$1>): Rule<T, Name$1>;
|
|
1397
2500
|
/**
|
|
1398
2501
|
* Create a validation rule iterating over a batch of items at a time.
|
|
1399
2502
|
* @param name - The name of the rule.
|
|
2503
|
+
* @param description - A human-readable description of the rule.
|
|
1400
2504
|
* @param run - The function that validates the rule.
|
|
1401
2505
|
* @returns The created rule.
|
|
1402
2506
|
*/
|
|
1403
|
-
declare function batch$1<Name extends string, T
|
|
1404
|
-
type MorphoContext = {
|
|
1405
|
-
chain: Chain;
|
|
1406
|
-
client: PublicClient;
|
|
1407
|
-
};
|
|
1408
|
-
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>)[];
|
|
1409
|
-
|
|
1410
|
-
type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
|
|
1411
|
-
type ValidationRule_MorphoContext = MorphoContext;
|
|
1412
|
-
type ValidationRule_Rule<T, Name extends string = string, Ctx = void> = Rule<T, Name, Ctx>;
|
|
1413
|
-
type ValidationRule_RuleNames<Rules extends readonly {
|
|
1414
|
-
name: string;
|
|
1415
|
-
}[]> = RuleNames<Rules>;
|
|
1416
|
-
type ValidationRule_Single<T, RuleName extends string, Ctx = void> = Single<T, RuleName, Ctx>;
|
|
1417
|
-
declare const ValidationRule_morpho: typeof morpho;
|
|
1418
|
-
declare const ValidationRule_single: typeof single;
|
|
1419
|
-
declare namespace ValidationRule {
|
|
1420
|
-
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 };
|
|
1421
|
-
}
|
|
1422
|
-
|
|
2507
|
+
declare function batch$1<Name$1 extends string, T>(name: Name$1, description: string, run: Batch<T, Name$1>): Rule<T, Name$1>;
|
|
1423
2508
|
/**
|
|
1424
2509
|
* A validation issue.
|
|
1425
2510
|
*/
|
|
1426
2511
|
type Issue<T, RuleName extends string = string> = {
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
2512
|
+
/** The name of the rule that caused the issue. */
|
|
2513
|
+
ruleName: RuleName;
|
|
2514
|
+
/** The message of the issue. */
|
|
2515
|
+
message: string;
|
|
2516
|
+
/** The item that was not valid. */
|
|
2517
|
+
item: T;
|
|
1433
2518
|
};
|
|
1434
2519
|
/**
|
|
1435
2520
|
* The result of a validation.
|
|
1436
2521
|
*/
|
|
1437
2522
|
type Result<T, RuleName extends string = string> = {
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
2523
|
+
/** The items that were valid. */
|
|
2524
|
+
valid: T[];
|
|
2525
|
+
/** The reports of the failed validations. */
|
|
2526
|
+
issues: Issue<T, RuleName>[];
|
|
1442
2527
|
};
|
|
1443
|
-
declare function run<T, Name extends string, Rules extends readonly Rule<T, Name
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
}): Promise<Result<T, RuleNames<Rules>>>;
|
|
1448
|
-
declare
|
|
1449
|
-
|
|
1450
|
-
rules: Rules;
|
|
1451
|
-
ctx: Ctx;
|
|
1452
|
-
chunkSize?: number;
|
|
1453
|
-
}): Promise<Result<T, RuleNames<Rules>>>;
|
|
1454
|
-
|
|
1455
|
-
type Validation_Issue<T, RuleName extends string = string> = Issue<T, RuleName>;
|
|
1456
|
-
type Validation_Result<T, RuleName extends string = string> = Result<T, RuleName>;
|
|
1457
|
-
declare const Validation_run: typeof run;
|
|
1458
|
-
declare namespace Validation {
|
|
1459
|
-
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
2528
|
+
declare function run<T, Name$1 extends string, Rules$1 extends readonly Rule<T, Name$1>[]>(parameters: {
|
|
2529
|
+
items: T[];
|
|
2530
|
+
rules: Rules$1;
|
|
2531
|
+
chunkSize?: number;
|
|
2532
|
+
}): Promise<Result<T, RuleNames<Rules$1>>>;
|
|
2533
|
+
declare namespace GateConfig_d_exports {
|
|
2534
|
+
export { CallbackConfig, GateConfig, assets$1 as assets, configs, getCallback, getCallbackAddresses, getCallbackType, getCallbackTypeAddresses };
|
|
1460
2535
|
}
|
|
1461
|
-
|
|
2536
|
+
type GateConfig = {
|
|
2537
|
+
callbacks?: CallbackConfig[];
|
|
2538
|
+
maturities?: MaturityType[];
|
|
2539
|
+
};
|
|
2540
|
+
type CallbackConfig = {
|
|
2541
|
+
type: CallbackType.BuyVaultV1Callback;
|
|
2542
|
+
addresses: Address[];
|
|
2543
|
+
vaultFactories: Address[];
|
|
2544
|
+
} | {
|
|
2545
|
+
type: CallbackType.SellERC20Callback;
|
|
2546
|
+
addresses: Address[];
|
|
2547
|
+
} | {
|
|
2548
|
+
type: CallbackType.BuyWithEmptyCallback;
|
|
2549
|
+
};
|
|
2550
|
+
declare function getCallback(chain: Name, type: CallbackType.BuyVaultV1Callback): Extract<CallbackConfig, {
|
|
2551
|
+
type: CallbackType.BuyVaultV1Callback;
|
|
2552
|
+
}> | undefined;
|
|
2553
|
+
declare function getCallback(chain: Name, type: CallbackType.SellERC20Callback): Extract<CallbackConfig, {
|
|
2554
|
+
type: CallbackType.SellERC20Callback;
|
|
2555
|
+
}> | undefined;
|
|
2556
|
+
declare function getCallback(chain: Name, type: CallbackType.BuyWithEmptyCallback): Extract<CallbackConfig, {
|
|
2557
|
+
type: CallbackType.BuyWithEmptyCallback;
|
|
2558
|
+
}> | undefined;
|
|
2559
|
+
declare function getCallback(chain: Name, type: CallbackType): CallbackConfig | undefined;
|
|
2560
|
+
/**
|
|
2561
|
+
* Attempts to infer the configured callback type from a callback address on a chain.
|
|
2562
|
+
* Skips the empty callback type as it does not carry addresses.
|
|
2563
|
+
*
|
|
2564
|
+
* @param chain - Chain name for which to infer the callback type
|
|
2565
|
+
* @param address - Callback contract address
|
|
2566
|
+
* @returns The callback type when found, otherwise undefined
|
|
2567
|
+
*/
|
|
2568
|
+
declare function getCallbackType(chain: Name, address: Address): CallbackType | undefined;
|
|
2569
|
+
/**
|
|
2570
|
+
* Returns the callback addresses for a given chain and callback type, if it exists.
|
|
2571
|
+
* @param chain - Chain name for which to read the validation configuration
|
|
2572
|
+
* @param type - Callback type to retrieve
|
|
2573
|
+
* @returns The matching callback addresses or an empty array if not configured
|
|
2574
|
+
*/
|
|
2575
|
+
declare function getCallbackTypeAddresses(chain: Name, type: CallbackType): Address[];
|
|
2576
|
+
/**
|
|
2577
|
+
* Returns the list of allowed non-empty callback addresses for a chain.
|
|
2578
|
+
*
|
|
2579
|
+
* @param chain - Chain name
|
|
2580
|
+
* @returns Array of allowed callback addresses (lowercased). Empty when none configured
|
|
2581
|
+
*/
|
|
2582
|
+
declare const getCallbackAddresses: (chain: Name) => Address[];
|
|
2583
|
+
declare const assets$1: Record<string, Address[]>;
|
|
2584
|
+
declare const configs: Record<Name, GateConfig>;
|
|
2585
|
+
declare namespace Gatekeeper_d_exports {
|
|
2586
|
+
export { Gatekeeper, Rules, create };
|
|
2587
|
+
}
|
|
2588
|
+
type Rules = readonly Rule<Offer, string>[];
|
|
2589
|
+
type Gatekeeper = {
|
|
2590
|
+
rules: Rules;
|
|
2591
|
+
isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
|
|
2592
|
+
};
|
|
2593
|
+
type GatekeeperParameters = {
|
|
2594
|
+
rules: Rules;
|
|
2595
|
+
};
|
|
2596
|
+
declare function create(parameters: GatekeeperParameters): Gatekeeper;
|
|
2597
|
+
//#endregion
|
|
2598
|
+
//#region src/gatekeeper/morphoRules.d.ts
|
|
2599
|
+
declare const morphoRules: (chains: Chain$1[]) => (Rule<Offer, "chain_ids"> | Rule<Offer, "maturity"> | Rule<Offer, "callback"> | Rule<Offer, "token">)[];
|
|
2600
|
+
declare namespace Rules_d_exports {
|
|
2601
|
+
export { ValidityParameters, callback, chains, maturity, token, validity };
|
|
2602
|
+
}
|
|
2603
|
+
type ValidityParameters = {
|
|
2604
|
+
client: PublicClient<Transport, Chain$1>;
|
|
2605
|
+
};
|
|
2606
|
+
/**
|
|
2607
|
+
* set of rules to validate offers.
|
|
2608
|
+
*
|
|
2609
|
+
* @param parameters - Validity parameters with chain and client
|
|
2610
|
+
* @returns Array of validation rules to evaluate against offers
|
|
2611
|
+
*/
|
|
2612
|
+
declare function validity(parameters: ValidityParameters): (Rule<Offer, "expiry"> | Rule<Offer, "sell_erc20_callback_invalid"> | Rule<Offer, "buy_offers_callback_vault_invalid">)[];
|
|
2613
|
+
declare const chains: ({
|
|
2614
|
+
chains
|
|
2615
|
+
}: {
|
|
2616
|
+
chains: Chain$1[];
|
|
2617
|
+
}) => Rule<Offer, "chain_ids">;
|
|
2618
|
+
declare const maturity: ({
|
|
2619
|
+
maturities
|
|
2620
|
+
}: {
|
|
2621
|
+
maturities: MaturityType[];
|
|
2622
|
+
}) => Rule<Offer, "maturity">;
|
|
2623
|
+
declare const callback: ({
|
|
2624
|
+
callbacks,
|
|
2625
|
+
allowedAddresses
|
|
2626
|
+
}: {
|
|
2627
|
+
callbacks: CallbackType[];
|
|
2628
|
+
allowedAddresses: Address[];
|
|
2629
|
+
}) => Rule<Offer, "callback">;
|
|
2630
|
+
/**
|
|
2631
|
+
* A validation rule that checks if the offer's token is allowed.
|
|
2632
|
+
* @param offer - The offer to validate.
|
|
2633
|
+
* @returns The issue that was found. If the offer is valid, this will be undefined.
|
|
2634
|
+
*/
|
|
2635
|
+
declare const token: ({
|
|
2636
|
+
assets
|
|
2637
|
+
}: {
|
|
2638
|
+
assets: Address[];
|
|
2639
|
+
}) => Rule<Offer, "token">;
|
|
2640
|
+
//#endregion
|
|
2641
|
+
//#region src/mempool/MempoolEVMClient.d.ts
|
|
1462
2642
|
declare function from(parameters: from.Parameters): from.ReturnType;
|
|
1463
2643
|
declare namespace from {
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
2644
|
+
type Parameters = {
|
|
2645
|
+
/** The viem client to use. */
|
|
2646
|
+
client: WalletClient;
|
|
2647
|
+
/** The mempool address. */
|
|
2648
|
+
mempoolAddress: Address;
|
|
2649
|
+
/** The block window to use for the mempool. Defaults to 100. */
|
|
2650
|
+
blockWindow?: number;
|
|
2651
|
+
};
|
|
2652
|
+
type ReturnType = Client$1;
|
|
2653
|
+
type ErrorType = null;
|
|
1474
2654
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
2655
|
+
declare namespace MempoolClient_d_exports {
|
|
2656
|
+
export { AddParameters, Client$1 as Client, GetParameters, connect };
|
|
2657
|
+
}
|
|
2658
|
+
type AddParameters = Compute<Omit<Offer, "hash" | "createdAt">[]>;
|
|
1479
2659
|
type GetParameters = {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
};
|
|
1494
|
-
type WatchParameters = {
|
|
1495
|
-
/** The async function to get the last synced block number from which to start watching.
|
|
1496
|
-
* 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.
|
|
1497
|
-
*/
|
|
1498
|
-
lastSyncedBlock: () => Promise<number>;
|
|
1499
|
-
/** The loan asset to watch. */
|
|
1500
|
-
loanToken?: string;
|
|
1501
|
-
/** The callback to call when a new batch of offers is found in the mempool.
|
|
1502
|
-
* @param offers The offers found in the mempool.
|
|
1503
|
-
* @param blockNumber The block number of the last processed offer. Block numbers will always ascend.
|
|
1504
|
-
*/
|
|
1505
|
-
onOffers: (offers: Offer[], blockNumber: number) => Promise<void>;
|
|
1506
|
-
/** The polling configuration. */
|
|
1507
|
-
polling?: {
|
|
1508
|
-
/** The interval in milliseconds to poll for new offers. Defaults to 30000. */
|
|
1509
|
-
interval?: number;
|
|
1510
|
-
/** The maximum number of offers that can be returned in a single batch.
|
|
1511
|
-
* Defaults to 100. Maximum is 1000. */
|
|
1512
|
-
maxBatchSize?: number;
|
|
1513
|
-
};
|
|
2660
|
+
/** The block number to get offers from. */
|
|
2661
|
+
blockNumberGte?: number;
|
|
2662
|
+
/** The block number to get offers to. */
|
|
2663
|
+
blockNumberLte?: number;
|
|
2664
|
+
/** The loan asset to get offers from. */
|
|
2665
|
+
loanToken?: string;
|
|
2666
|
+
/** The order to get offers. Defaults to "desc". */
|
|
2667
|
+
order?: "asc" | "desc";
|
|
2668
|
+
/** The options to get offers from. */
|
|
2669
|
+
options?: {
|
|
2670
|
+
/** The maximum number of offers to return. Defaults to 100. Maximum is 1000. */
|
|
2671
|
+
maxBatchSize?: number;
|
|
2672
|
+
};
|
|
1514
2673
|
};
|
|
1515
2674
|
/**
|
|
1516
2675
|
* Mempool client interface.
|
|
1517
2676
|
*/
|
|
1518
|
-
type Client = {
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
/**
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
stream: (parameters: Compute<Omit<GetParameters, "options"> & {
|
|
1543
|
-
options: GetParameters["options"] & {
|
|
1544
|
-
blockWindow?: number;
|
|
1545
|
-
};
|
|
1546
|
-
}>) => AsyncGenerator<{
|
|
1547
|
-
offers: Offer[];
|
|
1548
|
-
blockNumber: number;
|
|
1549
|
-
}>;
|
|
2677
|
+
type Client$1 = {
|
|
2678
|
+
/**
|
|
2679
|
+
* Add an offer to the mempool.
|
|
2680
|
+
* @returns The created offer with its hash.
|
|
2681
|
+
*/
|
|
2682
|
+
add: (parameters: AddParameters) => Promise<Hex>;
|
|
2683
|
+
/** Get offers from the mempool. */
|
|
2684
|
+
get: (parameters?: GetParameters) => AsyncGenerator<{
|
|
2685
|
+
offers: Offer[];
|
|
2686
|
+
/** The block number of the last processed offer. Depends on the `order` parameter, block numbers will ascend or descend. */
|
|
2687
|
+
blockNumber: number;
|
|
2688
|
+
}>;
|
|
2689
|
+
/**
|
|
2690
|
+
* Stream offers from the mempool.
|
|
2691
|
+
* @returns A generator of offers alongside the last block number processed.
|
|
2692
|
+
*/
|
|
2693
|
+
stream: (parameters: Compute<Omit<GetParameters, "options"> & {
|
|
2694
|
+
options: GetParameters["options"] & {
|
|
2695
|
+
blockWindow?: number;
|
|
2696
|
+
};
|
|
2697
|
+
}>) => AsyncGenerator<{
|
|
2698
|
+
offers: Offer[];
|
|
2699
|
+
blockNumber: number;
|
|
2700
|
+
}>;
|
|
1550
2701
|
};
|
|
1551
2702
|
/**
|
|
1552
2703
|
* Client to interact with the Mempool contract on a specific chain.
|
|
1553
2704
|
*/
|
|
1554
|
-
declare function connect(parameters: from.Parameters): Client;
|
|
2705
|
+
declare function connect(parameters: from.Parameters): Client$1;
|
|
1555
2706
|
declare namespace connect {
|
|
1556
|
-
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
type MempoolClient_AddParameters = AddParameters;
|
|
1560
|
-
type MempoolClient_Client = Client;
|
|
1561
|
-
type MempoolClient_GetParameters = GetParameters;
|
|
1562
|
-
type MempoolClient_WatchParameters = WatchParameters;
|
|
1563
|
-
declare const MempoolClient_connect: typeof connect;
|
|
1564
|
-
declare namespace MempoolClient {
|
|
1565
|
-
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 };
|
|
2707
|
+
type ErrorType = from.ErrorType;
|
|
1566
2708
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
1570
|
-
dir: "asc" | "desc";
|
|
1571
|
-
rate?: string;
|
|
1572
|
-
maturity?: number;
|
|
1573
|
-
expiry?: number;
|
|
1574
|
-
assets?: string;
|
|
1575
|
-
hash: string;
|
|
1576
|
-
page?: number;
|
|
1577
|
-
};
|
|
1578
|
-
declare function validate(cursor: unknown): cursor is Cursor;
|
|
1579
|
-
declare function encode(c: Cursor): string;
|
|
1580
|
-
declare function decode(token?: string): Cursor | null;
|
|
1581
|
-
|
|
1582
|
-
type Cursor$1_Cursor = Cursor;
|
|
1583
|
-
declare const Cursor$1_decode: typeof decode;
|
|
1584
|
-
declare const Cursor$1_encode: typeof encode;
|
|
1585
|
-
declare const Cursor$1_validate: typeof validate;
|
|
1586
|
-
declare namespace Cursor$1 {
|
|
1587
|
-
export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
|
|
1588
|
-
}
|
|
1589
|
-
|
|
2709
|
+
//#endregion
|
|
2710
|
+
//#region src/utils/BigMath.d.ts
|
|
1590
2711
|
declare function max$1(a: bigint, b: bigint): bigint;
|
|
1591
2712
|
declare function min(a: bigint, b: bigint): bigint;
|
|
1592
|
-
|
|
2713
|
+
//#endregion
|
|
2714
|
+
//#region src/utils/batch.d.ts
|
|
1593
2715
|
/**
|
|
1594
2716
|
* Splits an array into batches of a specified size.
|
|
1595
2717
|
* @param array The array to split.
|
|
@@ -1607,8 +2729,9 @@ declare function min(a: bigint, b: bigint): bigint;
|
|
|
1607
2729
|
* // [5]
|
|
1608
2730
|
* ```
|
|
1609
2731
|
*/
|
|
1610
|
-
declare function batch<T>(array:
|
|
1611
|
-
|
|
2732
|
+
declare function batch<T>(array: T[] | readonly T[], batchSize: number): Generator<T[], void, unknown>;
|
|
2733
|
+
//#endregion
|
|
2734
|
+
//#region src/utils/batchMulticall.d.ts
|
|
1612
2735
|
/**
|
|
1613
2736
|
* Helper function to execute multicall in batches with retry logic.
|
|
1614
2737
|
* Abstracts the common pattern of batching calls, retrying, and collecting results.
|
|
@@ -1617,59 +2740,54 @@ declare function batch<T>(array: Array<T>, batchSize: number): Generator<T[], vo
|
|
|
1617
2740
|
* @returns Promise resolving to flattened array of results
|
|
1618
2741
|
*/
|
|
1619
2742
|
declare function batchMulticall<TResult>(parameters: {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
2743
|
+
client: PublicClient<Transport, Chain$1>;
|
|
2744
|
+
calls: MulticallParameters["contracts"];
|
|
2745
|
+
batchSize: number;
|
|
2746
|
+
retryAttempts: number;
|
|
2747
|
+
retryDelayMs: number;
|
|
2748
|
+
blockNumber?: bigint;
|
|
1626
2749
|
}): Promise<TResult[]>;
|
|
1627
|
-
|
|
2750
|
+
//#endregion
|
|
2751
|
+
//#region src/utils/lazy.d.ts
|
|
1628
2752
|
/**
|
|
1629
2753
|
* Transform a polling function into an async generator.
|
|
1630
2754
|
* @param fn - The polling function to transform.
|
|
1631
2755
|
* @returns An async generator.
|
|
1632
2756
|
*/
|
|
1633
|
-
declare function lazy<T>(pollFn: (emit: (value: T) => void, {
|
|
1634
|
-
|
|
2757
|
+
declare function lazy<T>(pollFn: (emit: (value: T) => void, {
|
|
2758
|
+
stop
|
|
2759
|
+
}: {
|
|
2760
|
+
stop: () => void;
|
|
1635
2761
|
}) => () => boolean): () => AsyncGenerator<Awaited<NonNullable<T>>, void, unknown>;
|
|
1636
|
-
|
|
2762
|
+
//#endregion
|
|
2763
|
+
//#region src/utils/poll.d.ts
|
|
1637
2764
|
/**
|
|
1638
2765
|
* Polls a function at a specified interval.
|
|
1639
2766
|
* Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
|
|
1640
2767
|
*/
|
|
1641
|
-
declare function poll<data>(fn: ({
|
|
1642
|
-
|
|
1643
|
-
}
|
|
1644
|
-
|
|
2768
|
+
declare function poll<data>(fn: ({
|
|
2769
|
+
unpoll
|
|
2770
|
+
}: {
|
|
2771
|
+
unpoll: () => void;
|
|
2772
|
+
}) => Promise<data | undefined>, {
|
|
2773
|
+
interval
|
|
2774
|
+
}: {
|
|
2775
|
+
interval: () => Promise<number>;
|
|
1645
2776
|
}): () => boolean;
|
|
1646
|
-
|
|
2777
|
+
//#endregion
|
|
2778
|
+
//#region src/utils/retry.d.ts
|
|
1647
2779
|
declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
|
|
1648
|
-
|
|
2780
|
+
declare namespace time_d_exports {
|
|
2781
|
+
export { max, now };
|
|
2782
|
+
}
|
|
1649
2783
|
declare function now(): number;
|
|
1650
2784
|
declare function max(): number;
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
declare const time_now: typeof now;
|
|
1654
|
-
declare namespace time {
|
|
1655
|
-
export { time_max as max, time_now as now };
|
|
1656
|
-
}
|
|
1657
|
-
|
|
2785
|
+
//#endregion
|
|
2786
|
+
//#region src/utils/wait.d.ts
|
|
1658
2787
|
declare function wait(time: number): Promise<unknown>;
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
declare const index_BaseError: typeof BaseError;
|
|
1662
|
-
type index_GlobalErrorType<name extends string = "Error"> = GlobalErrorType<name>;
|
|
1663
|
-
type index_Snake<T> = Snake<T>;
|
|
1664
|
-
declare const index_batch: typeof batch;
|
|
1665
|
-
declare const index_batchMulticall: typeof batchMulticall;
|
|
1666
|
-
declare const index_lazy: typeof lazy;
|
|
1667
|
-
declare const index_min: typeof min;
|
|
1668
|
-
declare const index_poll: typeof poll;
|
|
1669
|
-
declare const index_retry: typeof retry;
|
|
1670
|
-
declare const index_wait: typeof wait;
|
|
1671
|
-
declare namespace index {
|
|
1672
|
-
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$3 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 };
|
|
2788
|
+
declare namespace index_d_exports$2 {
|
|
2789
|
+
export { BaseError, GlobalErrorType, ReorgError, Snake, time_d_exports as Time, batch, batchMulticall, fromSnakeCase$3 as fromSnakeCase, lazy, max$1 as max, min, poll, retry, stringifyBigint, toSnakeCase$1 as toSnakeCase, wait };
|
|
1673
2790
|
}
|
|
1674
|
-
|
|
1675
|
-
export { Abi,
|
|
2791
|
+
//#endregion
|
|
2792
|
+
export { index_d_exports as Abi, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, Collateral_d_exports as Collateral, Compute, Cursor_d_exports as Cursor, ERC4626_d_exports as ERC4626, Errors_d_exports as Errors, Format_d_exports as Format, GateConfig_d_exports as GateConfig, Gatekeeper_d_exports as Gatekeeper, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Maturity_d_exports as Maturity, MempoolClient_d_exports as Mempool, Obligation_d_exports as Obligation, Offer_d_exports as Offer, Oracle_d_exports as Oracle, Position_d_exports as Position, Quote_d_exports as Quote, index_d_exports$1 as RouterApi, Client_d_exports as RouterClient, Rules_d_exports as Rules, time_d_exports as Time, Transfer_d_exports as Transfer, Tree_d_exports as Tree, index_d_exports$2 as Utils, Gate_d_exports as Validation, morphoRules };
|
|
2793
|
+
//# sourceMappingURL=index.browser.d.ts.map
|