@morpho-org/morpho-sdk 6.0.0-next.2 → 6.0.0-next.3

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 (257) hide show
  1. package/MIGRATION-v5-to-v6.md +83 -29
  2. package/README.md +9 -7
  3. package/lib/cjs/abis.d.ts +3 -2844
  4. package/lib/cjs/abis.js +1 -1951
  5. package/lib/cjs/actions/blue/borrow.d.ts +3 -2
  6. package/lib/cjs/actions/blue/borrow.js +3 -2
  7. package/lib/cjs/actions/blue/common.js +1 -9
  8. package/lib/cjs/actions/blue/refinance.d.ts +2 -2
  9. package/lib/cjs/actions/blue/refinance.js +2 -2
  10. package/lib/cjs/actions/blue/repay.d.ts +1 -1
  11. package/lib/cjs/actions/blue/repay.js +1 -1
  12. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
  14. package/lib/cjs/actions/blue/supply.d.ts +2 -2
  15. package/lib/cjs/actions/blue/supply.js +2 -2
  16. package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -2
  17. package/lib/cjs/actions/blue/supplyCollateral.js +2 -2
  18. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +3 -2
  20. package/lib/cjs/actions/blue/withdraw.d.ts +3 -3
  21. package/lib/cjs/actions/blue/withdraw.js +3 -3
  22. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +2 -2
  23. package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
  24. package/lib/cjs/actions/bundles/common.d.ts +6 -2
  25. package/lib/cjs/actions/bundles/common.js +23 -5
  26. package/lib/cjs/actions/index.d.ts +0 -1
  27. package/lib/cjs/actions/index.js +0 -1
  28. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
  29. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -16
  30. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
  31. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
  32. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  33. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +4 -5
  34. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
  35. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +6 -11
  36. package/lib/cjs/actions/requirements/encode/index.d.ts +0 -1
  37. package/lib/cjs/actions/requirements/encode/index.js +0 -1
  38. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -6
  39. package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -6
  40. package/lib/cjs/actions/requirements/index.d.ts +0 -1
  41. package/lib/cjs/actions/requirements/index.js +0 -1
  42. package/lib/cjs/actions/vaultV1/deposit.d.ts +1 -2
  43. package/lib/cjs/actions/vaultV1/deposit.js +1 -2
  44. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +6 -5
  45. package/lib/cjs/actions/vaultV1/inKindRedeem.js +10 -7
  46. package/lib/cjs/actions/vaultV2/deposit.d.ts +1 -2
  47. package/lib/cjs/actions/vaultV2/deposit.js +1 -2
  48. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
  49. package/lib/cjs/actions/vaultV2/forceWithdraw.js +3 -3
  50. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +6 -5
  51. package/lib/cjs/actions/vaultV2/inKindRedeem.js +10 -7
  52. package/lib/cjs/augment.d.ts +0 -1
  53. package/lib/cjs/augment.js +0 -1
  54. package/lib/cjs/blue/abis.d.ts +1 -5
  55. package/lib/cjs/blue/abis.js +1 -7
  56. package/lib/cjs/blue/entities.d.ts +2 -8
  57. package/lib/cjs/blue/entities.js +1 -3
  58. package/lib/cjs/blue/fetch.d.ts +1 -3
  59. package/lib/cjs/blue/fetch.js +1 -3
  60. package/lib/cjs/blue/types.d.ts +2 -4
  61. package/lib/cjs/blue/utils.d.ts +1 -3
  62. package/lib/cjs/blue/utils.js +1 -3
  63. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  64. package/lib/cjs/client/morphoViemExtension.js +1 -1
  65. package/lib/cjs/constants.d.ts +3 -37
  66. package/lib/cjs/constants.js +1 -39
  67. package/lib/cjs/entities/blue/blue.d.ts +30 -265
  68. package/lib/cjs/entities/blue/blue.js +1 -205
  69. package/lib/cjs/entities/index.d.ts +3 -66
  70. package/lib/cjs/entities/index.js +1 -21
  71. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -2
  72. package/lib/cjs/entities/vaultV1/vaultV1.js +12 -7
  73. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +22 -9
  74. package/lib/cjs/entities/vaultV2/vaultV2.js +28 -15
  75. package/lib/cjs/entities/vaultV2BlueReallocationData.js +4 -21
  76. package/lib/cjs/errors.d.ts +2 -46
  77. package/lib/cjs/errors.js +1 -46
  78. package/lib/cjs/fetch.d.ts +1 -17
  79. package/lib/cjs/fetch.js +1 -17
  80. package/lib/cjs/helpers/constant.d.ts +0 -2
  81. package/lib/cjs/helpers/constant.js +0 -2
  82. package/lib/cjs/helpers/index.d.ts +2 -3
  83. package/lib/cjs/helpers/index.js +1 -9
  84. package/lib/cjs/helpers/slippage.d.ts +1 -103
  85. package/lib/cjs/helpers/slippage.js +0 -150
  86. package/lib/cjs/helpers/utilization.d.ts +12 -10
  87. package/lib/cjs/helpers/utilization.js +27 -12
  88. package/lib/cjs/helpers/validate.d.ts +1 -24
  89. package/lib/cjs/helpers/validate.js +2 -49
  90. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  91. package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
  92. package/lib/cjs/types/action.d.ts +17 -65
  93. package/lib/cjs/types/action.js +11 -4
  94. package/lib/cjs/types/error.d.ts +50 -381
  95. package/lib/cjs/types/error.js +64 -395
  96. package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
  97. package/lib/cjs/types.d.ts +2 -18
  98. package/lib/cjs/utils.d.ts +6 -35
  99. package/lib/cjs/utils.js +2 -36
  100. package/lib/esm/abis.d.ts +3 -2844
  101. package/lib/esm/abis.js +3 -1950
  102. package/lib/esm/actions/blue/borrow.d.ts +3 -2
  103. package/lib/esm/actions/blue/borrow.js +3 -2
  104. package/lib/esm/actions/blue/common.js +1 -9
  105. package/lib/esm/actions/blue/refinance.d.ts +2 -2
  106. package/lib/esm/actions/blue/refinance.js +2 -2
  107. package/lib/esm/actions/blue/repay.d.ts +1 -1
  108. package/lib/esm/actions/blue/repay.js +1 -1
  109. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  110. package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
  111. package/lib/esm/actions/blue/supply.d.ts +2 -2
  112. package/lib/esm/actions/blue/supply.js +2 -2
  113. package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -2
  114. package/lib/esm/actions/blue/supplyCollateral.js +2 -2
  115. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  116. package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -2
  117. package/lib/esm/actions/blue/withdraw.d.ts +3 -3
  118. package/lib/esm/actions/blue/withdraw.js +3 -3
  119. package/lib/esm/actions/blue/withdrawCollateral.d.ts +2 -2
  120. package/lib/esm/actions/blue/withdrawCollateral.js +2 -2
  121. package/lib/esm/actions/bundles/common.d.ts +6 -2
  122. package/lib/esm/actions/bundles/common.js +24 -6
  123. package/lib/esm/actions/index.d.ts +0 -1
  124. package/lib/esm/actions/index.js +0 -1
  125. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
  126. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +12 -17
  127. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
  128. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
  129. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  130. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +4 -5
  131. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
  132. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +6 -11
  133. package/lib/esm/actions/requirements/encode/index.d.ts +0 -1
  134. package/lib/esm/actions/requirements/encode/index.js +0 -1
  135. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -6
  136. package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -6
  137. package/lib/esm/actions/requirements/index.d.ts +0 -1
  138. package/lib/esm/actions/requirements/index.js +0 -1
  139. package/lib/esm/actions/vaultV1/deposit.d.ts +1 -2
  140. package/lib/esm/actions/vaultV1/deposit.js +1 -2
  141. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +6 -5
  142. package/lib/esm/actions/vaultV1/inKindRedeem.js +10 -7
  143. package/lib/esm/actions/vaultV2/deposit.d.ts +1 -2
  144. package/lib/esm/actions/vaultV2/deposit.js +1 -2
  145. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  146. package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
  147. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +6 -5
  148. package/lib/esm/actions/vaultV2/inKindRedeem.js +10 -7
  149. package/lib/esm/augment.d.ts +0 -1
  150. package/lib/esm/augment.js +0 -1
  151. package/lib/esm/blue/abis.d.ts +1 -5
  152. package/lib/esm/blue/abis.js +1 -5
  153. package/lib/esm/blue/entities.d.ts +2 -8
  154. package/lib/esm/blue/entities.js +1 -3
  155. package/lib/esm/blue/fetch.d.ts +1 -3
  156. package/lib/esm/blue/fetch.js +1 -3
  157. package/lib/esm/blue/types.d.ts +2 -4
  158. package/lib/esm/blue/utils.d.ts +1 -3
  159. package/lib/esm/blue/utils.js +1 -3
  160. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  161. package/lib/esm/client/morphoViemExtension.js +1 -1
  162. package/lib/esm/constants.d.ts +3 -37
  163. package/lib/esm/constants.js +3 -37
  164. package/lib/esm/entities/blue/blue.d.ts +30 -265
  165. package/lib/esm/entities/blue/blue.js +4 -208
  166. package/lib/esm/entities/index.d.ts +3 -66
  167. package/lib/esm/entities/index.js +1 -18
  168. package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -2
  169. package/lib/esm/entities/vaultV1/vaultV1.js +15 -10
  170. package/lib/esm/entities/vaultV2/vaultV2.d.ts +22 -9
  171. package/lib/esm/entities/vaultV2/vaultV2.js +32 -19
  172. package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -19
  173. package/lib/esm/errors.d.ts +2 -46
  174. package/lib/esm/errors.js +2 -46
  175. package/lib/esm/fetch.d.ts +1 -17
  176. package/lib/esm/fetch.js +1 -17
  177. package/lib/esm/helpers/constant.d.ts +0 -2
  178. package/lib/esm/helpers/constant.js +0 -2
  179. package/lib/esm/helpers/index.d.ts +2 -3
  180. package/lib/esm/helpers/index.js +2 -3
  181. package/lib/esm/helpers/slippage.d.ts +1 -103
  182. package/lib/esm/helpers/slippage.js +1 -147
  183. package/lib/esm/helpers/utilization.d.ts +12 -10
  184. package/lib/esm/helpers/utilization.js +26 -11
  185. package/lib/esm/helpers/validate.d.ts +1 -24
  186. package/lib/esm/helpers/validate.js +2 -48
  187. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  188. package/lib/esm/helpers/validateRequirementSpender.js +1 -3
  189. package/lib/esm/types/action.d.ts +17 -65
  190. package/lib/esm/types/action.js +12 -5
  191. package/lib/esm/types/error.d.ts +50 -381
  192. package/lib/esm/types/error.js +58 -377
  193. package/lib/esm/types/sharedLiquidity.d.ts +1 -117
  194. package/lib/esm/types.d.ts +2 -18
  195. package/lib/esm/utils.d.ts +6 -35
  196. package/lib/esm/utils.js +5 -34
  197. package/package.json +5 -13
  198. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
  199. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -88
  200. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  201. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -152
  202. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
  203. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -53
  204. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  205. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -74
  206. package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +0 -3
  207. package/lib/cjs/actions/requirements/generalAdapter/index.js +0 -19
  208. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  209. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +0 -48
  210. package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  211. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +0 -119
  212. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
  213. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -45
  214. package/lib/cjs/actions/signatures/index.d.ts +0 -3
  215. package/lib/cjs/actions/signatures/index.js +0 -19
  216. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
  217. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +0 -8
  218. package/lib/cjs/bundler/actions.d.ts +0 -797
  219. package/lib/cjs/bundler/actions.js +0 -1371
  220. package/lib/cjs/bundler/index.d.ts +0 -2
  221. package/lib/cjs/bundler/index.js +0 -18
  222. package/lib/cjs/bundler/types.d.ts +0 -235
  223. package/lib/cjs/bundler/types.js +0 -2
  224. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +0 -332
  225. package/lib/cjs/entities/vaultV1ReallocationData.js +0 -557
  226. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -80
  227. package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -245
  228. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
  229. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -84
  230. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  231. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -148
  232. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
  233. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -49
  234. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  235. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -70
  236. package/lib/esm/actions/requirements/generalAdapter/index.d.ts +0 -3
  237. package/lib/esm/actions/requirements/generalAdapter/index.js +0 -3
  238. package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  239. package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +0 -44
  240. package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  241. package/lib/esm/actions/signatures/getTokenRequirementActions.js +0 -115
  242. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
  243. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -41
  244. package/lib/esm/actions/signatures/index.d.ts +0 -3
  245. package/lib/esm/actions/signatures/index.js +0 -3
  246. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
  247. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -7
  248. package/lib/esm/bundler/actions.d.ts +0 -797
  249. package/lib/esm/bundler/actions.js +0 -1368
  250. package/lib/esm/bundler/index.d.ts +0 -2
  251. package/lib/esm/bundler/index.js +0 -2
  252. package/lib/esm/bundler/types.d.ts +0 -235
  253. package/lib/esm/bundler/types.js +0 -1
  254. package/lib/esm/entities/vaultV1ReallocationData.d.ts +0 -332
  255. package/lib/esm/entities/vaultV1ReallocationData.js +0 -559
  256. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -80
  257. package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -241
