@morpho-org/morpho-sdk 6.2.0 → 6.3.1
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/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/entities/blue/blue.d.ts +14 -2
- package/lib/cjs/entities/blue/blue.js +7 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +37 -11
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +176 -61
- package/lib/cjs/helpers/constant.d.ts +8 -0
- package/lib/cjs/helpers/constant.js +10 -1
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/utilization.d.ts +13 -0
- package/lib/cjs/helpers/utilization.js +19 -1
- package/lib/cjs/types/sharedLiquidity.d.ts +19 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +14 -2
- package/lib/esm/entities/blue/blue.js +7 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +37 -11
- package/lib/esm/entities/vaultV2BlueReallocationData.js +177 -62
- package/lib/esm/helpers/constant.d.ts +8 -0
- package/lib/esm/helpers/constant.js +9 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/utilization.d.ts +13 -0
- package/lib/esm/helpers/utilization.js +18 -1
- package/lib/esm/types/sharedLiquidity.d.ts +19 -1
- package/package.json +1 -1
|
@@ -7,6 +7,14 @@ export declare const DEFAULT_MAX_REALLOCATION_PENALTY = 0n;
|
|
|
7
7
|
export declare const MAX_REALLOCATION_PENALTY = 1000000000000000000n;
|
|
8
8
|
/** Default LLTV buffer: 0.5% below LLTV. Prevents instant liquidation on new positions. */
|
|
9
9
|
export declare const DEFAULT_LLTV_BUFFER: bigint;
|
|
10
|
+
/**
|
|
11
|
+
* Forward interest-accrual window, in seconds (2 hours), reserved in target-market
|
|
12
|
+
* cap checks (BluePublicAllocator max-in, Vault V2 absolute and relative caps) when
|
|
13
|
+
* planning reallocations, so a transaction included after the quote block does not
|
|
14
|
+
* revert on a cap check. Override with
|
|
15
|
+
* `VaultV2BluePublicAllocatorOptions.capAccrualBuffer`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_CAP_ACCRUAL_BUFFER: bigint;
|
|
10
18
|
/** Maximum absolute share price cap (100 RAY). Prevents absurd maxSharePrice values in repay. */
|
|
11
19
|
export declare const MAX_ABSOLUTE_SHARE_PRICE: bigint;
|
|
12
20
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_LLTV_BUFFER = exports.MAX_REALLOCATION_PENALTY = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.MAX_SLIPPAGE_TOLERANCE = void 0;
|
|
3
|
+
exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_LLTV_BUFFER = exports.MAX_REALLOCATION_PENALTY = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.MAX_SLIPPAGE_TOLERANCE = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
6
|
const viem_1 = require("viem");
|
|
6
7
|
/** Maximum slippage tolerance: 10% */
|
|
7
8
|
exports.MAX_SLIPPAGE_TOLERANCE = blue_sdk_1.MathLib.WAD / 10n;
|
|
@@ -11,6 +12,14 @@ exports.DEFAULT_MAX_REALLOCATION_PENALTY = 0n;
|
|
|
11
12
|
exports.MAX_REALLOCATION_PENALTY = blue_sdk_1.MathLib.WAD;
|
|
12
13
|
/** Default LLTV buffer: 0.5% below LLTV. Prevents instant liquidation on new positions. */
|
|
13
14
|
exports.DEFAULT_LLTV_BUFFER = blue_sdk_1.MathLib.WAD / 200n;
|
|
15
|
+
/**
|
|
16
|
+
* Forward interest-accrual window, in seconds (2 hours), reserved in target-market
|
|
17
|
+
* cap checks (BluePublicAllocator max-in, Vault V2 absolute and relative caps) when
|
|
18
|
+
* planning reallocations, so a transaction included after the quote block does not
|
|
19
|
+
* revert on a cap check. Override with
|
|
20
|
+
* `VaultV2BluePublicAllocatorOptions.capAccrualBuffer`.
|
|
21
|
+
*/
|
|
22
|
+
exports.DEFAULT_CAP_ACCRUAL_BUFFER = morpho_ts_1.Time.s.from.h(2n);
|
|
14
23
|
/** Maximum absolute share price cap (100 RAY). Prevents absurd maxSharePrice values in repay. */
|
|
15
24
|
exports.MAX_ABSOLUTE_SHARE_PRICE = 100n * blue_sdk_1.MathLib.RAY;
|
|
16
25
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
|
|
1
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
|
|
2
2
|
export { addTransactionMetadata } from "./metadata.js";
|
|
3
3
|
export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./previewVaultV2ForceWithdraw.js";
|
|
4
4
|
export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./previewVaultV2InKindRedeem.js";
|
package/lib/cjs/helpers/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = void 0;
|
|
3
|
+
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = void 0;
|
|
4
4
|
var constant_js_1 = require("./constant.js");
|
|
5
5
|
Object.defineProperty(exports, "APPROVE_ONLY_ONCE_TOKENS", { enumerable: true, get: function () { return constant_js_1.APPROVE_ONLY_ONCE_TOKENS; } });
|
|
6
|
+
Object.defineProperty(exports, "DEFAULT_CAP_ACCRUAL_BUFFER", { enumerable: true, get: function () { return constant_js_1.DEFAULT_CAP_ACCRUAL_BUFFER; } });
|
|
6
7
|
Object.defineProperty(exports, "DEFAULT_LLTV_BUFFER", { enumerable: true, get: function () { return constant_js_1.DEFAULT_LLTV_BUFFER; } });
|
|
7
8
|
Object.defineProperty(exports, "DEFAULT_MAX_REALLOCATION_PENALTY", { enumerable: true, get: function () { return constant_js_1.DEFAULT_MAX_REALLOCATION_PENALTY; } });
|
|
8
9
|
Object.defineProperty(exports, "DEFAULT_SUPPLY_TARGET_UTILIZATION", { enumerable: true, get: function () { return constant_js_1.DEFAULT_SUPPLY_TARGET_UTILIZATION; } });
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import { type BigIntish } from "@morpho-org/blue-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves and validates the target-market cap-accrual buffer.
|
|
4
|
+
* @internal
|
|
5
|
+
* @param value - Optional buffer duration in seconds.
|
|
6
|
+
* @returns The non-negative buffer duration, defaulting to two hours.
|
|
7
|
+
* @throws {NegativeInputError} when the buffer is negative.
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const buffer = resolveCapAccrualBuffer(undefined);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolveCapAccrualBuffer: (value?: BigIntish) => bigint;
|
|
1
14
|
/**
|
|
2
15
|
* Resolves and validates a source withdrawal utilization ceiling.
|
|
3
16
|
* @internal
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveMaxWithdrawalUtilization = void 0;
|
|
3
|
+
exports.resolveMaxWithdrawalUtilization = exports.resolveCapAccrualBuffer = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const index_js_1 = require("../types/index.js");
|
|
6
6
|
const constant_js_1 = require("./constant.js");
|
|
7
|
+
/**
|
|
8
|
+
* Resolves and validates the target-market cap-accrual buffer.
|
|
9
|
+
* @internal
|
|
10
|
+
* @param value - Optional buffer duration in seconds.
|
|
11
|
+
* @returns The non-negative buffer duration, defaulting to two hours.
|
|
12
|
+
* @throws {NegativeInputError} when the buffer is negative.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const buffer = resolveCapAccrualBuffer(undefined);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
const resolveCapAccrualBuffer = (value) => {
|
|
19
|
+
const buffer = value == null ? constant_js_1.DEFAULT_CAP_ACCRUAL_BUFFER : BigInt(value);
|
|
20
|
+
if (buffer < 0n)
|
|
21
|
+
throw new index_js_1.NegativeInputError("capAccrualBuffer", buffer);
|
|
22
|
+
return buffer;
|
|
23
|
+
};
|
|
24
|
+
exports.resolveCapAccrualBuffer = resolveCapAccrualBuffer;
|
|
7
25
|
/**
|
|
8
26
|
* Resolves and validates a source withdrawal utilization ceiling.
|
|
9
27
|
* @internal
|
|
@@ -4,8 +4,26 @@ import type { Address } from "viem";
|
|
|
4
4
|
export interface VaultV2BluePublicAllocatorOptions {
|
|
5
5
|
/** Whether Vault V2 public allocator discovery is enabled. */
|
|
6
6
|
readonly enabled?: boolean;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Timestamp at which market and Vault V2 state is evaluated. Canonical state
|
|
9
|
+
* and the returned post-state stay at this timestamp; only target-market cap
|
|
10
|
+
* checks reserve interest on the vault's existing allocation through this
|
|
11
|
+
* timestamp plus `capAccrualBuffer`. For market-source reallocations the
|
|
12
|
+
* source position's interest is also reserved on cap ids shared with the
|
|
13
|
+
* target, and reserves persist across every leg of a plan.
|
|
14
|
+
*/
|
|
8
15
|
readonly timestamp?: BigIntish;
|
|
16
|
+
/**
|
|
17
|
+
* Seconds beyond `timestamp` through which target-market cap checks reserve
|
|
18
|
+
* interest on the vault's existing allocation. For market-source
|
|
19
|
+
* reallocations the source position's interest is also reserved on cap ids
|
|
20
|
+
* shared with the target, and reserves persist across every leg of a plan.
|
|
21
|
+
* Market and Vault V2 state, including the returned post-state, stay at
|
|
22
|
+
* `timestamp`. Set to `0n` to disable.
|
|
23
|
+
*
|
|
24
|
+
* @default DEFAULT_CAP_ACCRUAL_BUFFER (2h)
|
|
25
|
+
*/
|
|
26
|
+
readonly capAccrualBuffer?: BigIntish;
|
|
9
27
|
/**
|
|
10
28
|
* Vault V2 addresses to consider. Arrays, readonly arrays, sets, and other
|
|
11
29
|
* iterables are accepted. Defaults to every vault in the reallocation data.
|
package/lib/esm/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
|
|
2
2
|
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
3
3
|
export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
|
|
4
|
-
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
|
4
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
package/lib/esm/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
|
|
2
2
|
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
3
3
|
export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
|
|
4
|
-
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
|
4
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
|
@@ -814,13 +814,19 @@ export interface BlueActions {
|
|
|
814
814
|
}) => Promise<VaultV2BlueReallocationData>;
|
|
815
815
|
/**
|
|
816
816
|
* Computes Vault V2 BluePublicAllocator reallocations for this market.
|
|
817
|
+
* Market/vault state and returned post-state stay at `options.timestamp`;
|
|
818
|
+
* only target-market cap checks reserve interest on the vault's existing
|
|
819
|
+
* allocation through `timestamp + capAccrualBuffer` (two hours by default;
|
|
820
|
+
* `0n` disables it). For market-source reallocations the source position's
|
|
821
|
+
* interest is also reserved on cap ids shared with the target, and reserves
|
|
822
|
+
* persist across every leg of a plan.
|
|
817
823
|
*
|
|
818
824
|
* @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
|
|
819
825
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
820
826
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
821
827
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
822
828
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
823
|
-
* @throws {NegativeInputError} when
|
|
829
|
+
* @throws {NegativeInputError} when the cap-accrual buffer, utilization, or penalty limit is negative.
|
|
824
830
|
* @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
|
|
825
831
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
826
832
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
@@ -1026,13 +1032,19 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1026
1032
|
}): Promise<VaultV2BlueReallocationData>;
|
|
1027
1033
|
/**
|
|
1028
1034
|
* Computes Vault V2 BluePublicAllocator reallocations for this market.
|
|
1035
|
+
* Market/vault state and returned post-state stay at `options.timestamp`;
|
|
1036
|
+
* only target-market cap checks reserve interest on the vault's existing
|
|
1037
|
+
* allocation through `timestamp + capAccrualBuffer` (two hours by default;
|
|
1038
|
+
* `0n` disables it). For market-source reallocations the source position's
|
|
1039
|
+
* interest is also reserved on cap ids shared with the target, and reserves
|
|
1040
|
+
* persist across every leg of a plan.
|
|
1029
1041
|
*
|
|
1030
1042
|
* @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
|
|
1031
1043
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
1032
1044
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
1033
1045
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
1034
1046
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
1035
|
-
* @throws {NegativeInputError} when
|
|
1047
|
+
* @throws {NegativeInputError} when the cap-accrual buffer, utilization, or penalty limit is negative.
|
|
1036
1048
|
* @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
|
|
1037
1049
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
1038
1050
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
@@ -730,13 +730,19 @@ export class MorphoBlue {
|
|
|
730
730
|
}
|
|
731
731
|
/**
|
|
732
732
|
* Computes Vault V2 BluePublicAllocator reallocations for this market.
|
|
733
|
+
* Market/vault state and returned post-state stay at `options.timestamp`;
|
|
734
|
+
* only target-market cap checks reserve interest on the vault's existing
|
|
735
|
+
* allocation through `timestamp + capAccrualBuffer` (two hours by default;
|
|
736
|
+
* `0n` disables it). For market-source reallocations the source position's
|
|
737
|
+
* interest is also reserved on cap ids shared with the target, and reserves
|
|
738
|
+
* persist across every leg of a plan.
|
|
733
739
|
*
|
|
734
740
|
* @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
|
|
735
741
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
736
742
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
737
743
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
738
744
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
739
|
-
* @throws {NegativeInputError} when
|
|
745
|
+
* @throws {NegativeInputError} when the cap-accrual buffer, utilization, or penalty limit is negative.
|
|
740
746
|
* @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
|
|
741
747
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
742
748
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
@@ -363,11 +363,18 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
363
363
|
* utilization defaults to 90% and is configurable through
|
|
364
364
|
* `options.maxWithdrawalUtilization`. Vaults whose configured penalty exceeds
|
|
365
365
|
* `options.maxPenalty` are ignored. By default, only zero-penalty vaults are
|
|
366
|
-
* considered.
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
366
|
+
* considered. Market/vault state and the returned post-state stay at
|
|
367
|
+
* `timestamp`; only target-market cap checks reserve interest the vault's
|
|
368
|
+
* existing allocation would accrue through `timestamp + capAccrualBuffer`
|
|
369
|
+
* (two hours by default; `0n` disables it). For market-source reallocations
|
|
370
|
+
* the source position's interest is also reserved on cap ids shared with the
|
|
371
|
+
* target, and reserves persist across every leg of a plan. Targets with no remaining supply
|
|
372
|
+
* or allocator capacity are skipped before projecting source interest. The
|
|
373
|
+
* adapter's minimum share minting requirement, supply-share limits, and target
|
|
374
|
+
* absolute or zero relative caps are checked against a one-asset deposit.
|
|
375
|
+
* Shared cap IDs that a source withdrawal can reduce remain eligible. Each
|
|
376
|
+
* accepted leg counts at least its requested `assets` against the target cap
|
|
377
|
+
* IDs, so a leg sized to a cap leaves no rounding headroom.
|
|
371
378
|
*
|
|
372
379
|
* Shared-cap discovery is conservative. Operation planning searches at most
|
|
373
380
|
* 1,024 base units above its targeted amount for the nearest executable fit.
|
|
@@ -377,9 +384,15 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
377
384
|
*
|
|
378
385
|
* @param marketId - Target Blue market id.
|
|
379
386
|
* @param options - Optional discovery controls and operation to support.
|
|
387
|
+
* Market/vault state and returned post-state stay at `timestamp`; only
|
|
388
|
+
* target-market cap checks reserve interest on the vault's existing allocation
|
|
389
|
+
* through `timestamp + capAccrualBuffer` (two hours by default; `0n` disables).
|
|
390
|
+
* For market-source reallocations the source position's interest is also
|
|
391
|
+
* reserved on cap ids shared with the target, and reserves persist across
|
|
392
|
+
* every leg of a plan.
|
|
380
393
|
* @returns Flat action-ready reallocations and their post-simulation state.
|
|
381
394
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
382
|
-
* @throws {NegativeInputError} when `maxWithdrawalUtilization
|
|
395
|
+
* @throws {NegativeInputError} when `capAccrualBuffer`, `maxWithdrawalUtilization`, or `maxPenalty` is negative.
|
|
383
396
|
* @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
|
|
384
397
|
* @throws {NonPositiveInputError} when the operation amount is not positive and planning is enabled.
|
|
385
398
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
@@ -431,12 +444,19 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
431
444
|
private computeVaultV2BlueReallocationsAtUtilizationInPlace;
|
|
432
445
|
/**
|
|
433
446
|
* Sums friendly Vault V2 shared liquidity available to a target market.
|
|
447
|
+
* Market/vault state and returned post-state stay at `timestamp`; only
|
|
448
|
+
* target-market cap checks reserve interest on the vault's existing allocation
|
|
449
|
+
* through `timestamp + capAccrualBuffer` (two hours by default; `0n` disables).
|
|
450
|
+
* For market-source reallocations the source position's interest is also
|
|
451
|
+
* reserved on cap ids shared with the target, and reserves persist across
|
|
452
|
+
* every leg of a plan.
|
|
434
453
|
*
|
|
435
454
|
* @param marketId - Target Blue market id.
|
|
436
|
-
* @param options - Optional timestamp, enable flag, vault
|
|
455
|
+
* @param options - Optional timestamp, cap-accrual buffer, enable flag, vault
|
|
456
|
+
* allowlist, source utilization ceiling, and maximum penalty.
|
|
437
457
|
* @returns Reallocatable market and idle assets, or `0n` when none are available; rounding-only shared-cap fits may be conservatively omitted.
|
|
438
458
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
439
|
-
* @throws {NegativeInputError} when `maxWithdrawalUtilization
|
|
459
|
+
* @throws {NegativeInputError} when `capAccrualBuffer`, `maxWithdrawalUtilization`, or `maxPenalty` is negative.
|
|
440
460
|
* @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
|
|
441
461
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
442
462
|
* @throws {UnknownReallocationVaultError} when configured vault state is absent.
|
|
@@ -470,14 +490,20 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
470
490
|
getPublicReallocationLiquidity(marketId: MarketId, options?: VaultV2BluePublicAllocatorOptions): bigint;
|
|
471
491
|
/**
|
|
472
492
|
* Computes borrow liquidity to a target utilization, including friendly
|
|
473
|
-
* Vault V2 public reallocations.
|
|
493
|
+
* Vault V2 public reallocations. Market/vault state and returned post-state
|
|
494
|
+
* stay at `timestamp`; only target-market cap checks reserve interest on the
|
|
495
|
+
* vault's existing allocation through `timestamp + capAccrualBuffer` (two
|
|
496
|
+
* hours by default; `0n` disables). For market-source reallocations the
|
|
497
|
+
* source position's interest is also reserved on cap ids shared with the
|
|
498
|
+
* target, and reserves persist across every leg of a plan.
|
|
474
499
|
*
|
|
475
500
|
* @param marketId - Target Blue market id.
|
|
476
501
|
* @param utilization - Desired utilization, scaled by WAD. Defaults to 90%.
|
|
477
|
-
* @param options - Optional timestamp, enable flag, vault
|
|
502
|
+
* @param options - Optional timestamp, cap-accrual buffer, enable flag, vault
|
|
503
|
+
* allowlist, source utilization ceiling, and maximum penalty.
|
|
478
504
|
* @returns Borrowable assets while remaining at or below `utilization`; rounding-only shared-cap fits may be conservatively omitted.
|
|
479
505
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
480
|
-
* @throws {NegativeInputError} when `maxWithdrawalUtilization
|
|
506
|
+
* @throws {NegativeInputError} when `capAccrualBuffer`, `maxWithdrawalUtilization`, or `maxPenalty` is negative.
|
|
481
507
|
* @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
|
|
482
508
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
483
509
|
* @throws {UnknownReallocationVaultError} when configured vault state is absent.
|