@morpho-org/morpho-sdk 10.0.2 → 10.1.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 (420) hide show
  1. package/README.md +6 -2
  2. package/lib/cjs/actions/blue/borrow.d.ts +2 -1
  3. package/lib/cjs/actions/blue/borrow.internal.d.ts +13 -0
  4. package/lib/cjs/actions/blue/borrow.internal.js +35 -0
  5. package/lib/cjs/actions/blue/borrow.js +4 -16
  6. package/lib/cjs/actions/blue/common.d.ts +50 -28
  7. package/lib/cjs/actions/blue/common.js +21 -34
  8. package/lib/cjs/actions/blue/encode.d.ts +23 -0
  9. package/lib/cjs/actions/blue/encode.js +171 -0
  10. package/lib/cjs/actions/blue/refinance.d.ts +3 -2
  11. package/lib/cjs/actions/blue/refinance.internal.d.ts +42 -0
  12. package/lib/cjs/actions/blue/refinance.internal.js +62 -0
  13. package/lib/cjs/actions/blue/refinance.js +5 -63
  14. package/lib/cjs/actions/blue/refinanceValidation.d.ts +4 -5
  15. package/lib/cjs/actions/blue/refinanceValidation.js +1 -3
  16. package/lib/cjs/actions/blue/repay.d.ts +1 -1
  17. package/lib/cjs/actions/blue/repay.internal.d.ts +13 -0
  18. package/lib/cjs/actions/blue/repay.internal.js +38 -0
  19. package/lib/cjs/actions/blue/repay.js +2 -17
  20. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  21. package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
  22. package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.js +112 -0
  23. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +3 -116
  24. package/lib/cjs/actions/blue/signatures.d.ts +30 -0
  25. package/lib/cjs/actions/blue/signatures.js +90 -0
  26. package/lib/cjs/actions/blue/supply.d.ts +1 -1
  27. package/lib/cjs/actions/blue/supply.internal.d.ts +32 -0
  28. package/lib/cjs/actions/blue/supply.internal.js +101 -0
  29. package/lib/cjs/actions/blue/supply.js +2 -67
  30. package/lib/cjs/actions/blue/supplyCollateral.d.ts +1 -1
  31. package/lib/cjs/actions/blue/supplyCollateral.internal.d.ts +13 -0
  32. package/lib/cjs/actions/blue/supplyCollateral.internal.js +37 -0
  33. package/lib/cjs/actions/blue/supplyCollateral.js +2 -17
  34. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +4 -3
  35. package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +63 -0
  36. package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +94 -0
  37. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +5 -106
  38. package/lib/cjs/actions/blue/withdraw.d.ts +4 -3
  39. package/lib/cjs/actions/blue/withdraw.internal.d.ts +56 -0
  40. package/lib/cjs/actions/blue/withdraw.internal.js +84 -0
  41. package/lib/cjs/actions/blue/withdraw.js +5 -78
  42. package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +2 -2
  43. package/lib/cjs/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
  44. package/lib/cjs/actions/blue/withdrawBuyCallback.internal.js +58 -0
  45. package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -39
  46. package/lib/cjs/actions/blue/withdrawCollateral.internal.d.ts +16 -0
  47. package/lib/cjs/actions/blue/withdrawCollateral.internal.js +39 -0
  48. package/lib/cjs/actions/blue/withdrawCollateral.js +2 -17
  49. package/lib/cjs/actions/bundles/common.d.ts +9 -0
  50. package/lib/cjs/actions/bundles/common.js +18 -6
  51. package/lib/cjs/actions/bundles/index.d.ts +1 -1
  52. package/lib/cjs/actions/bundles/index.js +3 -16
  53. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
  54. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +59 -60
  55. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +22 -1
  56. package/lib/cjs/actions/midnight/cancelAndMake.js +46 -87
  57. package/lib/cjs/actions/midnight/cancelOffers.d.ts +11 -0
  58. package/lib/cjs/actions/midnight/cancelOffers.js +22 -4
  59. package/lib/cjs/actions/midnight/encode.d.ts +36 -0
  60. package/lib/cjs/actions/midnight/encode.js +554 -0
  61. package/lib/cjs/actions/midnight/index.d.ts +14 -13
  62. package/lib/cjs/actions/midnight/index.js +29 -13
  63. package/lib/cjs/actions/midnight/parse.d.ts +35 -0
  64. package/lib/cjs/actions/midnight/parse.js +73 -0
  65. package/lib/cjs/actions/midnight/parseCollateralBatch.d.ts +58 -0
  66. package/lib/cjs/actions/midnight/parseCollateralBatch.js +216 -0
  67. package/lib/cjs/actions/midnight/redeem.d.ts +16 -3
  68. package/lib/cjs/actions/midnight/redeem.js +22 -51
  69. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
  70. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +42 -67
  71. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +40 -5
  72. package/lib/cjs/actions/midnight/supplyCollateral.js +60 -54
  73. package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +3 -3
  74. package/lib/cjs/actions/midnight/supplyCollateralBatch.js +3 -62
  75. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
  76. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +39 -66
  77. package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
  78. package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +142 -0
  79. package/lib/cjs/actions/midnight/takeBorrow.d.ts +17 -2
  80. package/lib/cjs/actions/midnight/takeBorrow.js +25 -55
  81. package/lib/cjs/actions/midnight/takeLend.d.ts +21 -1
  82. package/lib/cjs/actions/midnight/takeLend.js +30 -57
  83. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
  84. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +34 -61
  85. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +17 -2
  86. package/lib/cjs/actions/midnight/takeWithdraw.js +78 -115
  87. package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -3
  88. package/lib/cjs/actions/midnight/withdrawCollateral.js +25 -56
  89. package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
  90. package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +3 -71
  91. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
  92. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +39 -19
  93. package/lib/cjs/actions/requirements/blue/index.d.ts +1 -1
  94. package/lib/cjs/actions/requirements/blue/index.js +3 -15
  95. package/lib/cjs/actions/requirements/chainCheck.d.ts +5 -0
  96. package/lib/cjs/actions/requirements/chainCheck.js +10 -0
  97. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
  98. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +40 -27
  99. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
  100. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +36 -17
  101. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
  102. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +44 -9
  103. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
  104. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +61 -24
  105. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
  106. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +25 -4
  107. package/lib/cjs/actions/requirements/encode/index.d.ts +5 -5
  108. package/lib/cjs/actions/requirements/encode/index.js +11 -19
  109. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +26 -11
  110. package/lib/cjs/actions/requirements/getRequirementsApproval.js +40 -12
  111. package/lib/cjs/actions/requirements/index.d.ts +1 -1
  112. package/lib/cjs/actions/requirements/index.js +3 -1
  113. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
  114. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +34 -19
  115. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
  116. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +26 -12
  117. package/lib/cjs/actions/requirements/midnight/index.d.ts +2 -2
  118. package/lib/cjs/actions/requirements/midnight/index.js +5 -16
  119. package/lib/cjs/actions/vaultV1/deposit.d.ts +21 -0
  120. package/lib/cjs/actions/vaultV1/deposit.js +46 -10
  121. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +18 -1
  122. package/lib/cjs/actions/vaultV1/inKindRedeem.js +36 -16
  123. package/lib/cjs/actions/vaultV1/index.d.ts +5 -5
  124. package/lib/cjs/actions/vaultV1/index.js +11 -19
  125. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +21 -0
  126. package/lib/cjs/actions/vaultV1/migrateToV2.js +49 -11
  127. package/lib/cjs/actions/vaultV1/redeem.d.ts +19 -0
  128. package/lib/cjs/actions/vaultV1/redeem.js +28 -7
  129. package/lib/cjs/actions/vaultV1/withdraw.d.ts +19 -0
  130. package/lib/cjs/actions/vaultV1/withdraw.js +28 -7
  131. package/lib/cjs/actions/vaultV2/deposit.d.ts +21 -0
  132. package/lib/cjs/actions/vaultV2/deposit.js +46 -10
  133. package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +20 -2
  134. package/lib/cjs/actions/vaultV2/forceRedeem.js +39 -8
  135. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +23 -1
  136. package/lib/cjs/actions/vaultV2/forceWithdraw.js +36 -14
  137. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +18 -1
  138. package/lib/cjs/actions/vaultV2/inKindRedeem.js +35 -15
  139. package/lib/cjs/actions/vaultV2/index.d.ts +6 -6
  140. package/lib/cjs/actions/vaultV2/index.js +13 -20
  141. package/lib/cjs/actions/vaultV2/redeem.d.ts +19 -0
  142. package/lib/cjs/actions/vaultV2/redeem.js +28 -7
  143. package/lib/cjs/actions/vaultV2/withdraw.d.ts +19 -0
  144. package/lib/cjs/actions/vaultV2/withdraw.js +28 -7
  145. package/lib/cjs/entities/blue/blue.d.ts +35 -8
  146. package/lib/cjs/entities/blue/blue.js +467 -406
  147. package/lib/cjs/entities/midnight/midnight.d.ts +117 -41
  148. package/lib/cjs/entities/midnight/midnight.js +472 -843
  149. package/lib/cjs/entities/midnight/parse.d.ts +74 -0
  150. package/lib/cjs/entities/midnight/parse.js +336 -0
  151. package/lib/cjs/entities/midnight/prepare.d.ts +47 -0
  152. package/lib/cjs/entities/midnight/prepare.js +293 -0
  153. package/lib/cjs/entities/midnight/publication.d.ts +7 -3
  154. package/lib/cjs/entities/midnight/publication.js +10 -7
  155. package/lib/cjs/entities/midnight/types.d.ts +7 -0
  156. package/lib/cjs/entities/requirements/assertContractCode.d.ts +10 -5
  157. package/lib/cjs/entities/requirements/assertContractCode.js +24 -15
  158. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
  159. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +59 -51
  160. package/lib/cjs/entities/requirements/getErc2612Permit.d.ts +7 -3
  161. package/lib/cjs/entities/requirements/getErc2612Permit.js +20 -4
  162. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
  163. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +24 -7
  164. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
  165. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +27 -7
  166. package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
  167. package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
  168. package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
  169. package/lib/cjs/entities/requirements/index.d.ts +2 -2
  170. package/lib/cjs/entities/requirements/index.js +5 -16
  171. package/lib/cjs/entities/requirements/validateNativeRequirements.d.ts +21 -0
  172. package/lib/cjs/entities/requirements/validateNativeRequirements.js +37 -0
  173. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
  174. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +1 -7
  175. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +17 -40
  176. package/lib/cjs/entities/vaultV1/vaultV1.js +228 -159
  177. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
  178. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +9 -4
  179. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
  180. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +1 -7
  181. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +21 -52
  182. package/lib/cjs/entities/vaultV2/vaultV2.js +226 -150
  183. package/lib/cjs/helpers/parse.d.ts +33 -0
  184. package/lib/cjs/helpers/parse.js +71 -0
  185. package/lib/cjs/helpers/parseMidnight.d.ts +48 -0
  186. package/lib/cjs/helpers/parseMidnight.js +95 -0
  187. package/lib/cjs/helpers/parseMidnightMaker.d.ts +44 -0
  188. package/lib/cjs/helpers/parseMidnightMaker.js +154 -0
  189. package/lib/cjs/helpers/validate.d.ts +3 -2
  190. package/lib/cjs/helpers/validate.js +4 -0
  191. package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
  192. package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +4 -4
  193. package/lib/cjs/helpers/validateMidnightPublication.d.ts +17 -1
  194. package/lib/cjs/index.d.ts +1 -0
  195. package/lib/cjs/transactionPlan/blue/refinance.js +17 -9
  196. package/lib/cjs/transactionPlan/blue/repay.js +2 -1
  197. package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +23 -4
  198. package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +2 -2
  199. package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -2
  200. package/lib/cjs/transactionPlan/blue/withdraw.js +3 -3
  201. package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +6 -2
  202. package/lib/cjs/transactionPlan/validation.d.ts +1 -1
  203. package/lib/cjs/transactionPlan/validation.js +3 -0
  204. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +2 -2
  205. package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -2
  206. package/lib/cjs/types/action.d.ts +13 -2
  207. package/lib/cjs/types/error.d.ts +20 -2
  208. package/lib/cjs/types/error.js +32 -3
  209. package/lib/cjs/version.d.ts +1 -1
  210. package/lib/cjs/version.js +1 -1
  211. package/lib/esm/actions/blue/borrow.d.ts +2 -1
  212. package/lib/esm/actions/blue/borrow.internal.d.ts +13 -0
  213. package/lib/esm/actions/blue/borrow.internal.js +30 -0
  214. package/lib/esm/actions/blue/borrow.js +4 -16
  215. package/lib/esm/actions/blue/common.d.ts +50 -28
  216. package/lib/esm/actions/blue/common.js +21 -33
  217. package/lib/esm/actions/blue/encode.d.ts +23 -0
  218. package/lib/esm/actions/blue/encode.js +164 -0
  219. package/lib/esm/actions/blue/refinance.d.ts +3 -2
  220. package/lib/esm/actions/blue/refinance.internal.d.ts +42 -0
  221. package/lib/esm/actions/blue/refinance.internal.js +56 -0
  222. package/lib/esm/actions/blue/refinance.js +5 -63
  223. package/lib/esm/actions/blue/refinanceValidation.d.ts +4 -5
  224. package/lib/esm/actions/blue/refinanceValidation.js +2 -4
  225. package/lib/esm/actions/blue/repay.d.ts +1 -1
  226. package/lib/esm/actions/blue/repay.internal.d.ts +13 -0
  227. package/lib/esm/actions/blue/repay.internal.js +33 -0
  228. package/lib/esm/actions/blue/repay.js +2 -17
  229. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  230. package/lib/esm/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
  231. package/lib/esm/actions/blue/repayWithdrawCollateral.internal.js +104 -0
  232. package/lib/esm/actions/blue/repayWithdrawCollateral.js +3 -116
  233. package/lib/esm/actions/blue/signatures.d.ts +30 -0
  234. package/lib/esm/actions/blue/signatures.js +82 -0
  235. package/lib/esm/actions/blue/supply.d.ts +1 -1
  236. package/lib/esm/actions/blue/supply.internal.d.ts +32 -0
  237. package/lib/esm/actions/blue/supply.internal.js +95 -0
  238. package/lib/esm/actions/blue/supply.js +2 -67
  239. package/lib/esm/actions/blue/supplyCollateral.d.ts +1 -1
  240. package/lib/esm/actions/blue/supplyCollateral.internal.d.ts +13 -0
  241. package/lib/esm/actions/blue/supplyCollateral.internal.js +32 -0
  242. package/lib/esm/actions/blue/supplyCollateral.js +2 -17
  243. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +4 -3
  244. package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +63 -0
  245. package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +87 -0
  246. package/lib/esm/actions/blue/supplyCollateralBorrow.js +5 -106
  247. package/lib/esm/actions/blue/withdraw.d.ts +4 -3
  248. package/lib/esm/actions/blue/withdraw.internal.d.ts +56 -0
  249. package/lib/esm/actions/blue/withdraw.internal.js +77 -0
  250. package/lib/esm/actions/blue/withdraw.js +5 -78
  251. package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +2 -2
  252. package/lib/esm/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
  253. package/lib/esm/actions/blue/withdrawBuyCallback.internal.js +53 -0
  254. package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -39
  255. package/lib/esm/actions/blue/withdrawCollateral.internal.d.ts +16 -0
  256. package/lib/esm/actions/blue/withdrawCollateral.internal.js +34 -0
  257. package/lib/esm/actions/blue/withdrawCollateral.js +2 -17
  258. package/lib/esm/actions/bundles/common.d.ts +9 -0
  259. package/lib/esm/actions/bundles/common.js +15 -4
  260. package/lib/esm/actions/bundles/index.d.ts +1 -1
  261. package/lib/esm/actions/bundles/index.js +1 -1
  262. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
  263. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +58 -61
  264. package/lib/esm/actions/midnight/cancelAndMake.d.ts +22 -1
  265. package/lib/esm/actions/midnight/cancelAndMake.js +43 -85
  266. package/lib/esm/actions/midnight/cancelOffers.d.ts +11 -0
  267. package/lib/esm/actions/midnight/cancelOffers.js +18 -2
  268. package/lib/esm/actions/midnight/encode.d.ts +36 -0
  269. package/lib/esm/actions/midnight/encode.js +539 -0
  270. package/lib/esm/actions/midnight/index.d.ts +14 -13
  271. package/lib/esm/actions/midnight/index.js +14 -13
  272. package/lib/esm/actions/midnight/parse.d.ts +35 -0
  273. package/lib/esm/actions/midnight/parse.js +68 -0
  274. package/lib/esm/actions/midnight/parseCollateralBatch.d.ts +58 -0
  275. package/lib/esm/actions/midnight/parseCollateralBatch.js +209 -0
  276. package/lib/esm/actions/midnight/redeem.d.ts +16 -3
  277. package/lib/esm/actions/midnight/redeem.js +20 -50
  278. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
  279. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +38 -64
  280. package/lib/esm/actions/midnight/supplyCollateral.d.ts +40 -5
  281. package/lib/esm/actions/midnight/supplyCollateral.js +57 -53
  282. package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +3 -3
  283. package/lib/esm/actions/midnight/supplyCollateralBatch.js +3 -62
  284. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
  285. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +33 -61
  286. package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
  287. package/lib/esm/actions/midnight/supplyCollateralWithNative.js +137 -0
  288. package/lib/esm/actions/midnight/takeBorrow.d.ts +17 -2
  289. package/lib/esm/actions/midnight/takeBorrow.js +20 -51
  290. package/lib/esm/actions/midnight/takeLend.d.ts +21 -1
  291. package/lib/esm/actions/midnight/takeLend.js +26 -54
  292. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
  293. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +30 -58
  294. package/lib/esm/actions/midnight/takeWithdraw.d.ts +17 -2
  295. package/lib/esm/actions/midnight/takeWithdraw.js +76 -114
  296. package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -3
  297. package/lib/esm/actions/midnight/withdrawCollateral.js +23 -55
  298. package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
  299. package/lib/esm/actions/midnight/withdrawCollateralBatch.js +3 -71
  300. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
  301. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +36 -18
  302. package/lib/esm/actions/requirements/blue/index.d.ts +1 -1
  303. package/lib/esm/actions/requirements/blue/index.js +1 -1
  304. package/lib/esm/actions/requirements/chainCheck.d.ts +5 -0
  305. package/lib/esm/actions/requirements/chainCheck.js +6 -0
  306. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
  307. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +36 -25
  308. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
  309. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +33 -16
  310. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
  311. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +41 -8
  312. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
  313. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +59 -24
  314. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
  315. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +21 -2
  316. package/lib/esm/actions/requirements/encode/index.d.ts +5 -5
  317. package/lib/esm/actions/requirements/encode/index.js +5 -5
  318. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +26 -11
  319. package/lib/esm/actions/requirements/getRequirementsApproval.js +38 -12
  320. package/lib/esm/actions/requirements/index.d.ts +1 -1
  321. package/lib/esm/actions/requirements/index.js +1 -1
  322. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
  323. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +31 -18
  324. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
  325. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +22 -10
  326. package/lib/esm/actions/requirements/midnight/index.d.ts +2 -2
  327. package/lib/esm/actions/requirements/midnight/index.js +2 -2
  328. package/lib/esm/actions/vaultV1/deposit.d.ts +21 -0
  329. package/lib/esm/actions/vaultV1/deposit.js +43 -9
  330. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +18 -1
  331. package/lib/esm/actions/vaultV1/inKindRedeem.js +33 -15
  332. package/lib/esm/actions/vaultV1/index.d.ts +5 -5
  333. package/lib/esm/actions/vaultV1/index.js +5 -5
  334. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +21 -0
  335. package/lib/esm/actions/vaultV1/migrateToV2.js +47 -11
  336. package/lib/esm/actions/vaultV1/redeem.d.ts +19 -0
  337. package/lib/esm/actions/vaultV1/redeem.js +26 -7
  338. package/lib/esm/actions/vaultV1/withdraw.d.ts +19 -0
  339. package/lib/esm/actions/vaultV1/withdraw.js +26 -7
  340. package/lib/esm/actions/vaultV2/deposit.d.ts +21 -0
  341. package/lib/esm/actions/vaultV2/deposit.js +43 -9
  342. package/lib/esm/actions/vaultV2/forceRedeem.d.ts +20 -2
  343. package/lib/esm/actions/vaultV2/forceRedeem.js +35 -6
  344. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +23 -1
  345. package/lib/esm/actions/vaultV2/forceWithdraw.js +33 -13
  346. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +18 -1
  347. package/lib/esm/actions/vaultV2/inKindRedeem.js +32 -14
  348. package/lib/esm/actions/vaultV2/index.d.ts +6 -6
  349. package/lib/esm/actions/vaultV2/index.js +6 -6
  350. package/lib/esm/actions/vaultV2/redeem.d.ts +19 -0
  351. package/lib/esm/actions/vaultV2/redeem.js +26 -7
  352. package/lib/esm/actions/vaultV2/withdraw.d.ts +19 -0
  353. package/lib/esm/actions/vaultV2/withdraw.js +26 -7
  354. package/lib/esm/entities/blue/blue.d.ts +35 -8
  355. package/lib/esm/entities/blue/blue.js +449 -388
  356. package/lib/esm/entities/midnight/midnight.d.ts +117 -41
  357. package/lib/esm/entities/midnight/midnight.js +455 -826
  358. package/lib/esm/entities/midnight/parse.d.ts +74 -0
  359. package/lib/esm/entities/midnight/parse.js +320 -0
  360. package/lib/esm/entities/midnight/prepare.d.ts +47 -0
  361. package/lib/esm/entities/midnight/prepare.js +282 -0
  362. package/lib/esm/entities/midnight/publication.d.ts +7 -3
  363. package/lib/esm/entities/midnight/publication.js +7 -3
  364. package/lib/esm/entities/midnight/types.d.ts +7 -0
  365. package/lib/esm/entities/requirements/assertContractCode.d.ts +10 -5
  366. package/lib/esm/entities/requirements/assertContractCode.js +24 -15
  367. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
  368. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +53 -47
  369. package/lib/esm/entities/requirements/getErc2612Permit.d.ts +7 -3
  370. package/lib/esm/entities/requirements/getErc2612Permit.js +19 -4
  371. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
  372. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +20 -5
  373. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
  374. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +23 -5
  375. package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
  376. package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
  377. package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
  378. package/lib/esm/entities/requirements/index.d.ts +2 -2
  379. package/lib/esm/entities/requirements/index.js +2 -2
  380. package/lib/esm/entities/requirements/validateNativeRequirements.d.ts +21 -0
  381. package/lib/esm/entities/requirements/validateNativeRequirements.js +33 -0
  382. package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
  383. package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +1 -7
  384. package/lib/esm/entities/vaultV1/vaultV1.d.ts +17 -40
  385. package/lib/esm/entities/vaultV1/vaultV1.js +208 -139
  386. package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
  387. package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +10 -5
  388. package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
  389. package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +1 -7
  390. package/lib/esm/entities/vaultV2/vaultV2.d.ts +21 -52
  391. package/lib/esm/entities/vaultV2/vaultV2.js +209 -133
  392. package/lib/esm/helpers/parse.d.ts +33 -0
  393. package/lib/esm/helpers/parse.js +61 -0
  394. package/lib/esm/helpers/parseMidnight.d.ts +48 -0
  395. package/lib/esm/helpers/parseMidnight.js +80 -0
  396. package/lib/esm/helpers/parseMidnightMaker.d.ts +44 -0
  397. package/lib/esm/helpers/parseMidnightMaker.js +147 -0
  398. package/lib/esm/helpers/validate.d.ts +3 -2
  399. package/lib/esm/helpers/validate.js +5 -1
  400. package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
  401. package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +2 -2
  402. package/lib/esm/helpers/validateMidnightPublication.d.ts +17 -1
  403. package/lib/esm/index.d.ts +1 -0
  404. package/lib/esm/transactionPlan/blue/refinance.js +18 -10
  405. package/lib/esm/transactionPlan/blue/repay.js +3 -2
  406. package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +24 -5
  407. package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +2 -2
  408. package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -2
  409. package/lib/esm/transactionPlan/blue/withdraw.js +3 -3
  410. package/lib/esm/transactionPlan/blue/withdrawCollateral.js +6 -2
  411. package/lib/esm/transactionPlan/validation.d.ts +1 -1
  412. package/lib/esm/transactionPlan/validation.js +3 -0
  413. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +2 -2
  414. package/lib/esm/transactionPlan/vaultv1/deposit.js +2 -2
  415. package/lib/esm/types/action.d.ts +13 -2
  416. package/lib/esm/types/error.d.ts +20 -2
  417. package/lib/esm/types/error.js +27 -0
  418. package/lib/esm/version.d.ts +1 -1
  419. package/lib/esm/version.js +1 -1
  420. package/package.json +3 -3
