@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
|
@@ -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, {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { AccrualPosition, MarketParams, MathLib, } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { Time } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { blueWithdrawCollateral } from "../../actions/blue/withdrawCollateral.js";
|
|
4
4
|
import { normalizeBundlesCommonParams } from "../../actions/bundles/common.js";
|
|
5
5
|
import { DEFAULT_LLTV_BUFFER } from "../../helpers/constant.js";
|
|
6
6
|
import { getBlueBundlesV1QuoteTimestamp } from "../../helpers/getBlueBundlesV1QuoteTimestamp.js";
|
|
7
7
|
import { validatePositionHealthAfterWithdraw, validateUint256Field, } from "../../helpers/validate.js";
|
|
8
8
|
import { NonPositiveInputError, } from "../../types/index.js";
|
|
9
|
+
import { freezePlan, planHeader } from "../assemble.js";
|
|
9
10
|
import { IncompleteTransactionPlanError, TransactionPlanSignatureMismatchError, } from "../error.js";
|
|
10
11
|
import { getPlanObject, validatePlanField, validatePlanFields, } from "../validation.js";
|
|
11
12
|
import { validateMorphoAuthorizationRequest } from "./authorization.js";
|
|
12
13
|
import { prepareBlue, } from "./prepare.js";
|
|
14
|
+
import { BUNDLES_COMMON_FIELDS, signatureRoles, validateStoredBlueMarketParams, } from "./stored.js";
|
|
13
15
|
/**
|
|
14
16
|
* Prepares a BlueBundlesV1 collateral withdrawal with direct or inline signed Morpho authorization.
|
|
15
17
|
* Health uses the expiry floored at max(now, lastUpdate), with the entity's LLTV buffer.
|
|
@@ -30,7 +32,7 @@ import { prepareBlue, } from "./prepare.js";
|
|
|
30
32
|
* @param params.supportSignature - Optional Morpho authorization signature preference, defaulting to `false`; otherwise prepares a direct authorization transaction when needed.
|
|
31
33
|
* @param params.now - Optional reference timestamp in Unix seconds, normally the latest block timestamp; defaults to the device clock.
|
|
32
34
|
* @param params.expiresAt - Optional safe-integer Unix expiry later than `now`; defaults to `now + 2h` and governs every deadline.
|
|
33
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to
|
|
35
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to the action transaction's calldata; approval and authorization steps carry none.
|
|
34
36
|
* @param params.deployless - Optional shared intent field; unused because this operation reads no token metadata or allowances.
|
|
35
37
|
* @returns A deep-frozen, data-only `TransactionPlan` with chain, account, expiry, withdrawal step,
|
|
36
38
|
* and any preceding Morpho authorization step and signature request. The caller signs; the SDK never does.
|
|
@@ -56,7 +58,6 @@ import { prepareBlue, } from "./prepare.js";
|
|
|
56
58
|
* @throws {viem.BaseError} when a contract-code, chain ID, authorization or nonce RPC read fails.
|
|
57
59
|
* @example
|
|
58
60
|
* ```ts
|
|
59
|
-
* import assert from "node:assert/strict";
|
|
60
61
|
* import { markets } from "@morpho-org/morpho-test";
|
|
61
62
|
* import { fetchAccrualPosition } from "@morpho-org/morpho-sdk/blue/fetch";
|
|
62
63
|
* import {
|
|
@@ -71,7 +72,7 @@ import { prepareBlue, } from "./prepare.js";
|
|
|
71
72
|
* if (!ethereum) throw new Error("Install an Ethereum wallet to continue.");
|
|
72
73
|
* const wallet = createWalletClient({ chain: mainnet, transport: custom(ethereum) });
|
|
73
74
|
* const [account] = await wallet.requestAddresses();
|
|
74
|
-
*
|
|
75
|
+
* if (!account) throw new Error("Connect a wallet holding collateral in this market.");
|
|
75
76
|
* const market = markets[mainnet.id].usdc_wbtc;
|
|
76
77
|
* const position = await fetchAccrualPosition(account, market.id, client);
|
|
77
78
|
* const plan = await prepareBlueWithdrawCollateral(client, {
|
|
@@ -92,10 +93,25 @@ import { prepareBlue, } from "./prepare.js";
|
|
|
92
93
|
*/
|
|
93
94
|
export async function prepareBlueWithdrawCollateral(client, params) {
|
|
94
95
|
const now = params.now ?? Time.timestamp();
|
|
95
|
-
const { chainId, account, collateralAssets, marketId } = params;
|
|
96
|
-
const { loanToken, collateralToken, oracle, irm, lltv } =
|
|
96
|
+
const { chainId, account, collateralAssets, marketId, marketData, positionData, expiresAt, supportSignature, referralFee, calldataOrigin, deployless, } = params;
|
|
97
|
+
const { loanToken, collateralToken, oracle, irm, lltv } = marketData.market.params;
|
|
97
98
|
const marketParams = { loanToken, collateralToken, oracle, irm, lltv };
|
|
98
|
-
const { intent, steps, signatureRequests, morphoAuthorizationRequestId } = await prepareBlue({
|
|
99
|
+
const { intent, steps, signatureRequests, morphoAuthorizationRequestId } = await prepareBlue({
|
|
100
|
+
client,
|
|
101
|
+
params: {
|
|
102
|
+
chainId,
|
|
103
|
+
account,
|
|
104
|
+
marketId,
|
|
105
|
+
marketData,
|
|
106
|
+
positionData,
|
|
107
|
+
now,
|
|
108
|
+
expiresAt,
|
|
109
|
+
supportSignature,
|
|
110
|
+
referralFee,
|
|
111
|
+
calldataOrigin,
|
|
112
|
+
deployless,
|
|
113
|
+
},
|
|
114
|
+
}, (resolvedIntent) => {
|
|
99
115
|
// Reject invalid fees and deadlines before authorization reads.
|
|
100
116
|
normalizeBundlesCommonParams(resolvedIntent);
|
|
101
117
|
if (collateralAssets <= 0n) {
|
|
@@ -103,7 +119,7 @@ export async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
103
119
|
}
|
|
104
120
|
// Reject amounts outside the ABI range before reading authorization state.
|
|
105
121
|
validateUint256Field("collateralAssets", collateralAssets);
|
|
106
|
-
const position =
|
|
122
|
+
const { position } = positionData;
|
|
107
123
|
// Validate health against the same accrual horizon used by the existing handle.
|
|
108
124
|
validatePositionHealthAfterWithdraw({
|
|
109
125
|
positionData: position.borrowShares === 0n
|
|
@@ -119,12 +135,8 @@ export async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
119
135
|
});
|
|
120
136
|
return { id: "blueWithdrawCollateral", needsAuthorization: true };
|
|
121
137
|
});
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
chainId,
|
|
125
|
-
account,
|
|
126
|
-
expiresAt: intent.expiresAt,
|
|
127
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
138
|
+
return freezePlan({
|
|
139
|
+
...planHeader({ chainId, account }, intent),
|
|
128
140
|
steps: [
|
|
129
141
|
...steps,
|
|
130
142
|
{
|
|
@@ -132,9 +144,9 @@ export async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
132
144
|
label: "Withdraw Blue collateral",
|
|
133
145
|
action: {
|
|
134
146
|
type: "blueWithdrawCollateral",
|
|
135
|
-
signatureRequestIds:
|
|
136
|
-
|
|
137
|
-
|
|
147
|
+
signatureRequestIds: signatureRoles({
|
|
148
|
+
morphoAuthorization: morphoAuthorizationRequestId,
|
|
149
|
+
}),
|
|
138
150
|
inputs: {
|
|
139
151
|
chainId,
|
|
140
152
|
account,
|
|
@@ -152,7 +164,7 @@ export async function prepareBlueWithdrawCollateral(client, params) {
|
|
|
152
164
|
},
|
|
153
165
|
],
|
|
154
166
|
signatureRequests,
|
|
155
|
-
});
|
|
167
|
+
}, { detach: false });
|
|
156
168
|
}
|
|
157
169
|
/** @internal Binds an inline authorization to the collateral withdrawal that consumes it. */
|
|
158
170
|
export function validateBlueWithdrawCollateralAuthorizationRequest(request, action) {
|
|
@@ -230,19 +242,8 @@ export function validateBlueWithdrawCollateralPlanAction(action, path) {
|
|
|
230
242
|
fields: {
|
|
231
243
|
collateralAssets: "uint256 bigint",
|
|
232
244
|
maxLtv: "uint256 bigint",
|
|
233
|
-
|
|
234
|
-
referralFeePct: "uint256 bigint",
|
|
235
|
-
referralFeeRecipient: "address",
|
|
236
|
-
},
|
|
237
|
-
});
|
|
238
|
-
validatePlanFields(getPlanObject(inputs.marketParams, `${path}.inputs.marketParams`), {
|
|
239
|
-
path: `${path}.inputs.marketParams`,
|
|
240
|
-
fields: {
|
|
241
|
-
loanToken: "address",
|
|
242
|
-
collateralToken: "address",
|
|
243
|
-
oracle: "address",
|
|
244
|
-
irm: "address",
|
|
245
|
-
lltv: "uint256 bigint",
|
|
245
|
+
...BUNDLES_COMMON_FIELDS,
|
|
246
246
|
},
|
|
247
247
|
});
|
|
248
|
+
validateStoredBlueMarketParams(inputs.marketParams, `${path}.inputs.marketParams`);
|
|
248
249
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { DEFAULT_SLIPPAGE_TOLERANCE, } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { getBundlesReferralFeeAssets, normalizeBundlesCommonParams, } from "../actions/bundles/common.js";
|
|
4
4
|
import { validateClientChainId } from "../actions/requirements/validateClientChainId.js";
|
|
5
5
|
import { assertRegistryTargetsHaveCode } from "../entities/requirements/assertContractCode.js";
|
|
6
6
|
import { computeVaultMaxSharePrice } from "../helpers/index.js";
|
|
7
7
|
import { validateNativeVaultAsset, validateReferenceTime, validateSlippageTolerance, validateUint256Field, validateVaultDepositDeadline, } from "../helpers/validate.js";
|
|
8
8
|
import { NonPositiveInputError, } from "../types/index.js";
|
|
9
|
+
import { freezePlan, planHeader } from "./assemble.js";
|
|
9
10
|
import { InvalidTransactionPlanError } from "./error.js";
|
|
10
11
|
import { resolveIntent } from "./intent.js";
|
|
11
12
|
import { getTokenRequirements } from "./requirements.js";
|
|
@@ -95,12 +96,8 @@ export async function prepareVaultDeposit(client, params) {
|
|
|
95
96
|
]);
|
|
96
97
|
const approvals = requirements?.approvals ?? [];
|
|
97
98
|
const signatureRequests = requirements?.permit === undefined ? [] : [requirements.permit];
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
account,
|
|
101
|
-
chainId,
|
|
102
|
-
expiresAt: intent.expiresAt,
|
|
103
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
99
|
+
return freezePlan({
|
|
100
|
+
...planHeader({ chainId, account }, intent),
|
|
104
101
|
steps: [
|
|
105
102
|
...approvals,
|
|
106
103
|
{
|
|
@@ -124,5 +121,5 @@ export async function prepareVaultDeposit(client, params) {
|
|
|
124
121
|
},
|
|
125
122
|
],
|
|
126
123
|
signatureRequests,
|
|
127
|
-
})
|
|
124
|
+
}, { detach: true });
|
|
128
125
|
}
|
|
@@ -29,7 +29,7 @@ export interface IntentParams {
|
|
|
29
29
|
readonly supportSignature?: boolean;
|
|
30
30
|
/** Unix seconds. Defaults to two hours from now. */
|
|
31
31
|
readonly expiresAt?: number;
|
|
32
|
-
/** Optional attribution bytes (at most 1 MiB) appended verbatim to
|
|
32
|
+
/** Optional attribution bytes (at most 1 MiB) appended verbatim to the action transaction's calldata; ERC-20 approval, Morpho authorization and Midnight authorization steps carry none. */
|
|
33
33
|
readonly calldataOrigin?: Hex;
|
|
34
34
|
/** Whether token metadata reads for permits may use deployless aggregation. */
|
|
35
35
|
readonly deployless?: boolean;
|
|
@@ -28,7 +28,7 @@ export type MidnightMakeBorrowPlanParams = MidnightMakerPublicationPlanParams;
|
|
|
28
28
|
* Omitting it cancels nothing (an untyped JavaScript `null` does too).
|
|
29
29
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
30
30
|
* @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the first offer expiry minus one second.
|
|
31
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
31
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
32
32
|
* @returns A frozen plan with persisted publication data that can be restored and built offline.
|
|
33
33
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now` or a cancellation ceiling is not a bigint; checked before any request.
|
|
34
34
|
* @throws {ZeroAccountError} If the submitting account is zero.
|
|
@@ -24,7 +24,7 @@ import { parseMakeBorrowParams } from "./prepare.js";
|
|
|
24
24
|
* Omitting it cancels nothing (an untyped JavaScript `null` does too).
|
|
25
25
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
26
26
|
* @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the first offer expiry minus one second.
|
|
27
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
27
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
28
28
|
* @returns A frozen plan with persisted publication data that can be restored and built offline.
|
|
29
29
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now` or a cancellation ceiling is not a bigint; checked before any request.
|
|
30
30
|
* @throws {ZeroAccountError} If the submitting account is zero.
|
|
@@ -40,7 +40,7 @@ export interface MidnightMakeLendPlanParams extends MidnightMakerPublicationPlan
|
|
|
40
40
|
* @param params.reservedLoanAssets - Optional loan assets reserved by other open groups, excluding cancelled groups; defaults to `0n`.
|
|
41
41
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
42
42
|
* @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the first offer expiry minus one second.
|
|
43
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
43
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
44
44
|
* @returns A frozen, signature-free plan whose publication payload can be built offline.
|
|
45
45
|
* @throws {InvalidBigIntInputError} If `loanAssets`, a cancellation ceiling, or a supplied non-null `now`
|
|
46
46
|
* or `reservedLoanAssets` is not a bigint; checked before any request.
|
|
@@ -30,7 +30,7 @@ import { parseMakeLendParams, parseMakeRepayParams } from "./prepare.js";
|
|
|
30
30
|
* @param params.reservedLoanAssets - Optional loan assets reserved by other open groups, excluding cancelled groups; defaults to `0n`.
|
|
31
31
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
32
32
|
* @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the first offer expiry minus one second.
|
|
33
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
33
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
34
34
|
* @returns A frozen, signature-free plan whose publication payload can be built offline.
|
|
35
35
|
* @throws {InvalidBigIntInputError} If `loanAssets`, a cancellation ceiling, or a supplied non-null `now`
|
|
36
36
|
* or `reservedLoanAssets` is not a bigint; checked before any request.
|
|
@@ -36,7 +36,7 @@ export type MidnightMakeRepayPlanParams = MidnightMakeLendPlanParams;
|
|
|
36
36
|
* @param params.reservedLoanAssets - Optional loan assets reserved by other open groups, excluding cancelled groups; defaults to `0n`.
|
|
37
37
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
38
38
|
* @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the earliest offer expiry minus one second.
|
|
39
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
39
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
40
40
|
* @returns A frozen, signature-free plan.
|
|
41
41
|
* @throws {InvalidBigIntInputError} If `loanAssets`, a cancellation ceiling, or a supplied non-null `now`
|
|
42
42
|
* or `reservedLoanAssets` is not a bigint; checked before any request.
|
|
@@ -28,7 +28,7 @@ import { prepareFundedMidnightMakerPublication, } from "./makeLend.js";
|
|
|
28
28
|
* @param params.reservedLoanAssets - Optional loan assets reserved by other open groups, excluding cancelled groups; defaults to `0n`.
|
|
29
29
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
30
30
|
* @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the earliest offer expiry minus one second.
|
|
31
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
31
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
32
32
|
* @returns A frozen, signature-free plan.
|
|
33
33
|
* @throws {InvalidBigIntInputError} If `loanAssets`, a cancellation ceiling, or a supplied non-null `now`
|
|
34
34
|
* or `reservedLoanAssets` is not a bigint; checked before any request.
|
|
@@ -76,7 +76,7 @@ export interface MidnightRepayWithdrawCollateralPlanParams extends Pick<IntentPa
|
|
|
76
76
|
* @param params.now - Reference time in Unix seconds, normally the latest block's timestamp.
|
|
77
77
|
* omitting it uses the device clock (an untyped JavaScript `null` does too); that fallback is deprecated.
|
|
78
78
|
* @param params.expiresAt - Bundle execution deadline in Unix seconds. Defaults to two hours after `now`.
|
|
79
|
-
* @param params.calldataOrigin - Optional attribution bytes (at most 1 MiB) appended to each transaction's calldata.
|
|
79
|
+
* @param params.calldataOrigin - Optional attribution bytes (at most 1 MiB) appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
80
80
|
* @returns A frozen plan with prerequisite calls first and no signature requests.
|
|
81
81
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, the active repayment amount or a withdrawal's `collateralIndex` or `assets` is not a bigint; checked before any request.
|
|
82
82
|
* @throws {MarketIdMismatchError} If the position belongs to another market.
|
|
@@ -53,7 +53,7 @@ const actionId = "midnightRepayWithdrawCollateral";
|
|
|
53
53
|
* @param params.now - Reference time in Unix seconds, normally the latest block's timestamp.
|
|
54
54
|
* omitting it uses the device clock (an untyped JavaScript `null` does too); that fallback is deprecated.
|
|
55
55
|
* @param params.expiresAt - Bundle execution deadline in Unix seconds. Defaults to two hours after `now`.
|
|
56
|
-
* @param params.calldataOrigin - Optional attribution bytes (at most 1 MiB) appended to each transaction's calldata.
|
|
56
|
+
* @param params.calldataOrigin - Optional attribution bytes (at most 1 MiB) appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
57
57
|
* @returns A frozen plan with prerequisite calls first and no signature requests.
|
|
58
58
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, the active repayment amount or a withdrawal's `collateralIndex` or `assets` is not a bigint; checked before any request.
|
|
59
59
|
* @throws {MarketIdMismatchError} If the position belongs to another market.
|
|
@@ -56,7 +56,7 @@ export interface MidnightSupplyBlueMakeLendPlanParams extends MidnightMakerPubli
|
|
|
56
56
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
57
57
|
* The share preview uses the pinned block's timestamp instead.
|
|
58
58
|
* @param params.expiresAt - Unix seconds. Defaults to the earlier of now + 2 hours and one second before the first offer expiry.
|
|
59
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
59
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
60
60
|
* @returns A frozen plan with opaque publication bytes, buildable without the tree or API.
|
|
61
61
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now` is not a bigint; checked first.
|
|
62
62
|
* @throws {ZeroAccountError} If the submitting account is zero.
|
|
@@ -45,7 +45,7 @@ const actionId = "midnightSupplyBlueMakeLend";
|
|
|
45
45
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
46
46
|
* The share preview uses the pinned block's timestamp instead.
|
|
47
47
|
* @param params.expiresAt - Unix seconds. Defaults to the earlier of now + 2 hours and one second before the first offer expiry.
|
|
48
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
48
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
49
49
|
* @returns A frozen plan with opaque publication bytes, buildable without the tree or API.
|
|
50
50
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now` is not a bigint; checked first.
|
|
51
51
|
* @throws {ZeroAccountError} If the submitting account is zero.
|
|
@@ -39,7 +39,7 @@ export interface MidnightSupplyCollateralPlanParams extends Pick<IntentParams, "
|
|
|
39
39
|
* @param params.collateralAssets - Positive collateral quantity in token base units.
|
|
40
40
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
41
41
|
* @param params.expiresAt - Plan expiry in Unix seconds; defaults to two hours after `now`. Midnight does not enforce it onchain.
|
|
42
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
42
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
43
43
|
* @returns A frozen plan whose steps must be submitted in order from `params.account`.
|
|
44
44
|
* @throws {InvalidBigIntInputError} when a supplied non-null `now`, the collateral amount or the index
|
|
45
45
|
* is not a bigint.
|
|
@@ -27,7 +27,7 @@ const actionId = "midnightSupplyCollateral";
|
|
|
27
27
|
* @param params.collateralAssets - Positive collateral quantity in token base units.
|
|
28
28
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
29
29
|
* @param params.expiresAt - Plan expiry in Unix seconds; defaults to two hours after `now`. Midnight does not enforce it onchain.
|
|
30
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
30
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
31
31
|
* @returns A frozen plan whose steps must be submitted in order from `params.account`.
|
|
32
32
|
* @throws {InvalidBigIntInputError} when a supplied non-null `now`, the collateral amount or the index
|
|
33
33
|
* is not a bigint.
|
|
@@ -54,7 +54,7 @@ export interface MidnightSupplyCollateralBatchPlanParams extends Pick<IntentPara
|
|
|
54
54
|
* @param params.collateralSupplies - Nonempty ordered supplies, one per collateral index.
|
|
55
55
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
56
56
|
* @param params.expiresAt - Plan expiry in Unix seconds; defaults to two hours after `now`. Midnight does not enforce it onchain.
|
|
57
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
57
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
58
58
|
* @returns A frozen plan whose approval steps, if any, precede the multicall step; send them in order from `params.account`.
|
|
59
59
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, or a supply's `collateralIndex` or `assets`, is not a bigint; checked before any request.
|
|
60
60
|
* @throws {ZeroAccountError} If the account is the zero address.
|
|
@@ -37,7 +37,7 @@ const actionId = "midnightSupplyCollateralBatch";
|
|
|
37
37
|
* @param params.collateralSupplies - Nonempty ordered supplies, one per collateral index.
|
|
38
38
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
39
39
|
* @param params.expiresAt - Plan expiry in Unix seconds; defaults to two hours after `now`. Midnight does not enforce it onchain.
|
|
40
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
40
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
41
41
|
* @returns A frozen plan whose approval steps, if any, precede the multicall step; send them in order from `params.account`.
|
|
42
42
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, or a supply's `collateralIndex` or `assets`, is not a bigint; checked before any request.
|
|
43
43
|
* @throws {ZeroAccountError} If the account is the zero address.
|
|
@@ -42,7 +42,7 @@ export interface MidnightSupplyCollateralMakeBorrowPlanParams extends MidnightMa
|
|
|
42
42
|
* @param params.nativeAmount - Optional native ETH in wei, capped by the wrapped-native collateral pull.
|
|
43
43
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
44
44
|
* @param params.expiresAt - Unix seconds. The default is the earlier of now + 2 hours and the first offer expiry minus one second.
|
|
45
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
45
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
46
46
|
* @returns A frozen plan that builds offline from saved steps and opaque offer payload bytes.
|
|
47
47
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, a cancellation ceiling, or a collateral
|
|
48
48
|
* index or amount is not a bigint; checked before any request.
|
|
@@ -32,7 +32,7 @@ const actionId = "midnightSupplyCollateralMakeBorrow";
|
|
|
32
32
|
* @param params.nativeAmount - Optional native ETH in wei, capped by the wrapped-native collateral pull.
|
|
33
33
|
* @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
34
34
|
* @param params.expiresAt - Unix seconds. The default is the earlier of now + 2 hours and the first offer expiry minus one second.
|
|
35
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
35
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
36
36
|
* @returns A frozen plan that builds offline from saved steps and opaque offer payload bytes.
|
|
37
37
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, a cancellation ceiling, or a collateral
|
|
38
38
|
* index or amount is not a bigint; checked before any request.
|
|
@@ -50,7 +50,7 @@ export interface MidnightSupplyCollateralWithNativePlanParams extends Pick<Inten
|
|
|
50
50
|
* @param params.nativeAmount - Positive native funding in wei, at most `collateralAssets`; any rest is pulled as wNative.
|
|
51
51
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
52
52
|
* @param params.expiresAt - Bundle execution deadline in Unix seconds; defaults to two hours after `now`.
|
|
53
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
53
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
54
54
|
* @returns A frozen plan whose steps must be submitted in order from `params.account`.
|
|
55
55
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, the collateral amount or the index is not a bigint; checked before any request.
|
|
56
56
|
* @throws {ZeroAccountError} If the account is the zero address.
|
|
@@ -35,7 +35,7 @@ const actionId = "midnightSupplyCollateralWithNative";
|
|
|
35
35
|
* @param params.nativeAmount - Positive native funding in wei, at most `collateralAssets`; any rest is pulled as wNative.
|
|
36
36
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
37
37
|
* @param params.expiresAt - Bundle execution deadline in Unix seconds; defaults to two hours after `now`.
|
|
38
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
38
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
39
39
|
* @returns A frozen plan whose steps must be submitted in order from `params.account`.
|
|
40
40
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, the collateral amount or the index is not a bigint; checked before any request.
|
|
41
41
|
* @throws {ZeroAccountError} If the account is the zero address.
|
|
@@ -52,7 +52,7 @@ export interface MidnightTakeBorrowPlanParams extends Omit<IntentParams, "suppor
|
|
|
52
52
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
53
53
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
54
54
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
55
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
55
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
56
56
|
* @returns A frozen plan with a standalone authorization step if needed and no signature requests.
|
|
57
57
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, or a target amount, is not a bigint;
|
|
58
58
|
* checked before any request.
|
|
@@ -182,7 +182,7 @@ export interface MidnightSupplyCollateralTakeBorrowPlanParams extends MidnightTa
|
|
|
182
182
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
183
183
|
* @param params.now - Reference Unix timestamp in seconds; defaults to the device clock.
|
|
184
184
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
185
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
185
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
186
186
|
* @returns A frozen plan with any necessary approvals and authorization, without signature requests.
|
|
187
187
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, a target amount or a collateral index
|
|
188
188
|
* is not a bigint; checked before any request.
|
|
@@ -49,7 +49,7 @@ import { invalidSellTargetType, validateMidnightSellPlanAction, validateMidnight
|
|
|
49
49
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
50
50
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
51
51
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
52
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
52
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
53
53
|
* @returns A frozen plan with a standalone authorization step if needed and no signature requests.
|
|
54
54
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, or a target amount, is not a bigint;
|
|
55
55
|
* checked before any request.
|
|
@@ -175,7 +175,7 @@ export async function prepareMidnightTakeBorrow(client, params) {
|
|
|
175
175
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
176
176
|
* @param params.now - Reference Unix timestamp in seconds; defaults to the device clock.
|
|
177
177
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
178
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
178
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
179
179
|
* @returns A frozen plan with any necessary approvals and authorization, without signature requests.
|
|
180
180
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now`, a target amount or a collateral index
|
|
181
181
|
* is not a bigint; checked before any request.
|
|
@@ -61,7 +61,7 @@ export interface MidnightTakeRepayWithdrawCollateralPlanParams extends Omit<Inte
|
|
|
61
61
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
62
62
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
63
63
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
64
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
64
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
65
65
|
* @returns A frozen plan with any needed approval and standalone authorization, without signatures.
|
|
66
66
|
* @throws {InvalidBigIntInputError} when a supplied non-null `now`, `maxContinuousFee`, a target amount, or a withdrawal's collateral index or amount is not a bigint; checked before any request.
|
|
67
67
|
* @throws {ZeroAccountError} when the sender is the zero address.
|
|
@@ -86,7 +86,7 @@ const validateTakeRepayWithdrawCollateralPosition = (params) => {
|
|
|
86
86
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
87
87
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
88
88
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
89
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
89
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
90
90
|
* @returns A frozen plan with any needed approval and standalone authorization, without signatures.
|
|
91
91
|
* @throws {InvalidBigIntInputError} when a supplied non-null `now`, `maxContinuousFee`, a target amount, or a withdrawal's collateral index or amount is not a bigint; checked before any request.
|
|
92
92
|
* @throws {ZeroAccountError} when the sender is the zero address.
|
|
@@ -48,7 +48,7 @@ export interface MidnightTakeWithdrawPlanParams extends Omit<IntentParams, "supp
|
|
|
48
48
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
49
49
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
50
50
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
51
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
51
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
52
52
|
* @returns A frozen plan with a standalone authorization step if needed and no signature requests.
|
|
53
53
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now` or a target amount is not a
|
|
54
54
|
* bigint; checked before any request.
|
|
@@ -43,7 +43,7 @@ import { invalidSellTargetType, validateMidnightTargetAmountTypes, } from "./val
|
|
|
43
43
|
* @param params.referralFee.recipient - Recipient required for a positive referral fee.
|
|
44
44
|
* @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
|
|
45
45
|
* @param params.expiresAt - Onchain deadline in Unix seconds; defaults to, and may not exceed, one hour after `now`.
|
|
46
|
-
* @param params.calldataOrigin - Optional attribution bytes appended to each
|
|
46
|
+
* @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
|
|
47
47
|
* @returns A frozen plan with a standalone authorization step if needed and no signature requests.
|
|
48
48
|
* @throws {InvalidBigIntInputError} If a supplied non-null `now` or a target amount is not a
|
|
49
49
|
* bigint; checked before any request.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Erc2612RequirementSignature } from "../types/index.js";
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { BundlesTokenRequirementSignature, Erc2612RequirementSignature } from "../types/index.js";
|
|
3
3
|
import type { Action, SignatureRequest } from "./types.js";
|
|
4
|
+
import { type VaultPermitAction } from "./vaultBinding.js";
|
|
4
5
|
/** @internal Validates the stored ERC-2612 request shape without verifying its signature. */
|
|
5
6
|
export declare function validatePermitPlanRequest(request: Record<string, unknown>, path: string): void;
|
|
6
7
|
/** @internal Checks a permit's signing payload against its referencing action and encoding arguments. */
|
|
@@ -23,5 +24,17 @@ export declare function getSignedTokenPermit(requests: readonly SignatureRequest
|
|
|
23
24
|
readonly asset: Address;
|
|
24
25
|
readonly owner: Address;
|
|
25
26
|
}): Erc2612RequirementSignature | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* @internal Selects the vault action's signed token permit for its bundle pull, as its builder encodes it.
|
|
29
|
+
* @throws {IncompleteTransactionPlanError} If the referenced request is missing or unsigned.
|
|
30
|
+
* @throws {TransactionPlanSignatureMismatchError} If the referenced request is not a permit.
|
|
31
|
+
* @throws {BundlesPermitMismatchError} If the permit does not match the pull's spender, amount or deadline.
|
|
32
|
+
*/
|
|
33
|
+
export declare function selectVaultPermit(action: Extract<VaultPermitAction, {
|
|
34
|
+
readonly type: "vaultV1Deposit" | "vaultV2Deposit";
|
|
35
|
+
}>, requests: readonly SignatureRequest[]): BundlesTokenRequirementSignature | undefined;
|
|
36
|
+
export declare function selectVaultPermit(action: Exclude<VaultPermitAction, {
|
|
37
|
+
readonly type: "vaultV1Deposit" | "vaultV2Deposit";
|
|
38
|
+
}>, requests: readonly SignatureRequest[]): Erc2612RequirementSignature | undefined;
|
|
26
39
|
/** @internal Alias for existing Vault V2 plan builders. */
|
|
27
40
|
export { getSignedTokenPermit as getVaultPermit };
|