@morpho-org/morpho-sdk 1.1.0 → 1.2.1

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 (304) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +31 -33
  3. package/lib/cjs/actions/index.d.ts +4 -0
  4. package/lib/{actions → cjs/actions}/index.js +4 -4
  5. package/lib/cjs/actions/marketV1/borrow.d.ts +69 -0
  6. package/lib/cjs/actions/marketV1/borrow.js +97 -0
  7. package/lib/cjs/actions/marketV1/buildReallocationActions.d.ts +28 -0
  8. package/lib/cjs/actions/marketV1/buildReallocationActions.js +47 -0
  9. package/lib/cjs/actions/marketV1/index.d.ts +6 -0
  10. package/lib/{actions → cjs/actions}/marketV1/index.js +6 -6
  11. package/lib/cjs/actions/marketV1/repay.d.ts +89 -0
  12. package/lib/cjs/actions/marketV1/repay.js +134 -0
  13. package/lib/cjs/actions/marketV1/repayWithdrawCollateral.d.ts +103 -0
  14. package/lib/cjs/actions/marketV1/repayWithdrawCollateral.js +155 -0
  15. package/lib/cjs/actions/marketV1/supplyCollateral.d.ts +59 -0
  16. package/lib/cjs/actions/marketV1/supplyCollateral.js +116 -0
  17. package/lib/cjs/actions/marketV1/supplyCollateralBorrow.d.ts +91 -0
  18. package/lib/cjs/actions/marketV1/supplyCollateralBorrow.js +163 -0
  19. package/lib/cjs/actions/marketV1/withdrawCollateral.d.ts +49 -0
  20. package/lib/cjs/actions/marketV1/withdrawCollateral.js +72 -0
  21. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +36 -0
  22. package/lib/{actions → cjs/actions}/requirements/encode/encodeErc20Approval.js +25 -0
  23. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +52 -0
  24. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +108 -0
  25. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2.d.ts +44 -0
  26. package/lib/{actions → cjs/actions}/requirements/encode/encodeErc20Permit2.js +36 -4
  27. package/lib/cjs/actions/requirements/encode/index.d.ts +3 -0
  28. package/lib/{actions → cjs/actions}/requirements/encode/index.js +3 -3
  29. package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.d.ts +37 -0
  30. package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.js +71 -0
  31. package/lib/cjs/actions/requirements/getRequirements.d.ts +74 -0
  32. package/lib/cjs/actions/requirements/getRequirements.js +112 -0
  33. package/lib/cjs/actions/requirements/getRequirementsAction.d.ts +33 -0
  34. package/lib/{actions → cjs/actions}/requirements/getRequirementsAction.js +20 -4
  35. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +43 -0
  36. package/lib/cjs/actions/requirements/getRequirementsApproval.js +63 -0
  37. package/lib/cjs/actions/requirements/getRequirementsPermit.d.ts +45 -0
  38. package/lib/cjs/actions/requirements/getRequirementsPermit.js +57 -0
  39. package/lib/cjs/actions/requirements/getRequirementsPermit2.d.ts +63 -0
  40. package/lib/cjs/actions/requirements/getRequirementsPermit2.js +85 -0
  41. package/lib/cjs/actions/requirements/index.d.ts +6 -0
  42. package/lib/{actions → cjs/actions}/requirements/index.js +6 -6
  43. package/lib/cjs/actions/vaultV1/deposit.d.ts +72 -0
  44. package/lib/cjs/actions/vaultV1/deposit.js +146 -0
  45. package/lib/cjs/actions/vaultV1/index.d.ts +4 -0
  46. package/lib/{actions → cjs/actions}/vaultV1/index.js +4 -4
  47. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +84 -0
  48. package/lib/cjs/actions/vaultV1/migrateToV2.js +143 -0
  49. package/lib/cjs/actions/vaultV1/redeem.d.ts +39 -0
  50. package/lib/cjs/actions/vaultV1/redeem.js +57 -0
  51. package/lib/cjs/actions/vaultV1/withdraw.d.ts +39 -0
  52. package/lib/cjs/actions/vaultV1/withdraw.js +57 -0
  53. package/lib/cjs/actions/vaultV2/deposit.d.ts +72 -0
  54. package/lib/cjs/actions/vaultV2/deposit.js +146 -0
  55. package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +63 -0
  56. package/lib/cjs/actions/vaultV2/forceRedeem.js +99 -0
  57. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +58 -0
  58. package/lib/cjs/actions/vaultV2/forceWithdraw.js +94 -0
  59. package/lib/cjs/actions/vaultV2/index.d.ts +5 -0
  60. package/lib/{actions → cjs/actions}/vaultV2/index.js +5 -5
  61. package/lib/cjs/actions/vaultV2/redeem.d.ts +40 -0
  62. package/lib/cjs/actions/vaultV2/redeem.js +58 -0
  63. package/lib/cjs/actions/vaultV2/withdraw.d.ts +40 -0
  64. package/lib/cjs/actions/vaultV2/withdraw.js +58 -0
  65. package/lib/cjs/client/index.d.ts +2 -0
  66. package/lib/{client → cjs/client}/index.js +2 -2
  67. package/lib/cjs/client/morphoClient.d.ts +113 -0
  68. package/lib/cjs/client/morphoClient.js +123 -0
  69. package/lib/cjs/client/morphoViemExtension.d.ts +45 -0
  70. package/lib/cjs/client/morphoViemExtension.js +46 -0
  71. package/lib/cjs/entities/index.d.ts +3 -0
  72. package/lib/{entities → cjs/entities}/index.js +3 -3
  73. package/lib/cjs/entities/marketV1/index.d.ts +1 -0
  74. package/lib/{entities/vaultV1 → cjs/entities/marketV1}/index.js +1 -1
  75. package/lib/{entities → cjs/entities}/marketV1/marketV1.d.ts +9 -6
  76. package/lib/{entities → cjs/entities}/marketV1/marketV1.js +89 -87
  77. package/lib/cjs/entities/vaultV1/index.d.ts +1 -0
  78. package/lib/{entities/marketV1 → cjs/entities/vaultV1}/index.js +1 -1
  79. package/lib/{entities → cjs/entities}/vaultV1/vaultV1.d.ts +4 -8
  80. package/lib/{entities → cjs/entities}/vaultV1/vaultV1.js +39 -35
  81. package/lib/cjs/entities/vaultV2/index.d.ts +1 -0
  82. package/lib/{entities → cjs/entities}/vaultV2/index.js +1 -1
  83. package/lib/{entities → cjs/entities}/vaultV2/vaultV2.d.ts +2 -2
  84. package/lib/{entities → cjs/entities}/vaultV2/vaultV2.js +25 -24
  85. package/lib/{helpers → cjs/helpers}/computeReallocations.d.ts +1 -1
  86. package/lib/{helpers → cjs/helpers}/computeReallocations.js +2 -2
  87. package/lib/{helpers → cjs/helpers}/encodeDeallocation.d.ts +1 -1
  88. package/lib/{helpers → cjs/helpers}/encodeDeallocation.js +2 -2
  89. package/lib/{helpers → cjs/helpers}/index.d.ts +4 -4
  90. package/lib/{helpers → cjs/helpers}/index.js +19 -19
  91. package/lib/{helpers → cjs/helpers}/metadata.d.ts +1 -1
  92. package/lib/{helpers → cjs/helpers}/slippage.js +7 -7
  93. package/lib/{helpers → cjs/helpers}/validate.d.ts +1 -1
  94. package/lib/{helpers → cjs/helpers}/validate.js +33 -33
  95. package/lib/cjs/index.d.ts +5 -0
  96. package/lib/cjs/index.js +21 -0
  97. package/lib/cjs/package.json +1 -0
  98. package/lib/{types → cjs/types}/action.d.ts +1 -1
  99. package/lib/{types → cjs/types}/client.d.ts +6 -2
  100. package/lib/{types → cjs/types}/error.d.ts +46 -0
  101. package/lib/{types → cjs/types}/error.js +46 -0
  102. package/lib/cjs/types/index.d.ts +7 -0
  103. package/lib/cjs/types/index.js +23 -0
  104. package/lib/esm/actions/index.d.ts +4 -0
  105. package/lib/esm/actions/index.js +4 -0
  106. package/lib/esm/actions/marketV1/borrow.d.ts +69 -0
  107. package/lib/esm/actions/marketV1/borrow.js +93 -0
  108. package/lib/esm/actions/marketV1/buildReallocationActions.d.ts +28 -0
  109. package/lib/esm/actions/marketV1/buildReallocationActions.js +43 -0
  110. package/lib/esm/actions/marketV1/index.d.ts +6 -0
  111. package/lib/esm/actions/marketV1/index.js +6 -0
  112. package/lib/esm/actions/marketV1/repay.d.ts +89 -0
  113. package/lib/esm/actions/marketV1/repay.js +130 -0
  114. package/lib/esm/actions/marketV1/repayWithdrawCollateral.d.ts +103 -0
  115. package/lib/esm/actions/marketV1/repayWithdrawCollateral.js +151 -0
  116. package/lib/esm/actions/marketV1/supplyCollateral.d.ts +59 -0
  117. package/lib/esm/actions/marketV1/supplyCollateral.js +112 -0
  118. package/lib/esm/actions/marketV1/supplyCollateralBorrow.d.ts +91 -0
  119. package/lib/esm/actions/marketV1/supplyCollateralBorrow.js +159 -0
  120. package/lib/esm/actions/marketV1/withdrawCollateral.d.ts +49 -0
  121. package/lib/esm/actions/marketV1/withdrawCollateral.js +68 -0
  122. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +36 -0
  123. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +46 -0
  124. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +52 -0
  125. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +104 -0
  126. package/lib/esm/actions/requirements/encode/encodeErc20Permit2.d.ts +44 -0
  127. package/lib/esm/actions/requirements/encode/encodeErc20Permit2.js +98 -0
  128. package/lib/esm/actions/requirements/encode/index.d.ts +3 -0
  129. package/lib/esm/actions/requirements/encode/index.js +3 -0
  130. package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.d.ts +37 -0
  131. package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.js +67 -0
  132. package/lib/esm/actions/requirements/getRequirements.d.ts +74 -0
  133. package/lib/esm/actions/requirements/getRequirements.js +108 -0
  134. package/lib/esm/actions/requirements/getRequirementsAction.d.ts +33 -0
  135. package/lib/esm/actions/requirements/getRequirementsAction.js +76 -0
  136. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +43 -0
  137. package/lib/esm/actions/requirements/getRequirementsApproval.js +59 -0
  138. package/lib/esm/actions/requirements/getRequirementsPermit.d.ts +45 -0
  139. package/lib/esm/actions/requirements/getRequirementsPermit.js +53 -0
  140. package/lib/esm/actions/requirements/getRequirementsPermit2.d.ts +63 -0
  141. package/lib/esm/actions/requirements/getRequirementsPermit2.js +81 -0
  142. package/lib/esm/actions/requirements/index.d.ts +6 -0
  143. package/lib/esm/actions/requirements/index.js +6 -0
  144. package/lib/esm/actions/vaultV1/deposit.d.ts +72 -0
  145. package/lib/esm/actions/vaultV1/deposit.js +142 -0
  146. package/lib/esm/actions/vaultV1/index.d.ts +4 -0
  147. package/lib/esm/actions/vaultV1/index.js +4 -0
  148. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +84 -0
  149. package/lib/esm/actions/vaultV1/migrateToV2.js +139 -0
  150. package/lib/esm/actions/vaultV1/redeem.d.ts +39 -0
  151. package/lib/esm/actions/vaultV1/redeem.js +53 -0
  152. package/lib/esm/actions/vaultV1/withdraw.d.ts +39 -0
  153. package/lib/esm/actions/vaultV1/withdraw.js +53 -0
  154. package/lib/esm/actions/vaultV2/deposit.d.ts +72 -0
  155. package/lib/esm/actions/vaultV2/deposit.js +142 -0
  156. package/lib/esm/actions/vaultV2/forceRedeem.d.ts +63 -0
  157. package/lib/esm/actions/vaultV2/forceRedeem.js +95 -0
  158. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +58 -0
  159. package/lib/esm/actions/vaultV2/forceWithdraw.js +90 -0
  160. package/lib/esm/actions/vaultV2/index.d.ts +5 -0
  161. package/lib/esm/actions/vaultV2/index.js +5 -0
  162. package/lib/esm/actions/vaultV2/redeem.d.ts +40 -0
  163. package/lib/esm/actions/vaultV2/redeem.js +54 -0
  164. package/lib/esm/actions/vaultV2/withdraw.d.ts +40 -0
  165. package/lib/esm/actions/vaultV2/withdraw.js +54 -0
  166. package/lib/esm/client/index.d.ts +2 -0
  167. package/lib/esm/client/index.js +2 -0
  168. package/lib/esm/client/morphoClient.d.ts +113 -0
  169. package/lib/esm/client/morphoClient.js +119 -0
  170. package/lib/esm/client/morphoViemExtension.d.ts +45 -0
  171. package/lib/esm/client/morphoViemExtension.js +43 -0
  172. package/lib/esm/entities/index.d.ts +3 -0
  173. package/lib/esm/entities/index.js +3 -0
  174. package/lib/esm/entities/marketV1/index.d.ts +1 -0
  175. package/lib/esm/entities/marketV1/index.js +1 -0
  176. package/lib/esm/entities/marketV1/marketV1.d.ts +293 -0
  177. package/lib/esm/entities/marketV1/marketV1.js +529 -0
  178. package/lib/esm/entities/vaultV1/index.d.ts +1 -0
  179. package/lib/esm/entities/vaultV1/index.js +1 -0
  180. package/lib/esm/entities/vaultV1/vaultV1.d.ts +129 -0
  181. package/lib/esm/entities/vaultV1/vaultV1.js +186 -0
  182. package/lib/esm/entities/vaultV2/index.d.ts +1 -0
  183. package/lib/esm/entities/vaultV2/index.js +1 -0
  184. package/lib/esm/entities/vaultV2/vaultV2.d.ts +180 -0
  185. package/lib/esm/entities/vaultV2/vaultV2.js +164 -0
  186. package/lib/esm/helpers/computeReallocations.d.ts +23 -0
  187. package/lib/esm/helpers/computeReallocations.js +94 -0
  188. package/lib/esm/helpers/constant.d.ts +6 -0
  189. package/lib/esm/helpers/constant.js +7 -0
  190. package/lib/esm/helpers/encodeDeallocation.d.ts +10 -0
  191. package/lib/esm/helpers/encodeDeallocation.js +34 -0
  192. package/lib/esm/helpers/index.d.ts +4 -0
  193. package/lib/esm/helpers/index.js +4 -0
  194. package/lib/esm/helpers/metadata.d.ts +33 -0
  195. package/lib/esm/helpers/metadata.js +46 -0
  196. package/lib/esm/helpers/slippage.d.ts +46 -0
  197. package/lib/esm/helpers/slippage.js +69 -0
  198. package/lib/esm/helpers/validate.d.ts +156 -0
  199. package/lib/esm/helpers/validate.js +273 -0
  200. package/lib/esm/index.d.ts +5 -0
  201. package/lib/esm/index.js +5 -0
  202. package/lib/esm/package.json +1 -0
  203. package/lib/esm/types/action.d.ts +216 -0
  204. package/lib/esm/types/action.js +21 -0
  205. package/lib/esm/types/client.d.ts +19 -0
  206. package/lib/esm/types/client.js +1 -0
  207. package/lib/esm/types/data.d.ts +2 -0
  208. package/lib/esm/types/data.js +1 -0
  209. package/lib/esm/types/deallocation.d.ts +15 -0
  210. package/lib/esm/types/deallocation.js +1 -0
  211. package/lib/esm/types/entity.d.ts +5 -0
  212. package/lib/esm/types/entity.js +1 -0
  213. package/lib/esm/types/error.d.ts +205 -0
  214. package/lib/esm/types/error.js +276 -0
  215. package/lib/esm/types/index.d.ts +7 -0
  216. package/lib/esm/types/index.js +7 -0
  217. package/lib/esm/types/metadata.d.ts +4 -0
  218. package/lib/esm/types/metadata.js +1 -0
  219. package/lib/esm/types/sharedLiquidity.d.ts +41 -0
  220. package/lib/esm/types/sharedLiquidity.js +1 -0
  221. package/package.json +29 -54
  222. package/src/index.ts +5 -0
  223. package/lib/actions/index.d.ts +0 -4
  224. package/lib/actions/marketV1/borrow.d.ts +0 -34
  225. package/lib/actions/marketV1/borrow.js +0 -62
  226. package/lib/actions/marketV1/buildReallocationActions.d.ts +0 -17
  227. package/lib/actions/marketV1/buildReallocationActions.js +0 -36
  228. package/lib/actions/marketV1/index.d.ts +0 -6
  229. package/lib/actions/marketV1/repay.d.ts +0 -44
  230. package/lib/actions/marketV1/repay.js +0 -93
  231. package/lib/actions/marketV1/repayWithdrawCollateral.d.ts +0 -51
  232. package/lib/actions/marketV1/repayWithdrawCollateral.js +0 -108
  233. package/lib/actions/marketV1/supplyCollateral.d.ts +0 -28
  234. package/lib/actions/marketV1/supplyCollateral.js +0 -85
  235. package/lib/actions/marketV1/supplyCollateralBorrow.d.ts +0 -37
  236. package/lib/actions/marketV1/supplyCollateralBorrow.js +0 -109
  237. package/lib/actions/marketV1/withdrawCollateral.d.ts +0 -28
  238. package/lib/actions/marketV1/withdrawCollateral.js +0 -51
  239. package/lib/actions/requirements/encode/encodeErc20Approval.d.ts +0 -10
  240. package/lib/actions/requirements/encode/encodeErc20Permit.d.ts +0 -13
  241. package/lib/actions/requirements/encode/encodeErc20Permit.js +0 -70
  242. package/lib/actions/requirements/encode/encodeErc20Permit2.d.ts +0 -11
  243. package/lib/actions/requirements/encode/index.d.ts +0 -3
  244. package/lib/actions/requirements/getMorphoAuthorizationRequirement.d.ts +0 -21
  245. package/lib/actions/requirements/getMorphoAuthorizationRequirement.js +0 -55
  246. package/lib/actions/requirements/getRequirements.d.ts +0 -42
  247. package/lib/actions/requirements/getRequirements.js +0 -80
  248. package/lib/actions/requirements/getRequirementsAction.d.ts +0 -17
  249. package/lib/actions/requirements/getRequirementsApproval.d.ts +0 -31
  250. package/lib/actions/requirements/getRequirementsApproval.js +0 -51
  251. package/lib/actions/requirements/getRequirementsPermit.d.ts +0 -28
  252. package/lib/actions/requirements/getRequirementsPermit.js +0 -40
  253. package/lib/actions/requirements/getRequirementsPermit2.d.ts +0 -37
  254. package/lib/actions/requirements/getRequirementsPermit2.js +0 -59
  255. package/lib/actions/requirements/index.d.ts +0 -6
  256. package/lib/actions/vaultV1/deposit.d.ts +0 -41
  257. package/lib/actions/vaultV1/deposit.js +0 -116
  258. package/lib/actions/vaultV1/index.d.ts +0 -4
  259. package/lib/actions/vaultV1/migrateToV2.d.ts +0 -50
  260. package/lib/actions/vaultV1/migrateToV2.js +0 -108
  261. package/lib/actions/vaultV1/redeem.d.ts +0 -29
  262. package/lib/actions/vaultV1/redeem.js +0 -48
  263. package/lib/actions/vaultV1/withdraw.d.ts +0 -29
  264. package/lib/actions/vaultV1/withdraw.js +0 -48
  265. package/lib/actions/vaultV2/deposit.d.ts +0 -41
  266. package/lib/actions/vaultV2/deposit.js +0 -116
  267. package/lib/actions/vaultV2/forceRedeem.d.ts +0 -48
  268. package/lib/actions/vaultV2/forceRedeem.js +0 -85
  269. package/lib/actions/vaultV2/forceWithdraw.d.ts +0 -40
  270. package/lib/actions/vaultV2/forceWithdraw.js +0 -77
  271. package/lib/actions/vaultV2/index.d.ts +0 -5
  272. package/lib/actions/vaultV2/redeem.d.ts +0 -32
  273. package/lib/actions/vaultV2/redeem.js +0 -51
  274. package/lib/actions/vaultV2/withdraw.d.ts +0 -32
  275. package/lib/actions/vaultV2/withdraw.js +0 -51
  276. package/lib/client/index.d.ts +0 -2
  277. package/lib/client/morphoClient.d.ts +0 -25
  278. package/lib/client/morphoClient.js +0 -28
  279. package/lib/client/morphoViemExtension.d.ts +0 -39
  280. package/lib/client/morphoViemExtension.js +0 -40
  281. package/lib/entities/index.d.ts +0 -3
  282. package/lib/entities/marketV1/index.d.ts +0 -1
  283. package/lib/entities/vaultV1/index.d.ts +0 -1
  284. package/lib/entities/vaultV2/index.d.ts +0 -1
  285. package/lib/index.d.ts +0 -5
  286. package/lib/index.js +0 -21
  287. package/lib/types/index.d.ts +0 -7
  288. package/lib/types/index.js +0 -23
  289. /package/lib/{helpers → cjs/helpers}/constant.d.ts +0 -0
  290. /package/lib/{helpers → cjs/helpers}/constant.js +0 -0
  291. /package/lib/{helpers → cjs/helpers}/metadata.js +0 -0
  292. /package/lib/{helpers → cjs/helpers}/slippage.d.ts +0 -0
  293. /package/lib/{types → cjs/types}/action.js +0 -0
  294. /package/lib/{types → cjs/types}/client.js +0 -0
  295. /package/lib/{types → cjs/types}/data.d.ts +0 -0
  296. /package/lib/{types → cjs/types}/data.js +0 -0
  297. /package/lib/{types → cjs/types}/deallocation.d.ts +0 -0
  298. /package/lib/{types → cjs/types}/deallocation.js +0 -0
  299. /package/lib/{types → cjs/types}/entity.d.ts +0 -0
  300. /package/lib/{types → cjs/types}/entity.js +0 -0
  301. /package/lib/{types → cjs/types}/metadata.d.ts +0 -0
  302. /package/lib/{types → cjs/types}/metadata.js +0 -0
  303. /package/lib/{types → cjs/types}/sharedLiquidity.d.ts +0 -0
  304. /package/lib/{types → cjs/types}/sharedLiquidity.js +0 -0