@@ -0,0 +1,56 @@
1
+ import { parseBlueMarket } from "../../helpers/parse.js";
2
+ import { type BlueWithdrawAction, type Transaction } from "../../types/index.js";
3
+ import type { BlueAllocations, BlueOperationInput } from "./common.js";
4
+ import { parseBlueAllocations } from "./common.js";
5
+ import type { BlueWithdrawParams } from "./withdraw.js";
6
+ declare const blueWithdrawBrand: unique symbol;
7
+ /** Validated withdrawal inputs. @internal */
8
+ export interface BlueWithdrawInput extends BlueOperationInput {
9
+ readonly withdrawAssets: bigint;
10
+ readonly withdrawShares: bigint;
11
+ readonly publicAllocations: BlueAllocations["publicAllocations"];
12
+ readonly reallocationPenaltyAssets: bigint;
13
+ readonly [blueWithdrawBrand]: true;
14
+ }
15
+ /** Parses withdrawal mode after the scalar amount stages. @internal */
16
+ export declare const parseBlueWithdrawMode: (marketParams: ReturnType<typeof parseBlueMarket>, params: {
17
+ readonly withdrawAssets: bigint;
18
+ readonly withdrawShares: bigint;
19
+ readonly field: string;
20
+ }) => {
21
+ withdrawAssets: bigint;
22
+ withdrawShares: bigint;
23
+ };
24
+ /** Parses the penalty bound for assets-mode withdrawals. @internal */
25
+ export declare const parseBlueWithdrawPenalty: (allocations: ReturnType<typeof parseBlueAllocations>, mode: ReturnType<typeof parseBlueWithdrawMode>) => {
26
+ readonly publicAllocations: readonly {
27
+ readonly vault: import("viem").Address;
28
+ readonly adapter: import("viem").Address;
29
+ readonly marketParams: import("../../helpers/parse.js").BlueMarket;
30
+ readonly fromIdle: boolean;
31
+ readonly sourceAdapter: import("viem").Address;
32
+ readonly sourceMarketParams: import("../../helpers/parse.js").BlueMarket;
33
+ readonly assets: bigint;
34
+ readonly penalty: bigint;
35
+ }[];
36
+ readonly penaltyAssets: bigint;
37
+ };
38
+ /** Constructs complete raw withdrawal params, including optional authorization. @internal */
39
+ export declare const parseBlueWithdraw: (params: BlueWithdrawParams) => {
40
+ deadline: bigint;
41
+ referralFeePct: bigint;
42
+ referralFeeRecipient: import("viem").Address;
43
+ chainId: number;
44
+ userAddress: import("viem").Address;
45
+ marketParams: import("../../helpers/parse.js").BlueMarket;
46
+ metadata?: import("../../index.js").Metadata;
47
+ withdrawAssets: bigint;
48
+ withdrawShares: bigint;
49
+ publicAllocations: BlueAllocations["publicAllocations"];
50
+ reallocationPenaltyAssets: bigint;
51
+ [blueWithdrawBrand]: true;
52
+ signedAuthorization: import("./common.js").BlueBundlesV1SignedAuthorization;
53
+ };
54
+ /** Encodes parsed inputs and independently validates supplied signatures. @internal */
55
+ export declare const buildBlueWithdraw: (parsed: BlueWithdrawInput, signatures?: Pick<BlueWithdrawParams["args"], "authorizationSignature">) => Readonly<Transaction<BlueWithdrawAction>>;
56
+ export {};
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildBlueWithdraw = exports.parseBlueWithdraw = exports.parseBlueWithdrawPenalty = exports.parseBlueWithdrawMode = void 0;
4
+ const parse_js_1 = require("../../helpers/parse.js");
5
+ const index_js_1 = require("../../types/index.js");
6
+ const common_js_1 = require("./common.js");
7
+ const encode_js_1 = require("./encode.js");
8
+ /** Parses withdrawal mode after the scalar amount stages. @internal */
9
+ const parseBlueWithdrawMode = (marketParams, params) => {
10
+ const { withdrawAssets, withdrawShares, field } = params;
11
+ if (withdrawAssets > 0n && withdrawShares > 0n) {
12
+ throw new index_js_1.MutuallyExclusiveWithdrawAmountsError(marketParams.id);
13
+ }
14
+ if (withdrawAssets === 0n && withdrawShares === 0n) {
15
+ throw new index_js_1.NonPositiveInputError(field, 0n);
16
+ }
17
+ const result = { withdrawAssets, withdrawShares };
18
+ return result;
19
+ };
20
+ exports.parseBlueWithdrawMode = parseBlueWithdrawMode;
21
+ /** Parses the penalty bound for assets-mode withdrawals. @internal */
22
+ const parseBlueWithdrawPenalty = (allocations, mode) => {
23
+ if (mode.withdrawAssets > 0n &&
24
+ allocations.penaltyAssets > mode.withdrawAssets) {
25
+ throw new index_js_1.InputExceedsMaxError({
26
+ field: "reallocationPenaltyAssets",
27
+ value: allocations.penaltyAssets,
28
+ max: mode.withdrawAssets,
29
+ });
30
+ }
31
+ return allocations;
32
+ };
33
+ exports.parseBlueWithdrawPenalty = parseBlueWithdrawPenalty;
34
+ /** Constructs complete raw withdrawal params, including optional authorization. @internal */
35
+ const parseBlueWithdraw = (params) => {
36
+ const marketParams = (0, parse_js_1.parseBlueMarket)(params.market.marketParams);
37
+ const amounts = {
38
+ withdrawAssets: (0, parse_js_1.parseUint256)("withdrawAssets", params.args.withdrawAssets),
39
+ withdrawShares: (0, parse_js_1.parseUint256)("withdrawShares", params.args.withdrawShares),
40
+ };
41
+ const mode = (0, exports.parseBlueWithdrawMode)(marketParams, {
42
+ ...amounts,
43
+ field: "withdrawAssets or withdrawShares",
44
+ });
45
+ const common = {
46
+ chainId: params.market.chainId,
47
+ userAddress: params.args.userAddress,
48
+ deadline: params.args.deadline,
49
+ referralFeePct: params.args.referralFeePct,
50
+ referralFeeRecipient: params.args.referralFeeRecipient,
51
+ metadata: params.metadata,
52
+ };
53
+ const normalized = (0, common_js_1.parseBlueBundlesV1Common)(common);
54
+ const signedAuthorization = (0, common_js_1.getBlueBundlesV1SignedAuthorization)({
55
+ ...common,
56
+ authorizationSignature: params.args.authorizationSignature,
57
+ });
58
+ const allocations = (0, exports.parseBlueWithdrawPenalty)((0, common_js_1.parseBlueAllocations)([...(params.args.reallocations ?? [])], marketParams), mode);
59
+ const fields = {
60
+ ...normalized,
61
+ chainId: common.chainId,
62
+ userAddress: common.userAddress,
63
+ marketParams,
64
+ metadata: common.metadata,
65
+ ...amounts,
66
+ publicAllocations: allocations.publicAllocations,
67
+ reallocationPenaltyAssets: allocations.penaltyAssets,
68
+ };
69
+ const input = fields;
70
+ return { ...input, signedAuthorization };
71
+ };
72
+ exports.parseBlueWithdraw = parseBlueWithdraw;
73
+ /** Encodes parsed inputs and independently validates supplied signatures. @internal */
74
+ const buildBlueWithdraw = (parsed, signatures = {}) => {
75
+ return (0, encode_js_1.encodeBlueWithdraw)({
76
+ ...parsed,
77
+ signedAuthorization: (0, common_js_1.getBlueBundlesV1SignedAuthorization)({
78
+ chainId: parsed.chainId,
79
+ userAddress: parsed.userAddress,
80
+ authorizationSignature: signatures.authorizationSignature,
81
+ }),
82
+ });
83
+ };
84
+ exports.buildBlueWithdraw = buildBlueWithdraw;
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.blueWithdraw = void 0;
4
- const viem_1 = require("viem");
5
- const abis_js_1 = require("../../abis.js");
6
- const validate_js_1 = require("../../helpers/validate.js");
7
- const index_js_1 = require("../../types/index.js");
8
- const common_js_1 = require("../bundles/common.js");
9
- const common_js_2 = require("./common.js");
4
+ const encode_js_1 = require("./encode.js");
5
+ const withdraw_internal_js_1 = require("./withdraw.internal.js");
10
6
  /**
11
7
  * Encodes a direct BlueBundlesV1 loan-asset withdrawal transaction.
12
8
  *
@@ -28,7 +24,8 @@ const common_js_2 = require("./common.js");
28
24
  * @param params.metadata - Optional transaction metadata.
29
25
  * @returns A deep-frozen `Readonly<Transaction<BlueWithdrawAction>>` whose `to` address is
30
26
  * BlueBundlesV1 and whose `action` records the normalized withdrawal inputs.
31
- * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
27
+ * @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
28
+ * `id` that does not hash from its tuple fields.
32
29
  * @throws {NegativeInputError} when an amount, fee, or reallocation penalty is negative.
33
30
  * @throws {MutuallyExclusiveWithdrawAmountsError} when assets and shares are both nonzero.
34
31
  * @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
@@ -65,75 +62,5 @@ const common_js_2 = require("./common.js");
65
62
  * // tx satisfies Readonly<Transaction<BlueWithdrawAction>>
66
63
  * ```
67
64
  */
