@morpho-org/morpho-sdk 6.0.0-next.2 → 6.0.0-next.3
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 +83 -29
- package/README.md +9 -7
- package/lib/cjs/abis.d.ts +3 -2844
- package/lib/cjs/abis.js +1 -1951
- package/lib/cjs/actions/blue/borrow.d.ts +3 -2
- package/lib/cjs/actions/blue/borrow.js +3 -2
- package/lib/cjs/actions/blue/common.js +1 -9
- package/lib/cjs/actions/blue/refinance.d.ts +2 -2
- package/lib/cjs/actions/blue/refinance.js +2 -2
- package/lib/cjs/actions/blue/repay.d.ts +1 -1
- package/lib/cjs/actions/blue/repay.js +1 -1
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/cjs/actions/blue/supply.d.ts +2 -2
- package/lib/cjs/actions/blue/supply.js +2 -2
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/supplyCollateral.js +2 -2
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -2
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +3 -2
- package/lib/cjs/actions/blue/withdraw.d.ts +3 -3
- package/lib/cjs/actions/blue/withdraw.js +3 -3
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
- package/lib/cjs/actions/bundles/common.d.ts +6 -2
- package/lib/cjs/actions/bundles/common.js +23 -5
- package/lib/cjs/actions/index.d.ts +0 -1
- package/lib/cjs/actions/index.js +0 -1
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -16
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +4 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +6 -11
- package/lib/cjs/actions/requirements/encode/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/encode/index.js +0 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -6
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -6
- package/lib/cjs/actions/requirements/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/index.js +0 -1
- package/lib/cjs/actions/vaultV1/deposit.d.ts +1 -2
- package/lib/cjs/actions/vaultV1/deposit.js +1 -2
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +6 -5
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +10 -7
- package/lib/cjs/actions/vaultV2/deposit.d.ts +1 -2
- package/lib/cjs/actions/vaultV2/deposit.js +1 -2
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +3 -3
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +6 -5
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +10 -7
- package/lib/cjs/augment.d.ts +0 -1
- package/lib/cjs/augment.js +0 -1
- package/lib/cjs/blue/abis.d.ts +1 -5
- package/lib/cjs/blue/abis.js +1 -7
- package/lib/cjs/blue/entities.d.ts +2 -8
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/fetch.d.ts +1 -3
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/types.d.ts +2 -4
- package/lib/cjs/blue/utils.d.ts +1 -3
- package/lib/cjs/blue/utils.js +1 -3
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +1 -1
- package/lib/cjs/constants.d.ts +3 -37
- package/lib/cjs/constants.js +1 -39
- package/lib/cjs/entities/blue/blue.d.ts +30 -265
- package/lib/cjs/entities/blue/blue.js +1 -205
- package/lib/cjs/entities/index.d.ts +3 -66
- package/lib/cjs/entities/index.js +1 -21
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -2
- package/lib/cjs/entities/vaultV1/vaultV1.js +12 -7
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +22 -9
- package/lib/cjs/entities/vaultV2/vaultV2.js +28 -15
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +4 -21
- package/lib/cjs/errors.d.ts +2 -46
- package/lib/cjs/errors.js +1 -46
- package/lib/cjs/fetch.d.ts +1 -17
- package/lib/cjs/fetch.js +1 -17
- package/lib/cjs/helpers/constant.d.ts +0 -2
- package/lib/cjs/helpers/constant.js +0 -2
- package/lib/cjs/helpers/index.d.ts +2 -3
- package/lib/cjs/helpers/index.js +1 -9
- package/lib/cjs/helpers/slippage.d.ts +1 -103
- package/lib/cjs/helpers/slippage.js +0 -150
- package/lib/cjs/helpers/utilization.d.ts +12 -10
- package/lib/cjs/helpers/utilization.js +27 -12
- package/lib/cjs/helpers/validate.d.ts +1 -24
- package/lib/cjs/helpers/validate.js +2 -49
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
- package/lib/cjs/types/action.d.ts +17 -65
- package/lib/cjs/types/action.js +11 -4
- package/lib/cjs/types/error.d.ts +50 -381
- package/lib/cjs/types/error.js +64 -395
- package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
- package/lib/cjs/types.d.ts +2 -18
- package/lib/cjs/utils.d.ts +6 -35
- package/lib/cjs/utils.js +2 -36
- package/lib/esm/abis.d.ts +3 -2844
- package/lib/esm/abis.js +3 -1950
- package/lib/esm/actions/blue/borrow.d.ts +3 -2
- package/lib/esm/actions/blue/borrow.js +3 -2
- package/lib/esm/actions/blue/common.js +1 -9
- package/lib/esm/actions/blue/refinance.d.ts +2 -2
- package/lib/esm/actions/blue/refinance.js +2 -2
- package/lib/esm/actions/blue/repay.d.ts +1 -1
- package/lib/esm/actions/blue/repay.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/esm/actions/blue/supply.d.ts +2 -2
- package/lib/esm/actions/blue/supply.js +2 -2
- package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/supplyCollateral.js +2 -2
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -2
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -2
- package/lib/esm/actions/blue/withdraw.d.ts +3 -3
- package/lib/esm/actions/blue/withdraw.js +3 -3
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/withdrawCollateral.js +2 -2
- package/lib/esm/actions/bundles/common.d.ts +6 -2
- package/lib/esm/actions/bundles/common.js +24 -6
- package/lib/esm/actions/index.d.ts +0 -1
- package/lib/esm/actions/index.js +0 -1
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +12 -17
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +4 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +6 -11
- package/lib/esm/actions/requirements/encode/index.d.ts +0 -1
- package/lib/esm/actions/requirements/encode/index.js +0 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -6
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -6
- package/lib/esm/actions/requirements/index.d.ts +0 -1
- package/lib/esm/actions/requirements/index.js +0 -1
- package/lib/esm/actions/vaultV1/deposit.d.ts +1 -2
- package/lib/esm/actions/vaultV1/deposit.js +1 -2
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +6 -5
- package/lib/esm/actions/vaultV1/inKindRedeem.js +10 -7
- package/lib/esm/actions/vaultV2/deposit.d.ts +1 -2
- package/lib/esm/actions/vaultV2/deposit.js +1 -2
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +6 -5
- package/lib/esm/actions/vaultV2/inKindRedeem.js +10 -7
- package/lib/esm/augment.d.ts +0 -1
- package/lib/esm/augment.js +0 -1
- package/lib/esm/blue/abis.d.ts +1 -5
- package/lib/esm/blue/abis.js +1 -5
- package/lib/esm/blue/entities.d.ts +2 -8
- package/lib/esm/blue/entities.js +1 -3
- package/lib/esm/blue/fetch.d.ts +1 -3
- package/lib/esm/blue/fetch.js +1 -3
- package/lib/esm/blue/types.d.ts +2 -4
- package/lib/esm/blue/utils.d.ts +1 -3
- package/lib/esm/blue/utils.js +1 -3
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +1 -1
- package/lib/esm/constants.d.ts +3 -37
- package/lib/esm/constants.js +3 -37
- package/lib/esm/entities/blue/blue.d.ts +30 -265
- package/lib/esm/entities/blue/blue.js +4 -208
- package/lib/esm/entities/index.d.ts +3 -66
- package/lib/esm/entities/index.js +1 -18
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +15 -10
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +22 -9
- package/lib/esm/entities/vaultV2/vaultV2.js +32 -19
- package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -19
- package/lib/esm/errors.d.ts +2 -46
- package/lib/esm/errors.js +2 -46
- package/lib/esm/fetch.d.ts +1 -17
- package/lib/esm/fetch.js +1 -17
- package/lib/esm/helpers/constant.d.ts +0 -2
- package/lib/esm/helpers/constant.js +0 -2
- package/lib/esm/helpers/index.d.ts +2 -3
- package/lib/esm/helpers/index.js +2 -3
- package/lib/esm/helpers/slippage.d.ts +1 -103
- package/lib/esm/helpers/slippage.js +1 -147
- package/lib/esm/helpers/utilization.d.ts +12 -10
- package/lib/esm/helpers/utilization.js +26 -11
- package/lib/esm/helpers/validate.d.ts +1 -24
- package/lib/esm/helpers/validate.js +2 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -3
- package/lib/esm/types/action.d.ts +17 -65
- package/lib/esm/types/action.js +12 -5
- package/lib/esm/types/error.d.ts +50 -381
- package/lib/esm/types/error.js +58 -377
- package/lib/esm/types/sharedLiquidity.d.ts +1 -117
- package/lib/esm/types.d.ts +2 -18
- package/lib/esm/utils.d.ts +6 -35
- package/lib/esm/utils.js +5 -34
- package/package.json +5 -13
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -88
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -152
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -53
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -74
- package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +0 -3
- package/lib/cjs/actions/requirements/generalAdapter/index.js +0 -19
- package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
- package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +0 -48
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +0 -58
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +0 -119
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -45
- package/lib/cjs/actions/signatures/index.d.ts +0 -3
- package/lib/cjs/actions/signatures/index.js +0 -19
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +0 -8
- package/lib/cjs/bundler/actions.d.ts +0 -797
- package/lib/cjs/bundler/actions.js +0 -1371
- package/lib/cjs/bundler/index.d.ts +0 -2
- package/lib/cjs/bundler/index.js +0 -18
- package/lib/cjs/bundler/types.d.ts +0 -235
- package/lib/cjs/bundler/types.js +0 -2
- package/lib/cjs/entities/vaultV1ReallocationData.d.ts +0 -332
- package/lib/cjs/entities/vaultV1ReallocationData.js +0 -557
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -80
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -245
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -84
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -148
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -49
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -70
- package/lib/esm/actions/requirements/generalAdapter/index.d.ts +0 -3
- package/lib/esm/actions/requirements/generalAdapter/index.js +0 -3
- package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
- package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +0 -44
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +0 -58
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +0 -115
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -41
- package/lib/esm/actions/signatures/index.d.ts +0 -3
- package/lib/esm/actions/signatures/index.js +0 -3
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -7
- package/lib/esm/bundler/actions.d.ts +0 -797
- package/lib/esm/bundler/actions.js +0 -1368
- package/lib/esm/bundler/index.d.ts +0 -2
- package/lib/esm/bundler/index.js +0 -2
- package/lib/esm/bundler/types.d.ts +0 -235
- package/lib/esm/bundler/types.js +0 -1
- package/lib/esm/entities/vaultV1ReallocationData.d.ts +0 -332
- package/lib/esm/entities/vaultV1ReallocationData.js +0 -559
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -80
- package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -241
|
@@ -34,7 +34,7 @@ export interface BlueBorrowParams {
|
|
|
34
34
|
* Encodes a pure borrow through BlueBundlesV1.
|
|
35
35
|
*
|
|
36
36
|
* Delegates to {@link blueSupplyCollateralBorrow} with a zero collateral leg. Vault V2 allocator
|
|
37
|
-
* penalties and referral fees reduce the assets received
|
|
37
|
+
* penalties and referral fees reduce the assets received.
|
|
38
38
|
*
|
|
39
39
|
* @param params - Borrow encoding parameters.
|
|
40
40
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -53,8 +53,9 @@ export interface BlueBorrowParams {
|
|
|
53
53
|
* @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
|
|
54
54
|
* @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
|
|
55
55
|
* @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
|
|
56
|
-
* @throws {
|
|
56
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
57
57
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
58
|
+
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
58
59
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
59
60
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
60
61
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
@@ -4,7 +4,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
|
|
|
4
4
|
* Encodes a pure borrow through BlueBundlesV1.
|
|
5
5
|
*
|
|
6
6
|
* Delegates to {@link blueSupplyCollateralBorrow} with a zero collateral leg. Vault V2 allocator
|
|
7
|
-
* penalties and referral fees reduce the assets received
|
|
7
|
+
* penalties and referral fees reduce the assets received.
|
|
8
8
|
*
|
|
9
9
|
* @param params - Borrow encoding parameters.
|
|
10
10
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -23,8 +23,9 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
|
|
|
23
23
|
* @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
|
|
24
24
|
* @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
|
|
25
25
|
* @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
|
|
26
|
-
* @throws {
|
|
26
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
27
27
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
28
|
+
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
28
29
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
29
30
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
30
31
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
@@ -142,19 +142,11 @@ export const selectBlueBundlesV1RequirementSignatures = (signatures, accepts) =>
|
|
|
142
142
|
permit2SignatureTransfer: accepts.token,
|
|
143
143
|
authorization: accepts.authorization,
|
|
144
144
|
});
|
|
145
|
-
if (permit?.action.type === "permit2") {
|
|
146
|
-
throw new BundlesRequirementSignatureMismatchError({
|
|
147
|
-
field: "type",
|
|
148
|
-
expected: "permit or permit2SignatureTransfer",
|
|
149
|
-
actual: permit.action.type,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
145
|
if (permit != null && permit2SignatureTransfer != null) {
|
|
153
146
|
throw new AmbiguousRequirementSignaturesError("permit", 2);
|
|
154
147
|
}
|
|
155
148
|
return {
|
|
156
|
-
token: permit ??
|
|
157
|
-
permit2SignatureTransfer,
|
|
149
|
+
token: permit ?? permit2SignatureTransfer,
|
|
158
150
|
authorization,
|
|
159
151
|
};
|
|
160
152
|
};
|
|
@@ -61,9 +61,9 @@ export interface BlueRefinanceParams {
|
|
|
61
61
|
* @throws {NegativeInputError} when `maxLtv`, a referral fee, or a reallocation penalty is negative.
|
|
62
62
|
* @throws {NonPositiveInputError} when the deadline or a reallocation amount is not positive.
|
|
63
63
|
* @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its ABI bound.
|
|
64
|
-
* @throws {
|
|
64
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
65
65
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
66
|
-
* @throws {
|
|
66
|
+
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
67
67
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
68
68
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
69
69
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
|
|
@@ -31,9 +31,9 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
|
|
|
31
31
|
* @throws {NegativeInputError} when `maxLtv`, a referral fee, or a reallocation penalty is negative.
|
|
32
32
|
* @throws {NonPositiveInputError} when the deadline or a reallocation amount is not positive.
|
|
33
33
|
* @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its ABI bound.
|
|
34
|
-
* @throws {
|
|
34
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
35
35
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
36
|
-
* @throws {
|
|
36
|
+
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
37
37
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
38
38
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
39
39
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
|
|
@@ -67,7 +67,7 @@ export interface BlueRepayParams {
|
|
|
67
67
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
68
68
|
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
69
69
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
70
|
-
* @throws {
|
|
70
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
71
71
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
72
72
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
73
73
|
* @example
|
|
@@ -36,7 +36,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
|
|
|
36
36
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
37
37
|
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
38
38
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
39
|
-
* @throws {
|
|
39
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
40
40
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
41
41
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
42
42
|
* @example
|
|
@@ -43,7 +43,7 @@ export interface BlueRepayWithdrawCollateralParams {
|
|
|
43
43
|
*
|
|
44
44
|
* `maxRepayAssets` funds the live repayment plus fee and BlueBundlesV1 refunds the unused amount.
|
|
45
45
|
* A saturated `repayShares = maxUint256` closes the live remaining debt. This route has no
|
|
46
|
-
*
|
|
46
|
+
* share-price bound or `slippageTolerance` input.
|
|
47
47
|
*
|
|
48
48
|
* @param params - Combined-operation encoding parameters.
|
|
49
49
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -68,7 +68,7 @@ export interface BlueRepayWithdrawCollateralParams {
|
|
|
68
68
|
* @throws {NonPositiveInputError} when both operation legs are zero, repay funding is absent, or the deadline is invalid.
|
|
69
69
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} when exact-asset funding cannot cover the repayment and referral fee.
|
|
70
70
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
71
|
-
* @throws {
|
|
71
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
72
72
|
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
73
73
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
74
74
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
@@ -8,7 +8,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, ge
|
|
|
8
8
|
*
|
|
9
9
|
* `maxRepayAssets` funds the live repayment plus fee and BlueBundlesV1 refunds the unused amount.
|
|
10
10
|
* A saturated `repayShares = maxUint256` closes the live remaining debt. This route has no
|
|
11
|
-
*
|
|
11
|
+
* share-price bound or `slippageTolerance` input.
|
|
12
12
|
*
|
|
13
13
|
* @param params - Combined-operation encoding parameters.
|
|
14
14
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -33,7 +33,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, ge
|
|
|
33
33
|
* @throws {NonPositiveInputError} when both operation legs are zero, repay funding is absent, or the deadline is invalid.
|
|
34
34
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} when exact-asset funding cannot cover the repayment and referral fee.
|
|
35
35
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
36
|
-
* @throws {
|
|
36
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
37
37
|
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
38
38
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
39
39
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
@@ -32,7 +32,7 @@ export interface BlueSupplyParams {
|
|
|
32
32
|
* Encodes a direct BlueBundlesV1 loan-asset supply transaction.
|
|
33
33
|
*
|
|
34
34
|
* `assets` is the gross funded amount; BlueBundlesV1 deducts the referral fee before supplying.
|
|
35
|
-
* This route has no
|
|
35
|
+
* This route has no share-price bound or `slippageTolerance` input.
|
|
36
36
|
*
|
|
37
37
|
* @param params - Supply encoding parameters.
|
|
38
38
|
* @param params.market.chainId - Chain containing the BlueBundlesV1 deployment.
|
|
@@ -50,7 +50,7 @@ export interface BlueSupplyParams {
|
|
|
50
50
|
* @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
|
|
51
51
|
* @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
|
|
52
52
|
* @throws {InputExceedsMaxError} when `assets` exceeds `uint256` or `referralFeePct` is at least WAD.
|
|
53
|
-
* @throws {
|
|
53
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
54
54
|
* @throws {NativeFundingAmountMismatchError} when native funding does not equal `assets`.
|
|
55
55
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
56
56
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
@@ -7,7 +7,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normaliz
|
|
|
7
7
|
* Encodes a direct BlueBundlesV1 loan-asset supply transaction.
|
|
8
8
|
*
|
|
9
9
|
* `assets` is the gross funded amount; BlueBundlesV1 deducts the referral fee before supplying.
|
|
10
|
-
* This route has no
|
|
10
|
+
* This route has no share-price bound or `slippageTolerance` input.
|
|
11
11
|
*
|
|
12
12
|
* @param params - Supply encoding parameters.
|
|
13
13
|
* @param params.market.chainId - Chain containing the BlueBundlesV1 deployment.
|
|
@@ -25,7 +25,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normaliz
|
|
|
25
25
|
* @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
|
|
26
26
|
* @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
|
|
27
27
|
* @throws {InputExceedsMaxError} when `assets` exceeds `uint256` or `referralFeePct` is at least WAD.
|
|
28
|
-
* @throws {
|
|
28
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
29
29
|
* @throws {NativeFundingAmountMismatchError} when native funding does not equal `assets`.
|
|
30
30
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
31
31
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
@@ -32,7 +32,7 @@ export interface BlueSupplyCollateralParams {
|
|
|
32
32
|
* Encodes a pure collateral supply through BlueBundlesV1.
|
|
33
33
|
*
|
|
34
34
|
* Delegates to {@link blueSupplyCollateralBorrow} with a zero borrow leg and an unrestricted LTV
|
|
35
|
-
* cap. Native funding is exclusive with ERC-20 funding
|
|
35
|
+
* cap. Native funding is exclusive with ERC-20 funding.
|
|
36
36
|
*
|
|
37
37
|
* @param params - Collateral-supply encoding parameters.
|
|
38
38
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -59,7 +59,7 @@ export interface BlueSupplyCollateralParams {
|
|
|
59
59
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
60
60
|
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
61
61
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
62
|
-
* @throws {
|
|
62
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
63
63
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
64
64
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
65
65
|
* @example
|
|
@@ -5,7 +5,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
|
|
|
5
5
|
* Encodes a pure collateral supply through BlueBundlesV1.
|
|
6
6
|
*
|
|
7
7
|
* Delegates to {@link blueSupplyCollateralBorrow} with a zero borrow leg and an unrestricted LTV
|
|
8
|
-
* cap. Native funding is exclusive with ERC-20 funding
|
|
8
|
+
* cap. Native funding is exclusive with ERC-20 funding.
|
|
9
9
|
*
|
|
10
10
|
* @param params - Collateral-supply encoding parameters.
|
|
11
11
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -32,7 +32,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
|
|
|
32
32
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
33
33
|
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
34
34
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
35
|
-
* @throws {
|
|
35
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
36
36
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
37
37
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
38
38
|
* @example
|
|
@@ -40,7 +40,7 @@ export interface BlueSupplyCollateralBorrowParams {
|
|
|
40
40
|
* Encodes a direct BlueBundlesV1 collateral supply and/or borrow transaction.
|
|
41
41
|
*
|
|
42
42
|
* Reallocations are Vault V2-only and require a borrow leg. Penalties and referral fees reduce
|
|
43
|
-
* borrow proceeds. This route has no
|
|
43
|
+
* borrow proceeds. This route has no share-price bound or `slippageTolerance` input.
|
|
44
44
|
*
|
|
45
45
|
* @param params - Combined-operation encoding parameters.
|
|
46
46
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -64,8 +64,9 @@ export interface BlueSupplyCollateralBorrowParams {
|
|
|
64
64
|
* or a reallocation amount is not positive.
|
|
65
65
|
* @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
|
|
66
66
|
* @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its ABI bound.
|
|
67
|
-
* @throws {
|
|
67
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
68
68
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
69
|
+
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
69
70
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
70
71
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
71
72
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
@@ -7,7 +7,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
|
|
|
7
7
|
* Encodes a direct BlueBundlesV1 collateral supply and/or borrow transaction.
|
|
8
8
|
*
|
|
9
9
|
* Reallocations are Vault V2-only and require a borrow leg. Penalties and referral fees reduce
|
|
10
|
-
* borrow proceeds. This route has no
|
|
10
|
+
* borrow proceeds. This route has no share-price bound or `slippageTolerance` input.
|
|
11
11
|
*
|
|
12
12
|
* @param params - Combined-operation encoding parameters.
|
|
13
13
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -31,8 +31,9 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
|
|
|
31
31
|
* or a reallocation amount is not positive.
|
|
32
32
|
* @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
|
|
33
33
|
* @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its ABI bound.
|
|
34
|
-
* @throws {
|
|
34
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
35
35
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
36
|
+
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
36
37
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
37
38
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
38
39
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
@@ -35,7 +35,7 @@ export interface BlueWithdrawParams {
|
|
|
35
35
|
*
|
|
36
36
|
* Vault V2 allocator penalties and referral fees reduce the assets received. Shares mode has no
|
|
37
37
|
* saturated full-close sentinel or onchain minimum-assets guarantee, and this route has no
|
|
38
|
-
*
|
|
38
|
+
* share-price bound or `slippageTolerance` input.
|
|
39
39
|
*
|
|
40
40
|
* @param params - Withdrawal encoding parameters.
|
|
41
41
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -56,9 +56,9 @@ export interface BlueWithdrawParams {
|
|
|
56
56
|
* @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
|
|
57
57
|
* reallocation amount is provided.
|
|
58
58
|
* @throws {InputExceedsMaxError} when a withdraw amount, fee, reallocation amount, or penalty exceeds its ABI bound.
|
|
59
|
-
* @throws {
|
|
59
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
60
60
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
61
|
-
* @throws {
|
|
61
|
+
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
62
62
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
63
63
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
64
64
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
@@ -8,7 +8,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
|
|
|
8
8
|
*
|
|
9
9
|
* Vault V2 allocator penalties and referral fees reduce the assets received. Shares mode has no
|
|
10
10
|
* saturated full-close sentinel or onchain minimum-assets guarantee, and this route has no
|
|
11
|
-
*
|
|
11
|
+
* share-price bound or `slippageTolerance` input.
|
|
12
12
|
*
|
|
13
13
|
* @param params - Withdrawal encoding parameters.
|
|
14
14
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -29,9 +29,9 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
|
|
|
29
29
|
* @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
|
|
30
30
|
* reallocation amount is provided.
|
|
31
31
|
* @throws {InputExceedsMaxError} when a withdraw amount, fee, reallocation amount, or penalty exceeds its ABI bound.
|
|
32
|
-
* @throws {
|
|
32
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
33
33
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
34
|
-
* @throws {
|
|
34
|
+
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
35
35
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
36
36
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
37
37
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
@@ -32,7 +32,7 @@ export interface BlueWithdrawCollateralParams {
|
|
|
32
32
|
* Encodes a pure collateral withdrawal through BlueBundlesV1.
|
|
33
33
|
*
|
|
34
34
|
* Delegates to {@link blueRepayWithdrawCollateral} with a zero repay leg. BlueBundlesV1 enforces
|
|
35
|
-
* the supplied post-operation LTV, and no standalone Morpho
|
|
35
|
+
* the supplied post-operation LTV, and no standalone Morpho call is encoded.
|
|
36
36
|
*
|
|
37
37
|
* @param params - Collateral-withdrawal encoding parameters.
|
|
38
38
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -50,7 +50,7 @@ export interface BlueWithdrawCollateralParams {
|
|
|
50
50
|
* @throws {NegativeInputError} when collateral, LTV, or fee is negative.
|
|
51
51
|
* @throws {NonPositiveInputError} when collateral or deadline is not positive.
|
|
52
52
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
53
|
-
* @throws {
|
|
53
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
54
54
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
55
55
|
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
56
56
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
@@ -4,7 +4,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
|
|
|
4
4
|
* Encodes a pure collateral withdrawal through BlueBundlesV1.
|
|
5
5
|
*
|
|
6
6
|
* Delegates to {@link blueRepayWithdrawCollateral} with a zero repay leg. BlueBundlesV1 enforces
|
|
7
|
-
* the supplied post-operation LTV, and no standalone Morpho
|
|
7
|
+
* the supplied post-operation LTV, and no standalone Morpho call is encoded.
|
|
8
8
|
*
|
|
9
9
|
* @param params - Collateral-withdrawal encoding parameters.
|
|
10
10
|
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
@@ -22,7 +22,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
|
|
|
22
22
|
* @throws {NegativeInputError} when collateral, LTV, or fee is negative.
|
|
23
23
|
* @throws {NonPositiveInputError} when collateral or deadline is not positive.
|
|
24
24
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
25
|
-
* @throws {
|
|
25
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
26
26
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
27
27
|
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
28
28
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
@@ -96,11 +96,12 @@ export declare const resolveBundlesFunding: (params: BundlesFundingArgs) => {
|
|
|
96
96
|
* @param params.amount - Exact pull amount in the token's smallest unit; must match both signed amount fields.
|
|
97
97
|
* @param params.requirementSignature - Optional signed ERC-2612 or Permit2 SignatureTransfer requirement; omit for allowance funding.
|
|
98
98
|
* @returns An empty, ERC-2612, or Permit2 SignatureTransfer token permit.
|
|
99
|
-
* @throws {UnexpectedRequirementSignatureError} when Permit2 AllowanceTransfer is supplied.
|
|
100
99
|
* @throws {DepositOwnerMismatchError} when the signature owner differs from `userAddress`.
|
|
101
100
|
* @throws {DepositAssetMismatchError} when the signed token differs from `token`.
|
|
102
101
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `amount`.
|
|
103
102
|
* @throws {DepositSpenderMismatchError} when the signed spender differs from `spender`.
|
|
103
|
+
* @throws {UnsupportedRequirementSignatureError} when the signature's action type is neither
|
|
104
|
+
* "permit" nor "permit2SignatureTransfer".
|
|
104
105
|
* @throws {BundlesRequirementSignatureMismatchError} when signature metadata is malformed.
|
|
105
106
|
* @example
|
|
106
107
|
* ```ts
|
|
@@ -153,7 +154,10 @@ export declare const normalizeBundlesSignature: (serializedSignature: Hex, onInv
|
|
|
153
154
|
* @param params.amount - Optional exact share allowance in the vault share token's smallest unit.
|
|
154
155
|
* @param params.requirementSignature - Optional signed ERC-2612 share requirement; omit for the empty-permit sentinel.
|
|
155
156
|
* @returns The signed share permit or the contract's empty-permit sentinel.
|
|
156
|
-
* @throws {
|
|
157
|
+
* @throws {NonPositiveInputError} when a bundle or permit deadline is not positive.
|
|
158
|
+
* @throws {InputExceedsMaxError} when a bundle or permit deadline exceeds uint256.
|
|
159
|
+
* @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount or
|
|
160
|
+
* deadline, or signature is invalid.
|
|
157
161
|
* @example
|
|
158
162
|
* ```ts
|
|
159
163
|
* import { getBundlesSharesPermit } from "@morpho-org/morpho-sdk";
|
|
@@ -3,7 +3,7 @@ import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
|
3
3
|
import { compactSignatureToSignature, encodeAbiParameters, isAddressEqual, parseCompactSignature, parseSignature, size, zeroHash, } from "viem";
|
|
4
4
|
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
5
5
|
import { validateDeadline, validateReferralFee, } from "../../helpers/validate.js";
|
|
6
|
-
import { AmbiguousRequirementSignaturesError, BundlesPermitMismatchError, BundlesRequirementSignatureMismatchError, DepositAmountMismatchError, DepositAssetMismatchError, DepositOwnerMismatchError, DepositSpenderMismatchError, MixedBundlesFundingError, NegativeInputError, NonPositiveInputError, selectRequirementSignatures, UnexpectedRequirementSignatureError, } from "../../types/index.js";
|
|
6
|
+
import { AmbiguousRequirementSignaturesError, BundlesPermitMismatchError, BundlesRequirementSignatureMismatchError, DepositAmountMismatchError, DepositAssetMismatchError, DepositOwnerMismatchError, DepositSpenderMismatchError, MixedBundlesFundingError, NegativeInputError, NonPositiveInputError, selectRequirementSignatures, UnexpectedRequirementSignatureError, UnsupportedRequirementSignatureError, } from "../../types/index.js";
|
|
7
7
|
/** Numeric permit kinds consumed by `TokenLib.pullToken`. */
|
|
8
8
|
export const BundlesPermitKind = {
|
|
9
9
|
None: 0,
|
|
@@ -79,11 +79,12 @@ export const resolveBundlesFunding = (params) => {
|
|
|
79
79
|
* @param params.amount - Exact pull amount in the token's smallest unit; must match both signed amount fields.
|
|
80
80
|
* @param params.requirementSignature - Optional signed ERC-2612 or Permit2 SignatureTransfer requirement; omit for allowance funding.
|
|
81
81
|
* @returns An empty, ERC-2612, or Permit2 SignatureTransfer token permit.
|
|
82
|
-
* @throws {UnexpectedRequirementSignatureError} when Permit2 AllowanceTransfer is supplied.
|
|
83
82
|
* @throws {DepositOwnerMismatchError} when the signature owner differs from `userAddress`.
|
|
84
83
|
* @throws {DepositAssetMismatchError} when the signed token differs from `token`.
|
|
85
84
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `amount`.
|
|
86
85
|
* @throws {DepositSpenderMismatchError} when the signed spender differs from `spender`.
|
|
86
|
+
* @throws {UnsupportedRequirementSignatureError} when the signature's action type is neither
|
|
87
|
+
* "permit" nor "permit2SignatureTransfer".
|
|
87
88
|
* @throws {BundlesRequirementSignatureMismatchError} when signature metadata is malformed.
|
|
88
89
|
* @example
|
|
89
90
|
* ```ts
|
|
@@ -103,9 +104,9 @@ export const getBundlesTokenPermit = (params) => {
|
|
|
103
104
|
const { requirementSignature } = params;
|
|
104
105
|
if (requirementSignature == null)
|
|
105
106
|
return { ...EMPTY_TOKEN_PERMIT };
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
const { type } = requirementSignature.action;
|
|
108
|
+
if (type !== "permit" && type !== "permit2SignatureTransfer")
|
|
109
|
+
throw new UnsupportedRequirementSignatureError(type);
|
|
109
110
|
if (!isAddressEqual(requirementSignature.args.owner, params.userAddress)) {
|
|
110
111
|
throw new DepositOwnerMismatchError(params.userAddress, requirementSignature.args.owner);
|
|
111
112
|
}
|
|
@@ -225,7 +226,10 @@ export const normalizeBundlesSignature = (serializedSignature, onInvalid = (deta
|
|
|
225
226
|
* @param params.amount - Optional exact share allowance in the vault share token's smallest unit.
|
|
226
227
|
* @param params.requirementSignature - Optional signed ERC-2612 share requirement; omit for the empty-permit sentinel.
|
|
227
228
|
* @returns The signed share permit or the contract's empty-permit sentinel.
|
|
228
|
-
* @throws {
|
|
229
|
+
* @throws {NonPositiveInputError} when a bundle or permit deadline is not positive.
|
|
230
|
+
* @throws {InputExceedsMaxError} when a bundle or permit deadline exceeds uint256.
|
|
231
|
+
* @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount or
|
|
232
|
+
* deadline, or signature is invalid.
|
|
229
233
|
* @example
|
|
230
234
|
* ```ts
|
|
231
235
|
* import { getBundlesSharesPermit } from "@morpho-org/morpho-sdk";
|
|
@@ -240,6 +244,12 @@ export const normalizeBundlesSignature = (serializedSignature, onInvalid = (deta
|
|
|
240
244
|
*/
|
|
241
245
|
export const getBundlesSharesPermit = (params) => {
|
|
242
246
|
const { requirementSignature } = params;
|
|
247
|
+
// Require a positive uint256 for the fallback permit deadline.
|
|
248
|
+
validateDeadline(params.deadline);
|
|
249
|
+
if (requirementSignature != null) {
|
|
250
|
+
// Require a positive uint256 for the signed permit deadline too.
|
|
251
|
+
validateDeadline(requirementSignature.args.deadline);
|
|
252
|
+
}
|
|
243
253
|
if (requirementSignature == null) {
|
|
244
254
|
return {
|
|
245
255
|
value: 0n,
|
|
@@ -289,6 +299,14 @@ export const getBundlesSharesPermit = (params) => {
|
|
|
289
299
|
actual: String(requirementSignature.args.amount),
|
|
290
300
|
});
|
|
291
301
|
}
|
|
302
|
+
if ((params.owner != null || params.spender != null || params.amount != null) &&
|
|
303
|
+
requirementSignature.action.args.amount !== requirementSignature.args.amount) {
|
|
304
|
+
throw new BundlesPermitMismatchError({
|
|
305
|
+
field: "amount",
|
|
306
|
+
expected: String(requirementSignature.args.amount),
|
|
307
|
+
actual: String(requirementSignature.action.args.amount),
|
|
308
|
+
});
|
|
309
|
+
}
|
|
292
310
|
if ((params.owner != null || params.spender != null || params.amount != null) &&
|
|
293
311
|
requirementSignature.action.args.deadline !==
|
|
294
312
|
requirementSignature.args.deadline) {
|
|
@@ -6,6 +6,5 @@ export * from "./blue/index.js";
|
|
|
6
6
|
export * from "./bundles/index.js";
|
|
7
7
|
export * from "./midnight/index.js";
|
|
8
8
|
export * from "./requirements/index.js";
|
|
9
|
-
export * from "./signatures/index.js";
|
|
10
9
|
export * from "./vaultV1/index.js";
|
|
11
10
|
export * from "./vaultV2/index.js";
|
package/lib/esm/actions/index.js
CHANGED
|
@@ -10,15 +10,13 @@ import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, t
|
|
|
10
10
|
* - When `supportSignature` is falsy (default), returns the
|
|
11
11
|
* `setAuthorization(authorized, true)` transaction the user submits before the operation.
|
|
12
12
|
* - When `supportSignature` is `true`, reads the user's Morpho `nonce` and returns a signable
|
|
13
|
-
* `Requirement
|
|
14
|
-
* `setAuthorizationWithSig`, while BlueBundlesV1 embeds its signed-authorization struct.
|
|
13
|
+
* `Requirement` consumed by BlueBundlesV1.
|
|
15
14
|
*
|
|
16
15
|
* @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
17
|
-
* @param params.chainId - Target chain id used to resolve Morpho and
|
|
16
|
+
* @param params.chainId - Target chain id used to resolve Morpho and BlueBundlesV1.
|
|
18
17
|
* @param params.userAddress - The user granting authorization.
|
|
19
|
-
* @param params.authorized - Operator to authorize. Defaults to
|
|
20
|
-
*
|
|
21
|
-
* GeneralAdapter1 or BlueBundlesV1 operator.
|
|
18
|
+
* @param params.authorized - Operator to authorize. Defaults to the chain's registered
|
|
19
|
+
* BlueBundlesV1 deployment and must match it.
|
|
22
20
|
* @param params.deadline - Optional signature deadline forwarded to the authorization encoder.
|
|
23
21
|
* @param params.supportSignature - When `true`, return a signable `Requirement` instead of a
|
|
24
22
|
* transaction so the destination route can consume the signed authorization.
|
|
@@ -26,8 +24,8 @@ import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, t
|
|
|
26
24
|
* `Requirement` (when `supportSignature` is `true`), or `null` when authorization is already in
|
|
27
25
|
* place.
|
|
28
26
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
|
|
29
|
-
* @throws {UnsupportedAuthorizationOperatorError} when `authorized` is
|
|
30
|
-
*
|
|
27
|
+
* @throws {UnsupportedAuthorizationOperatorError} when `authorized` is not the chain's
|
|
28
|
+
* BlueBundlesV1 operator.
|
|
31
29
|
* @throws {NonPositiveInputError} when a provided `deadline` is not positive.
|
|
32
30
|
* @throws {InputExceedsMaxError} when a provided `deadline` exceeds `uint256`.
|
|
33
31
|
* @throws {ExpiredDeadlineError} when a provided `deadline` is positive but not in the future.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getChainAddresses } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { blueAbi } from "@morpho-org/blue-sdk-viem";
|
|
3
|
-
import { deepFreeze, Time } from "@morpho-org/morpho-ts";
|
|
3
|
+
import { deepFreeze, getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
4
4
|
import { encodeFunctionData, isAddressEqual, publicActions, } from "viem";
|
|
5
5
|
import { validateDeadline } from "../../../helpers/validate.js";
|
|
6
6
|
import { ChainIdMismatchError, ExpiredDeadlineError, UnsupportedAuthorizationOperatorError, } from "../../../types/index.js";
|
|
@@ -14,15 +14,13 @@ import { encodeBlueSignatureAuthorization } from "../encode/encodeBlueSignatureA
|
|
|
14
14
|
* - When `supportSignature` is falsy (default), returns the
|
|
15
15
|
* `setAuthorization(authorized, true)` transaction the user submits before the operation.
|
|
16
16
|
* - When `supportSignature` is `true`, reads the user's Morpho `nonce` and returns a signable
|
|
17
|
-
* `Requirement
|
|
18
|
-
* `setAuthorizationWithSig`, while BlueBundlesV1 embeds its signed-authorization struct.
|
|
17
|
+
* `Requirement` consumed by BlueBundlesV1.
|
|
19
18
|
*
|
|
20
19
|
* @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
21
|
-
* @param params.chainId - Target chain id used to resolve Morpho and
|
|
20
|
+
* @param params.chainId - Target chain id used to resolve Morpho and BlueBundlesV1.
|
|
22
21
|
* @param params.userAddress - The user granting authorization.
|
|
23
|
-
* @param params.authorized - Operator to authorize. Defaults to
|
|
24
|
-
*
|
|
25
|
-
* GeneralAdapter1 or BlueBundlesV1 operator.
|
|
22
|
+
* @param params.authorized - Operator to authorize. Defaults to the chain's registered
|
|
23
|
+
* BlueBundlesV1 deployment and must match it.
|
|
26
24
|
* @param params.deadline - Optional signature deadline forwarded to the authorization encoder.
|
|
27
25
|
* @param params.supportSignature - When `true`, return a signable `Requirement` instead of a
|
|
28
26
|
* transaction so the destination route can consume the signed authorization.
|
|
@@ -30,8 +28,8 @@ import { encodeBlueSignatureAuthorization } from "../encode/encodeBlueSignatureA
|
|
|
30
28
|
* `Requirement` (when `supportSignature` is `true`), or `null` when authorization is already in
|
|
31
29
|
* place.
|
|
32
30
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
|
|
33
|
-
* @throws {UnsupportedAuthorizationOperatorError} when `authorized` is
|
|
34
|
-
*
|
|
31
|
+
* @throws {UnsupportedAuthorizationOperatorError} when `authorized` is not the chain's
|
|
32
|
+
* BlueBundlesV1 operator.
|
|
35
33
|
* @throws {NonPositiveInputError} when a provided `deadline` is not positive.
|
|
36
34
|
* @throws {InputExceedsMaxError} when a provided `deadline` exceeds `uint256`.
|
|
37
35
|
* @throws {ExpiredDeadlineError} when a provided `deadline` is positive but not in the future.
|
|
@@ -63,16 +61,13 @@ export const getBlueAuthorizationRequirement = async (params) => {
|
|
|
63
61
|
if (viemClient.chain?.id !== chainId) {
|
|
64
62
|
throw new ChainIdMismatchError(viemClient.chain?.id, chainId);
|
|
65
63
|
}
|
|
66
|
-
const {
|
|
67
|
-
const
|
|
68
|
-
|
|
64
|
+
const { blue: morpho } = getChainAddresses(chainId);
|
|
65
|
+
const blueBundlesV1 = getChainAddress(chainId, "bundles.blueBundlesV1");
|
|
66
|
+
const authorized = params.authorized ?? blueBundlesV1;
|
|
67
|
+
// The SDK only ever authorizes the chain's registered BlueBundlesV1 operator;
|
|
69
68
|
// reject any other override so a misconfigured `authorized` cannot grant an arbitrary address
|
|
70
69
|
// control over the user's Morpho positions.
|
|
71
|
-
|
|
72
|
-
if (bundles?.blueBundlesV1 != null) {
|
|
73
|
-
supportedOperators.push(bundles.blueBundlesV1);
|
|
74
|
-
}
|
|
75
|
-
if (!supportedOperators.some((operator) => isAddressEqual(operator, authorized))) {
|
|
70
|
+
if (!isAddressEqual(blueBundlesV1, authorized)) {
|
|
76
71
|
throw new UnsupportedAuthorizationOperatorError(authorized, chainId);
|
|
77
72
|
}
|
|
78
73
|
const pc = viemClient.extend(publicActions);
|
|
@@ -5,7 +5,7 @@ import { type AuthorizationRequirementSignature, type Requirement } from "../../
|
|
|
5
5
|
interface EncodeBlueSignatureAuthorizationParams {
|
|
6
6
|
/** Account granting the authorization and signing it (the Morpho `authorizer`). */
|
|
7
7
|
owner: Address;
|
|
8
|
-
/**
|
|
8
|
+
/** BlueBundlesV1 operator to authorize on Morpho. */
|
|
9
9
|
authorized: Address;
|
|
10
10
|
/** Target chain id; must match `viemClient.chain.id`. */
|
|
11
11
|
chainId: number;
|
|
@@ -17,9 +17,8 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
17
17
|
deadline?: bigint;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Builds a Morpho authorization `Requirement` that, once signed, lets
|
|
21
|
-
* Morpho on the signer's behalf.
|
|
22
|
-
* BlueBundlesV1 embeds the same signed authorization in its direct-call struct.
|
|
20
|
+
* Builds a Morpho authorization `Requirement` that, once signed, lets BlueBundlesV1 operate on
|
|
21
|
+
* Morpho on the signer's behalf.
|
|
23
22
|
*
|
|
24
23
|
* The returned `Requirement.sign()` produces the EIP-712 signature over Morpho's `Authorization`
|
|
25
24
|
* typed data, verifies it against the connected account, and returns a deep-frozen
|
|
@@ -30,7 +29,7 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
30
29
|
* @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
31
30
|
* @param params - Authorization encoding parameters.
|
|
32
31
|
* @param params.owner - Account granting the authorization and signing it (the Morpho `authorizer`).
|
|
33
|
-
* @param params.authorized -
|
|
32
|
+
* @param params.authorized - BlueBundlesV1 operator to authorize.
|
|
34
33
|
* @param params.chainId - Target chain id.
|
|
35
34
|
* @param params.nonce - The owner's current Morpho authorization nonce.
|
|
36
35
|
* @param params.isAuthorized - Grant (`true`, default) or revoke (`false`).
|
|
@@ -54,7 +53,7 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
54
53
|
* const client = createWalletClient({ chain: mainnet, transport: http() });
|
|
55
54
|
* const requirement = await encodeBlueSignatureAuthorization(client, {
|
|
56
55
|
* owner,
|
|
57
|
-
* authorized:
|
|
56
|
+
* authorized: blueBundlesV1,
|
|
58
57
|
* chainId: 1,
|
|
59
58
|
* nonce: 0n,
|
|
60
59
|
* });
|