@morpho-org/morpho-sdk 5.5.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -7
- package/lib/cjs/abis.d.ts +15 -3
- package/lib/cjs/abis.js +15 -1
- package/lib/cjs/actions/blue/borrow.d.ts +21 -15
- package/lib/cjs/actions/blue/borrow.js +25 -18
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +1 -1
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +1 -1
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +62 -19
- package/lib/cjs/actions/blue/buildReallocationActions.js +123 -27
- package/lib/cjs/actions/blue/refinance.d.ts +14 -7
- package/lib/cjs/actions/blue/refinance.js +18 -10
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +28 -19
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +39 -23
- package/lib/cjs/actions/blue/withdraw.d.ts +20 -13
- package/lib/cjs/actions/blue/withdraw.js +23 -18
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +2 -2
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +2 -2
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +1 -1
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -1
- package/lib/cjs/blue/abis.d.ts +2 -0
- package/lib/cjs/blue/abis.js +33 -0
- package/lib/cjs/blue/addresses.d.ts +2 -0
- package/lib/cjs/blue/addresses.js +19 -0
- package/lib/cjs/blue/constants.d.ts +1 -0
- package/lib/cjs/blue/constants.js +13 -0
- package/lib/cjs/blue/entities.d.ts +2 -0
- package/lib/cjs/blue/entities.js +37 -0
- package/lib/cjs/blue/errors.d.ts +2 -0
- package/lib/cjs/blue/errors.js +29 -0
- package/lib/cjs/blue/fetch.d.ts +1 -0
- package/lib/cjs/blue/fetch.js +33 -0
- package/lib/cjs/blue/types.d.ts +2 -0
- package/lib/cjs/blue/types.js +2 -0
- package/lib/cjs/blue/utils.d.ts +3 -0
- package/lib/cjs/blue/utils.js +29 -0
- package/lib/cjs/bundler/actions.d.ts +122 -3
- package/lib/cjs/bundler/actions.js +216 -7
- package/lib/cjs/bundler/types.d.ts +20 -0
- package/lib/cjs/constants.d.ts +37 -3
- package/lib/cjs/constants.js +41 -1
- package/lib/cjs/entities/blue/blue.d.ts +362 -71
- package/lib/cjs/entities/blue/blue.js +286 -52
- package/lib/cjs/entities/index.d.ts +64 -4
- package/lib/cjs/entities/index.js +37 -22
- package/lib/cjs/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +40 -15
- package/lib/cjs/entities/{reallocationData.js → vaultV1ReallocationData.js} +29 -16
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +1 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +1300 -0
- package/lib/cjs/errors.d.ts +48 -3
- package/lib/cjs/errors.js +62 -1
- package/lib/cjs/fetch.d.ts +16 -1
- package/lib/cjs/fetch.js +24 -1
- package/lib/{esm/helpers/computeReallocations.d.ts → cjs/helpers/computeVaultV1Reallocations.d.ts} +14 -8
- package/lib/cjs/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +27 -13
- package/lib/cjs/helpers/constant.d.ts +5 -3
- package/lib/cjs/helpers/constant.js +6 -4
- package/lib/cjs/helpers/index.d.ts +2 -2
- package/lib/cjs/helpers/index.js +6 -3
- package/lib/cjs/helpers/validate.d.ts +32 -16
- package/lib/cjs/helpers/validate.js +142 -29
- package/lib/cjs/midnight/abis.d.ts +1 -0
- package/lib/cjs/midnight/abis.js +8 -0
- package/lib/cjs/midnight/constants.d.ts +1 -0
- package/lib/cjs/midnight/constants.js +19 -0
- package/lib/cjs/midnight/entities.d.ts +2 -0
- package/lib/cjs/midnight/entities.js +11 -0
- package/lib/cjs/midnight/errors.d.ts +1 -0
- package/lib/cjs/midnight/errors.js +24 -0
- package/lib/cjs/midnight/fetch.d.ts +1 -0
- package/lib/cjs/midnight/fetch.js +9 -0
- package/lib/cjs/midnight/types.d.ts +1 -0
- package/lib/cjs/midnight/types.js +2 -0
- package/lib/cjs/midnight/utils.d.ts +1 -0
- package/lib/cjs/midnight/utils.js +17 -0
- package/lib/cjs/types/action.d.ts +12 -0
- package/lib/cjs/types/error.d.ts +224 -5
- package/lib/cjs/types/error.js +269 -7
- package/lib/cjs/types/sharedLiquidity.d.ts +72 -8
- package/lib/cjs/types.d.ts +17 -2
- package/lib/cjs/utils.d.ts +31 -4
- package/lib/cjs/utils.js +44 -4
- package/lib/esm/abis.d.ts +15 -3
- package/lib/esm/abis.js +15 -3
- package/lib/esm/actions/blue/borrow.d.ts +21 -15
- package/lib/esm/actions/blue/borrow.js +26 -19
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +1 -1
- package/lib/esm/actions/blue/buildAssetFundingActions.js +1 -1
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +62 -19
- package/lib/esm/actions/blue/buildReallocationActions.js +119 -25
- package/lib/esm/actions/blue/refinance.d.ts +14 -7
- package/lib/esm/actions/blue/refinance.js +19 -11
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +28 -19
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +40 -24
- package/lib/esm/actions/blue/withdraw.d.ts +20 -13
- package/lib/esm/actions/blue/withdraw.js +24 -19
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +2 -2
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +2 -2
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +1 -1
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -1
- package/lib/esm/blue/abis.d.ts +2 -0
- package/lib/esm/blue/abis.js +2 -0
- package/lib/esm/blue/addresses.d.ts +2 -0
- package/lib/esm/blue/addresses.js +1 -0
- package/lib/esm/blue/constants.d.ts +1 -0
- package/lib/esm/blue/constants.js +1 -0
- package/lib/esm/blue/entities.d.ts +2 -0
- package/lib/esm/blue/entities.js +1 -0
- package/lib/esm/blue/errors.d.ts +2 -0
- package/lib/esm/blue/errors.js +2 -0
- package/lib/esm/blue/fetch.d.ts +1 -0
- package/lib/esm/blue/fetch.js +1 -0
- package/lib/esm/blue/types.d.ts +2 -0
- package/lib/esm/blue/types.js +1 -0
- package/lib/esm/blue/utils.d.ts +3 -0
- package/lib/esm/blue/utils.js +2 -0
- package/lib/esm/bundler/actions.d.ts +122 -3
- package/lib/esm/bundler/actions.js +219 -10
- package/lib/esm/bundler/types.d.ts +20 -0
- package/lib/esm/constants.d.ts +37 -3
- package/lib/esm/constants.js +37 -3
- package/lib/esm/entities/blue/blue.d.ts +362 -71
- package/lib/esm/entities/blue/blue.js +289 -55
- package/lib/esm/entities/index.d.ts +64 -4
- package/lib/esm/entities/index.js +19 -3
- package/lib/esm/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +40 -15
- package/lib/esm/entities/{reallocationData.js → vaultV1ReallocationData.js} +32 -14
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +1 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.js +1296 -0
- package/lib/esm/errors.d.ts +48 -3
- package/lib/esm/errors.js +48 -3
- package/lib/esm/fetch.d.ts +16 -1
- package/lib/esm/fetch.js +16 -1
- package/lib/{cjs/helpers/computeReallocations.d.ts → esm/helpers/computeVaultV1Reallocations.d.ts} +14 -8
- package/lib/esm/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +25 -11
- package/lib/esm/helpers/constant.d.ts +5 -3
- package/lib/esm/helpers/constant.js +5 -3
- package/lib/esm/helpers/index.d.ts +2 -2
- package/lib/esm/helpers/index.js +2 -2
- package/lib/esm/helpers/validate.d.ts +32 -16
- package/lib/esm/helpers/validate.js +143 -32
- package/lib/esm/midnight/abis.d.ts +1 -0
- package/lib/esm/midnight/abis.js +1 -0
- package/lib/esm/midnight/constants.d.ts +1 -0
- package/lib/esm/midnight/constants.js +1 -0
- package/lib/esm/midnight/entities.d.ts +2 -0
- package/lib/esm/midnight/entities.js +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -0
- package/lib/esm/midnight/errors.js +1 -0
- package/lib/esm/midnight/fetch.d.ts +1 -0
- package/lib/esm/midnight/fetch.js +1 -0
- package/lib/esm/midnight/types.d.ts +1 -0
- package/lib/esm/midnight/types.js +1 -0
- package/lib/esm/midnight/utils.d.ts +1 -0
- package/lib/esm/midnight/utils.js +1 -0
- package/lib/esm/types/action.d.ts +12 -0
- package/lib/esm/types/error.d.ts +224 -5
- package/lib/esm/types/error.js +253 -4
- package/lib/esm/types/sharedLiquidity.d.ts +72 -8
- package/lib/esm/types.d.ts +17 -2
- package/lib/esm/utils.d.ts +31 -4
- package/lib/esm/utils.js +31 -4
- package/package.json +23 -7
|
@@ -13,16 +13,16 @@ export interface PublicAllocatorOptions {
|
|
|
13
13
|
readonly timestamp?: BigIntish;
|
|
14
14
|
/**
|
|
15
15
|
* Vaults to consider for reallocation. They must have enabled the PublicAllocator.
|
|
16
|
+
* Arrays, readonly arrays, sets, and other iterables are accepted.
|
|
16
17
|
* Defaults to all vaults present in the reallocation data.
|
|
17
18
|
*/
|
|
18
|
-
readonly reallocatableVaults?:
|
|
19
|
+
readonly reallocatableVaults?: Iterable<Address>;
|
|
19
20
|
/**
|
|
20
21
|
* The maximum utilization each source market may reach when withdrawing
|
|
21
22
|
* shared liquidity, scaled by WAD.
|
|
22
23
|
*
|
|
23
|
-
* @deprecated
|
|
24
|
-
*
|
|
25
|
-
* configurable in the next major. Per-market overrides are still honored for now.
|
|
24
|
+
* @deprecated Per-market source ceilings will be removed in the next major.
|
|
25
|
+
* Use `defaultMaxWithdrawalUtilization` to configure one ceiling for every source.
|
|
26
26
|
*/
|
|
27
27
|
readonly maxWithdrawalUtilization?: Readonly<Record<MarketId, bigint | undefined>>;
|
|
28
28
|
/**
|
|
@@ -30,12 +30,37 @@ export interface PublicAllocatorOptions {
|
|
|
30
30
|
* shared liquidity, scaled by WAD.
|
|
31
31
|
*
|
|
32
32
|
* @default 90% (900000000000000000n)
|
|
33
|
-
* @deprecated The source-market withdrawal ceiling is fixed at 90%
|
|
34
|
-
* ({@link DEFAULT_WITHDRAWAL_TARGET_UTILIZATION}) and will stop being
|
|
35
|
-
* configurable in the next major. Overrides are still honored for now.
|
|
36
33
|
*/
|
|
37
34
|
readonly defaultMaxWithdrawalUtilization?: bigint;
|
|
38
35
|
}
|
|
36
|
+
/** Options controlling Vault V2 BluePublicAllocator reallocation discovery. */
|
|
37
|
+
export interface VaultV2BluePublicAllocatorOptions {
|
|
38
|
+
/** Whether Vault V2 public allocator discovery is enabled. */
|
|
39
|
+
readonly enabled?: boolean;
|
|
40
|
+
/** Timestamp at which market and Vault V2 interest is evaluated. */
|
|
41
|
+
readonly timestamp?: BigIntish;
|
|
42
|
+
/**
|
|
43
|
+
* Vault V2 addresses to consider. Arrays, readonly arrays, sets, and other
|
|
44
|
+
* iterables are accepted. Defaults to every vault in the reallocation data.
|
|
45
|
+
*/
|
|
46
|
+
readonly reallocatableVaults?: Iterable<Address>;
|
|
47
|
+
/**
|
|
48
|
+
* Maximum utilization source markets may reach during friendly discovery,
|
|
49
|
+
* scaled by WAD. The amount-aware planner falls back to 100% only when the
|
|
50
|
+
* friendly phase cannot cover the operation's absolute shortfall.
|
|
51
|
+
*
|
|
52
|
+
* @default 90% (900000000000000000n)
|
|
53
|
+
*/
|
|
54
|
+
readonly maxWithdrawalUtilization?: bigint;
|
|
55
|
+
/**
|
|
56
|
+
* Maximum proportional vault-asset penalty accepted for each
|
|
57
|
+
* BluePublicAllocator call, scaled by WAD. Vaults with a higher configured
|
|
58
|
+
* penalty are ignored. Must not exceed WAD (100%).
|
|
59
|
+
*
|
|
60
|
+
* @default 0n
|
|
61
|
+
*/
|
|
62
|
+
readonly maxPenalty?: bigint;
|
|
63
|
+
}
|
|
39
64
|
/**
|
|
40
65
|
* A computed source-market withdrawal before it is grouped by vault.
|
|
41
66
|
*/
|
|
@@ -60,13 +85,52 @@ export interface ReallocationWithdrawal {
|
|
|
60
85
|
* Maps 1:1 to a `PublicAllocator.reallocateTo()` call.
|
|
61
86
|
* Withdraws from source markets and supplies to the target market.
|
|
62
87
|
*/
|
|
63
|
-
export interface
|
|
88
|
+
export interface VaultV1Reallocation {
|
|
64
89
|
readonly vault: Address;
|
|
65
90
|
/** Fee in native token (ETH) paid to the PublicAllocator for this vault. */
|
|
66
91
|
readonly fee: bigint;
|
|
67
92
|
/** Source markets to withdraw from before supplying to the target market. */
|
|
68
93
|
readonly withdrawals: readonly ReallocationWithdrawal[];
|
|
69
94
|
}
|
|
95
|
+
/** Source of a Vault V2 BluePublicAllocator reallocation. */
|
|
96
|
+
export type VaultV2BlueReallocationSource = {
|
|
97
|
+
/** Reallocate from a Morpho Blue market. */
|
|
98
|
+
readonly type: "market";
|
|
99
|
+
/** Vault V2 adapter supplying the source market. */
|
|
100
|
+
readonly adapter: Address;
|
|
101
|
+
/** Source market parameters. */
|
|
102
|
+
readonly marketParams: MarketParams;
|
|
103
|
+
} | {
|
|
104
|
+
/** Allocate from vault idle liquidity without a synthetic market. */
|
|
105
|
+
readonly type: "idle";
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* One Blue Public Allocator contract call performed before a Blue action.
|
|
109
|
+
*
|
|
110
|
+
* The target market parameters are derived from the enclosing Blue action.
|
|
111
|
+
*/
|
|
112
|
+
export interface VaultV2BlueReallocation {
|
|
113
|
+
/** Vault whose liquidity is moved. */
|
|
114
|
+
readonly vault: Address;
|
|
115
|
+
/** Liquidity source. */
|
|
116
|
+
readonly from: VaultV2BlueReallocationSource;
|
|
117
|
+
/** Target Vault V2 adapter; the target market comes from the enclosing action. */
|
|
118
|
+
readonly to: {
|
|
119
|
+
readonly adapter: Address;
|
|
120
|
+
};
|
|
121
|
+
/** Asset amount, which must fit in `uint128`. */
|
|
122
|
+
readonly assets: bigint;
|
|
123
|
+
/** Vault-configured WAD-scaled penalty rate passed to the allocator. */
|
|
124
|
+
readonly penalty: bigint;
|
|
125
|
+
}
|
|
126
|
+
/** A homogeneous Blue action plan containing only Vault V1 or only Vault V2 reallocations. */
|
|
127
|
+
export type BlueReallocationPlan = Iterable<VaultV1Reallocation> | Iterable<VaultV2BlueReallocation>;
|
|
128
|
+
/**
|
|
129
|
+
* Deprecated name for a Vault V1 reallocation.
|
|
130
|
+
*
|
|
131
|
+
* @deprecated Use {@link VaultV1Reallocation} instead.
|
|
132
|
+
*/
|
|
133
|
+
export type VaultReallocation = VaultV1Reallocation;
|
|
70
134
|
/**
|
|
71
135
|
* Options for computing vault reallocations via the public allocator.
|
|
72
136
|
*
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
export type { BigIntish, CollateralAllocation, Eip712Field, Erc20AllowanceRecipient, Failable, Fetchable, InputMarketParams
|
|
2
|
-
|
|
1
|
+
export type { BigIntish, CollateralAllocation, Eip712Field, Erc20AllowanceRecipient, Failable, Fetchable, InputMarketParams as BlueInputMarketParams,
|
|
2
|
+
/** @deprecated Use `BlueInputMarketParams` or the raw `/blue/types` subpath. */
|
|
3
|
+
InputMarketParams, IPermit2Allowance, Loadable, MarketId as BlueMarketId,
|
|
4
|
+
/** @deprecated Use `BlueMarketId` or the raw `/blue/types` subpath. */
|
|
5
|
+
MarketId, MaxBorrowOptions as BlueMaxBorrowOptions,
|
|
6
|
+
/** @deprecated Use `BlueMaxBorrowOptions` or the raw `/blue/types` subpath. */
|
|
7
|
+
MaxBorrowOptions, MaxPositionCapacities as BlueMaxPositionCapacities,
|
|
8
|
+
/** @deprecated Use `BlueMaxPositionCapacities` or the raw `/blue/types` subpath. */
|
|
9
|
+
MaxPositionCapacities, MaxWithdrawCollateralOptions as BlueMaxWithdrawCollateralOptions,
|
|
10
|
+
/** @deprecated Use `BlueMaxWithdrawCollateralOptions` or the raw `/blue/types` subpath. */
|
|
11
|
+
MaxWithdrawCollateralOptions, Pending, Permit2Allowance, } from "@morpho-org/blue-sdk";
|
|
12
|
+
export type { AuthorizationArgs as BlueAuthorizationTypedDataArgs, DaiPermitArgs, DeploylessFetchParameters as BlueDeploylessFetchParameters,
|
|
13
|
+
/** @deprecated Use `BlueDeploylessFetchParameters` or the raw `/blue/types` subpath. */
|
|
14
|
+
DeploylessFetchParameters, FetchParameters as BlueFetchParameters,
|
|
15
|
+
/** @deprecated Use `BlueFetchParameters` or the raw `/blue/types` subpath. */
|
|
16
|
+
FetchParameters, InputAllocation as BlueInputAllocation, MetaMorphoCall as BlueMetaMorphoCall, Permit2PermitArgs, Permit2TransferFromArgs, PermitArgs as PermitTypedDataArgs, } from "@morpho-org/blue-sdk-viem";
|
|
17
|
+
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
18
|
export type { ChainMetadata } from "@morpho-org/morpho-ts";
|
|
4
19
|
export * from "./types/index.js";
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { AdaptiveCurveIrmLib
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib,
|
|
3
|
+
/** @deprecated Use BlueAdaptiveCurveIrmLib or the raw protocol subpath. */
|
|
4
|
+
AdaptiveCurveIrmLib, CapacityLimitReason, defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry, getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils,
|
|
5
|
+
/** @deprecated Use BlueMarketUtils or the raw protocol subpath. */
|
|
6
|
+
MarketUtils, MathLib, SharesMath as BlueSharesMath,
|
|
7
|
+
/** @deprecated Use BlueSharesMath or the raw protocol subpath. */
|
|
8
|
+
SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
9
|
+
export { decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData,
|
|
10
|
+
/** @deprecated Use getBlueAuthorizationTypedData or the raw protocol subpath. */
|
|
11
|
+
getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
12
|
+
export { EcrecoverRatifierUtils as MidnightEcrecoverRatifierUtils,
|
|
13
|
+
/** @deprecated Use MidnightEcrecoverRatifierUtils or the raw protocol subpath. */
|
|
14
|
+
EcrecoverRatifierUtils, eip712Digest, GroupUtils as MidnightGroupUtils,
|
|
15
|
+
/** @deprecated Use MidnightGroupUtils or the raw protocol subpath. */
|
|
16
|
+
GroupUtils, MarketUtils as MidnightMarketUtils, OfferChainUtils as MidnightOfferChainUtils, OfferUtils as MidnightOfferUtils,
|
|
17
|
+
/** @deprecated Use MidnightOfferUtils or the raw protocol subpath. */
|
|
18
|
+
OfferUtils, Payload as MidnightPayload,
|
|
19
|
+
/** @deprecated Use MidnightPayload or the raw protocol subpath. */
|
|
20
|
+
Payload, PositionUtils as MidnightPositionUtils, RatifierUtils as MidnightRatifierUtils,
|
|
21
|
+
/** @deprecated Use MidnightRatifierUtils or the raw protocol subpath. */
|
|
22
|
+
RatifierUtils, SetterRatifierUtils as MidnightSetterRatifierUtils,
|
|
23
|
+
/** @deprecated Use MidnightSetterRatifierUtils or the raw protocol subpath. */
|
|
24
|
+
SetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib,
|
|
25
|
+
/** @deprecated Use MidnightTakeAmountsLib or the raw protocol subpath. */
|
|
26
|
+
TakeAmountsLib, TickLib as MidnightTickLib,
|
|
27
|
+
/** @deprecated Use MidnightTickLib or the raw protocol subpath. */
|
|
28
|
+
TickLib, TreeUtils as MidnightTreeUtils,
|
|
29
|
+
/** @deprecated Use MidnightTreeUtils or the raw protocol subpath. */
|
|
30
|
+
TreeUtils, } from "@morpho-org/midnight-sdk";
|
|
5
31
|
export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, WithId, WithIndex, } from "@morpho-org/morpho-ts";
|
|
6
32
|
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";
|
|
7
|
-
export { computeReallocations } from "./helpers/
|
|
33
|
+
export { computeReallocations, computeVaultV1Reallocations, } from "./helpers/computeVaultV1Reallocations.js";
|
|
8
34
|
export { addTransactionMetadata } from "./helpers/metadata.js";
|
|
35
|
+
export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./helpers/previewVaultV2InKindRedeem.js";
|
|
9
36
|
export { computeMaxRepaySharePrice, computeMinBorrowSharePrice, } from "./helpers/slippage.js";
|
|
10
37
|
export { validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, } from "./helpers/validate.js";
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validateReallocations = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinBorrowSharePrice = void 0;
|
|
3
|
+
exports.TreeUtils = exports.MidnightTreeUtils = exports.TickLib = exports.MidnightTickLib = exports.TakeAmountsLib = exports.MidnightTakeAmountsLib = exports.SetterRatifierUtils = exports.MidnightSetterRatifierUtils = exports.RatifierUtils = exports.MidnightRatifierUtils = exports.MidnightPositionUtils = exports.Payload = exports.MidnightPayload = exports.OfferUtils = exports.MidnightOfferUtils = exports.MidnightOfferChainUtils = exports.MidnightMarketUtils = exports.GroupUtils = exports.MidnightGroupUtils = exports.eip712Digest = exports.EcrecoverRatifierUtils = exports.MidnightEcrecoverRatifierUtils = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.BlueMetaMorphoAction = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getDaiPermitTypedData = exports.getAuthorizationTypedData = exports.getBlueAuthorizationTypedData = exports.decodeBytes32String = exports.VaultV2Utils = exports.VaultV2BluePublicAllocatorConfigUtils = exports.VaultV2BlueMarketPublicAllocatorConfigUtils = exports.VaultUtils = exports.SharesMath = exports.BlueSharesMath = exports.MathLib = exports.MarketUtils = exports.BlueMarketUtils = exports.getBlueDefaultPreLiquidationParams = exports.blueDefaultPreLiquidationParamsRegistry = exports.CapacityLimitReason = exports.AdaptiveCurveIrmLib = exports.BlueAdaptiveCurveIrmLib = void 0;
|
|
4
|
+
exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validateReallocations = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinBorrowSharePrice = exports.computeMaxRepaySharePrice = exports.previewVaultV2InKindRedeem = exports.addTransactionMetadata = exports.computeVaultV1Reallocations = exports.computeReallocations = 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 = exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = exports.createHasValue = exports.createGetValue = exports.bigIntComparator = void 0;
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
|
+
Object.defineProperty(exports, "BlueAdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
7
|
+
/** @deprecated Use BlueAdaptiveCurveIrmLib or the raw protocol subpath. */
|
|
6
8
|
Object.defineProperty(exports, "AdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
7
9
|
Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
|
|
10
|
+
Object.defineProperty(exports, "blueDefaultPreLiquidationParamsRegistry", { enumerable: true, get: function () { return blue_sdk_1.defaultPreLiquidationParamsRegistry; } });
|
|
11
|
+
Object.defineProperty(exports, "getBlueDefaultPreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.getDefaultPreLiquidationParams; } });
|
|
12
|
+
Object.defineProperty(exports, "BlueMarketUtils", { enumerable: true, get: function () { return blue_sdk_1.MarketUtils; } });
|
|
13
|
+
/** @deprecated Use BlueMarketUtils or the raw protocol subpath. */
|
|
8
14
|
Object.defineProperty(exports, "MarketUtils", { enumerable: true, get: function () { return blue_sdk_1.MarketUtils; } });
|
|
9
15
|
Object.defineProperty(exports, "MathLib", { enumerable: true, get: function () { return blue_sdk_1.MathLib; } });
|
|
16
|
+
Object.defineProperty(exports, "BlueSharesMath", { enumerable: true, get: function () { return blue_sdk_1.SharesMath; } });
|
|
17
|
+
/** @deprecated Use BlueSharesMath or the raw protocol subpath. */
|
|
10
18
|
Object.defineProperty(exports, "SharesMath", { enumerable: true, get: function () { return blue_sdk_1.SharesMath; } });
|
|
11
19
|
Object.defineProperty(exports, "VaultUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultUtils; } });
|
|
20
|
+
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfigUtils; } });
|
|
21
|
+
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfigUtils; } });
|
|
22
|
+
Object.defineProperty(exports, "VaultV2Utils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Utils; } });
|
|
12
23
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
13
24
|
Object.defineProperty(exports, "decodeBytes32String", { enumerable: true, get: function () { return blue_sdk_viem_1.decodeBytes32String; } });
|
|
25
|
+
Object.defineProperty(exports, "getBlueAuthorizationTypedData", { enumerable: true, get: function () { return blue_sdk_viem_1.getAuthorizationTypedData; } });
|
|
26
|
+
/** @deprecated Use getBlueAuthorizationTypedData or the raw protocol subpath. */
|
|
14
27
|
Object.defineProperty(exports, "getAuthorizationTypedData", { enumerable: true, get: function () { return blue_sdk_viem_1.getAuthorizationTypedData; } });
|
|
28
|
+
Object.defineProperty(exports, "getDaiPermitTypedData", { enumerable: true, get: function () { return blue_sdk_viem_1.getDaiPermitTypedData; } });
|
|
15
29
|
Object.defineProperty(exports, "getPermit2PermitTypedData", { enumerable: true, get: function () { return blue_sdk_viem_1.getPermit2PermitTypedData; } });
|
|
16
30
|
Object.defineProperty(exports, "getPermit2TransferFromTypedData", { enumerable: true, get: function () { return blue_sdk_viem_1.getPermit2TransferFromTypedData; } });
|
|
17
31
|
Object.defineProperty(exports, "getPermitTypedData", { enumerable: true, get: function () { return blue_sdk_viem_1.getPermitTypedData; } });
|
|
32
|
+
Object.defineProperty(exports, "BlueMetaMorphoAction", { enumerable: true, get: function () { return blue_sdk_viem_1.MetaMorphoAction; } });
|
|
18
33
|
Object.defineProperty(exports, "optionalBoolean", { enumerable: true, get: function () { return blue_sdk_viem_1.optionalBoolean; } });
|
|
19
34
|
Object.defineProperty(exports, "readContractRestructured", { enumerable: true, get: function () { return blue_sdk_viem_1.readContractRestructured; } });
|
|
20
35
|
Object.defineProperty(exports, "restructure", { enumerable: true, get: function () { return blue_sdk_viem_1.restructure; } });
|
|
@@ -22,14 +37,36 @@ Object.defineProperty(exports, "safeGetAddress", { enumerable: true, get: functi
|
|
|
22
37
|
Object.defineProperty(exports, "safeParseNumber", { enumerable: true, get: function () { return blue_sdk_viem_1.safeParseNumber; } });
|
|
23
38
|
Object.defineProperty(exports, "safeParseUnits", { enumerable: true, get: function () { return blue_sdk_viem_1.safeParseUnits; } });
|
|
24
39
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
40
|
+
Object.defineProperty(exports, "MidnightEcrecoverRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifierUtils; } });
|
|
41
|
+
/** @deprecated Use MidnightEcrecoverRatifierUtils or the raw protocol subpath. */
|
|
25
42
|
Object.defineProperty(exports, "EcrecoverRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifierUtils; } });
|
|
43
|
+
Object.defineProperty(exports, "eip712Digest", { enumerable: true, get: function () { return midnight_sdk_1.eip712Digest; } });
|
|
44
|
+
Object.defineProperty(exports, "MidnightGroupUtils", { enumerable: true, get: function () { return midnight_sdk_1.GroupUtils; } });
|
|
45
|
+
/** @deprecated Use MidnightGroupUtils or the raw protocol subpath. */
|
|
26
46
|
Object.defineProperty(exports, "GroupUtils", { enumerable: true, get: function () { return midnight_sdk_1.GroupUtils; } });
|
|
47
|
+
Object.defineProperty(exports, "MidnightMarketUtils", { enumerable: true, get: function () { return midnight_sdk_1.MarketUtils; } });
|
|
48
|
+
Object.defineProperty(exports, "MidnightOfferChainUtils", { enumerable: true, get: function () { return midnight_sdk_1.OfferChainUtils; } });
|
|
49
|
+
Object.defineProperty(exports, "MidnightOfferUtils", { enumerable: true, get: function () { return midnight_sdk_1.OfferUtils; } });
|
|
50
|
+
/** @deprecated Use MidnightOfferUtils or the raw protocol subpath. */
|
|
27
51
|
Object.defineProperty(exports, "OfferUtils", { enumerable: true, get: function () { return midnight_sdk_1.OfferUtils; } });
|
|
52
|
+
Object.defineProperty(exports, "MidnightPayload", { enumerable: true, get: function () { return midnight_sdk_1.Payload; } });
|
|
53
|
+
/** @deprecated Use MidnightPayload or the raw protocol subpath. */
|
|
28
54
|
Object.defineProperty(exports, "Payload", { enumerable: true, get: function () { return midnight_sdk_1.Payload; } });
|
|
55
|
+
Object.defineProperty(exports, "MidnightPositionUtils", { enumerable: true, get: function () { return midnight_sdk_1.PositionUtils; } });
|
|
56
|
+
Object.defineProperty(exports, "MidnightRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.RatifierUtils; } });
|
|
57
|
+
/** @deprecated Use MidnightRatifierUtils or the raw protocol subpath. */
|
|
29
58
|
Object.defineProperty(exports, "RatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.RatifierUtils; } });
|
|
59
|
+
Object.defineProperty(exports, "MidnightSetterRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.SetterRatifierUtils; } });
|
|
60
|
+
/** @deprecated Use MidnightSetterRatifierUtils or the raw protocol subpath. */
|
|
30
61
|
Object.defineProperty(exports, "SetterRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.SetterRatifierUtils; } });
|
|
62
|
+
Object.defineProperty(exports, "MidnightTakeAmountsLib", { enumerable: true, get: function () { return midnight_sdk_1.TakeAmountsLib; } });
|
|
63
|
+
/** @deprecated Use MidnightTakeAmountsLib or the raw protocol subpath. */
|
|
31
64
|
Object.defineProperty(exports, "TakeAmountsLib", { enumerable: true, get: function () { return midnight_sdk_1.TakeAmountsLib; } });
|
|
65
|
+
Object.defineProperty(exports, "MidnightTickLib", { enumerable: true, get: function () { return midnight_sdk_1.TickLib; } });
|
|
66
|
+
/** @deprecated Use MidnightTickLib or the raw protocol subpath. */
|
|
32
67
|
Object.defineProperty(exports, "TickLib", { enumerable: true, get: function () { return midnight_sdk_1.TickLib; } });
|
|
68
|
+
Object.defineProperty(exports, "MidnightTreeUtils", { enumerable: true, get: function () { return midnight_sdk_1.TreeUtils; } });
|
|
69
|
+
/** @deprecated Use MidnightTreeUtils or the raw protocol subpath. */
|
|
33
70
|
Object.defineProperty(exports, "TreeUtils", { enumerable: true, get: function () { return midnight_sdk_1.TreeUtils; } });
|
|
34
71
|
var morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
35
72
|
Object.defineProperty(exports, "bigIntComparator", { enumerable: true, get: function () { return morpho_ts_1.bigIntComparator; } });
|
|
@@ -53,10 +90,13 @@ Object.defineProperty(exports, "retryPromiseLinearBackoff", { enumerable: true,
|
|
|
53
90
|
Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return morpho_ts_1.Time; } });
|
|
54
91
|
Object.defineProperty(exports, "transformValue", { enumerable: true, get: function () { return morpho_ts_1.transformValue; } });
|
|
55
92
|
Object.defineProperty(exports, "values", { enumerable: true, get: function () { return morpho_ts_1.values; } });
|
|
56
|
-
var
|
|
57
|
-
Object.defineProperty(exports, "computeReallocations", { enumerable: true, get: function () { return
|
|
93
|
+
var computeVaultV1Reallocations_js_1 = require("./helpers/computeVaultV1Reallocations.js");
|
|
94
|
+
Object.defineProperty(exports, "computeReallocations", { enumerable: true, get: function () { return computeVaultV1Reallocations_js_1.computeReallocations; } });
|
|
95
|
+
Object.defineProperty(exports, "computeVaultV1Reallocations", { enumerable: true, get: function () { return computeVaultV1Reallocations_js_1.computeVaultV1Reallocations; } });
|
|
58
96
|
var metadata_js_1 = require("./helpers/metadata.js");
|
|
59
97
|
Object.defineProperty(exports, "addTransactionMetadata", { enumerable: true, get: function () { return metadata_js_1.addTransactionMetadata; } });
|
|
98
|
+
var previewVaultV2InKindRedeem_js_1 = require("./helpers/previewVaultV2InKindRedeem.js");
|
|
99
|
+
Object.defineProperty(exports, "previewVaultV2InKindRedeem", { enumerable: true, get: function () { return previewVaultV2InKindRedeem_js_1.previewVaultV2InKindRedeem; } });
|
|
60
100
|
var slippage_js_1 = require("./helpers/slippage.js");
|
|
61
101
|
Object.defineProperty(exports, "computeMaxRepaySharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMaxRepaySharePrice; } });
|
|
62
102
|
Object.defineProperty(exports, "computeMinBorrowSharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMinBorrowSharePrice; } });
|
package/lib/esm/abis.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
export { marketParamsAbi
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { marketParamsAbi as blueMarketParamsAbi,
|
|
2
|
+
/** @deprecated Use `blueMarketParamsAbi` or the raw `/blue/abis` subpath. */
|
|
3
|
+
marketParamsAbi, } from "@morpho-org/blue-sdk";
|
|
4
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi,
|
|
5
|
+
/** @deprecated Use `blueAdaptiveCurveIrmAbi` or the raw `/blue/abis` subpath. */
|
|
6
|
+
adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi as bluePreLiquidationAbi,
|
|
7
|
+
/** @deprecated Use `bluePreLiquidationAbi` or the raw `/blue/abis` subpath. */
|
|
8
|
+
preLiquidationAbi, preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi,
|
|
9
|
+
/** @deprecated Use `bluePreLiquidationFactoryAbi` or the raw `/blue/abis` subpath. */
|
|
10
|
+
preLiquidationFactoryAbi, publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi, vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
11
|
+
export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi,
|
|
12
|
+
/** @deprecated Use `midnightEcrecoverRatifierAbi` or the raw `/midnight/abis` subpath. */
|
|
13
|
+
ecrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi as midnightSetterRatifierAbi,
|
|
14
|
+
/** @deprecated Use `midnightSetterRatifierAbi` or the raw `/midnight/abis` subpath. */
|
|
15
|
+
setterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
4
16
|
/** ABI for the VaultExitBundlesV1 periphery contract. */
|
|
5
17
|
export declare const vaultExitBundlesV1Abi: readonly [{
|
|
6
18
|
readonly type: "constructor";
|
package/lib/esm/abis.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
export { marketParamsAbi
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { marketParamsAbi as blueMarketParamsAbi,
|
|
2
|
+
/** @deprecated Use `blueMarketParamsAbi` or the raw `/blue/abis` subpath. */
|
|
3
|
+
marketParamsAbi, } from "@morpho-org/blue-sdk";
|
|
4
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi,
|
|
5
|
+
/** @deprecated Use `blueAdaptiveCurveIrmAbi` or the raw `/blue/abis` subpath. */
|
|
6
|
+
adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi as bluePreLiquidationAbi,
|
|
7
|
+
/** @deprecated Use `bluePreLiquidationAbi` or the raw `/blue/abis` subpath. */
|
|
8
|
+
preLiquidationAbi, preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi,
|
|
9
|
+
/** @deprecated Use `bluePreLiquidationFactoryAbi` or the raw `/blue/abis` subpath. */
|
|
10
|
+
preLiquidationFactoryAbi, publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi, vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
11
|
+
export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi,
|
|
12
|
+
/** @deprecated Use `midnightEcrecoverRatifierAbi` or the raw `/midnight/abis` subpath. */
|
|
13
|
+
ecrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi as midnightSetterRatifierAbi,
|
|
14
|
+
/** @deprecated Use `midnightSetterRatifierAbi` or the raw `/midnight/abis` subpath. */
|
|
15
|
+
setterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
4
16
|
/** ABI for the VaultExitBundlesV1 periphery contract. */
|
|
5
17
|
export const vaultExitBundlesV1Abi = [
|
|
6
18
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
|
-
import { type AuthorizationRequirementSignature, type BlueBorrowAction, type
|
|
3
|
+
import { type AuthorizationRequirementSignature, type BlueBorrowAction, type BlueReallocationPlan, type Metadata, type Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueBorrow}. */
|
|
5
5
|
export interface BlueBorrowParams {
|
|
6
6
|
market: {
|
|
@@ -14,8 +14,8 @@ export interface BlueBorrowParams {
|
|
|
14
14
|
receiver: Address;
|
|
15
15
|
/** Minimum borrow share price (in ray). Protects against share price manipulation. */
|
|
16
16
|
minSharePrice: bigint;
|
|
17
|
-
/** Vault reallocations to execute before borrowing
|
|
18
|
-
reallocations?:
|
|
17
|
+
/** Homogeneous Vault V1 or Vault V2 reallocations to execute before borrowing. */
|
|
18
|
+
reallocations?: BlueReallocationPlan;
|
|
19
19
|
/**
|
|
20
20
|
* Optional signed Morpho authorization. When provided, a `setAuthorizationWithSig` call is
|
|
21
21
|
* prepended to the bundle so GeneralAdapter1 is authorized in-bundle instead of via a
|
|
@@ -32,17 +32,18 @@ export interface BlueBorrowParams {
|
|
|
32
32
|
* `onBehalf`. Uses `minSharePrice` to protect against share price manipulation between
|
|
33
33
|
* transaction construction and execution.
|
|
34
34
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* accumulate in `tx.value
|
|
35
|
+
* A `reallocations` plan contains either PublicAllocator V1 entries or Vault V2
|
|
36
|
+
* BluePublicAllocator entries, never both. The calls run before the borrow.
|
|
37
|
+
* V1 fees accumulate in `tx.value`; V2 penalties are paid in the target loan
|
|
38
|
+
* token and donated directly to each vault.
|
|
38
39
|
*
|
|
39
40
|
* @param params.market.chainId - The chain the market lives on.
|
|
40
41
|
* @param params.market.marketParams - Market params (loanToken, collateralToken, oracle, irm, lltv).
|
|
41
42
|
* @param params.args.amount - Loan asset amount to borrow, in the loan token's smallest unit.
|
|
42
43
|
* @param params.args.receiver - Address that receives the borrowed assets.
|
|
43
44
|
* @param params.args.minSharePrice - Minimum borrow share price (in ray). Slippage protection.
|
|
44
|
-
* @param params.args.reallocations - Optional
|
|
45
|
-
*
|
|
45
|
+
* @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
|
|
46
|
+
* execute before borrowing.
|
|
46
47
|
* @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
|
|
47
48
|
* a `setAuthorizationWithSig` call is prepended to the bundle.
|
|
48
49
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
@@ -50,13 +51,18 @@ export interface BlueBorrowParams {
|
|
|
50
51
|
* typed `action` discriminator the simulation layer consumes.
|
|
51
52
|
* @throws {NonPositiveInputError} when `amount <= 0n` or any reallocation withdrawal amount
|
|
52
53
|
* is non-positive.
|
|
53
|
-
* @throws {
|
|
54
|
-
* @throws {
|
|
55
|
-
*
|
|
56
|
-
* @throws {
|
|
57
|
-
*
|
|
58
|
-
* @throws {
|
|
59
|
-
*
|
|
54
|
+
* @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
|
|
55
|
+
* @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
|
|
56
|
+
* @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
|
|
57
|
+
* @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
|
|
58
|
+
* @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
|
|
59
|
+
* @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
|
|
60
|
+
* @throws {NegativeInputError} when `minSharePrice < 0n`, a V1 fee, or a V2 penalty is negative.
|
|
61
|
+
* @throws {EmptyReallocationWithdrawalsError} when any `reallocation.withdrawals` is empty.
|
|
62
|
+
* @throws {ReallocationWithdrawalOnTargetMarketError} when any reallocation withdrawal references
|
|
63
|
+
* the target market.
|
|
64
|
+
* @throws {UnsortedReallocationWithdrawalsError} when reallocation withdrawals are not strictly
|
|
65
|
+
* sorted by market id.
|
|
60
66
|
* @example
|
|
61
67
|
* ```ts
|
|
62
68
|
* import { blueBorrow } from "@morpho-org/morpho-sdk";
|
|
@@ -3,7 +3,7 @@ import { BundlerAction } from "../../bundler/index.js";
|
|
|
3
3
|
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
4
4
|
import { NegativeInputError, NonPositiveInputError, } from "../../types/index.js";
|
|
5
5
|
import { getBlueAuthorizationAction } from "../signatures/getBlueAuthorizationAction.js";
|
|
6
|
-
import {
|
|
6
|
+
import { buildBlueReallocationActions } from "./buildReallocationActions.js";
|
|
7
7
|
/**
|
|
8
8
|
* Prepares a borrow transaction for a Morpho Blue market.
|
|
9
9
|
*
|
|
@@ -11,17 +11,18 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
11
11
|
* `onBehalf`. Uses `minSharePrice` to protect against share price manipulation between
|
|
12
12
|
* transaction construction and execution.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* accumulate in `tx.value
|
|
14
|
+
* A `reallocations` plan contains either PublicAllocator V1 entries or Vault V2
|
|
15
|
+
* BluePublicAllocator entries, never both. The calls run before the borrow.
|
|
16
|
+
* V1 fees accumulate in `tx.value`; V2 penalties are paid in the target loan
|
|
17
|
+
* token and donated directly to each vault.
|
|
17
18
|
*
|
|
18
19
|
* @param params.market.chainId - The chain the market lives on.
|
|
19
20
|
* @param params.market.marketParams - Market params (loanToken, collateralToken, oracle, irm, lltv).
|
|
20
21
|
* @param params.args.amount - Loan asset amount to borrow, in the loan token's smallest unit.
|
|
21
22
|
* @param params.args.receiver - Address that receives the borrowed assets.
|
|
22
23
|
* @param params.args.minSharePrice - Minimum borrow share price (in ray). Slippage protection.
|
|
23
|
-
* @param params.args.reallocations - Optional
|
|
24
|
-
*
|
|
24
|
+
* @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
|
|
25
|
+
* execute before borrowing.
|
|
25
26
|
* @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
|
|
26
27
|
* a `setAuthorizationWithSig` call is prepended to the bundle.
|
|
27
28
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
@@ -29,13 +30,18 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
29
30
|
* typed `action` discriminator the simulation layer consumes.
|
|
30
31
|
* @throws {NonPositiveInputError} when `amount <= 0n` or any reallocation withdrawal amount
|
|
31
32
|
* is non-positive.
|
|
32
|
-
* @throws {
|
|
33
|
-
* @throws {
|
|
34
|
-
*
|
|
35
|
-
* @throws {
|
|
36
|
-
*
|
|
37
|
-
* @throws {
|
|
38
|
-
*
|
|
33
|
+
* @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
|
|
34
|
+
* @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
|
|
35
|
+
* @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
|
|
36
|
+
* @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
|
|
37
|
+
* @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
|
|
38
|
+
* @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
|
|
39
|
+
* @throws {NegativeInputError} when `minSharePrice < 0n`, a V1 fee, or a V2 penalty is negative.
|
|
40
|
+
* @throws {EmptyReallocationWithdrawalsError} when any `reallocation.withdrawals` is empty.
|
|
41
|
+
* @throws {ReallocationWithdrawalOnTargetMarketError} when any reallocation withdrawal references
|
|
42
|
+
* the target market.
|
|
43
|
+
* @throws {UnsortedReallocationWithdrawalsError} when reallocation withdrawals are not strictly
|
|
44
|
+
* sorted by market id.
|
|
39
45
|
* @example
|
|
40
46
|
* ```ts
|
|
41
47
|
* import { blueBorrow } from "@morpho-org/morpho-sdk";
|
|
@@ -59,15 +65,15 @@ export const blueBorrow = ({ market: { chainId, marketParams }, args: { amount,
|
|
|
59
65
|
throw new NegativeInputError("minSharePrice", minSharePrice);
|
|
60
66
|
}
|
|
61
67
|
const actions = [];
|
|
62
|
-
let reallocationFee = 0n;
|
|
63
68
|
if (authorizationSignature) {
|
|
64
69
|
actions.push(getBlueAuthorizationAction(chainId, authorizationSignature));
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
+
const { actions: reallocationActions, fee: reallocationFee, penaltyAssets: reallocationPenaltyAssets, } = buildBlueReallocationActions({
|
|
72
|
+
chainId,
|
|
73
|
+
reallocations,
|
|
74
|
+
targetMarketParams: marketParams,
|
|
75
|
+
});
|
|
76
|
+
actions.push(...reallocationActions);
|
|
71
77
|
actions.push({
|
|
72
78
|
type: "morphoBorrow",
|
|
73
79
|
args: [marketParams, amount, 0n, minSharePrice, receiver, false],
|
|
@@ -86,6 +92,7 @@ export const blueBorrow = ({ market: { chainId, marketParams }, args: { amount,
|
|
|
86
92
|
receiver,
|
|
87
93
|
minSharePrice,
|
|
88
94
|
reallocationFee,
|
|
95
|
+
reallocationPenaltyAssets,
|
|
89
96
|
},
|
|
90
97
|
},
|
|
91
98
|
});
|
|
@@ -20,7 +20,7 @@ export interface BuildAssetFundingActionsParams {
|
|
|
20
20
|
* `blueSupplyCollateral`, `blueSupplyCollateralBorrow`, `blueRepay`, `blueRepayWithdrawCollateral`).
|
|
21
21
|
*
|
|
22
22
|
* Encode-only and synchronous: returns a fresh `Action[]` (never mutates its inputs, mirroring
|
|
23
|
-
* `
|
|
23
|
+
* `buildVaultV2BlueReallocationActions`) and reads no on-chain state. When `nativeAmount > 0n`, validates
|
|
24
24
|
* `asset` is the chain's wNative and emits `nativeTransfer → wrapNative`. When `erc20Amount > 0n`,
|
|
25
25
|
* pulls the ERC-20 via a signed permit/permit2 (`requirementSignature`) or a plain
|
|
26
26
|
* `erc20TransferFrom` — `getTokenRequirementActions` emits the latter itself when no signature is
|
|
@@ -7,7 +7,7 @@ import { getTokenRequirementActions } from "../signatures/getTokenRequirementAct
|
|
|
7
7
|
* `blueSupplyCollateral`, `blueSupplyCollateralBorrow`, `blueRepay`, `blueRepayWithdrawCollateral`).
|
|
8
8
|
*
|
|
9
9
|
* Encode-only and synchronous: returns a fresh `Action[]` (never mutates its inputs, mirroring
|
|
10
|
-
* `
|
|
10
|
+
* `buildVaultV2BlueReallocationActions`) and reads no on-chain state. When `nativeAmount > 0n`, validates
|
|
11
11
|
* `asset` is the chain's wNative and emits `nativeTransfer → wrapNative`. When `erc20Amount > 0n`,
|
|
12
12
|
* pulls the ERC-20 via a signed permit/permit2 (`requirementSignature`) or a plain
|
|
13
13
|
* `erc20TransferFrom` — `getTokenRequirementActions` emits the latter itself when no signature is
|
|
@@ -1,26 +1,69 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Action } from "../../bundler/index.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlueReallocationPlan, VaultV1Reallocation, VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
4
|
/**
|
|
5
|
-
* Builds reallocation
|
|
5
|
+
* Builds PublicAllocator V1 reallocation actions for a Morpho Blue target market.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* market. Returns `{ actions: [], fee: 0n }` for an empty input — callers gate on
|
|
9
|
-
* `reallocations.length > 0` and skip the call entirely in that case. Internal helper —
|
|
10
|
-
* consumed by the Blue actions that accept reallocations; not re-exported on the public surface.
|
|
7
|
+
* Preserves the supplied reallocation order and aggregates each allocator call's native fee.
|
|
11
8
|
*
|
|
12
|
-
* @param reallocations -
|
|
13
|
-
* @param targetMarketParams -
|
|
14
|
-
* @returns The
|
|
15
|
-
* @throws {NegativeInputError} when any reallocation fee is negative.
|
|
16
|
-
* @throws {EmptyReallocationWithdrawalsError} when any reallocation has no withdrawals.
|
|
17
|
-
* @throws {NonPositiveInputError} when any withdrawal amount is non-positive.
|
|
18
|
-
* @throws {ReallocationWithdrawalOnTargetMarketError} when a withdrawal references the target market.
|
|
19
|
-
* @throws {UnsortedReallocationWithdrawalsError} when withdrawals within a reallocation are not
|
|
20
|
-
* strictly sorted by market id.
|
|
9
|
+
* @param params.reallocations - Validated Vault V1 reallocations to execute.
|
|
10
|
+
* @param params.targetMarketParams - Morpho Blue market receiving the reallocated liquidity.
|
|
11
|
+
* @returns The reallocation actions and aggregate native fee, with zero V2 penalty assets.
|
|
21
12
|
* @internal
|
|
22
13
|
*/
|
|
23
|
-
export declare const
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
14
|
+
export declare const buildVaultV1ReallocationActions: ({ reallocations, targetMarketParams, }: {
|
|
15
|
+
readonly reallocations: readonly VaultV1Reallocation[];
|
|
16
|
+
readonly targetMarketParams: MarketParams;
|
|
17
|
+
}) => {
|
|
18
|
+
actions: Action[];
|
|
19
|
+
fee: bigint;
|
|
20
|
+
penaltyAssets: bigint;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Builds BluePublicAllocator reallocation actions for a Morpho Blue target market.
|
|
24
|
+
*
|
|
25
|
+
* Prepends one aggregate loan-token funding action when penalties are non-zero, then builds one
|
|
26
|
+
* allocator action per validated Vault V2 reallocation.
|
|
27
|
+
*
|
|
28
|
+
* @param params.chainId - Chain whose registered Bundler3 and allocator addresses are used.
|
|
29
|
+
* @param params.reallocations - Validated Vault V2 Blue reallocations to execute.
|
|
30
|
+
* @param params.targetMarketParams - Morpho Blue market receiving the reallocated liquidity.
|
|
31
|
+
* @param params.penaltyFundingSource - Optional source of penalty assets. Defaults to the
|
|
32
|
+
* transaction initiator.
|
|
33
|
+
* @returns The funding and reallocation actions and aggregate penalty assets, with zero native fee.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare const buildVaultV2BlueReallocationActions: ({ chainId, reallocations, targetMarketParams, penaltyFundingSource, }: {
|
|
37
|
+
readonly chainId: number;
|
|
38
|
+
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
39
|
+
readonly targetMarketParams: MarketParams;
|
|
40
|
+
readonly penaltyFundingSource?: "initiator" | "generalAdapter1";
|
|
41
|
+
}) => {
|
|
42
|
+
actions: Action[];
|
|
43
|
+
fee: bigint;
|
|
44
|
+
penaltyAssets: bigint;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Validates a homogeneous Blue reallocation plan and builds its Bundler actions.
|
|
48
|
+
*
|
|
49
|
+
* Dispatches Vault V1 and Vault V2 plans to their version-specific builders. V1 plans aggregate
|
|
50
|
+
* native fees, while V2 plans aggregate loan-token penalties using the selected funding source.
|
|
51
|
+
*
|
|
52
|
+
* @param params.chainId - Chain whose registered Bundler3 and allocator addresses are used.
|
|
53
|
+
* @param params.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocation plan.
|
|
54
|
+
* @param params.targetMarketParams - Morpho Blue market receiving the reallocated liquidity.
|
|
55
|
+
* @param params.penaltyFundingSource - Optional source of V2 penalty assets. Defaults to the
|
|
56
|
+
* transaction initiator.
|
|
57
|
+
* @returns The reallocation actions, aggregate V1 native fee, and aggregate V2 penalty assets.
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export declare const buildBlueReallocationActions: ({ chainId, reallocations, targetMarketParams, penaltyFundingSource, }: {
|
|
61
|
+
readonly chainId: number;
|
|
62
|
+
readonly reallocations: BlueReallocationPlan | undefined;
|
|
63
|
+
readonly targetMarketParams: MarketParams;
|
|
64
|
+
readonly penaltyFundingSource?: "initiator" | "generalAdapter1";
|
|
65
|
+
}) => {
|
|
66
|
+
actions: Action[];
|
|
67
|
+
fee: bigint;
|
|
68
|
+
penaltyAssets: bigint;
|
|
26
69
|
};
|