@@ -1,103 +1,7 @@
1
1
  import { AccrualVaultV2, MathLib, } from "@morpho-org/blue-sdk";
2
- import { ExcessiveSlippageToleranceError, NonPositiveInputError, ShareDivideByZeroError, VaultV2ForceWithdrawZeroSharePriceError, } from "../types/index.js";
2
+ import { NonPositiveInputError, VaultV2ForceWithdrawZeroSharePriceError, } from "../types/index.js";
3
3
  import { MAX_ABSOLUTE_SHARE_PRICE } from "./constant.js";
4
4
  import { validateSlippageTolerance } from "./validate.js";
5
- /**
6
- * Computes the minimum borrow share price (in RAY, 1e27) for slippage protection.
7
- *
8
- * Mirrors the on-chain check in GeneralAdapter1's `morphoBorrow`:
9
- * ```solidity
10
- * require(borrowedAssets.rDivDown(borrowedShares) >= minSharePriceE27)
11
- * ```
12
- *
13
- * @param params - Computation parameters.
14
- * @param params.borrowAmount - The amount of assets to borrow.
15
- * @param params.market - The market to compute the minimum borrow share price for.
16
- * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. 0.003e18 = 0.3%).
17
- * @returns minSharePriceE27 in RAY scale (1e27).
18
- */
19
- export function computeMinBorrowSharePrice(params) {
20
- const { borrowAmount, market, slippageTolerance } = params;
21
- if (slippageTolerance >= MathLib.WAD) {
22
- throw new ExcessiveSlippageToleranceError(slippageTolerance);
23
- }
24
- const expectedShares = market.toBorrowShares(borrowAmount, "Up");
25
- if (expectedShares === 0n) {
26
- throw new ShareDivideByZeroError(market.params.id);
27
- }
28
- return MathLib.mulDivDown(borrowAmount, MathLib.wToRay(MathLib.WAD - slippageTolerance), expectedShares);
29
- }
30
- /**
31
- * Computes the maximum repay share price (in RAY, 1e27) for slippage protection.
32
- *
33
- * Supports both repay-by-assets and repay-by-shares paths:
34
- * - By assets: derives expected shares from the repay amount via `toBorrowShares("Down")`.
35
- * - By shares: derives expected assets from the shares via `toBorrowAssets("Up")`.
36
- *
37
- * Direction is opposite of borrow's `minSharePrice`:
38
- * - Borrow uses `(WAD - slippage)` → lower bound (protects borrower from getting fewer assets per share).
39
- * - Repay uses `(WAD + slippage)` → upper bound (protects repayer from paying too many assets per share).
40
- *
41
- * Capped at {@link MAX_ABSOLUTE_SHARE_PRICE} to prevent absurd values.
42
- *
43
- * @param params - Computation parameters.
44
- * @param params.repayAssets - The amount of assets to repay (0n when repaying by shares).
45
- * @param params.repayShares - The amount of shares to repay (0n when repaying by assets).
46
- * @param params.market - The market to compute the maximum repay share price for.
47
- * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. 0.003e18 = 0.3%).
48
- * @returns maxSharePriceE27 in RAY scale (1e27).
49
- */
50
- export function computeMaxRepaySharePrice(params) {
51
- const { repayAssets, repayShares, market, slippageTolerance } = params;
52
- if (slippageTolerance >= MathLib.WAD) {
53
- throw new ExcessiveSlippageToleranceError(slippageTolerance);
54
- }
55
- let assets;
56
- let shares;
57
- if (repayShares > 0n) {
58
- assets = market.toBorrowAssets(repayShares, "Up");
59
- shares = repayShares;
60
- }
61
- else {
62
- assets = repayAssets;
63
- shares = market.toBorrowShares(repayAssets, "Down");
64
- }
65
- if (shares === 0n) {
66
- throw new ShareDivideByZeroError(market.params.id);
67
- }
68
- const maxSharePrice = MathLib.mulDivUp(assets, MathLib.wToRay(MathLib.WAD + slippageTolerance), shares);
69
- return MathLib.min(maxSharePrice, MAX_ABSOLUTE_SHARE_PRICE);
70
- }
71
- /**
72
- * Computes the maximum supply share price (in RAY, 1e27) for slippage protection.
73
- *
74
- * Mirrors the on-chain check in GeneralAdapter1's `morphoSupply`:
75
- * ```solidity
76
- * require(suppliedAssets.rDivUp(suppliedShares) <= maxSharePriceE27)
77
- * ```
78
- *
79
- * Caps at {@link MAX_ABSOLUTE_SHARE_PRICE} to prevent absurd values on extreme markets.
80
- *
81
- * @param params - Computation parameters.
82
- * @param params.supplyAssets - The amount of loan assets to supply.
83
- * @param params.market - The market to compute the maximum supply share price for.
84
- * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%).
85
- * @returns `maxSharePriceE27` in RAY scale (1e27).
86
- * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance >= WAD`.
87
- * @throws {ShareDivideByZeroError} when expected shares round down to zero.
88
- */
89
- export function computeMaxSupplySharePrice(params) {
90
- const { supplyAssets, market, slippageTolerance } = params;
91
- if (slippageTolerance >= MathLib.WAD) {
92
- throw new ExcessiveSlippageToleranceError(slippageTolerance);
93
- }
94
- const expectedShares = market.toSupplyShares(supplyAssets, "Down");
95
- if (expectedShares === 0n) {
96
- throw new ShareDivideByZeroError(market.params.id);
97
- }
98
- const maxSharePrice = MathLib.mulDivUp(supplyAssets, MathLib.wToRay(MathLib.WAD + slippageTolerance), expectedShares);
99
- return MathLib.min(maxSharePrice, MAX_ABSOLUTE_SHARE_PRICE);
100
- }
101
5
  /**
102
6
  * Computes the minimum Vault V2 force-withdraw share price (in RAY, 1e27) for slippage protection.
103
7
  *
@@ -162,56 +66,6 @@ export function computeMinForceWithdrawSharePrice(params) {
162
66
  }
163
67
  return minSharePriceE27;
164
68
  }
165
- /**
166
- * Computes the minimum withdraw share price (in RAY, 1e27) for slippage protection.
167
- *
168
- * Mirrors the on-chain check in GeneralAdapter1's `morphoWithdraw`:
169
- * ```solidity
170
- * require(withdrawnAssets.rDivDown(withdrawnShares) >= minSharePriceE27)
171
- * ```
172
- *
173
- * Supports both assets and shares modes:
174
- * - By assets: derives expected shares via `toSupplyShares("Up")` (upper bound, protects the
175
- * withdrawer against over-burning shares).
176
- * - By shares: derives expected assets via `toSupplyAssets("Down")` (lower bound, the on-chain
177
- * amount paid out).
178
- *
179
- * Direction is opposite of supply's `maxSharePrice`:
180
- * - Supply uses `(WAD + slippage)` → upper bound (anti-inflation).
181
- * - Withdraw uses `(WAD − slippage)` → lower bound (protects withdrawer from receiving too few
182
- * assets per share burned).
183
- *
184
- * @param params - Computation parameters.
185
- * @param params.withdrawAssets - The amount of assets to withdraw (`0n` when withdrawing by shares).
186
- * @param params.withdrawShares - The amount of shares to withdraw (`0n` when withdrawing by assets).
187
- * @param params.market - The market to compute the minimum withdraw share price for.
188
- * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%).
189
- * @returns `minSharePriceE27` in RAY scale (1e27).
190
- * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance >= WAD`.
191
- * @throws {ShareDivideByZeroError} when expected shares round down to zero.
192
- */
193
- export function computeMinWithdrawSharePrice(params) {
194
- const { withdrawAssets, withdrawShares, market, slippageTolerance } = params;
195
- if (slippageTolerance >= MathLib.WAD) {
196
- throw new ExcessiveSlippageToleranceError(slippageTolerance);
197
- }
198
- let assets;
199
- let shares;
200
- if (withdrawShares > 0n) {
201
- assets = market.toSupplyAssets(withdrawShares, "Down");
202
- shares = withdrawShares;
203
- }
204
- else {
205
- assets = withdrawAssets;
206
- shares = market.toSupplyShares(withdrawAssets, "Up");
207
- }
208
- // Dust shares can round to `assets === 0n` here, which would make
209
- // `minSharePriceE27 = 0` and silently nullify the on-chain slippage cap.
210
- if (shares === 0n || assets === 0n) {
211
- throw new ShareDivideByZeroError(market.params.id);
212
- }
213
- return MathLib.mulDivDown(assets, MathLib.wToRay(MathLib.WAD - slippageTolerance), shares);
214
- }
215
69
  /**
216
70
  * Computes the RAY-scaled maximum share price for a VaultBundlesV1 deposit leg.
217
71
  *
@@ -1,12 +1,14 @@
1
- import type { MarketId } from "@morpho-org/blue-sdk";
2
- import type { ReallocationComputeOptions } from "../types/index.js";
3
1
  /**
4
- * Resolves the effective supply target utilization for a market: the per-market
5
- * override, then the global default override, then
6
- * {@link DEFAULT_SUPPLY_TARGET_UTILIZATION}.
7
- *
8
- * @param marketId - The market whose supply target utilization to resolve.
9
- * @param options - Reallocation options carrying the per-market and default overrides.
10
- * @returns The supply target utilization, scaled by WAD.
2
+ * Resolves and validates a source withdrawal utilization ceiling.
3
+ * @internal
4
+ * @param value - Optional WAD-scaled utilization ceiling.
5
+ * @param field - Option name reported in validation errors.
6
+ * @returns A ceiling between zero and WAD, defaulting to the shared withdrawal target.
7
+ * @throws {NegativeInputError} when the ceiling is negative.
8
+ * @throws {InputExceedsMaxError} when the ceiling exceeds WAD.
9
+ * @example
10
+ * ```ts
11
+ * const ceiling = resolveMaxWithdrawalUtilization(undefined);
12
+ * ```
11
13
  */
