@morpho-org/morpho-sdk 5.2.0 → 5.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.
- package/README.md +46 -2
- package/lib/cjs/abis.d.ts +1 -0
- package/lib/cjs/abis.js +6 -1
- package/lib/cjs/actions/blue/borrow.d.ts +3 -7
- package/lib/cjs/actions/blue/borrow.js +5 -9
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +3 -4
- package/lib/cjs/actions/blue/buildReallocationActions.js +3 -4
- package/lib/cjs/actions/blue/refinance.d.ts +4 -8
- package/lib/cjs/actions/blue/refinance.js +10 -14
- package/lib/cjs/actions/blue/repay.d.ts +2 -5
- package/lib/cjs/actions/blue/repay.js +2 -5
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -6
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +4 -7
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +2 -5
- package/lib/cjs/actions/blue/resolveRepayFunding.js +15 -12
- package/lib/cjs/actions/blue/supply.d.ts +2 -4
- package/lib/cjs/actions/blue/supply.js +6 -8
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -3
- package/lib/cjs/actions/blue/supplyCollateral.js +5 -6
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +4 -9
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +9 -14
- package/lib/cjs/actions/blue/withdraw.d.ts +9 -7
- package/lib/cjs/actions/blue/withdraw.js +18 -10
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
- package/lib/cjs/actions/index.d.ts +2 -0
- package/lib/cjs/actions/index.js +1 -0
- package/lib/cjs/actions/midnight/authorization.d.ts +37 -0
- package/lib/cjs/actions/midnight/authorization.js +69 -0
- package/lib/cjs/actions/midnight/cancelOffer.d.ts +38 -0
- package/lib/cjs/actions/midnight/cancelOffer.js +73 -0
- package/lib/cjs/actions/midnight/index.d.ts +11 -0
- package/lib/cjs/actions/midnight/index.js +27 -0
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +52 -0
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +72 -0
- package/lib/cjs/actions/midnight/redeem.d.ts +43 -0
- package/lib/cjs/actions/midnight/redeem.js +79 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +53 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +121 -0
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +40 -0
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +59 -0
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +45 -0
- package/lib/cjs/actions/midnight/supplyCollateral.js +83 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +51 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -0
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +57 -0
- package/lib/cjs/actions/midnight/takeBorrow.js +110 -0
- package/lib/cjs/actions/midnight/takeLend.d.ts +57 -0
- package/lib/cjs/actions/midnight/takeLend.js +110 -0
- package/lib/cjs/actions/midnight/types.d.ts +39 -0
- package/lib/cjs/actions/midnight/types.js +15 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +5 -16
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +5 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +10 -14
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +2 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +11 -28
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +5 -17
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +10 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +10 -4
- package/lib/cjs/actions/requirements/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/index.js +1 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +49 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +76 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +44 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +78 -0
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +42 -0
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +70 -0
- package/lib/cjs/actions/requirements/midnight/index.d.ts +3 -0
- package/lib/cjs/actions/requirements/midnight/index.js +19 -0
- package/lib/cjs/actions/vaultV1/deposit.d.ts +3 -4
- package/lib/cjs/actions/vaultV1/deposit.js +7 -8
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +2 -3
- package/lib/cjs/actions/vaultV1/migrateToV2.js +5 -6
- package/lib/cjs/actions/vaultV1/redeem.d.ts +1 -1
- package/lib/cjs/actions/vaultV1/redeem.js +2 -2
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV1/withdraw.js +2 -2
- package/lib/cjs/actions/vaultV2/deposit.d.ts +3 -4
- package/lib/cjs/actions/vaultV2/deposit.js +7 -8
- package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +2 -3
- package/lib/cjs/actions/vaultV2/forceRedeem.js +3 -4
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +2 -2
- package/lib/cjs/actions/vaultV2/redeem.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/redeem.js +2 -2
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/withdraw.js +2 -2
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +5 -2
- package/lib/cjs/constants.d.ts +1 -0
- package/lib/cjs/constants.js +15 -1
- package/lib/cjs/entities/blue/blue.d.ts +5 -5
- package/lib/cjs/entities/blue/blue.js +93 -68
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/index.d.ts +2 -0
- package/lib/cjs/entities/midnight/index.js +18 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +402 -0
- package/lib/cjs/entities/midnight/midnight.js +1036 -0
- package/lib/cjs/entities/midnight/types.d.ts +164 -0
- package/lib/cjs/entities/midnight/types.js +2 -0
- package/lib/cjs/entities/vaultV1/vaultV1.js +10 -17
- package/lib/cjs/entities/vaultV2/vaultV2.js +19 -21
- package/lib/cjs/errors.d.ts +1 -0
- package/lib/cjs/errors.js +17 -1
- package/lib/cjs/helpers/encodeDeallocation.d.ts +1 -0
- package/lib/cjs/helpers/encodeDeallocation.js +2 -1
- package/lib/cjs/helpers/index.d.ts +4 -1
- package/lib/cjs/helpers/index.js +8 -1
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +34 -0
- package/lib/cjs/helpers/signAndVerifyTypedData.js +58 -0
- package/lib/cjs/helpers/validate.d.ts +40 -1
- package/lib/cjs/helpers/validate.js +47 -5
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +15 -0
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +32 -0
- package/lib/cjs/helpers/validateMidnightMarket.d.ts +10 -0
- package/lib/cjs/helpers/validateMidnightMarket.js +24 -0
- package/lib/cjs/helpers/validateOfferSides.d.ts +21 -0
- package/lib/cjs/helpers/validateOfferSides.js +36 -0
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +29 -0
- package/lib/cjs/helpers/validateRequirementSpender.js +49 -0
- package/lib/cjs/helpers/validateTakeableOffers.d.ts +18 -0
- package/lib/cjs/helpers/validateTakeableOffers.js +35 -0
- package/lib/cjs/midnight-api.d.ts +1 -0
- package/lib/cjs/midnight-api.js +17 -0
- package/lib/cjs/types/action.d.ts +189 -23
- package/lib/cjs/types/action.js +27 -7
- package/lib/cjs/types/client.d.ts +3 -2
- package/lib/cjs/types/error.d.ts +288 -119
- package/lib/cjs/types/error.js +259 -180
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +12 -2
- package/lib/esm/abis.d.ts +1 -0
- package/lib/esm/abis.js +1 -0
- package/lib/esm/actions/blue/borrow.d.ts +3 -7
- package/lib/esm/actions/blue/borrow.js +6 -10
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +3 -4
- package/lib/esm/actions/blue/buildReallocationActions.js +3 -4
- package/lib/esm/actions/blue/refinance.d.ts +4 -8
- package/lib/esm/actions/blue/refinance.js +11 -15
- package/lib/esm/actions/blue/repay.d.ts +2 -5
- package/lib/esm/actions/blue/repay.js +2 -5
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -6
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +5 -8
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +2 -5
- package/lib/esm/actions/blue/resolveRepayFunding.js +16 -13
- package/lib/esm/actions/blue/supply.d.ts +2 -4
- package/lib/esm/actions/blue/supply.js +7 -9
- package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -3
- package/lib/esm/actions/blue/supplyCollateral.js +6 -7
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +4 -9
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +10 -15
- package/lib/esm/actions/blue/withdraw.d.ts +9 -7
- package/lib/esm/actions/blue/withdraw.js +19 -11
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.js +3 -3
- package/lib/esm/actions/index.d.ts +2 -0
- package/lib/esm/actions/index.js +1 -0
- package/lib/esm/actions/midnight/authorization.d.ts +37 -0
- package/lib/esm/actions/midnight/authorization.js +65 -0
- package/lib/esm/actions/midnight/cancelOffer.d.ts +38 -0
- package/lib/esm/actions/midnight/cancelOffer.js +69 -0
- package/lib/esm/actions/midnight/index.d.ts +11 -0
- package/lib/esm/actions/midnight/index.js +11 -0
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +52 -0
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +68 -0
- package/lib/esm/actions/midnight/redeem.d.ts +43 -0
- package/lib/esm/actions/midnight/redeem.js +75 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +53 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +117 -0
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +40 -0
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +55 -0
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +45 -0
- package/lib/esm/actions/midnight/supplyCollateral.js +79 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +51 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +124 -0
- package/lib/esm/actions/midnight/takeBorrow.d.ts +57 -0
- package/lib/esm/actions/midnight/takeBorrow.js +106 -0
- package/lib/esm/actions/midnight/takeLend.d.ts +57 -0
- package/lib/esm/actions/midnight/takeLend.js +106 -0
- package/lib/esm/actions/midnight/types.d.ts +39 -0
- package/lib/esm/actions/midnight/types.js +12 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +6 -17
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +5 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +12 -16
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +2 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +12 -29
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +5 -17
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +10 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +10 -4
- package/lib/esm/actions/requirements/index.d.ts +1 -0
- package/lib/esm/actions/requirements/index.js +1 -0
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +49 -0
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +72 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +44 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +74 -0
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +42 -0
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +66 -0
- package/lib/esm/actions/requirements/midnight/index.d.ts +3 -0
- package/lib/esm/actions/requirements/midnight/index.js +3 -0
- package/lib/esm/actions/vaultV1/deposit.d.ts +3 -4
- package/lib/esm/actions/vaultV1/deposit.js +8 -9
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +2 -3
- package/lib/esm/actions/vaultV1/migrateToV2.js +6 -7
- package/lib/esm/actions/vaultV1/redeem.d.ts +1 -1
- package/lib/esm/actions/vaultV1/redeem.js +3 -3
- package/lib/esm/actions/vaultV1/withdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV1/withdraw.js +3 -3
- package/lib/esm/actions/vaultV2/deposit.d.ts +3 -4
- package/lib/esm/actions/vaultV2/deposit.js +8 -9
- package/lib/esm/actions/vaultV2/forceRedeem.d.ts +2 -3
- package/lib/esm/actions/vaultV2/forceRedeem.js +4 -5
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
- package/lib/esm/actions/vaultV2/redeem.d.ts +1 -1
- package/lib/esm/actions/vaultV2/redeem.js +3 -3
- package/lib/esm/actions/vaultV2/withdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/withdraw.js +3 -3
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +6 -3
- package/lib/esm/constants.d.ts +1 -0
- package/lib/esm/constants.js +1 -0
- package/lib/esm/entities/blue/blue.d.ts +5 -5
- package/lib/esm/entities/blue/blue.js +95 -70
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/index.d.ts +2 -0
- package/lib/esm/entities/midnight/index.js +2 -0
- package/lib/esm/entities/midnight/midnight.d.ts +402 -0
- package/lib/esm/entities/midnight/midnight.js +1032 -0
- package/lib/esm/entities/midnight/types.d.ts +164 -0
- package/lib/esm/entities/midnight/types.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.js +13 -20
- package/lib/esm/entities/vaultV2/vaultV2.js +9 -11
- package/lib/esm/errors.d.ts +1 -0
- package/lib/esm/errors.js +1 -0
- package/lib/esm/helpers/encodeDeallocation.d.ts +1 -0
- package/lib/esm/helpers/encodeDeallocation.js +3 -2
- package/lib/esm/helpers/index.d.ts +4 -1
- package/lib/esm/helpers/index.js +4 -1
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +34 -0
- package/lib/esm/helpers/signAndVerifyTypedData.js +54 -0
- package/lib/esm/helpers/validate.d.ts +40 -1
- package/lib/esm/helpers/validate.js +46 -5
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +15 -0
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +28 -0
- package/lib/esm/helpers/validateMidnightMarket.d.ts +10 -0
- package/lib/esm/helpers/validateMidnightMarket.js +20 -0
- package/lib/esm/helpers/validateOfferSides.d.ts +21 -0
- package/lib/esm/helpers/validateOfferSides.js +32 -0
- package/lib/esm/helpers/validateRequirementSpender.d.ts +29 -0
- package/lib/esm/helpers/validateRequirementSpender.js +45 -0
- package/lib/esm/helpers/validateTakeableOffers.d.ts +18 -0
- package/lib/esm/helpers/validateTakeableOffers.js +31 -0
- package/lib/esm/midnight-api.d.ts +1 -0
- package/lib/esm/midnight-api.js +1 -0
- package/lib/esm/types/action.d.ts +189 -23
- package/lib/esm/types/action.js +26 -7
- package/lib/esm/types/client.d.ts +3 -2
- package/lib/esm/types/error.d.ts +288 -119
- package/lib/esm/types/error.js +232 -154
- package/lib/esm/utils.d.ts +1 -0
- package/lib/esm/utils.js +1 -0
- package/package.json +12 -3
|
@@ -234,7 +234,99 @@ export interface BlueAuthorizationAction extends BaseAction<"blueAuthorization",
|
|
|
234
234
|
isAuthorized: boolean;
|
|
235
235
|
}> {
|
|
236
236
|
}
|
|
237
|
-
|
|
237
|
+
/** Metadata for a Midnight authorization prerequisite transaction. */
|
|
238
|
+
export interface MidnightAuthorizationAction extends BaseAction<"midnightAuthorization", {
|
|
239
|
+
readonly authorized: Address;
|
|
240
|
+
readonly isAuthorized: boolean;
|
|
241
|
+
readonly onBehalf: Address;
|
|
242
|
+
}> {
|
|
243
|
+
}
|
|
244
|
+
/** Metadata for a SetterRatifier ratify-root prerequisite transaction. */
|
|
245
|
+
export interface SetterRatifierRatifyRootAction extends BaseAction<"setterRatifierRatifyRoot", {
|
|
246
|
+
readonly maker: Address;
|
|
247
|
+
readonly root: Hex;
|
|
248
|
+
readonly isRootRatified: boolean;
|
|
249
|
+
}> {
|
|
250
|
+
}
|
|
251
|
+
/** Metadata for a Midnight bundle that lends into fixed-rate offers. */
|
|
252
|
+
export interface MidnightTakeLendAction extends BaseAction<"midnightTakeLend", {
|
|
253
|
+
readonly market: Hex;
|
|
254
|
+
readonly assets: bigint;
|
|
255
|
+
readonly minUnits: bigint;
|
|
256
|
+
readonly taker: Address;
|
|
257
|
+
readonly takeableOffers: number;
|
|
258
|
+
readonly deadline: bigint;
|
|
259
|
+
}> {
|
|
260
|
+
}
|
|
261
|
+
/** Metadata for a Midnight bundle that borrows from fixed-rate offers. */
|
|
262
|
+
export interface MidnightTakeBorrowAction extends BaseAction<"midnightTakeBorrow", {
|
|
263
|
+
readonly market: Hex;
|
|
264
|
+
readonly loanAssets: bigint;
|
|
265
|
+
readonly maxUnits: bigint;
|
|
266
|
+
readonly taker: Address;
|
|
267
|
+
readonly receiver: Address;
|
|
268
|
+
readonly collateralSupplies: number;
|
|
269
|
+
readonly takeableOffers: number;
|
|
270
|
+
readonly deadline: bigint;
|
|
271
|
+
}> {
|
|
272
|
+
}
|
|
273
|
+
/** Metadata for a Midnight bundle that supplies collateral and borrows from fixed-rate offers. */
|
|
274
|
+
export interface MidnightSupplyCollateralTakeBorrowAction extends BaseAction<"midnightSupplyCollateralTakeBorrow", {
|
|
275
|
+
readonly market: Hex;
|
|
276
|
+
readonly collateralAssets: bigint;
|
|
277
|
+
readonly loanAssets: bigint;
|
|
278
|
+
readonly maxUnits: bigint;
|
|
279
|
+
readonly taker: Address;
|
|
280
|
+
readonly receiver: Address;
|
|
281
|
+
readonly collateralSupplies: number;
|
|
282
|
+
readonly takeableOffers: number;
|
|
283
|
+
readonly deadline: bigint;
|
|
284
|
+
}> {
|
|
285
|
+
}
|
|
286
|
+
/** Metadata for a direct Midnight collateral-supply transaction. */
|
|
287
|
+
export interface MidnightSupplyCollateralAction extends BaseAction<"midnightSupplyCollateral", {
|
|
288
|
+
readonly market: Hex;
|
|
289
|
+
readonly collateralIndex: bigint;
|
|
290
|
+
readonly assets: bigint;
|
|
291
|
+
readonly onBehalf: Address;
|
|
292
|
+
}> {
|
|
293
|
+
}
|
|
294
|
+
/** Metadata for a Midnight mempool payload submission. */
|
|
295
|
+
export interface MempoolSubmitOffersAction extends BaseAction<"mempoolSubmitOffers", {
|
|
296
|
+
readonly groups: readonly Hex[];
|
|
297
|
+
readonly root: Hex;
|
|
298
|
+
readonly maker: Address;
|
|
299
|
+
readonly ratifier: Address;
|
|
300
|
+
readonly ratifierType: "ecrecover" | "setter";
|
|
301
|
+
readonly offers: number;
|
|
302
|
+
}> {
|
|
303
|
+
}
|
|
304
|
+
/** Metadata for a direct Midnight credit redemption transaction. */
|
|
305
|
+
export interface MidnightRedeemAction extends BaseAction<"midnightRedeem", {
|
|
306
|
+
readonly market: Hex;
|
|
307
|
+
readonly units: bigint;
|
|
308
|
+
readonly onBehalf: Address;
|
|
309
|
+
readonly receiver: Address;
|
|
310
|
+
}> {
|
|
311
|
+
}
|
|
312
|
+
/** Metadata for a Midnight bundle that repays credit and/or withdraws collateral. */
|
|
313
|
+
export interface MidnightRepayWithdrawCollateralAction extends BaseAction<"midnightRepayWithdrawCollateral", {
|
|
314
|
+
readonly market: Hex;
|
|
315
|
+
readonly repayAssets: bigint;
|
|
316
|
+
readonly collateralWithdrawals: number;
|
|
317
|
+
readonly onBehalf: Address;
|
|
318
|
+
readonly collateralReceiver: Address;
|
|
319
|
+
readonly deadline: bigint;
|
|
320
|
+
}> {
|
|
321
|
+
}
|
|
322
|
+
/** Metadata for a direct Midnight offer-cancellation transaction. */
|
|
323
|
+
export interface MidnightCancelOfferAction extends BaseAction<"midnightCancelOffer", {
|
|
324
|
+
readonly group: Hex;
|
|
325
|
+
readonly amount: bigint;
|
|
326
|
+
readonly onBehalf: Address;
|
|
327
|
+
}> {
|
|
328
|
+
}
|
|
329
|
+
export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueWithdrawAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | SetterRatifierRatifyRootAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MempoolSubmitOffersAction | MidnightRedeemAction | MidnightRepayWithdrawCollateralAction | MidnightCancelOfferAction;
|
|
238
330
|
export interface Transaction<TAction extends BaseAction = TransactionAction> {
|
|
239
331
|
readonly to: Address;
|
|
240
332
|
readonly value: bigint;
|
|
@@ -291,17 +383,12 @@ export interface AuthorizationSignatureArgs {
|
|
|
291
383
|
/** EIP-712 signature over the Morpho `Authorization` typed data. */
|
|
292
384
|
signature: Hex;
|
|
293
385
|
}
|
|
294
|
-
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
* {@link AuthorizationRequirementSignature}; the default keeps the broad union for mixed arrays.
|
|
301
|
-
*/
|
|
302
|
-
export interface Requirement<TSignature extends RequirementSignature = RequirementSignature> {
|
|
303
|
-
sign: (client: WalletClient, userAddress: Address) => Promise<TSignature>;
|
|
304
|
-
action: TSignature["action"];
|
|
386
|
+
/** Signed and encoded Ecrecover offer-root payload used by Midnight maker flows. */
|
|
387
|
+
export interface MidnightOfferRootSignatureArgs {
|
|
388
|
+
readonly owner: Address;
|
|
389
|
+
readonly root: Hex;
|
|
390
|
+
readonly signature: Hex;
|
|
391
|
+
readonly payload: Hex;
|
|
305
392
|
}
|
|
306
393
|
export interface PermitAction extends BaseAction<"permit", {
|
|
307
394
|
spender: Address;
|
|
@@ -326,6 +413,17 @@ export interface AuthorizationAction extends BaseAction<"authorization", {
|
|
|
326
413
|
deadline: bigint;
|
|
327
414
|
}> {
|
|
328
415
|
}
|
|
416
|
+
/** Metadata for a Midnight offer-root signature request. */
|
|
417
|
+
export interface MidnightOfferRootSignatureAction extends BaseAction<"midnightOfferRootSignature", {
|
|
418
|
+
readonly root: Hex;
|
|
419
|
+
readonly ratifier: Address;
|
|
420
|
+
readonly offers: number;
|
|
421
|
+
}> {
|
|
422
|
+
}
|
|
423
|
+
/** Action metadata supported by signature requirements. */
|
|
424
|
+
export type SignatureRequirementAction = PermitAction | Permit2Action | AuthorizationAction | MidnightOfferRootSignatureAction;
|
|
425
|
+
/** Argument payloads returned by signature requirements. */
|
|
426
|
+
export type RequirementSignatureArgs = PermitArgs | Permit2Args | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
|
|
329
427
|
/** A signed ERC-2612 permit or Permit2 approval requirement. */
|
|
330
428
|
export interface PermitRequirementSignature {
|
|
331
429
|
args: PermitArgs | Permit2Args;
|
|
@@ -336,18 +434,74 @@ export interface AuthorizationRequirementSignature {
|
|
|
336
434
|
args: AuthorizationSignatureArgs;
|
|
337
435
|
action: AuthorizationAction;
|
|
338
436
|
}
|
|
437
|
+
/** A signed Midnight Ecrecover offer-root requirement. */
|
|
438
|
+
export interface MidnightOfferRootSignature {
|
|
439
|
+
readonly args: MidnightOfferRootSignatureArgs;
|
|
440
|
+
readonly action: MidnightOfferRootSignatureAction;
|
|
441
|
+
}
|
|
339
442
|
/**
|
|
340
443
|
* The deep-frozen output of `Requirement.sign()`. Discriminated on `action.type`:
|
|
341
|
-
* `"permit"` / `"permit2"` carry token-approval args, `"authorization"` carries the
|
|
342
|
-
* Morpho authorization
|
|
444
|
+
* `"permit"` / `"permit2"` carry Bundler3 token-approval args, `"authorization"` carries the
|
|
445
|
+
* signed Morpho authorization, and Midnight adds `"midnightOfferRootSignature"`.
|
|
343
446
|
*/
|
|
344
|
-
export type RequirementSignature =
|
|
447
|
+
export type RequirementSignature<TAction extends SignatureRequirementAction | undefined = undefined, TArgs extends RequirementSignatureArgs | undefined = undefined> = TAction extends SignatureRequirementAction ? TArgs extends RequirementSignatureArgs ? {
|
|
448
|
+
args: TArgs;
|
|
449
|
+
action: TAction;
|
|
450
|
+
} : never : PermitRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
|
|
451
|
+
type RequirementResult<TSignatureOrAction extends RequirementSignature | SignatureRequirementAction, TArgs extends RequirementSignatureArgs | undefined> = TSignatureOrAction extends SignatureRequirementAction ? RequirementSignature<TSignatureOrAction, Extract<TArgs, RequirementSignatureArgs>> : Extract<TSignatureOrAction, RequirementSignature>;
|
|
452
|
+
/**
|
|
453
|
+
* A signable approval / authorization requirement. `sign()` returns the matching
|
|
454
|
+
* {@link RequirementSignature}; `action` describes the requirement without signing.
|
|
455
|
+
*
|
|
456
|
+
* Generic over the signature it produces so permit encoders narrow to
|
|
457
|
+
* {@link PermitRequirementSignature} and the authorization encoder to
|
|
458
|
+
* {@link AuthorizationRequirementSignature}; the two-parameter form is kept for
|
|
459
|
+
* Midnight action requirements that are parameterized by action and args.
|
|
460
|
+
*/
|
|
461
|
+
export interface Requirement<TSignatureOrAction extends RequirementSignature | SignatureRequirementAction = RequirementSignature, TArgs extends RequirementSignatureArgs | undefined = undefined> {
|
|
462
|
+
sign: (client: WalletClient, userAddress: Address) => Promise<RequirementResult<TSignatureOrAction, TArgs>>;
|
|
463
|
+
action: RequirementResult<TSignatureOrAction, TArgs>["action"];
|
|
464
|
+
}
|
|
345
465
|
/** Bundler3 token signature requirement. */
|
|
346
466
|
export type Bundler3TokenSignatureRequirement = Requirement<PermitRequirementSignature>;
|
|
467
|
+
/** Midnight Ecrecover offer-root signature requirement. */
|
|
468
|
+
export type MidnightOfferRootRequirement = Requirement<MidnightOfferRootSignatureAction, MidnightOfferRootSignatureArgs>;
|
|
469
|
+
/** Permit or Permit2 token signature requirement. */
|
|
470
|
+
export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement;
|
|
471
|
+
/** Bundler3 token signature result. */
|
|
472
|
+
export type Bundler3TokenRequirementSignature = PermitRequirementSignature;
|
|
473
|
+
/** Permit or Permit2 token signature result. */
|
|
474
|
+
export type TokenRequirementSignature = Bundler3TokenRequirementSignature;
|
|
475
|
+
/** Any signature result returned by an action-output signature requirement. */
|
|
476
|
+
export type AnyRequirementSignature = TokenRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
|
|
477
|
+
/** Any signature requirement returned by an entity action output. */
|
|
478
|
+
export type SignatureRequirement = TokenSignatureRequirement | MidnightOfferRootRequirement | Requirement<AuthorizationRequirementSignature>;
|
|
479
|
+
/** Call action metadata that can appear as an action prerequisite. */
|
|
480
|
+
export type CallRequirementAction = ERC20ApprovalAction | BlueAuthorizationAction | MidnightAuthorizationAction | SetterRatifierRatifyRootAction | MidnightSupplyCollateralAction;
|
|
481
|
+
/** Onchain call prerequisite returned by action-output `getRequirements()`. */
|
|
482
|
+
export type CallRequirement = Readonly<Transaction<CallRequirementAction>>;
|
|
483
|
+
/** Onchain call or signature prerequisite returned by an entity action output. */
|
|
484
|
+
export type ActionRequirement = CallRequirement | SignatureRequirement;
|
|
485
|
+
/** Optional controls used while resolving action prerequisites. */
|
|
486
|
+
interface ActionRequirementsParams {
|
|
487
|
+
/**
|
|
488
|
+
* Prefer the ERC-2612 simple-permit path when the SDK detects support.
|
|
489
|
+
* Leave unset or set to `false` to force the Permit2/classic approval fallback when
|
|
490
|
+
* a token is known to be incompatible despite passing the SDK's shallow nonce probe.
|
|
491
|
+
*/
|
|
492
|
+
readonly useSimplePermit?: boolean;
|
|
493
|
+
}
|
|
494
|
+
/** Lazy entity result exposing prerequisite resolution and synchronous transaction building. */
|
|
495
|
+
export interface ActionOutput<TAction extends BaseAction = TransactionAction, TSignatures = RequirementSignature, TRequirementsParams = ActionRequirementsParams> {
|
|
496
|
+
readonly buildTx: (signatures?: TSignatures) => Readonly<Transaction<TAction>>;
|
|
497
|
+
readonly getRequirements: (params?: TRequirementsParams) => Promise<readonly ActionRequirement[]>;
|
|
498
|
+
}
|
|
347
499
|
export declare function isRequirementApproval(requirement: unknown): requirement is Transaction<ERC20ApprovalAction>;
|
|
348
|
-
/** Checks whether an action requirement is a Blue authorization
|
|
500
|
+
/** Checks whether an action requirement is a Blue authorization call. */
|
|
349
501
|
export declare function isRequirementBlueAuthorization(requirement: unknown): requirement is Transaction<BlueAuthorizationAction>;
|
|
350
|
-
export declare function isRequirementSignature<T extends RequirementSignature = RequirementSignature>(requirement:
|
|
502
|
+
export declare function isRequirementSignature<T extends RequirementSignature = RequirementSignature>(requirement: CallRequirement | Requirement<T> | undefined): requirement is Requirement<T>;
|
|
503
|
+
export declare function isRequirementSignature(requirement: CallRequirement | Requirement | undefined): requirement is Requirement;
|
|
504
|
+
export declare function isRequirementSignature(requirement: ActionRequirement | undefined): requirement is SignatureRequirement;
|
|
351
505
|
/**
|
|
352
506
|
* Narrows a {@link RequirementSignature} to a permit / Permit2 token-approval signature.
|
|
353
507
|
*
|
|
@@ -362,26 +516,36 @@ export declare function isPermitSignature(signature: RequirementSignature): sign
|
|
|
362
516
|
* @returns `true` when `signature.action.type` is `"authorization"`.
|
|
363
517
|
*/
|
|
364
518
|
export declare function isAuthorizationSignature(signature: RequirementSignature): signature is AuthorizationRequirementSignature;
|
|
365
|
-
/**
|
|
519
|
+
/**
|
|
520
|
+
* Narrows a {@link RequirementSignature} to a Midnight offer-root signature.
|
|
521
|
+
*
|
|
522
|
+
* @param signature - The signed requirement to test.
|
|
523
|
+
* @returns `true` when `signature.action.type` is `"midnightOfferRootSignature"`.
|
|
524
|
+
*/
|
|
525
|
+
export declare function isMidnightOfferRootSignature(signature: RequirementSignature): signature is MidnightOfferRootSignature;
|
|
526
|
+
/** The typed requirement-signature slots a transaction builder consumes, split from a `buildTx` array. */
|
|
366
527
|
export interface SelectedRequirementSignatures {
|
|
367
528
|
/** The single permit / Permit2 signature, when present. */
|
|
368
529
|
permit?: PermitRequirementSignature;
|
|
369
530
|
/** The single Morpho authorization signature, when present. */
|
|
370
531
|
authorization?: AuthorizationRequirementSignature;
|
|
532
|
+
/** The single Midnight offer-root signature, when present. */
|
|
533
|
+
midnightOfferRoot?: MidnightOfferRootSignature;
|
|
371
534
|
}
|
|
372
535
|
/**
|
|
373
|
-
* Splits a `buildTx` signature array into its typed
|
|
536
|
+
* Splits a `buildTx` signature array into its typed requirement-signature slots, rejecting
|
|
374
537
|
* ambiguous or unexpected input so a path never silently consumes the wrong signature.
|
|
375
538
|
*
|
|
376
|
-
* A bundled path consumes at most one
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
539
|
+
* A bundled path consumes at most one signature of each accepted kind. Passing several of the same
|
|
540
|
+
* kind, or a kind the path does not consume, is rejected with a typed error rather than silently
|
|
541
|
+
* dropping the extras — the latter could otherwise leave a required authorization or permit
|
|
542
|
+
* unsigned (and the bundle reverting on-chain) or apply the wrong signature.
|
|
380
543
|
*
|
|
381
544
|
* @param signatures - The signatures passed to `buildTx`.
|
|
382
545
|
* @param accepts - Which signature kinds this operation consumes.
|
|
383
546
|
* @param accepts.permit - Whether a permit / Permit2 signature is consumed.
|
|
384
547
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
548
|
+
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
385
549
|
* @returns The single permit and/or authorization signature, when present.
|
|
386
550
|
* @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
|
|
387
551
|
* @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
|
|
@@ -398,4 +562,6 @@ export interface SelectedRequirementSignatures {
|
|
|
398
562
|
export declare function selectRequirementSignatures(signatures: readonly RequirementSignature[] | undefined, accepts: {
|
|
399
563
|
permit?: boolean;
|
|
400
564
|
authorization?: boolean;
|
|
565
|
+
midnightOfferRoot?: boolean;
|
|
401
566
|
}): SelectedRequirementSignatures;
|
|
567
|
+
export {};
|
package/lib/cjs/types/action.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.isRequirementBlueAuthorization = isRequirementBlueAuthorization;
|
|
|
5
5
|
exports.isRequirementSignature = isRequirementSignature;
|
|
6
6
|
exports.isPermitSignature = isPermitSignature;
|
|
7
7
|
exports.isAuthorizationSignature = isAuthorizationSignature;
|
|
8
|
+
exports.isMidnightOfferRootSignature = isMidnightOfferRootSignature;
|
|
8
9
|
exports.selectRequirementSignatures = selectRequirementSignatures;
|
|
9
10
|
const error_js_1 = require("./error.js");
|
|
10
11
|
function isRequirementApproval(requirement) {
|
|
@@ -19,7 +20,7 @@ function isRequirementApproval(requirement) {
|
|
|
19
20
|
"type" in requirement.action &&
|
|
20
21
|
requirement.action.type === "erc20Approval");
|
|
21
22
|
}
|
|
22
|
-
/** Checks whether an action requirement is a Blue authorization
|
|
23
|
+
/** Checks whether an action requirement is a Blue authorization call. */
|
|
23
24
|
function isRequirementBlueAuthorization(requirement) {
|
|
24
25
|
return (typeof requirement === "object" &&
|
|
25
26
|
requirement !== null &&
|
|
@@ -58,18 +59,28 @@ function isAuthorizationSignature(signature) {
|
|
|
58
59
|
return signature.action.type === "authorization";
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
61
|
-
*
|
|
62
|
+
* Narrows a {@link RequirementSignature} to a Midnight offer-root signature.
|
|
63
|
+
*
|
|
64
|
+
* @param signature - The signed requirement to test.
|
|
65
|
+
* @returns `true` when `signature.action.type` is `"midnightOfferRootSignature"`.
|
|
66
|
+
*/
|
|
67
|
+
function isMidnightOfferRootSignature(signature) {
|
|
68
|
+
return signature.action.type === "midnightOfferRootSignature";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Splits a `buildTx` signature array into its typed requirement-signature slots, rejecting
|
|
62
72
|
* ambiguous or unexpected input so a path never silently consumes the wrong signature.
|
|
63
73
|
*
|
|
64
|
-
* A bundled path consumes at most one
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
74
|
+
* A bundled path consumes at most one signature of each accepted kind. Passing several of the same
|
|
75
|
+
* kind, or a kind the path does not consume, is rejected with a typed error rather than silently
|
|
76
|
+
* dropping the extras — the latter could otherwise leave a required authorization or permit
|
|
77
|
+
* unsigned (and the bundle reverting on-chain) or apply the wrong signature.
|
|
68
78
|
*
|
|
69
79
|
* @param signatures - The signatures passed to `buildTx`.
|
|
70
80
|
* @param accepts - Which signature kinds this operation consumes.
|
|
71
81
|
* @param accepts.permit - Whether a permit / Permit2 signature is consumed.
|
|
72
82
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
83
|
+
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
73
84
|
* @returns The single permit and/or authorization signature, when present.
|
|
74
85
|
* @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
|
|
75
86
|
* @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
|
|
@@ -88,13 +99,22 @@ function selectRequirementSignatures(signatures, accepts) {
|
|
|
88
99
|
return {};
|
|
89
100
|
const permits = signatures.filter(isPermitSignature);
|
|
90
101
|
const authorizations = signatures.filter(isAuthorizationSignature);
|
|
102
|
+
const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
|
|
91
103
|
if (!accepts.permit && permits.length > 0)
|
|
92
104
|
throw new error_js_1.UnexpectedRequirementSignatureError("permit");
|
|
93
105
|
if (!accepts.authorization && authorizations.length > 0)
|
|
94
106
|
throw new error_js_1.UnexpectedRequirementSignatureError("authorization");
|
|
107
|
+
if (!accepts.midnightOfferRoot && midnightOfferRoots.length > 0)
|
|
108
|
+
throw new error_js_1.UnexpectedRequirementSignatureError("midnightOfferRootSignature");
|
|
95
109
|
if (permits.length > 1)
|
|
96
110
|
throw new error_js_1.AmbiguousRequirementSignaturesError("permit", permits.length);
|
|
97
111
|
if (authorizations.length > 1)
|
|
98
112
|
throw new error_js_1.AmbiguousRequirementSignaturesError("authorization", authorizations.length);
|
|
99
|
-
|
|
113
|
+
if (midnightOfferRoots.length > 1)
|
|
114
|
+
throw new error_js_1.AmbiguousRequirementSignaturesError("midnightOfferRootSignature", midnightOfferRoots.length);
|
|
115
|
+
return {
|
|
116
|
+
permit: permits[0],
|
|
117
|
+
authorization: authorizations[0],
|
|
118
|
+
midnightOfferRoot: midnightOfferRoots[0],
|
|
119
|
+
};
|
|
100
120
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address, Client } from "viem";
|
|
3
|
-
import type { BlueActions, VaultV1Actions, VaultV2Actions } from "../actions/index.js";
|
|
3
|
+
import type { BlueActions, MidnightActions, VaultV1Actions, VaultV2Actions } from "../actions/index.js";
|
|
4
4
|
import type { Metadata } from "./index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Structural contract the `morpho` namespace satisfies — the object exposed under `client.morpho`
|
|
7
7
|
* once a viem client is extended with {@link morphoViemExtension}. Carries the viem client, the
|
|
8
|
-
* resolved options bag, and the
|
|
8
|
+
* resolved options bag, and the four entity-factory methods the SDK exposes.
|
|
9
9
|
*/
|
|
10
10
|
export interface MorphoClientType {
|
|
11
11
|
readonly viemClient: Client;
|
|
@@ -17,4 +17,5 @@ export interface MorphoClientType {
|
|
|
17
17
|
vaultV1: (vault: Address, chainId: number) => VaultV1Actions;
|
|
18
18
|
vaultV2: (vault: Address, chainId: number) => VaultV2Actions;
|
|
19
19
|
blue: (marketParams: MarketParams, chainId: number) => BlueActions;
|
|
20
|
+
midnight: (chainId: number) => MidnightActions;
|
|
20
21
|
}
|