@morpho-org/morpho-sdk 7.1.0-next.1 → 8.2.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 (193) hide show
  1. package/MIGRATION-v7-to-v8.md +290 -0
  2. package/README.md +11 -6
  3. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +2 -0
  4. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +2 -0
  5. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +17 -71
  6. package/lib/cjs/actions/midnight/cancelAndMake.js +41 -29
  7. package/lib/cjs/actions/midnight/redeem.d.ts +8 -1
  8. package/lib/cjs/actions/midnight/redeem.js +18 -1
  9. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +19 -3
  10. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +24 -2
  11. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +1 -0
  12. package/lib/cjs/actions/midnight/supplyCollateral.js +3 -0
  13. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +21 -6
  14. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +49 -14
  15. package/lib/cjs/actions/midnight/takeBorrow.d.ts +18 -5
  16. package/lib/cjs/actions/midnight/takeBorrow.js +44 -12
  17. package/lib/cjs/actions/midnight/takeLend.d.ts +10 -5
  18. package/lib/cjs/actions/midnight/takeLend.js +27 -9
  19. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -7
  20. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +51 -27
  21. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +14 -5
  22. package/lib/cjs/actions/midnight/takeWithdraw.js +40 -9
  23. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -2
  24. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -6
  25. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +3 -0
  26. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +2 -1
  27. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +13 -2
  28. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +17 -6
  29. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +3 -0
  30. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -1
  31. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +5 -0
  32. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +4 -1
  33. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +3 -1
  34. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +5 -1
  35. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +3 -1
  36. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -1
  37. package/lib/cjs/actions/requirements/validateClientChainId.d.ts +26 -0
  38. package/lib/cjs/actions/requirements/validateClientChainId.js +34 -0
  39. package/lib/cjs/blue/errors.d.ts +1 -1
  40. package/lib/cjs/blue/errors.js +3 -1
  41. package/lib/cjs/blue/types.d.ts +1 -1
  42. package/lib/cjs/blue/utils.d.ts +1 -1
  43. package/lib/cjs/blue/utils.js +5 -1
  44. package/lib/cjs/entities/blue/blue.d.ts +109 -27
  45. package/lib/cjs/entities/blue/blue.js +103 -28
  46. package/lib/cjs/entities/index.d.ts +1 -1
  47. package/lib/cjs/entities/midnight/deadline.d.ts +15 -0
  48. package/lib/cjs/entities/midnight/deadline.js +24 -0
  49. package/lib/cjs/entities/midnight/midnight.d.ts +427 -72
  50. package/lib/cjs/entities/midnight/midnight.js +864 -186
  51. package/lib/cjs/entities/midnight/publication.d.ts +134 -0
  52. package/lib/cjs/entities/midnight/publication.js +404 -0
  53. package/lib/cjs/entities/midnight/types.d.ts +26 -5
  54. package/lib/cjs/entities/requirements/assertContractCode.d.ts +49 -0
  55. package/lib/cjs/entities/requirements/assertContractCode.js +79 -0
  56. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +19 -4
  57. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +45 -18
  58. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +3 -2
  59. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +5 -2
  60. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -1
  61. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
  62. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +63 -11
  63. package/lib/cjs/entities/vaultV1/vaultV1.js +52 -15
  64. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +54 -12
  65. package/lib/cjs/entities/vaultV2/vaultV2.js +52 -15
  66. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +12 -6
  67. package/lib/cjs/entities/vaultV2BlueReallocationData.js +42 -14
  68. package/lib/cjs/errors.d.ts +1 -1
  69. package/lib/cjs/errors.js +4 -2
  70. package/lib/cjs/helpers/constant.d.ts +5 -0
  71. package/lib/cjs/helpers/constant.js +6 -1
  72. package/lib/cjs/helpers/index.d.ts +1 -1
  73. package/lib/cjs/helpers/index.js +2 -1
  74. package/lib/cjs/helpers/validate.d.ts +163 -8
  75. package/lib/cjs/helpers/validate.js +179 -8
  76. package/lib/cjs/helpers/validateMidnightBounds.d.ts +47 -0
  77. package/lib/cjs/helpers/validateMidnightBounds.js +79 -0
  78. package/lib/cjs/helpers/validateMidnightPublication.d.ts +12 -0
  79. package/lib/cjs/helpers/validateMidnightPublication.js +144 -0
  80. package/lib/cjs/helpers/validateMidnightReceiver.d.ts +29 -0
  81. package/lib/cjs/helpers/validateMidnightReceiver.js +84 -0
  82. package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +102 -0
  83. package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +231 -0
  84. package/lib/cjs/index.d.ts +1 -0
  85. package/lib/cjs/index.js +3 -0
  86. package/lib/cjs/types/error.d.ts +197 -4
  87. package/lib/cjs/types/error.js +265 -5
  88. package/lib/cjs/types/index.d.ts +1 -0
  89. package/lib/cjs/types/index.js +1 -0
  90. package/lib/cjs/types/midnightCancelAndMake.d.ts +70 -0
  91. package/lib/cjs/types/midnightCancelAndMake.js +2 -0
  92. package/lib/cjs/types/midnightPublicationError.d.ts +332 -0
  93. package/lib/cjs/types/midnightPublicationError.js +376 -0
  94. package/lib/cjs/types/sharedLiquidity.d.ts +12 -7
  95. package/lib/cjs/types.d.ts +1 -1
  96. package/lib/cjs/utils.d.ts +2 -1
  97. package/lib/cjs/utils.js +8 -2
  98. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +2 -0
  99. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -0
  100. package/lib/esm/actions/midnight/cancelAndMake.d.ts +17 -71
  101. package/lib/esm/actions/midnight/cancelAndMake.js +42 -30
  102. package/lib/esm/actions/midnight/redeem.d.ts +8 -1
  103. package/lib/esm/actions/midnight/redeem.js +18 -1
  104. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +19 -3
  105. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +24 -2
  106. package/lib/esm/actions/midnight/supplyCollateral.d.ts +1 -0
  107. package/lib/esm/actions/midnight/supplyCollateral.js +3 -0
  108. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +21 -6
  109. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +52 -17
  110. package/lib/esm/actions/midnight/takeBorrow.d.ts +18 -5
  111. package/lib/esm/actions/midnight/takeBorrow.js +47 -15
  112. package/lib/esm/actions/midnight/takeLend.d.ts +10 -5
  113. package/lib/esm/actions/midnight/takeLend.js +27 -9
  114. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -7
  115. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +52 -28
  116. package/lib/esm/actions/midnight/takeWithdraw.d.ts +14 -5
  117. package/lib/esm/actions/midnight/takeWithdraw.js +41 -10
  118. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -2
  119. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +13 -8
  120. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +3 -0
  121. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +2 -1
  122. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +13 -2
  123. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +17 -6
  124. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +3 -0
  125. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -1
  126. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +5 -0
  127. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +4 -1
  128. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +3 -1
  129. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +5 -1
  130. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +3 -1
  131. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -1
  132. package/lib/esm/actions/requirements/validateClientChainId.d.ts +26 -0
  133. package/lib/esm/actions/requirements/validateClientChainId.js +30 -0
  134. package/lib/esm/blue/errors.d.ts +1 -1
  135. package/lib/esm/blue/errors.js +1 -1
  136. package/lib/esm/blue/types.d.ts +1 -1
  137. package/lib/esm/blue/utils.d.ts +1 -1
  138. package/lib/esm/blue/utils.js +1 -1
  139. package/lib/esm/entities/blue/blue.d.ts +109 -27
  140. package/lib/esm/entities/blue/blue.js +104 -29
  141. package/lib/esm/entities/index.d.ts +1 -1
  142. package/lib/esm/entities/midnight/deadline.d.ts +15 -0
  143. package/lib/esm/entities/midnight/deadline.js +20 -0
  144. package/lib/esm/entities/midnight/midnight.d.ts +427 -72
  145. package/lib/esm/entities/midnight/midnight.js +865 -187
  146. package/lib/esm/entities/midnight/publication.d.ts +134 -0
  147. package/lib/esm/entities/midnight/publication.js +397 -0
  148. package/lib/esm/entities/midnight/types.d.ts +26 -5
  149. package/lib/esm/entities/requirements/assertContractCode.d.ts +49 -0
  150. package/lib/esm/entities/requirements/assertContractCode.js +74 -0
  151. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +19 -4
  152. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +47 -20
  153. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +3 -2
  154. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +5 -2
  155. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -1
  156. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
  157. package/lib/esm/entities/vaultV1/vaultV1.d.ts +63 -11
  158. package/lib/esm/entities/vaultV1/vaultV1.js +53 -16
  159. package/lib/esm/entities/vaultV2/vaultV2.d.ts +54 -12
  160. package/lib/esm/entities/vaultV2/vaultV2.js +53 -16
  161. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +12 -6
  162. package/lib/esm/entities/vaultV2BlueReallocationData.js +42 -14
  163. package/lib/esm/errors.d.ts +1 -1
  164. package/lib/esm/errors.js +1 -1
  165. package/lib/esm/helpers/constant.d.ts +5 -0
  166. package/lib/esm/helpers/constant.js +5 -0
  167. package/lib/esm/helpers/index.d.ts +1 -1
  168. package/lib/esm/helpers/index.js +1 -1
  169. package/lib/esm/helpers/validate.d.ts +163 -8
  170. package/lib/esm/helpers/validate.js +177 -7
  171. package/lib/esm/helpers/validateMidnightBounds.d.ts +47 -0
  172. package/lib/esm/helpers/validateMidnightBounds.js +72 -0
  173. package/lib/esm/helpers/validateMidnightPublication.d.ts +12 -0
  174. package/lib/esm/helpers/validateMidnightPublication.js +139 -0
  175. package/lib/esm/helpers/validateMidnightReceiver.d.ts +29 -0
  176. package/lib/esm/helpers/validateMidnightReceiver.js +80 -0
  177. package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +102 -0
  178. package/lib/esm/helpers/validateMidnightTakeFeasibility.js +226 -0
  179. package/lib/esm/index.d.ts +1 -0
  180. package/lib/esm/index.js +1 -0
  181. package/lib/esm/types/error.d.ts +197 -4
  182. package/lib/esm/types/error.js +253 -2
  183. package/lib/esm/types/index.d.ts +1 -0
  184. package/lib/esm/types/index.js +1 -0
  185. package/lib/esm/types/midnightCancelAndMake.d.ts +70 -0
  186. package/lib/esm/types/midnightCancelAndMake.js +1 -0
  187. package/lib/esm/types/midnightPublicationError.d.ts +332 -0
  188. package/lib/esm/types/midnightPublicationError.js +359 -0
  189. package/lib/esm/types/sharedLiquidity.d.ts +12 -7
  190. package/lib/esm/types.d.ts +1 -1
  191. package/lib/esm/utils.d.ts +2 -1
  192. package/lib/esm/utils.js +2 -1
  193. package/package.json +7 -6
