@morpho-org/morpho-sdk 9.7.0 → 10.0.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 (185) hide show
  1. package/MIGRATION-v9-to-v10.md +114 -0
  2. package/README.md +5 -1
  3. package/lib/cjs/abis.d.ts +1 -1
  4. package/lib/cjs/abis.js +5 -1
  5. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
  6. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +1 -1
  7. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -1
  8. package/lib/cjs/actions/midnight/cancelAndMake.js +2 -1
  9. package/lib/cjs/actions/midnight/cancelOffers.d.ts +54 -0
  10. package/lib/cjs/actions/midnight/cancelOffers.js +107 -0
  11. package/lib/cjs/actions/midnight/index.d.ts +1 -0
  12. package/lib/cjs/actions/midnight/index.js +1 -0
  13. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
  14. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +1 -1
  15. package/lib/cjs/actions/midnight/takeBorrow.d.ts +1 -1
  16. package/lib/cjs/actions/midnight/takeBorrow.js +1 -1
  17. package/lib/cjs/actions/midnight/takeLend.d.ts +1 -1
  18. package/lib/cjs/actions/midnight/takeLend.js +1 -1
  19. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  20. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +1 -1
  21. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +1 -1
  22. package/lib/cjs/actions/midnight/takeWithdraw.js +1 -1
  23. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
  24. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
  25. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
  26. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
  27. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
  28. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +3 -3
  29. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
  30. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +3 -2
  31. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
  32. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
  33. package/lib/cjs/blue/abis.d.ts +1 -1
  34. package/lib/cjs/blue/abis.js +5 -1
  35. package/lib/cjs/blue/entities.d.ts +4 -4
  36. package/lib/cjs/blue/entities.js +3 -1
  37. package/lib/cjs/blue/errors.d.ts +2 -2
  38. package/lib/cjs/blue/errors.js +5 -1
  39. package/lib/cjs/blue/fetch.d.ts +2 -2
  40. package/lib/cjs/blue/fetch.js +3 -1
  41. package/lib/cjs/blue/utils.d.ts +1 -1
  42. package/lib/cjs/blue/utils.js +2 -1
  43. package/lib/cjs/entities/blue/blue.d.ts +34 -28
  44. package/lib/cjs/entities/blue/blue.js +99 -73
  45. package/lib/cjs/entities/index.d.ts +4 -4
  46. package/lib/cjs/entities/index.js +3 -1
  47. package/lib/cjs/entities/midnight/deadline.d.ts +2 -2
  48. package/lib/cjs/entities/midnight/deadline.js +2 -2
  49. package/lib/cjs/entities/midnight/midnight.d.ts +49 -51
  50. package/lib/cjs/entities/midnight/midnight.js +144 -131
  51. package/lib/cjs/entities/midnight/publication.d.ts +2 -0
  52. package/lib/cjs/entities/midnight/publication.js +126 -100
  53. package/lib/cjs/entities/midnight/types.d.ts +4 -4
  54. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
  55. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +17 -17
  56. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +3 -4
  57. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +1 -1
  58. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +12 -12
  59. package/lib/cjs/entities/vaultV1/vaultV1.js +83 -57
  60. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +50 -24
  61. package/lib/cjs/entities/vaultV2/vaultV2.js +166 -90
  62. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +17 -2
  63. package/lib/cjs/entities/vaultV2BlueReallocationData.js +1410 -806
  64. package/lib/cjs/errors.d.ts +4 -4
  65. package/lib/cjs/errors.js +7 -5
  66. package/lib/cjs/fetch.d.ts +2 -2
  67. package/lib/cjs/fetch.js +3 -1
  68. package/lib/cjs/helpers/deadShares.js +55 -34
  69. package/lib/cjs/helpers/metadata.d.ts +14 -2
  70. package/lib/cjs/helpers/metadata.js +39 -4
  71. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +34 -22
  72. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +7 -1
  73. package/lib/cjs/helpers/validate.js +76 -61
  74. package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +154 -103
  75. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +31 -20
  76. package/lib/cjs/index.d.ts +1 -0
  77. package/lib/cjs/index.js +3 -1
  78. package/lib/cjs/midnight/errors.d.ts +2 -1
  79. package/lib/cjs/midnight/errors.js +5 -4
  80. package/lib/cjs/transactionPlan/plan.js +6 -3
  81. package/lib/cjs/transactionPlan/serde.js +7 -7
  82. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +6 -4
  83. package/lib/cjs/transactionPlan/vaultv2/deposit.js +5 -3
  84. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +6 -4
  85. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +5 -3
  86. package/lib/cjs/types/action.d.ts +26 -2
  87. package/lib/cjs/types/action.js +1 -1
  88. package/lib/cjs/types/error.js +11 -5
  89. package/lib/cjs/types/metadata.d.ts +12 -2
  90. package/lib/cjs/utils.d.ts +2 -2
  91. package/lib/cjs/utils.js +4 -2
  92. package/lib/cjs/version.d.ts +2 -0
  93. package/lib/cjs/version.js +6 -0
  94. package/lib/esm/abis.d.ts +1 -1
  95. package/lib/esm/abis.js +1 -1
  96. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
  97. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +1 -1
  98. package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -1
  99. package/lib/esm/actions/midnight/cancelAndMake.js +2 -1
  100. package/lib/esm/actions/midnight/cancelOffers.d.ts +54 -0
  101. package/lib/esm/actions/midnight/cancelOffers.js +103 -0
  102. package/lib/esm/actions/midnight/index.d.ts +1 -0
  103. package/lib/esm/actions/midnight/index.js +1 -0
  104. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
  105. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +1 -1
  106. package/lib/esm/actions/midnight/takeBorrow.d.ts +1 -1
  107. package/lib/esm/actions/midnight/takeBorrow.js +1 -1
  108. package/lib/esm/actions/midnight/takeLend.d.ts +1 -1
  109. package/lib/esm/actions/midnight/takeLend.js +1 -1
  110. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  111. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +1 -1
  112. package/lib/esm/actions/midnight/takeWithdraw.d.ts +1 -1
  113. package/lib/esm/actions/midnight/takeWithdraw.js +1 -1
  114. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
  115. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
  116. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
  117. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
  118. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
  119. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +3 -3
  120. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
  121. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +3 -2
  122. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
  123. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
  124. package/lib/esm/blue/abis.d.ts +1 -1
  125. package/lib/esm/blue/abis.js +1 -1
  126. package/lib/esm/blue/entities.d.ts +4 -4
  127. package/lib/esm/blue/entities.js +2 -2
  128. package/lib/esm/blue/errors.d.ts +2 -2
  129. package/lib/esm/blue/errors.js +2 -2
  130. package/lib/esm/blue/fetch.d.ts +2 -2
  131. package/lib/esm/blue/fetch.js +2 -2
  132. package/lib/esm/blue/utils.d.ts +1 -1
  133. package/lib/esm/blue/utils.js +1 -1
  134. package/lib/esm/entities/blue/blue.d.ts +34 -28
  135. package/lib/esm/entities/blue/blue.js +99 -73
  136. package/lib/esm/entities/index.d.ts +4 -4
  137. package/lib/esm/entities/index.js +2 -2
  138. package/lib/esm/entities/midnight/deadline.d.ts +2 -2
  139. package/lib/esm/entities/midnight/deadline.js +2 -2
  140. package/lib/esm/entities/midnight/midnight.d.ts +49 -51
  141. package/lib/esm/entities/midnight/midnight.js +145 -132
  142. package/lib/esm/entities/midnight/publication.d.ts +2 -0
  143. package/lib/esm/entities/midnight/publication.js +126 -100
  144. package/lib/esm/entities/midnight/types.d.ts +4 -4
  145. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
  146. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +17 -17
  147. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +3 -4
  148. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +1 -1
  149. package/lib/esm/entities/vaultV1/vaultV1.d.ts +12 -12
  150. package/lib/esm/entities/vaultV1/vaultV1.js +83 -57
  151. package/lib/esm/entities/vaultV2/vaultV2.d.ts +50 -24
  152. package/lib/esm/entities/vaultV2/vaultV2.js +166 -90
  153. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +17 -2
  154. package/lib/esm/entities/vaultV2BlueReallocationData.js +1410 -806
  155. package/lib/esm/errors.d.ts +4 -4
  156. package/lib/esm/errors.js +4 -4
  157. package/lib/esm/fetch.d.ts +2 -2
  158. package/lib/esm/fetch.js +2 -2
  159. package/lib/esm/helpers/deadShares.js +56 -35
  160. package/lib/esm/helpers/metadata.d.ts +14 -2
  161. package/lib/esm/helpers/metadata.js +38 -4
  162. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +34 -22
  163. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +7 -1
  164. package/lib/esm/helpers/validate.js +76 -61
  165. package/lib/esm/helpers/validateMidnightTakeFeasibility.js +153 -102
  166. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +31 -20
  167. package/lib/esm/index.d.ts +1 -0
  168. package/lib/esm/index.js +1 -0
  169. package/lib/esm/midnight/errors.d.ts +2 -1
  170. package/lib/esm/midnight/errors.js +2 -1
  171. package/lib/esm/transactionPlan/plan.js +6 -3
  172. package/lib/esm/transactionPlan/serde.js +7 -7
  173. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +6 -4
  174. package/lib/esm/transactionPlan/vaultv2/deposit.js +5 -3
  175. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +6 -4
  176. package/lib/esm/transactionPlan/vaultv2/withdraw.js +5 -3
  177. package/lib/esm/types/action.d.ts +26 -2
  178. package/lib/esm/types/action.js +1 -1
  179. package/lib/esm/types/error.js +11 -5
  180. package/lib/esm/types/metadata.d.ts +12 -2
  181. package/lib/esm/utils.d.ts +2 -2
  182. package/lib/esm/utils.js +2 -2
  183. package/lib/esm/version.d.ts +2 -0
  184. package/lib/esm/version.js +3 -0
  185. package/package.json +8 -7
