@morpho-org/morpho-sdk 9.1.0 → 9.3.0-next.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.
Files changed (112) hide show
  1. package/README.md +5 -1
  2. package/lib/cjs/abis.d.ts +2 -2
  3. package/lib/cjs/abis.js +7 -1
  4. package/lib/cjs/actions/midnight/index.d.ts +1 -0
  5. package/lib/cjs/actions/midnight/index.js +1 -0
  6. package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +50 -0
  7. package/lib/cjs/actions/midnight/withdrawCollateral.js +105 -0
  8. package/lib/cjs/blue/abis.d.ts +1 -1
  9. package/lib/cjs/blue/abis.js +5 -1
  10. package/lib/cjs/blue/constants.d.ts +1 -1
  11. package/lib/cjs/blue/constants.js +2 -1
  12. package/lib/cjs/blue/entities.d.ts +4 -4
  13. package/lib/cjs/blue/entities.js +3 -1
  14. package/lib/cjs/blue/errors.d.ts +2 -2
  15. package/lib/cjs/blue/errors.js +5 -1
  16. package/lib/cjs/blue/fetch.d.ts +2 -2
  17. package/lib/cjs/blue/fetch.js +3 -1
  18. package/lib/cjs/blue/utils.d.ts +1 -1
  19. package/lib/cjs/blue/utils.js +2 -1
  20. package/lib/cjs/constants.d.ts +2 -2
  21. package/lib/cjs/constants.js +4 -1
  22. package/lib/cjs/entities/blue/blue.d.ts +71 -16
  23. package/lib/cjs/entities/blue/blue.js +32 -4
  24. package/lib/cjs/entities/index.d.ts +5 -5
  25. package/lib/cjs/entities/index.js +3 -1
  26. package/lib/cjs/entities/midnight/midnight.d.ts +58 -11
  27. package/lib/cjs/entities/midnight/midnight.js +103 -11
  28. package/lib/cjs/entities/midnight/publication.d.ts +2 -1
  29. package/lib/cjs/entities/midnight/publication.js +44 -64
  30. package/lib/cjs/entities/midnight/types.d.ts +8 -0
  31. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +8 -0
  32. package/lib/cjs/entities/vaultV1/vaultV1.js +5 -0
  33. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +37 -9
  34. package/lib/cjs/entities/vaultV2/vaultV2.js +36 -1
  35. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +42 -7
  36. package/lib/cjs/entities/vaultV2BlueReallocationData.js +206 -35
  37. package/lib/cjs/errors.d.ts +4 -4
  38. package/lib/cjs/errors.js +10 -5
  39. package/lib/cjs/fetch.d.ts +2 -2
  40. package/lib/cjs/fetch.js +3 -1
  41. package/lib/cjs/helpers/constant.d.ts +7 -0
  42. package/lib/cjs/helpers/constant.js +8 -1
  43. package/lib/cjs/helpers/deadShares.d.ts +82 -0
  44. package/lib/cjs/helpers/deadShares.js +202 -0
  45. package/lib/cjs/helpers/index.d.ts +2 -1
  46. package/lib/cjs/helpers/index.js +7 -1
  47. package/lib/cjs/midnight/abis.d.ts +1 -1
  48. package/lib/cjs/midnight/abis.js +3 -1
  49. package/lib/cjs/midnight/errors.d.ts +2 -1
  50. package/lib/cjs/midnight/errors.js +5 -4
  51. package/lib/cjs/types/action.d.ts +10 -1
  52. package/lib/cjs/types/error.d.ts +54 -5
  53. package/lib/cjs/types/error.js +60 -6
  54. package/lib/cjs/types/sharedLiquidity.d.ts +10 -6
  55. package/lib/cjs/utils.d.ts +2 -2
  56. package/lib/cjs/utils.js +4 -2
  57. package/lib/esm/abis.d.ts +2 -2
  58. package/lib/esm/abis.js +2 -2
  59. package/lib/esm/actions/midnight/index.d.ts +1 -0
  60. package/lib/esm/actions/midnight/index.js +1 -0
  61. package/lib/esm/actions/midnight/withdrawCollateral.d.ts +50 -0
  62. package/lib/esm/actions/midnight/withdrawCollateral.js +101 -0
  63. package/lib/esm/blue/abis.d.ts +1 -1
  64. package/lib/esm/blue/abis.js +1 -1
  65. package/lib/esm/blue/constants.d.ts +1 -1
  66. package/lib/esm/blue/constants.js +1 -1
  67. package/lib/esm/blue/entities.d.ts +4 -4
  68. package/lib/esm/blue/entities.js +2 -2
  69. package/lib/esm/blue/errors.d.ts +2 -2
  70. package/lib/esm/blue/errors.js +2 -2
  71. package/lib/esm/blue/fetch.d.ts +2 -2
  72. package/lib/esm/blue/fetch.js +2 -2
  73. package/lib/esm/blue/utils.d.ts +1 -1
  74. package/lib/esm/blue/utils.js +1 -1
  75. package/lib/esm/constants.d.ts +2 -2
  76. package/lib/esm/constants.js +2 -2
  77. package/lib/esm/entities/blue/blue.d.ts +71 -16
  78. package/lib/esm/entities/blue/blue.js +34 -6
  79. package/lib/esm/entities/index.d.ts +5 -5
  80. package/lib/esm/entities/index.js +2 -2
  81. package/lib/esm/entities/midnight/midnight.d.ts +58 -11
  82. package/lib/esm/entities/midnight/midnight.js +105 -13
  83. package/lib/esm/entities/midnight/publication.d.ts +2 -1
  84. package/lib/esm/entities/midnight/publication.js +45 -65
  85. package/lib/esm/entities/midnight/types.d.ts +8 -0
  86. package/lib/esm/entities/vaultV1/vaultV1.d.ts +8 -0
  87. package/lib/esm/entities/vaultV1/vaultV1.js +5 -0
  88. package/lib/esm/entities/vaultV2/vaultV2.d.ts +37 -9
  89. package/lib/esm/entities/vaultV2/vaultV2.js +36 -1
  90. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +42 -7
  91. package/lib/esm/entities/vaultV2BlueReallocationData.js +206 -35
  92. package/lib/esm/errors.d.ts +4 -4
  93. package/lib/esm/errors.js +4 -4
  94. package/lib/esm/fetch.d.ts +2 -2
  95. package/lib/esm/fetch.js +2 -2
  96. package/lib/esm/helpers/constant.d.ts +7 -0
  97. package/lib/esm/helpers/constant.js +7 -0
  98. package/lib/esm/helpers/deadShares.d.ts +82 -0
  99. package/lib/esm/helpers/deadShares.js +197 -0
  100. package/lib/esm/helpers/index.d.ts +2 -1
  101. package/lib/esm/helpers/index.js +2 -1
  102. package/lib/esm/midnight/abis.d.ts +1 -1
  103. package/lib/esm/midnight/abis.js +1 -1
  104. package/lib/esm/midnight/errors.d.ts +2 -1
  105. package/lib/esm/midnight/errors.js +2 -1
  106. package/lib/esm/types/action.d.ts +10 -1
  107. package/lib/esm/types/error.d.ts +54 -5
  108. package/lib/esm/types/error.js +57 -5
  109. package/lib/esm/types/sharedLiquidity.d.ts +10 -6
  110. package/lib/esm/utils.d.ts +2 -2
  111. package/lib/esm/utils.js +2 -2
  112. package/package.json +9 -8
