@morpho-org/morpho-sdk 9.1.0 → 9.2.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 +4 -0
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +3 -1
- package/lib/cjs/blue/constants.d.ts +1 -1
- package/lib/cjs/blue/constants.js +2 -1
- package/lib/cjs/constants.d.ts +2 -2
- package/lib/cjs/constants.js +4 -1
- package/lib/cjs/entities/blue/blue.d.ts +71 -16
- package/lib/cjs/entities/blue/blue.js +32 -4
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -1
- package/lib/cjs/entities/midnight/midnight.js +5 -4
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +8 -0
- package/lib/cjs/entities/vaultV1/vaultV1.js +5 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +4 -0
- package/lib/cjs/entities/vaultV2/vaultV2.js +3 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +37 -4
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +197 -32
- package/lib/cjs/helpers/constant.d.ts +7 -0
- package/lib/cjs/helpers/constant.js +8 -1
- package/lib/cjs/helpers/deadShares.d.ts +82 -0
- package/lib/cjs/helpers/deadShares.js +200 -0
- package/lib/cjs/helpers/index.d.ts +2 -1
- package/lib/cjs/helpers/index.js +7 -1
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -1
- package/lib/cjs/types/error.d.ts +54 -5
- package/lib/cjs/types/error.js +60 -6
- package/lib/cjs/types/sharedLiquidity.d.ts +10 -6
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/blue/constants.d.ts +1 -1
- package/lib/esm/blue/constants.js +1 -1
- package/lib/esm/constants.d.ts +2 -2
- package/lib/esm/constants.js +2 -2
- package/lib/esm/entities/blue/blue.d.ts +71 -16
- package/lib/esm/entities/blue/blue.js +34 -6
- package/lib/esm/entities/midnight/midnight.d.ts +2 -1
- package/lib/esm/entities/midnight/midnight.js +6 -5
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +8 -0
- package/lib/esm/entities/vaultV1/vaultV1.js +5 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +4 -0
- package/lib/esm/entities/vaultV2/vaultV2.js +3 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +37 -4
- package/lib/esm/entities/vaultV2BlueReallocationData.js +197 -32
- package/lib/esm/helpers/constant.d.ts +7 -0
- package/lib/esm/helpers/constant.js +7 -0
- package/lib/esm/helpers/deadShares.d.ts +82 -0
- package/lib/esm/helpers/deadShares.js +195 -0
- package/lib/esm/helpers/index.d.ts +2 -1
- package/lib/esm/helpers/index.js +2 -1
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/types/error.d.ts +54 -5
- package/lib/esm/types/error.js +57 -5
- package/lib/esm/types/sharedLiquidity.d.ts +10 -6
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -24,6 +24,10 @@ General Vault V1 operations remain supported.
|
|
|
24
24
|
pnpm add @morpho-org/morpho-sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
Read [Adopting dead-share protection](./DEAD-SHARE-PROTECTION.md) for the protected Blue `supply`
|
|
28
|
+
overload and the dead-deposit checks on supply and deposit flows. Snapshot-free Blue `supply`
|
|
29
|
+
is deprecated but remains unprotected during the deprecation minor.
|
|
30
|
+
|
|
27
31
|
Upgrading from v8? Read the [v8 → v9 migration guide](./MIGRATION-v8-to-v9.md) for the approval
|
|
28
32
|
API removals and the new unlimited-approval behavior.
|
|
29
33
|
|
package/lib/cjs/abis.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi,
|
|
|
4
4
|
preLiquidationAbi as bluePreLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
6
|
preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
7
|
-
export { blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
7
|
+
export { blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi as midnightEcrecoverAuthorizerAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
8
8
|
/** ABI for the VaultExitBundlesV1 periphery contract. */
|
|
9
9
|
export declare const vaultExitBundlesV1Abi: readonly [{
|
|
10
10
|
readonly type: "constructor";
|
package/lib/cjs/abis.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightBlueBuyCallbackFactoryAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = void 0;
|
|
3
|
+
exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightEcrecoverAuthorizerAbi = exports.midnightBlueBuyCallbackFactoryAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "blueMarketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
|
|
6
6
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
@@ -31,9 +31,11 @@ Object.defineProperty(exports, "wrappedBackedTokenAbi", { enumerable: true, get:
|
|
|
31
31
|
Object.defineProperty(exports, "wstEthAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.wstEthAbi; } });
|
|
32
32
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
33
33
|
Object.defineProperty(exports, "midnightBlueBuyCallbackFactoryAbi", { enumerable: true, get: function () { return midnight_sdk_1.blueBuyCallbackFactoryAbi; } });
|
|
34
|
+
Object.defineProperty(exports, "midnightEcrecoverAuthorizerAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverAuthorizerAbi; } });
|
|
34
35
|
Object.defineProperty(exports, "midnightEcrecoverRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverRatifierAbi; } });
|
|
35
36
|
Object.defineProperty(exports, "midnightAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightAbi; } });
|
|
36
37
|
Object.defineProperty(exports, "midnightBundlesV2Abi", { enumerable: true, get: function () { return midnight_sdk_1.midnightBundlesV2Abi; } });
|
|
38
|
+
Object.defineProperty(exports, "midnightEventsAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightEventsAbi; } });
|
|
37
39
|
Object.defineProperty(exports, "midnightPriceRatifierV1Abi", { enumerable: true, get: function () { return midnight_sdk_1.priceRatifierV1Abi; } });
|
|
38
40
|
Object.defineProperty(exports, "midnightRateRatifierV1Abi", { enumerable: true, get: function () { return midnight_sdk_1.rateRatifierV1Abi; } });
|
|
39
41
|
Object.defineProperty(exports, "midnightSetterRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.setterRatifierAbi; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId, LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType, } from "@morpho-org/blue-sdk";
|
|
1
|
+
export { DEAD_ADDRESS, DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId, LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType, } from "@morpho-org/blue-sdk";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.LIQUIDATION_CURSOR = exports.isMarketId = exports.ERC20_ALLOWANCE_RECIPIENTS = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = void 0;
|
|
3
|
+
exports.TransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.LIQUIDATION_CURSOR = exports.isMarketId = exports.ERC20_ALLOWANCE_RECIPIENTS = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = exports.DEAD_ADDRESS = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
+
Object.defineProperty(exports, "DEAD_ADDRESS", { enumerable: true, get: function () { return blue_sdk_1.DEAD_ADDRESS; } });
|
|
5
6
|
Object.defineProperty(exports, "DEFAULT_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE; } });
|
|
6
7
|
Object.defineProperty(exports, "EIP_712_FIELDS", { enumerable: true, get: function () { return blue_sdk_1.EIP_712_FIELDS; } });
|
|
7
8
|
Object.defineProperty(exports, "ERC20_ALLOWANCE_RECIPIENTS", { enumerable: true, get: function () { return blue_sdk_1.ERC20_ALLOWANCE_RECIPIENTS; } });
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
1
|
+
export { DEAD_ADDRESS, 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_ALLOCATOR_CAP_HEADROOM, 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, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, } from "./helpers/constant.js";
|
|
4
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, 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, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, } from "./helpers/constant.js";
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = 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.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.APPROVE_ONLY_ONCE_TOKENS = exports.ZERO_ADDRESS = exports.REWARDS_BASE_URL = exports.MORPHO_DOMAIN = exports.DOCS_BASE_URL = exports.ChainUtils = exports.ChainId = exports.BLUE_API_GRAPHQL_URL = exports.BLUE_API_BASE_URL = exports.MIDNIGHT_TIME_TO_MAX_LIF = exports.MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS = exports.MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH = exports.MIDNIGHT_PRICE_ROUNDING_STEP = exports.MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH = exports.MIDNIGHT_OFFER_TYPEHASH = exports.MIDNIGHT_MAX_TREE_HEIGHT = exports.MIDNIGHT_MAX_TICK = exports.MIDNIGHT_MAX_SETTLEMENT_FEES = exports.MIDNIGHT_MAX_OFFER_CAP = exports.MIDNIGHT_MAX_CONTINUOUS_FEE = exports.MIDNIGHT_MAX_COLLATERALS_PER_BORROWER = exports.MIDNIGHT_MAX_COLLATERALS = exports.MIDNIGHT_MARKET_TYPEHASH = exports.MIDNIGHT_EIP712_DOMAIN_TYPEHASH = exports.MIDNIGHT_DEFAULT_TICK_SPACING = exports.MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH = exports.MIDNIGHT_CBP = exports.BlueTransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.BLUE_LIQUIDATION_CURSOR = exports.isBlueMarketId = exports.ERC20_ALLOWANCE_RECIPIENTS = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = void 0;
|
|
3
|
+
exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = 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.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.APPROVE_ONLY_ONCE_TOKENS = exports.ZERO_ADDRESS = exports.REWARDS_BASE_URL = exports.MORPHO_DOMAIN = exports.DOCS_BASE_URL = exports.ChainUtils = exports.ChainId = exports.BLUE_API_GRAPHQL_URL = exports.BLUE_API_BASE_URL = exports.MIDNIGHT_TIME_TO_MAX_LIF = exports.MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS = exports.MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH = exports.MIDNIGHT_PRICE_ROUNDING_STEP = exports.MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH = exports.MIDNIGHT_OFFER_TYPEHASH = exports.MIDNIGHT_MAX_TREE_HEIGHT = exports.MIDNIGHT_MAX_TICK = exports.MIDNIGHT_MAX_SETTLEMENT_FEES = exports.MIDNIGHT_MAX_OFFER_CAP = exports.MIDNIGHT_MAX_CONTINUOUS_FEE = exports.MIDNIGHT_MAX_COLLATERALS_PER_BORROWER = exports.MIDNIGHT_MAX_COLLATERALS = exports.MIDNIGHT_MARKET_TYPEHASH = exports.MIDNIGHT_EIP712_DOMAIN_TYPEHASH = exports.MIDNIGHT_DEFAULT_TICK_SPACING = exports.MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH = exports.MIDNIGHT_CBP = exports.BlueTransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.BLUE_LIQUIDATION_CURSOR = exports.isBlueMarketId = exports.ERC20_ALLOWANCE_RECIPIENTS = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = exports.DEAD_ADDRESS = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
+
Object.defineProperty(exports, "DEAD_ADDRESS", { enumerable: true, get: function () { return blue_sdk_1.DEAD_ADDRESS; } });
|
|
5
6
|
Object.defineProperty(exports, "DEFAULT_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE; } });
|
|
6
7
|
Object.defineProperty(exports, "EIP_712_FIELDS", { enumerable: true, get: function () { return blue_sdk_1.EIP_712_FIELDS; } });
|
|
7
8
|
Object.defineProperty(exports, "ERC20_ALLOWANCE_RECIPIENTS", { enumerable: true, get: function () { return blue_sdk_1.ERC20_ALLOWANCE_RECIPIENTS; } });
|
|
@@ -52,3 +53,5 @@ Object.defineProperty(exports, "MAX_REALLOCATION_PENALTY", { enumerable: true, g
|
|
|
52
53
|
Object.defineProperty(exports, "MAX_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return constant_js_1.MAX_SLIPPAGE_TOLERANCE; } });
|
|
53
54
|
Object.defineProperty(exports, "MAX_TOKEN_APPROVALS", { enumerable: true, get: function () { return constant_js_1.MAX_TOKEN_APPROVALS; } });
|
|
54
55
|
Object.defineProperty(exports, "MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS", { enumerable: true, get: function () { return constant_js_1.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS; } });
|
|
56
|
+
Object.defineProperty(exports, "MIN_DEAD_SHARES", { enumerable: true, get: function () { return constant_js_1.MIN_DEAD_SHARES; } });
|
|
57
|
+
Object.defineProperty(exports, "MIN_VAULT_V2_DEAD_ASSETS", { enumerable: true, get: function () { return constant_js_1.MIN_VAULT_V2_DEAD_ASSETS; } });
|
|
@@ -150,6 +150,8 @@ export interface BlueActions {
|
|
|
150
150
|
* share-price bound or `slippageTolerance`.
|
|
151
151
|
*
|
|
152
152
|
* @param params.userAddress - User funding and receiving the supply position.
|
|
153
|
+
* @param params.marketData - Snapshot of this market from `getMarketData()` (or `fetchMarket` in
|
|
154
|
+
* `@morpho-org/blue-sdk-viem`), used to check its dead deposit before building.
|
|
153
155
|
* @param params.assets - Gross loan-token assets funded before the referral fee.
|
|
154
156
|
* @param params.nativeAmount - Optional full native funding; must equal `assets` and requires wNative.
|
|
155
157
|
* @param params.deadline - Final call deadline in Unix seconds.
|
|
@@ -177,6 +179,9 @@ export interface BlueActions {
|
|
|
177
179
|
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
|
|
178
180
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
179
181
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
182
|
+
* @throws {MarketIdMismatchError} when `marketData` belongs to another market.
|
|
183
|
+
* @throws {MissingDeadSharesDataError} when `marketData` has no `deadSupplyShares`.
|
|
184
|
+
* @throws {InsufficientDeadSharesError} when the market holds fewer than `MIN_DEAD_SHARES` supply shares at `DEAD_ADDRESS`.
|
|
180
185
|
* @throws {UnknownTokenError} from `getRequirements()` when the funded token's `decimals()` is unusable.
|
|
181
186
|
* @throws {MalformedTokenMetadataError} when the token's `eip712Domain()` or
|
|
182
187
|
* `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
|
|
@@ -198,6 +203,7 @@ export interface BlueActions {
|
|
|
198
203
|
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
199
204
|
* const action = market.supply({
|
|
200
205
|
* userAddress,
|
|
206
|
+
* marketData: await market.getMarketData(),
|
|
201
207
|
* assets: 1_000_000n,
|
|
202
208
|
* deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
|
|
203
209
|
* });
|
|
@@ -206,14 +212,29 @@ export interface BlueActions {
|
|
|
206
212
|
* // tx satisfies Readonly<Transaction<BlueSupplyAction>>
|
|
207
213
|
* ```
|
|
208
214
|
*/
|
|
209
|
-
supply:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
supply: {
|
|
216
|
+
(params: {
|
|
217
|
+
readonly userAddress: Address;
|
|
218
|
+
readonly marketData: Market;
|
|
219
|
+
readonly assets: bigint;
|
|
220
|
+
readonly nativeAmount?: bigint;
|
|
221
|
+
readonly deadline: bigint;
|
|
222
|
+
readonly referralFeePct?: bigint;
|
|
223
|
+
readonly referralFeeRecipient?: Address;
|
|
224
|
+
}): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
|
|
225
|
+
/**
|
|
226
|
+
* @deprecated Pass `marketData` from `getMarketData()` to check the dead deposit.
|
|
227
|
+
* Snapshot-free supply is unprotected and will be removed in the next major after one minor.
|
|
228
|
+
*/
|
|
229
|
+
(params: {
|
|
230
|
+
readonly userAddress: Address;
|
|
231
|
+
readonly assets: bigint;
|
|
232
|
+
readonly nativeAmount?: bigint;
|
|
233
|
+
readonly deadline: bigint;
|
|
234
|
+
readonly referralFeePct?: bigint;
|
|
235
|
+
readonly referralFeeRecipient?: Address;
|
|
236
|
+
}): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
|
|
237
|
+
};
|
|
217
238
|
/**
|
|
218
239
|
* Prepares a direct BlueBundlesV1 loan-asset withdrawal by assets or shares.
|
|
219
240
|
*
|
|
@@ -847,6 +868,13 @@ export interface BlueActions {
|
|
|
847
868
|
* Reads the target Morpho Blue market, each Vault V2 accrual tree, and each
|
|
848
869
|
* vault's BluePublicAllocator permissions and allocation caps at one block.
|
|
849
870
|
* The snapshot keeps the fetched block's timestamp as its default planning time.
|
|
871
|
+
* It always records Blue's loan-token balance in `blueBalances` at that
|
|
872
|
+
* block, so balance-based rejection applies to plans from this fetcher.
|
|
873
|
+
* Sizing has zero margin over that snapshot balance; activity on other Blue
|
|
874
|
+
* markets with the same loan token can make a plan revert. Refetch close to
|
|
875
|
+
* submission; there is no balance-buffer option.
|
|
876
|
+
* Hand-built data without a balance uses summed snapshot-market liquidity
|
|
877
|
+
* only to size plans and may add about the penalty in extra paid assets.
|
|
850
878
|
*
|
|
851
879
|
* @param params.vaultAddresses - Vault V2 addresses to inspect for market or idle liquidity.
|
|
852
880
|
* @param params.block.number - Block number used for every RPC read.
|
|
@@ -885,6 +913,11 @@ export interface BlueActions {
|
|
|
885
913
|
* persist across every leg of a plan. Operation plans keep
|
|
886
914
|
* `allocatorCapHeadroom` (1% of the cap by default) free under each target
|
|
887
915
|
* BluePublicAllocator cap unless the operation shortfall needs it.
|
|
916
|
+
* With an explicit `blueBalances` value, plans are rejected when Blue cannot
|
|
917
|
+
* fund the penalty flash loan, an earlier market-sourced withdrawal, or the
|
|
918
|
+
* final transfer. A missing balance uses summed snapshot-market liquidity
|
|
919
|
+
* only to size plans and may make them larger; it cannot cause a balance-based
|
|
920
|
+
* rejection.
|
|
888
921
|
* For `refinance`, compute the plan on the destination-market handle (for
|
|
889
922
|
* example, `client.morpho.blue(destination.marketParams, chainId)`), not the
|
|
890
923
|
* source-market handle. Pass the source position's `borrowAssets` accrued to
|
|
@@ -900,7 +933,7 @@ export interface BlueActions {
|
|
|
900
933
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
901
934
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
902
935
|
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
|
|
903
|
-
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD.
|
|
936
|
+
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD, or a selected borrow/withdraw plan otherwise covers its shortfall but its planned penalty exceeds the operation amount.
|
|
904
937
|
* @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
|
|
905
938
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
906
939
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
@@ -911,7 +944,7 @@ export interface BlueActions {
|
|
|
911
944
|
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
912
945
|
* @throws {ReallocationAdapterSupplySharesUnderflowError} when an inconsistent adapter snapshot underflows during the final transition.
|
|
913
946
|
* @throws {ReallocationAllocationUnderflowError} when an inconsistent allocation snapshot underflows during the final transition.
|
|
914
|
-
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the shortfall
|
|
947
|
+
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the operation shortfall or refinance penalties, or an explicit Blue balance cannot fund a required transfer.
|
|
915
948
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
916
949
|
* @example
|
|
917
950
|
* ```ts
|
|
@@ -961,15 +994,25 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
961
994
|
/** {@inheritDoc BlueActions.supply} */
|
|
962
995
|
supply(params: {
|
|
963
996
|
readonly userAddress: Address;
|
|
997
|
+
readonly marketData: Market;
|
|
964
998
|
readonly assets: bigint;
|
|
965
999
|
readonly nativeAmount?: bigint;
|
|
966
1000
|
readonly deadline: bigint;
|
|
967
1001
|
readonly referralFeePct?: bigint;
|
|
968
1002
|
readonly referralFeeRecipient?: Address;
|
|
969
|
-
}):
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1003
|
+
}): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
|
|
1004
|
+
/**
|
|
1005
|
+
* @deprecated Pass `marketData` from `getMarketData()` to check the dead deposit.
|
|
1006
|
+
* Snapshot-free supply is unprotected and will be removed in the next major after one minor.
|
|
1007
|
+
*/
|
|
1008
|
+
supply(params: {
|
|
1009
|
+
readonly userAddress: Address;
|
|
1010
|
+
readonly assets: bigint;
|
|
1011
|
+
readonly nativeAmount?: bigint;
|
|
1012
|
+
readonly deadline: bigint;
|
|
1013
|
+
readonly referralFeePct?: bigint;
|
|
1014
|
+
readonly referralFeeRecipient?: Address;
|
|
1015
|
+
}): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
|
|
973
1016
|
/** {@inheritDoc BlueActions.withdraw} */
|
|
974
1017
|
withdraw(params: {
|
|
975
1018
|
readonly userAddress: Address;
|
|
@@ -1084,6 +1127,13 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1084
1127
|
* Reads the target Morpho Blue market, each Vault V2 accrual tree, and each
|
|
1085
1128
|
* vault's BluePublicAllocator permissions and allocation caps at one block.
|
|
1086
1129
|
* The snapshot keeps the fetched block's timestamp as its default planning time.
|
|
1130
|
+
* It always records Blue's loan-token balance in `blueBalances` at that
|
|
1131
|
+
* block, so balance-based rejection applies to plans from this fetcher.
|
|
1132
|
+
* Sizing has zero margin over that snapshot balance; activity on other Blue
|
|
1133
|
+
* markets with the same loan token can make a plan revert. Refetch close to
|
|
1134
|
+
* submission; there is no balance-buffer option.
|
|
1135
|
+
* Hand-built data without a balance uses summed snapshot-market liquidity
|
|
1136
|
+
* only to size plans and may add about the penalty in extra paid assets.
|
|
1087
1137
|
*
|
|
1088
1138
|
* @param params.vaultAddresses - Vault V2 addresses to inspect for market or idle liquidity.
|
|
1089
1139
|
* @param params.block.number - Block number used for every RPC read.
|
|
@@ -1141,6 +1191,11 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1141
1191
|
* persist across every leg of a plan. Operation plans keep
|
|
1142
1192
|
* `allocatorCapHeadroom` (1% of the cap by default) free under each target
|
|
1143
1193
|
* BluePublicAllocator cap unless the operation shortfall needs it.
|
|
1194
|
+
* With an explicit `blueBalances` value, plans are rejected when Blue cannot
|
|
1195
|
+
* fund the penalty flash loan, an earlier market-sourced withdrawal, or the
|
|
1196
|
+
* final transfer. A missing balance uses summed snapshot-market liquidity
|
|
1197
|
+
* only to size plans and may make them larger; it cannot cause a balance-based
|
|
1198
|
+
* rejection.
|
|
1144
1199
|
* For `refinance`, compute the plan on the destination-market handle (for
|
|
1145
1200
|
* example, `client.morpho.blue(destination.marketParams, chainId)`), not the
|
|
1146
1201
|
* source-market handle. Pass the source position's `borrowAssets` accrued to
|
|
@@ -1156,7 +1211,7 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1156
1211
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
1157
1212
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
1158
1213
|
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
|
|
1159
|
-
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD.
|
|
1214
|
+
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD, or a selected borrow/withdraw plan otherwise covers its shortfall but its planned penalty exceeds the operation amount.
|
|
1160
1215
|
* @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
|
|
1161
1216
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
1162
1217
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
@@ -1167,7 +1222,7 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1167
1222
|
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
1168
1223
|
* @throws {ReallocationAdapterSupplySharesUnderflowError} when an inconsistent adapter snapshot underflows during the final transition.
|
|
1169
1224
|
* @throws {ReallocationAllocationUnderflowError} when an inconsistent allocation snapshot underflows during the final transition.
|
|
1170
|
-
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the shortfall
|
|
1225
|
+
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the operation shortfall or refinance penalties, or an explicit Blue balance cannot fund a required transfer.
|
|
1171
1226
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
1172
1227
|
* @example
|
|
1173
1228
|
* ```ts
|
|
@@ -5,9 +5,11 @@ 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 common_js_1 = require("../../actions/blue/common.js");
|
|
9
10
|
const index_js_1 = require("../../actions/index.js");
|
|
10
11
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
12
|
+
const deadShares_js_1 = require("../../helpers/deadShares.js");
|
|
11
13
|
const index_js_2 = require("../../helpers/index.js");
|
|
12
14
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
13
15
|
const index_js_3 = require("../../types/index.js");
|
|
@@ -127,7 +129,6 @@ class MorphoBlue {
|
|
|
127
129
|
deployless: this.client.options.supportDeployless,
|
|
128
130
|
});
|
|
129
131
|
}
|
|
130
|
-
/** {@inheritDoc BlueActions.supply} */
|
|
131
132
|
supply(params) {
|
|
132
133
|
const { userAddress, assets, nativeAmount, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
133
134
|
this.validateWriteCommon(params);
|
|
@@ -139,6 +140,13 @@ class MorphoBlue {
|
|
|
139
140
|
fundedAmount: assets,
|
|
140
141
|
nativeAmount,
|
|
141
142
|
});
|
|
143
|
+
if (params.marketData != null) {
|
|
144
|
+
if (params.marketData.id !== this.marketParams.id) {
|
|
145
|
+
throw new index_js_3.MarketIdMismatchError(params.marketData.id, this.marketParams.id);
|
|
146
|
+
}
|
|
147
|
+
// Throws when the market lacks a sufficient dead deposit; nothing to return.
|
|
148
|
+
(0, deadShares_js_1.validateBlueMarketDeadShares)(params.marketData);
|
|
149
|
+
}
|
|
142
150
|
return {
|
|
143
151
|
getRequirements: (requirementsParams) => {
|
|
144
152
|
const now = morpho_ts_1.Time.timestamp();
|
|
@@ -735,6 +743,13 @@ class MorphoBlue {
|
|
|
735
743
|
* Reads the target Morpho Blue market, each Vault V2 accrual tree, and each
|
|
736
744
|
* vault's BluePublicAllocator permissions and allocation caps at one block.
|
|
737
745
|
* The snapshot keeps the fetched block's timestamp as its default planning time.
|
|
746
|
+
* It always records Blue's loan-token balance in `blueBalances` at that
|
|
747
|
+
* block, so balance-based rejection applies to plans from this fetcher.
|
|
748
|
+
* Sizing has zero margin over that snapshot balance; activity on other Blue
|
|
749
|
+
* markets with the same loan token can make a plan revert. Refetch close to
|
|
750
|
+
* submission; there is no balance-buffer option.
|
|
751
|
+
* Hand-built data without a balance uses summed snapshot-market liquidity
|
|
752
|
+
* only to size plans and may add about the penalty in extra paid assets.
|
|
738
753
|
*
|
|
739
754
|
* @param params.vaultAddresses - Vault V2 addresses to inspect for market or idle liquidity.
|
|
740
755
|
* @param params.block.number - Block number used for every RPC read.
|
|
@@ -783,7 +798,7 @@ class MorphoBlue {
|
|
|
783
798
|
chainId: this.chainId,
|
|
784
799
|
deployless: this.client.options.supportDeployless,
|
|
785
800
|
};
|
|
786
|
-
const [targetMarket, vaultEntries] = await Promise.all([
|
|
801
|
+
const [targetMarket, vaultEntries, blueBalance] = await Promise.all([
|
|
787
802
|
(0, blue_sdk_viem_1.fetchMarket)(this.marketParams.id, client, fetchParams),
|
|
788
803
|
Promise.all(vaultAddresses.map(async (address) => {
|
|
789
804
|
const vault = await (0, blue_sdk_viem_1.fetchAccrualVaultV2)(address, client, fetchParams);
|
|
@@ -793,10 +808,18 @@ class MorphoBlue {
|
|
|
793
808
|
});
|
|
794
809
|
return { publicAllocatorData, vault };
|
|
795
810
|
})),
|
|
811
|
+
(0, actions_1.readContract)(client, {
|
|
812
|
+
address: this.marketParams.loanToken,
|
|
813
|
+
abi: viem_1.erc20Abi,
|
|
814
|
+
functionName: "balanceOf",
|
|
815
|
+
args: [(0, morpho_ts_1.getChainAddresses)(this.chainId).blue],
|
|
816
|
+
blockNumber: block.number,
|
|
817
|
+
}),
|
|
796
818
|
]);
|
|
797
819
|
return new vaultV2BlueReallocationData_js_1.VaultV2BlueReallocationData({
|
|
798
820
|
chainId: this.chainId,
|
|
799
821
|
timestamp: block.timestamp,
|
|
822
|
+
blueBalances: { [this.marketParams.loanToken]: blueBalance },
|
|
800
823
|
markets: { [targetMarket.id]: targetMarket },
|
|
801
824
|
vaults: Object.fromEntries(vaultEntries.map(({ vault }) => [vault.address, vault])),
|
|
802
825
|
allocations: Object.fromEntries(vaultEntries.map(({ publicAllocatorData, vault }) => [
|
|
@@ -827,6 +850,11 @@ class MorphoBlue {
|
|
|
827
850
|
* persist across every leg of a plan. Operation plans keep
|
|
828
851
|
* `allocatorCapHeadroom` (1% of the cap by default) free under each target
|
|
829
852
|
* BluePublicAllocator cap unless the operation shortfall needs it.
|
|
853
|
+
* With an explicit `blueBalances` value, plans are rejected when Blue cannot
|
|
854
|
+
* fund the penalty flash loan, an earlier market-sourced withdrawal, or the
|
|
855
|
+
* final transfer. A missing balance uses summed snapshot-market liquidity
|
|
856
|
+
* only to size plans and may make them larger; it cannot cause a balance-based
|
|
857
|
+
* rejection.
|
|
830
858
|
* For `refinance`, compute the plan on the destination-market handle (for
|
|
831
859
|
* example, `client.morpho.blue(destination.marketParams, chainId)`), not the
|
|
832
860
|
* source-market handle. Pass the source position's `borrowAssets` accrued to
|
|
@@ -842,7 +870,7 @@ class MorphoBlue {
|
|
|
842
870
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
843
871
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
844
872
|
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
|
|
845
|
-
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD.
|
|
873
|
+
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD, or a selected borrow/withdraw plan otherwise covers its shortfall but its planned penalty exceeds the operation amount.
|
|
846
874
|
* @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
|
|
847
875
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
848
876
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
@@ -853,7 +881,7 @@ class MorphoBlue {
|
|
|
853
881
|
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
854
882
|
* @throws {ReallocationAdapterSupplySharesUnderflowError} when an inconsistent adapter snapshot underflows during the final transition.
|
|
855
883
|
* @throws {ReallocationAllocationUnderflowError} when an inconsistent allocation snapshot underflows during the final transition.
|
|
856
|
-
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the shortfall
|
|
884
|
+
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the operation shortfall or refinance penalties, or an explicit Blue balance cannot fund a required transfer.
|
|
857
885
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
858
886
|
* @example
|
|
859
887
|
* ```ts
|
|
@@ -848,7 +848,8 @@ export declare class MorphoMidnight {
|
|
|
848
848
|
* @throws {MidnightMarketLiquidationCursorNotEnabledError} when an uncreated market uses a disabled liquidation cursor.
|
|
849
849
|
* @throws {MidnightMarketOracleWithoutCodeError} when an uncreated market's oracle has no code.
|
|
850
850
|
* @throws {viem.BaseError} when a pinned block, multicall, or oracle-code read fails.
|
|
851
|
-
* @throws {
|
|
851
|
+
* @throws {MissingDeadSharesDataError} when the fetched `blueMarket` snapshot has no `deadSupplyShares`.
|
|
852
|
+
* @throws {InsufficientDeadSharesError} when `blueMarket` holds fewer than `MIN_DEAD_SHARES` supply shares at `DEAD_ADDRESS`.
|
|
852
853
|
* @throws {ZeroBlueParkingSharesError} when `assetsToPark` would mint no supply shares at the current share price (checked at preparation time only).
|
|
853
854
|
* @throws {MidnightReplacementGroupCancelledError} when a published group is also cancelled.
|
|
854
855
|
* @throws {InvalidMidnightHexInputError} when a cancellation group or `callbackSalt` is not 32-byte hex.
|
|
@@ -11,6 +11,7 @@ const index_js_2 = require("../../actions/requirements/index.js");
|
|
|
11
11
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
12
12
|
const callback_js_1 = require("../../helpers/callback.js");
|
|
13
13
|
const constant_js_1 = require("../../helpers/constant.js");
|
|
14
|
+
const deadShares_js_1 = require("../../helpers/deadShares.js");
|
|
14
15
|
const encodeMidnightCalldata_js_1 = require("../../helpers/encodeMidnightCalldata.js");
|
|
15
16
|
const index_js_3 = require("../../helpers/index.js");
|
|
16
17
|
const validateMidnightAccount_js_1 = require("../../helpers/validateMidnightAccount.js");
|
|
@@ -1438,7 +1439,8 @@ class MorphoMidnight {
|
|
|
1438
1439
|
* @throws {MidnightMarketLiquidationCursorNotEnabledError} when an uncreated market uses a disabled liquidation cursor.
|
|
1439
1440
|
* @throws {MidnightMarketOracleWithoutCodeError} when an uncreated market's oracle has no code.
|
|
1440
1441
|
* @throws {viem.BaseError} when a pinned block, multicall, or oracle-code read fails.
|
|
1441
|
-
* @throws {
|
|
1442
|
+
* @throws {MissingDeadSharesDataError} when the fetched `blueMarket` snapshot has no `deadSupplyShares`.
|
|
1443
|
+
* @throws {InsufficientDeadSharesError} when `blueMarket` holds fewer than `MIN_DEAD_SHARES` supply shares at `DEAD_ADDRESS`.
|
|
1442
1444
|
* @throws {ZeroBlueParkingSharesError} when `assetsToPark` would mint no supply shares at the current share price (checked at preparation time only).
|
|
1443
1445
|
* @throws {MidnightReplacementGroupCancelledError} when a published group is also cancelled.
|
|
1444
1446
|
* @throws {InvalidMidnightHexInputError} when a cancellation group or `callbackSalt` is not 32-byte hex.
|
|
@@ -1494,9 +1496,8 @@ class MorphoMidnight {
|
|
|
1494
1496
|
}),
|
|
1495
1497
|
]);
|
|
1496
1498
|
const market = (0, morpho_ts_1._try)(() => fetched.accrueInterest(blue_sdk_1.MathLib.max(morpho_ts_1.Time.timestamp(), fetched.lastUpdate)), blue_sdk_1.UnsupportedMarketIrmError) ?? fetched;
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
}
|
|
1499
|
+
// Throws when the parking market lacks a sufficient dead deposit; nothing to return.
|
|
1500
|
+
(0, deadShares_js_1.validateBlueMarketDeadShares)(fetched);
|
|
1500
1501
|
if (market.toSupplyShares(params.assetsToPark, "Down") === 0n) {
|
|
1501
1502
|
throw new index_js_4.ZeroBlueParkingSharesError({
|
|
1502
1503
|
marketId: blueMarketId,
|
|
@@ -104,6 +104,10 @@ export interface VaultV1Actions {
|
|
|
104
104
|
* const tx = action.buildTx(); // For a client configured with supportSignature: false.
|
|
105
105
|
* // tx satisfies Readonly<Transaction<VaultV1DepositAction>>
|
|
106
106
|
* ```
|
|
107
|
+
* @throws {MissingDeadSharesDataError} when `vaultData` lacks the dead-share, cap or adapter data
|
|
108
|
+
* the dead-deposit check needs, such as a hand-built or API-sourced snapshot.
|
|
109
|
+
* @throws {InsufficientDeadSharesError} when the vault, or a market or vault it can allocate to,
|
|
110
|
+
* holds less than the required dead deposit.
|
|
107
111
|
*/
|
|
108
112
|
deposit: (params: {
|
|
109
113
|
readonly userAddress: Address;
|
|
@@ -457,6 +461,10 @@ export interface VaultV1Actions {
|
|
|
457
461
|
* const tx = migration.buildTx(signatures);
|
|
458
462
|
* // tx satisfies Readonly<Transaction<VaultV1MigrateToV2Action>>
|
|
459
463
|
* ```
|
|
464
|
+
* @throws {MissingDeadSharesDataError} when `targetVault` lacks the dead-share, cap or adapter data
|
|
465
|
+
* the dead-deposit check needs. The source Vault V1 is not checked.
|
|
466
|
+
* @throws {InsufficientDeadSharesError} when `targetVault`, or a market or vault it can allocate
|
|
467
|
+
* to, holds less than the required dead deposit.
|
|
460
468
|
*/
|
|
461
469
|
migrateToV2: (params: {
|
|
462
470
|
readonly userAddress: Address;
|
|
@@ -9,6 +9,7 @@ const actions_1 = require("viem/actions");
|
|
|
9
9
|
const common_js_1 = require("../../actions/bundles/common.js");
|
|
10
10
|
const index_js_1 = require("../../actions/index.js");
|
|
11
11
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
12
|
+
const deadShares_js_1 = require("../../helpers/deadShares.js");
|
|
12
13
|
const index_js_2 = require("../../helpers/index.js");
|
|
13
14
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
14
15
|
const index_js_3 = require("../../types/index.js");
|
|
@@ -78,6 +79,8 @@ class MorphoVaultV1 {
|
|
|
78
79
|
// The native path must target the chain's registered wrapped-native asset.
|
|
79
80
|
(0, validate_js_1.validateNativeVaultAsset)(this.chainId, vaultAsset);
|
|
80
81
|
}
|
|
82
|
+
// Throws when the vault, or a market it can allocate to, lacks a sufficient dead deposit.
|
|
83
|
+
(0, deadShares_js_1.validateVaultV1DeadShares)(vaultData);
|
|
81
84
|
const referralFeeAssets = (0, common_js_1.getBundlesReferralFeeAssets)(funding.assets, common.referralFeePct);
|
|
82
85
|
const maxSharePrice = (0, index_js_2.computeVaultMaxSharePrice)({
|
|
83
86
|
vaultData,
|
|
@@ -472,6 +475,8 @@ class MorphoVaultV1 {
|
|
|
472
475
|
referralFeePct: params.referralFeePct,
|
|
473
476
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
474
477
|
});
|
|
478
|
+
// Only the destination receives a deposit; the source vault is an exit.
|
|
479
|
+
(0, deadShares_js_1.validateVaultV2DeadShares)(params.targetVault);
|
|
475
480
|
// V1 redeem accrues market interest and performance fees before converting shares.
|
|
476
481
|
const grossAssets = assets ??
|
|
477
482
|
params.sourceVault
|
|
@@ -110,6 +110,10 @@ export interface VaultV2Actions {
|
|
|
110
110
|
* const tx = action.buildTx(); // For a client configured with supportSignature: false.
|
|
111
111
|
* // tx satisfies Readonly<Transaction<VaultV2DepositAction>>
|
|
112
112
|
* ```
|
|
113
|
+
* @throws {MissingDeadSharesDataError} when `vaultData` lacks the dead-share, cap or adapter data
|
|
114
|
+
* the dead-deposit check needs, such as a hand-built or API-sourced snapshot.
|
|
115
|
+
* @throws {InsufficientDeadSharesError} when the vault, or a market or vault it can allocate to,
|
|
116
|
+
* holds less than the required dead deposit.
|
|
113
117
|
*/
|
|
114
118
|
deposit: (params: {
|
|
115
119
|
readonly userAddress: Address;
|
|
@@ -9,6 +9,7 @@ const actions_1 = require("viem/actions");
|
|
|
9
9
|
const common_js_1 = require("../../actions/bundles/common.js");
|
|
10
10
|
const index_js_1 = require("../../actions/index.js");
|
|
11
11
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
12
|
+
const deadShares_js_1 = require("../../helpers/deadShares.js");
|
|
12
13
|
const index_js_2 = require("../../helpers/index.js");
|
|
13
14
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
14
15
|
const index_js_3 = require("../../types/index.js");
|
|
@@ -81,6 +82,8 @@ class MorphoVaultV2 {
|
|
|
81
82
|
// The native path must target the chain's registered wrapped-native asset.
|
|
82
83
|
(0, validate_js_1.validateNativeVaultAsset)(this.chainId, vaultAsset);
|
|
83
84
|
}
|
|
85
|
+
// Throws when the vault, or a market it can allocate to, lacks a sufficient dead deposit.
|
|
86
|
+
(0, deadShares_js_1.validateVaultV2DeadShares)(vaultData);
|
|
84
87
|
const referralFeeAssets = (0, common_js_1.getBundlesReferralFeeAssets)(funding.assets, common.referralFeePct);
|
|
85
88
|
const maxSharePrice = (0, index_js_2.computeVaultMaxSharePrice)({
|
|
86
89
|
vaultData,
|
|
@@ -26,6 +26,16 @@ export interface InputVaultV2BlueReallocationData {
|
|
|
26
26
|
* defaults to the latest market/vault `lastUpdate`.
|
|
27
27
|
*/
|
|
28
28
|
readonly timestamp?: BigIntish;
|
|
29
|
+
/**
|
|
30
|
+
* Morpho Blue's ERC-20 balances at the snapshot block, indexed by token address.
|
|
31
|
+
* Explicit balances increase with idle-sourced reallocations in returned
|
|
32
|
+
* post-states. Sizing has zero margin over the snapshot balance, so activity
|
|
33
|
+
* on other Blue markets with the same loan token can make a plan revert;
|
|
34
|
+
* refetch close to submission. A missing token uses summed non-negative
|
|
35
|
+
* snapshot-market supply-minus-borrow only to size plans; balance-based
|
|
36
|
+
* rejection requires an explicit balance.
|
|
37
|
+
*/
|
|
38
|
+
readonly blueBalances?: Readonly<Record<Address, BigIntish | undefined>>;
|
|
29
39
|
/** Markets indexed by market id. */
|
|
30
40
|
readonly markets?: Readonly<Record<MarketId, ReadonlyMarketSnapshot | undefined>>;
|
|
31
41
|
/** Accrued Vault V2 entities indexed by vault address. */
|
|
@@ -83,10 +93,22 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
83
93
|
private readonly mutableVaults;
|
|
84
94
|
/** Mutable allocation state used only by cloned simulation transitions. */
|
|
85
95
|
private readonly mutableAllocations;
|
|
96
|
+
/** Mutable Blue token balances used only by cloned simulation transitions. */
|
|
97
|
+
private readonly mutableBlueBalances;
|
|
86
98
|
/** Chain id associated with this snapshot. */
|
|
87
99
|
readonly chainId: number;
|
|
88
100
|
/** Timestamp of the block the state was fetched at. */
|
|
89
101
|
readonly timestamp?: bigint;
|
|
102
|
+
/**
|
|
103
|
+
* Morpho Blue's ERC-20 balances at the snapshot block, indexed by token address.
|
|
104
|
+
* Explicit balances increase with idle-sourced reallocations in returned
|
|
105
|
+
* post-states. Sizing has zero margin over the snapshot balance, so activity
|
|
106
|
+
* on other Blue markets with the same loan token can make a plan revert;
|
|
107
|
+
* refetch close to submission. A missing token uses summed non-negative
|
|
108
|
+
* snapshot-market supply-minus-borrow only to size plans; balance-based
|
|
109
|
+
* rejection requires an explicit balance.
|
|
110
|
+
*/
|
|
111
|
+
readonly blueBalances: Readonly<Record<Address, bigint | undefined>>;
|
|
90
112
|
/** Markets indexed by market id. */
|
|
91
113
|
readonly markets: Readonly<Record<MarketId, ReadonlyMarketSnapshot | undefined>>;
|
|
92
114
|
/** Vault V2 entities indexed by address. */
|
|
@@ -367,8 +389,9 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
367
389
|
* Without `options.operation`, discovers every friendly call. With an
|
|
368
390
|
* operation, penalty tiers are considered ascending, starting with free
|
|
369
391
|
* vaults. The free tier aims to bring the target market back to 90%
|
|
370
|
-
* utilization; positive tiers cover
|
|
371
|
-
*
|
|
392
|
+
* utilization; positive tiers cover the remaining absolute shortfall or,
|
|
393
|
+
* when larger, Blue's loan-token balance deficit while the penalty is
|
|
394
|
+
* flash-loaned. Within each tier, source markets go to the
|
|
372
395
|
* friendly source utilization (90% by default) before 100%. Free capacity
|
|
373
396
|
* inside `allocatorCapHeadroom` is kept unused, so a penalized leg can cover
|
|
374
397
|
* it instead. Discovery and liquidity getters still count every vault up to
|
|
@@ -382,6 +405,16 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
382
405
|
* The planner includes the referral fee and its allocator-leg penalties in
|
|
383
406
|
* destination debt, so penalized legs also cover their own penalty.
|
|
384
407
|
* Refinance never uses vaults with a 100% penalty.
|
|
408
|
+
* BlueBundlesV1 flash-loans the plan's penalty from Blue before executing
|
|
409
|
+
* reallocation legs. When an explicit `blueBalances` value is supplied, plans
|
|
410
|
+
* throw `InsufficientSharedLiquidityError` if Blue cannot fund that flash
|
|
411
|
+
* loan or a market-sourced leg's withdrawal before later idle legs arrive.
|
|
412
|
+
* Legs are not reordered. A missing balance falls back to summed snapshot-
|
|
413
|
+
* market liquidity only to size plans and may make them larger; it cannot
|
|
414
|
+
* cause rejection for Blue-balance constraints.
|
|
415
|
+
* Sizing has zero margin over the snapshot balance; activity on other Blue
|
|
416
|
+
* markets with the same loan token can make a plan revert. Refetch close to
|
|
417
|
+
* submission; there is no balance-buffer option.
|
|
385
418
|
* Friendly source utilization defaults to 90% and is configurable through
|
|
386
419
|
* `options.maxWithdrawalUtilization`. Market/vault state and the returned
|
|
387
420
|
* post-state stay at `timestamp`. An enabled operation that needs no
|
|
@@ -429,7 +462,7 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
429
462
|
* @returns Flat action-ready reallocations and their post-simulation state.
|
|
430
463
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
431
464
|
* @throws {NegativeInputError} when `capAccrualBuffer`, `allocatorCapHeadroom`, `maxWithdrawalUtilization`, `maxPenalty`, or `referralFeePct` is negative.
|
|
432
|
-
* @throws {InputExceedsMaxError} when `allocatorCapHeadroom`, `maxWithdrawalUtilization`, or `maxPenalty` exceeds WAD.
|
|
465
|
+
* @throws {InputExceedsMaxError} when `allocatorCapHeadroom`, `maxWithdrawalUtilization`, or `maxPenalty` exceeds WAD, or an enabled borrow/withdraw plan otherwise covers its shortfall but its planned penalty exceeds the operation amount.
|
|
433
466
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
434
467
|
* @throws {NonPositiveInputError} when the operation amount is not positive and planning is enabled.
|
|
435
468
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
@@ -438,7 +471,7 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
438
471
|
* @throws {UnknownReallocationActiveAdaptersError} when active-adapter state is absent for a vault.
|
|
439
472
|
* @throws {UnknownReallocationMarketPublicAllocatorConfigError} when an adapter-market allocator configuration is absent.
|
|
440
473
|
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
441
|
-
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the
|
|
474
|
+
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the operation shortfall or refinance penalties, or an explicit Blue balance cannot fund the penalty flash loan, an earlier market-sourced withdrawal, or the final operation transfer.
|
|
442
475
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdraw exceeds market supply.
|
|
443
476
|
* @example
|
|
444
477
|
* ```ts
|