12
- export declare const getSupplyTargetUtilization: (marketId: MarketId, options?: ReallocationComputeOptions) => bigint;
14
+ export declare const resolveMaxWithdrawalUtilization: (value: bigint | undefined, field?: "maxWithdrawalUtilization" | "defaultMaxWithdrawalUtilization") => bigint;
@@ -1,13 +1,28 @@
1
- import { DEFAULT_SUPPLY_TARGET_UTILIZATION } from "./constant.js";
1
+ import { MathLib } from "@morpho-org/blue-sdk";
2
+ import { InputExceedsMaxError, NegativeInputError } from "../types/index.js";
3
+ import { DEFAULT_WITHDRAWAL_TARGET_UTILIZATION } from "./constant.js";
2
4
  /**
3
- * Resolves the effective supply target utilization for a market: the per-market
4
- * override, then the global default override, then
5
- * {@link DEFAULT_SUPPLY_TARGET_UTILIZATION}.
6
- *
7
- * @param marketId - The market whose supply target utilization to resolve.
8
- * @param options - Reallocation options carrying the per-market and default overrides.
9
- * @returns The supply target utilization, scaled by WAD.
5
+ * Resolves and validates a source withdrawal utilization ceiling.
6
+ * @internal
7
+ * @param value - Optional WAD-scaled utilization ceiling.
8
+ * @param field - Option name reported in validation errors.
9
+ * @returns A ceiling between zero and WAD, defaulting to the shared withdrawal target.
10
+ * @throws {NegativeInputError} when the ceiling is negative.
11
+ * @throws {InputExceedsMaxError} when the ceiling exceeds WAD.
12
+ * @example
13
+ * ```ts
14
+ * const ceiling = resolveMaxWithdrawalUtilization(undefined);
15
+ * ```
10
16
  */
