@morpho-org/morpho-sdk 10.3.0 → 10.4.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/README.md +172 -8
- package/lib/cjs/actions/midnight/redeem.d.ts +20 -3
- package/lib/cjs/actions/midnight/redeem.js +58 -1
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
- package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +41 -0
- package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -2
- package/lib/cjs/actions/midnight/withdrawCollateral.js +26 -1
- package/lib/cjs/helpers/callback.d.ts +3 -2
- package/lib/cjs/helpers/callback.js +4 -20
- package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
- package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.js +30 -0
- package/lib/cjs/helpers/parseMidnightMaker.d.ts +21 -0
- package/lib/cjs/helpers/parseMidnightMaker.js +41 -1
- package/lib/cjs/helpers/validate.d.ts +49 -1
- package/lib/cjs/helpers/validate.js +87 -1
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +10 -0
- package/lib/cjs/helpers/validateMidnightPublication.js +18 -1
- package/lib/cjs/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
- package/lib/cjs/helpers/validateMidnightTakeableOfferFields.js +85 -0
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +23 -1
- package/lib/cjs/midnight/utils.d.ts +1 -1
- package/lib/cjs/midnight/utils.js +2 -1
- package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
- package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.js +264 -0
- package/lib/cjs/transactionPlan/error.d.ts +27 -0
- package/lib/cjs/transactionPlan/error.js +30 -1
- package/lib/cjs/transactionPlan/index.d.ts +40 -1
- package/lib/cjs/transactionPlan/index.js +46 -5
- package/lib/cjs/transactionPlan/midnight/authorization.d.ts +15 -0
- package/lib/cjs/transactionPlan/midnight/authorization.js +45 -0
- package/lib/cjs/transactionPlan/midnight/cancelOffers.d.ts +80 -0
- package/lib/cjs/transactionPlan/midnight/cancelOffers.js +125 -0
- package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +104 -0
- package/lib/cjs/transactionPlan/midnight/makeBorrow.js +126 -0
- package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +140 -0
- package/lib/cjs/transactionPlan/midnight/makeLend.js +176 -0
- package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +118 -0
- package/lib/cjs/transactionPlan/midnight/makeRepay.js +118 -0
- package/lib/cjs/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
- package/lib/cjs/transactionPlan/midnight/makeWithdraw.js +126 -0
- package/lib/cjs/transactionPlan/midnight/makerPublication.d.ts +55 -0
- package/lib/cjs/transactionPlan/midnight/makerPublication.js +315 -0
- package/lib/cjs/transactionPlan/midnight/market.d.ts +49 -0
- package/lib/cjs/transactionPlan/midnight/market.js +120 -0
- package/lib/cjs/transactionPlan/midnight/prepare.d.ts +244 -0
- package/lib/cjs/transactionPlan/midnight/prepare.js +547 -0
- package/lib/cjs/transactionPlan/midnight/publicationState.d.ts +24 -0
- package/lib/cjs/transactionPlan/midnight/publicationState.js +50 -0
- package/lib/cjs/transactionPlan/midnight/redeem.d.ts +102 -0
- package/lib/cjs/transactionPlan/midnight/redeem.js +170 -0
- package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
- package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.js +51 -0
- package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
- package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +328 -0
- package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
- package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +199 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +190 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +221 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +179 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
- package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +259 -0
- package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +304 -0
- package/lib/cjs/transactionPlan/midnight/takeBorrow.js +545 -0
- package/lib/cjs/transactionPlan/midnight/takeLend.d.ts +99 -0
- package/lib/cjs/transactionPlan/midnight/takeLend.js +263 -0
- package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
- package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +440 -0
- package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
- package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +240 -0
- package/lib/cjs/transactionPlan/midnight/validation.d.ts +22 -0
- package/lib/cjs/transactionPlan/midnight/validation.js +158 -0
- package/lib/cjs/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
- package/lib/cjs/transactionPlan/midnight/withdrawCollateral.js +228 -0
- package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
- package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.js +232 -0
- package/lib/cjs/transactionPlan/plan.d.ts +48 -14
- package/lib/cjs/transactionPlan/plan.js +103 -18
- package/lib/cjs/transactionPlan/requirements.d.ts +7 -4
- package/lib/cjs/transactionPlan/requirements.js +2 -2
- package/lib/cjs/transactionPlan/serde.d.ts +13 -2
- package/lib/cjs/transactionPlan/serde.js +68 -21
- package/lib/cjs/transactionPlan/types.d.ts +147 -0
- package/lib/cjs/transactionPlan/validateActions.d.ts +3 -1
- package/lib/cjs/transactionPlan/validateActions.js +31 -3
- package/lib/cjs/transactionPlan/validation.d.ts +1 -1
- package/lib/cjs/transactionPlan/validation.js +37 -1
- package/lib/cjs/types/error.d.ts +2 -0
- package/lib/cjs/types/error.js +2 -0
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/actions/midnight/redeem.d.ts +20 -3
- package/lib/esm/actions/midnight/redeem.js +56 -0
- package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
- package/lib/esm/actions/midnight/supplyCollateralWithNative.js +40 -0
- package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -2
- package/lib/esm/actions/midnight/withdrawCollateral.js +25 -1
- package/lib/esm/helpers/callback.d.ts +3 -2
- package/lib/esm/helpers/callback.js +5 -21
- package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
- package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.js +27 -0
- package/lib/esm/helpers/parseMidnightMaker.d.ts +21 -0
- package/lib/esm/helpers/parseMidnightMaker.js +40 -1
- package/lib/esm/helpers/validate.d.ts +49 -1
- package/lib/esm/helpers/validate.js +84 -1
- package/lib/esm/helpers/validateMidnightPublication.d.ts +10 -0
- package/lib/esm/helpers/validateMidnightPublication.js +16 -0
- package/lib/esm/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
- package/lib/esm/helpers/validateMidnightTakeableOfferFields.js +81 -0
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/midnight/utils.d.ts +1 -1
- package/lib/esm/midnight/utils.js +1 -1
- package/lib/esm/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
- package/lib/esm/transactionPlan/blue/withdrawBuyCallback.js +259 -0
- package/lib/esm/transactionPlan/error.d.ts +27 -0
- package/lib/esm/transactionPlan/error.js +28 -0
- package/lib/esm/transactionPlan/index.d.ts +40 -1
- package/lib/esm/transactionPlan/index.js +20 -1
- package/lib/esm/transactionPlan/midnight/authorization.d.ts +15 -0
- package/lib/esm/transactionPlan/midnight/authorization.js +40 -0
- package/lib/esm/transactionPlan/midnight/cancelOffers.d.ts +80 -0
- package/lib/esm/transactionPlan/midnight/cancelOffers.js +120 -0
- package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +104 -0
- package/lib/esm/transactionPlan/midnight/makeBorrow.js +123 -0
- package/lib/esm/transactionPlan/midnight/makeLend.d.ts +140 -0
- package/lib/esm/transactionPlan/midnight/makeLend.js +172 -0
- package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +118 -0
- package/lib/esm/transactionPlan/midnight/makeRepay.js +115 -0
- package/lib/esm/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
- package/lib/esm/transactionPlan/midnight/makeWithdraw.js +123 -0
- package/lib/esm/transactionPlan/midnight/makerPublication.d.ts +55 -0
- package/lib/esm/transactionPlan/midnight/makerPublication.js +310 -0
- package/lib/esm/transactionPlan/midnight/market.d.ts +49 -0
- package/lib/esm/transactionPlan/midnight/market.js +112 -0
- package/lib/esm/transactionPlan/midnight/prepare.d.ts +244 -0
- package/lib/esm/transactionPlan/midnight/prepare.js +536 -0
- package/lib/esm/transactionPlan/midnight/publicationState.d.ts +24 -0
- package/lib/esm/transactionPlan/midnight/publicationState.js +47 -0
- package/lib/esm/transactionPlan/midnight/redeem.d.ts +102 -0
- package/lib/esm/transactionPlan/midnight/redeem.js +165 -0
- package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
- package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.js +47 -0
- package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
- package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +323 -0
- package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
- package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +196 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateral.js +185 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +216 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +176 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
- package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +254 -0
- package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +304 -0
- package/lib/esm/transactionPlan/midnight/takeBorrow.js +539 -0
- package/lib/esm/transactionPlan/midnight/takeLend.d.ts +99 -0
- package/lib/esm/transactionPlan/midnight/takeLend.js +258 -0
- package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
- package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +435 -0
- package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
- package/lib/esm/transactionPlan/midnight/takeWithdraw.js +236 -0
- package/lib/esm/transactionPlan/midnight/validation.d.ts +22 -0
- package/lib/esm/transactionPlan/midnight/validation.js +151 -0
- package/lib/esm/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
- package/lib/esm/transactionPlan/midnight/withdrawCollateral.js +223 -0
- package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
- package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.js +227 -0
- package/lib/esm/transactionPlan/plan.d.ts +48 -14
- package/lib/esm/transactionPlan/plan.js +99 -14
- package/lib/esm/transactionPlan/requirements.d.ts +7 -4
- package/lib/esm/transactionPlan/requirements.js +2 -2
- package/lib/esm/transactionPlan/serde.d.ts +13 -2
- package/lib/esm/transactionPlan/serde.js +49 -2
- package/lib/esm/transactionPlan/types.d.ts +147 -0
- package/lib/esm/transactionPlan/validateActions.d.ts +3 -1
- package/lib/esm/transactionPlan/validateActions.js +31 -3
- package/lib/esm/transactionPlan/validation.d.ts +1 -1
- package/lib/esm/transactionPlan/validation.js +38 -2
- package/lib/esm/types/error.d.ts +2 -0
- package/lib/esm/types/error.js +2 -0
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +4 -4
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { InputMarketParams, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
+
import type { MarketUtils } from "@morpho-org/midnight-sdk";
|
|
2
3
|
import type { Address, Hex } from "viem";
|
|
3
4
|
import type { BlueRepayParams } from "../actions/blue/repay.js";
|
|
4
5
|
import type { BlueRepayWithdrawCollateralParams } from "../actions/blue/repayWithdrawCollateral.js";
|
|
5
6
|
import type { BlueSupplyCollateralBorrowParams } from "../actions/blue/supplyCollateralBorrow.js";
|
|
7
|
+
import type { MidnightRepayWithdrawCollateralParams } from "../actions/midnight/repayWithdrawCollateral.js";
|
|
8
|
+
import type { MidnightTakeBorrowParams } from "../actions/midnight/takeBorrow.js";
|
|
9
|
+
import type { MidnightTakeLendParams } from "../actions/midnight/takeLend.js";
|
|
10
|
+
import type { MidnightTakeRepayWithdrawCollateralParams } from "../actions/midnight/takeRepayWithdrawCollateral.js";
|
|
11
|
+
import type { MidnightTakeableOffer } from "../actions/midnight/types.js";
|
|
12
|
+
import type { MidnightBlueSupply, MidnightCollateralTransfer } from "../types/action.js";
|
|
6
13
|
import type { AuthorizationSignatureArgs, PermitAction, RequirementTypedData, VaultV1MigrateToV2AmountArgs, VaultV2BlueReallocation } from "../types/index.js";
|
|
14
|
+
import type { MidnightCancelAndMakeParams } from "../types/midnightCancelAndMake.js";
|
|
7
15
|
interface ActionInputs {
|
|
8
16
|
readonly chainId: number;
|
|
9
17
|
readonly account: Address;
|
|
@@ -25,6 +33,18 @@ type VaultSignatureRequestIds = {
|
|
|
25
33
|
/** Token permit consumed by the action; omitted when no permit is needed. */
|
|
26
34
|
readonly tokenPermit?: string;
|
|
27
35
|
};
|
|
36
|
+
type MidnightSellInputs = ActionInputs & Omit<MidnightTakeBorrowParams, "chainId" | "market" | "metadata" | "referralFeePct" | "referralFeeRecipient"> & {
|
|
37
|
+
readonly market: MidnightTakeableOffer["offer"]["market"];
|
|
38
|
+
readonly referralFeePct: bigint;
|
|
39
|
+
readonly referralFeeRecipient: Address;
|
|
40
|
+
};
|
|
41
|
+
type MidnightMakerPublicationInputs = ActionInputs & Pick<MidnightCancelAndMakeParams, "cancellations" | "deadline"> & {
|
|
42
|
+
readonly ratifierType: "priceV1" | "rateV1";
|
|
43
|
+
readonly ratifier: Address;
|
|
44
|
+
readonly root: Hex;
|
|
45
|
+
readonly groups: readonly Hex[];
|
|
46
|
+
readonly payload: Hex;
|
|
47
|
+
};
|
|
28
48
|
/**
|
|
29
49
|
* Recipes supported by TransactionPlan.
|
|
30
50
|
* Snapshot-derived values such as the asset and the quote are fixed on `inputs` at preparation;
|
|
@@ -33,6 +53,119 @@ type VaultSignatureRequestIds = {
|
|
|
33
53
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
34
54
|
*/
|
|
35
55
|
export type Action = {
|
|
56
|
+
readonly type: "midnightMakeBorrow";
|
|
57
|
+
readonly inputs: MidnightMakerPublicationInputs;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "midnightMakeLend";
|
|
60
|
+
readonly inputs: MidnightMakerPublicationInputs;
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "midnightMakeRepay";
|
|
63
|
+
readonly inputs: MidnightMakerPublicationInputs;
|
|
64
|
+
} | {
|
|
65
|
+
readonly type: "midnightMakeWithdraw";
|
|
66
|
+
readonly inputs: MidnightMakerPublicationInputs;
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: "midnightSupplyBlueMakeLend";
|
|
69
|
+
readonly inputs: MidnightMakerPublicationInputs & {
|
|
70
|
+
readonly blueSupply: MidnightBlueSupply;
|
|
71
|
+
/** Native ETH in wei, passed as transaction value. */
|
|
72
|
+
readonly nativeAssets?: bigint;
|
|
73
|
+
};
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: "midnightSupplyCollateralMakeBorrow";
|
|
76
|
+
readonly inputs: MidnightMakerPublicationInputs & {
|
|
77
|
+
readonly collateral: {
|
|
78
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
79
|
+
readonly supplies: readonly MidnightCollateralTransfer[];
|
|
80
|
+
};
|
|
81
|
+
/** Native ETH in wei, passed as transaction value. */
|
|
82
|
+
readonly nativeAssets?: bigint;
|
|
83
|
+
};
|
|
84
|
+
} | {
|
|
85
|
+
readonly type: "midnightRepayWithdrawCollateral";
|
|
86
|
+
readonly inputs: ActionInputs & Omit<MidnightRepayWithdrawCollateralParams, "chainId" | "market" | "metadata" | "nativeAmount"> & {
|
|
87
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
88
|
+
/** Native ETH in wei, passed as transaction value. Omitted or zero means no ETH funding. */
|
|
89
|
+
readonly nativeAssets?: bigint;
|
|
90
|
+
};
|
|
91
|
+
} | {
|
|
92
|
+
readonly type: "midnightTakeBorrow";
|
|
93
|
+
readonly inputs: MidnightSellInputs;
|
|
94
|
+
} | {
|
|
95
|
+
readonly type: "midnightTakeRepayWithdrawCollateral";
|
|
96
|
+
readonly inputs: ActionInputs & Omit<MidnightTakeRepayWithdrawCollateralParams, "chainId" | "market" | "metadata" | "nativeAmount" | "referralFeePct" | "referralFeeRecipient"> & {
|
|
97
|
+
readonly market: MidnightTakeableOffer["offer"]["market"];
|
|
98
|
+
readonly nativeAssets?: bigint;
|
|
99
|
+
readonly referralFeePct: bigint;
|
|
100
|
+
readonly referralFeeRecipient: Address;
|
|
101
|
+
};
|
|
102
|
+
} | {
|
|
103
|
+
readonly type: "midnightSupplyCollateralTakeBorrow";
|
|
104
|
+
readonly inputs: MidnightSellInputs & {
|
|
105
|
+
readonly collateralSupplies: readonly MidnightCollateralTransfer[];
|
|
106
|
+
/** Native ETH in wei, passed as transaction value. */
|
|
107
|
+
readonly nativeAssets?: bigint;
|
|
108
|
+
};
|
|
109
|
+
} | {
|
|
110
|
+
readonly type: "midnightTakeWithdraw";
|
|
111
|
+
readonly inputs: MidnightSellInputs;
|
|
112
|
+
} | {
|
|
113
|
+
readonly type: "midnightTakeLend";
|
|
114
|
+
readonly inputs: ActionInputs & Omit<MidnightTakeLendParams, "chainId" | "market" | "metadata" | "nativeAmount" | "referralFeePct" | "referralFeeRecipient"> & {
|
|
115
|
+
readonly market: MidnightTakeableOffer["offer"]["market"];
|
|
116
|
+
readonly nativeAssets?: bigint;
|
|
117
|
+
readonly referralFeePct: bigint;
|
|
118
|
+
readonly referralFeeRecipient: Address;
|
|
119
|
+
};
|
|
120
|
+
} | {
|
|
121
|
+
readonly type: "midnightAuthorization";
|
|
122
|
+
readonly inputs: ActionInputs;
|
|
123
|
+
} | {
|
|
124
|
+
readonly type: "midnightSupplyCollateral";
|
|
125
|
+
readonly inputs: ActionInputs & {
|
|
126
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
127
|
+
readonly collateralIndex: bigint;
|
|
128
|
+
readonly collateralAssets: bigint;
|
|
129
|
+
};
|
|
130
|
+
} | {
|
|
131
|
+
readonly type: "midnightWithdrawCollateral";
|
|
132
|
+
readonly inputs: ActionInputs & {
|
|
133
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
134
|
+
readonly collateralIndex: bigint;
|
|
135
|
+
readonly assets: bigint;
|
|
136
|
+
readonly receiver: Address;
|
|
137
|
+
};
|
|
138
|
+
} | {
|
|
139
|
+
readonly type: "midnightWithdrawCollateralBatch";
|
|
140
|
+
readonly inputs: ActionInputs & {
|
|
141
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
142
|
+
readonly collateralWithdrawals: readonly MidnightCollateralTransfer[];
|
|
143
|
+
readonly receiver: Address;
|
|
144
|
+
};
|
|
145
|
+
} | {
|
|
146
|
+
readonly type: "midnightSupplyCollateralBatch";
|
|
147
|
+
readonly inputs: ActionInputs & {
|
|
148
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
149
|
+
readonly collateralSupplies: readonly MidnightCollateralTransfer[];
|
|
150
|
+
};
|
|
151
|
+
} | {
|
|
152
|
+
readonly type: "midnightSupplyCollateralWithNative";
|
|
153
|
+
readonly inputs: ActionInputs & {
|
|
154
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
155
|
+
readonly collateralIndex: bigint;
|
|
156
|
+
readonly collateralAssets: bigint;
|
|
157
|
+
/** Native ETH in wei, passed as transaction value. */
|
|
158
|
+
readonly nativeAssets: bigint;
|
|
159
|
+
readonly deadline: bigint;
|
|
160
|
+
};
|
|
161
|
+
} | {
|
|
162
|
+
readonly type: "midnightRedeem";
|
|
163
|
+
readonly inputs: ActionInputs & {
|
|
164
|
+
readonly market: ReturnType<typeof MarketUtils.toStruct>;
|
|
165
|
+
readonly units: bigint;
|
|
166
|
+
readonly receiver: Address;
|
|
167
|
+
};
|
|
168
|
+
} | {
|
|
36
169
|
readonly type: "vaultV2ForceRedeem";
|
|
37
170
|
readonly inputs: ActionInputs & {
|
|
38
171
|
readonly vault: Address;
|
|
@@ -151,6 +284,15 @@ export type Action = {
|
|
|
151
284
|
readonly referralFeePct: bigint;
|
|
152
285
|
readonly referralFeeRecipient: Address;
|
|
153
286
|
};
|
|
287
|
+
} | {
|
|
288
|
+
readonly type: "blueWithdrawBuyCallback";
|
|
289
|
+
readonly inputs: ActionInputs & {
|
|
290
|
+
readonly marketParams: Readonly<InputMarketParams>;
|
|
291
|
+
/** BlueBuyCallback whose supply position is withdrawn to `account`, its owner. */
|
|
292
|
+
readonly callbackAddress: Address;
|
|
293
|
+
/** Every supply share the callback held in the prepared snapshot. */
|
|
294
|
+
readonly shares: bigint;
|
|
295
|
+
};
|
|
154
296
|
} | {
|
|
155
297
|
readonly type: "blueRepayWithdrawCollateral";
|
|
156
298
|
readonly inputs: ActionInputs & Omit<BlueRepayWithdrawCollateralParams["args"], "userAddress" | "requirementSignature" | "authorizationSignature" | "nativeAmount"> & {
|
|
@@ -283,6 +425,11 @@ export type Action = {
|
|
|
283
425
|
} | {
|
|
284
426
|
readonly type: "morphoAuthorization";
|
|
285
427
|
readonly inputs: ActionInputs;
|
|
428
|
+
} | {
|
|
429
|
+
readonly type: "midnightCancelOffers";
|
|
430
|
+
readonly inputs: ActionInputs & {
|
|
431
|
+
readonly groups: readonly Hex[];
|
|
432
|
+
};
|
|
286
433
|
};
|
|
287
434
|
/**
|
|
288
435
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Step } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* @internal Rejects unknown action types
|
|
3
|
+
* @internal Rejects unknown action types, and Midnight steps carrying a signature-request map,
|
|
4
|
+
* before interpreting requests or updates.
|
|
4
5
|
* @param steps - Steps whose action discriminators must be supported.
|
|
5
6
|
* @returns Nothing when every action type is supported.
|
|
6
7
|
* @throws {UnsupportedTransactionPlanActionError} when any step names an unsupported action type.
|
|
8
|
+
* @throws {InvalidTransactionPlanError} when a Midnight step carries `signatureRequestIds`, as restore does.
|
|
7
9
|
*/
|
|
8
10
|
export declare function validateTransactionPlanActions(steps: readonly Step[]): void;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { UnsupportedTransactionPlanActionError } from "./error.js";
|
|
2
|
+
import { validateSignaturelessMidnightAction } from "./midnight/authorization.js";
|
|
2
3
|
/**
|
|
3
|
-
* @internal Rejects unknown action types
|
|
4
|
+
* @internal Rejects unknown action types, and Midnight steps carrying a signature-request map,
|
|
5
|
+
* before interpreting requests or updates.
|
|
4
6
|
* @param steps - Steps whose action discriminators must be supported.
|
|
5
7
|
* @returns Nothing when every action type is supported.
|
|
6
8
|
* @throws {UnsupportedTransactionPlanActionError} when any step names an unsupported action type.
|
|
9
|
+
* @throws {InvalidTransactionPlanError} when a Midnight step carries `signatureRequestIds`, as restore does.
|
|
7
10
|
*/
|
|
8
11
|
export function validateTransactionPlanActions(steps) {
|
|
9
|
-
for (const step of steps) {
|
|
12
|
+
for (const [index, step] of steps.entries()) {
|
|
10
13
|
const actionType = step.action.type;
|
|
11
|
-
if (actionType !== "
|
|
14
|
+
if (actionType !== "midnightRedeem" &&
|
|
15
|
+
actionType !== "blueRefinance" &&
|
|
12
16
|
actionType !== "erc20Approval" &&
|
|
13
17
|
actionType !== "vaultV1Deposit" &&
|
|
14
18
|
actionType !== "vaultV1MigrateToV2" &&
|
|
@@ -20,8 +24,28 @@ export function validateTransactionPlanActions(steps) {
|
|
|
20
24
|
actionType !== "blueRepay" &&
|
|
21
25
|
actionType !== "blueWithdraw" &&
|
|
22
26
|
actionType !== "blueWithdrawCollateral" &&
|
|
27
|
+
actionType !== "blueWithdrawBuyCallback" &&
|
|
23
28
|
actionType !== "blueRepayWithdrawCollateral" &&
|
|
24
29
|
actionType !== "morphoAuthorization" &&
|
|
30
|
+
actionType !== "midnightAuthorization" &&
|
|
31
|
+
actionType !== "midnightMakeBorrow" &&
|
|
32
|
+
actionType !== "midnightMakeLend" &&
|
|
33
|
+
actionType !== "midnightMakeRepay" &&
|
|
34
|
+
actionType !== "midnightMakeWithdraw" &&
|
|
35
|
+
actionType !== "midnightSupplyBlueMakeLend" &&
|
|
36
|
+
actionType !== "midnightSupplyCollateralMakeBorrow" &&
|
|
37
|
+
actionType !== "midnightTakeBorrow" &&
|
|
38
|
+
actionType !== "midnightSupplyCollateralTakeBorrow" &&
|
|
39
|
+
actionType !== "midnightTakeLend" &&
|
|
40
|
+
actionType !== "midnightTakeRepayWithdrawCollateral" &&
|
|
41
|
+
actionType !== "midnightTakeWithdraw" &&
|
|
42
|
+
actionType !== "midnightRepayWithdrawCollateral" &&
|
|
43
|
+
actionType !== "midnightSupplyCollateral" &&
|
|
44
|
+
actionType !== "midnightSupplyCollateralWithNative" &&
|
|
45
|
+
actionType !== "midnightSupplyCollateralBatch" &&
|
|
46
|
+
actionType !== "midnightWithdrawCollateral" &&
|
|
47
|
+
actionType !== "midnightWithdrawCollateralBatch" &&
|
|
48
|
+
actionType !== "midnightCancelOffers" &&
|
|
25
49
|
actionType !== "vaultV2Deposit" &&
|
|
26
50
|
actionType !== "vaultV2Withdraw" &&
|
|
27
51
|
actionType !== "vaultV2Redeem" &&
|
|
@@ -32,5 +56,9 @@ export function validateTransactionPlanActions(steps) {
|
|
|
32
56
|
actionType !== "vaultV2InKindRedeem") {
|
|
33
57
|
throw new UnsupportedTransactionPlanActionError(actionType);
|
|
34
58
|
}
|
|
59
|
+
if (actionType.startsWith("midnight")) {
|
|
60
|
+
// Every Midnight step is signatureless: build and inspection reject the maps restore rejects.
|
|
61
|
+
validateSignaturelessMidnightAction(step.action, `$.steps[${index}].action`);
|
|
62
|
+
}
|
|
35
63
|
}
|
|
36
64
|
}
|
|
@@ -7,7 +7,7 @@ export declare function validateTransactionPlanHeader(plan: TransactionPlan): vo
|
|
|
7
7
|
/** @internal Compares an untrusted address without throwing on malformed input. */
|
|
8
8
|
export declare function matchesAddress(value: unknown, expected: Address): boolean;
|
|
9
9
|
/** @internal Scalar and collection shapes used by stored plan fields. */
|
|
10
|
-
type PlanFieldType = "string" | "address" | "hex" | "safe integer" | "positive safe integer" | "bigint" | "uint256 bigint" | "array";
|
|
10
|
+
type PlanFieldType = "string" | "address" | "hex" | "bytes32" | "boolean" | "safe integer" | "positive safe integer" | "bigint" | "uint128 bigint" | "uint256 bigint" | "array";
|
|
11
11
|
/** @internal Validates one restored field without coercing it. */
|
|
12
12
|
export declare function validatePlanField(value: unknown, options: {
|
|
13
13
|
readonly path: string;
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { isAddress, isAddressEqual, maxUint256 } from "viem";
|
|
1
|
+
import { isAddress, isAddressEqual, maxUint128, maxUint256, } from "viem";
|
|
2
2
|
import { InvalidTransactionPlanError } from "./error.js";
|
|
3
|
+
/**
|
|
4
|
+
* @internal Actions whose preparation stores `deadline = BigInt(expiresAt)`, so any other stored
|
|
5
|
+
* deadline would let the bundle execute after the expiry the plan reports.
|
|
6
|
+
*/
|
|
7
|
+
const EXPIRES_AT_DEADLINE_ACTIONS = new Set([
|
|
8
|
+
"midnightTakeLend",
|
|
9
|
+
"midnightTakeBorrow",
|
|
10
|
+
"midnightTakeWithdraw",
|
|
11
|
+
"midnightRepayWithdrawCollateral",
|
|
12
|
+
"midnightMakeBorrow",
|
|
13
|
+
"midnightMakeLend",
|
|
14
|
+
"midnightMakeWithdraw",
|
|
15
|
+
"midnightMakeRepay",
|
|
16
|
+
"midnightSupplyCollateralMakeBorrow",
|
|
17
|
+
"midnightSupplyBlueMakeLend",
|
|
18
|
+
"midnightSupplyCollateralTakeBorrow",
|
|
19
|
+
"midnightTakeRepayWithdrawCollateral",
|
|
20
|
+
"midnightSupplyCollateralWithNative",
|
|
21
|
+
]);
|
|
3
22
|
/** @internal Maximum calldata-origin length in bytes. */
|
|
4
23
|
const MAX_CALLDATA_ORIGIN_BYTES = 1024 * 1024;
|
|
5
24
|
/** @internal Rejects attribution bytes above the preparation and stored-plan limit. */
|
|
@@ -61,6 +80,13 @@ export function validateTransactionPlanHeader(plan) {
|
|
|
61
80
|
reason: "expected a deadline no earlier than expiresAt",
|
|
62
81
|
});
|
|
63
82
|
}
|
|
83
|
+
if (EXPIRES_AT_DEADLINE_ACTIONS.has(step.action.type) &&
|
|
84
|
+
(!("deadline" in inputs) || inputs.deadline !== BigInt(plan.expiresAt))) {
|
|
85
|
+
throw new InvalidTransactionPlanError({
|
|
86
|
+
path: `${path}.action.inputs.deadline`,
|
|
87
|
+
reason: "expected the plan expiresAt",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
64
90
|
}
|
|
65
91
|
const requestIds = new Set();
|
|
66
92
|
for (const [index, request] of plan.signatureRequests.entries()) {
|
|
@@ -102,6 +128,12 @@ export function validatePlanField(value, options) {
|
|
|
102
128
|
valid =
|
|
103
129
|
typeof value === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(value);
|
|
104
130
|
break;
|
|
131
|
+
case "bytes32":
|
|
132
|
+
valid = typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
133
|
+
break;
|
|
134
|
+
case "boolean":
|
|
135
|
+
valid = typeof value === "boolean";
|
|
136
|
+
break;
|
|
105
137
|
case "safe integer":
|
|
106
138
|
valid = typeof value === "number" && Number.isSafeInteger(value);
|
|
107
139
|
break;
|
|
@@ -112,8 +144,12 @@ export function validatePlanField(value, options) {
|
|
|
112
144
|
case "bigint":
|
|
113
145
|
valid = typeof value === "bigint";
|
|
114
146
|
break;
|
|
147
|
+
case "uint128 bigint":
|
|
115
148
|
case "uint256 bigint":
|
|
116
|
-
valid =
|
|
149
|
+
valid =
|
|
150
|
+
typeof value === "bigint" &&
|
|
151
|
+
value >= 0n &&
|
|
152
|
+
value <= (type === "uint128 bigint" ? maxUint128 : maxUint256);
|
|
117
153
|
break;
|
|
118
154
|
case "array":
|
|
119
155
|
valid = Array.isArray(value);
|
package/lib/esm/types/error.d.ts
CHANGED
|
@@ -1683,6 +1683,8 @@ export declare class MidnightCalldataEncodingError extends Error {
|
|
|
1683
1683
|
* pulled with native funding, or the token checked by
|
|
1684
1684
|
* `getMidnightApprovalRequirements`). `"blueMarket"` reports the Blue market encoding in
|
|
1685
1685
|
* `supplyBlueMakeLend`: a malformed address or an out-of-range `lltv`.
|
|
1686
|
+
* TransactionPlan take preparers report a malformed taken offer field by its path, such as
|
|
1687
|
+
* `"takeableOffers[i].offer.maker"` or `"takeableOffers[i].units"`.
|
|
1686
1688
|
* @param cause - viem encoding error.
|
|
1687
1689
|
*/
|
|
1688
1690
|
constructor(input: string, cause: BaseError);
|
package/lib/esm/types/error.js
CHANGED
|
@@ -2030,6 +2030,8 @@ export class MidnightCalldataEncodingError extends Error {
|
|
|
2030
2030
|
* pulled with native funding, or the token checked by
|
|
2031
2031
|
* `getMidnightApprovalRequirements`). `"blueMarket"` reports the Blue market encoding in
|
|
2032
2032
|
* `supplyBlueMakeLend`: a malformed address or an out-of-range `lltv`.
|
|
2033
|
+
* TransactionPlan take preparers report a malformed taken offer field by its path, such as
|
|
2034
|
+
* `"takeableOffers[i].offer.maker"` or `"takeableOffers[i].units"`.
|
|
2033
2035
|
* @param cause - viem encoding error.
|
|
2034
2036
|
*/
|
|
2035
2037
|
constructor(input, cause) {
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Installed @morpho-org/morpho-sdk package version. */
|
|
2
|
-
export declare const version = "10.
|
|
2
|
+
export declare const version = "10.4.0";
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/morpho-sdk",
|
|
3
3
|
"description": "Abstraction layer for Morpho's complexity.",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.4.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -162,10 +162,10 @@
|
|
|
162
162
|
"test": "vitest --root ../.. --project morpho-sdk --project morpho-sdk-fork"
|
|
163
163
|
},
|
|
164
164
|
"dependencies": {
|
|
165
|
-
"@morpho-org/blue-sdk": "^8.4.
|
|
165
|
+
"@morpho-org/blue-sdk": "^8.4.1",
|
|
166
166
|
"@morpho-org/blue-sdk-viem": "^7.6.0",
|
|
167
|
-
"@morpho-org/midnight-sdk": "^2.
|
|
168
|
-
"@morpho-org/morpho-ts": "^4.5.
|
|
167
|
+
"@morpho-org/midnight-sdk": "^2.10.0",
|
|
168
|
+
"@morpho-org/morpho-ts": "^4.5.1",
|
|
169
169
|
"@noble/curves": "1.9.1"
|
|
170
170
|
},
|
|
171
171
|
"peerDependencies": {
|