@@ -12,7 +12,7 @@ import { ChainIdMismatchError, ExpiredDeadlineError, UnsupportedAuthorizationOpe
12
12
  * typed data, verifies it against the connected account, and returns a deep-frozen
13
13
  * `RequirementSignature` the selected transaction route consumes. The requirement's
14
14
  * `action.typedData` holds that EIP-712 payload so it can be inspected or displayed before signing.
15
- * Deadline defaults to two hours from `Time.timestamp()`.
15
+ * Deadline defaults to two hours from `params.now` (the deprecated fallback uses the device clock).
16
16
  * The operator pin applies to grants and revocations alike: revoking a previously registered
17
17
  * operator is outside this helper's scope.
18
18
  *
@@ -26,7 +26,7 @@ import { ChainIdMismatchError, ExpiredDeadlineError, UnsupportedAuthorizationOpe
26
26
  * @param params.nonce - The owner's current Morpho authorization nonce.
27
27
  * @param params.isAuthorized - Grant (`true`, default) or revoke (`false`).
28
28
  * @param params.deadline - Optional signature deadline in seconds.
29
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
29
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
30
30
  * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
31
31
  * `sign(client, userAddress)` produces the deep-frozen signature.
32
32
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
@@ -84,7 +84,7 @@ export const encodeBlueSignatureAuthorization = async (viemClient, params) => {
84
84
  throw new ExpiredDeadlineError(params.deadline, timestamp);
85
85
  }
86
86
  }
87
- const deadline = params.deadline ?? Time.timestamp() + Time.s.from.h(2n);
87
+ const deadline = params.deadline ?? (params.now ?? Time.timestamp()) + Time.s.from.h(2n);
88
88
  const typedData = deepFreeze(getAuthorizationTypedData({ authorizer: owner, authorized, isAuthorized, nonce, deadline }, chainId));
89
89
  const action = {
90
90
  type: "authorization",
@@ -1,8 +1,8 @@
1
1
  import type { Address } from "@morpho-org/blue-sdk";
2
2
  import type { Client } from "viem";
3
- import { type Erc2612RequirementSignature, type Requirement } from "../../../types/index.js";
3
+ import { type Erc2612RequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
4
4
  /** Parameters for {@link encodeErc20Permit}. */
5
- interface EncodeErc20PermitParams {
5
+ interface EncodeErc20PermitParams extends ReferenceTimestampParams {
6
6
  token: Address;
7
7
  /** Account that owns the tokens and signs the permit. */
8
8
  owner: Address;
@@ -12,8 +12,6 @@ interface EncodeErc20PermitParams {
12
12
  nonce: bigint;
13
13
  supportDeployless?: boolean;
14
14
  deadline?: bigint;
15
- /** Timestamp the deadline is validated against; defaults to the current time. */
16
- now?: bigint;
17
15
  }
18
16
  /**
19
17
  * Builds an EIP-2612 permit `Requirement` that, once signed, lets a supported SDK spender pull
@@ -23,7 +21,7 @@ interface EncodeErc20PermitParams {
23
21
  * signature, verifies it against the connected account, and returns a `RequirementSignature`
24
22
  * the selected transaction route can consume. The requirement's `action.typedData` holds that
25
23
  * EIP-712 payload so it can be inspected or displayed before signing. Deadline defaults to two
26
- * hours from `Time.timestamp()`.
24
+ * hours from `params.now` (the deprecated fallback uses the device clock).
27
25
  *
28
26
  * @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
29
27
  * @param params - Permit encoding parameters.
@@ -36,7 +34,7 @@ interface EncodeErc20PermitParams {
36
34
  * @param params.nonce - The owner's current EIP-2612 nonce on `token`.
37
35
  * @param params.supportDeployless - Whether `fetchToken` should use deployless multicall.
38
36
  * @param params.deadline - Signature expiration timestamp. Defaults to two hours from now.
39
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
37
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
40
38
  * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
41
39
  * `sign(client, userAddress)` produces the deep-frozen signature.
42
40
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`, or when the RPC
@@ -13,7 +13,7 @@ import { validateClientChainId } from "../validateClientChainId.js";
13
13
  * signature, verifies it against the connected account, and returns a `RequirementSignature`
14
14
  * the selected transaction route can consume. The requirement's `action.typedData` holds that
15
15
  * EIP-712 payload so it can be inspected or displayed before signing. Deadline defaults to two
16
- * hours from `Time.timestamp()`.
16
+ * hours from `params.now` (the deprecated fallback uses the device clock).
17
17
  *
18
18
  * @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
19
19
  * @param params - Permit encoding parameters.
@@ -26,7 +26,7 @@ import { validateClientChainId } from "../validateClientChainId.js";
26
26
  * @param params.nonce - The owner's current EIP-2612 nonce on `token`.
27
27
  * @param params.supportDeployless - Whether `fetchToken` should use deployless multicall.
28
28
  * @param params.deadline - Signature expiration timestamp. Defaults to two hours from now.
29
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
29
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
30
30
  * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
31
31
  * `sign(client, userAddress)` produces the deep-frozen signature.
32
32
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`, or when the RPC
@@ -93,7 +93,7 @@ export const encodeErc20Permit = async (viemClient, params) => {
93
93
  throw new ExpiredDeadlineError(params.deadline, timestamp);
94
94
  }
95
95
  }
96
- const deadline = params.deadline ?? Time.timestamp() + Time.s.from.h(2n);
96
+ const deadline = params.deadline ?? (params.now ?? Time.timestamp()) + Time.s.from.h(2n);
97
97
  await validateClientChainId(viemClient, chainId);
98
98
  const tokenData = await fetchToken(token, viemClient, {
99
99
  deployless: supportDeployless,
@@ -1,10 +1,10 @@
1
1
  import type { Address } from "@morpho-org/blue-sdk";
2
- import { type Permit2SignatureTransferRequirementSignature, type Requirement } from "../../../types/index.js";
2
+ import { type Permit2SignatureTransferRequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
3
3
  /**
4
4
  * Parameters for {@link encodeErc20Permit2SignatureTransfer}.
5
5
  * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
6
6
  */
7
- export interface EncodeErc20Permit2SignatureTransferParams {
7
+ export interface EncodeErc20Permit2SignatureTransferParams extends ReferenceTimestampParams {
8
8
  /** ERC-20 token pulled through Permit2. */
9
9
  readonly token: Address;
10
10
  /** Registered fixed bundles deployment receiving permission to pull the token. */
@@ -17,8 +17,6 @@ export interface EncodeErc20Permit2SignatureTransferParams {
17
17
  readonly nonce: bigint;
18
18
  /** Signature expiration timestamp in seconds. */
19
19
  readonly deadline: bigint;
20
- /** Timestamp the deadline is validated against; defaults to the current time. */
21
- readonly now?: bigint;
22
20
  }
23
21
  /**
24
22
  * Builds a Permit2 SignatureTransfer requirement for a direct fixed-bundles token pull.
@@ -34,7 +32,7 @@ export interface EncodeErc20Permit2SignatureTransferParams {
34
32
  * @param params.chainId - Target chain id.
35
33
  * @param params.nonce - Unused Permit2 unordered nonce.
36
34
  * @param params.deadline - Signature expiration timestamp in seconds.
37
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
35
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
38
36
  * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose
39
37
  * `sign(client, userAddress)` returns a deep-frozen signature result.
40
38
  * @throws {NegativeInputError} when `amount` or `nonce` is negative.
@@ -62,7 +60,8 @@ export interface EncodeErc20Permit2SignatureTransferParams {
62
60
  * amount: 1_000_000n,
63
61
  * chainId: mainnet.id,
64
62
  * nonce: 0n,
65
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
63
+ * now: (await client.getBlock()).timestamp,
64
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
66
65
  * });
67
66
  * // requirement satisfies Requirement<Permit2SignatureTransferRequirementSignature>
68
67
  * ```
@@ -19,7 +19,7 @@ import { ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, } fr
19
19
  * @param params.chainId - Target chain id.
20
20
  * @param params.nonce - Unused Permit2 unordered nonce.
21
21
  * @param params.deadline - Signature expiration timestamp in seconds.
22
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
22
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
23
23
  * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose
24
24
  * `sign(client, userAddress)` returns a deep-frozen signature result.
25
25
  * @throws {NegativeInputError} when `amount` or `nonce` is negative.
@@ -47,7 +47,8 @@ import { ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, } fr
47
47
  * amount: 1_000_000n,
48
48
  * chainId: mainnet.id,
49
49
  * nonce: 0n,
50
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
50
+ * now: (await client.getBlock()).timestamp,
51
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
51
52
  * });
52
53
  * // requirement satisfies Requirement<Permit2SignatureTransferRequirementSignature>
53
54
  * ```
@@ -1,7 +1,7 @@
1
1
  import { type Address, Token } from "@morpho-org/blue-sdk";
2
- import { type PermitRequirementSignature, type Requirement } from "../../../types/index.js";
2
+ import { type PermitRequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
3
3
  /** Parameters for {@link encodeVaultSharesPermit}. */
4
- export interface EncodeVaultSharesPermitParams {
4
+ export interface EncodeVaultSharesPermitParams extends ReferenceTimestampParams {
5
5
  /** Vault share token, including V1 permit-domain metadata when available. */
6
6
  readonly vault: Token;
7
7
  /** Vault generation, which selects the standard V1 or two-field V2 domain. */
@@ -16,8 +16,6 @@ export interface EncodeVaultSharesPermitParams {
16
16
  readonly nonce: bigint;
17
17
  /** Shared permit and bundle deadline. */
18
18
  readonly deadline: bigint;
19
- /** Timestamp the deadline is validated against; defaults to the current time. */
20
- readonly now?: bigint;
21
19
  }
22
20
  /**
23
21
  * Builds an unlimited ERC-2612 shares-permit requirement used by a vault exit.
@@ -33,7 +31,7 @@ export interface EncodeVaultSharesPermitParams {
33
31
  * @param params.chainId - Chain on which the vault and spender are deployed.
34
32
  * @param params.nonce - Current vault permit nonce for the owner.
35
33
  * @param params.deadline - Shared permit and bundle deadline.
36
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
34
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
37
35
  * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose `sign()` result
38
36
  * can be embedded in fixed vault-bundles calldata.
39
37
  * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
@@ -20,7 +20,7 @@ import { ExpiredDeadlineError, } from "../../../types/index.js";
20
20
  * @param params.chainId - Chain on which the vault and spender are deployed.
21
21
  * @param params.nonce - Current vault permit nonce for the owner.
22
22
  * @param params.deadline - Shared permit and bundle deadline.
23
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
23
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
24
24
  * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose `sign()` result
25
25
  * can be embedded in fixed vault-bundles calldata.
26
26
  * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
@@ -59,31 +59,34 @@ import { ExpiredDeadlineError, } from "../../../types/index.js";
59
59
  export const encodeVaultSharesPermit = (params) => {
60
60
  const { vault: inputVault, version, spender, owner, chainId, nonce, deadline, } = params;
61
61
  const inputDomain = inputVault.eip5267Domain;
62
+ let eip5267Domain;
63
+ if (version === "vaultV2") {
64
+ eip5267Domain = new Eip5267Domain({
65
+ // Only the bitmap-selected fields enter Vault V2's domain separator.
66
+ fields: "0x0c",
67
+ name: "",
68
+ version: "",
69
+ chainId: BigInt(chainId),
70
+ verifyingContract: inputVault.address,
71
+ salt: zeroHash,
72
+ extensions: [],
73
+ });
74
+ }
75
+ else if (inputDomain != null) {
76
+ eip5267Domain = new Eip5267Domain({
77
+ fields: inputDomain.fields,
78
+ name: inputDomain.name,
79
+ version: inputDomain.version,
80
+ chainId: inputDomain.chainId,
81
+ verifyingContract: inputDomain.verifyingContract,
82
+ salt: inputDomain.salt,
83
+ extensions: [...inputDomain.extensions],
84
+ });
85
+ }
62
86
  const vault = new Token({
63
87
  address: inputVault.address,
64
88
  name: inputVault.name,
65
- eip5267Domain: version === "vaultV2"
66
- ? new Eip5267Domain({
67
- // Only the bitmap-selected fields enter Vault V2's domain separator.
68
- fields: "0x0c",
69
- name: "",
70
- version: "",
71
- chainId: BigInt(chainId),
72
- verifyingContract: inputVault.address,
73
- salt: zeroHash,
74
- extensions: [],
75
- })
76
- : inputDomain == null
77
- ? undefined
78
- : new Eip5267Domain({
79
- fields: inputDomain.fields,
80
- name: inputDomain.name,
81
- version: inputDomain.version,
82
- chainId: inputDomain.chainId,
83
- verifyingContract: inputDomain.verifyingContract,
84
- salt: inputDomain.salt,
85
- extensions: [...inputDomain.extensions],
86
- }),
89
+ eip5267Domain,
87
90
  });
88
91
  // Bind the permit to one of the registered fixed vault bundles deployments.
89
92
  validateRequirementSpender({
@@ -1,5 +1,5 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
2
+ export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  preLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
@@ -1,5 +1,5 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
2
+ export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  preLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
@@ -1,10 +1,10 @@
1
- export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
1
+ export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MidnightAdapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  IPreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
6
- export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
5
+ IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MidnightAdapter, IVaultV2MidnightAdapterAccrualMarket, IVaultV2MidnightAdapterCollateralParams, IVaultV2MidnightAdapterMarket, IVaultV2MidnightAdapterMarketData, IVaultV2MidnightAdapterMarketState, IVaultV2MidnightAdapterMidnightMarket, IVaultV2MidnightAdapterPosition, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultV2MidnightAdapterAccrualMarket, VaultV2MidnightAdapterMarketData, } from "@morpho-org/blue-sdk";
6
+ export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
7
7
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
8
8
  PreLiquidationParams,
9
9
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
10
- PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
10
+ PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
@@ -1,5 +1,5 @@
1
- export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
1
+ export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  PreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
5
+ PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
@@ -1,4 +1,4 @@
1
- export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
1
+ export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, InvalidPositionAccrualStateError, InvalidPositionLossFactorError, InvalidVaultV2MidnightAdapterMarketsError, 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, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
4
+ export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
@@ -1,4 +1,4 @@
1
- export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
1
+ export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, InvalidPositionAccrualStateError, InvalidPositionLossFactorError, InvalidVaultV2MidnightAdapterMarketsError, 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, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
4
+ export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
@@ -1,5 +1,5 @@
1
- export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
1
+ export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  fetchPreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
5
+ fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
@@ -1,5 +1,5 @@
1
- export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
1
+ export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  fetchPreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
5
+ fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
@@ -3,5 +3,5 @@ export { AdaptiveCurveIrmLib, CapacityLimitReason,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  defaultPreLiquidationParamsRegistry,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
6
- getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
6
+ getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
7
7
  export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
@@ -2,5 +2,5 @@ export { AdaptiveCurveIrmLib, CapacityLimitReason,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  defaultPreLiquidationParamsRegistry,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
5
+ getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
6
6
  export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
@@ -1,7 +1,7 @@
1
1
  import { type AccrualPosition, type Market, type MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
3
  import type { FetchParameters } from "../../types/data.js";
4
- import { type ActionOutput, type ActionRequirement, type AssetsOrSharesArgs, type BlueBorrowAction, type BlueRefinanceAction, type BlueRepayAction, type BlueRepayWithdrawCollateralAction, type BlueSupplyAction, type BlueSupplyCollateralAction, type BlueSupplyCollateralBorrowAction, type BlueWithdrawAction, type BlueWithdrawBuyCallbackAction, type BlueWithdrawCollateralAction, type MorphoClientType, type RequirementSignature, type VaultV2BluePublicAllocatorOptions, type VaultV2BlueReallocation } from "../../types/index.js";
4
+ import { type ActionOutput, type ActionRequirement, type AssetsOrSharesArgs, type BlueBorrowAction, type BlueRefinanceAction, type BlueRepayAction, type BlueRepayWithdrawCollateralAction, type BlueSupplyAction, type BlueSupplyCollateralAction, type BlueSupplyCollateralBorrowAction, type BlueWithdrawAction, type BlueWithdrawBuyCallbackAction, type BlueWithdrawCollateralAction, type MorphoClientType, type ReferenceTimestampParams, type RequirementSignature, type VaultV2BluePublicAllocatorOptions, type VaultV2BlueReallocation } from "../../types/index.js";
5
5
  import { VaultV2BlueReallocationData } from "../vaultV2BlueReallocationData.js";
6
6
  type VaultV2BlueReallocationsParams = {
7
7
  readonly reallocationData: VaultV2BlueReallocationData;
@@ -138,7 +138,7 @@ export interface BlueActions {
138
138
  readonly deadline: bigint;
139
139
  readonly referralFeePct?: bigint;
140
140
  readonly referralFeeRecipient?: Address;
141
- }) => ActionOutput<BlueSupplyCollateralAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
141
+ } & ReferenceTimestampParams) => ActionOutput<BlueSupplyCollateralAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
142
142
  /**
143
143
  * Prepares a direct BlueBundlesV1 loan-asset supply.
144
144
  *
@@ -202,7 +202,8 @@ export interface BlueActions {
202
202
  * userAddress,
203
203
  * marketData: await market.getMarketData(),
204
204
  * assets: 1_000_000n,
205
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
205
+ * now: (await client.getBlock()).timestamp,
206
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
206
207
  * });
207
208
  * const requirements = await action.getRequirements();
208
209
  * const tx = action.buildTx();
@@ -218,7 +219,7 @@ export interface BlueActions {
218
219
  readonly deadline: bigint;
219
220
  readonly referralFeePct?: bigint;
220
221
  readonly referralFeeRecipient?: Address;
221
- }): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
222
+ } & ReferenceTimestampParams): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
222
223
  /**
223
224
  * @deprecated Pass `marketData` from `getMarketData()`; the snapshot-free overload is removed in the next major.
224
225
  */
@@ -229,7 +230,7 @@ export interface BlueActions {
229
230
  readonly deadline: bigint;
230
231
  readonly referralFeePct?: bigint;
231
232
  readonly referralFeeRecipient?: Address;
232
- }): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
233
+ } & ReferenceTimestampParams): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
233
234
  };
234
235
  /**
235
236
  * Prepares a direct BlueBundlesV1 loan-asset withdrawal by assets or shares.
@@ -297,7 +298,8 @@ export interface BlueActions {
297
298
  * userAddress,
298
299
  * positionData,
299
300
  * shares: 1n,
300
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
301
+ * now: (await client.getBlock()).timestamp,
302
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
301
303
  * });
302
304
  * const requirements = await action.getRequirements();
303
305
  * const tx = action.buildTx();
@@ -311,7 +313,7 @@ export interface BlueActions {
311
313
  readonly deadline: bigint;
312
314
  readonly referralFeePct?: bigint;
313
315
  readonly referralFeeRecipient?: Address;
314
- } & AssetsOrSharesArgs) => ActionOutput<BlueWithdrawAction, readonly RequirementSignature[], undefined>;
316
+ } & ReferenceTimestampParams & AssetsOrSharesArgs) => ActionOutput<BlueWithdrawAction, readonly RequirementSignature[], undefined>;
315
317
  /**
316
318
  * Prepares a direct Morpho Blue withdrawal of a BlueBuyCallback's whole supply position to its
317
319
  * owner.
@@ -381,7 +383,7 @@ export interface BlueActions {
381
383
  readonly userAddress: Address;
382
384
  readonly callbackAddress: Address;
383
385
  readonly positionData: AccrualPosition;
384
- }) => ActionOutput<BlueWithdrawBuyCallbackAction, undefined, undefined>;
386
+ } & ReferenceTimestampParams) => ActionOutput<BlueWithdrawBuyCallbackAction, undefined, undefined>;
385
387
  /**
386
388
  * Prepares a direct BlueBundlesV1 loan-asset borrow.
387
389
  *
@@ -460,7 +462,7 @@ export interface BlueActions {
460
462
  readonly deadline: bigint;
461
463
  readonly referralFeePct?: bigint;
462
464
  readonly referralFeeRecipient?: Address;
463
- }) => ActionOutput<BlueBorrowAction, readonly RequirementSignature[], undefined>;
465
+ } & ReferenceTimestampParams) => ActionOutput<BlueBorrowAction, readonly RequirementSignature[], undefined>;
464
466
  /**
465
467
  * Prepares a direct BlueBundlesV1 loan-asset repayment.
466
468
  *
@@ -545,7 +547,7 @@ export interface BlueActions {
545
547
  readonly deadline: bigint;
546
548
  readonly referralFeePct?: bigint;
547
549
  readonly referralFeeRecipient?: Address;
548
- } & ({
550
+ } & ReferenceTimestampParams & ({
549
551
  readonly repayAssets: bigint;
550
552
  readonly repayShares?: never;
551
553
  } | {
@@ -623,7 +625,7 @@ export interface BlueActions {
623
625
  readonly deadline: bigint;
624
626
  readonly referralFeePct?: bigint;
625
627
  readonly referralFeeRecipient?: Address;
626
- }) => ActionOutput<BlueWithdrawCollateralAction, readonly RequirementSignature[], undefined>;
628
+ } & ReferenceTimestampParams) => ActionOutput<BlueWithdrawCollateralAction, readonly RequirementSignature[], undefined>;
627
629
  /**
628
630
  * Prepares a direct BlueBundlesV1 repay, collateral withdrawal, or atomic combination.
629
631
  *
@@ -706,7 +708,8 @@ export interface BlueActions {
706
708
  * positionData,
707
709
  * repayShares: maxUint256,
708
710
  * collateralAssets: 1n,
709
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
711
+ * now: (await client.getBlock()).timestamp,
712
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
710
713
  * });
711
714
  * const requirements = await action.getRequirements(); // Satisfy these first.
712
715
  * const tx = action.buildTx(); // For a client configured with supportSignature: false.
@@ -721,7 +724,7 @@ export interface BlueActions {
721
724
  readonly deadline: bigint;
722
725
  readonly referralFeePct?: bigint;
723
726
  readonly referralFeeRecipient?: Address;
724
- } & ({
727
+ } & ReferenceTimestampParams & ({
725
728
  readonly repayAssets: bigint;
726
729
  readonly repayShares?: never;
727
730
  } | {
@@ -807,7 +810,8 @@ export interface BlueActions {
807
810
  * positionData,
808
811
  * collateralAssets: 100_000_000n,
809
812
  * borrowAssets: 1_000_000n,
810
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
813
+ * now: (await client.getBlock()).timestamp,
814
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
811
815
  * });
812
816
  * const requirements = await action.getRequirements(); // Satisfy these first.
813
817
  * const tx = action.buildTx(); // For a client configured with supportSignature: false.
@@ -824,7 +828,7 @@ export interface BlueActions {
824
828
  readonly deadline: bigint;
825
829
  readonly referralFeePct?: bigint;
826
830
  readonly referralFeeRecipient?: Address;
827
- }) => ActionOutput<BlueSupplyCollateralBorrowAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
831
+ } & ReferenceTimestampParams) => ActionOutput<BlueSupplyCollateralBorrowAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
828
832
  /**
829
833
  * Prepares a direct BlueBundlesV1 full borrow-position migration.
830
834
  *
@@ -903,7 +907,8 @@ export interface BlueActions {
903
907
  * userAddress,
904
908
  * positionData: source,
905
909
  * destination: { marketParams: destinationParams, positionData: destination },
906
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
910
+ * now: (await client.getBlock()).timestamp,
911
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
907
912
  * });
908
913
  * const requirements = await action.getRequirements(); // Satisfy these first.
909
914
  * const tx = action.buildTx(); // For a client configured with supportSignature: false.
@@ -921,7 +926,7 @@ export interface BlueActions {
921
926
  readonly deadline: bigint;
922
927
  readonly referralFeePct?: bigint;
923
928
  readonly referralFeeRecipient?: Address;
924
- }) => ActionOutput<BlueRefinanceAction, readonly RequirementSignature[], undefined>;
929
+ } & ReferenceTimestampParams) => ActionOutput<BlueRefinanceAction, readonly RequirementSignature[], undefined>;
925
930
  /**
926
931
  * Fetches Vault V2 BluePublicAllocator state for this target market.
927
932
  *
@@ -1044,6 +1049,7 @@ export declare class MorphoBlue implements BlueActions {
1044
1049
  private assertWriteTargets;
1045
1050
  private getMaxLtv;
1046
1051
  private getBlueBundlesV1QuoteTimestamp;
1052
+ private quoteRepay;
1047
1053
  private getTokenRequirements;
1048
1054
  private getAuthorizationRequirements;
1049
1055
  getMarketData(parameters?: FetchParameters): Promise<Market>;
@@ -1057,7 +1063,7 @@ export declare class MorphoBlue implements BlueActions {
1057
1063
  readonly deadline: bigint;
1058
1064
  readonly referralFeePct?: bigint;
1059
1065
  readonly referralFeeRecipient?: Address;
1060
- }): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1066
+ } & ReferenceTimestampParams): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1061
1067
  /**
1062
1068
  * @deprecated Pass `marketData` from `getMarketData()`; the snapshot-free overload is removed in the next major.
1063
1069
  */
@@ -1068,7 +1074,7 @@ export declare class MorphoBlue implements BlueActions {
1068
1074
  readonly deadline: bigint;
1069
1075
  readonly referralFeePct?: bigint;
1070
1076
  readonly referralFeeRecipient?: Address;
1071
- }): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1077
+ } & ReferenceTimestampParams): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1072
1078
  /** {@inheritDoc BlueActions.withdraw} */
1073
1079
  withdraw(params: {
1074
1080
  readonly userAddress: Address;
@@ -1077,7 +1083,7 @@ export declare class MorphoBlue implements BlueActions {
1077
1083
  readonly deadline: bigint;
1078
1084
  readonly referralFeePct?: bigint;
1079
1085
  readonly referralFeeRecipient?: Address;
1080
- } & AssetsOrSharesArgs): {
1086
+ } & ReferenceTimestampParams & AssetsOrSharesArgs): {
1081
1087
  getRequirements: () => Promise<readonly ActionRequirement[]>;
1082
1088
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<BlueWithdrawAction>>;
1083
1089
  };
@@ -1086,7 +1092,7 @@ export declare class MorphoBlue implements BlueActions {
1086
1092
  readonly userAddress: Address;
1087
1093
  readonly callbackAddress: Address;
1088
1094
  readonly positionData: AccrualPosition;
1089
- }): ActionOutput<BlueWithdrawBuyCallbackAction, undefined, undefined>;
1095
+ } & ReferenceTimestampParams): ActionOutput<BlueWithdrawBuyCallbackAction, undefined, undefined>;
1090
1096
  /** {@inheritDoc BlueActions.supplyCollateral} */
