@morpho-org/midnight-sdk 1.2.1 → 1.3.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.
@@ -1,5 +1,6 @@
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, 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";
2
+ export type { FetchBookParams, FetchBookPriceLevelsParams, FetchBookQuoteParams, FetchBooksParams, FetchBookTakeableOffersParams, FetchTakeableOffersParams, MempoolPayloadValidationIssue, MempoolPayloadValidationIssueDetails, 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
+ export { MempoolPayloadValidationRule } from "./types.js";
3
4
  /**
4
5
  * Midnight API client and stateless helper surface for books and mempool data.
5
6
  *
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MidnightApi = void 0;
3
+ exports.MidnightApi = exports.MempoolPayloadValidationRule = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
5
  const errors_js_1 = require("../errors.js");
6
6
  const index_js_1 = require("../math/index.js");
7
7
  const Payload_js_1 = require("../signatures/Payload.js");
8
8
  const helpers_js_1 = require("./helpers.js");
9
+ var types_js_1 = require("./types.js");
10
+ Object.defineProperty(exports, "MempoolPayloadValidationRule", { enumerable: true, get: function () { return types_js_1.MempoolPayloadValidationRule; } });
9
11
  /**
10
12
  * Midnight API client and stateless helper surface for books and mempool data.
11
13
  *
@@ -1,5 +1,5 @@
1
1
  import { type Address, type Hash } from "viem";
2
- import type { ApiBookMarketResponse, ApiCollateralResponse, ApiPriceLevelResponse, ApiRequestParams, ApiTakeableOfferResponse, MempoolPayloadValidationResult, MidnightApiBookMarket, MidnightApiBookSide, MidnightApiCollateral, MidnightApiPriceLevel, MidnightApiTake } from "./types.js";
2
+ import { type ApiBookMarketResponse, type ApiCollateralResponse, type ApiPriceLevelResponse, type ApiRequestParams, type ApiTakeableOfferResponse, type MempoolPayloadValidationResult, type MidnightApiBookMarket, type MidnightApiBookSide, type MidnightApiCollateral, type MidnightApiPriceLevel, type MidnightApiTake } from "./types.js";
3
3
  /** @internal Sends one Midnight API request and maps non-2xx responses to SDK errors. */
4
4
  export declare function requestMidnightApi<Response = unknown>(params: ApiRequestParams): Promise<Response>;
5
5
  /** @internal Builds a book endpoint path with encoded path segments. */
@@ -12,8 +12,10 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
12
12
  const viem_1 = require("viem");
13
13
  const errors_js_1 = require("../errors.js");
14
14
  const index_js_1 = require("../market/index.js");
15
+ const types_js_1 = require("./types.js");
15
16
  const version_generated_js_1 = require("./version.generated.js");
16
17
  const DEFAULT_MIDNIGHT_API_URL = new URL("/v0/midnight", morpho_ts_1.BLUE_API_BASE_URL);
18
+ const MAX_UINT256_DECIMAL_LENGTH = viem_1.maxUint256.toString().length;
17
19
  /** @internal Sends one Midnight API request and maps non-2xx responses to SDK errors. */
18
20
  async function requestMidnightApi(params) {
19
21
  const baseUrl = new URL(params.baseUrl ?? DEFAULT_MIDNIGHT_API_URL);
@@ -220,7 +222,38 @@ function parseValidationResponse(response) {
220
222
  if (typeof rule !== "string") {
221
223
  throw new errors_js_1.InvalidMidnightApiResponseError('Midnight API validation issue is missing "rule".');
222
224
  }
223
- return { rule };
225
+ const details = record.details;
226
+ if (details == null)
227
+ return { rule };
228
+ if (rule === types_js_1.MempoolPayloadValidationRule.MinOfferAssetsUsd &&
229
+ isRecord(details)) {
230
+ const loanToken = details.loan_token;
231
+ const rawMinAssets = details.min_assets;
232
+ if (typeof loanToken === "string" &&
233
+ (0, viem_1.isAddress)(loanToken) &&
234
+ typeof rawMinAssets === "string" &&
235
+ rawMinAssets.length <= MAX_UINT256_DECIMAL_LENGTH &&
236
+ /^\d+$/.test(rawMinAssets)) {
237
+ const minAssets = BigInt(rawMinAssets);
238
+ if (minAssets <= viem_1.maxUint256) {
239
+ return {
240
+ rule,
241
+ details: {
242
+ type: "minOfferAssetsUsd",
243
+ loanToken,
244
+ minAssets,
245
+ },
246
+ };
247
+ }
248
+ }
249
+ }
250
+ return {
251
+ rule,
252
+ details: {
253
+ type: "unknown",
254
+ raw: details,
255
+ },
256
+ };
224
257
  });
225
258
  return {
226
259
  valid: issues.length === 0,
@@ -194,11 +194,79 @@ export interface FetchTakeableOffersParams extends MidnightApiConfig {
194
194
  readonly cursor?: string;
195
195
  }
196
196
  /**
197
- * One API validation issue.
197
+ * `MempoolPayloadValidationRule` lists known Midnight mempool validation rules.
198
+ */
199
+ export declare const MempoolPayloadValidationRule: {
200
+ readonly MinOfferAssetsUsd: "min_offer_assets_usd";
201
+ readonly PayloadVersion: "payload_version";
202
+ readonly PayloadFrame: "payload_frame";
203
+ readonly PayloadGzipLength: "payload_gzip_length";
204
+ readonly PayloadSuffixTooLarge: "payload_suffix_too_large";
205
+ readonly PayloadDecompression: "payload_decompression";
206
+ readonly PayloadAbiDecode: "payload_abi_decode";
207
+ readonly EmptyPayload: "empty_payload";
208
+ readonly MaxOffersPerTree: "max_offers_per_tree";
209
+ readonly DuplicateOfferHash: "duplicate_offer_hash";
210
+ readonly UnsupportedChain: "unsupported_chain";
211
+ readonly MarketChainMismatch: "market_chain_mismatch";
212
+ readonly Maturity: "maturity";
213
+ readonly LoanToken: "loan_token";
214
+ readonly CollateralToken: "collateral_token";
215
+ readonly Oracle: "oracle";
216
+ readonly MarketTriplet: "market_triplet";
217
+ readonly RcfThreshold: "rcf_threshold";
218
+ readonly CollateralLltv: "collateral_lltv";
219
+ readonly MaxLif: "max_lif";
220
+ readonly MaxCollaterals: "max_collaterals";
221
+ readonly AmountMissing: "amount_missing";
222
+ readonly AmountConflict: "amount_conflict";
223
+ readonly MinTick: "min_tick";
224
+ readonly MaxTick: "max_tick";
225
+ readonly TickSpacing: "tick_spacing";
226
+ readonly MinDuration: "min_duration";
227
+ readonly Ratifier: "ratifier";
228
+ readonly MixedMaker: "mixed_maker";
229
+ readonly MixedRatifier: "mixed_ratifier";
230
+ readonly GroupIdentity: "group_identity";
231
+ readonly GroupConsistency: "group_consistency";
232
+ readonly NonEmptyCallback: "non_empty_callback";
233
+ readonly BuyEmptyCallback: "buy_empty_callback";
234
+ readonly SellEmptyCallback: "sell_empty_callback";
235
+ };
236
+ /**
237
+ * `MempoolPayloadValidationRule` represents a rule returned by the API.
238
+ *
239
+ * Known values have autocomplete through the matching constant; the open
240
+ * string branch keeps newer API rules forward-compatible.
241
+ */
242
+ export type MempoolPayloadValidationRule = (typeof MempoolPayloadValidationRule)[keyof typeof MempoolPayloadValidationRule] | (string & Record<never, never>);
243
+ /**
244
+ * `MempoolPayloadValidationIssueDetails` represents parsed issue details.
245
+ *
246
+ * Unrecognized non-null details are retained verbatim so API additions do not
247
+ * make older SDK clients reject the entire validation response.
248
+ */
249
+ export type MempoolPayloadValidationIssueDetails = {
250
+ /** Identifies details for the `min_offer_assets_usd` rule. */
251
+ readonly type: "minOfferAssetsUsd";
252
+ /** Loan token of the first offer below its configured minimum. */
253
+ readonly loanToken: Address;
254
+ /** Configured minimum in raw loan-token assets. */
255
+ readonly minAssets: bigint;
256
+ } | {
257
+ /** Identifies details whose schema is not known by this SDK version. */
258
+ readonly type: "unknown";
259
+ /** Unmodified JSON value returned by the API. */
260
+ readonly raw: unknown;
261
+ };
262
+ /**
263
+ * `MempoolPayloadValidationIssue` represents one API validation issue.
198
264
  */
199
265
  export interface MempoolPayloadValidationIssue {
200
266
  /** API rule violated by the payload. */
201
- readonly rule: string;
267
+ readonly rule: MempoolPayloadValidationRule;
268
+ /** Parsed non-null details, when the API provides them. */
269
+ readonly details?: MempoolPayloadValidationIssueDetails;
202
270
  }
203
271
  /**
204
272
  * SDK-shaped result returned by Midnight mempool validation.
@@ -1,2 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MempoolPayloadValidationRule = void 0;
4
+ /**
5
+ * `MempoolPayloadValidationRule` lists known Midnight mempool validation rules.
6
+ */
7
+ exports.MempoolPayloadValidationRule = {
8
+ MinOfferAssetsUsd: "min_offer_assets_usd",
9
+ PayloadVersion: "payload_version",
10
+ PayloadFrame: "payload_frame",
11
+ PayloadGzipLength: "payload_gzip_length",
12
+ PayloadSuffixTooLarge: "payload_suffix_too_large",
13
+ PayloadDecompression: "payload_decompression",
14
+ PayloadAbiDecode: "payload_abi_decode",
15
+ EmptyPayload: "empty_payload",
16
+ MaxOffersPerTree: "max_offers_per_tree",
17
+ DuplicateOfferHash: "duplicate_offer_hash",
18
+ UnsupportedChain: "unsupported_chain",
19
+ MarketChainMismatch: "market_chain_mismatch",
20
+ Maturity: "maturity",
21
+ LoanToken: "loan_token",
22
+ CollateralToken: "collateral_token",
23
+ Oracle: "oracle",
24
+ MarketTriplet: "market_triplet",
25
+ RcfThreshold: "rcf_threshold",
26
+ CollateralLltv: "collateral_lltv",
27
+ MaxLif: "max_lif",
28
+ MaxCollaterals: "max_collaterals",
29
+ AmountMissing: "amount_missing",
30
+ AmountConflict: "amount_conflict",
31
+ MinTick: "min_tick",
32
+ MaxTick: "max_tick",
33
+ TickSpacing: "tick_spacing",
34
+ MinDuration: "min_duration",
35
+ Ratifier: "ratifier",
36
+ MixedMaker: "mixed_maker",
37
+ MixedRatifier: "mixed_ratifier",
38
+ GroupIdentity: "group_identity",
39
+ GroupConsistency: "group_consistency",
40
+ NonEmptyCallback: "non_empty_callback",
41
+ BuyEmptyCallback: "buy_empty_callback",
42
+ SellEmptyCallback: "sell_empty_callback",
43
+ };
@@ -1,2 +1,2 @@
1
1
  /** @internal Installed Midnight SDK package version. */
2
- export declare const MIDNIGHT_SDK_VERSION = "1.2.1";
2
+ export declare const MIDNIGHT_SDK_VERSION = "1.3.0";
@@ -3,4 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.MIDNIGHT_SDK_VERSION = void 0;
5
5
  /** @internal Installed Midnight SDK package version. */
6
- exports.MIDNIGHT_SDK_VERSION = "1.2.1";
6
+ exports.MIDNIGHT_SDK_VERSION = "1.3.0";
@@ -1,5 +1,6 @@
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, 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";
2
+ export type { FetchBookParams, FetchBookPriceLevelsParams, FetchBookQuoteParams, FetchBooksParams, FetchBookTakeableOffersParams, FetchTakeableOffersParams, MempoolPayloadValidationIssue, MempoolPayloadValidationIssueDetails, 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
+ export { MempoolPayloadValidationRule } from "./types.js";
3
4
  /**
4
5
  * Midnight API client and stateless helper surface for books and mempool data.
5
6
  *
@@ -3,6 +3,7 @@ import { InvalidMidnightApiResponseError } from "../errors.js";
3
3
  import { TickLib } from "../math/index.js";
4
4
  import { Payload } from "../signatures/Payload.js";
5
5
  import { buildBookPath, mapBookMarket, mapBoundTakeableOffers, mapPriceLevel, parseValidationResponse, requestMidnightApi, } from "./helpers.js";
6
+ export { MempoolPayloadValidationRule } from "./types.js";
6
7
  /**
7
8
  * Midnight API client and stateless helper surface for books and mempool data.
8
9
  *
@@ -1,5 +1,5 @@
1
1
  import { type Address, type Hash } from "viem";
2
- import type { ApiBookMarketResponse, ApiCollateralResponse, ApiPriceLevelResponse, ApiRequestParams, ApiTakeableOfferResponse, MempoolPayloadValidationResult, MidnightApiBookMarket, MidnightApiBookSide, MidnightApiCollateral, MidnightApiPriceLevel, MidnightApiTake } from "./types.js";
2
+ import { type ApiBookMarketResponse, type ApiCollateralResponse, type ApiPriceLevelResponse, type ApiRequestParams, type ApiTakeableOfferResponse, type MempoolPayloadValidationResult, type MidnightApiBookMarket, type MidnightApiBookSide, type MidnightApiCollateral, type MidnightApiPriceLevel, type MidnightApiTake } from "./types.js";
3
3
  /** @internal Sends one Midnight API request and maps non-2xx responses to SDK errors. */
4
4
  export declare function requestMidnightApi<Response = unknown>(params: ApiRequestParams): Promise<Response>;
5
5
  /** @internal Builds a book endpoint path with encoded path segments. */
@@ -1,9 +1,11 @@
1
1
  import { BLUE_API_BASE_URL, isHexEqual } from "@morpho-org/morpho-ts";
2
- import { isAddressEqual } from "viem";
2
+ import { isAddress, isAddressEqual, maxUint256, } from "viem";
3
3
  import { InvalidMidnightApiResponseError, MidnightApiError, } from "../errors.js";
4
4
  import { MarketUtils } from "../market/index.js";
5
+ import { MempoolPayloadValidationRule, } from "./types.js";
5
6
  import { MIDNIGHT_SDK_VERSION } from "./version.generated.js";
6
7
  const DEFAULT_MIDNIGHT_API_URL = new URL("/v0/midnight", BLUE_API_BASE_URL);
8
+ const MAX_UINT256_DECIMAL_LENGTH = maxUint256.toString().length;
7
9
  /** @internal Sends one Midnight API request and maps non-2xx responses to SDK errors. */
8
10
  export async function requestMidnightApi(params) {
9
11
  const baseUrl = new URL(params.baseUrl ?? DEFAULT_MIDNIGHT_API_URL);
@@ -210,7 +212,38 @@ export function parseValidationResponse(response) {
210
212
  if (typeof rule !== "string") {
211
213
  throw new InvalidMidnightApiResponseError('Midnight API validation issue is missing "rule".');
212
214
  }
213
- return { rule };
215
+ const details = record.details;
216
+ if (details == null)
217
+ return { rule };
218
+ if (rule === MempoolPayloadValidationRule.MinOfferAssetsUsd &&
219
+ isRecord(details)) {
220
+ const loanToken = details.loan_token;
221
+ const rawMinAssets = details.min_assets;
222
+ if (typeof loanToken === "string" &&
223
+ isAddress(loanToken) &&
224
+ typeof rawMinAssets === "string" &&
225
+ rawMinAssets.length <= MAX_UINT256_DECIMAL_LENGTH &&
226
+ /^\d+$/.test(rawMinAssets)) {
227
+ const minAssets = BigInt(rawMinAssets);
228
+ if (minAssets <= maxUint256) {
229
+ return {
230
+ rule,
231
+ details: {
232
+ type: "minOfferAssetsUsd",
233
+ loanToken,
234
+ minAssets,
235
+ },
236
+ };
237
+ }
238
+ }
239
+ }
240
+ return {
241
+ rule,
242
+ details: {
243
+ type: "unknown",
244
+ raw: details,
245
+ },
246
+ };
214
247
  });
215
248
  return {
216
249
  valid: issues.length === 0,
@@ -194,11 +194,79 @@ export interface FetchTakeableOffersParams extends MidnightApiConfig {
194
194
  readonly cursor?: string;
195
195
  }
196
196
  /**
197
- * One API validation issue.
197
+ * `MempoolPayloadValidationRule` lists known Midnight mempool validation rules.
198
+ */
199
+ export declare const MempoolPayloadValidationRule: {
200
+ readonly MinOfferAssetsUsd: "min_offer_assets_usd";
201
+ readonly PayloadVersion: "payload_version";
202
+ readonly PayloadFrame: "payload_frame";
203
+ readonly PayloadGzipLength: "payload_gzip_length";
204
+ readonly PayloadSuffixTooLarge: "payload_suffix_too_large";
205
+ readonly PayloadDecompression: "payload_decompression";
206
+ readonly PayloadAbiDecode: "payload_abi_decode";
207
+ readonly EmptyPayload: "empty_payload";
208
+ readonly MaxOffersPerTree: "max_offers_per_tree";
209
+ readonly DuplicateOfferHash: "duplicate_offer_hash";
210
+ readonly UnsupportedChain: "unsupported_chain";
211
+ readonly MarketChainMismatch: "market_chain_mismatch";
212
+ readonly Maturity: "maturity";
213
+ readonly LoanToken: "loan_token";
214
+ readonly CollateralToken: "collateral_token";
215
+ readonly Oracle: "oracle";
216
+ readonly MarketTriplet: "market_triplet";
217
+ readonly RcfThreshold: "rcf_threshold";
218
+ readonly CollateralLltv: "collateral_lltv";
219
+ readonly MaxLif: "max_lif";
220
+ readonly MaxCollaterals: "max_collaterals";
221
+ readonly AmountMissing: "amount_missing";
222
+ readonly AmountConflict: "amount_conflict";
223
+ readonly MinTick: "min_tick";
224
+ readonly MaxTick: "max_tick";
225
+ readonly TickSpacing: "tick_spacing";
226
+ readonly MinDuration: "min_duration";
227
+ readonly Ratifier: "ratifier";
228
+ readonly MixedMaker: "mixed_maker";
229
+ readonly MixedRatifier: "mixed_ratifier";
230
+ readonly GroupIdentity: "group_identity";
231
+ readonly GroupConsistency: "group_consistency";
232
+ readonly NonEmptyCallback: "non_empty_callback";
233
+ readonly BuyEmptyCallback: "buy_empty_callback";
234
+ readonly SellEmptyCallback: "sell_empty_callback";
235
+ };
236
+ /**
237
+ * `MempoolPayloadValidationRule` represents a rule returned by the API.
238
+ *
239
+ * Known values have autocomplete through the matching constant; the open
240
+ * string branch keeps newer API rules forward-compatible.
241
+ */
242
+ export type MempoolPayloadValidationRule = (typeof MempoolPayloadValidationRule)[keyof typeof MempoolPayloadValidationRule] | (string & Record<never, never>);
243
+ /**
244
+ * `MempoolPayloadValidationIssueDetails` represents parsed issue details.
245
+ *
246
+ * Unrecognized non-null details are retained verbatim so API additions do not
247
+ * make older SDK clients reject the entire validation response.
248
+ */
249
+ export type MempoolPayloadValidationIssueDetails = {
250
+ /** Identifies details for the `min_offer_assets_usd` rule. */
251
+ readonly type: "minOfferAssetsUsd";
252
+ /** Loan token of the first offer below its configured minimum. */
253
+ readonly loanToken: Address;
254
+ /** Configured minimum in raw loan-token assets. */
255
+ readonly minAssets: bigint;
256
+ } | {
257
+ /** Identifies details whose schema is not known by this SDK version. */
258
+ readonly type: "unknown";
259
+ /** Unmodified JSON value returned by the API. */
260
+ readonly raw: unknown;
261
+ };
262
+ /**
263
+ * `MempoolPayloadValidationIssue` represents one API validation issue.
198
264
  */
199
265
  export interface MempoolPayloadValidationIssue {
200
266
  /** API rule violated by the payload. */
201
- readonly rule: string;
267
+ readonly rule: MempoolPayloadValidationRule;
268
+ /** Parsed non-null details, when the API provides them. */
269
+ readonly details?: MempoolPayloadValidationIssueDetails;
202
270
  }
203
271
  /**
204
272
  * SDK-shaped result returned by Midnight mempool validation.
@@ -1 +1,40 @@
1
- export {};
1
+ /**
2
+ * `MempoolPayloadValidationRule` lists known Midnight mempool validation rules.
3
+ */
4
+ export const MempoolPayloadValidationRule = {
5
+ MinOfferAssetsUsd: "min_offer_assets_usd",
6
+ PayloadVersion: "payload_version",
7
+ PayloadFrame: "payload_frame",
8
+ PayloadGzipLength: "payload_gzip_length",
9
+ PayloadSuffixTooLarge: "payload_suffix_too_large",
10
+ PayloadDecompression: "payload_decompression",
11
+ PayloadAbiDecode: "payload_abi_decode",
12
+ EmptyPayload: "empty_payload",
13
+ MaxOffersPerTree: "max_offers_per_tree",
14
+ DuplicateOfferHash: "duplicate_offer_hash",
15
+ UnsupportedChain: "unsupported_chain",
16
+ MarketChainMismatch: "market_chain_mismatch",
17
+ Maturity: "maturity",
18
+ LoanToken: "loan_token",
19
+ CollateralToken: "collateral_token",
20
+ Oracle: "oracle",
21
+ MarketTriplet: "market_triplet",
22
+ RcfThreshold: "rcf_threshold",
23
+ CollateralLltv: "collateral_lltv",
24
+ MaxLif: "max_lif",
25
+ MaxCollaterals: "max_collaterals",
26
+ AmountMissing: "amount_missing",
27
+ AmountConflict: "amount_conflict",
28
+ MinTick: "min_tick",
29
+ MaxTick: "max_tick",
30
+ TickSpacing: "tick_spacing",
31
+ MinDuration: "min_duration",
32
+ Ratifier: "ratifier",
33
+ MixedMaker: "mixed_maker",
34
+ MixedRatifier: "mixed_ratifier",
35
+ GroupIdentity: "group_identity",
36
+ GroupConsistency: "group_consistency",
37
+ NonEmptyCallback: "non_empty_callback",
38
+ BuyEmptyCallback: "buy_empty_callback",
39
+ SellEmptyCallback: "sell_empty_callback",
40
+ };
@@ -1,2 +1,2 @@
1
1
  /** @internal Installed Midnight SDK package version. */
2
- export declare const MIDNIGHT_SDK_VERSION = "1.2.1";
2
+ export declare const MIDNIGHT_SDK_VERSION = "1.3.0";
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/release/generate-midnight-package-version.mjs. Do not edit.
2
2
  /** @internal Installed Midnight SDK package version. */
3
- export const MIDNIGHT_SDK_VERSION = "1.2.1";
3
+ export const MIDNIGHT_SDK_VERSION = "1.3.0";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/midnight-sdk",
3
3
  "description": "Viem-based package for Morpho Midnight that exports protocol utilities, fetch helpers, and Midnight API utilities under a dedicated API subpath.",
4
- "version": "1.2.1",
4
+ "version": "1.3.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"