@morpho-org/morpho-sdk 5.1.2 → 5.3.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/README.md +46 -2
- package/lib/cjs/abis.d.ts +1 -0
- package/lib/cjs/abis.js +6 -1
- package/lib/cjs/actions/blue/borrow.d.ts +3 -7
- package/lib/cjs/actions/blue/borrow.js +5 -9
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +3 -4
- package/lib/cjs/actions/blue/buildReallocationActions.js +3 -4
- package/lib/cjs/actions/blue/refinance.d.ts +4 -8
- package/lib/cjs/actions/blue/refinance.js +10 -14
- package/lib/cjs/actions/blue/repay.d.ts +2 -5
- package/lib/cjs/actions/blue/repay.js +2 -5
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -6
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +4 -7
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +2 -5
- package/lib/cjs/actions/blue/resolveRepayFunding.js +15 -12
- package/lib/cjs/actions/blue/supply.d.ts +2 -4
- package/lib/cjs/actions/blue/supply.js +6 -8
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -3
- package/lib/cjs/actions/blue/supplyCollateral.js +5 -6
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +4 -9
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +9 -14
- package/lib/cjs/actions/blue/withdraw.d.ts +9 -7
- package/lib/cjs/actions/blue/withdraw.js +18 -10
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
- package/lib/cjs/actions/index.d.ts +2 -0
- package/lib/cjs/actions/index.js +1 -0
- package/lib/cjs/actions/midnight/authorization.d.ts +37 -0
- package/lib/cjs/actions/midnight/authorization.js +69 -0
- package/lib/cjs/actions/midnight/cancelOffer.d.ts +38 -0
- package/lib/cjs/actions/midnight/cancelOffer.js +73 -0
- package/lib/cjs/actions/midnight/index.d.ts +11 -0
- package/lib/cjs/actions/midnight/index.js +27 -0
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +52 -0
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +72 -0
- package/lib/cjs/actions/midnight/redeem.d.ts +43 -0
- package/lib/cjs/actions/midnight/redeem.js +79 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +53 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +121 -0
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +40 -0
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +59 -0
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +45 -0
- package/lib/cjs/actions/midnight/supplyCollateral.js +83 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +51 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -0
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +57 -0
- package/lib/cjs/actions/midnight/takeBorrow.js +110 -0
- package/lib/cjs/actions/midnight/takeLend.d.ts +57 -0
- package/lib/cjs/actions/midnight/takeLend.js +110 -0
- package/lib/cjs/actions/midnight/types.d.ts +39 -0
- package/lib/cjs/actions/midnight/types.js +15 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +5 -16
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +5 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +10 -14
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +2 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +11 -28
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +5 -17
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +10 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +10 -4
- package/lib/cjs/actions/requirements/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/index.js +1 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +49 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +76 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +44 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +78 -0
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +42 -0
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +70 -0
- package/lib/cjs/actions/requirements/midnight/index.d.ts +3 -0
- package/lib/cjs/actions/requirements/midnight/index.js +19 -0
- package/lib/cjs/actions/vaultV1/deposit.d.ts +3 -4
- package/lib/cjs/actions/vaultV1/deposit.js +7 -8
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +2 -3
- package/lib/cjs/actions/vaultV1/migrateToV2.js +5 -6
- package/lib/cjs/actions/vaultV1/redeem.d.ts +1 -1
- package/lib/cjs/actions/vaultV1/redeem.js +2 -2
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV1/withdraw.js +2 -2
- package/lib/cjs/actions/vaultV2/deposit.d.ts +3 -4
- package/lib/cjs/actions/vaultV2/deposit.js +7 -8
- package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +2 -3
- package/lib/cjs/actions/vaultV2/forceRedeem.js +3 -4
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +2 -2
- package/lib/cjs/actions/vaultV2/redeem.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/redeem.js +2 -2
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/withdraw.js +2 -2
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +5 -2
- package/lib/cjs/constants.d.ts +1 -0
- package/lib/cjs/constants.js +15 -1
- package/lib/cjs/entities/blue/blue.d.ts +5 -5
- package/lib/cjs/entities/blue/blue.js +105 -86
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/index.d.ts +2 -0
- package/lib/cjs/entities/midnight/index.js +18 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +402 -0
- package/lib/cjs/entities/midnight/midnight.js +1036 -0
- package/lib/cjs/entities/midnight/types.d.ts +164 -0
- package/lib/cjs/entities/midnight/types.js +2 -0
- package/lib/cjs/entities/vaultV1/vaultV1.js +10 -17
- package/lib/cjs/entities/vaultV2/vaultV2.js +19 -21
- package/lib/cjs/errors.d.ts +1 -0
- package/lib/cjs/errors.js +17 -1
- package/lib/cjs/helpers/encodeDeallocation.d.ts +1 -0
- package/lib/cjs/helpers/encodeDeallocation.js +2 -1
- package/lib/cjs/helpers/index.d.ts +4 -1
- package/lib/cjs/helpers/index.js +8 -1
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +34 -0
- package/lib/cjs/helpers/signAndVerifyTypedData.js +58 -0
- package/lib/cjs/helpers/validate.d.ts +40 -1
- package/lib/cjs/helpers/validate.js +47 -5
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +15 -0
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +32 -0
- package/lib/cjs/helpers/validateMidnightMarket.d.ts +10 -0
- package/lib/cjs/helpers/validateMidnightMarket.js +24 -0
- package/lib/cjs/helpers/validateOfferSides.d.ts +21 -0
- package/lib/cjs/helpers/validateOfferSides.js +36 -0
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +29 -0
- package/lib/cjs/helpers/validateRequirementSpender.js +49 -0
- package/lib/cjs/helpers/validateTakeableOffers.d.ts +18 -0
- package/lib/cjs/helpers/validateTakeableOffers.js +35 -0
- package/lib/cjs/midnight-api.d.ts +1 -0
- package/lib/cjs/midnight-api.js +17 -0
- package/lib/cjs/types/action.d.ts +189 -23
- package/lib/cjs/types/action.js +27 -7
- package/lib/cjs/types/client.d.ts +3 -2
- package/lib/cjs/types/error.d.ts +288 -114
- package/lib/cjs/types/error.js +259 -175
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +12 -2
- package/lib/esm/abis.d.ts +1 -0
- package/lib/esm/abis.js +1 -0
- package/lib/esm/actions/blue/borrow.d.ts +3 -7
- package/lib/esm/actions/blue/borrow.js +6 -10
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +3 -4
- package/lib/esm/actions/blue/buildReallocationActions.js +3 -4
- package/lib/esm/actions/blue/refinance.d.ts +4 -8
- package/lib/esm/actions/blue/refinance.js +11 -15
- package/lib/esm/actions/blue/repay.d.ts +2 -5
- package/lib/esm/actions/blue/repay.js +2 -5
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -6
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +5 -8
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +2 -5
- package/lib/esm/actions/blue/resolveRepayFunding.js +16 -13
- package/lib/esm/actions/blue/supply.d.ts +2 -4
- package/lib/esm/actions/blue/supply.js +7 -9
- package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -3
- package/lib/esm/actions/blue/supplyCollateral.js +6 -7
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +4 -9
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +10 -15
- package/lib/esm/actions/blue/withdraw.d.ts +9 -7
- package/lib/esm/actions/blue/withdraw.js +19 -11
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.js +3 -3
- package/lib/esm/actions/index.d.ts +2 -0
- package/lib/esm/actions/index.js +1 -0
- package/lib/esm/actions/midnight/authorization.d.ts +37 -0
- package/lib/esm/actions/midnight/authorization.js +65 -0
- package/lib/esm/actions/midnight/cancelOffer.d.ts +38 -0
- package/lib/esm/actions/midnight/cancelOffer.js +69 -0
- package/lib/esm/actions/midnight/index.d.ts +11 -0
- package/lib/esm/actions/midnight/index.js +11 -0
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +52 -0
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +68 -0
- package/lib/esm/actions/midnight/redeem.d.ts +43 -0
- package/lib/esm/actions/midnight/redeem.js +75 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +53 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +117 -0
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +40 -0
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +55 -0
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +45 -0
- package/lib/esm/actions/midnight/supplyCollateral.js +79 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +51 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +124 -0
- package/lib/esm/actions/midnight/takeBorrow.d.ts +57 -0
- package/lib/esm/actions/midnight/takeBorrow.js +106 -0
- package/lib/esm/actions/midnight/takeLend.d.ts +57 -0
- package/lib/esm/actions/midnight/takeLend.js +106 -0
- package/lib/esm/actions/midnight/types.d.ts +39 -0
- package/lib/esm/actions/midnight/types.js +12 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +6 -17
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +5 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +12 -16
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +2 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +12 -29
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +5 -17
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +10 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +10 -4
- package/lib/esm/actions/requirements/index.d.ts +1 -0
- package/lib/esm/actions/requirements/index.js +1 -0
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +49 -0
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +72 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +44 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +74 -0
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +42 -0
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +66 -0
- package/lib/esm/actions/requirements/midnight/index.d.ts +3 -0
- package/lib/esm/actions/requirements/midnight/index.js +3 -0
- package/lib/esm/actions/vaultV1/deposit.d.ts +3 -4
- package/lib/esm/actions/vaultV1/deposit.js +8 -9
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +2 -3
- package/lib/esm/actions/vaultV1/migrateToV2.js +6 -7
- package/lib/esm/actions/vaultV1/redeem.d.ts +1 -1
- package/lib/esm/actions/vaultV1/redeem.js +3 -3
- package/lib/esm/actions/vaultV1/withdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV1/withdraw.js +3 -3
- package/lib/esm/actions/vaultV2/deposit.d.ts +3 -4
- package/lib/esm/actions/vaultV2/deposit.js +8 -9
- package/lib/esm/actions/vaultV2/forceRedeem.d.ts +2 -3
- package/lib/esm/actions/vaultV2/forceRedeem.js +4 -5
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
- package/lib/esm/actions/vaultV2/redeem.d.ts +1 -1
- package/lib/esm/actions/vaultV2/redeem.js +3 -3
- package/lib/esm/actions/vaultV2/withdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/withdraw.js +3 -3
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +6 -3
- package/lib/esm/constants.d.ts +1 -0
- package/lib/esm/constants.js +1 -0
- package/lib/esm/entities/blue/blue.d.ts +5 -5
- package/lib/esm/entities/blue/blue.js +107 -88
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/index.d.ts +2 -0
- package/lib/esm/entities/midnight/index.js +2 -0
- package/lib/esm/entities/midnight/midnight.d.ts +402 -0
- package/lib/esm/entities/midnight/midnight.js +1032 -0
- package/lib/esm/entities/midnight/types.d.ts +164 -0
- package/lib/esm/entities/midnight/types.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.js +13 -20
- package/lib/esm/entities/vaultV2/vaultV2.js +9 -11
- package/lib/esm/errors.d.ts +1 -0
- package/lib/esm/errors.js +1 -0
- package/lib/esm/helpers/encodeDeallocation.d.ts +1 -0
- package/lib/esm/helpers/encodeDeallocation.js +3 -2
- package/lib/esm/helpers/index.d.ts +4 -1
- package/lib/esm/helpers/index.js +4 -1
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +34 -0
- package/lib/esm/helpers/signAndVerifyTypedData.js +54 -0
- package/lib/esm/helpers/validate.d.ts +40 -1
- package/lib/esm/helpers/validate.js +46 -5
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +15 -0
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +28 -0
- package/lib/esm/helpers/validateMidnightMarket.d.ts +10 -0
- package/lib/esm/helpers/validateMidnightMarket.js +20 -0
- package/lib/esm/helpers/validateOfferSides.d.ts +21 -0
- package/lib/esm/helpers/validateOfferSides.js +32 -0
- package/lib/esm/helpers/validateRequirementSpender.d.ts +29 -0
- package/lib/esm/helpers/validateRequirementSpender.js +45 -0
- package/lib/esm/helpers/validateTakeableOffers.d.ts +18 -0
- package/lib/esm/helpers/validateTakeableOffers.js +31 -0
- package/lib/esm/midnight-api.d.ts +1 -0
- package/lib/esm/midnight-api.js +1 -0
- package/lib/esm/types/action.d.ts +189 -23
- package/lib/esm/types/action.js +26 -7
- package/lib/esm/types/client.d.ts +3 -2
- package/lib/esm/types/error.d.ts +288 -114
- package/lib/esm/types/error.js +232 -149
- package/lib/esm/utils.d.ts +1 -0
- package/lib/esm/utils.js +1 -0
- package/package.json +13 -4
package/lib/esm/types/error.js
CHANGED
|
@@ -1,4 +1,102 @@
|
|
|
1
1
|
import { UnknownDataError } from "@morpho-org/blue-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a morpho-sdk input that must be non-negative is negative.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { NegativeInputError } from "@morpho-org/morpho-sdk";
|
|
8
|
+
*
|
|
9
|
+
* const error = new NegativeInputError("amount", -1n);
|
|
10
|
+
* if (error instanceof NegativeInputError) {
|
|
11
|
+
* console.error(error.field, error.value);
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class NegativeInputError extends Error {
|
|
16
|
+
field;
|
|
17
|
+
value;
|
|
18
|
+
/**
|
|
19
|
+
* @param field - Public input field whose value is invalid.
|
|
20
|
+
* @param value - Negative bigint supplied for the field.
|
|
21
|
+
*/
|
|
22
|
+
constructor(field, value) {
|
|
23
|
+
super(`Input "${field}" must be non-negative, got "${value}".`);
|
|
24
|
+
this.field = field;
|
|
25
|
+
this.value = value;
|
|
26
|
+
this.name = "NegativeInputError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Thrown when a morpho-sdk input that must be positive is zero or negative.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { NonPositiveInputError } from "@morpho-org/morpho-sdk";
|
|
35
|
+
*
|
|
36
|
+
* const error = new NonPositiveInputError("shares", 0n);
|
|
37
|
+
* if (error instanceof NonPositiveInputError) {
|
|
38
|
+
* console.error(error.field, error.value);
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class NonPositiveInputError extends Error {
|
|
43
|
+
field;
|
|
44
|
+
value;
|
|
45
|
+
/**
|
|
46
|
+
* @param field - Public input field whose value is invalid.
|
|
47
|
+
* @param value - Zero or negative bigint supplied for the field.
|
|
48
|
+
*/
|
|
49
|
+
constructor(field, value) {
|
|
50
|
+
super(`Input "${field}" must be positive, got "${value}".`);
|
|
51
|
+
this.field = field;
|
|
52
|
+
this.value = value;
|
|
53
|
+
this.name = "NonPositiveInputError";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
57
|
+
export const NonPositiveAssetAmountError = NonPositiveInputError;
|
|
58
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
59
|
+
export const NonPositiveSharesAmountError = NonPositiveInputError;
|
|
60
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
61
|
+
export const NonPositiveMaxSharePriceError = NonPositiveInputError;
|
|
62
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
63
|
+
export const ZeroDepositAmountError = NonPositiveInputError;
|
|
64
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
65
|
+
export const NonPositiveBorrowAmountError = NonPositiveInputError;
|
|
66
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
67
|
+
export const ZeroCollateralAmountError = NonPositiveInputError;
|
|
68
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
69
|
+
export const NonPositiveReallocationAmountError = NonPositiveInputError;
|
|
70
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
71
|
+
export const NonPositiveRepayAmountError = NonPositiveInputError;
|
|
72
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
73
|
+
export const NonPositiveRepayMaxSharePriceError = NonPositiveInputError;
|
|
74
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
75
|
+
export const NonPositiveWithdrawCollateralAmountError = NonPositiveInputError;
|
|
76
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
77
|
+
export const ZeroSupplyAmountError = NonPositiveInputError;
|
|
78
|
+
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
79
|
+
export const NonPositiveWithdrawAmountError = NonPositiveInputError;
|
|
80
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
81
|
+
export const NegativeSlippageToleranceError = NegativeInputError;
|
|
82
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
83
|
+
export const NegativeNativeAmountError = NegativeInputError;
|
|
84
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
85
|
+
export const NegativeReallocationFeeError = NegativeInputError;
|
|
86
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
87
|
+
export const NonPositiveMinBorrowSharePriceError = NegativeInputError;
|
|
88
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
89
|
+
export const NegativeSupplyAmountError = NegativeInputError;
|
|
90
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
91
|
+
export const NegativeSupplyMaxSharePriceError = NegativeInputError;
|
|
92
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
93
|
+
export const NegativeWithdrawMinSharePriceError = NegativeInputError;
|
|
94
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
95
|
+
export const NegativeMinSharePriceError = NegativeInputError;
|
|
96
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
97
|
+
export const NegativeBorrowSharesError = NegativeInputError;
|
|
98
|
+
/** @deprecated Use {@link NegativeInputError}. */
|
|
99
|
+
export const NegativeMaxRepaySharePriceError = NegativeInputError;
|
|
2
100
|
/**
|
|
3
101
|
* Typed errors thrown while encoding supported Bundler3 actions.
|
|
4
102
|
*
|
|
@@ -75,21 +173,21 @@ export var BundlerErrors;
|
|
|
75
173
|
/**
|
|
76
174
|
* Thrown when `buildTx` receives more than one requirement signature of the same kind.
|
|
77
175
|
*
|
|
78
|
-
* A bundled path consumes at most one
|
|
79
|
-
*
|
|
176
|
+
* A bundled path consumes at most one signature per accepted kind; passing several of the same
|
|
177
|
+
* kind is ambiguous and would silently drop all but the first, so it is rejected instead.
|
|
80
178
|
*
|
|
81
179
|
* @example
|
|
82
180
|
* ```ts
|
|
83
181
|
* import { AmbiguousRequirementSignaturesError } from "@morpho-org/morpho-sdk";
|
|
84
182
|
*
|
|
85
183
|
* if (error instanceof AmbiguousRequirementSignaturesError) {
|
|
86
|
-
* // Pass a single
|
|
184
|
+
* // Pass a single signature per accepted kind to buildTx.
|
|
87
185
|
* }
|
|
88
186
|
* ```
|
|
89
187
|
*/
|
|
90
188
|
export class AmbiguousRequirementSignaturesError extends Error {
|
|
91
189
|
/**
|
|
92
|
-
* @param kind - The over-supplied signature kind
|
|
190
|
+
* @param kind - The over-supplied signature kind.
|
|
93
191
|
* @param count - How many signatures of that kind were received.
|
|
94
192
|
*/
|
|
95
193
|
constructor(kind, count) {
|
|
@@ -97,9 +195,8 @@ export class AmbiguousRequirementSignaturesError extends Error {
|
|
|
97
195
|
}
|
|
98
196
|
}
|
|
99
197
|
/**
|
|
100
|
-
* Thrown when `buildTx` receives a requirement signature of a kind the operation does not consume
|
|
101
|
-
*
|
|
102
|
-
* authorization or permit from being silently ignored.
|
|
198
|
+
* Thrown when `buildTx` receives a requirement signature of a kind the operation does not consume.
|
|
199
|
+
* Surfacing it prevents a signed requirement from being silently ignored.
|
|
103
200
|
*
|
|
104
201
|
* @example
|
|
105
202
|
* ```ts
|
|
@@ -112,30 +209,12 @@ export class AmbiguousRequirementSignaturesError extends Error {
|
|
|
112
209
|
*/
|
|
113
210
|
export class UnexpectedRequirementSignatureError extends Error {
|
|
114
211
|
/**
|
|
115
|
-
* @param kind - The unexpected signature kind
|
|
212
|
+
* @param kind - The unexpected signature kind.
|
|
116
213
|
*/
|
|
117
214
|
constructor(kind) {
|
|
118
215
|
super(`Received a ${kind} signature that this operation does not consume. Remove it from the buildTx signatures array.`);
|
|
119
216
|
}
|
|
120
217
|
}
|
|
121
|
-
/** Thrown when an asset amount is required to be positive but is zero or negative. */
|
|
122
|
-
export class NonPositiveAssetAmountError extends Error {
|
|
123
|
-
constructor(origin) {
|
|
124
|
-
super(`Asset amount must be positive for address ${origin}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/** Thrown when a shares amount is required to be positive but is zero or negative. */
|
|
128
|
-
export class NonPositiveSharesAmountError extends Error {
|
|
129
|
-
constructor(vault) {
|
|
130
|
-
super(`Shares amount must be positive for address: ${vault}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/** Thrown when a vault deposit's `maxSharePrice` slippage bound is zero or negative. */
|
|
134
|
-
export class NonPositiveMaxSharePriceError extends Error {
|
|
135
|
-
constructor(vault) {
|
|
136
|
-
super(`Max share price must be positive for vault: ${vault}`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
218
|
/** Thrown when a viem client's account address does not match the address required by the call. */
|
|
140
219
|
export class AddressMismatchError extends Error {
|
|
141
220
|
constructor(clientAddress, argsAddress) {
|
|
@@ -148,6 +227,12 @@ export class ChainIdMismatchError extends Error {
|
|
|
148
227
|
super(`Chain ID mismatch between client: ${clientChainId} and args: ${argsChainId}`);
|
|
149
228
|
}
|
|
150
229
|
}
|
|
230
|
+
/** Thrown when a runtime crypto API is required but unavailable. */
|
|
231
|
+
export class CryptoUnavailableError extends Error {
|
|
232
|
+
constructor(feature) {
|
|
233
|
+
super(`Crypto API is required for ${feature} but is unavailable.`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
151
236
|
/** Thrown when the viem client is missing a property the call requires (e.g. `account.address`). */
|
|
152
237
|
export class MissingClientPropertyError extends Error {
|
|
153
238
|
constructor(property) {
|
|
@@ -174,16 +259,18 @@ export class UnsupportedErc20ApprovalSpenderError extends Error {
|
|
|
174
259
|
super(`Requirement spender "${params.spender}" is not supported on chain "${params.chainId}". Use "${supported}".`);
|
|
175
260
|
}
|
|
176
261
|
}
|
|
177
|
-
/** Thrown when a
|
|
178
|
-
export class
|
|
179
|
-
constructor(
|
|
180
|
-
super(`
|
|
262
|
+
/** Thrown when a Midnight authorization requirement targets an unsupported operator. */
|
|
263
|
+
export class UnsupportedMidnightAuthorizationTargetError extends Error {
|
|
264
|
+
constructor(params) {
|
|
265
|
+
super(`Midnight authorization target "${params.authorized}" is not supported on chain "${params.chainId}". Use "${params.supportedTargets.join('", "')}".`);
|
|
181
266
|
}
|
|
182
267
|
}
|
|
183
|
-
/** Thrown when a Morpho accrual position
|
|
268
|
+
/** Thrown when a Morpho accrual position required by a call is missing. */
|
|
184
269
|
export class MissingAccrualPositionError extends Error {
|
|
185
270
|
constructor(market) {
|
|
186
|
-
super(
|
|
271
|
+
super(market == null
|
|
272
|
+
? "Accrual position is missing. Fetch the position data and try again."
|
|
273
|
+
: `Accrual position is missing for market: ${market}`);
|
|
187
274
|
}
|
|
188
275
|
}
|
|
189
276
|
/** Thrown when a slippage tolerance exceeds `MAX_SLIPPAGE_TOLERANCE` (10%). */
|
|
@@ -210,6 +297,18 @@ export class DepositAssetMismatchError extends Error {
|
|
|
210
297
|
super(`Deposit asset "${depositAsset}" does not match requirement signature asset "${signatureAsset}"`);
|
|
211
298
|
}
|
|
212
299
|
}
|
|
300
|
+
/** Thrown when a deposit's owner differs from the owner the supplied permit / permit2 signature was issued for. */
|
|
301
|
+
export class DepositOwnerMismatchError extends Error {
|
|
302
|
+
constructor(depositOwner, signatureOwner) {
|
|
303
|
+
super(`Deposit owner "${depositOwner}" does not match requirement signature owner "${signatureOwner}"`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/** Thrown when a deposit's spender differs from the spender the supplied permit / permit2 signature was issued for. */
|
|
307
|
+
export class DepositSpenderMismatchError extends Error {
|
|
308
|
+
constructor(depositSpender, signatureSpender) {
|
|
309
|
+
super(`Deposit spender "${depositSpender}" does not match requirement signature spender "${signatureSpender}"`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
213
312
|
/** Thrown when a `permit2` requirement signature is missing the `expiration` field. */
|
|
214
313
|
export class Permit2ExpirationMissingError extends Error {
|
|
215
314
|
constructor() {
|
|
@@ -228,36 +327,12 @@ export class ChainWNativeMissingError extends Error {
|
|
|
228
327
|
super(`Chain ${chainId} does not have a configured wrapped native token (wNative)`);
|
|
229
328
|
}
|
|
230
329
|
}
|
|
231
|
-
/** Thrown when `nativeAmount` is negative. */
|
|
232
|
-
export class NegativeNativeAmountError extends Error {
|
|
233
|
-
constructor(nativeAmount) {
|
|
234
|
-
super(`Native amount must not be negative, got ${nativeAmount}`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
/** Thrown when both `amount` and `nativeAmount` resolve to zero on a vault deposit. */
|
|
238
|
-
export class ZeroDepositAmountError extends Error {
|
|
239
|
-
constructor(vault) {
|
|
240
|
-
super(`Total deposit amount must be positive for vault: ${vault}. Both amount and nativeAmount are zero.`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
330
|
/** Thrown when a vault entity's address does not match the vault address embedded in the call's args. */
|
|
244
331
|
export class VaultAddressMismatchError extends Error {
|
|
245
332
|
constructor(vaultAddress, argsVaultAddress) {
|
|
246
333
|
super(`Vault address mismatch between vault: ${vaultAddress} and args: ${argsVaultAddress}`);
|
|
247
334
|
}
|
|
248
335
|
}
|
|
249
|
-
/** Thrown when a market borrow amount is zero or negative. */
|
|
250
|
-
export class NonPositiveBorrowAmountError extends Error {
|
|
251
|
-
constructor(market) {
|
|
252
|
-
super(`Borrow amount must be positive for market: ${market}`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
/** Thrown when both `amount` and `nativeAmount` resolve to zero on a market collateral supply. */
|
|
256
|
-
export class ZeroCollateralAmountError extends Error {
|
|
257
|
-
constructor(market) {
|
|
258
|
-
super(`Total collateral amount must be positive for market: ${market}. Both amount and nativeAmount are zero.`);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
336
|
/** Thrown when an action uses `nativeAmount` but the target asset is not the chain's wNative. */
|
|
262
337
|
export class NativeAmountOnNonWNativeAssetError extends Error {
|
|
263
338
|
constructor(asset, wNative) {
|
|
@@ -290,24 +365,12 @@ export class AccrualPositionUserMismatchError extends Error {
|
|
|
290
365
|
super(`Accrual position user ${positionUser} does not match expected user ${expectedUser}`);
|
|
291
366
|
}
|
|
292
367
|
}
|
|
293
|
-
/** Thrown when a reallocation's fee is negative. */
|
|
294
|
-
export class NegativeReallocationFeeError extends Error {
|
|
295
|
-
constructor(vault) {
|
|
296
|
-
super(`Reallocation fee must not be negative for vault: ${vault}`);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
368
|
/** Thrown when a reallocation has no withdrawals. */
|
|
300
369
|
export class EmptyReallocationWithdrawalsError extends Error {
|
|
301
370
|
constructor(vault) {
|
|
302
371
|
super(`Reallocation withdrawals list cannot be empty for vault: ${vault}`);
|
|
303
372
|
}
|
|
304
373
|
}
|
|
305
|
-
/** Thrown when a reallocation withdrawal amount is zero or negative. */
|
|
306
|
-
export class NonPositiveReallocationAmountError extends Error {
|
|
307
|
-
constructor(vault, market) {
|
|
308
|
-
super(`Reallocation withdrawal amount must be positive for vault ${vault} on market ${market}`);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
374
|
/** Thrown when a reallocation withdrawal references the operation's target market (which would be a no-op or self-deal). */
|
|
312
375
|
export class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
313
376
|
constructor(vault, marketId) {
|
|
@@ -320,19 +383,6 @@ export class UnsortedReallocationWithdrawalsError extends Error {
|
|
|
320
383
|
super(`Reallocation withdrawals must be strictly sorted by market ID for vault ${vault}. Market ${marketId} is out of order.`);
|
|
321
384
|
}
|
|
322
385
|
}
|
|
323
|
-
/**
|
|
324
|
-
* Thrown when a market repay's `transferAmount` is zero or negative.
|
|
325
|
-
*
|
|
326
|
-
* @deprecated No longer thrown. The repay action layer no longer validates `transferAmount`
|
|
327
|
-
* directly (assets mode uses {@link NonPositiveRepayAmountError}; shares mode allows a zero
|
|
328
|
-
* ERC-20 transfer for fully-native repays). Retained as exported API for back-compat; slated
|
|
329
|
-
* for removal in a future major.
|
|
330
|
-
*/
|
|
331
|
-
export class NonPositiveTransferAmountError extends Error {
|
|
332
|
-
constructor(market) {
|
|
333
|
-
super(`Transfer amount must be positive for market: ${market}`);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
386
|
/**
|
|
337
387
|
* Thrown when a market repay in assets mode has `transferAmount !== amount + nativeAmount` — the
|
|
338
388
|
* pre-resolved ERC-20 pull plus the wrapped native must equal the assets repaid, so the bundle
|
|
@@ -343,39 +393,12 @@ export class TransferAmountNotEqualToAssetsError extends Error {
|
|
|
343
393
|
super(`Transfer amount ${params.transferAmount} is not equal to repay assets ${params.assets} for market: ${params.market}. In assets mode, transferAmount must equal amount + nativeAmount.`);
|
|
344
394
|
}
|
|
345
395
|
}
|
|
346
|
-
/**
|
|
347
|
-
* Thrown when a shares-mode repay's `nativeAmount` exceeds `transferAmount`, which
|
|
348
|
-
* would make the ERC-20 amount to pull (`transferAmount − nativeAmount`) negative.
|
|
349
|
-
*/
|
|
350
|
-
export class NativeAmountExceedsTransferAmountError extends Error {
|
|
351
|
-
constructor(params) {
|
|
352
|
-
super(`Native amount ${params.nativeAmount} exceeds transfer amount ${params.transferAmount} for market: ${params.market}. Reduce nativeAmount to at most transferAmount.`);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
396
|
/** Thrown when a market repay specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
|
|
356
397
|
export class MutuallyExclusiveRepayAmountsError extends Error {
|
|
357
398
|
constructor(market) {
|
|
358
399
|
super(`Exactly one of assets or shares must be non-zero for market: ${market}. Both were provided.`);
|
|
359
400
|
}
|
|
360
401
|
}
|
|
361
|
-
/** Thrown when a market repay has non-positive amounts: both `assets` and `shares` are zero, or either is negative. */
|
|
362
|
-
export class NonPositiveRepayAmountError extends Error {
|
|
363
|
-
constructor(market) {
|
|
364
|
-
super(`Repay amount must be positive for market: ${market}`);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
/** Thrown when a market repay's `maxSharePrice` slippage bound is zero or negative. */
|
|
368
|
-
export class NonPositiveRepayMaxSharePriceError extends Error {
|
|
369
|
-
constructor(market) {
|
|
370
|
-
super(`Max share price must be positive for market: ${market}`);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
/** Thrown when a market `withdrawCollateral` amount is zero or negative. */
|
|
374
|
-
export class NonPositiveWithdrawCollateralAmountError extends Error {
|
|
375
|
-
constructor(market) {
|
|
376
|
-
super(`Withdraw collateral amount must be positive for market: ${market}`);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
402
|
/** Thrown when a withdraw amount exceeds the position's available collateral. */
|
|
380
403
|
export class WithdrawExceedsCollateralError extends Error {
|
|
381
404
|
constructor(params) {
|
|
@@ -492,40 +515,118 @@ export class UnknownReallocationPositionError extends UnknownDataError {
|
|
|
492
515
|
this.marketId = marketId;
|
|
493
516
|
}
|
|
494
517
|
}
|
|
495
|
-
/** Thrown when a
|
|
496
|
-
export class
|
|
497
|
-
constructor(
|
|
498
|
-
super(`
|
|
518
|
+
/** Thrown when a Midnight amount exceeds the maximum offer-cap value accepted onchain. */
|
|
519
|
+
export class MidnightAmountExceedsMaxOfferCapError extends Error {
|
|
520
|
+
constructor(params) {
|
|
521
|
+
super(`Midnight ${params.label} "${params.amount}" exceeds maximum offer cap "${params.maxOfferCap}". Reduce the amount to the maximum offer cap or less.`);
|
|
499
522
|
}
|
|
500
523
|
}
|
|
501
|
-
/** Thrown when a
|
|
502
|
-
export class
|
|
503
|
-
constructor(
|
|
504
|
-
super(
|
|
524
|
+
/** Thrown when a Midnight flow needs at least one takeable offer. */
|
|
525
|
+
export class EmptyMidnightTakeableOffersError extends Error {
|
|
526
|
+
constructor() {
|
|
527
|
+
super("Midnight takeable offers cannot be empty. Refresh the quote and try again.");
|
|
505
528
|
}
|
|
506
529
|
}
|
|
507
|
-
/** Thrown when a
|
|
508
|
-
export class
|
|
509
|
-
constructor(
|
|
510
|
-
super(`
|
|
530
|
+
/** Thrown when a Midnight offer has the wrong maker side for the requested flow. */
|
|
531
|
+
export class MidnightOfferSideMismatchError extends Error {
|
|
532
|
+
constructor(params) {
|
|
533
|
+
super(`Midnight offer "${params.index}" has buy="${params.actualBuy}", expected "${params.expectedBuy}". Use the matching flow or rebuild the offer list.`);
|
|
511
534
|
}
|
|
512
535
|
}
|
|
513
|
-
/** Thrown when
|
|
514
|
-
export class
|
|
515
|
-
constructor(
|
|
516
|
-
super(`
|
|
536
|
+
/** Thrown when a Midnight maker offer belongs to a different account than the action flow. */
|
|
537
|
+
export class MidnightOfferMakerMismatchError extends Error {
|
|
538
|
+
constructor(params) {
|
|
539
|
+
super(`Midnight offer "${params.index}" belongs to maker "${params.actualMaker}", expected "${params.expectedMaker}". Rebuild the offer set for the active account.`);
|
|
517
540
|
}
|
|
518
541
|
}
|
|
519
|
-
/** Thrown when a
|
|
520
|
-
export class
|
|
521
|
-
constructor(
|
|
522
|
-
super(`
|
|
542
|
+
/** Thrown when a Midnight maker offer targets a different chain than the action flow. */
|
|
543
|
+
export class MidnightOfferMarketChainMismatchError extends Error {
|
|
544
|
+
constructor(params) {
|
|
545
|
+
super(`Midnight offer "${params.index}" targets chain "${params.actualChainId}", expected "${params.expectedChainId}". Rebuild the offer set for the selected chain.`);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
/** Thrown when a Midnight maker offer targets a different Midnight contract than the action flow. */
|
|
549
|
+
export class MidnightOfferMarketAddressMismatchError extends Error {
|
|
550
|
+
constructor(params) {
|
|
551
|
+
super(`Midnight offer "${params.index}" targets Midnight "${params.actualMidnight}", expected "${params.expectedMidnight}". Rebuild the offer set for the selected chain.`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
/** Thrown when a Midnight market targets a different deployment than the selected chain. */
|
|
555
|
+
export class MidnightMarketAddressMismatchError extends Error {
|
|
556
|
+
constructor(params) {
|
|
557
|
+
super(`Midnight market targets contract "${params.actualMidnight}", expected "${params.expectedMidnight}". Use market data from the selected chain deployment.`);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
/** Thrown when a Midnight make-lend offer does not use the approved loan token. */
|
|
561
|
+
export class MidnightOfferMarketLoanTokenMismatchError extends Error {
|
|
562
|
+
constructor(params) {
|
|
563
|
+
super(`Midnight offer "${params.index}" uses loan token "${params.actualLoanToken}", expected "${params.expectedLoanToken}". Rebuild the lend offer set for the approved loan token.`);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
/** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
|
|
567
|
+
export class MidnightTakeableOfferMarketMismatchError extends Error {
|
|
568
|
+
constructor(params) {
|
|
569
|
+
super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
/** Thrown when a Midnight offer tree uses an unsupported ratifier address. */
|
|
573
|
+
export class UnknownMidnightRatifierError extends Error {
|
|
574
|
+
constructor(params) {
|
|
575
|
+
super(`Midnight offer tree uses ratifier "${params.ratifier}", expected "${params.ecrecoverRatifier}" or "${params.setterRatifier}". Rebuild the tree with a supported ratifier.`);
|
|
523
576
|
}
|
|
524
577
|
}
|
|
525
|
-
/** Thrown when a
|
|
526
|
-
export class
|
|
578
|
+
/** Thrown when a Midnight Ecrecover maker flow builds the submit transaction before signing. */
|
|
579
|
+
export class MissingMidnightOfferRootSignatureError extends Error {
|
|
580
|
+
constructor() {
|
|
581
|
+
super("Midnight offer root signature is missing. Sign the offer-root requirement before building the submit transaction.");
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
/** Thrown when a Midnight offer-root signature does not match the prepared tree root. */
|
|
585
|
+
export class MidnightOfferRootMismatchError extends Error {
|
|
586
|
+
constructor(params) {
|
|
587
|
+
super(`Midnight offer root mismatch: expected "${params.expectedRoot}", got "${params.actualRoot}". Rebuild the flow and sign again.`);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
/** Thrown when a Midnight offer-root signature was produced by another maker account. */
|
|
591
|
+
export class MidnightOfferRootOwnerMismatchError extends Error {
|
|
592
|
+
constructor(params) {
|
|
593
|
+
super(`Midnight offer root owner mismatch: expected "${params.expectedOwner}", got "${params.actualOwner}". Rebuild the flow and sign again.`);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/** Thrown when a Midnight offer-root signature targets another ratifier. */
|
|
597
|
+
export class MidnightOfferRootRatifierMismatchError extends Error {
|
|
598
|
+
constructor(params) {
|
|
599
|
+
super(`Midnight offer root ratifier mismatch: expected "${params.expectedRatifier}", got "${params.actualRatifier}". Rebuild the flow and sign again.`);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
/** Thrown when a Midnight offer-root signature was produced for another offer count. */
|
|
603
|
+
export class MidnightOfferRootOfferCountMismatchError extends Error {
|
|
604
|
+
constructor(params) {
|
|
605
|
+
super(`Midnight offer root offer-count mismatch: expected "${params.expectedOffers}", got "${params.actualOffers}". Rebuild the flow and sign again.`);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
/** Thrown when a Midnight offer-root signature was not prepared by this maker flow. */
|
|
609
|
+
export class UnpreparedMidnightOfferRootSignatureError extends Error {
|
|
610
|
+
constructor() {
|
|
611
|
+
super("Midnight offer root signature was not prepared for this offer tree. Sign this flow's offer-root requirement before building the submit transaction.");
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/** Thrown when a Midnight redeem flow finds no credit units for the user. */
|
|
615
|
+
export class NoMidnightCreditToRedeemError extends Error {
|
|
527
616
|
constructor(market) {
|
|
528
|
-
super(`
|
|
617
|
+
super(`No Midnight credit is available to redeem for market "${market}".`);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/** Thrown when a Midnight redeem amount exceeds the user's accrued credit. */
|
|
621
|
+
export class MidnightRedeemExceedsCreditError extends Error {
|
|
622
|
+
constructor(params) {
|
|
623
|
+
super(`Midnight redeem amount exceeds position credit on market "${params.market}": units "${params.units}", credit "${params.credit}". Redeem less or refresh the position data.`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
/** Thrown when a Midnight redeem amount exceeds the market's currently withdrawable liquidity. */
|
|
627
|
+
export class InsufficientMidnightWithdrawableLiquidityError extends Error {
|
|
628
|
+
constructor(params) {
|
|
629
|
+
super(`Midnight withdrawable liquidity is insufficient on market "${params.market}": units "${params.units}", withdrawable "${params.withdrawable}". Try again later or redeem less.`);
|
|
529
630
|
}
|
|
530
631
|
}
|
|
531
632
|
/** Thrown when a loan-asset withdraw specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
|
|
@@ -566,30 +667,12 @@ export class VaultAssetMismatchError extends Error {
|
|
|
566
667
|
super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
|
|
567
668
|
}
|
|
568
669
|
}
|
|
569
|
-
/** Thrown when a vault redeem's `minSharePrice` slippage bound is negative. */
|
|
570
|
-
export class NegativeMinSharePriceError extends Error {
|
|
571
|
-
constructor(vault) {
|
|
572
|
-
super(`Min share price must be non-negative for vault: ${vault}`);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
/** Thrown when a refinance's `borrowShares` argument is negative. */
|
|
576
|
-
export class NegativeBorrowSharesError extends Error {
|
|
577
|
-
constructor(market) {
|
|
578
|
-
super(`Borrow shares must be non-negative for market: ${market}`);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
670
|
/** Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive). */
|
|
582
671
|
export class BorrowAmountAndSharesExclusiveError extends Error {
|
|
583
672
|
constructor(market) {
|
|
584
673
|
super(`Exactly one of borrowAssets or borrowShares must be non-zero for market: ${market}. Both were provided.`);
|
|
585
674
|
}
|
|
586
675
|
}
|
|
587
|
-
/** Thrown when a refinance's `maxRepaySharePrice` slippage bound is negative. */
|
|
588
|
-
export class NegativeMaxRepaySharePriceError extends Error {
|
|
589
|
-
constructor(market) {
|
|
590
|
-
super(`Max repay share price must be non-negative for market: ${market}`);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
676
|
/** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
|
|
594
677
|
export class RefinanceSameMarketError extends Error {
|
|
595
678
|
constructor(market) {
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
|
|
2
2
|
export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, } from "@morpho-org/blue-sdk";
|
|
3
3
|
export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
4
|
+
export { EcrecoverRatifierUtils, GroupUtils, OfferUtils, Payload, RatifierUtils, SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
|
|
4
5
|
export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, WithId, WithIndex, } from "@morpho-org/morpho-ts";
|
|
5
6
|
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";
|
|
6
7
|
export { computeReallocations } from "./helpers/computeReallocations.js";
|
package/lib/esm/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, } from "@morpho-org/blue-sdk";
|
|
2
2
|
export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
3
|
+
export { EcrecoverRatifierUtils, GroupUtils, OfferUtils, Payload, RatifierUtils, SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
|
|
3
4
|
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";
|
|
4
5
|
export { computeReallocations } from "./helpers/computeReallocations.js";
|
|
5
6
|
export { addTransactionMetadata } from "./helpers/metadata.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": "5.
|
|
4
|
+
"version": "5.3.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Foulks-Plb <https://x.com/FoulkPlb>"
|
|
@@ -75,6 +75,11 @@
|
|
|
75
75
|
"import": "./lib/esm/format.js",
|
|
76
76
|
"require": "./lib/cjs/format.js"
|
|
77
77
|
},
|
|
78
|
+
"./midnight-api": {
|
|
79
|
+
"types": "./lib/esm/midnight-api.d.ts",
|
|
80
|
+
"import": "./lib/esm/midnight-api.js",
|
|
81
|
+
"require": "./lib/cjs/midnight-api.js"
|
|
82
|
+
},
|
|
78
83
|
"./types": {
|
|
79
84
|
"types": "./lib/esm/types.d.ts",
|
|
80
85
|
"import": "./lib/esm/types.js",
|
|
@@ -118,6 +123,9 @@
|
|
|
118
123
|
"format": [
|
|
119
124
|
"lib/esm/format.d.ts"
|
|
120
125
|
],
|
|
126
|
+
"midnight-api": [
|
|
127
|
+
"lib/esm/midnight-api.d.ts"
|
|
128
|
+
],
|
|
121
129
|
"types": [
|
|
122
130
|
"lib/esm/types.d.ts"
|
|
123
131
|
],
|
|
@@ -138,8 +146,9 @@
|
|
|
138
146
|
"dependencies": {
|
|
139
147
|
"zod": "^4.4.3",
|
|
140
148
|
"@morpho-org/blue-sdk": "^6.3.1",
|
|
141
|
-
"@morpho-org/blue-sdk-viem": "^5.
|
|
142
|
-
"@morpho-org/morpho-ts": "^2.8.0"
|
|
149
|
+
"@morpho-org/blue-sdk-viem": "^5.2.0",
|
|
150
|
+
"@morpho-org/morpho-ts": "^2.8.0",
|
|
151
|
+
"@morpho-org/midnight-sdk": "^1.2.0"
|
|
143
152
|
},
|
|
144
153
|
"peerDependencies": {
|
|
145
154
|
"viem": "^2.0.0"
|
|
@@ -152,7 +161,7 @@
|
|
|
152
161
|
"vitest": "^4.1.9",
|
|
153
162
|
"@morpho-org/bundler-sdk-viem": "^5.0.3",
|
|
154
163
|
"@morpho-org/simulation-sdk": "^4.0.3",
|
|
155
|
-
"@morpho-org/test": "^2.8.
|
|
164
|
+
"@morpho-org/test": "^2.8.3"
|
|
156
165
|
},
|
|
157
166
|
"scripts": {
|
|
158
167
|
"prepublish": "$npm_execpath build",
|