@morpho-org/morpho-sdk 6.1.0 → 6.3.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 (57) hide show
  1. package/lib/cjs/blue/errors.d.ts +1 -1
  2. package/lib/cjs/blue/errors.js +2 -1
  3. package/lib/cjs/constants.d.ts +1 -1
  4. package/lib/cjs/constants.js +2 -1
  5. package/lib/cjs/entities/blue/blue.d.ts +14 -2
  6. package/lib/cjs/entities/blue/blue.js +7 -1
  7. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +1 -0
  8. package/lib/cjs/entities/vaultV1/vaultV1.js +1 -0
  9. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +34 -9
  10. package/lib/cjs/entities/vaultV2BlueReallocationData.js +167 -47
  11. package/lib/cjs/errors.d.ts +1 -1
  12. package/lib/cjs/errors.js +3 -2
  13. package/lib/cjs/helpers/constant.d.ts +8 -0
  14. package/lib/cjs/helpers/constant.js +10 -1
  15. package/lib/cjs/helpers/encodeDeallocation.d.ts +1 -0
  16. package/lib/cjs/helpers/encodeDeallocation.js +1 -0
  17. package/lib/cjs/helpers/index.d.ts +1 -1
  18. package/lib/cjs/helpers/index.js +2 -1
  19. package/lib/cjs/helpers/metadata.d.ts +13 -0
  20. package/lib/cjs/helpers/metadata.js +13 -0
  21. package/lib/cjs/helpers/utilization.d.ts +13 -0
  22. package/lib/cjs/helpers/utilization.js +19 -1
  23. package/lib/cjs/helpers/validate.d.ts +0 -2
  24. package/lib/cjs/helpers/validate.js +2 -3
  25. package/lib/cjs/types/data.d.ts +3 -0
  26. package/lib/cjs/types/entity.d.ts +3 -0
  27. package/lib/cjs/types/metadata.d.ts +6 -0
  28. package/lib/cjs/types/sharedLiquidity.d.ts +19 -1
  29. package/lib/esm/blue/errors.d.ts +1 -1
  30. package/lib/esm/blue/errors.js +1 -1
  31. package/lib/esm/constants.d.ts +1 -1
  32. package/lib/esm/constants.js +1 -1
  33. package/lib/esm/entities/blue/blue.d.ts +14 -2
  34. package/lib/esm/entities/blue/blue.js +7 -1
  35. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +1 -0
  36. package/lib/esm/entities/vaultV1/vaultV1.js +1 -0
  37. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +34 -9
  38. package/lib/esm/entities/vaultV2BlueReallocationData.js +168 -48
  39. package/lib/esm/errors.d.ts +1 -1
  40. package/lib/esm/errors.js +1 -1
  41. package/lib/esm/helpers/constant.d.ts +8 -0
  42. package/lib/esm/helpers/constant.js +9 -0
  43. package/lib/esm/helpers/encodeDeallocation.d.ts +1 -0
  44. package/lib/esm/helpers/encodeDeallocation.js +1 -0
  45. package/lib/esm/helpers/index.d.ts +1 -1
  46. package/lib/esm/helpers/index.js +1 -1
  47. package/lib/esm/helpers/metadata.d.ts +13 -0
  48. package/lib/esm/helpers/metadata.js +13 -0
  49. package/lib/esm/helpers/utilization.d.ts +13 -0
  50. package/lib/esm/helpers/utilization.js +18 -1
  51. package/lib/esm/helpers/validate.d.ts +0 -2
  52. package/lib/esm/helpers/validate.js +1 -1
  53. package/lib/esm/types/data.d.ts +3 -0
  54. package/lib/esm/types/entity.d.ts +3 -0
  55. package/lib/esm/types/metadata.d.ts +6 -0
  56. package/lib/esm/types/sharedLiquidity.d.ts +19 -1
  57. package/package.json +4 -4
@@ -2,8 +2,6 @@ import { type AccrualPosition, type MarketId } from "@morpho-org/blue-sdk";
2
2
  import type { MarketInput as MidnightMarketInput } from "@morpho-org/midnight-sdk";
3
3
  import { type Address } from "viem";
4
4
  import { type VaultV2BlueReallocation } from "../types/index.js";
