@morpho-org/morpho-sdk 1.0.1 → 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 -7
- package/lib/{types → cjs/types}/error.js +47 -7
- 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 -85
- 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
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
/** Thrown when an asset amount is required to be positive but is zero or negative. */
|
|
3
|
+
export declare class NonPositiveAssetAmountError extends Error {
|
|
4
|
+
constructor(origin: Address);
|
|
5
|
+
}
|
|
6
|
+
/** Thrown when a shares amount is required to be positive but is zero or negative. */
|
|
7
|
+
export declare class NonPositiveSharesAmountError extends Error {
|
|
8
|
+
constructor(vault: Address);
|
|
9
|
+
}
|
|
10
|
+
/** Thrown when a vault deposit's `maxSharePrice` slippage bound is zero or negative. */
|
|
11
|
+
export declare class NonPositiveMaxSharePriceError extends Error {
|
|
12
|
+
constructor(vault: Address);
|
|
13
|
+
}
|
|
14
|
+
/** Thrown when a viem client's account address does not match the address required by the call. */
|
|
15
|
+
export declare class AddressMismatchError extends Error {
|
|
16
|
+
constructor(clientAddress: Address, argsAddress: Address);
|
|
17
|
+
}
|
|
18
|
+
/** Thrown when a viem client's chain id does not match the chain id required by the call. */
|
|
19
|
+
export declare class ChainIdMismatchError extends Error {
|
|
20
|
+
constructor(clientChainId: number | undefined, argsChainId: number);
|
|
21
|
+
}
|
|
22
|
+
/** Thrown when the viem client is missing a property the call requires (e.g. `account.address`). */
|
|
23
|
+
export declare class MissingClientPropertyError extends Error {
|
|
24
|
+
constructor(property: string);
|
|
25
|
+
}
|
|
26
|
+
/** Thrown when an approval amount is smaller than the spend amount it must cover. */
|
|
27
|
+
export declare class ApprovalAmountLessThanSpendAmountError extends Error {
|
|
28
|
+
constructor();
|
|
29
|
+
}
|
|
30
|
+
/** Thrown when a slippage tolerance is negative. */
|
|
31
|
+
export declare class NegativeSlippageToleranceError extends Error {
|
|
32
|
+
constructor(slippageTolerance: bigint);
|
|
33
|
+
}
|
|
34
|
+
/** Thrown when a Morpho accrual position is missing for a market the call needs to read. */
|
|
35
|
+
export declare class MissingAccrualPositionError extends Error {
|
|
36
|
+
constructor(market: string);
|
|
37
|
+
}
|
|
38
|
+
/** Thrown when a slippage tolerance exceeds `MAX_SLIPPAGE_TOLERANCE` (10%). */
|
|
39
|
+
export declare class ExcessiveSlippageToleranceError extends Error {
|
|
40
|
+
constructor(slippageTolerance: bigint);
|
|
41
|
+
}
|
|
42
|
+
/** Thrown when a VaultV2 force-withdraw or force-redeem call has no deallocations to perform. */
|
|
43
|
+
export declare class EmptyDeallocationsError extends Error {
|
|
44
|
+
constructor(vault: Address);
|
|
45
|
+
}
|
|
46
|
+
/** Thrown when a deposit's amount differs from the amount the supplied permit / permit2 signature was issued for. */
|
|
47
|
+
export declare class DepositAmountMismatchError extends Error {
|
|
48
|
+
constructor(depositAmount: bigint, signatureAmount: bigint);
|
|
49
|
+
}
|
|
50
|
+
/** Thrown when a deposit's asset differs from the asset the supplied permit / permit2 signature was issued for. */
|
|
51
|
+
export declare class DepositAssetMismatchError extends Error {
|
|
52
|
+
constructor(depositAsset: Address, signatureAsset: Address);
|
|
53
|
+
}
|
|
54
|
+
/** Thrown when a vault deposit uses `nativeAmount` but the vault asset is not the chain's wNative. */
|
|
55
|
+
export declare class NativeAmountOnNonWNativeVaultError extends Error {
|
|
56
|
+
constructor(vaultAsset: Address, wNative: Address);
|
|
57
|
+
}
|
|
58
|
+
/** Thrown when a `nativeAmount` is supplied but the chain has no configured wNative address. */
|
|
59
|
+
export declare class ChainWNativeMissingError extends Error {
|
|
60
|
+
constructor(chainId: number);
|
|
61
|
+
}
|
|
62
|
+
/** Thrown when `nativeAmount` is negative. */
|
|
63
|
+
export declare class NegativeNativeAmountError extends Error {
|
|
64
|
+
constructor(nativeAmount: bigint);
|
|
65
|
+
}
|
|
66
|
+
/** Thrown when both `amount` and `nativeAmount` resolve to zero on a vault deposit. */
|
|
67
|
+
export declare class ZeroDepositAmountError extends Error {
|
|
68
|
+
constructor(vault: Address);
|
|
69
|
+
}
|
|
70
|
+
/** Thrown when a vault entity's address does not match the vault address embedded in the call's args. */
|
|
71
|
+
export declare class VaultAddressMismatchError extends Error {
|
|
72
|
+
constructor(vaultAddress: Address, argsVaultAddress: Address);
|
|
73
|
+
}
|
|
74
|
+
/** Thrown when a market borrow amount is zero or negative. */
|
|
75
|
+
export declare class NonPositiveBorrowAmountError extends Error {
|
|
76
|
+
constructor(market: string);
|
|
77
|
+
}
|
|
78
|
+
/** Thrown when both `amount` and `nativeAmount` resolve to zero on a market collateral supply. */
|
|
79
|
+
export declare class ZeroCollateralAmountError extends Error {
|
|
80
|
+
constructor(market: string);
|
|
81
|
+
}
|
|
82
|
+
/** Thrown when a collateral supply uses `nativeAmount` but the collateral token is not the chain's wNative. */
|
|
83
|
+
export declare class NativeAmountOnNonWNativeCollateralError extends Error {
|
|
84
|
+
constructor(collateralToken: Address, wNative: Address);
|
|
85
|
+
}
|
|
86
|
+
/** Thrown when a borrow exceeds the LLTV-buffered safe maximum for the position. */
|
|
87
|
+
export declare class BorrowExceedsSafeLtvError extends Error {
|
|
88
|
+
constructor(borrowAmount: bigint, maxSafeBorrow: bigint);
|
|
89
|
+
}
|
|
90
|
+
/** Thrown when the market's oracle price is unavailable and position health cannot be validated. */
|
|
91
|
+
export declare class MissingMarketPriceError extends Error {
|
|
92
|
+
constructor(market: string);
|
|
93
|
+
}
|
|
94
|
+
/** Thrown when a `MarketParams.id` does not match the expected market id derived from the other fields. */
|
|
95
|
+
export declare class MarketIdMismatchError extends Error {
|
|
96
|
+
constructor(marketId: string, expectedMarketId: string);
|
|
97
|
+
}
|
|
98
|
+
/** Thrown when an accrual position belongs to a different user than the one expected by the call. */
|
|
99
|
+
export declare class AccrualPositionUserMismatchError extends Error {
|
|
100
|
+
constructor(positionUser: string, expectedUser: string);
|
|
101
|
+
}
|
|
102
|
+
/** Thrown when a reallocation's fee is negative. */
|
|
103
|
+
export declare class NegativeReallocationFeeError extends Error {
|
|
104
|
+
constructor(vault: string);
|
|
105
|
+
}
|
|
106
|
+
/** Thrown when a reallocation has no withdrawals. */
|
|
107
|
+
export declare class EmptyReallocationWithdrawalsError extends Error {
|
|
108
|
+
constructor(vault: string);
|
|
109
|
+
}
|
|
110
|
+
/** Thrown when a reallocation withdrawal amount is zero or negative. */
|
|
111
|
+
export declare class NonPositiveReallocationAmountError extends Error {
|
|
112
|
+
constructor(vault: string, market: string);
|
|
113
|
+
}
|
|
114
|
+
/** Thrown when a reallocation withdrawal references the borrow target market (which would be a no-op or self-deal). */
|
|
115
|
+
export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
116
|
+
constructor(vault: string, marketId: string);
|
|
117
|
+
}
|
|
118
|
+
/** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
|
|
119
|
+
export declare class UnsortedReallocationWithdrawalsError extends Error {
|
|
120
|
+
constructor(vault: string, marketId: string);
|
|
121
|
+
}
|
|
122
|
+
/** Thrown when a market repay's `transferAmount` is zero or negative. */
|
|
123
|
+
export declare class NonPositiveTransferAmountError extends Error {
|
|
124
|
+
constructor(market: string);
|
|
125
|
+
}
|
|
126
|
+
/** Thrown when a market repay in assets mode has `transferAmount !== assets` (asset-mode requires exact transfer). */
|
|
127
|
+
export declare class TransferAmountNotEqualToAssetsError extends Error {
|
|
128
|
+
constructor(params: {
|
|
129
|
+
transferAmount: bigint;
|
|
130
|
+
assets: bigint;
|
|
131
|
+
market: string;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/** Thrown when a market repay specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
|
|
135
|
+
export declare class MutuallyExclusiveRepayAmountsError extends Error {
|
|
136
|
+
constructor(market: string);
|
|
137
|
+
}
|
|
138
|
+
/** Thrown when a market repay has non-positive amounts: both `assets` and `shares` are zero, or either is negative. */
|
|
139
|
+
export declare class NonPositiveRepayAmountError extends Error {
|
|
140
|
+
constructor(market: string);
|
|
141
|
+
}
|
|
142
|
+
/** Thrown when a market repay's `maxSharePrice` slippage bound is zero or negative. */
|
|
143
|
+
export declare class NonPositiveRepayMaxSharePriceError extends Error {
|
|
144
|
+
constructor(market: string);
|
|
145
|
+
}
|
|
146
|
+
/** Thrown when a market `withdrawCollateral` amount is zero or negative. */
|
|
147
|
+
export declare class NonPositiveWithdrawCollateralAmountError extends Error {
|
|
148
|
+
constructor(market: string);
|
|
149
|
+
}
|
|
150
|
+
/** Thrown when a withdraw amount exceeds the position's available collateral. */
|
|
151
|
+
export declare class WithdrawExceedsCollateralError extends Error {
|
|
152
|
+
constructor(params: {
|
|
153
|
+
withdrawAmount: bigint;
|
|
154
|
+
available: bigint;
|
|
155
|
+
market: string;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/** Thrown when a collateral withdrawal would leave the borrower's position above the LLTV-buffered safe maximum. */
|
|
159
|
+
export declare class WithdrawMakesPositionUnhealthyError extends Error {
|
|
160
|
+
constructor(params: {
|
|
161
|
+
withdrawAmount: bigint;
|
|
162
|
+
borrowAssets: bigint;
|
|
163
|
+
maxSafeBorrow: bigint;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/** Thrown when a share-amount conversion would divide by zero (the market has no shares of the relevant kind). */
|
|
167
|
+
export declare class ShareDivideByZeroError extends Error {
|
|
168
|
+
constructor(market: string);
|
|
169
|
+
}
|
|
170
|
+
/** Thrown when a repay amount in assets exceeds the borrower's outstanding debt. */
|
|
171
|
+
export declare class RepayExceedsDebtError extends Error {
|
|
172
|
+
constructor(params: {
|
|
173
|
+
repayAmount: bigint;
|
|
174
|
+
debt: bigint;
|
|
175
|
+
market: string;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/** Thrown when EIP-712 signature verification fails (the signed data does not match the expected signer). */
|
|
179
|
+
export declare class InvalidSignatureError extends Error {
|
|
180
|
+
constructor();
|
|
181
|
+
}
|
|
182
|
+
/** Thrown when a repay in shares mode supplies more shares than the borrower owes. */
|
|
183
|
+
export declare class RepaySharesExceedDebtError extends Error {
|
|
184
|
+
constructor(params: {
|
|
185
|
+
repayShares: bigint;
|
|
186
|
+
borrowShares: bigint;
|
|
187
|
+
market: string;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/** Thrown when a vault selected for reallocation has no configured `PublicAllocator`. */
|
|
191
|
+
export declare class MissingPublicAllocatorConfigError extends Error {
|
|
192
|
+
constructor(vault: string);
|
|
193
|
+
}
|
|
194
|
+
/** Thrown when a market borrow's `minSharePrice` slippage bound is negative. */
|
|
195
|
+
export declare class NonPositiveMinBorrowSharePriceError extends Error {
|
|
196
|
+
constructor(market: string);
|
|
197
|
+
}
|
|
198
|
+
/** Thrown when a vault migration's source vault asset differs from the target vault asset. */
|
|
199
|
+
export declare class VaultAssetMismatchError extends Error {
|
|
200
|
+
constructor(sourceAsset: Address, targetAsset: Address);
|
|
201
|
+
}
|
|
202
|
+
/** Thrown when a vault redeem's `minSharePrice` slippage bound is negative. */
|
|
203
|
+
export declare class NegativeMinSharePriceError extends Error {
|
|
204
|
+
constructor(vault: Address);
|
|
205
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/** Thrown when an asset amount is required to be positive but is zero or negative. */
|
|
2
|
+
export class NonPositiveAssetAmountError extends Error {
|
|
3
|
+
constructor(origin) {
|
|
4
|
+
super(`Asset amount must be positive for address ${origin}`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/** Thrown when a shares amount is required to be positive but is zero or negative. */
|
|
8
|
+
export class NonPositiveSharesAmountError extends Error {
|
|
9
|
+
constructor(vault) {
|
|
10
|
+
super(`Shares amount must be positive for address: ${vault}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Thrown when a vault deposit's `maxSharePrice` slippage bound is zero or negative. */
|
|
14
|
+
export class NonPositiveMaxSharePriceError extends Error {
|
|
15
|
+
constructor(vault) {
|
|
16
|
+
super(`Max share price must be positive for vault: ${vault}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Thrown when a viem client's account address does not match the address required by the call. */
|
|
20
|
+
export class AddressMismatchError extends Error {
|
|
21
|
+
constructor(clientAddress, argsAddress) {
|
|
22
|
+
super(`Address mismatch between client: ${clientAddress} and args: ${argsAddress}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Thrown when a viem client's chain id does not match the chain id required by the call. */
|
|
26
|
+
export class ChainIdMismatchError extends Error {
|
|
27
|
+
constructor(clientChainId, argsChainId) {
|
|
28
|
+
super(`Chain ID mismatch between client: ${clientChainId} and args: ${argsChainId}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Thrown when the viem client is missing a property the call requires (e.g. `account.address`). */
|
|
32
|
+
export class MissingClientPropertyError extends Error {
|
|
33
|
+
constructor(property) {
|
|
34
|
+
super(`A required ${property} is missing from the client.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Thrown when an approval amount is smaller than the spend amount it must cover. */
|
|
38
|
+
export class ApprovalAmountLessThanSpendAmountError extends Error {
|
|
39
|
+
constructor() {
|
|
40
|
+
super("Approval amount is less than spend amount");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Thrown when a slippage tolerance is negative. */
|
|
44
|
+
export class NegativeSlippageToleranceError extends Error {
|
|
45
|
+
constructor(slippageTolerance) {
|
|
46
|
+
super(`Slippage tolerance ${slippageTolerance} must not be negative`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Thrown when a Morpho accrual position is missing for a market the call needs to read. */
|
|
50
|
+
export class MissingAccrualPositionError extends Error {
|
|
51
|
+
constructor(market) {
|
|
52
|
+
super(`Accrual position is missing for market: ${market}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Thrown when a slippage tolerance exceeds `MAX_SLIPPAGE_TOLERANCE` (10%). */
|
|
56
|
+
export class ExcessiveSlippageToleranceError extends Error {
|
|
57
|
+
constructor(slippageTolerance) {
|
|
58
|
+
super(`Slippage tolerance ${slippageTolerance} exceeds maximum allowed (10%)`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Thrown when a VaultV2 force-withdraw or force-redeem call has no deallocations to perform. */
|
|
62
|
+
export class EmptyDeallocationsError extends Error {
|
|
63
|
+
constructor(vault) {
|
|
64
|
+
super(`Deallocations list cannot be empty for vault: ${vault}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Thrown when a deposit's amount differs from the amount the supplied permit / permit2 signature was issued for. */
|
|
68
|
+
export class DepositAmountMismatchError extends Error {
|
|
69
|
+
constructor(depositAmount, signatureAmount) {
|
|
70
|
+
super(`Deposit amount ${depositAmount} does not match requirement signature amount ${signatureAmount}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Thrown when a deposit's asset differs from the asset the supplied permit / permit2 signature was issued for. */
|
|
74
|
+
export class DepositAssetMismatchError extends Error {
|
|
75
|
+
constructor(depositAsset, signatureAsset) {
|
|
76
|
+
super(`Deposit asset ${depositAsset} does not match requirement signature asset ${signatureAsset}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** Thrown when a vault deposit uses `nativeAmount` but the vault asset is not the chain's wNative. */
|
|
80
|
+
export class NativeAmountOnNonWNativeVaultError extends Error {
|
|
81
|
+
constructor(vaultAsset, wNative) {
|
|
82
|
+
super(`Cannot use nativeAmount: vault asset ${vaultAsset} is not the wrapped native token ${wNative}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Thrown when a `nativeAmount` is supplied but the chain has no configured wNative address. */
|
|
86
|
+
export class ChainWNativeMissingError extends Error {
|
|
87
|
+
constructor(chainId) {
|
|
88
|
+
super(`Chain ${chainId} does not have a configured wrapped native token (wNative)`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Thrown when `nativeAmount` is negative. */
|
|
92
|
+
export class NegativeNativeAmountError extends Error {
|
|
93
|
+
constructor(nativeAmount) {
|
|
94
|
+
super(`Native amount must not be negative, got ${nativeAmount}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Thrown when both `amount` and `nativeAmount` resolve to zero on a vault deposit. */
|
|
98
|
+
export class ZeroDepositAmountError extends Error {
|
|
99
|
+
constructor(vault) {
|
|
100
|
+
super(`Total deposit amount must be positive for vault: ${vault}. Both amount and nativeAmount are zero.`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Thrown when a vault entity's address does not match the vault address embedded in the call's args. */
|
|
104
|
+
export class VaultAddressMismatchError extends Error {
|
|
105
|
+
constructor(vaultAddress, argsVaultAddress) {
|
|
106
|
+
super(`Vault address mismatch between vault: ${vaultAddress} and args: ${argsVaultAddress}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Thrown when a market borrow amount is zero or negative. */
|
|
110
|
+
export class NonPositiveBorrowAmountError extends Error {
|
|
111
|
+
constructor(market) {
|
|
112
|
+
super(`Borrow amount must be positive for market: ${market}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** Thrown when both `amount` and `nativeAmount` resolve to zero on a market collateral supply. */
|
|
116
|
+
export class ZeroCollateralAmountError extends Error {
|
|
117
|
+
constructor(market) {
|
|
118
|
+
super(`Total collateral amount must be positive for market: ${market}. Both amount and nativeAmount are zero.`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Thrown when a collateral supply uses `nativeAmount` but the collateral token is not the chain's wNative. */
|
|
122
|
+
export class NativeAmountOnNonWNativeCollateralError extends Error {
|
|
123
|
+
constructor(collateralToken, wNative) {
|
|
124
|
+
super(`Cannot use nativeAmount: collateral token ${collateralToken} is not the wrapped native token ${wNative}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** Thrown when a borrow exceeds the LLTV-buffered safe maximum for the position. */
|
|
128
|
+
export class BorrowExceedsSafeLtvError extends Error {
|
|
129
|
+
constructor(borrowAmount, maxSafeBorrow) {
|
|
130
|
+
super(`Borrow amount ${borrowAmount} exceeds safe maximum ${maxSafeBorrow} (LLTV minus buffer). Reduce borrow or increase collateral.`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Thrown when the market's oracle price is unavailable and position health cannot be validated. */
|
|
134
|
+
export class MissingMarketPriceError extends Error {
|
|
135
|
+
constructor(market) {
|
|
136
|
+
super(`Oracle price unavailable for market ${market}. Cannot validate position health.`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Thrown when a `MarketParams.id` does not match the expected market id derived from the other fields. */
|
|
140
|
+
export class MarketIdMismatchError extends Error {
|
|
141
|
+
constructor(marketId, expectedMarketId) {
|
|
142
|
+
super(`Market ${marketId} does not match expected market ${expectedMarketId}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** Thrown when an accrual position belongs to a different user than the one expected by the call. */
|
|
146
|
+
export class AccrualPositionUserMismatchError extends Error {
|
|
147
|
+
constructor(positionUser, expectedUser) {
|
|
148
|
+
super(`Accrual position user ${positionUser} does not match expected user ${expectedUser}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Thrown when a reallocation's fee is negative. */
|
|
152
|
+
export class NegativeReallocationFeeError extends Error {
|
|
153
|
+
constructor(vault) {
|
|
154
|
+
super(`Reallocation fee must not be negative for vault: ${vault}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** Thrown when a reallocation has no withdrawals. */
|
|
158
|
+
export class EmptyReallocationWithdrawalsError extends Error {
|
|
159
|
+
constructor(vault) {
|
|
160
|
+
super(`Reallocation withdrawals list cannot be empty for vault: ${vault}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** Thrown when a reallocation withdrawal amount is zero or negative. */
|
|
164
|
+
export class NonPositiveReallocationAmountError extends Error {
|
|
165
|
+
constructor(vault, market) {
|
|
166
|
+
super(`Reallocation withdrawal amount must be positive for vault ${vault} on market ${market}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Thrown when a reallocation withdrawal references the borrow target market (which would be a no-op or self-deal). */
|
|
170
|
+
export class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
171
|
+
constructor(vault, marketId) {
|
|
172
|
+
super(`Reallocation withdrawal cannot include the borrow target market ${marketId} for vault ${vault}.`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
|
|
176
|
+
export class UnsortedReallocationWithdrawalsError extends Error {
|
|
177
|
+
constructor(vault, marketId) {
|
|
178
|
+
super(`Reallocation withdrawals must be strictly sorted by market ID for vault ${vault}. Market ${marketId} is out of order.`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/** Thrown when a market repay's `transferAmount` is zero or negative. */
|
|
182
|
+
export class NonPositiveTransferAmountError extends Error {
|
|
183
|
+
constructor(market) {
|
|
184
|
+
super(`Transfer amount must be positive for market: ${market}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** Thrown when a market repay in assets mode has `transferAmount !== assets` (asset-mode requires exact transfer). */
|
|
188
|
+
export class TransferAmountNotEqualToAssetsError extends Error {
|
|
189
|
+
constructor(params) {
|
|
190
|
+
super(`Transfer amount ${params.transferAmount} is not equal to repay assets ${params.assets} for market: ${params.market}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Thrown when a market repay specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
|
|
194
|
+
export class MutuallyExclusiveRepayAmountsError extends Error {
|
|
195
|
+
constructor(market) {
|
|
196
|
+
super(`Exactly one of assets or shares must be non-zero for market: ${market}. Both were provided.`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** Thrown when a market repay has non-positive amounts: both `assets` and `shares` are zero, or either is negative. */
|
|
200
|
+
export class NonPositiveRepayAmountError extends Error {
|
|
201
|
+
constructor(market) {
|
|
202
|
+
super(`Repay amount must be positive for market: ${market}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/** Thrown when a market repay's `maxSharePrice` slippage bound is zero or negative. */
|
|
206
|
+
export class NonPositiveRepayMaxSharePriceError extends Error {
|
|
207
|
+
constructor(market) {
|
|
208
|
+
super(`Max share price must be positive for market: ${market}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** Thrown when a market `withdrawCollateral` amount is zero or negative. */
|
|
212
|
+
export class NonPositiveWithdrawCollateralAmountError extends Error {
|
|
213
|
+
constructor(market) {
|
|
214
|
+
super(`Withdraw collateral amount must be positive for market: ${market}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/** Thrown when a withdraw amount exceeds the position's available collateral. */
|
|
218
|
+
export class WithdrawExceedsCollateralError extends Error {
|
|
219
|
+
constructor(params) {
|
|
220
|
+
super(`Withdraw amount ${params.withdrawAmount} exceeds available collateral ${params.available} for market: ${params.market}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** Thrown when a collateral withdrawal would leave the borrower's position above the LLTV-buffered safe maximum. */
|
|
224
|
+
export class WithdrawMakesPositionUnhealthyError extends Error {
|
|
225
|
+
constructor(params) {
|
|
226
|
+
super(`Withdrawing ${params.withdrawAmount} collateral would make position unhealthy. Max safe borrow after withdrawal: ${params.maxSafeBorrow}. Actual Borrow assets: ${params.borrowAssets}.`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/** Thrown when a share-amount conversion would divide by zero (the market has no shares of the relevant kind). */
|
|
230
|
+
export class ShareDivideByZeroError extends Error {
|
|
231
|
+
constructor(market) {
|
|
232
|
+
super(`Share divide by zero error for market: ${market}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/** Thrown when a repay amount in assets exceeds the borrower's outstanding debt. */
|
|
236
|
+
export class RepayExceedsDebtError extends Error {
|
|
237
|
+
constructor(params) {
|
|
238
|
+
super(`Repay amount ${params.repayAmount} exceeds outstanding debt ${params.debt} for market: ${params.market}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/** Thrown when EIP-712 signature verification fails (the signed data does not match the expected signer). */
|
|
242
|
+
export class InvalidSignatureError extends Error {
|
|
243
|
+
constructor() {
|
|
244
|
+
super("Signature verification failed: the signed data does not match the expected signer address");
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/** Thrown when a repay in shares mode supplies more shares than the borrower owes. */
|
|
248
|
+
export class RepaySharesExceedDebtError extends Error {
|
|
249
|
+
constructor(params) {
|
|
250
|
+
super(`Repay shares ${params.repayShares} exceed outstanding borrow shares ${params.borrowShares} for market: ${params.market}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/** Thrown when a vault selected for reallocation has no configured `PublicAllocator`. */
|
|
254
|
+
export class MissingPublicAllocatorConfigError extends Error {
|
|
255
|
+
constructor(vault) {
|
|
256
|
+
super(`Vault ${vault} has no public allocator configured but was selected for reallocation`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** Thrown when a market borrow's `minSharePrice` slippage bound is negative. */
|
|
260
|
+
export class NonPositiveMinBorrowSharePriceError extends Error {
|
|
261
|
+
constructor(market) {
|
|
262
|
+
super(`Min share price must be non-negative for market: ${market}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/** Thrown when a vault migration's source vault asset differs from the target vault asset. */
|
|
266
|
+
export class VaultAssetMismatchError extends Error {
|
|
267
|
+
constructor(sourceAsset, targetAsset) {
|
|
268
|
+
super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** Thrown when a vault redeem's `minSharePrice` slippage bound is negative. */
|
|
272
|
+
export class NegativeMinSharePriceError extends Error {
|
|
273
|
+
constructor(vault) {
|
|
274
|
+
super(`Min share price must be non-negative for vault: ${vault}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { MarketId, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
+
import type { PublicAllocatorOptions } from "@morpho-org/simulation-sdk";
|
|
3
|
+
import type { Address } from "viem";
|
|
4
|
+
/** A single withdrawal from a source market within a vault reallocation. */
|
|
5
|
+
export interface ReallocationWithdrawal {
|
|
6
|
+
readonly marketParams: MarketParams;
|
|
7
|
+
readonly amount: bigint;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A computed reallocation for a single vault.
|
|
11
|
+
*
|
|
12
|
+
* Maps 1:1 to a `PublicAllocator.reallocateTo()` call.
|
|
13
|
+
* Withdraws from source markets and supplies to the target market.
|
|
14
|
+
*/
|
|
15
|
+
export interface VaultReallocation {
|
|
16
|
+
readonly vault: Address;
|
|
17
|
+
/** Fee in native token (ETH) paid to the PublicAllocator for this vault. */
|
|
18
|
+
readonly fee: bigint;
|
|
19
|
+
/** Source markets to withdraw from before supplying to the target market. */
|
|
20
|
+
readonly withdrawals: readonly ReallocationWithdrawal[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for computing vault reallocations via the public allocator.
|
|
24
|
+
*
|
|
25
|
+
* Extends {@link PublicAllocatorOptions} with supply-side utilization targets
|
|
26
|
+
* that determine when reallocation is triggered.
|
|
27
|
+
*/
|
|
28
|
+
export interface ReallocationComputeOptions extends PublicAllocatorOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Per-market target utilization above which the shared liquidity algorithm
|
|
31
|
+
* is triggered (scaled by WAD). Overrides `defaultSupplyTargetUtilization`
|
|
32
|
+
* for the specified market.
|
|
33
|
+
*/
|
|
34
|
+
readonly supplyTargetUtilization?: Record<MarketId, bigint | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* The default target utilization above which the shared liquidity algorithm
|
|
37
|
+
* is triggered (scaled by WAD).
|
|
38
|
+
* @default 90.5% (905000000000000000n)
|
|
39
|
+
*/
|
|
40
|
+
readonly defaultSupplyTargetUtilization?: bigint;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,78 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/morpho-sdk",
|
|
3
3
|
"description": "Abstraction layer for Morpho's complexity.",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Foulks-Plb <https://x.com/FoulkPlb>"
|
|
8
8
|
],
|
|
9
|
-
"repository": "github:morpho-org/
|
|
10
|
-
"homepage": "https://github.com/morpho-org/
|
|
9
|
+
"repository": "github:morpho-org/sdks",
|
|
10
|
+
"homepage": "https://github.com/morpho-org/sdks",
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/morpho-org/
|
|
12
|
+
"url": "https://github.com/morpho-org/sdks/issues",
|
|
13
13
|
"email": "contact@morpho.org"
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"lending",
|
|
19
|
-
"borrowing",
|
|
20
|
-
"defi",
|
|
21
|
-
"ethereum",
|
|
22
|
-
"vault",
|
|
23
|
-
"market",
|
|
24
|
-
"sdk",
|
|
25
|
-
"viem",
|
|
26
|
-
"erc4626",
|
|
27
|
-
"morpho-blue",
|
|
28
|
-
"metamorpho",
|
|
29
|
-
"typescript",
|
|
30
|
-
"bundler"
|
|
31
|
-
],
|
|
32
|
-
"main": "./lib/index.js",
|
|
33
|
-
"types": "./lib/index.d.ts",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "src/index.ts",
|
|
34
18
|
"files": [
|
|
35
19
|
"lib"
|
|
36
20
|
],
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"@vitest/ui": "3.2.4",
|
|
44
|
-
"dotenv": "^17.2.3",
|
|
45
|
-
"husky": "^9.1.7",
|
|
46
|
-
"typescript": "^5.7.2",
|
|
47
|
-
"viem": "^2.48.1",
|
|
48
|
-
"vitest": "^3.0.5"
|
|
49
|
-
},
|
|
50
|
-
"publishConfig": {
|
|
51
|
-
"access": "public"
|
|
21
|
+
"scripts": {
|
|
22
|
+
"prepublish": "$npm_execpath build",
|
|
23
|
+
"build": "tsc --noEmit && $npm_execpath build:cjs && $npm_execpath build:esm",
|
|
24
|
+
"build:cjs": "tsc --build tsconfig.build.cjs.json && echo '{\"type\":\"commonjs\"}' > lib/cjs/package.json",
|
|
25
|
+
"build:esm": "tsc --build tsconfig.build.esm.json && echo '{\"type\":\"module\"}' > lib/esm/package.json",
|
|
26
|
+
"test": "vitest --root ../.. --project morpho-sdk"
|
|
52
27
|
},
|
|
53
28
|
"dependencies": {
|
|
54
|
-
"@morpho-org/blue-sdk": "
|
|
55
|
-
"@morpho-org/blue-sdk-viem": "
|
|
56
|
-
"@morpho-org/bundler-sdk-viem": "
|
|
57
|
-
"@morpho-org/morpho-ts": "
|
|
58
|
-
"@morpho-org/simulation-sdk": "
|
|
29
|
+
"@morpho-org/blue-sdk": "workspace:^",
|
|
30
|
+
"@morpho-org/blue-sdk-viem": "workspace:^",
|
|
31
|
+
"@morpho-org/bundler-sdk-viem": "workspace:^",
|
|
32
|
+
"@morpho-org/morpho-ts": "workspace:^",
|
|
33
|
+
"@morpho-org/simulation-sdk": "workspace:^",
|
|
59
34
|
"zod": "^4.1.12"
|
|
60
35
|
},
|
|
61
36
|
"peerDependencies": {
|
|
62
37
|
"viem": "^2.0.0"
|
|
63
38
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@morpho-org/test": "workspace:^",
|
|
41
|
+
"dotenv": "^16.4.5",
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"viem": "^2.41.2",
|
|
44
|
+
"vitest": "^4.1.4"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"exports": {
|
|
48
|
+
".": {
|
|
49
|
+
"types": "./lib/esm/index.d.ts",
|
|
50
|
+
"import": "./lib/esm/index.js",
|
|
51
|
+
"require": "./lib/cjs/index.js"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
77
54
|
}
|
|
78
|
-
}
|
|
55
|
+
}
|