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

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 (277) hide show
  1. package/MIGRATION-v5-to-v6.md +88 -32
  2. package/README.md +9 -7
  3. package/lib/cjs/abis.d.ts +7 -2844
  4. package/lib/cjs/abis.js +3 -1951
  5. package/lib/cjs/actions/blue/borrow.d.ts +3 -2
  6. package/lib/cjs/actions/blue/borrow.js +3 -2
  7. package/lib/cjs/actions/blue/common.js +1 -9
  8. package/lib/cjs/actions/blue/refinance.d.ts +2 -2
  9. package/lib/cjs/actions/blue/refinance.js +2 -2
  10. package/lib/cjs/actions/blue/repay.d.ts +1 -1
  11. package/lib/cjs/actions/blue/repay.js +1 -1
  12. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
  14. package/lib/cjs/actions/blue/supply.d.ts +2 -2
  15. package/lib/cjs/actions/blue/supply.js +2 -2
  16. package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -2
  17. package/lib/cjs/actions/blue/supplyCollateral.js +2 -2
  18. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +3 -2
  20. package/lib/cjs/actions/blue/withdraw.d.ts +3 -3
  21. package/lib/cjs/actions/blue/withdraw.js +3 -3
  22. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +2 -2
  23. package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
  24. package/lib/cjs/actions/bundles/common.d.ts +6 -2
  25. package/lib/cjs/actions/bundles/common.js +31 -5
  26. package/lib/cjs/actions/index.d.ts +0 -1
  27. package/lib/cjs/actions/index.js +0 -1
  28. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
  29. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -16
  30. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
  31. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
  32. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  33. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +4 -5
  34. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
  35. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +6 -11
  36. package/lib/cjs/actions/requirements/encode/index.d.ts +0 -1
  37. package/lib/cjs/actions/requirements/encode/index.js +0 -1
  38. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -6
  39. package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -6
  40. package/lib/cjs/actions/requirements/index.d.ts +0 -1
  41. package/lib/cjs/actions/requirements/index.js +0 -1
  42. package/lib/cjs/actions/vaultV1/deposit.d.ts +1 -2
  43. package/lib/cjs/actions/vaultV1/deposit.js +1 -2
  44. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +7 -5
  45. package/lib/cjs/actions/vaultV1/inKindRedeem.js +11 -7
  46. package/lib/cjs/actions/vaultV2/deposit.d.ts +1 -2
  47. package/lib/cjs/actions/vaultV2/deposit.js +1 -2
  48. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
  49. package/lib/cjs/actions/vaultV2/forceWithdraw.js +3 -3
  50. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +7 -5
  51. package/lib/cjs/actions/vaultV2/inKindRedeem.js +11 -7
  52. package/lib/cjs/augment/AccrualPosition.d.ts +1 -0
  53. package/lib/cjs/augment.d.ts +0 -1
  54. package/lib/cjs/augment.js +0 -1
  55. package/lib/cjs/blue/abis.d.ts +5 -5
  56. package/lib/cjs/blue/abis.js +3 -7
  57. package/lib/cjs/blue/entities.d.ts +10 -8
  58. package/lib/cjs/blue/entities.js +3 -3
  59. package/lib/cjs/blue/errors.d.ts +4 -2
  60. package/lib/cjs/blue/errors.js +3 -1
  61. package/lib/cjs/blue/fetch.d.ts +5 -3
  62. package/lib/cjs/blue/fetch.js +3 -3
  63. package/lib/cjs/blue/types.d.ts +2 -4
  64. package/lib/cjs/blue/utils.d.ts +6 -4
  65. package/lib/cjs/blue/utils.js +3 -3
  66. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  67. package/lib/cjs/client/morphoViemExtension.js +1 -1
  68. package/lib/cjs/constants.d.ts +3 -37
  69. package/lib/cjs/constants.js +1 -39
  70. package/lib/cjs/entities/blue/blue.d.ts +30 -265
  71. package/lib/cjs/entities/blue/blue.js +1 -205
  72. package/lib/cjs/entities/index.d.ts +11 -66
  73. package/lib/cjs/entities/index.js +3 -21
  74. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
  75. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
  76. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +13 -5
  77. package/lib/cjs/entities/vaultV1/vaultV1.js +16 -10
  78. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +40 -19
  79. package/lib/cjs/entities/vaultV2/vaultV2.js +57 -26
  80. package/lib/cjs/entities/vaultV2BlueReallocationData.js +4 -21
  81. package/lib/cjs/errors.d.ts +5 -47
  82. package/lib/cjs/errors.js +4 -46
  83. package/lib/cjs/fetch.d.ts +5 -17
  84. package/lib/cjs/fetch.js +3 -17
  85. package/lib/cjs/helpers/constant.d.ts +0 -2
  86. package/lib/cjs/helpers/constant.js +0 -2
  87. package/lib/cjs/helpers/index.d.ts +2 -3
  88. package/lib/cjs/helpers/index.js +1 -9
  89. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +11 -5
  90. package/lib/cjs/helpers/slippage.d.ts +1 -103
  91. package/lib/cjs/helpers/slippage.js +0 -150
  92. package/lib/cjs/helpers/utilization.d.ts +12 -10
  93. package/lib/cjs/helpers/utilization.js +27 -12
  94. package/lib/cjs/helpers/validate.d.ts +1 -24
  95. package/lib/cjs/helpers/validate.js +2 -49
  96. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  97. package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
  98. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
  99. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +48 -15
  100. package/lib/cjs/midnight/errors.d.ts +1 -1
  101. package/lib/cjs/midnight/errors.js +2 -1
  102. package/lib/cjs/types/action.d.ts +17 -65
  103. package/lib/cjs/types/action.js +11 -4
  104. package/lib/cjs/types/error.d.ts +50 -381
  105. package/lib/cjs/types/error.js +64 -395
  106. package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
  107. package/lib/cjs/types.d.ts +2 -18
  108. package/lib/cjs/utils.d.ts +10 -35
  109. package/lib/cjs/utils.js +4 -36
  110. package/lib/esm/abis.d.ts +7 -2844
  111. package/lib/esm/abis.js +7 -1950
  112. package/lib/esm/actions/blue/borrow.d.ts +3 -2
  113. package/lib/esm/actions/blue/borrow.js +3 -2
  114. package/lib/esm/actions/blue/common.js +1 -9
  115. package/lib/esm/actions/blue/refinance.d.ts +2 -2
  116. package/lib/esm/actions/blue/refinance.js +2 -2
  117. package/lib/esm/actions/blue/repay.d.ts +1 -1
  118. package/lib/esm/actions/blue/repay.js +1 -1
  119. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  120. package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
  121. package/lib/esm/actions/blue/supply.d.ts +2 -2
  122. package/lib/esm/actions/blue/supply.js +2 -2
  123. package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -2
  124. package/lib/esm/actions/blue/supplyCollateral.js +2 -2
  125. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  126. package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -2
  127. package/lib/esm/actions/blue/withdraw.d.ts +3 -3
  128. package/lib/esm/actions/blue/withdraw.js +3 -3
  129. package/lib/esm/actions/blue/withdrawCollateral.d.ts +2 -2
  130. package/lib/esm/actions/blue/withdrawCollateral.js +2 -2
  131. package/lib/esm/actions/bundles/common.d.ts +6 -2
  132. package/lib/esm/actions/bundles/common.js +32 -6
  133. package/lib/esm/actions/index.d.ts +0 -1
  134. package/lib/esm/actions/index.js +0 -1
  135. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
  136. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +12 -17
  137. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
  138. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
  139. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  140. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +4 -5
  141. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
  142. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +6 -11
  143. package/lib/esm/actions/requirements/encode/index.d.ts +0 -1
  144. package/lib/esm/actions/requirements/encode/index.js +0 -1
  145. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -6
  146. package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -6
  147. package/lib/esm/actions/requirements/index.d.ts +0 -1
  148. package/lib/esm/actions/requirements/index.js +0 -1
  149. package/lib/esm/actions/vaultV1/deposit.d.ts +1 -2
  150. package/lib/esm/actions/vaultV1/deposit.js +1 -2
  151. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +7 -5
  152. package/lib/esm/actions/vaultV1/inKindRedeem.js +11 -7
  153. package/lib/esm/actions/vaultV2/deposit.d.ts +1 -2
  154. package/lib/esm/actions/vaultV2/deposit.js +1 -2
  155. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  156. package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
  157. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +7 -5
  158. package/lib/esm/actions/vaultV2/inKindRedeem.js +11 -7
  159. package/lib/esm/augment/AccrualPosition.d.ts +1 -0
  160. package/lib/esm/augment.d.ts +0 -1
  161. package/lib/esm/augment.js +0 -1
  162. package/lib/esm/blue/abis.d.ts +5 -5
  163. package/lib/esm/blue/abis.js +5 -5
  164. package/lib/esm/blue/entities.d.ts +10 -8
  165. package/lib/esm/blue/entities.js +5 -3
  166. package/lib/esm/blue/errors.d.ts +4 -2
  167. package/lib/esm/blue/errors.js +4 -2
  168. package/lib/esm/blue/fetch.d.ts +5 -3
  169. package/lib/esm/blue/fetch.js +5 -3
  170. package/lib/esm/blue/types.d.ts +2 -4
  171. package/lib/esm/blue/utils.d.ts +6 -4
  172. package/lib/esm/blue/utils.js +6 -4
  173. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  174. package/lib/esm/client/morphoViemExtension.js +1 -1
  175. package/lib/esm/constants.d.ts +3 -37
  176. package/lib/esm/constants.js +3 -37
  177. package/lib/esm/entities/blue/blue.d.ts +30 -265
  178. package/lib/esm/entities/blue/blue.js +4 -208
  179. package/lib/esm/entities/index.d.ts +11 -66
  180. package/lib/esm/entities/index.js +5 -18
  181. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
  182. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
  183. package/lib/esm/entities/vaultV1/vaultV1.d.ts +13 -5
  184. package/lib/esm/entities/vaultV1/vaultV1.js +19 -13
  185. package/lib/esm/entities/vaultV2/vaultV2.d.ts +40 -19
  186. package/lib/esm/entities/vaultV2/vaultV2.js +61 -30
  187. package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -19
  188. package/lib/esm/errors.d.ts +5 -47
  189. package/lib/esm/errors.js +5 -47
  190. package/lib/esm/fetch.d.ts +5 -17
  191. package/lib/esm/fetch.js +5 -17
  192. package/lib/esm/helpers/constant.d.ts +0 -2
  193. package/lib/esm/helpers/constant.js +0 -2
  194. package/lib/esm/helpers/index.d.ts +2 -3
  195. package/lib/esm/helpers/index.js +2 -3
  196. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +11 -5
  197. package/lib/esm/helpers/slippage.d.ts +1 -103
  198. package/lib/esm/helpers/slippage.js +1 -147
  199. package/lib/esm/helpers/utilization.d.ts +12 -10
  200. package/lib/esm/helpers/utilization.js +26 -11
  201. package/lib/esm/helpers/validate.d.ts +1 -24
  202. package/lib/esm/helpers/validate.js +2 -48
  203. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  204. package/lib/esm/helpers/validateRequirementSpender.js +1 -3
  205. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
  206. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +48 -15
  207. package/lib/esm/midnight/errors.d.ts +1 -1
  208. package/lib/esm/midnight/errors.js +1 -1
  209. package/lib/esm/types/action.d.ts +17 -65
  210. package/lib/esm/types/action.js +12 -5
  211. package/lib/esm/types/error.d.ts +50 -381
  212. package/lib/esm/types/error.js +58 -377
  213. package/lib/esm/types/sharedLiquidity.d.ts +1 -117
  214. package/lib/esm/types.d.ts +2 -18
  215. package/lib/esm/utils.d.ts +10 -35
  216. package/lib/esm/utils.js +9 -34
  217. package/package.json +6 -17
  218. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
  219. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -88
  220. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  221. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -152
  222. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
  223. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -53
  224. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  225. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -74
  226. package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +0 -3
  227. package/lib/cjs/actions/requirements/generalAdapter/index.js +0 -19
  228. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  229. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +0 -48
  230. package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  231. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +0 -119
  232. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
  233. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -45
  234. package/lib/cjs/actions/signatures/index.d.ts +0 -3
  235. package/lib/cjs/actions/signatures/index.js +0 -19
  236. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
  237. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +0 -8
  238. package/lib/cjs/bundler/actions.d.ts +0 -797
  239. package/lib/cjs/bundler/actions.js +0 -1371
  240. package/lib/cjs/bundler/index.d.ts +0 -2
  241. package/lib/cjs/bundler/index.js +0 -18
  242. package/lib/cjs/bundler/types.d.ts +0 -235
  243. package/lib/cjs/bundler/types.js +0 -2
  244. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +0 -332
  245. package/lib/cjs/entities/vaultV1ReallocationData.js +0 -557
  246. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -80
  247. package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -245
  248. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
  249. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -84
  250. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  251. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -148
  252. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
  253. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -49
  254. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  255. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -70
  256. package/lib/esm/actions/requirements/generalAdapter/index.d.ts +0 -3
  257. package/lib/esm/actions/requirements/generalAdapter/index.js +0 -3
  258. package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  259. package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +0 -44
  260. package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  261. package/lib/esm/actions/signatures/getTokenRequirementActions.js +0 -115
  262. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
  263. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -41
  264. package/lib/esm/actions/signatures/index.d.ts +0 -3
  265. package/lib/esm/actions/signatures/index.js +0 -3
  266. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
  267. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -7
  268. package/lib/esm/bundler/actions.d.ts +0 -797
  269. package/lib/esm/bundler/actions.js +0 -1368
  270. package/lib/esm/bundler/index.d.ts +0 -2
  271. package/lib/esm/bundler/index.js +0 -2
  272. package/lib/esm/bundler/types.d.ts +0 -235
  273. package/lib/esm/bundler/types.js +0 -1
  274. package/lib/esm/entities/vaultV1ReallocationData.d.ts +0 -332
  275. package/lib/esm/entities/vaultV1ReallocationData.js +0 -559
  276. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -80
  277. package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -241