5
- /** @internal */
6
- export declare const compareMarketIds: (idA: MarketId, idB: MarketId) => -1 | 0 | 1;
7
5
  /**
8
6
  * Rejects a `bigint` field that falls outside the unsigned 256-bit ABI range so a direct caller
9
7
  * gets the SDK's typed error instead of viem's `IntegerOutOfRangeError` at encode time. `maxUint256`
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateUint256Field = exports.compareMarketIds = void 0;
3
+ exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateUint256Field = void 0;
4
4
  exports.validateUserAddress = validateUserAddress;
5
5
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
6
6
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
@@ -17,7 +17,6 @@ const compareMarketIds = (idA, idB) => {
17
17
  return -1;
18
18
  return 0;
19
19
  };
20
- exports.compareMarketIds = compareMarketIds;
21
20
  /**
22
21
  * Rejects a `bigint` field that falls outside the unsigned 256-bit ABI range so a direct caller
23
22
  * gets the SDK's typed error instead of viem's `IntegerOutOfRangeError` at encode time. `maxUint256`
@@ -452,7 +451,7 @@ const validateVaultV2BlueReallocations = (reallocations, targetMarketId) => {
452
451
  }
453
452
  penaltyByVault.set(penaltyKey, reallocation.penalty);
454
453
  if (sourceMarketId !== undefined &&
455
- (0, exports.compareMarketIds)(sourceMarketId, targetMarketId) === 0) {
454
+ compareMarketIds(sourceMarketId, targetMarketId) === 0) {
456
455
  throw new index_js_1.ReallocationWithdrawalOnTargetMarketError(reallocation.vault, sourceMarketId);
457
456
  }
458
457
  }
@@ -1,2 +1,5 @@
1
1
  import type { CallParameters, UnionPick } from "viem";
2
+ /**
3
+ * Viem call options forwarded to SDK data-fetching helpers.
4
+ */
2
5
  export type FetchParameters = UnionPick<CallParameters, "account" | "blockNumber" | "blockTag" | "stateOverride">;
@@ -1,5 +1,8 @@
1
1
  import type { Address } from "viem";
2
+ /** Identifies a vault and its underlying asset. */
2
3
  export interface VaultParams {
4
+ /** The vault contract address. */
3
5
  vault: Address;
6
+ /** The address of the vault's underlying asset. */
4
7
  asset: Address;
5
8
  }
@@ -1,4 +1,10 @@
1
+ /** Analytics metadata appended to transaction calldata. */
1
2
  export interface Metadata {
3
+ /**
4
+ * Raw or 0x-prefixed hex origin of at most four bytes (eight hex characters) and even length.
5
+ * Invalid values are dropped with a console warning.
6
+ */
2
7
  origin: string;
8
+ /** When true, append the current Unix timestamp as four bytes before the origin. */
3
9
  timestamp?: boolean;
4
10
  }
