@morpho-org/morpho-sdk 8.2.0 → 9.0.0
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-v8-to-v9.md +54 -0
- package/README.md +14 -8
- package/lib/cjs/actions/bundles/common.d.ts +4 -7
- package/lib/cjs/actions/bundles/common.js +8 -14
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +1 -8
- package/lib/cjs/actions/midnight/authorization.d.ts +3 -1
- package/lib/cjs/actions/midnight/authorization.js +11 -1
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -0
- package/lib/cjs/actions/midnight/cancelAndMake.js +10 -2
- package/lib/cjs/actions/midnight/redeem.d.ts +4 -1
- package/lib/cjs/actions/midnight/redeem.js +13 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +7 -3
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +5 -1
- package/lib/cjs/actions/midnight/supplyCollateral.js +14 -3
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +9 -3
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +3 -1
- package/lib/cjs/actions/midnight/takeBorrow.js +9 -3
- package/lib/cjs/actions/midnight/takeLend.d.ts +1 -0
- package/lib/cjs/actions/midnight/takeLend.js +7 -2
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +8 -2
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +3 -1
- package/lib/cjs/actions/midnight/takeWithdraw.js +10 -3
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +5 -7
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +7 -11
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +8 -15
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +11 -8
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +1 -1
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +4 -4
- package/lib/cjs/actions/vaultV1/withdraw.js +4 -4
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +1 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +1 -1
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +4 -4
- package/lib/cjs/actions/vaultV2/withdraw.js +4 -4
- package/lib/cjs/entities/blue/blue.d.ts +2 -12
- package/lib/cjs/entities/blue/blue.js +0 -4
- package/lib/cjs/entities/midnight/midnight.d.ts +58 -17
- package/lib/cjs/entities/midnight/midnight.js +133 -52
- package/lib/cjs/entities/midnight/types.d.ts +2 -9
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +0 -7
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -20
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +40 -37
- package/lib/cjs/entities/vaultV1/vaultV1.js +5 -34
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +36 -34
- package/lib/cjs/entities/vaultV2/vaultV2.js +8 -34
- package/lib/cjs/helpers/encodeMidnightCalldata.d.ts +48 -0
- package/lib/cjs/helpers/encodeMidnightCalldata.js +74 -0
- package/lib/cjs/helpers/slippage.d.ts +9 -25
- package/lib/cjs/helpers/slippage.js +10 -27
- package/lib/cjs/helpers/validate.d.ts +1 -0
- package/lib/cjs/helpers/validate.js +5 -0
- package/lib/cjs/helpers/validateMidnightAccount.d.ts +34 -0
- package/lib/cjs/helpers/validateMidnightAccount.js +47 -0
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +4 -0
- package/lib/cjs/helpers/validateMidnightMarket.d.ts +2 -0
- package/lib/cjs/helpers/validateMidnightMarket.js +5 -0
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +11 -0
- package/lib/cjs/helpers/validateMidnightPublication.js +12 -1
- package/lib/cjs/helpers/validateMidnightReceiver.d.ts +1 -0
- package/lib/cjs/helpers/validateMidnightReceiver.js +8 -0
- package/lib/cjs/helpers/validateTakeableOffers.d.ts +2 -1
- package/lib/cjs/helpers/validateTakeableOffers.js +4 -3
- package/lib/cjs/types/action.d.ts +3 -1
- package/lib/cjs/types/error.d.ts +64 -5
- package/lib/cjs/types/error.js +152 -10
- package/lib/esm/actions/bundles/common.d.ts +4 -7
- package/lib/esm/actions/bundles/common.js +8 -14
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -9
- package/lib/esm/actions/midnight/authorization.d.ts +3 -1
- package/lib/esm/actions/midnight/authorization.js +12 -2
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -0
- package/lib/esm/actions/midnight/cancelAndMake.js +11 -3
- package/lib/esm/actions/midnight/redeem.d.ts +4 -1
- package/lib/esm/actions/midnight/redeem.js +15 -5
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +8 -4
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +5 -1
- package/lib/esm/actions/midnight/supplyCollateral.js +16 -5
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +10 -4
- package/lib/esm/actions/midnight/takeBorrow.d.ts +3 -1
- package/lib/esm/actions/midnight/takeBorrow.js +10 -4
- package/lib/esm/actions/midnight/takeLend.d.ts +1 -0
- package/lib/esm/actions/midnight/takeLend.js +8 -3
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +9 -3
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +3 -1
- package/lib/esm/actions/midnight/takeWithdraw.js +11 -4
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -8
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +7 -11
- package/lib/esm/actions/requirements/getRequirementsApproval.js +9 -16
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +12 -9
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +1 -1
- package/lib/esm/actions/vaultV1/withdraw.d.ts +4 -4
- package/lib/esm/actions/vaultV1/withdraw.js +4 -4
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +1 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.js +1 -1
- package/lib/esm/actions/vaultV2/withdraw.d.ts +4 -4
- package/lib/esm/actions/vaultV2/withdraw.js +4 -4
- package/lib/esm/entities/blue/blue.d.ts +2 -12
- package/lib/esm/entities/blue/blue.js +0 -4
- package/lib/esm/entities/midnight/midnight.d.ts +58 -17
- package/lib/esm/entities/midnight/midnight.js +134 -53
- package/lib/esm/entities/midnight/types.d.ts +2 -9
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +1 -8
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +9 -21
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +40 -37
- package/lib/esm/entities/vaultV1/vaultV1.js +6 -35
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +36 -34
- package/lib/esm/entities/vaultV2/vaultV2.js +8 -34
- package/lib/esm/helpers/encodeMidnightCalldata.d.ts +48 -0
- package/lib/esm/helpers/encodeMidnightCalldata.js +69 -0
- package/lib/esm/helpers/slippage.d.ts +9 -25
- package/lib/esm/helpers/slippage.js +9 -25
- package/lib/esm/helpers/validate.d.ts +1 -0
- package/lib/esm/helpers/validate.js +5 -0
- package/lib/esm/helpers/validateMidnightAccount.d.ts +34 -0
- package/lib/esm/helpers/validateMidnightAccount.js +43 -0
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +4 -0
- package/lib/esm/helpers/validateMidnightMarket.d.ts +2 -0
- package/lib/esm/helpers/validateMidnightMarket.js +5 -0
- package/lib/esm/helpers/validateMidnightPublication.d.ts +11 -0
- package/lib/esm/helpers/validateMidnightPublication.js +10 -0
- package/lib/esm/helpers/validateMidnightReceiver.d.ts +1 -0
- package/lib/esm/helpers/validateMidnightReceiver.js +8 -0
- package/lib/esm/helpers/validateTakeableOffers.d.ts +2 -1
- package/lib/esm/helpers/validateTakeableOffers.js +4 -3
- package/lib/esm/types/action.d.ts +3 -1
- package/lib/esm/types/error.d.ts +64 -5
- package/lib/esm/types/error.js +146 -6
- package/package.json +6 -5
package/lib/esm/types/error.js
CHANGED
|
@@ -794,6 +794,7 @@ export class AmbiguousRequirementSignaturesError extends Error {
|
|
|
794
794
|
*/
|
|
795
795
|
constructor(kind, count) {
|
|
796
796
|
super(`Expected at most one ${kind} signature but received ${count}. Pass a single ${kind} signature to buildTx.`);
|
|
797
|
+
this.name = "AmbiguousRequirementSignaturesError";
|
|
797
798
|
}
|
|
798
799
|
}
|
|
799
800
|
/**
|
|
@@ -815,6 +816,7 @@ export class UnexpectedRequirementSignatureError extends Error {
|
|
|
815
816
|
*/
|
|
816
817
|
constructor(kind) {
|
|
817
818
|
super(`Received a ${kind} signature that this operation does not consume. Remove it from the buildTx signatures array.`);
|
|
819
|
+
this.name = "UnexpectedRequirementSignatureError";
|
|
818
820
|
}
|
|
819
821
|
}
|
|
820
822
|
/** Thrown when `buildTx` receives a requirement signature whose action type is not supported. */
|
|
@@ -826,36 +828,35 @@ export class UnsupportedRequirementSignatureError extends Error {
|
|
|
826
828
|
constructor(type) {
|
|
827
829
|
super(`Received a requirement signature with unsupported action type "${type}". Re-run getRequirements() and sign the current requirements.`);
|
|
828
830
|
this.type = type;
|
|
831
|
+
this.name = "UnsupportedRequirementSignatureError";
|
|
829
832
|
}
|
|
830
833
|
}
|
|
831
834
|
/** Thrown when a viem client's account address does not match the address required by the call. */
|
|
832
835
|
export class AddressMismatchError extends Error {
|
|
833
836
|
constructor(clientAddress, argsAddress) {
|
|
834
837
|
super(`Address mismatch between client: ${clientAddress} and args: ${argsAddress}`);
|
|
838
|
+
this.name = "AddressMismatchError";
|
|
835
839
|
}
|
|
836
840
|
}
|
|
837
841
|
/** Thrown when a viem client's chain id does not match the chain id required by the call. */
|
|
838
842
|
export class ChainIdMismatchError extends Error {
|
|
839
843
|
constructor(clientChainId, argsChainId) {
|
|
840
844
|
super(`Chain ID mismatch between client: ${clientChainId} and args: ${argsChainId}`);
|
|
845
|
+
this.name = "ChainIdMismatchError";
|
|
841
846
|
}
|
|
842
847
|
}
|
|
843
848
|
/** Thrown when a runtime crypto API is required but unavailable. */
|
|
844
849
|
export class CryptoUnavailableError extends Error {
|
|
845
850
|
constructor(feature) {
|
|
846
851
|
super(`Crypto API is required for ${feature} but is unavailable.`);
|
|
852
|
+
this.name = "CryptoUnavailableError";
|
|
847
853
|
}
|
|
848
854
|
}
|
|
849
855
|
/** Thrown when the viem client is missing a property the call requires (e.g. `account.address`). */
|
|
850
856
|
export class MissingClientPropertyError extends Error {
|
|
851
857
|
constructor(property) {
|
|
852
858
|
super(`A required ${property} is missing from the client.`);
|
|
853
|
-
|
|
854
|
-
}
|
|
855
|
-
/** Thrown when an approval amount is smaller than the spend amount it must cover. */
|
|
856
|
-
export class ApprovalAmountLessThanSpendAmountError extends Error {
|
|
857
|
-
constructor() {
|
|
858
|
-
super("Approval amount is less than spend amount");
|
|
859
|
+
this.name = "MissingClientPropertyError";
|
|
859
860
|
}
|
|
860
861
|
}
|
|
861
862
|
/** Thrown when a requirement encoder targets an unsupported spender. */
|
|
@@ -865,12 +866,14 @@ export class UnsupportedErc20ApprovalSpenderError extends Error {
|
|
|
865
866
|
.filter((address) => address != null)
|
|
866
867
|
.join('", "');
|
|
867
868
|
super(`Requirement spender "${params.spender}" is not supported on chain "${params.chainId}". Use "${supported}".`);
|
|
869
|
+
this.name = "UnsupportedErc20ApprovalSpenderError";
|
|
868
870
|
}
|
|
869
871
|
}
|
|
870
872
|
/** Thrown when a Midnight authorization target (a requirement operator, or the ratifier that `midnightCancelAndMake` activates and MidnightBundlesV2 authorizes) is not registered for the chain. */
|
|
871
873
|
export class UnsupportedMidnightAuthorizationTargetError extends Error {
|
|
872
874
|
constructor(params) {
|
|
873
875
|
super(`Midnight authorization target "${params.authorized}" is not supported on chain "${params.chainId}". Use "${params.supportedTargets.join('", "')}".`);
|
|
876
|
+
this.name = "UnsupportedMidnightAuthorizationTargetError";
|
|
874
877
|
}
|
|
875
878
|
}
|
|
876
879
|
/** Thrown when a Morpho accrual position required by a call is missing. */
|
|
@@ -879,96 +882,112 @@ export class MissingAccrualPositionError extends Error {
|
|
|
879
882
|
super(market == null
|
|
880
883
|
? "Accrual position is missing. Fetch the position data and try again."
|
|
881
884
|
: `Accrual position is missing for market: ${market}`);
|
|
885
|
+
this.name = "MissingAccrualPositionError";
|
|
882
886
|
}
|
|
883
887
|
}
|
|
884
888
|
/** Thrown when a slippage tolerance exceeds `MAX_SLIPPAGE_TOLERANCE` (10%). */
|
|
885
889
|
export class ExcessiveSlippageToleranceError extends Error {
|
|
886
890
|
constructor(slippageTolerance) {
|
|
887
891
|
super(`Slippage tolerance ${slippageTolerance} exceeds maximum allowed (10%)`);
|
|
892
|
+
this.name = "ExcessiveSlippageToleranceError";
|
|
888
893
|
}
|
|
889
894
|
}
|
|
890
895
|
/** Thrown when a VaultV2 force-withdraw or force-redeem call has no deallocations to perform. */
|
|
891
896
|
export class EmptyDeallocationsError extends Error {
|
|
892
897
|
constructor(vault) {
|
|
893
898
|
super(`Deallocations list cannot be empty for vault: ${vault}`);
|
|
899
|
+
this.name = "EmptyDeallocationsError";
|
|
894
900
|
}
|
|
895
901
|
}
|
|
896
902
|
/** Thrown when a deposit's amount differs from the amount the supplied permit / permit2 signature was issued for. */
|
|
897
903
|
export class DepositAmountMismatchError extends Error {
|
|
898
904
|
constructor(depositAmount, signatureAmount) {
|
|
899
905
|
super(`Deposit amount "${depositAmount}" does not match requirement signature amount "${signatureAmount}"`);
|
|
906
|
+
this.name = "DepositAmountMismatchError";
|
|
900
907
|
}
|
|
901
908
|
}
|
|
902
909
|
/** Thrown when a deposit's asset differs from the asset the supplied permit / permit2 signature was issued for. */
|
|
903
910
|
export class DepositAssetMismatchError extends Error {
|
|
904
911
|
constructor(depositAsset, signatureAsset) {
|
|
905
912
|
super(`Deposit asset "${depositAsset}" does not match requirement signature asset "${signatureAsset}"`);
|
|
913
|
+
this.name = "DepositAssetMismatchError";
|
|
906
914
|
}
|
|
907
915
|
}
|
|
908
916
|
/** Thrown when a deposit's owner differs from the owner the supplied permit / permit2 signature was issued for. */
|
|
909
917
|
export class DepositOwnerMismatchError extends Error {
|
|
910
918
|
constructor(depositOwner, signatureOwner) {
|
|
911
919
|
super(`Deposit owner "${depositOwner}" does not match requirement signature owner "${signatureOwner}"`);
|
|
920
|
+
this.name = "DepositOwnerMismatchError";
|
|
912
921
|
}
|
|
913
922
|
}
|
|
914
923
|
/** Thrown when a deposit's spender differs from the spender the supplied permit / permit2 signature was issued for. */
|
|
915
924
|
export class DepositSpenderMismatchError extends Error {
|
|
916
925
|
constructor(depositSpender, signatureSpender) {
|
|
917
926
|
super(`Deposit spender "${depositSpender}" does not match requirement signature spender "${signatureSpender}"`);
|
|
927
|
+
this.name = "DepositSpenderMismatchError";
|
|
918
928
|
}
|
|
919
929
|
}
|
|
920
930
|
/** Thrown when a vault deposit uses `nativeAmount` but the vault asset is not the chain's wNative. */
|
|
921
931
|
export class NativeAmountOnNonWNativeVaultError extends Error {
|
|
922
932
|
constructor(vaultAsset, wNative) {
|
|
923
933
|
super(`Cannot use nativeAmount: vault asset ${vaultAsset} is not the wrapped native token ${wNative}`);
|
|
934
|
+
this.name = "NativeAmountOnNonWNativeVaultError";
|
|
924
935
|
}
|
|
925
936
|
}
|
|
926
937
|
/** Thrown when a `nativeAmount` is supplied but the chain has no configured wNative address. */
|
|
927
938
|
export class ChainWNativeMissingError extends Error {
|
|
928
939
|
constructor(chainId) {
|
|
929
940
|
super(`Chain ${chainId} does not have a configured wrapped native token (wNative)`);
|
|
941
|
+
this.name = "ChainWNativeMissingError";
|
|
930
942
|
}
|
|
931
943
|
}
|
|
932
944
|
/** Thrown when a vault entity's address does not match the vault address embedded in the call's args. */
|
|
933
945
|
export class VaultAddressMismatchError extends Error {
|
|
934
946
|
constructor(vaultAddress, argsVaultAddress) {
|
|
935
947
|
super(`Vault address mismatch between vault: ${vaultAddress} and args: ${argsVaultAddress}`);
|
|
948
|
+
this.name = "VaultAddressMismatchError";
|
|
936
949
|
}
|
|
937
950
|
}
|
|
938
951
|
/** Thrown when an action uses `nativeAmount` but the target asset is not the chain's wNative. */
|
|
939
952
|
export class NativeAmountOnNonWNativeAssetError extends Error {
|
|
940
953
|
constructor(asset, wNative) {
|
|
941
954
|
super(`Cannot use nativeAmount: asset ${asset} is not the wrapped native token ${wNative}`);
|
|
955
|
+
this.name = "NativeAmountOnNonWNativeAssetError";
|
|
942
956
|
}
|
|
943
957
|
}
|
|
944
958
|
/** Thrown when a borrow exceeds the LLTV-buffered safe maximum for the position. */
|
|
945
959
|
export class BorrowExceedsSafeLtvError extends Error {
|
|
946
960
|
constructor(borrowAmount, maxSafeBorrow) {
|
|
947
961
|
super(`Borrow amount ${borrowAmount} exceeds safe maximum ${maxSafeBorrow} (LLTV minus buffer). Reduce borrow or increase collateral.`);
|
|
962
|
+
this.name = "BorrowExceedsSafeLtvError";
|
|
948
963
|
}
|
|
949
964
|
}
|
|
950
965
|
/** Thrown when the market's oracle price is unavailable and position health cannot be validated. */
|
|
951
966
|
export class MissingMarketPriceError extends Error {
|
|
952
967
|
constructor(market) {
|
|
953
968
|
super(`Oracle price unavailable for market ${market}. Cannot validate position health.`);
|
|
969
|
+
this.name = "MissingMarketPriceError";
|
|
954
970
|
}
|
|
955
971
|
}
|
|
956
972
|
/** Thrown when a `MarketParams.id` does not match the expected market id derived from the other fields. */
|
|
957
973
|
export class MarketIdMismatchError extends Error {
|
|
958
974
|
constructor(marketId, expectedMarketId) {
|
|
959
975
|
super(`Market ${marketId} does not match expected market ${expectedMarketId}`);
|
|
976
|
+
this.name = "MarketIdMismatchError";
|
|
960
977
|
}
|
|
961
978
|
}
|
|
962
979
|
/** Thrown when an accrual position belongs to a different user than the one expected by the call. */
|
|
963
980
|
export class AccrualPositionUserMismatchError extends Error {
|
|
964
981
|
constructor(positionUser, expectedUser) {
|
|
965
982
|
super(`Accrual position user ${positionUser} does not match expected user ${expectedUser}`);
|
|
983
|
+
this.name = "AccrualPositionUserMismatchError";
|
|
966
984
|
}
|
|
967
985
|
}
|
|
968
986
|
/** Thrown when a Public Allocator source references the target Blue market. */
|
|
969
987
|
export class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
970
988
|
constructor(vault, marketId) {
|
|
971
989
|
super(`Reallocation withdrawal cannot include the target market ${marketId} for vault ${vault}.`);
|
|
990
|
+
this.name = "ReallocationWithdrawalOnTargetMarketError";
|
|
972
991
|
}
|
|
973
992
|
}
|
|
974
993
|
/**
|
|
@@ -1086,36 +1105,42 @@ export class InconsistentReallocationPenaltyError extends Error {
|
|
|
1086
1105
|
export class MutuallyExclusiveRepayAmountsError extends Error {
|
|
1087
1106
|
constructor(market) {
|
|
1088
1107
|
super(`Exactly one of assets or shares must be non-zero for market: ${market}. Both were provided.`);
|
|
1108
|
+
this.name = "MutuallyExclusiveRepayAmountsError";
|
|
1089
1109
|
}
|
|
1090
1110
|
}
|
|
1091
1111
|
/** Thrown when a withdraw amount exceeds the position's available collateral. */
|
|
1092
1112
|
export class WithdrawExceedsCollateralError extends Error {
|
|
1093
1113
|
constructor(params) {
|
|
1094
1114
|
super(`Withdraw amount ${params.withdrawAmount} exceeds available collateral ${params.available} for market: ${params.market}`);
|
|
1115
|
+
this.name = "WithdrawExceedsCollateralError";
|
|
1095
1116
|
}
|
|
1096
1117
|
}
|
|
1097
1118
|
/** Thrown when a collateral withdrawal would leave the borrower's position above the LLTV-buffered safe maximum. */
|
|
1098
1119
|
export class WithdrawMakesPositionUnhealthyError extends Error {
|
|
1099
1120
|
constructor(params) {
|
|
1100
1121
|
super(`Withdrawing ${params.withdrawAmount} collateral would make position unhealthy. Max safe borrow after withdrawal: ${params.maxSafeBorrow}. Actual Borrow assets: ${params.borrowAssets}.`);
|
|
1122
|
+
this.name = "WithdrawMakesPositionUnhealthyError";
|
|
1101
1123
|
}
|
|
1102
1124
|
}
|
|
1103
1125
|
/** Thrown when a repay amount in assets exceeds the borrower's outstanding debt. */
|
|
1104
1126
|
export class RepayExceedsDebtError extends Error {
|
|
1105
1127
|
constructor(params) {
|
|
1106
1128
|
super(`Repay amount ${params.repayAmount} exceeds outstanding debt ${params.debt} for market: ${params.market}`);
|
|
1129
|
+
this.name = "RepayExceedsDebtError";
|
|
1107
1130
|
}
|
|
1108
1131
|
}
|
|
1109
1132
|
/** Thrown when EIP-712 signature verification fails (the signed data does not match the expected signer). */
|
|
1110
1133
|
export class InvalidSignatureError extends Error {
|
|
1111
1134
|
constructor() {
|
|
1112
1135
|
super("Signature verification failed: the signed data does not match the expected signer address");
|
|
1136
|
+
this.name = "InvalidSignatureError";
|
|
1113
1137
|
}
|
|
1114
1138
|
}
|
|
1115
1139
|
/** Thrown when a repay in shares mode supplies more shares than the borrower owes. */
|
|
1116
1140
|
export class RepaySharesExceedDebtError extends Error {
|
|
1117
1141
|
constructor(params) {
|
|
1118
1142
|
super(`Repay shares ${params.repayShares} exceed outstanding borrow shares ${params.borrowShares} for market: ${params.market}`);
|
|
1143
|
+
this.name = "RepaySharesExceedDebtError";
|
|
1119
1144
|
}
|
|
1120
1145
|
}
|
|
1121
1146
|
/**
|
|
@@ -1130,6 +1155,7 @@ export class InsufficientSharedLiquidityError extends Error {
|
|
|
1130
1155
|
constructor(params) {
|
|
1131
1156
|
super(`Shared liquidity is insufficient on market ${params.marketId}: shortfall "${params.shortfall}", available "${params.available}". Reduce the operation amount or wait for additional vault liquidity.`);
|
|
1132
1157
|
this.params = params;
|
|
1158
|
+
this.name = "InsufficientSharedLiquidityError";
|
|
1133
1159
|
}
|
|
1134
1160
|
}
|
|
1135
1161
|
/** Thrown when reallocation state does not contain a requested market. */
|
|
@@ -1141,6 +1167,7 @@ export class UnknownReallocationMarketError extends UnknownDataError {
|
|
|
1141
1167
|
constructor(marketId) {
|
|
1142
1168
|
super(`unknown reallocation market "${marketId}"`);
|
|
1143
1169
|
this.marketId = marketId;
|
|
1170
|
+
this.name = "UnknownReallocationMarketError";
|
|
1144
1171
|
}
|
|
1145
1172
|
}
|
|
1146
1173
|
/** Thrown when reallocation state does not contain a requested vault. */
|
|
@@ -1152,6 +1179,7 @@ export class UnknownReallocationVaultError extends UnknownDataError {
|
|
|
1152
1179
|
constructor(vault) {
|
|
1153
1180
|
super(`unknown reallocation vault "${vault}"`);
|
|
1154
1181
|
this.vault = vault;
|
|
1182
|
+
this.name = "UnknownReallocationVaultError";
|
|
1155
1183
|
}
|
|
1156
1184
|
}
|
|
1157
1185
|
/** Thrown when Vault V2 reallocation state does not contain a requested allocation id. */
|
|
@@ -1166,6 +1194,7 @@ export class UnknownReallocationAllocationError extends UnknownDataError {
|
|
|
1166
1194
|
super(`unknown reallocation allocation "${id}" for vault "${vault}"`);
|
|
1167
1195
|
this.vault = vault;
|
|
1168
1196
|
this.id = id;
|
|
1197
|
+
this.name = "UnknownReallocationAllocationError";
|
|
1169
1198
|
}
|
|
1170
1199
|
}
|
|
1171
1200
|
/** Thrown when Vault V2 reallocation state lacks the vault-wide allocator configuration. */
|
|
@@ -1175,6 +1204,7 @@ export class UnknownReallocationPublicAllocatorConfigError extends UnknownDataEr
|
|
|
1175
1204
|
constructor(vault) {
|
|
1176
1205
|
super(`unknown public allocator configuration for vault "${vault}"`);
|
|
1177
1206
|
this.vault = vault;
|
|
1207
|
+
this.name = "UnknownReallocationPublicAllocatorConfigError";
|
|
1178
1208
|
}
|
|
1179
1209
|
}
|
|
1180
1210
|
/** Thrown when Vault V2 reallocation state lacks the fetched active-adapter set. */
|
|
@@ -1184,6 +1214,7 @@ export class UnknownReallocationActiveAdaptersError extends UnknownDataError {
|
|
|
1184
1214
|
constructor(vault) {
|
|
1185
1215
|
super(`unknown active adapters for reallocation vault "${vault}"`);
|
|
1186
1216
|
this.vault = vault;
|
|
1217
|
+
this.name = "UnknownReallocationActiveAdaptersError";
|
|
1187
1218
|
}
|
|
1188
1219
|
}
|
|
1189
1220
|
/** Thrown when Vault V2 reallocation state lacks an adapter-market allocator configuration. */
|
|
@@ -1198,6 +1229,7 @@ export class UnknownReallocationMarketPublicAllocatorConfigError extends Unknown
|
|
|
1198
1229
|
super(`unknown public allocator configuration "${adapterMarketCapId}" for vault "${vault}"`);
|
|
1199
1230
|
this.vault = vault;
|
|
1200
1231
|
this.adapterMarketCapId = adapterMarketCapId;
|
|
1232
|
+
this.name = "UnknownReallocationMarketPublicAllocatorConfigError";
|
|
1201
1233
|
}
|
|
1202
1234
|
}
|
|
1203
1235
|
/** Thrown when Vault V2 reallocation state does not contain a requested adapter. */
|
|
@@ -1212,6 +1244,7 @@ export class UnknownReallocationAdapterError extends UnknownDataError {
|
|
|
1212
1244
|
super(`unknown reallocation adapter "${adapter}" for vault "${vault}"`);
|
|
1213
1245
|
this.vault = vault;
|
|
1214
1246
|
this.adapter = adapter;
|
|
1247
|
+
this.name = "UnknownReallocationAdapterError";
|
|
1215
1248
|
}
|
|
1216
1249
|
}
|
|
1217
1250
|
/** Thrown when a simulated Vault V2 allocation transition would underflow. */
|
|
@@ -1220,6 +1253,7 @@ export class ReallocationAllocationUnderflowError extends Error {
|
|
|
1220
1253
|
constructor(params) {
|
|
1221
1254
|
super(`Reallocation change "${params.change}" exceeds allocation "${params.allocation}" for id "${params.id}" on vault "${params.vault}". Refresh the reallocation data and recompute the plan.`);
|
|
1222
1255
|
this.params = params;
|
|
1256
|
+
this.name = "ReallocationAllocationUnderflowError";
|
|
1223
1257
|
}
|
|
1224
1258
|
}
|
|
1225
1259
|
/** Thrown when a simulated Vault V2 market withdrawal exceeds the adapter's supply shares. */
|
|
@@ -1228,48 +1262,56 @@ export class ReallocationAdapterSupplySharesUnderflowError extends Error {
|
|
|
1228
1262
|
constructor(params) {
|
|
1229
1263
|
super(`Reallocation withdraw shares "${params.withdrawnShares}" exceed adapter supply shares "${params.supplyShares}" on market "${params.marketId}" for adapter "${params.adapter}". Refresh the reallocation data and recompute the plan.`);
|
|
1230
1264
|
this.params = params;
|
|
1265
|
+
this.name = "ReallocationAdapterSupplySharesUnderflowError";
|
|
1231
1266
|
}
|
|
1232
1267
|
}
|
|
1233
1268
|
/** Thrown when a Midnight batch cancellation has no offer groups. */
|
|
1234
1269
|
export class EmptyMidnightGroupCancellationsError extends Error {
|
|
1235
1270
|
constructor() {
|
|
1236
1271
|
super("Midnight group cancellations cannot be empty. Pass at least one offer group to cancel.");
|
|
1272
|
+
this.name = "EmptyMidnightGroupCancellationsError";
|
|
1237
1273
|
}
|
|
1238
1274
|
}
|
|
1239
1275
|
/** Thrown when a Midnight flow passes a collateral market with no collateral supplies. */
|
|
1240
1276
|
export class EmptyMidnightCollateralSuppliesError extends Error {
|
|
1241
1277
|
constructor() {
|
|
1242
1278
|
super("Midnight collateral supplies cannot be empty. Pass at least one collateral supply, or use `makeBorrow` to publish without collateral.");
|
|
1279
|
+
this.name = "EmptyMidnightCollateralSuppliesError";
|
|
1243
1280
|
}
|
|
1244
1281
|
}
|
|
1245
1282
|
/** Thrown when a Midnight batch cancellation lists the same offer group twice. */
|
|
1246
1283
|
export class DuplicateMidnightGroupCancellationError extends Error {
|
|
1247
1284
|
constructor(params) {
|
|
1248
1285
|
super(`Midnight group cancellation "${params.index}" repeats group "${params.group}". Pass each offer group once.`);
|
|
1286
|
+
this.name = "DuplicateMidnightGroupCancellationError";
|
|
1249
1287
|
}
|
|
1250
1288
|
}
|
|
1251
1289
|
/** Thrown when a Midnight flow needs at least one takeable offer. */
|
|
1252
1290
|
export class EmptyMidnightTakeableOffersError extends Error {
|
|
1253
1291
|
constructor() {
|
|
1254
1292
|
super("Midnight takeable offers cannot be empty. Refresh the quote and try again.");
|
|
1293
|
+
this.name = "EmptyMidnightTakeableOffersError";
|
|
1255
1294
|
}
|
|
1256
1295
|
}
|
|
1257
1296
|
/** Thrown when a Midnight offer has the wrong maker side for the requested flow. */
|
|
1258
1297
|
export class MidnightOfferSideMismatchError extends Error {
|
|
1259
1298
|
constructor(params) {
|
|
1260
1299
|
super(`Midnight offer "${params.index}" has buy="${params.actualBuy}", expected "${params.expectedBuy}". Use the matching flow or rebuild the offer list.`);
|
|
1300
|
+
this.name = "MidnightOfferSideMismatchError";
|
|
1261
1301
|
}
|
|
1262
1302
|
}
|
|
1263
1303
|
/** Thrown when a Midnight maker method that is not a limit exit receives a reduce-only offer. */
|
|
1264
1304
|
export class MidnightOfferReduceOnlyError extends Error {
|
|
1265
1305
|
constructor(params) {
|
|
1266
1306
|
super(`Midnight offer "${params.index}" is reduce-only. Rebuild the offer with reduceOnly=false; reduce-only exits need a dedicated exit flow.`);
|
|
1307
|
+
this.name = "MidnightOfferReduceOnlyError";
|
|
1267
1308
|
}
|
|
1268
1309
|
}
|
|
1269
1310
|
/** Thrown when a Midnight maker offer belongs to a different account than the action flow. */
|
|
1270
1311
|
export class MidnightOfferMakerMismatchError extends Error {
|
|
1271
1312
|
constructor(params) {
|
|
1272
1313
|
super(`Midnight offer "${params.index}" belongs to maker "${params.actualMaker}", expected "${params.expectedMaker}". Rebuild the offer set for the active account.`);
|
|
1314
|
+
this.name = "MidnightOfferMakerMismatchError";
|
|
1273
1315
|
}
|
|
1274
1316
|
}
|
|
1275
1317
|
/** Thrown when a Midnight maker offer sets a nonzero continuous fee cap. */
|
|
@@ -1435,6 +1477,18 @@ export class MidnightZeroReceiverError extends Error {
|
|
|
1435
1477
|
this.name = "MidnightZeroReceiverError";
|
|
1436
1478
|
}
|
|
1437
1479
|
}
|
|
1480
|
+
/** Thrown when a Midnight flow uses the zero address as the account it acts for. */
|
|
1481
|
+
export class MidnightZeroOnBehalfError extends Error {
|
|
1482
|
+
field;
|
|
1483
|
+
/**
|
|
1484
|
+
* @param field - Account field containing the zero address.
|
|
1485
|
+
*/
|
|
1486
|
+
constructor(field) {
|
|
1487
|
+
super(`Midnight "${field}" cannot be the zero address. Provide a valid account.`);
|
|
1488
|
+
this.field = field;
|
|
1489
|
+
this.name = "MidnightZeroOnBehalfError";
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1438
1492
|
/**
|
|
1439
1493
|
* Thrown when a Midnight receiver is a Midnight protocol or market token contract that cannot
|
|
1440
1494
|
* forward received assets.
|
|
@@ -1488,84 +1542,98 @@ export class MidnightTakeDeadlineTooFarError extends Error {
|
|
|
1488
1542
|
export class MidnightOfferMarketChainMismatchError extends Error {
|
|
1489
1543
|
constructor(params) {
|
|
1490
1544
|
super(`Midnight offer "${params.index}" targets chain "${params.actualChainId}", expected "${params.expectedChainId}". Rebuild the offer set for the selected chain.`);
|
|
1545
|
+
this.name = "MidnightOfferMarketChainMismatchError";
|
|
1491
1546
|
}
|
|
1492
1547
|
}
|
|
1493
1548
|
/** Thrown when a Midnight maker offer targets a different Midnight contract than the action flow. */
|
|
1494
1549
|
export class MidnightOfferMarketAddressMismatchError extends Error {
|
|
1495
1550
|
constructor(params) {
|
|
1496
1551
|
super(`Midnight offer "${params.index}" targets Midnight "${params.actualMidnight}", expected "${params.expectedMidnight}". Rebuild the offer set for the selected chain.`);
|
|
1552
|
+
this.name = "MidnightOfferMarketAddressMismatchError";
|
|
1497
1553
|
}
|
|
1498
1554
|
}
|
|
1499
1555
|
/** Thrown when a Midnight market targets a different deployment than the selected chain. */
|
|
1500
1556
|
export class MidnightMarketAddressMismatchError extends Error {
|
|
1501
1557
|
constructor(params) {
|
|
1502
1558
|
super(`Midnight market targets contract "${params.actualMidnight}", expected "${params.expectedMidnight}". Use market data from the selected chain deployment.`);
|
|
1559
|
+
this.name = "MidnightMarketAddressMismatchError";
|
|
1503
1560
|
}
|
|
1504
1561
|
}
|
|
1505
1562
|
/** Thrown when a Midnight make-lend offer does not use the approved loan token. */
|
|
1506
1563
|
export class MidnightOfferMarketLoanTokenMismatchError extends Error {
|
|
1507
1564
|
constructor(params) {
|
|
1508
1565
|
super(`Midnight offer "${params.index}" uses loan token "${params.actualLoanToken}", expected "${params.expectedLoanToken}". Rebuild the lend offer set for the approved loan token.`);
|
|
1566
|
+
this.name = "MidnightOfferMarketLoanTokenMismatchError";
|
|
1509
1567
|
}
|
|
1510
1568
|
}
|
|
1511
1569
|
/** Thrown when a Blue-funded Midnight lend offer does not use the maker's derived `BlueBuyCallback`. */
|
|
1512
1570
|
export class MidnightOfferCallbackMismatchError extends Error {
|
|
1513
1571
|
constructor(params) {
|
|
1514
1572
|
super(`Midnight offer "${params.index}" uses callback "${params.actualCallback}", expected the maker's BlueBuyCallback "${params.expectedCallback}". Rebuild the offer with the derived callback.`);
|
|
1573
|
+
this.name = "MidnightOfferCallbackMismatchError";
|
|
1515
1574
|
}
|
|
1516
1575
|
}
|
|
1517
1576
|
/** Thrown when a Blue-funded Midnight lend offer's callback data is not the ABI-encoded Blue market. */
|
|
1518
1577
|
export class MidnightOfferCallbackDataMismatchError extends Error {
|
|
1519
1578
|
constructor(params) {
|
|
1520
1579
|
super(`Midnight offer "${params.index}" uses callback data "${params.actualCallbackData}", expected "${params.expectedCallbackData}". Set the callback data to the ABI-encoded Blue market the assets are parked in.`);
|
|
1580
|
+
this.name = "MidnightOfferCallbackDataMismatchError";
|
|
1521
1581
|
}
|
|
1522
1582
|
}
|
|
1523
1583
|
/** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
|
|
1524
1584
|
export class EmptyBlueParkingMarketError extends Error {
|
|
1525
1585
|
constructor(params) {
|
|
1526
1586
|
super(`Morpho Blue market "${params.marketId}" has no supply shares. Parking assets in an empty market is exposed to supply-share-price inflation; choose a market with existing supply.`);
|
|
1587
|
+
this.name = "EmptyBlueParkingMarketError";
|
|
1527
1588
|
}
|
|
1528
1589
|
}
|
|
1529
1590
|
/** Thrown when parked assets would mint no Morpho Blue supply shares. */
|
|
1530
1591
|
export class ZeroBlueParkingSharesError extends Error {
|
|
1531
1592
|
constructor(params) {
|
|
1532
1593
|
super(`Supplying "${params.assets}" assets to Morpho Blue market "${params.marketId}" mints zero supply shares at its current share price; park more assets or choose another market.`);
|
|
1594
|
+
this.name = "ZeroBlueParkingSharesError";
|
|
1533
1595
|
}
|
|
1534
1596
|
}
|
|
1535
1597
|
/** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
|
|
1536
1598
|
export class MidnightTakeableOfferMarketMismatchError extends Error {
|
|
1537
1599
|
constructor(params) {
|
|
1538
1600
|
super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
|
|
1601
|
+
this.name = "MidnightTakeableOfferMarketMismatchError";
|
|
1539
1602
|
}
|
|
1540
1603
|
}
|
|
1541
1604
|
/** Thrown when a Midnight offer's ratifier does not match its tree's ratifier route. */
|
|
1542
1605
|
export class MidnightOfferRatifierMismatchError extends Error {
|
|
1543
1606
|
constructor(params) {
|
|
1544
1607
|
super(`Midnight offer "${params.index}" uses ratifier "${params.actualRatifier}", expected "${params.expectedRatifier}" for its tree type. Rebuild the offer with the tree's ratifier.`);
|
|
1608
|
+
this.name = "MidnightOfferRatifierMismatchError";
|
|
1545
1609
|
}
|
|
1546
1610
|
}
|
|
1547
1611
|
/** Thrown when a Midnight repost cancels a group it also publishes. */
|
|
1548
1612
|
export class MidnightReplacementGroupCancelledError extends Error {
|
|
1549
1613
|
constructor(params) {
|
|
1550
1614
|
super(`Midnight offer group "${params.group}" is both published and cancelled. Give replacement offers a fresh group.`);
|
|
1615
|
+
this.name = "MidnightReplacementGroupCancelledError";
|
|
1551
1616
|
}
|
|
1552
1617
|
}
|
|
1553
1618
|
/** Thrown when a Midnight redeem flow finds no credit units for the user. */
|
|
1554
1619
|
export class NoMidnightCreditToRedeemError extends Error {
|
|
1555
1620
|
constructor(market) {
|
|
1556
1621
|
super(`No Midnight credit is available to redeem for market "${market}".`);
|
|
1622
|
+
this.name = "NoMidnightCreditToRedeemError";
|
|
1557
1623
|
}
|
|
1558
1624
|
}
|
|
1559
1625
|
/** Thrown when a Midnight redeem amount exceeds the user's accrued credit. */
|
|
1560
1626
|
export class MidnightRedeemExceedsCreditError extends Error {
|
|
1561
1627
|
constructor(params) {
|
|
1562
1628
|
super(`Midnight redeem amount exceeds position credit on market "${params.market}": units "${params.units}", credit "${params.credit}". Redeem less or refresh the position data.`);
|
|
1629
|
+
this.name = "MidnightRedeemExceedsCreditError";
|
|
1563
1630
|
}
|
|
1564
1631
|
}
|
|
1565
1632
|
/** Thrown when a Midnight redeem amount exceeds the market's currently withdrawable liquidity. */
|
|
1566
1633
|
export class InsufficientMidnightWithdrawableLiquidityError extends Error {
|
|
1567
1634
|
constructor(params) {
|
|
1568
1635
|
super(`Midnight withdrawable liquidity is insufficient on market "${params.market}": units "${params.units}", withdrawable "${params.withdrawable}". Try again later or redeem less.`);
|
|
1636
|
+
this.name = "InsufficientMidnightWithdrawableLiquidityError";
|
|
1569
1637
|
}
|
|
1570
1638
|
}
|
|
1571
1639
|
/**
|
|
@@ -1629,18 +1697,21 @@ export class MidnightInvalidAccountAddressError extends Error {
|
|
|
1629
1697
|
export class MutuallyExclusiveWithdrawAmountsError extends Error {
|
|
1630
1698
|
constructor(market) {
|
|
1631
1699
|
super(`Exactly one of assets or shares must be non-zero for market: ${market}. Both were provided.`);
|
|
1700
|
+
this.name = "MutuallyExclusiveWithdrawAmountsError";
|
|
1632
1701
|
}
|
|
1633
1702
|
}
|
|
1634
1703
|
/** Thrown when a loan-asset withdraw in assets mode exceeds the user's supplied assets in the market. */
|
|
1635
1704
|
export class WithdrawExceedsSupplyError extends Error {
|
|
1636
1705
|
constructor(params) {
|
|
1637
1706
|
super(`Withdraw amount ${params.withdrawAmount} exceeds available supply ${params.available} for market: ${params.market}. Reduce withdraw amount.`);
|
|
1707
|
+
this.name = "WithdrawExceedsSupplyError";
|
|
1638
1708
|
}
|
|
1639
1709
|
}
|
|
1640
1710
|
/** Thrown when a loan-asset withdraw in shares mode exceeds the user's owned supply shares in the market. */
|
|
1641
1711
|
export class WithdrawSharesExceedSupplyError extends Error {
|
|
1642
1712
|
constructor(params) {
|
|
1643
1713
|
super(`Withdraw shares ${params.withdrawShares} exceed owned supply shares ${params.supplyShares} for market: ${params.market}. Reduce withdraw shares.`);
|
|
1714
|
+
this.name = "WithdrawSharesExceedSupplyError";
|
|
1644
1715
|
}
|
|
1645
1716
|
}
|
|
1646
1717
|
/**
|
|
@@ -1655,30 +1726,35 @@ export class ReallocationWithdrawExceedsMarketSupplyError extends Error {
|
|
|
1655
1726
|
constructor(params) {
|
|
1656
1727
|
super(`Withdraw amount "${params.withdrawAmount}" exceeds market total supply "${params.totalSupplyAssets}" on market ${params.marketId}. Reduce the withdraw amount.`);
|
|
1657
1728
|
this.params = params;
|
|
1729
|
+
this.name = "ReallocationWithdrawExceedsMarketSupplyError";
|
|
1658
1730
|
}
|
|
1659
1731
|
}
|
|
1660
1732
|
/** Thrown when a vault migration's source vault asset differs from the target vault asset. */
|
|
1661
1733
|
export class VaultAssetMismatchError extends Error {
|
|
1662
1734
|
constructor(sourceAsset, targetAsset) {
|
|
1663
1735
|
super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
|
|
1736
|
+
this.name = "VaultAssetMismatchError";
|
|
1664
1737
|
}
|
|
1665
1738
|
}
|
|
1666
1739
|
/** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
|
|
1667
1740
|
export class RefinanceSameMarketError extends Error {
|
|
1668
1741
|
constructor(market) {
|
|
1669
1742
|
super(`Refinance source and target market ${market} are identical. Refinance requires a different target market.`);
|
|
1743
|
+
this.name = "RefinanceSameMarketError";
|
|
1670
1744
|
}
|
|
1671
1745
|
}
|
|
1672
1746
|
/** Thrown when a refinance's source and target markets do not share the same loan or collateral token. */
|
|
1673
1747
|
export class RefinanceTokenMismatchError extends Error {
|
|
1674
1748
|
constructor(sourceMarket, targetMarket) {
|
|
1675
1749
|
super(`Refinance source market ${sourceMarket} and target market ${targetMarket} must share the same loanToken and collateralToken.`);
|
|
1750
|
+
this.name = "RefinanceTokenMismatchError";
|
|
1676
1751
|
}
|
|
1677
1752
|
}
|
|
1678
1753
|
/** Thrown when a maker limit-exit offer can increase or open a position. */
|
|
1679
1754
|
export class MidnightOfferNotReduceOnlyError extends Error {
|
|
1680
1755
|
constructor(params) {
|
|
1681
1756
|
super(`Midnight exit offer "${params.index}" must have reduceOnly=true. Rebuild the offer tree for the exit intent.`);
|
|
1757
|
+
this.name = "MidnightOfferNotReduceOnlyError";
|
|
1682
1758
|
}
|
|
1683
1759
|
}
|
|
1684
1760
|
/**
|
|
@@ -1721,3 +1797,67 @@ export class MissingContractCodeError extends Error {
|
|
|
1721
1797
|
this.name = "MissingContractCodeError";
|
|
1722
1798
|
}
|
|
1723
1799
|
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Thrown when a Midnight flow is prepared for the zero address. Midnight would revert
|
|
1802
|
+
* `Unauthorized()`, and requirements resolved for the zero address can never be sent.
|
|
1803
|
+
*
|
|
1804
|
+
* @example
|
|
1805
|
+
* ```ts
|
|
1806
|
+
* import { MidnightZeroAccountError } from "@morpho-org/morpho-sdk";
|
|
1807
|
+
*
|
|
1808
|
+
* const error = new MidnightZeroAccountError("accountAddress");
|
|
1809
|
+
* // error.field === "accountAddress"
|
|
1810
|
+
* ```
|
|
1811
|
+
*/
|
|
1812
|
+
export class MidnightZeroAccountError extends Error {
|
|
1813
|
+
field;
|
|
1814
|
+
/**
|
|
1815
|
+
* @param field - Account field containing the zero address: `accountAddress` for an entity
|
|
1816
|
+
* method, `owner` for a requirement helper. A zero `onBehalf` on a direct Midnight call throws
|
|
1817
|
+
* {@link MidnightZeroOnBehalfError} instead.
|
|
1818
|
+
*/
|
|
1819
|
+
constructor(field) {
|
|
1820
|
+
super(`Midnight "${field}" cannot be the zero address. Pass the account that sends the transaction.`);
|
|
1821
|
+
this.field = field;
|
|
1822
|
+
this.name = "MidnightZeroAccountError";
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Thrown when a Midnight builder or `MorphoMidnight` method cannot ABI-encode its calldata,
|
|
1827
|
+
* offer tree or market id, for example a `bytes32` field that is not 32 bytes, an integer
|
|
1828
|
+
* outside its Solidity type or a malformed address. Wraps the viem error as `cause`.
|
|
1829
|
+
*
|
|
1830
|
+
* @example
|
|
1831
|
+
* ```ts
|
|
1832
|
+
* import { MidnightCalldataEncodingError } from "@morpho-org/morpho-sdk";
|
|
1833
|
+
* import { BaseError } from "viem";
|
|
1834
|
+
*
|
|
1835
|
+
* const error = new MidnightCalldataEncodingError(
|
|
1836
|
+
* "midnightBundlesV2CancelAndMake",
|
|
1837
|
+
* new BaseError("bad bytes32"),
|
|
1838
|
+
* );
|
|
1839
|
+
* // error.input === "midnightBundlesV2CancelAndMake"
|
|
1840
|
+
* ```
|
|
1841
|
+
*/
|
|
1842
|
+
export class MidnightCalldataEncodingError extends Error {
|
|
1843
|
+
input;
|
|
1844
|
+
cause;
|
|
1845
|
+
/**
|
|
1846
|
+
* @param input - Input that could not be encoded: the contract function whose calldata
|
|
1847
|
+
* failed, `"offers"` for offer-tree hashing, `"marketId"` for market-id hashing, or the name
|
|
1848
|
+
* of the malformed address input, such as `"accountAddress"`, `"onBehalf"`, `"owner"`,
|
|
1849
|
+
* `"receiver"`, `"collateralReceiver"`, `"referralFeeRecipient"`, `"market.midnight"`,
|
|
1850
|
+
* `"authorized"`, `"publication.ratifier"`, `"loanToken"`, `"market.loanToken"`,
|
|
1851
|
+
* `"market.collateralParams[i].token"`, `"positionData.user"`, `"spender"` or `"token"` (a token
|
|
1852
|
+
* pulled with native funding, or the token checked by
|
|
1853
|
+
* `getMidnightApprovalRequirements`). `"blueMarket"` reports the Blue market encoding in
|
|
1854
|
+
* `supplyBlueMakeLend`: a malformed address or an out-of-range `lltv`.
|
|
1855
|
+
* @param cause - viem encoding error.
|
|
1856
|
+
*/
|
|
1857
|
+
constructor(input, cause) {
|
|
1858
|
+
super(`Cannot encode Midnight input "${input}": ${cause.shortMessage} Check bytes32 sizes, integer ranges and addresses in the inputs.`, { cause });
|
|
1859
|
+
this.input = input;
|
|
1860
|
+
this.cause = cause;
|
|
1861
|
+
this.name = "MidnightCalldataEncodingError";
|
|
1862
|
+
}
|
|
1863
|
+
}
|
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": "
|
|
4
|
+
"version": "9.0.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -149,13 +149,14 @@
|
|
|
149
149
|
"lib",
|
|
150
150
|
"MIGRATION-v5-to-v6.md",
|
|
151
151
|
"MIGRATION-v6-to-v7.md",
|
|
152
|
-
"MIGRATION-v7-to-v8.md"
|
|
152
|
+
"MIGRATION-v7-to-v8.md",
|
|
153
|
+
"MIGRATION-v8-to-v9.md"
|
|
153
154
|
],
|
|
154
155
|
"dependencies": {
|
|
155
156
|
"@morpho-org/blue-sdk": "^8.0.1",
|
|
156
157
|
"@morpho-org/blue-sdk-viem": "^7.0.0",
|
|
157
|
-
"@morpho-org/midnight-sdk": "^2.
|
|
158
|
-
"@morpho-org/morpho-ts": "^4.0
|
|
158
|
+
"@morpho-org/midnight-sdk": "^2.2.0",
|
|
159
|
+
"@morpho-org/morpho-ts": "^4.1.0"
|
|
159
160
|
},
|
|
160
161
|
"peerDependencies": {
|
|
161
162
|
"viem": "^2.0.0"
|
|
@@ -166,7 +167,7 @@
|
|
|
166
167
|
"fast-check": "^4.9.0",
|
|
167
168
|
"typescript": "7.0.2",
|
|
168
169
|
"viem": "^2.55.10",
|
|
169
|
-
"vitest": "^4.1.
|
|
170
|
+
"vitest": "^4.1.12"
|
|
170
171
|
},
|
|
171
172
|
"scripts": {
|
|
172
173
|
"prepublish": "pnpm build",
|