@morpho-org/midnight-sdk 1.8.0 → 2.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/MIGRATION-v1-to-v2.md +6 -0
- package/README.md +17 -15
- package/lib/cjs/abis.d.ts +1870 -1461
- package/lib/cjs/abis.js +2151 -1626
- package/lib/cjs/api/helpers.d.ts +1 -17
- package/lib/cjs/api/helpers.js +0 -4
- package/lib/cjs/api/types.d.ts +5 -4
- package/lib/cjs/api/version.generated.d.ts +1 -1
- package/lib/cjs/api/version.generated.js +2 -2
- package/lib/cjs/bundlesV2.d.ts +15 -0
- package/lib/cjs/bundlesV2.js +2 -0
- package/lib/cjs/fetch/Ratifier.js +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/esm/abis.d.ts +1870 -1461
- package/lib/esm/abis.js +2150 -1625
- package/lib/esm/api/helpers.d.ts +1 -17
- package/lib/esm/api/helpers.js +4 -4
- package/lib/esm/api/types.d.ts +5 -4
- package/lib/esm/api/version.generated.d.ts +1 -1
- package/lib/esm/api/version.generated.js +2 -2
- package/lib/esm/bundlesV2.d.ts +15 -0
- package/lib/esm/bundlesV2.js +1 -0
- package/lib/esm/fetch/Ratifier.js +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/package.json +8 -7
package/lib/cjs/api/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Address, type Hash } from "viem";
|
|
2
|
-
import { type ApiBookMarketResponse, type
|
|
2
|
+
import { type ApiBookMarketResponse, type ApiPriceLevelResponse, type ApiRequestParams, type ApiTakeableOfferResponse, type MempoolPayloadValidationResult, type MidnightApiBookMarket, type MidnightApiBookSide, 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. */
|
|
@@ -8,16 +8,6 @@ export declare function buildBookPath(params: {
|
|
|
8
8
|
readonly side?: MidnightApiBookSide;
|
|
9
9
|
readonly suffix?: "quote" | "takeable-offers";
|
|
10
10
|
}): string;
|
|
11
|
-
/**
|
|
12
|
-
* @internal Maps a book market API payload to the SDK response shape, rejecting any
|
|
13
|
-
* response whose advertised `market_id` cannot be derived from — or does not match —
|
|
14
|
-
* its own market params. Recomputing the id with `MarketUtils.toId` (mirroring the
|
|
15
|
-
* takeable-offers path) stops a hostile API from pairing a trusted id with foreign
|
|
16
|
-
* metadata; every book flows through here, so both bound paths reject the same substitution.
|
|
17
|
-
* Collaterals are returned in the protocol's canonical order so their array index matches
|
|
18
|
-
* the onchain `collateralIndex`.
|
|
19
|
-
*/
|
|
20
|
-
export declare function mapBookMarket(book: ApiBookMarketResponse): MidnightApiBookMarket;
|
|
21
11
|
/** @internal Maps a book market, binding its verified id to the requested market. */
|
|
22
12
|
export declare function mapBoundBookMarket(book: ApiBookMarketResponse, requestedMarketId: Hash): MidnightApiBookMarket;
|
|
23
13
|
/** @internal Requested `fetchBooks` filters that every returned book must satisfy. */
|
|
@@ -30,14 +20,8 @@ export interface BookFilterContext {
|
|
|
30
20
|
}
|
|
31
21
|
/** @internal Maps listed book markets, binding each verified id to requested filters when present. */
|
|
32
22
|
export declare function mapBoundBooks(books: readonly ApiBookMarketResponse[], context?: BookFilterContext): MidnightApiBookMarket[];
|
|
33
|
-
/** @internal Maps a collateral API payload to the SDK response shape. */
|
|
34
|
-
export declare function mapCollateral(collateral: ApiCollateralResponse): MidnightApiCollateral;
|
|
35
|
-
/** @internal Maps a price-level API payload to the SDK response shape. */
|
|
36
|
-
export declare function mapPriceLevel(level: ApiPriceLevelResponse): MidnightApiPriceLevel;
|
|
37
23
|
/** @internal Maps API price levels and sorts them best first: asks by ascending tick, bids by descending tick. */
|
|
38
24
|
export declare function mapPriceLevels(levels: readonly ApiPriceLevelResponse[], side: MidnightApiBookSide): MidnightApiPriceLevel[];
|
|
39
|
-
/** @internal Maps a takeable-offer API payload to the SDK response shape. */
|
|
40
|
-
export declare function mapTakeableOffer(takeableOffer: ApiTakeableOfferResponse): MidnightApiTake;
|
|
41
25
|
/** @internal API response context required for a takeable offer to be executable for the caller's request. */
|
|
42
26
|
export interface TakeableOfferContext {
|
|
43
27
|
readonly marketId?: Hash;
|
package/lib/cjs/api/helpers.js
CHANGED
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requestMidnightApi = requestMidnightApi;
|
|
4
4
|
exports.buildBookPath = buildBookPath;
|
|
5
|
-
exports.mapBookMarket = mapBookMarket;
|
|
6
5
|
exports.mapBoundBookMarket = mapBoundBookMarket;
|
|
7
6
|
exports.mapBoundBooks = mapBoundBooks;
|
|
8
|
-
exports.mapCollateral = mapCollateral;
|
|
9
|
-
exports.mapPriceLevel = mapPriceLevel;
|
|
10
7
|
exports.mapPriceLevels = mapPriceLevels;
|
|
11
|
-
exports.mapTakeableOffer = mapTakeableOffer;
|
|
12
8
|
exports.mapBoundTakeableOffers = mapBoundTakeableOffers;
|
|
13
9
|
exports.parseValidationResponse = parseValidationResponse;
|
|
14
10
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
package/lib/cjs/api/types.d.ts
CHANGED
|
@@ -440,9 +440,9 @@ export interface MidnightApiTakeableOffersResult {
|
|
|
440
440
|
readonly data: readonly MidnightApiTake[];
|
|
441
441
|
}
|
|
442
442
|
/** @internal HTTP method owned by Midnight API helpers. */
|
|
443
|
-
|
|
443
|
+
type ApiMethod = "GET" | "POST";
|
|
444
444
|
/** @internal Query values serializable by Midnight API helpers. */
|
|
445
|
-
|
|
445
|
+
type QueryValue = string | number | bigint | boolean | Date | readonly string[] | readonly number[] | undefined;
|
|
446
446
|
/** @internal Request descriptor consumed by the Midnight API HTTP helper. */
|
|
447
447
|
export type ApiRequestParams = MidnightApiConfig & {
|
|
448
448
|
readonly method: ApiMethod;
|
|
@@ -493,7 +493,7 @@ export type ApiPriceLevelsResponse = {
|
|
|
493
493
|
readonly data: readonly ApiPriceLevelResponse[];
|
|
494
494
|
};
|
|
495
495
|
/** @internal Offer market response shape returned by the API. */
|
|
496
|
-
|
|
496
|
+
type ApiOfferMarketResponse = {
|
|
497
497
|
readonly chain_id: number;
|
|
498
498
|
readonly midnight: Address;
|
|
499
499
|
readonly loan_token: Address;
|
|
@@ -504,7 +504,7 @@ export type ApiOfferMarketResponse = {
|
|
|
504
504
|
readonly liquidator_gate: Address;
|
|
505
505
|
};
|
|
506
506
|
/** @internal Inline offer response shape returned by the API. */
|
|
507
|
-
|
|
507
|
+
type ApiOfferResponse = {
|
|
508
508
|
readonly market: ApiOfferMarketResponse;
|
|
509
509
|
readonly buy: boolean;
|
|
510
510
|
readonly maker: Address;
|
|
@@ -547,3 +547,4 @@ export type ApiTakeableOffersResponse = {
|
|
|
547
547
|
readonly cursor: string | null;
|
|
548
548
|
readonly data: readonly ApiTakeableOfferResponse[];
|
|
549
549
|
};
|
|
550
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal Installed Midnight SDK package version. */
|
|
2
|
-
export declare const MIDNIGHT_SDK_VERSION = "
|
|
2
|
+
export declare const MIDNIGHT_SDK_VERSION = "2.0.0";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Generated by scripts/
|
|
2
|
+
// Generated by scripts/generate-midnight-package-version.ts. Do not edit.
|
|
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 = "
|
|
6
|
+
exports.MIDNIGHT_SDK_VERSION = "2.0.0";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Hex } from "viem";
|
|
2
|
+
/** `MidnightBundlesV2` group cancellation: marks `group` fully consumed if its consumption is at most `maxConsumed`. */
|
|
3
|
+
export interface GroupCancellation {
|
|
4
|
+
/** Offer group id. */
|
|
5
|
+
readonly group: Hex;
|
|
6
|
+
/** Largest current group consumption accepted (uint128); the whole call reverts above it. */
|
|
7
|
+
readonly maxConsumed: bigint;
|
|
8
|
+
}
|
|
9
|
+
/** `MidnightBundlesV2` collateral transfer: `assets` of the market collateral at `collateralIndex`. */
|
|
10
|
+
export interface CollateralTransfer {
|
|
11
|
+
/** Index of the collateral in the market's `collateralParams`. */
|
|
12
|
+
readonly collateralIndex: bigint;
|
|
13
|
+
/** Collateral assets. */
|
|
14
|
+
readonly assets: bigint;
|
|
15
|
+
}
|
|
@@ -42,6 +42,7 @@ async function fetchRatifierInfo(client, params) {
|
|
|
42
42
|
const chainId = await (0, utils_js_1.resolveChainId)(client);
|
|
43
43
|
const ecrecoverRatifier = (0, morpho_ts_1.getChainAddress)(chainId, "ecrecoverRatifier");
|
|
44
44
|
const setterRatifier = (0, morpho_ts_1.getChainAddress)(chainId, "setterRatifier");
|
|
45
|
+
// eth_getCode is trusted; the returned ratifier is a suggestion the caller commits to on Offer.create. See THREAT_MODEL.md, RPC.
|
|
45
46
|
const bytecode = await (0, actions_1.getBytecode)(client, {
|
|
46
47
|
...(params.blockNumber != null
|
|
47
48
|
? { blockNumber: params.blockNumber }
|