1091
1097
  supplyCollateral(params: {
1092
1098
  readonly userAddress: Address;
@@ -1095,7 +1101,7 @@ export declare class MorphoBlue implements BlueActions {
1095
1101
  readonly deadline: bigint;
1096
1102
  readonly referralFeePct?: bigint;
1097
1103
  readonly referralFeeRecipient?: Address;
1098
- }): ActionOutput<BlueSupplyCollateralAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1104
+ } & ReferenceTimestampParams): ActionOutput<BlueSupplyCollateralAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1099
1105
  /** {@inheritDoc BlueActions.borrow} */
1100
1106
  borrow(params: {
1101
1107
  readonly userAddress: Address;
@@ -1105,7 +1111,7 @@ export declare class MorphoBlue implements BlueActions {
1105
1111
  readonly deadline: bigint;
1106
1112
  readonly referralFeePct?: bigint;
1107
1113
  readonly referralFeeRecipient?: Address;
1108
- }): ActionOutput<BlueBorrowAction, readonly RequirementSignature[], undefined>;
1114
+ } & ReferenceTimestampParams): ActionOutput<BlueBorrowAction, readonly RequirementSignature[], undefined>;
1109
1115
  /** {@inheritDoc BlueActions.repay} */
1110
1116
  repay(params: {
1111
1117
  readonly userAddress: Address;
@@ -1114,7 +1120,7 @@ export declare class MorphoBlue implements BlueActions {
1114
1120
  readonly deadline: bigint;
1115
1121
  readonly referralFeePct?: bigint;
1116
1122
  readonly referralFeeRecipient?: Address;
1117
- } & ({
1123
+ } & ReferenceTimestampParams & ({
1118
1124
  readonly repayAssets: bigint;
1119
1125
  readonly repayShares?: never;
1120
1126
  } | {
@@ -1129,7 +1135,7 @@ export declare class MorphoBlue implements BlueActions {
1129
1135
  readonly deadline: bigint;
1130
1136
  readonly referralFeePct?: bigint;
1131
1137
  readonly referralFeeRecipient?: Address;
1132
- }): ActionOutput<BlueWithdrawCollateralAction, readonly RequirementSignature[], undefined>;
1138
+ } & ReferenceTimestampParams): ActionOutput<BlueWithdrawCollateralAction, readonly RequirementSignature[], undefined>;
1133
1139
  /** {@inheritDoc BlueActions.repayWithdrawCollateral} */
1134
1140
  repayWithdrawCollateral(params: {
1135
1141
  readonly userAddress: Address;
@@ -1139,7 +1145,7 @@ export declare class MorphoBlue implements BlueActions {
1139
1145
  readonly deadline: bigint;
1140
1146
  readonly referralFeePct?: bigint;
1141
1147
  readonly referralFeeRecipient?: Address;
1142
- } & ({
1148
+ } & ReferenceTimestampParams & ({
1143
1149
  readonly repayAssets: bigint;
1144
1150
  readonly repayShares?: never;
1145
1151
  } | {
@@ -1163,7 +1169,7 @@ export declare class MorphoBlue implements BlueActions {
1163
1169
  readonly deadline: bigint;
1164
1170
  readonly referralFeePct?: bigint;
1165
1171
  readonly referralFeeRecipient?: Address;
1166
- }): {
1172
+ } & ReferenceTimestampParams): {
1167
1173
  getRequirements: (requirementsParams?: BlueTokenRequirementsParams) => Promise<readonly ActionRequirement[]>;
1168
1174
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<BlueSupplyCollateralBorrowAction>>;
1169
1175
  };
@@ -1179,7 +1185,7 @@ export declare class MorphoBlue implements BlueActions {
1179
1185
  readonly deadline: bigint;
1180
1186
  readonly referralFeePct?: bigint;
1181
1187
  readonly referralFeeRecipient?: Address;
1182
- }): {
1188
+ } & ReferenceTimestampParams): {
1183
1189
  getRequirements: () => Promise<readonly ActionRequirement[]>;
1184
1190
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<BlueRefinanceAction>>;
1185
1191
  };