@@ -0,0 +1,72 @@
1
+ import { maxUint128 } from "viem";
2
+ import { InputExceedsMaxError, MidnightReferralFeePctExceededError, NegativeInputError, } from "../types/error.js";
3
+ import { MIDNIGHT_MAX_REFERRAL_FEE_PCT } from "./constant.js";
4
+ /**
5
+ * Validates an integer stored by Midnight as `uint128`.
6
+ *
7
+ * @param field - Input field name used in validation errors.
8
+ * @param value - Candidate bigint.
9
+ * @returns Nothing when `value` is within the unsigned 128-bit range.
10
+ * @throws {NegativeInputError} when `value` is negative.
11
+ * @throws {InputExceedsMaxError} when `value` exceeds `maxUint128`.
12
+ * @internal
13
+ */
14
+ export const validateMidnightUint128Field = (field, value) => {
15
+ if (value < 0n)
16
+ throw new NegativeInputError(field, value);
17
+ if (value > maxUint128) {
18
+ throw new InputExceedsMaxError({ field, value, max: maxUint128 });
19
+ }
20
+ };
21
+ /**
22
+ * Enforces the SDK's 10% (`WAD / 10n`) Midnight referral-fee cap. The contract
23
+ * itself only requires `referralFeePct < WAD`.
24
+ *
25
+ * @param referralFeePct - Candidate referral fee percentage.
26
+ * @returns Nothing when the fee is within the SDK cap.
27
+ * @throws {MidnightReferralFeePctExceededError} when the fee exceeds the SDK cap.
28
+ * @internal
29
+ */
30
+ export const validateMidnightReferralFeeCap = (referralFeePct) => {
31
+ if (referralFeePct > MIDNIGHT_MAX_REFERRAL_FEE_PCT) {
32
+ throw new MidnightReferralFeePctExceededError(referralFeePct);
33
+ }
34
+ };
35
+ /**
36
+ * Enforces the uint128 collateral-supply total for each collateral index.
37
+ *
38
+ * @param field - Input array name used in validation errors.
39
+ * @param supplies - Transfers grouped by collateral index.
40
+ * @returns Nothing when every per-key sum is at most `maxUint128`.
41
+ * @throws {InputExceedsMaxError} when a per-key sum exceeds `maxUint128`.
42
+ * @internal
43
+ */
44
+ export const validateMidnightCollateralSupplySums = (field, supplies) => {
45
+ const sums = new Map();
46
+ for (const { collateralIndex, assets } of supplies) {
47
+ const sum = (sums.get(collateralIndex) ?? 0n) + assets;
48
+ if (sum > maxUint128) {
49
+ throw new InputExceedsMaxError({
50
+ field: `${field}(collateralIndex=${collateralIndex})`,
51
+ value: sum,
52
+ max: maxUint128,
53
+ });
54
+ }
55
+ sums.set(collateralIndex, sum);
56
+ }
57
+ };
58
+ /**
59
+ * Enforces uint128 limits on each offer's `maxUnits` and `maxAssets`.
60
+ *
61
+ * @param takeableOffers - Offers selected for a Midnight take.
62
+ * @returns Nothing when every offer cap is in the unsigned 128-bit range.
63
+ * @throws {NegativeInputError} when an offer cap is negative.
64
+ * @throws {InputExceedsMaxError} when an offer cap exceeds `maxUint128`.
65
+ * @internal
66
+ */
67
+ export const validateMidnightTakeableOfferBounds = (takeableOffers) => {
68
+ for (const [index, { offer }] of takeableOffers.entries()) {
69
+ validateMidnightUint128Field(`takeableOffers[${index}].offer.maxUnits`, offer.maxUnits);
70
+ validateMidnightUint128Field(`takeableOffers[${index}].offer.maxAssets`, offer.maxAssets);
71
+ }
72
+ };
@@ -0,0 +1,12 @@
1
+ import type { MidnightCancelAndMakeParams } from "../types/midnightCancelAndMake.js";
2
+ /** @internal */
3
+ export declare const snapshotMidnightCancelAndMakeParams: (params: MidnightCancelAndMakeParams) => MidnightCancelAndMakeParams;
4
+ /**
5
+ * @internal
6
+ * Validates Midnight publication and cancellation hex inputs.
7
+ *
8
+ * @param params - Snapshotted cancellation and publication inputs.
9
+ * @throws {InvalidMidnightHexInputError} when a root, publication group, cancellation group,
10
+ * callback salt, or root-signature `r`/`s` is not 32-byte hex, or payload is malformed or oversized.
11
+ */
12
+ export declare const validateMidnightPublication: (params: MidnightCancelAndMakeParams) => void;
@@ -0,0 +1,139 @@
1
+ import { MarketUtils, Payload } from "@morpho-org/midnight-sdk";
2
+ import { isHex } from "viem";
3
+ import { InvalidMidnightHexInputError } from "../types/index.js";
4
+ /** @internal */
5
+ export const snapshotMidnightCancelAndMakeParams = (params) => {
6
+ const { chainId, cancellations: inputCancellations, deadline, nativeAmount, metadata: inputMetadata, publication: inputPublication, } = params;
7
+ const cancellations = inputCancellations.map(({ group, maxConsumed }) => ({
8
+ group,
9
+ maxConsumed,
10
+ }));
11
+ let metadata;
12
+ if (inputMetadata != null) {
13
+ const { origin, timestamp } = inputMetadata;
14
+ metadata = { origin, ...(timestamp !== undefined && { timestamp }) };
15
+ }
16
+ let publication;
17
+ if (inputPublication != null) {
18
+ const { ratifier, root, groups: inputGroups, payload, rootSignature: inputSignature, blueSupply: inputBlueSupply, collateral: inputCollateral, } = inputPublication;
19
+ const groups = inputGroups.map((group) => group);
20
+ const rootSignature = inputSignature == null
21
+ ? undefined
22
+ : {
23
+ height: inputSignature.height,
24
+ nonce: inputSignature.nonce,
25
+ deadline: inputSignature.deadline,
26
+ v: inputSignature.v,
27
+ r: inputSignature.r,
28
+ s: inputSignature.s,
29
+ };
30
+ let blueSupply;
31
+ if (inputBlueSupply != null) {
32
+ const { market: inputMarket, assets, callbackSalt } = inputBlueSupply;
33
+ const { loanToken, collateralToken, oracle, irm, lltv } = inputMarket;
34
+ blueSupply = {
35
+ market: { loanToken, collateralToken, oracle, irm, lltv },
36
+ assets,
37
+ callbackSalt,
38
+ };
39
+ }
40
+ let collateral;
41
+ if (inputCollateral != null) {
42
+ const { market: inputMarket, supplies: inputSupplies } = inputCollateral;
43
+ const supplies = inputSupplies.map(({ collateralIndex, assets }) => ({
44
+ collateralIndex,
45
+ assets,
46
+ }));
47
+ collateral = { market: MarketUtils.toStruct(inputMarket), supplies };
48
+ }
49
+ publication = {
50
+ ratifier,
51
+ root,
52
+ groups,
53
+ payload,
54
+ ...(rootSignature != null && { rootSignature }),
55
+ ...(blueSupply != null && { blueSupply }),
56
+ ...(collateral != null && { collateral }),
57
+ };
58
+ }
59
+ return {
60
+ chainId,
61
+ cancellations,
62
+ deadline,
63
+ ...(nativeAmount !== undefined && { nativeAmount }),
64
+ ...(metadata != null && { metadata }),
65
+ ...(publication != null && { publication }),
66
+ };
67
+ };
68
+ /**
69
+ * @internal
70
+ * Validates Midnight publication and cancellation hex inputs.
71
+ *
72
+ * @param params - Snapshotted cancellation and publication inputs.
73
+ * @throws {InvalidMidnightHexInputError} when a root, publication group, cancellation group,
74
+ * callback salt, or root-signature `r`/`s` is not 32-byte hex, or payload is malformed or oversized.
75
+ */
76
+ export const validateMidnightPublication = (params) => {
77
+ for (const [index, cancellation] of params.cancellations.entries()) {
78
+ validateHexInput(cancellation.group, `cancellations[${index}].group`, {
79
+ exactBytes: 32,
80
+ });
81
+ }
82
+ const publication = params.publication;
83
+ if (publication == null)
84
+ return;
85
+ validateHexInput(publication.root, "publication.root", { exactBytes: 32 });
86
+ for (const [index, group] of publication.groups.entries()) {
87
+ validateHexInput(group, `publication.groups[${index}]`, {
88
+ exactBytes: 32,
89
+ });
90
+ }
91
+ if (publication.blueSupply != null) {
92
+ validateHexInput(publication.blueSupply.callbackSalt, "publication.blueSupply.callbackSalt", { exactBytes: 32 });
93
+ }
94
+ if (publication.rootSignature != null) {
95
+ validateHexInput(publication.rootSignature.r, "publication.rootSignature.r", {
96
+ exactBytes: 32,
97
+ });
98
+ validateHexInput(publication.rootSignature.s, "publication.rootSignature.s", {
99
+ exactBytes: 32,
100
+ });
101
+ }
102
+ if (publication.payload === "0x")
103
+ return;
104
+ validateHexInput(publication.payload, "publication.payload", {
105
+ maxBytes: Payload.MAX_PAYLOAD_BYTES,
106
+ });
107
+ };
108
+ // biome-ignore lint/complexity/useMaxParams: Keep value, field, and size explicit.
109
+ const validateHexInput = (value, field, size) => {
110
+ if (!isHex(value)) {
111
+ throw new InvalidMidnightHexInputError({
112
+ field,
113
+ value,
114
+ reason: "notHex",
115
+ });
116
+ }
117
+ if (value.length % 2 !== 0) {
118
+ throw new InvalidMidnightHexInputError({
119
+ field,
120
+ value,
121
+ reason: "oddLength",
122
+ });
123
+ }
124
+ const byteLength = (value.length - 2) / 2;
125
+ if ("exactBytes" in size && byteLength !== size.exactBytes) {
126
+ throw new InvalidMidnightHexInputError({
127
+ field,
128
+ value,
129
+ reason: "wrongSize",
130
+ });
131
+ }
132
+ if ("maxBytes" in size && byteLength > size.maxBytes) {
133
+ throw new InvalidMidnightHexInputError({
134
+ field,
135
+ value,
136
+ reason: "tooLong",
137
+ });
138
+ }
139
+ };
@@ -0,0 +1,29 @@
1
+ import type { MarketInput } from "@morpho-org/midnight-sdk";
2
+ import { type Address } from "viem";
3
+ /**
4
+ * Validates that a Midnight receiver field names an account that can forward received assets.
5
+ *
6
+ * `MidnightBundlesV2` has no sweep and Midnight core does not account self-transfers, so assets
7
+ * sent to a Midnight protocol contract, or to the market's loan or collateral token contracts,
8
+ * are lost permanently. The zero address burns them on tokens that accept it.
9
+ *
10
+ * @param params - Chain, market, and receiver field to check.
11
+ * @param params.chainId - Chain id used to resolve the Midnight protocol addresses.
12
+ * @param params.market - Midnight market whose token contracts are also rejected.
13
+ * @param params.field - Receiver field being validated, reported on the thrown error.
14
+ * @param params.receiver - Receiver address to check.
15
+ * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
16
+ * @throws {MidnightZeroReceiverError} when `receiver` is the zero address and `field` is not
17
+ * `"referralFeeRecipient"`.
18
+ * @throws {ReferralFeeRecipientMissingError} when `receiver` is the zero address and `field` is
19
+ * `"referralFeeRecipient"`.
20
+ * @throws {MidnightContractReceiverError} when `receiver` is a Midnight protocol contract, the
21
+ * market's `midnight` contract, its `loanToken`, or one of its `collateralParams[i].token`.
22
+ * @internal
23
+ */
24
+ export declare const validateMidnightReceiver: (params: {
25
+ readonly chainId: number;
26
+ readonly market: MarketInput;
27
+ readonly field: "receiver" | "collateralReceiver" | "referralFeeRecipient";
28
+ readonly receiver: Address;
29
+ }) => void;
@@ -0,0 +1,80 @@
1
+ import { getChainAddresses } from "@morpho-org/morpho-ts";
2
+ import { isAddressEqual, zeroAddress } from "viem";
3
+ import { MidnightContractReceiverError, MidnightZeroReceiverError, ReferralFeeRecipientMissingError, } from "../types/index.js";
4
+ /** Registry keys of the Midnight protocol contracts that cannot forward received assets. */
5
+ const MIDNIGHT_CONTRACT_KEYS = [
6
+ "midnight",
7
+ "midnightBundlesV2",
8
+ "midnightBlueBuyCallbackFactory",
9
+ "midnightMempool",
10
+ "ecrecoverRatifier",
11
+ "ecrecoverAuthorizer",
12
+ "setterRatifier",
13
+ "priceRatifierV1",
14
+ "rateRatifierV1",
15
+ ];
16
+ /**
17
+ * Validates that a Midnight receiver field names an account that can forward received assets.
18
+ *
19
+ * `MidnightBundlesV2` has no sweep and Midnight core does not account self-transfers, so assets
20
+ * sent to a Midnight protocol contract, or to the market's loan or collateral token contracts,
21
+ * are lost permanently. The zero address burns them on tokens that accept it.
22
+ *
23
+ * @param params - Chain, market, and receiver field to check.
24
+ * @param params.chainId - Chain id used to resolve the Midnight protocol addresses.
25
+ * @param params.market - Midnight market whose token contracts are also rejected.
26
+ * @param params.field - Receiver field being validated, reported on the thrown error.
27
+ * @param params.receiver - Receiver address to check.
28
+ * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
29
+ * @throws {MidnightZeroReceiverError} when `receiver` is the zero address and `field` is not
30
+ * `"referralFeeRecipient"`.
31
+ * @throws {ReferralFeeRecipientMissingError} when `receiver` is the zero address and `field` is
32
+ * `"referralFeeRecipient"`.
33
+ * @throws {MidnightContractReceiverError} when `receiver` is a Midnight protocol contract, the
34
+ * market's `midnight` contract, its `loanToken`, or one of its `collateralParams[i].token`.
35
+ * @internal
36
+ */
37
+ export const validateMidnightReceiver = (params) => {
38
+ const { field, receiver } = params;
39
+ const market = "params" in params.market ? params.market.params : params.market;
40
+ if (isAddressEqual(receiver, zeroAddress)) {
41
+ if (field === "referralFeeRecipient") {
42
+ throw new ReferralFeeRecipientMissingError();
43
+ }
44
+ throw new MidnightZeroReceiverError(field);
45
+ }
46
+ const chainAddresses = getChainAddresses(params.chainId);
47
+ if (isAddressEqual(receiver, market.midnight)) {
48
+ throw new MidnightContractReceiverError({
49
+ field,
50
+ receiver,
51
+ contract: "midnight",
52
+ });
53
+ }
54
+ for (const key of MIDNIGHT_CONTRACT_KEYS) {
55
+ const contract = chainAddresses[key];
56
+ if (contract != null && isAddressEqual(receiver, contract)) {
57
+ throw new MidnightContractReceiverError({
58
+ field,
59
+ receiver,
60
+ contract: key,
61
+ });
62
+ }
63
+ }
64
+ if (isAddressEqual(receiver, market.loanToken)) {
65
+ throw new MidnightContractReceiverError({
66
+ field,
67
+ receiver,
68
+ contract: "loanToken",
69
+ });
70
+ }
71
+ for (const [index, { token }] of market.collateralParams.entries()) {
72
+ if (isAddressEqual(receiver, token)) {
73
+ throw new MidnightContractReceiverError({
74
+ field,
75
+ receiver,
76
+ contract: `collateralToken[${index}]`,
77
+ });
78
+ }
79
+ }
80
+ };
@@ -0,0 +1,102 @@
1
+ import { type Market, type OfferStruct } from "@morpho-org/midnight-sdk";
2
+ import { type Address } from "viem";
3
+ import { type MidnightBuyTarget, type MidnightSellTarget } from "../types/index.js";
4
+ /** Takeable-offer fields the check reads, so helpers stay independent of the actions layer. */
5
+ type TakeableOfferLike = {
6
+ readonly units: bigint;
7
+ readonly offer: OfferStruct;
8
+ };
9
+ /**
10
+ * Rejects `MidnightBundlesV2` sell targets that no offer can satisfy.
11
+ *
12
+ * A Midnight unit sells for at most one loan asset, so a units target yields at most `units` minus
13
+ * the referral fee, and an assets target needs at least `assets` plus the referral fee in units.
14
+ *
15
+ * @param params - Sell target and validated referral fee.
16
+ * @param params.target - Sell target of `takeBorrow`, `takeWithdraw` or `supplyCollateralTakeBorrow`.
17
+ * @param params.referralFeePct - WAD-scaled referral fee, already checked to be below WAD.
18
+ * @returns Nothing when the target is reachable at some price.
19
+ * @throws {MidnightTakeTargetUnreachableError} when `target.minSellerAssets` exceeds the most the
20
+ * units can yield, or `target.maxUnits` is below the units the assets need.
21
+ * @internal
22
+ */
23
+ export declare const validateMidnightSellTargetBounds: (params: {
24
+ readonly target: MidnightSellTarget;
25
+ readonly referralFeePct: bigint;
26
+ }) => void;
27
+ /**
28
+ * Inputs shared by the Midnight entity take flows' feasibility check.
29
+ *
30
+ * @internal
31
+ */
32
+ export type MidnightTakeFeasibilityParams<T extends TakeableOfferLike = TakeableOfferLike> = {
33
+ /** Offers supplied by the caller. */
34
+ readonly takeableOffers: readonly T[];
35
+ /** Taker; it sends the transaction, so offers it made are self-takes. */
36
+ readonly accountAddress: Address;
37
+ /** Market snapshot used for maturity, continuous fee and settlement fees. */
38
+ readonly marketData: Market;
39
+ /** Current timestamp in seconds. */
40
+ readonly now: bigint;
41
+ /** Bundle deadline in seconds. */
42
+ readonly deadline: bigint;
43
+ /** WAD-scaled referral fee, already checked to be below WAD. */
44
+ readonly referralFeePct: bigint;
45
+ /**
46
+ * Units the bundle fills without offers: withdrawn credit for sells, the direct repay at par for
47
+ * buys with `repayEnabled`. Use an upper bound.
48
+ */
49
+ readonly fallbackUnits: bigint;
50
+ } & ({
51
+ /** Taker buys units from sell offers (`takeLend`, `takeRepayWithdrawCollateral`). */
52
+ readonly side: "buy";
53
+ readonly target: MidnightBuyTarget;
54
+ /** Largest market continuous fee the caller accepts. */
55
+ readonly maxContinuousFee: bigint;
56
+ /**
57
+ * Debt from the position snapshot for a reduce-only repay; the target may not exceed it, and a
58
+ * `units: maxUint256` target resolves to it.
59
+ */
60
+ readonly debt?: bigint;
61
+ } | {
62
+ /** Taker sells units to buy offers (`takeBorrow`, `takeWithdraw`, `supplyCollateralTakeBorrow`). */
63
+ readonly side: "sell";
64
+ readonly target: MidnightSellTarget;
65
+ /** Whether offer fills open debt for the taker, which Midnight blocks after maturity. */
66
+ readonly increasesDebt: boolean;
67
+ /**
68
+ * Taker credit from the position snapshot. After maturity, debt-opening offer fills can only
69
+ * sell the credit left after the fallback withdrawal.
70
+ */
71
+ readonly credit?: bigint;
72
+ });
73
+ /**
74
+ * Rejects Midnight entity takes that `MidnightBundlesV2` would revert, and drops offers that can
75
+ * only abort the bundle.
76
+ *
77
+ * `MidnightBundlesV2` skips an offer whose take reverts, so a dead offer only matters when no other
78
+ * offer or fallback can fill the target. An offer is dead when it is expired, cannot start before
79
+ * `deadline`, was made by `accountAddress`, has a `continuousFeeCap` below the market fee, carries
80
+ * zero units, has a tick outside `[0, MAX_TICK]`, is a buy offer with a non-zero
81
+ * `receiverIfMakerIsSeller`, or opens debt after maturity once the withdrawal used all the taker's
82
+ * credit. Some offers revert the whole bundle before the take, so they are removed instead: on a
83
+ * buy assets target, a sell offer whose tick is out of range or whose buyer price is zero or above
84
+ * one at every time up to `deadline`; on any sell, a buy offer whose tick is out of range, whose
85
+ * price is zero, or whose price is below the settlement fee (at or below it on an assets target) at every
86
+ * time up to `deadline`.
87
+ *
88
+ * @param params - Offers, taker, market snapshot, clock, target and fallback.
89
+ * @returns `params.takeableOffers` itself, or a copy without the removed offers.
90
+ * @throws {ExpiredDeadlineError} when `deadline` is not after `now`.
91
+ * @throws {MidnightContinuousFeeAboveMaxError} when a buy's `maxContinuousFee` is below the market
92
+ * continuous fee.
93
+ * @throws {MidnightRepayExceedsDebtError} when a reduce-only repay target exceeds `debt`.
94
+ * @throws {MidnightTakeableOffersNotFillableError} when every offer is dead and the flow has no
95
+ * fallback, or every offer would abort the bundle.
96
+ * @throws {MidnightTakeTargetUnreachableError} when the live offers plus the fallback cannot hold
97
+ * the target's units or a buy assets target's `minUnits`, or a buy units target's
98
+ * `maxBuyerAssets` is below its minimum cost.
99
+ * @internal
100
+ */
101
+ export declare const validateMidnightTakeFeasibility: <T extends TakeableOfferLike>(params: MidnightTakeFeasibilityParams<T>) => readonly T[];
102
+ export {};
@@ -0,0 +1,226 @@
1
+ import { MathLib } from "@morpho-org/blue-sdk";
2
+ import { MAX_TICK, MarketUtils, SETTLEMENT_FEE_BREAKPOINTS, TickLib, } from "@morpho-org/midnight-sdk";
3
+ import { isAddressEqual, maxUint256, zeroAddress } from "viem";
4
+ import { ExpiredDeadlineError, MidnightContinuousFeeAboveMaxError, MidnightRepayExceedsDebtError, MidnightTakeableOffersNotFillableError, MidnightTakeTargetUnreachableError, } from "../types/index.js";
5
+ import { grossFromNetAssets } from "./referralFee.js";
6
+ const netOfReferralFee = (assets, referralFeePct) => assets - MathLib.mulDivDown(assets, referralFeePct, MathLib.WAD);
7
+ /**
8
+ * Rejects `MidnightBundlesV2` sell targets that no offer can satisfy.
9
+ *
10
+ * A Midnight unit sells for at most one loan asset, so a units target yields at most `units` minus
11
+ * the referral fee, and an assets target needs at least `assets` plus the referral fee in units.
12
+ *
13
+ * @param params - Sell target and validated referral fee.
14
+ * @param params.target - Sell target of `takeBorrow`, `takeWithdraw` or `supplyCollateralTakeBorrow`.
15
+ * @param params.referralFeePct - WAD-scaled referral fee, already checked to be below WAD.
16
+ * @returns Nothing when the target is reachable at some price.
17
+ * @throws {MidnightTakeTargetUnreachableError} when `target.minSellerAssets` exceeds the most the
18
+ * units can yield, or `target.maxUnits` is below the units the assets need.
19
+ * @internal
20
+ */
21
+ export const validateMidnightSellTargetBounds = (params) => {
22
+ const { target, referralFeePct } = params;
23
+ if (target.type === "units") {
24
+ const maxSellerAssets = netOfReferralFee(target.units, referralFeePct);
25
+ if (target.minSellerAssets > maxSellerAssets) {
26
+ throw new MidnightTakeTargetUnreachableError({
27
+ field: "target.minSellerAssets",
28
+ value: target.minSellerAssets,
29
+ limit: maxSellerAssets,
30
+ });
31
+ }
32
+ return;
33
+ }
34
+ // MidnightBundlesV2 grosses the received assets up by the referral fee before filling.
35
+ const minUnits = grossFromNetAssets({
36
+ netAssets: target.assets,
37
+ referralFeePct,
38
+ });
39
+ if (target.maxUnits < minUnits) {
40
+ throw new MidnightTakeTargetUnreachableError({
41
+ field: "target.maxUnits",
42
+ value: target.maxUnits,
43
+ limit: minUnits,
44
+ });
45
+ }
46
+ };
47
+ /**
48
+ * Rejects Midnight entity takes that `MidnightBundlesV2` would revert, and drops offers that can
49
+ * only abort the bundle.
50
+ *
51
+ * `MidnightBundlesV2` skips an offer whose take reverts, so a dead offer only matters when no other
52
+ * offer or fallback can fill the target. An offer is dead when it is expired, cannot start before
53
+ * `deadline`, was made by `accountAddress`, has a `continuousFeeCap` below the market fee, carries
54
+ * zero units, has a tick outside `[0, MAX_TICK]`, is a buy offer with a non-zero
55
+ * `receiverIfMakerIsSeller`, or opens debt after maturity once the withdrawal used all the taker's
56
+ * credit. Some offers revert the whole bundle before the take, so they are removed instead: on a
57
+ * buy assets target, a sell offer whose tick is out of range or whose buyer price is zero or above
58
+ * one at every time up to `deadline`; on any sell, a buy offer whose tick is out of range, whose
59
+ * price is zero, or whose price is below the settlement fee (at or below it on an assets target) at every
60
+ * time up to `deadline`.
61
+ *
62
+ * @param params - Offers, taker, market snapshot, clock, target and fallback.
63
+ * @returns `params.takeableOffers` itself, or a copy without the removed offers.
64
+ * @throws {ExpiredDeadlineError} when `deadline` is not after `now`.
65
+ * @throws {MidnightContinuousFeeAboveMaxError} when a buy's `maxContinuousFee` is below the market
66
+ * continuous fee.
67
+ * @throws {MidnightRepayExceedsDebtError} when a reduce-only repay target exceeds `debt`.
68
+ * @throws {MidnightTakeableOffersNotFillableError} when every offer is dead and the flow has no
69
+ * fallback, or every offer would abort the bundle.
70
+ * @throws {MidnightTakeTargetUnreachableError} when the live offers plus the fallback cannot hold
71
+ * the target's units or a buy assets target's `minUnits`, or a buy units target's
72
+ * `maxBuyerAssets` is below its minimum cost.
73
+ * @internal
74
+ */
75
+ export const validateMidnightTakeFeasibility = (params) => {
76
+ // The raw builder rejects an empty list with `EmptyMidnightTakeableOffersError`.
77
+ if (params.takeableOffers.length === 0)
78
+ return params.takeableOffers;
79
+ const { marketData, now, deadline, referralFeePct, target } = params;
80
+ // The entity checked the deadline on an earlier clock read; recheck so the fee window is never empty.
81
+ if (deadline <= now)
82
+ throw new ExpiredDeadlineError(deadline, now);
83
+ const maturity = marketData.params.maturity;
84
+ const marketFee = BigInt(marketData.continuousFee);
85
+ if (params.side === "buy") {
86
+ if (params.maxContinuousFee < marketFee) {
87
+ throw new MidnightContinuousFeeAboveMaxError({
88
+ maxContinuousFee: params.maxContinuousFee,
89
+ continuousFee: marketFee,
90
+ });
91
+ }
92
+ const { debt, target: buyTarget } = params;
93
+ if (debt !== undefined) {
94
+ // Reduce-only buys fill at most the debt, and an assets target pays at most one asset per unit.
95
+ const repay = buyTarget.type === "units"
96
+ ? buyTarget.units === maxUint256
97
+ ? undefined
98
+ : { field: "target.units", value: buyTarget.units }
99
+ : buyTarget.minUnits > debt
100
+ ? {
101
+ field: "target.minUnits",
102
+ value: buyTarget.minUnits,
103
+ }
104
+ : {
105
+ field: "target.assets",
106
+ value: netOfReferralFee(buyTarget.assets, referralFeePct),
107
+ };
108
+ if (repay && repay.value > debt) {
109
+ throw new MidnightRepayExceedsDebtError({ ...repay, debt });
110
+ }
111
+ }
112
+ }
113
+ const fees = [
114
+ maturity - deadline,
115
+ maturity - now,
116
+ ...SETTLEMENT_FEE_BREAKPOINTS,
117
+ ]
118
+ .filter((ttm) => ttm >= maturity - deadline && ttm <= maturity - now)
119
+ .map((ttm) => MarketUtils.getSettlementFee({
120
+ settlementFeeCbps: marketData.settlementFeeCbps,
121
+ timeToMaturity: MathLib.max(ttm, 0n),
122
+ }));
123
+ const minFee = MathLib.min(...fees);
124
+ const maxFee = MathLib.max(...fees);
125
+ const dead = [];
126
+ const removed = new Set();
127
+ // Post-maturity sells cannot open debt, so offers only take the credit left after the withdrawal.
128
+ const sellableCredit = params.side === "sell" && params.increasesDebt && now > maturity
129
+ ? MathLib.zeroFloorSub(params.credit ?? 0n, params.fallbackUnits)
130
+ : undefined;
131
+ let liveUnits = 0n;
132
+ let minBuyerPrice = params.fallbackUnits > 0n ? MathLib.WAD : maxUint256;
133
+ for (const [index, { units, offer }] of params.takeableOffers.entries()) {
134
+ const tickInRange = offer.tick >= 0n && offer.tick <= MAX_TICK;
135
+ const offerPrice = tickInRange ? TickLib.tickToPrice(offer.tick) : 0n;
136
+ let reason;
137
+ // The bundle converts every buy assets target price outside its per-offer catch,
138
+ // so a degenerate price aborts the bundle even when the offer is otherwise dead.
139
+ if (params.side === "buy" && target.type === "assets") {
140
+ if (!tickInRange)
141
+ reason = "tickOutOfRange";
142
+ else if (offerPrice + maxFee === 0n)
143
+ reason = "zeroBuyerPrice";
144
+ else if (offerPrice + minFee > MathLib.WAD)
145
+ reason = "buyerPriceAboveOne";
146
+ if (reason)
147
+ removed.add(index);
148
+ }
149
+ // Every sell converts a buy offer's price outside the catch too, which underflows below the fee.
150
+ if (params.side === "sell") {
151
+ if (!tickInRange)
152
+ reason = "tickOutOfRange";
153
+ else if (offerPrice === 0n)
154
+ reason = "zeroBuyerPrice";
155
+ // An assets target also divides by the seller price, which is zero at the fee.
156
+ else if (offerPrice < minFee ||
157
+ (target.type === "assets" && offerPrice === minFee))
158
+ reason = "priceBelowSettlementFee";
159
+ if (reason)
160
+ removed.add(index);
161
+ }
162
+ if (!reason) {
163
+ if (units === 0n)
164
+ reason = "zeroUnits";
165
+ else if (!tickInRange)
166
+ reason = "tickOutOfRange";
167
+ else if (offer.expiry < now)
168
+ reason = "expired";
169
+ else if (offer.start > deadline)
170
+ reason = "notStarted";
171
+ else if (isAddressEqual(offer.maker, params.accountAddress))
172
+ reason = "selfTake";
173
+ else if (offer.continuousFeeCap < marketFee)
174
+ reason = "continuousFeeCapBelowMarketFee";
175
+ else if (params.side === "sell" &&
176
+ !isAddressEqual(offer.receiverIfMakerIsSeller, zeroAddress))
177
+ reason = "receiverIfMakerIsSellerNotZero";
178
+ else if (sellableCredit === 0n)
179
+ reason = "marketMatured";
180
+ }
181
+ if (reason) {
182
+ dead.push({ index, reason });
183
+ continue;
184
+ }
185
+ liveUnits += units;
186
+ minBuyerPrice = MathLib.min(minBuyerPrice, offerPrice + minFee);
187
+ }
188
+ if (dead.length === params.takeableOffers.length &&
189
+ (params.fallbackUnits === 0n || removed.size === dead.length)) {
190
+ throw new MidnightTakeableOffersNotFillableError(dead);
191
+ }
192
+ const requiredUnits = params.side === "sell"
193
+ ? target.type === "units"
194
+ ? target.units
195
+ : grossFromNetAssets({ netAssets: target.assets, referralFeePct })
196
+ : params.target.type === "units"
197
+ ? params.target.units === maxUint256
198
+ ? (params.debt ?? 0n)
199
+ : params.target.units
200
+ : MathLib.max(netOfReferralFee(params.target.assets, referralFeePct), params.target.minUnits);
201
+ const fillableUnits = (sellableCredit === undefined
202
+ ? liveUnits
203
+ : MathLib.min(liveUnits, sellableCredit)) + params.fallbackUnits;
204
+ if (fillableUnits < requiredUnits) {
205
+ throw new MidnightTakeTargetUnreachableError({
206
+ field: "takeableOffers",
207
+ value: fillableUnits,
208
+ limit: requiredUnits,
209
+ });
210
+ }
211
+ if (params.side === "buy" && params.target.type === "units") {
212
+ // Every unit costs at least the cheapest live price, and the fee is grossed up on top.
213
+ const minCost = MathLib.mulDivDown(requiredUnits, minBuyerPrice, MathLib.WAD);
214
+ const minPull = grossFromNetAssets({ netAssets: minCost, referralFeePct });
215
+ if (params.target.maxBuyerAssets < minPull) {
216
+ throw new MidnightTakeTargetUnreachableError({
217
+ field: "target.maxBuyerAssets",
218
+ value: params.target.maxBuyerAssets,
219
+ limit: minPull,
220
+ });
221
+ }
222
+ }
223
+ return removed.size === 0
224
+ ? params.takeableOffers
225
+ : params.takeableOffers.filter((_, index) => !removed.has(index));
226
+ };
@@ -1,4 +1,5 @@
1
1
  export * from "./actions/index.js";
2
+ export { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
2
3
  export * from "./client/index.js";
3
4
  export * from "./entities/requirements/index.js";
4
5
  export * from "./helpers/index.js";
package/lib/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./actions/index.js";
2
+ export { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
2
3
  export * from "./client/index.js";
3
4
  export * from "./entities/requirements/index.js";
4
5
  export * from "./helpers/index.js";