11
- export const getSupplyTargetUtilization = (marketId, options) => options?.supplyTargetUtilization?.[marketId] ??
12
- options?.defaultSupplyTargetUtilization ??
13
- DEFAULT_SUPPLY_TARGET_UTILIZATION;
17
+ export const resolveMaxWithdrawalUtilization = (value, field = "maxWithdrawalUtilization") => {
18
+ const utilization = value ?? DEFAULT_WITHDRAWAL_TARGET_UTILIZATION;
19
+ if (utilization < 0n)
20
+ throw new NegativeInputError(field, utilization);
21
+ if (utilization > MathLib.WAD)
22
+ throw new InputExceedsMaxError({
23
+ field,
24
+ value: utilization,
25
+ max: MathLib.WAD,
26
+ });
27
+ return utilization;
28
+ };
@@ -1,7 +1,7 @@
1
1
  import { type AccrualPosition, type MarketId } from "@morpho-org/blue-sdk";
2
2
  import type { MarketInput as MidnightMarketInput } from "@morpho-org/midnight-sdk";
3
3
  import { type Address } from "viem";
4
- import { type VaultV1Reallocation, type VaultV2BlueReallocation } from "../types/index.js";
4
+ import { type VaultV2BlueReallocation } from "../types/index.js";
5
5
  /** @internal */
