@morpho-org/morpho-sdk 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +3 -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/requirements/getRequirementsApproval.js +2 -1
- package/lib/cjs/bundler/actions.d.ts +117 -0
- package/lib/cjs/bundler/actions.js +211 -4
- package/lib/cjs/bundler/types.d.ts +20 -0
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +3 -1
- package/lib/cjs/entities/blue/blue.d.ts +360 -71
- package/lib/cjs/entities/blue/blue.js +285 -52
- package/lib/cjs/entities/index.d.ts +2 -1
- package/lib/cjs/entities/index.js +6 -3
- 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 +1311 -0
- 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 +30 -14
- package/lib/cjs/helpers/validate.js +140 -27
- 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/utils.d.ts +2 -2
- package/lib/cjs/utils.js +6 -4
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- 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/requirements/getRequirementsApproval.js +2 -1
- package/lib/esm/bundler/actions.d.ts +117 -0
- package/lib/esm/bundler/actions.js +214 -7
- package/lib/esm/bundler/types.d.ts +20 -0
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +360 -71
- package/lib/esm/entities/blue/blue.js +288 -55
- package/lib/esm/entities/index.d.ts +2 -1
- package/lib/esm/entities/index.js +2 -1
- 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 +1307 -0
- 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 +30 -14
- package/lib/esm/helpers/validate.js +141 -30
- 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/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +5 -5
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import { AccrualPosition, type Market, type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
3
|
import type { FetchParameters } from "../../types/data.js";
|
|
4
|
-
import { type AssetsOrSharesArgs, type BlueAuthorizationAction, type BlueBorrowAction, type BlueRefinanceAction, type BlueRepayAction, type BlueRepayWithdrawCollateralAction, type BlueSupplyAction, type BlueSupplyCollateralAction, type BlueSupplyCollateralBorrowAction, type BlueWithdrawAction, type BlueWithdrawCollateralAction, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type PermitRequirementSignature, type ReallocationComputeOptions, type RepayAmountArgs, type Requirement, type RequirementSignature, type Transaction, type
|
|
5
|
-
import {
|
|
4
|
+
import { type AssetsOrSharesArgs, type BlueAuthorizationAction, type BlueBorrowAction, type BlueReallocationPlan, type BlueRefinanceAction, type BlueRepayAction, type BlueRepayWithdrawCollateralAction, type BlueSupplyAction, type BlueSupplyCollateralAction, type BlueSupplyCollateralBorrowAction, type BlueWithdrawAction, type BlueWithdrawCollateralAction, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type PermitRequirementSignature, type ReallocationComputeOptions, type RepayAmountArgs, type Requirement, type RequirementSignature, type Transaction, type VaultV1Reallocation, type VaultV2BluePublicAllocatorOptions, type VaultV2BlueReallocation } from "../../types/index.js";
|
|
5
|
+
import { VaultV1ReallocationData } from "../vaultV1ReallocationData.js";
|
|
6
|
+
import { VaultV2BlueReallocationData } from "../vaultV2BlueReallocationData.js";
|
|
7
|
+
type VaultV1ReallocationsParams = {
|
|
8
|
+
readonly reallocationData: VaultV1ReallocationData;
|
|
9
|
+
readonly options?: ReallocationComputeOptions;
|
|
10
|
+
} & ({
|
|
11
|
+
readonly operation: "borrow" | "withdraw";
|
|
12
|
+
readonly amount: bigint;
|
|
13
|
+
readonly borrowAmount?: never;
|
|
14
|
+
} | {
|
|
15
|
+
/** @deprecated Pass `{ operation: "borrow", amount }` instead. */
|
|
16
|
+
readonly borrowAmount: bigint;
|
|
17
|
+
readonly operation?: never;
|
|
18
|
+
readonly amount?: never;
|
|
19
|
+
});
|
|
20
|
+
type VaultV2BlueReallocationsParams = {
|
|
21
|
+
readonly reallocationData: VaultV2BlueReallocationData;
|
|
22
|
+
readonly options?: VaultV2BluePublicAllocatorOptions & {
|
|
23
|
+
readonly operation?: {
|
|
24
|
+
readonly type: "borrow" | "withdraw";
|
|
25
|
+
readonly amount: bigint;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
6
29
|
export interface BlueActions {
|
|
7
30
|
/**
|
|
8
31
|
* Fetches the latest market data with accrued interest.
|
|
@@ -80,28 +103,35 @@ export interface BlueActions {
|
|
|
80
103
|
*
|
|
81
104
|
* Computes `minSharePrice` from market supply state and `slippageTolerance`.
|
|
82
105
|
*
|
|
83
|
-
* When `reallocations` is provided,
|
|
84
|
-
*
|
|
85
|
-
*
|
|
106
|
+
* When `reallocations` is provided, its homogeneous V1 or V2 actions are
|
|
107
|
+
* prepended to move liquidity before withdrawing. V1 fees add
|
|
108
|
+
* to the transaction value; V2 penalties are paid in the loan token.
|
|
86
109
|
*
|
|
87
|
-
* `getRequirements` returns
|
|
88
|
-
*
|
|
89
|
-
*
|
|
110
|
+
* `getRequirements` returns the loan-token approval needed for V2 penalties
|
|
111
|
+
* and `morpho.setAuthorization(generalAdapter1, true)` when GA1 is not yet
|
|
112
|
+
* authorized on Morpho.
|
|
90
113
|
*
|
|
91
114
|
* **Stale `positionData` may cause unexpected supply share calculations.**
|
|
92
115
|
*
|
|
93
116
|
* @param params - Withdraw parameters including pre-fetched `positionData`.
|
|
94
117
|
* @returns Object with `buildTx` and `getRequirements`.
|
|
118
|
+
* @throws {BundlerErrors.UnexpectedAction} when a V2 plan is unsupported on the chain.
|
|
119
|
+
* @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
|
|
120
|
+
* @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
|
|
121
|
+
* @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
|
|
122
|
+
* @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
|
|
123
|
+
* @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
|
|
124
|
+
* @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
|
|
95
125
|
*/
|
|
96
126
|
withdraw: (params: {
|
|
97
127
|
userAddress: Address;
|
|
98
128
|
receiver?: Address;
|
|
99
129
|
positionData: AccrualPosition;
|
|
100
130
|
slippageTolerance?: bigint;
|
|
101
|
-
reallocations?:
|
|
131
|
+
reallocations?: BlueReallocationPlan;
|
|
102
132
|
} & AssetsOrSharesArgs) => {
|
|
103
133
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueWithdrawAction>>;
|
|
104
|
-
getRequirements: () => Promise<(Readonly<Transaction<BlueAuthorizationAction>> | Requirement)[]>;
|
|
134
|
+
getRequirements: () => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<BlueAuthorizationAction>> | Requirement)[]>;
|
|
105
135
|
};
|
|
106
136
|
/**
|
|
107
137
|
* Prepares a borrow transaction.
|
|
@@ -110,26 +140,34 @@ export interface BlueActions {
|
|
|
110
140
|
* Validates position health with LLTV buffer (0.5%) using the pre-fetched `positionData`.
|
|
111
141
|
* Computes `minSharePrice` from market borrow state and `slippageTolerance`.
|
|
112
142
|
*
|
|
113
|
-
* When `reallocations` is provided,
|
|
114
|
-
*
|
|
143
|
+
* When `reallocations` is provided, its homogeneous V1 or V2 actions are
|
|
144
|
+
* prepended before borrowing. V1 fees add to the transaction
|
|
145
|
+
* value; V2 penalties are paid in the loan token.
|
|
115
146
|
*
|
|
116
|
-
* `getRequirements` returns
|
|
117
|
-
*
|
|
147
|
+
* `getRequirements` returns the loan-token approval needed for V2 penalties
|
|
148
|
+
* and Morpho authorization for GeneralAdapter1 when needed.
|
|
118
149
|
*
|
|
119
150
|
* **Stale `positionData` may cause unexpected health.**
|
|
120
151
|
*
|
|
121
152
|
* @param params - Borrow parameters including pre-fetched `positionData` for health validation.
|
|
122
153
|
* @returns Object with `buildTx` and `getRequirements`.
|
|
154
|
+
* @throws {BundlerErrors.UnexpectedAction} when a V2 plan is unsupported on the chain.
|
|
155
|
+
* @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
|
|
156
|
+
* @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
|
|
157
|
+
* @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
|
|
158
|
+
* @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
|
|
159
|
+
* @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
|
|
160
|
+
* @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
|
|
123
161
|
*/
|
|
124
162
|
borrow: (params: {
|
|
125
163
|
userAddress: Address;
|
|
126
164
|
amount: bigint;
|
|
127
165
|
positionData: AccrualPosition;
|
|
128
166
|
slippageTolerance?: bigint;
|
|
129
|
-
reallocations?:
|
|
167
|
+
reallocations?: BlueReallocationPlan;
|
|
130
168
|
}) => {
|
|
131
169
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueBorrowAction>>;
|
|
132
|
-
getRequirements: () => Promise<(Readonly<Transaction<BlueAuthorizationAction>> | Requirement)[]>;
|
|
170
|
+
getRequirements: () => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<BlueAuthorizationAction>> | Requirement)[]>;
|
|
133
171
|
};
|
|
134
172
|
/**
|
|
135
173
|
* Prepares a repay transaction.
|
|
@@ -224,24 +262,33 @@ export interface BlueActions {
|
|
|
224
262
|
* Routed through the bundler. Validates position health with LLTV buffer
|
|
225
263
|
* to prevent instant liquidation on new positions near the LLTV threshold.
|
|
226
264
|
*
|
|
227
|
-
* When `reallocations` is provided,
|
|
228
|
-
* `morphoBorrow
|
|
265
|
+
* When `reallocations` is provided, its homogeneous V1 or V2 actions run
|
|
266
|
+
* between the collateral supply and `morphoBorrow`. V1 fees add
|
|
267
|
+
* to the transaction value; V2 penalties are paid in the loan token.
|
|
229
268
|
*
|
|
230
269
|
* `getRequirements` returns in parallel:
|
|
231
270
|
* - ERC20 approval or permit for collateral token (to GeneralAdapter1).
|
|
271
|
+
* - Classic ERC20 approval for any V2 loan-token penalties.
|
|
232
272
|
* - `morpho.setAuthorization(generalAdapter1, true)` if adapter is not yet authorized.
|
|
233
273
|
*
|
|
234
274
|
* **Stale `positionData` may cause unexpected health.**
|
|
235
275
|
*
|
|
236
276
|
* @param params - Combined parameters including pre-fetched `positionData` for health validation.
|
|
237
277
|
* @returns Object with `buildTx` and `getRequirements`.
|
|
278
|
+
* @throws {BundlerErrors.UnexpectedAction} when a V2 plan is unsupported on the chain.
|
|
279
|
+
* @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
|
|
280
|
+
* @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
|
|
281
|
+
* @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
|
|
282
|
+
* @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
|
|
283
|
+
* @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
|
|
284
|
+
* @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
|
|
238
285
|
*/
|
|
239
286
|
supplyCollateralBorrow: (params: {
|
|
240
287
|
userAddress: Address;
|
|
241
288
|
positionData: AccrualPosition;
|
|
242
289
|
borrowAmount: bigint;
|
|
243
290
|
slippageTolerance?: bigint;
|
|
244
|
-
reallocations?:
|
|
291
|
+
reallocations?: BlueReallocationPlan;
|
|
245
292
|
} & DepositAmountArgs) => {
|
|
246
293
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueSupplyCollateralBorrowAction>>;
|
|
247
294
|
getRequirements: (params?: {
|
|
@@ -261,9 +308,12 @@ export interface BlueActions {
|
|
|
261
308
|
* both the residual source and the aggregate target position stay within LLTV − buffer. Both
|
|
262
309
|
* markets are forward-accrued to `now`; in shares mode the target borrow is overshot by
|
|
263
310
|
* `slippageTolerance` and the callback sweeps the residual.
|
|
311
|
+
* A homogeneous V1 or V2 target reallocation plan runs first; V1 fees add
|
|
312
|
+
* to the transaction value and V2 penalties are paid
|
|
313
|
+
* in the loan token.
|
|
264
314
|
*
|
|
265
|
-
* `getRequirements` returns
|
|
266
|
-
*
|
|
315
|
+
* `getRequirements` returns the loan-token approval needed for V2 penalties
|
|
316
|
+
* and Morpho authorization for GeneralAdapter1 when needed.
|
|
267
317
|
*
|
|
268
318
|
* @param params.userAddress - Position owner on both markets.
|
|
269
319
|
* @param params.positionData - Pre-fetched source-market accrual position.
|
|
@@ -273,8 +323,15 @@ export interface BlueActions {
|
|
|
273
323
|
* @param params.borrowAssets - Loan assets to repay on source; exclusive with `borrowShares`.
|
|
274
324
|
* @param params.borrowShares - Borrow shares to repay on source; exclusive with `borrowAssets`.
|
|
275
325
|
* @param params.slippageTolerance - WAD slippage tolerance. Defaults to `DEFAULT_SLIPPAGE_TOLERANCE`.
|
|
276
|
-
* @param params.targetReallocations -
|
|
326
|
+
* @param params.targetReallocations - Homogeneous Vault V1 or Vault V2 reallocations into the target market.
|
|
277
327
|
* @returns Object with `buildTx` and `getRequirements`.
|
|
328
|
+
* @throws {BundlerErrors.UnexpectedAction} when a V2 plan is unsupported on the chain.
|
|
329
|
+
* @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
|
|
330
|
+
* @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
|
|
331
|
+
* @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
|
|
332
|
+
* @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
|
|
333
|
+
* @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
|
|
334
|
+
* @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
|
|
278
335
|
*/
|
|
279
336
|
refinance: (params: {
|
|
280
337
|
userAddress: Address;
|
|
@@ -287,13 +344,13 @@ export interface BlueActions {
|
|
|
287
344
|
borrowAssets?: bigint;
|
|
288
345
|
borrowShares?: bigint;
|
|
289
346
|
slippageTolerance?: bigint;
|
|
290
|
-
targetReallocations?:
|
|
347
|
+
targetReallocations?: BlueReallocationPlan;
|
|
291
348
|
}) => {
|
|
292
349
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueRefinanceAction>>;
|
|
293
|
-
getRequirements: () => Promise<(Readonly<Transaction<BlueAuthorizationAction>> | Requirement)[]>;
|
|
350
|
+
getRequirements: () => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<BlueAuthorizationAction>> | Requirement)[]>;
|
|
294
351
|
};
|
|
295
352
|
/**
|
|
296
|
-
* Fetches all on-chain data needed to construct a {@link
|
|
353
|
+
* Fetches all on-chain data needed to construct a {@link VaultV1ReallocationData}
|
|
297
354
|
* for computing vault reallocations via the public allocator.
|
|
298
355
|
*
|
|
299
356
|
* The target market is refetched internally at `block.number` so the
|
|
@@ -302,16 +359,33 @@ export interface BlueActions {
|
|
|
302
359
|
* inject unnecessary `reallocateTo` actions (and their PublicAllocator
|
|
303
360
|
* fees) into the resulting bundle.
|
|
304
361
|
*
|
|
305
|
-
* The returned reallocation data can be passed to {@link
|
|
306
|
-
* to compute the `
|
|
362
|
+
* The returned reallocation data can be passed to {@link getVaultV1Reallocations}
|
|
363
|
+
* to compute the `VaultV1Reallocation[]` array for `borrow()` or
|
|
307
364
|
* `supplyCollateralBorrow()`.
|
|
308
365
|
*
|
|
309
366
|
* **Stale data reverts on-chain (fail-safe).**
|
|
310
367
|
*
|
|
311
368
|
* @param params.vaultAddresses - Addresses of MetaMorpho vaults that allocate to this market.
|
|
312
369
|
* @param params.block - The block to fetch data at (number and timestamp).
|
|
313
|
-
* @returns A
|
|
370
|
+
* @returns A VaultV1ReallocationData instance populated with all required data.
|
|
371
|
+
* @throws {ChainIdMismatchError} when the client chain does not match this market.
|
|
372
|
+
*/
|
|
373
|
+
getVaultV1ReallocationData: (params: {
|
|
374
|
+
vaultAddresses: readonly Address[];
|
|
375
|
+
block: {
|
|
376
|
+
readonly number: bigint;
|
|
377
|
+
readonly timestamp: bigint;
|
|
378
|
+
};
|
|
379
|
+
}) => Promise<VaultV1ReallocationData>;
|
|
380
|
+
/**
|
|
381
|
+
* Fetches Vault V1 PublicAllocator state using the deprecated unversioned name.
|
|
382
|
+
*
|
|
383
|
+
* @param params.vaultAddresses - Addresses of MetaMorpho vaults that allocate to this market.
|
|
384
|
+
* @param params.block.number - Block number used for every RPC read.
|
|
385
|
+
* @param params.block.timestamp - Timestamp corresponding to the fetched block.
|
|
386
|
+
* @returns A `VaultV1ReallocationData` snapshot populated from one block.
|
|
314
387
|
* @throws {ChainIdMismatchError} when the client chain does not match this market.
|
|
388
|
+
* @deprecated Use {@link getVaultV1ReallocationData} instead.
|
|
315
389
|
*/
|
|
316
390
|
getReallocationData: (params: {
|
|
317
391
|
vaultAddresses: readonly Address[];
|
|
@@ -319,9 +393,34 @@ export interface BlueActions {
|
|
|
319
393
|
readonly number: bigint;
|
|
320
394
|
readonly timestamp: bigint;
|
|
321
395
|
};
|
|
322
|
-
}) => Promise<
|
|
396
|
+
}) => Promise<VaultV1ReallocationData>;
|
|
323
397
|
/**
|
|
324
|
-
*
|
|
398
|
+
* Fetches Vault V2 BluePublicAllocator state for this target market.
|
|
399
|
+
*
|
|
400
|
+
* Reads the target Morpho Blue market, each Vault V2 accrual tree, and each
|
|
401
|
+
* vault's BluePublicAllocator permissions and allocation caps at one block.
|
|
402
|
+
*
|
|
403
|
+
* @param params.vaultAddresses - Vault V2 addresses to inspect for market or idle liquidity.
|
|
404
|
+
* @param params.block.number - Block number used for every RPC read.
|
|
405
|
+
* @param params.block.timestamp - Timestamp corresponding to the fetched block.
|
|
406
|
+
* @returns A `VaultV2BlueReallocationData` snapshot ready for {@link getVaultV2BlueReallocations}.
|
|
407
|
+
* @throws {ChainIdMismatchError} when the client chain does not match this market.
|
|
408
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
409
|
+
* @throws {UnknownAddressError} when the chain has no BluePublicAllocator deployment.
|
|
410
|
+
* @throws {UnknownFactory} when the chain has no Vault V2 factory.
|
|
411
|
+
* @throws {UnknownOfFactory} when a requested address is not a Vault V2 from that factory.
|
|
412
|
+
* @throws {UnsupportedVaultV2AdapterError} when a vault contains an unsupported adapter.
|
|
413
|
+
* @throws {viem.BaseError} when an RPC or contract read fails with no fallback left.
|
|
414
|
+
*/
|
|
415
|
+
getVaultV2BlueReallocationData: (params: {
|
|
416
|
+
vaultAddresses: readonly Address[];
|
|
417
|
+
block: {
|
|
418
|
+
readonly number: bigint;
|
|
419
|
+
readonly timestamp: bigint;
|
|
420
|
+
};
|
|
421
|
+
}) => Promise<VaultV2BlueReallocationData>;
|
|
422
|
+
/**
|
|
423
|
+
* Computes Vault V1 PublicAllocator reallocations for this market.
|
|
325
424
|
*
|
|
326
425
|
* Uses the shared-liquidity algorithm to determine which vaults should reallocate liquidity to
|
|
327
426
|
* this market via the PublicAllocator, based on the post-operation utilization target.
|
|
@@ -329,7 +428,7 @@ export interface BlueActions {
|
|
|
329
428
|
* Pass `{ borrowAmount }` for a borrow (legacy alias, equivalent to `{ operation: "borrow",
|
|
330
429
|
* amount }`) or `{ operation: "withdraw", amount }` for a loan-asset withdraw.
|
|
331
430
|
*
|
|
332
|
-
* @param params.reallocationData - The current on-chain state (from {@link
|
|
431
|
+
* @param params.reallocationData - The current on-chain state (from {@link getVaultV1ReallocationData}).
|
|
333
432
|
* @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
|
|
334
433
|
* Defaults to `"borrow"` when `borrowAmount` is provided.
|
|
335
434
|
* @param params.amount - The borrow or withdraw amount used to compute the post-state utilization.
|
|
@@ -342,28 +441,82 @@ export interface BlueActions {
|
|
|
342
441
|
* or `withdraw()`. Empty array if no reallocation is needed.
|
|
343
442
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
|
|
344
443
|
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market — preventing fee-bearing reallocations from being attached to a call that would still revert onchain.
|
|
444
|
+
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds the target market supply.
|
|
345
445
|
* @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
|
|
346
446
|
* @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* const reallocations = market.getVaultV1Reallocations({
|
|
450
|
+
* reallocationData,
|
|
451
|
+
* operation: "borrow",
|
|
452
|
+
* amount: 1_000_000n,
|
|
453
|
+
* });
|
|
454
|
+
* ```
|
|
347
455
|
*/
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
456
|
+
getVaultV1Reallocations: (params: VaultV1ReallocationsParams) => readonly VaultV1Reallocation[];
|
|
457
|
+
/**
|
|
458
|
+
* Computes Vault V1 PublicAllocator reallocations using the deprecated unversioned name.
|
|
459
|
+
*
|
|
460
|
+
* @param params.reallocationData - State returned by {@link getVaultV1ReallocationData}.
|
|
461
|
+
* @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
|
|
462
|
+
* @param params.amount - The borrow or withdraw amount used to compute post-state utilization.
|
|
463
|
+
* @param params.borrowAmount - Deprecated borrow amount alias.
|
|
464
|
+
* @param params.options - Optional allocator and utilization options.
|
|
465
|
+
* @returns Vault V1 reallocations ready for a Blue action.
|
|
466
|
+
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
467
|
+
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
|
|
468
|
+
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
469
|
+
* @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
|
|
470
|
+
* @throws {UnknownReallocationMarketError} when the target market is absent.
|
|
471
|
+
* @deprecated Use {@link getVaultV1Reallocations} instead.
|
|
472
|
+
* @example
|
|
473
|
+
* ```ts
|
|
474
|
+
* const reallocations = market.getReallocations({
|
|
475
|
+
* reallocationData,
|
|
476
|
+
* operation: "borrow",
|
|
477
|
+
* amount: 1_000_000n,
|
|
478
|
+
* });
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
getReallocations: (params: VaultV1ReallocationsParams) => readonly VaultV1Reallocation[];
|
|
482
|
+
/**
|
|
483
|
+
* Computes Vault V2 BluePublicAllocator reallocations for this market.
|
|
484
|
+
*
|
|
485
|
+
* @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
|
|
486
|
+
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
487
|
+
* @returns Action-ready reallocations and their post-simulation state.
|
|
488
|
+
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
489
|
+
* @throws {NegativeInputError} when a utilization or penalty limit is negative.
|
|
490
|
+
* @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
|
|
491
|
+
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
492
|
+
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
493
|
+
* @throws {UnknownReallocationVaultError} when configured vault state is absent.
|
|
494
|
+
* @throws {UnknownReallocationPublicAllocatorConfigError} when allocator authorization state is absent.
|
|
495
|
+
* @throws {UnknownReallocationActiveAdaptersError} when active-adapter state is absent.
|
|
496
|
+
* @throws {UnknownReallocationMarketPublicAllocatorConfigError} when an adapter-market allocator configuration is absent.
|
|
497
|
+
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
498
|
+
* @throws {ReallocationAllocationUnderflowError} when an inconsistent allocation snapshot underflows during the final transition.
|
|
499
|
+
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the shortfall.
|
|
500
|
+
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
501
|
+
* @example
|
|
502
|
+
* ```ts
|
|
503
|
+
* const result = market.getVaultV2BlueReallocations({
|
|
504
|
+
* reallocationData,
|
|
505
|
+
* options: { operation: { type: "borrow", amount: 1_000_000n } },
|
|
506
|
+
* });
|
|
507
|
+
* ```
|
|
508
|
+
*/
|
|
509
|
+
getVaultV2BlueReallocations: (params: VaultV2BlueReallocationsParams) => {
|
|
510
|
+
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
511
|
+
readonly data: VaultV2BlueReallocationData;
|
|
512
|
+
};
|
|
361
513
|
}
|
|
362
514
|
export declare class MorphoBlue implements BlueActions {
|
|
363
515
|
private readonly client;
|
|
364
516
|
readonly marketParams: MarketParams;
|
|
365
517
|
private readonly chainId;
|
|
366
518
|
constructor(client: MorphoClientType, marketParams: MarketParams, chainId: number);
|
|
519
|
+
private getReallocationPenaltyRequirements;
|
|
367
520
|
getMarketData(parameters?: FetchParameters): Promise<Market>;
|
|
368
521
|
getPositionData(userAddress: Address, parameters?: FetchParameters): Promise<AccrualPosition>;
|
|
369
522
|
supply({ amount, userAddress, nativeAmount, marketData, slippageTolerance, }: {
|
|
@@ -381,9 +534,9 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
381
534
|
receiver?: Address;
|
|
382
535
|
positionData: AccrualPosition;
|
|
383
536
|
slippageTolerance?: bigint;
|
|
384
|
-
reallocations?:
|
|
537
|
+
reallocations?: BlueReallocationPlan;
|
|
385
538
|
} & AssetsOrSharesArgs): {
|
|
386
|
-
getRequirements: () => Promise<(Readonly<Transaction<BlueAuthorizationAction>> | Requirement<import("../../types/action.js").AuthorizationRequirementSignature, undefined>)[]>;
|
|
539
|
+
getRequirements: () => Promise<(import("../../types/action.js").Bundler3TokenSignatureRequirement | Readonly<Transaction<BlueAuthorizationAction>> | Readonly<Transaction<ERC20ApprovalAction>> | Requirement<import("../../types/action.js").AuthorizationRequirementSignature, undefined>)[]>;
|
|
387
540
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueWithdrawAction>>;
|
|
388
541
|
};
|
|
389
542
|
supplyCollateral({ amount, userAddress, nativeAmount, }: {
|
|
@@ -399,9 +552,9 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
399
552
|
userAddress: Address;
|
|
400
553
|
positionData: AccrualPosition;
|
|
401
554
|
slippageTolerance?: bigint;
|
|
402
|
-
reallocations?:
|
|
555
|
+
reallocations?: BlueReallocationPlan;
|
|
403
556
|
}): {
|
|
404
|
-
getRequirements: () => Promise<(Readonly<Transaction<BlueAuthorizationAction>> | Requirement<import("../../types/action.js").AuthorizationRequirementSignature, undefined>)[]>;
|
|
557
|
+
getRequirements: () => Promise<(import("../../types/action.js").Bundler3TokenSignatureRequirement | Readonly<Transaction<BlueAuthorizationAction>> | Readonly<Transaction<ERC20ApprovalAction>> | Requirement<import("../../types/action.js").AuthorizationRequirementSignature, undefined>)[]>;
|
|
405
558
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueBorrowAction>>;
|
|
406
559
|
};
|
|
407
560
|
repay(params: {
|
|
@@ -437,7 +590,7 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
437
590
|
positionData: AccrualPosition;
|
|
438
591
|
borrowAmount: bigint;
|
|
439
592
|
slippageTolerance?: bigint;
|
|
440
|
-
reallocations?:
|
|
593
|
+
reallocations?: BlueReallocationPlan;
|
|
441
594
|
} & DepositAmountArgs): {
|
|
442
595
|
getRequirements: (params?: {
|
|
443
596
|
useSimplePermit?: boolean;
|
|
@@ -455,35 +608,118 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
455
608
|
borrowAssets?: bigint;
|
|
456
609
|
borrowShares?: bigint;
|
|
457
610
|
slippageTolerance?: bigint;
|
|
458
|
-
targetReallocations?:
|
|
611
|
+
targetReallocations?: BlueReallocationPlan;
|
|
459
612
|
}): {
|
|
460
|
-
getRequirements: () => Promise<(Readonly<Transaction<BlueAuthorizationAction>> | Requirement<import("../../types/action.js").AuthorizationRequirementSignature, undefined>)[]>;
|
|
613
|
+
getRequirements: () => Promise<(import("../../types/action.js").Bundler3TokenSignatureRequirement | Readonly<Transaction<BlueAuthorizationAction>> | Readonly<Transaction<ERC20ApprovalAction>> | Requirement<import("../../types/action.js").AuthorizationRequirementSignature, undefined>)[]>;
|
|
461
614
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueRefinanceAction>>;
|
|
462
615
|
};
|
|
463
616
|
/**
|
|
464
617
|
* Fetches all on-chain inputs needed to compute public allocator reallocations.
|
|
465
618
|
*
|
|
466
|
-
* @param params - Reallocation data fetch parameters.
|
|
467
619
|
* @param params.vaultAddresses - Vaults to inspect for source-market liquidity.
|
|
468
|
-
* @param params.block - Block number
|
|
469
|
-
* @
|
|
620
|
+
* @param params.block.number - Block number used for every RPC read.
|
|
621
|
+
* @param params.block.timestamp - Timestamp corresponding to the fetched block.
|
|
622
|
+
* @returns Reallocation data ready for {@link getVaultV1Reallocations}.
|
|
623
|
+
* @throws {ChainIdMismatchError} when the client chain does not match this market.
|
|
624
|
+
* @example
|
|
625
|
+
* ```ts
|
|
626
|
+
* import { markets, vaults } from "@morpho-org/morpho-test";
|
|
627
|
+
* import { createPublicClient, http } from "viem";
|
|
628
|
+
* import { mainnet } from "viem/chains";
|
|
629
|
+
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
630
|
+
* import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
|
|
631
|
+
*
|
|
632
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
633
|
+
* .extend(morphoViemExtension());
|
|
634
|
+
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
635
|
+
* const block = await client.getBlock();
|
|
636
|
+
* const data: VaultV1ReallocationData = await market.getVaultV1ReallocationData({
|
|
637
|
+
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
638
|
+
* block,
|
|
639
|
+
* });
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
getVaultV1ReallocationData({ vaultAddresses, block, }: {
|
|
643
|
+
vaultAddresses: readonly Address[];
|
|
644
|
+
block: {
|
|
645
|
+
readonly number: bigint;
|
|
646
|
+
readonly timestamp: bigint;
|
|
647
|
+
};
|
|
648
|
+
}): Promise<VaultV1ReallocationData>;
|
|
649
|
+
/**
|
|
650
|
+
* Fetches Vault V1 PublicAllocator state using the deprecated unversioned name.
|
|
651
|
+
*
|
|
652
|
+
* @param params.vaultAddresses - Addresses of MetaMorpho vaults that allocate to this market.
|
|
653
|
+
* @param params.block.number - Block number used for every RPC read.
|
|
654
|
+
* @param params.block.timestamp - Timestamp corresponding to the fetched block.
|
|
655
|
+
* @returns A `VaultV1ReallocationData` snapshot populated from one block.
|
|
470
656
|
* @throws {ChainIdMismatchError} when the client chain does not match this market.
|
|
657
|
+
* @deprecated Use {@link getVaultV1ReallocationData} instead.
|
|
658
|
+
* @example
|
|
659
|
+
* ```ts
|
|
660
|
+
* const data = await market.getReallocationData({ vaultAddresses, block });
|
|
661
|
+
* // Equivalent to market.getVaultV1ReallocationData({ vaultAddresses, block }).
|
|
662
|
+
* ```
|
|
471
663
|
*/
|
|
472
|
-
getReallocationData(
|
|
664
|
+
getReallocationData(params: {
|
|
473
665
|
vaultAddresses: readonly Address[];
|
|
474
666
|
block: {
|
|
475
667
|
readonly number: bigint;
|
|
476
668
|
readonly timestamp: bigint;
|
|
477
669
|
};
|
|
478
|
-
}): Promise<
|
|
670
|
+
}): Promise<VaultV1ReallocationData>;
|
|
479
671
|
/**
|
|
480
|
-
*
|
|
672
|
+
* Fetches Vault V2 BluePublicAllocator state for this target market.
|
|
673
|
+
*
|
|
674
|
+
* Reads the target Morpho Blue market, each Vault V2 accrual tree, and each
|
|
675
|
+
* vault's BluePublicAllocator permissions and allocation caps at one block.
|
|
676
|
+
*
|
|
677
|
+
* @param params.vaultAddresses - Vault V2 addresses to inspect for market or idle liquidity.
|
|
678
|
+
* @param params.block.number - Block number used for every RPC read.
|
|
679
|
+
* @param params.block.timestamp - Timestamp corresponding to the fetched block.
|
|
680
|
+
* @returns A `VaultV2BlueReallocationData` snapshot ready for {@link getVaultV2BlueReallocations}.
|
|
681
|
+
* @throws {ChainIdMismatchError} when the client chain does not match this market.
|
|
682
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
683
|
+
* @throws {UnknownAddressError} when the chain has no BluePublicAllocator deployment.
|
|
684
|
+
* @throws {UnknownFactory} when the chain has no Vault V2 factory.
|
|
685
|
+
* @throws {UnknownOfFactory} when a requested address is not a Vault V2 from that factory.
|
|
686
|
+
* @throws {UnsupportedVaultV2AdapterError} when a vault contains an unsupported adapter.
|
|
687
|
+
* @throws {viem.BaseError} when an RPC or contract read fails with no fallback left.
|
|
688
|
+
* @example
|
|
689
|
+
* ```ts
|
|
690
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
691
|
+
* import { createPublicClient, http } from "viem";
|
|
692
|
+
* import { mainnet } from "viem/chains";
|
|
693
|
+
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
694
|
+
* import type { VaultV2BlueReallocationData } from "@morpho-org/morpho-sdk/entities";
|
|
695
|
+
*
|
|
696
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
697
|
+
* .extend(morphoViemExtension());
|
|
698
|
+
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
699
|
+
* const block = await client.getBlock();
|
|
700
|
+
* const keyrockUsdcVaultV2 = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
|
|
701
|
+
* const data: VaultV2BlueReallocationData =
|
|
702
|
+
* await market.getVaultV2BlueReallocationData({
|
|
703
|
+
* vaultAddresses: [keyrockUsdcVaultV2],
|
|
704
|
+
* block,
|
|
705
|
+
* });
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
getVaultV2BlueReallocationData({ vaultAddresses, block, }: {
|
|
709
|
+
vaultAddresses: readonly Address[];
|
|
710
|
+
block: {
|
|
711
|
+
readonly number: bigint;
|
|
712
|
+
readonly timestamp: bigint;
|
|
713
|
+
};
|
|
714
|
+
}): Promise<VaultV2BlueReallocationData>;
|
|
715
|
+
/**
|
|
716
|
+
* Computes Vault V1 PublicAllocator reallocations for this market.
|
|
481
717
|
*
|
|
482
718
|
* Pass `{ borrowAmount }` for a borrow (legacy alias, equivalent to `{ operation: "borrow", amount }`)
|
|
483
719
|
* or `{ operation, amount }` for a borrow or loan-asset withdraw.
|
|
484
720
|
*
|
|
485
721
|
* @param params - Reallocation computation parameters.
|
|
486
|
-
* @param params.reallocationData - State returned by {@link
|
|
722
|
+
* @param params.reallocationData - State returned by {@link getVaultV1ReallocationData}.
|
|
487
723
|
* @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
|
|
488
724
|
* @param params.amount - The borrow or withdraw amount used to compute the post-state utilization.
|
|
489
725
|
* @param params.borrowAmount - {@deprecated Pass `{ operation: "borrow", amount }` instead.}
|
|
@@ -494,18 +730,71 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
494
730
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
|
|
495
731
|
* @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
|
|
496
732
|
* @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
|
|
733
|
+
* @example
|
|
734
|
+
* ```ts
|
|
735
|
+
* const reallocations = market.getVaultV1Reallocations({
|
|
736
|
+
* reallocationData,
|
|
737
|
+
* operation: "borrow",
|
|
738
|
+
* amount: 1_000_000n,
|
|
739
|
+
* });
|
|
740
|
+
* ```
|
|
497
741
|
*/
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
742
|
+
getVaultV1Reallocations(params: VaultV1ReallocationsParams): readonly VaultV1Reallocation[];
|
|
743
|
+
/**
|
|
744
|
+
* Computes Vault V1 PublicAllocator reallocations using the deprecated unversioned name.
|
|
745
|
+
*
|
|
746
|
+
* @param params.reallocationData - State returned by {@link getVaultV1ReallocationData}.
|
|
747
|
+
* @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
|
|
748
|
+
* @param params.amount - The borrow or withdraw amount used to compute post-state utilization.
|
|
749
|
+
* @param params.borrowAmount - Deprecated borrow amount alias.
|
|
750
|
+
* @param params.options - Optional allocator and utilization options.
|
|
751
|
+
* @returns Vault V1 reallocations ready for a Blue action.
|
|
752
|
+
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
753
|
+
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
|
|
754
|
+
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
755
|
+
* @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
|
|
756
|
+
* @throws {UnknownReallocationMarketError} when the target market is absent.
|
|
757
|
+
* @deprecated Use {@link getVaultV1Reallocations} instead.
|
|
758
|
+
* @example
|
|
759
|
+
* ```ts
|
|
760
|
+
* const reallocations = market.getReallocations({
|
|
761
|
+
* reallocationData,
|
|
762
|
+
* operation: "borrow",
|
|
763
|
+
* amount: 1_000_000n,
|
|
764
|
+
* });
|
|
765
|
+
* ```
|
|
766
|
+
*/
|
|
767
|
+
getReallocations(params: VaultV1ReallocationsParams): readonly VaultV1Reallocation[];
|
|
768
|
+
/**
|
|
769
|
+
* Computes Vault V2 BluePublicAllocator reallocations for this market.
|
|
770
|
+
*
|
|
771
|
+
* @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
|
|
772
|
+
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
773
|
+
* @returns Action-ready reallocations and their post-simulation state.
|
|
774
|
+
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
775
|
+
* @throws {NegativeInputError} when a utilization or penalty limit is negative.
|
|
776
|
+
* @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
|
|
777
|
+
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
778
|
+
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
779
|
+
* @throws {UnknownReallocationVaultError} when configured vault state is absent.
|
|
780
|
+
* @throws {UnknownReallocationPublicAllocatorConfigError} when allocator authorization state is absent.
|
|
781
|
+
* @throws {UnknownReallocationActiveAdaptersError} when active-adapter state is absent.
|
|
782
|
+
* @throws {UnknownReallocationMarketPublicAllocatorConfigError} when an adapter-market allocator configuration is absent.
|
|
783
|
+
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
784
|
+
* @throws {ReallocationAllocationUnderflowError} when an inconsistent allocation snapshot underflows during the final transition.
|
|
785
|
+
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the shortfall.
|
|
786
|
+
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
787
|
+
* @example
|
|
788
|
+
* ```ts
|
|
789
|
+
* const result = market.getVaultV2BlueReallocations({
|
|
790
|
+
* reallocationData,
|
|
791
|
+
* options: { operation: { type: "borrow", amount: 1_000_000n } },
|
|
792
|
+
* });
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
getVaultV2BlueReallocations({ reallocationData, options, }: VaultV2BlueReallocationsParams): {
|
|
796
|
+
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
797
|
+
readonly data: VaultV2BlueReallocationData;
|
|
798
|
+
};
|
|
511
799
|
}
|
|
800
|
+
export {};
|