@morpho-org/morpho-sdk 1.1.0 → 1.2.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/LICENSE +2 -2
- package/README.md +31 -33
- package/lib/cjs/actions/index.d.ts +4 -0
- package/lib/{actions → cjs/actions}/index.js +4 -4
- package/lib/cjs/actions/marketV1/borrow.d.ts +69 -0
- package/lib/cjs/actions/marketV1/borrow.js +97 -0
- package/lib/cjs/actions/marketV1/buildReallocationActions.d.ts +28 -0
- package/lib/cjs/actions/marketV1/buildReallocationActions.js +47 -0
- package/lib/cjs/actions/marketV1/index.d.ts +6 -0
- package/lib/{actions → cjs/actions}/marketV1/index.js +6 -6
- package/lib/cjs/actions/marketV1/repay.d.ts +89 -0
- package/lib/cjs/actions/marketV1/repay.js +134 -0
- package/lib/cjs/actions/marketV1/repayWithdrawCollateral.d.ts +103 -0
- package/lib/cjs/actions/marketV1/repayWithdrawCollateral.js +155 -0
- package/lib/cjs/actions/marketV1/supplyCollateral.d.ts +59 -0
- package/lib/cjs/actions/marketV1/supplyCollateral.js +116 -0
- package/lib/cjs/actions/marketV1/supplyCollateralBorrow.d.ts +91 -0
- package/lib/cjs/actions/marketV1/supplyCollateralBorrow.js +163 -0
- package/lib/cjs/actions/marketV1/withdrawCollateral.d.ts +49 -0
- package/lib/cjs/actions/marketV1/withdrawCollateral.js +72 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +36 -0
- package/lib/{actions → cjs/actions}/requirements/encode/encodeErc20Approval.js +25 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +52 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +108 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2.d.ts +44 -0
- package/lib/{actions → cjs/actions}/requirements/encode/encodeErc20Permit2.js +36 -4
- package/lib/cjs/actions/requirements/encode/index.d.ts +3 -0
- package/lib/{actions → cjs/actions}/requirements/encode/index.js +3 -3
- package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.d.ts +37 -0
- package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.js +71 -0
- package/lib/cjs/actions/requirements/getRequirements.d.ts +74 -0
- package/lib/cjs/actions/requirements/getRequirements.js +112 -0
- package/lib/cjs/actions/requirements/getRequirementsAction.d.ts +33 -0
- package/lib/{actions → cjs/actions}/requirements/getRequirementsAction.js +20 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +43 -0
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +63 -0
- package/lib/cjs/actions/requirements/getRequirementsPermit.d.ts +45 -0
- package/lib/cjs/actions/requirements/getRequirementsPermit.js +57 -0
- package/lib/cjs/actions/requirements/getRequirementsPermit2.d.ts +63 -0
- package/lib/cjs/actions/requirements/getRequirementsPermit2.js +85 -0
- package/lib/cjs/actions/requirements/index.d.ts +6 -0
- package/lib/{actions → cjs/actions}/requirements/index.js +6 -6
- package/lib/cjs/actions/vaultV1/deposit.d.ts +72 -0
- package/lib/cjs/actions/vaultV1/deposit.js +146 -0
- package/lib/cjs/actions/vaultV1/index.d.ts +4 -0
- package/lib/{actions → cjs/actions}/vaultV1/index.js +4 -4
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +84 -0
- package/lib/cjs/actions/vaultV1/migrateToV2.js +143 -0
- package/lib/cjs/actions/vaultV1/redeem.d.ts +39 -0
- package/lib/cjs/actions/vaultV1/redeem.js +57 -0
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +39 -0
- package/lib/cjs/actions/vaultV1/withdraw.js +57 -0
- package/lib/cjs/actions/vaultV2/deposit.d.ts +72 -0
- package/lib/cjs/actions/vaultV2/deposit.js +146 -0
- package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +63 -0
- package/lib/cjs/actions/vaultV2/forceRedeem.js +99 -0
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +58 -0
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +94 -0
- package/lib/cjs/actions/vaultV2/index.d.ts +5 -0
- package/lib/{actions → cjs/actions}/vaultV2/index.js +5 -5
- package/lib/cjs/actions/vaultV2/redeem.d.ts +40 -0
- package/lib/cjs/actions/vaultV2/redeem.js +58 -0
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +40 -0
- package/lib/cjs/actions/vaultV2/withdraw.js +58 -0
- package/lib/cjs/client/index.d.ts +2 -0
- package/lib/{client → cjs/client}/index.js +2 -2
- package/lib/cjs/client/morphoClient.d.ts +113 -0
- package/lib/cjs/client/morphoClient.js +123 -0
- package/lib/cjs/client/morphoViemExtension.d.ts +45 -0
- package/lib/cjs/client/morphoViemExtension.js +46 -0
- package/lib/cjs/entities/index.d.ts +3 -0
- package/lib/{entities → cjs/entities}/index.js +3 -3
- package/lib/cjs/entities/marketV1/index.d.ts +1 -0
- package/lib/{entities/vaultV1 → cjs/entities/marketV1}/index.js +1 -1
- package/lib/{entities → cjs/entities}/marketV1/marketV1.d.ts +9 -6
- package/lib/{entities → cjs/entities}/marketV1/marketV1.js +89 -87
- package/lib/cjs/entities/vaultV1/index.d.ts +1 -0
- package/lib/{entities/marketV1 → cjs/entities/vaultV1}/index.js +1 -1
- package/lib/{entities → cjs/entities}/vaultV1/vaultV1.d.ts +4 -8
- package/lib/{entities → cjs/entities}/vaultV1/vaultV1.js +39 -35
- package/lib/cjs/entities/vaultV2/index.d.ts +1 -0
- package/lib/{entities → cjs/entities}/vaultV2/index.js +1 -1
- package/lib/{entities → cjs/entities}/vaultV2/vaultV2.d.ts +2 -2
- package/lib/{entities → cjs/entities}/vaultV2/vaultV2.js +25 -24
- package/lib/{helpers → cjs/helpers}/computeReallocations.d.ts +1 -1
- package/lib/{helpers → cjs/helpers}/computeReallocations.js +2 -2
- package/lib/{helpers → cjs/helpers}/encodeDeallocation.d.ts +1 -1
- package/lib/{helpers → cjs/helpers}/encodeDeallocation.js +2 -2
- package/lib/{helpers → cjs/helpers}/index.d.ts +4 -4
- package/lib/{helpers → cjs/helpers}/index.js +19 -19
- package/lib/{helpers → cjs/helpers}/metadata.d.ts +1 -1
- package/lib/{helpers → cjs/helpers}/slippage.js +7 -7
- package/lib/{helpers → cjs/helpers}/validate.d.ts +1 -1
- package/lib/{helpers → cjs/helpers}/validate.js +33 -33
- package/lib/cjs/index.d.ts +5 -0
- package/lib/cjs/index.js +21 -0
- package/lib/cjs/package.json +1 -0
- package/lib/{types → cjs/types}/action.d.ts +1 -1
- package/lib/{types → cjs/types}/client.d.ts +6 -2
- package/lib/{types → cjs/types}/error.d.ts +46 -0
- package/lib/{types → cjs/types}/error.js +46 -0
- package/lib/cjs/types/index.d.ts +7 -0
- package/lib/cjs/types/index.js +23 -0
- package/lib/esm/actions/index.d.ts +4 -0
- package/lib/esm/actions/index.js +4 -0
- package/lib/esm/actions/marketV1/borrow.d.ts +69 -0
- package/lib/esm/actions/marketV1/borrow.js +93 -0
- package/lib/esm/actions/marketV1/buildReallocationActions.d.ts +28 -0
- package/lib/esm/actions/marketV1/buildReallocationActions.js +43 -0
- package/lib/esm/actions/marketV1/index.d.ts +6 -0
- package/lib/esm/actions/marketV1/index.js +6 -0
- package/lib/esm/actions/marketV1/repay.d.ts +89 -0
- package/lib/esm/actions/marketV1/repay.js +130 -0
- package/lib/esm/actions/marketV1/repayWithdrawCollateral.d.ts +103 -0
- package/lib/esm/actions/marketV1/repayWithdrawCollateral.js +151 -0
- package/lib/esm/actions/marketV1/supplyCollateral.d.ts +59 -0
- package/lib/esm/actions/marketV1/supplyCollateral.js +112 -0
- package/lib/esm/actions/marketV1/supplyCollateralBorrow.d.ts +91 -0
- package/lib/esm/actions/marketV1/supplyCollateralBorrow.js +159 -0
- package/lib/esm/actions/marketV1/withdrawCollateral.d.ts +49 -0
- package/lib/esm/actions/marketV1/withdrawCollateral.js +68 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +36 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +46 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +52 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +104 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2.d.ts +44 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2.js +98 -0
- package/lib/esm/actions/requirements/encode/index.d.ts +3 -0
- package/lib/esm/actions/requirements/encode/index.js +3 -0
- package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.d.ts +37 -0
- package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.js +67 -0
- package/lib/esm/actions/requirements/getRequirements.d.ts +74 -0
- package/lib/esm/actions/requirements/getRequirements.js +108 -0
- package/lib/esm/actions/requirements/getRequirementsAction.d.ts +33 -0
- package/lib/esm/actions/requirements/getRequirementsAction.js +76 -0
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +43 -0
- package/lib/esm/actions/requirements/getRequirementsApproval.js +59 -0
- package/lib/esm/actions/requirements/getRequirementsPermit.d.ts +45 -0
- package/lib/esm/actions/requirements/getRequirementsPermit.js +53 -0
- package/lib/esm/actions/requirements/getRequirementsPermit2.d.ts +63 -0
- package/lib/esm/actions/requirements/getRequirementsPermit2.js +81 -0
- package/lib/esm/actions/requirements/index.d.ts +6 -0
- package/lib/esm/actions/requirements/index.js +6 -0
- package/lib/esm/actions/vaultV1/deposit.d.ts +72 -0
- package/lib/esm/actions/vaultV1/deposit.js +142 -0
- package/lib/esm/actions/vaultV1/index.d.ts +4 -0
- package/lib/esm/actions/vaultV1/index.js +4 -0
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +84 -0
- package/lib/esm/actions/vaultV1/migrateToV2.js +139 -0
- package/lib/esm/actions/vaultV1/redeem.d.ts +39 -0
- package/lib/esm/actions/vaultV1/redeem.js +53 -0
- package/lib/esm/actions/vaultV1/withdraw.d.ts +39 -0
- package/lib/esm/actions/vaultV1/withdraw.js +53 -0
- package/lib/esm/actions/vaultV2/deposit.d.ts +72 -0
- package/lib/esm/actions/vaultV2/deposit.js +142 -0
- package/lib/esm/actions/vaultV2/forceRedeem.d.ts +63 -0
- package/lib/esm/actions/vaultV2/forceRedeem.js +95 -0
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +58 -0
- package/lib/esm/actions/vaultV2/forceWithdraw.js +90 -0
- package/lib/esm/actions/vaultV2/index.d.ts +5 -0
- package/lib/esm/actions/vaultV2/index.js +5 -0
- package/lib/esm/actions/vaultV2/redeem.d.ts +40 -0
- package/lib/esm/actions/vaultV2/redeem.js +54 -0
- package/lib/esm/actions/vaultV2/withdraw.d.ts +40 -0
- package/lib/esm/actions/vaultV2/withdraw.js +54 -0
- package/lib/esm/client/index.d.ts +2 -0
- package/lib/esm/client/index.js +2 -0
- package/lib/esm/client/morphoClient.d.ts +113 -0
- package/lib/esm/client/morphoClient.js +119 -0
- package/lib/esm/client/morphoViemExtension.d.ts +45 -0
- package/lib/esm/client/morphoViemExtension.js +43 -0
- package/lib/esm/entities/index.d.ts +3 -0
- package/lib/esm/entities/index.js +3 -0
- package/lib/esm/entities/marketV1/index.d.ts +1 -0
- package/lib/esm/entities/marketV1/index.js +1 -0
- package/lib/esm/entities/marketV1/marketV1.d.ts +293 -0
- package/lib/esm/entities/marketV1/marketV1.js +529 -0
- package/lib/esm/entities/vaultV1/index.d.ts +1 -0
- package/lib/esm/entities/vaultV1/index.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +129 -0
- package/lib/esm/entities/vaultV1/vaultV1.js +186 -0
- package/lib/esm/entities/vaultV2/index.d.ts +1 -0
- package/lib/esm/entities/vaultV2/index.js +1 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +180 -0
- package/lib/esm/entities/vaultV2/vaultV2.js +164 -0
- package/lib/esm/helpers/computeReallocations.d.ts +23 -0
- package/lib/esm/helpers/computeReallocations.js +94 -0
- package/lib/esm/helpers/constant.d.ts +6 -0
- package/lib/esm/helpers/constant.js +7 -0
- package/lib/esm/helpers/encodeDeallocation.d.ts +10 -0
- package/lib/esm/helpers/encodeDeallocation.js +34 -0
- package/lib/esm/helpers/index.d.ts +4 -0
- package/lib/esm/helpers/index.js +4 -0
- package/lib/esm/helpers/metadata.d.ts +33 -0
- package/lib/esm/helpers/metadata.js +46 -0
- package/lib/esm/helpers/slippage.d.ts +46 -0
- package/lib/esm/helpers/slippage.js +69 -0
- package/lib/esm/helpers/validate.d.ts +156 -0
- package/lib/esm/helpers/validate.js +273 -0
- package/lib/esm/index.d.ts +5 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/types/action.d.ts +216 -0
- package/lib/esm/types/action.js +21 -0
- package/lib/esm/types/client.d.ts +19 -0
- package/lib/esm/types/client.js +1 -0
- package/lib/esm/types/data.d.ts +2 -0
- package/lib/esm/types/data.js +1 -0
- package/lib/esm/types/deallocation.d.ts +15 -0
- package/lib/esm/types/deallocation.js +1 -0
- package/lib/esm/types/entity.d.ts +5 -0
- package/lib/esm/types/entity.js +1 -0
- package/lib/esm/types/error.d.ts +205 -0
- package/lib/esm/types/error.js +276 -0
- package/lib/esm/types/index.d.ts +7 -0
- package/lib/esm/types/index.js +7 -0
- package/lib/esm/types/metadata.d.ts +4 -0
- package/lib/esm/types/metadata.js +1 -0
- package/lib/esm/types/sharedLiquidity.d.ts +41 -0
- package/lib/esm/types/sharedLiquidity.js +1 -0
- package/package.json +33 -56
- package/src/index.ts +5 -0
- package/lib/actions/index.d.ts +0 -4
- package/lib/actions/marketV1/borrow.d.ts +0 -34
- package/lib/actions/marketV1/borrow.js +0 -62
- package/lib/actions/marketV1/buildReallocationActions.d.ts +0 -17
- package/lib/actions/marketV1/buildReallocationActions.js +0 -36
- package/lib/actions/marketV1/index.d.ts +0 -6
- package/lib/actions/marketV1/repay.d.ts +0 -44
- package/lib/actions/marketV1/repay.js +0 -93
- package/lib/actions/marketV1/repayWithdrawCollateral.d.ts +0 -51
- package/lib/actions/marketV1/repayWithdrawCollateral.js +0 -108
- package/lib/actions/marketV1/supplyCollateral.d.ts +0 -28
- package/lib/actions/marketV1/supplyCollateral.js +0 -85
- package/lib/actions/marketV1/supplyCollateralBorrow.d.ts +0 -37
- package/lib/actions/marketV1/supplyCollateralBorrow.js +0 -109
- package/lib/actions/marketV1/withdrawCollateral.d.ts +0 -28
- package/lib/actions/marketV1/withdrawCollateral.js +0 -51
- package/lib/actions/requirements/encode/encodeErc20Approval.d.ts +0 -10
- package/lib/actions/requirements/encode/encodeErc20Permit.d.ts +0 -13
- package/lib/actions/requirements/encode/encodeErc20Permit.js +0 -70
- package/lib/actions/requirements/encode/encodeErc20Permit2.d.ts +0 -11
- package/lib/actions/requirements/encode/index.d.ts +0 -3
- package/lib/actions/requirements/getMorphoAuthorizationRequirement.d.ts +0 -21
- package/lib/actions/requirements/getMorphoAuthorizationRequirement.js +0 -55
- package/lib/actions/requirements/getRequirements.d.ts +0 -42
- package/lib/actions/requirements/getRequirements.js +0 -80
- package/lib/actions/requirements/getRequirementsAction.d.ts +0 -17
- package/lib/actions/requirements/getRequirementsApproval.d.ts +0 -31
- package/lib/actions/requirements/getRequirementsApproval.js +0 -51
- package/lib/actions/requirements/getRequirementsPermit.d.ts +0 -28
- package/lib/actions/requirements/getRequirementsPermit.js +0 -40
- package/lib/actions/requirements/getRequirementsPermit2.d.ts +0 -37
- package/lib/actions/requirements/getRequirementsPermit2.js +0 -59
- package/lib/actions/requirements/index.d.ts +0 -6
- package/lib/actions/vaultV1/deposit.d.ts +0 -41
- package/lib/actions/vaultV1/deposit.js +0 -116
- package/lib/actions/vaultV1/index.d.ts +0 -4
- package/lib/actions/vaultV1/migrateToV2.d.ts +0 -50
- package/lib/actions/vaultV1/migrateToV2.js +0 -108
- package/lib/actions/vaultV1/redeem.d.ts +0 -29
- package/lib/actions/vaultV1/redeem.js +0 -48
- package/lib/actions/vaultV1/withdraw.d.ts +0 -29
- package/lib/actions/vaultV1/withdraw.js +0 -48
- package/lib/actions/vaultV2/deposit.d.ts +0 -41
- package/lib/actions/vaultV2/deposit.js +0 -116
- package/lib/actions/vaultV2/forceRedeem.d.ts +0 -48
- package/lib/actions/vaultV2/forceRedeem.js +0 -85
- package/lib/actions/vaultV2/forceWithdraw.d.ts +0 -40
- package/lib/actions/vaultV2/forceWithdraw.js +0 -77
- package/lib/actions/vaultV2/index.d.ts +0 -5
- package/lib/actions/vaultV2/redeem.d.ts +0 -32
- package/lib/actions/vaultV2/redeem.js +0 -51
- package/lib/actions/vaultV2/withdraw.d.ts +0 -32
- package/lib/actions/vaultV2/withdraw.js +0 -51
- package/lib/client/index.d.ts +0 -2
- package/lib/client/morphoClient.d.ts +0 -25
- package/lib/client/morphoClient.js +0 -28
- package/lib/client/morphoViemExtension.d.ts +0 -39
- package/lib/client/morphoViemExtension.js +0 -40
- package/lib/entities/index.d.ts +0 -3
- package/lib/entities/marketV1/index.d.ts +0 -1
- package/lib/entities/vaultV1/index.d.ts +0 -1
- package/lib/entities/vaultV2/index.d.ts +0 -1
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -21
- package/lib/types/index.d.ts +0 -7
- package/lib/types/index.js +0 -23
- /package/lib/{helpers → cjs/helpers}/constant.d.ts +0 -0
- /package/lib/{helpers → cjs/helpers}/constant.js +0 -0
- /package/lib/{helpers → cjs/helpers}/metadata.js +0 -0
- /package/lib/{helpers → cjs/helpers}/slippage.d.ts +0 -0
- /package/lib/{types → cjs/types}/action.js +0 -0
- /package/lib/{types → cjs/types}/client.js +0 -0
- /package/lib/{types → cjs/types}/data.d.ts +0 -0
- /package/lib/{types → cjs/types}/data.js +0 -0
- /package/lib/{types → cjs/types}/deallocation.d.ts +0 -0
- /package/lib/{types → cjs/types}/deallocation.js +0 -0
- /package/lib/{types → cjs/types}/entity.d.ts +0 -0
- /package/lib/{types → cjs/types}/entity.js +0 -0
- /package/lib/{types → cjs/types}/metadata.d.ts +0 -0
- /package/lib/{types → cjs/types}/metadata.js +0 -0
- /package/lib/{types → cjs/types}/sharedLiquidity.d.ts +0 -0
- /package/lib/{types → cjs/types}/sharedLiquidity.js +0 -0
|
@@ -4,8 +4,8 @@ exports.validateSlippageTolerance = exports.validateReallocations = exports.vali
|
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const index_js_1 = require("../types/index.js");
|
|
8
|
+
const constant_js_1 = require("./constant.js");
|
|
9
9
|
/**
|
|
10
10
|
* Validates that the client has a connected account AND that it matches
|
|
11
11
|
* the provided user address.
|
|
@@ -25,10 +25,10 @@ const constant_1 = require("./constant");
|
|
|
25
25
|
*/
|
|
26
26
|
const validateUserAddress = (clientAccountAddress, userAddress) => {
|
|
27
27
|
if (clientAccountAddress === undefined) {
|
|
28
|
-
throw new
|
|
28
|
+
throw new index_js_1.MissingClientPropertyError("account");
|
|
29
29
|
}
|
|
30
30
|
if (!(0, viem_1.isAddressEqual)(clientAccountAddress, userAddress)) {
|
|
31
|
-
throw new
|
|
31
|
+
throw new index_js_1.AddressMismatchError(clientAccountAddress, userAddress);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
exports.validateUserAddress = validateUserAddress;
|
|
@@ -47,10 +47,10 @@ exports.validateUserAddress = validateUserAddress;
|
|
|
47
47
|
const validateAccrualPosition = (params) => {
|
|
48
48
|
const { positionData, expectedMarketId, expectedUser } = params;
|
|
49
49
|
if (positionData.marketId !== expectedMarketId) {
|
|
50
|
-
throw new
|
|
50
|
+
throw new index_js_1.MarketIdMismatchError(positionData.marketId, expectedMarketId);
|
|
51
51
|
}
|
|
52
52
|
if (!(0, viem_1.isAddressEqual)(positionData.user, expectedUser)) {
|
|
53
|
-
throw new
|
|
53
|
+
throw new index_js_1.AccrualPositionUserMismatchError(positionData.user, expectedUser);
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
exports.validateAccrualPosition = validateAccrualPosition;
|
|
@@ -69,16 +69,16 @@ const validatePositionHealth = (params) => {
|
|
|
69
69
|
const { positionData, additionalCollateral, borrowAmount, marketId, lltv } = params;
|
|
70
70
|
const { price } = positionData.market;
|
|
71
71
|
if (!price) {
|
|
72
|
-
throw new
|
|
72
|
+
throw new index_js_1.MissingMarketPriceError(marketId);
|
|
73
73
|
}
|
|
74
74
|
const totalCollateralAfter = positionData.collateral + additionalCollateral;
|
|
75
75
|
const collateralValueAfter = blue_sdk_1.MathLib.mulDivDown(totalCollateralAfter, price, blue_sdk_1.ORACLE_PRICE_SCALE);
|
|
76
|
-
const effectiveLltv = lltv >
|
|
76
|
+
const effectiveLltv = lltv > constant_js_1.DEFAULT_LLTV_BUFFER ? lltv - constant_js_1.DEFAULT_LLTV_BUFFER : 0n;
|
|
77
77
|
const maxSafeBorrowAfter = blue_sdk_1.MathLib.wMulDown(collateralValueAfter, effectiveLltv);
|
|
78
78
|
const totalBorrowAfter = positionData.borrowAssets + borrowAmount + 1n; // +1 to account for share-to-asset rounding (happens when the borrow amount doesn't divide evenly into shares)
|
|
79
79
|
if (totalBorrowAfter > maxSafeBorrowAfter) {
|
|
80
80
|
const maxSafeAdditionalBorrow = blue_sdk_1.MathLib.zeroFloorSub(maxSafeBorrowAfter, positionData.borrowAssets);
|
|
81
|
-
throw new
|
|
81
|
+
throw new index_js_1.BorrowExceedsSafeLtvError(borrowAmount, maxSafeAdditionalBorrow);
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
exports.validatePositionHealth = validatePositionHealth;
|
|
@@ -91,7 +91,7 @@ exports.validatePositionHealth = validatePositionHealth;
|
|
|
91
91
|
*/
|
|
92
92
|
const validateChainId = (clientChainId, expectedChainId) => {
|
|
93
93
|
if (clientChainId !== expectedChainId) {
|
|
94
|
-
throw new
|
|
94
|
+
throw new index_js_1.ChainIdMismatchError(clientChainId, expectedChainId);
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
exports.validateChainId = validateChainId;
|
|
@@ -106,10 +106,10 @@ exports.validateChainId = validateChainId;
|
|
|
106
106
|
const validateNativeCollateral = (chainId, collateralToken) => {
|
|
107
107
|
const { wNative } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
108
108
|
if (!(0, morpho_ts_1.isDefined)(wNative)) {
|
|
109
|
-
throw new
|
|
109
|
+
throw new index_js_1.ChainWNativeMissingError(chainId);
|
|
110
110
|
}
|
|
111
111
|
if (!(0, viem_1.isAddressEqual)(collateralToken, wNative)) {
|
|
112
|
-
throw new
|
|
112
|
+
throw new index_js_1.NativeAmountOnNonWNativeCollateralError(collateralToken, wNative);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
exports.validateNativeCollateral = validateNativeCollateral;
|
|
@@ -126,10 +126,10 @@ exports.validateNativeCollateral = validateNativeCollateral;
|
|
|
126
126
|
const validatePositionHealthAfterWithdraw = (params) => {
|
|
127
127
|
const { positionData, withdrawAmount, lltv, marketId } = params;
|
|
128
128
|
if (positionData.marketId !== marketId) {
|
|
129
|
-
throw new
|
|
129
|
+
throw new index_js_1.MarketIdMismatchError(positionData.marketId, marketId);
|
|
130
130
|
}
|
|
131
131
|
if (withdrawAmount > positionData.collateral) {
|
|
132
|
-
throw new
|
|
132
|
+
throw new index_js_1.WithdrawExceedsCollateralError({
|
|
133
133
|
withdrawAmount,
|
|
134
134
|
available: positionData.collateral,
|
|
135
135
|
market: marketId,
|
|
@@ -141,14 +141,14 @@ const validatePositionHealthAfterWithdraw = (params) => {
|
|
|
141
141
|
}
|
|
142
142
|
const { price } = positionData.market;
|
|
143
143
|
if (!price) {
|
|
144
|
-
throw new
|
|
144
|
+
throw new index_js_1.MissingMarketPriceError(positionData.marketId);
|
|
145
145
|
}
|
|
146
146
|
const collateralAfter = positionData.collateral - withdrawAmount;
|
|
147
147
|
const collateralValueAfter = blue_sdk_1.MathLib.mulDivDown(collateralAfter, price, blue_sdk_1.ORACLE_PRICE_SCALE);
|
|
148
|
-
const effectiveLltv = lltv >
|
|
148
|
+
const effectiveLltv = lltv > constant_js_1.DEFAULT_LLTV_BUFFER ? lltv - constant_js_1.DEFAULT_LLTV_BUFFER : 0n;
|
|
149
149
|
const maxSafeBorrowAfter = blue_sdk_1.MathLib.wMulDown(collateralValueAfter, effectiveLltv);
|
|
150
150
|
if (positionData.borrowAssets > maxSafeBorrowAfter) {
|
|
151
|
-
throw new
|
|
151
|
+
throw new index_js_1.WithdrawMakesPositionUnhealthyError({
|
|
152
152
|
withdrawAmount,
|
|
153
153
|
borrowAssets: positionData.borrowAssets,
|
|
154
154
|
maxSafeBorrow: maxSafeBorrowAfter,
|
|
@@ -167,7 +167,7 @@ exports.validatePositionHealthAfterWithdraw = validatePositionHealthAfterWithdra
|
|
|
167
167
|
const validateRepayAmount = (params) => {
|
|
168
168
|
const { positionData, repayAssets, marketId } = params;
|
|
169
169
|
if (repayAssets > positionData.borrowAssets) {
|
|
170
|
-
throw new
|
|
170
|
+
throw new index_js_1.RepayExceedsDebtError({
|
|
171
171
|
repayAmount: repayAssets,
|
|
172
172
|
debt: positionData.borrowAssets,
|
|
173
173
|
market: marketId,
|
|
@@ -186,7 +186,7 @@ exports.validateRepayAmount = validateRepayAmount;
|
|
|
186
186
|
const validateRepayShares = (params) => {
|
|
187
187
|
const { positionData, repayShares, marketId } = params;
|
|
188
188
|
if (repayShares > positionData.borrowShares) {
|
|
189
|
-
throw new
|
|
189
|
+
throw new index_js_1.RepaySharesExceedDebtError({
|
|
190
190
|
repayShares,
|
|
191
191
|
borrowShares: positionData.borrowShares,
|
|
192
192
|
market: marketId,
|
|
@@ -208,22 +208,22 @@ exports.validateRepayShares = validateRepayShares;
|
|
|
208
208
|
const validateRepayParams = (params) => {
|
|
209
209
|
const { assets, shares, transferAmount, maxSharePrice, marketId } = params;
|
|
210
210
|
if (maxSharePrice <= 0n) {
|
|
211
|
-
throw new
|
|
211
|
+
throw new index_js_1.NonPositiveRepayMaxSharePriceError(marketId);
|
|
212
212
|
}
|
|
213
213
|
if (assets < 0n || shares < 0n) {
|
|
214
|
-
throw new
|
|
214
|
+
throw new index_js_1.NonPositiveRepayAmountError(marketId);
|
|
215
215
|
}
|
|
216
216
|
if (assets > 0n && shares > 0n) {
|
|
217
|
-
throw new
|
|
217
|
+
throw new index_js_1.MutuallyExclusiveRepayAmountsError(marketId);
|
|
218
218
|
}
|
|
219
219
|
if (assets === 0n && shares === 0n) {
|
|
220
|
-
throw new
|
|
220
|
+
throw new index_js_1.NonPositiveRepayAmountError(marketId);
|
|
221
221
|
}
|
|
222
222
|
if (transferAmount <= 0n) {
|
|
223
|
-
throw new
|
|
223
|
+
throw new index_js_1.NonPositiveTransferAmountError(marketId);
|
|
224
224
|
}
|
|
225
225
|
if (assets > 0n && transferAmount !== assets) {
|
|
226
|
-
throw new
|
|
226
|
+
throw new index_js_1.TransferAmountNotEqualToAssetsError({
|
|
227
227
|
transferAmount,
|
|
228
228
|
assets,
|
|
229
229
|
market: marketId,
|
|
@@ -247,21 +247,21 @@ exports.validateRepayParams = validateRepayParams;
|
|
|
247
247
|
const validateReallocations = (reallocations, targetMarketId) => {
|
|
248
248
|
for (const r of reallocations) {
|
|
249
249
|
if (r.fee < 0n) {
|
|
250
|
-
throw new
|
|
250
|
+
throw new index_js_1.NegativeReallocationFeeError(r.vault);
|
|
251
251
|
}
|
|
252
252
|
if (r.withdrawals.length === 0) {
|
|
253
|
-
throw new
|
|
253
|
+
throw new index_js_1.EmptyReallocationWithdrawalsError(r.vault);
|
|
254
254
|
}
|
|
255
255
|
let prevId;
|
|
256
256
|
for (const w of r.withdrawals) {
|
|
257
257
|
if (w.amount <= 0n) {
|
|
258
|
-
throw new
|
|
258
|
+
throw new index_js_1.NonPositiveReallocationAmountError(r.vault, w.marketParams.id);
|
|
259
259
|
}
|
|
260
260
|
if (w.marketParams.id === targetMarketId) {
|
|
261
|
-
throw new
|
|
261
|
+
throw new index_js_1.ReallocationWithdrawalOnTargetMarketError(r.vault, w.marketParams.id);
|
|
262
262
|
}
|
|
263
263
|
if (prevId !== undefined && w.marketParams.id <= prevId) {
|
|
264
|
-
throw new
|
|
264
|
+
throw new index_js_1.UnsortedReallocationWithdrawalsError(r.vault, w.marketParams.id);
|
|
265
265
|
}
|
|
266
266
|
prevId = w.marketParams.id;
|
|
267
267
|
}
|
|
@@ -278,10 +278,10 @@ exports.validateReallocations = validateReallocations;
|
|
|
278
278
|
*/
|
|
279
279
|
const validateSlippageTolerance = (slippageTolerance) => {
|
|
280
280
|
if (slippageTolerance < 0n) {
|
|
281
|
-
throw new
|
|
281
|
+
throw new index_js_1.NegativeSlippageToleranceError(slippageTolerance);
|
|
282
282
|
}
|
|
283
|
-
if (slippageTolerance >
|
|
284
|
-
throw new
|
|
283
|
+
if (slippageTolerance > constant_js_1.MAX_SLIPPAGE_TOLERANCE) {
|
|
284
|
+
throw new index_js_1.ExcessiveSlippageToleranceError(slippageTolerance);
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
287
|
exports.validateSlippageTolerance = validateSlippageTolerance;
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./actions/index.js"), exports);
|
|
18
|
+
__exportStar(require("./client/index.js"), exports);
|
|
19
|
+
__exportStar(require("./entities/index.js"), exports);
|
|
20
|
+
__exportStar(require("./helpers/index.js"), exports);
|
|
21
|
+
__exportStar(require("./types/index.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Client, Hex } from "viem";
|
|
2
|
-
import type { Deallocation } from "./deallocation";
|
|
2
|
+
import type { Deallocation } from "./deallocation.js";
|
|
3
3
|
export interface BaseAction<TType extends string = string, TArgs extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
4
|
readonly type: TType;
|
|
5
5
|
readonly args: TArgs;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address, Client } from "viem";
|
|
3
|
-
import type { MarketV1Actions, VaultV1Actions, VaultV2Actions } from "../entities";
|
|
4
|
-
import type { Metadata } from "./index";
|
|
3
|
+
import type { MarketV1Actions, VaultV1Actions, VaultV2Actions } from "../entities/index.js";
|
|
4
|
+
import type { Metadata } from "./index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Structural contract every concrete `MorphoClient` implementation satisfies. Carries the viem
|
|
7
|
+
* client, the resolved options bag, and the three entity-factory methods the SDK exposes.
|
|
8
|
+
*/
|
|
5
9
|
export interface MorphoClientType {
|
|
6
10
|
readonly viemClient: Client;
|
|
7
11
|
readonly options: {
|
|
@@ -1,97 +1,129 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
+
/** Thrown when an asset amount is required to be positive but is zero or negative. */
|
|
2
3
|
export declare class NonPositiveAssetAmountError extends Error {
|
|
3
4
|
constructor(origin: Address);
|
|
4
5
|
}
|
|
6
|
+
/** Thrown when a shares amount is required to be positive but is zero or negative. */
|
|
5
7
|
export declare class NonPositiveSharesAmountError extends Error {
|
|
6
8
|
constructor(vault: Address);
|
|
7
9
|
}
|
|
10
|
+
/** Thrown when a vault deposit's `maxSharePrice` slippage bound is zero or negative. */
|
|
8
11
|
export declare class NonPositiveMaxSharePriceError extends Error {
|
|
9
12
|
constructor(vault: Address);
|
|
10
13
|
}
|
|
14
|
+
/** Thrown when a viem client's account address does not match the address required by the call. */
|
|
11
15
|
export declare class AddressMismatchError extends Error {
|
|
12
16
|
constructor(clientAddress: Address, argsAddress: Address);
|
|
13
17
|
}
|
|
18
|
+
/** Thrown when a viem client's chain id does not match the chain id required by the call. */
|
|
14
19
|
export declare class ChainIdMismatchError extends Error {
|
|
15
20
|
constructor(clientChainId: number | undefined, argsChainId: number);
|
|
16
21
|
}
|
|
22
|
+
/** Thrown when the viem client is missing a property the call requires (e.g. `account.address`). */
|
|
17
23
|
export declare class MissingClientPropertyError extends Error {
|
|
18
24
|
constructor(property: string);
|
|
19
25
|
}
|
|
26
|
+
/** Thrown when an approval amount is smaller than the spend amount it must cover. */
|
|
20
27
|
export declare class ApprovalAmountLessThanSpendAmountError extends Error {
|
|
21
28
|
constructor();
|
|
22
29
|
}
|
|
30
|
+
/** Thrown when a slippage tolerance is negative. */
|
|
23
31
|
export declare class NegativeSlippageToleranceError extends Error {
|
|
24
32
|
constructor(slippageTolerance: bigint);
|
|
25
33
|
}
|
|
34
|
+
/** Thrown when a Morpho accrual position is missing for a market the call needs to read. */
|
|
26
35
|
export declare class MissingAccrualPositionError extends Error {
|
|
27
36
|
constructor(market: string);
|
|
28
37
|
}
|
|
38
|
+
/** Thrown when a slippage tolerance exceeds `MAX_SLIPPAGE_TOLERANCE` (10%). */
|
|
29
39
|
export declare class ExcessiveSlippageToleranceError extends Error {
|
|
30
40
|
constructor(slippageTolerance: bigint);
|
|
31
41
|
}
|
|
42
|
+
/** Thrown when a VaultV2 force-withdraw or force-redeem call has no deallocations to perform. */
|
|
32
43
|
export declare class EmptyDeallocationsError extends Error {
|
|
33
44
|
constructor(vault: Address);
|
|
34
45
|
}
|
|
46
|
+
/** Thrown when a deposit's amount differs from the amount the supplied permit / permit2 signature was issued for. */
|
|
35
47
|
export declare class DepositAmountMismatchError extends Error {
|
|
36
48
|
constructor(depositAmount: bigint, signatureAmount: bigint);
|
|
37
49
|
}
|
|
50
|
+
/** Thrown when a deposit's asset differs from the asset the supplied permit / permit2 signature was issued for. */
|
|
38
51
|
export declare class DepositAssetMismatchError extends Error {
|
|
39
52
|
constructor(depositAsset: Address, signatureAsset: Address);
|
|
40
53
|
}
|
|
54
|
+
/** Thrown when a vault deposit uses `nativeAmount` but the vault asset is not the chain's wNative. */
|
|
41
55
|
export declare class NativeAmountOnNonWNativeVaultError extends Error {
|
|
42
56
|
constructor(vaultAsset: Address, wNative: Address);
|
|
43
57
|
}
|
|
58
|
+
/** Thrown when a `nativeAmount` is supplied but the chain has no configured wNative address. */
|
|
44
59
|
export declare class ChainWNativeMissingError extends Error {
|
|
45
60
|
constructor(chainId: number);
|
|
46
61
|
}
|
|
62
|
+
/** Thrown when `nativeAmount` is negative. */
|
|
47
63
|
export declare class NegativeNativeAmountError extends Error {
|
|
48
64
|
constructor(nativeAmount: bigint);
|
|
49
65
|
}
|
|
66
|
+
/** Thrown when both `amount` and `nativeAmount` resolve to zero on a vault deposit. */
|
|
50
67
|
export declare class ZeroDepositAmountError extends Error {
|
|
51
68
|
constructor(vault: Address);
|
|
52
69
|
}
|
|
70
|
+
/** Thrown when a vault entity's address does not match the vault address embedded in the call's args. */
|
|
53
71
|
export declare class VaultAddressMismatchError extends Error {
|
|
54
72
|
constructor(vaultAddress: Address, argsVaultAddress: Address);
|
|
55
73
|
}
|
|
74
|
+
/** Thrown when a market borrow amount is zero or negative. */
|
|
56
75
|
export declare class NonPositiveBorrowAmountError extends Error {
|
|
57
76
|
constructor(market: string);
|
|
58
77
|
}
|
|
78
|
+
/** Thrown when both `amount` and `nativeAmount` resolve to zero on a market collateral supply. */
|
|
59
79
|
export declare class ZeroCollateralAmountError extends Error {
|
|
60
80
|
constructor(market: string);
|
|
61
81
|
}
|
|
82
|
+
/** Thrown when a collateral supply uses `nativeAmount` but the collateral token is not the chain's wNative. */
|
|
62
83
|
export declare class NativeAmountOnNonWNativeCollateralError extends Error {
|
|
63
84
|
constructor(collateralToken: Address, wNative: Address);
|
|
64
85
|
}
|
|
86
|
+
/** Thrown when a borrow exceeds the LLTV-buffered safe maximum for the position. */
|
|
65
87
|
export declare class BorrowExceedsSafeLtvError extends Error {
|
|
66
88
|
constructor(borrowAmount: bigint, maxSafeBorrow: bigint);
|
|
67
89
|
}
|
|
90
|
+
/** Thrown when the market's oracle price is unavailable and position health cannot be validated. */
|
|
68
91
|
export declare class MissingMarketPriceError extends Error {
|
|
69
92
|
constructor(market: string);
|
|
70
93
|
}
|
|
94
|
+
/** Thrown when a `MarketParams.id` does not match the expected market id derived from the other fields. */
|
|
71
95
|
export declare class MarketIdMismatchError extends Error {
|
|
72
96
|
constructor(marketId: string, expectedMarketId: string);
|
|
73
97
|
}
|
|
98
|
+
/** Thrown when an accrual position belongs to a different user than the one expected by the call. */
|
|
74
99
|
export declare class AccrualPositionUserMismatchError extends Error {
|
|
75
100
|
constructor(positionUser: string, expectedUser: string);
|
|
76
101
|
}
|
|
102
|
+
/** Thrown when a reallocation's fee is negative. */
|
|
77
103
|
export declare class NegativeReallocationFeeError extends Error {
|
|
78
104
|
constructor(vault: string);
|
|
79
105
|
}
|
|
106
|
+
/** Thrown when a reallocation has no withdrawals. */
|
|
80
107
|
export declare class EmptyReallocationWithdrawalsError extends Error {
|
|
81
108
|
constructor(vault: string);
|
|
82
109
|
}
|
|
110
|
+
/** Thrown when a reallocation withdrawal amount is zero or negative. */
|
|
83
111
|
export declare class NonPositiveReallocationAmountError extends Error {
|
|
84
112
|
constructor(vault: string, market: string);
|
|
85
113
|
}
|
|
114
|
+
/** Thrown when a reallocation withdrawal references the borrow target market (which would be a no-op or self-deal). */
|
|
86
115
|
export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
87
116
|
constructor(vault: string, marketId: string);
|
|
88
117
|
}
|
|
118
|
+
/** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
|
|
89
119
|
export declare class UnsortedReallocationWithdrawalsError extends Error {
|
|
90
120
|
constructor(vault: string, marketId: string);
|
|
91
121
|
}
|
|
122
|
+
/** Thrown when a market repay's `transferAmount` is zero or negative. */
|
|
92
123
|
export declare class NonPositiveTransferAmountError extends Error {
|
|
93
124
|
constructor(market: string);
|
|
94
125
|
}
|
|
126
|
+
/** Thrown when a market repay in assets mode has `transferAmount !== assets` (asset-mode requires exact transfer). */
|
|
95
127
|
export declare class TransferAmountNotEqualToAssetsError extends Error {
|
|
96
128
|
constructor(params: {
|
|
97
129
|
transferAmount: bigint;
|
|
@@ -99,18 +131,23 @@ export declare class TransferAmountNotEqualToAssetsError extends Error {
|
|
|
99
131
|
market: string;
|
|
100
132
|
});
|
|
101
133
|
}
|
|
134
|
+
/** Thrown when a market repay specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
|
|
102
135
|
export declare class MutuallyExclusiveRepayAmountsError extends Error {
|
|
103
136
|
constructor(market: string);
|
|
104
137
|
}
|
|
138
|
+
/** Thrown when a market repay has non-positive amounts: both `assets` and `shares` are zero, or either is negative. */
|
|
105
139
|
export declare class NonPositiveRepayAmountError extends Error {
|
|
106
140
|
constructor(market: string);
|
|
107
141
|
}
|
|
142
|
+
/** Thrown when a market repay's `maxSharePrice` slippage bound is zero or negative. */
|
|
108
143
|
export declare class NonPositiveRepayMaxSharePriceError extends Error {
|
|
109
144
|
constructor(market: string);
|
|
110
145
|
}
|
|
146
|
+
/** Thrown when a market `withdrawCollateral` amount is zero or negative. */
|
|
111
147
|
export declare class NonPositiveWithdrawCollateralAmountError extends Error {
|
|
112
148
|
constructor(market: string);
|
|
113
149
|
}
|
|
150
|
+
/** Thrown when a withdraw amount exceeds the position's available collateral. */
|
|
114
151
|
export declare class WithdrawExceedsCollateralError extends Error {
|
|
115
152
|
constructor(params: {
|
|
116
153
|
withdrawAmount: bigint;
|
|
@@ -118,6 +155,7 @@ export declare class WithdrawExceedsCollateralError extends Error {
|
|
|
118
155
|
market: string;
|
|
119
156
|
});
|
|
120
157
|
}
|
|
158
|
+
/** Thrown when a collateral withdrawal would leave the borrower's position above the LLTV-buffered safe maximum. */
|
|
121
159
|
export declare class WithdrawMakesPositionUnhealthyError extends Error {
|
|
122
160
|
constructor(params: {
|
|
123
161
|
withdrawAmount: bigint;
|
|
@@ -125,9 +163,11 @@ export declare class WithdrawMakesPositionUnhealthyError extends Error {
|
|
|
125
163
|
maxSafeBorrow: bigint;
|
|
126
164
|
});
|
|
127
165
|
}
|
|
166
|
+
/** Thrown when a share-amount conversion would divide by zero (the market has no shares of the relevant kind). */
|
|
128
167
|
export declare class ShareDivideByZeroError extends Error {
|
|
129
168
|
constructor(market: string);
|
|
130
169
|
}
|
|
170
|
+
/** Thrown when a repay amount in assets exceeds the borrower's outstanding debt. */
|
|
131
171
|
export declare class RepayExceedsDebtError extends Error {
|
|
132
172
|
constructor(params: {
|
|
133
173
|
repayAmount: bigint;
|
|
@@ -135,9 +175,11 @@ export declare class RepayExceedsDebtError extends Error {
|
|
|
135
175
|
market: string;
|
|
136
176
|
});
|
|
137
177
|
}
|
|
178
|
+
/** Thrown when EIP-712 signature verification fails (the signed data does not match the expected signer). */
|
|
138
179
|
export declare class InvalidSignatureError extends Error {
|
|
139
180
|
constructor();
|
|
140
181
|
}
|
|
182
|
+
/** Thrown when a repay in shares mode supplies more shares than the borrower owes. */
|
|
141
183
|
export declare class RepaySharesExceedDebtError extends Error {
|
|
142
184
|
constructor(params: {
|
|
143
185
|
repayShares: bigint;
|
|
@@ -145,15 +187,19 @@ export declare class RepaySharesExceedDebtError extends Error {
|
|
|
145
187
|
market: string;
|
|
146
188
|
});
|
|
147
189
|
}
|
|
190
|
+
/** Thrown when a vault selected for reallocation has no configured `PublicAllocator`. */
|
|
148
191
|
export declare class MissingPublicAllocatorConfigError extends Error {
|
|
149
192
|
constructor(vault: string);
|
|
150
193
|
}
|
|
194
|
+
/** Thrown when a market borrow's `minSharePrice` slippage bound is negative. */
|
|
151
195
|
export declare class NonPositiveMinBorrowSharePriceError extends Error {
|
|
152
196
|
constructor(market: string);
|
|
153
197
|
}
|
|
198
|
+
/** Thrown when a vault migration's source vault asset differs from the target vault asset. */
|
|
154
199
|
export declare class VaultAssetMismatchError extends Error {
|
|
155
200
|
constructor(sourceAsset: Address, targetAsset: Address);
|
|
156
201
|
}
|
|
202
|
+
/** Thrown when a vault redeem's `minSharePrice` slippage bound is negative. */
|
|
157
203
|
export declare class NegativeMinSharePriceError extends Error {
|
|
158
204
|
constructor(vault: Address);
|
|
159
205
|
}
|