@@ -0,0 +1,82 @@
1
+ import { type AccrualVault, type AccrualVaultV2, type IMarket } from "@morpho-org/blue-sdk";
2
+ import type { Address, Hash } from "viem";
3
+ type DeadSharesPath = readonly (Address | Hash)[];
4
+ /**
5
+ * Checks that a Morpho Blue market holds at least `MIN_DEAD_SHARES` supply shares at `DEAD_ADDRESS`.
6
+ *
7
+ * @param market - Fetched market snapshot.
8
+ * @param path - Vaults leading to this market, outermost first; empty for a direct market.
9
+ * @returns Nothing; returns normally when the market passes.
10
+ * @throws {MissingDeadSharesDataError} when `market.deadSupplyShares` was not fetched.
11
+ * @throws {InsufficientDeadSharesError} when the market holds fewer than `MIN_DEAD_SHARES` dead supply shares.
12
+ * @example
13
+ * ```ts
14
+ * import { validateBlueMarketDeadShares } from "@morpho-org/morpho-sdk";
15
+ * import { fetchBlueMarket } from "@morpho-org/morpho-sdk/fetch";
16
+ * import { markets } from "@morpho-org/morpho-test";
17
+ * import { createPublicClient, http } from "viem";
18
+ * import { mainnet } from "viem/chains";
19
+ *
20
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
21
+ * const market = await fetchBlueMarket(markets[mainnet.id].usdc_wbtc.id, client);
22
+ * validateBlueMarketDeadShares(market);
23
+ * // Returns void on success; throws if the snapshot fails the rule.
24
+ * ```
25
+ */
26
+ export declare function validateBlueMarketDeadShares(market: Pick<IMarket, "params" | "deadSupplyShares"> & {
27
+ readonly id: Hash;
28
+ }, path?: DeadSharesPath): void;
29
+ /**
30
+ * Checks that a Vault V1 holds at least `MIN_DEAD_SHARES` shares at `DEAD_ADDRESS` and that every
31
+ * market in its withdraw queue passes `validateBlueMarketDeadShares`.
32
+ *
33
+ * @param vault - Fetched vault snapshot with its withdraw-queue allocations.
34
+ * @param path - Vaults leading to this vault, outermost first; empty for a direct deposit.
35
+ * @returns Nothing; returns normally when the vault and everything it can allocate to pass.
36
+ * @throws {MissingDeadSharesDataError} when `vault.deadShares`, a withdraw-queue allocation or a
37
+ * market's `deadSupplyShares` was not fetched.
38
+ * @throws {InsufficientDeadSharesError} when the vault or one of its withdraw-queue markets holds
39
+ * too few dead shares.
40
+ * @example
41
+ * ```ts
42
+ * import { validateVaultV1DeadShares } from "@morpho-org/morpho-sdk";
43
+ * import { fetchAccrualVault } from "@morpho-org/morpho-sdk/fetch";
44
+ * import { vaults } from "@morpho-org/morpho-test";
45
+ * import { createPublicClient, http } from "viem";
46
+ * import { mainnet } from "viem/chains";
47
+ *
48
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
49
+ * const vault = await fetchAccrualVault(vaults[mainnet.id].steakUsdc.address, client);
50
+ * validateVaultV1DeadShares(vault);
51
+ * // Returns void on success; throws if the snapshot fails the rule.
52
+ * ```
53
+ */
54
+ export declare function validateVaultV1DeadShares(vault: AccrualVault, path?: DeadSharesPath): void;
55
+ /**
56
+ * Checks a Vault V2 against the dead-deposit rule: at least `MIN_DEAD_SHARES` shares at
57
+ * `DEAD_ADDRESS` worth at least `MIN_VAULT_V2_DEAD_ASSETS` assets, a share price above
58
+ * `1 / (10 * virtualShares)`, and every Blue market or Vault V1 it can allocate to (non-zero
59
+ * absolute cap) passing its own rule. Zero-cap entries are skipped.
60
+ *
61
+ * @param vault - Fetched vault snapshot with its adapters and `absoluteCaps`.
62
+ * @param path - Vaults leading to this vault, outermost first; empty for a direct deposit.
63
+ * @returns Nothing; returns normally when the vault and everything it can allocate to pass.
64
+ * @throws {MissingDeadSharesDataError} when a dead-share field, an adapter cap, or the data of an
65
+ * adapter the SDK cannot hydrate is missing.
66
+ * @throws {InsufficientDeadSharesError} when the vault or an allocatable market or Vault V1 fails the rule.
67
+ * @example
68
+ * ```ts
69
+ * import { validateVaultV2DeadShares } from "@morpho-org/morpho-sdk";
70
+ * import { fetchAccrualVaultV2 } from "@morpho-org/morpho-sdk/fetch";
71
+ * import { createPublicClient, http } from "viem";
72
+ * import { mainnet } from "viem/chains";
73
+ *
74
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
75
+ * const keyrockUsdcVaultV2 = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
76
+ * const vault = await fetchAccrualVaultV2(keyrockUsdcVaultV2, client);
77
+ * validateVaultV2DeadShares(vault);
78
+ * // Returns void on success; throws if the snapshot fails the rule.
79
+ * ```
80
+ */
81
+ export declare function validateVaultV2DeadShares(vault: AccrualVaultV2, path?: DeadSharesPath): void;
82
+ export {};
@@ -0,0 +1,197 @@
1
+ import { AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, MarketParams, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk";
2
+ import { InsufficientDeadSharesError, MissingDeadSharesDataError, } from "../types/error.js";
3
+ import { MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS } from "./constant.js";
4
+ /**
5
+ * Checks that a Morpho Blue market holds at least `MIN_DEAD_SHARES` supply shares at `DEAD_ADDRESS`.
6
+ *
7
+ * @param market - Fetched market snapshot.
8
+ * @param path - Vaults leading to this market, outermost first; empty for a direct market.
9
+ * @returns Nothing; returns normally when the market passes.
10
+ * @throws {MissingDeadSharesDataError} when `market.deadSupplyShares` was not fetched.
11
+ * @throws {InsufficientDeadSharesError} when the market holds fewer than `MIN_DEAD_SHARES` dead supply shares.
12
+ * @example
13
+ * ```ts
14
+ * import { validateBlueMarketDeadShares } from "@morpho-org/morpho-sdk";
15
+ * import { fetchBlueMarket } from "@morpho-org/morpho-sdk/fetch";
16
+ * import { markets } from "@morpho-org/morpho-test";
17
+ * import { createPublicClient, http } from "viem";
18
+ * import { mainnet } from "viem/chains";
19
+ *
20
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
21
+ * const market = await fetchBlueMarket(markets[mainnet.id].usdc_wbtc.id, client);
22
+ * validateBlueMarketDeadShares(market);
23
+ * // Returns void on success; throws if the snapshot fails the rule.
24
+ * ```
25
+ */
26
+ export function validateBlueMarketDeadShares(market, path = []) {
27
+ const entity = [...path, market.id];
28
+ if (market.deadSupplyShares == null)
29
+ throw new MissingDeadSharesDataError({ entity, field: "deadSupplyShares" });
30
+ if (market.deadSupplyShares < MIN_DEAD_SHARES)
31
+ throw new InsufficientDeadSharesError({
32
+ entity,
33
+ reason: "deadShares",
34
+ observed: market.deadSupplyShares,
35
+ required: MIN_DEAD_SHARES,
36
+ });
37
+ }
38
+ /**
39
+ * Checks that a Vault V1 holds at least `MIN_DEAD_SHARES` shares at `DEAD_ADDRESS` and that every
40
+ * market in its withdraw queue passes `validateBlueMarketDeadShares`.
41
+ *
42
+ * @param vault - Fetched vault snapshot with its withdraw-queue allocations.
43
+ * @param path - Vaults leading to this vault, outermost first; empty for a direct deposit.
44
+ * @returns Nothing; returns normally when the vault and everything it can allocate to pass.
45
+ * @throws {MissingDeadSharesDataError} when `vault.deadShares`, a withdraw-queue allocation or a
46
+ * market's `deadSupplyShares` was not fetched.
47
+ * @throws {InsufficientDeadSharesError} when the vault or one of its withdraw-queue markets holds
48
+ * too few dead shares.
49
+ * @example
50
+ * ```ts
51
+ * import { validateVaultV1DeadShares } from "@morpho-org/morpho-sdk";
52
+ * import { fetchAccrualVault } from "@morpho-org/morpho-sdk/fetch";
53
+ * import { vaults } from "@morpho-org/morpho-test";
54
+ * import { createPublicClient, http } from "viem";
55
+ * import { mainnet } from "viem/chains";
56
+ *
57
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
58
+ * const vault = await fetchAccrualVault(vaults[mainnet.id].steakUsdc.address, client);
59
+ * validateVaultV1DeadShares(vault);
60
+ * // Returns void on success; throws if the snapshot fails the rule.
61
+ * ```
62
+ */
63
+ export function validateVaultV1DeadShares(vault, path = []) {
64
+ const entity = [...path, vault.address];
65
+ if (vault.deadShares == null)
66
+ throw new MissingDeadSharesDataError({ entity, field: "deadShares" });
67
+ if (vault.deadShares < MIN_DEAD_SHARES)
68
+ throw new InsufficientDeadSharesError({
69
+ entity,
70
+ reason: "deadShares",
71
+ observed: vault.deadShares,
72
+ required: MIN_DEAD_SHARES,
73
+ });
74
+ for (const marketId of vault.withdrawQueue) {
75
+ const allocation = vault.allocations.get(marketId);
76
+ if (allocation == null)
77
+ throw new MissingDeadSharesDataError({
78
+ entity: [...entity, marketId],
79
+ field: "allocation",
80
+ });
81
+ validateBlueMarketDeadShares(allocation.position.market, entity);
82
+ }
83
+ }
84
+ /**
85
+ * Checks a Vault V2 against the dead-deposit rule: at least `MIN_DEAD_SHARES` shares at
86
+ * `DEAD_ADDRESS` worth at least `MIN_VAULT_V2_DEAD_ASSETS` assets, a share price above
87
+ * `1 / (10 * virtualShares)`, and every Blue market or Vault V1 it can allocate to (non-zero
88
+ * absolute cap) passing its own rule. Zero-cap entries are skipped.
89
+ *
90
+ * @param vault - Fetched vault snapshot with its adapters and `absoluteCaps`.
91
+ * @param path - Vaults leading to this vault, outermost first; empty for a direct deposit.
92
+ * @returns Nothing; returns normally when the vault and everything it can allocate to pass.
93
+ * @throws {MissingDeadSharesDataError} when a dead-share field, an adapter cap, or the data of an
94
+ * adapter the SDK cannot hydrate is missing.
95
+ * @throws {InsufficientDeadSharesError} when the vault or an allocatable market or Vault V1 fails the rule.
96
+ * @example
97
+ * ```ts
98
+ * import { validateVaultV2DeadShares } from "@morpho-org/morpho-sdk";
99
+ * import { fetchAccrualVaultV2 } from "@morpho-org/morpho-sdk/fetch";
100
+ * import { createPublicClient, http } from "viem";
101
+ * import { mainnet } from "viem/chains";
102
+ *
103
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
104
+ * const keyrockUsdcVaultV2 = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
105
+ * const vault = await fetchAccrualVaultV2(keyrockUsdcVaultV2, client);
106
+ * validateVaultV2DeadShares(vault);
107
+ * // Returns void on success; throws if the snapshot fails the rule.
108
+ * ```
109
+ */
110
+ export function validateVaultV2DeadShares(vault, path = []) {
111
+ const entity = [...path, vault.address];
112
+ const { deadShares, deadAssets, absoluteCaps } = vault;
113
+ if (deadShares == null)
114
+ throw new MissingDeadSharesDataError({ entity, field: "deadShares" });
115
+ if (deadAssets == null)
116
+ throw new MissingDeadSharesDataError({ entity, field: "deadAssets" });
117
+ if (absoluteCaps == null)
118
+ throw new MissingDeadSharesDataError({ entity, field: "absoluteCaps" });
119
+ if (deadShares < MIN_DEAD_SHARES)
120
+ throw new InsufficientDeadSharesError({
121
+ entity,
122
+ reason: "deadShares",
123
+ observed: deadShares,
124
+ required: MIN_DEAD_SHARES,
125
+ });
126
+ if (deadAssets < MIN_VAULT_V2_DEAD_ASSETS)
127
+ throw new InsufficientDeadSharesError({
128
+ entity,
129
+ reason: "deadAssets",
130
+ observed: deadAssets,
131
+ required: MIN_VAULT_V2_DEAD_ASSETS,
132
+ });
133
+ // Share price (totalAssets + 1) / (totalSupply + virtualShares) must exceed 1 / (10 * virtualShares).
134
+ const priceNumerator = (vault._totalAssets + 1n) * 10n * vault.virtualShares;
135
+ const priceDenominator = vault.totalSupply + vault.virtualShares;
136
+ if (priceNumerator <= priceDenominator)
137
+ throw new InsufficientDeadSharesError({
138
+ entity,
139
+ reason: "sharePrice",
140
+ observed: priceNumerator,
141
+ required: priceDenominator + 1n,
142
+ });
143
+ const capOf = (id, adapter) => {
144
+ const cap = absoluteCaps[id];
145
+ if (cap == null)
146
+ throw new MissingDeadSharesDataError({
147
+ entity: [...entity, adapter],
148
+ field: "absoluteCaps",
149
+ });
150
+ return cap;
151
+ };
152
+ for (const adapter of vault.accrualAdapters) {
153
+ if (adapter instanceof AccrualVaultV2MidnightAdapter)
154
+ continue;
155
+ if (adapter instanceof AccrualVaultV2MorphoVaultV1Adapter) {
156
+ const id = VaultV2MorphoVaultV1Adapter.adapterCapId(adapter.address);
157
+ if (capOf(id, adapter.address) > 0n)
158
+ validateVaultV1DeadShares(adapter.accrualVaultV1, entity);
159
+ }
160
+ else if (adapter instanceof AccrualVaultV2MorphoMarketV1Adapter) {
161
+ for (const { market } of adapter.positions) {
162
+ const id = VaultV2MorphoMarketV1Adapter.adapterMarketCapId(adapter.address, market.params);
163
+ if (capOf(id, adapter.address) > 0n)
164
+ validateBlueMarketDeadShares(market, entity);
165
+ }
166
+ }
167
+ else if (adapter instanceof AccrualVaultV2MorphoMarketV1AdapterV2) {
168
+ for (const market of adapter.markets) {
169
+ const id = VaultV2MorphoMarketV1AdapterV2.adapterMarketCapId(adapter.address, market.params);
170
+ if (capOf(id, adapter.address) > 0n)
171
+ validateBlueMarketDeadShares(market, entity);
172
+ }
173
+ }
174
+ else {
175
+ throw new MissingDeadSharesDataError({
176
+ entity: [...entity, adapter.address],
177
+ field: "adapter",
178
+ });
179
+ }
180
+ }
181
+ // Deposits are allocated to the liquidity market, so the snapshot must hold it even when it
182
+ // has no allocation yet (the adapters only list markets they currently supply to).
183
+ const liquidityAdapter = vault.accrualLiquidityAdapter;
184
+ if (vault.liquidityData === "0x" ||
185
+ !(liquidityAdapter instanceof AccrualVaultV2MorphoMarketV1Adapter ||
186
+ liquidityAdapter instanceof AccrualVaultV2MorphoMarketV1AdapterV2))
187
+ return;
188
+ const liquidityMarketId = MarketParams.fromHex(vault.liquidityData).id;
189
+ const markets = liquidityAdapter instanceof AccrualVaultV2MorphoMarketV1Adapter
190
+ ? liquidityAdapter.positions.map(({ market }) => market)
191
+ : liquidityAdapter.markets;
192
+ if (!markets.some(({ id }) => id === liquidityMarketId))
193
+ throw new MissingDeadSharesDataError({
194
+ entity: [...entity, liquidityAdapter.address, liquidityMarketId],
195
+ field: "liquidityMarket",
196
+ });
197
+ }
@@ -1,5 +1,6 @@
1
1
  export { getMidnightBlueBuyCallbackAddress, getMidnightBlueBuyCallbackData, } from "./callback.js";
2
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, } from "./constant.js";
2
+ export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, } from "./constant.js";
3
+ export { validateBlueMarketDeadShares, validateVaultV1DeadShares, validateVaultV2DeadShares, } from "./deadShares.js";
3
4
  export { addTransactionMetadata } from "./metadata.js";
