@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
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
3
|
+
exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketPublicAllocatorConfig = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.BlueUser = exports.Token = exports.PreLiquidationPosition = exports.BluePreLiquidationPosition = exports.PreLiquidationParams = exports.BluePreLiquidationParams = exports.Position = exports.BluePosition = exports.MarketParams = exports.BlueMarketParams = exports.Market = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = exports.BlueAccrualPosition = void 0;
|
|
4
|
+
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.VaultV1ReallocationData = exports.ReallocationData = void 0;
|
|
18
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
|
+
Object.defineProperty(exports, "BlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
7
|
+
/** @deprecated Use `BlueAccrualPosition` or the raw Blue subpath. */
|
|
19
8
|
Object.defineProperty(exports, "AccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
20
9
|
Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
|
|
21
10
|
Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
|
|
@@ -27,12 +16,24 @@ Object.defineProperty(exports, "ConstantWrappedToken", { enumerable: true, get:
|
|
|
27
16
|
Object.defineProperty(exports, "Eip5267Domain", { enumerable: true, get: function () { return blue_sdk_1.Eip5267Domain; } });
|
|
28
17
|
Object.defineProperty(exports, "ExchangeRateWrappedToken", { enumerable: true, get: function () { return blue_sdk_1.ExchangeRateWrappedToken; } });
|
|
29
18
|
Object.defineProperty(exports, "Holding", { enumerable: true, get: function () { return blue_sdk_1.Holding; } });
|
|
19
|
+
Object.defineProperty(exports, "BlueMarket", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
|
|
20
|
+
/** @deprecated Use `BlueMarket` or the raw Blue subpath. */
|
|
30
21
|
Object.defineProperty(exports, "Market", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
|
|
22
|
+
Object.defineProperty(exports, "BlueMarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
|
|
23
|
+
/** @deprecated Use `BlueMarketParams` or the raw Blue subpath. */
|
|
31
24
|
Object.defineProperty(exports, "MarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
|
|
25
|
+
Object.defineProperty(exports, "BluePosition", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
|
|
26
|
+
/** @deprecated Use `BluePosition` or the raw Blue subpath. */
|
|
32
27
|
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
|
|
28
|
+
Object.defineProperty(exports, "BluePreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
|
|
29
|
+
/** @deprecated Use `BluePreLiquidationParams` or the raw Blue subpath. */
|
|
33
30
|
Object.defineProperty(exports, "PreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
|
|
31
|
+
Object.defineProperty(exports, "BluePreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
|
|
32
|
+
/** @deprecated Use `BluePreLiquidationPosition` or the raw Blue subpath. */
|
|
34
33
|
Object.defineProperty(exports, "PreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
|
|
35
34
|
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return blue_sdk_1.Token; } });
|
|
35
|
+
Object.defineProperty(exports, "BlueUser", { enumerable: true, get: function () { return blue_sdk_1.User; } });
|
|
36
|
+
/** @deprecated Use `BlueUser` or the raw Blue subpath. */
|
|
36
37
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return blue_sdk_1.User; } });
|
|
37
38
|
Object.defineProperty(exports, "Vault", { enumerable: true, get: function () { return blue_sdk_1.Vault; } });
|
|
38
39
|
Object.defineProperty(exports, "VaultConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultConfig; } });
|
|
@@ -43,16 +44,30 @@ Object.defineProperty(exports, "VaultToken", { enumerable: true, get: function (
|
|
|
43
44
|
Object.defineProperty(exports, "VaultUser", { enumerable: true, get: function () { return blue_sdk_1.VaultUser; } });
|
|
44
45
|
Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2; } });
|
|
45
46
|
Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
|
|
47
|
+
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfig; } });
|
|
48
|
+
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfig; } });
|
|
46
49
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
|
|
47
50
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
|
|
48
51
|
Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
|
|
49
52
|
Object.defineProperty(exports, "WrappedToken", { enumerable: true, get: function () { return blue_sdk_1.WrappedToken; } });
|
|
53
|
+
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
54
|
+
Object.defineProperty(exports, "MidnightAccrualPosition", { enumerable: true, get: function () { return midnight_sdk_1.AccrualPosition; } });
|
|
55
|
+
Object.defineProperty(exports, "MidnightGroup", { enumerable: true, get: function () { return midnight_sdk_1.Group; } });
|
|
56
|
+
Object.defineProperty(exports, "MidnightMarket", { enumerable: true, get: function () { return midnight_sdk_1.Market; } });
|
|
57
|
+
Object.defineProperty(exports, "MidnightMarketParams", { enumerable: true, get: function () { return midnight_sdk_1.MarketParams; } });
|
|
58
|
+
Object.defineProperty(exports, "MidnightOffer", { enumerable: true, get: function () { return midnight_sdk_1.Offer; } });
|
|
59
|
+
Object.defineProperty(exports, "MidnightPosition", { enumerable: true, get: function () { return midnight_sdk_1.Position; } });
|
|
60
|
+
Object.defineProperty(exports, "MidnightTree", { enumerable: true, get: function () { return midnight_sdk_1.Tree; } });
|
|
50
61
|
var index_js_1 = require("./blue/index.js");
|
|
51
62
|
Object.defineProperty(exports, "MorphoBlue", { enumerable: true, get: function () { return index_js_1.MorphoBlue; } });
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Object.defineProperty(exports, "
|
|
63
|
+
var index_js_2 = require("./midnight/index.js");
|
|
64
|
+
Object.defineProperty(exports, "MorphoMidnight", { enumerable: true, get: function () { return index_js_2.MorphoMidnight; } });
|
|
65
|
+
var index_js_3 = require("./vaultV1/index.js");
|
|
66
|
+
Object.defineProperty(exports, "MorphoVaultV1", { enumerable: true, get: function () { return index_js_3.MorphoVaultV1; } });
|
|
67
|
+
var vaultV1ReallocationData_js_1 = require("./vaultV1ReallocationData.js");
|
|
68
|
+
Object.defineProperty(exports, "ReallocationData", { enumerable: true, get: function () { return vaultV1ReallocationData_js_1.ReallocationData; } });
|
|
69
|
+
Object.defineProperty(exports, "VaultV1ReallocationData", { enumerable: true, get: function () { return vaultV1ReallocationData_js_1.VaultV1ReallocationData; } });
|
|
70
|
+
var index_js_4 = require("./vaultV2/index.js");
|
|
71
|
+
Object.defineProperty(exports, "MorphoVaultV2", { enumerable: true, get: function () { return index_js_4.MorphoVaultV2; } });
|
|
72
|
+
var vaultV2BlueReallocationData_js_1 = require("./vaultV2BlueReallocationData.js");
|
|
73
|
+
Object.defineProperty(exports, "VaultV2BlueReallocationData", { enumerable: true, get: function () { return vaultV2BlueReallocationData_js_1.VaultV2BlueReallocationData; } });
|
|
@@ -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.
|
|
@@ -131,7 +137,7 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
131
137
|
* morphoViemExtension,
|
|
132
138
|
* type PublicReallocation,
|
|
133
139
|
* } from "@morpho-org/morpho-sdk";
|
|
134
|
-
* import type {
|
|
140
|
+
* import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
|
|
135
141
|
*
|
|
136
142
|
* const client = createPublicClient({
|
|
137
143
|
* chain: mainnet,
|
|
@@ -141,22 +147,35 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
141
147
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
142
148
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
143
149
|
* const block = await client.getBlock();
|
|
144
|
-
* const reallocationData = await market.
|
|
150
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
145
151
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
146
152
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
147
153
|
* });
|
|
148
154
|
*
|
|
149
155
|
* const result: {
|
|
150
156
|
* withdrawals: readonly PublicReallocation[];
|
|
151
|
-
* data:
|
|
152
|
-
* } = reallocationData.
|
|
157
|
+
* data: VaultV1ReallocationData;
|
|
158
|
+
* } = reallocationData.computeVaultV1Reallocations(marketParams.id, {
|
|
153
159
|
* timestamp: block.timestamp,
|
|
154
160
|
* });
|
|
155
161
|
* ```
|
|
156
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
|
+
*/
|
|
157
176
|
getMarketPublicReallocations(marketId: MarketId, options?: PublicAllocatorOptions): {
|
|
158
177
|
readonly withdrawals: readonly PublicReallocation[];
|
|
159
|
-
data:
|
|
178
|
+
data: VaultV1ReallocationData;
|
|
160
179
|
};
|
|
161
180
|
/**
|
|
162
181
|
* Sums the public-allocator liquidity reallocatable into `marketId` from
|
|
@@ -186,7 +205,7 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
186
205
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
187
206
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
188
207
|
* const block = await client.getBlock();
|
|
189
|
-
* const reallocationData = await market.
|
|
208
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
190
209
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
191
210
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
192
211
|
* });
|
|
@@ -237,7 +256,7 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
237
256
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
238
257
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
239
258
|
* const block = await client.getBlock();
|
|
240
|
-
* const reallocationData = await market.
|
|
259
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
241
260
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
242
261
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
243
262
|
* });
|
|
@@ -282,5 +301,11 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
282
301
|
readonly assets: bigint;
|
|
283
302
|
};
|
|
284
303
|
readonly timestamp: bigint;
|
|
285
|
-
}):
|
|
304
|
+
}): VaultV1ReallocationData;
|
|
286
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)) {
|
|
@@ -224,7 +224,7 @@ class ReallocationData {
|
|
|
224
224
|
* morphoViemExtension,
|
|
225
225
|
* type PublicReallocation,
|
|
226
226
|
* } from "@morpho-org/morpho-sdk";
|
|
227
|
-
* import type {
|
|
227
|
+
* import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
|
|
228
228
|
*
|
|
229
229
|
* const client = createPublicClient({
|
|
230
230
|
* chain: mainnet,
|
|
@@ -234,27 +234,27 @@ class ReallocationData {
|
|
|
234
234
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
235
235
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
236
236
|
* const block = await client.getBlock();
|
|
237
|
-
* const reallocationData = await market.
|
|
237
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
238
238
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
239
239
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
240
240
|
* });
|
|
241
241
|
*
|
|
242
242
|
* const result: {
|
|
243
243
|
* withdrawals: readonly PublicReallocation[];
|
|
244
|
-
* data:
|
|
245
|
-
* } = reallocationData.
|
|
244
|
+
* data: VaultV1ReallocationData;
|
|
245
|
+
* } = reallocationData.computeVaultV1Reallocations(marketParams.id, {
|
|
246
246
|
* timestamp: block.timestamp,
|
|
247
247
|
* });
|
|
248
248
|
* ```
|
|
249
249
|
*/
|
|
250
|
-
|
|
250
|
+
computeVaultV1Reallocations(marketId, options = {}) {
|
|
251
251
|
const { enabled = true, timestamp, reallocatableVaults, defaultMaxWithdrawalUtilization = constant_js_1.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, maxWithdrawalUtilization = {}, } = options;
|
|
252
252
|
if (!enabled)
|
|
253
253
|
return { withdrawals: [], data: this };
|
|
254
254
|
const accrualTimestamp = BigInt(timestamp ?? this.getMarket(marketId).lastUpdate);
|
|
255
255
|
const configuredVaults = Object.keys(this.vaultMarketConfigs);
|
|
256
256
|
const vaultKeyByLower = new Map(configuredVaults.map((vault) => [vault.toLowerCase(), vault]));
|
|
257
|
-
const vaults = Array.from(new Set((reallocatableVaults ?? configuredVaults)
|
|
257
|
+
const vaults = Array.from(new Set([...(reallocatableVaults ?? configuredVaults)]
|
|
258
258
|
.map((vault) => vaultKeyByLower.get(vault.toLowerCase()))
|
|
259
259
|
.filter((vault) => vault != null))).filter((vault) => {
|
|
260
260
|
const vaultMarketConfig = this.vaultMarketConfigs[vault]?.[marketId];
|
|
@@ -303,6 +303,18 @@ class ReallocationData {
|
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
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
|
+
}
|
|
306
318
|
/**
|
|
307
319
|
* Sums the public-allocator liquidity reallocatable into `marketId` from
|
|
308
320
|
* sibling markets.
|
|
@@ -331,7 +343,7 @@ class ReallocationData {
|
|
|
331
343
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
332
344
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
333
345
|
* const block = await client.getBlock();
|
|
334
|
-
* const reallocationData = await market.
|
|
346
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
335
347
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
336
348
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
337
349
|
* });
|
|
@@ -343,7 +355,7 @@ class ReallocationData {
|
|
|
343
355
|
* ```
|
|
344
356
|
*/
|
|
345
357
|
getPublicReallocationLiquidity(marketId, options) {
|
|
346
|
-
const { withdrawals } = this.
|
|
358
|
+
const { withdrawals } = this.computeVaultV1Reallocations(marketId, options);
|
|
347
359
|
return withdrawals.reduce((total, { assets }) => total + assets, 0n);
|
|
348
360
|
}
|
|
349
361
|
/**
|
|
@@ -385,7 +397,7 @@ class ReallocationData {
|
|
|
385
397
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
386
398
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
387
399
|
* const block = await client.getBlock();
|
|
388
|
-
* const reallocationData = await market.
|
|
400
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
389
401
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
390
402
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
391
403
|
* });
|
|
@@ -516,4 +528,5 @@ class ReallocationData {
|
|
|
516
528
|
return data;
|
|
517
529
|
}
|
|
518
530
|
}
|
|
519
|
-
exports.
|
|
531
|
+
exports.VaultV1ReallocationData = VaultV1ReallocationData;
|
|
532
|
+
exports.ReallocationData = VaultV1ReallocationData;
|
|
@@ -86,7 +86,7 @@ export interface VaultV2Actions {
|
|
|
86
86
|
* multiple share burns. The SDK intentionally does not validate the user's share balance; size
|
|
87
87
|
* it so `amount + BigInt(marketParamsList.length) <= vault.previewRedeem(sharesHeld)`. The
|
|
88
88
|
* per-market term covers V2 withdrawal rounding and is not needed for V1. The share allowance
|
|
89
|
-
* includes the penalty burns and accrual through the bundle deadline.
|
|
89
|
+
* includes that buffer, the penalty burns, and accrual through the bundle deadline.
|
|
90
90
|
*
|
|
91
91
|
* Idle balance, penalty, and adapter positions can drift after the snapshot, so an on-chain
|
|
92
92
|
* under-coverage panic remains possible if vault state changes between preparation and inclusion.
|
|
@@ -208,11 +208,11 @@ class MorphoVaultV2 {
|
|
|
208
208
|
}
|
|
209
209
|
let remaining = assetsToDeallocate;
|
|
210
210
|
let peak = 0n;
|
|
211
|
-
let requiredShareAllowance = 0n;
|
|
212
211
|
const consumedMarketIds = new Set();
|
|
213
212
|
const { vault: allowanceVault } = vaultData.accrueInterest(deadline);
|
|
214
213
|
// Interest can lower the burn, while management fees can raise it; bound both endpoints.
|
|
215
214
|
const previewAllowance = (assets) => blue_sdk_1.MathLib.max(vaultData.toShares(assets, "Up"), allowanceVault.toShares(assets, "Up"));
|
|
215
|
+
let requiredShareAllowance = previewAllowance(BigInt(marketParamsListSnapshot.length));
|
|
216
216
|
// Pre-burn previews upper-bound each separately rounded idle, penalty, and main burn.
|
|
217
217
|
requiredShareAllowance += previewAllowance(idleAssets);
|
|
218
218
|
for (const id of marketIdListSnapshot) {
|