@morpho-org/morpho-sdk 6.0.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v5-to-v6.md +1 -1
- package/README.md +1 -1
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +3 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +16 -5
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +16 -5
- package/lib/cjs/blue/errors.d.ts +1 -1
- package/lib/cjs/blue/errors.js +2 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +4 -1
- package/lib/cjs/entities/blue/blue.d.ts +28 -0
- package/lib/cjs/entities/blue/blue.js +1 -0
- package/lib/cjs/entities/index.d.ts +1 -1
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +1 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -2
- package/lib/cjs/entities/vaultV1/vaultV1.js +2 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +35 -11
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -0
- package/lib/cjs/errors.d.ts +2 -2
- package/lib/cjs/errors.js +9 -1
- package/lib/cjs/helpers/encodeDeallocation.d.ts +1 -0
- package/lib/cjs/helpers/encodeDeallocation.js +1 -0
- package/lib/cjs/helpers/metadata.d.ts +13 -0
- package/lib/cjs/helpers/metadata.js +13 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +10 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +10 -6
- package/lib/cjs/helpers/slippage.d.ts +3 -2
- package/lib/cjs/helpers/slippage.js +3 -2
- package/lib/cjs/helpers/validate.d.ts +40 -2
- package/lib/cjs/helpers/validate.js +42 -3
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +94 -59
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +94 -59
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -1
- package/lib/cjs/midnight/constants.d.ts +1 -1
- package/lib/cjs/midnight/constants.js +4 -1
- package/lib/cjs/midnight/entities.d.ts +1 -1
- package/lib/cjs/midnight/errors.d.ts +1 -1
- package/lib/cjs/midnight/errors.js +7 -1
- package/lib/cjs/midnight/types.d.ts +1 -1
- package/lib/cjs/midnight/utils.d.ts +11 -1
- package/lib/cjs/midnight/utils.js +13 -1
- package/lib/cjs/types/action.d.ts +34 -0
- package/lib/cjs/types/action.js +10 -0
- package/lib/cjs/types/data.d.ts +3 -0
- package/lib/cjs/types/entity.d.ts +3 -0
- package/lib/cjs/types/metadata.d.ts +6 -0
- package/lib/cjs/types.d.ts +1 -1
- package/lib/cjs/utils.d.ts +11 -1
- package/lib/cjs/utils.js +14 -2
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +16 -5
- package/lib/esm/actions/vaultV2/forceWithdraw.js +16 -5
- package/lib/esm/blue/errors.d.ts +1 -1
- package/lib/esm/blue/errors.js +1 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +28 -0
- package/lib/esm/entities/blue/blue.js +1 -0
- package/lib/esm/entities/index.d.ts +1 -1
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +2 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +35 -11
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -0
- package/lib/esm/errors.d.ts +2 -2
- package/lib/esm/errors.js +2 -2
- package/lib/esm/helpers/encodeDeallocation.d.ts +1 -0
- package/lib/esm/helpers/encodeDeallocation.js +1 -0
- package/lib/esm/helpers/metadata.d.ts +13 -0
- package/lib/esm/helpers/metadata.js +13 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +10 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +10 -6
- package/lib/esm/helpers/slippage.d.ts +3 -2
- package/lib/esm/helpers/slippage.js +3 -2
- package/lib/esm/helpers/validate.d.ts +40 -2
- package/lib/esm/helpers/validate.js +41 -1
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +94 -59
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +94 -59
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/constants.d.ts +1 -1
- package/lib/esm/midnight/constants.js +1 -1
- package/lib/esm/midnight/entities.d.ts +1 -1
- package/lib/esm/midnight/errors.d.ts +1 -1
- package/lib/esm/midnight/errors.js +1 -1
- package/lib/esm/midnight/types.d.ts +1 -1
- package/lib/esm/midnight/utils.d.ts +11 -1
- package/lib/esm/midnight/utils.js +11 -1
- package/lib/esm/types/action.d.ts +34 -0
- package/lib/esm/types/action.js +10 -0
- package/lib/esm/types/data.d.ts +3 -0
- package/lib/esm/types/entity.d.ts +3 -0
- package/lib/esm/types/metadata.d.ts +6 -0
- package/lib/esm/types.d.ts +1 -1
- package/lib/esm/utils.d.ts +11 -1
- package/lib/esm/utils.js +11 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { BuildFixedRateOfferChainParams, DecodedEcrecoverRatifierData, DecodedSetterRatifierData, DeploylessFetchParameters, EcrecoverRatificationTypedData, EcrecoverRatifierDataDigestParams, EcrecoverRatifierDataParams, EcrecoverRatifierDataVerificationParams, EcrecoverRatifierRatifyParams, EcrecoverRatifierRootDigestParams, EcrecoverRatifierTypedDataParams, EcrecoverSignatureInput, FixedRateOfferChainLeg, GetRatifierInfoParams, MidnightCallParameters, MidnightFetchParams, RatifierInfo, SetterRatifierDataParams, SetterRatifierDataVerificationParams, VerifiedEcrecoverRatifierData, } from "@morpho-org/midnight-sdk";
|
|
1
|
+
export type { BuildFixedRateOfferChainParams, DecodedEcrecoverRatifierData, DecodedPriceRatifierV1Data, DecodedRateRatifierV1Data, DecodedSetterRatifierData, DeploylessFetchParameters, EcrecoverRatificationTypedData, EcrecoverRatifierDataDigestParams, EcrecoverRatifierDataParams, EcrecoverRatifierDataRequest, EcrecoverRatifierDataVerificationParams, EcrecoverRatifierRatifyParams, EcrecoverRatifierRatifyRequest, EcrecoverRatifierRootDigestParams, EcrecoverRatifierSignRequest, EcrecoverRatifierTypedDataParams, EcrecoverRatifierTypedDataRequest, EcrecoverSignatureInput, FixedRateOfferChainLeg, GetRatifierInfoParams, MidnightCallParameters, MidnightFetchParams, PriceRatifierV1Leaf, PriceRatifierV1LeafStruct, PriceRatifierV1TreeDescriptor, PriceRatifierV1TreeInput, RateRatifierV1Leaf, RateRatifierV1LeafStruct, RateRatifierV1TreeDescriptor, RateRatifierV1TreeInput, RatifierInfo, SetterRatifierDataParams, SetterRatifierDataRequest, SetterRatifierDataVerificationParams, SetterRatifierRatifyRequest, VerifiedEcrecoverRatifierData, } from "@morpho-org/midnight-sdk";
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { EcrecoverRatifier,
|
|
2
|
+
/** @deprecated Use EcrecoverRatifier with a tagged tree. */
|
|
3
|
+
EcrecoverRatifierUtils, eip712Digest, GroupUtils, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, PriceRatifierV1,
|
|
4
|
+
/** @deprecated Use PriceRatifierV1. */
|
|
5
|
+
PriceRatifierV1Utils, RateRatifierV1,
|
|
6
|
+
/** @deprecated Use RateRatifierV1. */
|
|
7
|
+
RateRatifierV1Utils, Ratifier,
|
|
8
|
+
/** @deprecated Use Ratifier. */
|
|
9
|
+
RatifierUtils, SetterRatifier,
|
|
10
|
+
/** @deprecated Use SetterRatifier with a tagged tree. */
|
|
11
|
+
SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TreeUtils = exports.TickLib = exports.TakeAmountsLib = exports.SetterRatifierUtils = exports.RatifierUtils = exports.PositionUtils = exports.Payload = exports.OfferUtils = exports.OfferChainUtils = exports.MarketUtils = exports.GroupUtils = exports.eip712Digest = exports.EcrecoverRatifierUtils = void 0;
|
|
3
|
+
exports.TreeUtils = exports.TickLib = exports.TakeAmountsLib = exports.SetterRatifierUtils = exports.SetterRatifier = exports.RatifierUtils = exports.Ratifier = exports.RateRatifierV1Utils = exports.RateRatifierV1 = exports.PriceRatifierV1Utils = exports.PriceRatifierV1 = exports.PositionUtils = exports.Payload = exports.OfferUtils = exports.OfferChainUtils = exports.MarketUtils = exports.GroupUtils = exports.eip712Digest = exports.EcrecoverRatifierUtils = exports.EcrecoverRatifier = void 0;
|
|
4
4
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
+
Object.defineProperty(exports, "EcrecoverRatifier", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifier; } });
|
|
6
|
+
/** @deprecated Use EcrecoverRatifier with a tagged tree. */
|
|
5
7
|
Object.defineProperty(exports, "EcrecoverRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifierUtils; } });
|
|
6
8
|
Object.defineProperty(exports, "eip712Digest", { enumerable: true, get: function () { return midnight_sdk_1.eip712Digest; } });
|
|
7
9
|
Object.defineProperty(exports, "GroupUtils", { enumerable: true, get: function () { return midnight_sdk_1.GroupUtils; } });
|
|
@@ -10,7 +12,17 @@ Object.defineProperty(exports, "OfferChainUtils", { enumerable: true, get: funct
|
|
|
10
12
|
Object.defineProperty(exports, "OfferUtils", { enumerable: true, get: function () { return midnight_sdk_1.OfferUtils; } });
|
|
11
13
|
Object.defineProperty(exports, "Payload", { enumerable: true, get: function () { return midnight_sdk_1.Payload; } });
|
|
12
14
|
Object.defineProperty(exports, "PositionUtils", { enumerable: true, get: function () { return midnight_sdk_1.PositionUtils; } });
|
|
15
|
+
Object.defineProperty(exports, "PriceRatifierV1", { enumerable: true, get: function () { return midnight_sdk_1.PriceRatifierV1; } });
|
|
16
|
+
/** @deprecated Use PriceRatifierV1. */
|
|
17
|
+
Object.defineProperty(exports, "PriceRatifierV1Utils", { enumerable: true, get: function () { return midnight_sdk_1.PriceRatifierV1Utils; } });
|
|
18
|
+
Object.defineProperty(exports, "RateRatifierV1", { enumerable: true, get: function () { return midnight_sdk_1.RateRatifierV1; } });
|
|
19
|
+
/** @deprecated Use RateRatifierV1. */
|
|
20
|
+
Object.defineProperty(exports, "RateRatifierV1Utils", { enumerable: true, get: function () { return midnight_sdk_1.RateRatifierV1Utils; } });
|
|
21
|
+
Object.defineProperty(exports, "Ratifier", { enumerable: true, get: function () { return midnight_sdk_1.Ratifier; } });
|
|
22
|
+
/** @deprecated Use Ratifier. */
|
|
13
23
|
Object.defineProperty(exports, "RatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.RatifierUtils; } });
|
|
24
|
+
Object.defineProperty(exports, "SetterRatifier", { enumerable: true, get: function () { return midnight_sdk_1.SetterRatifier; } });
|
|
25
|
+
/** @deprecated Use SetterRatifier with a tagged tree. */
|
|
14
26
|
Object.defineProperty(exports, "SetterRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.SetterRatifierUtils; } });
|
|
15
27
|
Object.defineProperty(exports, "TakeAmountsLib", { enumerable: true, get: function () { return midnight_sdk_1.TakeAmountsLib; } });
|
|
16
28
|
Object.defineProperty(exports, "TickLib", { enumerable: true, get: function () { return midnight_sdk_1.TickLib; } });
|
|
@@ -16,11 +16,13 @@ export interface BaseAction<TType extends string = string, TArgs extends Record<
|
|
|
16
16
|
readonly type: TType;
|
|
17
17
|
readonly args: TArgs;
|
|
18
18
|
}
|
|
19
|
+
/** Metadata for an ERC-20 `approve` call granting `spender` an `amount` allowance. */
|
|
19
20
|
export interface ERC20ApprovalAction extends BaseAction<"erc20Approval", {
|
|
20
21
|
spender: Address;
|
|
21
22
|
amount: bigint;
|
|
22
23
|
}> {
|
|
23
24
|
}
|
|
25
|
+
/** Metadata for an ERC-2612 permit signature requirement, exposing only the `sign` callback. */
|
|
24
26
|
export interface ERC20PermitAction {
|
|
25
27
|
sign: (client: WalletClient, userAddress: Address) => Promise<Hex>;
|
|
26
28
|
}
|
|
@@ -106,6 +108,7 @@ export interface VaultV2ForceWithdrawAction extends BaseAction<"vaultV2ForceWith
|
|
|
106
108
|
readonly deadline: bigint;
|
|
107
109
|
}> {
|
|
108
110
|
}
|
|
111
|
+
/** Metadata for a Vault V2 force redeem executed through the vault's native multicall. */
|
|
109
112
|
export interface VaultV2ForceRedeemAction extends BaseAction<"vaultV2ForceRedeem", {
|
|
110
113
|
vault: Address;
|
|
111
114
|
deallocations: readonly Deallocation[];
|
|
@@ -637,6 +640,27 @@ export interface ActionOutput<TAction extends BaseAction = TransactionAction, TS
|
|
|
637
640
|
export declare function isRequirementApproval(requirement: unknown): requirement is Transaction<ERC20ApprovalAction>;
|
|
638
641
|
/** Checks whether an action requirement is a Blue authorization call. */
|
|
639
642
|
export declare function isRequirementBlueAuthorization(requirement: unknown): requirement is Transaction<BlueAuthorizationAction>;
|
|
643
|
+
/**
|
|
644
|
+
* Narrows an action requirement to a signature requirement.
|
|
645
|
+
*
|
|
646
|
+
* A signature requirement exposes a `sign` callback; call requirements are plain transactions.
|
|
647
|
+
*
|
|
648
|
+
* @param requirement - The requirement returned by `getRequirements()` to test.
|
|
649
|
+
* @returns `true` when `requirement` carries a `sign` function.
|
|
650
|
+
* @example
|
|
651
|
+
* ```ts
|
|
652
|
+
* import { isRequirementSignature } from "@morpho-org/morpho-sdk";
|
|
653
|
+
*
|
|
654
|
+
* for (const requirement of await handle.getRequirements()) {
|
|
655
|
+
* if (isRequirementSignature(requirement)) {
|
|
656
|
+
* signatures.push(await requirement.sign(walletClient, userAddress));
|
|
657
|
+
* } else {
|
|
658
|
+
* const hash = await walletClient.sendTransaction(requirement);
|
|
659
|
+
* await client.waitForTransactionReceipt({ hash });
|
|
660
|
+
* }
|
|
661
|
+
* }
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
640
664
|
export declare function isRequirementSignature<T extends RequirementSignature = RequirementSignature>(requirement: CallRequirement | Requirement<T> | undefined): requirement is Requirement<T>;
|
|
641
665
|
export declare function isRequirementSignature(requirement: CallRequirement | Requirement | undefined): requirement is Requirement;
|
|
642
666
|
export declare function isRequirementSignature(requirement: ActionRequirement | undefined): requirement is SignatureRequirement;
|
|
@@ -645,6 +669,16 @@ export declare function isRequirementSignature(requirement: ActionRequirement |
|
|
|
645
669
|
*
|
|
646
670
|
* @param signature - The signed requirement to test.
|
|
647
671
|
* @returns `true` when `signature.action.type` is `"permit"`.
|
|
672
|
+
* @example
|
|
673
|
+
* ```ts
|
|
674
|
+
* import {
|
|
675
|
+
* isPermitSignature,
|
|
676
|
+
* type RequirementSignature,
|
|
677
|
+
* } from "@morpho-org/morpho-sdk";
|
|
678
|
+
*
|
|
679
|
+
* const getPermitDeadline = (signature: RequirementSignature): bigint | undefined =>
|
|
680
|
+
* isPermitSignature(signature) ? signature.args.deadline : undefined;
|
|
681
|
+
* ```
|
|
648
682
|
*/
|
|
649
683
|
export declare function isPermitSignature(signature: RequirementSignature): signature is PermitRequirementSignature;
|
|
650
684
|
/**
|
package/lib/cjs/types/action.js
CHANGED
|
@@ -46,6 +46,16 @@ function isRequirementSignature(requirement) {
|
|
|
46
46
|
*
|
|
47
47
|
* @param signature - The signed requirement to test.
|
|
48
48
|
* @returns `true` when `signature.action.type` is `"permit"`.
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import {
|
|
52
|
+
* isPermitSignature,
|
|
53
|
+
* type RequirementSignature,
|
|
54
|
+
* } from "@morpho-org/morpho-sdk";
|
|
55
|
+
*
|
|
56
|
+
* const getPermitDeadline = (signature: RequirementSignature): bigint | undefined =>
|
|
57
|
+
* isPermitSignature(signature) ? signature.args.deadline : undefined;
|
|
58
|
+
* ```
|
|
49
59
|
*/
|
|
50
60
|
function isPermitSignature(signature) {
|
|
51
61
|
return signature.action.type === "permit";
|
package/lib/cjs/types/data.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
/** Analytics metadata appended to transaction calldata. */
|
|
1
2
|
export interface Metadata {
|
|
3
|
+
/**
|
|
4
|
+
* Raw or 0x-prefixed hex origin of at most four bytes (eight hex characters) and even length.
|
|
5
|
+
* Invalid values are dropped with a console warning.
|
|
6
|
+
*/
|
|
2
7
|
origin: string;
|
|
8
|
+
/** When true, append the current Unix timestamp as four bytes before the origin. */
|
|
3
9
|
timestamp?: boolean;
|
|
4
10
|
}
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { BigIntish, CollateralAllocation, Eip712Field, Erc20AllowanceRecipient, Failable, Fetchable, InputMarketParams as BlueInputMarketParams, Loadable, MarketId as BlueMarketId, MaxBorrowOptions as BlueMaxBorrowOptions, MaxPositionCapacities as BlueMaxPositionCapacities, MaxWithdrawCollateralOptions as BlueMaxWithdrawCollateralOptions, Pending, } from "@morpho-org/blue-sdk";
|
|
2
2
|
export type { AuthorizationArgs as BlueAuthorizationTypedDataArgs, DeploylessFetchParameters as BlueDeploylessFetchParameters, FetchParameters as BlueFetchParameters, InputAllocation as BlueInputAllocation, MetaMorphoCall as BlueMetaMorphoCall, Permit2PermitArgs, Permit2TransferFromArgs, PermitArgs as PermitTypedDataArgs, } from "@morpho-org/blue-sdk-viem";
|
|
3
|
-
export type { BuildFixedRateOfferChainParams as MidnightBuildFixedRateOfferChainParams, DecodedEcrecoverRatifierData as MidnightDecodedEcrecoverRatifierData, DecodedSetterRatifierData as MidnightDecodedSetterRatifierData, DeploylessFetchParameters as MidnightDeploylessFetchParameters, EcrecoverRatificationTypedData as MidnightEcrecoverRatificationTypedData, EcrecoverRatifierDataDigestParams as MidnightEcrecoverRatifierDataDigestParams, EcrecoverRatifierDataParams as MidnightEcrecoverRatifierDataParams, EcrecoverRatifierDataVerificationParams as MidnightEcrecoverRatifierDataVerificationParams, EcrecoverRatifierRatifyParams as MidnightEcrecoverRatifierRatifyParams, EcrecoverRatifierRootDigestParams as MidnightEcrecoverRatifierRootDigestParams, EcrecoverRatifierTypedDataParams as MidnightEcrecoverRatifierTypedDataParams, EcrecoverSignatureInput as MidnightEcrecoverSignatureInput, FixedRateOfferChainLeg as MidnightFixedRateOfferChainLeg, GetRatifierInfoParams as MidnightGetRatifierInfoParams, MidnightCallParameters, MidnightFetchParams, RatifierInfo as MidnightRatifierInfo, SetterRatifierDataParams as MidnightSetterRatifierDataParams, SetterRatifierDataVerificationParams as MidnightSetterRatifierDataVerificationParams, VerifiedEcrecoverRatifierData as MidnightVerifiedEcrecoverRatifierData, } from "@morpho-org/midnight-sdk";
|
|
3
|
+
export type { BuildFixedRateOfferChainParams as MidnightBuildFixedRateOfferChainParams, DecodedEcrecoverRatifierData as MidnightDecodedEcrecoverRatifierData, DecodedPriceRatifierV1Data as MidnightDecodedPriceRatifierV1Data, DecodedRateRatifierV1Data as MidnightDecodedRateRatifierV1Data, DecodedSetterRatifierData as MidnightDecodedSetterRatifierData, DeploylessFetchParameters as MidnightDeploylessFetchParameters, EcrecoverRatificationTypedData as MidnightEcrecoverRatificationTypedData, EcrecoverRatifierDataDigestParams as MidnightEcrecoverRatifierDataDigestParams, EcrecoverRatifierDataParams as MidnightEcrecoverRatifierDataParams, EcrecoverRatifierDataRequest as MidnightEcrecoverRatifierDataRequest, EcrecoverRatifierDataVerificationParams as MidnightEcrecoverRatifierDataVerificationParams, EcrecoverRatifierRatifyParams as MidnightEcrecoverRatifierRatifyParams, EcrecoverRatifierRatifyRequest as MidnightEcrecoverRatifierRatifyRequest, EcrecoverRatifierRootDigestParams as MidnightEcrecoverRatifierRootDigestParams, EcrecoverRatifierSignRequest as MidnightEcrecoverRatifierSignRequest, EcrecoverRatifierTypedDataParams as MidnightEcrecoverRatifierTypedDataParams, EcrecoverRatifierTypedDataRequest as MidnightEcrecoverRatifierTypedDataRequest, EcrecoverSignatureInput as MidnightEcrecoverSignatureInput, FixedRateOfferChainLeg as MidnightFixedRateOfferChainLeg, GetRatifierInfoParams as MidnightGetRatifierInfoParams, MidnightCallParameters, MidnightFetchParams, PriceRatifierV1Leaf as MidnightPriceRatifierV1Leaf, PriceRatifierV1LeafStruct as MidnightPriceRatifierV1LeafStruct, PriceRatifierV1TreeDescriptor as MidnightPriceRatifierV1TreeDescriptor, PriceRatifierV1TreeInput as MidnightPriceRatifierV1TreeInput, RateRatifierV1Leaf as MidnightRateRatifierV1Leaf, RateRatifierV1LeafStruct as MidnightRateRatifierV1LeafStruct, RateRatifierV1TreeDescriptor as MidnightRateRatifierV1TreeDescriptor, RateRatifierV1TreeInput as MidnightRateRatifierV1TreeInput, RatifierInfo as MidnightRatifierInfo, SetterRatifierDataParams as MidnightSetterRatifierDataParams, SetterRatifierDataRequest as MidnightSetterRatifierDataRequest, SetterRatifierDataVerificationParams as MidnightSetterRatifierDataVerificationParams, SetterRatifierRatifyRequest as MidnightSetterRatifierRatifyRequest, VerifiedEcrecoverRatifierData as MidnightVerifiedEcrecoverRatifierData, } from "@morpho-org/midnight-sdk";
|
|
4
4
|
export type { ChainMetadata } from "@morpho-org/morpho-ts";
|
|
5
5
|
export * from "./types/index.js";
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -5,7 +5,17 @@ defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
|
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
6
|
getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
7
7
|
export { decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
8
|
-
export {
|
|
8
|
+
export { EcrecoverRatifier as MidnightEcrecoverRatifier,
|
|
9
|
+
/** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
|
|
10
|
+
EcrecoverRatifierUtils as MidnightEcrecoverRatifierUtils, eip712Digest, GroupUtils as MidnightGroupUtils, MarketUtils as MidnightMarketUtils, OfferChainUtils as MidnightOfferChainUtils, OfferUtils as MidnightOfferUtils, Payload as MidnightPayload, PositionUtils as MidnightPositionUtils, PriceRatifierV1 as MidnightPriceRatifierV1,
|
|
11
|
+
/** @deprecated Use MidnightPriceRatifierV1. */
|
|
12
|
+
PriceRatifierV1Utils as MidnightPriceRatifierV1Utils, RateRatifierV1 as MidnightRateRatifierV1,
|
|
13
|
+
/** @deprecated Use MidnightRateRatifierV1. */
|
|
14
|
+
RateRatifierV1Utils as MidnightRateRatifierV1Utils, Ratifier as MidnightRatifier,
|
|
15
|
+
/** @deprecated Use MidnightRatifier. */
|
|
16
|
+
RatifierUtils as MidnightRatifierUtils, SetterRatifier as MidnightSetterRatifier,
|
|
17
|
+
/** @deprecated Use MidnightSetterRatifier with a tagged tree. */
|
|
18
|
+
SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
|
|
9
19
|
export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, } from "@morpho-org/morpho-ts";
|
|
10
20
|
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
|
|
11
21
|
export { addTransactionMetadata } from "./helpers/metadata.js";
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinForceWithdrawSharePrice = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.keys = exports.isNotUndefined = void 0;
|
|
3
|
+
exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = exports.createHasValue = exports.createGetValue = exports.bigIntComparator = exports.MidnightTreeUtils = exports.MidnightTickLib = exports.MidnightTakeAmountsLib = exports.MidnightSetterRatifierUtils = exports.MidnightSetterRatifier = exports.MidnightRatifierUtils = exports.MidnightRatifier = exports.MidnightRateRatifierV1Utils = exports.MidnightRateRatifierV1 = exports.MidnightPriceRatifierV1Utils = exports.MidnightPriceRatifierV1 = exports.MidnightPositionUtils = exports.MidnightPayload = exports.MidnightOfferUtils = exports.MidnightOfferChainUtils = exports.MidnightMarketUtils = exports.MidnightGroupUtils = exports.eip712Digest = exports.MidnightEcrecoverRatifierUtils = exports.MidnightEcrecoverRatifier = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.BlueMetaMorphoAction = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getBlueAuthorizationTypedData = exports.decodeBytes32String = exports.VaultV2Utils = exports.VaultV2BluePublicAllocatorConfigUtils = exports.VaultV2BlueMarketPublicAllocatorConfigUtils = exports.VaultUtils = exports.BlueSharesMath = exports.MathLib = exports.BlueMarketUtils = exports.getBlueDefaultPreLiquidationParams = exports.blueDefaultPreLiquidationParamsRegistry = exports.CapacityLimitReason = exports.BlueAdaptiveCurveIrmLib = void 0;
|
|
4
|
+
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinForceWithdrawSharePrice = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.keys = exports.isNotUndefined = exports.isNotNull = exports.isDefined = exports.hasValue = exports.getValue = exports.getSubdomainBaseUrl = exports.getLastDefined = exports.getLast = void 0;
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
6
|
Object.defineProperty(exports, "BlueAdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
7
7
|
Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
|
|
@@ -30,6 +30,8 @@ Object.defineProperty(exports, "safeGetAddress", { enumerable: true, get: functi
|
|
|
30
30
|
Object.defineProperty(exports, "safeParseNumber", { enumerable: true, get: function () { return blue_sdk_viem_1.safeParseNumber; } });
|
|
31
31
|
Object.defineProperty(exports, "safeParseUnits", { enumerable: true, get: function () { return blue_sdk_viem_1.safeParseUnits; } });
|
|
32
32
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
33
|
+
Object.defineProperty(exports, "MidnightEcrecoverRatifier", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifier; } });
|
|
34
|
+
/** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
|
|
33
35
|
Object.defineProperty(exports, "MidnightEcrecoverRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifierUtils; } });
|
|
34
36
|
Object.defineProperty(exports, "eip712Digest", { enumerable: true, get: function () { return midnight_sdk_1.eip712Digest; } });
|
|
35
37
|
Object.defineProperty(exports, "MidnightGroupUtils", { enumerable: true, get: function () { return midnight_sdk_1.GroupUtils; } });
|
|
@@ -38,7 +40,17 @@ Object.defineProperty(exports, "MidnightOfferChainUtils", { enumerable: true, ge
|
|
|
38
40
|
Object.defineProperty(exports, "MidnightOfferUtils", { enumerable: true, get: function () { return midnight_sdk_1.OfferUtils; } });
|
|
39
41
|
Object.defineProperty(exports, "MidnightPayload", { enumerable: true, get: function () { return midnight_sdk_1.Payload; } });
|
|
40
42
|
Object.defineProperty(exports, "MidnightPositionUtils", { enumerable: true, get: function () { return midnight_sdk_1.PositionUtils; } });
|
|
43
|
+
Object.defineProperty(exports, "MidnightPriceRatifierV1", { enumerable: true, get: function () { return midnight_sdk_1.PriceRatifierV1; } });
|
|
44
|
+
/** @deprecated Use MidnightPriceRatifierV1. */
|
|
45
|
+
Object.defineProperty(exports, "MidnightPriceRatifierV1Utils", { enumerable: true, get: function () { return midnight_sdk_1.PriceRatifierV1Utils; } });
|
|
46
|
+
Object.defineProperty(exports, "MidnightRateRatifierV1", { enumerable: true, get: function () { return midnight_sdk_1.RateRatifierV1; } });
|
|
47
|
+
/** @deprecated Use MidnightRateRatifierV1. */
|
|
48
|
+
Object.defineProperty(exports, "MidnightRateRatifierV1Utils", { enumerable: true, get: function () { return midnight_sdk_1.RateRatifierV1Utils; } });
|
|
49
|
+
Object.defineProperty(exports, "MidnightRatifier", { enumerable: true, get: function () { return midnight_sdk_1.Ratifier; } });
|
|
50
|
+
/** @deprecated Use MidnightRatifier. */
|
|
41
51
|
Object.defineProperty(exports, "MidnightRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.RatifierUtils; } });
|
|
52
|
+
Object.defineProperty(exports, "MidnightSetterRatifier", { enumerable: true, get: function () { return midnight_sdk_1.SetterRatifier; } });
|
|
53
|
+
/** @deprecated Use MidnightSetterRatifier with a tagged tree. */
|
|
42
54
|
Object.defineProperty(exports, "MidnightSetterRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.SetterRatifierUtils; } });
|
|
43
55
|
Object.defineProperty(exports, "MidnightTakeAmountsLib", { enumerable: true, get: function () { return midnight_sdk_1.TakeAmountsLib; } });
|
|
44
56
|
Object.defineProperty(exports, "MidnightTickLib", { enumerable: true, get: function () { return midnight_sdk_1.TickLib; } });
|
package/lib/esm/abis.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi,
|
|
|
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 { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
7
|
+
export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, 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
|
@@ -4,7 +4,7 @@ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi,
|
|
|
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 { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
7
|
+
export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, 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
|
{
|
|
@@ -67,12 +67,23 @@ export interface VaultV2ForceWithdrawParams {
|
|
|
67
67
|
* @example
|
|
68
68
|
* ```ts
|
|
69
69
|
* import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
|
|
70
|
+
* import type { Address } from "viem";
|
|
71
|
+
* import { mainnet } from "viem/chains";
|
|
70
72
|
*
|
|
71
|
-
*
|
|
72
|
-
* vault:
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
73
|
+
* export function buildForceWithdraw(
|
|
74
|
+
* vault: Address,
|
|
75
|
+
* adapter: Address,
|
|
76
|
+
* minSharePriceE27: bigint,
|
|
77
|
+
* userAddress: Address,
|
|
78
|
+
* deadline: bigint,
|
|
79
|
+
* ) {
|
|
80
|
+
* const tx = vaultV2ForceWithdraw({
|
|
81
|
+
* vault: { chainId: mainnet.id, address: vault },
|
|
82
|
+
* args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
|
|
83
|
+
* });
|
|
84
|
+
* // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
|
|
85
|
+
* return tx;
|
|
86
|
+
* }
|
|
76
87
|
* ```
|
|
77
88
|
*/
|
|
78
89
|
export declare const vaultV2ForceWithdraw: ({ vault, args, metadata, }: VaultV2ForceWithdrawParams) => Readonly<Transaction<VaultV2ForceWithdrawAction>>;
|
|
@@ -54,12 +54,23 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
|
|
|
54
54
|
* @example
|
|
55
55
|
* ```ts
|
|
56
56
|
* import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
|
|
57
|
+
* import type { Address } from "viem";
|
|
58
|
+
* import { mainnet } from "viem/chains";
|
|
57
59
|
*
|
|
58
|
-
*
|
|
59
|
-
* vault:
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
60
|
+
* export function buildForceWithdraw(
|
|
61
|
+
* vault: Address,
|
|
62
|
+
* adapter: Address,
|
|
63
|
+
* minSharePriceE27: bigint,
|
|
64
|
+
* userAddress: Address,
|
|
65
|
+
* deadline: bigint,
|
|
66
|
+
* ) {
|
|
67
|
+
* const tx = vaultV2ForceWithdraw({
|
|
68
|
+
* vault: { chainId: mainnet.id, address: vault },
|
|
69
|
+
* args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
|
|
70
|
+
* });
|
|
71
|
+
* // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
|
|
72
|
+
* return tx;
|
|
73
|
+
* }
|
|
63
74
|
* ```
|
|
64
75
|
*/
|
|
65
76
|
export const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
|
package/lib/esm/blue/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
4
|
+
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MarketParamsIdMismatchError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
package/lib/esm/blue/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
4
|
+
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MarketParamsIdMismatchError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
package/lib/esm/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
2
|
+
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
3
3
|
export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
|
|
4
4
|
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
package/lib/esm/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
2
|
+
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
3
3
|
export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
|
|
4
4
|
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
|
@@ -24,12 +24,26 @@ export interface BlueTokenRequirementsParams {
|
|
|
24
24
|
*/
|
|
25
25
|
readonly approvalAmount?: bigint;
|
|
26
26
|
}
|
|
27
|
+
/** Action surface for Morpho Blue reads and writes; writes route through BlueBundlesV1. */
|
|
27
28
|
export interface BlueActions {
|
|
28
29
|
/**
|
|
29
30
|
* Fetches the latest market data with accrued interest.
|
|
30
31
|
*
|
|
31
32
|
* @param parameters - Optional fetch parameters (block number, state overrides).
|
|
32
33
|
* @returns Market state including total supply/borrow assets and shares.
|
|
34
|
+
* @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
38
|
+
* import { createPublicClient, http } from "viem";
|
|
39
|
+
* import { mainnet } from "viem/chains";
|
|
40
|
+
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
41
|
+
*
|
|
42
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
43
|
+
* .extend(morphoViemExtension());
|
|
44
|
+
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
45
|
+
* const marketData = await market.getMarketData();
|
|
46
|
+
* ```
|
|
33
47
|
*/
|
|
34
48
|
getMarketData: (parameters?: FetchParameters) => Promise<Market>;
|
|
35
49
|
/**
|
|
@@ -38,6 +52,19 @@ export interface BlueActions {
|
|
|
38
52
|
* @param userAddress - The user whose position to fetch.
|
|
39
53
|
* @param parameters - Optional fetch parameters (block number, state overrides).
|
|
40
54
|
* @returns Accrual position with health metrics (maxBorrowAssets, ltv, isHealthy).
|
|
55
|
+
* @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
59
|
+
* import { createPublicClient, http, zeroAddress } from "viem";
|
|
60
|
+
* import { mainnet } from "viem/chains";
|
|
61
|
+
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
62
|
+
*
|
|
63
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
64
|
+
* .extend(morphoViemExtension());
|
|
65
|
+
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
66
|
+
* const position = await market.getPositionData(zeroAddress);
|
|
67
|
+
* ```
|
|
41
68
|
*/
|
|
42
69
|
getPositionData: (userAddress: Address, parameters?: FetchParameters) => Promise<AccrualPosition>;
|
|
43
70
|
/**
|
|
@@ -819,6 +846,7 @@ export interface BlueActions {
|
|
|
819
846
|
readonly data: VaultV2BlueReallocationData;
|
|
820
847
|
};
|
|
821
848
|
}
|
|
849
|
+
/** Binds a viem client to a Morpho Blue market's action builders. */
|
|
822
850
|
export declare class MorphoBlue implements BlueActions {
|
|
823
851
|
private readonly client;
|
|
824
852
|
readonly marketParams: MarketParams;
|
|
@@ -8,6 +8,7 @@ import { DEFAULT_LLTV_BUFFER, validateAccrualPosition, validateChainId, validate
|
|
|
8
8
|
import { ExpiredDeadlineError, InputExceedsMaxError, MaxRepayAssetsBelowRepayAssetsError, MissingAccrualPositionError, MutuallyExclusiveRepayAmountsError, MutuallyExclusiveWithdrawAmountsError, NegativeInputError, NonPositiveInputError, ReallocationsRequireBorrowError, RefinanceSameMarketError, RefinanceTokenMismatchError, } from "../../types/index.js";
|
|
9
9
|
import { getBundlesTokenRequirements } from "../requirements/index.js";
|
|
10
10
|
import { VaultV2BlueReallocationData } from "../vaultV2BlueReallocationData.js";
|
|
11
|
+
/** Binds a viem client to a Morpho Blue market's action builders. */
|
|
11
12
|
export class MorphoBlue {
|
|
12
13
|
client;
|
|
13
14
|
marketParams;
|
|
@@ -8,7 +8,7 @@ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, A
|
|
|
8
8
|
PreLiquidationParams as BluePreLiquidationParams,
|
|
9
9
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
10
10
|
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
11
|
-
export type { BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, RatifierTreeInput as MidnightRatifierTreeInput, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeDescriptor as MidnightTreeDescriptor, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, } from "@morpho-org/midnight-sdk";
|
|
11
|
+
export type { AnyTree as MidnightAnyTree, AnyTreeSnapshot as MidnightAnyTreeSnapshot, BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, EcrecoverTreeCreateRequest as MidnightEcrecoverTreeCreateRequest, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, PriceRatifierV1TreeCreateRequest as MidnightPriceRatifierV1TreeCreateRequest, RateRatifierV1TreeCreateRequest as MidnightRateRatifierV1TreeCreateRequest, RatifierKind as MidnightRatifierKind, RatifierTreeInput as MidnightRatifierTreeInput, RatifierTypes as MidnightRatifierTypes, SetterTreeCreateRequest as MidnightSetterTreeCreateRequest, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeCreateRequest as MidnightTreeCreateRequest, TreeData as MidnightTreeData, TreeDescriptor as MidnightTreeDescriptor, TreeEntry as MidnightTreeEntry, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, TreeSnapshot as MidnightTreeSnapshot, TypedRatifierTreeInput as MidnightTypedRatifierTreeInput, TypedTreeMempoolValidateParams as MidnightTypedTreeMempoolValidateParams, } from "@morpho-org/midnight-sdk";
|
|
12
12
|
export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
|
|
13
13
|
export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
|
|
14
14
|
export { MorphoBlue } from "./blue/index.js";
|
|
@@ -31,6 +31,7 @@ export const getVaultBundlesSharesRequirements = async (viemClient, params) => {
|
|
|
31
31
|
throw new ExpiredDeadlineError(params.deadline, now);
|
|
32
32
|
}
|
|
33
33
|
const spender = getChainAddress(params.chainId, "bundles.vaultBundlesV1");
|
|
34
|
+
// The allowance is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
|
|
34
35
|
const allowance = await readContract(viemClient, {
|
|
35
36
|
address: params.vaultData.address,
|
|
36
37
|
abi: erc20Abi,
|
|
@@ -3,13 +3,19 @@ import { fetchAccrualVault } from "@morpho-org/blue-sdk-viem";
|
|
|
3
3
|
import { type Address } from "viem";
|
|
4
4
|
import type { FetchParameters } from "../../types/data.js";
|
|
5
5
|
import { type ActionOutput, type ActionRequirement, type BundlesFundingArgs, type BundlesTokenRequirementsOptions, type MorphoClientType, type RequirementSignature, type VaultV1DepositAction, type VaultV1InKindRedeemAction, type VaultV1MigrateToV2Action, type VaultV1MigrateToV2AmountArgs, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
|
|
6
|
+
/** Action surface for Vault V1 reads and writes; writes route through VaultBundlesV1 and VaultExitBundlesV1. */
|
|
6
7
|
export interface VaultV1Actions {
|
|
7
8
|
/**
|
|
8
9
|
* Fetches direct onchain vault and allocation state without applying virtual interest.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* Reads the Vault V1 state through `fetchAccrualVault` on the entity's client.
|
|
12
|
+
*
|
|
13
|
+
* @param parameters - Optional viem fetch parameters (block number, block tag, state override).
|
|
14
|
+
* @returns The hydrated `AccrualVault` snapshot.
|
|
12
15
|
* @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
|
|
16
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
17
|
+
* @throws {UnknownBlueFactory} when the configured chain has no MetaMorpho factory.
|
|
18
|
+
* @throws {UnknownBlueOfFactory} when the vault is not a MetaMorpho vault from the configured factory.
|
|
13
19
|
*/
|
|
14
20
|
getData: (parameters?: FetchParameters) => Promise<Awaited<ReturnType<typeof fetchAccrualVault>>>;
|
|
15
21
|
/**
|
|
@@ -414,6 +420,7 @@ export interface VaultV1Actions {
|
|
|
414
420
|
readonly deadline?: bigint;
|
|
415
421
|
} & VaultV1MigrateToV2AmountArgs) => ActionOutput<VaultV1MigrateToV2Action, readonly RequirementSignature[], undefined>;
|
|
416
422
|
}
|
|
423
|
+
/** Binds a viem client to a Vault V1 (MetaMorpho) vault's action builders. */
|
|
417
424
|
export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
418
425
|
private readonly client;
|
|
419
426
|
private readonly vault;
|
|
@@ -10,6 +10,7 @@ import { validateDeadline, validateNativeVaultAsset, validateUint256Field, } fro
|
|
|
10
10
|
import { AmountAndSharesExclusiveError, EmptyMarketParamsListError, ExpiredDeadlineError, InKindRedeemCoverageError, InsufficientBlueBalanceForInKindRedeemError, NonPositiveInputError, SameVaultMigrationError, VaultAddressMismatchError, VaultAssetMismatchError, VaultIsBlueFeeRecipientError, VaultMorphoMismatchError, } from "../../types/index.js";
|
|
11
11
|
import { getVaultBundlesSharesRequirements } from "../requirements/getVaultBundlesSharesRequirements.js";
|
|
12
12
|
import { getBundlesTokenRequirements } from "../requirements/index.js";
|
|
13
|
+
/** Binds a viem client to a Vault V1 (MetaMorpho) vault's action builders. */
|
|
13
14
|
export class MorphoVaultV1 {
|
|
14
15
|
client;
|
|
15
16
|
vault;
|
|
@@ -336,6 +337,7 @@ export class MorphoVaultV1 {
|
|
|
336
337
|
abi: metaMorphoAbi,
|
|
337
338
|
functionName: "MORPHO",
|
|
338
339
|
},
|
|
340
|
+
// feeRecipient() is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
|
|
339
341
|
{
|
|
340
342
|
address: blue,
|
|
341
343
|
abi: blueAbi,
|
|
@@ -3,15 +3,24 @@ import { fetchAccrualVaultV2 } from "@morpho-org/blue-sdk-viem";
|
|
|
3
3
|
import { type Address } from "viem";
|
|
4
4
|
import type { FetchParameters } from "../../types/data.js";
|
|
5
5
|
import { type ActionOutput, type ActionRequirement, type BundlesFundingArgs, type BundlesTokenRequirementsOptions, type Deallocation, type MorphoClientType, type RequirementSignature, type Transaction, type VaultV2DepositAction, type VaultV2ForceRedeemAction, type VaultV2ForceWithdrawAction, type VaultV2InKindRedeemAction, type VaultV2RedeemAction, type VaultV2WithdrawAction } from "../../types/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Action surface for Vault V2 reads and writes; writes route through VaultBundlesV1 and
|
|
8
|
+
* VaultExitBundlesV1, except `forceRedeem`, which uses the vault's native multicall.
|
|
9
|
+
*/
|
|
6
10
|
export interface VaultV2Actions {
|
|
7
11
|
/**
|
|
8
|
-
* Fetches the latest vault
|
|
12
|
+
* Fetches the latest accrual snapshot of the vault.
|
|
9
13
|
*
|
|
10
|
-
*
|
|
11
|
-
* @param {FetchParameters} [parameters] - The parameters for the fetch operation.
|
|
14
|
+
* Reads the Vault V2 state through `fetchAccrualVaultV2` on the entity's client.
|
|
12
15
|
*
|
|
13
|
-
* @
|
|
16
|
+
* @param parameters - Optional viem fetch parameters (block number, block tag, state override).
|
|
17
|
+
* @returns The hydrated `AccrualVaultV2` snapshot.
|
|
14
18
|
* @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
|
|
19
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
20
|
+
* @throws {UnknownBlueFactory} when the configured chain has no VaultV2 factory.
|
|
21
|
+
* @throws {UnknownBlueOfFactory} when the vault is not a VaultV2 from the configured factory.
|
|
22
|
+
* @throws {UnsupportedBlueVaultV2AdapterError} when the vault or one of its adapters uses an
|
|
23
|
+
* unsupported adapter class.
|
|
15
24
|
*/
|
|
16
25
|
getData: (parameters?: FetchParameters) => Promise<Awaited<ReturnType<typeof fetchAccrualVaultV2>>>;
|
|
17
26
|
/**
|
|
@@ -463,13 +472,27 @@ export interface VaultV2Actions {
|
|
|
463
472
|
* asset-equivalent of the redeemed shares. The caller should apply a buffer on the deallocated
|
|
464
473
|
* amounts to account for share-price drift between submission and execution.
|
|
465
474
|
*
|
|
466
|
-
* @param
|
|
467
|
-
* @param
|
|
468
|
-
* @param
|
|
469
|
-
* @
|
|
470
|
-
*
|
|
471
|
-
* @
|
|
472
|
-
* @
|
|
475
|
+
* @param params.deallocations - Typed list of `forceDeallocate` calls to perform before the redeem.
|
|
476
|
+
* @param params.redeem.shares - Amount of vault shares to redeem after the deallocations.
|
|
477
|
+
* @param params.userAddress - Account that pays the deallocation penalties and receives the redeemed assets.
|
|
478
|
+
* @returns An object whose `buildTx()` returns a deep-frozen `Transaction<VaultV2ForceRedeemAction>`
|
|
479
|
+
* encoding the vault `multicall`.
|
|
480
|
+
* @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
|
|
481
|
+
* @throws {EmptyDeallocationsError} from `buildTx()` when `deallocations` is empty.
|
|
482
|
+
* @throws {NonPositiveInputError} from `buildTx()` when `redeem.shares <= 0n` or any deallocation
|
|
483
|
+
* amount is non-positive.
|
|
484
|
+
* @example
|
|
485
|
+
* ```ts
|
|
486
|
+
* const vault = client.morpho.vaultV2(vaultAddress, 1);
|
|
487
|
+
* const tx = vault
|
|
488
|
+
* .forceRedeem({
|
|
489
|
+
* deallocations: [{ adapter, marketParams, amount: 1_000_000n }],
|
|
490
|
+
* redeem: { shares: 500_000n },
|
|
491
|
+
* userAddress,
|
|
492
|
+
* })
|
|
493
|
+
* .buildTx();
|
|
494
|
+
* // tx satisfies Readonly<Transaction<VaultV2ForceRedeemAction>>
|
|
495
|
+
* ```
|
|
473
496
|
*/
|
|
474
497
|
forceRedeem: (params: {
|
|
475
498
|
deallocations: readonly Deallocation[];
|
|
@@ -481,6 +504,7 @@ export interface VaultV2Actions {
|
|
|
481
504
|
buildTx: () => Readonly<Transaction<VaultV2ForceRedeemAction>>;
|
|
482
505
|
};
|
|
483
506
|
}
|
|
507
|
+
/** Binds a viem client to a Vault V2 vault's action builders. */
|
|
484
508
|
export declare class MorphoVaultV2 implements VaultV2Actions {
|
|
485
509
|
private readonly client;
|
|
486
510
|
private readonly vault;
|
|
@@ -13,6 +13,7 @@ import { getBundlesTokenRequirements } from "../requirements/index.js";
|
|
|
13
13
|
// Maximum accepted deadline horizon; the on-chain management fee is capped at 5%/yr so the
|
|
14
14
|
// accrual model stays well-defined inside it.
|
|
15
15
|
const VAULT_V2_FEE_PROJECTION_HORIZON = Time.s.from.y(1n);
|
|
16
|
+
/** Binds a viem client to a Vault V2 vault's action builders. */
|
|
16
17
|
export class MorphoVaultV2 {
|
|
17
18
|
client;
|
|
18
19
|
vault;
|