6
6
  export declare const compareMarketIds: (idA: MarketId, idB: MarketId) => -1 | 0 | 1;
7
7
  /**
@@ -209,29 +209,6 @@ export declare const validateRepayShares: (params: {
209
209
  repayShares: bigint;
210
210
  marketId: MarketId;
211
211
  }) => void;
212
- /**
213
- * Validates that Vault V1 PublicAllocator reallocations are well-formed.
214
- *
215
- * @param reallocations - Vault V1 reallocations to validate.
216
- * @param targetMarketId - The operation's target market ID.
217
- * @returns Nothing when every reallocation is valid.
218
- * @throws {NegativeInputError} when a reallocation fee is negative.
219
- * @throws {EmptyReallocationWithdrawalsError} when a reallocation has no withdrawals.
220
- * @throws {NonPositiveInputError} when a withdrawal amount is non-positive.
221
- * @throws {ReallocationWithdrawalOnTargetMarketError} when a withdrawal references the target market.
222
- * @throws {UnsortedReallocationWithdrawalsError} when withdrawals are not strictly market-id sorted.
223
- * @deprecated Vault V1 PublicAllocator validation will be removed in the next major. Use Vault V2
224
- * reallocations for new integrations.
225
- * @example
226
- * ```ts
227
- * import type { BlueMarketId } from "@morpho-org/morpho-sdk/types";
228
- * import { validateReallocations } from "@morpho-org/morpho-sdk";
229
- * import { zeroHash } from "viem";
230
- *
231
- * const result: void = validateReallocations([], zeroHash as BlueMarketId);
232
- * ```
233
- */
234
- export declare const validateReallocations: (reallocations: Iterable<VaultV1Reallocation>, targetMarketId: MarketId) => void;
235
212
  /** @internal */
236
213
  export declare const validateVaultV2BlueReallocations: (reallocations: Iterable<VaultV2BlueReallocation>, targetMarketId: MarketId) => void;
237
214
  /**
@@ -1,7 +1,7 @@
1
1
  import { getChainAddresses, MarketUtils, MathLib, ORACLE_PRICE_SCALE, } from "@morpho-org/blue-sdk";
2
2
  import { isDefined } from "@morpho-org/morpho-ts";
3
3
  import { isAddress, isAddressEqual, maxUint128, maxUint256, zeroAddress, } from "viem";
4
- import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, ChainIdMismatchError, ChainWNativeMissingError, EmptyReallocationWithdrawalsError, ExcessiveSlippageToleranceError, InconsistentReallocationPenaltyError, InputExceedsMaxError, InvalidReallocationAddressError, InvalidReallocationShapeError, InvalidReallocationSourceTypeError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, NativeAmountOnNonWNativeAssetError, NativeAmountOnNonWNativeVaultError, NegativeInputError, NonPositiveInputError, ReallocationWithdrawalOnTargetMarketError, ReferralFeePctExceededError, ReferralFeeRecipientMissingError, RepayExceedsDebtError, RepaySharesExceedDebtError, UnsortedReallocationWithdrawalsError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
4
+ import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, ChainIdMismatchError, ChainWNativeMissingError, ExcessiveSlippageToleranceError, InconsistentReallocationPenaltyError, InputExceedsMaxError, InvalidReallocationAddressError, InvalidReallocationSourceTypeError, InvalidVaultV2BlueReallocationShapeError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, NativeAmountOnNonWNativeAssetError, NativeAmountOnNonWNativeVaultError, NegativeInputError, NonPositiveInputError, ReallocationWithdrawalOnTargetMarketError, ReferralFeePctExceededError, ReferralFeeRecipientMissingError, RepayExceedsDebtError, RepaySharesExceedDebtError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
5
5
  import { DEFAULT_LLTV_BUFFER, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, } from "./constant.js";
6
6
  /** @internal */
7
7
  export const compareMarketIds = (idA, idB) => {
@@ -318,52 +318,6 @@ export const validateRepayShares = (params) => {
318
318
  });
319
319
  }
320
320
  };
