@morpho-org/morpho-sdk 5.10.1 → 5.12.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 (79) hide show
  1. package/README.md +6 -0
  2. package/lib/cjs/abis.d.ts +17 -2
  3. package/lib/cjs/abis.js +14 -1
  4. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
  5. package/lib/cjs/blue/abis.d.ts +5 -1
  6. package/lib/cjs/blue/abis.js +2 -0
  7. package/lib/cjs/blue/entities.d.ts +8 -2
  8. package/lib/cjs/blue/entities.js +1 -0
  9. package/lib/cjs/blue/errors.d.ts +1 -1
  10. package/lib/cjs/blue/errors.js +2 -1
  11. package/lib/cjs/blue/fetch.d.ts +3 -1
  12. package/lib/cjs/blue/fetch.js +1 -0
  13. package/lib/cjs/entities/blue/blue.d.ts +10 -0
  14. package/lib/cjs/entities/blue/blue.js +9 -2
  15. package/lib/cjs/entities/index.d.ts +8 -2
  16. package/lib/cjs/entities/index.js +1 -0
  17. package/lib/cjs/entities/midnight/midnight.js +5 -13
  18. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +2 -0
  19. package/lib/cjs/entities/vaultV1/vaultV1.js +2 -0
  20. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +6 -0
  21. package/lib/cjs/entities/vaultV1ReallocationData.js +20 -5
  22. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +2 -0
  23. package/lib/cjs/entities/vaultV2/vaultV2.js +3 -1
  24. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
  25. package/lib/cjs/entities/vaultV2BlueReallocationData.js +41 -12
  26. package/lib/cjs/errors.d.ts +1 -1
  27. package/lib/cjs/errors.js +3 -2
  28. package/lib/cjs/fetch.d.ts +3 -1
  29. package/lib/cjs/fetch.js +1 -0
  30. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +2 -0
  31. package/lib/cjs/helpers/computeVaultV1Reallocations.js +2 -0
  32. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  33. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
  34. package/lib/cjs/helpers/validate.d.ts +30 -8
  35. package/lib/cjs/helpers/validate.js +30 -8
  36. package/lib/cjs/types/action.d.ts +57 -4
  37. package/lib/cjs/types/error.d.ts +1 -1
  38. package/lib/cjs/types/error.js +2 -2
  39. package/lib/cjs/types/sharedLiquidity.d.ts +2 -2
  40. package/lib/esm/abis.d.ts +17 -2
  41. package/lib/esm/abis.js +17 -2
  42. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
  43. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +3 -1
  44. package/lib/esm/blue/abis.d.ts +5 -1
  45. package/lib/esm/blue/abis.js +5 -1
  46. package/lib/esm/blue/entities.d.ts +8 -2
  47. package/lib/esm/blue/entities.js +3 -1
  48. package/lib/esm/blue/errors.d.ts +1 -1
  49. package/lib/esm/blue/errors.js +1 -1
  50. package/lib/esm/blue/fetch.d.ts +3 -1
  51. package/lib/esm/blue/fetch.js +3 -1
  52. package/lib/esm/entities/blue/blue.d.ts +10 -0
  53. package/lib/esm/entities/blue/blue.js +9 -2
  54. package/lib/esm/entities/index.d.ts +8 -2
  55. package/lib/esm/entities/index.js +3 -1
  56. package/lib/esm/entities/midnight/midnight.js +5 -13
  57. package/lib/esm/entities/vaultV1/vaultV1.d.ts +2 -0
  58. package/lib/esm/entities/vaultV1/vaultV1.js +2 -0
  59. package/lib/esm/entities/vaultV1ReallocationData.d.ts +6 -0
  60. package/lib/esm/entities/vaultV1ReallocationData.js +20 -5
  61. package/lib/esm/entities/vaultV2/vaultV2.d.ts +2 -0
  62. package/lib/esm/entities/vaultV2/vaultV2.js +3 -1
  63. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
  64. package/lib/esm/entities/vaultV2BlueReallocationData.js +41 -12
  65. package/lib/esm/errors.d.ts +1 -1
  66. package/lib/esm/errors.js +1 -1
  67. package/lib/esm/fetch.d.ts +3 -1
  68. package/lib/esm/fetch.js +3 -1
  69. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +2 -0
  70. package/lib/esm/helpers/computeVaultV1Reallocations.js +2 -0
  71. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  72. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
  73. package/lib/esm/helpers/validate.d.ts +30 -8
  74. package/lib/esm/helpers/validate.js +30 -8
  75. package/lib/esm/types/action.d.ts +57 -4
  76. package/lib/esm/types/error.d.ts +1 -1
  77. package/lib/esm/types/error.js +2 -2
  78. package/lib/esm/types/sharedLiquidity.d.ts +2 -2
  79. package/package.json +5 -5
