@morpho-org/midnight-sdk 0.1.0 → 1.0.0
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/LICENSE +21 -0
- package/README.md +56 -46
- package/lib/cjs/abis.d.ts +1185 -996
- package/lib/cjs/abis.js +1445 -1211
- package/lib/cjs/api/MidnightApi.d.ts +22 -16
- package/lib/cjs/api/MidnightApi.js +22 -16
- package/lib/cjs/api/helpers.js +6 -3
- package/lib/cjs/api/types.d.ts +35 -9
- package/lib/cjs/constants.d.ts +12 -11
- package/lib/cjs/constants.js +14 -12
- package/lib/cjs/errors.d.ts +74 -1
- package/lib/cjs/errors.js +94 -3
- package/lib/cjs/fetch/Market.js +0 -1
- package/lib/cjs/fetch/index.d.ts +0 -1
- package/lib/cjs/fetch/index.js +0 -1
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +2 -23
- package/lib/cjs/market/Market.d.ts +99 -33
- package/lib/cjs/market/Market.js +137 -28
- package/lib/cjs/market/MarketUtils.d.ts +61 -41
- package/lib/cjs/market/MarketUtils.js +108 -48
- package/lib/cjs/market/Position.d.ts +16 -11
- package/lib/cjs/market/Position.js +18 -12
- package/lib/cjs/market/PositionUtils.d.ts +6 -4
- package/lib/cjs/market/PositionUtils.js +9 -6
- package/lib/cjs/math/TickLib.d.ts +22 -0
- package/lib/cjs/math/TickLib.js +30 -0
- package/lib/cjs/math/index.d.ts +0 -1
- package/lib/cjs/math/index.js +0 -1
- package/lib/cjs/offers/Offer.d.ts +217 -11
- package/lib/cjs/offers/Offer.js +215 -7
- package/lib/cjs/offers/OfferUtils.d.ts +245 -139
- package/lib/cjs/offers/OfferUtils.js +304 -36
- package/lib/cjs/queries/GetPosition.d.ts +1 -1
- package/lib/cjs/queries/GetPosition.js +1 -1
- package/lib/cjs/signatures/EcrecoverRatifierUtils.d.ts +66 -38
- package/lib/cjs/signatures/EcrecoverRatifierUtils.js +147 -79
- package/lib/cjs/signatures/Group.d.ts +12 -4
- package/lib/cjs/signatures/Group.js +12 -4
- package/lib/cjs/signatures/GroupUtils.d.ts +12 -4
- package/lib/cjs/signatures/GroupUtils.js +6 -2
- package/lib/cjs/signatures/Payload.d.ts +277 -277
- package/lib/cjs/signatures/Payload.js +517 -534
- package/lib/cjs/signatures/RatifierUtils.d.ts +57 -0
- package/lib/cjs/signatures/RatifierUtils.js +94 -0
- package/lib/cjs/signatures/SetterRatifierUtils.d.ts +21 -13
- package/lib/cjs/signatures/SetterRatifierUtils.js +25 -20
- package/lib/cjs/signatures/Tree.d.ts +28 -16
- package/lib/cjs/signatures/Tree.js +25 -13
- package/lib/cjs/signatures/TreeUtils.d.ts +181 -62
- package/lib/cjs/signatures/TreeUtils.js +73 -76
- package/lib/cjs/signatures/index.d.ts +1 -0
- package/lib/cjs/signatures/index.js +3 -0
- package/lib/cjs/signatures/offerStructInternal.d.ts +14 -0
- package/lib/cjs/signatures/offerStructInternal.js +72 -0
- package/lib/esm/abis.d.ts +1185 -996
- package/lib/esm/abis.js +1445 -1211
- package/lib/esm/api/MidnightApi.d.ts +22 -16
- package/lib/esm/api/MidnightApi.js +23 -17
- package/lib/esm/api/helpers.js +6 -3
- package/lib/esm/api/types.d.ts +35 -9
- package/lib/esm/constants.d.ts +12 -11
- package/lib/esm/constants.js +13 -11
- package/lib/esm/errors.d.ts +74 -1
- package/lib/esm/errors.js +89 -2
- package/lib/esm/fetch/Market.js +0 -1
- package/lib/esm/fetch/index.d.ts +0 -1
- package/lib/esm/fetch/index.js +0 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/market/Market.d.ts +99 -33
- package/lib/esm/market/Market.js +137 -28
- package/lib/esm/market/MarketUtils.d.ts +61 -41
- package/lib/esm/market/MarketUtils.js +109 -49
- package/lib/esm/market/Position.d.ts +16 -11
- package/lib/esm/market/Position.js +19 -13
- package/lib/esm/market/PositionUtils.d.ts +6 -4
- package/lib/esm/market/PositionUtils.js +9 -6
- package/lib/esm/math/TickLib.d.ts +22 -0
- package/lib/esm/math/TickLib.js +31 -1
- package/lib/esm/math/index.d.ts +0 -1
- package/lib/esm/math/index.js +0 -1
- package/lib/esm/offers/Offer.d.ts +217 -11
- package/lib/esm/offers/Offer.js +216 -8
- package/lib/esm/offers/OfferUtils.d.ts +245 -139
- package/lib/esm/offers/OfferUtils.js +306 -38
- package/lib/esm/queries/GetPosition.d.ts +1 -1
- package/lib/esm/queries/GetPosition.js +1 -1
- package/lib/esm/signatures/EcrecoverRatifierUtils.d.ts +66 -38
- package/lib/esm/signatures/EcrecoverRatifierUtils.js +149 -81
- package/lib/esm/signatures/Group.d.ts +12 -4
- package/lib/esm/signatures/Group.js +12 -4
- package/lib/esm/signatures/GroupUtils.d.ts +12 -4
- package/lib/esm/signatures/GroupUtils.js +6 -2
- package/lib/esm/signatures/Payload.d.ts +277 -277
- package/lib/esm/signatures/Payload.js +517 -531
- package/lib/esm/signatures/RatifierUtils.d.ts +57 -0
- package/lib/esm/signatures/RatifierUtils.js +94 -0
- package/lib/esm/signatures/SetterRatifierUtils.d.ts +21 -13
- package/lib/esm/signatures/SetterRatifierUtils.js +25 -20
- package/lib/esm/signatures/Tree.d.ts +28 -16
- package/lib/esm/signatures/Tree.js +25 -13
- package/lib/esm/signatures/TreeUtils.d.ts +181 -62
- package/lib/esm/signatures/TreeUtils.js +75 -78
- package/lib/esm/signatures/index.d.ts +1 -0
- package/lib/esm/signatures/index.js +1 -0
- package/lib/esm/signatures/offerStructInternal.d.ts +14 -0
- package/lib/esm/signatures/offerStructInternal.js +67 -0
- package/package.json +28 -32
- package/src/index.ts +1 -1
- package/lib/cjs/fetch/Offer.d.ts +0 -74
- package/lib/cjs/fetch/Offer.js +0 -119
- package/lib/cjs/math/ConsumableUnitsLib.d.ts +0 -57
- package/lib/cjs/math/ConsumableUnitsLib.js +0 -77
- package/lib/esm/fetch/Offer.d.ts +0 -74
- package/lib/esm/fetch/Offer.js +0 -116
- package/lib/esm/math/ConsumableUnitsLib.d.ts +0 -57
- package/lib/esm/math/ConsumableUnitsLib.js +0 -74
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { FetchBookParams, FetchBookPriceLevelsParams, FetchBookQuoteParams, FetchBooksParams, FetchBookTakeableOffersParams, FetchTakeableOffersParams, MempoolPayloadValidationResult, MidnightApiBookPriceLevelsResult, MidnightApiBookResult, MidnightApiBooksResult, MidnightApiBookTakeableOffersResult, MidnightApiClientParams, MidnightApiConstructorConfig, MidnightApiQuoteResult, MidnightApiTakeableOffersResult, ValidateMempoolItemsParams, ValidateMempoolPayloadParams } from "./types.js";
|
|
2
|
-
export type { FetchBookParams, FetchBookPriceLevelsParams, FetchBookQuoteParams, FetchBooksParams, FetchBookTakeableOffersParams, FetchTakeableOffersParams, MempoolPayloadValidationIssue, MempoolPayloadValidationResult, MidnightApiBookMarket, MidnightApiBookPriceLevelsResult, MidnightApiBookResult, MidnightApiBookSide, MidnightApiBookSort, MidnightApiBookSortField, MidnightApiBookSortTerm, MidnightApiBooksResult, MidnightApiBookTakeableOffersResult, MidnightApiClientParams, MidnightApiCollateral, MidnightApiConfig, MidnightApiConstructorConfig, MidnightApiFetch, MidnightApiPriceLevel, MidnightApiQuote, MidnightApiQuoteAssetsTarget, MidnightApiQuoteAverageWorstPriceGuard, MidnightApiQuoteResult, MidnightApiQuoteSlippageGuard, MidnightApiQuoteUnitsTarget, MidnightApiQuoteWithoutGuard, MidnightApiRequestOptions, MidnightApiSlippage, MidnightApiTake, MidnightApiTakeableOffersResult, ValidateMempoolItemsParams, ValidateMempoolPayloadParams, } from "./types.js";
|
|
2
|
+
export type { FetchBookParams, FetchBookPriceLevelsParams, FetchBookQuoteParams, FetchBooksParams, FetchBookTakeableOffersParams, FetchTakeableOffersParams, MempoolPayloadValidationIssue, MempoolPayloadValidationResult, MempoolPayloadValidationSuccess, MidnightApiBookMarket, MidnightApiBookPriceLevelsResult, MidnightApiBookResult, MidnightApiBookSide, MidnightApiBookSort, MidnightApiBookSortField, MidnightApiBookSortTerm, MidnightApiBooksResult, MidnightApiBookTakeableOffersResult, MidnightApiClientParams, MidnightApiCollateral, MidnightApiConfig, MidnightApiConstructorConfig, MidnightApiFetch, MidnightApiPriceLevel, MidnightApiQuote, MidnightApiQuoteAssetsTarget, MidnightApiQuoteAverageWorstPriceGuard, MidnightApiQuoteResult, MidnightApiQuoteSlippageGuard, MidnightApiQuoteUnitsTarget, MidnightApiQuoteWithoutGuard, MidnightApiRequestOptions, MidnightApiSlippage, MidnightApiTake, MidnightApiTakeableOffersResult, ValidateMempoolItemsParams, ValidateMempoolPayloadParams, } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Midnight API client and stateless helper surface for books and mempool data.
|
|
5
5
|
*
|
|
6
|
-
* Static methods use `https://api.morpho.org/
|
|
6
|
+
* Static methods use `https://api.morpho.org/v0/midnight` by default and accept
|
|
7
7
|
* per-call configuration. Instances keep shared `baseUrl`, `fetch`, and request
|
|
8
8
|
* options for integrations that make repeated calls.
|
|
9
9
|
* Caller input and successful JSON output shapes are trusted at runtime;
|
|
@@ -18,7 +18,7 @@ export type { FetchBookParams, FetchBookPriceLevelsParams, FetchBookQuoteParams,
|
|
|
18
18
|
* payload: "0x0100000000",
|
|
19
19
|
* });
|
|
20
20
|
*
|
|
21
|
-
* const api = new MidnightApi("https://api.morpho.org/
|
|
21
|
+
* const api = new MidnightApi("https://api.morpho.org/v0/midnight");
|
|
22
22
|
* const configured = await api.validateMempoolPayload({
|
|
23
23
|
* chainId: 8453,
|
|
24
24
|
* payload: "0x0100000000",
|
|
@@ -42,7 +42,7 @@ export declare class MidnightApi {
|
|
|
42
42
|
* import { MidnightApi } from "@morpho-org/midnight-sdk/api";
|
|
43
43
|
*
|
|
44
44
|
* const api = new MidnightApi({
|
|
45
|
-
* baseUrl: "https://api.morpho.org/
|
|
45
|
+
* baseUrl: "https://api.morpho.org/v0/midnight",
|
|
46
46
|
* });
|
|
47
47
|
* console.log(api);
|
|
48
48
|
* ```
|
|
@@ -216,9 +216,9 @@ export declare class MidnightApi {
|
|
|
216
216
|
* Validates an encoded Midnight mempool payload against API policy.
|
|
217
217
|
*
|
|
218
218
|
* Use when an integration already has encoded payload bytes and wants API
|
|
219
|
-
* feedback before publishing those bytes onchain. Normal SDK maker flows
|
|
220
|
-
*
|
|
221
|
-
* validating
|
|
219
|
+
* feedback before publishing those bytes onchain. Normal SDK maker flows can
|
|
220
|
+
* call `Tree.mempoolValidate` before ratification, or pass ratification
|
|
221
|
+
* inputs to that helper when validating final payload bytes.
|
|
222
222
|
*
|
|
223
223
|
* Sends `POST /mempool/validate` to the Midnight API. Does not read onchain RPC state.
|
|
224
224
|
*
|
|
@@ -247,9 +247,10 @@ export declare class MidnightApi {
|
|
|
247
247
|
* Encodes SDK-native payload items and validates them against API policy.
|
|
248
248
|
*
|
|
249
249
|
* Use when an integration already has payload-ready items but not encoded
|
|
250
|
-
* payload bytes. Normal SDK maker flows
|
|
251
|
-
* before ratification
|
|
252
|
-
*
|
|
250
|
+
* payload bytes. Normal SDK maker flows can call `Tree.mempoolValidate`
|
|
251
|
+
* before ratification, or pass ratification inputs to that helper when
|
|
252
|
+
* validating final payload bytes. This helper owns the temporary payload
|
|
253
|
+
* encoding for validation only.
|
|
253
254
|
*
|
|
254
255
|
* Encodes `params.items`, then sends `POST /mempool/validate` to the Midnight API. Does not read onchain RPC state.
|
|
255
256
|
*
|
|
@@ -260,7 +261,7 @@ export declare class MidnightApi {
|
|
|
260
261
|
* @param params.fetch - Optional fetch implementation override.
|
|
261
262
|
* @param params.request - Optional fetch options forwarded to this request.
|
|
262
263
|
* @returns API issues and `valid` summary.
|
|
263
|
-
* @throws {
|
|
264
|
+
* @throws {PayloadDecodeError} when item encoding fails.
|
|
264
265
|
* @throws {MidnightApiError} when the API returns a non-2xx response.
|
|
265
266
|
* @throws {InvalidMidnightApiResponseError} when the API returns malformed success JSON.
|
|
266
267
|
* @example
|
|
@@ -271,12 +272,14 @@ export declare class MidnightApi {
|
|
|
271
272
|
*
|
|
272
273
|
* const offer = Offer.create({
|
|
273
274
|
* market: {
|
|
275
|
+
* chainId: 8453,
|
|
276
|
+
* midnight: "0x0000000000000000000000000000000000001000",
|
|
274
277
|
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
275
278
|
* collateralParams: [
|
|
276
279
|
* {
|
|
277
280
|
* token: "0x0000000000000000000000000000000000007000",
|
|
278
281
|
* lltv: 770000000000000000n,
|
|
279
|
-
*
|
|
282
|
+
* liquidationCursor: 250000000000000000n,
|
|
280
283
|
* oracle: "0x0000000000000000000000000000000000008000",
|
|
281
284
|
* },
|
|
282
285
|
* ],
|
|
@@ -479,8 +482,9 @@ export declare class MidnightApi {
|
|
|
479
482
|
* Validates payload-ready items with this client's configuration.
|
|
480
483
|
*
|
|
481
484
|
* Use when an integration already has payload-ready items but not encoded
|
|
482
|
-
* payload bytes. Normal SDK maker flows
|
|
483
|
-
* before ratification
|
|
485
|
+
* payload bytes. Normal SDK maker flows can call `Tree.mempoolValidate`
|
|
486
|
+
* before ratification, or pass ratification inputs to that helper when
|
|
487
|
+
* validating final payload bytes.
|
|
484
488
|
*
|
|
485
489
|
* Encodes `params.items`, then sends `POST /mempool/validate` to the Midnight API using this client's configuration. Does not read onchain RPC state.
|
|
486
490
|
*
|
|
@@ -488,7 +492,7 @@ export declare class MidnightApi {
|
|
|
488
492
|
* @param params.items - SDK-native payload items to encode before API validation.
|
|
489
493
|
* @param params.timestamp - Optional ISO-8601 timestamp or `Date` selecting the API policy snapshot.
|
|
490
494
|
* @returns API validation result.
|
|
491
|
-
* @throws {
|
|
495
|
+
* @throws {PayloadDecodeError} when item encoding fails.
|
|
492
496
|
* @throws {MidnightApiError} when the API returns a non-2xx response.
|
|
493
497
|
* @throws {InvalidMidnightApiResponseError} when the API returns malformed success JSON.
|
|
494
498
|
* @example
|
|
@@ -500,12 +504,14 @@ export declare class MidnightApi {
|
|
|
500
504
|
* const api = new MidnightApi();
|
|
501
505
|
* const offer = Offer.create({
|
|
502
506
|
* market: {
|
|
507
|
+
* chainId: 8453,
|
|
508
|
+
* midnight: "0x0000000000000000000000000000000000001000",
|
|
503
509
|
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
504
510
|
* collateralParams: [
|
|
505
511
|
* {
|
|
506
512
|
* token: "0x0000000000000000000000000000000000007000",
|
|
507
513
|
* lltv: 770000000000000000n,
|
|
508
|
-
*
|
|
514
|
+
* liquidationCursor: 250000000000000000n,
|
|
509
515
|
* oracle: "0x0000000000000000000000000000000000008000",
|
|
510
516
|
* },
|
|
511
517
|
* ],
|
|
@@ -6,7 +6,7 @@ const helpers_js_1 = require("./helpers.js");
|
|
|
6
6
|
/**
|
|
7
7
|
* Midnight API client and stateless helper surface for books and mempool data.
|
|
8
8
|
*
|
|
9
|
-
* Static methods use `https://api.morpho.org/
|
|
9
|
+
* Static methods use `https://api.morpho.org/v0/midnight` by default and accept
|
|
10
10
|
* per-call configuration. Instances keep shared `baseUrl`, `fetch`, and request
|
|
11
11
|
* options for integrations that make repeated calls.
|
|
12
12
|
* Caller input and successful JSON output shapes are trusted at runtime;
|
|
@@ -21,7 +21,7 @@ const helpers_js_1 = require("./helpers.js");
|
|
|
21
21
|
* payload: "0x0100000000",
|
|
22
22
|
* });
|
|
23
23
|
*
|
|
24
|
-
* const api = new MidnightApi("https://api.morpho.org/
|
|
24
|
+
* const api = new MidnightApi("https://api.morpho.org/v0/midnight");
|
|
25
25
|
* const configured = await api.validateMempoolPayload({
|
|
26
26
|
* chainId: 8453,
|
|
27
27
|
* payload: "0x0100000000",
|
|
@@ -45,7 +45,7 @@ class MidnightApi {
|
|
|
45
45
|
* import { MidnightApi } from "@morpho-org/midnight-sdk/api";
|
|
46
46
|
*
|
|
47
47
|
* const api = new MidnightApi({
|
|
48
|
-
* baseUrl: "https://api.morpho.org/
|
|
48
|
+
* baseUrl: "https://api.morpho.org/v0/midnight",
|
|
49
49
|
* });
|
|
50
50
|
* console.log(api);
|
|
51
51
|
* ```
|
|
@@ -330,9 +330,9 @@ class MidnightApi {
|
|
|
330
330
|
* Validates an encoded Midnight mempool payload against API policy.
|
|
331
331
|
*
|
|
332
332
|
* Use when an integration already has encoded payload bytes and wants API
|
|
333
|
-
* feedback before publishing those bytes onchain. Normal SDK maker flows
|
|
334
|
-
*
|
|
335
|
-
* validating
|
|
333
|
+
* feedback before publishing those bytes onchain. Normal SDK maker flows can
|
|
334
|
+
* call `Tree.mempoolValidate` before ratification, or pass ratification
|
|
335
|
+
* inputs to that helper when validating final payload bytes.
|
|
336
336
|
*
|
|
337
337
|
* Sends `POST /mempool/validate` to the Midnight API. Does not read onchain RPC state.
|
|
338
338
|
*
|
|
@@ -376,9 +376,10 @@ class MidnightApi {
|
|
|
376
376
|
* Encodes SDK-native payload items and validates them against API policy.
|
|
377
377
|
*
|
|
378
378
|
* Use when an integration already has payload-ready items but not encoded
|
|
379
|
-
* payload bytes. Normal SDK maker flows
|
|
380
|
-
* before ratification
|
|
381
|
-
*
|
|
379
|
+
* payload bytes. Normal SDK maker flows can call `Tree.mempoolValidate`
|
|
380
|
+
* before ratification, or pass ratification inputs to that helper when
|
|
381
|
+
* validating final payload bytes. This helper owns the temporary payload
|
|
382
|
+
* encoding for validation only.
|
|
382
383
|
*
|
|
383
384
|
* Encodes `params.items`, then sends `POST /mempool/validate` to the Midnight API. Does not read onchain RPC state.
|
|
384
385
|
*
|
|
@@ -389,7 +390,7 @@ class MidnightApi {
|
|
|
389
390
|
* @param params.fetch - Optional fetch implementation override.
|
|
390
391
|
* @param params.request - Optional fetch options forwarded to this request.
|
|
391
392
|
* @returns API issues and `valid` summary.
|
|
392
|
-
* @throws {
|
|
393
|
+
* @throws {PayloadDecodeError} when item encoding fails.
|
|
393
394
|
* @throws {MidnightApiError} when the API returns a non-2xx response.
|
|
394
395
|
* @throws {InvalidMidnightApiResponseError} when the API returns malformed success JSON.
|
|
395
396
|
* @example
|
|
@@ -400,12 +401,14 @@ class MidnightApi {
|
|
|
400
401
|
*
|
|
401
402
|
* const offer = Offer.create({
|
|
402
403
|
* market: {
|
|
404
|
+
* chainId: 8453,
|
|
405
|
+
* midnight: "0x0000000000000000000000000000000000001000",
|
|
403
406
|
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
404
407
|
* collateralParams: [
|
|
405
408
|
* {
|
|
406
409
|
* token: "0x0000000000000000000000000000000000007000",
|
|
407
410
|
* lltv: 770000000000000000n,
|
|
408
|
-
*
|
|
411
|
+
* liquidationCursor: 250000000000000000n,
|
|
409
412
|
* oracle: "0x0000000000000000000000000000000000008000",
|
|
410
413
|
* },
|
|
411
414
|
* ],
|
|
@@ -431,7 +434,7 @@ class MidnightApi {
|
|
|
431
434
|
*/
|
|
432
435
|
static async validateMempoolItems(params) {
|
|
433
436
|
const input = params;
|
|
434
|
-
const payload = await
|
|
437
|
+
const payload = await Payload_js_1.Payload.encode(input.items);
|
|
435
438
|
return MidnightApi.validateMempoolPayload({
|
|
436
439
|
baseUrl: input.baseUrl,
|
|
437
440
|
fetch: input.fetch,
|
|
@@ -654,8 +657,9 @@ class MidnightApi {
|
|
|
654
657
|
* Validates payload-ready items with this client's configuration.
|
|
655
658
|
*
|
|
656
659
|
* Use when an integration already has payload-ready items but not encoded
|
|
657
|
-
* payload bytes. Normal SDK maker flows
|
|
658
|
-
* before ratification
|
|
660
|
+
* payload bytes. Normal SDK maker flows can call `Tree.mempoolValidate`
|
|
661
|
+
* before ratification, or pass ratification inputs to that helper when
|
|
662
|
+
* validating final payload bytes.
|
|
659
663
|
*
|
|
660
664
|
* Encodes `params.items`, then sends `POST /mempool/validate` to the Midnight API using this client's configuration. Does not read onchain RPC state.
|
|
661
665
|
*
|
|
@@ -663,7 +667,7 @@ class MidnightApi {
|
|
|
663
667
|
* @param params.items - SDK-native payload items to encode before API validation.
|
|
664
668
|
* @param params.timestamp - Optional ISO-8601 timestamp or `Date` selecting the API policy snapshot.
|
|
665
669
|
* @returns API validation result.
|
|
666
|
-
* @throws {
|
|
670
|
+
* @throws {PayloadDecodeError} when item encoding fails.
|
|
667
671
|
* @throws {MidnightApiError} when the API returns a non-2xx response.
|
|
668
672
|
* @throws {InvalidMidnightApiResponseError} when the API returns malformed success JSON.
|
|
669
673
|
* @example
|
|
@@ -675,12 +679,14 @@ class MidnightApi {
|
|
|
675
679
|
* const api = new MidnightApi();
|
|
676
680
|
* const offer = Offer.create({
|
|
677
681
|
* market: {
|
|
682
|
+
* chainId: 8453,
|
|
683
|
+
* midnight: "0x0000000000000000000000000000000000001000",
|
|
678
684
|
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
679
685
|
* collateralParams: [
|
|
680
686
|
* {
|
|
681
687
|
* token: "0x0000000000000000000000000000000000007000",
|
|
682
688
|
* lltv: 770000000000000000n,
|
|
683
|
-
*
|
|
689
|
+
* liquidationCursor: 250000000000000000n,
|
|
684
690
|
* oracle: "0x0000000000000000000000000000000000008000",
|
|
685
691
|
* },
|
|
686
692
|
* ],
|
package/lib/cjs/api/helpers.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.mapTakeableOffer = mapTakeableOffer;
|
|
|
9
9
|
exports.parseValidationResponse = parseValidationResponse;
|
|
10
10
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
11
11
|
const errors_js_1 = require("../errors.js");
|
|
12
|
-
const DEFAULT_MIDNIGHT_API_URL = new URL("/
|
|
12
|
+
const DEFAULT_MIDNIGHT_API_URL = new URL("/v0/midnight", morpho_ts_1.BLUE_API_BASE_URL);
|
|
13
13
|
// Keep this literal in source so the browser ESM build does not import package.json
|
|
14
14
|
// through Node-only createRequire/module shims.
|
|
15
15
|
const MIDNIGHT_SDK_VERSION = "0.1.0";
|
|
@@ -92,6 +92,7 @@ function mapBookMarket(book) {
|
|
|
92
92
|
return {
|
|
93
93
|
marketId: book.market_id,
|
|
94
94
|
chainId: book.chain_id,
|
|
95
|
+
midnight: book.midnight,
|
|
95
96
|
loanToken: book.loan_token,
|
|
96
97
|
collaterals: book.collaterals.map(mapCollateral),
|
|
97
98
|
maturity: book.maturity,
|
|
@@ -107,7 +108,7 @@ function mapCollateral(collateral) {
|
|
|
107
108
|
return {
|
|
108
109
|
token: collateral.token,
|
|
109
110
|
lltv: collateral.lltv,
|
|
110
|
-
|
|
111
|
+
liquidationCursor: collateral.liquidation_cursor,
|
|
111
112
|
oracle: collateral.oracle,
|
|
112
113
|
};
|
|
113
114
|
}
|
|
@@ -129,11 +130,13 @@ function mapTakeableOffer(takeableOffer) {
|
|
|
129
130
|
units: BigInt(takeableOffer.units),
|
|
130
131
|
offer: {
|
|
131
132
|
market: {
|
|
133
|
+
chainId: BigInt(offer.market.chain_id),
|
|
134
|
+
midnight: offer.market.midnight,
|
|
132
135
|
loanToken: offer.market.loan_token,
|
|
133
136
|
collateralParams: offer.market.collaterals.map((collateral) => ({
|
|
134
137
|
token: collateral.token,
|
|
135
138
|
lltv: BigInt(collateral.lltv),
|
|
136
|
-
|
|
139
|
+
liquidationCursor: BigInt(collateral.liquidation_cursor),
|
|
137
140
|
oracle: collateral.oracle,
|
|
138
141
|
})),
|
|
139
142
|
maturity: BigInt(offer.market.maturity),
|
package/lib/cjs/api/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BigIntish } from "@morpho-org/morpho-ts";
|
|
2
2
|
import type { Address, Hash, Hex } from "viem";
|
|
3
3
|
import type { OfferStruct } from "../offers/Offer.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { Payload } from "../signatures/Payload.js";
|
|
5
5
|
/**
|
|
6
6
|
* Fetch implementation used by Midnight API helpers.
|
|
7
7
|
*/
|
|
@@ -17,7 +17,7 @@ export type MidnightApiRequestOptions = Omit<RequestInit, "method" | "body">;
|
|
|
17
17
|
* Shared configuration for Midnight API calls.
|
|
18
18
|
*/
|
|
19
19
|
export interface MidnightApiConfig {
|
|
20
|
-
/** Midnight API base URL. Defaults to `https://api.morpho.org/
|
|
20
|
+
/** Midnight API base URL. Defaults to `https://api.morpho.org/v0/midnight`. */
|
|
21
21
|
readonly baseUrl?: string | URL;
|
|
22
22
|
/** Fetch implementation. Defaults to the global `fetch`. */
|
|
23
23
|
readonly fetch?: MidnightApiFetch;
|
|
@@ -70,7 +70,7 @@ export interface ValidateMempoolItemsParams extends MidnightApiConfig {
|
|
|
70
70
|
/** Chain id whose API policy should validate the payload. */
|
|
71
71
|
readonly chainId: number;
|
|
72
72
|
/** SDK-native payload items to encode before API validation. */
|
|
73
|
-
readonly items: readonly
|
|
73
|
+
readonly items: readonly Payload.Item[];
|
|
74
74
|
/** Optional ISO-8601 timestamp or `Date` selecting the API policy snapshot. */
|
|
75
75
|
readonly timestamp?: string | Date;
|
|
76
76
|
}
|
|
@@ -209,6 +209,28 @@ export interface MempoolPayloadValidationResult {
|
|
|
209
209
|
/** Payload-level API issues. */
|
|
210
210
|
readonly issues: readonly MempoolPayloadValidationIssue[];
|
|
211
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Successful Midnight mempool validation result.
|
|
214
|
+
*
|
|
215
|
+
* Returned by `Tree.mempoolValidate` and `TreeUtils.mempoolValidate`, which
|
|
216
|
+
* throw `MidnightMempoolValidationError` instead of returning unsuccessful API
|
|
217
|
+
* validation results.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* import type { MempoolPayloadValidationSuccess } from "@morpho-org/midnight-sdk/api";
|
|
222
|
+
*
|
|
223
|
+
* const result: MempoolPayloadValidationSuccess = {
|
|
224
|
+
* valid: true,
|
|
225
|
+
* issues: [],
|
|
226
|
+
* };
|
|
227
|
+
* console.log(result.valid);
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
export type MempoolPayloadValidationSuccess = MempoolPayloadValidationResult & {
|
|
231
|
+
/** Successful tree validation always has `valid: true`. */
|
|
232
|
+
readonly valid: true;
|
|
233
|
+
};
|
|
212
234
|
/**
|
|
213
235
|
* Collateral metadata returned by Midnight API book routes.
|
|
214
236
|
*/
|
|
@@ -217,8 +239,8 @@ export interface MidnightApiCollateral {
|
|
|
217
239
|
readonly token: Address;
|
|
218
240
|
/** WAD-scaled liquidation loan-to-value. */
|
|
219
241
|
readonly lltv: string;
|
|
220
|
-
/** WAD-scaled maximum liquidation incentive factor. */
|
|
221
|
-
readonly
|
|
242
|
+
/** WAD-scaled liquidation cursor used to compute the maximum liquidation incentive factor. */
|
|
243
|
+
readonly liquidationCursor: string;
|
|
222
244
|
/** Oracle address used to price this collateral. */
|
|
223
245
|
readonly oracle: Address;
|
|
224
246
|
}
|
|
@@ -245,6 +267,8 @@ export interface MidnightApiBookMarket {
|
|
|
245
267
|
readonly marketId: Hash;
|
|
246
268
|
/** Chain id the market lives on. */
|
|
247
269
|
readonly chainId: number;
|
|
270
|
+
/** Core Midnight contract address for the market chain. */
|
|
271
|
+
readonly midnight: Address;
|
|
248
272
|
/** Loan token address. */
|
|
249
273
|
readonly loanToken: Address;
|
|
250
274
|
/** Collateral definitions for the market. */
|
|
@@ -282,9 +306,8 @@ export interface MidnightApiBookResult {
|
|
|
282
306
|
* ABI-ready take returned by Midnight API book and quote routes.
|
|
283
307
|
*
|
|
284
308
|
* This shape matches the Midnight periphery `Take` tuple. Pass `offer`,
|
|
285
|
-
* `ratifierData`, and `units` directly to `IMidnight.take
|
|
286
|
-
*
|
|
287
|
-
* API metadata and is ignored by ABI encoders.
|
|
309
|
+
* `ratifierData`, and `units` directly to `IMidnight.take`. `marketId` is API
|
|
310
|
+
* metadata and is ignored by ABI encoders.
|
|
288
311
|
*/
|
|
289
312
|
export interface MidnightApiTake {
|
|
290
313
|
/** Market id the offer belongs to. */
|
|
@@ -361,7 +384,7 @@ export type ApiRequestParams = MidnightApiConfig & {
|
|
|
361
384
|
export type ApiCollateralResponse = {
|
|
362
385
|
readonly token: Address;
|
|
363
386
|
readonly lltv: string;
|
|
364
|
-
readonly
|
|
387
|
+
readonly liquidation_cursor: string;
|
|
365
388
|
readonly oracle: Address;
|
|
366
389
|
};
|
|
367
390
|
/** @internal Price-level response shape returned by the API. */
|
|
@@ -376,6 +399,7 @@ export type ApiPriceLevelResponse = {
|
|
|
376
399
|
export type ApiBookMarketResponse = {
|
|
377
400
|
readonly market_id: Hash;
|
|
378
401
|
readonly chain_id: number;
|
|
402
|
+
readonly midnight: Address;
|
|
379
403
|
readonly loan_token: Address;
|
|
380
404
|
readonly collaterals: readonly ApiCollateralResponse[];
|
|
381
405
|
readonly maturity: number;
|
|
@@ -400,6 +424,8 @@ export type ApiPriceLevelsResponse = {
|
|
|
400
424
|
};
|
|
401
425
|
/** @internal Offer market response shape returned by the API. */
|
|
402
426
|
export type ApiOfferMarketResponse = {
|
|
427
|
+
readonly chain_id: number;
|
|
428
|
+
readonly midnight: Address;
|
|
403
429
|
readonly loan_token: Address;
|
|
404
430
|
readonly collaterals: readonly ApiCollateralResponse[];
|
|
405
431
|
readonly maturity: number;
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -101,27 +101,28 @@ export declare const MAX_SETTLEMENT_FEES: readonly [14000000000000n, 14000000000
|
|
|
101
101
|
*/
|
|
102
102
|
export declare const MAX_CONTINUOUS_FEE = 317097919n;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* Maximum value accepted by the uint128 offer cap fields.
|
|
105
105
|
*
|
|
106
106
|
* @example
|
|
107
107
|
* ```ts
|
|
108
|
-
* import {
|
|
108
|
+
* import { MAX_OFFER_CAP } from "@morpho-org/midnight-sdk";
|
|
109
109
|
*
|
|
110
|
-
* console.log(
|
|
110
|
+
* console.log(MAX_OFFER_CAP);
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
|
-
export declare const
|
|
113
|
+
export declare const MAX_OFFER_CAP: bigint;
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
115
|
+
* Seconds after maturity over which post-maturity LIF reaches the computed
|
|
116
|
+
* maximum liquidation incentive factor.
|
|
116
117
|
*
|
|
117
118
|
* @example
|
|
118
119
|
* ```ts
|
|
119
|
-
* import {
|
|
120
|
+
* import { TIME_TO_MAX_LIF } from "@morpho-org/midnight-sdk";
|
|
120
121
|
*
|
|
121
|
-
* console.log(
|
|
122
|
+
* console.log(TIME_TO_MAX_LIF);
|
|
122
123
|
* ```
|
|
123
124
|
*/
|
|
124
|
-
export declare const
|
|
125
|
+
export declare const TIME_TO_MAX_LIF: bigint;
|
|
125
126
|
/**
|
|
126
127
|
* HashLib collateral params typehash.
|
|
127
128
|
*
|
|
@@ -132,7 +133,7 @@ export declare const LIQUIDATION_CURSOR_HIGH = 500000000000000000n;
|
|
|
132
133
|
* console.log(COLLATERAL_PARAMS_TYPEHASH);
|
|
133
134
|
* ```
|
|
134
135
|
*/
|
|
135
|
-
export declare const COLLATERAL_PARAMS_TYPEHASH = "
|
|
136
|
+
export declare const COLLATERAL_PARAMS_TYPEHASH = "0x39ed3f928d24fd00574b1a02aba9c2483abcf5d9a3a366118c9a5aa29885b841";
|
|
136
137
|
/**
|
|
137
138
|
* HashLib market typehash.
|
|
138
139
|
*
|
|
@@ -143,7 +144,7 @@ export declare const COLLATERAL_PARAMS_TYPEHASH = "0xaf44a88eb50ebdbbebd980e5a23
|
|
|
143
144
|
* console.log(MARKET_TYPEHASH);
|
|
144
145
|
* ```
|
|
145
146
|
*/
|
|
146
|
-
export declare const MARKET_TYPEHASH = "
|
|
147
|
+
export declare const MARKET_TYPEHASH = "0x510b3862f3816a109c9340b76972e8a30984246be06e034ae12ed2934220391a";
|
|
147
148
|
/**
|
|
148
149
|
* HashLib offer typehash.
|
|
149
150
|
*
|
|
@@ -154,7 +155,7 @@ export declare const MARKET_TYPEHASH = "0x358117e98511cc3df97175dca58053b06675b4
|
|
|
154
155
|
* console.log(OFFER_TYPEHASH);
|
|
155
156
|
* ```
|
|
156
157
|
*/
|
|
157
|
-
export declare const OFFER_TYPEHASH = "
|
|
158
|
+
export declare const OFFER_TYPEHASH = "0x9905214264a9fb7b6cc1b0e33db7a04687c6e4185a84755d29914314aa9d8906";
|
|
158
159
|
/**
|
|
159
160
|
* EcrecoverRatifier EIP-712 domain typehash.
|
|
160
161
|
*
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EIP712_DOMAIN_TYPEHASH = exports.OFFER_TYPEHASH = exports.MARKET_TYPEHASH = exports.COLLATERAL_PARAMS_TYPEHASH = exports.
|
|
3
|
+
exports.EIP712_DOMAIN_TYPEHASH = exports.OFFER_TYPEHASH = exports.MARKET_TYPEHASH = exports.COLLATERAL_PARAMS_TYPEHASH = exports.TIME_TO_MAX_LIF = exports.MAX_OFFER_CAP = exports.MAX_CONTINUOUS_FEE = exports.MAX_SETTLEMENT_FEES = exports.MAX_COLLATERALS_PER_BORROWER = exports.MAX_COLLATERALS = exports.DEFAULT_TICK_SPACING = exports.PRICE_ROUNDING_STEP = exports.MAX_TICK = exports.SETTLEMENT_FEE_BREAKPOINTS = exports.CBP = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
4
5
|
/**
|
|
5
6
|
* Centibip scale used by settlement fees.
|
|
6
7
|
*
|
|
@@ -120,27 +121,28 @@ exports.MAX_SETTLEMENT_FEES = [
|
|
|
120
121
|
*/
|
|
121
122
|
exports.MAX_CONTINUOUS_FEE = 317097919n;
|
|
122
123
|
/**
|
|
123
|
-
*
|
|
124
|
+
* Maximum value accepted by the uint128 offer cap fields.
|
|
124
125
|
*
|
|
125
126
|
* @example
|
|
126
127
|
* ```ts
|
|
127
|
-
* import {
|
|
128
|
+
* import { MAX_OFFER_CAP } from "@morpho-org/midnight-sdk";
|
|
128
129
|
*
|
|
129
|
-
* console.log(
|
|
130
|
+
* console.log(MAX_OFFER_CAP);
|
|
130
131
|
* ```
|
|
131
132
|
*/
|
|
132
|
-
exports.
|
|
133
|
+
exports.MAX_OFFER_CAP = viem_1.maxUint128;
|
|
133
134
|
/**
|
|
134
|
-
*
|
|
135
|
+
* Seconds after maturity over which post-maturity LIF reaches the computed
|
|
136
|
+
* maximum liquidation incentive factor.
|
|
135
137
|
*
|
|
136
138
|
* @example
|
|
137
139
|
* ```ts
|
|
138
|
-
* import {
|
|
140
|
+
* import { TIME_TO_MAX_LIF } from "@morpho-org/midnight-sdk";
|
|
139
141
|
*
|
|
140
|
-
* console.log(
|
|
142
|
+
* console.log(TIME_TO_MAX_LIF);
|
|
141
143
|
* ```
|
|
142
144
|
*/
|
|
143
|
-
exports.
|
|
145
|
+
exports.TIME_TO_MAX_LIF = 60n * 60n;
|
|
144
146
|
/**
|
|
145
147
|
* HashLib collateral params typehash.
|
|
146
148
|
*
|
|
@@ -151,7 +153,7 @@ exports.LIQUIDATION_CURSOR_HIGH = 500000000000000000n;
|
|
|
151
153
|
* console.log(COLLATERAL_PARAMS_TYPEHASH);
|
|
152
154
|
* ```
|
|
153
155
|
*/
|
|
154
|
-
exports.COLLATERAL_PARAMS_TYPEHASH = "
|
|
156
|
+
exports.COLLATERAL_PARAMS_TYPEHASH = "0x39ed3f928d24fd00574b1a02aba9c2483abcf5d9a3a366118c9a5aa29885b841";
|
|
155
157
|
/**
|
|
156
158
|
* HashLib market typehash.
|
|
157
159
|
*
|
|
@@ -162,7 +164,7 @@ exports.COLLATERAL_PARAMS_TYPEHASH = "0xaf44a88eb50ebdbbebd980e5a23045c44f61ece5
|
|
|
162
164
|
* console.log(MARKET_TYPEHASH);
|
|
163
165
|
* ```
|
|
164
166
|
*/
|
|
165
|
-
exports.MARKET_TYPEHASH = "
|
|
167
|
+
exports.MARKET_TYPEHASH = "0x510b3862f3816a109c9340b76972e8a30984246be06e034ae12ed2934220391a";
|
|
166
168
|
/**
|
|
167
169
|
* HashLib offer typehash.
|
|
168
170
|
*
|
|
@@ -173,7 +175,7 @@ exports.MARKET_TYPEHASH = "0x358117e98511cc3df97175dca58053b06675b43ad090b0553f8
|
|
|
173
175
|
* console.log(OFFER_TYPEHASH);
|
|
174
176
|
* ```
|
|
175
177
|
*/
|
|
176
|
-
exports.OFFER_TYPEHASH = "
|
|
178
|
+
exports.OFFER_TYPEHASH = "0x9905214264a9fb7b6cc1b0e33db7a04687c6e4185a84755d29914314aa9d8906";
|
|
177
179
|
/**
|
|
178
180
|
* EcrecoverRatifier EIP-712 domain typehash.
|
|
179
181
|
*
|
package/lib/cjs/errors.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
+
import type { MempoolPayloadValidationIssue } from "./api/types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Thrown when a Midnight offer group violates protocol-level group mechanics.
|
|
4
5
|
*
|
|
@@ -135,6 +136,31 @@ export declare class InvalidMarketParameterError extends Error {
|
|
|
135
136
|
readonly cause?: unknown;
|
|
136
137
|
});
|
|
137
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Thrown when a Midnight market collateral index is not configured.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* import { UnknownCollateralIndexError } from "@morpho-org/midnight-sdk";
|
|
145
|
+
*
|
|
146
|
+
* throw new UnknownCollateralIndexError({
|
|
147
|
+
* market: "0x1111111111111111111111111111111111111111111111111111111111111111",
|
|
148
|
+
* collateralIndex: 2n,
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
* @param params.market - Market id whose collateral list was queried.
|
|
152
|
+
* @param params.collateralIndex - Missing collateral index.
|
|
153
|
+
*/
|
|
154
|
+
export declare class UnknownCollateralIndexError extends Error {
|
|
155
|
+
/** Market id whose collateral list was queried. */
|
|
156
|
+
readonly market: string;
|
|
157
|
+
/** Missing collateral index. */
|
|
158
|
+
readonly collateralIndex: bigint;
|
|
159
|
+
constructor(params: {
|
|
160
|
+
readonly market: string;
|
|
161
|
+
readonly collateralIndex: bigint;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
138
164
|
/**
|
|
139
165
|
* Thrown when an offer builder receives a parameter that cannot satisfy Midnight protocol rules.
|
|
140
166
|
*
|
|
@@ -161,6 +187,21 @@ export declare class InvalidOfferParameterError extends Error {
|
|
|
161
187
|
readonly cause?: unknown;
|
|
162
188
|
});
|
|
163
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Thrown when Midnight mempool payload bytes cannot be encoded or decoded.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* import { PayloadDecodeError } from "@morpho-org/midnight-sdk";
|
|
196
|
+
*
|
|
197
|
+
* throw new PayloadDecodeError("payload too short for header");
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export declare class PayloadDecodeError extends Error {
|
|
201
|
+
/** Machine-readable decode failure reason without the class message prefix. */
|
|
202
|
+
readonly reason: string;
|
|
203
|
+
constructor(reason: string, cause?: Error);
|
|
204
|
+
}
|
|
164
205
|
/**
|
|
165
206
|
* Thrown when a tree height exceeds the ratifier typehash table.
|
|
166
207
|
*
|
|
@@ -187,6 +228,38 @@ export declare class InvalidTreeHeightError extends Error {
|
|
|
187
228
|
export declare class InvalidTreeError extends Error {
|
|
188
229
|
constructor(message: string);
|
|
189
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Thrown when a viem client's chain id does not match the chain id required by a signing flow.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* import { ChainIdMismatchError } from "@morpho-org/midnight-sdk";
|
|
237
|
+
*
|
|
238
|
+
* throw new ChainIdMismatchError(1, 8453n);
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export declare class ChainIdMismatchError extends Error {
|
|
242
|
+
/** Chain id reported by the viem client, when configured. */
|
|
243
|
+
readonly clientChainId: number | undefined;
|
|
244
|
+
/** Chain id required by the data being signed. */
|
|
245
|
+
readonly expectedChainId: bigint;
|
|
246
|
+
constructor(clientChainId: number | undefined, expectedChainId: bigint);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Thrown when the Midnight API rejects a tree during mempool policy validation.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* import { MidnightMempoolValidationError } from "@morpho-org/midnight-sdk";
|
|
254
|
+
*
|
|
255
|
+
* throw new MidnightMempoolValidationError([{ rule: "tick_spacing" }]);
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
export declare class MidnightMempoolValidationError extends Error {
|
|
259
|
+
/** Validation issues returned by the Midnight API. */
|
|
260
|
+
readonly issues: readonly MempoolPayloadValidationIssue[];
|
|
261
|
+
constructor(issues: readonly MempoolPayloadValidationIssue[]);
|
|
262
|
+
}
|
|
190
263
|
/**
|
|
191
264
|
* Thrown when a typed-data signature does not recover to the expected signer.
|
|
192
265
|
*
|
|
@@ -202,7 +275,7 @@ export declare class InvalidTreeError extends Error {
|
|
|
202
275
|
export declare class InvalidTypedDataSignatureError extends Error {
|
|
203
276
|
/** Signer address the signature was expected to recover. */
|
|
204
277
|
readonly signer: Address;
|
|
205
|
-
constructor(signer: Address);
|
|
278
|
+
constructor(signer: Address, cause?: unknown);
|
|
206
279
|
}
|
|
207
280
|
/**
|
|
208
281
|
* Thrown when the Midnight API returns a non-2xx response.
|