@morpho-org/consumer-sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +178 -44
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.js +1 -0
- package/lib/actions/requirements/getRequirements.js +3 -0
- package/lib/actions/requirements/getRequirementsAction.d.ts +2 -2
- package/lib/actions/requirements/getRequirementsAction.js +7 -7
- package/lib/actions/vaultV1/deposit.d.ts +41 -0
- package/lib/actions/vaultV1/deposit.js +116 -0
- package/lib/actions/vaultV1/index.d.ts +3 -0
- package/lib/actions/vaultV1/index.js +19 -0
- package/lib/actions/vaultV1/redeem.d.ts +29 -0
- package/lib/actions/vaultV1/redeem.js +48 -0
- package/lib/actions/vaultV1/withdraw.d.ts +29 -0
- package/lib/actions/vaultV1/withdraw.js +48 -0
- package/lib/actions/vaultV2/deposit.d.ts +20 -25
- package/lib/actions/vaultV2/deposit.js +78 -40
- package/lib/actions/vaultV2/forceRedeem.js +2 -2
- package/lib/actions/vaultV2/forceWithdraw.d.ts +2 -2
- package/lib/actions/vaultV2/forceWithdraw.js +8 -8
- package/lib/actions/vaultV2/redeem.js +2 -2
- package/lib/actions/vaultV2/withdraw.d.ts +3 -3
- package/lib/actions/vaultV2/withdraw.js +6 -6
- package/lib/client/morphoClient.d.ts +2 -1
- package/lib/client/morphoClient.js +3 -0
- package/lib/client/morphoViemExtension.d.ts +12 -9
- package/lib/client/morphoViemExtension.js +12 -9
- package/lib/entities/index.d.ts +1 -0
- package/lib/entities/index.js +1 -0
- package/lib/entities/vaultV1/index.d.ts +1 -0
- package/lib/entities/vaultV1/index.js +17 -0
- package/lib/entities/vaultV1/vaultV1.d.ts +95 -0
- package/lib/entities/vaultV1/vaultV1.js +125 -0
- package/lib/entities/vaultV2/vaultV2.d.ts +24 -21
- package/lib/entities/vaultV2/vaultV2.js +39 -16
- package/lib/helpers/encodeDeallocation.js +3 -3
- package/lib/types/action.d.ts +39 -4
- package/lib/types/client.d.ts +2 -1
- package/lib/types/deallocation.d.ts +1 -1
- package/lib/types/error.d.ts +22 -4
- package/lib/types/error.js +48 -12
- package/package.json +1 -1
package/lib/types/error.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeallocationsExceedWithdrawError = exports.DepositAssetMismatchError = exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.ApprovalAmountLessThanSpendAmountError = exports.MissingClientPropertyError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.
|
|
4
|
-
class
|
|
3
|
+
exports.VaultAddressMismatchError = exports.ZeroDepositAmountError = exports.NegativeNativeAmountError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.DeallocationsExceedWithdrawError = exports.DepositAssetMismatchError = exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.NegativeSlippageToleranceError = exports.ApprovalAmountLessThanSpendAmountError = exports.MissingClientPropertyError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.NonPositiveMaxSharePriceError = exports.NonPositiveSharesAmountError = exports.NonPositiveAssetAmountError = void 0;
|
|
4
|
+
class NonPositiveAssetAmountError extends Error {
|
|
5
5
|
constructor(origin) {
|
|
6
|
-
super(`Asset amount
|
|
6
|
+
super(`Asset amount must be positive for address ${origin}`);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
exports.
|
|
10
|
-
class
|
|
9
|
+
exports.NonPositiveAssetAmountError = NonPositiveAssetAmountError;
|
|
10
|
+
class NonPositiveSharesAmountError extends Error {
|
|
11
11
|
constructor(vault) {
|
|
12
|
-
super(`Shares amount
|
|
12
|
+
super(`Shares amount must be positive for address: ${vault}`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
exports.
|
|
16
|
-
class
|
|
15
|
+
exports.NonPositiveSharesAmountError = NonPositiveSharesAmountError;
|
|
16
|
+
class NonPositiveMaxSharePriceError extends Error {
|
|
17
17
|
constructor(vault) {
|
|
18
|
-
super(`Max share price
|
|
18
|
+
super(`Max share price must be positive for vault: ${vault}`);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
exports.
|
|
21
|
+
exports.NonPositiveMaxSharePriceError = NonPositiveMaxSharePriceError;
|
|
22
22
|
class AddressMismatchError extends Error {
|
|
23
23
|
constructor(clientAddress, argsAddress) {
|
|
24
24
|
super(`Address mismatch between client: ${clientAddress} and args: ${argsAddress}`);
|
|
@@ -43,6 +43,12 @@ class ApprovalAmountLessThanSpendAmountError extends Error {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
exports.ApprovalAmountLessThanSpendAmountError = ApprovalAmountLessThanSpendAmountError;
|
|
46
|
+
class NegativeSlippageToleranceError extends Error {
|
|
47
|
+
constructor(slippageTolerance) {
|
|
48
|
+
super(`Slippage tolerance ${slippageTolerance} must not be negative`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.NegativeSlippageToleranceError = NegativeSlippageToleranceError;
|
|
46
52
|
class ExcessiveSlippageToleranceError extends Error {
|
|
47
53
|
constructor(slippageTolerance) {
|
|
48
54
|
super(`Slippage tolerance ${slippageTolerance} exceeds maximum allowed (10%)`);
|
|
@@ -68,8 +74,38 @@ class DepositAssetMismatchError extends Error {
|
|
|
68
74
|
}
|
|
69
75
|
exports.DepositAssetMismatchError = DepositAssetMismatchError;
|
|
70
76
|
class DeallocationsExceedWithdrawError extends Error {
|
|
71
|
-
constructor(vault,
|
|
72
|
-
super(`Total deallocated
|
|
77
|
+
constructor(vault, withdrawAmount, totalDeallocated) {
|
|
78
|
+
super(`Total deallocated amount (${totalDeallocated}) exceed withdraw amount (${withdrawAmount}) for vault: ${vault}`);
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
exports.DeallocationsExceedWithdrawError = DeallocationsExceedWithdrawError;
|
|
82
|
+
class NativeAmountOnNonWNativeVaultError extends Error {
|
|
83
|
+
constructor(vaultAsset, wNative) {
|
|
84
|
+
super(`Cannot use nativeAmount: vault asset ${vaultAsset} is not the wrapped native token ${wNative}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.NativeAmountOnNonWNativeVaultError = NativeAmountOnNonWNativeVaultError;
|
|
88
|
+
class ChainWNativeMissingError extends Error {
|
|
89
|
+
constructor(chainId) {
|
|
90
|
+
super(`Chain ${chainId} does not have a configured wrapped native token (wNative)`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.ChainWNativeMissingError = ChainWNativeMissingError;
|
|
94
|
+
class NegativeNativeAmountError extends Error {
|
|
95
|
+
constructor(nativeAmount) {
|
|
96
|
+
super(`Native amount must not be negative, got ${nativeAmount}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.NegativeNativeAmountError = NegativeNativeAmountError;
|
|
100
|
+
class ZeroDepositAmountError extends Error {
|
|
101
|
+
constructor(vault) {
|
|
102
|
+
super(`Total deposit amount must be positive for vault: ${vault}. Both amount and nativeAmount are zero.`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.ZeroDepositAmountError = ZeroDepositAmountError;
|
|
106
|
+
class VaultAddressMismatchError extends Error {
|
|
107
|
+
constructor(vaultAddress, argsVaultAddress) {
|
|
108
|
+
super(`Vault address mismatch between vault: ${vaultAddress} and args: ${argsVaultAddress}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.VaultAddressMismatchError = VaultAddressMismatchError;
|
package/package.json
CHANGED