321
- /**
322
- * Validates that Vault V1 PublicAllocator reallocations are well-formed.
323
- *
324
- * @param reallocations - Vault V1 reallocations to validate.
325
- * @param targetMarketId - The operation's target market ID.
326
- * @returns Nothing when every reallocation is valid.
327
- * @throws {NegativeInputError} when a reallocation fee is negative.
328
- * @throws {EmptyReallocationWithdrawalsError} when a reallocation has no withdrawals.
329
- * @throws {NonPositiveInputError} when a withdrawal amount is non-positive.
330
- * @throws {ReallocationWithdrawalOnTargetMarketError} when a withdrawal references the target market.
331
- * @throws {UnsortedReallocationWithdrawalsError} when withdrawals are not strictly market-id sorted.
332
- * @deprecated Vault V1 PublicAllocator validation will be removed in the next major. Use Vault V2
333
- * reallocations for new integrations.
334
- * @example
335
- * ```ts
336
- * import type { BlueMarketId } from "@morpho-org/morpho-sdk/types";
337
- * import { validateReallocations } from "@morpho-org/morpho-sdk";
338
- * import { zeroHash } from "viem";
339
- *
340
- * const result: void = validateReallocations([], zeroHash as BlueMarketId);
341
- * ```
342
- */
343
- export const validateReallocations = (reallocations, targetMarketId) => {
344
- for (const reallocation of reallocations) {
345
- if (reallocation.fee < 0n) {
346
- throw new NegativeInputError("reallocation.fee", reallocation.fee);
347
- }
348
- if (reallocation.withdrawals.length === 0) {
349
- throw new EmptyReallocationWithdrawalsError(reallocation.vault);
350
- }
351
- let previousMarketId;
352
- for (const withdrawal of reallocation.withdrawals) {
353
- if (withdrawal.amount <= 0n) {
354
- throw new NonPositiveInputError(`reallocation.withdrawals[${withdrawal.marketParams.id}].amount`, withdrawal.amount);
355
- }
356
- if (withdrawal.marketParams.id === targetMarketId) {
357
- throw new ReallocationWithdrawalOnTargetMarketError(reallocation.vault, withdrawal.marketParams.id);
358
- }
359
- if (previousMarketId !== undefined &&
360
- compareMarketIds(withdrawal.marketParams.id, previousMarketId) <= 0) {
361
- throw new UnsortedReallocationWithdrawalsError(reallocation.vault, withdrawal.marketParams.id);
362
- }
363
- previousMarketId = withdrawal.marketParams.id;
364
- }
365
- }
366
- };
367
321
  /** @internal */
368
322
  export const validateVaultV2BlueReallocations = (reallocations, targetMarketId) => {
369
323
  const penaltyByVault = new Map();
@@ -375,7 +329,7 @@ export const validateVaultV2BlueReallocations = (reallocations, targetMarketId)
375
329
  reallocation === null ||
376
330
  "withdrawals" in reallocation ||
377
331
  "fee" in reallocation) {
378
- throw new InvalidReallocationShapeError();
332
+ throw new InvalidVaultV2BlueReallocationShapeError();
379
333
  }
