@morpho-org/morpho-sdk 5.4.1 → 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 +23 -7
- package/lib/cjs/abis.d.ts +314 -1
- package/lib/cjs/abis.js +169 -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/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +9 -2
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +131 -0
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -3
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +91 -0
- package/lib/cjs/actions/signatures/index.d.ts +1 -0
- package/lib/cjs/actions/signatures/index.js +1 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +54 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +96 -0
- package/lib/cjs/actions/vaultV1/index.d.ts +1 -0
- package/lib/cjs/actions/vaultV1/index.js +1 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +56 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +97 -0
- package/lib/cjs/actions/vaultV2/index.d.ts +1 -0
- package/lib/cjs/actions/vaultV2/index.js +1 -0
- package/lib/cjs/bundler/actions.d.ts +118 -2
- package/lib/cjs/bundler/actions.js +212 -6
- 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 +365 -76
- 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/vaultV1/vaultV1.d.ts +82 -4
- package/lib/cjs/entities/vaultV1/vaultV1.js +164 -0
- package/lib/cjs/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
- package/lib/cjs/entities/{reallocationData.js → vaultV1ReallocationData.js} +30 -18
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +89 -3
- package/lib/cjs/entities/vaultV2/vaultV2.js +181 -0
- 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 +3 -2
- package/lib/cjs/helpers/index.js +8 -3
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +73 -0
- package/lib/cjs/helpers/validate.d.ts +31 -15
- package/lib/cjs/helpers/validate.js +140 -27
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +2 -1
- package/lib/cjs/types/action.d.ts +33 -1
- package/lib/cjs/types/error.d.ts +363 -5
- package/lib/cjs/types/error.js +455 -6
- 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 +314 -1
- package/lib/esm/abis.js +167 -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/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -2
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +127 -0
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -3
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +87 -0
- package/lib/esm/actions/signatures/index.d.ts +1 -0
- package/lib/esm/actions/signatures/index.js +1 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +54 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.js +92 -0
- package/lib/esm/actions/vaultV1/index.d.ts +1 -0
- package/lib/esm/actions/vaultV1/index.js +1 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +56 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.js +93 -0
- package/lib/esm/actions/vaultV2/index.d.ts +1 -0
- package/lib/esm/actions/vaultV2/index.js +1 -0
- package/lib/esm/bundler/actions.d.ts +118 -2
- package/lib/esm/bundler/actions.js +215 -9
- 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 +362 -73
- 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/vaultV1/vaultV1.d.ts +80 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +170 -6
- package/lib/esm/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
- package/lib/esm/entities/{reallocationData.js → vaultV1ReallocationData.js} +33 -16
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +88 -2
- package/lib/esm/entities/vaultV2/vaultV2.js +187 -6
- 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 +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +70 -0
- package/lib/esm/helpers/validate.d.ts +31 -15
- package/lib/esm/helpers/validate.js +141 -30
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +2 -1
- package/lib/esm/types/action.d.ts +33 -1
- package/lib/esm/types/error.d.ts +363 -5
- package/lib/esm/types/error.js +428 -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 +9 -11
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type AccrualVault, type AccrualVaultV2 } from "@morpho-org/blue-sdk";
|
|
1
|
+
import { type AccrualVault, type AccrualVaultV2, type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { fetchAccrualVault } from "@morpho-org/blue-sdk-viem";
|
|
3
3
|
import { type Address } from "viem";
|
|
4
4
|
import type { FetchParameters } from "../../types/data.js";
|
|
5
|
-
import { type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type PermitRequirementSignature, type Requirement, type RequirementSignature, type Transaction, type VaultV1DepositAction, type VaultV1MigrateToV2Action, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
|
|
5
|
+
import { type ActionOutput, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type PermitRequirementSignature, type Requirement, type RequirementSignature, type Transaction, type VaultV1DepositAction, type VaultV1InKindRedeemAction, type VaultV1MigrateToV2Action, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
|
|
6
6
|
export interface VaultV1Actions {
|
|
7
7
|
/**
|
|
8
8
|
* Fetches the latest vault data with accrued interest.
|
|
@@ -63,6 +63,76 @@ export interface VaultV1Actions {
|
|
|
63
63
|
}) => {
|
|
64
64
|
buildTx: () => Readonly<Transaction<VaultV1RedeemAction>>;
|
|
65
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Prepares an illiquid Vault V1 exit into the vault's Morpho Blue supply positions.
|
|
68
|
+
*
|
|
69
|
+
* The caller controls market order and must call `getRequirements()` before `buildTx()` so the
|
|
70
|
+
* RPC-backed Blue-balance and Morpho-deployment checks run. The SDK validates market coverage but
|
|
71
|
+
* intentionally does not validate the user's share balance; size `amount` in asset terms against
|
|
72
|
+
* `previewRedeem(sharesHeld)`. The share allowance first accrues pending performance-fee shares,
|
|
73
|
+
* then uses the current rounded-up share preview; future interest can only reduce the required
|
|
74
|
+
* burn.
|
|
75
|
+
*
|
|
76
|
+
* Snapshot state can drift before inclusion, so a later reallocation may still make the on-chain
|
|
77
|
+
* loop under-cover even after pre-flight succeeds.
|
|
78
|
+
*
|
|
79
|
+
* @param params - In-kind redemption parameters.
|
|
80
|
+
* @param params.amount - Asset-denominated amount to exit.
|
|
81
|
+
* @param params.marketParamsList - Ordered vault markets consumed greedily by the contract;
|
|
82
|
+
* repeated entries cannot draw from the same vault position twice.
|
|
83
|
+
* @param params.vaultData - Pre-fetched Vault V1 accrual snapshot.
|
|
84
|
+
* @param params.userAddress - Account that signs and submits the exit.
|
|
85
|
+
* @param params.deadline - Optional shared permit/bundle deadline; defaults to two hours from now.
|
|
86
|
+
* @returns Lazy prerequisite resolution and a synchronous transaction builder.
|
|
87
|
+
* @throws {ChainIdMismatchError} when the client and entity target different chains.
|
|
88
|
+
* @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
|
|
89
|
+
* @throws {NonPositiveInputError} when `amount` is not positive.
|
|
90
|
+
* @throws {EmptyMarketParamsListError} when the market list is empty.
|
|
91
|
+
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
92
|
+
* requirement resolution.
|
|
93
|
+
* @throws {InKindRedeemCoverageError} when the ordered list cannot cover `amount` without
|
|
94
|
+
* assigning more than the vault owns in a repeated market.
|
|
95
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
96
|
+
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
97
|
+
* @throws {viem.BaseError} from `getRequirements()` when an RPC or multicall contract read fails.
|
|
98
|
+
* @throws {VaultMorphoMismatchError} from `getRequirements()` when the vault uses another Morpho deployment.
|
|
99
|
+
* @throws {VaultIsBlueFeeRecipientError} from `getRequirements()` when Morpho Blue accrues protocol fees to the vault.
|
|
100
|
+
* @throws {InsufficientBlueBalanceForInKindRedeemError} from `getRequirements()` when Blue cannot fund the flash loan.
|
|
101
|
+
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
|
|
102
|
+
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
|
|
103
|
+
* @throws {VaultExitBundlesV1PermitMismatchError} from `buildTx()` when the requirement has the wrong permit kind, asset, or signature encoding.
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* import { isRequirementSignature } from "@morpho-org/morpho-sdk";
|
|
107
|
+
*
|
|
108
|
+
* const vault = client.morpho.vaultV1(vaultAddress, 1);
|
|
109
|
+
* const vaultData = await vault.getData();
|
|
110
|
+
* const exit = vault.inKindRedeem({
|
|
111
|
+
* amount: 1_000_000n,
|
|
112
|
+
* marketParamsList,
|
|
113
|
+
* vaultData,
|
|
114
|
+
* userAddress,
|
|
115
|
+
* });
|
|
116
|
+
* const signatures = [];
|
|
117
|
+
* for (const requirement of await exit.getRequirements()) {
|
|
118
|
+
* if (isRequirementSignature(requirement)) {
|
|
119
|
+
* signatures.push(await requirement.sign(walletClient, userAddress));
|
|
120
|
+
* } else {
|
|
121
|
+
* const hash = await walletClient.sendTransaction(requirement);
|
|
122
|
+
* await client.waitForTransactionReceipt({ hash });
|
|
123
|
+
* }
|
|
124
|
+
* }
|
|
125
|
+
* const tx = exit.buildTx(signatures);
|
|
126
|
+
* // tx satisfies Readonly<Transaction<VaultV1InKindRedeemAction>>
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
readonly inKindRedeem: (params: {
|
|
130
|
+
readonly amount: bigint;
|
|
131
|
+
readonly marketParamsList: readonly MarketParams[];
|
|
132
|
+
readonly vaultData: AccrualVault;
|
|
133
|
+
readonly userAddress: Address;
|
|
134
|
+
readonly deadline?: bigint;
|
|
135
|
+
}) => ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
|
|
66
136
|
/**
|
|
67
137
|
* Prepares a full migration from VaultV1 to VaultV2.
|
|
68
138
|
*
|
|
@@ -101,7 +171,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
101
171
|
} & DepositAmountArgs): {
|
|
102
172
|
getRequirements: (params?: {
|
|
103
173
|
useSimplePermit?: boolean;
|
|
104
|
-
}) => Promise<(import("../../
|
|
174
|
+
}) => Promise<(import("../../index.js").Bundler3TokenSignatureRequirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
|
|
105
175
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<VaultV1DepositAction>>;
|
|
106
176
|
};
|
|
107
177
|
withdraw({ amount, userAddress }: {
|
|
@@ -116,6 +186,14 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
116
186
|
}): {
|
|
117
187
|
buildTx: () => Readonly<Transaction<VaultV1RedeemAction>>;
|
|
118
188
|
};
|
|
189
|
+
/** {@inheritDoc VaultV1Actions.inKindRedeem} */
|
|
190
|
+
inKindRedeem({ amount, marketParamsList, vaultData, userAddress, deadline: deadlineOverride, }: {
|
|
191
|
+
readonly amount: bigint;
|
|
192
|
+
readonly marketParamsList: readonly MarketParams[];
|
|
193
|
+
readonly vaultData: AccrualVault;
|
|
194
|
+
readonly userAddress: Address;
|
|
195
|
+
readonly deadline?: bigint;
|
|
196
|
+
}): ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
|
|
119
197
|
migrateToV2({ userAddress, sourceVault, targetVault, shares, slippageTolerance, }: {
|
|
120
198
|
userAddress: Address;
|
|
121
199
|
sourceVault: AccrualVault;
|
|
@@ -123,7 +201,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
123
201
|
shares: bigint;
|
|
124
202
|
slippageTolerance?: bigint;
|
|
125
203
|
}): {
|
|
126
|
-
getRequirements: () => Promise<(import("../../
|
|
204
|
+
getRequirements: () => Promise<(import("../../index.js").Bundler3TokenSignatureRequirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
|
|
127
205
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<VaultV1MigrateToV2Action>>;
|
|
128
206
|
};
|
|
129
207
|
}
|
|
@@ -5,6 +5,7 @@ const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
|
5
5
|
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
6
6
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
7
7
|
const viem_1 = require("viem");
|
|
8
|
+
const actions_1 = require("viem/actions");
|
|
8
9
|
const index_js_1 = require("../../actions/index.js");
|
|
9
10
|
const constant_js_1 = require("../../helpers/constant.js");
|
|
10
11
|
const index_js_2 = require("../../helpers/index.js");
|
|
@@ -131,6 +132,169 @@ class MorphoVaultV1 {
|
|
|
131
132
|
}),
|
|
132
133
|
};
|
|
133
134
|
}
|
|
135
|
+
/** {@inheritDoc VaultV1Actions.inKindRedeem} */
|
|
136
|
+
inKindRedeem({ amount, marketParamsList, vaultData, userAddress, deadline: deadlineOverride, }) {
|
|
137
|
+
if (this.client.viemClient.chain?.id !== this.chainId) {
|
|
138
|
+
throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
|
|
139
|
+
}
|
|
140
|
+
if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
|
|
141
|
+
throw new index_js_3.VaultAddressMismatchError(this.vault, vaultData.address);
|
|
142
|
+
}
|
|
143
|
+
if (amount <= 0n)
|
|
144
|
+
throw new index_js_3.NonPositiveInputError("amount", amount);
|
|
145
|
+
if (marketParamsList.length === 0)
|
|
146
|
+
throw new index_js_3.EmptyMarketParamsListError();
|
|
147
|
+
const marketParamsListSnapshot = marketParamsList.map(({ loanToken, collateralToken, oracle, irm, lltv }) => ({
|
|
148
|
+
loanToken,
|
|
149
|
+
collateralToken,
|
|
150
|
+
oracle,
|
|
151
|
+
irm,
|
|
152
|
+
lltv,
|
|
153
|
+
}));
|
|
154
|
+
const now = morpho_ts_1.Time.timestamp();
|
|
155
|
+
const deadline = deadlineOverride ?? now + morpho_ts_1.Time.s.from.h(2n);
|
|
156
|
+
if (deadline <= now)
|
|
157
|
+
throw new index_js_3.ExpiredDeadlineError(deadline, now);
|
|
158
|
+
const vaultExitBundlesV1 = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultExitBundlesV1");
|
|
159
|
+
const addresses = (0, blue_sdk_1.getChainAddresses)(this.chainId);
|
|
160
|
+
const blue = addresses.blue ?? addresses.morpho;
|
|
161
|
+
let covered = 0n;
|
|
162
|
+
const assignedByMarket = new Map();
|
|
163
|
+
for (const marketParams of marketParamsListSnapshot) {
|
|
164
|
+
if (covered === amount)
|
|
165
|
+
break;
|
|
166
|
+
const marketId = blue_sdk_1.MarketUtils.getMarketId(marketParams);
|
|
167
|
+
const allocation = vaultData.allocations.get(marketId);
|
|
168
|
+
if (allocation?.config.enabled !== true)
|
|
169
|
+
continue;
|
|
170
|
+
const market = allocation.position.market.accrueInterest(now);
|
|
171
|
+
const available = market.toSupplyAssets(allocation.position.supplyShares);
|
|
172
|
+
const assigned = assignedByMarket.get(marketId) ?? 0n;
|
|
173
|
+
const chunk = blue_sdk_1.MathLib.min(available, amount - covered);
|
|
174
|
+
if (assigned + chunk > available) {
|
|
175
|
+
throw new index_js_3.InKindRedeemCoverageError({
|
|
176
|
+
required: amount,
|
|
177
|
+
covered,
|
|
178
|
+
maxExitAssets: covered,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
assignedByMarket.set(marketId, assigned + chunk);
|
|
182
|
+
covered += chunk;
|
|
183
|
+
}
|
|
184
|
+
if (covered < amount) {
|
|
185
|
+
throw new index_js_3.InKindRedeemCoverageError({
|
|
186
|
+
required: amount,
|
|
187
|
+
covered,
|
|
188
|
+
maxExitAssets: covered,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// Account for pending performance-fee shares before previewing the burn. Once accrued, future
|
|
192
|
+
// V1 interest cannot lower the share price, so this upper-bounds execution.
|
|
193
|
+
const requiredShareAllowance = vaultData
|
|
194
|
+
.accrueInterest(now)
|
|
195
|
+
.toShares(amount);
|
|
196
|
+
return {
|
|
197
|
+
getRequirements: async () => {
|
|
198
|
+
const requirementsTimestamp = morpho_ts_1.Time.timestamp();
|
|
199
|
+
if (deadline <= requirementsTimestamp) {
|
|
200
|
+
throw new index_js_3.ExpiredDeadlineError(deadline, requirementsTimestamp);
|
|
201
|
+
}
|
|
202
|
+
const [allowance, nonce, blueBalance, morpho, blueFeeRecipient] = await (0, actions_1.multicall)(this.client.viemClient, {
|
|
203
|
+
allowFailure: false,
|
|
204
|
+
contracts: [
|
|
205
|
+
{
|
|
206
|
+
address: this.vault,
|
|
207
|
+
abi: viem_1.erc20Abi,
|
|
208
|
+
functionName: "allowance",
|
|
209
|
+
args: [userAddress, vaultExitBundlesV1],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
address: this.vault,
|
|
213
|
+
abi: blue_sdk_viem_1.erc2612Abi,
|
|
214
|
+
functionName: "nonces",
|
|
215
|
+
args: [userAddress],
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
address: vaultData.asset,
|
|
219
|
+
abi: viem_1.erc20Abi,
|
|
220
|
+
functionName: "balanceOf",
|
|
221
|
+
args: [blue],
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
address: this.vault,
|
|
225
|
+
abi: blue_sdk_viem_1.metaMorphoAbi,
|
|
226
|
+
functionName: "MORPHO",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
address: blue,
|
|
230
|
+
abi: blue_sdk_viem_1.blueAbi,
|
|
231
|
+
functionName: "feeRecipient",
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
});
|
|
235
|
+
if (!(0, viem_1.isAddressEqual)(morpho, blue)) {
|
|
236
|
+
throw new index_js_3.VaultMorphoMismatchError({
|
|
237
|
+
vault: this.vault,
|
|
238
|
+
expected: blue,
|
|
239
|
+
actual: morpho,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
// Reject this unsupported configuration before authorizing vault shares:
|
|
243
|
+
// VaultExitBundlesV1 omits newly accrued Morpho fee shares when estimating the
|
|
244
|
+
// vault position, so its callback can exhaust marketParamsList and panic on-chain.
|
|
245
|
+
if ((0, viem_1.isAddressEqual)(blueFeeRecipient, this.vault)) {
|
|
246
|
+
throw new index_js_3.VaultIsBlueFeeRecipientError(this.vault, blue);
|
|
247
|
+
}
|
|
248
|
+
if (blueBalance < amount) {
|
|
249
|
+
throw new index_js_3.InsufficientBlueBalanceForInKindRedeemError({
|
|
250
|
+
asset: vaultData.asset,
|
|
251
|
+
available: blueBalance,
|
|
252
|
+
required: amount,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (allowance >= requiredShareAllowance)
|
|
256
|
+
return [];
|
|
257
|
+
if (this.client.options.supportSignature) {
|
|
258
|
+
return [
|
|
259
|
+
(0, index_js_1.encodeVaultSharesPermit)({
|
|
260
|
+
vault: vaultData,
|
|
261
|
+
version: "vaultV1",
|
|
262
|
+
spender: vaultExitBundlesV1,
|
|
263
|
+
owner: userAddress,
|
|
264
|
+
chainId: this.chainId,
|
|
265
|
+
nonce,
|
|
266
|
+
amount: requiredShareAllowance,
|
|
267
|
+
deadline,
|
|
268
|
+
}),
|
|
269
|
+
];
|
|
270
|
+
}
|
|
271
|
+
return [
|
|
272
|
+
(0, index_js_1.encodeErc20Approval)({
|
|
273
|
+
token: this.vault,
|
|
274
|
+
spender: vaultExitBundlesV1,
|
|
275
|
+
amount: requiredShareAllowance,
|
|
276
|
+
chainId: this.chainId,
|
|
277
|
+
}),
|
|
278
|
+
];
|
|
279
|
+
},
|
|
280
|
+
buildTx: (signatures) => {
|
|
281
|
+
const { permit } = (0, index_js_3.selectRequirementSignatures)(signatures, {
|
|
282
|
+
permit: true,
|
|
283
|
+
});
|
|
284
|
+
return (0, index_js_1.vaultV1InKindRedeem)({
|
|
285
|
+
vault: { chainId: this.chainId, address: this.vault },
|
|
286
|
+
args: {
|
|
287
|
+
amount,
|
|
288
|
+
marketParamsList: marketParamsListSnapshot,
|
|
289
|
+
userAddress,
|
|
290
|
+
deadline,
|
|
291
|
+
requirementSignature: permit,
|
|
292
|
+
},
|
|
293
|
+
metadata: this.client.options.metadata,
|
|
294
|
+
});
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
}
|
|
134
298
|
migrateToV2({ userAddress, sourceVault, targetVault, shares, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, }) {
|
|
135
299
|
(0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
136
300
|
if (!(0, viem_1.isAddressEqual)(sourceVault.address, this.vault)) {
|
|
@@ -2,9 +2,9 @@ import { AccrualPosition, Market, type MarketId, Position, Vault, VaultMarketCon
|
|
|
2
2
|
import type { Address } from "viem";
|
|
3
3
|
import type { PublicAllocatorOptions, PublicReallocation, ReallocationComputeOptions } from "../types/index.js";
|
|
4
4
|
/**
|
|
5
|
-
* Input state required to construct {@link
|
|
5
|
+
* Input state required to construct {@link VaultV1ReallocationData}.
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
7
|
+
export interface InputVaultV1ReallocationData {
|
|
8
8
|
/** Chain id associated with the fetched state. */
|
|
9
9
|
readonly chainId: number;
|
|
10
10
|
/** Markets indexed by market id. */
|
|
@@ -16,13 +16,19 @@ export interface InputReallocationData {
|
|
|
16
16
|
/** Vault market configs indexed by vault address, then by market id. */
|
|
17
17
|
readonly vaultMarketConfigs?: Readonly<Record<Address, Readonly<Record<MarketId, VaultMarketConfig | undefined>>>>;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Deprecated input name for Vault V1 reallocation data.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Use {@link InputVaultV1ReallocationData} instead.
|
|
23
|
+
*/
|
|
24
|
+
export type InputReallocationData = InputVaultV1ReallocationData;
|
|
19
25
|
/**
|
|
20
26
|
* Narrow state container for computing public allocator reallocations.
|
|
21
27
|
*
|
|
22
28
|
* @remarks
|
|
23
29
|
* The class owns only the market, vault, position, vault-market-config,
|
|
24
30
|
* and chain data needed by the shared-liquidity algorithm. Constructor inputs
|
|
25
|
-
* are cloned, and simulation steps return cloned `
|
|
31
|
+
* are cloned, and simulation steps return cloned `VaultV1ReallocationData` instances
|
|
26
32
|
* so fetched caller inputs are not mutated.
|
|
27
33
|
*
|
|
28
34
|
* Public records are exposed for inspection and snapshotting only. Treat
|
|
@@ -30,7 +36,7 @@ export interface InputReallocationData {
|
|
|
30
36
|
* contract keyed by market id or address; use the getters for typed absence
|
|
31
37
|
* errors and use simulation methods to produce updated state.
|
|
32
38
|
*/
|
|
33
|
-
export declare class
|
|
39
|
+
export declare class VaultV1ReallocationData implements InputVaultV1ReallocationData {
|
|
34
40
|
/** Chain id associated with the fetched reallocation data. */
|
|
35
41
|
readonly chainId: number;
|
|
36
42
|
/** Markets indexed by market id. */
|
|
@@ -47,13 +53,13 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
47
53
|
*
|
|
48
54
|
* @param input - Reallocation input data fetched at a consistent chain state.
|
|
49
55
|
*/
|
|
50
|
-
constructor(input:
|
|
56
|
+
constructor(input: InputVaultV1ReallocationData);
|
|
51
57
|
/**
|
|
52
58
|
* Creates a deep clone of this reallocation state.
|
|
53
59
|
*
|
|
54
|
-
* @returns A new `
|
|
60
|
+
* @returns A new `VaultV1ReallocationData` instance with cloned entity objects.
|
|
55
61
|
*/
|
|
56
|
-
clone():
|
|
62
|
+
clone(): VaultV1ReallocationData;
|
|
57
63
|
private forkAliasedState;
|
|
58
64
|
/**
|
|
59
65
|
* Gets a market by id.
|
|
@@ -109,8 +115,7 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
109
115
|
*
|
|
110
116
|
* Pass `options.timestamp` to evaluate market interest and pending public
|
|
111
117
|
* allocator caps at the same block as the fetched reallocation data.
|
|
112
|
-
* This method does not add
|
|
113
|
-
* `SimulationState.getMarketPublicReallocations` applied before measuring
|
|
118
|
+
* This method does not add an implicit delay margin before measuring
|
|
114
119
|
* target-market vault headroom. If a transaction may land later than the
|
|
115
120
|
* fetched block, pass a future `timestamp` or reserve your own headroom so
|
|
116
121
|
* interest accrued before inclusion does not make `reallocateTo` exceed the
|
|
@@ -132,7 +137,7 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
132
137
|
* morphoViemExtension,
|
|
133
138
|
* type PublicReallocation,
|
|
134
139
|
* } from "@morpho-org/morpho-sdk";
|
|
135
|
-
* import type {
|
|
140
|
+
* import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
|
|
136
141
|
*
|
|
137
142
|
* const client = createPublicClient({
|
|
138
143
|
* chain: mainnet,
|
|
@@ -142,22 +147,35 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
142
147
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
143
148
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
144
149
|
* const block = await client.getBlock();
|
|
145
|
-
* const reallocationData = await market.
|
|
150
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
146
151
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
147
152
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
148
153
|
* });
|
|
149
154
|
*
|
|
150
155
|
* const result: {
|
|
151
156
|
* withdrawals: readonly PublicReallocation[];
|
|
152
|
-
* data:
|
|
153
|
-
* } = reallocationData.
|
|
157
|
+
* data: VaultV1ReallocationData;
|
|
158
|
+
* } = reallocationData.computeVaultV1Reallocations(marketParams.id, {
|
|
154
159
|
* timestamp: block.timestamp,
|
|
155
160
|
* });
|
|
156
161
|
* ```
|
|
157
162
|
*/
|
|
163
|
+
computeVaultV1Reallocations(marketId: MarketId, options?: PublicAllocatorOptions): {
|
|
164
|
+
readonly withdrawals: readonly PublicReallocation[];
|
|
165
|
+
data: VaultV1ReallocationData;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Calculates Vault V1 public reallocations that can supply liquidity to `marketId`.
|
|
169
|
+
*
|
|
170
|
+
* @param marketId - Target market to supply with shared liquidity.
|
|
171
|
+
* @param options - Optional allocator discovery options.
|
|
172
|
+
* @returns Computed source-market withdrawals and the post-reallocation state.
|
|
173
|
+
* @throws {@link UnknownReallocationMarketError} when the target market is absent.
|
|
174
|
+
* @deprecated Use {@link computeVaultV1Reallocations} instead.
|
|
175
|
+
*/
|
|
158
176
|
getMarketPublicReallocations(marketId: MarketId, options?: PublicAllocatorOptions): {
|
|
159
177
|
readonly withdrawals: readonly PublicReallocation[];
|
|
160
|
-
data:
|
|
178
|
+
data: VaultV1ReallocationData;
|
|
161
179
|
};
|
|
162
180
|
/**
|
|
163
181
|
* Sums the public-allocator liquidity reallocatable into `marketId` from
|
|
@@ -187,7 +205,7 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
187
205
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
188
206
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
189
207
|
* const block = await client.getBlock();
|
|
190
|
-
* const reallocationData = await market.
|
|
208
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
191
209
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
192
210
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
193
211
|
* });
|
|
@@ -238,7 +256,7 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
238
256
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
239
257
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
240
258
|
* const block = await client.getBlock();
|
|
241
|
-
* const reallocationData = await market.
|
|
259
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
242
260
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
243
261
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
244
262
|
* });
|
|
@@ -283,5 +301,11 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
283
301
|
readonly assets: bigint;
|
|
284
302
|
};
|
|
285
303
|
readonly timestamp: bigint;
|
|
286
|
-
}):
|
|
304
|
+
}): VaultV1ReallocationData;
|
|
287
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Deprecated class name for Vault V1 reallocation data.
|
|
308
|
+
*
|
|
309
|
+
* @deprecated Use {@link VaultV1ReallocationData} instead.
|
|
310
|
+
*/
|
|
311
|
+
export { VaultV1ReallocationData as ReallocationData };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReallocationData = void 0;
|
|
3
|
+
exports.ReallocationData = exports.VaultV1ReallocationData = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const constant_js_1 = require("../helpers/constant.js");
|
|
@@ -53,7 +53,7 @@ const cloneVaultMarketConfig = (config) => new blue_sdk_1.VaultMarketConfig({
|
|
|
53
53
|
* @remarks
|
|
54
54
|
* The class owns only the market, vault, position, vault-market-config,
|
|
55
55
|
* and chain data needed by the shared-liquidity algorithm. Constructor inputs
|
|
56
|
-
* are cloned, and simulation steps return cloned `
|
|
56
|
+
* are cloned, and simulation steps return cloned `VaultV1ReallocationData` instances
|
|
57
57
|
* so fetched caller inputs are not mutated.
|
|
58
58
|
*
|
|
59
59
|
* Public records are exposed for inspection and snapshotting only. Treat
|
|
@@ -61,7 +61,7 @@ const cloneVaultMarketConfig = (config) => new blue_sdk_1.VaultMarketConfig({
|
|
|
61
61
|
* contract keyed by market id or address; use the getters for typed absence
|
|
62
62
|
* errors and use simulation methods to produce updated state.
|
|
63
63
|
*/
|
|
64
|
-
class
|
|
64
|
+
class VaultV1ReallocationData {
|
|
65
65
|
/** Chain id associated with the fetched reallocation data. */
|
|
66
66
|
chainId;
|
|
67
67
|
/** Markets indexed by market id. */
|
|
@@ -109,13 +109,13 @@ class ReallocationData {
|
|
|
109
109
|
/**
|
|
110
110
|
* Creates a deep clone of this reallocation state.
|
|
111
111
|
*
|
|
112
|
-
* @returns A new `
|
|
112
|
+
* @returns A new `VaultV1ReallocationData` instance with cloned entity objects.
|
|
113
113
|
*/
|
|
114
114
|
clone() {
|
|
115
|
-
return new
|
|
115
|
+
return new VaultV1ReallocationData(this);
|
|
116
116
|
}
|
|
117
117
|
forkAliasedState() {
|
|
118
|
-
const data = new
|
|
118
|
+
const data = new VaultV1ReallocationData({ chainId: this.chainId });
|
|
119
119
|
Object.assign(data.markets, this.markets);
|
|
120
120
|
Object.assign(data.vaults, this.vaults);
|
|
121
121
|
for (const [user, positions] of Object.entries(this.positions)) {
|
|
@@ -202,8 +202,7 @@ class ReallocationData {
|
|
|
202
202
|
*
|
|
203
203
|
* Pass `options.timestamp` to evaluate market interest and pending public
|
|
204
204
|
* allocator caps at the same block as the fetched reallocation data.
|
|
205
|
-
* This method does not add
|
|
206
|
-
* `SimulationState.getMarketPublicReallocations` applied before measuring
|
|
205
|
+
* This method does not add an implicit delay margin before measuring
|
|
207
206
|
* target-market vault headroom. If a transaction may land later than the
|
|
208
207
|
* fetched block, pass a future `timestamp` or reserve your own headroom so
|
|
209
208
|
* interest accrued before inclusion does not make `reallocateTo` exceed the
|
|
@@ -225,7 +224,7 @@ class ReallocationData {
|
|
|
225
224
|
* morphoViemExtension,
|
|
226
225
|
* type PublicReallocation,
|
|
227
226
|
* } from "@morpho-org/morpho-sdk";
|
|
228
|
-
* import type {
|
|
227
|
+
* import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
|
|
229
228
|
*
|
|
230
229
|
* const client = createPublicClient({
|
|
231
230
|
* chain: mainnet,
|
|
@@ -235,27 +234,27 @@ class ReallocationData {
|
|
|
235
234
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
236
235
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
237
236
|
* const block = await client.getBlock();
|
|
238
|
-
* const reallocationData = await market.
|
|
237
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
239
238
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
240
239
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
241
240
|
* });
|
|
242
241
|
*
|
|
243
242
|
* const result: {
|
|
244
243
|
* withdrawals: readonly PublicReallocation[];
|
|
245
|
-
* data:
|
|
246
|
-
* } = reallocationData.
|
|
244
|
+
* data: VaultV1ReallocationData;
|
|
245
|
+
* } = reallocationData.computeVaultV1Reallocations(marketParams.id, {
|
|
247
246
|
* timestamp: block.timestamp,
|
|
248
247
|
* });
|
|
249
248
|
* ```
|
|
250
249
|
*/
|
|
251
|
-
|
|
250
|
+
computeVaultV1Reallocations(marketId, options = {}) {
|
|
252
251
|
const { enabled = true, timestamp, reallocatableVaults, defaultMaxWithdrawalUtilization = constant_js_1.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, maxWithdrawalUtilization = {}, } = options;
|
|
253
252
|
if (!enabled)
|
|
254
253
|
return { withdrawals: [], data: this };
|
|
255
254
|
const accrualTimestamp = BigInt(timestamp ?? this.getMarket(marketId).lastUpdate);
|
|
256
255
|
const configuredVaults = Object.keys(this.vaultMarketConfigs);
|
|
257
256
|
const vaultKeyByLower = new Map(configuredVaults.map((vault) => [vault.toLowerCase(), vault]));
|
|
258
|
-
const vaults = Array.from(new Set((reallocatableVaults ?? configuredVaults)
|
|
257
|
+
const vaults = Array.from(new Set([...(reallocatableVaults ?? configuredVaults)]
|
|
259
258
|
.map((vault) => vaultKeyByLower.get(vault.toLowerCase()))
|
|
260
259
|
.filter((vault) => vault != null))).filter((vault) => {
|
|
261
260
|
const vaultMarketConfig = this.vaultMarketConfigs[vault]?.[marketId];
|
|
@@ -304,6 +303,18 @@ class ReallocationData {
|
|
|
304
303
|
});
|
|
305
304
|
}
|
|
306
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Calculates Vault V1 public reallocations that can supply liquidity to `marketId`.
|
|
308
|
+
*
|
|
309
|
+
* @param marketId - Target market to supply with shared liquidity.
|
|
310
|
+
* @param options - Optional allocator discovery options.
|
|
311
|
+
* @returns Computed source-market withdrawals and the post-reallocation state.
|
|
312
|
+
* @throws {@link UnknownReallocationMarketError} when the target market is absent.
|
|
313
|
+
* @deprecated Use {@link computeVaultV1Reallocations} instead.
|
|
314
|
+
*/
|
|
315
|
+
getMarketPublicReallocations(marketId, options = {}) {
|
|
316
|
+
return this.computeVaultV1Reallocations(marketId, options);
|
|
317
|
+
}
|
|
307
318
|
/**
|
|
308
319
|
* Sums the public-allocator liquidity reallocatable into `marketId` from
|
|
309
320
|
* sibling markets.
|
|
@@ -332,7 +343,7 @@ class ReallocationData {
|
|
|
332
343
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
333
344
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
334
345
|
* const block = await client.getBlock();
|
|
335
|
-
* const reallocationData = await market.
|
|
346
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
336
347
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
337
348
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
338
349
|
* });
|
|
@@ -344,7 +355,7 @@ class ReallocationData {
|
|
|
344
355
|
* ```
|
|
345
356
|
*/
|
|
346
357
|
getPublicReallocationLiquidity(marketId, options) {
|
|
347
|
-
const { withdrawals } = this.
|
|
358
|
+
const { withdrawals } = this.computeVaultV1Reallocations(marketId, options);
|
|
348
359
|
return withdrawals.reduce((total, { assets }) => total + assets, 0n);
|
|
349
360
|
}
|
|
350
361
|
/**
|
|
@@ -386,7 +397,7 @@ class ReallocationData {
|
|
|
386
397
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
387
398
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
388
399
|
* const block = await client.getBlock();
|
|
389
|
-
* const reallocationData = await market.
|
|
400
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
390
401
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
391
402
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
392
403
|
* });
|
|
@@ -517,4 +528,5 @@ class ReallocationData {
|
|
|
517
528
|
return data;
|
|
518
529
|
}
|
|
519
530
|
}
|
|
520
|
-
exports.
|
|
531
|
+
exports.VaultV1ReallocationData = VaultV1ReallocationData;
|
|
532
|
+
exports.ReallocationData = VaultV1ReallocationData;
|