@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.
Files changed (188) hide show
  1. package/README.md +172 -8
  2. package/lib/cjs/actions/midnight/redeem.d.ts +20 -3
  3. package/lib/cjs/actions/midnight/redeem.js +58 -1
  4. package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
  5. package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +41 -0
  6. package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -2
  7. package/lib/cjs/actions/midnight/withdrawCollateral.js +26 -1
  8. package/lib/cjs/helpers/callback.d.ts +3 -2
  9. package/lib/cjs/helpers/callback.js +4 -20
  10. package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
  11. package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.js +30 -0
  12. package/lib/cjs/helpers/parseMidnightMaker.d.ts +21 -0
  13. package/lib/cjs/helpers/parseMidnightMaker.js +41 -1
  14. package/lib/cjs/helpers/validate.d.ts +49 -1
  15. package/lib/cjs/helpers/validate.js +87 -1
  16. package/lib/cjs/helpers/validateMidnightPublication.d.ts +10 -0
  17. package/lib/cjs/helpers/validateMidnightPublication.js +18 -1
  18. package/lib/cjs/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
  19. package/lib/cjs/helpers/validateMidnightTakeableOfferFields.js +85 -0
  20. package/lib/cjs/index.d.ts +2 -2
  21. package/lib/cjs/index.js +23 -1
  22. package/lib/cjs/midnight/utils.d.ts +1 -1
  23. package/lib/cjs/midnight/utils.js +2 -1
  24. package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
  25. package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.js +264 -0
  26. package/lib/cjs/transactionPlan/error.d.ts +27 -0
  27. package/lib/cjs/transactionPlan/error.js +30 -1
  28. package/lib/cjs/transactionPlan/index.d.ts +40 -1
  29. package/lib/cjs/transactionPlan/index.js +46 -5
  30. package/lib/cjs/transactionPlan/midnight/authorization.d.ts +15 -0
  31. package/lib/cjs/transactionPlan/midnight/authorization.js +45 -0
  32. package/lib/cjs/transactionPlan/midnight/cancelOffers.d.ts +80 -0
  33. package/lib/cjs/transactionPlan/midnight/cancelOffers.js +125 -0
  34. package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +104 -0
  35. package/lib/cjs/transactionPlan/midnight/makeBorrow.js +126 -0
  36. package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +140 -0
  37. package/lib/cjs/transactionPlan/midnight/makeLend.js +176 -0
  38. package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +118 -0
  39. package/lib/cjs/transactionPlan/midnight/makeRepay.js +118 -0
  40. package/lib/cjs/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
  41. package/lib/cjs/transactionPlan/midnight/makeWithdraw.js +126 -0
  42. package/lib/cjs/transactionPlan/midnight/makerPublication.d.ts +55 -0
  43. package/lib/cjs/transactionPlan/midnight/makerPublication.js +315 -0
  44. package/lib/cjs/transactionPlan/midnight/market.d.ts +49 -0
  45. package/lib/cjs/transactionPlan/midnight/market.js +120 -0
  46. package/lib/cjs/transactionPlan/midnight/prepare.d.ts +244 -0
  47. package/lib/cjs/transactionPlan/midnight/prepare.js +547 -0
  48. package/lib/cjs/transactionPlan/midnight/publicationState.d.ts +24 -0
  49. package/lib/cjs/transactionPlan/midnight/publicationState.js +50 -0
  50. package/lib/cjs/transactionPlan/midnight/redeem.d.ts +102 -0
  51. package/lib/cjs/transactionPlan/midnight/redeem.js +170 -0
  52. package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
  53. package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.js +51 -0
  54. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
  55. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +328 -0
  56. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
  57. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +199 -0
  58. package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
  59. package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +190 -0
  60. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
  61. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +221 -0
  62. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
  63. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +179 -0
  64. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
  65. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +259 -0
  66. package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +304 -0
  67. package/lib/cjs/transactionPlan/midnight/takeBorrow.js +545 -0
  68. package/lib/cjs/transactionPlan/midnight/takeLend.d.ts +99 -0
  69. package/lib/cjs/transactionPlan/midnight/takeLend.js +263 -0
  70. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
  71. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +440 -0
  72. package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
  73. package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +240 -0
  74. package/lib/cjs/transactionPlan/midnight/validation.d.ts +22 -0
  75. package/lib/cjs/transactionPlan/midnight/validation.js +158 -0
  76. package/lib/cjs/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
  77. package/lib/cjs/transactionPlan/midnight/withdrawCollateral.js +228 -0
  78. package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
  79. package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.js +232 -0
  80. package/lib/cjs/transactionPlan/plan.d.ts +48 -14
  81. package/lib/cjs/transactionPlan/plan.js +103 -18
  82. package/lib/cjs/transactionPlan/requirements.d.ts +7 -4
  83. package/lib/cjs/transactionPlan/requirements.js +2 -2
  84. package/lib/cjs/transactionPlan/serde.d.ts +13 -2
  85. package/lib/cjs/transactionPlan/serde.js +68 -21
  86. package/lib/cjs/transactionPlan/types.d.ts +147 -0
  87. package/lib/cjs/transactionPlan/validateActions.d.ts +3 -1
  88. package/lib/cjs/transactionPlan/validateActions.js +31 -3
  89. package/lib/cjs/transactionPlan/validation.d.ts +1 -1
  90. package/lib/cjs/transactionPlan/validation.js +37 -1
  91. package/lib/cjs/types/error.d.ts +2 -0
  92. package/lib/cjs/types/error.js +2 -0
  93. package/lib/cjs/version.d.ts +1 -1
  94. package/lib/cjs/version.js +1 -1
  95. package/lib/esm/actions/midnight/redeem.d.ts +20 -3
  96. package/lib/esm/actions/midnight/redeem.js +56 -0
  97. package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
  98. package/lib/esm/actions/midnight/supplyCollateralWithNative.js +40 -0
  99. package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -2
  100. package/lib/esm/actions/midnight/withdrawCollateral.js +25 -1
  101. package/lib/esm/helpers/callback.d.ts +3 -2
  102. package/lib/esm/helpers/callback.js +5 -21
  103. package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
  104. package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.js +27 -0
  105. package/lib/esm/helpers/parseMidnightMaker.d.ts +21 -0
  106. package/lib/esm/helpers/parseMidnightMaker.js +40 -1
  107. package/lib/esm/helpers/validate.d.ts +49 -1
  108. package/lib/esm/helpers/validate.js +84 -1
  109. package/lib/esm/helpers/validateMidnightPublication.d.ts +10 -0
  110. package/lib/esm/helpers/validateMidnightPublication.js +16 -0
  111. package/lib/esm/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
  112. package/lib/esm/helpers/validateMidnightTakeableOfferFields.js +81 -0
  113. package/lib/esm/index.d.ts +2 -2
  114. package/lib/esm/index.js +1 -1
  115. package/lib/esm/midnight/utils.d.ts +1 -1
  116. package/lib/esm/midnight/utils.js +1 -1
  117. package/lib/esm/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
  118. package/lib/esm/transactionPlan/blue/withdrawBuyCallback.js +259 -0
  119. package/lib/esm/transactionPlan/error.d.ts +27 -0
  120. package/lib/esm/transactionPlan/error.js +28 -0
  121. package/lib/esm/transactionPlan/index.d.ts +40 -1
  122. package/lib/esm/transactionPlan/index.js +20 -1
  123. package/lib/esm/transactionPlan/midnight/authorization.d.ts +15 -0
  124. package/lib/esm/transactionPlan/midnight/authorization.js +40 -0
  125. package/lib/esm/transactionPlan/midnight/cancelOffers.d.ts +80 -0
  126. package/lib/esm/transactionPlan/midnight/cancelOffers.js +120 -0
  127. package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +104 -0
  128. package/lib/esm/transactionPlan/midnight/makeBorrow.js +123 -0
  129. package/lib/esm/transactionPlan/midnight/makeLend.d.ts +140 -0
  130. package/lib/esm/transactionPlan/midnight/makeLend.js +172 -0
  131. package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +118 -0
  132. package/lib/esm/transactionPlan/midnight/makeRepay.js +115 -0
  133. package/lib/esm/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
  134. package/lib/esm/transactionPlan/midnight/makeWithdraw.js +123 -0
  135. package/lib/esm/transactionPlan/midnight/makerPublication.d.ts +55 -0
  136. package/lib/esm/transactionPlan/midnight/makerPublication.js +310 -0
  137. package/lib/esm/transactionPlan/midnight/market.d.ts +49 -0
  138. package/lib/esm/transactionPlan/midnight/market.js +112 -0
  139. package/lib/esm/transactionPlan/midnight/prepare.d.ts +244 -0
  140. package/lib/esm/transactionPlan/midnight/prepare.js +536 -0
  141. package/lib/esm/transactionPlan/midnight/publicationState.d.ts +24 -0
  142. package/lib/esm/transactionPlan/midnight/publicationState.js +47 -0
  143. package/lib/esm/transactionPlan/midnight/redeem.d.ts +102 -0
  144. package/lib/esm/transactionPlan/midnight/redeem.js +165 -0
  145. package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
  146. package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.js +47 -0
  147. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
  148. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +323 -0
  149. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
  150. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +196 -0
  151. package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
  152. package/lib/esm/transactionPlan/midnight/supplyCollateral.js +185 -0
  153. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
  154. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +216 -0
  155. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
  156. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +176 -0
  157. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
  158. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +254 -0
  159. package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +304 -0
  160. package/lib/esm/transactionPlan/midnight/takeBorrow.js +539 -0
  161. package/lib/esm/transactionPlan/midnight/takeLend.d.ts +99 -0
  162. package/lib/esm/transactionPlan/midnight/takeLend.js +258 -0
  163. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
  164. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +435 -0
  165. package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
  166. package/lib/esm/transactionPlan/midnight/takeWithdraw.js +236 -0
  167. package/lib/esm/transactionPlan/midnight/validation.d.ts +22 -0
  168. package/lib/esm/transactionPlan/midnight/validation.js +151 -0
  169. package/lib/esm/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
  170. package/lib/esm/transactionPlan/midnight/withdrawCollateral.js +223 -0
  171. package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
  172. package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.js +227 -0
  173. package/lib/esm/transactionPlan/plan.d.ts +48 -14
  174. package/lib/esm/transactionPlan/plan.js +99 -14
  175. package/lib/esm/transactionPlan/requirements.d.ts +7 -4
  176. package/lib/esm/transactionPlan/requirements.js +2 -2
  177. package/lib/esm/transactionPlan/serde.d.ts +13 -2
  178. package/lib/esm/transactionPlan/serde.js +49 -2
  179. package/lib/esm/transactionPlan/types.d.ts +147 -0
  180. package/lib/esm/transactionPlan/validateActions.d.ts +3 -1
  181. package/lib/esm/transactionPlan/validateActions.js +31 -3
  182. package/lib/esm/transactionPlan/validation.d.ts +1 -1
  183. package/lib/esm/transactionPlan/validation.js +38 -2
  184. package/lib/esm/types/error.d.ts +2 -0
  185. package/lib/esm/types/error.js +2 -0
  186. package/lib/esm/version.d.ts +1 -1
  187. package/lib/esm/version.js +1 -1
  188. 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 before interpreting requests or updates.
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 before interpreting requests or updates.
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 !== "blueRefinance" &&
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 = typeof value === "bigint" && value >= 0n && value <= maxUint256;
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);
@@ -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);
@@ -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) {
@@ -1,2 +1,2 @@
1
1
  /** Installed @morpho-org/morpho-sdk package version. */
2
- export declare const version = "10.3.0";
2
+ export declare const version = "10.4.0";
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/generate-package-versions.ts. Do not edit.
2
2
  /** Installed @morpho-org/morpho-sdk package version. */
3
- export const version = "10.3.0";
3
+ export const version = "10.4.0";
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.3.0",
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.0",
165
+ "@morpho-org/blue-sdk": "^8.4.1",
166
166
  "@morpho-org/blue-sdk-viem": "^7.6.0",
167
- "@morpho-org/midnight-sdk": "^2.9.0",
168
- "@morpho-org/morpho-ts": "^4.5.0",
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": {