@@ -4,8 +4,26 @@ import type { Address } from "viem";
4
4
  export interface VaultV2BluePublicAllocatorOptions {
5
5
  /** Whether Vault V2 public allocator discovery is enabled. */
6
6
  readonly enabled?: boolean;
7
- /** Timestamp at which market and Vault V2 interest is evaluated. */
7
+ /**
8
+ * Timestamp at which market and Vault V2 state is evaluated. Canonical state
9
+ * and the returned post-state stay at this timestamp; only target-market cap
10
+ * checks reserve interest on the vault's existing allocation through this
11
+ * timestamp plus `capAccrualBuffer`. For market-source reallocations the
12
+ * source position's interest is also reserved on cap ids shared with the
13
+ * target, and reserves persist across every leg of a plan.
14
+ */
8
15
  readonly timestamp?: BigIntish;
16
+ /**
17
+ * Seconds beyond `timestamp` through which target-market cap checks reserve
18
+ * interest on the vault's existing allocation. For market-source
19
+ * reallocations the source position's interest is also reserved on cap ids
20
+ * shared with the target, and reserves persist across every leg of a plan.
21
+ * Market and Vault V2 state, including the returned post-state, stay at
22
+ * `timestamp`. Set to `0n` to disable.
23
+ *
24
+ * @default DEFAULT_CAP_ACCRUAL_BUFFER (2h)
25
+ */
26
+ readonly capAccrualBuffer?: BigIntish;
9
27
  /**
10
28
  * Vault V2 addresses to consider. Arrays, readonly arrays, sets, and other
11
29
  * iterables are accepted. Defaults to every vault in the reallocation data.
@@ -1,4 +1,4 @@
1
1
  export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
- export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
4
+ export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MarketParamsIdMismatchError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
@@ -1,4 +1,4 @@
1
1
  export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
- export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
4
+ export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MarketParamsIdMismatchError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
@@ -1,4 +1,4 @@
1
1
  export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
2
2
  export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
3
3
  export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
4
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_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, } from "./helpers/constant.js";
4
+ export { APPROVE_ONLY_ONCE_TOKENS, 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, } from "./helpers/constant.js";
@@ -1,4 +1,4 @@
1
1
  export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
2
2
  export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
3
3
  export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
4
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_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, } from "./helpers/constant.js";
4
+ export { APPROVE_ONLY_ONCE_TOKENS, 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, } from "./helpers/constant.js";
@@ -814,13 +814,19 @@ export interface BlueActions {
814
814
  }) => Promise<VaultV2BlueReallocationData>;
815
815
  /**
816
816
  * Computes Vault V2 BluePublicAllocator reallocations for this market.
817
+ * Market/vault state and returned post-state stay at `options.timestamp`;
818
+ * only target-market cap checks reserve interest on the vault's existing
819
+ * allocation through `timestamp + capAccrualBuffer` (two hours by default;
820
+ * `0n` disables it). For market-source reallocations the source position's
821
+ * interest is also reserved on cap ids shared with the target, and reserves
822
+ * persist across every leg of a plan.
817
823
  *
818
824
  * @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
819
825
  * @param params.options - Optional allocator discovery controls and operation to support.
820
826
  * @returns Action-ready reallocations and their post-simulation state.
821
827
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
822
828
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
823
- * @throws {NegativeInputError} when a utilization or penalty limit is negative.
829
+ * @throws {NegativeInputError} when the cap-accrual buffer, utilization, or penalty limit is negative.
824
830
  * @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
825
831
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
826
832
  * @throws {UnknownReallocationMarketError} when a required market is absent.
@@ -1026,13 +1032,19 @@ export declare class MorphoBlue implements BlueActions {
1026
1032
  }): Promise<VaultV2BlueReallocationData>;
1027
1033
  /**
1028
1034
  * Computes Vault V2 BluePublicAllocator reallocations for this market.
1035
+ * Market/vault state and returned post-state stay at `options.timestamp`;
1036
+ * only target-market cap checks reserve interest on the vault's existing
1037
+ * allocation through `timestamp + capAccrualBuffer` (two hours by default;
1038
+ * `0n` disables it). For market-source reallocations the source position's
1039
+ * interest is also reserved on cap ids shared with the target, and reserves
1040
+ * persist across every leg of a plan.
1029
1041
  *
1030
1042
  * @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
1031
1043
  * @param params.options - Optional allocator discovery controls and operation to support.
1032
1044
  * @returns Action-ready reallocations and their post-simulation state.
1033
1045
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
1034
1046
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1035
- * @throws {NegativeInputError} when a utilization or penalty limit is negative.
1047
+ * @throws {NegativeInputError} when the cap-accrual buffer, utilization, or penalty limit is negative.
1036
1048
  * @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
1037
1049
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
1038
1050
  * @throws {UnknownReallocationMarketError} when a required market is absent.
@@ -730,13 +730,19 @@ export class MorphoBlue {
730
730
  }
731
731
  /**
732
732
  * Computes Vault V2 BluePublicAllocator reallocations for this market.
733
+ * Market/vault state and returned post-state stay at `options.timestamp`;
734
+ * only target-market cap checks reserve interest on the vault's existing
735
+ * allocation through `timestamp + capAccrualBuffer` (two hours by default;
736
+ * `0n` disables it). For market-source reallocations the source position's
737
+ * interest is also reserved on cap ids shared with the target, and reserves
738
+ * persist across every leg of a plan.
733
739
  *
734
740
  * @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
735
741
  * @param params.options - Optional allocator discovery controls and operation to support.
736
742
  * @returns Action-ready reallocations and their post-simulation state.
737
743
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
738
744
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
739
- * @throws {NegativeInputError} when a utilization or penalty limit is negative.
745
+ * @throws {NegativeInputError} when the cap-accrual buffer, utilization, or penalty limit is negative.
740
746
  * @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
741
747
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
742
748
  * @throws {UnknownReallocationMarketError} when a required market is absent.
@@ -31,6 +31,7 @@ export const getVaultBundlesSharesRequirements = async (viemClient, params) => {
31
31
  throw new ExpiredDeadlineError(params.deadline, now);
32
32
  }
33
33
  const spender = getChainAddress(params.chainId, "bundles.vaultBundlesV1");
34
+ // The allowance is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
34
35
  const allowance = await readContract(viemClient, {
35
36
  address: params.vaultData.address,
36
37
  abi: erc20Abi,
@@ -337,6 +337,7 @@ export class MorphoVaultV1 {
337
337
  abi: metaMorphoAbi,
338
338
  functionName: "MORPHO",
339
339
  },
340
+ // feeRecipient() is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
340
341
  {
341
342
  address: blue,
342
343
  abi: blueAbi,
@@ -363,9 +363,15 @@ 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. 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.
366
+ * considered. Market/vault state and the returned post-state stay at
367
+ * `timestamp`; only target-market cap checks reserve interest the vault's
368
+ * existing allocation would accrue through `timestamp + capAccrualBuffer`
369
+ * (two hours by default; `0n` disables it). For market-source reallocations
370
+ * the source position's interest is also reserved on cap ids shared with the
371
+ * target, and reserves persist across every leg of a plan. Targets with no remaining supply
372
+ * or allocator capacity are skipped before projecting source interest. The
373
+ * adapter's minimum share minting requirement, supply-share limits, and target
374
+ * absolute or zero relative caps are checked against a one-asset deposit.
369
375
  * Shared cap IDs that a source withdrawal can reduce remain eligible, as do deposits whose
370
376
  * allocation does not increase after rounding.
371
377
  *
@@ -377,9 +383,15 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
377
383
  *
378
384
  * @param marketId - Target Blue market id.
379
385
  * @param options - Optional discovery controls and operation to support.
386
+ * Market/vault state and returned post-state stay at `timestamp`; only
387
+ * target-market cap checks reserve interest on the vault's existing allocation
388
+ * through `timestamp + capAccrualBuffer` (two hours by default; `0n` disables).
389
+ * For market-source reallocations the source position's interest is also
390
+ * reserved on cap ids shared with the target, and reserves persist across
391
+ * every leg of a plan.
380
392
  * @returns Flat action-ready reallocations and their post-simulation state.
381
393
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
382
- * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
394
+ * @throws {NegativeInputError} when `capAccrualBuffer`, `maxWithdrawalUtilization`, or `maxPenalty` is negative.
383
395
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
384
396
  * @throws {NonPositiveInputError} when the operation amount is not positive and planning is enabled.
385
397
  * @throws {UnknownReallocationMarketError} when a required market is absent.
@@ -431,12 +443,19 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
431
443
  private computeVaultV2BlueReallocationsAtUtilizationInPlace;
432
444
  /**
433
445
  * Sums friendly Vault V2 shared liquidity available to a target market.
446
+ * Market/vault state and returned post-state stay at `timestamp`; only
447
+ * target-market cap checks reserve interest on the vault's existing allocation
448
+ * through `timestamp + capAccrualBuffer` (two hours by default; `0n` disables).
449
+ * For market-source reallocations the source position's interest is also
450
+ * reserved on cap ids shared with the target, and reserves persist across
451
+ * every leg of a plan.
434
452
  *
435
453
  * @param marketId - Target Blue market id.
436
- * @param options - Optional timestamp, enable flag, vault allowlist, source utilization ceiling, and maximum penalty.
454
+ * @param options - Optional timestamp, cap-accrual buffer, enable flag, vault
455
+ * allowlist, source utilization ceiling, and maximum penalty.
437
456
  * @returns Reallocatable market and idle assets, or `0n` when none are available; rounding-only shared-cap fits may be conservatively omitted.
438
457
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
439
- * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
458
+ * @throws {NegativeInputError} when `capAccrualBuffer`, `maxWithdrawalUtilization`, or `maxPenalty` is negative.
440
459
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
441
460
  * @throws {UnknownReallocationMarketError} when a required market is absent.
442
461
  * @throws {UnknownReallocationVaultError} when configured vault state is absent.
@@ -470,14 +489,20 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
470
489
  getPublicReallocationLiquidity(marketId: MarketId, options?: VaultV2BluePublicAllocatorOptions): bigint;
471
490
  /**
472
491
  * Computes borrow liquidity to a target utilization, including friendly
473
- * Vault V2 public reallocations.
492
+ * Vault V2 public reallocations. Market/vault state and returned post-state
493
+ * stay at `timestamp`; only target-market cap checks reserve interest on the
494
+ * vault's existing allocation through `timestamp + capAccrualBuffer` (two
495
+ * hours by default; `0n` disables). For market-source reallocations the
496
+ * source position's interest is also reserved on cap ids shared with the
497
+ * target, and reserves persist across every leg of a plan.
474
498
  *
475
499
  * @param marketId - Target Blue market id.
476
500
  * @param utilization - Desired utilization, scaled by WAD. Defaults to 90%.
477
- * @param options - Optional timestamp, enable flag, vault allowlist, source utilization ceiling, and maximum penalty.
501
+ * @param options - Optional timestamp, cap-accrual buffer, enable flag, vault
502
+ * allowlist, source utilization ceiling, and maximum penalty.
478
503
  * @returns Borrowable assets while remaining at or below `utilization`; rounding-only shared-cap fits may be conservatively omitted.
479
504
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
480
- * @throws {NegativeInputError} when `maxWithdrawalUtilization` or `maxPenalty` is negative.
505
+ * @throws {NegativeInputError} when `capAccrualBuffer`, `maxWithdrawalUtilization`, or `maxPenalty` is negative.
481
506
  * @throws {InputExceedsMaxError} when `maxWithdrawalUtilization` or `maxPenalty` exceeds WAD.
482
507
  * @throws {UnknownReallocationMarketError} when a required market is absent.
483
508
  * @throws {UnknownReallocationVaultError} when configured vault state is absent.