@morpho-org/morpho-sdk 9.3.0 → 9.5.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/MIGRATION-v5-to-v6.md +7 -0
- package/MIGRATION-v7-to-v8.md +7 -0
- package/MIGRATION-v8-to-v9.md +7 -0
- package/README.md +9 -5
- package/lib/cjs/abis.d.ts +2 -2
- package/lib/cjs/abis.js +4 -1
- package/lib/cjs/actions/blue/index.d.ts +1 -0
- package/lib/cjs/actions/blue/index.js +1 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +60 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +79 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +4 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +3 -1
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +1 -1
- package/lib/cjs/entities/blue/blue.d.ts +88 -23
- package/lib/cjs/entities/blue/blue.js +89 -22
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +21 -25
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +50 -85
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +6 -3
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +2 -2
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +5 -11
- package/lib/cjs/entities/vaultV1/vaultV1.js +3 -11
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +5 -11
- package/lib/cjs/entities/vaultV2/vaultV2.js +3 -11
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +40 -4
- package/lib/cjs/errors.d.ts +1 -1
- package/lib/cjs/errors.js +3 -1
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +2 -1
- package/lib/cjs/types/action.d.ts +26 -5
- package/lib/cjs/types/action.js +1 -0
- package/lib/cjs/types/error.d.ts +42 -2
- package/lib/cjs/types/error.js +49 -3
- package/lib/esm/abis.d.ts +2 -2
- package/lib/esm/abis.js +2 -2
- package/lib/esm/actions/blue/index.d.ts +1 -0
- package/lib/esm/actions/blue/index.js +1 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +60 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.js +75 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +4 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +88 -23
- package/lib/esm/entities/blue/blue.js +91 -24
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +21 -25
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +52 -87
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +6 -3
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +2 -2
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +5 -11
- package/lib/esm/entities/vaultV1/vaultV1.js +4 -12
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +5 -11
- package/lib/esm/entities/vaultV2/vaultV2.js +4 -12
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.js +40 -4
- package/lib/esm/errors.d.ts +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/types/action.d.ts +26 -5
- package/lib/esm/types/action.js +1 -0
- package/lib/esm/types/error.d.ts +42 -2
- package/lib/esm/types/error.js +43 -2
- package/package.json +5 -5
|
@@ -42,17 +42,12 @@ class MorphoVaultV2 {
|
|
|
42
42
|
* before any other requirement read. The `inKindRedeem` and `forceWithdraw` paths validate the
|
|
43
43
|
* client chain before this code check.
|
|
44
44
|
*
|
|
45
|
-
* @param roles - Registry labels to resolve and check
|
|
46
|
-
* chain registers none.
|
|
45
|
+
* @param roles - Registry labels to resolve and check.
|
|
47
46
|
*/
|
|
48
47
|
async assertWriteTargets(roles) {
|
|
49
48
|
const targets = [];
|
|
50
49
|
for (const role of roles) {
|
|
51
|
-
const address =
|
|
52
|
-
? (0, morpho_ts_1.getChainAddresses)(this.chainId).permit2
|
|
53
|
-
: (0, morpho_ts_1.getChainAddress)(this.chainId, role);
|
|
54
|
-
if (address == null)
|
|
55
|
-
continue;
|
|
50
|
+
const address = (0, morpho_ts_1.getChainAddress)(this.chainId, role);
|
|
56
51
|
targets.push({ role, address });
|
|
57
52
|
}
|
|
58
53
|
await (0, assertContractCode_js_1.assertRegistryTargetsHaveCode)(this.client.viemClient, this.chainId, targets);
|
|
@@ -100,9 +95,7 @@ class MorphoVaultV2 {
|
|
|
100
95
|
// Memoize the in-flight promise so concurrent callers share one round of
|
|
101
96
|
// allowance/nonce reads.
|
|
102
97
|
const pending = (async () => {
|
|
103
|
-
await this.assertWriteTargets(
|
|
104
|
-
? ["bundles.vaultBundlesV1", "permit2"]
|
|
105
|
-
: ["bundles.vaultBundlesV1"]);
|
|
98
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
|
|
106
99
|
return funding.value > 0n
|
|
107
100
|
? []
|
|
108
101
|
: (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
|
|
@@ -115,7 +108,6 @@ class MorphoVaultV2 {
|
|
|
115
108
|
supportSignature: this.client.options.supportSignature,
|
|
116
109
|
supportDeployless: this.client.options.supportDeployless,
|
|
117
110
|
useSimplePermit: requirementOptions?.useSimplePermit,
|
|
118
|
-
permit2Nonce: requirementOptions?.permit2Nonce,
|
|
119
111
|
now,
|
|
120
112
|
});
|
|
121
113
|
})();
|
|
@@ -450,6 +450,9 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
450
450
|
* Full-liquidity discovery omits a candidate when its non-shared maximum
|
|
451
451
|
* violates a shared cap instead of scanning smaller base-unit amounts. These
|
|
452
452
|
* bounds can understate executable liquidity in rounding-only edge cases.
|
|
453
|
+
* With an explicit Blue balance, a paid operation may retry the same search
|
|
454
|
+
* from a physical-funding budget and keep a strictly cheaper feasible plan.
|
|
455
|
+
* This bounded refinement does not guarantee globally minimal penalties.
|
|
453
456
|
*
|
|
454
457
|
* @param marketId - Target Blue market id.
|
|
455
458
|
* @param options - Optional discovery controls and operation to support.
|
|
@@ -654,6 +654,9 @@ class VaultV2BlueReallocationData {
|
|
|
654
654
|
* Full-liquidity discovery omits a candidate when its non-shared maximum
|
|
655
655
|
* violates a shared cap instead of scanning smaller base-unit amounts. These
|
|
656
656
|
* bounds can understate executable liquidity in rounding-only edge cases.
|
|
657
|
+
* With an explicit Blue balance, a paid operation may retry the same search
|
|
658
|
+
* from a physical-funding budget and keep a strictly cheaper feasible plan.
|
|
659
|
+
* This bounded refinement does not guarantee globally minimal penalties.
|
|
657
660
|
*
|
|
658
661
|
* @param marketId - Target Blue market id.
|
|
659
662
|
* @param options - Optional discovery controls and operation to support.
|
|
@@ -808,7 +811,7 @@ class VaultV2BlueReallocationData {
|
|
|
808
811
|
? [config.penalty]
|
|
809
812
|
: [])),
|
|
810
813
|
].sort((0, morpho_ts_1.bigIntComparator)((tier) => tier));
|
|
811
|
-
const plan = (maxAssets, headroom) => {
|
|
814
|
+
const plan = (maxAssets, { headroom, usePhysicalBalance = false, }) => {
|
|
812
815
|
let reserves = createCapReserveState(this.mutableMarkets);
|
|
813
816
|
const reallocations = [];
|
|
814
817
|
let data = this.clone();
|
|
@@ -832,6 +835,19 @@ class VaultV2BlueReallocationData {
|
|
|
832
835
|
: isFreeFriendlyPass
|
|
833
836
|
? maxAssets
|
|
834
837
|
: remainingShortfall;
|
|
838
|
+
if (usePhysicalBalance && penalty > 0n) {
|
|
839
|
+
const penaltyMultiplier = type === "refinance" ? 2n : 1n;
|
|
840
|
+
const physicalPenalty = penaltyMultiplier * penalty;
|
|
841
|
+
if (physicalPenalty < blue_sdk_1.MathLib.WAD) {
|
|
842
|
+
const idleAssets = reallocations.reduce((total, { from, assets }) => from.type === "idle" ? total + assets : total, 0n);
|
|
843
|
+
// Idle must fund both the operation and its penalty flash loan.
|
|
844
|
+
const physicalShortfall = blue_sdk_1.MathLib.zeroFloorSub(amount +
|
|
845
|
+
feeAssets +
|
|
846
|
+
penaltyMultiplier *
|
|
847
|
+
(0, common_js_1.getBlueBundlesV1PenaltyAssets)(reallocations), blueBalance + idleAssets);
|
|
848
|
+
passMaxAssets = blue_sdk_1.MathLib.max(passMaxAssets, blue_sdk_1.MathLib.mulDivUp(physicalShortfall, blue_sdk_1.MathLib.WAD, blue_sdk_1.MathLib.WAD - physicalPenalty));
|
|
849
|
+
}
|
|
850
|
+
}
|
|
835
851
|
const retryPaidPass = penalty > 0n;
|
|
836
852
|
let lo = retryPaidPass ? passMaxAssets - 1n : 0n;
|
|
837
853
|
let tryFullCapacityAttempt = false;
|
|
@@ -1022,6 +1038,8 @@ class VaultV2BlueReallocationData {
|
|
|
1022
1038
|
? reallocatedAssets >= absoluteShortfall + penaltyAssets
|
|
1023
1039
|
: reallocatedAssets >= absoluteShortfall;
|
|
1024
1040
|
return {
|
|
1041
|
+
maxAssets,
|
|
1042
|
+
headroom,
|
|
1025
1043
|
reallocations,
|
|
1026
1044
|
data,
|
|
1027
1045
|
liquidityBound: allocatorCapBoundTargets.size > 0 || idleBoundVaults.size > 0,
|
|
@@ -1038,12 +1056,12 @@ class VaultV2BlueReallocationData {
|
|
|
1038
1056
|
// (nearly) all of a source vault's starting idle, revert once another
|
|
1039
1057
|
// allocation lands first. A bound plan therefore moves only the operation's
|
|
1040
1058
|
// shortfall, or what unbound legs moved.
|
|
1041
|
-
const target = plan(requiredAssets, allocatorCapHeadroom);
|
|
1059
|
+
const target = plan(requiredAssets, { headroom: allocatorCapHeadroom });
|
|
1042
1060
|
let selected = target;
|
|
1043
1061
|
if (allocatorCapHeadroom > 0n && target.liquidityBound) {
|
|
1044
1062
|
selected = plan(absoluteShortfall > target.unboundAssets
|
|
1045
1063
|
? absoluteShortfall
|
|
1046
|
-
: target.unboundAssets, allocatorCapHeadroom);
|
|
1064
|
+
: target.unboundAssets, { headroom: allocatorCapHeadroom });
|
|
1047
1065
|
// Shared-cap fitting is not monotonic in the budget.
|
|
1048
1066
|
if (!selected.coversShortfall && target.coversShortfall)
|
|
1049
1067
|
selected = target;
|
|
@@ -1054,7 +1072,7 @@ class VaultV2BlueReallocationData {
|
|
|
1054
1072
|
for (const maxAssets of fullCapBudgets) {
|
|
1055
1073
|
if (selected.coversShortfall)
|
|
1056
1074
|
break;
|
|
1057
|
-
selected = plan(maxAssets, 0n);
|
|
1075
|
+
selected = plan(maxAssets, { headroom: 0n });
|
|
1058
1076
|
if (selected.reallocatedAssets > available)
|
|
1059
1077
|
available = selected.reallocatedAssets;
|
|
1060
1078
|
}
|
|
@@ -1086,6 +1104,24 @@ class VaultV2BlueReallocationData {
|
|
|
1086
1104
|
available,
|
|
1087
1105
|
});
|
|
1088
1106
|
}
|
|
1107
|
+
const selectedPenaltyAssets = (0, common_js_1.getBlueBundlesV1PenaltyAssets)(selected.reallocations);
|
|
1108
|
+
if (hasExplicitBlueBalance &&
|
|
1109
|
+
selectedPenaltyAssets > 1n &&
|
|
1110
|
+
blueBalance <
|
|
1111
|
+
amount +
|
|
1112
|
+
feeAssets +
|
|
1113
|
+
(type === "refinance" ? 2n : 1n) * selectedPenaltyAssets) {
|
|
1114
|
+
// Amount feasibility is not monotonic: retain the original plan unless
|
|
1115
|
+
// the physical-balance seed finds a fully funded, strictly cheaper one.
|
|
1116
|
+
const alternative = plan(selected.maxAssets, {
|
|
1117
|
+
headroom: selected.headroom,
|
|
1118
|
+
usePhysicalBalance: true,
|
|
1119
|
+
});
|
|
1120
|
+
if (alternative.coversShortfall &&
|
|
1121
|
+
(0, common_js_1.getBlueBundlesV1PenaltyAssets)(alternative.reallocations) <
|
|
1122
|
+
(0, common_js_1.getBlueBundlesV1PenaltyAssets)(selected.reallocations))
|
|
1123
|
+
selected = alternative;
|
|
1124
|
+
}
|
|
1089
1125
|
return { reallocations: selected.reallocations, data: selected.data };
|
|
1090
1126
|
}
|
|
1091
1127
|
computeVaultV2BlueReallocationsAtUtilizationInPlace({ context, reserves, marketId, maxWithdrawalUtilization, maxAssets, capAccrualBuffer, allocatorCapHeadroom = 0n, penalty, options = {}, }) {
|
package/lib/cjs/errors.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError
|
|
|
4
4
|
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
5
|
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
6
6
|
export type { ErrorClass } from "@morpho-org/morpho-ts";
|
|
7
|
-
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
|
7
|
+
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, RetriesExhaustedError, RetryStoppedError, } from "@morpho-org/morpho-ts";
|
package/lib/cjs/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.Permit2ExpirationOutOfRangeError = exports.NonTupleReturnValueError = exports.MissingPermitDomainNameError = exports.BlueMarketParamsIdMismatchError = exports.MalformedTokenMetadataError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
|
|
4
|
-
exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = void 0;
|
|
4
|
+
exports.RetryStoppedError = exports.RetriesExhaustedError = exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = void 0;
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
6
|
Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
|
|
7
7
|
Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: true, get: function () { return blue_sdk_1.IncompleteChainRegistryError; } });
|
|
@@ -70,3 +70,5 @@ Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: f
|
|
|
70
70
|
Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
|
|
71
71
|
Object.defineProperty(exports, "NegativeValueError", { enumerable: true, get: function () { return morpho_ts_1.NegativeValueError; } });
|
|
72
72
|
Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return morpho_ts_1.RegistryValueAlreadyRegisteredError; } });
|
|
73
|
+
Object.defineProperty(exports, "RetriesExhaustedError", { enumerable: true, get: function () { return morpho_ts_1.RetriesExhaustedError; } });
|
|
74
|
+
Object.defineProperty(exports, "RetryStoppedError", { enumerable: true, get: function () { return morpho_ts_1.RetryStoppedError; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { blueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
1
|
+
export { blueBuyCallbackAbi, blueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
package/lib/cjs/midnight/abis.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setterRatifierAbi = exports.rateRatifierV1Abi = exports.priceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.ecrecoverRatifierAbi = exports.ecrecoverAuthorizerAbi = exports.blueBuyCallbackFactoryAbi = void 0;
|
|
3
|
+
exports.setterRatifierAbi = exports.rateRatifierV1Abi = exports.priceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.ecrecoverRatifierAbi = exports.ecrecoverAuthorizerAbi = exports.blueBuyCallbackFactoryAbi = exports.blueBuyCallbackAbi = void 0;
|
|
4
4
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
+
Object.defineProperty(exports, "blueBuyCallbackAbi", { enumerable: true, get: function () { return midnight_sdk_1.blueBuyCallbackAbi; } });
|
|
5
6
|
Object.defineProperty(exports, "blueBuyCallbackFactoryAbi", { enumerable: true, get: function () { return midnight_sdk_1.blueBuyCallbackFactoryAbi; } });
|
|
6
7
|
Object.defineProperty(exports, "ecrecoverAuthorizerAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverAuthorizerAbi; } });
|
|
7
8
|
Object.defineProperty(exports, "ecrecoverRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverRatifierAbi; } });
|
|
@@ -282,6 +282,20 @@ export interface BlueWithdrawAction extends BaseAction<"blueWithdraw", {
|
|
|
282
282
|
readonly deadline: bigint;
|
|
283
283
|
}> {
|
|
284
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Metadata for a direct Morpho Blue withdrawal of a BlueBuyCallback's whole supply position,
|
|
287
|
+
* sent by the callback's owner.
|
|
288
|
+
*/
|
|
289
|
+
export interface BlueWithdrawBuyCallbackAction extends BaseAction<"blueWithdrawBuyCallback", {
|
|
290
|
+
readonly market: Hex;
|
|
291
|
+
/** Supply shares burned: the callback's whole position. */
|
|
292
|
+
readonly shares: bigint;
|
|
293
|
+
/** BlueBuyCallback whose supply position is withdrawn. */
|
|
294
|
+
readonly onBehalf: Address;
|
|
295
|
+
/** Account receiving the withdrawn loan assets: the callback's owner. */
|
|
296
|
+
readonly receiver: Address;
|
|
297
|
+
}> {
|
|
298
|
+
}
|
|
285
299
|
type BlueSupplyCollateralBorrowActionArgs = {
|
|
286
300
|
readonly market: Hex;
|
|
287
301
|
readonly collateralAssets: bigint;
|
|
@@ -510,7 +524,7 @@ export interface MidnightCancelAndMakeAction extends BaseAction<"midnightCancelA
|
|
|
510
524
|
* VaultV2, Blue, and Midnight flows. The `type` tag discriminates the union so
|
|
511
525
|
* consumers can `switch` exhaustively on it.
|
|
512
526
|
*/
|
|
513
|
-
export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightTakeWithdrawAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MidnightWithdrawCollateralAction | MidnightRedeemAction | MidnightTakeRepayWithdrawCollateralAction | MidnightRepayWithdrawCollateralAction | MidnightCancelAndMakeAction;
|
|
527
|
+
export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueWithdrawBuyCallbackAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightTakeWithdrawAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MidnightWithdrawCollateralAction | MidnightRedeemAction | MidnightTakeRepayWithdrawCollateralAction | MidnightRepayWithdrawCollateralAction | MidnightCancelAndMakeAction;
|
|
514
528
|
/**
|
|
515
529
|
* Describes a single, immutable, deep-frozen transaction to submit on-chain:
|
|
516
530
|
* the target `to`, native `value`, encoded call `data`, and the originating
|
|
@@ -534,9 +548,9 @@ export type BundlesFundingArgs = {
|
|
|
534
548
|
};
|
|
535
549
|
/** Controls token requirements generated for a bundles-funded action. */
|
|
536
550
|
export interface BundlesTokenRequirementsOptions {
|
|
537
|
-
/** Prefer ERC-2612 when the funded token exposes a compatible nonce. */
|
|
551
|
+
/** Prefer ERC-2612 when the funded token exposes a compatible nonce; defaults to true when signatures are supported. */
|
|
538
552
|
readonly useSimplePermit?: boolean;
|
|
539
|
-
/**
|
|
553
|
+
/** @deprecated Ignored. The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals. */
|
|
540
554
|
readonly permit2Nonce?: bigint;
|
|
541
555
|
}
|
|
542
556
|
/** Mutually exclusive source amount accepted by a Vault V1 to Vault V2 migration. */
|
|
@@ -598,7 +612,10 @@ export interface PermitAction extends BaseAction<"permit", {
|
|
|
598
612
|
*/
|
|
599
613
|
readonly typedData?: RequirementTypedData;
|
|
600
614
|
}
|
|
601
|
-
/**
|
|
615
|
+
/**
|
|
616
|
+
* Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull.
|
|
617
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
618
|
+
*/
|
|
602
619
|
export interface Permit2SignatureTransferAction extends BaseAction<"permit2SignatureTransfer", {
|
|
603
620
|
readonly spender: Address;
|
|
604
621
|
readonly amount: bigint;
|
|
@@ -630,7 +647,10 @@ export interface Erc2612RequirementSignature {
|
|
|
630
647
|
}
|
|
631
648
|
/** A signed ERC-2612 permit requirement accepted by vault-share bundle calls. */
|
|
632
649
|
export type PermitRequirementSignature = Erc2612RequirementSignature;
|
|
633
|
-
/**
|
|
650
|
+
/**
|
|
651
|
+
* A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts.
|
|
652
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
653
|
+
*/
|
|
634
654
|
export interface Permit2SignatureTransferRequirementSignature {
|
|
635
655
|
readonly args: Readonly<PermitArgs>;
|
|
636
656
|
readonly action: Permit2SignatureTransferAction;
|
|
@@ -860,6 +880,7 @@ export declare function isPermitSignature(signature: RequirementSignature): sign
|
|
|
860
880
|
* const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
|
|
861
881
|
* isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
|
|
862
882
|
* ```
|
|
883
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
863
884
|
*/
|
|
864
885
|
export declare function isPermit2SignatureTransferSignature(signature: RequirementSignature): signature is Permit2SignatureTransferRequirementSignature;
|
|
865
886
|
/**
|
package/lib/cjs/types/action.js
CHANGED
|
@@ -165,6 +165,7 @@ function isPermitSignature(signature) {
|
|
|
165
165
|
* const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
|
|
166
166
|
* isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
|
|
167
167
|
* ```
|
|
168
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
168
169
|
*/
|
|
169
170
|
function isPermit2SignatureTransferSignature(signature) {
|
|
170
171
|
return signature.action.type === "permit2SignatureTransfer";
|
package/lib/cjs/types/error.d.ts
CHANGED
|
@@ -538,7 +538,10 @@ export declare class BundlesRequirementSignatureMismatchError extends Error {
|
|
|
538
538
|
cause?: unknown;
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
|
-
/**
|
|
541
|
+
/**
|
|
542
|
+
* Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed.
|
|
543
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
544
|
+
*/
|
|
542
545
|
export declare class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
|
|
543
546
|
readonly owner: Address;
|
|
544
547
|
readonly nonce: bigint;
|
|
@@ -548,7 +551,10 @@ export declare class Permit2SignatureTransferNonceAlreadyUsedError extends Error
|
|
|
548
551
|
*/
|
|
549
552
|
constructor(owner: Address, nonce: bigint);
|
|
550
553
|
}
|
|
551
|
-
/**
|
|
554
|
+
/**
|
|
555
|
+
* Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce.
|
|
556
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
557
|
+
*/
|
|
552
558
|
export declare class NoUnusedPermit2NonceError extends Error {
|
|
553
559
|
readonly owner: Address;
|
|
554
560
|
readonly startNonce: bigint;
|
|
@@ -1475,6 +1481,40 @@ export declare class WithdrawSharesExceedSupplyError extends Error {
|
|
|
1475
1481
|
market: string;
|
|
1476
1482
|
});
|
|
1477
1483
|
}
|
|
1484
|
+
/** Thrown when a Blue withdrawal finds no supply shares to withdraw for the position owner. */
|
|
1485
|
+
export declare class EmptyBlueSupplyPositionError extends Error {
|
|
1486
|
+
constructor(params: {
|
|
1487
|
+
market: string;
|
|
1488
|
+
user: string;
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
/** Thrown when a Blue withdrawal needs more assets than the market's available liquidity. */
|
|
1492
|
+
export declare class InsufficientBlueLiquidityError extends Error {
|
|
1493
|
+
constructor(params: {
|
|
1494
|
+
market: string;
|
|
1495
|
+
assets: bigint;
|
|
1496
|
+
liquidity: bigint;
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
/** Thrown when an address is not a BlueBuyCallback created by the chain's registered factory. */
|
|
1500
|
+
export declare class NotBlueBuyCallbackError extends Error {
|
|
1501
|
+
constructor(callback: string);
|
|
1502
|
+
}
|
|
1503
|
+
/** Thrown when a BlueBuyCallback's `OWNER()` is not the account withdrawing its Blue position. */
|
|
1504
|
+
export declare class BlueBuyCallbackOwnerMismatchError extends Error {
|
|
1505
|
+
constructor(params: {
|
|
1506
|
+
callback: string;
|
|
1507
|
+
owner: string;
|
|
1508
|
+
userAddress: string;
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
/** Thrown when Morpho Blue does not authorize an account to withdraw a BlueBuyCallback's position. */
|
|
1512
|
+
export declare class BlueBuyCallbackUnauthorizedError extends Error {
|
|
1513
|
+
constructor(params: {
|
|
1514
|
+
callback: string;
|
|
1515
|
+
userAddress: string;
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1478
1518
|
/**
|
|
1479
1519
|
* Thrown when a Vault V2 reallocation planner receives a withdraw `amount` greater
|
|
1480
1520
|
* than the target market's current `totalSupplyAssets` — the post-withdraw
|
package/lib/cjs/types/error.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DepositOwnerMismatchError = exports.DepositAssetMismatchError = exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.MissingAccrualPositionError = exports.UnsupportedMidnightAuthorizationTargetError = exports.UnsupportedErc20ApprovalSpenderError = exports.MissingClientPropertyError = exports.CryptoUnavailableError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.UnsupportedRequirementSignatureError = exports.UnexpectedRequirementSignatureError = exports.AmbiguousRequirementSignaturesError = exports.MaxRepayAssetsBelowRepayAssetsError = exports.ReallocationsRequireBorrowError = exports.UnsupportedAuthorizationOperatorError = exports.ReallocationLoanTokenMismatchError = exports.SameVaultMigrationError = exports.AmountAndSharesExclusiveError = exports.MixedBundlesFundingError = exports.MidnightReferralFeePctExceededError = exports.ReferralFeePctExceededError = exports.ReferralFeeRecipientMissingError = exports.NativeFundingAmountMismatchError = exports.NoUnusedPermit2NonceError = exports.Permit2SignatureTransferNonceAlreadyUsedError = exports.BundlesRequirementSignatureMismatchError = exports.BundlesPermitMismatchError = exports.VaultIsBlueFeeRecipientError = exports.VaultMorphoMismatchError = exports.InsufficientBlueBalanceForInKindRedeemError = exports.InKindRedeemCoverageError = exports.InKindRedeemZeroDeallocationError = exports.VaultV2ForceWithdrawFeeSharesExceedBurnError = exports.VaultV2ForceWithdrawSharePriceBelowFloorError = exports.VaultV2ForceWithdrawZeroSharePriceError = exports.VaultV2ForceWithdrawZeroWithdrawalError = exports.VaultV2ForceWithdrawCoverageError = exports.VaultV2UndecodableLiquidityDataError = exports.VaultV2UnsupportedLiquidityAdapterError = exports.VaultV2UnsupportedExitAdapterError = exports.AdapterNotPartOfVaultError = exports.VaultV2SingleAdapterRequiredError = exports.ExpiredDeadlineError = exports.EmptyMarketParamsListError = exports.InputExceedsMaxError = exports.NonPositiveInputError = exports.NegativeInputError = void 0;
|
|
4
4
|
exports.MidnightOfferMarketAddressMismatchError = exports.MidnightOfferMarketChainMismatchError = exports.MidnightTakeDeadlineTooFarError = exports.MidnightContractReceiverError = exports.MidnightZeroOnBehalfError = exports.MidnightZeroReceiverError = exports.MidnightRepayExceedsDebtError = exports.MidnightContinuousFeeAboveMaxError = exports.MidnightTakeTargetUnreachableError = exports.MidnightTakeableOffersNotFillableError = exports.UnboundedMidnightTakeInputError = exports.MidnightOfferSellerReceiverMismatchError = exports.MidnightOfferContinuousFeeCapError = exports.MidnightOfferMakerMismatchError = exports.MidnightOfferReduceOnlyError = exports.MidnightOfferSideMismatchError = exports.EmptyMidnightTakeableOffersError = exports.DuplicateMidnightGroupCancellationError = exports.EmptyMidnightCollateralSuppliesError = exports.EmptyMidnightGroupCancellationsError = exports.ReallocationAdapterSupplySharesUnderflowError = exports.ReallocationAllocationUnderflowError = exports.UnknownReallocationAdapterError = exports.UnknownReallocationMarketPublicAllocatorConfigError = exports.UnknownReallocationActiveAdaptersError = exports.UnknownReallocationPublicAllocatorConfigError = exports.UnknownReallocationAllocationError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.RepaySharesExceedDebtError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.MutuallyExclusiveRepayAmountsError = exports.InconsistentReallocationPenaltyError = exports.InvalidReallocationSourceTypeError = exports.InvalidReallocationAddressError = exports.InvalidVaultV2BlueReallocationShapeError = exports.ReallocationWithdrawalOnTargetMarketError = exports.AccrualPositionUserMismatchError = exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeAssetError = exports.VaultAddressMismatchError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.DepositSpenderMismatchError = void 0;
|
|
5
|
-
exports.MidnightCalldataEncodingError = exports.MidnightZeroAccountError = exports.MissingContractCodeError = exports.MidnightOfferNotReduceOnlyError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.MidnightInvalidAccountAddressError = exports.InvalidMidnightHexInputError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.MidnightReplacementGroupCancelledError = exports.MidnightOfferRatifierMismatchError = exports.MidnightTakeableOfferZeroSellerReceiverError = exports.MidnightTakeableOfferMarketMismatchError = exports.MissingDeadSharesDataError = exports.InsufficientDeadSharesError = exports.ZeroBlueParkingSharesError = exports.EmptyBlueParkingMarketError = exports.MidnightOfferCallbackDataMismatchError = exports.MidnightOfferCallbackMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = void 0;
|
|
5
|
+
exports.MidnightCalldataEncodingError = exports.MidnightZeroAccountError = exports.MissingContractCodeError = exports.MidnightOfferNotReduceOnlyError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.BlueBuyCallbackUnauthorizedError = exports.BlueBuyCallbackOwnerMismatchError = exports.NotBlueBuyCallbackError = exports.InsufficientBlueLiquidityError = exports.EmptyBlueSupplyPositionError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.MidnightInvalidAccountAddressError = exports.InvalidMidnightHexInputError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.MidnightReplacementGroupCancelledError = exports.MidnightOfferRatifierMismatchError = exports.MidnightTakeableOfferZeroSellerReceiverError = exports.MidnightTakeableOfferMarketMismatchError = exports.MissingDeadSharesDataError = exports.InsufficientDeadSharesError = exports.ZeroBlueParkingSharesError = exports.EmptyBlueParkingMarketError = exports.MidnightOfferCallbackDataMismatchError = exports.MidnightOfferCallbackMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = void 0;
|
|
6
6
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
7
7
|
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
8
8
|
const constant_js_1 = require("../helpers/constant.js");
|
|
@@ -627,7 +627,10 @@ class BundlesRequirementSignatureMismatchError extends Error {
|
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
629
|
exports.BundlesRequirementSignatureMismatchError = BundlesRequirementSignatureMismatchError;
|
|
630
|
-
/**
|
|
630
|
+
/**
|
|
631
|
+
* Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed.
|
|
632
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
633
|
+
*/
|
|
631
634
|
class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
|
|
632
635
|
owner;
|
|
633
636
|
nonce;
|
|
@@ -643,7 +646,10 @@ class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
|
|
|
643
646
|
}
|
|
644
647
|
}
|
|
645
648
|
exports.Permit2SignatureTransferNonceAlreadyUsedError = Permit2SignatureTransferNonceAlreadyUsedError;
|
|
646
|
-
/**
|
|
649
|
+
/**
|
|
650
|
+
* Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce.
|
|
651
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
652
|
+
*/
|
|
647
653
|
class NoUnusedPermit2NonceError extends Error {
|
|
648
654
|
owner;
|
|
649
655
|
startNonce;
|
|
@@ -1896,6 +1902,46 @@ class WithdrawSharesExceedSupplyError extends Error {
|
|
|
1896
1902
|
}
|
|
1897
1903
|
}
|
|
1898
1904
|
exports.WithdrawSharesExceedSupplyError = WithdrawSharesExceedSupplyError;
|
|
1905
|
+
/** Thrown when a Blue withdrawal finds no supply shares to withdraw for the position owner. */
|
|
1906
|
+
class EmptyBlueSupplyPositionError extends Error {
|
|
1907
|
+
constructor(params) {
|
|
1908
|
+
super(`Supply position of "${params.user}" is empty on market "${params.market}". Refresh the position data or skip the withdrawal.`);
|
|
1909
|
+
this.name = "EmptyBlueSupplyPositionError";
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
exports.EmptyBlueSupplyPositionError = EmptyBlueSupplyPositionError;
|
|
1913
|
+
/** Thrown when a Blue withdrawal needs more assets than the market's available liquidity. */
|
|
1914
|
+
class InsufficientBlueLiquidityError extends Error {
|
|
1915
|
+
constructor(params) {
|
|
1916
|
+
super(`Blue liquidity is insufficient on market "${params.market}": assets "${params.assets}", liquidity "${params.liquidity}". Try again when liquidity returns.`);
|
|
1917
|
+
this.name = "InsufficientBlueLiquidityError";
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
exports.InsufficientBlueLiquidityError = InsufficientBlueLiquidityError;
|
|
1921
|
+
/** Thrown when an address is not a BlueBuyCallback created by the chain's registered factory. */
|
|
1922
|
+
class NotBlueBuyCallbackError extends Error {
|
|
1923
|
+
constructor(callback) {
|
|
1924
|
+
super(`Address "${callback}" is not a BlueBuyCallback created by the registered factory. Pass a callback created by midnightBlueBuyCallbackFactory.`);
|
|
1925
|
+
this.name = "NotBlueBuyCallbackError";
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
exports.NotBlueBuyCallbackError = NotBlueBuyCallbackError;
|
|
1929
|
+
/** Thrown when a BlueBuyCallback's `OWNER()` is not the account withdrawing its Blue position. */
|
|
1930
|
+
class BlueBuyCallbackOwnerMismatchError extends Error {
|
|
1931
|
+
constructor(params) {
|
|
1932
|
+
super(`BlueBuyCallback "${params.callback}" is owned by "${params.owner}", not "${params.userAddress}". Withdraw from the owner's account.`);
|
|
1933
|
+
this.name = "BlueBuyCallbackOwnerMismatchError";
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
exports.BlueBuyCallbackOwnerMismatchError = BlueBuyCallbackOwnerMismatchError;
|
|
1937
|
+
/** Thrown when Morpho Blue does not authorize an account to withdraw a BlueBuyCallback's position. */
|
|
1938
|
+
class BlueBuyCallbackUnauthorizedError extends Error {
|
|
1939
|
+
constructor(params) {
|
|
1940
|
+
super(`"${params.userAddress}" is not authorized on Morpho Blue to withdraw for BlueBuyCallback "${params.callback}". Call setAuthorization on the callback from its owner, then retry.`);
|
|
1941
|
+
this.name = "BlueBuyCallbackUnauthorizedError";
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
exports.BlueBuyCallbackUnauthorizedError = BlueBuyCallbackUnauthorizedError;
|
|
1899
1945
|
/**
|
|
1900
1946
|
* Thrown when a Vault V2 reallocation planner receives a withdraw `amount` greater
|
|
1901
1947
|
* than the target market's current `totalSupplyAssets` — the post-withdraw
|
package/lib/esm/abis.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
2
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, 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 as bluePreLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
6
|
preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
7
|
-
export { blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi as midnightEcrecoverAuthorizerAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
7
|
+
export { blueBuyCallbackAbi as midnightBlueBuyCallbackAbi, blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi as midnightEcrecoverAuthorizerAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
8
8
|
/** ABI for the VaultExitBundlesV1 periphery contract. */
|
|
9
9
|
export declare const vaultExitBundlesV1Abi: readonly [{
|
|
10
10
|
readonly type: "constructor";
|
package/lib/esm/abis.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
2
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, 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 as bluePreLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
6
|
preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
7
|
-
export { blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi as midnightEcrecoverAuthorizerAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
7
|
+
export { blueBuyCallbackAbi as midnightBlueBuyCallbackAbi, blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi as midnightEcrecoverAuthorizerAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
8
8
|
/** ABI for the VaultExitBundlesV1 periphery contract. */
|
|
9
9
|
export const vaultExitBundlesV1Abi = [
|
|
10
10
|
{
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
+
import { type Address } from "viem";
|
|
3
|
+
import { type BlueWithdrawBuyCallbackAction, type Metadata, type Transaction } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueWithdrawBuyCallback}. */
|
|
5
|
+
export interface BlueWithdrawBuyCallbackParams {
|
|
6
|
+
/** Chain and scoped Morpho Blue market. */
|
|
7
|
+
readonly market: {
|
|
8
|
+
readonly chainId: number;
|
|
9
|
+
readonly marketParams: MarketParams;
|
|
10
|
+
};
|
|
11
|
+
/** Direct Morpho Blue withdrawal arguments. */
|
|
12
|
+
readonly args: {
|
|
13
|
+
/** BlueBuyCallback whose supply position is withdrawn. */
|
|
14
|
+
readonly callbackAddress: Address;
|
|
15
|
+
/** Callback owner, who sends the transaction and receives the loan assets. */
|
|
16
|
+
readonly userAddress: Address;
|
|
17
|
+
/** Supply shares burned. */
|
|
18
|
+
readonly shares: bigint;
|
|
19
|
+
};
|
|
20
|
+
/** Optional transaction metadata suffix. */
|
|
21
|
+
readonly metadata?: Metadata;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Encodes a direct Morpho Blue `withdraw` of a BlueBuyCallback's supply shares to its owner.
|
|
25
|
+
*
|
|
26
|
+
* The call is `withdraw(marketParams, 0, shares, callbackAddress, userAddress)` on Morpho Blue, not
|
|
27
|
+
* BlueBundlesV1: the callback authorizes its owner on Blue, so the owner withdraws on its behalf
|
|
28
|
+
* directly. Use `client.morpho.blue(...).withdrawBuyCallback(...)` to check the callback, its owner,
|
|
29
|
+
* the Blue authorization and the market liquidity first.
|
|
30
|
+
*
|
|
31
|
+
* @param params - Withdrawal encoding parameters.
|
|
32
|
+
* @param params.market.chainId - Chain containing Morpho Blue.
|
|
33
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
34
|
+
* @param params.args.callbackAddress - BlueBuyCallback whose supply position is withdrawn.
|
|
35
|
+
* @param params.args.userAddress - Callback owner, sender and receiver of the loan assets.
|
|
36
|
+
* @param params.args.shares - Supply shares burned.
|
|
37
|
+
* @param params.metadata - Optional transaction metadata.
|
|
38
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawBuyCallbackAction>>` whose `to` address
|
|
39
|
+
* is Morpho Blue.
|
|
40
|
+
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
41
|
+
* @throws {NegativeInputError} when `shares` is negative.
|
|
42
|
+
* @throws {NonPositiveInputError} when `shares` is zero.
|
|
43
|
+
* @throws {InputExceedsMaxError} when `shares` exceeds `uint256`.
|
|
44
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
45
|
+
* @throws {UnknownAddressError} when Morpho Blue is not registered.
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
49
|
+
* import { blueWithdrawBuyCallback } from "@morpho-org/morpho-sdk";
|
|
50
|
+
* import { zeroAddress } from "viem";
|
|
51
|
+
* import { mainnet } from "viem/chains";
|
|
52
|
+
*
|
|
53
|
+
* const tx = blueWithdrawBuyCallback({
|
|
54
|
+
* market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
|
|
55
|
+
* args: { callbackAddress: zeroAddress, userAddress: zeroAddress, shares: 1_000_000n },
|
|
56
|
+
* });
|
|
57
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawBuyCallbackAction>>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const blueWithdrawBuyCallback: (params: BlueWithdrawBuyCallbackParams) => Readonly<Transaction<BlueWithdrawBuyCallbackAction>>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
2
|
+
import { encodeFunctionData } from "viem";
|
|
3
|
+
import { blueAbi } from "../../abis.js";
|
|
4
|
+
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
5
|
+
import { validateMarketParamsId, validateUint256Field, } from "../../helpers/validate.js";
|
|
6
|
+
import { NonPositiveInputError, } from "../../types/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Encodes a direct Morpho Blue `withdraw` of a BlueBuyCallback's supply shares to its owner.
|
|
9
|
+
*
|
|
10
|
+
* The call is `withdraw(marketParams, 0, shares, callbackAddress, userAddress)` on Morpho Blue, not
|
|
11
|
+
* BlueBundlesV1: the callback authorizes its owner on Blue, so the owner withdraws on its behalf
|
|
12
|
+
* directly. Use `client.morpho.blue(...).withdrawBuyCallback(...)` to check the callback, its owner,
|
|
13
|
+
* the Blue authorization and the market liquidity first.
|
|
14
|
+
*
|
|
15
|
+
* @param params - Withdrawal encoding parameters.
|
|
16
|
+
* @param params.market.chainId - Chain containing Morpho Blue.
|
|
17
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
18
|
+
* @param params.args.callbackAddress - BlueBuyCallback whose supply position is withdrawn.
|
|
19
|
+
* @param params.args.userAddress - Callback owner, sender and receiver of the loan assets.
|
|
20
|
+
* @param params.args.shares - Supply shares burned.
|
|
21
|
+
* @param params.metadata - Optional transaction metadata.
|
|
22
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawBuyCallbackAction>>` whose `to` address
|
|
23
|
+
* is Morpho Blue.
|
|
24
|
+
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
25
|
+
* @throws {NegativeInputError} when `shares` is negative.
|
|
26
|
+
* @throws {NonPositiveInputError} when `shares` is zero.
|
|
27
|
+
* @throws {InputExceedsMaxError} when `shares` exceeds `uint256`.
|
|
28
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
29
|
+
* @throws {UnknownAddressError} when Morpho Blue is not registered.
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
33
|
+
* import { blueWithdrawBuyCallback } from "@morpho-org/morpho-sdk";
|
|
34
|
+
* import { zeroAddress } from "viem";
|
|
35
|
+
* import { mainnet } from "viem/chains";
|
|
36
|
+
*
|
|
37
|
+
* const tx = blueWithdrawBuyCallback({
|
|
38
|
+
* market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
|
|
39
|
+
* args: { callbackAddress: zeroAddress, userAddress: zeroAddress, shares: 1_000_000n },
|
|
40
|
+
* });
|
|
41
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawBuyCallbackAction>>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export const blueWithdrawBuyCallback = (params) => {
|
|
45
|
+
const { chainId, marketParams } = params.market;
|
|
46
|
+
const { callbackAddress, userAddress, shares } = params.args;
|
|
47
|
+
validateMarketParamsId(marketParams);
|
|
48
|
+
validateUint256Field("shares", shares);
|
|
49
|
+
if (shares === 0n)
|
|
50
|
+
throw new NonPositiveInputError("shares", shares);
|
|
51
|
+
let tx = {
|
|
52
|
+
to: getChainAddress(chainId, "blue"),
|
|
53
|
+
value: 0n,
|
|
54
|
+
data: encodeFunctionData({
|
|
55
|
+
abi: blueAbi,
|
|
56
|
+
functionName: "withdraw",
|
|
57
|
+
args: [marketParams, 0n, shares, callbackAddress, userAddress],
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
if (params.metadata) {
|
|
61
|
+
tx = addTransactionMetadata(tx, params.metadata);
|
|
62
|
+
}
|
|
63
|
+
return deepFreeze({
|
|
64
|
+
...tx,
|
|
65
|
+
action: {
|
|
66
|
+
type: "blueWithdrawBuyCallback",
|
|
67
|
+
args: {
|
|
68
|
+
market: marketParams.id,
|
|
69
|
+
shares,
|
|
70
|
+
onBehalf: callbackAddress,
|
|
71
|
+
receiver: userAddress,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
};
|
|
@@ -6,6 +6,7 @@ export type BundlesTokenRequirementsState = {
|
|
|
6
6
|
/** Current allowance of the funding token for `spender`. */
|
|
7
7
|
readonly allowance: bigint;
|
|
8
8
|
} | {
|
|
9
|
+
/** @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals. */
|
|
9
10
|
readonly type: "permit2SignatureTransfer";
|
|
10
11
|
readonly permit2Allowance: bigint;
|
|
11
12
|
readonly permit2Nonce: bigint;
|