68
- const blueWithdraw = (params) => {
69
- const { chainId, marketParams } = params.market;
70
- (0, validate_js_1.validateMarketParamsId)(marketParams);
71
- const { userAddress, withdrawAssets, withdrawShares, authorizationSignature, } = params.args;
72
- (0, validate_js_1.validateUint256Field)("withdrawAssets", withdrawAssets);
73
- (0, validate_js_1.validateUint256Field)("withdrawShares", withdrawShares);
74
- if (withdrawAssets > 0n && withdrawShares > 0n) {
75
- throw new index_js_1.MutuallyExclusiveWithdrawAmountsError(marketParams.id);
76
- }
77
- if (withdrawAssets === 0n && withdrawShares === 0n) {
78
- throw new index_js_1.NonPositiveInputError("withdrawAssets or withdrawShares", 0n);
79
- }
80
- const common = {
81
- chainId,
82
- userAddress,
83
- deadline: params.args.deadline,
84
- referralFeePct: params.args.referralFeePct,
85
- referralFeeRecipient: params.args.referralFeeRecipient,
86
- metadata: params.metadata,
87
- };
88
- const { referralFeePct, referralFeeRecipient } = (0, common_js_2.normalizeBlueBundlesV1CommonParams)(common);
89
- const signedAuthorization = (0, common_js_2.getBlueBundlesV1SignedAuthorization)({
90
- chainId,
91
- userAddress,
92
- authorizationSignature,
93
- });
94
- const publicAllocations = (0, common_js_2.getBlueBundlesV1PublicAllocations)([...(params.args.reallocations ?? [])], marketParams);
95
- const reallocationPenaltyAssets = (0, common_js_2.getBlueBundlesV1PenaltyAssets)(publicAllocations);
96
- if (withdrawAssets > 0n && reallocationPenaltyAssets > withdrawAssets) {
97
- throw new index_js_1.InputExceedsMaxError({
98
- field: "reallocationPenaltyAssets",
99
- value: reallocationPenaltyAssets,
100
- max: withdrawAssets,
101
- });
102
- }
103
- return (0, common_js_2.finalizeBlueBundlesV1Transaction)({
104
- common,
105
- value: 0n,
106
- data: (0, viem_1.encodeFunctionData)({
107
- abi: abis_js_1.blueBundlesV1Abi,
108
- functionName: "blueBundlesV1Withdraw",
109
- args: [
110
- marketParams,
111
- withdrawAssets,
112
- withdrawShares,
113
- signedAuthorization,
114
- publicAllocations,
115
- referralFeePct,
116
- referralFeeRecipient,
117
- params.args.deadline,
118
- ],
119
- }),
120
- action: {
121
- type: "blueWithdraw",
122
- args: {
123
- market: marketParams.id,
124
- withdrawAssets,
125
- withdrawShares,
126
- onBehalf: userAddress,
127
- reallocations: publicAllocations.length,
128
- reallocationPenaltyAssets,
129
- referralFeePct,
130
- referralFeeRecipient,
131
- referralFeeAssets: withdrawAssets > 0n
132
- ? (0, common_js_1.getBundlesReferralFeeAssets)(withdrawAssets - reallocationPenaltyAssets, referralFeePct)
133
- : undefined,
134
- deadline: params.args.deadline,
135
- },
136
- },
137
- });
138
- };
65
+ const blueWithdraw = (params) => (0, encode_js_1.encodeBlueWithdraw)((0, withdraw_internal_js_1.parseBlueWithdraw)(params));
139
66
  exports.blueWithdraw = blueWithdraw;
