@morpho-org/morpho-sdk 10.4.0 → 10.5.0-next.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/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +5 -1
- package/lib/cjs/actions/blue/common.js +12 -3
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +5 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +3 -1
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +5 -1
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +3 -1
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +2 -1
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/midnight/midnight.d.ts +100 -103
- package/lib/cjs/entities/midnight/midnight.js +99 -99
- package/lib/cjs/entities/vaultV1/vaultV1.js +0 -1
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +34 -8
- package/lib/cjs/entities/vaultV2/vaultV2.js +39 -2
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -2
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +6 -2
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +7 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/helpers/deadShares.js +3 -0
- package/lib/cjs/helpers/validate.d.ts +11 -1
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/transactionPlan/assemble.d.ts +24 -0
- package/lib/cjs/transactionPlan/assemble.js +25 -0
- package/lib/cjs/transactionPlan/blue/borrow.js +14 -64
- package/lib/cjs/transactionPlan/blue/refinance.js +9 -11
- package/lib/cjs/transactionPlan/blue/repay.js +10 -24
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +49 -45
- package/lib/cjs/transactionPlan/blue/stored.d.ts +26 -0
- package/lib/cjs/transactionPlan/blue/stored.js +87 -0
- package/lib/cjs/transactionPlan/blue/supply.js +7 -22
- package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/blue/supplyCollateral.js +10 -15
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +14 -64
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/withdraw.js +67 -79
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +31 -30
- package/lib/cjs/transactionPlan/deposit.js +4 -7
- package/lib/cjs/transactionPlan/intent.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/makeBorrow.js +1 -1
- package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/makeLend.js +1 -1
- package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/makeRepay.js +1 -1
- package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +1 -1
- package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +2 -2
- package/lib/cjs/transactionPlan/midnight/takeBorrow.js +2 -2
- package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +1 -1
- package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +1 -1
- package/lib/cjs/transactionPlan/permit.d.ts +15 -2
- package/lib/cjs/transactionPlan/permit.js +26 -68
- package/lib/cjs/transactionPlan/plan.d.ts +51 -1
- package/lib/cjs/transactionPlan/plan.js +56 -13
- package/lib/cjs/transactionPlan/redeem.js +4 -7
- package/lib/cjs/transactionPlan/types.d.ts +4 -3
- package/lib/cjs/transactionPlan/vaultBinding.d.ts +29 -0
- package/lib/cjs/transactionPlan/vaultBinding.js +69 -0
- package/lib/cjs/transactionPlan/vaultRequirements.d.ts +20 -0
- package/lib/cjs/transactionPlan/vaultRequirements.js +37 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -13
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +10 -41
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +6 -18
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -12
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +4 -7
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +12 -42
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +10 -41
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -13
- package/lib/cjs/transactionPlan/withdraw.js +4 -7
- package/lib/cjs/types/error.d.ts +2 -1
- package/lib/cjs/types/error.js +3 -2
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/blue/common.js +13 -4
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +100 -103
- package/lib/esm/entities/midnight/midnight.js +99 -99
- package/lib/esm/entities/vaultV1/vaultV1.js +0 -1
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +34 -8
- package/lib/esm/entities/vaultV2/vaultV2.js +40 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -2
- package/lib/esm/entities/vaultV2BlueReallocationData.js +6 -2
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/deadShares.js +4 -1
- package/lib/esm/helpers/validate.d.ts +11 -1
- package/lib/esm/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/transactionPlan/assemble.d.ts +24 -0
- package/lib/esm/transactionPlan/assemble.js +21 -0
- package/lib/esm/transactionPlan/blue/borrow.js +15 -65
- package/lib/esm/transactionPlan/blue/refinance.js +10 -12
- package/lib/esm/transactionPlan/blue/repay.js +11 -25
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +50 -46
- package/lib/esm/transactionPlan/blue/stored.d.ts +26 -0
- package/lib/esm/transactionPlan/blue/stored.js +80 -0
- package/lib/esm/transactionPlan/blue/supply.js +7 -22
- package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/blue/supplyCollateral.js +10 -15
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +15 -65
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/withdraw.js +70 -82
- package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +32 -31
- package/lib/esm/transactionPlan/deposit.js +5 -8
- package/lib/esm/transactionPlan/intent.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/makeBorrow.js +1 -1
- package/lib/esm/transactionPlan/midnight/makeLend.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/makeLend.js +1 -1
- package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/makeRepay.js +1 -1
- package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateral.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +1 -1
- package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +2 -2
- package/lib/esm/transactionPlan/midnight/takeBorrow.js +2 -2
- package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +1 -1
- package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/takeWithdraw.js +1 -1
- package/lib/esm/transactionPlan/permit.d.ts +15 -2
- package/lib/esm/transactionPlan/permit.js +25 -68
- package/lib/esm/transactionPlan/plan.d.ts +51 -1
- package/lib/esm/transactionPlan/plan.js +55 -13
- package/lib/esm/transactionPlan/redeem.js +5 -8
- package/lib/esm/transactionPlan/types.d.ts +4 -3
- package/lib/esm/transactionPlan/vaultBinding.d.ts +29 -0
- package/lib/esm/transactionPlan/vaultBinding.js +65 -0
- package/lib/esm/transactionPlan/vaultRequirements.d.ts +20 -0
- package/lib/esm/transactionPlan/vaultRequirements.js +34 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -14
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +12 -43
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +9 -21
- package/lib/esm/transactionPlan/vaultv1/redeem.js +2 -13
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +5 -8
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +15 -45
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +12 -43
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/redeem.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +3 -14
- package/lib/esm/transactionPlan/withdraw.js +5 -8
- package/lib/esm/types/error.d.ts +2 -1
- package/lib/esm/types/error.js +3 -2
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +7 -7
|
@@ -40,7 +40,7 @@ const actionId = "midnightSupplyCollateralWithNative";
|
|
|
40
40
|
* @param params.nativeAmount - Positive native funding in wei, at most `collateralAssets`; any rest is pulled as wNative.
|
|
41
41
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
42
42
|
* @param params.expiresAt - Bundle execution deadline in Unix seconds; defaults to two hours after `now`.
|
|
43
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
43
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
44
44
|
* @returns A frozen plan whose steps must be submitted in order from `params.account`.
|
|
45
45
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, the collateral amount or the index is not a bigint; checked before any request.
|
|
46
46
|
* @throws {ZeroAccountError} If the account is the zero address.
|
|
@@ -52,7 +52,7 @@ export interface MidnightTakeBorrowPlanParams extends Omit<IntentParams, "suppor
|
|
|
52
52
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
53
53
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
54
54
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
55
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
55
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
56
56
|
* @returns A frozen plan with a standalone authorization step if needed and no signature requests.
|
|
57
57
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, or a target amount, is not a bigint;
|
|
58
58
|
* checked before any request.
|
|
@@ -182,7 +182,7 @@ export interface MidnightSupplyCollateralTakeBorrowPlanParams extends MidnightTa
|
|
|
182
182
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
183
183
|
* @param params.now - Reference Unix timestamp in seconds; defaults to the device clock.
|
|
184
184
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
185
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
185
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
186
186
|
* @returns A frozen plan with any necessary approvals and authorization, without signature requests.
|
|
187
187
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, a target amount or a collateral index
|
|
188
188
|
* is not a bigint; checked before any request.
|
|
@@ -55,7 +55,7 @@ const validation_js_2 = require("./validation.js");
|
|
|
55
55
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
56
56
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
57
57
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
58
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
58
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
59
59
|
* @returns A frozen plan with a standalone authorization step if needed and no signature requests.
|
|
60
60
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, or a target amount, is not a bigint;
|
|
61
61
|
* checked before any request.
|
|
@@ -181,7 +181,7 @@ async function prepareMidnightTakeBorrow(client, params) {
|
|
|
181
181
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
182
182
|
* @param params.now - Reference Unix timestamp in seconds; defaults to the device clock.
|
|
183
183
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
184
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
184
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
185
185
|
* @returns A frozen plan with any necessary approvals and authorization, without signature requests.
|
|
186
186
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, a target amount or a collateral index
|
|
187
187
|
* is not a bigint; checked before any request.
|
|
@@ -61,7 +61,7 @@ export interface MidnightTakeRepayWithdrawCollateralPlanParams extends Omit<Inte
|
|
|
61
61
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
62
62
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
63
63
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
64
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
64
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
65
65
|
* @returns A frozen plan with any needed approval and standalone authorization, without signatures.
|
|
66
66
|
* @throws {InvalidBigIntInputError} when a supplied non-null `now`, `maxContinuousFee`, a target amount, or a withdrawal's collateral index or amount is not a bigint; checked before any request.
|
|
67
67
|
* @throws {ZeroAccountError} when the sender is the zero address.
|
|
@@ -91,7 +91,7 @@ const validateTakeRepayWithdrawCollateralPosition = (params) => {
|
|
|
91
91
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
92
92
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
93
93
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
94
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
94
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
95
95
|
* @returns A frozen plan with any needed approval and standalone authorization, without signatures.
|
|
96
96
|
* @throws {InvalidBigIntInputError} when a supplied non-null `now`, `maxContinuousFee`, a target amount, or a withdrawal's collateral index or amount is not a bigint; checked before any request.
|
|
97
97
|
* @throws {ZeroAccountError} when the sender is the zero address.
|
|
@@ -48,7 +48,7 @@ export interface MidnightTakeWithdrawPlanParams extends Omit<IntentParams, "supp
|
|
|
48
48
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
49
49
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
50
50
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
51
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
51
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
52
52
|
* @returns A frozen plan with a standalone authorization step if needed and no signature requests.
|
|
53
53
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now` or a target amount is not a
|
|
54
54
|
* bigint; checked before any request.
|
|
@@ -47,7 +47,7 @@ const validation_js_1 = require("./validation.js");
|
|
|
47
47
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
48
48
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
49
49
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
50
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
50
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
51
51
|
* @returns A frozen plan with a standalone authorization step if needed and no signature requests.
|
|
52
52
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now` or a target amount is not a
|
|
53
53
|
* bigint; checked before any request.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Erc2612RequirementSignature } from "../types/index.js";
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { BundlesTokenRequirementSignature, Erc2612RequirementSignature } from "../types/index.js";
|
|
3
3
|
import type { Action, SignatureRequest } from "./types.js";
|
|
4
|
+
import { type VaultPermitAction } from "./vaultBinding.js";
|
|
4
5
|
/** @internal Validates the stored ERC-2612 request shape without verifying its signature. */
|
|
5
6
|
export declare function validatePermitPlanRequest(request: Record<string, unknown>, path: string): void;
|
|
6
7
|
/** @internal Checks a permit's signing payload against its referencing action and encoding arguments. */
|
|
@@ -23,5 +24,17 @@ export declare function getSignedTokenPermit(requests: readonly SignatureRequest
|
|
|
23
24
|
readonly asset: Address;
|
|
24
25
|
readonly owner: Address;
|
|
25
26
|
}): Erc2612RequirementSignature | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* @internal Selects the vault action's signed token permit for its bundle pull, as its builder encodes it.
|
|
29
|
+
* @throws {IncompleteTransactionPlanError} If the referenced request is missing or unsigned.
|
|
30
|
+
* @throws {TransactionPlanSignatureMismatchError} If the referenced request is not a permit.
|
|
31
|
+
* @throws {BundlesPermitMismatchError} If the permit does not match the pull's spender, amount or deadline.
|
|
32
|
+
*/
|
|
33
|
+
export declare function selectVaultPermit(action: Extract<VaultPermitAction, {
|
|
34
|
+
readonly type: "vaultV1Deposit" | "vaultV2Deposit";
|
|
35
|
+
}>, requests: readonly SignatureRequest[]): BundlesTokenRequirementSignature | undefined;
|
|
36
|
+
export declare function selectVaultPermit(action: Exclude<VaultPermitAction, {
|
|
37
|
+
readonly type: "vaultV1Deposit" | "vaultV2Deposit";
|
|
38
|
+
}>, requests: readonly SignatureRequest[]): Erc2612RequirementSignature | undefined;
|
|
26
39
|
/** @internal Alias for existing Vault V2 plan builders. */
|
|
27
40
|
export { getSignedTokenPermit as getVaultPermit };
|
|
@@ -5,12 +5,14 @@ exports.validateVaultPermitRequest = validateVaultPermitRequest;
|
|
|
5
5
|
exports.validateTokenPermitRequest = validateTokenPermitRequest;
|
|
6
6
|
exports.getSignedTokenPermit = getSignedTokenPermit;
|
|
7
7
|
exports.getVaultPermit = getSignedTokenPermit;
|
|
8
|
+
exports.selectVaultPermit = selectVaultPermit;
|
|
8
9
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
9
10
|
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
10
11
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
11
|
-
const
|
|
12
|
+
const common_js_1 = require("../actions/bundles/common.js");
|
|
12
13
|
const error_js_1 = require("./error.js");
|
|
13
14
|
const validation_js_1 = require("./validation.js");
|
|
15
|
+
const vaultBinding_js_1 = require("./vaultBinding.js");
|
|
14
16
|
/** @internal Validates the stored ERC-2612 request shape without verifying its signature. */
|
|
15
17
|
function validatePermitPlanRequest(request, path) {
|
|
16
18
|
const args = (0, validation_js_1.getPlanObject)(request.args, `${path}.args`);
|
|
@@ -83,72 +85,10 @@ function validatePermitPlanRequest(request, path) {
|
|
|
83
85
|
}
|
|
84
86
|
/** @internal Checks a permit's signing payload against its referencing action and encoding arguments. */
|
|
85
87
|
function validateVaultPermitRequest(request, action) {
|
|
86
|
-
if (request.kind !== "permit") {
|
|
88
|
+
if (request.kind !== "permit" || !(0, vaultBinding_js_1.isVaultPermitAction)(action)) {
|
|
87
89
|
throw new error_js_1.TransactionPlanSignatureMismatchError(request.id, "reference");
|
|
88
90
|
}
|
|
89
|
-
|
|
90
|
-
let asset;
|
|
91
|
-
let amount;
|
|
92
|
-
let exact = false;
|
|
93
|
-
switch (action.type) {
|
|
94
|
-
case "vaultV2Deposit":
|
|
95
|
-
spenderKey = "bundles.vaultBundlesV1";
|
|
96
|
-
asset = action.inputs.asset;
|
|
97
|
-
amount = action.inputs.assets;
|
|
98
|
-
exact = true;
|
|
99
|
-
break;
|
|
100
|
-
case "vaultV1Deposit":
|
|
101
|
-
spenderKey = "bundles.vaultBundlesV1";
|
|
102
|
-
asset = action.inputs.asset;
|
|
103
|
-
amount = action.inputs.assets;
|
|
104
|
-
exact = true;
|
|
105
|
-
break;
|
|
106
|
-
case "vaultV1Withdraw":
|
|
107
|
-
spenderKey = "bundles.vaultBundlesV1";
|
|
108
|
-
asset = action.inputs.vault;
|
|
109
|
-
amount = action.inputs.requiredShareAllowance;
|
|
110
|
-
break;
|
|
111
|
-
case "vaultV2Withdraw":
|
|
112
|
-
spenderKey = "bundles.vaultBundlesV1";
|
|
113
|
-
asset = action.inputs.vault;
|
|
114
|
-
amount = action.inputs.requiredShareAllowance;
|
|
115
|
-
break;
|
|
116
|
-
case "vaultV2Redeem":
|
|
117
|
-
spenderKey = "bundles.vaultBundlesV1";
|
|
118
|
-
asset = action.inputs.vault;
|
|
119
|
-
amount = action.inputs.shares;
|
|
120
|
-
break;
|
|
121
|
-
case "vaultV1Redeem":
|
|
122
|
-
spenderKey = "bundles.vaultBundlesV1";
|
|
123
|
-
asset = action.inputs.vault;
|
|
124
|
-
amount = action.inputs.shares;
|
|
125
|
-
break;
|
|
126
|
-
case "vaultV2ForceWithdraw":
|
|
127
|
-
spenderKey = "bundles.vaultExitBundlesV1";
|
|
128
|
-
asset = action.inputs.vault;
|
|
129
|
-
amount = viem_1.maxUint256;
|
|
130
|
-
exact = true;
|
|
131
|
-
break;
|
|
132
|
-
case "vaultV1MigrateToV2":
|
|
133
|
-
spenderKey = "bundles.vaultBundlesV1";
|
|
134
|
-
asset = action.inputs.sourceVault;
|
|
135
|
-
amount = action.inputs.requiredShareAllowance;
|
|
136
|
-
break;
|
|
137
|
-
case "vaultV2InKindRedeem":
|
|
138
|
-
spenderKey = "bundles.vaultExitBundlesV1";
|
|
139
|
-
asset = action.inputs.vault;
|
|
140
|
-
amount = viem_1.maxUint256;
|
|
141
|
-
exact = true;
|
|
142
|
-
break;
|
|
143
|
-
case "vaultV1InKindRedeem":
|
|
144
|
-
spenderKey = "bundles.vaultExitBundlesV1";
|
|
145
|
-
asset = action.inputs.vault;
|
|
146
|
-
amount = viem_1.maxUint256;
|
|
147
|
-
exact = true;
|
|
148
|
-
break;
|
|
149
|
-
default:
|
|
150
|
-
throw new error_js_1.TransactionPlanSignatureMismatchError(request.id, "reference");
|
|
151
|
-
}
|
|
91
|
+
const { bundler, asset, restore } = (0, vaultBinding_js_1.getVaultPermitBinding)(action);
|
|
152
92
|
if (action.signatureRequestIds.tokenPermit !== request.id) {
|
|
153
93
|
throw new error_js_1.TransactionPlanSignatureMismatchError(request.id, "reference");
|
|
154
94
|
}
|
|
@@ -156,10 +96,10 @@ function validateVaultPermitRequest(request, action) {
|
|
|
156
96
|
chainId: action.inputs.chainId,
|
|
157
97
|
account: action.inputs.account,
|
|
158
98
|
deadline: action.inputs.deadline,
|
|
159
|
-
bundler
|
|
99
|
+
bundler,
|
|
160
100
|
asset,
|
|
161
|
-
amount,
|
|
162
|
-
exact,
|
|
101
|
+
amount: restore.amount,
|
|
102
|
+
exact: restore.exact,
|
|
163
103
|
});
|
|
164
104
|
}
|
|
165
105
|
/** @internal Binds the signing payload and encoding arguments to a registered bundle's token pull. */
|
|
@@ -241,3 +181,21 @@ function getSignedTokenPermit(requests, { id, asset, owner, }) {
|
|
|
241
181
|
},
|
|
242
182
|
};
|
|
243
183
|
}
|
|
184
|
+
function selectVaultPermit(action, requests) {
|
|
185
|
+
const { chainId, account, deadline } = action.inputs;
|
|
186
|
+
const { bundler, asset, build } = (0, vaultBinding_js_1.getVaultPermitBinding)(action);
|
|
187
|
+
const signature = getSignedTokenPermit(requests, {
|
|
188
|
+
id: action.signatureRequestIds.tokenPermit,
|
|
189
|
+
asset,
|
|
190
|
+
owner: account,
|
|
191
|
+
});
|
|
192
|
+
const signatures = signature ? [signature] : [];
|
|
193
|
+
const expected = {
|
|
194
|
+
spender: (0, morpho_ts_1.getChainAddress)(chainId, bundler),
|
|
195
|
+
amount: build.amount,
|
|
196
|
+
deadline,
|
|
197
|
+
};
|
|
198
|
+
return build.pull === "token"
|
|
199
|
+
? (0, common_js_1.selectBundlesTokenRequirementSignature)(signatures, expected)
|
|
200
|
+
: (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, expected);
|
|
201
|
+
}
|
|
@@ -57,6 +57,56 @@ export declare function verifyPlanSignature(request: SignatureRequest, signature
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
export declare function getPendingSignatureRequests(plan: TransactionPlan): readonly SignatureRequest[];
|
|
60
|
+
/**
|
|
61
|
+
* @internal Whether a step's transaction carries the plan's `calldataOrigin`. Operation steps do;
|
|
62
|
+
* approval and authorization prerequisites never do, matching the entity path. Every action type
|
|
63
|
+
* must be listed, so a new type does not compile until its role is chosen.
|
|
64
|
+
*/
|
|
65
|
+
export declare const CALLDATA_ORIGIN_ROLE: {
|
|
66
|
+
readonly blueBorrow: "operation";
|
|
67
|
+
readonly blueRefinance: "operation";
|
|
68
|
+
readonly blueRepay: "operation";
|
|
69
|
+
readonly blueRepayWithdrawCollateral: "operation";
|
|
70
|
+
readonly blueSupply: "operation";
|
|
71
|
+
readonly blueSupplyCollateral: "operation";
|
|
72
|
+
readonly blueSupplyCollateralBorrow: "operation";
|
|
73
|
+
readonly blueWithdraw: "operation";
|
|
74
|
+
readonly blueWithdrawBuyCallback: "operation";
|
|
75
|
+
readonly blueWithdrawCollateral: "operation";
|
|
76
|
+
readonly erc20Approval: "prerequisite";
|
|
77
|
+
readonly midnightAuthorization: "prerequisite";
|
|
78
|
+
readonly midnightCancelOffers: "operation";
|
|
79
|
+
readonly midnightMakeBorrow: "operation";
|
|
80
|
+
readonly midnightMakeLend: "operation";
|
|
81
|
+
readonly midnightMakeRepay: "operation";
|
|
82
|
+
readonly midnightMakeWithdraw: "operation";
|
|
83
|
+
readonly midnightRedeem: "operation";
|
|
84
|
+
readonly midnightRepayWithdrawCollateral: "operation";
|
|
85
|
+
readonly midnightSupplyBlueMakeLend: "operation";
|
|
86
|
+
readonly midnightSupplyCollateral: "operation";
|
|
87
|
+
readonly midnightSupplyCollateralBatch: "operation";
|
|
88
|
+
readonly midnightSupplyCollateralMakeBorrow: "operation";
|
|
89
|
+
readonly midnightSupplyCollateralTakeBorrow: "operation";
|
|
90
|
+
readonly midnightSupplyCollateralWithNative: "operation";
|
|
91
|
+
readonly midnightTakeBorrow: "operation";
|
|
92
|
+
readonly midnightTakeLend: "operation";
|
|
93
|
+
readonly midnightTakeRepayWithdrawCollateral: "operation";
|
|
94
|
+
readonly midnightTakeWithdraw: "operation";
|
|
95
|
+
readonly midnightWithdrawCollateral: "operation";
|
|
96
|
+
readonly midnightWithdrawCollateralBatch: "operation";
|
|
97
|
+
readonly morphoAuthorization: "prerequisite";
|
|
98
|
+
readonly vaultV1Deposit: "operation";
|
|
99
|
+
readonly vaultV1InKindRedeem: "operation";
|
|
100
|
+
readonly vaultV1MigrateToV2: "operation";
|
|
101
|
+
readonly vaultV1Redeem: "operation";
|
|
102
|
+
readonly vaultV1Withdraw: "operation";
|
|
103
|
+
readonly vaultV2Deposit: "operation";
|
|
104
|
+
readonly vaultV2ForceRedeem: "operation";
|
|
105
|
+
readonly vaultV2ForceWithdraw: "operation";
|
|
106
|
+
readonly vaultV2InKindRedeem: "operation";
|
|
107
|
+
readonly vaultV2Redeem: "operation";
|
|
108
|
+
readonly vaultV2Withdraw: "operation";
|
|
109
|
+
};
|
|
60
110
|
/**
|
|
61
111
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
62
112
|
* Builds one transaction from a step, its fixed inputs and the signatures its action names.
|
|
@@ -68,7 +118,7 @@ export declare function getPendingSignatureRequests(plan: TransactionPlan): read
|
|
|
68
118
|
* not operation amounts, market parameters or referral fees/recipients. Protect those unsigned fields.
|
|
69
119
|
* @param plan - Plan supplying referenced signature requests and the calldata origin; chain and account come from the action inputs.
|
|
70
120
|
* @param step - Recipe to encode; missing signatures on unrelated supported steps do not block it.
|
|
71
|
-
* @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set.
|
|
121
|
+
* @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set, except for ERC-20 approval, Morpho authorization and Midnight authorization prerequisite steps.
|
|
72
122
|
* @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent, a Midnight repayment type is unsupported, a Midnight market lists its collateral out of ascending token order, a Midnight single-collateral step has no bigint `collateralIndex`, or a Midnight collateral batch's list is not an array or holds a non-object entry (path under `$.inputs`).
|
|
73
123
|
* @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty, or a Midnight collateral batch entry's `collateralIndex` or `assets`, is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
|
|
74
124
|
* @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CALLDATA_ORIGIN_ROLE = void 0;
|
|
3
4
|
exports.applySignatures = applySignatures;
|
|
4
5
|
exports.verifyPlanSignature = verifyPlanSignature;
|
|
5
6
|
exports.getPendingSignatureRequests = getPendingSignatureRequests;
|
|
@@ -41,6 +42,7 @@ const withdrawCollateralBatch_js_1 = require("./midnight/withdrawCollateralBatch
|
|
|
41
42
|
const permit_js_1 = require("./permit.js");
|
|
42
43
|
const validateActions_js_1 = require("./validateActions.js");
|
|
43
44
|
const validation_js_1 = require("./validation.js");
|
|
45
|
+
const vaultBinding_js_1 = require("./vaultBinding.js");
|
|
44
46
|
const deposit_js_1 = require("./vaultv1/deposit.js");
|
|
45
47
|
const inKindRedeem_js_1 = require("./vaultv1/inKindRedeem.js");
|
|
46
48
|
const migrateToV2_js_1 = require("./vaultv1/migrateToV2.js");
|
|
@@ -251,17 +253,7 @@ function validateSignatureRequest(request, action) {
|
|
|
251
253
|
nonce: action.inputs.authorizationNonce,
|
|
252
254
|
});
|
|
253
255
|
}
|
|
254
|
-
if (request.kind === "permit" &&
|
|
255
|
-
(action.type === "vaultV2Deposit" ||
|
|
256
|
-
action.type === "vaultV1Deposit" ||
|
|
257
|
-
action.type === "vaultV1Withdraw" ||
|
|
258
|
-
action.type === "vaultV2Withdraw" ||
|
|
259
|
-
action.type === "vaultV2Redeem" ||
|
|
260
|
-
action.type === "vaultV1Redeem" ||
|
|
261
|
-
action.type === "vaultV2ForceWithdraw" ||
|
|
262
|
-
action.type === "vaultV1MigrateToV2" ||
|
|
263
|
-
action.type === "vaultV2InKindRedeem" ||
|
|
264
|
-
action.type === "vaultV1InKindRedeem")) {
|
|
256
|
+
if (request.kind === "permit" && (0, vaultBinding_js_1.isVaultPermitAction)(action)) {
|
|
265
257
|
(0, permit_js_1.validateVaultPermitRequest)(request, action);
|
|
266
258
|
return;
|
|
267
259
|
}
|
|
@@ -409,6 +401,56 @@ function encodeStep(action, requests) {
|
|
|
409
401
|
return (0, inKindRedeem_js_2.buildVaultV2InKindRedeem)(action, requests);
|
|
410
402
|
}
|
|
411
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* @internal Whether a step's transaction carries the plan's `calldataOrigin`. Operation steps do;
|
|
406
|
+
* approval and authorization prerequisites never do, matching the entity path. Every action type
|
|
407
|
+
* must be listed, so a new type does not compile until its role is chosen.
|
|
408
|
+
*/
|
|
409
|
+
exports.CALLDATA_ORIGIN_ROLE = {
|
|
410
|
+
blueBorrow: "operation",
|
|
411
|
+
blueRefinance: "operation",
|
|
412
|
+
blueRepay: "operation",
|
|
413
|
+
blueRepayWithdrawCollateral: "operation",
|
|
414
|
+
blueSupply: "operation",
|
|
415
|
+
blueSupplyCollateral: "operation",
|
|
416
|
+
blueSupplyCollateralBorrow: "operation",
|
|
417
|
+
blueWithdraw: "operation",
|
|
418
|
+
blueWithdrawBuyCallback: "operation",
|
|
419
|
+
blueWithdrawCollateral: "operation",
|
|
420
|
+
erc20Approval: "prerequisite",
|
|
421
|
+
midnightAuthorization: "prerequisite",
|
|
422
|
+
midnightCancelOffers: "operation",
|
|
423
|
+
midnightMakeBorrow: "operation",
|
|
424
|
+
midnightMakeLend: "operation",
|
|
425
|
+
midnightMakeRepay: "operation",
|
|
426
|
+
midnightMakeWithdraw: "operation",
|
|
427
|
+
midnightRedeem: "operation",
|
|
428
|
+
midnightRepayWithdrawCollateral: "operation",
|
|
429
|
+
midnightSupplyBlueMakeLend: "operation",
|
|
430
|
+
midnightSupplyCollateral: "operation",
|
|
431
|
+
midnightSupplyCollateralBatch: "operation",
|
|
432
|
+
midnightSupplyCollateralMakeBorrow: "operation",
|
|
433
|
+
midnightSupplyCollateralTakeBorrow: "operation",
|
|
434
|
+
midnightSupplyCollateralWithNative: "operation",
|
|
435
|
+
midnightTakeBorrow: "operation",
|
|
436
|
+
midnightTakeLend: "operation",
|
|
437
|
+
midnightTakeRepayWithdrawCollateral: "operation",
|
|
438
|
+
midnightTakeWithdraw: "operation",
|
|
439
|
+
midnightWithdrawCollateral: "operation",
|
|
440
|
+
midnightWithdrawCollateralBatch: "operation",
|
|
441
|
+
morphoAuthorization: "prerequisite",
|
|
442
|
+
vaultV1Deposit: "operation",
|
|
443
|
+
vaultV1InKindRedeem: "operation",
|
|
444
|
+
vaultV1MigrateToV2: "operation",
|
|
445
|
+
vaultV1Redeem: "operation",
|
|
446
|
+
vaultV1Withdraw: "operation",
|
|
447
|
+
vaultV2Deposit: "operation",
|
|
448
|
+
vaultV2ForceRedeem: "operation",
|
|
449
|
+
vaultV2ForceWithdraw: "operation",
|
|
450
|
+
vaultV2InKindRedeem: "operation",
|
|
451
|
+
vaultV2Redeem: "operation",
|
|
452
|
+
vaultV2Withdraw: "operation",
|
|
453
|
+
};
|
|
412
454
|
/**
|
|
413
455
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
414
456
|
* Builds one transaction from a step, its fixed inputs and the signatures its action names.
|
|
@@ -420,7 +462,7 @@ function encodeStep(action, requests) {
|
|
|
420
462
|
* not operation amounts, market parameters or referral fees/recipients. Protect those unsigned fields.
|
|
421
463
|
* @param plan - Plan supplying referenced signature requests and the calldata origin; chain and account come from the action inputs.
|
|
422
464
|
* @param step - Recipe to encode; missing signatures on unrelated supported steps do not block it.
|
|
423
|
-
* @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set.
|
|
465
|
+
* @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set, except for ERC-20 approval, Morpho authorization and Midnight authorization prerequisite steps.
|
|
424
466
|
* @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent, a Midnight repayment type is unsupported, a Midnight market lists its collateral out of ascending token order, a Midnight single-collateral step has no bigint `collateralIndex`, or a Midnight collateral batch's list is not an array or holds a non-object entry (path under `$.inputs`).
|
|
425
467
|
* @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty, or a Midnight collateral batch entry's `collateralIndex` or `assets`, is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
|
|
426
468
|
* @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
|
|
@@ -525,7 +567,8 @@ function buildTransaction(plan, step) {
|
|
|
525
567
|
return (0, morpho_ts_1.deepFreeze)({
|
|
526
568
|
to,
|
|
527
569
|
value,
|
|
528
|
-
data: plan.calldataOrigin === undefined
|
|
570
|
+
data: plan.calldataOrigin === undefined ||
|
|
571
|
+
exports.CALLDATA_ORIGIN_ROLE[step.action.type] === "prerequisite"
|
|
529
572
|
? data
|
|
530
573
|
: (0, viem_1.concatHex)([data, plan.calldataOrigin]),
|
|
531
574
|
action,
|
|
@@ -6,6 +6,7 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
|
6
6
|
const common_js_1 = require("../actions/bundles/common.js");
|
|
7
7
|
const validate_js_1 = require("../helpers/validate.js");
|
|
8
8
|
const index_js_1 = require("../types/index.js");
|
|
9
|
+
const assemble_js_1 = require("./assemble.js");
|
|
9
10
|
const intent_js_1 = require("./intent.js");
|
|
10
11
|
const shareSpending_js_1 = require("./shareSpending.js");
|
|
11
12
|
const validation_js_1 = require("./validation.js");
|
|
@@ -30,12 +31,8 @@ async function prepareVaultRedeem(client, params) {
|
|
|
30
31
|
supportSignature: intent.supportSignature,
|
|
31
32
|
now,
|
|
32
33
|
});
|
|
33
|
-
return (0,
|
|
34
|
-
|
|
35
|
-
account,
|
|
36
|
-
chainId,
|
|
37
|
-
expiresAt: intent.expiresAt,
|
|
38
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
34
|
+
return (0, assemble_js_1.freezePlan)({
|
|
35
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
39
36
|
steps: [
|
|
40
37
|
...approvals,
|
|
41
38
|
{
|
|
@@ -51,7 +48,7 @@ async function prepareVaultRedeem(client, params) {
|
|
|
51
48
|
},
|
|
52
49
|
],
|
|
53
50
|
signatureRequests,
|
|
54
|
-
})
|
|
51
|
+
}, { detach: true });
|
|
55
52
|
}
|
|
56
53
|
/** @internal Validates stored V1 and V2 exact-share redemption inputs. */
|
|
57
54
|
function validateRedeemPlanAction(action, path) {
|
|
@@ -9,6 +9,7 @@ import type { MidnightTakeBorrowParams } from "../actions/midnight/takeBorrow.js
|
|
|
9
9
|
import type { MidnightTakeLendParams } from "../actions/midnight/takeLend.js";
|
|
10
10
|
import type { MidnightTakeRepayWithdrawCollateralParams } from "../actions/midnight/takeRepayWithdrawCollateral.js";
|
|
11
11
|
import type { MidnightTakeableOffer } from "../actions/midnight/types.js";
|
|
12
|
+
import type { BlueReallocationInput } from "../helpers/validate.js";
|
|
12
13
|
import type { MidnightBlueSupply, MidnightCollateralTransfer } from "../types/action.js";
|
|
13
14
|
import type { AuthorizationSignatureArgs, PermitAction, RequirementTypedData, VaultV1MigrateToV2AmountArgs, VaultV2BlueReallocation } from "../types/index.js";
|
|
14
15
|
import type { MidnightCancelAndMakeParams } from "../types/midnightCancelAndMake.js";
|
|
@@ -255,12 +256,12 @@ export type Action = {
|
|
|
255
256
|
} | {
|
|
256
257
|
readonly type: "blueWithdraw";
|
|
257
258
|
readonly inputs: ActionInputs & {
|
|
258
|
-
readonly marketParams:
|
|
259
|
+
readonly marketParams: Readonly<InputMarketParams>;
|
|
259
260
|
readonly withdrawAssets: bigint;
|
|
260
261
|
readonly withdrawShares: bigint;
|
|
261
262
|
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
262
263
|
readonly maxPenalty?: bigint;
|
|
263
|
-
readonly reallocations: readonly
|
|
264
|
+
readonly reallocations: readonly BlueReallocationInput[];
|
|
264
265
|
readonly deadline: bigint;
|
|
265
266
|
readonly referralFeePct: bigint;
|
|
266
267
|
readonly referralFeeRecipient: Address;
|
|
@@ -470,7 +471,7 @@ export interface TransactionPlan {
|
|
|
470
471
|
readonly account: Address;
|
|
471
472
|
/** Unix seconds. One expiry governs every step deadline and signature deadline. */
|
|
472
473
|
readonly expiresAt: number;
|
|
473
|
-
/** Appended verbatim to
|
|
474
|
+
/** Appended verbatim to the action transaction's calldata; ERC-20 approval, Morpho authorization and Midnight authorization steps carry none. */
|
|
474
475
|
readonly calldataOrigin?: Hex;
|
|
475
476
|
readonly steps: readonly Step[];
|
|
476
477
|
readonly signatureRequests: readonly SignatureRequest[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Address } from "viem";
|
|
2
|
+
import type { Action } from "./types.js";
|
|
3
|
+
declare const VAULT_PERMIT_ACTION_TYPES: readonly ["vaultV2Deposit", "vaultV1Deposit", "vaultV1Withdraw", "vaultV2Withdraw", "vaultV2Redeem", "vaultV1Redeem", "vaultV2ForceWithdraw", "vaultV1MigrateToV2", "vaultV2InKindRedeem", "vaultV1InKindRedeem"];
|
|
4
|
+
/** @internal Vault actions whose step pulls a token through a bundle and may consume a permit. */
|
|
5
|
+
export type VaultPermitAction = Extract<Action, {
|
|
6
|
+
readonly type: (typeof VAULT_PERMIT_ACTION_TYPES)[number];
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* @internal The bundle, signed token and amounts a vault action's token permit must match.
|
|
10
|
+
* `restore` binds the stored signing payload; `build` is what the bundle pull selects, which differs
|
|
11
|
+
* from `restore` for deposits (`assets` versus `assets ?? nativeAssets`).
|
|
12
|
+
*/
|
|
13
|
+
export interface VaultPermitBinding {
|
|
14
|
+
readonly bundler: "bundles.vaultBundlesV1" | "bundles.vaultExitBundlesV1";
|
|
15
|
+
readonly asset: Address;
|
|
16
|
+
readonly restore: {
|
|
17
|
+
readonly amount: bigint | undefined;
|
|
18
|
+
readonly exact: boolean;
|
|
19
|
+
};
|
|
20
|
+
readonly build: {
|
|
21
|
+
readonly amount: bigint;
|
|
22
|
+
readonly pull: "token" | "shares";
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** @internal Whether the action is one of the vault actions a token permit can fund. */
|
|
26
|
+
export declare function isVaultPermitAction(action: Action): action is VaultPermitAction;
|
|
27
|
+
/** @internal Reads the permit binding from the vault action's stored inputs. */
|
|
28
|
+
export declare function getVaultPermitBinding(action: VaultPermitAction): VaultPermitBinding;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isVaultPermitAction = isVaultPermitAction;
|
|
4
|
+
exports.getVaultPermitBinding = getVaultPermitBinding;
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const VAULT_PERMIT_ACTION_TYPES = [
|
|
7
|
+
"vaultV2Deposit",
|
|
8
|
+
"vaultV1Deposit",
|
|
9
|
+
"vaultV1Withdraw",
|
|
10
|
+
"vaultV2Withdraw",
|
|
11
|
+
"vaultV2Redeem",
|
|
12
|
+
"vaultV1Redeem",
|
|
13
|
+
"vaultV2ForceWithdraw",
|
|
14
|
+
"vaultV1MigrateToV2",
|
|
15
|
+
"vaultV2InKindRedeem",
|
|
16
|
+
"vaultV1InKindRedeem",
|
|
17
|
+
];
|
|
18
|
+
/** @internal Whether the action is one of the vault actions a token permit can fund. */
|
|
19
|
+
function isVaultPermitAction(action) {
|
|
20
|
+
return VAULT_PERMIT_ACTION_TYPES.includes(action.type);
|
|
21
|
+
}
|
|
22
|
+
/** @internal Reads the permit binding from the vault action's stored inputs. */
|
|
23
|
+
function getVaultPermitBinding(action) {
|
|
24
|
+
switch (action.type) {
|
|
25
|
+
case "vaultV2Deposit":
|
|
26
|
+
case "vaultV1Deposit":
|
|
27
|
+
return {
|
|
28
|
+
bundler: "bundles.vaultBundlesV1",
|
|
29
|
+
asset: action.inputs.asset,
|
|
30
|
+
restore: { amount: action.inputs.assets, exact: true },
|
|
31
|
+
build: {
|
|
32
|
+
amount: action.inputs.assets ?? action.inputs.nativeAssets,
|
|
33
|
+
pull: "token",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
case "vaultV1Withdraw":
|
|
37
|
+
case "vaultV2Withdraw":
|
|
38
|
+
return {
|
|
39
|
+
bundler: "bundles.vaultBundlesV1",
|
|
40
|
+
asset: action.inputs.vault,
|
|
41
|
+
restore: { amount: action.inputs.requiredShareAllowance, exact: false },
|
|
42
|
+
build: { amount: action.inputs.requiredShareAllowance, pull: "shares" },
|
|
43
|
+
};
|
|
44
|
+
case "vaultV2Redeem":
|
|
45
|
+
case "vaultV1Redeem":
|
|
46
|
+
return {
|
|
47
|
+
bundler: "bundles.vaultBundlesV1",
|
|
48
|
+
asset: action.inputs.vault,
|
|
49
|
+
restore: { amount: action.inputs.shares, exact: false },
|
|
50
|
+
build: { amount: action.inputs.shares, pull: "shares" },
|
|
51
|
+
};
|
|
52
|
+
case "vaultV1MigrateToV2":
|
|
53
|
+
return {
|
|
54
|
+
bundler: "bundles.vaultBundlesV1",
|
|
55
|
+
asset: action.inputs.sourceVault,
|
|
56
|
+
restore: { amount: action.inputs.requiredShareAllowance, exact: false },
|
|
57
|
+
build: { amount: action.inputs.requiredShareAllowance, pull: "shares" },
|
|
58
|
+
};
|
|
59
|
+
case "vaultV2ForceWithdraw":
|
|
60
|
+
case "vaultV2InKindRedeem":
|
|
61
|
+
case "vaultV1InKindRedeem":
|
|
62
|
+
return {
|
|
63
|
+
bundler: "bundles.vaultExitBundlesV1",
|
|
64
|
+
asset: action.inputs.vault,
|
|
65
|
+
restore: { amount: viem_1.maxUint256, exact: true },
|
|
66
|
+
build: { amount: viem_1.maxUint256, pull: "shares" },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type ActionRequirement } from "../types/index.js";
|
|
3
|
+
import type { SignatureRequest, Step } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal Turns a vault exit's share requirements into approval steps and permit requests.
|
|
6
|
+
* Steps take the ID `${id}:approval` and requests `${id}:tokenPermit`; `signatureRequestIds`
|
|
7
|
+
* names the permit only when one is requested.
|
|
8
|
+
* @throws {UnsupportedRequirementSignatureError} If a requirement is a signature other than a permit.
|
|
9
|
+
*/
|
|
10
|
+
export declare function vaultRequirementSteps(requirements: readonly ActionRequirement[], { id, chainId, account, }: {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly chainId: number;
|
|
13
|
+
readonly account: Address;
|
|
14
|
+
}): {
|
|
15
|
+
readonly approvals: Step[];
|
|
16
|
+
readonly signatureRequests: SignatureRequest[];
|
|
17
|
+
readonly signatureRequestIds: {
|
|
18
|
+
readonly tokenPermit?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vaultRequirementSteps = vaultRequirementSteps;
|
|
4
|
+
const index_js_1 = require("../types/index.js");
|
|
5
|
+
const requirements_js_1 = require("./requirements.js");
|
|
6
|
+
/**
|
|
7
|
+
* @internal Turns a vault exit's share requirements into approval steps and permit requests.
|
|
8
|
+
* Steps take the ID `${id}:approval` and requests `${id}:tokenPermit`; `signatureRequestIds`
|
|
9
|
+
* names the permit only when one is requested.
|
|
10
|
+
* @throws {UnsupportedRequirementSignatureError} If a requirement is a signature other than a permit.
|
|
11
|
+
*/
|
|
12
|
+
function vaultRequirementSteps(requirements, { id, chainId, account, }) {
|
|
13
|
+
const approvals = [];
|
|
14
|
+
const signatureRequests = [];
|
|
15
|
+
const tokenPermit = `${id}:tokenPermit`;
|
|
16
|
+
for (const requirement of requirements) {
|
|
17
|
+
if ((0, index_js_1.isRequirementApproval)(requirement)) {
|
|
18
|
+
approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
|
|
19
|
+
id: `${id}:approval`,
|
|
20
|
+
chainId,
|
|
21
|
+
account,
|
|
22
|
+
denomination: "shares",
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
else if (requirement.action.type === "permit") {
|
|
26
|
+
signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)({ action: requirement.action }, tokenPermit));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new index_js_1.UnsupportedRequirementSignatureError(requirement.action.type);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
approvals,
|
|
34
|
+
signatureRequests,
|
|
35
|
+
signatureRequestIds: signatureRequests.length > 0 ? { tokenPermit } : {},
|
|
36
|
+
};
|
|
37
|
+
}
|