@morpho-org/morpho-sdk 9.6.0-next.0 → 9.6.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 +59 -0
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/cjs/actions/bundles/common.js +39 -32
- package/lib/cjs/actions/midnight/cancelAndMake.js +20 -98
- package/lib/cjs/actions/midnight/index.d.ts +2 -0
- package/lib/cjs/actions/midnight/index.js +2 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +5 -6
- package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +39 -0
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +91 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +31 -32
- package/lib/cjs/actions/midnight/takeBorrow.js +24 -23
- package/lib/cjs/actions/midnight/takeLend.js +24 -23
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +20 -19
- package/lib/cjs/actions/midnight/takeWithdraw.js +24 -23
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +44 -0
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +104 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +1 -0
- package/lib/cjs/actions/vaultV1/migrateToV2.js +7 -7
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/entities/index.d.ts +5 -5
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +77 -3
- package/lib/cjs/entities/midnight/midnight.js +174 -0
- package/lib/cjs/entities/midnight/types.d.ts +16 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +8 -33
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -33
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -5
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +3 -9
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +6 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/deadShares.js +0 -2
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +1 -0
- package/lib/cjs/helpers/signAndVerifyTypedData.js +12 -5
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +68 -0
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +129 -0
- package/lib/cjs/helpers/validateMidnightCollateralBatch.d.ts +14 -0
- package/lib/cjs/helpers/validateMidnightCollateralBatch.js +27 -0
- package/lib/cjs/helpers/validateMidnightCollateralSupplies.d.ts +17 -0
- package/lib/cjs/helpers/validateMidnightCollateralSupplies.js +28 -0
- package/lib/cjs/helpers/validatePositiveInput.d.ts +10 -0
- package/lib/cjs/helpers/validatePositiveInput.js +18 -0
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +5 -5
- package/lib/cjs/types/action.d.ts +18 -3
- package/lib/cjs/types/error.d.ts +23 -2
- package/lib/cjs/types/error.js +45 -5
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/esm/actions/bundles/common.js +39 -32
- package/lib/esm/actions/midnight/cancelAndMake.js +25 -103
- package/lib/esm/actions/midnight/index.d.ts +2 -0
- package/lib/esm/actions/midnight/index.js +2 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +5 -6
- package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +39 -0
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +87 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +33 -34
- package/lib/esm/actions/midnight/takeBorrow.js +25 -24
- package/lib/esm/actions/midnight/takeLend.js +25 -24
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +20 -19
- package/lib/esm/actions/midnight/takeWithdraw.js +25 -24
- package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +44 -0
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +100 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +1 -0
- package/lib/esm/actions/vaultV1/migrateToV2.js +8 -8
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/entities/index.d.ts +5 -5
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +77 -3
- package/lib/esm/entities/midnight/midnight.js +176 -2
- package/lib/esm/entities/midnight/types.d.ts +16 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +8 -33
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -33
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -5
- package/lib/esm/entities/vaultV2BlueReallocationData.js +3 -9
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/deadShares.js +1 -3
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +1 -0
- package/lib/esm/helpers/signAndVerifyTypedData.js +13 -6
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +68 -0
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +124 -0
- package/lib/esm/helpers/validateMidnightCollateralBatch.d.ts +14 -0
- package/lib/esm/helpers/validateMidnightCollateralBatch.js +24 -0
- package/lib/esm/helpers/validateMidnightCollateralSupplies.d.ts +17 -0
- package/lib/esm/helpers/validateMidnightCollateralSupplies.js +24 -0
- package/lib/esm/helpers/validatePositiveInput.d.ts +10 -0
- package/lib/esm/helpers/validatePositiveInput.js +14 -0
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/types/action.d.ts +18 -3
- package/lib/esm/types/error.d.ts +23 -2
- package/lib/esm/types/error.js +40 -3
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +6 -6
|
@@ -9,9 +9,11 @@ const index_js_1 = require("../../helpers/index.js");
|
|
|
9
9
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
10
10
|
const validateMidnightAccount_js_1 = require("../../helpers/validateMidnightAccount.js");
|
|
11
11
|
const validateMidnightBounds_js_1 = require("../../helpers/validateMidnightBounds.js");
|
|
12
|
+
const validateMidnightCollateralSupplies_js_1 = require("../../helpers/validateMidnightCollateralSupplies.js");
|
|
12
13
|
const validateMidnightMarket_js_1 = require("../../helpers/validateMidnightMarket.js");
|
|
13
14
|
const validateMidnightReceiver_js_1 = require("../../helpers/validateMidnightReceiver.js");
|
|
14
15
|
const validateMidnightTakeFeasibility_js_1 = require("../../helpers/validateMidnightTakeFeasibility.js");
|
|
16
|
+
const validatePositiveInput_js_1 = require("../../helpers/validatePositiveInput.js");
|
|
15
17
|
const validateTakeableOffers_js_1 = require("../../helpers/validateTakeableOffers.js");
|
|
16
18
|
const index_js_2 = require("../../types/index.js");
|
|
17
19
|
/**
|
|
@@ -98,15 +100,12 @@ const midnightSupplyCollateralTakeBorrow = (params) => {
|
|
|
98
100
|
if (params.collateralSupplies.length === 0) {
|
|
99
101
|
throw new index_js_2.EmptyMidnightCollateralSuppliesError();
|
|
100
102
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
midnight_sdk_1.MarketUtils.getCollateralByIndex(params.market, collateralIndex);
|
|
108
|
-
}
|
|
109
|
-
(0, validateMidnightBounds_js_1.validateMidnightCollateralSupplySums)("collateralSupplies", params.collateralSupplies);
|
|
103
|
+
// Validation only; checks supply entries and their per-index totals.
|
|
104
|
+
(0, validateMidnightCollateralSupplies_js_1.validateMidnightCollateralSupplies)({
|
|
105
|
+
market: params.market,
|
|
106
|
+
field: "collateralSupplies",
|
|
107
|
+
supplies: params.collateralSupplies,
|
|
108
|
+
});
|
|
110
109
|
const marketId = (0, validateTakeableOffers_js_1.validateTakeableOffers)({
|
|
111
110
|
market: params.market,
|
|
112
111
|
takeableOffers: params.takeableOffers,
|
|
@@ -121,31 +120,31 @@ const midnightSupplyCollateralTakeBorrow = (params) => {
|
|
|
121
120
|
receiver: params.receiver,
|
|
122
121
|
});
|
|
123
122
|
const { target } = params;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
if (target.units === viem_1.maxUint256) {
|
|
139
|
-
throw new index_js_2.UnboundedMidnightTakeInputError("target.units");
|
|
140
|
-
}
|
|
141
|
-
if (target.units <= 0n) {
|
|
142
|
-
throw new index_js_2.NonPositiveInputError("target.units", target.units);
|
|
123
|
+
switch (target.type) {
|
|
124
|
+
case "assets": {
|
|
125
|
+
// Validation only; rejects non-positive amounts.
|
|
126
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.assets", target.assets);
|
|
127
|
+
if (target.maxUnits === viem_1.maxUint256) {
|
|
128
|
+
throw new index_js_2.UnboundedMidnightTakeInputError("target.maxUnits");
|
|
129
|
+
}
|
|
130
|
+
// Validation only; rejects non-positive amounts.
|
|
131
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.maxUnits", target.maxUnits);
|
|
132
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.assets", target.assets);
|
|
133
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxUnits", target.maxUnits);
|
|
134
|
+
break;
|
|
143
135
|
}
|
|
144
|
-
|
|
145
|
-
|
|
136
|
+
default: {
|
|
137
|
+
if (target.units === viem_1.maxUint256) {
|
|
138
|
+
throw new index_js_2.UnboundedMidnightTakeInputError("target.units");
|
|
139
|
+
}
|
|
140
|
+
// Validation only; rejects non-positive amounts.
|
|
141
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.units", target.units);
|
|
142
|
+
// Validation only; rejects non-positive amounts.
|
|
143
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.minSellerAssets", target.minSellerAssets);
|
|
144
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
145
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minSellerAssets", target.minSellerAssets);
|
|
146
|
+
break;
|
|
146
147
|
}
|
|
147
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
148
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minSellerAssets", target.minSellerAssets);
|
|
149
148
|
}
|
|
150
149
|
if (params.deadline === viem_1.maxUint256) {
|
|
151
150
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
@@ -12,6 +12,7 @@ const validateMidnightBounds_js_1 = require("../../helpers/validateMidnightBound
|
|
|
12
12
|
const validateMidnightMarket_js_1 = require("../../helpers/validateMidnightMarket.js");
|
|
13
13
|
const validateMidnightReceiver_js_1 = require("../../helpers/validateMidnightReceiver.js");
|
|
14
14
|
const validateMidnightTakeFeasibility_js_1 = require("../../helpers/validateMidnightTakeFeasibility.js");
|
|
15
|
+
const validatePositiveInput_js_1 = require("../../helpers/validatePositiveInput.js");
|
|
15
16
|
const validateTakeableOffers_js_1 = require("../../helpers/validateTakeableOffers.js");
|
|
16
17
|
const index_js_2 = require("../../types/index.js");
|
|
17
18
|
/**
|
|
@@ -97,31 +98,31 @@ const midnightTakeBorrow = (params) => {
|
|
|
97
98
|
receiver: params.receiver,
|
|
98
99
|
});
|
|
99
100
|
const { target } = params;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
switch (target.type) {
|
|
102
|
+
case "assets": {
|
|
103
|
+
// Validation only; rejects non-positive amounts.
|
|
104
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.assets", target.assets);
|
|
105
|
+
if (target.maxUnits === viem_1.maxUint256) {
|
|
106
|
+
throw new index_js_2.UnboundedMidnightTakeInputError("target.maxUnits");
|
|
107
|
+
}
|
|
108
|
+
// Validation only; rejects non-positive amounts.
|
|
109
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.maxUnits", target.maxUnits);
|
|
110
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.assets", target.assets);
|
|
111
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxUnits", target.maxUnits);
|
|
112
|
+
break;
|
|
103
113
|
}
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
default: {
|
|
115
|
+
if (target.units === viem_1.maxUint256) {
|
|
116
|
+
throw new index_js_2.UnboundedMidnightTakeInputError("target.units");
|
|
117
|
+
}
|
|
118
|
+
// Validation only; rejects non-positive amounts.
|
|
119
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.units", target.units);
|
|
120
|
+
// Validation only; rejects non-positive amounts.
|
|
121
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.minSellerAssets", target.minSellerAssets);
|
|
122
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
123
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minSellerAssets", target.minSellerAssets);
|
|
124
|
+
break;
|
|
106
125
|
}
|
|
107
|
-
if (target.maxUnits <= 0n) {
|
|
108
|
-
throw new index_js_2.NonPositiveInputError("target.maxUnits", target.maxUnits);
|
|
109
|
-
}
|
|
110
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.assets", target.assets);
|
|
111
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxUnits", target.maxUnits);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
if (target.units === viem_1.maxUint256) {
|
|
115
|
-
throw new index_js_2.UnboundedMidnightTakeInputError("target.units");
|
|
116
|
-
}
|
|
117
|
-
if (target.units <= 0n) {
|
|
118
|
-
throw new index_js_2.NonPositiveInputError("target.units", target.units);
|
|
119
|
-
}
|
|
120
|
-
if (target.minSellerAssets <= 0n) {
|
|
121
|
-
throw new index_js_2.NonPositiveInputError("target.minSellerAssets", target.minSellerAssets);
|
|
122
|
-
}
|
|
123
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
124
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minSellerAssets", target.minSellerAssets);
|
|
125
126
|
}
|
|
126
127
|
if (params.deadline === viem_1.maxUint256) {
|
|
127
128
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
@@ -11,6 +11,7 @@ const validateMidnightAccount_js_1 = require("../../helpers/validateMidnightAcco
|
|
|
11
11
|
const validateMidnightBounds_js_1 = require("../../helpers/validateMidnightBounds.js");
|
|
12
12
|
const validateMidnightMarket_js_1 = require("../../helpers/validateMidnightMarket.js");
|
|
13
13
|
const validateMidnightReceiver_js_1 = require("../../helpers/validateMidnightReceiver.js");
|
|
14
|
+
const validatePositiveInput_js_1 = require("../../helpers/validatePositiveInput.js");
|
|
14
15
|
const validateTakeableOffers_js_1 = require("../../helpers/validateTakeableOffers.js");
|
|
15
16
|
const index_js_2 = require("../../types/index.js");
|
|
16
17
|
/**
|
|
@@ -87,31 +88,31 @@ const midnightTakeLend = (params) => {
|
|
|
87
88
|
});
|
|
88
89
|
(0, validateMidnightBounds_js_1.validateMidnightTakeableOfferBounds)(params.takeableOffers);
|
|
89
90
|
const { target } = params;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
switch (target.type) {
|
|
92
|
+
case "assets": {
|
|
93
|
+
// Validation only; rejects non-positive amounts.
|
|
94
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.assets", target.assets);
|
|
95
|
+
// Validation only; rejects non-positive amounts.
|
|
96
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.minUnits", target.minUnits);
|
|
97
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.assets", target.assets);
|
|
98
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minUnits", target.minUnits);
|
|
99
|
+
break;
|
|
93
100
|
}
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
default: {
|
|
102
|
+
if (target.units === viem_1.maxUint256) {
|
|
103
|
+
throw new index_js_2.UnboundedMidnightTakeInputError("target.units");
|
|
104
|
+
}
|
|
105
|
+
if (target.maxBuyerAssets === viem_1.maxUint256) {
|
|
106
|
+
throw new index_js_2.UnboundedMidnightTakeInputError("target.maxBuyerAssets");
|
|
107
|
+
}
|
|
108
|
+
// Validation only; rejects non-positive amounts.
|
|
109
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.units", target.units);
|
|
110
|
+
// Validation only; rejects non-positive amounts.
|
|
111
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.maxBuyerAssets", target.maxBuyerAssets);
|
|
112
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
113
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxBuyerAssets", target.maxBuyerAssets);
|
|
114
|
+
break;
|
|
96
115
|
}
|
|
97
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.assets", target.assets);
|
|
98
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minUnits", target.minUnits);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
if (target.units === viem_1.maxUint256) {
|
|
102
|
-
throw new index_js_2.UnboundedMidnightTakeInputError("target.units");
|
|
103
|
-
}
|
|
104
|
-
if (target.maxBuyerAssets === viem_1.maxUint256) {
|
|
105
|
-
throw new index_js_2.UnboundedMidnightTakeInputError("target.maxBuyerAssets");
|
|
106
|
-
}
|
|
107
|
-
if (target.units <= 0n) {
|
|
108
|
-
throw new index_js_2.NonPositiveInputError("target.units", target.units);
|
|
109
|
-
}
|
|
110
|
-
if (target.maxBuyerAssets <= 0n) {
|
|
111
|
-
throw new index_js_2.NonPositiveInputError("target.maxBuyerAssets", target.maxBuyerAssets);
|
|
112
|
-
}
|
|
113
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
114
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxBuyerAssets", target.maxBuyerAssets);
|
|
115
116
|
}
|
|
116
117
|
(0, validate_js_1.validateUint256Field)("maxContinuousFee", params.maxContinuousFee);
|
|
117
118
|
if (params.deadline === viem_1.maxUint256) {
|
|
@@ -11,6 +11,7 @@ const validateMidnightAccount_js_1 = require("../../helpers/validateMidnightAcco
|
|
|
11
11
|
const validateMidnightBounds_js_1 = require("../../helpers/validateMidnightBounds.js");
|
|
12
12
|
const validateMidnightMarket_js_1 = require("../../helpers/validateMidnightMarket.js");
|
|
13
13
|
const validateMidnightReceiver_js_1 = require("../../helpers/validateMidnightReceiver.js");
|
|
14
|
+
const validatePositiveInput_js_1 = require("../../helpers/validatePositiveInput.js");
|
|
14
15
|
const validateTakeableOffers_js_1 = require("../../helpers/validateTakeableOffers.js");
|
|
15
16
|
const index_js_2 = require("../../types/index.js");
|
|
16
17
|
/**
|
|
@@ -103,9 +104,8 @@ const midnightTakeRepayWithdrawCollateral = (params) => {
|
|
|
103
104
|
// Reject markets from another chain deployment before checking offers against them.
|
|
104
105
|
(0, validateMidnightMarket_js_1.validateMidnightMarket)({ market: params.market, chainId: params.chainId });
|
|
105
106
|
for (const [index, { collateralIndex, assets },] of params.collateralWithdrawals.entries()) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
107
|
+
// Validation only; rejects non-positive amounts.
|
|
108
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)(`collateralWithdrawals[${index}].assets`, assets);
|
|
109
109
|
if (assets !== viem_1.maxUint256) {
|
|
110
110
|
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)(`collateralWithdrawals[${index}].assets`, assets);
|
|
111
111
|
}
|
|
@@ -129,24 +129,25 @@ const midnightTakeRepayWithdrawCollateral = (params) => {
|
|
|
129
129
|
});
|
|
130
130
|
(0, validateMidnightBounds_js_1.validateMidnightTakeableOfferBounds)(params.takeableOffers);
|
|
131
131
|
const { target } = params;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
else {
|
|
140
|
-
if (target.units <= 0n) {
|
|
141
|
-
throw new index_js_2.NonPositiveInputError("target.units", target.units);
|
|
142
|
-
}
|
|
143
|
-
if (target.maxBuyerAssets <= 0n) {
|
|
144
|
-
throw new index_js_2.NonPositiveInputError("target.maxBuyerAssets", target.maxBuyerAssets);
|
|
132
|
+
switch (target.type) {
|
|
133
|
+
case "assets": {
|
|
134
|
+
// Validation only; rejects non-positive amounts.
|
|
135
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.minUnits", target.minUnits);
|
|
136
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.assets", target.assets);
|
|
137
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minUnits", target.minUnits);
|
|
138
|
+
break;
|
|
145
139
|
}
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
default: {
|
|
141
|
+
// Validation only; rejects non-positive amounts.
|
|
142
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.units", target.units);
|
|
143
|
+
// Validation only; rejects non-positive amounts.
|
|
144
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.maxBuyerAssets", target.maxBuyerAssets);
|
|
145
|
+
if (target.units !== viem_1.maxUint256) {
|
|
146
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
147
|
+
}
|
|
148
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxBuyerAssets", target.maxBuyerAssets);
|
|
149
|
+
break;
|
|
148
150
|
}
|
|
149
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxBuyerAssets", target.maxBuyerAssets);
|
|
150
151
|
}
|
|
151
152
|
(0, validate_js_1.validateUint256Field)("maxContinuousFee", params.maxContinuousFee);
|
|
152
153
|
if (params.deadline === viem_1.maxUint256) {
|
|
@@ -12,6 +12,7 @@ const validateMidnightBounds_js_1 = require("../../helpers/validateMidnightBound
|
|
|
12
12
|
const validateMidnightMarket_js_1 = require("../../helpers/validateMidnightMarket.js");
|
|
13
13
|
const validateMidnightReceiver_js_1 = require("../../helpers/validateMidnightReceiver.js");
|
|
14
14
|
const validateMidnightTakeFeasibility_js_1 = require("../../helpers/validateMidnightTakeFeasibility.js");
|
|
15
|
+
const validatePositiveInput_js_1 = require("../../helpers/validatePositiveInput.js");
|
|
15
16
|
const validateTakeableOffers_js_1 = require("../../helpers/validateTakeableOffers.js");
|
|
16
17
|
const index_js_2 = require("../../types/index.js");
|
|
17
18
|
const validateParams = (params) => {
|
|
@@ -32,31 +33,31 @@ const validateParams = (params) => {
|
|
|
32
33
|
receiver: params.receiver,
|
|
33
34
|
});
|
|
34
35
|
const { target } = params;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
switch (target.type) {
|
|
37
|
+
case "assets": {
|
|
38
|
+
// Validation only; rejects non-positive amounts.
|
|
39
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.assets", target.assets);
|
|
40
|
+
if (target.maxUnits === viem_1.maxUint256) {
|
|
41
|
+
throw new index_js_2.UnboundedMidnightTakeInputError("target.maxUnits");
|
|
42
|
+
}
|
|
43
|
+
// Validation only; rejects non-positive amounts.
|
|
44
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.maxUnits", target.maxUnits);
|
|
45
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.assets", target.assets);
|
|
46
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxUnits", target.maxUnits);
|
|
47
|
+
break;
|
|
38
48
|
}
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
default: {
|
|
50
|
+
if (target.units === viem_1.maxUint256) {
|
|
51
|
+
throw new index_js_2.UnboundedMidnightTakeInputError("target.units");
|
|
52
|
+
}
|
|
53
|
+
// Validation only; rejects non-positive amounts.
|
|
54
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.units", target.units);
|
|
55
|
+
// Validation only; rejects non-positive amounts.
|
|
56
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("target.minSellerAssets", target.minSellerAssets);
|
|
57
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
58
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minSellerAssets", target.minSellerAssets);
|
|
59
|
+
break;
|
|
41
60
|
}
|
|
42
|
-
if (target.maxUnits <= 0n) {
|
|
43
|
-
throw new index_js_2.NonPositiveInputError("target.maxUnits", target.maxUnits);
|
|
44
|
-
}
|
|
45
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.assets", target.assets);
|
|
46
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.maxUnits", target.maxUnits);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
if (target.units === viem_1.maxUint256) {
|
|
50
|
-
throw new index_js_2.UnboundedMidnightTakeInputError("target.units");
|
|
51
|
-
}
|
|
52
|
-
if (target.units <= 0n) {
|
|
53
|
-
throw new index_js_2.NonPositiveInputError("target.units", target.units);
|
|
54
|
-
}
|
|
55
|
-
if (target.minSellerAssets <= 0n) {
|
|
56
|
-
throw new index_js_2.NonPositiveInputError("target.minSellerAssets", target.minSellerAssets);
|
|
57
|
-
}
|
|
58
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.units", target.units);
|
|
59
|
-
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("target.minSellerAssets", target.minSellerAssets);
|
|
60
61
|
}
|
|
61
62
|
if (params.deadline === viem_1.maxUint256) {
|
|
62
63
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type MarketInput } from "@morpho-org/midnight-sdk";
|
|
2
|
+
import { type Address } from "viem";
|
|
3
|
+
import { type Metadata, type MidnightCollateralTransfer, type MidnightWithdrawCollateralBatchAction, type Transaction } from "../../types/index.js";
|
|
4
|
+
/** Parameters for an atomic direct Midnight collateral withdrawal batch. */
|
|
5
|
+
export interface MidnightWithdrawCollateralBatchParams {
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
readonly market: MarketInput;
|
|
8
|
+
readonly collateralWithdrawals: readonly MidnightCollateralTransfer[];
|
|
9
|
+
readonly onBehalf: Address;
|
|
10
|
+
readonly receiver: Address;
|
|
11
|
+
readonly metadata?: Metadata;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Encodes ordered collateral withdrawals in one Midnight multicall, even for one entry.
|
|
15
|
+
* Duplicates are rejected: pass one entry per index, unlike bundle flows which sum them.
|
|
16
|
+
*
|
|
17
|
+
* @param params - Market, ordered withdrawals, owner, shared receiver and optional metadata.
|
|
18
|
+
* @param params.chainId - Chain containing Midnight.
|
|
19
|
+
* @param params.market - Market holding collateral.
|
|
20
|
+
* @param params.collateralWithdrawals - Nonempty ordered withdrawals, with unique collateral indexes.
|
|
21
|
+
* @param params.onBehalf - Collateral owner; this account or an authorized operator must send the transaction.
|
|
22
|
+
* @param params.receiver - Shared recipient of all withdrawn collateral.
|
|
23
|
+
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
24
|
+
* @returns A deep-frozen transaction targeting Midnight.
|
|
25
|
+
* @throws {EmptyMidnightCollateralWithdrawalsError} when the list is empty.
|
|
26
|
+
* @throws {DuplicateMidnightCollateralIndexError} when an index repeats.
|
|
27
|
+
* @throws {MidnightZeroReceiverError} when receiver is zero.
|
|
28
|
+
* @throws {MidnightContractReceiverError} when receiver cannot safely receive collateral.
|
|
29
|
+
* @throws {NonPositiveInputError} when assets are not positive.
|
|
30
|
+
* @throws {InputExceedsMaxError} when assets exceed uint128.
|
|
31
|
+
* @throws {MidnightZeroOnBehalfError} when onBehalf is zero.
|
|
32
|
+
* @throws {ChainIdMismatchError} when the market targets another chain.
|
|
33
|
+
* @throws {MidnightMarketAddressMismatchError} when the deployment differs.
|
|
34
|
+
* @throws {UnknownCollateralIndexError} when an index is not configured.
|
|
35
|
+
* @throws {MidnightCalldataEncodingError} when an address or ABI input is malformed.
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const tx = midnightWithdrawCollateralBatch({
|
|
39
|
+
* chainId: 8453, market: marketData.params, onBehalf: user, receiver: user,
|
|
40
|
+
* collateralWithdrawals: [{ collateralIndex: 0n, assets: 100n }],
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const midnightWithdrawCollateralBatch: (params: MidnightWithdrawCollateralBatchParams) => Readonly<Transaction<MidnightWithdrawCollateralBatchAction>>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.midnightWithdrawCollateralBatch = void 0;
|
|
4
|
+
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const encodeMidnightCalldata_js_1 = require("../../helpers/encodeMidnightCalldata.js");
|
|
8
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
9
|
+
const validateMidnightAccount_js_1 = require("../../helpers/validateMidnightAccount.js");
|
|
10
|
+
const validateMidnightBounds_js_1 = require("../../helpers/validateMidnightBounds.js");
|
|
11
|
+
const validateMidnightCollateralBatch_js_1 = require("../../helpers/validateMidnightCollateralBatch.js");
|
|
12
|
+
const validateMidnightMarket_js_1 = require("../../helpers/validateMidnightMarket.js");
|
|
13
|
+
const validateMidnightReceiver_js_1 = require("../../helpers/validateMidnightReceiver.js");
|
|
14
|
+
const index_js_2 = require("../../types/index.js");
|
|
15
|
+
/**
|
|
16
|
+
* Encodes ordered collateral withdrawals in one Midnight multicall, even for one entry.
|
|
17
|
+
* Duplicates are rejected: pass one entry per index, unlike bundle flows which sum them.
|
|
18
|
+
*
|
|
19
|
+
* @param params - Market, ordered withdrawals, owner, shared receiver and optional metadata.
|
|
20
|
+
* @param params.chainId - Chain containing Midnight.
|
|
21
|
+
* @param params.market - Market holding collateral.
|
|
22
|
+
* @param params.collateralWithdrawals - Nonempty ordered withdrawals, with unique collateral indexes.
|
|
23
|
+
* @param params.onBehalf - Collateral owner; this account or an authorized operator must send the transaction.
|
|
24
|
+
* @param params.receiver - Shared recipient of all withdrawn collateral.
|
|
25
|
+
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
26
|
+
* @returns A deep-frozen transaction targeting Midnight.
|
|
27
|
+
* @throws {EmptyMidnightCollateralWithdrawalsError} when the list is empty.
|
|
28
|
+
* @throws {DuplicateMidnightCollateralIndexError} when an index repeats.
|
|
29
|
+
* @throws {MidnightZeroReceiverError} when receiver is zero.
|
|
30
|
+
* @throws {MidnightContractReceiverError} when receiver cannot safely receive collateral.
|
|
31
|
+
* @throws {NonPositiveInputError} when assets are not positive.
|
|
32
|
+
* @throws {InputExceedsMaxError} when assets exceed uint128.
|
|
33
|
+
* @throws {MidnightZeroOnBehalfError} when onBehalf is zero.
|
|
34
|
+
* @throws {ChainIdMismatchError} when the market targets another chain.
|
|
35
|
+
* @throws {MidnightMarketAddressMismatchError} when the deployment differs.
|
|
36
|
+
* @throws {UnknownCollateralIndexError} when an index is not configured.
|
|
37
|
+
* @throws {MidnightCalldataEncodingError} when an address or ABI input is malformed.
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const tx = midnightWithdrawCollateralBatch({
|
|
41
|
+
* chainId: 8453, market: marketData.params, onBehalf: user, receiver: user,
|
|
42
|
+
* collateralWithdrawals: [{ collateralIndex: 0n, assets: 100n }],
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
const midnightWithdrawCollateralBatch = (params) => {
|
|
47
|
+
// Reject malformed addresses before comparing with zero.
|
|
48
|
+
(0, validateMidnightAccount_js_1.validateMidnightAddress)("onBehalf", params.onBehalf);
|
|
49
|
+
if ((0, viem_1.isAddressEqual)(params.onBehalf, viem_1.zeroAddress)) {
|
|
50
|
+
throw new index_js_2.MidnightZeroOnBehalfError("onBehalf");
|
|
51
|
+
}
|
|
52
|
+
// Reject markets from another deployment before encoding.
|
|
53
|
+
(0, validateMidnightMarket_js_1.validateMidnightMarket)({ market: params.market, chainId: params.chainId });
|
|
54
|
+
(0, validateMidnightReceiver_js_1.validateMidnightReceiver)({
|
|
55
|
+
chainId: params.chainId,
|
|
56
|
+
market: params.market,
|
|
57
|
+
field: "receiver",
|
|
58
|
+
receiver: params.receiver,
|
|
59
|
+
});
|
|
60
|
+
// Direct batches require one entry per index rather than summing duplicates.
|
|
61
|
+
(0, validateMidnightCollateralBatch_js_1.validateMidnightCollateralBatch)(params.collateralWithdrawals, new index_js_2.EmptyMidnightCollateralWithdrawalsError());
|
|
62
|
+
const calls = params.collateralWithdrawals.map(({ collateralIndex, assets }) => {
|
|
63
|
+
if (assets <= 0n)
|
|
64
|
+
throw new index_js_2.NonPositiveInputError("assets", assets);
|
|
65
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("assets", assets);
|
|
66
|
+
// Reject indexes not configured on the market.
|
|
67
|
+
midnight_sdk_1.MarketUtils.getCollateralByIndex(params.market, collateralIndex);
|
|
68
|
+
return (0, encodeMidnightCalldata_js_1.encodeMidnightCalldata)({
|
|
69
|
+
abi: midnight_sdk_1.midnightAbi,
|
|
70
|
+
functionName: "withdrawCollateral",
|
|
71
|
+
args: [
|
|
72
|
+
midnight_sdk_1.MarketUtils.toStruct(params.market),
|
|
73
|
+
collateralIndex,
|
|
74
|
+
assets,
|
|
75
|
+
params.onBehalf,
|
|
76
|
+
params.receiver,
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
let tx = {
|
|
81
|
+
to: (0, morpho_ts_1.getChainAddress)(params.chainId, "midnight"),
|
|
82
|
+
value: 0n,
|
|
83
|
+
data: (0, encodeMidnightCalldata_js_1.encodeMidnightCalldata)({
|
|
84
|
+
abi: midnight_sdk_1.midnightAbi,
|
|
85
|
+
functionName: "multicall",
|
|
86
|
+
args: [calls],
|
|
87
|
+
}),
|
|
88
|
+
};
|
|
89
|
+
if (params.metadata)
|
|
90
|
+
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
91
|
+
return (0, morpho_ts_1.deepFreeze)({
|
|
92
|
+
...tx,
|
|
93
|
+
action: {
|
|
94
|
+
type: "midnightWithdrawCollateralBatch",
|
|
95
|
+
args: {
|
|
96
|
+
market: (0, encodeMidnightCalldata_js_1.encodeMidnightMarketId)(params.market),
|
|
97
|
+
collateralWithdrawals: params.collateralWithdrawals.map(({ collateralIndex, assets }) => ({ collateralIndex, assets })),
|
|
98
|
+
onBehalf: params.onBehalf,
|
|
99
|
+
receiver: params.receiver,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
exports.midnightWithdrawCollateralBatch = midnightWithdrawCollateralBatch;
|
|
@@ -55,6 +55,7 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
55
55
|
* @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
|
|
56
56
|
* client account differs from `userAddress`.
|
|
57
57
|
* @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails.
|
|
58
|
+
* @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
|
|
58
59
|
* @example
|
|
59
60
|
* ```ts
|
|
60
61
|
* import { createWalletClient, http } from "viem";
|
|
@@ -44,6 +44,7 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
44
44
|
* @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
|
|
45
45
|
* client account differs from `userAddress`.
|
|
46
46
|
* @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails.
|
|
47
|
+
* @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
|
|
47
48
|
* @example
|
|
48
49
|
* ```ts
|
|
49
50
|
* import { createWalletClient, http } from "viem";
|
|
@@ -62,6 +62,7 @@ interface EncodeErc20PermitParams {
|
|
|
62
62
|
* @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
|
|
63
63
|
* client account differs from `userAddress`.
|
|
64
64
|
* @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails.
|
|
65
|
+
* @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
|
|
65
66
|
* @example
|
|
66
67
|
* ```ts
|
|
67
68
|
* import { createWalletClient, http } from "viem";
|
|
@@ -55,6 +55,7 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
|
|
|
55
55
|
* @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
|
|
56
56
|
* client account differs from `userAddress`.
|
|
57
57
|
* @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails.
|
|
58
|
+
* @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
|
|
58
59
|
* @example
|
|
59
60
|
* ```ts
|
|
60
61
|
* import { createWalletClient, http } from "viem";
|
|
@@ -48,6 +48,7 @@ export interface EncodeErc20Permit2SignatureTransferParams {
|
|
|
48
48
|
* @throws {AddressMismatchError} from `sign()` when the wallet account differs from `userAddress`.
|
|
49
49
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet chain differs from `chainId`.
|
|
50
50
|
* @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails.
|
|
51
|
+
* @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
|
|
51
52
|
* @example
|
|
52
53
|
* ```ts
|
|
53
54
|
* import { addressesRegistry } from "@morpho-org/blue-sdk";
|
|
@@ -36,6 +36,7 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
36
36
|
* @throws {AddressMismatchError} from `sign()` when the wallet account differs from `userAddress`.
|
|
37
37
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet chain differs from `chainId`.
|
|
38
38
|
* @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails.
|
|
39
|
+
* @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
|
|
39
40
|
* @example
|
|
40
41
|
* ```ts
|
|
41
42
|
* import { addressesRegistry } from "@morpho-org/blue-sdk";
|
|
@@ -46,6 +46,7 @@ export interface EncodeVaultSharesPermitParams {
|
|
|
46
46
|
* wallet account differs from `userAddress`.
|
|
47
47
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
|
|
48
48
|
* @throws {InvalidSignatureError} from `sign()` when signature recovery fails.
|
|
49
|
+
* @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
|
|
49
50
|
* @throws {InvalidPermitDomainChainIdError} when a Vault V1 permit domain targets another chain or omits `chainId`.
|
|
50
51
|
* @throws {InvalidPermitDomainVerifyingContractError} when a Vault V1 permit domain targets another token or omits `verifyingContract`.
|
|
51
52
|
* @throws {UnsupportedPermitDomainExtensionsError} when a Vault V1 permit domain advertises unsupported extensions.
|
|
@@ -36,6 +36,7 @@ const index_js_1 = require("../../../types/index.js");
|
|
|
36
36
|
* wallet account differs from `userAddress`.
|
|
37
37
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
|
|
38
38
|
* @throws {InvalidSignatureError} from `sign()` when signature recovery fails.
|
|
39
|
+
* @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
|
|
39
40
|
* @throws {InvalidPermitDomainChainIdError} when a Vault V1 permit domain targets another chain or omits `chainId`.
|
|
40
41
|
* @throws {InvalidPermitDomainVerifyingContractError} when a Vault V1 permit domain targets another token or omits `verifyingContract`.
|
|
41
42
|
* @throws {UnsupportedPermitDomainExtensionsError} when a Vault V1 permit domain advertises unsupported extensions.
|
|
@@ -5,6 +5,7 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
|
5
5
|
const viem_1 = require("viem");
|
|
6
6
|
const abis_js_1 = require("../../abis.js");
|
|
7
7
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
8
|
+
const validatePositiveInput_js_1 = require("../../helpers/validatePositiveInput.js");
|
|
8
9
|
const index_js_1 = require("../../types/index.js");
|
|
9
10
|
const common_js_1 = require("../bundles/common.js");
|
|
10
11
|
/**
|
|
@@ -89,14 +90,13 @@ const vaultV1MigrateToV2 = (params) => {
|
|
|
89
90
|
throw new index_js_1.AmountAndSharesExclusiveError();
|
|
90
91
|
}
|
|
91
92
|
const selectedAmount = assets ?? shares ?? 0n;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
93
|
+
const amountField = assets != null ? "assets" : "shares";
|
|
94
|
+
// Validation only; rejects non-positive migration amounts.
|
|
95
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)(amountField, selectedAmount);
|
|
96
|
+
// Validation only; rejects non-positive share-price bounds.
|
|
97
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("maxSharePriceVaultV2", params.args.maxSharePriceVaultV2);
|
|
98
98
|
// Reject ABI overflow with SDK errors before calldata encoding.
|
|
99
|
-
(0, validate_js_1.validateUint256Field)(
|
|
99
|
+
(0, validate_js_1.validateUint256Field)(amountField, selectedAmount);
|
|
100
100
|
(0, validate_js_1.validateUint256Field)("maxSharePriceVaultV2", params.args.maxSharePriceVaultV2);
|
|
101
101
|
const common = (0, common_js_1.normalizeBundlesCommonParams)(params.args);
|
|
102
102
|
const spender = (0, morpho_ts_1.getChainAddress)(params.vault.chainId, "bundles.vaultBundlesV1");
|
package/lib/cjs/blue/abis.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi,
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
preLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|