@morpho-org/morpho-sdk 6.0.0-next.0 → 6.0.0-next.2
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 +329 -15
- package/README.md +93 -47
- package/lib/cjs/abis.d.ts +227 -2
- package/lib/cjs/abis.js +156 -3
- 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 +28 -162
- 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 +3 -8
- 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 +230 -0
- package/lib/cjs/actions/bundles/common.js +507 -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/getBlueAuthorizationRequirement.d.ts +3 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +6 -10
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -2
- package/lib/cjs/actions/requirements/blue/index.js +0 -2
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -21
- 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 +19 -10
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +43 -31
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
- package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +27 -22
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
- 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/generalAdapter/getGeneralAdapterRequirements.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
- 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 +28 -30
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +20 -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/inKindRedeem.d.ts +1 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +3 -2
- 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/forceWithdraw.d.ts +58 -39
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +3 -2
- 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/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
- package/lib/cjs/blue/abis.d.ts +5 -1
- package/lib/cjs/blue/abis.js +2 -0
- package/lib/cjs/blue/entities.d.ts +8 -2
- package/lib/cjs/blue/entities.js +1 -0
- package/lib/cjs/blue/errors.d.ts +1 -1
- package/lib/cjs/blue/errors.js +2 -1
- package/lib/cjs/blue/fetch.d.ts +3 -1
- package/lib/cjs/blue/fetch.js +1 -0
- package/lib/cjs/entities/blue/blue.d.ts +29 -20
- package/lib/cjs/entities/blue/blue.js +6 -1
- package/lib/cjs/entities/index.d.ts +9 -2
- package/lib/cjs/entities/index.js +16 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/entities/midnight/midnight.js +20 -24
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +76 -75
- package/lib/{esm/actions/requirements/blue → cjs/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
- 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 +2 -0
- package/lib/cjs/entities/requirements/index.js +18 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +356 -101
- package/lib/cjs/entities/vaultV1/vaultV1.js +334 -120
- package/lib/cjs/entities/vaultV1ReallocationData.d.ts +6 -0
- package/lib/cjs/entities/vaultV1ReallocationData.js +20 -5
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +359 -100
- package/lib/cjs/entities/vaultV2/vaultV2.js +448 -93
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +46 -13
- package/lib/cjs/errors.d.ts +1 -1
- package/lib/cjs/errors.js +3 -2
- package/lib/cjs/fetch.d.ts +3 -1
- package/lib/cjs/fetch.js +1 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +2 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +2 -0
- package/lib/cjs/helpers/index.d.ts +4 -1
- package/lib/cjs/helpers/index.js +14 -1
- package/lib/cjs/helpers/metadata.d.ts +3 -5
- package/lib/cjs/helpers/metadata.js +4 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/cjs/helpers/referralFee.d.ts +21 -0
- package/lib/cjs/helpers/referralFee.js +35 -0
- package/lib/cjs/helpers/slippage.d.ts +136 -1
- package/lib/cjs/helpers/slippage.js +188 -0
- package/lib/cjs/helpers/validate.d.ts +67 -8
- package/lib/cjs/helpers/validate.js +94 -9
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +273 -82
- package/lib/cjs/types/action.js +12 -12
- package/lib/cjs/types/error.d.ts +349 -23
- package/lib/cjs/types/error.js +393 -39
- package/lib/cjs/types/sharedLiquidity.d.ts +2 -2
- package/lib/cjs/utils.d.ts +3 -1
- package/lib/cjs/utils.js +10 -1
- package/lib/esm/abis.d.ts +227 -2
- package/lib/esm/abis.js +157 -2
- 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 +30 -164
- 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 +5 -10
- 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 +230 -0
- package/lib/esm/actions/bundles/common.js +494 -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/getBlueAuthorizationRequirement.d.ts +3 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +8 -12
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -2
- package/lib/esm/actions/requirements/blue/index.js +0 -2
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +22 -22
- 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 +19 -10
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +44 -32
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
- package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +25 -20
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
- 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/generalAdapter/getGeneralAdapterRequirements.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
- 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 +28 -30
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +21 -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/inKindRedeem.d.ts +1 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.js +3 -2
- 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/forceWithdraw.d.ts +58 -39
- package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.js +3 -2
- 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/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +3 -1
- package/lib/esm/blue/abis.d.ts +5 -1
- package/lib/esm/blue/abis.js +5 -1
- package/lib/esm/blue/entities.d.ts +8 -2
- package/lib/esm/blue/entities.js +3 -1
- package/lib/esm/blue/errors.d.ts +1 -1
- package/lib/esm/blue/errors.js +1 -1
- package/lib/esm/blue/fetch.d.ts +3 -1
- package/lib/esm/blue/fetch.js +3 -1
- package/lib/esm/entities/blue/blue.d.ts +29 -20
- package/lib/esm/entities/blue/blue.js +7 -2
- package/lib/esm/entities/index.d.ts +9 -2
- package/lib/esm/entities/index.js +4 -1
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/entities/midnight/midnight.js +20 -24
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +67 -66
- package/lib/{cjs/actions/requirements/blue → esm/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
- 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 +2 -0
- package/lib/esm/entities/requirements/index.js +2 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +356 -101
- package/lib/esm/entities/vaultV1/vaultV1.js +338 -124
- package/lib/esm/entities/vaultV1ReallocationData.d.ts +6 -0
- package/lib/esm/entities/vaultV1ReallocationData.js +20 -5
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +359 -100
- package/lib/esm/entities/vaultV2/vaultV2.js +452 -97
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.js +46 -13
- package/lib/esm/errors.d.ts +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/fetch.d.ts +3 -1
- package/lib/esm/fetch.js +3 -1
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +2 -0
- package/lib/esm/helpers/computeVaultV1Reallocations.js +2 -0
- package/lib/esm/helpers/index.d.ts +4 -1
- package/lib/esm/helpers/index.js +4 -1
- package/lib/esm/helpers/metadata.d.ts +3 -5
- package/lib/esm/helpers/metadata.js +4 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/esm/helpers/referralFee.d.ts +21 -0
- package/lib/esm/helpers/referralFee.js +31 -0
- package/lib/esm/helpers/slippage.d.ts +136 -1
- package/lib/esm/helpers/slippage.js +186 -2
- package/lib/esm/helpers/validate.d.ts +67 -8
- package/lib/esm/helpers/validate.js +92 -10
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +273 -82
- package/lib/esm/types/action.js +11 -11
- package/lib/esm/types/error.d.ts +349 -23
- package/lib/esm/types/error.js +377 -31
- package/lib/esm/types/sharedLiquidity.d.ts +2 -2
- package/lib/esm/utils.d.ts +3 -1
- package/lib/esm/utils.js +3 -1
- package/package.json +7 -7
package/lib/esm/types/error.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UnknownDataError } from "@morpho-org/blue-sdk";
|
|
1
|
+
import { MathLib, UnknownDataError } from "@morpho-org/blue-sdk";
|
|
2
2
|
/**
|
|
3
3
|
* Thrown when a morpho-sdk input that must be non-negative is negative.
|
|
4
4
|
*
|
|
@@ -97,8 +97,23 @@ export class ExpiredDeadlineError extends Error {
|
|
|
97
97
|
this.name = "ExpiredDeadlineError";
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
/**
|
|
101
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Thrown when a VaultExitBundlesV1 Vault V2 exit targets a vault without exactly one adapter.
|
|
102
|
+
*
|
|
103
|
+
* Both `vaultExitBundlesV1InKindRedemptionVaultV2` and
|
|
104
|
+
* `vaultExitBundlesV1ForceWithdrawVaultV2` require `adaptersLength() == 1`.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { VaultV2SingleAdapterRequiredError } from "@morpho-org/morpho-sdk";
|
|
109
|
+
*
|
|
110
|
+
* const error = new VaultV2SingleAdapterRequiredError(vault, 2);
|
|
111
|
+
* if (error instanceof VaultV2SingleAdapterRequiredError) {
|
|
112
|
+
* console.error(error.vault, error.adapters);
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export class VaultV2SingleAdapterRequiredError extends Error {
|
|
102
117
|
vault;
|
|
103
118
|
adapters;
|
|
104
119
|
/**
|
|
@@ -106,12 +121,14 @@ export class InKindRedeemRequiresSingleAdapterError extends Error {
|
|
|
106
121
|
* @param adapters - Number of adapters in the supplied vault snapshot.
|
|
107
122
|
*/
|
|
108
123
|
constructor(vault, adapters) {
|
|
109
|
-
super(`Vault "${vault}" has "${adapters}" adapters.
|
|
124
|
+
super(`Vault "${vault}" has "${adapters}" adapters. VaultExitBundlesV1 exits require exactly one MorphoMarketV1AdapterV2.`);
|
|
110
125
|
this.vault = vault;
|
|
111
126
|
this.adapters = adapters;
|
|
112
|
-
this.name = "
|
|
127
|
+
this.name = "VaultV2SingleAdapterRequiredError";
|
|
113
128
|
}
|
|
114
129
|
}
|
|
130
|
+
/** @deprecated Use {@link VaultV2SingleAdapterRequiredError}. */
|
|
131
|
+
export const InKindRedeemRequiresSingleAdapterError = VaultV2SingleAdapterRequiredError;
|
|
115
132
|
/** Thrown when a requested in-kind redemption adapter is not part of the Vault V2 snapshot. */
|
|
116
133
|
export class AdapterNotPartOfVaultError extends Error {
|
|
117
134
|
vault;
|
|
@@ -127,16 +144,290 @@ export class AdapterNotPartOfVaultError extends Error {
|
|
|
127
144
|
this.name = "AdapterNotPartOfVaultError";
|
|
128
145
|
}
|
|
129
146
|
}
|
|
130
|
-
/**
|
|
131
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Thrown when the Vault V2 adapter cannot expose MorphoMarketV1AdapterV2 market shares.
|
|
149
|
+
*
|
|
150
|
+
* VaultExitBundlesV1 casts the adapter to `IMorphoMarketV1AdapterV2`, so a legacy
|
|
151
|
+
* positions-based `MorphoMarketV1Adapter` or a `MorphoVaultV1Adapter` cannot be exited.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* import { VaultV2UnsupportedExitAdapterError } from "@morpho-org/morpho-sdk";
|
|
156
|
+
*
|
|
157
|
+
* const error = new VaultV2UnsupportedExitAdapterError(adapter);
|
|
158
|
+
* if (error instanceof VaultV2UnsupportedExitAdapterError) {
|
|
159
|
+
* console.error(error.adapter);
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export class VaultV2UnsupportedExitAdapterError extends Error {
|
|
132
164
|
adapter;
|
|
133
165
|
/**
|
|
134
166
|
* @param adapter - Unsupported Vault V2 adapter address.
|
|
135
167
|
*/
|
|
136
168
|
constructor(adapter) {
|
|
137
|
-
super(`Adapter "${adapter}" does not support Vault V2
|
|
169
|
+
super(`Adapter "${adapter}" does not support Vault V2 exits through VaultExitBundlesV1. Use a MorphoMarketV1AdapterV2-backed vault.`);
|
|
138
170
|
this.adapter = adapter;
|
|
139
|
-
this.name = "
|
|
171
|
+
this.name = "VaultV2UnsupportedExitAdapterError";
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** @deprecated Use {@link VaultV2UnsupportedExitAdapterError}. */
|
|
175
|
+
export const UnsupportedInKindAdapterError = VaultV2UnsupportedExitAdapterError;
|
|
176
|
+
/**
|
|
177
|
+
* Thrown when a Vault V2 exit cannot resolve the vault's configured liquidity adapter.
|
|
178
|
+
*
|
|
179
|
+
* `VaultExitBundlesV1.vaultExitBundlesV1ForceWithdrawVaultV2` casts `liquidityAdapter` to
|
|
180
|
+
* `IMorphoMarketV1AdapterV2` and ABI-decodes `liquidityData` as `MarketParams`. Because the exit
|
|
181
|
+
* also requires `adaptersLength() == 1`, the only resolvable configurations are an unset
|
|
182
|
+
* liquidity adapter or the vault's sole adapter.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { VaultV2UnsupportedLiquidityAdapterError } from "@morpho-org/morpho-sdk";
|
|
187
|
+
*
|
|
188
|
+
* const error = new VaultV2UnsupportedLiquidityAdapterError({
|
|
189
|
+
* vault,
|
|
190
|
+
* liquidityAdapter,
|
|
191
|
+
* adapter,
|
|
192
|
+
* });
|
|
193
|
+
* if (error instanceof VaultV2UnsupportedLiquidityAdapterError) {
|
|
194
|
+
* console.error(error.liquidityAdapter, error.adapter);
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export class VaultV2UnsupportedLiquidityAdapterError extends Error {
|
|
199
|
+
/** Vault V2 address. */
|
|
200
|
+
vault;
|
|
201
|
+
/** Liquidity adapter configured on the vault. */
|
|
202
|
+
liquidityAdapter;
|
|
203
|
+
/** Sole adapter the exit targets. */
|
|
204
|
+
adapter;
|
|
205
|
+
/**
|
|
206
|
+
* @param params - Liquidity-adapter mismatch details.
|
|
207
|
+
* @param params.vault - Vault V2 address.
|
|
208
|
+
* @param params.liquidityAdapter - Liquidity adapter configured on the vault.
|
|
209
|
+
* @param params.adapter - Sole adapter the exit targets.
|
|
210
|
+
*/
|
|
211
|
+
constructor(params) {
|
|
212
|
+
super(`Vault "${params.vault}" routes liquidity through "${params.liquidityAdapter}", which is neither unset nor its sole adapter "${params.adapter}". Use another exit path until the vault routes liquidity through its sole MorphoMarketV1AdapterV2.`);
|
|
213
|
+
this.vault = params.vault;
|
|
214
|
+
this.liquidityAdapter = params.liquidityAdapter;
|
|
215
|
+
this.adapter = params.adapter;
|
|
216
|
+
this.name = "VaultV2UnsupportedLiquidityAdapterError";
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Thrown when a Vault V2 exit cannot ABI-decode the vault's `liquidityData` as `MarketParams`.
|
|
221
|
+
*
|
|
222
|
+
* Distinct from {@link VaultV2UnsupportedLiquidityAdapterError}: the liquidity adapter *is* the
|
|
223
|
+
* vault's sole adapter, but the market params stored alongside it are unusable, so the contract's
|
|
224
|
+
* `abi.decode` would revert. Only the vault curator can repair this by re-setting the liquidity
|
|
225
|
+
* adapter and data.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* import { VaultV2UndecodableLiquidityDataError } from "@morpho-org/morpho-sdk";
|
|
230
|
+
*
|
|
231
|
+
* try {
|
|
232
|
+
* vault.forceWithdraw({ exitAssets: 1_000_000n, vaultData, userAddress });
|
|
233
|
+
* } catch (error) {
|
|
234
|
+
* if (error instanceof VaultV2UndecodableLiquidityDataError) {
|
|
235
|
+
* console.error(error.liquidityData, error.cause);
|
|
236
|
+
* }
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
export class VaultV2UndecodableLiquidityDataError extends Error {
|
|
241
|
+
/** Vault V2 address. */
|
|
242
|
+
vault;
|
|
243
|
+
/** Liquidity adapter configured on the vault. */
|
|
244
|
+
liquidityAdapter;
|
|
245
|
+
/** Raw `liquidityData` that failed to decode. */
|
|
246
|
+
liquidityData;
|
|
247
|
+
/**
|
|
248
|
+
* @param params - Undecodable liquidity-data details.
|
|
249
|
+
* @param params.vault - Vault V2 address.
|
|
250
|
+
* @param params.liquidityAdapter - Liquidity adapter configured on the vault.
|
|
251
|
+
* @param params.liquidityData - Raw `liquidityData` that failed to decode.
|
|
252
|
+
* @param params.cause - Underlying decode failure.
|
|
253
|
+
*/
|
|
254
|
+
constructor(params) {
|
|
255
|
+
super(`Vault "${params.vault}" stores liquidity data "${params.liquidityData}" for adapter "${params.liquidityAdapter}" that does not decode as MarketParams. Use another exit path until the vault curator re-sets its liquidity adapter and data.`, { cause: params.cause });
|
|
256
|
+
this.vault = params.vault;
|
|
257
|
+
this.liquidityAdapter = params.liquidityAdapter;
|
|
258
|
+
this.liquidityData = params.liquidityData;
|
|
259
|
+
this.name = "VaultV2UndecodableLiquidityDataError";
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Thrown when the adapter's markets cannot cover a Vault V2 force withdrawal.
|
|
264
|
+
*
|
|
265
|
+
* `vaultExitBundlesV1ForceWithdrawVaultV2` loops over the adapter's market list without a bound,
|
|
266
|
+
* so an under-covered request reverts on-chain with a raw `panic 0x32`. This error surfaces that
|
|
267
|
+
* failure before submission.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* import { VaultV2ForceWithdrawCoverageError } from "@morpho-org/morpho-sdk";
|
|
272
|
+
*
|
|
273
|
+
* const error = new VaultV2ForceWithdrawCoverageError({
|
|
274
|
+
* required: 100n,
|
|
275
|
+
* covered: 40n,
|
|
276
|
+
* maxExitAssets: 60n,
|
|
277
|
+
* });
|
|
278
|
+
* if (error instanceof VaultV2ForceWithdrawCoverageError) {
|
|
279
|
+
* console.error(error.maxExitAssets);
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
export class VaultV2ForceWithdrawCoverageError extends Error {
|
|
284
|
+
/** Assets that must be force-deallocated from the adapter's markets. */
|
|
285
|
+
required;
|
|
286
|
+
/** Assets the adapter's markets can actually release. */
|
|
287
|
+
covered;
|
|
288
|
+
/** Largest penalty-inclusive `exitAssets` the current vault state supports. */
|
|
289
|
+
maxExitAssets;
|
|
290
|
+
/**
|
|
291
|
+
* @param params - Coverage values used to explain the rejected exit.
|
|
292
|
+
* @param params.required - Assets that must be force-deallocated.
|
|
293
|
+
* @param params.covered - Assets the adapter's markets can release.
|
|
294
|
+
* @param params.maxExitAssets - Largest supported penalty-inclusive `exitAssets`.
|
|
295
|
+
*/
|
|
296
|
+
constructor(params) {
|
|
297
|
+
super(`Force withdrawal requires "${params.required}" force-deallocated assets but the adapter's markets only release "${params.covered}". Reduce exitAssets to at most "${params.maxExitAssets}" or wait for market liquidity.`);
|
|
298
|
+
this.required = params.required;
|
|
299
|
+
this.covered = params.covered;
|
|
300
|
+
this.maxExitAssets = params.maxExitAssets;
|
|
301
|
+
this.name = "VaultV2ForceWithdrawCoverageError";
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Thrown when a Vault V2 force withdrawal would withdraw nothing while still consuming its permit.
|
|
306
|
+
*
|
|
307
|
+
* Happens on a dust `exitAssets` when the vault has no penalty-free liquidity and the
|
|
308
|
+
* penalty-adjusted remainder rounds down to zero.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```ts
|
|
312
|
+
* import { VaultV2ForceWithdrawZeroWithdrawalError } from "@morpho-org/morpho-sdk";
|
|
313
|
+
*
|
|
314
|
+
* const error = new VaultV2ForceWithdrawZeroWithdrawalError({
|
|
315
|
+
* vault,
|
|
316
|
+
* exitAssets: 1n,
|
|
317
|
+
* penalty: 20_000000000000000n,
|
|
318
|
+
* });
|
|
319
|
+
* if (error instanceof VaultV2ForceWithdrawZeroWithdrawalError) {
|
|
320
|
+
* console.error(error.exitAssets, error.penalty);
|
|
321
|
+
* }
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
export class VaultV2ForceWithdrawZeroWithdrawalError extends Error {
|
|
325
|
+
/** Vault V2 address. */
|
|
326
|
+
vault;
|
|
327
|
+
/** Positive penalty-inclusive amount requested by the caller. */
|
|
328
|
+
exitAssets;
|
|
329
|
+
/** WAD-scaled force-deallocation penalty applied by the adapter. */
|
|
330
|
+
penalty;
|
|
331
|
+
/**
|
|
332
|
+
* @param params - Values that caused the exit to withdraw nothing.
|
|
333
|
+
* @param params.vault - Vault V2 address.
|
|
334
|
+
* @param params.exitAssets - Positive penalty-inclusive amount requested by the caller.
|
|
335
|
+
* @param params.penalty - WAD-scaled force-deallocation penalty applied by the adapter.
|
|
336
|
+
*/
|
|
337
|
+
constructor(params) {
|
|
338
|
+
super(`Vault "${params.vault}" has no penalty-free liquidity, and force-withdraw exitAssets "${params.exitAssets}" rounds to zero withdrawn assets after applying penalty "${params.penalty}". Increase exitAssets or use another exit path.`);
|
|
339
|
+
this.vault = params.vault;
|
|
340
|
+
this.exitAssets = params.exitAssets;
|
|
341
|
+
this.penalty = params.penalty;
|
|
342
|
+
this.name = "VaultV2ForceWithdrawZeroWithdrawalError";
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Thrown when a Vault V2 force withdrawal's derived share-price floor rounds down to zero.
|
|
347
|
+
*
|
|
348
|
+
* VaultExitBundlesV1 reads `minSharePriceE27 == 0` as "no bound at all", so emitting a rounded-down
|
|
349
|
+
* zero would silently ship an exit with none of the slippage protection this path exists to add.
|
|
350
|
+
* Reaching it means the exit burns more shares than `withdrawnAssets` can price at RAY scale — a
|
|
351
|
+
* vault whose share price has collapsed below `1e-27` assets per share, or a dust exit against one.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* import { VaultV2ForceWithdrawZeroSharePriceError } from "@morpho-org/morpho-sdk";
|
|
356
|
+
*
|
|
357
|
+
* try {
|
|
358
|
+
* vault.forceWithdraw({ exitAssets, vaultData, userAddress });
|
|
359
|
+
* } catch (error) {
|
|
360
|
+
* if (error instanceof VaultV2ForceWithdrawZeroSharePriceError) {
|
|
361
|
+
* console.error(error.withdrawnAssets, error.sharesBurnt);
|
|
362
|
+
* }
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
export class VaultV2ForceWithdrawZeroSharePriceError extends Error {
|
|
367
|
+
/** Assets the exit withdraws in total, before the referral fee. */
|
|
368
|
+
withdrawnAssets;
|
|
369
|
+
/** Upper bound of the vault shares the exit burns. */
|
|
370
|
+
sharesBurnt;
|
|
371
|
+
/** WAD-scaled slippage tolerance applied to the floor. */
|
|
372
|
+
slippageTolerance;
|
|
373
|
+
/**
|
|
374
|
+
* @param params - Values whose ratio rounded down to a zero share-price floor.
|
|
375
|
+
* @param params.withdrawnAssets - Assets the exit withdraws in total, before the referral fee.
|
|
376
|
+
* @param params.sharesBurnt - Upper bound of the vault shares the exit burns.
|
|
377
|
+
* @param params.slippageTolerance - WAD-scaled slippage tolerance applied to the floor.
|
|
378
|
+
*/
|
|
379
|
+
constructor(params) {
|
|
380
|
+
super(`Force-withdraw share-price floor rounds to zero: withdrawnAssets "${params.withdrawnAssets}" over sharesBurnt "${params.sharesBurnt}" at slippageTolerance "${params.slippageTolerance}". The contract reads a zero floor as no bound at all, so this exit cannot be built safely — increase exitAssets or use another exit path.`);
|
|
381
|
+
this.withdrawnAssets = params.withdrawnAssets;
|
|
382
|
+
this.sharesBurnt = params.sharesBurnt;
|
|
383
|
+
this.slippageTolerance = params.slippageTolerance;
|
|
384
|
+
this.name = "VaultV2ForceWithdrawZeroSharePriceError";
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Thrown when fee shares projected to the accepted deadline reach the lower force-withdraw
|
|
389
|
+
* burn bound at that time.
|
|
390
|
+
*
|
|
391
|
+
* VaultExitBundlesV1 measures shares burned after its first withdrawal accrues fees. If the
|
|
392
|
+
* recipient's fee shares are at least the measured burn bound, its share-price check is skipped or
|
|
393
|
+
* reverts due to an underflow.
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* import { VaultV2ForceWithdrawFeeSharesExceedBurnError } from "@morpho-org/morpho-sdk";
|
|
398
|
+
*
|
|
399
|
+
* try {
|
|
400
|
+
* vault.forceWithdraw({ exitAssets, vaultData, userAddress });
|
|
401
|
+
* } catch (error) {
|
|
402
|
+
* if (error instanceof VaultV2ForceWithdrawFeeSharesExceedBurnError) {
|
|
403
|
+
* console.error(error.sharesBurnt, error.feeShares);
|
|
404
|
+
* }
|
|
405
|
+
* }
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
export class VaultV2ForceWithdrawFeeSharesExceedBurnError extends Error {
|
|
409
|
+
/** Vault V2 address being exited. */
|
|
410
|
+
vault;
|
|
411
|
+
/** Fee-recipient account submitting the exit. */
|
|
412
|
+
userAddress;
|
|
413
|
+
/** Lower bound of shares measured as burned by VaultExitBundlesV1. */
|
|
414
|
+
sharesBurnt;
|
|
415
|
+
/** Fee shares projected for `userAddress` at the accepted deadline. */
|
|
416
|
+
feeShares;
|
|
417
|
+
/**
|
|
418
|
+
* @param params - Fee-share and burn-bound values that make the exit unsafe.
|
|
419
|
+
* @param params.vault - Vault V2 address being exited.
|
|
420
|
+
* @param params.userAddress - Fee-recipient account submitting the exit.
|
|
421
|
+
* @param params.sharesBurnt - Lower bound of shares measured as burned by VaultExitBundlesV1.
|
|
422
|
+
* @param params.feeShares - Fee shares projected for `userAddress` at the accepted deadline.
|
|
423
|
+
*/
|
|
424
|
+
constructor(params) {
|
|
425
|
+
super(`Vault V2 "${params.vault}" fee-recipient account "${params.userAddress}" accrues "${params.feeShares}" fee shares, reaching the lower force-withdraw share-burn bound "${params.sharesBurnt}". VaultExitBundlesV1's share-price check would be skipped or revert. Increase exitAssets or let the vault accrue first.`);
|
|
426
|
+
this.vault = params.vault;
|
|
427
|
+
this.userAddress = params.userAddress;
|
|
428
|
+
this.sharesBurnt = params.sharesBurnt;
|
|
429
|
+
this.feeShares = params.feeShares;
|
|
430
|
+
this.name = "VaultV2ForceWithdrawFeeSharesExceedBurnError";
|
|
140
431
|
}
|
|
141
432
|
}
|
|
142
433
|
/** Thrown when a Vault V2 in-kind redemption rounds to no deallocated assets. */
|
|
@@ -230,8 +521,8 @@ export class VaultIsBlueFeeRecipientError extends Error {
|
|
|
230
521
|
this.name = "VaultIsBlueFeeRecipientError";
|
|
231
522
|
}
|
|
232
523
|
}
|
|
233
|
-
/** Thrown when a vault-shares requirement cannot be safely encoded as
|
|
234
|
-
export class
|
|
524
|
+
/** Thrown when a vault-shares requirement cannot be safely encoded as a bundles permit. */
|
|
525
|
+
export class BundlesPermitMismatchError extends Error {
|
|
235
526
|
/**
|
|
236
527
|
* @param params - Permit mismatch values used to explain the rejection.
|
|
237
528
|
* @param params.field - Permit field that does not match the exit.
|
|
@@ -243,18 +534,30 @@ export class VaultExitBundlesV1PermitMismatchError extends Error {
|
|
|
243
534
|
expected;
|
|
244
535
|
actual;
|
|
245
536
|
constructor(params) {
|
|
246
|
-
super(`
|
|
537
|
+
super(`Bundles permit ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Resolve and sign the requirements returned by this prepared operation.`, { cause: params.cause });
|
|
247
538
|
this.field = params.field;
|
|
248
539
|
this.expected = params.expected;
|
|
249
540
|
this.actual = params.actual;
|
|
541
|
+
this.name = "BundlesPermitMismatchError";
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Thrown by the deprecated VaultExitBundlesV1 permit compatibility helper.
|
|
546
|
+
*
|
|
547
|
+
* @deprecated Use {@link BundlesPermitMismatchError} with `getBundlesSharesPermit`.
|
|
548
|
+
*/
|
|
549
|
+
export class VaultExitBundlesV1PermitMismatchError extends BundlesPermitMismatchError {
|
|
550
|
+
constructor(params) {
|
|
551
|
+
super(params);
|
|
552
|
+
this.message = `VaultExitBundlesV1 permit ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Rebuild and sign the vault-exit permit.`;
|
|
250
553
|
this.name = "VaultExitBundlesV1PermitMismatchError";
|
|
251
554
|
}
|
|
252
555
|
}
|
|
253
|
-
/** Thrown when a signed requirement cannot be safely encoded for
|
|
254
|
-
export class
|
|
255
|
-
/** Field whose signed value or encoding is invalid for the
|
|
556
|
+
/** Thrown when a signed requirement cannot be safely encoded for a fixed bundles call. */
|
|
557
|
+
export class BundlesRequirementSignatureMismatchError extends Error {
|
|
558
|
+
/** Field whose signed value or encoding is invalid for the fixed bundles call. */
|
|
256
559
|
field;
|
|
257
|
-
/** Value required by
|
|
560
|
+
/** Value required by the fixed bundles call. */
|
|
258
561
|
expected;
|
|
259
562
|
/** Value supplied by the signed requirement. */
|
|
260
563
|
actual;
|
|
@@ -266,22 +569,17 @@ export class BlueBundlesV1RequirementSignatureMismatchError extends Error {
|
|
|
266
569
|
* @param params.cause - Original signature parser failure, when applicable.
|
|
267
570
|
*/
|
|
268
571
|
constructor(params) {
|
|
269
|
-
super(`
|
|
572
|
+
super(`Bundles requirement ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Resolve and sign the requirements returned by this prepared operation.`, { cause: params.cause });
|
|
270
573
|
this.field = params.field;
|
|
271
574
|
this.expected = params.expected;
|
|
272
575
|
this.actual = params.actual;
|
|
273
|
-
this.name = "
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
/** Thrown when Permit2 SignatureTransfer is selected without an explicit unordered nonce. */
|
|
277
|
-
export class MissingPermit2TransferFromNonceError extends Error {
|
|
278
|
-
constructor() {
|
|
279
|
-
super("Permit2 SignatureTransfer requires an explicit unused permit2Nonce. Generate a unique uint256 nonce, pass it to getRequirements(), and resolve the requirements again.");
|
|
280
|
-
this.name = "MissingPermit2TransferFromNonceError";
|
|
576
|
+
this.name = "BundlesRequirementSignatureMismatchError";
|
|
281
577
|
}
|
|
282
578
|
}
|
|
579
|
+
/** @deprecated Use {@link BundlesRequirementSignatureMismatchError}. */
|
|
580
|
+
export { BundlesRequirementSignatureMismatchError as BlueBundlesV1RequirementSignatureMismatchError, };
|
|
283
581
|
/** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
|
|
284
|
-
export class
|
|
582
|
+
export class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
|
|
285
583
|
owner;
|
|
286
584
|
nonce;
|
|
287
585
|
/**
|
|
@@ -292,7 +590,7 @@ export class Permit2TransferFromNonceAlreadyUsedError extends Error {
|
|
|
292
590
|
super(`Permit2 nonce "${nonce}" is already used for owner "${owner}". Generate a different uint256 permit2Nonce and resolve the requirements again.`);
|
|
293
591
|
this.owner = owner;
|
|
294
592
|
this.nonce = nonce;
|
|
295
|
-
this.name = "
|
|
593
|
+
this.name = "Permit2SignatureTransferNonceAlreadyUsedError";
|
|
296
594
|
}
|
|
297
595
|
}
|
|
298
596
|
/** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
|
|
@@ -310,6 +608,8 @@ export class NoUnusedPermit2NonceError extends Error {
|
|
|
310
608
|
this.name = "NoUnusedPermit2NonceError";
|
|
311
609
|
}
|
|
312
610
|
}
|
|
611
|
+
/** @deprecated Use {@link Permit2SignatureTransferNonceAlreadyUsedError}. */
|
|
612
|
+
export { Permit2SignatureTransferNonceAlreadyUsedError as Permit2TransferFromNonceAlreadyUsedError, };
|
|
313
613
|
/** Thrown when native funding does not exactly match the contract's gross token pull. */
|
|
314
614
|
export class NativeFundingAmountMismatchError extends Error {
|
|
315
615
|
nativeAmount;
|
|
@@ -326,10 +626,56 @@ export class NativeFundingAmountMismatchError extends Error {
|
|
|
326
626
|
}
|
|
327
627
|
}
|
|
328
628
|
/** Thrown when a positive referral fee has no recipient. */
|
|
329
|
-
export class
|
|
629
|
+
export class ReferralFeeRecipientMissingError extends Error {
|
|
330
630
|
constructor() {
|
|
331
631
|
super("A positive referralFeePct requires referralFeeRecipient. Provide the recipient or set referralFeePct to zero.");
|
|
332
|
-
this.name = "
|
|
632
|
+
this.name = "ReferralFeeRecipientMissingError";
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
/** @deprecated Use {@link ReferralFeeRecipientMissingError}. */
|
|
636
|
+
export const MissingReferralFeeRecipientError = ReferralFeeRecipientMissingError;
|
|
637
|
+
/**
|
|
638
|
+
* Thrown when a referral fee percentage is outside the contract's `[0, WAD)` range.
|
|
639
|
+
*
|
|
640
|
+
* Extends {@link InputExceedsMaxError} — and reports the same `field`, `value`, and `max` the
|
|
641
|
+
* generic bound error used to carry for this input — so integrators already pattern-matching
|
|
642
|
+
* `InputExceedsMaxError` keep catching this failure.
|
|
643
|
+
*/
|
|
644
|
+
export class ReferralFeePctExceededError extends InputExceedsMaxError {
|
|
645
|
+
referralFeePct;
|
|
646
|
+
/** @param referralFeePct - WAD-scaled referral fee percentage supplied by the caller. */
|
|
647
|
+
constructor(referralFeePct) {
|
|
648
|
+
super({
|
|
649
|
+
field: "referralFeePct",
|
|
650
|
+
value: referralFeePct,
|
|
651
|
+
max: MathLib.WAD - 1n,
|
|
652
|
+
});
|
|
653
|
+
this.referralFeePct = referralFeePct;
|
|
654
|
+
this.message = `Referral fee percentage "${referralFeePct}" must be below WAD. Reduce referralFeePct or disable the referral fee.`;
|
|
655
|
+
this.name = "ReferralFeePctExceededError";
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/** Thrown when a fixed bundles call mixes ERC-20 and native funding. */
|
|
659
|
+
export class MixedBundlesFundingError extends Error {
|
|
660
|
+
constructor() {
|
|
661
|
+
super("Bundles funding accepts either amount or nativeAmount, not both. Choose one funding source and rebuild the transaction.");
|
|
662
|
+
this.name = "MixedBundlesFundingError";
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
/** Thrown when a vault migration specifies both assets and shares, or neither. */
|
|
666
|
+
export class AmountAndSharesExclusiveError extends Error {
|
|
667
|
+
constructor() {
|
|
668
|
+
super("Vault migration requires exactly one of assets or shares. Choose the desired withdrawal mode and rebuild the transaction.");
|
|
669
|
+
this.name = "AmountAndSharesExclusiveError";
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
/** Thrown when a vault migration selects the same source and destination vault. */
|
|
673
|
+
export class SameVaultMigrationError extends Error {
|
|
674
|
+
vault;
|
|
675
|
+
constructor(vault) {
|
|
676
|
+
super(`Source and destination vault are both "${vault}". Select a different destination vault.`);
|
|
677
|
+
this.vault = vault;
|
|
678
|
+
this.name = "SameVaultMigrationError";
|
|
333
679
|
}
|
|
334
680
|
}
|
|
335
681
|
/** Thrown when a BlueBundlesV1 reallocation source uses another loan token. */
|
|
@@ -1194,10 +1540,10 @@ export class MidnightOfferRootOfferCountMismatchError extends Error {
|
|
|
1194
1540
|
super(`Midnight offer root offer-count mismatch: expected "${params.expectedOffers}", got "${params.actualOffers}". Rebuild the flow and sign again.`);
|
|
1195
1541
|
}
|
|
1196
1542
|
}
|
|
1197
|
-
/** Thrown when a Midnight offer-root signature
|
|
1543
|
+
/** Thrown when a Midnight offer-root signature carries no encoded payload. */
|
|
1198
1544
|
export class UnpreparedMidnightOfferRootSignatureError extends Error {
|
|
1199
1545
|
constructor() {
|
|
1200
|
-
super("Midnight offer root signature
|
|
1546
|
+
super("Midnight offer root signature carries no encoded payload. Sign the offer-root requirement (its signature already includes the payload) before building the submit transaction.");
|
|
1201
1547
|
}
|
|
1202
1548
|
}
|
|
1203
1549
|
/** Thrown when a Midnight redeem flow finds no credit units for the user. */
|
|
@@ -24,8 +24,8 @@ export interface PublicAllocatorOptions {
|
|
|
24
24
|
* The maximum utilization each source market may reach when withdrawing
|
|
25
25
|
* shared liquidity, scaled by WAD.
|
|
26
26
|
*
|
|
27
|
-
* @deprecated
|
|
28
|
-
* Use `
|
|
27
|
+
* @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
|
|
28
|
+
* Use `VaultV2BluePublicAllocatorOptions.maxWithdrawalUtilization` with the Vault V2 planner.
|
|
29
29
|
*/
|
|
30
30
|
readonly maxWithdrawalUtilization?: Readonly<Record<MarketId, bigint | undefined>>;
|
|
31
31
|
/**
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDotte
|
|
|
34
34
|
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
|
|
35
35
|
export { computeReallocations, computeVaultV1Reallocations, } from "./helpers/computeVaultV1Reallocations.js";
|
|
36
36
|
export { addTransactionMetadata } from "./helpers/metadata.js";
|
|
37
|
+
export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./helpers/previewVaultV2ForceWithdraw.js";
|
|
37
38
|
export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./helpers/previewVaultV2InKindRedeem.js";
|
|
38
|
-
export { computeMaxRepaySharePrice, computeMinBorrowSharePrice, } from "./helpers/slippage.js";
|
|
39
|
+
export { computeMaxRepaySharePrice, computeMinBorrowSharePrice, computeMinForceWithdrawSharePrice, } from "./helpers/slippage.js";
|
|
39
40
|
export { validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, } from "./helpers/validate.js";
|
|
41
|
+
export { computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawPlan, } from "./helpers/vaultV2ForceWithdrawPlan.js";
|
package/lib/esm/utils.js
CHANGED
|
@@ -32,6 +32,8 @@ TreeUtils, } from "@morpho-org/midnight-sdk";
|
|
|
32
32
|
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
|
|
33
33
|
export { computeReallocations, computeVaultV1Reallocations, } from "./helpers/computeVaultV1Reallocations.js";
|
|
34
34
|
export { addTransactionMetadata } from "./helpers/metadata.js";
|
|
35
|
+
export { previewVaultV2ForceWithdraw, } from "./helpers/previewVaultV2ForceWithdraw.js";
|
|
35
36
|
export { previewVaultV2InKindRedeem, } from "./helpers/previewVaultV2InKindRedeem.js";
|
|
36
|
-
export { computeMaxRepaySharePrice, computeMinBorrowSharePrice, } from "./helpers/slippage.js";
|
|
37
|
+
export { computeMaxRepaySharePrice, computeMinBorrowSharePrice, computeMinForceWithdrawSharePrice, } from "./helpers/slippage.js";
|
|
37
38
|
export { validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, } from "./helpers/validate.js";
|
|
39
|
+
export { computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, } from "./helpers/vaultV2ForceWithdrawPlan.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/morpho-sdk",
|
|
3
3
|
"description": "Abstraction layer for Morpho's complexity.",
|
|
4
|
-
"version": "6.0.0-next.
|
|
4
|
+
"version": "6.0.0-next.2",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Foulks-Plb <https://x.com/FoulkPlb>"
|
|
@@ -162,10 +162,10 @@
|
|
|
162
162
|
],
|
|
163
163
|
"dependencies": {
|
|
164
164
|
"zod": "^4.4.3",
|
|
165
|
-
"@morpho-org/blue-sdk": "^6.
|
|
166
|
-
"@morpho-org/blue-sdk-viem": "^5.
|
|
167
|
-
"@morpho-org/midnight-sdk": "^1.
|
|
168
|
-
"@morpho-org/morpho-ts": "^2.
|
|
165
|
+
"@morpho-org/blue-sdk": "^6.10.0-next.0",
|
|
166
|
+
"@morpho-org/blue-sdk-viem": "^5.7.0",
|
|
167
|
+
"@morpho-org/midnight-sdk": "^1.4.0",
|
|
168
|
+
"@morpho-org/morpho-ts": "^2.13.0"
|
|
169
169
|
},
|
|
170
170
|
"peerDependencies": {
|
|
171
171
|
"viem": "^2.0.0"
|
|
@@ -179,8 +179,8 @@
|
|
|
179
179
|
"@morpho-org/test": "^2.10.0"
|
|
180
180
|
},
|
|
181
181
|
"scripts": {
|
|
182
|
-
"prepublish": "
|
|
183
|
-
"build": "tsc --noEmit &&
|
|
182
|
+
"prepublish": "pnpm build",
|
|
183
|
+
"build": "tsc --noEmit && pnpm build:cjs && pnpm build:esm",
|
|
184
184
|
"build:cjs": "tsc --build tsconfig.build.cjs.json && echo '{\"type\":\"commonjs\"}' > lib/cjs/package.json",
|
|
185
185
|
"build:esm": "tsc --build tsconfig.build.esm.json && echo '{\"type\":\"module\"}' > lib/esm/package.json",
|
|
186
186
|
"test": "vitest --root ../.. --project morpho-sdk --project morpho-sdk-fork"
|