@morpho-org/morpho-sdk 10.4.0 → 10.5.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/actions/blue/common.js +12 -3
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +16 -11
- package/lib/cjs/actions/midnight/takeBorrow.js +14 -8
- package/lib/cjs/actions/midnight/takeLend.js +15 -9
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +19 -13
- package/lib/cjs/actions/midnight/takeWithdraw.js +14 -8
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +3 -2
- package/lib/cjs/entities/midnight/midnight.d.ts +106 -103
- package/lib/cjs/entities/midnight/midnight.js +120 -101
- package/lib/cjs/entities/vaultV1/vaultV1.js +0 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +0 -1
- package/lib/cjs/helpers/constant.d.ts +7 -0
- package/lib/cjs/helpers/constant.js +8 -1
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/validate.d.ts +25 -1
- package/lib/cjs/helpers/validate.js +25 -1
- 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 +6 -2
- package/lib/cjs/transactionPlan/midnight/takeBorrow.js +10 -4
- 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 +27 -1
- package/lib/cjs/types/error.js +32 -3
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/actions/blue/common.js +13 -4
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +16 -11
- package/lib/esm/actions/midnight/takeBorrow.js +14 -8
- package/lib/esm/actions/midnight/takeLend.js +15 -9
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +19 -13
- package/lib/esm/actions/midnight/takeWithdraw.js +14 -8
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/midnight/midnight.d.ts +106 -103
- package/lib/esm/entities/midnight/midnight.js +120 -101
- package/lib/esm/entities/vaultV1/vaultV1.js +0 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +0 -1
- package/lib/esm/helpers/constant.d.ts +7 -0
- package/lib/esm/helpers/constant.js +7 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/validate.d.ts +25 -1
- package/lib/esm/helpers/validate.js +25 -2
- 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 +6 -2
- package/lib/esm/transactionPlan/midnight/takeBorrow.js +11 -5
- 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 +27 -1
- package/lib/esm/types/error.js +30 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -5,14 +5,15 @@ exports.prepareBlueSupply = prepareBlueSupply;
|
|
|
5
5
|
exports.validateBlueSupplyPermitRequest = validateBlueSupplyPermitRequest;
|
|
6
6
|
exports.buildBlueSupply = buildBlueSupply;
|
|
7
7
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
8
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
9
8
|
const supply_js_1 = require("../../actions/blue/supply.js");
|
|
10
9
|
const common_js_1 = require("../../actions/bundles/common.js");
|
|
11
10
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
11
|
+
const assemble_js_1 = require("../assemble.js");
|
|
12
12
|
const error_js_1 = require("../error.js");
|
|
13
13
|
const permit_js_1 = require("../permit.js");
|
|
14
14
|
const validation_js_1 = require("../validation.js");
|
|
15
15
|
const prepare_js_1 = require("./prepare.js");
|
|
16
|
+
const stored_js_1 = require("./stored.js");
|
|
16
17
|
/** @internal Validates the stored supply recipe without requiring class instances. */
|
|
17
18
|
function validateBlueSupplyPlanAction(action, path) {
|
|
18
19
|
const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
|
|
@@ -20,9 +21,7 @@ function validateBlueSupplyPlanAction(action, path) {
|
|
|
20
21
|
path: `${path}.inputs`,
|
|
21
22
|
fields: {
|
|
22
23
|
assets: "uint256 bigint",
|
|
23
|
-
|
|
24
|
-
referralFeePct: "uint256 bigint",
|
|
25
|
-
referralFeeRecipient: "address",
|
|
24
|
+
...stored_js_1.BUNDLES_COMMON_FIELDS,
|
|
26
25
|
},
|
|
27
26
|
});
|
|
28
27
|
if (inputs.nativeAssets !== undefined) {
|
|
@@ -32,17 +31,7 @@ function validateBlueSupplyPlanAction(action, path) {
|
|
|
32
31
|
});
|
|
33
32
|
validateNativeAssets(inputs, `${path}.inputs.nativeAssets`);
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
(0, validation_js_1.validatePlanFields)(market, {
|
|
37
|
-
path: `${path}.inputs.marketParams`,
|
|
38
|
-
fields: {
|
|
39
|
-
loanToken: "address",
|
|
40
|
-
collateralToken: "address",
|
|
41
|
-
oracle: "address",
|
|
42
|
-
irm: "address",
|
|
43
|
-
lltv: "uint256 bigint",
|
|
44
|
-
},
|
|
45
|
-
});
|
|
34
|
+
(0, stored_js_1.validateStoredBlueMarketParams)(inputs.marketParams, `${path}.inputs.marketParams`);
|
|
46
35
|
(0, validation_js_1.getPlanObject)(action.signatureRequestIds, `${path}.signatureRequestIds`);
|
|
47
36
|
}
|
|
48
37
|
/**
|
|
@@ -157,12 +146,8 @@ async function prepareBlueSupply(client, params) {
|
|
|
157
146
|
});
|
|
158
147
|
await (0, validateClientChainId_js_1.validateClientChainId)(client, chainId);
|
|
159
148
|
const { intent, steps, signatureRequests } = prepared;
|
|
160
|
-
return (0,
|
|
161
|
-
|
|
162
|
-
chainId,
|
|
163
|
-
account,
|
|
164
|
-
expiresAt: intent.expiresAt,
|
|
165
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
149
|
+
return (0, assemble_js_1.freezePlan)({
|
|
150
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
166
151
|
steps: [
|
|
167
152
|
...steps,
|
|
168
153
|
{
|
|
@@ -185,7 +170,7 @@ async function prepareBlueSupply(client, params) {
|
|
|
185
170
|
},
|
|
186
171
|
],
|
|
187
172
|
signatureRequests,
|
|
188
|
-
})
|
|
173
|
+
}, { detach: true });
|
|
189
174
|
}
|
|
190
175
|
/** @internal Binds an exact token permit to this supply's pull. */
|
|
191
176
|
function validateBlueSupplyPermitRequest(request, action) {
|
|
@@ -45,7 +45,7 @@ export interface BlueSupplyCollateralPlanParams extends IntentParams, ReferenceT
|
|
|
45
45
|
* @param params.supportSignature - Prefer an ERC-2612 permit where available; defaults to false.
|
|
46
46
|
* @param params.now - Reference Unix timestamp in seconds; defaults to the device clock.
|
|
47
47
|
* @param params.expiresAt - Expiry in Unix seconds, later than `now`; defaults to `now + 2h`.
|
|
48
|
-
* @param params.calldataOrigin - Optional non-empty hex bytes appended to
|
|
48
|
+
* @param params.calldataOrigin - Optional non-empty hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
49
49
|
* @param params.deployless - Whether permit metadata reads may use deployless aggregation.
|
|
50
50
|
* @returns A frozen plan containing the collateral supply step and any token prerequisites.
|
|
51
51
|
* @throws {BlueSnapshotChainMismatchError} when the snapshot comes from another chain.
|
|
@@ -5,16 +5,17 @@ exports.validateSupplyCollateralPlanAction = validateSupplyCollateralPlanAction;
|
|
|
5
5
|
exports.validateSupplyCollateralPermitRequest = validateSupplyCollateralPermitRequest;
|
|
6
6
|
exports.buildBlueSupplyCollateral = buildBlueSupplyCollateral;
|
|
7
7
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
8
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
9
8
|
const viem_1 = require("viem");
|
|
10
9
|
const supplyCollateral_js_1 = require("../../actions/blue/supplyCollateral.js");
|
|
11
10
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
12
11
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
12
|
const index_js_1 = require("../../types/index.js");
|
|
13
|
+
const assemble_js_1 = require("../assemble.js");
|
|
14
14
|
const error_js_1 = require("../error.js");
|
|
15
15
|
const permit_js_1 = require("../permit.js");
|
|
16
16
|
const validation_js_1 = require("../validation.js");
|
|
17
17
|
const prepare_js_1 = require("./prepare.js");
|
|
18
|
+
const stored_js_1 = require("./stored.js");
|
|
18
19
|
const actionId = "blueSupplyCollateral";
|
|
19
20
|
/**
|
|
20
21
|
* Prepares a collateral-only supply through BlueBundlesV1 from a caller-fetched market snapshot.
|
|
@@ -34,7 +35,7 @@ const actionId = "blueSupplyCollateral";
|
|
|
34
35
|
* @param params.supportSignature - Prefer an ERC-2612 permit where available; defaults to false.
|
|
35
36
|
* @param params.now - Reference Unix timestamp in seconds; defaults to the device clock.
|
|
36
37
|
* @param params.expiresAt - Expiry in Unix seconds, later than `now`; defaults to `now + 2h`.
|
|
37
|
-
* @param params.calldataOrigin - Optional non-empty hex bytes appended to
|
|
38
|
+
* @param params.calldataOrigin - Optional non-empty hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
38
39
|
* @param params.deployless - Whether permit metadata reads may use deployless aggregation.
|
|
39
40
|
* @returns A frozen plan containing the collateral supply step and any token prerequisites.
|
|
40
41
|
* @throws {BlueSnapshotChainMismatchError} when the snapshot comes from another chain.
|
|
@@ -99,12 +100,8 @@ async function prepareBlueSupplyCollateral(client, params) {
|
|
|
99
100
|
await (0, validateClientChainId_js_1.validateClientChainId)(client, chainId);
|
|
100
101
|
}
|
|
101
102
|
const tokenPermit = signatureRequests.find(({ kind }) => kind === "permit");
|
|
102
|
-
return (0,
|
|
103
|
-
|
|
104
|
-
chainId,
|
|
105
|
-
account,
|
|
106
|
-
expiresAt: intent.expiresAt,
|
|
107
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
103
|
+
return (0, assemble_js_1.freezePlan)({
|
|
104
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
|
|
108
105
|
steps: [
|
|
109
106
|
...steps,
|
|
110
107
|
{
|
|
@@ -122,14 +119,14 @@ async function prepareBlueSupplyCollateral(client, params) {
|
|
|
122
119
|
referralFeePct: intent.referralFeePct,
|
|
123
120
|
referralFeeRecipient: intent.referralFeeRecipient ?? viem_1.zeroAddress,
|
|
124
121
|
},
|
|
125
|
-
signatureRequestIds:
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
signatureRequestIds: (0, stored_js_1.signatureRoles)({
|
|
123
|
+
tokenPermit: tokenPermit?.id,
|
|
124
|
+
}),
|
|
128
125
|
},
|
|
129
126
|
},
|
|
130
127
|
],
|
|
131
128
|
signatureRequests,
|
|
132
|
-
})
|
|
129
|
+
}, { detach: true });
|
|
133
130
|
}
|
|
134
131
|
/** @internal Validates the stored collateral supply action and its token permit role. */
|
|
135
132
|
function validateSupplyCollateralPlanAction(action, path) {
|
|
@@ -139,9 +136,7 @@ function validateSupplyCollateralPlanAction(action, path) {
|
|
|
139
136
|
path: inputsPath,
|
|
140
137
|
fields: {
|
|
141
138
|
collateralAssets: "uint256 bigint",
|
|
142
|
-
|
|
143
|
-
referralFeePct: "uint256 bigint",
|
|
144
|
-
referralFeeRecipient: "address",
|
|
139
|
+
...stored_js_1.BUNDLES_COMMON_FIELDS,
|
|
145
140
|
},
|
|
146
141
|
});
|
|
147
142
|
const marketPath = `${inputsPath}.marketParams`;
|
|
@@ -13,11 +13,13 @@ const getBlueBundlesV1QuoteTimestamp_js_1 = require("../../helpers/getBlueBundle
|
|
|
13
13
|
const index_js_1 = require("../../helpers/index.js");
|
|
14
14
|
const parse_js_1 = require("../../helpers/parse.js");
|
|
15
15
|
const index_js_2 = require("../../types/index.js");
|
|
16
|
+
const assemble_js_1 = require("../assemble.js");
|
|
16
17
|
const error_js_1 = require("../error.js");
|
|
17
18
|
const permit_js_1 = require("../permit.js");
|
|
18
19
|
const validation_js_1 = require("../validation.js");
|
|
19
20
|
const authorization_js_1 = require("./authorization.js");
|
|
20
21
|
const prepare_js_1 = require("./prepare.js");
|
|
22
|
+
const stored_js_1 = require("./stored.js");
|
|
21
23
|
/**
|
|
22
24
|
* Prepares collateral funding and Morpho authorization for one BlueBundlesV1 call. Snapshots
|
|
23
25
|
* are validated before reads; health uses the expiry floored at max(now, lastUpdate).
|
|
@@ -162,14 +164,8 @@ async function prepareBlueSupplyCollateralBorrow(client, params) {
|
|
|
162
164
|
await (0, validateClientChainId_js_1.validateClientChainId)(client, chainId);
|
|
163
165
|
const authorization = prepared.signatureRequests.find((request) => request.id === prepared.morphoAuthorizationRequestId);
|
|
164
166
|
const permit = prepared.signatureRequests.find((request) => request.kind === "permit");
|
|
165
|
-
return (0,
|
|
166
|
-
|
|
167
|
-
chainId,
|
|
168
|
-
account,
|
|
169
|
-
expiresAt: prepared.intent.expiresAt,
|
|
170
|
-
...(prepared.intent.calldataOrigin && {
|
|
171
|
-
calldataOrigin: prepared.intent.calldataOrigin,
|
|
172
|
-
}),
|
|
167
|
+
return (0, assemble_js_1.freezePlan)({
|
|
168
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, prepared.intent),
|
|
173
169
|
steps: [
|
|
174
170
|
...prepared.steps,
|
|
175
171
|
{
|
|
@@ -205,15 +201,15 @@ async function prepareBlueSupplyCollateralBorrow(client, params) {
|
|
|
205
201
|
authorizationNonce: authorization.args.nonce,
|
|
206
202
|
}),
|
|
207
203
|
},
|
|
208
|
-
signatureRequestIds: {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
},
|
|
204
|
+
signatureRequestIds: (0, stored_js_1.signatureRoles)({
|
|
205
|
+
tokenPermit: permit?.id,
|
|
206
|
+
morphoAuthorization: authorization?.id,
|
|
207
|
+
}),
|
|
212
208
|
},
|
|
213
209
|
},
|
|
214
210
|
],
|
|
215
211
|
signatureRequests: prepared.signatureRequests,
|
|
216
|
-
})
|
|
212
|
+
}, { detach: true });
|
|
217
213
|
}
|
|
218
214
|
function captureSupplyBorrowIntent(params) {
|
|
219
215
|
const { chainId, account, marketId, marketData, positionData, expiresAt, referralFee, supportSignature, calldataOrigin, deployless, now = morpho_ts_1.Time.timestamp(), } = params;
|
|
@@ -300,26 +296,6 @@ function buildBlueSupplyCollateralBorrow(action, requests) {
|
|
|
300
296
|
},
|
|
301
297
|
});
|
|
302
298
|
}
|
|
303
|
-
function validateMarket(value, path) {
|
|
304
|
-
const market = (0, validation_js_1.getPlanObject)(value, path);
|
|
305
|
-
(0, validation_js_1.validatePlanFields)(market, {
|
|
306
|
-
path,
|
|
307
|
-
fields: {
|
|
308
|
-
id: "hex",
|
|
309
|
-
loanToken: "address",
|
|
310
|
-
collateralToken: "address",
|
|
311
|
-
oracle: "address",
|
|
312
|
-
irm: "address",
|
|
313
|
-
lltv: "uint256 bigint",
|
|
314
|
-
},
|
|
315
|
-
});
|
|
316
|
-
if (typeof market.id !== "string" || market.id.length !== 66) {
|
|
317
|
-
throw new error_js_1.InvalidTransactionPlanError({
|
|
318
|
-
path: `${path}.id`,
|
|
319
|
-
reason: "expected a 32-byte market ID",
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
299
|
/** @internal Validates the complete stored input and reallocation shape. */
|
|
324
300
|
function validateSupplyCollateralBorrowPlanAction(action, path) {
|
|
325
301
|
const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
|
|
@@ -352,7 +328,7 @@ function validateSupplyCollateralBorrowPlanAction(action, path) {
|
|
|
352
328
|
type: "address",
|
|
353
329
|
});
|
|
354
330
|
}
|
|
355
|
-
|
|
331
|
+
(0, stored_js_1.validateStoredBlueMarket)(inputs.marketParams, `${path}.inputs.marketParams`);
|
|
356
332
|
const ids = (0, validation_js_1.getPlanObject)(action.signatureRequestIds, `${path}.signatureRequestIds`);
|
|
357
333
|
for (const key of Object.keys(ids)) {
|
|
358
334
|
if (key !== "tokenPermit" && key !== "morphoAuthorization") {
|
|
@@ -379,34 +355,8 @@ function validateSupplyCollateralBorrowPlanAction(action, path) {
|
|
|
379
355
|
type: "uint256 bigint",
|
|
380
356
|
});
|
|
381
357
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
path: entryPath,
|
|
387
|
-
fields: {
|
|
388
|
-
vault: "address",
|
|
389
|
-
assets: "uint256 bigint",
|
|
390
|
-
penalty: "uint256 bigint",
|
|
391
|
-
},
|
|
392
|
-
});
|
|
393
|
-
(0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(entry.to, `${entryPath}.to`), {
|
|
394
|
-
path: `${entryPath}.to`,
|
|
395
|
-
fields: { adapter: "address" },
|
|
396
|
-
});
|
|
397
|
-
const from = (0, validation_js_1.getPlanObject)(entry.from, `${entryPath}.from`);
|
|
398
|
-
if (from.type === "market") {
|
|
399
|
-
(0, validation_js_1.validatePlanFields)(from, {
|
|
400
|
-
path: `${entryPath}.from`,
|
|
401
|
-
fields: { adapter: "address" },
|
|
402
|
-
});
|
|
403
|
-
validateMarket(from.marketParams, `${entryPath}.from.marketParams`);
|
|
404
|
-
}
|
|
405
|
-
else if (from.type !== "idle") {
|
|
406
|
-
throw new error_js_1.InvalidTransactionPlanError({
|
|
407
|
-
path: `${entryPath}.from.type`,
|
|
408
|
-
reason: "expected market or idle",
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
}
|
|
358
|
+
(0, stored_js_1.validateStoredReallocations)(inputs.reallocations, {
|
|
359
|
+
path: `${path}.inputs.reallocations`,
|
|
360
|
+
marketParams: stored_js_1.validateStoredBlueMarket,
|
|
361
|
+
});
|
|
412
362
|
}
|
|
@@ -69,7 +69,7 @@ export type BlueWithdrawPlanParams = IntentParams & AssetsOrSharesArgs & {
|
|
|
69
69
|
* @param params.supportSignature - Optional Morpho authorization signature preference; defaults to `false`, selecting a direct authorization transaction when needed. Neither mode requests a token allowance or Permit2 signature.
|
|
70
70
|
* @param params.now - Optional reference timestamp in seconds, normally the latest block timestamp; defaults to the device clock.
|
|
71
71
|
* @param params.expiresAt - Optional Unix expiry in safe-integer seconds, later than `now`; defaults to `now + 2h`.
|
|
72
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
72
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata, not to approval or authorization steps; omitted by default.
|
|
73
73
|
* @param params.deployless - Optional shared intent field; unused because withdrawal reads no token metadata.
|
|
74
74
|
* @returns A deep-frozen, data-only `{ version, chainId, account, expiresAt, steps, signatureRequests, calldataOrigin? }` plan with a withdrawal step. Direct Morpho authorization is a preceding step; signed authorization is consumed inline by the withdrawal. Attach signatures before building.
|
|
75
75
|
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
@@ -100,7 +100,6 @@ export type BlueWithdrawPlanParams = IntentParams & AssetsOrSharesArgs & {
|
|
|
100
100
|
* @throws {WithdrawSharesExceedSupplyError} when `shares` exceeds the position's supply shares.
|
|
101
101
|
* @throws {MissingContractCodeError} when registered BlueBundlesV1 or Blue has no deployed code.
|
|
102
102
|
* @throws {viem.BaseError} when a chain, bytecode, authorization or nonce RPC read fails, or ABI encoding rejects malformed input.
|
|
103
|
-
* @throws {UnexpectedRequirementSignatureError} when an authorization requirement returns a nonce that is not a bigint.
|
|
104
103
|
* @throws {TransactionPlanSignatureMismatchError} when the authorization requirement does not match the prepared account, chain, nonce or deadline.
|
|
105
104
|
* @example
|
|
106
105
|
* ```ts
|
|
@@ -120,7 +119,7 @@ export type BlueWithdrawPlanParams = IntentParams & AssetsOrSharesArgs & {
|
|
|
120
119
|
* positionData: { chainId: mainnet.id, position },
|
|
121
120
|
* now: (await client.getBlock()).timestamp,
|
|
122
121
|
* });
|
|
123
|
-
* // plan: { version:
|
|
122
|
+
* // plan: { version: 2, chainId, account, expiresAt, steps, signatureRequests }
|
|
124
123
|
* // Sign any pending Morpho authorization request, then build and submit each step in order.
|
|
125
124
|
* ```
|
|
126
125
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
@@ -5,17 +5,18 @@ exports.validateBlueWithdrawAuthorizationRequest = validateBlueWithdrawAuthoriza
|
|
|
5
5
|
exports.buildBlueWithdraw = buildBlueWithdraw;
|
|
6
6
|
exports.validateBlueWithdrawPlanAction = validateBlueWithdrawPlanAction;
|
|
7
7
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
8
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
9
8
|
const viem_1 = require("viem");
|
|
10
9
|
const common_js_1 = require("../../actions/blue/common.js");
|
|
11
10
|
const withdraw_js_1 = require("../../actions/blue/withdraw.js");
|
|
12
11
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
13
12
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
14
13
|
const index_js_1 = require("../../types/index.js");
|
|
14
|
+
const assemble_js_1 = require("../assemble.js");
|
|
15
15
|
const error_js_1 = require("../error.js");
|
|
16
16
|
const validation_js_1 = require("../validation.js");
|
|
17
17
|
const authorization_js_1 = require("./authorization.js");
|
|
18
18
|
const prepare_js_1 = require("./prepare.js");
|
|
19
|
+
const stored_js_1 = require("./stored.js");
|
|
19
20
|
/**
|
|
20
21
|
* Prepares a BlueBundlesV1 withdrawal with only Morpho authorization prerequisites, never token approvals.
|
|
21
22
|
* The caller supplies market and position snapshots; the SDK reads authorization but never signs.
|
|
@@ -48,7 +49,7 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
48
49
|
* @param params.supportSignature - Optional Morpho authorization signature preference; defaults to `false`, selecting a direct authorization transaction when needed. Neither mode requests a token allowance or Permit2 signature.
|
|
49
50
|
* @param params.now - Optional reference timestamp in seconds, normally the latest block timestamp; defaults to the device clock.
|
|
50
51
|
* @param params.expiresAt - Optional Unix expiry in safe-integer seconds, later than `now`; defaults to `now + 2h`.
|
|
51
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
52
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata, not to approval or authorization steps; omitted by default.
|
|
52
53
|
* @param params.deployless - Optional shared intent field; unused because withdrawal reads no token metadata.
|
|
53
54
|
* @returns A deep-frozen, data-only `{ version, chainId, account, expiresAt, steps, signatureRequests, calldataOrigin? }` plan with a withdrawal step. Direct Morpho authorization is a preceding step; signed authorization is consumed inline by the withdrawal. Attach signatures before building.
|
|
54
55
|
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
@@ -79,7 +80,6 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
79
80
|
* @throws {WithdrawSharesExceedSupplyError} when `shares` exceeds the position's supply shares.
|
|
80
81
|
* @throws {MissingContractCodeError} when registered BlueBundlesV1 or Blue has no deployed code.
|
|
81
82
|
* @throws {viem.BaseError} when a chain, bytecode, authorization or nonce RPC read fails, or ABI encoding rejects malformed input.
|
|
82
|
-
* @throws {UnexpectedRequirementSignatureError} when an authorization requirement returns a nonce that is not a bigint.
|
|
83
83
|
* @throws {TransactionPlanSignatureMismatchError} when the authorization requirement does not match the prepared account, chain, nonce or deadline.
|
|
84
84
|
* @example
|
|
85
85
|
* ```ts
|
|
@@ -99,33 +99,65 @@ const prepare_js_1 = require("./prepare.js");
|
|
|
99
99
|
* positionData: { chainId: mainnet.id, position },
|
|
100
100
|
* now: (await client.getBlock()).timestamp,
|
|
101
101
|
* });
|
|
102
|
-
* // plan: { version:
|
|
102
|
+
* // plan: { version: 2, chainId, account, expiresAt, steps, signatureRequests }
|
|
103
103
|
* // Sign any pending Morpho authorization request, then build and submit each step in order.
|
|
104
104
|
* ```
|
|
105
105
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
106
106
|
*/
|
|
107
107
|
async function prepareBlueWithdraw(client, params) {
|
|
108
|
-
const { maxPenalty } = params;
|
|
109
|
-
|
|
108
|
+
const { maxPenalty, chainId, account } = params;
|
|
109
|
+
const supplied = params.reallocations ?? [];
|
|
110
|
+
let reallocations;
|
|
111
|
+
try {
|
|
112
|
+
reallocations = structuredClone(Array.isArray(supplied)
|
|
113
|
+
? supplied.map((entry) => {
|
|
114
|
+
if (entry === null ||
|
|
115
|
+
typeof entry !== "object" ||
|
|
116
|
+
"withdrawals" in entry ||
|
|
117
|
+
"fee" in entry) {
|
|
118
|
+
return entry;
|
|
119
|
+
}
|
|
120
|
+
const { vault, from, to, assets, penalty } = entry;
|
|
121
|
+
return { vault, from, to, assets, penalty };
|
|
122
|
+
})
|
|
123
|
+
: supplied);
|
|
124
|
+
}
|
|
125
|
+
catch (cause) {
|
|
126
|
+
throw new index_js_1.InvalidVaultV2BlueReallocationShapeError({ cause });
|
|
127
|
+
}
|
|
128
|
+
await (0, validateClientChainId_js_1.validateClientChainId)(client, chainId);
|
|
110
129
|
const { positionData: snapshot } = params;
|
|
111
130
|
if (snapshot == null) {
|
|
112
131
|
throw new index_js_1.MissingAccrualPositionError(params.marketId);
|
|
113
132
|
}
|
|
114
133
|
const withdrawals = [];
|
|
115
|
-
const
|
|
134
|
+
const captured = {
|
|
135
|
+
chainId,
|
|
136
|
+
account,
|
|
137
|
+
marketId: params.marketId,
|
|
138
|
+
marketData: params.marketData,
|
|
139
|
+
positionData: snapshot,
|
|
140
|
+
now: params.now,
|
|
141
|
+
expiresAt: params.expiresAt,
|
|
142
|
+
supportSignature: params.supportSignature,
|
|
143
|
+
referralFee: params.referralFee,
|
|
144
|
+
calldataOrigin: params.calldataOrigin,
|
|
145
|
+
deployless: params.deployless,
|
|
146
|
+
};
|
|
147
|
+
const { intent: resolvedIntent, steps, signatureRequests, } = await (0, prepare_js_1.prepareBlue)({ client, params: captured }, (intent) => {
|
|
116
148
|
const inputs = {
|
|
117
|
-
chainId
|
|
118
|
-
account
|
|
149
|
+
chainId,
|
|
150
|
+
account,
|
|
119
151
|
marketParams: {
|
|
120
|
-
loanToken:
|
|
121
|
-
collateralToken:
|
|
122
|
-
oracle:
|
|
123
|
-
irm:
|
|
124
|
-
lltv:
|
|
152
|
+
loanToken: captured.marketData.market.params.loanToken,
|
|
153
|
+
collateralToken: captured.marketData.market.params.collateralToken,
|
|
154
|
+
oracle: captured.marketData.market.params.oracle,
|
|
155
|
+
irm: captured.marketData.market.params.irm,
|
|
156
|
+
lltv: captured.marketData.market.params.lltv,
|
|
125
157
|
},
|
|
126
158
|
withdrawAssets: "assets" in params ? (params.assets ?? 0n) : 0n,
|
|
127
159
|
withdrawShares: "shares" in params ? (params.shares ?? 0n) : 0n,
|
|
128
|
-
reallocations
|
|
160
|
+
reallocations,
|
|
129
161
|
...(maxPenalty !== undefined && { maxPenalty }),
|
|
130
162
|
deadline: intent.deadline,
|
|
131
163
|
referralFeePct: intent.referralFeePct,
|
|
@@ -157,7 +189,7 @@ async function prepareBlueWithdraw(client, params) {
|
|
|
157
189
|
positionData,
|
|
158
190
|
withdrawShares: inputs.withdrawShares,
|
|
159
191
|
withdrawAssets: inputs.withdrawAssets,
|
|
160
|
-
marketId:
|
|
192
|
+
marketId: captured.marketId,
|
|
161
193
|
});
|
|
162
194
|
withdrawals.push({
|
|
163
195
|
id: "blueWithdraw",
|
|
@@ -166,14 +198,8 @@ async function prepareBlueWithdraw(client, params) {
|
|
|
166
198
|
});
|
|
167
199
|
return { id: "blueWithdraw", needsAuthorization: true };
|
|
168
200
|
});
|
|
169
|
-
return (0,
|
|
170
|
-
|
|
171
|
-
chainId: params.chainId,
|
|
172
|
-
account: params.account,
|
|
173
|
-
expiresAt: resolvedIntent.expiresAt,
|
|
174
|
-
...(resolvedIntent.calldataOrigin && {
|
|
175
|
-
calldataOrigin: resolvedIntent.calldataOrigin,
|
|
176
|
-
}),
|
|
201
|
+
return (0, assemble_js_1.freezePlan)({
|
|
202
|
+
...(0, assemble_js_1.planHeader)({ chainId, account }, resolvedIntent),
|
|
177
203
|
steps: [
|
|
178
204
|
...steps,
|
|
179
205
|
...withdrawals.map((step) => {
|
|
@@ -196,7 +222,7 @@ async function prepareBlueWithdraw(client, params) {
|
|
|
196
222
|
}),
|
|
197
223
|
],
|
|
198
224
|
signatureRequests,
|
|
199
|
-
})
|
|
225
|
+
}, { detach: true });
|
|
200
226
|
}
|
|
201
227
|
/** @internal Binds an inline authorization to the withdrawal that consumes it. */
|
|
202
228
|
function validateBlueWithdrawAuthorizationRequest(request, action) {
|
|
@@ -250,7 +276,7 @@ function buildBlueWithdraw(action, requests = []) {
|
|
|
250
276
|
},
|
|
251
277
|
};
|
|
252
278
|
}
|
|
253
|
-
const targetMarketParams =
|
|
279
|
+
const targetMarketParams = toEncoderMarketParams(marketParams);
|
|
254
280
|
// Reject malformed entries with typed errors before reading their source fields.
|
|
255
281
|
(0, validate_js_1.validateVaultV2BlueReallocations)(args.reallocations, {
|
|
256
282
|
targetMarketId: targetMarketParams.id,
|
|
@@ -261,7 +287,7 @@ function buildBlueWithdraw(action, requests = []) {
|
|
|
261
287
|
from: entry.from.type === "market"
|
|
262
288
|
? {
|
|
263
289
|
...entry.from,
|
|
264
|
-
marketParams:
|
|
290
|
+
marketParams: toEncoderMarketParams(entry.from.marketParams),
|
|
265
291
|
}
|
|
266
292
|
: entry.from,
|
|
267
293
|
}));
|
|
@@ -275,6 +301,15 @@ function buildBlueWithdraw(action, requests = []) {
|
|
|
275
301
|
},
|
|
276
302
|
});
|
|
277
303
|
}
|
|
304
|
+
function toEncoderMarketParams(marketParams) {
|
|
305
|
+
const { loanToken, collateralToken, oracle, irm, lltv } = marketParams;
|
|
306
|
+
const tuple = { loanToken, collateralToken, oracle, irm, lltv };
|
|
307
|
+
return {
|
|
308
|
+
...tuple,
|
|
309
|
+
id: blue_sdk_1.MarketUtils.getMarketId(tuple),
|
|
310
|
+
liquidationIncentiveFactor: blue_sdk_1.MarketUtils.getLiquidationIncentiveFactor(tuple),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
278
313
|
/** @internal Validates stored withdrawal scalars and allocator input shapes. */
|
|
279
314
|
function validateBlueWithdrawPlanAction(action, path) {
|
|
280
315
|
const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
|
|
@@ -300,60 +335,13 @@ function validateBlueWithdrawPlanAction(action, path) {
|
|
|
300
335
|
fields: {
|
|
301
336
|
withdrawAssets: "uint256 bigint",
|
|
302
337
|
withdrawShares: "uint256 bigint",
|
|
303
|
-
|
|
304
|
-
referralFeePct: "uint256 bigint",
|
|
305
|
-
referralFeeRecipient: "address",
|
|
338
|
+
...stored_js_1.BUNDLES_COMMON_FIELDS,
|
|
306
339
|
reallocations: "array",
|
|
307
340
|
},
|
|
308
341
|
});
|
|
309
|
-
(0,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
collateralToken: "address",
|
|
314
|
-
oracle: "address",
|
|
315
|
-
irm: "address",
|
|
316
|
-
lltv: "uint256 bigint",
|
|
317
|
-
},
|
|
342
|
+
(0, stored_js_1.validateStoredBlueMarketParams)(inputs.marketParams, `${path}.inputs.marketParams`);
|
|
343
|
+
(0, stored_js_1.validateStoredReallocations)(inputs.reallocations, {
|
|
344
|
+
path: `${path}.inputs.reallocations`,
|
|
345
|
+
marketParams: stored_js_1.validateStoredBlueMarketParams,
|
|
318
346
|
});
|
|
319
|
-
for (const [index, value] of inputs.reallocations.entries()) {
|
|
320
|
-
const entryPath = `${path}.inputs.reallocations[${index}]`;
|
|
321
|
-
const entry = (0, validation_js_1.getPlanObject)(value, entryPath);
|
|
322
|
-
(0, validation_js_1.validatePlanFields)(entry, {
|
|
323
|
-
path: entryPath,
|
|
324
|
-
fields: {
|
|
325
|
-
vault: "address",
|
|
326
|
-
assets: "uint256 bigint",
|
|
327
|
-
penalty: "uint256 bigint",
|
|
328
|
-
},
|
|
329
|
-
});
|
|
330
|
-
(0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(entry.to, `${entryPath}.to`), {
|
|
331
|
-
path: `${entryPath}.to`,
|
|
332
|
-
fields: { adapter: "address" },
|
|
333
|
-
});
|
|
334
|
-
const from = (0, validation_js_1.getPlanObject)(entry.from, `${entryPath}.from`);
|
|
335
|
-
if (from.type === "idle") {
|
|
336
|
-
continue;
|
|
337
|
-
}
|
|
338
|
-
if (from.type !== "market") {
|
|
339
|
-
throw new error_js_1.InvalidTransactionPlanError({
|
|
340
|
-
path: `${entryPath}.from.type`,
|
|
341
|
-
reason: "expected market or idle",
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
(0, validation_js_1.validatePlanFields)(from, {
|
|
345
|
-
path: `${entryPath}.from`,
|
|
346
|
-
fields: { adapter: "address" },
|
|
347
|
-
});
|
|
348
|
-
(0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(from.marketParams, `${entryPath}.from.marketParams`), {
|
|
349
|
-
path: `${entryPath}.from.marketParams`,
|
|
350
|
-
fields: {
|
|
351
|
-
loanToken: "address",
|
|
352
|
-
collateralToken: "address",
|
|
353
|
-
oracle: "address",
|
|
354
|
-
irm: "address",
|
|
355
|
-
lltv: "uint256 bigint",
|
|
356
|
-
},
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
347
|
}
|
|
@@ -48,7 +48,7 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
|
|
|
48
48
|
* @param params.supportSignature - Optional Morpho authorization signature preference, defaulting to `false`; otherwise prepares a direct authorization transaction when needed.
|
|
49
49
|
* @param params.now - Optional reference timestamp in Unix seconds, normally the latest block timestamp; defaults to the device clock.
|
|
50
50
|
* @param params.expiresAt - Optional safe-integer Unix expiry later than `now`; defaults to `now + 2h` and governs every deadline.
|
|
51
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to
|
|
51
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to the action transaction's calldata; approval and authorization steps carry none.
|
|
52
52
|
* @param params.deployless - Optional shared intent field; unused because this operation reads no token metadata or allowances.
|
|
53
53
|
* @returns A deep-frozen, data-only `TransactionPlan` with chain, account, expiry, withdrawal step,
|
|
54
54
|
* and any preceding Morpho authorization step and signature request. The caller signs; the SDK never does.
|
|
@@ -74,7 +74,6 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
|
|
|
74
74
|
* @throws {viem.BaseError} when a contract-code, chain ID, authorization or nonce RPC read fails.
|
|
75
75
|
* @example
|
|
76
76
|
* ```ts
|
|
77
|
-
* import assert from "node:assert/strict";
|
|
78
77
|
* import { markets } from "@morpho-org/morpho-test";
|
|
79
78
|
* import { fetchAccrualPosition } from "@morpho-org/morpho-sdk/blue/fetch";
|
|
80
79
|
* import {
|
|
@@ -89,7 +88,7 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
|
|
|
89
88
|
* if (!ethereum) throw new Error("Install an Ethereum wallet to continue.");
|
|
90
89
|
* const wallet = createWalletClient({ chain: mainnet, transport: custom(ethereum) });
|
|
91
90
|
* const [account] = await wallet.requestAddresses();
|
|
92
|
-
*
|
|
91
|
+
* if (!account) throw new Error("Connect a wallet holding collateral in this market.");
|
|
93
92
|
* const market = markets[mainnet.id].usdc_wbtc;
|
|
94
93
|
* const position = await fetchAccrualPosition(account, market.id, client);
|
|
95
94
|
* const plan = await prepareBlueWithdrawCollateral(client, {
|