@morpho-org/morpho-sdk 9.1.0-next.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 +7 -1
- package/lib/cjs/abis.d.ts +2 -2
- package/lib/cjs/abis.js +3 -5
- package/lib/cjs/actions/blue/borrow.d.ts +1 -0
- package/lib/cjs/actions/blue/borrow.js +1 -0
- package/lib/cjs/actions/blue/refinance.d.ts +1 -0
- package/lib/cjs/actions/blue/refinance.js +3 -0
- package/lib/cjs/actions/blue/repay.d.ts +1 -0
- package/lib/cjs/actions/blue/repay.js +1 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -0
- package/lib/cjs/actions/blue/supply.d.ts +1 -0
- package/lib/cjs/actions/blue/supply.js +2 -0
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +1 -0
- package/lib/cjs/actions/blue/supplyCollateral.js +1 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +1 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +2 -0
- package/lib/cjs/actions/blue/withdraw.d.ts +1 -0
- package/lib/cjs/actions/blue/withdraw.js +2 -0
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/blue/withdrawCollateral.js +1 -0
- package/lib/cjs/actions/midnight/takeLend.d.ts +1 -0
- package/lib/cjs/actions/midnight/takeLend.js +1 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +1 -0
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/constants.d.ts +1 -1
- package/lib/cjs/blue/constants.js +2 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +2 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +1 -7
- package/lib/cjs/constants.d.ts +2 -2
- package/lib/cjs/constants.js +4 -1
- package/lib/cjs/entities/blue/blue.d.ts +112 -21
- package/lib/cjs/entities/blue/blue.js +58 -6
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +9 -6
- package/lib/cjs/entities/midnight/midnight.js +12 -9
- package/lib/cjs/entities/midnight/types.d.ts +8 -1
- 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 +16 -34
- package/lib/cjs/entities/vaultV2/vaultV2.js +12 -38
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +77 -19
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +376 -80
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +6 -10
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- 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/helpers/validate.d.ts +11 -1
- package/lib/cjs/helpers/validate.js +17 -1
- package/lib/cjs/helpers/validateTakeableOffers.d.ts +4 -2
- package/lib/cjs/helpers/validateTakeableOffers.js +12 -1
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -1
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/types/error.d.ts +60 -5
- package/lib/cjs/types/error.js +68 -6
- package/lib/cjs/types/sharedLiquidity.d.ts +31 -11
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/esm/abis.d.ts +2 -2
- package/lib/esm/abis.js +2 -2
- package/lib/esm/actions/blue/borrow.d.ts +1 -0
- package/lib/esm/actions/blue/borrow.js +1 -0
- package/lib/esm/actions/blue/refinance.d.ts +1 -0
- package/lib/esm/actions/blue/refinance.js +4 -1
- package/lib/esm/actions/blue/repay.d.ts +1 -0
- package/lib/esm/actions/blue/repay.js +1 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +3 -1
- package/lib/esm/actions/blue/supply.d.ts +1 -0
- package/lib/esm/actions/blue/supply.js +3 -1
- package/lib/esm/actions/blue/supplyCollateral.d.ts +1 -0
- package/lib/esm/actions/blue/supplyCollateral.js +1 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +1 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -1
- package/lib/esm/actions/blue/withdraw.d.ts +1 -0
- package/lib/esm/actions/blue/withdraw.js +3 -1
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/blue/withdrawCollateral.js +1 -0
- package/lib/esm/actions/midnight/takeLend.d.ts +1 -0
- package/lib/esm/actions/midnight/takeLend.js +1 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +1 -0
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/constants.d.ts +1 -1
- package/lib/esm/blue/constants.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +1 -7
- package/lib/esm/constants.d.ts +2 -2
- package/lib/esm/constants.js +2 -2
- package/lib/esm/entities/blue/blue.d.ts +112 -21
- package/lib/esm/entities/blue/blue.js +60 -8
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +9 -6
- package/lib/esm/entities/midnight/midnight.js +13 -10
- package/lib/esm/entities/midnight/types.d.ts +8 -1
- 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 +16 -34
- package/lib/esm/entities/vaultV2/vaultV2.js +13 -39
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +77 -19
- package/lib/esm/entities/vaultV2BlueReallocationData.js +377 -81
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- 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/helpers/validate.d.ts +11 -1
- package/lib/esm/helpers/validate.js +15 -0
- package/lib/esm/helpers/validateTakeableOffers.d.ts +4 -2
- package/lib/esm/helpers/validateTakeableOffers.js +13 -2
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/types/error.d.ts +60 -5
- package/lib/esm/types/error.js +64 -5
- package/lib/esm/types/sharedLiquidity.d.ts +31 -11
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +9 -8
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; } });
|
|
@@ -9,6 +9,10 @@ type VaultV2BlueReallocationsParams = {
|
|
|
9
9
|
readonly operation?: {
|
|
10
10
|
readonly type: "borrow" | "withdraw";
|
|
11
11
|
readonly amount: bigint;
|
|
12
|
+
} | {
|
|
13
|
+
readonly type: "refinance";
|
|
14
|
+
readonly amount: bigint;
|
|
15
|
+
readonly referralFeePct?: bigint;
|
|
12
16
|
};
|
|
13
17
|
};
|
|
14
18
|
};
|
|
@@ -146,6 +150,8 @@ export interface BlueActions {
|
|
|
146
150
|
* share-price bound or `slippageTolerance`.
|
|
147
151
|
*
|
|
148
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.
|
|
149
155
|
* @param params.assets - Gross loan-token assets funded before the referral fee.
|
|
150
156
|
* @param params.nativeAmount - Optional full native funding; must equal `assets` and requires wNative.
|
|
151
157
|
* @param params.deadline - Final call deadline in Unix seconds.
|
|
@@ -173,6 +179,9 @@ export interface BlueActions {
|
|
|
173
179
|
* @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
|
|
174
180
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
175
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`.
|
|
176
185
|
* @throws {UnknownTokenError} from `getRequirements()` when the funded token's `decimals()` is unusable.
|
|
177
186
|
* @throws {MalformedTokenMetadataError} when the token's `eip712Domain()` or
|
|
178
187
|
* `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
|
|
@@ -194,6 +203,7 @@ export interface BlueActions {
|
|
|
194
203
|
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
195
204
|
* const action = market.supply({
|
|
196
205
|
* userAddress,
|
|
206
|
+
* marketData: await market.getMarketData(),
|
|
197
207
|
* assets: 1_000_000n,
|
|
198
208
|
* deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
|
|
199
209
|
* });
|
|
@@ -202,14 +212,29 @@ export interface BlueActions {
|
|
|
202
212
|
* // tx satisfies Readonly<Transaction<BlueSupplyAction>>
|
|
203
213
|
* ```
|
|
204
214
|
*/
|
|
205
|
-
supply:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
+
};
|
|
213
238
|
/**
|
|
214
239
|
* Prepares a direct BlueBundlesV1 loan-asset withdrawal by assets or shares.
|
|
215
240
|
*
|
|
@@ -764,7 +789,7 @@ export interface BlueActions {
|
|
|
764
789
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
765
790
|
* @throws {UnsupportedBlueMarketIrmError} when positive source or destination debt requires an unsupported IRM projection.
|
|
766
791
|
* @throws {MissingAccrualPositionError} when either position snapshot is absent at runtime.
|
|
767
|
-
* @throws {MarketIdMismatchError} when a position snapshot belongs to another market.
|
|
792
|
+
* @throws {MarketIdMismatchError} when `destination.marketParams.id` does not hash from its tuple fields, or a position snapshot belongs to another market.
|
|
768
793
|
* @throws {AccrualPositionUserMismatchError} when a position snapshot belongs to another user.
|
|
769
794
|
* @throws {RefinanceSameMarketError} when source and destination IDs match.
|
|
770
795
|
* @throws {RefinanceTokenMismatchError} when their loan or collateral tokens differ.
|
|
@@ -842,10 +867,20 @@ export interface BlueActions {
|
|
|
842
867
|
*
|
|
843
868
|
* Reads the target Morpho Blue market, each Vault V2 accrual tree, and each
|
|
844
869
|
* vault's BluePublicAllocator permissions and allocation caps at one block.
|
|
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.
|
|
845
878
|
*
|
|
846
879
|
* @param params.vaultAddresses - Vault V2 addresses to inspect for market or idle liquidity.
|
|
847
880
|
* @param params.block.number - Block number used for every RPC read.
|
|
848
|
-
* @param params.block.timestamp - Timestamp
|
|
881
|
+
* @param params.block.timestamp - Timestamp of the fetched block. Stored on the snapshot and used as the
|
|
882
|
+
* planning timestamp when `options.timestamp` is omitted, never earlier than the latest market/vault
|
|
883
|
+
* `lastUpdate`. An explicit `options.timestamp` is used as given.
|
|
849
884
|
* @returns A `VaultV2BlueReallocationData` snapshot ready for {@link getVaultV2BlueReallocations}.
|
|
850
885
|
* @throws {ChainIdMismatchError} when the client declares another chain or its RPC reports another
|
|
851
886
|
* chain via `eth_chainId`.
|
|
@@ -878,14 +913,28 @@ export interface BlueActions {
|
|
|
878
913
|
* persist across every leg of a plan. Operation plans keep
|
|
879
914
|
* `allocatorCapHeadroom` (1% of the cap by default) free under each target
|
|
880
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.
|
|
921
|
+
* For `refinance`, compute the plan on the destination-market handle (for
|
|
922
|
+
* example, `client.morpho.blue(destination.marketParams, chainId)`), not the
|
|
923
|
+
* source-market handle. Pass the source position's `borrowAssets` accrued to
|
|
924
|
+
* `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
|
|
925
|
+
* `operation.amount`; the optional `operation.referralFeePct` is WAD-scaled.
|
|
926
|
+
* The planner includes the referral fee and its own planned allocator-leg
|
|
927
|
+
* penalties in destination debt. Refinance never uses vaults with a 100%
|
|
928
|
+
* penalty.
|
|
881
929
|
*
|
|
882
930
|
* @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
|
|
883
931
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
884
932
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
885
933
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
886
934
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
887
|
-
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization,
|
|
888
|
-
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD.
|
|
935
|
+
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
|
|
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.
|
|
937
|
+
* @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
|
|
889
938
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
890
939
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
891
940
|
* @throws {UnknownReallocationVaultError} when configured vault state is absent.
|
|
@@ -895,7 +944,7 @@ export interface BlueActions {
|
|
|
895
944
|
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
896
945
|
* @throws {ReallocationAdapterSupplySharesUnderflowError} when an inconsistent adapter snapshot underflows during the final transition.
|
|
897
946
|
* @throws {ReallocationAllocationUnderflowError} when an inconsistent allocation snapshot underflows during the final transition.
|
|
898
|
-
* @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.
|
|
899
948
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
900
949
|
* @example
|
|
901
950
|
* ```ts
|
|
@@ -915,6 +964,14 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
915
964
|
private readonly client;
|
|
916
965
|
readonly marketParams: MarketParams;
|
|
917
966
|
private readonly chainId;
|
|
967
|
+
/**
|
|
968
|
+
* Binds `client` to the market described by `marketParams` on `chainId`.
|
|
969
|
+
*
|
|
970
|
+
* @param client - Morpho client used for reads and requirement lookups.
|
|
971
|
+
* @param marketParams - Market params whose `id` must hash from their five tuple fields.
|
|
972
|
+
* @param chainId - Chain the market lives on.
|
|
973
|
+
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
974
|
+
*/
|
|
918
975
|
constructor(client: MorphoClientType, marketParams: MarketParams, chainId: number);
|
|
919
976
|
private validateDeadline;
|
|
920
977
|
private validateWriteCommon;
|
|
@@ -937,15 +994,25 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
937
994
|
/** {@inheritDoc BlueActions.supply} */
|
|
938
995
|
supply(params: {
|
|
939
996
|
readonly userAddress: Address;
|
|
997
|
+
readonly marketData: Market;
|
|
940
998
|
readonly assets: bigint;
|
|
941
999
|
readonly nativeAmount?: bigint;
|
|
942
1000
|
readonly deadline: bigint;
|
|
943
1001
|
readonly referralFeePct?: bigint;
|
|
944
1002
|
readonly referralFeeRecipient?: Address;
|
|
945
|
-
}):
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
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>;
|
|
949
1016
|
/** {@inheritDoc BlueActions.withdraw} */
|
|
950
1017
|
withdraw(params: {
|
|
951
1018
|
readonly userAddress: Address;
|
|
@@ -1059,10 +1126,20 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1059
1126
|
*
|
|
1060
1127
|
* Reads the target Morpho Blue market, each Vault V2 accrual tree, and each
|
|
1061
1128
|
* vault's BluePublicAllocator permissions and allocation caps at one block.
|
|
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.
|
|
1062
1137
|
*
|
|
1063
1138
|
* @param params.vaultAddresses - Vault V2 addresses to inspect for market or idle liquidity.
|
|
1064
1139
|
* @param params.block.number - Block number used for every RPC read.
|
|
1065
|
-
* @param params.block.timestamp - Timestamp
|
|
1140
|
+
* @param params.block.timestamp - Timestamp of the fetched block. Stored on the snapshot and used as the
|
|
1141
|
+
* planning timestamp when `options.timestamp` is omitted, never earlier than the latest market/vault
|
|
1142
|
+
* `lastUpdate`. An explicit `options.timestamp` is used as given.
|
|
1066
1143
|
* @returns A `VaultV2BlueReallocationData` snapshot ready for {@link getVaultV2BlueReallocations}.
|
|
1067
1144
|
* @throws {ChainIdMismatchError} when the client declares another chain or its RPC reports another
|
|
1068
1145
|
* chain via `eth_chainId`.
|
|
@@ -1114,14 +1191,28 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1114
1191
|
* persist across every leg of a plan. Operation plans keep
|
|
1115
1192
|
* `allocatorCapHeadroom` (1% of the cap by default) free under each target
|
|
1116
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.
|
|
1199
|
+
* For `refinance`, compute the plan on the destination-market handle (for
|
|
1200
|
+
* example, `client.morpho.blue(destination.marketParams, chainId)`), not the
|
|
1201
|
+
* source-market handle. Pass the source position's `borrowAssets` accrued to
|
|
1202
|
+
* `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
|
|
1203
|
+
* `operation.amount`; the optional `operation.referralFeePct` is WAD-scaled.
|
|
1204
|
+
* The planner includes the referral fee and its own planned allocator-leg
|
|
1205
|
+
* penalties in destination debt. Refinance never uses vaults with a 100%
|
|
1206
|
+
* penalty.
|
|
1117
1207
|
*
|
|
1118
1208
|
* @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
|
|
1119
1209
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
1120
1210
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
1121
1211
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
1122
1212
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
1123
|
-
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization,
|
|
1124
|
-
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD.
|
|
1213
|
+
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
|
|
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.
|
|
1215
|
+
* @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
|
|
1125
1216
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
1126
1217
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
1127
1218
|
* @throws {UnknownReallocationVaultError} when configured vault state is absent.
|
|
@@ -1131,7 +1222,7 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1131
1222
|
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
1132
1223
|
* @throws {ReallocationAdapterSupplySharesUnderflowError} when an inconsistent adapter snapshot underflows during the final transition.
|
|
1133
1224
|
* @throws {ReallocationAllocationUnderflowError} when an inconsistent allocation snapshot underflows during the final transition.
|
|
1134
|
-
* @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.
|
|
1135
1226
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
1136
1227
|
* @example
|
|
1137
1228
|
* ```ts
|
|
@@ -5,10 +5,13 @@ 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");
|
|
14
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
12
15
|
const index_js_3 = require("../../types/index.js");
|
|
13
16
|
const assertContractCode_js_1 = require("../requirements/assertContractCode.js");
|
|
14
17
|
const index_js_4 = require("../requirements/index.js");
|
|
@@ -18,11 +21,20 @@ class MorphoBlue {
|
|
|
18
21
|
client;
|
|
19
22
|
marketParams;
|
|
20
23
|
chainId;
|
|
24
|
+
/**
|
|
25
|
+
* Binds `client` to the market described by `marketParams` on `chainId`.
|
|
26
|
+
*
|
|
27
|
+
* @param client - Morpho client used for reads and requirement lookups.
|
|
28
|
+
* @param marketParams - Market params whose `id` must hash from their five tuple fields.
|
|
29
|
+
* @param chainId - Chain the market lives on.
|
|
30
|
+
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
31
|
+
*/
|
|
21
32
|
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
22
33
|
constructor(client, marketParams, chainId) {
|
|
23
34
|
this.client = client;
|
|
24
35
|
this.marketParams = marketParams;
|
|
25
36
|
this.chainId = chainId;
|
|
37
|
+
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
26
38
|
}
|
|
27
39
|
validateDeadline(deadline, now = morpho_ts_1.Time.timestamp()) {
|
|
28
40
|
if (deadline <= now) {
|
|
@@ -117,7 +129,6 @@ class MorphoBlue {
|
|
|
117
129
|
deployless: this.client.options.supportDeployless,
|
|
118
130
|
});
|
|
119
131
|
}
|
|
120
|
-
/** {@inheritDoc BlueActions.supply} */
|
|
121
132
|
supply(params) {
|
|
122
133
|
const { userAddress, assets, nativeAmount, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
123
134
|
this.validateWriteCommon(params);
|
|
@@ -129,6 +140,13 @@ class MorphoBlue {
|
|
|
129
140
|
fundedAmount: assets,
|
|
130
141
|
nativeAmount,
|
|
131
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
|
+
}
|
|
132
150
|
return {
|
|
133
151
|
getRequirements: (requirementsParams) => {
|
|
134
152
|
const now = morpho_ts_1.Time.timestamp();
|
|
@@ -640,6 +658,7 @@ class MorphoBlue {
|
|
|
640
658
|
refinance(params) {
|
|
641
659
|
const { userAddress, positionData, destination, deadline, referralFeeRecipient, } = params;
|
|
642
660
|
this.validateWriteCommon(params);
|
|
661
|
+
(0, validate_js_1.validateMarketParamsId)(destination.marketParams);
|
|
643
662
|
// `validateWriteCommon` returns void, so default an omitted `referralFeePct` to `0n`
|
|
644
663
|
// here, matching the pure action's normalization.
|
|
645
664
|
const referralFeePct = params.referralFeePct ?? 0n;
|
|
@@ -723,10 +742,20 @@ class MorphoBlue {
|
|
|
723
742
|
*
|
|
724
743
|
* Reads the target Morpho Blue market, each Vault V2 accrual tree, and each
|
|
725
744
|
* vault's BluePublicAllocator permissions and allocation caps at one block.
|
|
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.
|
|
726
753
|
*
|
|
727
754
|
* @param params.vaultAddresses - Vault V2 addresses to inspect for market or idle liquidity.
|
|
728
755
|
* @param params.block.number - Block number used for every RPC read.
|
|
729
|
-
* @param params.block.timestamp - Timestamp
|
|
756
|
+
* @param params.block.timestamp - Timestamp of the fetched block. Stored on the snapshot and used as the
|
|
757
|
+
* planning timestamp when `options.timestamp` is omitted, never earlier than the latest market/vault
|
|
758
|
+
* `lastUpdate`. An explicit `options.timestamp` is used as given.
|
|
730
759
|
* @returns A `VaultV2BlueReallocationData` snapshot ready for {@link getVaultV2BlueReallocations}.
|
|
731
760
|
* @throws {ChainIdMismatchError} when the client declares another chain or its RPC reports another
|
|
732
761
|
* chain via `eth_chainId`.
|
|
@@ -769,7 +798,7 @@ class MorphoBlue {
|
|
|
769
798
|
chainId: this.chainId,
|
|
770
799
|
deployless: this.client.options.supportDeployless,
|
|
771
800
|
};
|
|
772
|
-
const [targetMarket, vaultEntries] = await Promise.all([
|
|
801
|
+
const [targetMarket, vaultEntries, blueBalance] = await Promise.all([
|
|
773
802
|
(0, blue_sdk_viem_1.fetchMarket)(this.marketParams.id, client, fetchParams),
|
|
774
803
|
Promise.all(vaultAddresses.map(async (address) => {
|
|
775
804
|
const vault = await (0, blue_sdk_viem_1.fetchAccrualVaultV2)(address, client, fetchParams);
|
|
@@ -779,9 +808,18 @@ class MorphoBlue {
|
|
|
779
808
|
});
|
|
780
809
|
return { publicAllocatorData, vault };
|
|
781
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
|
+
}),
|
|
782
818
|
]);
|
|
783
819
|
return new vaultV2BlueReallocationData_js_1.VaultV2BlueReallocationData({
|
|
784
820
|
chainId: this.chainId,
|
|
821
|
+
timestamp: block.timestamp,
|
|
822
|
+
blueBalances: { [this.marketParams.loanToken]: blueBalance },
|
|
785
823
|
markets: { [targetMarket.id]: targetMarket },
|
|
786
824
|
vaults: Object.fromEntries(vaultEntries.map(({ vault }) => [vault.address, vault])),
|
|
787
825
|
allocations: Object.fromEntries(vaultEntries.map(({ publicAllocatorData, vault }) => [
|
|
@@ -812,14 +850,28 @@ class MorphoBlue {
|
|
|
812
850
|
* persist across every leg of a plan. Operation plans keep
|
|
813
851
|
* `allocatorCapHeadroom` (1% of the cap by default) free under each target
|
|
814
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.
|
|
858
|
+
* For `refinance`, compute the plan on the destination-market handle (for
|
|
859
|
+
* example, `client.morpho.blue(destination.marketParams, chainId)`), not the
|
|
860
|
+
* source-market handle. Pass the source position's `borrowAssets` accrued to
|
|
861
|
+
* `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
|
|
862
|
+
* `operation.amount`; the optional `operation.referralFeePct` is WAD-scaled.
|
|
863
|
+
* The planner includes the referral fee and its own planned allocator-leg
|
|
864
|
+
* penalties in destination debt. Refinance never uses vaults with a 100%
|
|
865
|
+
* penalty.
|
|
815
866
|
*
|
|
816
867
|
* @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
|
|
817
868
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
818
869
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
819
870
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
820
871
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
821
|
-
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization,
|
|
822
|
-
* @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD.
|
|
872
|
+
* @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
|
|
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.
|
|
874
|
+
* @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
|
|
823
875
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
824
876
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
825
877
|
* @throws {UnknownReallocationVaultError} when configured vault state is absent.
|
|
@@ -829,7 +881,7 @@ class MorphoBlue {
|
|
|
829
881
|
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
830
882
|
* @throws {ReallocationAdapterSupplySharesUnderflowError} when an inconsistent adapter snapshot underflows during the final transition.
|
|
831
883
|
* @throws {ReallocationAllocationUnderflowError} when an inconsistent allocation snapshot underflows during the final transition.
|
|
832
|
-
* @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.
|
|
833
885
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
834
886
|
* @example
|
|
835
887
|
* ```ts
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter,
|
|
1
|
+
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
IPreLiquidationParams as IBluePreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig,
|
|
6
|
-
export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2,
|
|
5
|
+
IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
|
|
6
|
+
export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
|
|
7
7
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
8
|
PreLiquidationParams as BluePreLiquidationParams,
|
|
9
9
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
10
|
-
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig,
|
|
10
|
+
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
11
11
|
export type { AnyTree as MidnightAnyTree, AnyTreeSnapshot as MidnightAnyTreeSnapshot, BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, EcrecoverTreeCreateRequest as MidnightEcrecoverTreeCreateRequest, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, PriceRatifierV1TreeCreateRequest as MidnightPriceRatifierV1TreeCreateRequest, RateRatifierV1TreeCreateRequest as MidnightRateRatifierV1TreeCreateRequest, RatifierKind as MidnightRatifierKind, RatifierTreeInput as MidnightRatifierTreeInput, RatifierTypes as MidnightRatifierTypes, SetterTreeCreateRequest as MidnightSetterTreeCreateRequest, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeCreateRequest as MidnightTreeCreateRequest, TreeData as MidnightTreeData, TreeDescriptor as MidnightTreeDescriptor, TreeEntry as MidnightTreeEntry, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, TreeSnapshot as MidnightTreeSnapshot, TypedRatifierTreeInput as MidnightTypedRatifierTreeInput, TypedTreeMempoolValidateParams as MidnightTypedTreeMempoolValidateParams, } from "@morpho-org/midnight-sdk";
|
|
12
12
|
export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
|
|
13
13
|
export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
|
|
@@ -14,12 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = 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.
|
|
17
|
+
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = 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.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.BlueUser = exports.Token = exports.BluePreLiquidationPosition = exports.BluePreLiquidationParams = exports.BluePosition = exports.BlueMarketParams = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.BlueAccrualPosition = void 0;
|
|
18
18
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
19
19
|
Object.defineProperty(exports, "BlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
20
20
|
Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
|
|
21
21
|
Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
|
|
22
|
-
Object.defineProperty(exports, "AccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MidnightAdapter; } });
|
|
23
22
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
|
|
24
23
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
25
24
|
Object.defineProperty(exports, "AccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -47,7 +46,6 @@ Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () {
|
|
|
47
46
|
Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
|
|
48
47
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfig; } });
|
|
49
48
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfig; } });
|
|
50
|
-
Object.defineProperty(exports, "VaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapter; } });
|
|
51
49
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
|
|
52
50
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
|
|
53
51
|
Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
|
|
@@ -197,6 +197,7 @@ export declare class MorphoMidnight {
|
|
|
197
197
|
* @throws {EmptyMidnightTakeableOffersError} when no offers are supplied.
|
|
198
198
|
* @throws {MidnightOfferSideMismatchError} when an offer has the wrong maker side.
|
|
199
199
|
* @throws {MidnightTakeableOfferMarketMismatchError} when an offer targets another market.
|
|
200
|
+
* @throws {MidnightTakeableOfferZeroSellerReceiverError} when a sell offer routes seller proceeds to the zero address.
|
|
200
201
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
201
202
|
* @throws {MidnightReferralFeePctExceededError} when `referralFeePct` exceeds 10% (`WAD / 10n`).
|
|
202
203
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient.
|
|
@@ -552,6 +553,7 @@ export declare class MorphoMidnight {
|
|
|
552
553
|
* @throws {EmptyMidnightTakeableOffersError} when no offers are supplied.
|
|
553
554
|
* @throws {MidnightOfferSideMismatchError} when an offer has the wrong maker side.
|
|
554
555
|
* @throws {MidnightTakeableOfferMarketMismatchError} when an offer targets another market.
|
|
556
|
+
* @throws {MidnightTakeableOfferZeroSellerReceiverError} when a sell offer routes seller proceeds to the zero address.
|
|
555
557
|
* @throws {ExpiredDeadlineError} when `deadline` has expired.
|
|
556
558
|
* @throws {MidnightTakeDeadlineTooFarError} when `deadline` is more than one hour from now.
|
|
557
559
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
@@ -636,14 +638,14 @@ export declare class MorphoMidnight {
|
|
|
636
638
|
* for a new publication. Calls the Midnight mempool validation API while preparing the tree;
|
|
637
639
|
* `validation: false` skips that call.
|
|
638
640
|
*
|
|
639
|
-
* @param params - Maker, lend-side offers,
|
|
641
|
+
* @param params - Maker, lend-side offers, `loanAssets` and `reservedLoanAssets` allowance thresholds, cancellations, and deadline.
|
|
640
642
|
* @param params.accountAddress - Maker expected on every offer; must send the transaction.
|
|
641
643
|
* @param params.offers - PriceRatifierV1 or RateRatifierV1 tree, or its `Tree.create` request.
|
|
642
644
|
* @param params.cancellations - Previous groups to cancel with their consumption ceilings.
|
|
643
645
|
* @param params.deadline - Bundle execution deadline timestamp.
|
|
644
646
|
* @param params.validation - Midnight mempool API request controls, or `false` to skip the API call.
|
|
645
647
|
* @param params.loanToken - Loan token shared by every offer market.
|
|
646
|
-
* @param params.loanAssets -
|
|
648
|
+
* @param params.loanAssets - Minimum Midnight allowance (with `reservedLoanAssets`) that `getRequirements()` checks; the approval it returns is unlimited. The signed offer caps bound fills.
|
|
647
649
|
* @param params.reservedLoanAssets - Existing loan assets reserved by other open groups, excluding groups in `cancellations`.
|
|
648
650
|
* @returns Prepared group metadata, lazy approval/authorization requirements, and a synchronous transaction builder.
|
|
649
651
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
@@ -846,7 +848,8 @@ export declare class MorphoMidnight {
|
|
|
846
848
|
* @throws {MidnightMarketLiquidationCursorNotEnabledError} when an uncreated market uses a disabled liquidation cursor.
|
|
847
849
|
* @throws {MidnightMarketOracleWithoutCodeError} when an uncreated market's oracle has no code.
|
|
848
850
|
* @throws {viem.BaseError} when a pinned block, multicall, or oracle-code read fails.
|
|
849
|
-
* @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`.
|
|
850
853
|
* @throws {ZeroBlueParkingSharesError} when `assetsToPark` would mint no supply shares at the current share price (checked at preparation time only).
|
|
851
854
|
* @throws {MidnightReplacementGroupCancelledError} when a published group is also cancelled.
|
|
852
855
|
* @throws {InvalidMidnightHexInputError} when a cancellation group or `callbackSalt` is not 32-byte hex.
|
|
@@ -946,7 +949,7 @@ export declare class MorphoMidnight {
|
|
|
946
949
|
*
|
|
947
950
|
* Shares the lend-side publication and requirement handling of {@link MorphoMidnight.makeLend}.
|
|
948
951
|
* Loan assets are pulled by Midnight when the offers fill, not during publication.
|
|
949
|
-
*
|
|
952
|
+
* `loanAssets` is only the allowance threshold `getRequirements()` checks, as in `makeLend`; the signed offer caps bound fills.
|
|
950
953
|
* A partially consumed offer group remains publishable with its shared remaining cap reduced.
|
|
951
954
|
* No repay offer can be live after market maturity; late borrowers should repay directly with
|
|
952
955
|
* {@link MorphoMidnight.repayWithdrawCollateral}.
|
|
@@ -954,14 +957,14 @@ export declare class MorphoMidnight {
|
|
|
954
957
|
* Every offer must already have `buy = true` and `reduceOnly = true`.
|
|
955
958
|
* The supplied tree, group caps and prices are preserved; no separate root signature is needed.
|
|
956
959
|
*
|
|
957
|
-
* @param params - Maker, reduce-only offers, optional cancellations,
|
|
960
|
+
* @param params - Maker, reduce-only offers, optional cancellations, `loanAssets` and `reservedLoanAssets` allowance thresholds, and deadline.
|
|
958
961
|
* @param params.accountAddress - Maker expected on every offer; must send the transaction.
|
|
959
962
|
* @param params.offers - PriceRatifierV1 or RateRatifierV1 tree, or its `Tree.create` request.
|
|
960
963
|
* @param params.cancellations - Previous groups to cancel with their consumption ceilings.
|
|
961
964
|
* @param params.deadline - Bundle execution deadline timestamp.
|
|
962
965
|
* @param params.validation - Midnight mempool API request controls, or `false` to skip the API call.
|
|
963
966
|
* @param params.loanToken - Loan token shared by every offer market.
|
|
964
|
-
* @param params.loanAssets -
|
|
967
|
+
* @param params.loanAssets - Minimum Midnight allowance (with `reservedLoanAssets`) that `getRequirements()` checks; the approval it returns is unlimited. The signed offer caps bound fills.
|
|
965
968
|
* @param params.reservedLoanAssets - Existing loan assets reserved by other open groups.
|
|
966
969
|
* @returns Prepared root and groups, lazy requirements, and a synchronous publication builder.
|
|
967
970
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|