@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
|
@@ -47,7 +47,7 @@ export interface VaultV1DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
47
47
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
48
48
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
49
49
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
50
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
50
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
51
51
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
52
52
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
53
53
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV1Deposit = prepareVaultV1Deposit;
|
|
4
4
|
exports.buildVaultV1Deposit = buildVaultV1Deposit;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const deposit_js_1 = require("../../actions/vaultV1/deposit.js");
|
|
8
6
|
const deposit_js_2 = require("../deposit.js");
|
|
9
7
|
const permit_js_1 = require("../permit.js");
|
|
@@ -25,7 +23,7 @@ const permit_js_1 = require("../permit.js");
|
|
|
25
23
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
26
24
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
27
25
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
28
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
26
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
29
27
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
30
28
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
31
29
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
@@ -71,16 +69,7 @@ async function prepareVaultV1Deposit(client, params) {
|
|
|
71
69
|
/** @internal Encodes the deposit from its self-contained inputs and resolved signature requests. */
|
|
72
70
|
function buildVaultV1Deposit(action, requests) {
|
|
73
71
|
const { asset, chainId, account, assets, nativeAssets, ...args } = action.inputs;
|
|
74
|
-
const
|
|
75
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
76
|
-
asset,
|
|
77
|
-
owner: account,
|
|
78
|
-
});
|
|
79
|
-
const requirementSignature = (0, common_js_1.selectBundlesTokenRequirementSignature)(signature ? [signature] : [], {
|
|
80
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
81
|
-
amount: assets ?? nativeAssets,
|
|
82
|
-
deadline: action.inputs.deadline,
|
|
83
|
-
});
|
|
72
|
+
const requirementSignature = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
84
73
|
return (0, deposit_js_1.vaultV1Deposit)({
|
|
85
74
|
vault: { chainId, address: action.inputs.vault, asset },
|
|
86
75
|
args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccrualVault, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Client } from "viem";
|
|
3
|
+
import type { ReferenceTimestampParams, Transaction, VaultV1InKindRedeemAction } from "../../types/index.js";
|
|
4
4
|
import { type IntentParams } from "../intent.js";
|
|
5
5
|
import type { Action, SignatureRequest, TransactionPlan } from "../types.js";
|
|
6
6
|
/**
|
|
@@ -4,17 +4,15 @@ exports.prepareVaultV1InKindRedeem = prepareVaultV1InKindRedeem;
|
|
|
4
4
|
exports.buildVaultV1InKindRedeem = buildVaultV1InKindRedeem;
|
|
5
5
|
exports.validateInKindRedeemPlanAction = validateInKindRedeemPlanAction;
|
|
6
6
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
9
7
|
const inKindRedeem_js_1 = require("../../actions/vaultV1/inKindRedeem.js");
|
|
10
8
|
const getVaultV1InKindRedeemRequirements_js_1 = require("../../entities/requirements/getVaultV1InKindRedeemRequirements.js");
|
|
11
9
|
const inKindRedeemQuote_js_1 = require("../../entities/vaultV1/inKindRedeemQuote.js");
|
|
12
10
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
|
-
const
|
|
11
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
12
|
const intent_js_1 = require("../intent.js");
|
|
15
13
|
const permit_js_1 = require("../permit.js");
|
|
16
|
-
const requirements_js_1 = require("../requirements.js");
|
|
17
14
|
const validation_js_1 = require("../validation.js");
|
|
15
|
+
const vaultRequirements_js_1 = require("../vaultRequirements.js");
|
|
18
16
|
/**
|
|
19
17
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
20
18
|
* Prepares the stable Vault V1 in-kind exit through VaultExitBundlesV1.
|
|
@@ -103,31 +101,13 @@ async function prepareVaultV1InKindRedeem(client, params) {
|
|
|
103
101
|
now,
|
|
104
102
|
amount: params.assets,
|
|
105
103
|
});
|
|
106
|
-
const approvals =
|
|
107
|
-
|
|
108
|
-
const id = "vaultV1InKindRedeem:tokenPermit";
|
|
109
|
-
for (const requirement of requirements) {
|
|
110
|
-
if ((0, index_js_1.isRequirementApproval)(requirement)) {
|
|
111
|
-
approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
|
|
112
|
-
id: "vaultV1InKindRedeem:approval",
|
|
113
|
-
chainId,
|
|
114
|
-
account,
|
|
115
|
-
denomination: "shares",
|
|
116
|
-
}));
|
|
117
|
-
}
|
|
118
|
-
else if (requirement.action.type === "permit") {
|
|
119
|
-
signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)({ action: requirement.action }, id));
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
throw new index_js_1.UnsupportedRequirementSignatureError(requirement.action.type);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return (0, morpho_ts_1.deepFreeze)(structuredClone({
|
|
126
|
-
version: 2,
|
|
104
|
+
const { approvals, signatureRequests, signatureRequestIds } = (0, vaultRequirements_js_1.vaultRequirementSteps)(requirements, {
|
|
105
|
+
id: "vaultV1InKindRedeem",
|
|
127
106
|
chainId,
|
|
128
107
|
account,
|
|
129
|
-
|
|
130
|
-
|
|
108
|
+
});
|
|
109
|
+
return (0, assemble_js_1.freezePlan)({
|
|
110
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
131
111
|
steps: [
|
|
132
112
|
...approvals,
|
|
133
113
|
{
|
|
@@ -143,28 +123,17 @@ async function prepareVaultV1InKindRedeem(client, params) {
|
|
|
143
123
|
deadline: inputs.deadline,
|
|
144
124
|
marketParamsList: inputs.marketParamsList,
|
|
145
125
|
},
|
|
146
|
-
signatureRequestIds
|
|
147
|
-
? { tokenPermit: id }
|
|
148
|
-
: {},
|
|
126
|
+
signatureRequestIds,
|
|
149
127
|
},
|
|
150
128
|
},
|
|
151
129
|
],
|
|
152
130
|
signatureRequests,
|
|
153
|
-
})
|
|
131
|
+
}, { detach: true });
|
|
154
132
|
}
|
|
155
133
|
/** @internal Encodes the fixed in-kind exit with its referenced permit. */
|
|
156
134
|
function buildVaultV1InKindRedeem(action, requests) {
|
|
157
135
|
const { chainId, account, vault, assets, ...args } = action.inputs;
|
|
158
|
-
const
|
|
159
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
160
|
-
asset: vault,
|
|
161
|
-
owner: account,
|
|
162
|
-
});
|
|
163
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
164
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultExitBundlesV1"),
|
|
165
|
-
amount: viem_1.maxUint256,
|
|
166
|
-
deadline: action.inputs.deadline,
|
|
167
|
-
});
|
|
136
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
168
137
|
return (0, inKindRedeem_js_1.vaultV1InKindRedeem)({
|
|
169
138
|
vault: { chainId, address: vault },
|
|
170
139
|
args: {
|
|
@@ -47,7 +47,7 @@ export type VaultV1MigrateToV2PlanParams = Omit<IntentParams, "deployless"> & Re
|
|
|
47
47
|
* @param params.supportSignature - Optional unlimited ERC-2612 share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient. Vault V1 shares support ERC-2612; no Permit2 is used.
|
|
48
48
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
49
49
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
50
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
50
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
51
51
|
* @returns A static migration plan with any required source share approval or permit.
|
|
52
52
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
53
53
|
* @throws {VaultAssetMismatchError} If the vault assets differ.
|
|
@@ -11,6 +11,7 @@ const migrateToV2_js_1 = require("../../actions/vaultV1/migrateToV2.js");
|
|
|
11
11
|
const migrateToV2Quote_js_1 = require("../../entities/vaultV1/migrateToV2Quote.js");
|
|
12
12
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
13
|
const index_js_1 = require("../../types/index.js");
|
|
14
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
15
|
const error_js_1 = require("../error.js");
|
|
15
16
|
const intent_js_1 = require("../intent.js");
|
|
16
17
|
const permit_js_1 = require("../permit.js");
|
|
@@ -65,7 +66,7 @@ function validateMigrateToV2PlanAction(action, path) {
|
|
|
65
66
|
* @param params.supportSignature - Optional unlimited ERC-2612 share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient. Vault V1 shares support ERC-2612; no Permit2 is used.
|
|
66
67
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
67
68
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
68
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
69
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
69
70
|
* @returns A static migration plan with any required source share approval or permit.
|
|
70
71
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
71
72
|
* @throws {VaultAssetMismatchError} If the vault assets differ.
|
|
@@ -162,12 +163,8 @@ async function prepareVaultV1MigrateToV2(client, params) {
|
|
|
162
163
|
supportSignature: intent.supportSignature,
|
|
163
164
|
now,
|
|
164
165
|
});
|
|
165
|
-
return (0,
|
|
166
|
-
|
|
167
|
-
account,
|
|
168
|
-
chainId,
|
|
169
|
-
expiresAt: intent.expiresAt,
|
|
170
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
166
|
+
return (0, assemble_js_1.freezePlan)({
|
|
167
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
171
168
|
steps: [
|
|
172
169
|
...approvals,
|
|
173
170
|
{
|
|
@@ -194,21 +191,12 @@ async function prepareVaultV1MigrateToV2(client, params) {
|
|
|
194
191
|
},
|
|
195
192
|
],
|
|
196
193
|
signatureRequests,
|
|
197
|
-
})
|
|
194
|
+
}, { detach: true });
|
|
198
195
|
}
|
|
199
196
|
/** @internal Maps stored maxSharePrice to the ABI maxSharePriceVaultV2 and encodes the source permit. */
|
|
200
197
|
function buildVaultV1MigrateToV2(action, requests) {
|
|
201
198
|
const { vault: _vault, sourceVault, maxSharePrice, asset, requiredShareAllowance, chainId, account, ...args } = action.inputs;
|
|
202
|
-
const
|
|
203
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
204
|
-
asset: sourceVault,
|
|
205
|
-
owner: account,
|
|
206
|
-
});
|
|
207
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
208
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
209
|
-
amount: requiredShareAllowance,
|
|
210
|
-
deadline: args.deadline,
|
|
211
|
-
});
|
|
199
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
212
200
|
return (0, migrateToV2_js_1.vaultV1MigrateToV2)({
|
|
213
201
|
vault: { chainId, address: sourceVault, asset },
|
|
214
202
|
args: {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV1Redeem = prepareVaultV1Redeem;
|
|
4
4
|
exports.buildVaultV1Redeem = buildVaultV1Redeem;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const redeem_js_1 = require("../../actions/vaultV1/redeem.js");
|
|
8
6
|
const permit_js_1 = require("../permit.js");
|
|
9
7
|
const redeem_js_2 = require("../redeem.js");
|
|
@@ -57,16 +55,7 @@ async function prepareVaultV1Redeem(client, params) {
|
|
|
57
55
|
/** @internal Encodes a redemption from fixed inputs and the referenced share permit. */
|
|
58
56
|
function buildVaultV1Redeem(action, requests) {
|
|
59
57
|
const { chainId, account, ...args } = action.inputs;
|
|
60
|
-
const
|
|
61
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
62
|
-
asset: action.inputs.vault,
|
|
63
|
-
owner: account,
|
|
64
|
-
});
|
|
65
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
66
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
67
|
-
amount: action.inputs.shares,
|
|
68
|
-
deadline: action.inputs.deadline,
|
|
69
|
-
});
|
|
58
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
70
59
|
return (0, redeem_js_1.vaultV1Redeem)({
|
|
71
60
|
vault: { chainId, address: action.inputs.vault },
|
|
72
61
|
args: {
|
|
@@ -36,7 +36,7 @@ export interface VaultV1WithdrawPlanParams extends WithdrawPlanParams<AccrualVau
|
|
|
36
36
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
37
37
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
38
38
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
39
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
39
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
40
40
|
* @returns A plan with the withdrawal step and any required share approval or signature request.
|
|
41
41
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
42
42
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV1Withdraw = prepareVaultV1Withdraw;
|
|
4
4
|
exports.buildVaultV1Withdraw = buildVaultV1Withdraw;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const withdraw_js_1 = require("../../actions/vaultV1/withdraw.js");
|
|
8
6
|
const permit_js_1 = require("../permit.js");
|
|
9
7
|
const withdraw_js_2 = require("../withdraw.js");
|
|
@@ -26,7 +24,7 @@ const withdraw_js_2 = require("../withdraw.js");
|
|
|
26
24
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
27
25
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
28
26
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
29
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
27
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
30
28
|
* @returns A plan with the withdrawal step and any required share approval or signature request.
|
|
31
29
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
32
30
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -66,16 +64,7 @@ async function prepareVaultV1Withdraw(client, params) {
|
|
|
66
64
|
/** @internal Encodes the withdrawal from its self-contained inputs and resolved signature requests. */
|
|
67
65
|
function buildVaultV1Withdraw(action, requests) {
|
|
68
66
|
const { requiredShareAllowance, chainId, account, assets, ...args } = action.inputs;
|
|
69
|
-
const
|
|
70
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
71
|
-
asset: action.inputs.vault,
|
|
72
|
-
owner: account,
|
|
73
|
-
});
|
|
74
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
75
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
76
|
-
amount: requiredShareAllowance,
|
|
77
|
-
deadline: action.inputs.deadline,
|
|
78
|
-
});
|
|
67
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
79
68
|
return (0, withdraw_js_1.vaultV1Withdraw)({
|
|
80
69
|
vault: { chainId, address: action.inputs.vault },
|
|
81
70
|
args: {
|
|
@@ -26,7 +26,7 @@ export interface VaultV2DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
26
26
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
27
27
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
28
28
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
29
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
29
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
30
30
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
31
31
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
32
32
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareVaultV2Deposit = prepareVaultV2Deposit;
|
|
4
4
|
exports.buildVaultV2Deposit = buildVaultV2Deposit;
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
7
5
|
const deposit_js_1 = require("../../actions/vaultV2/deposit.js");
|
|
8
6
|
const deposit_js_2 = require("../deposit.js");
|
|
9
7
|
const permit_js_1 = require("../permit.js");
|
|
@@ -24,7 +22,7 @@ const permit_js_1 = require("../permit.js");
|
|
|
24
22
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
25
23
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
26
24
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
27
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
25
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
28
26
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
29
27
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
30
28
|
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
@@ -64,16 +62,7 @@ async function prepareVaultV2Deposit(client, params) {
|
|
|
64
62
|
/** @internal Encodes the deposit from its self-contained inputs and resolved signature requests. */
|
|
65
63
|
function buildVaultV2Deposit(action, requests) {
|
|
66
64
|
const { asset, chainId, account, assets, nativeAssets, ...args } = action.inputs;
|
|
67
|
-
const
|
|
68
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
69
|
-
asset,
|
|
70
|
-
owner: account,
|
|
71
|
-
});
|
|
72
|
-
const requirementSignature = (0, common_js_1.selectBundlesTokenRequirementSignature)(signature ? [signature] : [], {
|
|
73
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1"),
|
|
74
|
-
amount: assets ?? nativeAssets,
|
|
75
|
-
deadline: action.inputs.deadline,
|
|
76
|
-
});
|
|
65
|
+
const requirementSignature = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
77
66
|
return (0, deposit_js_1.vaultV2Deposit)({
|
|
78
67
|
vault: { chainId, address: action.inputs.vault, asset },
|
|
79
68
|
args: {
|
|
@@ -37,7 +37,7 @@ export interface VaultV2ForceRedeemPlanParams extends Pick<IntentParams, "chainI
|
|
|
37
37
|
* @param params.deallocations - Non-empty, ordered deallocations with positive `assets` in asset base units, including any penalty buffer.
|
|
38
38
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
39
39
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` and is plan metadata only.
|
|
40
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
40
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
41
41
|
* @returns A deep-frozen `TransactionPlan` containing one `vaultV2ForceRedeem` step and no signature requests.
|
|
42
42
|
* @throws {ChainIdMismatchError} If the client targets another chain.
|
|
43
43
|
* @throws {EmptyDeallocationsError} If `deallocations` is empty.
|
|
@@ -7,6 +7,7 @@ const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
|
7
7
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
8
8
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
9
9
|
const forceRedeem_js_1 = require("../../actions/vaultV2/forceRedeem.js");
|
|
10
|
+
const assemble_js_1 = require("../assemble.js");
|
|
10
11
|
const intent_js_1 = require("../intent.js");
|
|
11
12
|
const validation_js_1 = require("../validation.js");
|
|
12
13
|
/** @internal Validates the stored force-redeem action's plain input shape. */
|
|
@@ -55,7 +56,7 @@ function validateForceRedeemPlanAction(action, path) {
|
|
|
55
56
|
* @param params.deallocations - Non-empty, ordered deallocations with positive `assets` in asset base units, including any penalty buffer.
|
|
56
57
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
57
58
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` and is plan metadata only.
|
|
58
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
59
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
59
60
|
* @returns A deep-frozen `TransactionPlan` containing one `vaultV2ForceRedeem` step and no signature requests.
|
|
60
61
|
* @throws {ChainIdMismatchError} If the client targets another chain.
|
|
61
62
|
* @throws {EmptyDeallocationsError} If `deallocations` is empty.
|
|
@@ -90,11 +91,7 @@ async function prepareVaultV2ForceRedeem(client, params) {
|
|
|
90
91
|
const now = params.now ?? morpho_ts_1.Time.timestamp();
|
|
91
92
|
const intent = (0, intent_js_1.resolveIntent)(params, now);
|
|
92
93
|
const plan = structuredClone({
|
|
93
|
-
|
|
94
|
-
account: params.account,
|
|
95
|
-
chainId: params.chainId,
|
|
96
|
-
expiresAt: intent.expiresAt,
|
|
97
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
94
|
+
...(0, assemble_js_1.planHeader)({ chainId: params.chainId, account: params.account }, intent),
|
|
98
95
|
steps: [
|
|
99
96
|
{
|
|
100
97
|
id: "vaultV2ForceRedeem",
|
|
@@ -128,7 +125,7 @@ async function prepareVaultV2ForceRedeem(client, params) {
|
|
|
128
125
|
// Validate the cloned inputs with the action encoder before returning a plan.
|
|
129
126
|
buildVaultV2ForceRedeem(plan.steps[0].action);
|
|
130
127
|
await (0, validateClientChainId_js_1.validateClientChainId)(client, params.chainId);
|
|
131
|
-
return (0,
|
|
128
|
+
return (0, assemble_js_1.freezePlan)(plan, { detach: false });
|
|
132
129
|
}
|
|
133
130
|
/** @internal Encodes the fixed multicall through the same action as the forceRedeem handle. */
|
|
134
131
|
function buildVaultV2ForceRedeem(action) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AccrualVaultV2 } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import type { Address, Client } from "viem";
|
|
3
3
|
import { type ReferenceTimestampParams, type Transaction, type VaultV2ForceWithdrawAction } from "../../types/index.js";
|
|
4
4
|
import { type IntentParams } from "../intent.js";
|
|
5
5
|
import type { Action, SignatureRequest, TransactionPlan } from "../types.js";
|
|
@@ -44,7 +44,7 @@ export interface VaultV2ForceWithdrawPlanParams extends Omit<IntentParams, "depl
|
|
|
44
44
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; insufficient allowance produces an unlimited direct share approval, or an unlimited share permit when `true`.
|
|
45
45
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
46
46
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now` and within the fee-projection horizon; defaults to `now + 2h`.
|
|
47
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
47
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
48
48
|
* @returns A deep-frozen plan containing ordered share approvals, if needed, followed by the forced exit and its concrete permit request, if needed.
|
|
49
49
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
50
50
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -4,18 +4,17 @@ exports.prepareVaultV2ForceWithdraw = prepareVaultV2ForceWithdraw;
|
|
|
4
4
|
exports.buildVaultV2ForceWithdraw = buildVaultV2ForceWithdraw;
|
|
5
5
|
exports.validateForceWithdrawPlanAction = validateForceWithdrawPlanAction;
|
|
6
6
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
9
7
|
const forceWithdraw_js_1 = require("../../actions/vaultV2/forceWithdraw.js");
|
|
10
8
|
const getVaultV2ForceWithdrawRequirements_js_1 = require("../../entities/requirements/getVaultV2ForceWithdrawRequirements.js");
|
|
11
9
|
const forceWithdrawQuote_js_1 = require("../../entities/vaultV2/forceWithdrawQuote.js");
|
|
12
10
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
11
|
const index_js_1 = require("../../types/index.js");
|
|
12
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
13
|
const error_js_1 = require("../error.js");
|
|
15
14
|
const intent_js_1 = require("../intent.js");
|
|
16
15
|
const permit_js_1 = require("../permit.js");
|
|
17
|
-
const requirements_js_1 = require("../requirements.js");
|
|
18
16
|
const validation_js_1 = require("../validation.js");
|
|
17
|
+
const vaultRequirements_js_1 = require("../vaultRequirements.js");
|
|
19
18
|
/**
|
|
20
19
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
21
20
|
* Prepares a static forced-exit plan using shared snapshot quoting and requirement helpers.
|
|
@@ -34,7 +33,7 @@ const validation_js_1 = require("../validation.js");
|
|
|
34
33
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; insufficient allowance produces an unlimited direct share approval, or an unlimited share permit when `true`.
|
|
35
34
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
36
35
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now` and within the fee-projection horizon; defaults to `now + 2h`.
|
|
37
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
36
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
38
37
|
* @returns A deep-frozen plan containing ordered share approvals, if needed, followed by the forced exit and its concrete permit request, if needed.
|
|
39
38
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
40
39
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -119,31 +118,13 @@ async function prepareVaultV2ForceWithdraw(client, params) {
|
|
|
119
118
|
supportSignature: intent.supportSignature,
|
|
120
119
|
now,
|
|
121
120
|
});
|
|
122
|
-
const approvals =
|
|
123
|
-
|
|
124
|
-
const tokenPermitRequestId = "vaultV2ForceWithdraw:tokenPermit";
|
|
125
|
-
for (const requirement of requirements) {
|
|
126
|
-
if ((0, index_js_1.isRequirementApproval)(requirement)) {
|
|
127
|
-
approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
|
|
128
|
-
id: "vaultV2ForceWithdraw:approval",
|
|
129
|
-
chainId,
|
|
130
|
-
account,
|
|
131
|
-
denomination: "shares",
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
|
-
else if (requirement.action.type === "permit") {
|
|
135
|
-
signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)({ action: requirement.action }, tokenPermitRequestId));
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
throw new index_js_1.UnsupportedRequirementSignatureError(requirement.action.type);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return (0, morpho_ts_1.deepFreeze)(structuredClone({
|
|
142
|
-
version: 2,
|
|
143
|
-
account,
|
|
121
|
+
const { approvals, signatureRequests, signatureRequestIds } = (0, vaultRequirements_js_1.vaultRequirementSteps)(requirements, {
|
|
122
|
+
id: "vaultV2ForceWithdraw",
|
|
144
123
|
chainId,
|
|
145
|
-
|
|
146
|
-
|
|
124
|
+
account,
|
|
125
|
+
});
|
|
126
|
+
return (0, assemble_js_1.freezePlan)({
|
|
127
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
147
128
|
steps: [
|
|
148
129
|
...approvals,
|
|
149
130
|
{
|
|
@@ -152,14 +133,12 @@ async function prepareVaultV2ForceWithdraw(client, params) {
|
|
|
152
133
|
action: {
|
|
153
134
|
type: "vaultV2ForceWithdraw",
|
|
154
135
|
inputs: { ...inputs, assets, chainId, account },
|
|
155
|
-
signatureRequestIds
|
|
156
|
-
? { tokenPermit: tokenPermitRequestId }
|
|
157
|
-
: {},
|
|
136
|
+
signatureRequestIds,
|
|
158
137
|
},
|
|
159
138
|
},
|
|
160
139
|
],
|
|
161
140
|
signatureRequests,
|
|
162
|
-
})
|
|
141
|
+
}, { detach: true });
|
|
163
142
|
}
|
|
164
143
|
/** @internal Encodes the forced exit from fixed inputs and its referenced vault-share permit. */
|
|
165
144
|
function buildVaultV2ForceWithdraw(action, requests) {
|
|
@@ -167,16 +146,7 @@ function buildVaultV2ForceWithdraw(action, requests) {
|
|
|
167
146
|
if (args.minSharePriceE27 <= 0n) {
|
|
168
147
|
throw new index_js_1.NonPositiveInputError("minSharePriceE27", args.minSharePriceE27);
|
|
169
148
|
}
|
|
170
|
-
const
|
|
171
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
172
|
-
asset: action.inputs.vault,
|
|
173
|
-
owner: account,
|
|
174
|
-
});
|
|
175
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
176
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultExitBundlesV1"),
|
|
177
|
-
amount: viem_1.maxUint256,
|
|
178
|
-
deadline: action.inputs.deadline,
|
|
179
|
-
});
|
|
149
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
180
150
|
return (0, forceWithdraw_js_1.vaultV2ForceWithdraw)({
|
|
181
151
|
vault: { chainId, address: action.inputs.vault },
|
|
182
152
|
args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccrualVaultV2, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Address, Client } from "viem";
|
|
3
|
+
import type { ReferenceTimestampParams, Transaction, VaultV2InKindRedeemAction } from "../../types/index.js";
|
|
4
4
|
import { type IntentParams } from "../intent.js";
|
|
5
5
|
import type { Action, SignatureRequest, TransactionPlan } from "../types.js";
|
|
6
6
|
/**
|
|
@@ -4,17 +4,15 @@ exports.prepareVaultV2InKindRedeem = prepareVaultV2InKindRedeem;
|
|
|
4
4
|
exports.buildVaultV2InKindRedeem = buildVaultV2InKindRedeem;
|
|
5
5
|
exports.validateInKindRedeemPlanAction = validateInKindRedeemPlanAction;
|
|
6
6
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const common_js_1 = require("../../actions/bundles/common.js");
|
|
9
7
|
const inKindRedeem_js_1 = require("../../actions/vaultV2/inKindRedeem.js");
|
|
10
8
|
const getVaultV2InKindRedeemRequirements_js_1 = require("../../entities/requirements/getVaultV2InKindRedeemRequirements.js");
|
|
11
9
|
const inKindRedeemQuote_js_1 = require("../../entities/vaultV2/inKindRedeemQuote.js");
|
|
12
10
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
|
-
const
|
|
11
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
12
|
const intent_js_1 = require("../intent.js");
|
|
15
13
|
const permit_js_1 = require("../permit.js");
|
|
16
|
-
const requirements_js_1 = require("../requirements.js");
|
|
17
14
|
const validation_js_1 = require("../validation.js");
|
|
15
|
+
const vaultRequirements_js_1 = require("../vaultRequirements.js");
|
|
18
16
|
/**
|
|
19
17
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
20
18
|
* Prepares the existing Vault V2 in-kind exit through VaultExitBundlesV1. Preparation validates
|
|
@@ -112,31 +110,13 @@ async function prepareVaultV2InKindRedeem(client, params) {
|
|
|
112
110
|
peak: quote.peak,
|
|
113
111
|
now,
|
|
114
112
|
});
|
|
115
|
-
const approvals =
|
|
116
|
-
|
|
117
|
-
const tokenPermit = "vaultV2InKindRedeem:tokenPermit";
|
|
118
|
-
for (const requirement of requirements) {
|
|
119
|
-
if ((0, index_js_1.isRequirementApproval)(requirement)) {
|
|
120
|
-
approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
|
|
121
|
-
id: "vaultV2InKindRedeem:approval",
|
|
122
|
-
chainId,
|
|
123
|
-
account,
|
|
124
|
-
denomination: "shares",
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
else if (requirement.action.type === "permit") {
|
|
128
|
-
signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)({ action: requirement.action }, tokenPermit));
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
throw new index_js_1.UnsupportedRequirementSignatureError(requirement.action.type);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return (0, morpho_ts_1.deepFreeze)(structuredClone({
|
|
135
|
-
version: 2,
|
|
113
|
+
const { approvals, signatureRequests, signatureRequestIds } = (0, vaultRequirements_js_1.vaultRequirementSteps)(requirements, {
|
|
114
|
+
id: "vaultV2InKindRedeem",
|
|
136
115
|
chainId,
|
|
137
116
|
account,
|
|
138
|
-
|
|
139
|
-
|
|
117
|
+
});
|
|
118
|
+
return (0, assemble_js_1.freezePlan)({
|
|
119
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
140
120
|
steps: [
|
|
141
121
|
...approvals,
|
|
142
122
|
{
|
|
@@ -145,28 +125,17 @@ async function prepareVaultV2InKindRedeem(client, params) {
|
|
|
145
125
|
action: {
|
|
146
126
|
type: "vaultV2InKindRedeem",
|
|
147
127
|
inputs: { ...inputs, assets, chainId, account },
|
|
148
|
-
signatureRequestIds
|
|
149
|
-
? { tokenPermit }
|
|
150
|
-
: {},
|
|
128
|
+
signatureRequestIds,
|
|
151
129
|
},
|
|
152
130
|
},
|
|
153
131
|
],
|
|
154
132
|
signatureRequests,
|
|
155
|
-
})
|
|
133
|
+
}, { detach: true });
|
|
156
134
|
}
|
|
157
135
|
/** @internal Encodes only the saved inputs and referenced unlimited share permit. */
|
|
158
136
|
function buildVaultV2InKindRedeem(action, requests) {
|
|
159
137
|
const { chainId, account, assets, ...args } = action.inputs;
|
|
160
|
-
const
|
|
161
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
162
|
-
asset: args.vault,
|
|
163
|
-
owner: account,
|
|
164
|
-
});
|
|
165
|
-
const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signature ? [signature] : [], {
|
|
166
|
-
spender: (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultExitBundlesV1"),
|
|
167
|
-
amount: viem_1.maxUint256,
|
|
168
|
-
deadline: args.deadline,
|
|
169
|
-
});
|
|
138
|
+
const permit = (0, permit_js_1.selectVaultPermit)(action, requests);
|
|
170
139
|
return (0, inKindRedeem_js_1.vaultV2InKindRedeem)({
|
|
171
140
|
vault: { chainId, address: args.vault },
|
|
172
141
|
args: {
|
|
@@ -40,7 +40,7 @@ export interface VaultV2RedeemPlanParams extends RedeemPlanParams {
|
|
|
40
40
|
* @param params.supportSignature - Optional ERC-2612 share-permit preference; defaults to `false` for direct approval.
|
|
41
41
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
42
42
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
43
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
43
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
44
44
|
* @returns A deep-frozen, serializable `TransactionPlan` with version, chain, account, expiry,
|
|
45
45
|
* ordered approval/redeem steps and signature requests. Any required share approval or permit is unlimited.
|
|
46
46
|
* @throws {ZeroAccountError} when `account` is the zero address.
|