@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
|
@@ -1,58 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vaultV2Withdraw = void 0;
|
|
4
|
-
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
5
|
const viem_1 = require("viem");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const abis_js_1 = require("../../abis.js");
|
|
7
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
8
|
+
const index_js_1 = require("../../types/index.js");
|
|
9
|
+
const common_js_1 = require("../bundles/common.js");
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Encodes an exact-assets Vault V2 withdrawal through VaultBundlesV1.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* This low-level builder does not bind `permit.value` to a share cap; use
|
|
14
|
+
* `MorphoVaultV2.withdraw().buildTx()` to validate it against the cap from `getRequirements()`.
|
|
14
15
|
*
|
|
15
|
-
* @param params.vault.
|
|
16
|
-
* @param params.
|
|
17
|
-
* @param params.args.
|
|
18
|
-
* @param params.args.
|
|
19
|
-
* @param params.
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
17
|
+
* @param params.vault.address - Vault V2 whose shares are burned for the withdrawal.
|
|
18
|
+
* @param params.args.amount - Positive gross withdrawal in underlying asset base units, before fees.
|
|
19
|
+
* @param params.args.userAddress - Share owner and transaction sender; receives the net withdrawn assets.
|
|
20
|
+
* @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
|
|
21
|
+
* @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
|
|
22
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
23
|
+
* and the registered VaultBundlesV1 spender. Omit when the exact share allowance is already set.
|
|
24
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
25
|
+
* The fee is rounded down and deducted from the gross withdrawn assets.
|
|
26
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
27
|
+
* when `referralFeePct > 0n`.
|
|
28
|
+
* @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
|
|
29
|
+
* execution reverts. This pure builder does not check the current time.
|
|
30
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
31
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
32
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
33
|
+
* @returns A deep-frozen `Transaction<VaultV2WithdrawAction>` targeting VaultBundlesV1, with
|
|
34
|
+
* `to`, `value: 0n`, `data`, and gross/fee/net withdrawal action metadata.
|
|
35
|
+
* @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
|
|
36
|
+
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256.
|
|
37
|
+
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
38
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
39
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
|
|
40
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
41
|
+
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
42
|
+
* @throws {BundlesPermitMismatchError} when the optional share permit is incompatible.
|
|
43
|
+
* @throws {viem.BaseError} when transaction encoding fails.
|
|
23
44
|
* @example
|
|
24
45
|
* ```ts
|
|
25
46
|
* import { vaultV2Withdraw } from "@morpho-org/morpho-sdk";
|
|
47
|
+
* import type { Address } from "viem";
|
|
48
|
+
* import { mainnet } from "viem/chains";
|
|
26
49
|
*
|
|
27
|
-
*
|
|
28
|
-
* vault
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
50
|
+
* export function buildUsdcWithdrawal(userAddress: Address, deadline: bigint) {
|
|
51
|
+
* const vault = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
|
|
52
|
+
* // Set the exact vault-share allowance before submitting; the entity API derives that cap.
|
|
53
|
+
* const tx = vaultV2Withdraw({
|
|
54
|
+
* vault: { chainId: mainnet.id, address: vault },
|
|
55
|
+
* args: { amount: 1_000_000n, userAddress, deadline },
|
|
56
|
+
* });
|
|
57
|
+
* // tx satisfies Readonly<Transaction<VaultV2WithdrawAction>>
|
|
58
|
+
* return tx;
|
|
59
|
+
* }
|
|
32
60
|
* ```
|
|
33
61
|
*/
|
|
34
|
-
const vaultV2Withdraw = (
|
|
35
|
-
if (amount <= 0n) {
|
|
36
|
-
throw new
|
|
62
|
+
const vaultV2Withdraw = (params) => {
|
|
63
|
+
if (params.args.amount <= 0n) {
|
|
64
|
+
throw new index_js_1.NonPositiveInputError("amount", params.args.amount);
|
|
37
65
|
}
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
// Validate the ABI bound before encoding to preserve the SDK's typed errors.
|
|
67
|
+
(0, validate_js_1.validateUint256Field)("amount", params.args.amount);
|
|
68
|
+
const common = (0, common_js_1.normalizeBundlesCommonParams)(params.args);
|
|
69
|
+
const spender = (0, morpho_ts_1.getChainAddress)(params.vault.chainId, "bundles.vaultBundlesV1");
|
|
70
|
+
const sharesPermit = (0, common_js_1.getBundlesSharesPermit)({
|
|
71
|
+
vault: params.vault.address,
|
|
72
|
+
deadline: common.deadline,
|
|
73
|
+
owner: params.args.userAddress,
|
|
74
|
+
spender,
|
|
75
|
+
requirementSignature: params.args.requirementSignature,
|
|
76
|
+
});
|
|
77
|
+
const referralFeeAssets = (0, common_js_1.getBundlesReferralFeeAssets)(params.args.amount, common.referralFeePct);
|
|
78
|
+
return (0, common_js_1.finalizeVaultBundlesV1Transaction)({
|
|
79
|
+
chainId: params.vault.chainId,
|
|
80
|
+
value: 0n,
|
|
40
81
|
data: (0, viem_1.encodeFunctionData)({
|
|
41
|
-
abi:
|
|
42
|
-
functionName: "
|
|
43
|
-
args: [
|
|
82
|
+
abi: abis_js_1.vaultBundlesV1Abi,
|
|
83
|
+
functionName: "vaultBundlesV1Withdraw",
|
|
84
|
+
args: [
|
|
85
|
+
params.vault.address,
|
|
86
|
+
params.args.amount,
|
|
87
|
+
0n,
|
|
88
|
+
sharesPermit,
|
|
89
|
+
common.referralFeePct,
|
|
90
|
+
common.referralFeeRecipient,
|
|
91
|
+
common.deadline,
|
|
92
|
+
],
|
|
44
93
|
}),
|
|
45
|
-
value: 0n,
|
|
46
|
-
};
|
|
47
|
-
if (metadata) {
|
|
48
|
-
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
49
|
-
}
|
|
50
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
51
|
-
...tx,
|
|
52
94
|
action: {
|
|
53
95
|
type: "vaultV2Withdraw",
|
|
54
|
-
args: {
|
|
96
|
+
args: {
|
|
97
|
+
vault: params.vault.address,
|
|
98
|
+
amount: params.args.amount,
|
|
99
|
+
referralFeePct: common.referralFeePct,
|
|
100
|
+
referralFeeRecipient: common.referralFeeRecipient,
|
|
101
|
+
referralFeeAssets,
|
|
102
|
+
netAssets: params.args.amount - referralFeeAssets,
|
|
103
|
+
deadline: common.deadline,
|
|
104
|
+
},
|
|
55
105
|
},
|
|
106
|
+
metadata: params.metadata,
|
|
56
107
|
});
|
|
57
108
|
};
|
|
58
109
|
exports.vaultV2Withdraw = vaultV2Withdraw;
|
|
@@ -77,15 +77,15 @@ export interface BlueActions {
|
|
|
77
77
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
78
78
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
79
79
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
80
|
-
* @throws {
|
|
81
|
-
* @throws {
|
|
80
|
+
* @throws {MissingPermit2SignatureTransferNonceError} from `getRequirements()` when Permit2 is selected without a nonce.
|
|
81
|
+
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
82
82
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
83
83
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
|
|
84
84
|
* @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
|
|
85
85
|
* @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the collateral token.
|
|
86
86
|
* @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from `collateralAssets`.
|
|
87
87
|
* @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
|
|
88
|
-
* @throws {
|
|
88
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
|
|
89
89
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
90
90
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
91
91
|
* @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, or token metadata read fails.
|
|
@@ -141,8 +141,8 @@ export interface BlueActions {
|
|
|
141
141
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
142
142
|
* @throws {InputExceedsMaxError} when `assets` or `deadline` exceeds `uint256`, when the referral fee is at least WAD, or from `getRequirements()` when an explicit `permit2Nonce` exceeds `uint256`.
|
|
143
143
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
144
|
-
* @throws {
|
|
145
|
-
* @throws {
|
|
144
|
+
* @throws {MissingPermit2SignatureTransferNonceError} from `getRequirements()` when Permit2 is selected without an explicit nonce.
|
|
145
|
+
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
146
146
|
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when a classic `approvalAmount` is below the funded `assets`.
|
|
147
147
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
148
148
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when the route cannot consume a supplied signature.
|
|
@@ -150,7 +150,7 @@ export interface BlueActions {
|
|
|
150
150
|
* @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the loan token.
|
|
151
151
|
* @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from `assets`.
|
|
152
152
|
* @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
|
|
153
|
-
* @throws {
|
|
153
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
|
|
154
154
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
155
155
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
156
156
|
* @throws {viem.BaseError} from `getRequirements()` when a required allowance, nonce, or token metadata read fails.
|
|
@@ -221,7 +221,7 @@ export interface BlueActions {
|
|
|
221
221
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
|
|
222
222
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-authorization signature is supplied.
|
|
223
223
|
* @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
|
|
224
|
-
* @throws {
|
|
224
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
|
|
225
225
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
226
226
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
227
227
|
* @throws {viem.BaseError} from `getRequirements()` when authorization reads fail.
|
|
@@ -295,7 +295,7 @@ export interface BlueActions {
|
|
|
295
295
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
|
|
296
296
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a token signature is supplied.
|
|
297
297
|
* @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
|
|
298
|
-
* @throws {
|
|
298
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
|
|
299
299
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
300
300
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
301
301
|
* @throws {viem.BaseError} from `getRequirements()` when authorization reads fail.
|
|
@@ -366,15 +366,15 @@ export interface BlueActions {
|
|
|
366
366
|
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
367
367
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
368
368
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
369
|
-
* @throws {
|
|
370
|
-
* @throws {
|
|
369
|
+
* @throws {MissingPermit2SignatureTransferNonceError} from `getRequirements()` when Permit2 is selected without a nonce.
|
|
370
|
+
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
371
371
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
372
372
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an authorization signature is supplied.
|
|
373
373
|
* @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
|
|
374
374
|
* @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the loan token.
|
|
375
375
|
* @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from the derived funding cap.
|
|
376
376
|
* @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
|
|
377
|
-
* @throws {
|
|
377
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
|
|
378
378
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
379
379
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
380
380
|
* @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, or token metadata read fails.
|
|
@@ -447,7 +447,7 @@ export interface BlueActions {
|
|
|
447
447
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
|
|
448
448
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a token signature is supplied.
|
|
449
449
|
* @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
|
|
450
|
-
* @throws {
|
|
450
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
|
|
451
451
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
452
452
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
453
453
|
* @throws {viem.BaseError} from `getRequirements()` when authorization reads fail.
|
|
@@ -527,15 +527,15 @@ export interface BlueActions {
|
|
|
527
527
|
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
528
528
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
529
529
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
530
|
-
* @throws {
|
|
531
|
-
* @throws {
|
|
530
|
+
* @throws {MissingPermit2SignatureTransferNonceError} from `getRequirements()` when Permit2 is selected without an explicit nonce.
|
|
531
|
+
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
532
532
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple signatures of one kind are supplied.
|
|
533
533
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an inactive leg cannot consume a supplied signature.
|
|
534
534
|
* @throws {DepositOwnerMismatchError} from `buildTx()` when a signed owner differs from `userAddress`.
|
|
535
535
|
* @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the loan token.
|
|
536
536
|
* @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from the derived funding cap.
|
|
537
537
|
* @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
|
|
538
|
-
* @throws {
|
|
538
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
|
|
539
539
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
540
540
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
541
541
|
* @throws {viem.BaseError} from `getRequirements()` when a required allowance, nonce, token metadata, or authorization read fails.
|
|
@@ -625,15 +625,15 @@ export interface BlueActions {
|
|
|
625
625
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
626
626
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
627
627
|
* @throws {ReallocationLoanTokenMismatchError} when a source uses another loan token.
|
|
628
|
-
* @throws {
|
|
629
|
-
* @throws {
|
|
628
|
+
* @throws {MissingPermit2SignatureTransferNonceError} from `getRequirements()` when Permit2 is selected without an explicit nonce.
|
|
629
|
+
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
630
630
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple signatures of one kind are supplied.
|
|
631
631
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an inactive leg cannot consume a supplied signature.
|
|
632
632
|
* @throws {DepositOwnerMismatchError} from `buildTx()` when a signed owner differs from `userAddress`.
|
|
633
633
|
* @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the collateral token.
|
|
634
634
|
* @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from `collateralAssets`.
|
|
635
635
|
* @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
|
|
636
|
-
* @throws {
|
|
636
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
|
|
637
637
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
638
638
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
639
639
|
* @throws {viem.BaseError} from `getRequirements()` when a required allowance, nonce, token metadata, or authorization read fails.
|
|
@@ -714,7 +714,7 @@ export interface BlueActions {
|
|
|
714
714
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
|
|
715
715
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-authorization signature is supplied.
|
|
716
716
|
* @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
|
|
717
|
-
* @throws {
|
|
717
|
+
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
|
|
718
718
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
719
719
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
720
720
|
* @throws {viem.BaseError} from `getRequirements()` when authorization reads fail.
|
|
@@ -9,6 +9,7 @@ const common_js_1 = require("../../actions/blue/common.js");
|
|
|
9
9
|
const index_js_1 = require("../../actions/index.js");
|
|
10
10
|
const index_js_2 = require("../../helpers/index.js");
|
|
11
11
|
const index_js_3 = require("../../types/index.js");
|
|
12
|
+
const index_js_4 = require("../requirements/index.js");
|
|
12
13
|
const vaultV1ReallocationData_js_1 = require("../vaultV1ReallocationData.js");
|
|
13
14
|
const vaultV2BlueReallocationData_js_1 = require("../vaultV2BlueReallocationData.js");
|
|
14
15
|
class MorphoBlue {
|
|
@@ -50,8 +51,9 @@ class MorphoBlue {
|
|
|
50
51
|
}
|
|
51
52
|
async getTokenRequirements(params) {
|
|
52
53
|
this.validateDeadline(params.deadline);
|
|
53
|
-
return (0,
|
|
54
|
+
return (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
|
|
54
55
|
token: params.token,
|
|
56
|
+
spender: (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.blueBundlesV1"),
|
|
55
57
|
amount: params.amount,
|
|
56
58
|
owner: params.userAddress,
|
|
57
59
|
chainId: this.chainId,
|
|
@@ -62,6 +62,7 @@ TakeBorrowParams, TakeLendParams as MidnightTakeLendParams,
|
|
|
62
62
|
/** @deprecated Use `MidnightTakeLendParams`. */
|
|
63
63
|
TakeLendParams, } from "./midnight/index.js";
|
|
64
64
|
export { type MidnightActionOutput, type MidnightActionSignatures, type MidnightActions, MorphoMidnight, } from "./midnight/index.js";
|
|
65
|
+
export * from "./requirements/index.js";
|
|
65
66
|
export { MorphoVaultV1 } from "./vaultV1/index.js";
|
|
66
67
|
export { type InputReallocationData, type InputVaultV1ReallocationData, ReallocationData, VaultV1ReallocationData, } from "./vaultV1ReallocationData.js";
|
|
67
68
|
export { MorphoVaultV2 } from "./vaultV2/index.js";
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketPublicAllocatorConfig = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.BlueUser = exports.Token = exports.PreLiquidationPosition = exports.BluePreLiquidationPosition = exports.PreLiquidationParams = exports.BluePreLiquidationParams = exports.Position = exports.BluePosition = exports.MarketParams = exports.BlueMarketParams = exports.Market = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = exports.BlueAccrualPosition = void 0;
|
|
4
18
|
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.VaultV1ReallocationData = exports.ReallocationData = void 0;
|
|
@@ -62,6 +76,7 @@ var index_js_1 = require("./blue/index.js");
|
|
|
62
76
|
Object.defineProperty(exports, "MorphoBlue", { enumerable: true, get: function () { return index_js_1.MorphoBlue; } });
|
|
63
77
|
var index_js_2 = require("./midnight/index.js");
|
|
64
78
|
Object.defineProperty(exports, "MorphoMidnight", { enumerable: true, get: function () { return index_js_2.MorphoMidnight; } });
|
|
79
|
+
__exportStar(require("./requirements/index.js"), exports);
|
|
65
80
|
var index_js_3 = require("./vaultV1/index.js");
|
|
66
81
|
Object.defineProperty(exports, "MorphoVaultV1", { enumerable: true, get: function () { return index_js_3.MorphoVaultV1; } });
|
|
67
82
|
var vaultV1ReallocationData_js_1 = require("./vaultV1ReallocationData.js");
|
|
@@ -20,8 +20,8 @@ import type { GetOffersDataParams, GetPositionDataParams, MakeLendParams, MakeOf
|
|
|
20
20
|
* const output = midnight.takeLend({
|
|
21
21
|
* accountAddress: lender,
|
|
22
22
|
* marketData,
|
|
23
|
-
* assets:
|
|
24
|
-
* minUnits:
|
|
23
|
+
* assets: 1_000_000n,
|
|
24
|
+
* minUnits: 900_000n,
|
|
25
25
|
* takeableOffers: quote.data.takeableOffers,
|
|
26
26
|
* deadline: maxUint256,
|
|
27
27
|
* });
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type Address, type Client } from "viem";
|
|
2
|
-
import { type
|
|
3
|
-
/** Parameters for {@link
|
|
4
|
-
export interface
|
|
2
|
+
import { type BundlesTokenSignatureRequirement, type ERC20ApprovalAction, type Transaction } from "../../types/index.js";
|
|
3
|
+
/** Parameters for {@link getBundlesTokenRequirements}. */
|
|
4
|
+
export interface GetBundlesTokenRequirementsParams {
|
|
5
5
|
/** ERC-20 token funded by the operation. */
|
|
6
6
|
readonly token: Address;
|
|
7
|
-
/**
|
|
7
|
+
/** Registered fixed bundles contract that pulls the token. */
|
|
8
|
+
readonly spender: Address;
|
|
9
|
+
/** Exact amount the bundles contract will pull. */
|
|
8
10
|
readonly amount: bigint;
|
|
9
11
|
/** Classic approval amount; defaults to the exact pull amount. */
|
|
10
12
|
readonly approvalAmount?: bigint;
|
|
@@ -25,17 +27,18 @@ export interface GetBlueBundlesV1TokenRequirementsParams {
|
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Resolves direct approval, ERC-2612, or Permit2 SignatureTransfer prerequisites for
|
|
28
|
-
*
|
|
30
|
+
* a registered fixed bundles contract.
|
|
29
31
|
*
|
|
30
32
|
* Reads only the allowance and nonce state required by the selected path. Permit2 keeps the
|
|
31
|
-
* ERC-20 allowance on canonical Permit2 while the one-time signed transfer names
|
|
33
|
+
* ERC-20 allowance on canonical Permit2 while the one-time signed transfer names the bundles contract
|
|
32
34
|
* as spender. Permit2 SignatureTransfer requires an explicit unused unordered nonce so concurrent
|
|
33
35
|
* requirements never silently sign the same owner-global nonce.
|
|
34
36
|
*
|
|
35
37
|
* @param viemClient - Connected viem client used for allowance and nonce reads.
|
|
36
38
|
* @param params - Token requirement parameters.
|
|
37
39
|
* @param params.token - ERC-20 token funded by the operation.
|
|
38
|
-
* @param params.
|
|
40
|
+
* @param params.spender - Registered fixed bundles contract that pulls the token.
|
|
41
|
+
* @param params.amount - Exact amount the contract will pull; zero returns no requirements.
|
|
39
42
|
* @param params.approvalAmount - Classic approval amount; defaults to `amount` and is ignored by signature paths.
|
|
40
43
|
* @param params.owner - Account funding the operation.
|
|
41
44
|
* @param params.chainId - Target chain id; must match the client chain.
|
|
@@ -50,9 +53,10 @@ export interface GetBlueBundlesV1TokenRequirementsParams {
|
|
|
50
53
|
* @throws {NonPositiveInputError} when `deadline` is not positive.
|
|
51
54
|
* @throws {ExpiredDeadlineError} when `deadline` is positive but not in the future.
|
|
52
55
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
53
|
-
* @throws {
|
|
54
|
-
*
|
|
55
|
-
* @throws {
|
|
56
|
+
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not the chain's registered
|
|
57
|
+
* BlueBundlesV1 or VaultBundlesV1 deployment, including for a zero-amount request.
|
|
58
|
+
* @throws {MissingPermit2SignatureTransferNonceError} when Permit2 is selected without a nonce.
|
|
59
|
+
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} when `permit2Nonce` is already consumed.
|
|
56
60
|
* @throws {InputExceedsMaxError} when `amount`, `deadline`, or `permit2Nonce` exceeds uint256.
|
|
57
61
|
* @throws {ApprovalAmountLessThanSpendAmountError} when `approvalAmount` is below `amount`.
|
|
58
62
|
* @throws {viem.BaseError} when a required allowance, Permit2 nonce-bitmap, or ERC-2612 metadata
|
|
@@ -60,13 +64,16 @@ export interface GetBlueBundlesV1TokenRequirementsParams {
|
|
|
60
64
|
* @example
|
|
61
65
|
* ```ts
|
|
62
66
|
* import { addressesRegistry } from "@morpho-org/blue-sdk";
|
|
67
|
+
* import { getChainAddress } from "@morpho-org/morpho-ts";
|
|
63
68
|
* import { createPublicClient, http, zeroAddress } from "viem";
|
|
64
69
|
* import { mainnet } from "viem/chains";
|
|
65
|
-
* import {
|
|
70
|
+
* import { getBundlesTokenRequirements } from "@morpho-org/morpho-sdk";
|
|
66
71
|
*
|
|
67
72
|
* const client = createPublicClient({ chain: mainnet, transport: http() });
|
|
68
|
-
* const
|
|
73
|
+
* const vaultBundlesV1 = getChainAddress(mainnet.id, "bundles.vaultBundlesV1");
|
|
74
|
+
* const requirements = await getBundlesTokenRequirements(client, {
|
|
69
75
|
* token: addressesRegistry[mainnet.id].usdc,
|
|
76
|
+
* spender: vaultBundlesV1,
|
|
70
77
|
* amount: 1_000_000n,
|
|
71
78
|
* owner: zeroAddress,
|
|
72
79
|
* chainId: mainnet.id,
|
|
@@ -74,7 +81,7 @@ export interface GetBlueBundlesV1TokenRequirementsParams {
|
|
|
74
81
|
* supportSignature: true,
|
|
75
82
|
* permit2Nonce: 42n,
|
|
76
83
|
* });
|
|
77
|
-
* // requirements contains approvals and/or signable
|
|
84
|
+
* // requirements contains approvals and/or signable bundles token requirements.
|
|
78
85
|
* ```
|
|
79
86
|
*/
|
|
80
|
-
export declare const
|
|
87
|
+
export declare const getBundlesTokenRequirements: (viemClient: Client, params: GetBundlesTokenRequirementsParams) => Promise<readonly (Readonly<Transaction<ERC20ApprovalAction>> | BundlesTokenSignatureRequirement)[]>;
|