@@ -4,14 +4,15 @@ exports.MorphoVaultV1 = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
6
6
  const viem_1 = require("viem");
7
- const actions_1 = require("../../actions");
8
- const helpers_1 = require("../../helpers");
9
- const constant_1 = require("../../helpers/constant");
10
- const types_1 = require("../../types");
7
+ const index_js_1 = require("../../actions/index.js");
8
+ const constant_js_1 = require("../../helpers/constant.js");
9
+ const index_js_2 = require("../../helpers/index.js");
10
+ const index_js_3 = require("../../types/index.js");
11
11
  class MorphoVaultV1 {
12
12
  client;
13
13
  vault;
14
14
  chainId;
15
+ // biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
15
16
  constructor(client, vault, chainId) {
16
17
  this.client = client;
17
18
  this.vault = vault;
@@ -20,7 +21,7 @@ class MorphoVaultV1 {
20
21
  async getData(parameters) {
21
22
  if (this.client.viemClient.chain?.id &&
22
23
  this.client.viemClient.chain?.id !== this.chainId) {
23
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
24
+ throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
24
25
  }
25
26
  return (0, blue_sdk_viem_1.fetchAccrualVault)(this.vault, this.client.viemClient, {
26
27
  ...parameters,
@@ -30,43 +31,43 @@ class MorphoVaultV1 {
30
31
  }
31
32
  deposit({ amount = 0n, userAddress, accrualVault, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, nativeAmount, }) {
32
33
  if (this.client.viemClient.chain?.id !== this.chainId) {
33
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
34
+ throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
34
35
  }
35
36
  if (!(0, viem_1.isAddressEqual)(accrualVault.address, this.vault)) {
36
- throw new types_1.VaultAddressMismatchError(this.vault, accrualVault.address);
37
+ throw new index_js_3.VaultAddressMismatchError(this.vault, accrualVault.address);
37
38
  }
38
39
  if (amount < 0n) {
39
- throw new types_1.NonPositiveAssetAmountError(this.vault);
40
+ throw new index_js_3.NonPositiveAssetAmountError(this.vault);
40
41
  }
41
42
  if (nativeAmount && nativeAmount < 0n) {
42
- throw new types_1.NegativeNativeAmountError(nativeAmount);
43
+ throw new index_js_3.NegativeNativeAmountError(nativeAmount);
43
44
  }
44
45
  let wNative;
45
46
  if (nativeAmount) {
46
47
  ({ wNative } = (0, blue_sdk_1.getChainAddresses)(this.chainId));
47
48
  if (!wNative) {
48
- throw new types_1.ChainWNativeMissingError(this.chainId);
49
+ throw new index_js_3.ChainWNativeMissingError(this.chainId);
49
50
  }
50
51
  }
51
52
  if (slippageTolerance < 0n) {
52
- throw new types_1.NegativeSlippageToleranceError(slippageTolerance);
53
+ throw new index_js_3.NegativeSlippageToleranceError(slippageTolerance);
53
54
  }
54
- if (slippageTolerance > constant_1.MAX_SLIPPAGE_TOLERANCE) {
55
- throw new types_1.ExcessiveSlippageToleranceError(slippageTolerance);
55
+ if (slippageTolerance > constant_js_1.MAX_SLIPPAGE_TOLERANCE) {
56
+ throw new index_js_3.ExcessiveSlippageToleranceError(slippageTolerance);
56
57
  }
57
58
  if (nativeAmount && wNative) {
58
59
  if (!(0, viem_1.isAddressEqual)(accrualVault.asset, wNative)) {
59
- throw new types_1.NativeAmountOnNonWNativeVaultError(accrualVault.asset, wNative);
60
+ throw new index_js_3.NativeAmountOnNonWNativeVaultError(accrualVault.asset, wNative);
60
61
  }
61
62
  }
62
63
  const totalAssets = amount + (nativeAmount ?? 0n);
63
64
  const shares = accrualVault.toShares(totalAssets);
64
65
  if (shares <= 0n) {
65
- throw new types_1.NonPositiveSharesAmountError(this.vault);
66
+ throw new index_js_3.NonPositiveSharesAmountError(this.vault);
66
67
  }
67
- const maxSharePrice = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(totalAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippageTolerance), shares), constant_1.MAX_ABSOLUTE_SHARE_PRICE);
68
+ const maxSharePrice = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(totalAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippageTolerance), shares), constant_js_1.MAX_ABSOLUTE_SHARE_PRICE);
68
69
  return {
69
- getRequirements: async (params) => await (0, actions_1.getRequirements)(this.client.viemClient, {
70
+ getRequirements: async (params) => await (0, index_js_1.getRequirements)(this.client.viemClient, {
70
71
  address: accrualVault.asset,
71
72
  chainId: this.chainId,
72
73
  supportSignature: this.client.options.supportSignature,
@@ -77,7 +78,7 @@ class MorphoVaultV1 {
77
78
  from: userAddress,
78
79
  },
79
80
  }),
80
- buildTx: (requirementSignature) => (0, actions_1.vaultV1Deposit)({
81
+ buildTx: (requirementSignature) => (0, index_js_1.vaultV1Deposit)({
81
82
  vault: {
82
83
  chainId: this.chainId,
83
84
  address: this.vault,
@@ -96,10 +97,10 @@ class MorphoVaultV1 {
96
97
  }
97
98
  withdraw({ amount, userAddress }) {
98
99
  if (this.client.viemClient.chain?.id !== this.chainId) {
99
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
100
+ throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
100
101
  }
101
102
  return {
102
- buildTx: () => (0, actions_1.vaultV1Withdraw)({
103
+ buildTx: () => (0, index_js_1.vaultV1Withdraw)({
103
104
  vault: { address: this.vault },
104
105
  args: {
105
106
  amount,
@@ -112,10 +113,10 @@ class MorphoVaultV1 {
112
113
  }
113
114
  redeem({ shares, userAddress }) {
114
115
  if (this.client.viemClient.chain?.id !== this.chainId) {
115
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
116
+ throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
116
117
  }
117
118
  return {
118
- buildTx: () => (0, actions_1.vaultV1Redeem)({
119
+ buildTx: () => (0, index_js_1.vaultV1Redeem)({
119
120
  vault: { address: this.vault },
120
121
  args: {
121
122
  shares,
@@ -127,22 +128,22 @@ class MorphoVaultV1 {
127
128
  };
128
129
  }
129
130
  migrateToV2({ userAddress, sourceVault, targetVault, shares, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, }) {
130
- (0, helpers_1.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
131
- (0, helpers_1.validateUserAddress)(this.client.viemClient.account?.address, userAddress);
131
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
132
+ (0, index_js_2.validateUserAddress)(this.client.viemClient.account?.address, userAddress);
132
133
  if (!(0, viem_1.isAddressEqual)(sourceVault.address, this.vault)) {
133
- throw new types_1.VaultAddressMismatchError(this.vault, sourceVault.address);
134
+ throw new index_js_3.VaultAddressMismatchError(this.vault, sourceVault.address);
134
135
  }
135
136
  if (!(0, viem_1.isAddressEqual)(sourceVault.asset, targetVault.asset)) {
136
- throw new types_1.VaultAssetMismatchError(sourceVault.asset, targetVault.asset);
137
+ throw new index_js_3.VaultAssetMismatchError(sourceVault.asset, targetVault.asset);
137
138
  }
138
139
  if (shares <= 0n) {
139
- throw new types_1.NonPositiveSharesAmountError(this.vault);
140
+ throw new index_js_3.NonPositiveSharesAmountError(this.vault);
140
141
  }
141
142
  if (slippageTolerance < 0n) {
142
- throw new types_1.NegativeSlippageToleranceError(slippageTolerance);
143
+ throw new index_js_3.NegativeSlippageToleranceError(slippageTolerance);
143
144
  }
144
- if (slippageTolerance > constant_1.MAX_SLIPPAGE_TOLERANCE) {
145
- throw new types_1.ExcessiveSlippageToleranceError(slippageTolerance);
145
+ if (slippageTolerance > constant_js_1.MAX_SLIPPAGE_TOLERANCE) {
146
+ throw new index_js_3.ExcessiveSlippageToleranceError(slippageTolerance);
146
147
  }
147
148
  // Compute minSharePriceVaultV1 for V1 redeem (slippage downward)
148
149
  const v1RefAssets = sourceVault.toAssets(shares);
@@ -150,28 +151,31 @@ class MorphoVaultV1 {
150
151
  // Compute maxSharePriceVaultV2 for V2 deposit (slippage upward)
151
152
  const v2RefShares = targetVault.toShares(v1RefAssets);
152
153
  if (v2RefShares <= 0n) {
153
- throw new types_1.NonPositiveSharesAmountError(targetVault.address);
154
+ throw new index_js_3.NonPositiveSharesAmountError(targetVault.address);
154
155
  }
155
- const maxSharePriceVaultV2 = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(v1RefAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippageTolerance), v2RefShares), constant_1.MAX_ABSOLUTE_SHARE_PRICE);
156
+ const maxSharePriceVaultV2 = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(v1RefAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippageTolerance), v2RefShares), constant_js_1.MAX_ABSOLUTE_SHARE_PRICE);
156
157
  return {
157
- getRequirements: async (params) => await (0, actions_1.getRequirements)(this.client.viemClient, {
158
+ getRequirements: async () => await (0, index_js_1.getRequirements)(this.client.viemClient, {
158
159
  address: this.vault,
159
160
  chainId: this.chainId,
160
161
  supportSignature: this.client.options.supportSignature,
161
162
  supportDeployless: this.client.options.supportDeployless,
162
- useSimplePermit: params?.useSimplePermit,
163
+ // V1 shares always implement EIP-2612.
164
+ useSimplePermit: true,
163
165
  args: {
164
166
  amount: shares,
165
167
  from: userAddress,
166
168
  },
167
169
  }),
168
- buildTx: (requirementSignature) => (0, actions_1.vaultV1MigrateToV2)({
170
+ buildTx: (requirementSignature) => (0, index_js_1.vaultV1MigrateToV2)({
169
171
  vault: {
170
172
  chainId: this.chainId,
171
173
  address: this.vault,
174
+ asset: sourceVault.asset,
172
175
  },
173
176
  args: {
174
177
  targetVault: targetVault.address,
178
+ targetAsset: targetVault.asset,
175
179
  shares,
176
180
  minSharePriceVaultV1,
177
181
  maxSharePriceVaultV2,
@@ -0,0 +1 @@
1
+ export * from "./vaultV2.js";
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./vaultV2"), exports);
17
+ __exportStar(require("./vaultV2.js"), exports);
@@ -1,8 +1,8 @@
1
1
  import { type AccrualVaultV2 } from "@morpho-org/blue-sdk";
2
2
  import { fetchAccrualVaultV2 } from "@morpho-org/blue-sdk-viem";
3
3
  import { type Address } from "viem";
4
- import { type Deallocation, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type Requirement, type RequirementSignature, type Transaction, type VaultV2DepositAction, type VaultV2ForceRedeemAction, type VaultV2ForceWithdrawAction, type VaultV2RedeemAction, type VaultV2WithdrawAction } from "../../types";
5
- import type { FetchParameters } from "../../types/data";
4
+ import type { FetchParameters } from "../../types/data.js";
5
+ import { type Deallocation, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type Requirement, type RequirementSignature, type Transaction, type VaultV2DepositAction, type VaultV2ForceRedeemAction, type VaultV2ForceWithdrawAction, type VaultV2RedeemAction, type VaultV2WithdrawAction } from "../../types/index.js";
6
6
  export interface VaultV2Actions {
7
7
  /**
8
8
  * Fetches the latest vault data.
@@ -4,13 +4,14 @@ exports.MorphoVaultV2 = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
6
6
  const viem_1 = require("viem");
7
- const actions_1 = require("../../actions");
8
- const constant_1 = require("../../helpers/constant");
9
- const types_1 = require("../../types");
7
+ const index_js_1 = require("../../actions/index.js");
8
+ const constant_js_1 = require("../../helpers/constant.js");
9
+ const index_js_2 = require("../../types/index.js");
10
10
  class MorphoVaultV2 {
11
11
  client;
12
12
  vault;
13
13
  chainId;
14
+ // biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
14
15
  constructor(client, vault, chainId) {
15
16
  this.client = client;
16
17
  this.vault = vault;
@@ -19,7 +20,7 @@ class MorphoVaultV2 {
19
20
  async getData(parameters) {
20
21
  if (this.client.viemClient.chain?.id &&
21
22
  this.client.viemClient.chain?.id !== this.chainId) {
22
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
23
+ throw new index_js_2.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
23
24
  }
24
25
  return (0, blue_sdk_viem_1.fetchAccrualVaultV2)(this.vault, this.client.viemClient, {
25
26
  ...parameters,
@@ -29,43 +30,43 @@ class MorphoVaultV2 {
29
30
  }
30
31
  deposit({ amount = 0n, userAddress, accrualVault, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, nativeAmount, }) {
31
32
  if (this.client.viemClient.chain?.id !== this.chainId) {
32
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
33
+ throw new index_js_2.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
33
34
  }
34
35
  if (!(0, viem_1.isAddressEqual)(accrualVault.address, this.vault)) {
35
- throw new types_1.VaultAddressMismatchError(this.vault, accrualVault.address);
36
+ throw new index_js_2.VaultAddressMismatchError(this.vault, accrualVault.address);
36
37
  }
37
38
  if (amount < 0n) {
38
- throw new types_1.NonPositiveAssetAmountError(this.vault);
39
+ throw new index_js_2.NonPositiveAssetAmountError(this.vault);
39
40
  }
40
41
  if (nativeAmount && nativeAmount < 0n) {
41
- throw new types_1.NegativeNativeAmountError(nativeAmount);
42
+ throw new index_js_2.NegativeNativeAmountError(nativeAmount);
42
43
  }
43
44
  let wNative;
44
45
  if (nativeAmount) {
45
46
  ({ wNative } = (0, blue_sdk_1.getChainAddresses)(this.chainId));
46
47
  if (!wNative) {
47
- throw new types_1.ChainWNativeMissingError(this.chainId);
48
+ throw new index_js_2.ChainWNativeMissingError(this.chainId);
48
49
  }
49
50
  }
50
51
  if (slippageTolerance < 0n) {
51
- throw new types_1.NegativeSlippageToleranceError(slippageTolerance);
52
+ throw new index_js_2.NegativeSlippageToleranceError(slippageTolerance);
52
53
  }
53
- if (slippageTolerance > constant_1.MAX_SLIPPAGE_TOLERANCE) {
54
- throw new types_1.ExcessiveSlippageToleranceError(slippageTolerance);
54
+ if (slippageTolerance > constant_js_1.MAX_SLIPPAGE_TOLERANCE) {
55
+ throw new index_js_2.ExcessiveSlippageToleranceError(slippageTolerance);
55
56
  }
56
57
  if (nativeAmount && wNative) {
57
58
  if (!(0, viem_1.isAddressEqual)(accrualVault.asset, wNative)) {
58
- throw new types_1.NativeAmountOnNonWNativeVaultError(accrualVault.asset, wNative);
59
+ throw new index_js_2.NativeAmountOnNonWNativeVaultError(accrualVault.asset, wNative);
59
60
  }
60
61
  }
61
62
  const totalAssets = amount + (nativeAmount ?? 0n);
62
63
  const shares = accrualVault.toShares(totalAssets);
63
64
  if (shares <= 0n) {
64
- throw new types_1.NonPositiveSharesAmountError(this.vault);
65
+ throw new index_js_2.NonPositiveSharesAmountError(this.vault);
65
66
  }
66
67
  const maxSharePrice = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(totalAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippageTolerance), shares), blue_sdk_1.MathLib.RAY * 100n);
67
68
  return {
68
- getRequirements: async (params) => await (0, actions_1.getRequirements)(this.client.viemClient, {
69
+ getRequirements: async (params) => await (0, index_js_1.getRequirements)(this.client.viemClient, {
69
70
  address: accrualVault.asset,
70
71
  chainId: this.chainId,
71
72
  supportSignature: this.client.options.supportSignature,
@@ -76,7 +77,7 @@ class MorphoVaultV2 {
76
77
  from: userAddress,
77
78
  },
78
79
  }),
79
- buildTx: (requirementSignature) => (0, actions_1.vaultV2Deposit)({
80
+ buildTx: (requirementSignature) => (0, index_js_1.vaultV2Deposit)({
80
81
  vault: {
81
82
  chainId: this.chainId,
82
83
  address: this.vault,
@@ -95,10 +96,10 @@ class MorphoVaultV2 {
95
96
  }
96
97
  withdraw({ amount, userAddress }) {
97
98
  if (this.client.viemClient.chain?.id !== this.chainId) {
98
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
99
+ throw new index_js_2.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
99
100
  }
100
101
  return {
101
- buildTx: () => (0, actions_1.vaultV2Withdraw)({
102
+ buildTx: () => (0, index_js_1.vaultV2Withdraw)({
102
103
  vault: { address: this.vault },
103
104
  args: {
104
105
  amount,
@@ -111,10 +112,10 @@ class MorphoVaultV2 {
111
112
  }
112
113
  redeem({ shares, userAddress }) {
113
114
  if (this.client.viemClient.chain?.id !== this.chainId) {
114
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
115
+ throw new index_js_2.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
115
116
  }
116
117
  return {
117
- buildTx: () => (0, actions_1.vaultV2Redeem)({
118
+ buildTx: () => (0, index_js_1.vaultV2Redeem)({
118
119
  vault: { address: this.vault },
119
120
  args: {
120
121
  shares,
@@ -127,10 +128,10 @@ class MorphoVaultV2 {
127
128
  }
128
129
  forceWithdraw({ deallocations, withdraw, userAddress, }) {
129
130
  if (this.client.viemClient.chain?.id !== this.chainId) {
130
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
131
+ throw new index_js_2.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
131
132
  }
132
133
  return {
133
- buildTx: () => (0, actions_1.vaultV2ForceWithdraw)({
134
+ buildTx: () => (0, index_js_1.vaultV2ForceWithdraw)({
134
135
  vault: { address: this.vault },
135
136
  args: {
136
137
  deallocations,
@@ -146,10 +147,10 @@ class MorphoVaultV2 {
146
147
  }
147
148
  forceRedeem({ deallocations, redeem, userAddress, }) {
148
149
  if (this.client.viemClient.chain?.id !== this.chainId) {
149
- throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
150
+ throw new index_js_2.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
150
151
  }
151
152
  return {
152
- buildTx: () => (0, actions_1.vaultV2ForceRedeem)({
153
+ buildTx: () => (0, index_js_1.vaultV2ForceRedeem)({
153
154
  vault: { address: this.vault },
154
155
  args: {
155
156
  deallocations,
@@ -1,6 +1,6 @@
1
1
  import { type MarketId } from "@morpho-org/blue-sdk";
2
2
  import type { SimulationState } from "@morpho-org/simulation-sdk";
3
- import { type ReallocationComputeOptions, type VaultReallocation } from "../types";
3
+ import { type ReallocationComputeOptions, type VaultReallocation } from "../types/index.js";
4
4
  /**
5
5
  * Computes vault reallocations for a borrow operation on a target market.
6
6
  *
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.computeReallocations = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const bundler_sdk_viem_1 = require("@morpho-org/bundler-sdk-viem");
6
- const types_1 = require("../types");
6
+ const index_js_1 = require("../types/index.js");
7
7
  /**
8
8
  * Computes vault reallocations for a borrow operation on a target market.
9
9
  *
@@ -82,7 +82,7 @@ const computeReallocations = ({ reallocationData: data, marketId, borrowAmount,
82
82
  fee: (() => {
83
83
  const config = data.getVault(vault).publicAllocatorConfig;
84
84
  if (config == null) {
85
- throw new types_1.MissingPublicAllocatorConfigError(vault);
85
+ throw new index_js_1.MissingPublicAllocatorConfigError(vault);
86
86
  }
87
87
  return config.fee;
88
88
  })(),
@@ -1,5 +1,5 @@
1
1
  import { type Address, type Hex } from "viem";
2
- import { type Deallocation } from "../types";
2
+ import { type Deallocation } from "../types/index.js";
3
3
  /**
4
4
  * Encodes a single `forceDeallocate` call as ABI-encoded calldata.
5
5
  *
@@ -4,7 +4,7 @@ exports.encodeForceDeallocateCall = encodeForceDeallocateCall;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
6
6
  const viem_1 = require("viem");
7
- const types_1 = require("../types");
7
+ const index_js_1 = require("../types/index.js");
8
8
  /**
9
9
  * Encodes the adapter-specific `data` bytes for a `forceDeallocate` call.
10
10
  *
@@ -26,7 +26,7 @@ function encodeDeallocateData(deallocation) {
26
26
  */
27
27
  function encodeForceDeallocateCall(deallocation, onBehalf) {
28
28
  if (deallocation.amount <= 0n) {
29
- throw new types_1.NonPositiveAssetAmountError(deallocation.adapter);
29
+ throw new index_js_1.NonPositiveAssetAmountError(deallocation.adapter);
30
30
  }
31
31
  const data = encodeDeallocateData(deallocation);
32
32
  return (0, viem_1.encodeFunctionData)({
@@ -1,4 +1,4 @@
1
- export { computeReallocations } from "./computeReallocations";
2
- export { addTransactionMetadata } from "./metadata";
3
- export { computeMaxRepaySharePrice, computeMinBorrowSharePrice, } from "./slippage";
4
- export { validateAccrualPosition, validateChainId, validateNativeCollateral, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayParams, validateRepayShares, validateSlippageTolerance, validateUserAddress, } from "./validate";
1
+ export { computeReallocations } from "./computeReallocations.js";
2
+ export { addTransactionMetadata } from "./metadata.js";
3
+ export { computeMaxRepaySharePrice, computeMinBorrowSharePrice, } from "./slippage.js";
4
+ export { validateAccrualPosition, validateChainId, validateNativeCollateral, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayParams, validateRepayShares, validateSlippageTolerance, validateUserAddress, } from "./validate.js";
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayParams = exports.validateRepayAmount = exports.validateReallocations = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeCollateral = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinBorrowSharePrice = exports.computeMaxRepaySharePrice = exports.addTransactionMetadata = exports.computeReallocations = void 0;
4
- var computeReallocations_1 = require("./computeReallocations");
5
- Object.defineProperty(exports, "computeReallocations", { enumerable: true, get: function () { return computeReallocations_1.computeReallocations; } });
6
- var metadata_1 = require("./metadata");
7
- Object.defineProperty(exports, "addTransactionMetadata", { enumerable: true, get: function () { return metadata_1.addTransactionMetadata; } });
8
- var slippage_1 = require("./slippage");
9
- Object.defineProperty(exports, "computeMaxRepaySharePrice", { enumerable: true, get: function () { return slippage_1.computeMaxRepaySharePrice; } });
10
- Object.defineProperty(exports, "computeMinBorrowSharePrice", { enumerable: true, get: function () { return slippage_1.computeMinBorrowSharePrice; } });
11
- var validate_1 = require("./validate");
12
- Object.defineProperty(exports, "validateAccrualPosition", { enumerable: true, get: function () { return validate_1.validateAccrualPosition; } });
13
- Object.defineProperty(exports, "validateChainId", { enumerable: true, get: function () { return validate_1.validateChainId; } });
14
- Object.defineProperty(exports, "validateNativeCollateral", { enumerable: true, get: function () { return validate_1.validateNativeCollateral; } });
15
- Object.defineProperty(exports, "validatePositionHealth", { enumerable: true, get: function () { return validate_1.validatePositionHealth; } });
16
- Object.defineProperty(exports, "validatePositionHealthAfterWithdraw", { enumerable: true, get: function () { return validate_1.validatePositionHealthAfterWithdraw; } });
17
- Object.defineProperty(exports, "validateReallocations", { enumerable: true, get: function () { return validate_1.validateReallocations; } });
18
- Object.defineProperty(exports, "validateRepayAmount", { enumerable: true, get: function () { return validate_1.validateRepayAmount; } });
19
- Object.defineProperty(exports, "validateRepayParams", { enumerable: true, get: function () { return validate_1.validateRepayParams; } });
20
- Object.defineProperty(exports, "validateRepayShares", { enumerable: true, get: function () { return validate_1.validateRepayShares; } });
21
- Object.defineProperty(exports, "validateSlippageTolerance", { enumerable: true, get: function () { return validate_1.validateSlippageTolerance; } });
22
- Object.defineProperty(exports, "validateUserAddress", { enumerable: true, get: function () { return validate_1.validateUserAddress; } });
4
+ var computeReallocations_js_1 = require("./computeReallocations.js");
5
+ Object.defineProperty(exports, "computeReallocations", { enumerable: true, get: function () { return computeReallocations_js_1.computeReallocations; } });
6
+ var metadata_js_1 = require("./metadata.js");
7
+ Object.defineProperty(exports, "addTransactionMetadata", { enumerable: true, get: function () { return metadata_js_1.addTransactionMetadata; } });
8
+ var slippage_js_1 = require("./slippage.js");
9
+ Object.defineProperty(exports, "computeMaxRepaySharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMaxRepaySharePrice; } });
10
+ Object.defineProperty(exports, "computeMinBorrowSharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMinBorrowSharePrice; } });
11
+ var validate_js_1 = require("./validate.js");
12
+ Object.defineProperty(exports, "validateAccrualPosition", { enumerable: true, get: function () { return validate_js_1.validateAccrualPosition; } });
13
+ Object.defineProperty(exports, "validateChainId", { enumerable: true, get: function () { return validate_js_1.validateChainId; } });
14
+ Object.defineProperty(exports, "validateNativeCollateral", { enumerable: true, get: function () { return validate_js_1.validateNativeCollateral; } });
15
+ Object.defineProperty(exports, "validatePositionHealth", { enumerable: true, get: function () { return validate_js_1.validatePositionHealth; } });
16
+ Object.defineProperty(exports, "validatePositionHealthAfterWithdraw", { enumerable: true, get: function () { return validate_js_1.validatePositionHealthAfterWithdraw; } });
17
+ Object.defineProperty(exports, "validateReallocations", { enumerable: true, get: function () { return validate_js_1.validateReallocations; } });
18
+ Object.defineProperty(exports, "validateRepayAmount", { enumerable: true, get: function () { return validate_js_1.validateRepayAmount; } });
19
+ Object.defineProperty(exports, "validateRepayParams", { enumerable: true, get: function () { return validate_js_1.validateRepayParams; } });
20
+ Object.defineProperty(exports, "validateRepayShares", { enumerable: true, get: function () { return validate_js_1.validateRepayShares; } });
21
+ Object.defineProperty(exports, "validateSlippageTolerance", { enumerable: true, get: function () { return validate_js_1.validateSlippageTolerance; } });
22
+ Object.defineProperty(exports, "validateUserAddress", { enumerable: true, get: function () { return validate_js_1.validateUserAddress; } });
@@ -1,5 +1,5 @@
1
1
  import { type Address, type Hex } from "viem";
2
- import type { Metadata } from "../types";
2
+ import type { Metadata } from "../types/index.js";
3
3
  /**
4
4
  * Adds metadata to a transaction object by concatenating additional
5
5
  * hex-encoded data to the transaction's `data` field. The additional
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.computeMinBorrowSharePrice = computeMinBorrowSharePrice;
4
4
  exports.computeMaxRepaySharePrice = computeMaxRepaySharePrice;
5
5
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
6
- const types_1 = require("../types");
7
- const constant_1 = require("./constant");
6
+ const index_js_1 = require("../types/index.js");
7
+ const constant_js_1 = require("./constant.js");
8
8
  /**
9
9
  * Computes the minimum borrow share price (in RAY, 1e27) for slippage protection.
10
10
  *
@@ -22,11 +22,11 @@ const constant_1 = require("./constant");
22
22
  function computeMinBorrowSharePrice(params) {
23
23
  const { borrowAmount, market, slippageTolerance } = params;
24
24
  if (slippageTolerance >= blue_sdk_1.MathLib.WAD) {
25
- throw new types_1.ExcessiveSlippageToleranceError(slippageTolerance);
25
+ throw new index_js_1.ExcessiveSlippageToleranceError(slippageTolerance);
26
26
  }
27
27
  const expectedShares = market.toBorrowShares(borrowAmount, "Up");
28
28
  if (expectedShares === 0n) {
29
- throw new types_1.ShareDivideByZeroError(market.params.id);
29
+ throw new index_js_1.ShareDivideByZeroError(market.params.id);
30
30
  }
31
31
  return blue_sdk_1.MathLib.mulDivDown(borrowAmount, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippageTolerance), expectedShares);
32
32
  }
@@ -53,7 +53,7 @@ function computeMinBorrowSharePrice(params) {
53
53
  function computeMaxRepaySharePrice(params) {
54
54
  const { repayAssets, repayShares, market, slippageTolerance } = params;
55
55
  if (slippageTolerance >= blue_sdk_1.MathLib.WAD) {
56
- throw new types_1.ExcessiveSlippageToleranceError(slippageTolerance);
56
+ throw new index_js_1.ExcessiveSlippageToleranceError(slippageTolerance);
57
57
  }
58
58
  let assets;
59
59
  let shares;
@@ -66,8 +66,8 @@ function computeMaxRepaySharePrice(params) {
66
66
  shares = market.toBorrowShares(repayAssets, "Down");
67
67
  }
68
68
  if (shares === 0n) {
69
- throw new types_1.ShareDivideByZeroError(market.params.id);
69
+ throw new index_js_1.ShareDivideByZeroError(market.params.id);
70
70
  }
71
71
  const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(assets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippageTolerance), shares);
72
- return blue_sdk_1.MathLib.min(maxSharePrice, constant_1.MAX_ABSOLUTE_SHARE_PRICE);
72
+ return blue_sdk_1.MathLib.min(maxSharePrice, constant_js_1.MAX_ABSOLUTE_SHARE_PRICE);
73
73
  }
@@ -1,6 +1,6 @@
1
1
  import { type AccrualPosition, type MarketId } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
- import { type VaultReallocation } from "../types";
3
+ import { type VaultReallocation } from "../types/index.js";
4
4
  /**
5
5
  * Validates that the client has a connected account AND that it matches
6
6
  * the provided user address.