@@ -1,6 +1,6 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
- import { type Address } from "viem";
3
- import { type BlueWithdrawBuyCallbackAction, type Metadata, type Transaction } from "../../types/index.js";
2
+ import type { Address } from "viem";
3
+ import type { BlueWithdrawBuyCallbackAction, Metadata, Transaction } from "../../types/index.js";
4
4
  /** Parameters for {@link blueWithdrawBuyCallback}. */
5
5
  export interface BlueWithdrawBuyCallbackParams {
6
6
  /** Chain and scoped Morpho Blue market. */
@@ -0,0 +1,20 @@
1
+ import { type Address } from "viem";
2
+ import type { BlueMarket } from "../../helpers/parse.js";
3
+ import { type BlueWithdrawBuyCallbackAction, type Metadata, type Transaction } from "../../types/index.js";
4
+ import type { BlueWithdrawBuyCallbackParams } from "./withdrawBuyCallback.js";
5
+ declare const blueWithdrawBuyCallbackBrand: unique symbol;
6
+ /** Validated direct callback withdrawal inputs. @internal */
7
+ export interface BlueWithdrawBuyCallbackInput {
8
+ readonly metadata?: Metadata;
9
+ readonly marketParams: BlueMarket;
10
+ readonly callbackAddress: Address;
11
+ readonly userAddress: Address;
12
+ readonly shares: bigint;
13
+ readonly to: Address;
14
+ readonly [blueWithdrawBuyCallbackBrand]: true;
15
+ }
16
+ /** Parses the direct callback withdrawal without reading chain state. @internal */
17
+ export declare const parseBlueWithdrawBuyCallback: (params: BlueWithdrawBuyCallbackParams) => BlueWithdrawBuyCallbackInput;
18
+ /** Encodes an already parsed direct callback withdrawal. @internal */
19
+ export declare const buildBlueWithdrawBuyCallback: (parsed: ReturnType<typeof parseBlueWithdrawBuyCallback>) => Readonly<Transaction<BlueWithdrawBuyCallbackAction>>;
20
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildBlueWithdrawBuyCallback = exports.parseBlueWithdrawBuyCallback = void 0;
4
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
+ const viem_1 = require("viem");
6
+ const abis_js_1 = require("../../abis.js");
7
+ const index_js_1 = require("../../helpers/index.js");
8
+ const parse_js_1 = require("../../helpers/parse.js");
9
+ const index_js_2 = require("../../types/index.js");
10
+ /** Parses the direct callback withdrawal without reading chain state. @internal */
11
+ const parseBlueWithdrawBuyCallback = (params) => {
12
+ const marketParams = (0, parse_js_1.parseBlueMarket)(params.market.marketParams);
13
+ const { chainId } = params.market;
14
+ const { callbackAddress, userAddress } = params.args;
15
+ const shares = (0, parse_js_1.parseUint256)("shares", params.args.shares);
16
+ if (shares === 0n) {
17
+ throw new index_js_2.NonPositiveInputError("shares", shares);
18
+ }
19
+ const result = {
20
+ metadata: params.metadata,
21
+ marketParams,
22
+ callbackAddress,
23
+ userAddress,
24
+ shares,
25
+ to: (0, morpho_ts_1.getChainAddress)(chainId, "blue"),
26
+ };
27
+ return result;
28
+ };
29
+ exports.parseBlueWithdrawBuyCallback = parseBlueWithdrawBuyCallback;
30
+ /** Encodes an already parsed direct callback withdrawal. @internal */
31
+ const buildBlueWithdrawBuyCallback = (parsed) => {
32
+ const { metadata, marketParams, callbackAddress, userAddress, shares, to } = parsed;
33
+ let tx = {
34
+ to,
35
+ value: 0n,
36
+ data: (0, viem_1.encodeFunctionData)({
37
+ abi: abis_js_1.blueAbi,
38
+ functionName: "withdraw",
39
+ args: [marketParams, 0n, shares, callbackAddress, userAddress],
40
+ }),
41
+ };
42
+ if (metadata) {
43
+ tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
44
+ }
45
+ return (0, morpho_ts_1.deepFreeze)({
46
+ ...tx,
47
+ action: {
48
+ type: "blueWithdrawBuyCallback",
49
+ args: {
50
+ market: marketParams.id,
51
+ shares,
52
+ onBehalf: callbackAddress,
53
+ receiver: userAddress,
54
+ },
55
+ },
56
+ });
57
+ };
58
+ exports.buildBlueWithdrawBuyCallback = buildBlueWithdrawBuyCallback;
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.blueWithdrawBuyCallback = void 0;
4
- const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
- const viem_1 = require("viem");
6
- const abis_js_1 = require("../../abis.js");
7
- const index_js_1 = require("../../helpers/index.js");
8
- const validate_js_1 = require("../../helpers/validate.js");
9
- const index_js_2 = require("../../types/index.js");
4
+ const withdrawBuyCallback_internal_js_1 = require("./withdrawBuyCallback.internal.js");
10
5
  /**
11
6
  * Encodes a direct Morpho Blue `withdraw` of a BlueBuyCallback's supply shares to its owner.
12
7
  *
@@ -44,37 +39,5 @@ const index_js_2 = require("../../types/index.js");
44
39
  * // tx satisfies Readonly<Transaction<BlueWithdrawBuyCallbackAction>>
45
40
  * ```
46
41
  */
47
- const blueWithdrawBuyCallback = (params) => {
48
- const { chainId, marketParams } = params.market;
49
- const { callbackAddress, userAddress, shares } = params.args;
50
- (0, validate_js_1.validateMarketParamsId)(marketParams);
51
- (0, validate_js_1.validateUint256Field)("shares", shares);
52
- if (shares === 0n) {
53
- throw new index_js_2.NonPositiveInputError("shares", shares);
54
- }
55
- let tx = {
56
- to: (0, morpho_ts_1.getChainAddress)(chainId, "blue"),
57
- value: 0n,
58
- data: (0, viem_1.encodeFunctionData)({
59
- abi: abis_js_1.blueAbi,
60
- functionName: "withdraw",
61
- args: [marketParams, 0n, shares, callbackAddress, userAddress],
62
- }),
63
- };
64
- if (params.metadata) {
65
- tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
66
- }
67
- return (0, morpho_ts_1.deepFreeze)({
68
- ...tx,
69
- action: {
70
- type: "blueWithdrawBuyCallback",
71
- args: {
72
- market: marketParams.id,
73
- shares,
74
- onBehalf: callbackAddress,
75
- receiver: userAddress,
76
- },
77
- },
78
- });
79
- };
42
+ const blueWithdrawBuyCallback = (params) => (0, withdrawBuyCallback_internal_js_1.buildBlueWithdrawBuyCallback)((0, withdrawBuyCallback_internal_js_1.parseBlueWithdrawBuyCallback)(params));
80
43
  exports.blueWithdrawBuyCallback = blueWithdrawBuyCallback;
@@ -0,0 +1,16 @@
1
+ import type { BlueWithdrawCollateralAction, Transaction } from "../../types/index.js";
2
+ import { type BlueRepayInput, parseBlueRepayWithdrawCollateral } from "./repayWithdrawCollateral.internal.js";
3
+ import type { BlueWithdrawCollateralParams } from "./withdrawCollateral.js";
4
+ /** Complete collateral-withdrawal input with repayment disabled. @internal */
5
+ export interface BlueWithdrawCollateralInput extends BlueRepayInput {
6
+ readonly repayAssets: 0n;
7
+ readonly repayShares: 0n;
8
+ readonly maxRepayAssets: 0n;
9
+ readonly hasRepay: false;
10
+ }
11
+ /** Constructs the complete raw collateral withdrawal with repayment disabled. @internal */
12
+ export declare const parseBlueWithdrawCollateral: (params: BlueWithdrawCollateralParams & {
13
+ readonly args: Pick<Parameters<typeof parseBlueRepayWithdrawCollateral>[0]["args"], "requirementSignature">;
14
+ }) => BlueWithdrawCollateralInput & Pick<ReturnType<typeof parseBlueRepayWithdrawCollateral>, "bound">;
15
+ /** Encodes only a completed pure collateral-withdrawal operation. @internal */
16
+ export declare const buildBlueWithdrawCollateral: (parsed: ReturnType<typeof parseBlueWithdrawCollateral>) => Readonly<Transaction<BlueWithdrawCollateralAction>>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildBlueWithdrawCollateral = exports.parseBlueWithdrawCollateral = void 0;
4
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
+ const encode_js_1 = require("./encode.js");
6
+ const repayWithdrawCollateral_internal_js_1 = require("./repayWithdrawCollateral.internal.js");
7
+ /** Constructs the complete raw collateral withdrawal with repayment disabled. @internal */
8
+ const parseBlueWithdrawCollateral = (params) => ({
9
+ ...(0, repayWithdrawCollateral_internal_js_1.parseBlueRepayWithdrawCollateral)({
10
+ ...params,
11
+ args: {
12
+ requirementSignature: params.args.requirementSignature,
13
+ userAddress: params.args.userAddress,
14
+ collateralAssets: params.args.collateralAssets,
15
+ maxLtv: params.args.maxLtv,
16
+ deadline: params.args.deadline,
17
+ referralFeePct: params.args.referralFeePct,
18
+ referralFeeRecipient: params.args.referralFeeRecipient,
19
+ authorizationSignature: params.args.authorizationSignature,
20
+ repayAssets: 0n,
21
+ repayShares: 0n,
22
+ maxRepayAssets: 0n,
23
+ },
24
+ }),
25
+ repayAssets: 0n,
26
+ repayShares: 0n,
27
+ maxRepayAssets: 0n,
28
+ hasRepay: false,
29
+ });
30
+ exports.parseBlueWithdrawCollateral = parseBlueWithdrawCollateral;
31
+ /** Encodes only a completed pure collateral-withdrawal operation. @internal */
32
+ const buildBlueWithdrawCollateral = (parsed) => {
33
+ const transaction = (0, encode_js_1.encodeBlueRepayWithdrawCollateral)(parsed);
34
+ return (0, morpho_ts_1.deepFreeze)({
35
+ ...transaction,
36
+ action: { ...transaction.action, type: "blueWithdrawCollateral" },
37
+ });
38
+ };
39
+ exports.buildBlueWithdrawCollateral = buildBlueWithdrawCollateral;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.blueWithdrawCollateral = void 0;
4
- const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
- const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
4
+ const withdrawCollateral_internal_js_1 = require("./withdrawCollateral.internal.js");
6
5
  /**
7
6
  * Encodes a pure collateral withdrawal through BlueBundlesV1.
8
7
  *
@@ -50,19 +49,5 @@ const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
50
49
  * // tx satisfies Readonly<Transaction<BlueWithdrawCollateralAction>>
51
50
  * ```
52
51
  */
53
- const blueWithdrawCollateral = (params) => {
54
- const transaction = (0, repayWithdrawCollateral_js_1.blueRepayWithdrawCollateral)({
55
- ...params,
56
- args: {
57
- ...params.args,
58
- repayAssets: 0n,
59
- repayShares: 0n,
60
- maxRepayAssets: 0n,
61
- },
62
- });
63
- return (0, morpho_ts_1.deepFreeze)({
64
- ...transaction,
65
- action: { ...transaction.action, type: "blueWithdrawCollateral" },
66
- });
67
- };
52
+ const blueWithdrawCollateral = (params) => (0, withdrawCollateral_internal_js_1.buildBlueWithdrawCollateral)((0, withdrawCollateral_internal_js_1.parseBlueWithdrawCollateral)(params));
68
53
  exports.blueWithdrawCollateral = blueWithdrawCollateral;
@@ -176,6 +176,15 @@ export declare const getBundlesSharesPermit: (params: {
176
176
  readonly amount?: bigint;
177
177
  readonly requirementSignature?: PermitRequirementSignature;
178
178
  }) => BundleSharesPermit;
179
+ /** Binds a fresh share signature to a complete operation's checked fallback deadline. @internal */
180
+ export declare const getParsedBundlesSharesPermit: (params: {
181
+ readonly vault: Address;
182
+ readonly deadline: bigint;
183
+ readonly owner?: Address;
184
+ readonly spender?: Address;
185
+ readonly amount?: bigint;
186
+ readonly requirementSignature?: PermitRequirementSignature;
187
+ }) => BundleSharesPermit;
179
188
  /**
180
189
  * Selects the one token signature accepted by a bundles-funded call.
181
190
  *
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.finalizeVaultBundlesV1Transaction = exports.getBundlesReferralFeeAssets = exports.selectBundlesSharesPermitSignature = exports.selectBundlesTokenRequirementSignature = exports.getBundlesSharesPermit = exports.normalizeBundlesSignature = exports.getBundlesTokenPermit = exports.resolveBundlesFunding = exports.normalizeBundlesCommonParams = exports.BundlesPermitKind = void 0;
3
+ exports.finalizeVaultBundlesV1Transaction = exports.getBundlesReferralFeeAssets = exports.selectBundlesSharesPermitSignature = exports.selectBundlesTokenRequirementSignature = exports.getParsedBundlesSharesPermit = exports.getBundlesSharesPermit = exports.normalizeBundlesSignature = exports.getBundlesTokenPermit = exports.resolveBundlesFunding = exports.normalizeBundlesCommonParams = exports.BundlesPermitKind = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
6
  const viem_1 = require("viem");
7
7
  const index_js_1 = require("../../helpers/index.js");
8
+ const parse_js_1 = require("../../helpers/parse.js");
8
9
  const validate_js_1 = require("../../helpers/validate.js");
9
10
  const index_js_2 = require("../../types/index.js");
10
11
  /** Numeric permit kinds consumed by `TokenLib.pullToken`. */
@@ -31,10 +32,11 @@ const EMPTY_TOKEN_PERMIT = {
31
32
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
32
33
  */
33
34
  const normalizeBundlesCommonParams = (params) => {
34
- (0, validate_js_1.validateDeadline)(params.deadline);
35
+ const { deadline } = params;
36
+ (0, validate_js_1.validateDeadline)(deadline);
35
37
  const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
36
38
  return {
37
- deadline: params.deadline,
39
+ deadline,
38
40
  referralFeePct,
39
41
  referralFeeRecipient,
40
42
  };
@@ -261,9 +263,19 @@ const validateBundlesPermitValue = (params) => {
261
263
  * ```
262
264
  */
263
265
  const getBundlesSharesPermit = (params) => {
266
+ return (0, exports.getParsedBundlesSharesPermit)({
267
+ deadline: (0, parse_js_1.parseDeadline)(params.deadline),
268
+ vault: params.vault,
269
+ owner: params.owner,
270
+ spender: params.spender,
271
+ amount: params.amount,
272
+ requirementSignature: params.requirementSignature,
273
+ });
274
+ };
275
+ exports.getBundlesSharesPermit = getBundlesSharesPermit;
276
+ /** Binds a fresh share signature to a complete operation's checked fallback deadline. @internal */
277
+ const getParsedBundlesSharesPermit = (params) => {
264
278
  const { requirementSignature } = params;
265
- // Require a positive uint256 for the fallback permit deadline.
266
- (0, validate_js_1.validateDeadline)(params.deadline);
267
279
  if (requirementSignature == null) {
268
280
  return {
269
281
  value: 0n,
@@ -346,7 +358,7 @@ const getBundlesSharesPermit = (params) => {
346
358
  ...signature,
347
359
  };
348
360
  };
349
- exports.getBundlesSharesPermit = getBundlesSharesPermit;
361
+ exports.getParsedBundlesSharesPermit = getParsedBundlesSharesPermit;
350
362
  /**
351
363
  * Selects the one token signature accepted by a bundles-funded call.
352
364
  *
@@ -1,3 +1,3 @@
1
1
  export type { BundleSharesPermit, BundlesCommonParams, BundlesTokenPermit, NormalizedBundlesCommonParams, } from "./common.js";
2
2
  export { BundlesPermitKind, getBundlesSharesPermit, getBundlesTokenPermit, resolveBundlesFunding, } from "./common.js";
3
- export * from "./resolveBundlesTokenRequirements.js";
3
+ export { type BundlesTokenRequirementsState, resolveBundlesTokenRequirements, } from "./resolveBundlesTokenRequirements.js";
@@ -1,23 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.resolveBundlesFunding = exports.getBundlesTokenPermit = exports.getBundlesSharesPermit = exports.BundlesPermitKind = void 0;
3
+ exports.resolveBundlesTokenRequirements = exports.resolveBundlesFunding = exports.getBundlesTokenPermit = exports.getBundlesSharesPermit = exports.BundlesPermitKind = void 0;
18
4
  var common_js_1 = require("./common.js");
19
5
  Object.defineProperty(exports, "BundlesPermitKind", { enumerable: true, get: function () { return common_js_1.BundlesPermitKind; } });
20
6
  Object.defineProperty(exports, "getBundlesSharesPermit", { enumerable: true, get: function () { return common_js_1.getBundlesSharesPermit; } });
21
7
  Object.defineProperty(exports, "getBundlesTokenPermit", { enumerable: true, get: function () { return common_js_1.getBundlesTokenPermit; } });
22
8
  Object.defineProperty(exports, "resolveBundlesFunding", { enumerable: true, get: function () { return common_js_1.resolveBundlesFunding; } });
23
- __exportStar(require("./resolveBundlesTokenRequirements.js"), exports);
9
+ var resolveBundlesTokenRequirements_js_1 = require("./resolveBundlesTokenRequirements.js");
10
+ Object.defineProperty(exports, "resolveBundlesTokenRequirements", { enumerable: true, get: function () { return resolveBundlesTokenRequirements_js_1.resolveBundlesTokenRequirements; } });
@@ -1,5 +1,16 @@
1
1
  import type { Address } from "viem";
2
2
  import { type BundlesTokenSignatureRequirement, type ERC20ApprovalAction, type ReferenceTimestampParams, type Transaction } from "../../types/index.js";
3
+ import { type Erc20Permit2SignatureTransferInput } from "../requirements/encode/encodeErc20Permit2SignatureTransfer.js";
4
+ import { type RequirementsApprovalInput } from "../requirements/getRequirementsApproval.js";
5
+ declare const bundlesTokenRequirementsInput: unique symbol;
6
+ /** Complete checked state-resolution invocation, with ordered child operations. @internal */
7
+ export interface BundlesTokenRequirementsInput {
8
+ readonly approval?: RequirementsApprovalInput;
9
+ readonly permit?: Erc20Permit2SignatureTransferInput;
10
+ readonly [bundlesTokenRequirementsInput]: true;
11
+ }
12
+ /** Owns the complete state-dependent static contract and legacy error precedence. @internal */
13
+ export declare const parseBundlesTokenRequirements: (params: Parameters<typeof resolveBundlesTokenRequirements>[0]) => BundlesTokenRequirementsInput;
3
14
  /** Plain onchain state used by {@link resolveBundlesTokenRequirements}. */
4
15
  export type BundlesTokenRequirementsState = {
5
16
  readonly type: "approval";
@@ -76,3 +87,6 @@ export declare const resolveBundlesTokenRequirements: (params: {
76
87
  readonly deadline: bigint;
77
88
  readonly state: BundlesTokenRequirementsState;
78
89
  } & ReferenceTimestampParams) => readonly (Readonly<Transaction<ERC20ApprovalAction>> | BundlesTokenSignatureRequirement)[];
90
+ /** Resolves the complete checked operation without repeating its static guards. @internal */
91
+ export declare const resolveParsedBundlesTokenRequirements: (params: BundlesTokenRequirementsInput) => readonly (Readonly<Transaction<ERC20ApprovalAction>> | BundlesTokenSignatureRequirement)[];
92
+ export {};