@morpho-org/morpho-sdk 7.0.0 → 7.1.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v6-to-v7.md +6 -0
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +5 -1
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +5 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +3 -1
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +5 -1
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +3 -1
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +2 -1
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/midnight/midnight.d.ts +5 -2
- package/lib/cjs/entities/midnight/midnight.js +5 -2
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +1 -1
- package/lib/cjs/entities/vaultV1/vaultV1.js +31 -34
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +35 -11
- package/lib/cjs/entities/vaultV2/vaultV2.js +67 -41
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +9 -3
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +10 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/types/action.d.ts +102 -1
- package/lib/cjs/types/action.js +102 -1
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.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/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +5 -2
- package/lib/esm/entities/midnight/midnight.js +5 -2
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +1 -1
- package/lib/esm/entities/vaultV1/vaultV1.js +32 -35
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +35 -11
- package/lib/esm/entities/vaultV2/vaultV2.js +68 -42
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +9 -3
- 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/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/types/action.d.ts +102 -1
- package/lib/esm/types/action.js +102 -1
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +8 -9
|
@@ -17,6 +17,11 @@ const index_js_4 = require("../requirements/index.js");
|
|
|
17
17
|
// Maximum accepted deadline horizon; the on-chain management fee is capped at 5%/yr so the
|
|
18
18
|
// accrual model stays well-defined inside it.
|
|
19
19
|
const VAULT_V2_FEE_PROJECTION_HORIZON = morpho_ts_1.Time.s.from.y(1n);
|
|
20
|
+
/**
|
|
21
|
+
* Midnight adapters revert vault-initiated `allocate` and `deallocate` (`SelfAllocationOnly`), so a
|
|
22
|
+
* vault routing liquidity through one accepts no deposit and serves exits from idle assets only.
|
|
23
|
+
*/
|
|
24
|
+
const isMidnightLiquidityAdapter = (vaultData) => vaultData.accrualLiquidityAdapter?.type === "VaultV2MidnightAdapter";
|
|
20
25
|
/** Binds a viem client to a Vault V2 vault's action builders. */
|
|
21
26
|
class MorphoVaultV2 {
|
|
22
27
|
client;
|
|
@@ -59,6 +64,13 @@ class MorphoVaultV2 {
|
|
|
59
64
|
// The native path must target the chain's registered wrapped-native asset.
|
|
60
65
|
(0, validate_js_1.validateNativeVaultAsset)(this.chainId, vaultAsset);
|
|
61
66
|
}
|
|
67
|
+
if (isMidnightLiquidityAdapter(vaultData)) {
|
|
68
|
+
throw new index_js_3.InputExceedsMaxError({
|
|
69
|
+
field: funding.value > 0n ? "nativeAmount" : "amount",
|
|
70
|
+
value: funding.assets,
|
|
71
|
+
max: 0n,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
62
74
|
const referralFeeAssets = (0, common_js_1.getBundlesReferralFeeAssets)(funding.assets, common.referralFeePct);
|
|
63
75
|
const maxSharePrice = (0, index_js_2.computeVaultMaxSharePrice)({
|
|
64
76
|
vaultData,
|
|
@@ -136,6 +148,14 @@ class MorphoVaultV2 {
|
|
|
136
148
|
throw new index_js_3.NonPositiveInputError("amount", amount);
|
|
137
149
|
// Reject values outside the ABI range before resolving any requirements.
|
|
138
150
|
(0, validate_js_1.validateUint256Field)("amount", amount);
|
|
151
|
+
if (isMidnightLiquidityAdapter(vaultData) &&
|
|
152
|
+
amount > vaultData.assetBalance) {
|
|
153
|
+
throw new index_js_3.InputExceedsMaxError({
|
|
154
|
+
field: "amount",
|
|
155
|
+
value: amount,
|
|
156
|
+
max: vaultData.assetBalance,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
139
159
|
const createdAt = morpho_ts_1.Time.timestamp();
|
|
140
160
|
const deadline = params.deadline ?? createdAt + morpho_ts_1.Time.s.from.h(2n);
|
|
141
161
|
if (deadline <= createdAt)
|
|
@@ -223,8 +243,20 @@ class MorphoVaultV2 {
|
|
|
223
243
|
const now = morpho_ts_1.Time.timestamp();
|
|
224
244
|
if (deadline <= now)
|
|
225
245
|
throw new index_js_3.ExpiredDeadlineError(deadline, now);
|
|
246
|
+
const vaultData = await this.getData();
|
|
247
|
+
if (isMidnightLiquidityAdapter(vaultData)) {
|
|
248
|
+
// Onchain redeem accrues interest before converting shares to assets.
|
|
249
|
+
const { vault: accrued } = vaultData.accrueInterest(now);
|
|
250
|
+
if (accrued.toAssets(shares) > accrued.assetBalance) {
|
|
251
|
+
throw new index_js_3.InputExceedsMaxError({
|
|
252
|
+
field: "shares",
|
|
253
|
+
value: shares,
|
|
254
|
+
max: accrued.toShares(accrued.assetBalance),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
226
258
|
return (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
|
|
227
|
-
vaultData
|
|
259
|
+
vaultData,
|
|
228
260
|
version: "vaultV2",
|
|
229
261
|
owner: userAddress,
|
|
230
262
|
chainId: this.chainId,
|
|
@@ -362,29 +394,26 @@ class MorphoVaultV2 {
|
|
|
362
394
|
// after intermediate penalty share burns, so one standalone read is not execution-equivalent
|
|
363
395
|
// either. Simulate the finalized transaction after authorization when gate compatibility
|
|
364
396
|
// must be checked before submission.
|
|
365
|
-
const [allowance, nonce, blueBalance] = await
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
],
|
|
387
|
-
});
|
|
397
|
+
const [allowance, nonce, blueBalance] = await Promise.all([
|
|
398
|
+
(0, actions_1.readContract)(this.client.viemClient, {
|
|
399
|
+
address: this.vault,
|
|
400
|
+
abi: viem_1.erc20Abi,
|
|
401
|
+
functionName: "allowance",
|
|
402
|
+
args: [userAddress, vaultExitBundlesV1],
|
|
403
|
+
}),
|
|
404
|
+
(0, actions_1.readContract)(this.client.viemClient, {
|
|
405
|
+
address: this.vault,
|
|
406
|
+
abi: blue_sdk_viem_1.erc2612Abi,
|
|
407
|
+
functionName: "nonces",
|
|
408
|
+
args: [userAddress],
|
|
409
|
+
}),
|
|
410
|
+
(0, actions_1.readContract)(this.client.viemClient, {
|
|
411
|
+
address: vaultData.asset,
|
|
412
|
+
abi: viem_1.erc20Abi,
|
|
413
|
+
functionName: "balanceOf",
|
|
414
|
+
args: [blue],
|
|
415
|
+
}),
|
|
416
|
+
]);
|
|
388
417
|
if (blueBalance < peak) {
|
|
389
418
|
throw new index_js_3.InsufficientBlueBalanceForInKindRedeemError({
|
|
390
419
|
asset: vaultData.asset,
|
|
@@ -626,23 +655,20 @@ class MorphoVaultV2 {
|
|
|
626
655
|
// external code re-evaluated after each intermediate penalty burn, so neither is
|
|
627
656
|
// execution-equivalent from a standalone read. Unlike in-kind redemption, this exit never
|
|
628
657
|
// supplies into Morpho Blue, so no Blue token-balance check is needed.
|
|
629
|
-
const [allowance, nonce] = await
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
},
|
|
644
|
-
],
|
|
645
|
-
});
|
|
658
|
+
const [allowance, nonce] = await Promise.all([
|
|
659
|
+
(0, actions_1.readContract)(this.client.viemClient, {
|
|
660
|
+
address: this.vault,
|
|
661
|
+
abi: viem_1.erc20Abi,
|
|
662
|
+
functionName: "allowance",
|
|
663
|
+
args: [userAddress, vaultExitBundlesV1],
|
|
664
|
+
}),
|
|
665
|
+
(0, actions_1.readContract)(this.client.viemClient, {
|
|
666
|
+
address: this.vault,
|
|
667
|
+
abi: blue_sdk_viem_1.erc2612Abi,
|
|
668
|
+
functionName: "nonces",
|
|
669
|
+
args: [userAddress],
|
|
670
|
+
}),
|
|
671
|
+
]);
|
|
646
672
|
if (allowance >= requiredShareAllowance)
|
|
647
673
|
return [];
|
|
648
674
|
if (this.client.options.supportSignature) {
|
|
@@ -39,8 +39,9 @@ export interface InputVaultV2BlueReallocationData {
|
|
|
39
39
|
/**
|
|
40
40
|
* Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
|
|
41
41
|
*
|
|
42
|
-
* Constructor inputs are cloned
|
|
43
|
-
*
|
|
42
|
+
* Constructor inputs are cloned, except Midnight adapter snapshots: those are
|
|
43
|
+
* shared by reference and must be treated as read-only. Every simulated
|
|
44
|
+
* reallocation returns a new instance. Planning keeps the transaction-scoped `firstTotalAssets`
|
|
44
45
|
* denominator outside the durable snapshot while applying reallocations in
|
|
45
46
|
* contract order. Penalty donations update simulated vault accounting but are
|
|
46
47
|
* excluded from same-plan idle liquidity so round-up dust cannot create
|
|
@@ -100,7 +101,8 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
100
101
|
/**
|
|
101
102
|
* Clones the complete simulation snapshot.
|
|
102
103
|
*
|
|
103
|
-
* @returns A deep clone of this simulation state.
|
|
104
|
+
* @returns A deep clone of this simulation state. Midnight adapter snapshots are
|
|
105
|
+
* shared by reference and must be treated as read-only.
|
|
104
106
|
* @example
|
|
105
107
|
* ```ts
|
|
106
108
|
* import { markets } from "@morpho-org/morpho-test";
|
|
@@ -78,6 +78,10 @@ const cloneAccrualVault = (vault, markets) => new blue_sdk_1.AccrualVault({
|
|
|
78
78
|
position: clonePosition(position, markets),
|
|
79
79
|
})));
|
|
80
80
|
const cloneAdapter = (adapter, markets) => {
|
|
81
|
+
// BluePublicAllocator never moves Midnight liquidity, and reallocation never mutates a Midnight
|
|
82
|
+
// adapter, so its read-only snapshot is shared as-is.
|
|
83
|
+
if (adapter.type === "VaultV2MidnightAdapter")
|
|
84
|
+
return adapter;
|
|
81
85
|
const base = {
|
|
82
86
|
address: adapter.address,
|
|
83
87
|
parentVault: adapter.parentVault,
|
|
@@ -125,8 +129,9 @@ const cloneVault = (vault, { markets, adapterKeysToClone, }) => {
|
|
|
125
129
|
/**
|
|
126
130
|
* Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
|
|
127
131
|
*
|
|
128
|
-
* Constructor inputs are cloned
|
|
129
|
-
*
|
|
132
|
+
* Constructor inputs are cloned, except Midnight adapter snapshots: those are
|
|
133
|
+
* shared by reference and must be treated as read-only. Every simulated
|
|
134
|
+
* reallocation returns a new instance. Planning keeps the transaction-scoped `firstTotalAssets`
|
|
130
135
|
* denominator outside the durable snapshot while applying reallocations in
|
|
131
136
|
* contract order. Penalty donations update simulated vault accounting but are
|
|
132
137
|
* excluded from same-plan idle liquidity so round-up dust cannot create
|
|
@@ -248,7 +253,8 @@ class VaultV2BlueReallocationData {
|
|
|
248
253
|
/**
|
|
249
254
|
* Clones the complete simulation snapshot.
|
|
250
255
|
*
|
|
251
|
-
* @returns A deep clone of this simulation state.
|
|
256
|
+
* @returns A deep clone of this simulation state. Midnight adapter snapshots are
|
|
257
|
+
* shared by reference and must be treated as read-only.
|
|
252
258
|
* @example
|
|
253
259
|
* ```ts
|
|
254
260
|
* import { markets } from "@morpho-org/morpho-test";
|
package/lib/cjs/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, InvalidVaultV2MidnightAdapterMarketsError as InvalidBlueVaultV2MidnightAdapterMarketsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
-
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError,
|
|
4
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError as BlueUnresolvedBlockNumberError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
6
6
|
export type { ErrorClass } from "@morpho-org/morpho-ts";
|
|
7
|
-
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
|
7
|
+
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, InvalidPositionAccrualStateError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
package/lib/cjs/errors.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.
|
|
4
|
-
exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError =
|
|
3
|
+
exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.BlueUnresolvedBlockNumberError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.NonTupleReturnValueError = exports.BlueMarketParamsIdMismatchError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueVaultV2MidnightAdapterMarketsError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
|
|
4
|
+
exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidPositionAccrualStateError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = void 0;
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
6
|
Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
|
|
7
7
|
Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: true, get: function () { return blue_sdk_1.IncompleteChainRegistryError; } });
|
|
8
8
|
Object.defineProperty(exports, "InvalidBlueMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidMarketParamsError; } });
|
|
9
|
+
Object.defineProperty(exports, "InvalidBlueVaultV2MidnightAdapterMarketsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidVaultV2MidnightAdapterMarketsError; } });
|
|
9
10
|
Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return blue_sdk_1.UnknownAddressError; } });
|
|
10
11
|
Object.defineProperty(exports, "UnknownBlueDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
|
|
11
12
|
Object.defineProperty(exports, "UnknownBlueFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownFactory; } });
|
|
@@ -31,6 +32,7 @@ Object.defineProperty(exports, "BlueMarketParamsIdMismatchError", { enumerable:
|
|
|
31
32
|
Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, get: function () { return blue_sdk_viem_1.NonTupleReturnValueError; } });
|
|
32
33
|
Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
|
|
33
34
|
Object.defineProperty(exports, "UnnamedAbiOutputsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnnamedAbiOutputsError; } });
|
|
35
|
+
Object.defineProperty(exports, "BlueUnresolvedBlockNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnresolvedBlockNumberError; } });
|
|
34
36
|
Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
|
|
35
37
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
36
38
|
Object.defineProperty(exports, "MidnightChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
@@ -40,9 +42,6 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
|
|
|
40
42
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
41
43
|
Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
42
44
|
Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
|
|
43
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
|
|
44
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
|
|
45
|
-
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
|
|
46
45
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
|
|
47
46
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
|
|
48
47
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
|
|
@@ -65,5 +64,11 @@ Object.defineProperty(exports, "_try", { enumerable: true, get: function () { re
|
|
|
65
64
|
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
|
|
66
65
|
Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return morpho_ts_1.InvalidAddressError; } });
|
|
67
66
|
Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
|
|
67
|
+
Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
68
|
+
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
69
|
+
Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
70
|
+
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
71
|
+
Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
72
|
+
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
68
73
|
Object.defineProperty(exports, "NegativeValueError", { enumerable: true, get: function () { return morpho_ts_1.NegativeValueError; } });
|
|
69
74
|
Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return morpho_ts_1.RegistryValueAlreadyRegisteredError; } });
|
package/lib/cjs/fetch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
1
|
+
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
6
6
|
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
package/lib/cjs/fetch.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchBlueUser = exports.fetchToken = exports.fetchBluePreLiquidationPosition = exports.fetchBluePreLiquidationParams = exports.fetchBluePosition = exports.fetchBlueMarketParams = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchBlueAccrualPosition = void 0;
|
|
3
|
+
exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2MidnightAdapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchBlueUser = exports.fetchToken = exports.fetchBluePreLiquidationPosition = exports.fetchBluePreLiquidationParams = exports.fetchBluePosition = exports.fetchBlueMarketParams = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2MidnightAdapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchBlueAccrualPosition = void 0;
|
|
4
4
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
5
|
Object.defineProperty(exports, "fetchBlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualPosition; } });
|
|
6
6
|
Object.defineProperty(exports, "fetchAccrualVault", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVault; } });
|
|
7
7
|
Object.defineProperty(exports, "fetchAccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2; } });
|
|
8
8
|
Object.defineProperty(exports, "fetchAccrualVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2Adapter; } });
|
|
9
|
+
Object.defineProperty(exports, "fetchAccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MidnightAdapter; } });
|
|
9
10
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1Adapter; } });
|
|
10
11
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
11
12
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -29,6 +30,7 @@ Object.defineProperty(exports, "fetchVaultV2Adapter", { enumerable: true, get: f
|
|
|
29
30
|
Object.defineProperty(exports, "fetchVaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BlueMarketPublicAllocatorConfig; } });
|
|
30
31
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorConfig; } });
|
|
31
32
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorData", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorData; } });
|
|
33
|
+
Object.defineProperty(exports, "fetchVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MidnightAdapter; } });
|
|
32
34
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1Adapter; } });
|
|
33
35
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1AdapterV2; } });
|
|
34
36
|
Object.defineProperty(exports, "fetchVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError,
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
2
|
+
export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.
|
|
3
|
+
exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.ChainIdMismatchError = void 0;
|
|
4
4
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
5
|
Object.defineProperty(exports, "ChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
6
6
|
Object.defineProperty(exports, "InvalidEcrecoverSignatureVError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureVError; } });
|
|
@@ -9,9 +9,6 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
|
|
|
9
9
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
10
10
|
Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
11
11
|
Object.defineProperty(exports, "InvalidOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
|
|
12
|
-
Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
|
|
13
|
-
Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
|
|
14
|
-
Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
|
|
15
12
|
Object.defineProperty(exports, "InvalidRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
|
|
16
13
|
Object.defineProperty(exports, "InvalidRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
|
|
17
14
|
Object.defineProperty(exports, "InvalidRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
|
|
@@ -29,3 +26,7 @@ Object.defineProperty(exports, "RatifierV1TakerNotAllowedError", { enumerable: t
|
|
|
29
26
|
Object.defineProperty(exports, "SettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
|
|
30
27
|
Object.defineProperty(exports, "TickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
|
|
31
28
|
Object.defineProperty(exports, "UnknownCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
|
|
29
|
+
var morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
30
|
+
Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
31
|
+
Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
32
|
+
Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
@@ -677,8 +677,99 @@ export interface ActionOutput<TAction extends BaseAction = TransactionAction, TS
|
|
|
677
677
|
readonly buildTx: (signatures?: TSignatures) => Readonly<Transaction<TAction>>;
|
|
678
678
|
readonly getRequirements: (params?: TRequirementsParams) => Promise<readonly ActionRequirement[]>;
|
|
679
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* Narrows an action requirement to an ERC-20 approval transaction.
|
|
682
|
+
*
|
|
683
|
+
* @param requirement - The requirement returned by `getRequirements()` to test.
|
|
684
|
+
* @returns `true` when `requirement.action.type` is `"erc20Approval"`.
|
|
685
|
+
* @example
|
|
686
|
+
* ```ts
|
|
687
|
+
* import { vaults } from "@morpho-org/morpho-test";
|
|
688
|
+
* import {
|
|
689
|
+
* isRequirementApproval,
|
|
690
|
+
* morphoViemExtension,
|
|
691
|
+
* } from "@morpho-org/morpho-sdk";
|
|
692
|
+
* import { createWalletClient, http, publicActions, zeroAddress } from "viem";
|
|
693
|
+
* import { mainnet } from "viem/chains";
|
|
694
|
+
*
|
|
695
|
+
* const client = createWalletClient({
|
|
696
|
+
* chain: mainnet,
|
|
697
|
+
* transport: http(),
|
|
698
|
+
* account: zeroAddress,
|
|
699
|
+
* })
|
|
700
|
+
* .extend(publicActions)
|
|
701
|
+
* .extend(morphoViemExtension());
|
|
702
|
+
*
|
|
703
|
+
* const vault = client.morpho.vaultV1(
|
|
704
|
+
* vaults[mainnet.id].steakUsdc.address,
|
|
705
|
+
* mainnet.id,
|
|
706
|
+
* );
|
|
707
|
+
* const vaultData = await vault.getData();
|
|
708
|
+
* const handle = vault.deposit({
|
|
709
|
+
* amount: 1_000_000n,
|
|
710
|
+
* userAddress: zeroAddress,
|
|
711
|
+
* vaultData,
|
|
712
|
+
* });
|
|
713
|
+
*
|
|
714
|
+
* for (const requirement of await handle.getRequirements()) {
|
|
715
|
+
* if (!isRequirementApproval(requirement)) continue;
|
|
716
|
+
*
|
|
717
|
+
* const { amount, spender } = requirement.action.args;
|
|
718
|
+
* const hash = await client.sendTransaction(requirement);
|
|
719
|
+
* console.log({ amount, spender, hash });
|
|
720
|
+
* await client.waitForTransactionReceipt({ hash });
|
|
721
|
+
* }
|
|
722
|
+
* ```
|
|
723
|
+
*/
|
|
680
724
|
export declare function isRequirementApproval(requirement: unknown): requirement is Transaction<ERC20ApprovalAction>;
|
|
681
|
-
/**
|
|
725
|
+
/**
|
|
726
|
+
* Narrows an action requirement to a Blue authorization call.
|
|
727
|
+
*
|
|
728
|
+
* @param requirement - The requirement returned by `getRequirements()` to test.
|
|
729
|
+
* @returns `true` when the requirement is a call whose `action.type` is `"blueAuthorization"`.
|
|
730
|
+
* @example
|
|
731
|
+
* ```ts
|
|
732
|
+
* import { AccrualPosition } from "@morpho-org/blue-sdk";
|
|
733
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
734
|
+
* import { Time } from "@morpho-org/morpho-ts";
|
|
735
|
+
* import { createWalletClient, http, publicActions, zeroAddress } from "viem";
|
|
736
|
+
* import { mainnet } from "viem/chains";
|
|
737
|
+
* import {
|
|
738
|
+
* isRequirementBlueAuthorization,
|
|
739
|
+
* morphoViemExtension,
|
|
740
|
+
* } from "@morpho-org/morpho-sdk";
|
|
741
|
+
*
|
|
742
|
+
* const client = createWalletClient({
|
|
743
|
+
* chain: mainnet,
|
|
744
|
+
* transport: http(),
|
|
745
|
+
* account: zeroAddress,
|
|
746
|
+
* })
|
|
747
|
+
* .extend(publicActions)
|
|
748
|
+
* .extend(morphoViemExtension());
|
|
749
|
+
*
|
|
750
|
+
* const blue = client.morpho.blue(
|
|
751
|
+
* markets[mainnet.id].usdc_wbtc,
|
|
752
|
+
* mainnet.id,
|
|
753
|
+
* );
|
|
754
|
+
* const positionData = new AccrualPosition(
|
|
755
|
+
* { user: zeroAddress, supplyShares: 0n, borrowShares: 0n, collateral: 10n ** 8n },
|
|
756
|
+
* await blue.getMarketData(),
|
|
757
|
+
* );
|
|
758
|
+
* const handle = blue.borrow({
|
|
759
|
+
* userAddress: zeroAddress,
|
|
760
|
+
* borrowAssets: 1_000_000n,
|
|
761
|
+
* positionData,
|
|
762
|
+
* deadline: Time.timestamp() + 600n,
|
|
763
|
+
* });
|
|
764
|
+
*
|
|
765
|
+
* for (const requirement of await handle.getRequirements()) {
|
|
766
|
+
* if (!isRequirementBlueAuthorization(requirement)) continue;
|
|
767
|
+
*
|
|
768
|
+
* const hash = await client.sendTransaction(requirement);
|
|
769
|
+
* await client.waitForTransactionReceipt({ hash });
|
|
770
|
+
* }
|
|
771
|
+
* ```
|
|
772
|
+
*/
|
|
682
773
|
export declare function isRequirementBlueAuthorization(requirement: unknown): requirement is Transaction<BlueAuthorizationAction>;
|
|
683
774
|
/**
|
|
684
775
|
* Narrows an action requirement to a signature requirement.
|
|
@@ -743,6 +834,16 @@ export declare function isPermit2SignatureTransferSignature(signature: Requireme
|
|
|
743
834
|
*
|
|
744
835
|
* @param signature - The signed requirement to test.
|
|
745
836
|
* @returns `true` when `signature.action.type` is `"authorization"`.
|
|
837
|
+
* @example
|
|
838
|
+
* ```ts
|
|
839
|
+
* import {
|
|
840
|
+
* isAuthorizationSignature,
|
|
841
|
+
* type RequirementSignature,
|
|
842
|
+
* } from "@morpho-org/morpho-sdk";
|
|
843
|
+
*
|
|
844
|
+
* const getAuthorizationNonce = (signature: RequirementSignature): bigint | undefined =>
|
|
845
|
+
* isAuthorizationSignature(signature) ? signature.args.nonce : undefined;
|
|
846
|
+
* ```
|
|
746
847
|
*/
|
|
747
848
|
export declare function isAuthorizationSignature(signature: RequirementSignature): signature is AuthorizationRequirementSignature;
|
|
748
849
|
/** The typed requirement-signature slots a transaction builder consumes, split from a `buildTx` array. */
|
package/lib/cjs/types/action.js
CHANGED
|
@@ -8,6 +8,50 @@ exports.isPermit2SignatureTransferSignature = isPermit2SignatureTransferSignatur
|
|
|
8
8
|
exports.isAuthorizationSignature = isAuthorizationSignature;
|
|
9
9
|
exports.selectRequirementSignatures = selectRequirementSignatures;
|
|
10
10
|
const error_js_1 = require("./error.js");
|
|
11
|
+
/**
|
|
12
|
+
* Narrows an action requirement to an ERC-20 approval transaction.
|
|
13
|
+
*
|
|
14
|
+
* @param requirement - The requirement returned by `getRequirements()` to test.
|
|
15
|
+
* @returns `true` when `requirement.action.type` is `"erc20Approval"`.
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { vaults } from "@morpho-org/morpho-test";
|
|
19
|
+
* import {
|
|
20
|
+
* isRequirementApproval,
|
|
21
|
+
* morphoViemExtension,
|
|
22
|
+
* } from "@morpho-org/morpho-sdk";
|
|
23
|
+
* import { createWalletClient, http, publicActions, zeroAddress } from "viem";
|
|
24
|
+
* import { mainnet } from "viem/chains";
|
|
25
|
+
*
|
|
26
|
+
* const client = createWalletClient({
|
|
27
|
+
* chain: mainnet,
|
|
28
|
+
* transport: http(),
|
|
29
|
+
* account: zeroAddress,
|
|
30
|
+
* })
|
|
31
|
+
* .extend(publicActions)
|
|
32
|
+
* .extend(morphoViemExtension());
|
|
33
|
+
*
|
|
34
|
+
* const vault = client.morpho.vaultV1(
|
|
35
|
+
* vaults[mainnet.id].steakUsdc.address,
|
|
36
|
+
* mainnet.id,
|
|
37
|
+
* );
|
|
38
|
+
* const vaultData = await vault.getData();
|
|
39
|
+
* const handle = vault.deposit({
|
|
40
|
+
* amount: 1_000_000n,
|
|
41
|
+
* userAddress: zeroAddress,
|
|
42
|
+
* vaultData,
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* for (const requirement of await handle.getRequirements()) {
|
|
46
|
+
* if (!isRequirementApproval(requirement)) continue;
|
|
47
|
+
*
|
|
48
|
+
* const { amount, spender } = requirement.action.args;
|
|
49
|
+
* const hash = await client.sendTransaction(requirement);
|
|
50
|
+
* console.log({ amount, spender, hash });
|
|
51
|
+
* await client.waitForTransactionReceipt({ hash });
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
11
55
|
function isRequirementApproval(requirement) {
|
|
12
56
|
return (typeof requirement === "object" &&
|
|
13
57
|
requirement !== null &&
|
|
@@ -20,7 +64,54 @@ function isRequirementApproval(requirement) {
|
|
|
20
64
|
"type" in requirement.action &&
|
|
21
65
|
requirement.action.type === "erc20Approval");
|
|
22
66
|
}
|
|
23
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Narrows an action requirement to a Blue authorization call.
|
|
69
|
+
*
|
|
70
|
+
* @param requirement - The requirement returned by `getRequirements()` to test.
|
|
71
|
+
* @returns `true` when the requirement is a call whose `action.type` is `"blueAuthorization"`.
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { AccrualPosition } from "@morpho-org/blue-sdk";
|
|
75
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
76
|
+
* import { Time } from "@morpho-org/morpho-ts";
|
|
77
|
+
* import { createWalletClient, http, publicActions, zeroAddress } from "viem";
|
|
78
|
+
* import { mainnet } from "viem/chains";
|
|
79
|
+
* import {
|
|
80
|
+
* isRequirementBlueAuthorization,
|
|
81
|
+
* morphoViemExtension,
|
|
82
|
+
* } from "@morpho-org/morpho-sdk";
|
|
83
|
+
*
|
|
84
|
+
* const client = createWalletClient({
|
|
85
|
+
* chain: mainnet,
|
|
86
|
+
* transport: http(),
|
|
87
|
+
* account: zeroAddress,
|
|
88
|
+
* })
|
|
89
|
+
* .extend(publicActions)
|
|
90
|
+
* .extend(morphoViemExtension());
|
|
91
|
+
*
|
|
92
|
+
* const blue = client.morpho.blue(
|
|
93
|
+
* markets[mainnet.id].usdc_wbtc,
|
|
94
|
+
* mainnet.id,
|
|
95
|
+
* );
|
|
96
|
+
* const positionData = new AccrualPosition(
|
|
97
|
+
* { user: zeroAddress, supplyShares: 0n, borrowShares: 0n, collateral: 10n ** 8n },
|
|
98
|
+
* await blue.getMarketData(),
|
|
99
|
+
* );
|
|
100
|
+
* const handle = blue.borrow({
|
|
101
|
+
* userAddress: zeroAddress,
|
|
102
|
+
* borrowAssets: 1_000_000n,
|
|
103
|
+
* positionData,
|
|
104
|
+
* deadline: Time.timestamp() + 600n,
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* for (const requirement of await handle.getRequirements()) {
|
|
108
|
+
* if (!isRequirementBlueAuthorization(requirement)) continue;
|
|
109
|
+
*
|
|
110
|
+
* const hash = await client.sendTransaction(requirement);
|
|
111
|
+
* await client.waitForTransactionReceipt({ hash });
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
24
115
|
function isRequirementBlueAuthorization(requirement) {
|
|
25
116
|
return (typeof requirement === "object" &&
|
|
26
117
|
requirement !== null &&
|
|
@@ -83,6 +174,16 @@ function isPermit2SignatureTransferSignature(signature) {
|
|
|
83
174
|
*
|
|
84
175
|
* @param signature - The signed requirement to test.
|
|
85
176
|
* @returns `true` when `signature.action.type` is `"authorization"`.
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* import {
|
|
180
|
+
* isAuthorizationSignature,
|
|
181
|
+
* type RequirementSignature,
|
|
182
|
+
* } from "@morpho-org/morpho-sdk";
|
|
183
|
+
*
|
|
184
|
+
* const getAuthorizationNonce = (signature: RequirementSignature): bigint | undefined =>
|
|
185
|
+
* isAuthorizationSignature(signature) ? signature.args.nonce : undefined;
|
|
186
|
+
* ```
|
|
86
187
|
*/
|
|
87
188
|
function isAuthorizationSignature(signature) {
|
|
88
189
|
return signature.action.type === "authorization";
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
|
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
-
getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
6
|
+
getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
7
7
|
export { decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
8
8
|
export { EcrecoverRatifier as MidnightEcrecoverRatifier,
|
|
9
9
|
/** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
|
|
@@ -17,7 +17,7 @@ RatifierUtils as MidnightRatifierUtils, SetterRatifier as MidnightSetterRatifier
|
|
|
17
17
|
/** @deprecated Use MidnightSetterRatifier with a tagged tree. */
|
|
18
18
|
SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
|
|
19
19
|
export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, } from "@morpho-org/morpho-ts";
|
|
20
|
-
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
|
|
20
|
+
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, MidnightPositionLib, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
|
|
21
21
|
export { addTransactionMetadata } from "./helpers/metadata.js";
|
|
22
22
|
export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./helpers/previewVaultV2ForceWithdraw.js";
|
|
23
23
|
export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./helpers/previewVaultV2InKindRedeem.js";
|