@morpho-org/morpho-sdk 6.0.0-next.0 → 6.0.0-next.1
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/MIGRATION-v5-to-v6.md +206 -3
- package/README.md +81 -41
- package/lib/cjs/abis.d.ts +210 -0
- package/lib/cjs/abis.js +142 -2
- package/lib/cjs/actions/blue/borrow.d.ts +1 -1
- package/lib/cjs/actions/blue/borrow.js +1 -1
- package/lib/cjs/actions/blue/common.d.ts +6 -19
- package/lib/cjs/actions/blue/common.js +25 -138
- package/lib/cjs/actions/blue/refinance.d.ts +1 -1
- package/lib/cjs/actions/blue/refinance.js +1 -1
- package/lib/cjs/actions/blue/repay.d.ts +3 -3
- package/lib/cjs/actions/blue/repay.js +1 -1
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -3
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +1 -1
- package/lib/cjs/actions/blue/supply.d.ts +3 -3
- package/lib/cjs/actions/blue/supply.js +1 -1
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +3 -3
- package/lib/cjs/actions/blue/supplyCollateral.js +1 -1
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -3
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +1 -1
- package/lib/cjs/actions/blue/withdraw.d.ts +1 -1
- package/lib/cjs/actions/blue/withdraw.js +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.js +1 -1
- package/lib/cjs/actions/bundles/common.d.ts +200 -0
- package/lib/cjs/actions/bundles/common.js +469 -0
- package/lib/cjs/actions/bundles/index.d.ts +3 -0
- package/lib/cjs/actions/bundles/index.js +23 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +125 -0
- package/lib/cjs/actions/index.d.ts +1 -0
- package/lib/cjs/actions/index.js +1 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +2 -2
- package/lib/cjs/actions/midnight/takeBorrow.js +2 -2
- package/lib/cjs/actions/midnight/takeLend.d.ts +2 -2
- package/lib/cjs/actions/midnight/takeLend.js +2 -2
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +1 -1
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/blue/index.js +0 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +3 -3
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +10 -4
- package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +12 -12
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +13 -13
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/index.js +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +4 -3
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +4 -3
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +2 -2
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +18 -66
- package/lib/cjs/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/cjs/actions/vaultV1/deposit.js +110 -109
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/cjs/actions/vaultV1/migrateToV2.js +91 -104
- package/lib/cjs/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/cjs/actions/vaultV1/redeem.js +56 -33
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/cjs/actions/vaultV1/withdraw.js +86 -34
- package/lib/cjs/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/cjs/actions/vaultV2/deposit.js +111 -109
- package/lib/cjs/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/cjs/actions/vaultV2/redeem.js +56 -34
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/cjs/actions/vaultV2/withdraw.js +86 -35
- package/lib/cjs/entities/blue/blue.d.ts +19 -19
- package/lib/cjs/entities/blue/blue.js +3 -1
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +21 -14
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +61 -65
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +74 -0
- package/lib/cjs/entities/requirements/index.d.ts +1 -0
- package/lib/cjs/entities/requirements/index.js +17 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/cjs/entities/vaultV1/vaultV1.js +322 -120
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/cjs/entities/vaultV2/vaultV2.js +219 -77
- package/lib/cjs/helpers/index.d.ts +2 -1
- package/lib/cjs/helpers/index.js +5 -1
- package/lib/cjs/helpers/referralFee.d.ts +21 -0
- package/lib/cjs/helpers/referralFee.js +35 -0
- package/lib/cjs/helpers/slippage.d.ts +90 -1
- package/lib/cjs/helpers/slippage.js +123 -0
- package/lib/cjs/helpers/validate.d.ts +2 -0
- package/lib/cjs/helpers/validate.js +12 -1
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +179 -70
- package/lib/cjs/types/action.js +12 -12
- package/lib/cjs/types/error.d.ts +62 -14
- package/lib/cjs/types/error.js +88 -22
- package/lib/esm/abis.d.ts +210 -0
- package/lib/esm/abis.js +140 -0
- package/lib/esm/actions/blue/borrow.d.ts +1 -1
- package/lib/esm/actions/blue/borrow.js +1 -1
- package/lib/esm/actions/blue/common.d.ts +6 -19
- package/lib/esm/actions/blue/common.js +27 -140
- package/lib/esm/actions/blue/refinance.d.ts +1 -1
- package/lib/esm/actions/blue/refinance.js +1 -1
- package/lib/esm/actions/blue/repay.d.ts +3 -3
- package/lib/esm/actions/blue/repay.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -3
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +1 -1
- package/lib/esm/actions/blue/supply.d.ts +3 -3
- package/lib/esm/actions/blue/supply.js +1 -1
- package/lib/esm/actions/blue/supplyCollateral.d.ts +3 -3
- package/lib/esm/actions/blue/supplyCollateral.js +1 -1
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -3
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +1 -1
- package/lib/esm/actions/blue/withdraw.d.ts +1 -1
- package/lib/esm/actions/blue/withdraw.js +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.js +1 -1
- package/lib/esm/actions/bundles/common.d.ts +200 -0
- package/lib/esm/actions/bundles/common.js +457 -0
- package/lib/esm/actions/bundles/index.d.ts +3 -0
- package/lib/esm/actions/bundles/index.js +2 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +121 -0
- package/lib/esm/actions/index.d.ts +1 -0
- package/lib/esm/actions/index.js +1 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
- package/lib/esm/actions/midnight/takeBorrow.d.ts +2 -2
- package/lib/esm/actions/midnight/takeBorrow.js +2 -2
- package/lib/esm/actions/midnight/takeLend.d.ts +2 -2
- package/lib/esm/actions/midnight/takeLend.js +2 -2
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +1 -1
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -1
- package/lib/esm/actions/requirements/blue/index.js +0 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +3 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +10 -4
- package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +12 -12
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +11 -11
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/index.js +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +4 -3
- package/lib/esm/actions/requirements/getRequirementsApproval.js +4 -3
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +3 -3
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +19 -67
- package/lib/esm/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/esm/actions/vaultV1/deposit.js +112 -111
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/esm/actions/vaultV1/migrateToV2.js +93 -106
- package/lib/esm/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/esm/actions/vaultV1/redeem.js +56 -33
- package/lib/esm/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/esm/actions/vaultV1/withdraw.js +86 -34
- package/lib/esm/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/esm/actions/vaultV2/deposit.js +113 -111
- package/lib/esm/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/esm/actions/vaultV2/redeem.js +56 -34
- package/lib/esm/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/esm/actions/vaultV2/withdraw.js +86 -35
- package/lib/esm/entities/blue/blue.d.ts +19 -19
- package/lib/esm/entities/blue/blue.js +4 -2
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +21 -14
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +51 -55
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +70 -0
- package/lib/esm/entities/requirements/index.d.ts +1 -0
- package/lib/esm/entities/requirements/index.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/esm/entities/vaultV1/vaultV1.js +326 -124
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/esm/entities/vaultV2/vaultV2.js +222 -80
- package/lib/esm/helpers/index.d.ts +2 -1
- package/lib/esm/helpers/index.js +2 -1
- package/lib/esm/helpers/referralFee.d.ts +21 -0
- package/lib/esm/helpers/referralFee.js +31 -0
- package/lib/esm/helpers/slippage.d.ts +90 -1
- package/lib/esm/helpers/slippage.js +122 -2
- package/lib/esm/helpers/validate.d.ts +2 -0
- package/lib/esm/helpers/validate.js +11 -1
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +179 -70
- package/lib/esm/types/action.js +11 -11
- package/lib/esm/types/error.d.ts +62 -14
- package/lib/esm/types/error.js +80 -16
- package/package.json +3 -3
|
@@ -108,6 +108,8 @@ export declare const validateChainId: (clientChainId: number | undefined, expect
|
|
|
108
108
|
* @throws {NativeAmountOnNonWNativeAssetError} if the asset is not wNative.
|
|
109
109
|
*/
|
|
110
110
|
export declare const validateNativeAsset: (chainId: number, asset: Address) => void;
|
|
111
|
+
/** @internal Validates native funding against a vault's wrapped-native asset. */
|
|
112
|
+
export declare const validateNativeVaultAsset: (chainId: number, vaultAsset: Address) => void;
|
|
111
113
|
/**
|
|
112
114
|
* Validates that the resulting position stays within the safe LTV threshold
|
|
113
115
|
* (LLTV minus buffer) after withdrawing collateral.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getChainAddresses, MarketUtils, MathLib, ORACLE_PRICE_SCALE, } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { isDefined } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { isAddress, isAddressEqual, maxUint128, maxUint256, } from "viem";
|
|
4
|
-
import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, ChainIdMismatchError, ChainWNativeMissingError, EmptyReallocationWithdrawalsError, ExcessiveSlippageToleranceError, InconsistentReallocationPenaltyError, InputExceedsMaxError, InvalidReallocationAddressError, InvalidReallocationShapeError, InvalidReallocationSourceTypeError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, NativeAmountOnNonWNativeAssetError, NegativeInputError, NonPositiveInputError, ReallocationWithdrawalOnTargetMarketError, RepayExceedsDebtError, RepaySharesExceedDebtError, UnsortedReallocationWithdrawalsError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
|
|
4
|
+
import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, ChainIdMismatchError, ChainWNativeMissingError, EmptyReallocationWithdrawalsError, ExcessiveSlippageToleranceError, InconsistentReallocationPenaltyError, InputExceedsMaxError, InvalidReallocationAddressError, InvalidReallocationShapeError, InvalidReallocationSourceTypeError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, NativeAmountOnNonWNativeAssetError, NativeAmountOnNonWNativeVaultError, NegativeInputError, NonPositiveInputError, ReallocationWithdrawalOnTargetMarketError, RepayExceedsDebtError, RepaySharesExceedDebtError, UnsortedReallocationWithdrawalsError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
|
|
5
5
|
import { DEFAULT_LLTV_BUFFER, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, } from "./constant.js";
|
|
6
6
|
/** @internal */
|
|
7
7
|
export const compareMarketIds = (idA, idB) => {
|
|
@@ -158,6 +158,16 @@ export const validateNativeAsset = (chainId, asset) => {
|
|
|
158
158
|
throw new NativeAmountOnNonWNativeAssetError(asset, wNative);
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
+
/** @internal Validates native funding against a vault's wrapped-native asset. */
|
|
162
|
+
export const validateNativeVaultAsset = (chainId, vaultAsset) => {
|
|
163
|
+
const { wNative } = getChainAddresses(chainId);
|
|
164
|
+
if (!isDefined(wNative)) {
|
|
165
|
+
throw new ChainWNativeMissingError(chainId);
|
|
166
|
+
}
|
|
167
|
+
if (!isAddressEqual(vaultAsset, wNative)) {
|
|
168
|
+
throw new NativeAmountOnNonWNativeVaultError(vaultAsset, wNative);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
161
171
|
/**
|
|
162
172
|
* Validates that the resulting position stays within the safe LTV threshold
|
|
163
173
|
* (LLTV minus buffer) after withdrawing collateral.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Address } from "@morpho-org/blue-sdk";
|
|
2
2
|
/** Supported spender slots that can be validated against the chain address registry. */
|
|
3
|
-
export type RequirementSpenderKey = "generalAdapter1" | "permit2" | "midnight" | "midnightBundles" | "vaultExitBundlesV1" | "blueBundlesV1";
|
|
3
|
+
export type RequirementSpenderKey = "generalAdapter1" | "permit2" | "midnight" | "midnightBundles" | "vaultExitBundlesV1" | "vaultBundlesV1" | "blueBundlesV1";
|
|
4
4
|
/**
|
|
5
5
|
* Validates that a requirement encoder spender matches one of the allowed chain addresses.
|
|
6
6
|
*
|
|
@@ -31,6 +31,7 @@ export const validateRequirementSpender = (params) => {
|
|
|
31
31
|
midnight,
|
|
32
32
|
midnightBundles,
|
|
33
33
|
vaultExitBundlesV1: bundles?.vaultExitBundlesV1,
|
|
34
|
+
vaultBundlesV1: bundles?.vaultBundlesV1,
|
|
34
35
|
blueBundlesV1: bundles?.blueBundlesV1,
|
|
35
36
|
};
|
|
36
37
|
const supportedSpenders = params.allowed.map((key) => addresses[key]);
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
|
@@ -13,24 +13,58 @@ export interface ERC20ApprovalAction extends BaseAction<"erc20Approval", {
|
|
|
13
13
|
export interface ERC20PermitAction {
|
|
14
14
|
sign: (client: WalletClient, userAddress: Address) => Promise<Hex>;
|
|
15
15
|
}
|
|
16
|
+
/** Metadata for a direct Vault V2 deposit through VaultBundlesV1. */
|
|
16
17
|
export interface VaultV2DepositAction extends BaseAction<"vaultV2Deposit", {
|
|
17
|
-
vault
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
/** Destination vault receiving net assets; shares are minted to the transaction sender. */
|
|
19
|
+
readonly vault: Address;
|
|
20
|
+
/** Gross funding in asset base units, for either ERC-20 or native funding, before fees. */
|
|
21
|
+
readonly amount: bigint;
|
|
22
|
+
/** Maximum asset/share ratio scaled by 1e27, computed from net assets through the deadline. */
|
|
23
|
+
readonly maxSharePrice: bigint;
|
|
24
|
+
/** Native funding marker: equals `amount` and transaction `value` on native deposits; otherwise undefined. */
|
|
25
|
+
readonly nativeAmount?: bigint;
|
|
26
|
+
/** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
|
|
27
|
+
readonly referralFeePct: bigint;
|
|
28
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
29
|
+
readonly referralFeeRecipient: Address;
|
|
30
|
+
/** Fee in asset base units: floor(amount * referralFeePct / WAD). */
|
|
31
|
+
readonly referralFeeAssets: bigint;
|
|
32
|
+
/** Assets deposited into the vault: amount minus referralFeeAssets. */
|
|
33
|
+
readonly netAssets: bigint;
|
|
34
|
+
/** Execution and token-permit expiration as a Unix timestamp in seconds. */
|
|
35
|
+
readonly deadline: bigint;
|
|
22
36
|
}> {
|
|
23
37
|
}
|
|
38
|
+
/** Metadata for an exact-assets Vault V2 withdrawal through VaultBundlesV1. */
|
|
24
39
|
export interface VaultV2WithdrawAction extends BaseAction<"vaultV2Withdraw", {
|
|
25
|
-
vault
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
/** Source vault whose shares are burned from the transaction sender. */
|
|
41
|
+
readonly vault: Address;
|
|
42
|
+
/** Gross withdrawal in asset base units, before the referral fee is deducted. */
|
|
43
|
+
readonly amount: bigint;
|
|
44
|
+
/** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
|
|
45
|
+
readonly referralFeePct: bigint;
|
|
46
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
47
|
+
readonly referralFeeRecipient: Address;
|
|
48
|
+
/** Fee in asset base units: floor(amount * referralFeePct / WAD). */
|
|
49
|
+
readonly referralFeeAssets: bigint;
|
|
50
|
+
/** Assets received by the transaction sender: amount minus referralFeeAssets. */
|
|
51
|
+
readonly netAssets: bigint;
|
|
52
|
+
/** Execution and share-permit expiration as a Unix timestamp in seconds. */
|
|
53
|
+
readonly deadline: bigint;
|
|
28
54
|
}> {
|
|
29
55
|
}
|
|
56
|
+
/** Metadata for an exact-shares Vault V2 redemption through VaultBundlesV1. */
|
|
30
57
|
export interface VaultV2RedeemAction extends BaseAction<"vaultV2Redeem", {
|
|
31
|
-
vault
|
|
32
|
-
|
|
33
|
-
|
|
58
|
+
/** Source vault whose shares are burned from the transaction sender. */
|
|
59
|
+
readonly vault: Address;
|
|
60
|
+
/** Exact shares to burn, in vault-share base units. */
|
|
61
|
+
readonly shares: bigint;
|
|
62
|
+
/** Referral fee fraction scaled by WAD (1e18), deducted from redeemed assets; zero disables it. */
|
|
63
|
+
readonly referralFeePct: bigint;
|
|
64
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
65
|
+
readonly referralFeeRecipient: Address;
|
|
66
|
+
/** Execution and share-permit expiration as a Unix timestamp in seconds. */
|
|
67
|
+
readonly deadline: bigint;
|
|
34
68
|
}> {
|
|
35
69
|
}
|
|
36
70
|
/** Metadata for a Vault V2 in-kind redemption into Morpho Blue supply positions. */
|
|
@@ -63,24 +97,58 @@ export interface VaultV2ForceRedeemAction extends BaseAction<"vaultV2ForceRedeem
|
|
|
63
97
|
onBehalf: Address;
|
|
64
98
|
}> {
|
|
65
99
|
}
|
|
100
|
+
/** Metadata for a direct Vault V1 deposit through VaultBundlesV1. */
|
|
66
101
|
export interface VaultV1DepositAction extends BaseAction<"vaultV1Deposit", {
|
|
67
|
-
vault
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
102
|
+
/** Destination vault receiving net assets; shares are minted to the transaction sender. */
|
|
103
|
+
readonly vault: Address;
|
|
104
|
+
/** Gross funding in asset base units, for either ERC-20 or native funding, before fees. */
|
|
105
|
+
readonly amount: bigint;
|
|
106
|
+
/** Maximum asset/share ratio scaled by 1e27, computed from net assets through the deadline. */
|
|
107
|
+
readonly maxSharePrice: bigint;
|
|
108
|
+
/** Native funding marker: equals `amount` and transaction `value` on native deposits; otherwise undefined. */
|
|
109
|
+
readonly nativeAmount?: bigint;
|
|
110
|
+
/** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
|
|
111
|
+
readonly referralFeePct: bigint;
|
|
112
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
113
|
+
readonly referralFeeRecipient: Address;
|
|
114
|
+
/** Fee in asset base units: floor(amount * referralFeePct / WAD). */
|
|
115
|
+
readonly referralFeeAssets: bigint;
|
|
116
|
+
/** Assets deposited into the vault: amount minus referralFeeAssets. */
|
|
117
|
+
readonly netAssets: bigint;
|
|
118
|
+
/** Execution and token-permit expiration as a Unix timestamp in seconds. */
|
|
119
|
+
readonly deadline: bigint;
|
|
72
120
|
}> {
|
|
73
121
|
}
|
|
122
|
+
/** Metadata for an exact-assets Vault V1 withdrawal through VaultBundlesV1. */
|
|
74
123
|
export interface VaultV1WithdrawAction extends BaseAction<"vaultV1Withdraw", {
|
|
75
|
-
vault
|
|
76
|
-
|
|
77
|
-
|
|
124
|
+
/** Source vault whose shares are burned from the transaction sender. */
|
|
125
|
+
readonly vault: Address;
|
|
126
|
+
/** Gross withdrawal in asset base units, before the referral fee is deducted. */
|
|
127
|
+
readonly amount: bigint;
|
|
128
|
+
/** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
|
|
129
|
+
readonly referralFeePct: bigint;
|
|
130
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
131
|
+
readonly referralFeeRecipient: Address;
|
|
132
|
+
/** Fee in asset base units: floor(amount * referralFeePct / WAD). */
|
|
133
|
+
readonly referralFeeAssets: bigint;
|
|
134
|
+
/** Assets received by the transaction sender: amount minus referralFeeAssets. */
|
|
135
|
+
readonly netAssets: bigint;
|
|
136
|
+
/** Execution and share-permit expiration as a Unix timestamp in seconds. */
|
|
137
|
+
readonly deadline: bigint;
|
|
78
138
|
}> {
|
|
79
139
|
}
|
|
140
|
+
/** Metadata for an exact-shares Vault V1 redemption through VaultBundlesV1. */
|
|
80
141
|
export interface VaultV1RedeemAction extends BaseAction<"vaultV1Redeem", {
|
|
81
|
-
vault
|
|
82
|
-
|
|
83
|
-
|
|
142
|
+
/** Source vault whose shares are burned from the transaction sender. */
|
|
143
|
+
readonly vault: Address;
|
|
144
|
+
/** Exact shares to burn, in vault-share base units. */
|
|
145
|
+
readonly shares: bigint;
|
|
146
|
+
/** Referral fee fraction scaled by WAD (1e18), deducted from redeemed assets; zero disables it. */
|
|
147
|
+
readonly referralFeePct: bigint;
|
|
148
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
149
|
+
readonly referralFeeRecipient: Address;
|
|
150
|
+
/** Execution and share-permit expiration as a Unix timestamp in seconds. */
|
|
151
|
+
readonly deadline: bigint;
|
|
84
152
|
}> {
|
|
85
153
|
}
|
|
86
154
|
/** Metadata for a Vault V1 in-kind redemption into Morpho Blue supply positions. */
|
|
@@ -92,13 +160,28 @@ export interface VaultV1InKindRedeemAction extends BaseAction<"vaultV1InKindRede
|
|
|
92
160
|
readonly deadline: bigint;
|
|
93
161
|
}> {
|
|
94
162
|
}
|
|
163
|
+
/** Metadata for an assets-or-shares Vault V1 to Vault V2 migration through VaultBundlesV1. */
|
|
95
164
|
export interface VaultV1MigrateToV2Action extends BaseAction<"vaultV1MigrateToV2", {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
shares
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
165
|
+
/** Source Vault V1 whose shares are burned from the transaction sender. */
|
|
166
|
+
readonly sourceVault: Address;
|
|
167
|
+
/** Destination Vault V2 receiving net assets; shares are minted to the transaction sender. */
|
|
168
|
+
readonly targetVault: Address;
|
|
169
|
+
/** Gross assets to withdraw in asset base units; zero in exact-shares mode. */
|
|
170
|
+
readonly assets: bigint;
|
|
171
|
+
/** Source shares to burn in vault-share base units; zero in exact-assets mode. */
|
|
172
|
+
readonly shares: bigint;
|
|
173
|
+
/** Maximum destination asset base units per share base unit, scaled by RAY (1e27). */
|
|
174
|
+
readonly maxSharePriceVaultV2: bigint;
|
|
175
|
+
/** Referral fee fraction scaled by WAD (1e18), deducted before depositing; zero disables it. */
|
|
176
|
+
readonly referralFeePct: bigint;
|
|
177
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
178
|
+
readonly referralFeeRecipient: Address;
|
|
179
|
+
/** Fee in asset base units: floor(assets * referralFeePct / WAD); omitted in exact-shares mode. */
|
|
180
|
+
readonly referralFeeAssets?: bigint;
|
|
181
|
+
/** Assets deposited: assets minus referralFeeAssets; omitted in exact-shares mode. */
|
|
182
|
+
readonly netAssets?: bigint;
|
|
183
|
+
/** Execution and source share-permit expiration as a Unix timestamp in seconds. */
|
|
184
|
+
readonly deadline: bigint;
|
|
102
185
|
}> {
|
|
103
186
|
}
|
|
104
187
|
/** Metadata for a direct BlueBundlesV1 loan-asset supply. */
|
|
@@ -297,7 +380,7 @@ export interface MidnightCancelOfferAction extends BaseAction<"midnightCancelOff
|
|
|
297
380
|
}> {
|
|
298
381
|
}
|
|
299
382
|
/** Metadata discriminators carried by transactions returned by the SDK. */
|
|
300
|
-
export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction |
|
|
383
|
+
export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | SetterRatifierRatifyRootAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MempoolSubmitOffersAction | MidnightRedeemAction | MidnightRepayWithdrawCollateralAction | MidnightCancelOfferAction;
|
|
301
384
|
export interface Transaction<TAction extends BaseAction = TransactionAction> {
|
|
302
385
|
readonly to: Address;
|
|
303
386
|
readonly value: bigint;
|
|
@@ -318,22 +401,45 @@ export type DepositAmountArgs = {
|
|
|
318
401
|
nativeAmount: bigint;
|
|
319
402
|
amount?: bigint;
|
|
320
403
|
};
|
|
404
|
+
/** Mutually exclusive ERC-20 or native funding accepted by fixed bundles entrypoints. */
|
|
405
|
+
export type BundlesFundingArgs = {
|
|
406
|
+
readonly amount: bigint;
|
|
407
|
+
readonly nativeAmount?: never;
|
|
408
|
+
} | {
|
|
409
|
+
readonly nativeAmount: bigint;
|
|
410
|
+
readonly amount?: never;
|
|
411
|
+
};
|
|
412
|
+
/** Controls token requirements generated for a bundles-funded action. */
|
|
413
|
+
export interface BundlesTokenRequirementsOptions {
|
|
414
|
+
/** Prefer ERC-2612 when the funded token exposes a compatible nonce. */
|
|
415
|
+
readonly useSimplePermit?: boolean;
|
|
416
|
+
/** Explicit unused Permit2 SignatureTransfer unordered nonce. */
|
|
417
|
+
readonly permit2Nonce?: bigint;
|
|
418
|
+
}
|
|
419
|
+
/** Mutually exclusive source amount accepted by a Vault V1 to Vault V2 migration. */
|
|
420
|
+
export type VaultV1MigrateToV2AmountArgs = {
|
|
421
|
+
readonly shares: bigint;
|
|
422
|
+
readonly assets?: never;
|
|
423
|
+
} | {
|
|
424
|
+
readonly assets: bigint;
|
|
425
|
+
readonly shares?: never;
|
|
426
|
+
};
|
|
321
427
|
export interface PermitArgs {
|
|
322
|
-
owner: Address;
|
|
323
|
-
nonce: bigint;
|
|
324
|
-
asset: Address;
|
|
325
|
-
signature: Hex;
|
|
326
|
-
amount: bigint;
|
|
327
|
-
deadline: bigint;
|
|
428
|
+
readonly owner: Address;
|
|
429
|
+
readonly nonce: bigint;
|
|
430
|
+
readonly asset: Address;
|
|
431
|
+
readonly signature: Hex;
|
|
432
|
+
readonly amount: bigint;
|
|
433
|
+
readonly deadline: bigint;
|
|
328
434
|
}
|
|
329
435
|
export interface Permit2Args {
|
|
330
|
-
owner: Address;
|
|
331
|
-
nonce: bigint;
|
|
332
|
-
asset: Address;
|
|
333
|
-
signature: Hex;
|
|
334
|
-
amount: bigint;
|
|
335
|
-
deadline: bigint;
|
|
336
|
-
expiration: bigint;
|
|
436
|
+
readonly owner: Address;
|
|
437
|
+
readonly nonce: bigint;
|
|
438
|
+
readonly asset: Address;
|
|
439
|
+
readonly signature: Hex;
|
|
440
|
+
readonly amount: bigint;
|
|
441
|
+
readonly deadline: bigint;
|
|
442
|
+
readonly expiration: bigint;
|
|
337
443
|
}
|
|
338
444
|
/**
|
|
339
445
|
* Signed Morpho Blue authorization payload produced when an integrator opts into offchain
|
|
@@ -362,9 +468,11 @@ export interface MidnightOfferRootSignatureArgs {
|
|
|
362
468
|
readonly payload: Hex;
|
|
363
469
|
}
|
|
364
470
|
export interface PermitAction extends BaseAction<"permit", {
|
|
365
|
-
spender: Address;
|
|
366
|
-
amount: bigint;
|
|
367
|
-
deadline: bigint;
|
|
471
|
+
readonly spender: Address;
|
|
472
|
+
readonly amount: bigint;
|
|
473
|
+
readonly deadline: bigint;
|
|
474
|
+
/** Permit nonce captured by a prepared requirement, when available. */
|
|
475
|
+
readonly nonce?: bigint;
|
|
368
476
|
}> {
|
|
369
477
|
}
|
|
370
478
|
export interface Permit2Action extends BaseAction<"permit2", {
|
|
@@ -374,10 +482,11 @@ export interface Permit2Action extends BaseAction<"permit2", {
|
|
|
374
482
|
expiration: bigint;
|
|
375
483
|
}> {
|
|
376
484
|
}
|
|
377
|
-
/** Signable Permit2 SignatureTransfer requirement for a
|
|
378
|
-
export interface
|
|
485
|
+
/** Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull. */
|
|
486
|
+
export interface Permit2SignatureTransferAction extends BaseAction<"permit2SignatureTransfer", {
|
|
379
487
|
readonly spender: Address;
|
|
380
488
|
readonly amount: bigint;
|
|
489
|
+
readonly nonce: bigint;
|
|
381
490
|
readonly deadline: bigint;
|
|
382
491
|
}> {
|
|
383
492
|
}
|
|
@@ -399,7 +508,7 @@ export interface MidnightOfferRootSignatureAction extends BaseAction<"midnightOf
|
|
|
399
508
|
}> {
|
|
400
509
|
}
|
|
401
510
|
/** Action metadata supported by signature requirements. */
|
|
402
|
-
export type SignatureRequirementAction = PermitAction | Permit2Action |
|
|
511
|
+
export type SignatureRequirementAction = PermitAction | Permit2Action | Permit2SignatureTransferAction | AuthorizationAction | MidnightOfferRootSignatureAction;
|
|
403
512
|
/** Argument payloads returned by signature requirements. */
|
|
404
513
|
export type RequirementSignatureArgs = PermitArgs | Permit2Args | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
|
|
405
514
|
/** A signed ERC-2612 permit requirement. */
|
|
@@ -414,10 +523,10 @@ export interface Permit2AllowanceRequirementSignature {
|
|
|
414
523
|
}
|
|
415
524
|
/** A signed ERC-2612 permit or Permit2 AllowanceTransfer requirement. */
|
|
416
525
|
export type PermitRequirementSignature = Erc2612RequirementSignature | Permit2AllowanceRequirementSignature;
|
|
417
|
-
/** A signed Permit2 SignatureTransfer requirement used by
|
|
418
|
-
export interface
|
|
526
|
+
/** A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts. */
|
|
527
|
+
export interface Permit2SignatureTransferRequirementSignature {
|
|
419
528
|
readonly args: Readonly<PermitArgs>;
|
|
420
|
-
readonly action:
|
|
529
|
+
readonly action: Permit2SignatureTransferAction;
|
|
421
530
|
}
|
|
422
531
|
/** A signed Morpho authorization consumed by Bundler3 or a direct BlueBundlesV1 call. */
|
|
423
532
|
export interface AuthorizationRequirementSignature {
|
|
@@ -431,14 +540,14 @@ export interface MidnightOfferRootSignature {
|
|
|
431
540
|
}
|
|
432
541
|
/**
|
|
433
542
|
* The deep-frozen output of `Requirement.sign()`. Discriminated on `action.type`:
|
|
434
|
-
* `"permit"` / `"permit2"` carry token-approval args, `"
|
|
435
|
-
*
|
|
543
|
+
* `"permit"` / `"permit2"` carry token-approval args, `"permit2SignatureTransfer"` carries a
|
|
544
|
+
* bundles SignatureTransfer, `"authorization"` carries the signed Morpho authorization,
|
|
436
545
|
* and Midnight adds `"midnightOfferRootSignature"`.
|
|
437
546
|
*/
|
|
438
547
|
export type RequirementSignature<TAction extends SignatureRequirementAction | undefined = undefined, TArgs extends RequirementSignatureArgs | undefined = undefined> = TAction extends SignatureRequirementAction ? TArgs extends RequirementSignatureArgs ? {
|
|
439
548
|
args: TArgs;
|
|
440
549
|
action: TAction;
|
|
441
|
-
} : never : PermitRequirementSignature |
|
|
550
|
+
} : never : PermitRequirementSignature | Permit2SignatureTransferRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
|
|
442
551
|
type RequirementResult<TSignatureOrAction extends RequirementSignature | SignatureRequirementAction, TArgs extends RequirementSignatureArgs | undefined> = TSignatureOrAction extends SignatureRequirementAction ? RequirementSignature<TSignatureOrAction, Extract<TArgs, RequirementSignatureArgs>> : Extract<TSignatureOrAction, RequirementSignature>;
|
|
443
552
|
/**
|
|
444
553
|
* A signable approval / authorization requirement. `sign()` returns the matching
|
|
@@ -455,18 +564,18 @@ export interface Requirement<TSignatureOrAction extends RequirementSignature | S
|
|
|
455
564
|
}
|
|
456
565
|
/** Bundler3 token signature requirement. */
|
|
457
566
|
export type Bundler3TokenSignatureRequirement = Requirement<PermitRequirementSignature>;
|
|
458
|
-
/**
|
|
459
|
-
export type
|
|
567
|
+
/** ERC-2612 or Permit2 SignatureTransfer requirement consumed by a fixed bundles contract. */
|
|
568
|
+
export type BundlesTokenSignatureRequirement = Requirement<BundlesTokenRequirementSignature>;
|
|
460
569
|
/** Midnight Ecrecover offer-root signature requirement. */
|
|
461
570
|
export type MidnightOfferRootRequirement = Requirement<MidnightOfferRootSignatureAction, MidnightOfferRootSignatureArgs>;
|
|
462
571
|
/** Any token signature requirement supported by an SDK transaction route. */
|
|
463
|
-
export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement |
|
|
572
|
+
export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement | BundlesTokenSignatureRequirement;
|
|
464
573
|
/** Bundler3 token signature result. */
|
|
465
574
|
export type Bundler3TokenRequirementSignature = PermitRequirementSignature;
|
|
466
|
-
/**
|
|
467
|
-
export type
|
|
575
|
+
/** Token signature result consumed by a fixed bundles contract. */
|
|
576
|
+
export type BundlesTokenRequirementSignature = Erc2612RequirementSignature | Permit2SignatureTransferRequirementSignature;
|
|
468
577
|
/** Any token signature result supported by an SDK transaction route. */
|
|
469
|
-
export type TokenRequirementSignature = Bundler3TokenRequirementSignature |
|
|
578
|
+
export type TokenRequirementSignature = Bundler3TokenRequirementSignature | BundlesTokenRequirementSignature;
|
|
470
579
|
/** Any signature result returned by an action-output signature requirement. */
|
|
471
580
|
export type AnyRequirementSignature = TokenRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
|
|
472
581
|
/** Any signature requirement returned by an entity action output. */
|
|
@@ -508,19 +617,19 @@ export declare function isPermitSignature(signature: RequirementSignature): sign
|
|
|
508
617
|
* Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
|
|
509
618
|
*
|
|
510
619
|
* @param signature - The signed requirement to test.
|
|
511
|
-
* @returns `true` when `signature.action.type` is `"
|
|
620
|
+
* @returns `true` when `signature.action.type` is `"permit2SignatureTransfer"`.
|
|
512
621
|
* @example
|
|
513
622
|
* ```ts
|
|
514
623
|
* import {
|
|
515
|
-
*
|
|
624
|
+
* isPermit2SignatureTransferSignature,
|
|
516
625
|
* type RequirementSignature,
|
|
517
626
|
* } from "@morpho-org/morpho-sdk";
|
|
518
627
|
*
|
|
519
628
|
* const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
|
|
520
|
-
*
|
|
629
|
+
* isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
|
|
521
630
|
* ```
|
|
522
631
|
*/
|
|
523
|
-
export declare function
|
|
632
|
+
export declare function isPermit2SignatureTransferSignature(signature: RequirementSignature): signature is Permit2SignatureTransferRequirementSignature;
|
|
524
633
|
/**
|
|
525
634
|
* Narrows a {@link RequirementSignature} to a signed Morpho authorization.
|
|
526
635
|
*
|
|
@@ -540,7 +649,7 @@ export interface SelectedRequirementSignatures {
|
|
|
540
649
|
/** The single ERC-2612 or Permit2 AllowanceTransfer signature, when present. */
|
|
541
650
|
readonly permit?: PermitRequirementSignature;
|
|
542
651
|
/** The single Permit2 SignatureTransfer signature, when present. */
|
|
543
|
-
readonly
|
|
652
|
+
readonly permit2SignatureTransfer?: Permit2SignatureTransferRequirementSignature;
|
|
544
653
|
/** The single Morpho authorization signature, when present. */
|
|
545
654
|
readonly authorization?: AuthorizationRequirementSignature;
|
|
546
655
|
/** The single Midnight offer-root signature, when present. */
|
|
@@ -558,7 +667,7 @@ export interface SelectedRequirementSignatures {
|
|
|
558
667
|
* @param signatures - The signatures passed to `buildTx`.
|
|
559
668
|
* @param accepts - Which signature kinds this operation consumes.
|
|
560
669
|
* @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
|
|
561
|
-
* @param accepts.
|
|
670
|
+
* @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
|
|
562
671
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
563
672
|
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
564
673
|
* @returns The accepted signature in each typed slot, when present.
|
|
@@ -575,9 +684,9 @@ export interface SelectedRequirementSignatures {
|
|
|
575
684
|
* ```
|
|
576
685
|
*/
|
|
577
686
|
export declare function selectRequirementSignatures(signatures: readonly RequirementSignature[] | undefined, accepts: {
|
|
578
|
-
permit?: boolean;
|
|
579
|
-
|
|
580
|
-
authorization?: boolean;
|
|
581
|
-
midnightOfferRoot?: boolean;
|
|
687
|
+
readonly permit?: boolean;
|
|
688
|
+
readonly permit2SignatureTransfer?: boolean;
|
|
689
|
+
readonly authorization?: boolean;
|
|
690
|
+
readonly midnightOfferRoot?: boolean;
|
|
582
691
|
}): SelectedRequirementSignatures;
|
|
583
692
|
export {};
|
package/lib/esm/types/action.js
CHANGED
|
@@ -44,20 +44,20 @@ export function isPermitSignature(signature) {
|
|
|
44
44
|
* Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
|
|
45
45
|
*
|
|
46
46
|
* @param signature - The signed requirement to test.
|
|
47
|
-
* @returns `true` when `signature.action.type` is `"
|
|
47
|
+
* @returns `true` when `signature.action.type` is `"permit2SignatureTransfer"`.
|
|
48
48
|
* @example
|
|
49
49
|
* ```ts
|
|
50
50
|
* import {
|
|
51
|
-
*
|
|
51
|
+
* isPermit2SignatureTransferSignature,
|
|
52
52
|
* type RequirementSignature,
|
|
53
53
|
* } from "@morpho-org/morpho-sdk";
|
|
54
54
|
*
|
|
55
55
|
* const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
|
|
56
|
-
*
|
|
56
|
+
* isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
export function
|
|
60
|
-
return signature.action.type === "
|
|
59
|
+
export function isPermit2SignatureTransferSignature(signature) {
|
|
60
|
+
return signature.action.type === "permit2SignatureTransfer";
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Narrows a {@link RequirementSignature} to a signed Morpho authorization.
|
|
@@ -89,7 +89,7 @@ export function isMidnightOfferRootSignature(signature) {
|
|
|
89
89
|
* @param signatures - The signatures passed to `buildTx`.
|
|
90
90
|
* @param accepts - Which signature kinds this operation consumes.
|
|
91
91
|
* @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
|
|
92
|
-
* @param accepts.
|
|
92
|
+
* @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
|
|
93
93
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
94
94
|
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
95
95
|
* @returns The accepted signature in each typed slot, when present.
|
|
@@ -109,13 +109,13 @@ export function selectRequirementSignatures(signatures, accepts) {
|
|
|
109
109
|
if (signatures == null)
|
|
110
110
|
return {};
|
|
111
111
|
const permits = signatures.filter(isPermitSignature);
|
|
112
|
-
const permit2Transfers = signatures.filter(
|
|
112
|
+
const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
|
|
113
113
|
const authorizations = signatures.filter(isAuthorizationSignature);
|
|
114
114
|
const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
|
|
115
115
|
if (!accepts.permit && permits.length > 0)
|
|
116
116
|
throw new UnexpectedRequirementSignatureError("permit");
|
|
117
|
-
if (!accepts.
|
|
118
|
-
throw new UnexpectedRequirementSignatureError("
|
|
117
|
+
if (!accepts.permit2SignatureTransfer && permit2Transfers.length > 0)
|
|
118
|
+
throw new UnexpectedRequirementSignatureError("permit2SignatureTransfer");
|
|
119
119
|
if (!accepts.authorization && authorizations.length > 0)
|
|
120
120
|
throw new UnexpectedRequirementSignatureError("authorization");
|
|
121
121
|
if (!accepts.midnightOfferRoot && midnightOfferRoots.length > 0)
|
|
@@ -123,14 +123,14 @@ export function selectRequirementSignatures(signatures, accepts) {
|
|
|
123
123
|
if (permits.length > 1)
|
|
124
124
|
throw new AmbiguousRequirementSignaturesError("permit", permits.length);
|
|
125
125
|
if (permit2Transfers.length > 1)
|
|
126
|
-
throw new AmbiguousRequirementSignaturesError("
|
|
126
|
+
throw new AmbiguousRequirementSignaturesError("permit2SignatureTransfer", permit2Transfers.length);
|
|
127
127
|
if (authorizations.length > 1)
|
|
128
128
|
throw new AmbiguousRequirementSignaturesError("authorization", authorizations.length);
|
|
129
129
|
if (midnightOfferRoots.length > 1)
|
|
130
130
|
throw new AmbiguousRequirementSignaturesError("midnightOfferRootSignature", midnightOfferRoots.length);
|
|
131
131
|
return {
|
|
132
132
|
permit: permits[0],
|
|
133
|
-
|
|
133
|
+
permit2SignatureTransfer: permit2Transfers[0],
|
|
134
134
|
authorization: authorizations[0],
|
|
135
135
|
midnightOfferRoot: midnightOfferRoots[0],
|
|
136
136
|
};
|