4
5
  export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./previewVaultV2ForceWithdraw.js";
5
6
  export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./previewVaultV2InKindRedeem.js";
@@ -1,5 +1,6 @@
1
1
  export { getMidnightBlueBuyCallbackAddress, getMidnightBlueBuyCallbackData, } from "./callback.js";
2
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, } from "./constant.js";
2
+ export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, } from "./constant.js";
3
+ export { validateBlueMarketDeadShares, validateVaultV1DeadShares, validateVaultV2DeadShares, } from "./deadShares.js";
3
4
  export { addTransactionMetadata } from "./metadata.js";
4
5
  export { previewVaultV2ForceWithdraw, } from "./previewVaultV2ForceWithdraw.js";
5
6
  export { previewVaultV2InKindRedeem, } from "./previewVaultV2InKindRedeem.js";
@@ -1 +1 @@
1
- export { blueBuyCallbackFactoryAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
1
+ export { blueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
@@ -1 +1 @@
1
- export { blueBuyCallbackFactoryAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
1
+ export { blueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
@@ -1 +1,2 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
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 +1,2 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
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";
@@ -435,6 +435,15 @@ export interface MidnightSupplyCollateralAction extends BaseAction<"midnightSupp
435
435
  readonly onBehalf: Address;
436
436
  }> {
437
437
  }
438
+ /** Metadata for a direct Midnight collateral withdrawal transaction. */
439
+ export interface MidnightWithdrawCollateralAction extends BaseAction<"midnightWithdrawCollateral", {
440
+ readonly market: Hex;
441
+ readonly collateralIndex: bigint;
442
+ readonly assets: bigint;
443
+ readonly onBehalf: Address;
444
+ readonly receiver: Address;
445
+ }> {
446
+ }
438
447
  /** Metadata for a direct Midnight credit redemption transaction. */
439
448
  export interface MidnightRedeemAction extends BaseAction<"midnightRedeem", {
440
449
  readonly market: Hex;
@@ -501,7 +510,7 @@ export interface MidnightCancelAndMakeAction extends BaseAction<"midnightCancelA
501
510
  * VaultV2, Blue, and Midnight flows. The `type` tag discriminates the union so
502
511
  * consumers can `switch` exhaustively on it.
503
512
  */
504
- export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightTakeWithdrawAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MidnightRedeemAction | MidnightTakeRepayWithdrawCollateralAction | MidnightRepayWithdrawCollateralAction | MidnightCancelAndMakeAction;
513
+ export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightTakeWithdrawAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MidnightWithdrawCollateralAction | MidnightRedeemAction | MidnightTakeRepayWithdrawCollateralAction | MidnightRepayWithdrawCollateralAction | MidnightCancelAndMakeAction;
505
514
  /**
506
515
  * Describes a single, immutable, deep-frozen transaction to submit on-chain:
507
516
  * the target `to`, native `value`, encoded call `data`, and the originating
@@ -929,11 +929,16 @@ export declare class RepaySharesExceedDebtError extends Error {
929
929
  });
930
930
  }
931
931
  /**
932
- * Thrown when shared liquidity selected by a Vault V2 reallocation planner cannot
933
- * cover the operation's absolute shortfall on the target market — the resulting
934
- * `morphoBorrow` or `morphoWithdraw` would still revert onchain.
932
+ * Thrown when shared liquidity cannot cover the operation's required
933
+ * reallocated assets. When Blue's balance is explicit, it is also thrown if
934
+ * that balance cannot fund the penalty flash loan, an earlier market-sourced
935
+ * withdrawal, or the final operation transfer. A borrow or withdraw plan that
936
+ * otherwise covers its shortfall but whose planned penalty exceeds its amount
937
+ * instead throws `InputExceedsMaxError`.
935
938
  *
936
- * Pattern-match on the class and inspect `params` to surface the gap to users.
939
+ * `shortfall` is the reallocated assets required by the operation and is
940
+ * comparable to `available`. Pattern-match on the class and inspect `params`
941
+ * to surface the gap to users.
937
942
  */
938
943
  export declare class InsufficientSharedLiquidityError extends Error {
939
944
  readonly params: {
@@ -1316,7 +1321,12 @@ export declare class MidnightOfferCallbackDataMismatchError extends Error {
1316
1321
  readonly actualCallbackData: Hex;
1317
1322
  });
1318
1323
  }
1319
- /** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
1324
+ /**
1325
+ * Thrown when loan assets would be parked in a Morpho Blue market with no existing supply.
1326
+ *
1327
+ * @deprecated `supplyBlueMakeLend` now throws `InsufficientDeadSharesError` or
1328
+ * `MissingDeadSharesDataError` instead; kept exported so existing `instanceof` checks compile.
1329
+ */
1320
1330
  export declare class EmptyBlueParkingMarketError extends Error {
1321
1331
  constructor(params: {
1322
1332
  readonly marketId: MarketId;
@@ -1332,6 +1342,45 @@ export declare class ZeroBlueParkingSharesError extends Error {
1332
1342
  readonly assets: bigint;
1333
1343
  });
1334
1344
  }
1345
+ /** Which dead-deposit condition an entity failed. */
1346
+ export type DeadSharesFailureReason = "deadShares" | "deadAssets" | "sharePrice";
1347
+ /**
1348
+ * Thrown when a Morpho Blue market or vault, or a market or Vault V1 it can allocate to, fails the
1349
+ * dead-deposit rule that protects deposits against share-price inflation.
1350
+ */
1351
+ export declare class InsufficientDeadSharesError extends Error {
1352
+ /** Failing entity, outermost vault first; the last element is the market id or vault address. */
1353
+ readonly entity: readonly (Address | Hash)[];
1354
+ /** Failed condition. */
1355
+ readonly reason: DeadSharesFailureReason;
1356
+ /** Observed dead shares or assets; for `sharePrice`, `(totalAssets + 1) * 10 * virtualShares`. */
1357
+ readonly observed: bigint;
1358
+ /** Required minimum; for `sharePrice`, `totalSupply + virtualShares + 1`. */
1359
+ readonly required: bigint;
1360
+ constructor(params: {
1361
+ readonly entity: readonly (Address | Hash)[];
1362
+ readonly reason: DeadSharesFailureReason;
1363
+ readonly observed: bigint;
1364
+ readonly required: bigint;
1365
+ });
1366
+ }
1367
+ /** Snapshot field the dead-deposit check needs but the snapshot does not carry. */
1368
+ export type DeadSharesDataField = "deadSupplyShares" | "deadShares" | "deadAssets" | "absoluteCaps" | "allocation" | "adapter" | "liquidityMarket";
1369
+ /**
1370
+ * Thrown when a market or vault snapshot lacks the data the dead-deposit check needs, such as a
1371
+ * snapshot built by hand, from the Morpho API or by an older fetcher, or a Vault V2 adapter the
1372
+ * SDK cannot hydrate. The check fails closed rather than pass unverified data.
1373
+ */
1374
+ export declare class MissingDeadSharesDataError extends Error {
1375
+ /** Entity missing the data, outermost vault first. */
1376
+ readonly entity: readonly (Address | Hash)[];
1377
+ /** Missing field. */
1378
+ readonly field: DeadSharesDataField;
1379
+ constructor(params: {
1380
+ readonly entity: readonly (Address | Hash)[];
1381
+ readonly field: DeadSharesDataField;
1382
+ });
1383
+ }
1335
1384
  /** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
1336
1385
  export declare class MidnightTakeableOfferMarketMismatchError extends Error {
1337
1386
  constructor(params: {
@@ -1144,11 +1144,16 @@ export class RepaySharesExceedDebtError extends Error {
1144
1144
  }
1145
1145
  }
1146
1146
  /**
1147
- * Thrown when shared liquidity selected by a Vault V2 reallocation planner cannot
1148
- * cover the operation's absolute shortfall on the target market — the resulting
1149
- * `morphoBorrow` or `morphoWithdraw` would still revert onchain.
1147
+ * Thrown when shared liquidity cannot cover the operation's required
1148
+ * reallocated assets. When Blue's balance is explicit, it is also thrown if
1149
+ * that balance cannot fund the penalty flash loan, an earlier market-sourced
1150
+ * withdrawal, or the final operation transfer. A borrow or withdraw plan that
1151
+ * otherwise covers its shortfall but whose planned penalty exceeds its amount
1152
+ * instead throws `InputExceedsMaxError`.
1150
1153
  *
1151
- * Pattern-match on the class and inspect `params` to surface the gap to users.
1154
+ * `shortfall` is the reallocated assets required by the operation and is
1155
+ * comparable to `available`. Pattern-match on the class and inspect `params`
1156
+ * to surface the gap to users.
1152
1157
  */
1153
1158
  export class InsufficientSharedLiquidityError extends Error {
1154
1159
  params;
@@ -1580,7 +1585,12 @@ export class MidnightOfferCallbackDataMismatchError extends Error {
1580
1585
  this.name = "MidnightOfferCallbackDataMismatchError";
1581
1586
  }
1582
1587
  }
1583
- /** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
1588
+ /**
1589
+ * Thrown when loan assets would be parked in a Morpho Blue market with no existing supply.
1590
+ *
1591
+ * @deprecated `supplyBlueMakeLend` now throws `InsufficientDeadSharesError` or
1592
+ * `MissingDeadSharesDataError` instead; kept exported so existing `instanceof` checks compile.
1593
+ */
1584
1594
  export class EmptyBlueParkingMarketError extends Error {
1585
1595
  constructor(params) {
1586
1596
  super(`Morpho Blue market "${params.marketId}" has no supply shares. Parking assets in an empty market is exposed to supply-share-price inflation; choose a market with existing supply.`);
@@ -1597,6 +1607,48 @@ export class ZeroBlueParkingSharesError extends Error {
1597
1607
  this.name = "ZeroBlueParkingSharesError";
1598
1608
  }
1599
1609
  }
1610
+ /**
1611
+ * Thrown when a Morpho Blue market or vault, or a market or Vault V1 it can allocate to, fails the
1612
+ * dead-deposit rule that protects deposits against share-price inflation.
1613
+ */
1614
+ export class InsufficientDeadSharesError extends Error {
1615
+ /** Failing entity, outermost vault first; the last element is the market id or vault address. */
1616
+ entity;
1617
+ /** Failed condition. */
1618
+ reason;
1619
+ /** Observed dead shares or assets; for `sharePrice`, `(totalAssets + 1) * 10 * virtualShares`. */
1620
+ observed;
1621
+ /** Required minimum; for `sharePrice`, `totalSupply + virtualShares + 1`. */
1622
+ required;
1623
+ constructor(params) {
1624
+ const target = params.entity.join(" > ");
1625
+ super(params.reason === "sharePrice"
1626
+ ? `Vault V2 "${target}" share price is at or below 1 / (10 * virtualShares) ("${params.observed}" < "${params.required}"), so it may have been deflated before its dead deposit. Choose another vault.`
1627
+ : `"${target}" holds "${params.observed}" dead ${params.reason === "deadShares" ? "shares" : "assets"} at 0x000000000000000000000000000000000000dEaD, below the required "${params.required}". Choose a market or vault with a sufficient dead deposit.`);
1628
+ this.name = "InsufficientDeadSharesError";
1629
+ this.entity = params.entity;
1630
+ this.reason = params.reason;
1631
+ this.observed = params.observed;
1632
+ this.required = params.required;
1633
+ }
1634
+ }
1635
+ /**
1636
+ * Thrown when a market or vault snapshot lacks the data the dead-deposit check needs, such as a
1637
+ * snapshot built by hand, from the Morpho API or by an older fetcher, or a Vault V2 adapter the
1638
+ * SDK cannot hydrate. The check fails closed rather than pass unverified data.
1639
+ */
1640
+ export class MissingDeadSharesDataError extends Error {
1641
+ /** Entity missing the data, outermost vault first. */
1642
+ entity;
1643
+ /** Missing field. */
1644
+ field;
1645
+ constructor(params) {
1646
+ super(`"${params.entity.join(" > ")}" has no "${params.field}" data for the dead-deposit check. Fetch the snapshot with the @morpho-org/blue-sdk-viem fetchers before building the transaction.`);
1647
+ this.name = "MissingDeadSharesDataError";
1648
+ this.entity = params.entity;
1649
+ this.field = params.field;
1650
+ }
1651
+ }
1600
1652
  /** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
1601
1653
  export class MidnightTakeableOfferMarketMismatchError extends Error {
1602
1654
  constructor(params) {
@@ -56,9 +56,11 @@ export interface VaultV2BluePublicAllocatorOptions {
56
56
  readonly reallocatableVaults?: Iterable<Address>;
57
57
  /**
58
58
  * Maximum utilization source markets may reach during friendly discovery,
59
- * scaled by WAD. Within each penalty tier, the amount-aware planner falls
60
- * back to 100% only when that tier's friendly pass leaves an absolute
61
- * shortfall.
59
+ * scaled by WAD. Within each penalty tier, the planner tries this friendly
60
+ * utilization before falling back to 100% when required coverage remains.
61
+ * Positive-penalty tiers cover the remaining absolute shortfall or, when
62
+ * larger, Blue's loan-token balance deficit while BlueBundlesV1 flash-loans
63
+ * the penalty.
62
64
  *
63
65
  * @default 90% (900000000000000000n)
64
66
  */
@@ -66,9 +68,11 @@ export interface VaultV2BluePublicAllocatorOptions {
66
68
  /**
67
69
  * Maximum proportional vault-asset penalty accepted per call, scaled by
68
70
  * WAD; higher-penalty vaults are ignored. Must not exceed WAD. Operation
69
- * plans consider penalty tiers ascending, free first. Each tier uses friendly
70
- * source utilization (90% by default) before 100%; positive tiers cover only
71
- * the remaining absolute shortfall. Free capacity inside
71
+ * plans consider penalty tiers ascending, free first. Each tier tries
72
+ * friendly source utilization (90% by default) before falling back to 100%
73
+ * when required coverage remains. Positive-penalty tiers cover the remaining
74
+ * absolute shortfall or, when larger, Blue's loan-token balance deficit while
75
+ * BlueBundlesV1 flash-loans the penalty. Free capacity inside
72
76
  * `allocatorCapHeadroom` stays unused, so a penalized leg can cover it.
73
77
  * Getters count all vaults up to this limit. For `refinance`, compute the
74
78
  * plan on the destination-market handle (for example,
@@ -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 { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, 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 { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
22
22
  export { addTransactionMetadata } from "./helpers/metadata.js";
23
23
  export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./helpers/previewVaultV2ForceWithdraw.js";
package/lib/esm/utils.js CHANGED
@@ -2,7 +2,7 @@ export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
5
+ getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
6
6
  export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
7
7
  export { EcrecoverRatifier as MidnightEcrecoverRatifier,
8
8
  /** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
@@ -15,7 +15,7 @@ RateRatifierV1Utils as MidnightRateRatifierV1Utils, Ratifier as MidnightRatifier
15
15
  RatifierUtils as MidnightRatifierUtils, SetterRatifier as MidnightSetterRatifier,
16
16
  /** @deprecated Use MidnightSetterRatifier with a tagged tree. */
17
17
  SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
18
- 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";
18
+ 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";
19
19
  export { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
20
20
  export { addTransactionMetadata } from "./helpers/metadata.js";
21
21
  export { previewVaultV2ForceWithdraw, } from "./helpers/previewVaultV2ForceWithdraw.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/morpho-sdk",
3
3
  "description": "Abstraction layer for Morpho's complexity.",
4
- "version": "9.1.0",
4
+ "version": "9.3.0-next.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -150,20 +150,21 @@
150
150
  "MIGRATION-v5-to-v6.md",
151
151
  "MIGRATION-v6-to-v7.md",
152
152
  "MIGRATION-v7-to-v8.md",
153
- "MIGRATION-v8-to-v9.md"
153
+ "MIGRATION-v8-to-v9.md",
154
+ "DEAD-SHARE-PROTECTION.md"
154
155
  ],
155
156
  "dependencies": {
156
- "@morpho-org/blue-sdk": "^8.0.2",
157
- "@morpho-org/blue-sdk-viem": "^7.1.0",
158
- "@morpho-org/midnight-sdk": "^2.2.1",
159
- "@morpho-org/morpho-ts": "^4.1.0"
157
+ "@morpho-org/blue-sdk": "^8.2.0-next.0",
158
+ "@morpho-org/blue-sdk-viem": "^7.3.0-next.0",
159
+ "@morpho-org/midnight-sdk": "^2.4.0-next.0",
160
+ "@morpho-org/morpho-ts": "^4.2.0-next.1"
160
161
  },
161
162
  "peerDependencies": {
162
163
  "viem": "^2.0.0"
163
164
  },
164
165
  "devDependencies": {
165
- "@morpho-org/morpho-test": "^4.1.0",
166
- "@morpho-org/test": "^2.11.0",
166
+ "@morpho-org/morpho-test": "^4.2.0",
167
+ "@morpho-org/test": "^2.13.0-next.0",
167
168
  "fast-check": "^4.9.0",
168
169
  "typescript": "7.0.2",
169
170
  "viem": "^2.55.10",