@@ -210,10 +210,13 @@ export class VaultV1ReallocationData {
210
210
  * Returned `data` normalizes `vault.publicAllocatorConfig.accruedFee` to the
211
211
  * on-chain `reallocateTo` fee semantics: one fee charge per vault with at
212
212
  * least one computed withdrawal.
213
+ * Sources with zero allocator withdrawal capacity and destinations with no deposit capacity
214
+ * are skipped before projecting source interest.
213
215
  *
214
216
  * @param marketId - Target market to supply with shared liquidity.
215
217
  * @param options - Optional allocator discovery options.
216
218
  * @returns Computed source-market withdrawals and the post-reallocation state.
219
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
217
220
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
218
221
  * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
219
222
  * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
@@ -311,6 +314,7 @@ export class VaultV1ReallocationData {
311
314
  * @param marketId - Target market to supply with shared liquidity.
312
315
  * @param options - Optional allocator discovery options.
313
316
  * @returns Computed source-market withdrawals and the post-reallocation state.
317
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
314
318
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
315
319
  * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
316
320
  * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
@@ -330,6 +334,7 @@ export class VaultV1ReallocationData {
330
334
  * @param marketId - Target market that would receive the liquidity.
331
335
  * @param options - Optional allocator discovery options.
332
336
  * @returns Total reallocatable assets in loan-token units; `0n` when none is available.
337
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
333
338
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
334
339
  * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
335
340
  * `VaultV2BlueReallocationData.getPublicReallocationLiquidity`.
@@ -386,6 +391,7 @@ export class VaultV1ReallocationData {
386
391
  * @param utilization - Utilization to bring the market to, scaled by WAD. Defaults to {@link DEFAULT_SUPPLY_TARGET_UTILIZATION}.
387
392
  * @param options - Optional reallocation options (supply target utilization trigger, timestamp, withdrawal caps).
388
393
  * @returns Available liquidity to the given utilization in loan-token units; `0n` when none is available.
394
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
389
395
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
390
396
  * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
391
397
  * `VaultV2BlueReallocationData.getAvailableLiquidityToUtilization`.
@@ -443,25 +449,34 @@ export class VaultV1ReallocationData {
443
449
  getLargestVaultWithdrawal({ vault, marketId, withdrawals, defaultMaxWithdrawalUtilization, maxWithdrawalUtilization, timestamp, }) {
444
450
  return _try(() => {
445
451
  const { cap, pendingCap, publicAllocatorConfig } = this.getVaultMarketConfig(vault, marketId);
452
+ const maxIn = publicAllocatorConfig?.maxIn ?? 0n;
446
453
  const validCap = pendingCap.validAt >= timestamp
447
454
  ? MathLib.min(pendingCap.value, cap)
448
455
  : cap;
456
+ if (maxIn === 0n || validCap === 0n)
457
+ return { vault };
449
458
  const suppliable = MathLib.zeroFloorSub(validCap, this.getAccrualPosition(vault, marketId).accrueInterest(timestamp)
450
459
  .supplyAssets);
460
+ if (suppliable === 0n)
461
+ return { vault };
451
462
  const marketWithdrawals = this.getVault(vault)
452
463
  .withdrawQueue.filter((srcMarketId) => srcMarketId !== marketId &&
453
464
  !withdrawals.some((withdrawal) => withdrawal.id === srcMarketId && withdrawal.vault === vault))
454
465
  .map((srcMarketId) => {
455
466
  const withdrawal = _try(() => {
456
- const srcPosition = this.getAccrualPosition(vault, srcMarketId).accrueInterest(timestamp);
457
- const targetUtilizationLiquidity = srcPosition.market.getWithdrawToUtilization(maxWithdrawalUtilization[srcMarketId] ??
458
- defaultMaxWithdrawalUtilization);
459
467
  const srcConfig = this.getVaultMarketConfig(vault, srcMarketId);
460
- if (!srcConfig.enabled)
468
+ const maxOut = srcConfig.publicAllocatorConfig?.maxOut ?? 0n;
469
+ if (!srcConfig.enabled || maxOut === 0n)
470
+ return { id: srcMarketId, assets: 0n };
471
+ const rawSrcPosition = this.getAccrualPosition(vault, srcMarketId);
472
+ if (rawSrcPosition.supplyShares === 0n)
461
473
  return { id: srcMarketId, assets: 0n };
474
+ const srcPosition = rawSrcPosition.accrueInterest(timestamp);
475
+ const targetUtilizationLiquidity = srcPosition.market.getWithdrawToUtilization(maxWithdrawalUtilization[srcMarketId] ??
476
+ defaultMaxWithdrawalUtilization);
462
477
  return {
463
478
  id: srcMarketId,
464
- assets: MathLib.min(srcPosition.supplyAssets, targetUtilizationLiquidity, suppliable, publicAllocatorConfig?.maxIn ?? 0n, srcConfig.publicAllocatorConfig?.maxOut ?? 0n),
479
+ assets: MathLib.min(srcPosition.supplyAssets, targetUtilizationLiquidity, suppliable, maxIn, maxOut),
465
480
  };
466
481
  }, UnknownDataError);
467
482
  return withdrawal ?? { id: srcMarketId, assets: 0n };
@@ -30,6 +30,7 @@ export interface VaultV2Actions {
30
30
  * @returns {Object} The result object.
31
31
  * @returns {Readonly<Transaction<VaultV2DepositAction>>} returns.tx The prepared deposit transaction.
32
32
  * @returns {Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement<PermitRequirementSignature>)[]>} returns.getRequirements The function for retrieving all required approval transactions.
33
+ * @throws {UnsupportedBlueMarketIrmError} when an underlying market with positive debt uses an unsupported IRM.
33
34
  */
34
35
  deposit: (params: {
35
36
  userAddress: Address;
@@ -101,6 +102,7 @@ export interface VaultV2Actions {
101
102
  * @param params.deadline - Optional shared permit/bundle deadline; defaults to two hours from now.
102
103
  * @returns Lazy prerequisite resolution and a synchronous transaction builder.
103
104
  * @throws {ChainIdMismatchError} when the client and entity target different chains.
105
+ * @throws {UnsupportedBlueMarketIrmError} when an adapter-listed market with positive debt uses an unsupported IRM.
104
106
  * @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
105
107
  * @throws {NonPositiveInputError} when `amount` is not positive.
106
108
  * @throws {InKindRedeemZeroDeallocationError} when the vault has no idle assets and the
@@ -173,7 +173,9 @@ export class MorphoVaultV2 {
173
173
  if (assetsToDeallocate > 0n && marketParamsListSnapshot.length === 0) {
174
174
  throw new EmptyMarketParamsListError();
175
175
  }
176
- const assetsByMarket = new Map(soleAdapter.markets.map((market) => [
176
+ const assetsByMarket = new Map(soleAdapter.markets
177
+ .filter((market) => (soleAdapter.supplyShares[market.id] ?? 0n) !== 0n)
178
+ .map((market) => [
177
179
  market.id,
178
180
  market
179
181
  .accrueInterest(now)
@@ -363,7 +363,11 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
363
363
  * utilization defaults to 90% and is configurable through
364
364
  * `options.maxWithdrawalUtilization`. Vaults whose configured penalty exceeds
365
365
  * `options.maxPenalty` are ignored. By default, only zero-penalty vaults are
366
- * considered.
366
+ * considered. Targets with no remaining supply or allocator capacity are skipped before
367
+ * projecting source interest. The adapter's minimum share minting requirement, supply-share
368
+ * limits, and target absolute or zero relative caps are checked against a one-asset deposit.
369
+ * Shared cap IDs that a source withdrawal can reduce remain eligible, as do deposits whose
370
+ * allocation does not increase after rounding.
367
371
  *
368
372
  * Shared-cap discovery is conservative. Operation planning searches at most
369
373
  * 1,024 base units above its targeted amount for the nearest executable fit.
@@ -374,6 +378,7 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
374
378
  * @param marketId - Target Blue market id.
375
379
  * @param options - Optional discovery controls and operation to support.
376
380
  * @returns Flat action-ready reallocations and their post-simulation state.
381
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
377
382
  * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
378
383
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
379
384
  * @throws {NonPositiveInputError} when the operation amount is not positive and planning is enabled.
@@ -430,6 +435,7 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
430
435
  * @param marketId - Target Blue market id.
431
436
  * @param options - Optional timestamp, enable flag, vault allowlist, source utilization ceiling, and maximum penalty.
432
437
  * @returns Reallocatable market and idle assets, or `0n` when none are available; rounding-only shared-cap fits may be conservatively omitted.
438
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
433
439
  * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
434
440
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
435
441
  * @throws {UnknownReallocationMarketError} when a required market is absent.
@@ -470,6 +476,7 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
470
476
  * @param utilization - Desired utilization, scaled by WAD. Defaults to 90%.
471
477
  * @param options - Optional timestamp, enable flag, vault allowlist, source utilization ceiling, and maximum penalty.
472
478
  * @returns Borrowable assets while remaining at or below `utilization`; rounding-only shared-cap fits may be conservatively omitted.
479
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
473
480
  * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
474
481
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
475
482
  * @throws {UnknownReallocationMarketError} when a required market is absent.
@@ -572,7 +572,11 @@ export class VaultV2BlueReallocationData {
572
572
  * utilization defaults to 90% and is configurable through
573
573
  * `options.maxWithdrawalUtilization`. Vaults whose configured penalty exceeds
574
574
  * `options.maxPenalty` are ignored. By default, only zero-penalty vaults are
575
- * considered.
575
+ * considered. Targets with no remaining supply or allocator capacity are skipped before
576
+ * projecting source interest. The adapter's minimum share minting requirement, supply-share
577
+ * limits, and target absolute or zero relative caps are checked against a one-asset deposit.
578
+ * Shared cap IDs that a source withdrawal can reduce remain eligible, as do deposits whose
579
+ * allocation does not increase after rounding.
576
580
  *
577
581
  * Shared-cap discovery is conservative. Operation planning searches at most
578
582
  * 1,024 base units above its targeted amount for the nearest executable fit.
@@ -583,6 +587,7 @@ export class VaultV2BlueReallocationData {
583
587
  * @param marketId - Target Blue market id.
584
588
  * @param options - Optional discovery controls and operation to support.
585
589
  * @returns Flat action-ready reallocations and their post-simulation state.
590
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
586
591
  * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
587
592
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
588
593
  * @throws {NonPositiveInputError} when the operation amount is not positive and planning is enabled.
@@ -723,9 +728,7 @@ export class VaultV2BlueReallocationData {
723
728
  : BigInt(options.timestamp);
724
729
  let data = this;
725
730
  let simulationContext = context;
726
- data.setMarkets(Object.values(data.markets)
727
- .filter((market) => market != null)
728
- .map((market) => market.accrueInterest(timestamp)));
731
+ data.setMarkets([data.getMarket(marketId).accrueInterest(timestamp)]);
729
732
  const reallocations = [];
730
733
  const configuredVaults = Object.keys(data.vaults);
731
734
  const vaultKeyByLower = new Map(configuredVaults.map((vault) => [vault.toLowerCase(), vault]));
@@ -760,6 +763,7 @@ export class VaultV2BlueReallocationData {
760
763
  activeAdaptersCache.set(vaultAddress, activeAdapters);
761
764
  }
762
765
  const targetSupplyHeadroom = MathLib.zeroFloorSub(MathLib.MAX_UINT_128, targetMarket.totalSupplyAssets);
766
+ const minimumSupply = targetMarket.supply(1n, 0n);
763
767
  const rawCandidates = [];
764
768
  // Missing nested allocator state means the snapshot is incomplete, so
765
769
  // typed getter errors below must propagate. Only explicit zero caps or
@@ -781,17 +785,35 @@ export class VaultV2BlueReallocationData {
781
785
  const adapterCapAllocation = data.getAllocation(vaultAddress, adapterCapId);
782
786
  const collateralCapAllocation = data.getAllocation(vaultAddress, collateralCapId);
783
787
  const adapterMarketCapAllocation = data.getAllocation(vaultAddress, adapterMarketCapId);
784
- if ([
788
+ const targetAllocations = [
785
789
  adapterCapAllocation,
786
790
  collateralCapAllocation,
787
791
  adapterMarketCapAllocation,
788
- ].some(({ absoluteCap }) => absoluteCap === 0n))
792
+ ];
793
+ if (targetAllocations.some(({ absoluteCap }) => absoluteCap === 0n))
789
794
  continue;
790
795
  const expectedSupplyAssets = targetMarket.toSupplyAssets(adapter.supplyShares[marketId] ?? 0n);
791
796
  const untracked = MathLib.zeroFloorSub(expectedSupplyAssets, adapterMarketCapAllocation.allocation);
792
797
  const allocatorHeadroom = marketPublicAllocatorConfig.getMaxIn(adapterMarketCapAllocation.allocation + untracked);
798
+ const minimumAllocation = minimumSupply.market.toSupplyAssets((adapter.supplyShares[marketId] ?? 0n) + minimumSupply.shares);
799
+ const minimumAllocationChange = minimumAllocation - adapterMarketCapAllocation.allocation;
800
+ const blockedTargetIds = targetAllocations
801
+ .filter(({ allocation, absoluteCap, relativeCap }) => {
802
+ const nextAllocation = allocation + minimumAllocationChange;
803
+ return (nextAllocation > absoluteCap ||
804
+ (relativeCap === 0n && nextAllocation > 0n));
805
+ })
806
+ .map(({ id }) => id);
807
+ // MorphoMarketV1AdapterV2 rejects supplies that mint fewer shares than assets.
808
+ if (targetSupplyHeadroom === 0n ||
809
+ allocatorHeadroom === 0n ||
810
+ minimumSupply.shares < minimumSupply.assets ||
811
+ minimumSupply.market.totalSupplyShares > MathLib.MAX_UINT_128 ||
812
+ blockedTargetIds.includes(adapterMarketCapId))
813
+ continue;
793
814
  if (publicAllocatorConfig.canPullFromIdle &&
794
- availableIdleAssets > 0n) {
815
+ availableIdleAssets > 0n &&
816
+ blockedTargetIds.length === 0) {
795
817
  const assets = MathLib.min(MathLib.MAX_UINT_128, targetSupplyHeadroom, allocatorHeadroom, availableIdleAssets);
796
818
  if (assets > 0n) {
797
819
  rawCandidates.push({
@@ -827,8 +849,16 @@ export class VaultV2BlueReallocationData {
827
849
  const sourceAllocations = sourceIds.map((id) => data.getAllocation(vaultAddress, id));
828
850
  if (sourceAllocations.some(({ allocation }) => allocation === 0n))
829
851
  continue;
830
- const expectedSourceSupplyAssets = sourceMarket.toSupplyAssets(sourceAdapter.supplyShares[sourceMarket.id] ?? 0n);
831
- const assets = MathLib.min(MathLib.MAX_UINT_128, targetSupplyHeadroom, allocatorHeadroom, expectedSourceSupplyAssets, sourceMarket.getWithdrawToUtilization(maxWithdrawalUtilization));
852
+ const sourceSupplyShares = sourceAdapter.supplyShares[sourceMarket.id] ?? 0n;
853
+ if (sourceSupplyShares === 0n)
854
+ continue;
855
+ // A withdrawal can create target headroom only for shared cap IDs.
856
+ if (blockedTargetIds.some((id) => !sourceIds.includes(id)))
857
+ continue;
858
+ const accruedSourceMarket = sourceMarket.accrueInterest(timestamp);
859
+ data.setMarkets([accruedSourceMarket]);
860
+ const expectedSourceSupplyAssets = accruedSourceMarket.toSupplyAssets(sourceSupplyShares);
861
+ const assets = MathLib.min(MathLib.MAX_UINT_128, targetSupplyHeadroom, allocatorHeadroom, expectedSourceSupplyAssets, accruedSourceMarket.getWithdrawToUtilization(maxWithdrawalUtilization));
832
862
  if (assets <= 0n)
833
863
  continue;
834
864
  rawCandidates.push({
@@ -849,9 +879,6 @@ export class VaultV2BlueReallocationData {
849
879
  for (const reallocation of rawCandidates) {
850
880
  let lower = 0n;
851
881
  let upper = reallocation.assets;
852
- // MorphoMarketV1AdapterV2 rejects supplies that mint fewer shares than assets.
853
- if (targetMarket.toSupplyShares(upper, "Down") < upper)
854
- continue;
855
882
  const reallocationAdapter = data.getAdapter(reallocation.vault, reallocation.to.adapter);
856
883
  const targetIds = getAdapterIds(adapterIdsCache, reallocationAdapter, targetMarket);
857
884
  const sourceIds = new Set();
@@ -955,6 +982,7 @@ export class VaultV2BlueReallocationData {
955
982
  * @param marketId - Target Blue market id.
956
983
  * @param options - Optional timestamp, enable flag, vault allowlist, source utilization ceiling, and maximum penalty.
957
984
  * @returns Reallocatable market and idle assets, or `0n` when none are available; rounding-only shared-cap fits may be conservatively omitted.
985
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
958
986
  * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
959
987
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
960
988
  * @throws {UnknownReallocationMarketError} when a required market is absent.
@@ -1007,6 +1035,7 @@ export class VaultV2BlueReallocationData {
1007
1035
  * @param utilization - Desired utilization, scaled by WAD. Defaults to 90%.
1008
1036
  * @param options - Optional timestamp, enable flag, vault allowlist, source utilization ceiling, and maximum penalty.
1009
1037
  * @returns Borrowable assets while remaining at or below `utilization`; rounding-only shared-cap fits may be conservatively omitted.
1038
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1010
1039
  * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
1011
1040
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
1012
1041
  * @throws {UnknownReallocationMarketError} when a required market is absent.
@@ -14,7 +14,7 @@ UnknownTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError,
14
14
  /** @deprecated Use UnknownBlueTokenPriceError or the raw protocol subpath. */
15
15
  UnknownTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError,
16
16
  /** @deprecated Use UnknownBlueVaultConfigError or the raw protocol subpath. */
17
- UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
17
+ UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
18
18
  /** @deprecated Use UnsupportedBluePreLiquidationParamsError or the raw protocol subpath. */
19
19
  UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError,
20
20
  /** @deprecated Use UnsupportedBlueVaultV2AdapterError or the raw protocol subpath. */
package/lib/esm/errors.js CHANGED
@@ -14,7 +14,7 @@ UnknownTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError,
14
14
  /** @deprecated Use UnknownBlueTokenPriceError or the raw protocol subpath. */
15
15
  UnknownTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError,
16
16
  /** @deprecated Use UnknownBlueVaultConfigError or the raw protocol subpath. */
17
- UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
17
+ UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
18
18
  /** @deprecated Use UnsupportedBluePreLiquidationParamsError or the raw protocol subpath. */
19
19
  UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError,
20
20
  /** @deprecated Use UnsupportedBlueVaultV2AdapterError or the raw protocol subpath. */
@@ -12,5 +12,7 @@ fetchPreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidatio
12
12
  /** @deprecated Use `fetchBluePreLiquidationPosition` or the raw `/blue/fetch` subpath. */
13
13
  fetchPreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser,
14
14
  /** @deprecated Use `fetchBlueUser` or the raw `/blue/fetch` subpath. */
15
- fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
15
+ fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
16
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
17
+ fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
16
18
  export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
package/lib/esm/fetch.js CHANGED
@@ -12,5 +12,7 @@ fetchPreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidatio
12
12
  /** @deprecated Use `fetchBluePreLiquidationPosition` or the raw `/blue/fetch` subpath. */
13
13
  fetchPreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser,
14
14
  /** @deprecated Use `fetchBlueUser` or the raw `/blue/fetch` subpath. */
15
- fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
15
+ fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
16
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
17
+ fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
16
18
  export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
@@ -22,6 +22,7 @@ import { type ReallocationComputeOptions, type VaultV1Reallocation } from "../ty
22
22
  * @param params.amount - The borrow or withdraw amount used to compute the post-state utilization.
23
23
  * @param params.options - Optional reallocation computation options.
24
24
  * @returns Array of vault reallocations, sorted with withdrawals in ascending market id order.
25
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
25
26
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market — preventing fee-bearing reallocations from being attached to a call that would still revert onchain.
26
27
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets` — the on-chain call would revert regardless of reallocations.
27
28
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
@@ -78,6 +79,7 @@ export declare const computeVaultV1Reallocations: ({ reallocationData: data, mar
78
79
  /**
79
80
  * Deprecated name for the Vault V1 amount-aware reallocation planner.
80
81
  *
82
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
81
83
  * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
82
84
  * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
83
85
  */
@@ -75,6 +75,7 @@ const capVaultWithdrawals = (withdrawals, assets) => {
75
75
  * @param params.amount - The borrow or withdraw amount used to compute the post-state utilization.
76
76
  * @param params.options - Optional reallocation computation options.
77
77
  * @returns Array of vault reallocations, sorted with withdrawals in ascending market id order.
78
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
78
79
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market — preventing fee-bearing reallocations from being attached to a call that would still revert onchain.
79
80
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets` — the on-chain call would revert regardless of reallocations.
80
81
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
@@ -239,6 +240,7 @@ export const computeVaultV1Reallocations = ({ reallocationData: data, marketId,
239
240
  /**
240
241
  * Deprecated name for the Vault V1 amount-aware reallocation planner.
241
242
  *
243
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
242
244
  * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
243
245
  * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
244
246
  */
@@ -35,6 +35,7 @@ export interface VaultV2InKindRedeemMarketPreview {
35
35
  * @param params.requestedExitAssets - Positive penalty-inclusive amount the user wants to exit.
36
36
  * @param params.timestamp - Timestamp used to accrue Morpho Blue markets before calculating capacity.
37
37
  * @returns Frontend-ready market choices, or an empty list when no choices are available.
38
+ * @throws {UnsupportedBlueMarketIrmError} when an adapter-listed market with positive debt uses an unsupported IRM.
38
39
  * @example
39
40
  * ```ts
40
41
  * import { previewVaultV2InKindRedeem } from "@morpho-org/morpho-sdk";
@@ -11,6 +11,7 @@ import { AccrualVaultV2MorphoMarketV1AdapterV2, MathLib, } from "@morpho-org/blu
11
11
  * @param params.requestedExitAssets - Positive penalty-inclusive amount the user wants to exit.
12
12
  * @param params.timestamp - Timestamp used to accrue Morpho Blue markets before calculating capacity.
13
13
  * @returns Frontend-ready market choices, or an empty list when no choices are available.
14
+ * @throws {UnsupportedBlueMarketIrmError} when an adapter-listed market with positive debt uses an unsupported IRM.
14
15
  * @example
15
16
  * ```ts
16
17
  * import { previewVaultV2InKindRedeem } from "@morpho-org/morpho-sdk";
@@ -37,6 +38,7 @@ export function previewVaultV2InKindRedeem(vaultData, params) {
37
38
  const penalty = vaultData.forceDeallocatePenalties[adapter.address] ?? 0n;
38
39
  const availableIdleAssets = vaultData.assetBalance;
39
40
  const allocations = adapter.markets
41
+ .filter((market) => (adapter.supplyShares[market.id] ?? 0n) !== 0n)
40
42
  .map((market) => ({
41
43
  market,
42
44
  allocationAssets: market
@@ -23,22 +23,44 @@ export declare const validateMidnightMarketChainId: (market: MidnightMarketInput
23
23
  * Asserts that the client has a connected account AND that it matches
24
24
  * the provided user address.
25
25
  *
26
- * Used internally by the signature requirements (`encodeErc20Permit`,
27
- * `encodeErc20Permit2Approve`) to enforce builder = signer at `sign()` time:
28
- * the signing flow is the only path where an account/address mismatch
29
- * is a real security concern (rather than just an integrator footgun).
26
+ * Used at `sign()` time by the shared `signAndVerifyTypedData` helper (which
27
+ * backs the permit, Permit2, Blue authorization, and Midnight offer-root
28
+ * signature flows) and by `encodeVaultSharesPermit`, to enforce builder =
29
+ * signer: the signing flow is
30
+ * the only path where an account/address mismatch is a real security concern
31
+ * (rather than just an integrator footgun).
30
32
  *
31
33
  * Transaction builders no longer call this helper — callers are
32
34
  * responsible for keeping `userAddress` aligned with the signing account
33
35
  * at the builder layer.
34
36
  *
35
- * Throws {@link MissingClientPropertyError} if the client has no account.
36
- * Throws {@link AddressMismatchError} if the client account differs from
37
- * `userAddress`.
38
- *
39
37
  * @param clientAccountAddress - The client's account address; if undefined,
40
38
  * `MissingClientPropertyError` is thrown.
41
39
  * @param userAddress - The user address provided by the caller.
40
+ * @returns Nothing; narrows `clientAccountAddress` to a defined `Address` when
41
+ * it is present and equal to `userAddress`.
42
+ * @throws {MissingClientPropertyError} when the client has no connected account.
43
+ * @throws {AddressMismatchError} when the client account differs from
44
+ * `userAddress`.
45
+ * @example
46
+ * ```ts
47
+ * import { createWalletClient, http } from "viem";
48
+ * import { privateKeyToAccount } from "viem/accounts";
49
+ * import { mainnet } from "viem/chains";
50
+ * import { validateUserAddress } from "@morpho-org/morpho-sdk";
51
+ *
52
+ * const account = privateKeyToAccount("0x...");
53
+ * const walletClient = createWalletClient({
54
+ * account,
55
+ * chain: mainnet,
56
+ * transport: http(),
57
+ * });
58
+ *
59
+ * // Inside a `sign()` flow, before producing a typed-data signature:
60
+ * validateUserAddress(walletClient.account?.address, account.address);
61
+ * // Passes when the connected account equals the expected signer;
62
+ * // throws if the wallet has no account or signs for a different address.
63
+ * ```
42
64
  */
43
65
  export declare function validateUserAddress(clientAccountAddress: Address | undefined, userAddress: Address): asserts clientAccountAddress is Address;
44
66
  /**
@@ -35,22 +35,44 @@ export const validateMidnightMarketChainId = (market, chainId) => {
35
35
  * Asserts that the client has a connected account AND that it matches
36
36
  * the provided user address.
37
37
  *
38
- * Used internally by the signature requirements (`encodeErc20Permit`,
39
- * `encodeErc20Permit2Approve`) to enforce builder = signer at `sign()` time:
40
- * the signing flow is the only path where an account/address mismatch
41
- * is a real security concern (rather than just an integrator footgun).
38
+ * Used at `sign()` time by the shared `signAndVerifyTypedData` helper (which
39
+ * backs the permit, Permit2, Blue authorization, and Midnight offer-root
40
+ * signature flows) and by `encodeVaultSharesPermit`, to enforce builder =
41
+ * signer: the signing flow is
42
+ * the only path where an account/address mismatch is a real security concern
43
+ * (rather than just an integrator footgun).
42
44
  *
43
45
  * Transaction builders no longer call this helper — callers are
44
46
  * responsible for keeping `userAddress` aligned with the signing account
45
47
  * at the builder layer.
46
48
  *
47
- * Throws {@link MissingClientPropertyError} if the client has no account.
48
- * Throws {@link AddressMismatchError} if the client account differs from
49
- * `userAddress`.
50
- *
51
49
  * @param clientAccountAddress - The client's account address; if undefined,
52
50
  * `MissingClientPropertyError` is thrown.
53
51
  * @param userAddress - The user address provided by the caller.
52
+ * @returns Nothing; narrows `clientAccountAddress` to a defined `Address` when
53
+ * it is present and equal to `userAddress`.
54
+ * @throws {MissingClientPropertyError} when the client has no connected account.
55
+ * @throws {AddressMismatchError} when the client account differs from
56
+ * `userAddress`.
57
+ * @example
58
+ * ```ts
59
+ * import { createWalletClient, http } from "viem";
60
+ * import { privateKeyToAccount } from "viem/accounts";
61
+ * import { mainnet } from "viem/chains";
62
+ * import { validateUserAddress } from "@morpho-org/morpho-sdk";
63
+ *
64
+ * const account = privateKeyToAccount("0x...");
65
+ * const walletClient = createWalletClient({
66
+ * account,
67
+ * chain: mainnet,
68
+ * transport: http(),
69
+ * });
70
+ *
71
+ * // Inside a `sign()` flow, before producing a typed-data signature:
72
+ * validateUserAddress(walletClient.account?.address, account.address);
73
+ * // Passes when the connected account equals the expected signer;
74
+ * // throws if the wallet has no account or signs for a different address.
75
+ * ```
54
76
  */
55
77
  export function validateUserAddress(clientAccountAddress, userAddress) {
56
78
  if (clientAccountAddress === undefined) {
@@ -1,6 +1,17 @@
1
1
  import type { InputMarketParams } from "@morpho-org/blue-sdk";
2
2
  import type { Address, Hex, WalletClient } from "viem";
3
3
  import type { Deallocation } from "./deallocation.js";
4
+ /**
5
+ * Serves as the common discriminated action-metadata base shared by both
6
+ * {@link TransactionAction} (actions that carry encoded calldata) and
7
+ * {@link SignatureRequirementAction} (signature requirements whose metadata is
8
+ * exposed before any calldata exists). Each concrete action narrows
9
+ * {@link BaseAction} on its literal `type` tag and carries an
10
+ * operation-specific `args` record surfaced for tracing.
11
+ *
12
+ * @typeParam TType - Literal discriminator identifying the action.
13
+ * @typeParam TArgs - The action's argument record.
14
+ */
4
15
  export interface BaseAction<TType extends string = string, TArgs extends Record<string, unknown> = Record<string, unknown>> {
5
16
  readonly type: TType;
6
17
  readonly args: TArgs;
@@ -115,7 +126,11 @@ export interface BlueWithdrawAction extends BaseAction<"blueWithdraw", {
115
126
  shares: bigint;
116
127
  receiver: Address;
117
128
  minSharePrice: bigint;
118
- /** Native-token fees paid to PublicAllocator V1. */
129
+ /**
130
+ * Native-token fees paid to PublicAllocator V1.
131
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
132
+ * Vault V2 loan-token penalties are reported in `reallocationPenaltyAssets`.
133
+ */
119
134
  reallocationFee: bigint;
120
135
  /** Loan-token assets donated as BluePublicAllocator V2 penalties. */
121
136
  readonly reallocationPenaltyAssets: bigint;
@@ -133,7 +148,11 @@ export interface BlueBorrowAction extends BaseAction<"blueBorrow", {
133
148
  amount: bigint;
134
149
  receiver: Address;
135
150
  minSharePrice: bigint;
136
- /** Native-token fees paid to PublicAllocator V1. */
151
+ /**
152
+ * Native-token fees paid to PublicAllocator V1.
153
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
154
+ * Vault V2 loan-token penalties are reported in `reallocationPenaltyAssets`.
155
+ */
137
156
  reallocationFee: bigint;
138
157
  /** Loan-token assets donated as BluePublicAllocator V2 penalties. */
139
158
  readonly reallocationPenaltyAssets: bigint;
@@ -147,7 +166,11 @@ export interface BlueSupplyCollateralBorrowAction extends BaseAction<"blueSupply
147
166
  onBehalf: Address;
148
167
  receiver: Address;
149
168
  nativeAmount?: bigint;
150
- /** Native-token fees paid to PublicAllocator V1. */
169
+ /**
170
+ * Native-token fees paid to PublicAllocator V1.
171
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
172
+ * Vault V2 loan-token penalties are reported in `reallocationPenaltyAssets`.
173
+ */
151
174
  reallocationFee: bigint;
152
175
  /** Loan-token assets donated as BluePublicAllocator V2 penalties. */
153
176
  readonly reallocationPenaltyAssets: bigint;
@@ -194,7 +217,11 @@ export interface BlueRefinanceAction extends BaseAction<"blueRefinance", {
194
217
  readonly minBorrowSharePrice: bigint;
195
218
  readonly maxRepaySharePrice: bigint;
196
219
  readonly user: Address;
197
- /** Native-token fees paid to PublicAllocator V1. */
220
+ /**
221
+ * Native-token fees paid to PublicAllocator V1.
222
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
223
+ * Vault V2 loan-token penalties are reported in `reallocationPenaltyAssets`.
224
+ */
198
225
  readonly reallocationFee: bigint;
199
226
  /** Loan-token assets donated as BluePublicAllocator V2 penalties. */
200
227
  readonly reallocationPenaltyAssets: bigint;
@@ -358,7 +385,19 @@ export interface MidnightCancelOfferAction extends BaseAction<"midnightCancelOff
358
385
  readonly onBehalf: Address;
359
386
  }> {
360
387
  }
388
+ /**
389
+ * Enumerates every action a {@link Transaction} can describe across the VaultV1,
390
+ * VaultV2, Blue, and Midnight flows. The `type` tag discriminates the union so
391
+ * consumers can `switch` exhaustively on it.
392
+ */
361
393
  export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueWithdrawAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | SetterRatifierRatifyRootAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MempoolSubmitOffersAction | MidnightRedeemAction | MidnightRepayWithdrawCollateralAction | MidnightCancelOfferAction;
394
+ /**
395
+ * Describes a single, immutable, deep-frozen transaction to submit on-chain:
396
+ * the target `to`, native `value`, encoded call `data`, and the originating
397
+ * {@link BaseAction} for tracing. Every action builder returns one.
398
+ *
399
+ * @typeParam TAction - The action that produced this transaction.
400
+ */
362
401
  export interface Transaction<TAction extends BaseAction = TransactionAction> {
363
402
  readonly to: Address;
364
403
  readonly value: bigint;
@@ -379,6 +418,14 @@ export type DepositAmountArgs = {
379
418
  nativeAmount: bigint;
380
419
  amount?: bigint;
381
420
  };
421
+ /**
422
+ * Holds the pre-resolved arguments for an ERC-2612 `permit`: the signed approval
423
+ * of `amount` of `asset` from `owner` to the permitted spender, bounded by the
424
+ * `deadline` timestamp and consuming the given `nonce`. The spender is the
425
+ * GeneralAdapter1/Bundler3 periphery for bundler permits, or the standalone
426
+ * `VaultExitBundlesV1` contract for an in-kind vault redemption permit produced
427
+ * by `encodeVaultSharesPermit`.
428
+ */
382
429
  export interface PermitArgs {
383
430
  owner: Address;
384
431
  nonce: bigint;
@@ -387,6 +434,12 @@ export interface PermitArgs {
387
434
  amount: bigint;
388
435
  deadline: bigint;
389
436
  }
437
+ /**
438
+ * Holds the pre-resolved arguments for a Permit2 `permit` bundler call. It
439
+ * mirrors {@link PermitArgs} but adds the Permit2 allowance `expiration` (when
440
+ * the on-chain allowance lapses) alongside the signature `deadline` (by when the
441
+ * signature must be submitted).
442
+ */
390
443
  export interface Permit2Args {
391
444
  owner: Address;
392
445
  nonce: bigint;
@@ -971,7 +971,7 @@ export declare class MidnightOfferRootOfferCountMismatchError extends Error {
971
971
  actualOffers: number;
972
972
  });
973
973
  }
974
- /** Thrown when a Midnight offer-root signature was not prepared by this maker flow. */
974
+ /** Thrown when a Midnight offer-root signature carries no encoded payload. */
975
975
  export declare class UnpreparedMidnightOfferRootSignatureError extends Error {
976
976
  constructor();
977
977
  }
@@ -1057,10 +1057,10 @@ export class MidnightOfferRootOfferCountMismatchError extends Error {
1057
1057
  super(`Midnight offer root offer-count mismatch: expected "${params.expectedOffers}", got "${params.actualOffers}". Rebuild the flow and sign again.`);
1058
1058
  }
1059
1059
  }
1060
- /** Thrown when a Midnight offer-root signature was not prepared by this maker flow. */
1060
+ /** Thrown when a Midnight offer-root signature carries no encoded payload. */
1061
1061
  export class UnpreparedMidnightOfferRootSignatureError extends Error {
1062
1062
  constructor() {
1063
- super("Midnight offer root signature was not prepared for this offer tree. Sign this flow's offer-root requirement before building the submit transaction.");
1063
+ super("Midnight offer root signature carries no encoded payload. Sign the offer-root requirement (its signature already includes the payload) before building the submit transaction.");
1064
1064
  }
1065
1065
  }
1066
1066
  /** Thrown when a Midnight redeem flow finds no credit units for the user. */