380
334
  if (typeof reallocation.vault !== "string" ||
381
335
  !isAddress(reallocation.vault)) {
@@ -1,6 +1,6 @@
1
1
  import { type Address } from "@morpho-org/blue-sdk";
2
2
  /** Supported spender slots that can be validated against the chain address registry. */
3
- export type RequirementSpenderKey = "generalAdapter1" | "permit2" | "midnight" | "midnightBundles" | "vaultExitBundlesV1" | "vaultBundlesV1" | "blueBundlesV1";
3
+ export type RequirementSpenderKey = "permit2" | "midnight" | "midnightBundles" | "vaultExitBundlesV1" | "vaultBundlesV1" | "blueBundlesV1";
4
4
  /**
5
5
  * Validates that a requirement encoder spender matches one of the allowed chain addresses.
6
6
  *
@@ -24,9 +24,8 @@ import { UnsupportedErc20ApprovalSpenderError } from "../types/index.js";
24
24
  * ```
25
25
  */
26
26
  export const validateRequirementSpender = (params) => {
27
- const { permit2, midnight, midnightBundles, bundler3: { generalAdapter1 }, bundles, } = getChainAddresses(params.chainId);
27
+ const { permit2, midnight, midnightBundles, bundles } = getChainAddresses(params.chainId);
28
28
  const addresses = {
29
- generalAdapter1,
30
29
  permit2,
31
30
  midnight,
32
31
  midnightBundles,
@@ -39,7 +38,6 @@ export const validateRequirementSpender = (params) => {
39
38
  throw new UnsupportedErc20ApprovalSpenderError({
40
39
  spender: params.spender,
41
40
  chainId: params.chainId,
42
- generalAdapter1,
43
41
  permit2,
44
42
  midnight,
45
43
  midnightBundles,
@@ -417,20 +417,6 @@ export interface Transaction<TAction extends BaseAction = TransactionAction> {
417
417
  readonly data: Hex;
418
418
  readonly action: TAction;
419
419
  }
420
- /**
421
- * Enforces that at least one deposit amount source is provided.
422
- *
423
- * - `amount` alone: standard ERC20 deposit.
424
- * - `nativeAmount` alone: pure native-wrap deposit (vault asset must be wNative).
425
- * - Both: mixed deposit (ERC20 transfer + native wrap).
426
- */
427
- export type DepositAmountArgs = {
428
- amount: bigint;
429
- nativeAmount?: bigint;
430
- } | {
431
- nativeAmount: bigint;
432
- amount?: bigint;
433
- };
434
420
  /** Mutually exclusive ERC-20 or native funding accepted by fixed bundles entrypoints. */
435
421
  export type BundlesFundingArgs = {
436
422
  readonly amount: bigint;
@@ -458,8 +444,7 @@ export type VaultV1MigrateToV2AmountArgs = {
458
444
  * Holds the pre-resolved arguments for an ERC-2612 `permit`: the signed approval
459
445
  * of `amount` of `asset` from `owner` to the permitted spender, bounded by the
460
446
  * `deadline` timestamp and consuming the given `nonce`. The associated
461
- * {@link PermitAction} identifies the permitted spender, including fixed-bundle
462
- * contracts and the GeneralAdapter1 periphery.
447
+ * {@link PermitAction} identifies the permitted fixed-bundle contract.
463
448
  */
464
449
  export interface PermitArgs {
465
450
  readonly owner: Address;
@@ -469,25 +454,10 @@ export interface PermitArgs {
469
454
  readonly amount: bigint;
470
455
  readonly deadline: bigint;
471
456
  }
472
- /**
473
- * Holds the pre-resolved arguments for a Permit2 `permit` bundler call. It
474
- * mirrors {@link PermitArgs} but adds the Permit2 allowance `expiration` (when
475
- * the on-chain allowance lapses) alongside the signature `deadline` (by when the
476
- * signature must be submitted).
477
- */
478
- export interface Permit2Args {
479
- readonly owner: Address;
480
- readonly nonce: bigint;
481
- readonly asset: Address;
482
- readonly signature: Hex;
483
- readonly amount: bigint;
484
- readonly deadline: bigint;
485
- readonly expiration: bigint;
486
- }
487
457
  /**
488
458
  * Signed Morpho Blue authorization payload produced when an integrator opts into offchain
489
- * signatures (`supportSignature: true`). Bundler3 consumes it through `setAuthorizationWithSig`;
490
- * direct BlueBundlesV1 writes encode it into their signed-authorization struct.
459
+ * signatures (`supportSignature: true`). BlueBundlesV1 encodes it into its
460
+ * signed-authorization struct.
491
461
  */
492
462
  export interface AuthorizationSignatureArgs {
493
463
  /** Account granting the authorization (the position owner). */
@@ -527,15 +497,6 @@ export interface PermitAction extends BaseAction<"permit", {
527
497
  */
528
498
  readonly typedData?: RequirementTypedData;
529
499
  }
530
- export interface Permit2Action extends BaseAction<"permit2", {
531
- spender: Address;
532
- amount: bigint;
533
- deadline: bigint;
534
- expiration: bigint;
535
- }> {
536
- /** EIP-712 payload to sign for this Permit2 AllowanceTransfer. See {@link PermitAction.typedData}. */
537
- readonly typedData?: RequirementTypedData;
538
- }
539
500
  /** Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull. */
540
501
  export interface Permit2SignatureTransferAction extends BaseAction<"permit2SignatureTransfer", {
541
502
  readonly spender: Address;
@@ -547,8 +508,7 @@ export interface Permit2SignatureTransferAction extends BaseAction<"permit2Signa
547
508
  readonly typedData?: RequirementTypedData;
548
509
  }
549
510
  /**
550
- * Signable Morpho authorization requirement. Its `authorized` operator is route-specific:
551
- * GeneralAdapter1 for Bundler3 flows or BlueBundlesV1 for direct Blue writes.
511
+ * Signable Morpho authorization requirement for direct BlueBundlesV1 writes.
552
512
  */
553
513
  export interface AuthorizationAction extends BaseAction<"authorization", {
554
514
  authorized: Address;
@@ -575,27 +535,22 @@ export interface MidnightOfferRootSignatureAction extends BaseAction<"midnightOf
575
535
  readonly typedData?: RequirementTypedData;
576
536
  }
577
537
  /** Action metadata supported by signature requirements. */
578
- export type SignatureRequirementAction = PermitAction | Permit2Action | Permit2SignatureTransferAction | AuthorizationAction | MidnightOfferRootSignatureAction;
538
+ export type SignatureRequirementAction = PermitAction | Permit2SignatureTransferAction | AuthorizationAction | MidnightOfferRootSignatureAction;
579
539
  /** Argument payloads returned by signature requirements. */
580
- export type RequirementSignatureArgs = PermitArgs | Permit2Args | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
540
+ export type RequirementSignatureArgs = PermitArgs | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
581
541
  /** A signed ERC-2612 permit requirement. */
582
542
  export interface Erc2612RequirementSignature {
583
543
  readonly args: Readonly<PermitArgs>;
584
544
  readonly action: PermitAction;
585
545
  }
586
- /** A signed Permit2 AllowanceTransfer requirement used by Bundler3. */
587
- export interface Permit2AllowanceRequirementSignature {
588
- readonly args: Readonly<Permit2Args>;
589
- readonly action: Permit2Action;
590
- }
591
- /** A signed ERC-2612 permit or Permit2 AllowanceTransfer requirement. */
592
- export type PermitRequirementSignature = Erc2612RequirementSignature | Permit2AllowanceRequirementSignature;
546
+ /** A signed ERC-2612 permit requirement accepted by vault-share bundle calls. */
547
+ export type PermitRequirementSignature = Erc2612RequirementSignature;
593
548
  /** A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts. */
594
549
  export interface Permit2SignatureTransferRequirementSignature {
595
550
  readonly args: Readonly<PermitArgs>;
596
551
  readonly action: Permit2SignatureTransferAction;
597
552
  }
598
- /** A signed Morpho authorization consumed by Bundler3 or a direct BlueBundlesV1 call. */
553
+ /** A signed Morpho authorization consumed by a direct BlueBundlesV1 call. */
599
554
  export interface AuthorizationRequirementSignature {
600
555
  readonly args: AuthorizationSignatureArgs;
601
556
  readonly action: AuthorizationAction;
@@ -607,7 +562,7 @@ export interface MidnightOfferRootSignature {
607
562
  }
608
563
  /**
609
564
  * The deep-frozen output of `Requirement.sign()`. Discriminated on `action.type`:
610
- * `"permit"` / `"permit2"` carry token-approval args, `"permit2SignatureTransfer"` carries a
565
+ * `"permit"` carries token-approval args, `"permit2SignatureTransfer"` carries a
611
566
  * bundles SignatureTransfer, `"authorization"` carries the signed Morpho authorization,
612
567
  * and Midnight adds `"midnightOfferRootSignature"`.
613
568
  */
@@ -644,20 +599,16 @@ export interface Requirement<TSignatureOrAction extends RequirementSignature | S
644
599
  readonly typedData: RequirementTypedData;
645
600
  };
646
601
  }
647
- /** Bundler3 token signature requirement. */
648
- export type Bundler3TokenSignatureRequirement = Requirement<PermitRequirementSignature>;
649
602
  /** ERC-2612 or Permit2 SignatureTransfer requirement consumed by a fixed bundles contract. */
650
603
  export type BundlesTokenSignatureRequirement = Requirement<BundlesTokenRequirementSignature>;
651
604
  /** Midnight Ecrecover offer-root signature requirement. */
652
605
  export type MidnightOfferRootRequirement = Requirement<MidnightOfferRootSignatureAction, MidnightOfferRootSignatureArgs>;
653
606
  /** Any token signature requirement supported by an SDK transaction route. */
654
- export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement | BundlesTokenSignatureRequirement;
655
- /** Bundler3 token signature result. */
656
- export type Bundler3TokenRequirementSignature = PermitRequirementSignature;
607
+ export type TokenSignatureRequirement = BundlesTokenSignatureRequirement;
657
608
  /** Token signature result consumed by a fixed bundles contract. */
658
609
  export type BundlesTokenRequirementSignature = Erc2612RequirementSignature | Permit2SignatureTransferRequirementSignature;
659
610
  /** Any token signature result supported by an SDK transaction route. */
660
- export type TokenRequirementSignature = Bundler3TokenRequirementSignature | BundlesTokenRequirementSignature;
611
+ export type TokenRequirementSignature = BundlesTokenRequirementSignature;
661
612
  /** Any signature result returned by an action-output signature requirement. */
662
613
  export type AnyRequirementSignature = TokenRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
663
614
  /** Any signature requirement returned by an entity action output. */
@@ -689,10 +640,10 @@ export declare function isRequirementSignature<T extends RequirementSignature =
689
640
  export declare function isRequirementSignature(requirement: CallRequirement | Requirement | undefined): requirement is Requirement;
690
641
  export declare function isRequirementSignature(requirement: ActionRequirement | undefined): requirement is SignatureRequirement;
691
642
  /**
692
- * Narrows a {@link RequirementSignature} to a permit / Permit2 token-approval signature.
643
+ * Narrows a {@link RequirementSignature} to an ERC-2612 permit signature.
693
644
  *
694
645
  * @param signature - The signed requirement to test.
695
- * @returns `true` when `signature.action.type` is `"permit"` or `"permit2"`.
646
+ * @returns `true` when `signature.action.type` is `"permit"`.
696
647
  */
697
648
  export declare function isPermitSignature(signature: RequirementSignature): signature is PermitRequirementSignature;
698
649
  /**
@@ -728,7 +679,7 @@ export declare function isAuthorizationSignature(signature: RequirementSignature
728
679
  export declare function isMidnightOfferRootSignature(signature: RequirementSignature): signature is MidnightOfferRootSignature;
729
680
  /** The typed requirement-signature slots a transaction builder consumes, split from a `buildTx` array. */
730
681
  export interface SelectedRequirementSignatures {
731
- /** The single ERC-2612 or Permit2 AllowanceTransfer signature, when present. */
682
+ /** The single ERC-2612 signature, when present. */
732
683
  readonly permit?: PermitRequirementSignature;
733
684
  /** The single Permit2 SignatureTransfer signature, when present. */
734
685
  readonly permit2SignatureTransfer?: Permit2SignatureTransferRequirementSignature;
@@ -748,12 +699,13 @@ export interface SelectedRequirementSignatures {
748
699
  *
749
700
  * @param signatures - The signatures passed to `buildTx`.
750
701
  * @param accepts - Which signature kinds this operation consumes.
751
- * @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
702
+ * @param accepts.permit - Whether an ERC-2612 signature is consumed.
752
703
  * @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
753
704
  * @param accepts.authorization - Whether a Morpho authorization signature is consumed.
754
705
  * @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
755
706
  * @returns The accepted signature in each typed slot, when present.
756
707
  * @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
708
+ * @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
757
709
  * @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
758
710
  * @example
759
711
  * ```ts
@@ -1,4 +1,4 @@
1
- import { AmbiguousRequirementSignaturesError, UnexpectedRequirementSignatureError, } from "./error.js";
1
+ import { AmbiguousRequirementSignaturesError, UnexpectedRequirementSignatureError, UnsupportedRequirementSignatureError, } from "./error.js";
2
2
  export function isRequirementApproval(requirement) {
3
3
  return (typeof requirement === "object" &&
4
4
  requirement !== null &&
@@ -32,13 +32,13 @@ export function isRequirementSignature(requirement) {
32
32
  typeof requirement.sign === "function");
33
33
  }
34
34
  /**
35
- * Narrows a {@link RequirementSignature} to a permit / Permit2 token-approval signature.
35
+ * Narrows a {@link RequirementSignature} to an ERC-2612 permit signature.
36
36
  *
37
37
  * @param signature - The signed requirement to test.
38
- * @returns `true` when `signature.action.type` is `"permit"` or `"permit2"`.
38
+ * @returns `true` when `signature.action.type` is `"permit"`.
39
39
  */
40
40
  export function isPermitSignature(signature) {
41
- return (signature.action.type === "permit" || signature.action.type === "permit2");
41
+ return signature.action.type === "permit";
42
42
  }
43
43
  /**
44
44
  * Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
@@ -88,12 +88,13 @@ export function isMidnightOfferRootSignature(signature) {
88
88
  *
89
89
  * @param signatures - The signatures passed to `buildTx`.
90
90
  * @param accepts - Which signature kinds this operation consumes.
91
- * @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
91
+ * @param accepts.permit - Whether an ERC-2612 signature is consumed.
92
92
  * @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
93
93
  * @param accepts.authorization - Whether a Morpho authorization signature is consumed.
94
94
  * @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
95
95
  * @returns The accepted signature in each typed slot, when present.
96
96
  * @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
97
+ * @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
97
98
  * @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
98
99
  * @example
99
100
  * ```ts
@@ -112,6 +113,12 @@ export function selectRequirementSignatures(signatures, accepts) {
112
113
  const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
113
114
  const authorizations = signatures.filter(isAuthorizationSignature);
114
115
  const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
116
+ const unsupported = signatures.find((signature) => !isPermitSignature(signature) &&
117
+ !isPermit2SignatureTransferSignature(signature) &&
118
+ !isAuthorizationSignature(signature) &&
119
+ !isMidnightOfferRootSignature(signature));
120
+ if (unsupported != null)
121
+ throw new UnsupportedRequirementSignatureError(unsupported.action.type);
115
122
  if (!accepts.permit && permits.length > 0)
116
123
  throw new UnexpectedRequirementSignatureError("permit");
117
124
  if (!accepts.permit2SignatureTransfer && permit2Transfers.length > 0)