@@ -1,2 +0,0 @@
1
- export * from "./actions.js";
2
- export * from "./types.js";
@@ -1,2 +0,0 @@
1
- export * from "./actions.js";
2
- export * from "./types.js";
@@ -1,235 +0,0 @@
1
- import type { InputMarketParams } from "@morpho-org/blue-sdk";
2
- import type { Address, Hex } from "viem";
3
- /**
4
- * Morpho authorization payload signed by a user for Bundler3-mediated Morpho
5
- * Blue execution.
6
- */
7
- export interface Authorization {
8
- /** Address granting or revoking authorization. */
9
- readonly authorizer: Address;
10
- /** Address receiving authorization. */
11
- readonly authorized: Address;
12
- /** Whether authorization is granted (`true`) or revoked (`false`). */
13
- readonly isAuthorized: boolean;
14
- /** Morpho authorization nonce consumed by the signature. */
15
- readonly nonce: bigint;
16
- /** Signature deadline timestamp in seconds. */
17
- readonly deadline: bigint;
18
- }
19
- /**
20
- * Public allocator withdrawal input used by a `reallocateTo` Bundler3 action.
21
- *
22
- * @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use Vault V2
23
- * BluePublicAllocator actions.
24
- */
25
- export interface InputReallocation {
26
- /** Market to withdraw liquidity from. */
27
- readonly marketParams: InputMarketParams;
28
- /** Amount of loan assets to withdraw from the market. */
29
- readonly amount: bigint;
30
- }
31
- /**
32
- * Permit2 single-permit token allowance details.
33
- */
34
- export interface Permit2PermitSingleDetails {
35
- /** ERC20 token approved through Permit2. */
36
- readonly token: Address;
37
- /** Allowance amount approved through Permit2. */
38
- readonly amount: bigint;
39
- /** Permit2 allowance expiration timestamp in seconds. */
40
- readonly expiration: number;
41
- /** Permit2 nonce consumed by the signature. */
42
- readonly nonce: number;
43
- }
44
- /**
45
- * Permit2 single-permit payload signed by the token owner.
46
- */
47
- export interface Permit2PermitSingle {
48
- /** Token, amount, expiration, and nonce being approved. */
49
- readonly details: Permit2PermitSingleDetails;
50
- /** Deadline timestamp for consuming the Permit2 signature. */
51
- readonly sigDeadline: bigint;
52
- }
53
- /**
54
- * Argument tuples for Bundler3 actions supported by `morpho-sdk`.
55
- */
56
- export interface ActionArgs {
57
- /** Native-token transfer from `owner` to `recipient` for `amount`; `skipRevert` controls Bundler3 revert handling. */
58
- readonly nativeTransfer: [
59
- owner: Address,
60
- recipient: Address,
61
- amount: bigint,
62
- skipRevert?: boolean
63
- ];
64
- /** ERC20 transfer from `adapter` to `recipient` for `amount` of `asset`; `skipRevert` controls Bundler3 revert handling. */
65
- readonly erc20Transfer: [
66
- asset: Address,
67
- recipient: Address,
68
- amount: bigint,
69
- adapter: Address,
70
- skipRevert?: boolean
71
- ];
72
- /** GeneralAdapter1 ERC20 `transferFrom` of `asset` and `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
73
- readonly erc20TransferFrom: [
74
- asset: Address,
75
- amount: bigint,
76
- recipient: Address,
77
- skipRevert?: boolean
78
- ];
79
- /** ERC-2612 permit from `owner` for `asset`, `amount`, `deadline`, and `signature`; `skipRevert` controls Bundler3 revert handling. */
80
- readonly permit: [
81
- owner: Address,
82
- asset: Address,
83
- amount: bigint,
84
- deadline: bigint,
85
- signature: Hex | null,
86
- skipRevert?: boolean
87
- ];
88
- /** Permit2 approval from `owner` for `permitSingle` and `signature`; `skipRevert` controls Bundler3 revert handling. */
89
- readonly approve2: [
90
- owner: Address,
91
- permitSingle: Permit2PermitSingle,
92
- signature: Hex | null,
93
- skipRevert?: boolean
94
- ];
95
- /** GeneralAdapter1 Permit2 transfer of `asset` and `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
96
- readonly transferFrom2: [
97
- asset: Address,
98
- amount: bigint,
99
- recipient: Address,
100
- skipRevert?: boolean
101
- ];
102
- /** ERC4626 deposit into `erc4626` for `assets`, `maxSharePrice`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
103
- readonly erc4626Deposit: [
104
- erc4626: Address,
105
- assets: bigint,
106
- maxSharePrice: bigint,
107
- receiver: Address,
108
- skipRevert?: boolean
109
- ];
110
- /** ERC4626 redeem from `erc4626` for `shares`, `minSharePrice`, `receiver`, and `owner`; `skipRevert` controls Bundler3 revert handling. */
111
- readonly erc4626Redeem: [
112
- erc4626: Address,
113
- shares: bigint,
114
- minSharePrice: bigint,
115
- receiver: Address,
116
- owner: Address,
117
- skipRevert?: boolean
118
- ];
119
- /** Morpho Blue `setAuthorizationWithSig` call submitting a signed `authorization` and its `signature`; `skipRevert` controls Bundler3 revert handling. */
120
- readonly morphoSetAuthorizationWithSig: [
121
- authorization: Authorization,
122
- signature: Hex | null,
123
- skipRevert?: boolean
124
- ];
125
- /** Morpho Blue supply-collateral call for `market`, `assets`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
126
- readonly morphoSupplyCollateral: [
127
- market: InputMarketParams,
128
- assets: bigint,
129
- onBehalf: Address,
130
- onMorphoSupplyCollateral: Action[],
131
- skipRevert?: boolean
132
- ];
133
- /** Morpho Blue supply call for `market`, `assets` or `shares`, `slippageAmount`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
134
- readonly morphoSupply: [
135
- market: InputMarketParams,
136
- assets: bigint,
137
- shares: bigint,
138
- slippageAmount: bigint,
139
- onBehalf: Address,
140
- onMorphoSupply: Action[],
141
- skipRevert?: boolean
142
- ];
143
- /** Morpho Blue borrow call for `market`, `assets` or `shares`, `minSharePrice`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
144
- readonly morphoBorrow: [
145
- market: InputMarketParams,
146
- assets: bigint,
147
- shares: bigint,
148
- minSharePrice: bigint,
149
- receiver: Address,
150
- skipRevert?: boolean
151
- ];
152
- /** Morpho Blue repay call for `market`, `assets` or `shares`, `maxSharePrice`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
153
- readonly morphoRepay: [
154
- market: InputMarketParams,
155
- assets: bigint,
156
- shares: bigint,
157
- maxSharePrice: bigint,
158
- onBehalf: Address,
159
- onMorphoRepay: Action[],
160
- skipRevert?: boolean
161
- ];
162
- /** Morpho Blue withdraw call for `market`, `assets` or `shares`, `slippageAmount`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
163
- readonly morphoWithdraw: [
164
- market: InputMarketParams,
165
- assets: bigint,
166
- shares: bigint,
167
- slippageAmount: bigint,
168
- receiver: Address,
169
- skipRevert?: boolean
170
- ];
171
- /** Morpho Blue withdraw-collateral call for `market`, `assets`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
172
- readonly morphoWithdrawCollateral: [
173
- market: InputMarketParams,
174
- assets: bigint,
175
- receiver: Address,
176
- skipRevert?: boolean
177
- ];
178
- /**
179
- * PublicAllocator reallocation to `supplyMarket` from `vault` withdrawals while paying `fee`;
180
- * `skipRevert` controls Bundler3 revert handling.
181
- *
182
- * @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use Vault V2
183
- * BluePublicAllocator actions.
184
- */
185
- readonly reallocateTo: [
186
- vault: Address,
187
- fee: bigint,
188
- withdrawals: InputReallocation[],
189
- supplyMarket: InputMarketParams,
190
- skipRevert?: boolean
191
- ];
192
- /** Vault V2 Blue Public Allocator market-to-market reallocation with a WAD-scaled penalty. */
193
- readonly vaultV2BluePublicAllocatorReallocate: [
194
- vault: Address,
195
- deallocateAdapter: Address,
196
- deallocateMarket: InputMarketParams,
197
- allocateAdapter: Address,
198
- allocateMarket: InputMarketParams,
199
- assets: bigint,
200
- penalty: bigint,
201
- skipRevert?: boolean
202
- ];
203
- /** Vault V2 Blue Public Allocator idle-to-market allocation with a WAD-scaled penalty. */
204
- readonly vaultV2BluePublicAllocatorAllocateFromIdle: [
205
- vault: Address,
206
- adapter: Address,
207
- market: InputMarketParams,
208
- assets: bigint,
209
- penalty: bigint,
210
- skipRevert?: boolean
211
- ];
212
- /** GeneralAdapter1 native wrap of `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
213
- readonly wrapNative: [
214
- amount: bigint,
215
- recipient: Address,
216
- skipRevert?: boolean
217
- ];
218
- }
219
- /**
220
- * Supported Bundler3 action discriminator.
221
- */
222
- export type ActionType = keyof ActionArgs;
223
- /**
224
- * Supported Bundler3 action object map keyed by action discriminator.
225
- */
226
- export type Actions = {
227
- readonly [T in ActionType]: {
228
- readonly type: T;
229
- readonly args: ActionArgs[T];
230
- };
231
- };
232
- /**
233
- * Discriminated union of Bundler3 actions supported by `morpho-sdk`.
234
- */
235
- export type Action = Actions[ActionType];
@@ -1 +0,0 @@
1
- export {};
@@ -1,332 +0,0 @@
1
- import { AccrualPosition, Market, type MarketId, Position, Vault, VaultMarketConfig } from "@morpho-org/blue-sdk";
2
- import type { Address } from "viem";
3
- import type { PublicAllocatorOptions, PublicReallocation, ReallocationComputeOptions } from "../types/index.js";
4
- /**
5
- * Input state required to construct {@link VaultV1ReallocationData}.
6
- *
7
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
8
- * `InputVaultV2BlueReallocationData`.
9
- */
10
- export interface InputVaultV1ReallocationData {
11
- /** Chain id associated with the fetched state. */
12
- readonly chainId: number;
13
- /** Markets indexed by market id. */
14
- readonly markets?: Readonly<Record<MarketId, Market | undefined>>;
15
- /** Vaults indexed by vault address. */
16
- readonly vaults?: Readonly<Record<Address, Vault | undefined>>;
17
- /** Positions indexed by user or vault address, then by market id. */
18
- readonly positions?: Readonly<Record<Address, Readonly<Record<MarketId, Position | undefined>>>>;
19
- /** Vault market configs indexed by vault address, then by market id. */
20
- readonly vaultMarketConfigs?: Readonly<Record<Address, Readonly<Record<MarketId, VaultMarketConfig | undefined>>>>;
21
- }
22
- /**
23
- * Deprecated input name for Vault V1 reallocation data.
24
- *
25
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
26
- * `InputVaultV2BlueReallocationData`.
27
- */
28
- export type InputReallocationData = InputVaultV1ReallocationData;
29
- /**
30
- * Narrow state container for computing public allocator reallocations.
31
- *
32
- * @remarks
33
- * The class owns only the market, vault, position, vault-market-config,
34
- * and chain data needed by the shared-liquidity algorithm. Constructor inputs
35
- * are cloned, and simulation steps return cloned `VaultV1ReallocationData` instances
36
- * so fetched caller inputs are not mutated.
37
- *
38
- * Public records are exposed for inspection and snapshotting only. Treat
39
- * `markets`, `vaults`, `positions`, and `vaultMarketConfigs` as a read
40
- * contract keyed by market id or address; use the getters for typed absence
41
- * errors and use simulation methods to produce updated state.
42
- *
43
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
44
- * `VaultV2BlueReallocationData`.
45
- */
46
- export declare class VaultV1ReallocationData implements InputVaultV1ReallocationData {
47
- /** Chain id associated with the fetched reallocation data. */
48
- readonly chainId: number;
49
- /** Markets indexed by market id. */
50
- readonly markets: Record<MarketId, Market | undefined>;
51
- /** Vaults indexed by vault address. */
52
- readonly vaults: Record<Address, Vault | undefined>;
53
- /** Positions indexed by user or vault address, then by market id. */
54
- readonly positions: Record<Address, Record<MarketId, Position | undefined>>;
55
- /** Vault market configs indexed by vault address, then by market id. */
56
- readonly vaultMarketConfigs: Record<Address, Record<MarketId, VaultMarketConfig | undefined>>;
57
- /**
58
- * Creates a cloned reallocation state from fetched market, vault, position,
59
- * and vault-market-config data.
60
- *
61
- * @param input - Reallocation input data fetched at a consistent chain state.
62
- */
63
- constructor(input: InputVaultV1ReallocationData);
64
- /**
65
- * Creates a deep clone of this reallocation state.
66
- *
67
- * @returns A new `VaultV1ReallocationData` instance with cloned entity objects.
68
- */
69
- clone(): VaultV1ReallocationData;
70
- private forkAliasedState;
71
- /**
72
- * Gets a market by id.
73
- *
74
- * @param marketId - Market id to read.
75
- * @returns The cloned market data.
76
- * @throws {@link UnknownReallocationMarketError} when the market is absent.
77
- */
78
- getMarket(marketId: MarketId): Market;
79
- /**
80
- * Gets a vault by address.
81
- *
82
- * @param vault - Vault address to read.
83
- * @returns The cloned vault data.
84
- * @throws {@link UnknownReallocationVaultError} when the vault is absent.
85
- */
86
- getVault(vault: Address): Vault;
87
- /**
88
- * Gets a raw market position.
89
- *
90
- * @param user - Position owner address, usually a MetaMorpho vault.
91
- * @param marketId - Market id for the position.
92
- * @returns The cloned position data.
93
- * @throws {@link UnknownReallocationPositionError} when the position is absent.
94
- */
95
- getPosition(user: Address, marketId: MarketId): Position;
96
- /**
97
- * Gets a position wrapped with its market accrual helpers.
98
- *
99
- * @param user - Position owner address, usually a MetaMorpho vault.
100
- * @param marketId - Market id for the position.
101
- * @returns Accrual-aware position data.
102
- * @throws {@link UnknownReallocationPositionError} when the position is absent.
103
- * @throws {@link UnknownReallocationMarketError} when the market is absent.
104
- */
105
- getAccrualPosition(user: Address, marketId: MarketId): AccrualPosition;
106
- /**
107
- * Gets a vault-market config.
108
- *
109
- * @param vault - Vault address.
110
- * @param marketId - Market id configured by the vault.
111
- * @returns The cloned vault-market config.
112
- * @throws {@link UnknownReallocationVaultMarketConfigError} when the config is absent.
113
- */
114
- getVaultMarketConfig(vault: Address, marketId: MarketId): VaultMarketConfig;
115
- /**
116
- * Calculates public reallocations that can supply liquidity to `marketId`.
117
- *
118
- * @remarks
119
- * The algorithm repeatedly chooses the single largest currently available
120
- * source-market withdrawal across reallocatable vaults, applies that
121
- * withdrawal to a cloned state, and repeats until no valid withdrawal remains.
122
- *
123
- * Pass `options.timestamp` to evaluate market interest and pending public
124
- * allocator caps at the same block as the fetched reallocation data.
125
- * This method does not add an implicit delay margin before measuring
126
- * target-market vault headroom. If a transaction may land later than the
127
- * fetched block, pass a future `timestamp` or reserve your own headroom so
128
- * interest accrued before inclusion does not make `reallocateTo` exceed the
129
- * target market cap.
130
- * Returned `data` normalizes `vault.publicAllocatorConfig.accruedFee` to the
131
- * on-chain `reallocateTo` fee semantics: one fee charge per vault with at
132
- * least one computed withdrawal.
133
- * Sources with zero allocator withdrawal capacity and destinations with no deposit capacity
134
- * are skipped before projecting source interest.
135
- *
136
- * @param marketId - Target market to supply with shared liquidity.
137
- * @param options - Optional allocator discovery options.
138
- * @returns Computed source-market withdrawals and the post-reallocation state.
139
- * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
140
- * @throws {@link UnknownReallocationMarketError} when the target market is absent.
141
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
142
- * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
143
- * @example
144
- * ```ts
145
- * import { createPublicClient, http } from "viem";
146
- * import { mainnet } from "viem/chains";
147
- * import { markets, vaults } from "@morpho-org/morpho-test";
148
- * import {
149
- * morphoViemExtension,
150
- * type PublicReallocation,
151
- * } from "@morpho-org/morpho-sdk";
152
- * import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
153
- *
154
- * const client = createPublicClient({
155
- * chain: mainnet,
156
- * transport: http(),
157
- * }).extend(morphoViemExtension());
158
- *
159
- * const marketParams = markets[mainnet.id].usdc_wbtc;
160
- * const market = client.morpho.blue(marketParams, mainnet.id);
161
- * const block = await client.getBlock();
162
- * const reallocationData = await market.getVaultV1ReallocationData({
163
- * vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
164
- * block: { number: block.number, timestamp: block.timestamp },
165
- * });
166
- *
167
- * const result: {
168
- * withdrawals: readonly PublicReallocation[];
169
- * data: VaultV1ReallocationData;
170
- * } = reallocationData.computeVaultV1Reallocations(marketParams.id, {
171
- * timestamp: block.timestamp,
172
- * });
173
- * ```
174
- */
175
- computeVaultV1Reallocations(marketId: MarketId, options?: PublicAllocatorOptions): {
176
- readonly withdrawals: readonly PublicReallocation[];
177
- data: VaultV1ReallocationData;
178
- };
179
- /**
180
- * Calculates Vault V1 public reallocations that can supply liquidity to `marketId`.
181
- *
182
- * @param marketId - Target market to supply with shared liquidity.
183
- * @param options - Optional allocator discovery options.
184
- * @returns Computed source-market withdrawals and the post-reallocation state.
185
- * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
186
- * @throws {@link UnknownReallocationMarketError} when the target market is absent.
187
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
188
- * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
189
- */
190
- getMarketPublicReallocations(marketId: MarketId, options?: PublicAllocatorOptions): {
191
- readonly withdrawals: readonly PublicReallocation[];
192
- data: VaultV1ReallocationData;
193
- };
194
- /**
195
- * Sums the public-allocator liquidity reallocatable into `marketId` from
196
- * sibling markets.
197
- *
198
- * Read-only metric — never throws on insufficiency (returns `0n`). Bounded by
199
- * each source market's withdrawal utilization cap and the target market's
200
- * vault supply-cap headroom. Pass `options.defaultMaxWithdrawalUtilization` to
201
- * widen the source ceiling (e.g. `MathLib.WAD` for the full drain).
202
- *
203
- * @param marketId - Target market that would receive the liquidity.
204
- * @param options - Optional allocator discovery options.
205
- * @returns Total reallocatable assets in loan-token units; `0n` when none is available.
206
- * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
207
- * @throws {@link UnknownReallocationMarketError} when the target market is absent.
208
- * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
209
- * `VaultV2BlueReallocationData.getPublicReallocationLiquidity`.
210
- * @example
211
- * ```ts
212
- * import { createPublicClient, http } from "viem";
213
- * import { mainnet } from "viem/chains";
214
- * import { markets, vaults } from "@morpho-org/morpho-test";
215
- * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
216
- *
217
- * const client = createPublicClient({
218
- * chain: mainnet,
219
- * transport: http(),
220
- * }).extend(morphoViemExtension());
221
- *
222
- * const marketParams = markets[mainnet.id].usdc_wbtc;
223
- * const market = client.morpho.blue(marketParams, mainnet.id);
224
- * const block = await client.getBlock();
225
- * const reallocationData = await market.getVaultV1ReallocationData({
226
- * vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
227
- * block: { number: block.number, timestamp: block.timestamp },
228
- * });
229
- *
230
- * const liquidity: bigint = reallocationData.getPublicReallocationLiquidity(
231
- * marketParams.id,
232
- * { timestamp: block.timestamp },
233
- * );
234
- * ```
235
- */
236
- getPublicReallocationLiquidity(marketId: MarketId, options?: PublicAllocatorOptions): bigint;
237
- /**
238
- * Computes the liquidity available to bring `marketId` to `utilization`,
239
- * counting the public-allocator liquidity reallocatable into it.
240
- *
241
- * Returns the max borrow `x` keeping post-borrow utilization
242
- * `(borrow + x) / (supply + L) ≤ utilization`, where `L` is the
243
- * reallocatable liquidity added to the market's supply — equivalently
244
- * `getBorrowToUtilization({ supply + L, borrow }, utilization)`. Below
245
- * `utilization` this is the market's own borrow headroom plus `utilization · L`;
246
- * reallocated supply also raises the supply denominator, so only that scaled
247
- * share backs further borrow.
248
- *
249
- * Read-only metric — never throws on insufficiency:
250
- * - returns only the market's own borrow headroom when
251
- * `supplyTargetUtilization > utilization` (reallocation would not
252
- * trigger at that utilization);
253
- * - returns `0n` when the market is already at or above `utilization` and `L`
254
- * is too small to bring it back under.
255
- *
256
- * @param marketId - Target market to borrow from.
257
- * @param utilization - Utilization to bring the market to, scaled by WAD. Defaults to {@link DEFAULT_SUPPLY_TARGET_UTILIZATION}.
258
- * @param options - Optional reallocation options (supply target utilization trigger, timestamp, withdrawal caps).
259
- * @returns Available liquidity to the given utilization in loan-token units; `0n` when none is available.
260
- * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
261
- * @throws {@link UnknownReallocationMarketError} when the target market is absent.
262
- * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
263
- * `VaultV2BlueReallocationData.getAvailableLiquidityToUtilization`.
264
- * @example
265
- * ```ts
266
- * import { createPublicClient, http, parseEther } from "viem";
267
- * import { mainnet } from "viem/chains";
268
- * import { markets, vaults } from "@morpho-org/morpho-test";
269
- * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
270
- *
271
- * const client = createPublicClient({
272
- * chain: mainnet,
273
- * transport: http(),
274
- * }).extend(morphoViemExtension());
275
- *
276
- * const marketParams = markets[mainnet.id].usdc_wbtc;
277
- * const market = client.morpho.blue(marketParams, mainnet.id);
278
- * const block = await client.getBlock();
279
- * const reallocationData = await market.getVaultV1ReallocationData({
280
- * vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
281
- * block: { number: block.number, timestamp: block.timestamp },
282
- * });
283
- *
284
- * // Max borrow keeping utilization at or below 90%, counting shared liquidity.
285
- * const available: bigint =
286
- * reallocationData.getAvailableLiquidityToUtilization(
287
- * marketParams.id,
288
- * parseEther("0.9"),
289
- * { timestamp: block.timestamp },
290
- * );
291
- * ```
292
- */
293
- getAvailableLiquidityToUtilization(marketId: MarketId, utilization?: bigint, options?: ReallocationComputeOptions): bigint;
294
- /**
295
- * Gets the largest currently valid source-market withdrawal for a vault.
296
- *
297
- * @param params - Candidate vault, target market, prior withdrawals, and allocator limits.
298
- * @returns The largest withdrawal candidate, or `undefined` if required data is missing.
299
- *
300
- * @internal
301
- */
302
- private getLargestVaultWithdrawal;
303
- /**
304
- * Applies one public allocator withdrawal and corresponding target-market supply.
305
- *
306
- * @param vault - Vault performing the public reallocation.
307
- * @param supplyMarketId - Target market that receives the withdrawn assets.
308
- * @param withdrawal - Source market id and asset amount to withdraw.
309
- * @param timestamp - Timestamp used to accrue source and target positions.
310
- * @returns A cloned state after applying the simulated reallocation.
311
- * @throws {@link MissingPublicAllocatorConfigError} when the vault allocator config is absent.
312
- * @throws {@link UnknownReallocationVaultMarketConfigError} when source or target allocator limits are absent.
313
- *
314
- * @internal
315
- */
316
- protected applyPublicReallocation({ vault, supplyMarketId, withdrawal, timestamp, }: {
317
- readonly vault: Address;
318
- readonly supplyMarketId: MarketId;
319
- readonly withdrawal: {
320
- readonly id: MarketId;
321
- readonly assets: bigint;
322
- };
323
- readonly timestamp: bigint;
324
- }): VaultV1ReallocationData;
325
- }
326
- /**
327
- * Deprecated class name for Vault V1 reallocation data.
328
- *
329
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
330
- * `VaultV2BlueReallocationData`.
331
- */
332
- export { VaultV1ReallocationData as ReallocationData };