@morpho-org/morpho-sdk 5.9.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 +404 -0
- package/README.md +127 -69
- package/lib/cjs/abis.d.ts +210 -0
- package/lib/cjs/abis.js +142 -2
- package/lib/cjs/actions/blue/borrow.d.ts +62 -61
- package/lib/cjs/actions/blue/borrow.js +48 -80
- package/lib/cjs/actions/blue/common.d.ts +86 -0
- package/lib/cjs/actions/blue/common.js +205 -0
- package/lib/cjs/actions/blue/refinance.d.ts +72 -112
- package/lib/cjs/actions/blue/refinance.js +97 -199
- package/lib/cjs/actions/blue/repay.d.ts +72 -68
- package/lib/cjs/actions/blue/repay.js +56 -118
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +148 -137
- package/lib/cjs/actions/blue/supply.d.ts +62 -45
- package/lib/cjs/actions/blue/supply.js +94 -70
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/cjs/actions/blue/supplyCollateral.js +52 -69
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +133 -120
- package/lib/cjs/actions/blue/withdraw.d.ts +68 -79
- package/lib/cjs/actions/blue/withdraw.js +101 -97
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/cjs/actions/blue/withdrawCollateral.js +45 -50
- 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 +2 -1
- 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/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +60 -19
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +72 -0
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/blue/index.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +30 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +8 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +39 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +123 -0
- 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 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +6 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +6 -4
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
- 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/bundler/actions.d.ts +4 -4
- package/lib/cjs/bundler/actions.js +4 -4
- package/lib/cjs/client/morphoViemExtension.d.ts +2 -1
- package/lib/cjs/client/morphoViemExtension.js +2 -1
- package/lib/cjs/entities/blue/blue.d.ts +806 -374
- package/lib/cjs/entities/blue/blue.js +449 -696
- package/lib/cjs/entities/index.d.ts +2 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +203 -0
- 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/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +3 -9
- 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 +16 -23
- package/lib/cjs/helpers/validate.js +41 -48
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +3 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +303 -210
- package/lib/cjs/types/action.js +29 -2
- package/lib/cjs/types/client.d.ts +9 -0
- package/lib/cjs/types/error.d.ts +193 -18
- package/lib/cjs/types/error.js +267 -24
- package/lib/cjs/types/sharedLiquidity.d.ts +0 -7
- package/lib/esm/abis.d.ts +210 -0
- package/lib/esm/abis.js +140 -0
- package/lib/esm/actions/blue/borrow.d.ts +62 -61
- package/lib/esm/actions/blue/borrow.js +48 -80
- package/lib/esm/actions/blue/common.d.ts +86 -0
- package/lib/esm/actions/blue/common.js +193 -0
- package/lib/esm/actions/blue/refinance.d.ts +72 -112
- package/lib/esm/actions/blue/refinance.js +98 -200
- package/lib/esm/actions/blue/repay.d.ts +72 -68
- package/lib/esm/actions/blue/repay.js +56 -118
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +149 -138
- package/lib/esm/actions/blue/supply.d.ts +62 -45
- package/lib/esm/actions/blue/supply.js +94 -70
- package/lib/esm/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/esm/actions/blue/supplyCollateral.js +52 -69
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +134 -121
- package/lib/esm/actions/blue/withdraw.d.ts +68 -79
- package/lib/esm/actions/blue/withdraw.js +100 -96
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/esm/actions/blue/withdrawCollateral.js +45 -50
- 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 +2 -1
- 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/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +63 -22
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +68 -0
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -0
- package/lib/esm/actions/requirements/blue/index.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +31 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +40 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +119 -0
- 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 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +6 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +6 -4
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
- 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/bundler/actions.d.ts +4 -4
- package/lib/esm/bundler/actions.js +4 -4
- package/lib/esm/client/morphoViemExtension.d.ts +2 -1
- package/lib/esm/client/morphoViemExtension.js +2 -1
- package/lib/esm/entities/blue/blue.d.ts +806 -374
- package/lib/esm/entities/blue/blue.js +455 -702
- package/lib/esm/entities/index.d.ts +2 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +199 -0
- 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/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/esm/helpers/computeVaultV1Reallocations.js +3 -9
- 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 +16 -23
- package/lib/esm/helpers/validate.js +40 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/esm/helpers/validateRequirementSpender.js +3 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +303 -210
- package/lib/esm/types/action.js +28 -2
- package/lib/esm/types/client.d.ts +9 -0
- package/lib/esm/types/error.d.ts +193 -18
- package/lib/esm/types/error.js +252 -21
- package/lib/esm/types/sharedLiquidity.d.ts +0 -7
- package/package.json +6 -5
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +0 -63
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/cjs/actions/blue/buildReallocationActions.js +0 -141
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/cjs/actions/blue/resolveRepayFunding.js +0 -85
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/esm/actions/blue/buildAssetFundingActions.js +0 -59
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/esm/actions/blue/buildReallocationActions.js +0 -135
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/esm/actions/blue/resolveRepayFunding.js +0 -81
|
@@ -1,72 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueWithdrawCollateral = void 0;
|
|
4
|
-
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
-
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
6
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
|
-
const
|
|
8
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
9
|
-
const index_js_2 = require("../../types/index.js");
|
|
5
|
+
const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
|
|
10
6
|
/**
|
|
11
|
-
*
|
|
7
|
+
* Encodes a pure collateral withdrawal through BlueBundlesV1.
|
|
12
8
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Delegates to {@link blueRepayWithdrawCollateral} with a zero repay leg. BlueBundlesV1 enforces
|
|
10
|
+
* the supplied post-operation LTV, and no standalone Morpho or Bundler3 call is encoded.
|
|
15
11
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param params.market.
|
|
19
|
-
* @param params.
|
|
20
|
-
* @param params.args.
|
|
21
|
-
* @param params.args.
|
|
22
|
-
* @param params.args.
|
|
23
|
-
* @param params.
|
|
24
|
-
* @
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
12
|
+
* @param params - Collateral-withdrawal encoding parameters.
|
|
13
|
+
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
14
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
15
|
+
* @param params.args.userAddress - User whose collateral position is reduced.
|
|
16
|
+
* @param params.args.collateralAssets - Collateral assets withdrawn.
|
|
17
|
+
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
18
|
+
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
19
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee.
|
|
20
|
+
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
21
|
+
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
22
|
+
* @param params.metadata - Optional transaction metadata.
|
|
23
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawCollateralAction>>` whose calldata
|
|
24
|
+
* invokes the combined BlueBundlesV1 entrypoint with a zero repay leg.
|
|
25
|
+
* @throws {NegativeInputError} when collateral, LTV, or fee is negative.
|
|
26
|
+
* @throws {NonPositiveInputError} when collateral or deadline is not positive.
|
|
27
|
+
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
28
|
+
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
29
|
+
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
30
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
31
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
32
|
+
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
27
33
|
* @example
|
|
28
34
|
* ```ts
|
|
35
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
29
36
|
* import { blueWithdrawCollateral } from "@morpho-org/morpho-sdk";
|
|
37
|
+
* import { zeroAddress } from "viem";
|
|
38
|
+
* import { mainnet } from "viem/chains";
|
|
30
39
|
*
|
|
31
40
|
* const tx = blueWithdrawCollateral({
|
|
32
|
-
* market: { chainId:
|
|
41
|
+
* market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
|
|
33
42
|
* args: {
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
43
|
+
* userAddress: zeroAddress,
|
|
44
|
+
* collateralAssets: 1_000_000_000_000_000_000n,
|
|
45
|
+
* maxLtv: 850000000000000000n,
|
|
46
|
+
* deadline: 1_900_000_000n,
|
|
37
47
|
* },
|
|
38
48
|
* });
|
|
39
49
|
* // tx satisfies Readonly<Transaction<BlueWithdrawCollateralAction>>
|
|
40
50
|
* ```
|
|
41
51
|
*/
|
|
42
|
-
const blueWithdrawCollateral = (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
abi: blue_sdk_viem_1.blueAbi,
|
|
51
|
-
functionName: "withdrawCollateral",
|
|
52
|
-
args: [marketParams, amount, onBehalf, receiver],
|
|
53
|
-
}),
|
|
54
|
-
value: 0n,
|
|
55
|
-
};
|
|
56
|
-
if (metadata) {
|
|
57
|
-
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
58
|
-
}
|
|
59
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
60
|
-
...tx,
|
|
61
|
-
action: {
|
|
62
|
-
type: "blueWithdrawCollateral",
|
|
63
|
-
args: {
|
|
64
|
-
market: marketParams.id,
|
|
65
|
-
amount,
|
|
66
|
-
onBehalf,
|
|
67
|
-
receiver,
|
|
68
|
-
},
|
|
52
|
+
const blueWithdrawCollateral = (params) => {
|
|
53
|
+
const transaction = (0, repayWithdrawCollateral_js_1.blueRepayWithdrawCollateral)({
|
|
54
|
+
...params,
|
|
55
|
+
args: {
|
|
56
|
+
...params.args,
|
|
57
|
+
repayAssets: 0n,
|
|
58
|
+
repayShares: 0n,
|
|
59
|
+
maxRepayAssets: 0n,
|
|
69
60
|
},
|
|
70
61
|
});
|
|
62
|
+
return (0, morpho_ts_1.deepFreeze)({
|
|
63
|
+
...transaction,
|
|
64
|
+
action: { ...transaction.action, type: "blueWithdrawCollateral" },
|
|
65
|
+
});
|
|
71
66
|
};
|
|
72
67
|
exports.blueWithdrawCollateral = blueWithdrawCollateral;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import { type BaseAction, type BundlesFundingArgs, type BundlesTokenRequirementSignature, type Erc2612RequirementSignature, type Metadata, type Permit2SignatureTransferAction, type PermitAction, type PermitRequirementSignature, type RequirementSignature, type TokenRequirementSignature, type Transaction } from "../../types/index.js";
|
|
3
|
+
/** Numeric permit kinds consumed by `TokenLib.pullToken`. */
|
|
4
|
+
export declare const BundlesPermitKind: {
|
|
5
|
+
readonly None: 0;
|
|
6
|
+
readonly ERC2612: 1;
|
|
7
|
+
readonly Permit2: 2;
|
|
8
|
+
};
|
|
9
|
+
/** A numeric permit kind consumed by `TokenLib.pullToken`. */
|
|
10
|
+
export type BundlesPermitKind = (typeof BundlesPermitKind)[keyof typeof BundlesPermitKind];
|
|
11
|
+
/** ABI-ready token permit consumed by fixed bundles deposit and funding entrypoints. */
|
|
12
|
+
export interface BundlesTokenPermit {
|
|
13
|
+
/** TokenLib permit dispatch kind. */
|
|
14
|
+
readonly kind: BundlesPermitKind;
|
|
15
|
+
/** ABI-encoded permit payload, or empty bytes for classic allowance funding. */
|
|
16
|
+
readonly data: Hex;
|
|
17
|
+
}
|
|
18
|
+
/** ABI-ready ERC-2612 share permit consumed by vault bundles. */
|
|
19
|
+
export interface BundleSharesPermit {
|
|
20
|
+
/** Exact vault-share allowance authorized by the permit. */
|
|
21
|
+
readonly value: bigint;
|
|
22
|
+
/** Vault permit nonce signed by the owner. */
|
|
23
|
+
readonly nonce: bigint;
|
|
24
|
+
/** Permit signature deadline. */
|
|
25
|
+
readonly deadline: bigint;
|
|
26
|
+
/** ECDSA recovery identifier, or zero for the empty sentinel. */
|
|
27
|
+
readonly v: number;
|
|
28
|
+
/** ECDSA signature `r`, or zero for the empty sentinel. */
|
|
29
|
+
readonly r: Hex;
|
|
30
|
+
/** ECDSA signature `s`, or zero for the empty sentinel. */
|
|
31
|
+
readonly s: Hex;
|
|
32
|
+
}
|
|
33
|
+
/** Compatibility alias for the canonical {@link BundleSharesPermit} tuple. */
|
|
34
|
+
export type BundlesSharesPermit = BundleSharesPermit;
|
|
35
|
+
/** Common deadline and referral fields shared by fixed bundles calls. */
|
|
36
|
+
export interface BundlesCommonParams {
|
|
37
|
+
/** Contract execution deadline. */
|
|
38
|
+
readonly deadline: bigint;
|
|
39
|
+
/** Optional WAD-scaled referral fee percentage. */
|
|
40
|
+
readonly referralFeePct?: bigint;
|
|
41
|
+
/** Recipient required when `referralFeePct` is positive. */
|
|
42
|
+
readonly referralFeeRecipient?: Address;
|
|
43
|
+
}
|
|
44
|
+
/** Normalized deadline and referral fields encoded by fixed bundles calls. */
|
|
45
|
+
export interface NormalizedBundlesCommonParams {
|
|
46
|
+
/** Validated contract execution deadline. */
|
|
47
|
+
readonly deadline: bigint;
|
|
48
|
+
/** Validated WAD-scaled referral fee percentage. */
|
|
49
|
+
readonly referralFeePct: bigint;
|
|
50
|
+
/** Referral recipient, or the zero address when fees are disabled. */
|
|
51
|
+
readonly referralFeeRecipient: Address;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Validates and normalizes a bundles deadline and referral fee configuration.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*
|
|
58
|
+
* @param params - Common bundles parameters.
|
|
59
|
+
* @returns Validated values with explicit zero defaults.
|
|
60
|
+
* @throws {NonPositiveInputError} when `deadline` is not positive.
|
|
61
|
+
* @throws {InputExceedsMaxError} when `deadline` exceeds uint256.
|
|
62
|
+
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
63
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct >= WAD`.
|
|
64
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
65
|
+
*/
|
|
66
|
+
export declare const normalizeBundlesCommonParams: (params: BundlesCommonParams) => NormalizedBundlesCommonParams;
|
|
67
|
+
/**
|
|
68
|
+
* Resolves mutually exclusive ERC-20/native funding into the entrypoint amount and transaction value.
|
|
69
|
+
*
|
|
70
|
+
* @param params - Exclusive bundles funding.
|
|
71
|
+
* @param params.amount - ERC-20 funding in the token's smallest unit; mutually exclusive with `nativeAmount`.
|
|
72
|
+
* @param params.nativeAmount - Native funding in wei; mutually exclusive with `amount`.
|
|
73
|
+
* @returns The gross ABI asset amount and native transaction value.
|
|
74
|
+
* @throws {MixedBundlesFundingError} when both funding keys are present.
|
|
75
|
+
* @throws {NegativeInputError} when the selected amount is negative.
|
|
76
|
+
* @throws {NonPositiveInputError} when the selected amount is not positive.
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { resolveBundlesFunding } from "@morpho-org/morpho-sdk";
|
|
80
|
+
*
|
|
81
|
+
* const funding = resolveBundlesFunding({ amount: 1_000_000n });
|
|
82
|
+
* // funding is { assets: 1_000_000n, value: 0n }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare const resolveBundlesFunding: (params: BundlesFundingArgs) => {
|
|
86
|
+
readonly assets: bigint;
|
|
87
|
+
readonly value: bigint;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Converts an optional signed token requirement into the ABI-ready TokenLib permit tuple.
|
|
91
|
+
*
|
|
92
|
+
* @param params - Expected funding values and optional signed requirement.
|
|
93
|
+
* @param params.userAddress - Account funding the operation; must match the signature owner.
|
|
94
|
+
* @param params.token - ERC-20 funding token; must match the signed asset.
|
|
95
|
+
* @param params.spender - Fixed bundles contract authorized to pull the token.
|
|
96
|
+
* @param params.amount - Exact pull amount in the token's smallest unit; must match both signed amount fields.
|
|
97
|
+
* @param params.requirementSignature - Optional signed ERC-2612 or Permit2 SignatureTransfer requirement; omit for allowance funding.
|
|
98
|
+
* @returns An empty, ERC-2612, or Permit2 SignatureTransfer token permit.
|
|
99
|
+
* @throws {UnexpectedRequirementSignatureError} when Permit2 AllowanceTransfer is supplied.
|
|
100
|
+
* @throws {DepositOwnerMismatchError} when the signature owner differs from `userAddress`.
|
|
101
|
+
* @throws {DepositAssetMismatchError} when the signed token differs from `token`.
|
|
102
|
+
* @throws {DepositAmountMismatchError} when the signed amount differs from `amount`.
|
|
103
|
+
* @throws {DepositSpenderMismatchError} when the signed spender differs from `spender`.
|
|
104
|
+
* @throws {BundlesRequirementSignatureMismatchError} when signature metadata is malformed.
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { getBundlesTokenPermit } from "@morpho-org/morpho-sdk";
|
|
108
|
+
* import { zeroAddress } from "viem";
|
|
109
|
+
*
|
|
110
|
+
* const permit = getBundlesTokenPermit({
|
|
111
|
+
* userAddress: zeroAddress,
|
|
112
|
+
* token: zeroAddress,
|
|
113
|
+
* spender: zeroAddress,
|
|
114
|
+
* amount: 1n,
|
|
115
|
+
* });
|
|
116
|
+
* // permit is { kind: 0, data: "0x" }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare const getBundlesTokenPermit: (params: {
|
|
120
|
+
readonly userAddress: Address;
|
|
121
|
+
readonly token: Address;
|
|
122
|
+
readonly spender: Address;
|
|
123
|
+
readonly amount: bigint;
|
|
124
|
+
readonly requirementSignature?: TokenRequirementSignature;
|
|
125
|
+
}) => BundlesTokenPermit;
|
|
126
|
+
/** @internal Normalizes a compact or serialized ECDSA signature for bundles permit tuples. */
|
|
127
|
+
export declare const normalizeBundlesSignature: (serializedSignature: Hex) => {
|
|
128
|
+
readonly v: number;
|
|
129
|
+
readonly r: Hex;
|
|
130
|
+
readonly s: Hex;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Converts an optional vault-share ERC-2612 requirement into the ABI-ready Permit tuple.
|
|
134
|
+
*
|
|
135
|
+
* @param params - Vault token, empty-sentinel deadline, and optional signed requirement.
|
|
136
|
+
* @param params.vault - Vault share token authorized by the permit.
|
|
137
|
+
* @param params.deadline - Unix timestamp in seconds used by the empty-permit sentinel.
|
|
138
|
+
* @param params.owner - Optional expected signature owner.
|
|
139
|
+
* @param params.spender - Optional expected fixed bundles contract authorized to pull shares.
|
|
140
|
+
* @param params.amount - Optional exact share allowance in the vault share token's smallest unit.
|
|
141
|
+
* @param params.requirementSignature - Optional signed ERC-2612 share requirement; omit for the empty-permit sentinel.
|
|
142
|
+
* @returns The signed share permit or the contract's empty-permit sentinel.
|
|
143
|
+
* @throws {BundlesPermitMismatchError} when the requirement kind, token, or signature is invalid.
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { getBundlesSharesPermit } from "@morpho-org/morpho-sdk";
|
|
147
|
+
* import { zeroAddress } from "viem";
|
|
148
|
+
*
|
|
149
|
+
* const permit = getBundlesSharesPermit({
|
|
150
|
+
* vault: zeroAddress,
|
|
151
|
+
* deadline: 1_900_000_000n,
|
|
152
|
+
* });
|
|
153
|
+
* // permit.value === 0n
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare const getBundlesSharesPermit: (params: {
|
|
157
|
+
readonly vault: Address;
|
|
158
|
+
readonly deadline: bigint;
|
|
159
|
+
readonly owner?: Address;
|
|
160
|
+
readonly spender?: Address;
|
|
161
|
+
readonly amount?: bigint;
|
|
162
|
+
readonly requirementSignature?: PermitRequirementSignature;
|
|
163
|
+
}) => BundleSharesPermit;
|
|
164
|
+
/**
|
|
165
|
+
* Selects the one token signature accepted by a bundles-funded call.
|
|
166
|
+
*
|
|
167
|
+
* @internal
|
|
168
|
+
*
|
|
169
|
+
* @param signatures - Signatures passed to `buildTx`.
|
|
170
|
+
* @param expectedRequirement - Signature requirement captured by this prepared operation.
|
|
171
|
+
* @returns The selected ERC-2612 or Permit2 SignatureTransfer signature.
|
|
172
|
+
* @throws {UnexpectedRequirementSignatureError} when a non-token signature is supplied.
|
|
173
|
+
* @throws {AmbiguousRequirementSignaturesError} when both token signature kinds are supplied.
|
|
174
|
+
*/
|
|
175
|
+
export declare const selectBundlesTokenRequirementSignature: (signatures: readonly RequirementSignature[] | undefined, expectedRequirement?: PermitAction | Permit2SignatureTransferAction) => BundlesTokenRequirementSignature | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* Selects the exact ERC-2612 vault-share permit produced for one prepared exit.
|
|
178
|
+
*
|
|
179
|
+
* @internal
|
|
180
|
+
*
|
|
181
|
+
* @param signatures - Signatures passed to the prepared operation's `buildTx` function.
|
|
182
|
+
* @param prepared - Exact share cap and permit requirement captured by this prepared operation.
|
|
183
|
+
* @returns The matching ERC-2612 signature, or `undefined` when no signature is supplied.
|
|
184
|
+
* @throws {BundlesPermitMismatchError} when the signature is not ERC-2612, was built for another
|
|
185
|
+
* share cap, or is supplied before this operation resolves its share cap.
|
|
186
|
+
*/
|
|
187
|
+
export declare const selectBundlesSharesRequirementSignature: (signatures: readonly RequirementSignature[] | undefined, prepared: {
|
|
188
|
+
readonly requiredShareAllowance: bigint | undefined;
|
|
189
|
+
readonly expectedRequirement?: PermitAction;
|
|
190
|
+
}) => Erc2612RequirementSignature | undefined;
|
|
191
|
+
/** @internal Returns the exact referral fee deducted from a fixed gross asset amount. */
|
|
192
|
+
export declare const getBundlesReferralFeeAssets: (assets: bigint, referralFeePct: bigint) => bigint;
|
|
193
|
+
/** @internal Finalizes a direct VaultBundlesV1 transaction with metadata and immutable action data. */
|
|
194
|
+
export declare const finalizeVaultBundlesV1Transaction: <TAction extends BaseAction>(params: {
|
|
195
|
+
readonly chainId: number;
|
|
196
|
+
readonly value: bigint;
|
|
197
|
+
readonly data: Hex;
|
|
198
|
+
readonly action: TAction;
|
|
199
|
+
readonly metadata?: Metadata;
|
|
200
|
+
}) => Readonly<Transaction<TAction>>;
|