@morpho-org/morpho-sdk 5.9.0 → 6.0.0-next.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 (243) hide show
  1. package/MIGRATION-v5-to-v6.md +404 -0
  2. package/README.md +127 -69
  3. package/lib/cjs/abis.d.ts +210 -0
  4. package/lib/cjs/abis.js +142 -2
  5. package/lib/cjs/actions/blue/borrow.d.ts +62 -61
  6. package/lib/cjs/actions/blue/borrow.js +48 -80
  7. package/lib/cjs/actions/blue/common.d.ts +86 -0
  8. package/lib/cjs/actions/blue/common.js +205 -0
  9. package/lib/cjs/actions/blue/refinance.d.ts +72 -112
  10. package/lib/cjs/actions/blue/refinance.js +97 -199
  11. package/lib/cjs/actions/blue/repay.d.ts +72 -68
  12. package/lib/cjs/actions/blue/repay.js +56 -118
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +85 -90
  14. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +148 -137
  15. package/lib/cjs/actions/blue/supply.d.ts +62 -45
  16. package/lib/cjs/actions/blue/supply.js +94 -70
  17. package/lib/cjs/actions/blue/supplyCollateral.d.ts +63 -40
  18. package/lib/cjs/actions/blue/supplyCollateral.js +52 -69
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +82 -90
  20. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +133 -120
  21. package/lib/cjs/actions/blue/withdraw.d.ts +68 -79
  22. package/lib/cjs/actions/blue/withdraw.js +101 -97
  23. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +56 -28
  24. package/lib/cjs/actions/blue/withdrawCollateral.js +45 -50
  25. package/lib/cjs/actions/bundles/common.d.ts +200 -0
  26. package/lib/cjs/actions/bundles/common.js +469 -0
  27. package/lib/cjs/actions/bundles/index.d.ts +3 -0
  28. package/lib/cjs/actions/bundles/index.js +23 -0
  29. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
  30. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +125 -0
  31. package/lib/cjs/actions/index.d.ts +2 -1
  32. package/lib/cjs/actions/index.js +1 -0
  33. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
  34. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
  35. package/lib/cjs/actions/midnight/takeBorrow.d.ts +2 -2
  36. package/lib/cjs/actions/midnight/takeBorrow.js +2 -2
  37. package/lib/cjs/actions/midnight/takeLend.d.ts +2 -2
  38. package/lib/cjs/actions/midnight/takeLend.js +2 -2
  39. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
  40. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +60 -19
  41. package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
  42. package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +72 -0
  43. package/lib/cjs/actions/requirements/blue/index.d.ts +1 -0
  44. package/lib/cjs/actions/requirements/blue/index.js +1 -0
  45. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
  46. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +30 -5
  47. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
  48. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +8 -2
  49. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
  50. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +39 -6
  51. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
  52. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +123 -0
  53. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
  54. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
  55. package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
  56. package/lib/cjs/actions/requirements/encode/index.js +1 -0
  57. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
  58. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +6 -4
  59. package/lib/cjs/actions/requirements/getRequirementsApproval.js +6 -4
  60. package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
  61. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
  62. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
  63. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +18 -66
  64. package/lib/cjs/actions/vaultV1/deposit.d.ts +73 -57
  65. package/lib/cjs/actions/vaultV1/deposit.js +110 -109
  66. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +43 -66
  67. package/lib/cjs/actions/vaultV1/migrateToV2.js +91 -104
  68. package/lib/cjs/actions/vaultV1/redeem.d.ts +30 -23
  69. package/lib/cjs/actions/vaultV1/redeem.js +56 -33
  70. package/lib/cjs/actions/vaultV1/withdraw.d.ts +58 -24
  71. package/lib/cjs/actions/vaultV1/withdraw.js +86 -34
  72. package/lib/cjs/actions/vaultV2/deposit.d.ts +74 -57
  73. package/lib/cjs/actions/vaultV2/deposit.js +111 -109
  74. package/lib/cjs/actions/vaultV2/redeem.d.ts +30 -24
  75. package/lib/cjs/actions/vaultV2/redeem.js +56 -34
  76. package/lib/cjs/actions/vaultV2/withdraw.d.ts +58 -25
  77. package/lib/cjs/actions/vaultV2/withdraw.js +86 -35
  78. package/lib/cjs/bundler/actions.d.ts +4 -4
  79. package/lib/cjs/bundler/actions.js +4 -4
  80. package/lib/cjs/client/morphoViemExtension.d.ts +2 -1
  81. package/lib/cjs/client/morphoViemExtension.js +2 -1
  82. package/lib/cjs/entities/blue/blue.d.ts +806 -374
  83. package/lib/cjs/entities/blue/blue.js +449 -696
  84. package/lib/cjs/entities/index.d.ts +2 -0
  85. package/lib/cjs/entities/index.js +15 -0
  86. package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
  87. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
  88. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +203 -0
  89. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
  90. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +74 -0
  91. package/lib/cjs/entities/requirements/index.d.ts +1 -0
  92. package/lib/cjs/entities/requirements/index.js +17 -0
  93. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +348 -98
  94. package/lib/cjs/entities/vaultV1/vaultV1.js +322 -120
  95. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +221 -68
  96. package/lib/cjs/entities/vaultV2/vaultV2.js +219 -77
  97. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +3 -9
  98. package/lib/cjs/helpers/computeVaultV1Reallocations.js +3 -9
  99. package/lib/cjs/helpers/index.d.ts +2 -1
  100. package/lib/cjs/helpers/index.js +5 -1
  101. package/lib/cjs/helpers/referralFee.d.ts +21 -0
  102. package/lib/cjs/helpers/referralFee.js +35 -0
  103. package/lib/cjs/helpers/slippage.d.ts +90 -1
  104. package/lib/cjs/helpers/slippage.js +123 -0
  105. package/lib/cjs/helpers/validate.d.ts +16 -23
  106. package/lib/cjs/helpers/validate.js +41 -48
  107. package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
  108. package/lib/cjs/helpers/validateRequirementSpender.js +3 -0
  109. package/lib/cjs/index.d.ts +1 -0
  110. package/lib/cjs/index.js +1 -0
  111. package/lib/cjs/types/action.d.ts +303 -210
  112. package/lib/cjs/types/action.js +29 -2
  113. package/lib/cjs/types/client.d.ts +9 -0
  114. package/lib/cjs/types/error.d.ts +193 -18
  115. package/lib/cjs/types/error.js +267 -24
  116. package/lib/cjs/types/sharedLiquidity.d.ts +0 -7
  117. package/lib/esm/abis.d.ts +210 -0
  118. package/lib/esm/abis.js +140 -0
  119. package/lib/esm/actions/blue/borrow.d.ts +62 -61
  120. package/lib/esm/actions/blue/borrow.js +48 -80
  121. package/lib/esm/actions/blue/common.d.ts +86 -0
  122. package/lib/esm/actions/blue/common.js +193 -0
  123. package/lib/esm/actions/blue/refinance.d.ts +72 -112
  124. package/lib/esm/actions/blue/refinance.js +98 -200
  125. package/lib/esm/actions/blue/repay.d.ts +72 -68
  126. package/lib/esm/actions/blue/repay.js +56 -118
  127. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +85 -90
  128. package/lib/esm/actions/blue/repayWithdrawCollateral.js +149 -138
  129. package/lib/esm/actions/blue/supply.d.ts +62 -45
  130. package/lib/esm/actions/blue/supply.js +94 -70
  131. package/lib/esm/actions/blue/supplyCollateral.d.ts +63 -40
  132. package/lib/esm/actions/blue/supplyCollateral.js +52 -69
  133. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +82 -90
  134. package/lib/esm/actions/blue/supplyCollateralBorrow.js +134 -121
  135. package/lib/esm/actions/blue/withdraw.d.ts +68 -79
  136. package/lib/esm/actions/blue/withdraw.js +100 -96
  137. package/lib/esm/actions/blue/withdrawCollateral.d.ts +56 -28
  138. package/lib/esm/actions/blue/withdrawCollateral.js +45 -50
  139. package/lib/esm/actions/bundles/common.d.ts +200 -0
  140. package/lib/esm/actions/bundles/common.js +457 -0
  141. package/lib/esm/actions/bundles/index.d.ts +3 -0
  142. package/lib/esm/actions/bundles/index.js +2 -0
  143. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
  144. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +121 -0
  145. package/lib/esm/actions/index.d.ts +2 -1
  146. package/lib/esm/actions/index.js +1 -0
  147. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
  148. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
  149. package/lib/esm/actions/midnight/takeBorrow.d.ts +2 -2
  150. package/lib/esm/actions/midnight/takeBorrow.js +2 -2
  151. package/lib/esm/actions/midnight/takeLend.d.ts +2 -2
  152. package/lib/esm/actions/midnight/takeLend.js +2 -2
  153. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
  154. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +63 -22
  155. package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
  156. package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +68 -0
  157. package/lib/esm/actions/requirements/blue/index.d.ts +1 -0
  158. package/lib/esm/actions/requirements/blue/index.js +1 -0
  159. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
  160. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +31 -6
  161. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
  162. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -3
  163. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
  164. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +40 -7
  165. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
  166. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +119 -0
  167. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
  168. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
  169. package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
  170. package/lib/esm/actions/requirements/encode/index.js +1 -0
  171. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
  172. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +6 -4
  173. package/lib/esm/actions/requirements/getRequirementsApproval.js +6 -4
  174. package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
  175. package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
  176. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
  177. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +19 -67
  178. package/lib/esm/actions/vaultV1/deposit.d.ts +73 -57
  179. package/lib/esm/actions/vaultV1/deposit.js +112 -111
  180. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +43 -66
  181. package/lib/esm/actions/vaultV1/migrateToV2.js +93 -106
  182. package/lib/esm/actions/vaultV1/redeem.d.ts +30 -23
  183. package/lib/esm/actions/vaultV1/redeem.js +56 -33
  184. package/lib/esm/actions/vaultV1/withdraw.d.ts +58 -24
  185. package/lib/esm/actions/vaultV1/withdraw.js +86 -34
  186. package/lib/esm/actions/vaultV2/deposit.d.ts +74 -57
  187. package/lib/esm/actions/vaultV2/deposit.js +113 -111
  188. package/lib/esm/actions/vaultV2/redeem.d.ts +30 -24
  189. package/lib/esm/actions/vaultV2/redeem.js +56 -34
  190. package/lib/esm/actions/vaultV2/withdraw.d.ts +58 -25
  191. package/lib/esm/actions/vaultV2/withdraw.js +86 -35
  192. package/lib/esm/bundler/actions.d.ts +4 -4
  193. package/lib/esm/bundler/actions.js +4 -4
  194. package/lib/esm/client/morphoViemExtension.d.ts +2 -1
  195. package/lib/esm/client/morphoViemExtension.js +2 -1
  196. package/lib/esm/entities/blue/blue.d.ts +806 -374
  197. package/lib/esm/entities/blue/blue.js +455 -702
  198. package/lib/esm/entities/index.d.ts +2 -0
  199. package/lib/esm/entities/index.js +1 -0
  200. package/lib/esm/entities/midnight/midnight.d.ts +2 -2
  201. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
  202. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +199 -0
  203. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
  204. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +70 -0
  205. package/lib/esm/entities/requirements/index.d.ts +1 -0
  206. package/lib/esm/entities/requirements/index.js +1 -0
  207. package/lib/esm/entities/vaultV1/vaultV1.d.ts +348 -98
  208. package/lib/esm/entities/vaultV1/vaultV1.js +326 -124
  209. package/lib/esm/entities/vaultV2/vaultV2.d.ts +221 -68
  210. package/lib/esm/entities/vaultV2/vaultV2.js +222 -80
  211. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +3 -9
  212. package/lib/esm/helpers/computeVaultV1Reallocations.js +3 -9
  213. package/lib/esm/helpers/index.d.ts +2 -1
  214. package/lib/esm/helpers/index.js +2 -1
  215. package/lib/esm/helpers/referralFee.d.ts +21 -0
  216. package/lib/esm/helpers/referralFee.js +31 -0
  217. package/lib/esm/helpers/slippage.d.ts +90 -1
  218. package/lib/esm/helpers/slippage.js +122 -2
  219. package/lib/esm/helpers/validate.d.ts +16 -23
  220. package/lib/esm/helpers/validate.js +40 -48
  221. package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
  222. package/lib/esm/helpers/validateRequirementSpender.js +3 -0
  223. package/lib/esm/index.d.ts +1 -0
  224. package/lib/esm/index.js +1 -0
  225. package/lib/esm/types/action.d.ts +303 -210
  226. package/lib/esm/types/action.js +28 -2
  227. package/lib/esm/types/client.d.ts +9 -0
  228. package/lib/esm/types/error.d.ts +193 -18
  229. package/lib/esm/types/error.js +252 -21
  230. package/lib/esm/types/sharedLiquidity.d.ts +0 -7
  231. package/package.json +6 -5
  232. package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +0 -47
  233. package/lib/cjs/actions/blue/buildAssetFundingActions.js +0 -63
  234. package/lib/cjs/actions/blue/buildReallocationActions.d.ts +0 -69
  235. package/lib/cjs/actions/blue/buildReallocationActions.js +0 -141
  236. package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +0 -66
  237. package/lib/cjs/actions/blue/resolveRepayFunding.js +0 -85
  238. package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +0 -47
  239. package/lib/esm/actions/blue/buildAssetFundingActions.js +0 -59
  240. package/lib/esm/actions/blue/buildReallocationActions.d.ts +0 -69
  241. package/lib/esm/actions/blue/buildReallocationActions.js +0 -135
  242. package/lib/esm/actions/blue/resolveRepayFunding.d.ts +0 -66
  243. package/lib/esm/actions/blue/resolveRepayFunding.js +0 -81
@@ -13,24 +13,58 @@ export interface ERC20ApprovalAction extends BaseAction<"erc20Approval", {
13
13
  export interface ERC20PermitAction {
14
14
  sign: (client: WalletClient, userAddress: Address) => Promise<Hex>;
15
15
  }
16
+ /** Metadata for a direct Vault V2 deposit through VaultBundlesV1. */
16
17
  export interface VaultV2DepositAction extends BaseAction<"vaultV2Deposit", {
17
- vault: Address;
18
- amount: bigint;
19
- maxSharePrice: bigint;
20
- recipient: Address;
21
- nativeAmount?: bigint;
18
+ /** Destination vault receiving net assets; shares are minted to the transaction sender. */
19
+ readonly vault: Address;
20
+ /** Gross funding in asset base units, for either ERC-20 or native funding, before fees. */
21
+ readonly amount: bigint;
22
+ /** Maximum asset/share ratio scaled by 1e27, computed from net assets through the deadline. */
23
+ readonly maxSharePrice: bigint;
24
+ /** Native funding marker: equals `amount` and transaction `value` on native deposits; otherwise undefined. */
25
+ readonly nativeAmount?: bigint;
26
+ /** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
27
+ readonly referralFeePct: bigint;
28
+ /** Recipient of the referral fee; zero address when the fee is disabled by default. */
29
+ readonly referralFeeRecipient: Address;
30
+ /** Fee in asset base units: floor(amount * referralFeePct / WAD). */
31
+ readonly referralFeeAssets: bigint;
32
+ /** Assets deposited into the vault: amount minus referralFeeAssets. */
33
+ readonly netAssets: bigint;
34
+ /** Execution and token-permit expiration as a Unix timestamp in seconds. */
35
+ readonly deadline: bigint;
22
36
  }> {
23
37
  }
38
+ /** Metadata for an exact-assets Vault V2 withdrawal through VaultBundlesV1. */
24
39
  export interface VaultV2WithdrawAction extends BaseAction<"vaultV2Withdraw", {
25
- vault: Address;
26
- amount: bigint;
27
- recipient: Address;
40
+ /** Source vault whose shares are burned from the transaction sender. */
41
+ readonly vault: Address;
42
+ /** Gross withdrawal in asset base units, before the referral fee is deducted. */
43
+ readonly amount: bigint;
44
+ /** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
45
+ readonly referralFeePct: bigint;
46
+ /** Recipient of the referral fee; zero address when the fee is disabled by default. */
47
+ readonly referralFeeRecipient: Address;
48
+ /** Fee in asset base units: floor(amount * referralFeePct / WAD). */
49
+ readonly referralFeeAssets: bigint;
50
+ /** Assets received by the transaction sender: amount minus referralFeeAssets. */
51
+ readonly netAssets: bigint;
52
+ /** Execution and share-permit expiration as a Unix timestamp in seconds. */
53
+ readonly deadline: bigint;
28
54
  }> {
29
55
  }
56
+ /** Metadata for an exact-shares Vault V2 redemption through VaultBundlesV1. */
30
57
  export interface VaultV2RedeemAction extends BaseAction<"vaultV2Redeem", {
31
- vault: Address;
32
- shares: bigint;
33
- recipient: Address;
58
+ /** Source vault whose shares are burned from the transaction sender. */
59
+ readonly vault: Address;
60
+ /** Exact shares to burn, in vault-share base units. */
61
+ readonly shares: bigint;
62
+ /** Referral fee fraction scaled by WAD (1e18), deducted from redeemed assets; zero disables it. */
63
+ readonly referralFeePct: bigint;
64
+ /** Recipient of the referral fee; zero address when the fee is disabled by default. */
65
+ readonly referralFeeRecipient: Address;
66
+ /** Execution and share-permit expiration as a Unix timestamp in seconds. */
67
+ readonly deadline: bigint;
34
68
  }> {
35
69
  }
36
70
  /** Metadata for a Vault V2 in-kind redemption into Morpho Blue supply positions. */
@@ -63,24 +97,58 @@ export interface VaultV2ForceRedeemAction extends BaseAction<"vaultV2ForceRedeem
63
97
  onBehalf: Address;
64
98
  }> {
65
99
  }
100
+ /** Metadata for a direct Vault V1 deposit through VaultBundlesV1. */
66
101
  export interface VaultV1DepositAction extends BaseAction<"vaultV1Deposit", {
67
- vault: Address;
68
- amount: bigint;
69
- maxSharePrice: bigint;
70
- recipient: Address;
71
- nativeAmount?: bigint;
102
+ /** Destination vault receiving net assets; shares are minted to the transaction sender. */
103
+ readonly vault: Address;
104
+ /** Gross funding in asset base units, for either ERC-20 or native funding, before fees. */
105
+ readonly amount: bigint;
106
+ /** Maximum asset/share ratio scaled by 1e27, computed from net assets through the deadline. */
107
+ readonly maxSharePrice: bigint;
108
+ /** Native funding marker: equals `amount` and transaction `value` on native deposits; otherwise undefined. */
109
+ readonly nativeAmount?: bigint;
110
+ /** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
111
+ readonly referralFeePct: bigint;
112
+ /** Recipient of the referral fee; zero address when the fee is disabled by default. */
113
+ readonly referralFeeRecipient: Address;
114
+ /** Fee in asset base units: floor(amount * referralFeePct / WAD). */
115
+ readonly referralFeeAssets: bigint;
116
+ /** Assets deposited into the vault: amount minus referralFeeAssets. */
117
+ readonly netAssets: bigint;
118
+ /** Execution and token-permit expiration as a Unix timestamp in seconds. */
119
+ readonly deadline: bigint;
72
120
  }> {
73
121
  }
122
+ /** Metadata for an exact-assets Vault V1 withdrawal through VaultBundlesV1. */
74
123
  export interface VaultV1WithdrawAction extends BaseAction<"vaultV1Withdraw", {
75
- vault: Address;
76
- amount: bigint;
77
- recipient: Address;
124
+ /** Source vault whose shares are burned from the transaction sender. */
125
+ readonly vault: Address;
126
+ /** Gross withdrawal in asset base units, before the referral fee is deducted. */
127
+ readonly amount: bigint;
128
+ /** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
129
+ readonly referralFeePct: bigint;
130
+ /** Recipient of the referral fee; zero address when the fee is disabled by default. */
131
+ readonly referralFeeRecipient: Address;
132
+ /** Fee in asset base units: floor(amount * referralFeePct / WAD). */
133
+ readonly referralFeeAssets: bigint;
134
+ /** Assets received by the transaction sender: amount minus referralFeeAssets. */
135
+ readonly netAssets: bigint;
136
+ /** Execution and share-permit expiration as a Unix timestamp in seconds. */
137
+ readonly deadline: bigint;
78
138
  }> {
79
139
  }
140
+ /** Metadata for an exact-shares Vault V1 redemption through VaultBundlesV1. */
80
141
  export interface VaultV1RedeemAction extends BaseAction<"vaultV1Redeem", {
81
- vault: Address;
82
- shares: bigint;
83
- recipient: Address;
142
+ /** Source vault whose shares are burned from the transaction sender. */
143
+ readonly vault: Address;
144
+ /** Exact shares to burn, in vault-share base units. */
145
+ readonly shares: bigint;
146
+ /** Referral fee fraction scaled by WAD (1e18), deducted from redeemed assets; zero disables it. */
147
+ readonly referralFeePct: bigint;
148
+ /** Recipient of the referral fee; zero address when the fee is disabled by default. */
149
+ readonly referralFeeRecipient: Address;
150
+ /** Execution and share-permit expiration as a Unix timestamp in seconds. */
151
+ readonly deadline: bigint;
84
152
  }> {
85
153
  }
86
154
  /** Metadata for a Vault V1 in-kind redemption into Morpho Blue supply positions. */
@@ -92,112 +160,110 @@ export interface VaultV1InKindRedeemAction extends BaseAction<"vaultV1InKindRede
92
160
  readonly deadline: bigint;
93
161
  }> {
94
162
  }
163
+ /** Metadata for an assets-or-shares Vault V1 to Vault V2 migration through VaultBundlesV1. */
95
164
  export interface VaultV1MigrateToV2Action extends BaseAction<"vaultV1MigrateToV2", {
96
- sourceVault: Address;
97
- targetVault: Address;
98
- shares: bigint;
99
- minSharePriceVaultV1: bigint;
100
- maxSharePriceVaultV2: bigint;
101
- recipient: Address;
165
+ /** Source Vault V1 whose shares are burned from the transaction sender. */
166
+ readonly sourceVault: Address;
167
+ /** Destination Vault V2 receiving net assets; shares are minted to the transaction sender. */
168
+ readonly targetVault: Address;
169
+ /** Gross assets to withdraw in asset base units; zero in exact-shares mode. */
170
+ readonly assets: bigint;
171
+ /** Source shares to burn in vault-share base units; zero in exact-assets mode. */
172
+ readonly shares: bigint;
173
+ /** Maximum destination asset base units per share base unit, scaled by RAY (1e27). */
174
+ readonly maxSharePriceVaultV2: bigint;
175
+ /** Referral fee fraction scaled by WAD (1e18), deducted before depositing; zero disables it. */
176
+ readonly referralFeePct: bigint;
177
+ /** Recipient of the referral fee; zero address when the fee is disabled by default. */
178
+ readonly referralFeeRecipient: Address;
179
+ /** Fee in asset base units: floor(assets * referralFeePct / WAD); omitted in exact-shares mode. */
180
+ readonly referralFeeAssets?: bigint;
181
+ /** Assets deposited: assets minus referralFeeAssets; omitted in exact-shares mode. */
182
+ readonly netAssets?: bigint;
183
+ /** Execution and source share-permit expiration as a Unix timestamp in seconds. */
184
+ readonly deadline: bigint;
102
185
  }> {
103
186
  }
187
+ /** Metadata for a direct BlueBundlesV1 loan-asset supply. */
104
188
  export interface BlueSupplyAction extends BaseAction<"blueSupply", {
105
- market: Hex;
106
- amount: bigint;
107
- onBehalf: Address;
108
- maxSharePrice: bigint;
109
- nativeAmount?: bigint;
189
+ readonly market: Hex;
190
+ readonly assets: bigint;
191
+ readonly onBehalf: Address;
192
+ readonly nativeAmount?: bigint;
193
+ readonly referralFeePct: bigint;
194
+ readonly referralFeeRecipient: Address;
195
+ readonly deadline: bigint;
110
196
  }> {
111
197
  }
198
+ /** Metadata for a direct BlueBundlesV1 loan-asset withdrawal. */
112
199
  export interface BlueWithdrawAction extends BaseAction<"blueWithdraw", {
113
- market: Hex;
114
- assets: bigint;
115
- shares: bigint;
116
- receiver: Address;
117
- minSharePrice: bigint;
118
- /** Native-token fees paid to PublicAllocator V1. */
119
- reallocationFee: bigint;
120
- /** Loan-token assets donated as BluePublicAllocator V2 penalties. */
200
+ readonly market: Hex;
201
+ readonly withdrawAssets: bigint;
202
+ readonly withdrawShares: bigint;
203
+ readonly onBehalf: Address;
204
+ readonly reallocations: number;
121
205
  readonly reallocationPenaltyAssets: bigint;
206
+ readonly referralFeePct: bigint;
207
+ readonly referralFeeRecipient: Address;
208
+ readonly deadline: bigint;
122
209
  }> {
123
210
  }
124
- export interface BlueSupplyCollateralAction extends BaseAction<"blueSupplyCollateral", {
125
- market: Hex;
126
- amount: bigint;
127
- onBehalf: Address;
128
- nativeAmount?: bigint;
129
- }> {
130
- }
131
- export interface BlueBorrowAction extends BaseAction<"blueBorrow", {
132
- market: Hex;
133
- amount: bigint;
134
- receiver: Address;
135
- minSharePrice: bigint;
136
- /** Native-token fees paid to PublicAllocator V1. */
137
- reallocationFee: bigint;
138
- /** Loan-token assets donated as BluePublicAllocator V2 penalties. */
211
+ type BlueSupplyCollateralBorrowActionArgs = {
212
+ readonly market: Hex;
213
+ readonly collateralAssets: bigint;
214
+ readonly borrowAssets: bigint;
215
+ readonly maxLtv: bigint;
216
+ readonly onBehalf: Address;
217
+ readonly nativeAmount?: bigint;
218
+ readonly reallocations: number;
139
219
  readonly reallocationPenaltyAssets: bigint;
140
- }> {
220
+ readonly referralFeePct: bigint;
221
+ readonly referralFeeRecipient: Address;
222
+ readonly deadline: bigint;
223
+ };
224
+ /** Metadata for a direct BlueBundlesV1 collateral supply. */
225
+ export interface BlueSupplyCollateralAction extends BaseAction<"blueSupplyCollateral", BlueSupplyCollateralBorrowActionArgs> {
141
226
  }
142
- export interface BlueSupplyCollateralBorrowAction extends BaseAction<"blueSupplyCollateralBorrow", {
143
- market: Hex;
144
- collateralAmount: bigint;
145
- borrowAmount: bigint;
146
- minSharePrice: bigint;
147
- onBehalf: Address;
148
- receiver: Address;
149
- nativeAmount?: bigint;
150
- /** Native-token fees paid to PublicAllocator V1. */
151
- reallocationFee: bigint;
152
- /** Loan-token assets donated as BluePublicAllocator V2 penalties. */
153
- readonly reallocationPenaltyAssets: bigint;
154
- }> {
227
+ /** Metadata for a direct BlueBundlesV1 borrow. */
228
+ export interface BlueBorrowAction extends BaseAction<"blueBorrow", BlueSupplyCollateralBorrowActionArgs> {
155
229
  }
156
- export interface BlueRepayAction extends BaseAction<"blueRepay", {
157
- market: Hex;
158
- assets: bigint;
159
- shares: bigint;
160
- transferAmount: bigint;
161
- onBehalf: Address;
162
- receiver: Address;
163
- maxSharePrice: bigint;
164
- /** Native token wrapped into wNative to fund the repay. Present when `> 0n`. */
165
- nativeAmount?: bigint;
166
- }> {
230
+ /** Metadata for a direct BlueBundlesV1 collateral-supply and/or borrow. */
231
+ export interface BlueSupplyCollateralBorrowAction extends BaseAction<"blueSupplyCollateralBorrow", BlueSupplyCollateralBorrowActionArgs> {
167
232
  }
168
- export interface BlueWithdrawCollateralAction extends BaseAction<"blueWithdrawCollateral", {
169
- market: Hex;
170
- amount: bigint;
171
- onBehalf: Address;
172
- receiver: Address;
173
- }> {
233
+ type BlueRepayWithdrawCollateralActionArgs = {
234
+ readonly market: Hex;
235
+ readonly repayAssets: bigint;
236
+ readonly repayShares: bigint;
237
+ readonly maxRepayAssets: bigint;
238
+ readonly collateralAssets: bigint;
239
+ readonly maxLtv: bigint;
240
+ readonly onBehalf: Address;
241
+ readonly nativeAmount?: bigint;
242
+ readonly referralFeePct: bigint;
243
+ readonly referralFeeRecipient: Address;
244
+ readonly deadline: bigint;
245
+ };
246
+ /** Metadata for a direct BlueBundlesV1 repayment. */
247
+ export interface BlueRepayAction extends BaseAction<"blueRepay", BlueRepayWithdrawCollateralActionArgs> {
174
248
  }
175
- export interface BlueRepayWithdrawCollateralAction extends BaseAction<"blueRepayWithdrawCollateral", {
176
- market: Hex;
177
- repayAssets: bigint;
178
- repayShares: bigint;
179
- transferAmount: bigint;
180
- withdrawAmount: bigint;
181
- maxSharePrice: bigint;
182
- onBehalf: Address;
183
- receiver: Address;
184
- /** Native token wrapped into wNative to fund the repay. Present when `> 0n`. */
185
- nativeAmount?: bigint;
186
- }> {
249
+ /** Metadata for a direct BlueBundlesV1 collateral withdrawal. */
250
+ export interface BlueWithdrawCollateralAction extends BaseAction<"blueWithdrawCollateral", BlueRepayWithdrawCollateralActionArgs> {
251
+ }
252
+ /** Metadata for a direct BlueBundlesV1 repay and/or collateral withdrawal. */
253
+ export interface BlueRepayWithdrawCollateralAction extends BaseAction<"blueRepayWithdrawCollateral", BlueRepayWithdrawCollateralActionArgs> {
187
254
  }
255
+ /** Metadata for a direct BlueBundlesV1 full borrow-position migration. */
188
256
  export interface BlueRefinanceAction extends BaseAction<"blueRefinance", {
189
257
  readonly sourceMarket: Hex;
190
- readonly targetMarket: Hex;
191
- readonly collateralAmount: bigint;
192
- readonly borrowAssets: bigint;
193
- readonly borrowShares: bigint;
194
- readonly minBorrowSharePrice: bigint;
195
- readonly maxRepaySharePrice: bigint;
196
- readonly user: Address;
197
- /** Native-token fees paid to PublicAllocator V1. */
198
- readonly reallocationFee: bigint;
258
+ readonly destinationMarket: Hex;
259
+ readonly maxLtv: bigint;
260
+ readonly onBehalf: Address;
261
+ readonly reallocations: number;
199
262
  /** Loan-token assets donated as BluePublicAllocator V2 penalties. */
200
263
  readonly reallocationPenaltyAssets: bigint;
264
+ readonly referralFeePct: bigint;
265
+ readonly referralFeeRecipient: Address;
266
+ readonly deadline: bigint;
201
267
  }> {
202
268
  }
203
269
  /**
@@ -207,59 +273,14 @@ export interface BlueRefinanceAction extends BaseAction<"blueRefinance", {
207
273
  * - `shares`: operate on an exact share count (typical for full position closes,
208
274
  * immune to interest accrual between tx construction and execution).
209
275
  *
210
- * Used by withdraw (asserts on supply side). Repay uses {@link RepayAmountArgs},
211
- * which additionally supports native wrapping.
276
+ * Used by BlueBundlesV1 withdrawal; repayment has its own assets-or-shares union because a pure
277
+ * collateral withdrawal has no repay amount.
212
278
  */
213
279
  export type AssetsOrSharesArgs = {
214
- assets: bigint;
280
+ readonly assets: bigint;
215
281
  } | {
216
- shares: bigint;
282
+ readonly shares: bigint;
217
283
  };
218
- /**
219
- * Repay funding sources for the **entity layer** (`MorphoBlue.repay` /
220
- * `MorphoBlue.repayWithdrawCollateral`), which computes the loan-token
221
- * `transferAmount` itself from live market state.
222
- *
223
- * - **assets mode** ({@link DepositAmountArgs}): repay an exact asset total of
224
- * `amount` (ERC-20) + `nativeAmount` (wrapped native). Additive — mirrors `blueSupply`.
225
- * - **shares mode** (`{ shares }`): repay an exact borrow-share count (full close,
226
- * immune to interest accrual). `nativeAmount` funds part of the transfer.
227
- *
228
- * `nativeAmount` requires the market's loan token to be the chain's wNative.
229
- */
230
- export type RepayAmountArgs = DepositAmountArgs | {
231
- shares: bigint;
232
- nativeAmount?: bigint;
233
- };
234
- /**
235
- * Repay funding sources for the **action layer** (`blueRepay` /
236
- * `blueRepayWithdrawCollateral`) — a flat, pre-resolved shape. The entity layer
237
- * ({@link RepayAmountArgs}) derives these from live market state; the action does no
238
- * amount arithmetic. The mode is discriminated on `shares`:
239
- *
240
- * - **assets mode** (`shares` unset/`0n`): repays `transferAmount` assets
241
- * (`= amount + nativeAmount`, additive like `blueSupply`), pulling `amount` ERC-20
242
- * and wrapping `nativeAmount`. No residual.
243
- * - **shares mode** (`shares > 0n`): repays an exact borrow-share count (full close),
244
- * pulling `transferAmount` ERC-20 (already net of native) and wrapping `nativeAmount`;
245
- * the residual loan token is skimmed back to `receiver`.
246
- *
247
- * `nativeAmount` requires the market's loan token to be the chain's wNative.
248
- */
249
- export interface RepayActionAmountArgs {
250
- /** Assets-mode ERC-20 loan tokens pulled from the payer. Omit (or `0n`) in shares mode. */
251
- amount?: bigint;
252
- /** Shares-mode borrow shares to repay (full close). Omit (or `0n`) in assets mode. */
253
- shares?: bigint;
254
- /** Native ETH wrapped into wNative to help fund the repay. Loan token must be wNative. */
255
- nativeAmount?: bigint;
256
- /**
257
- * Loan tokens routed into `GeneralAdapter1`. Assets mode: the total repaid
258
- * (`amount + nativeAmount`). Shares mode: the ERC-20 pulled
259
- * (`toBorrowAssets(shares) − nativeAmount`).
260
- */
261
- transferAmount: bigint;
262
- }
263
284
  /** Metadata for a Blue authorization prerequisite transaction. */
264
285
  export interface BlueAuthorizationAction extends BaseAction<"blueAuthorization", {
265
286
  authorized: Address;
@@ -358,7 +379,8 @@ export interface MidnightCancelOfferAction extends BaseAction<"midnightCancelOff
358
379
  readonly onBehalf: Address;
359
380
  }> {
360
381
  }
361
- export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueWithdrawAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | SetterRatifierRatifyRootAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MempoolSubmitOffersAction | MidnightRedeemAction | MidnightRepayWithdrawCollateralAction | MidnightCancelOfferAction;
382
+ /** Metadata discriminators carried by transactions returned by the SDK. */
383
+ export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | SetterRatifierRatifyRootAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MempoolSubmitOffersAction | MidnightRedeemAction | MidnightRepayWithdrawCollateralAction | MidnightCancelOfferAction;
362
384
  export interface Transaction<TAction extends BaseAction = TransactionAction> {
363
385
  readonly to: Address;
364
386
  readonly value: bigint;
@@ -379,41 +401,64 @@ export type DepositAmountArgs = {
379
401
  nativeAmount: bigint;
380
402
  amount?: bigint;
381
403
  };
404
+ /** Mutually exclusive ERC-20 or native funding accepted by fixed bundles entrypoints. */
405
+ export type BundlesFundingArgs = {
406
+ readonly amount: bigint;
407
+ readonly nativeAmount?: never;
408
+ } | {
409
+ readonly nativeAmount: bigint;
410
+ readonly amount?: never;
411
+ };
412
+ /** Controls token requirements generated for a bundles-funded action. */
413
+ export interface BundlesTokenRequirementsOptions {
414
+ /** Prefer ERC-2612 when the funded token exposes a compatible nonce. */
415
+ readonly useSimplePermit?: boolean;
416
+ /** Explicit unused Permit2 SignatureTransfer unordered nonce. */
417
+ readonly permit2Nonce?: bigint;
418
+ }
419
+ /** Mutually exclusive source amount accepted by a Vault V1 to Vault V2 migration. */
420
+ export type VaultV1MigrateToV2AmountArgs = {
421
+ readonly shares: bigint;
422
+ readonly assets?: never;
423
+ } | {
424
+ readonly assets: bigint;
425
+ readonly shares?: never;
426
+ };
382
427
  export interface PermitArgs {
383
- owner: Address;
384
- nonce: bigint;
385
- asset: Address;
386
- signature: Hex;
387
- amount: bigint;
388
- deadline: bigint;
428
+ readonly owner: Address;
429
+ readonly nonce: bigint;
430
+ readonly asset: Address;
431
+ readonly signature: Hex;
432
+ readonly amount: bigint;
433
+ readonly deadline: bigint;
389
434
  }
390
435
  export interface Permit2Args {
391
- owner: Address;
392
- nonce: bigint;
393
- asset: Address;
394
- signature: Hex;
395
- amount: bigint;
396
- deadline: bigint;
397
- expiration: bigint;
436
+ readonly owner: Address;
437
+ readonly nonce: bigint;
438
+ readonly asset: Address;
439
+ readonly signature: Hex;
440
+ readonly amount: bigint;
441
+ readonly deadline: bigint;
442
+ readonly expiration: bigint;
398
443
  }
399
444
  /**
400
445
  * Signed Morpho Blue authorization payload produced when an integrator opts into offchain
401
- * signatures (`supportSignature: true`). Consumed by the action layer to emit a
402
- * `setAuthorizationWithSig` bundler call in place of a standalone `setAuthorization` transaction.
446
+ * signatures (`supportSignature: true`). Bundler3 consumes it through `setAuthorizationWithSig`;
447
+ * direct BlueBundlesV1 writes encode it into their signed-authorization struct.
403
448
  */
404
449
  export interface AuthorizationSignatureArgs {
405
450
  /** Account granting the authorization (the position owner). */
406
- owner: Address;
407
- /** Account being authorized to operate on Morpho on the owner's behalf (GeneralAdapter1). */
408
- authorized: Address;
451
+ readonly owner: Address;
452
+ /** Account being authorized to operate on Morpho on the owner's behalf. */
453
+ readonly authorized: Address;
409
454
  /** Whether the authorization is granted (`true`) or revoked (`false`). */
410
- isAuthorized: boolean;
455
+ readonly isAuthorized: boolean;
411
456
  /** Morpho authorization nonce consumed by the signature. */
412
- nonce: bigint;
457
+ readonly nonce: bigint;
413
458
  /** Signature deadline timestamp in seconds. */
414
- deadline: bigint;
459
+ readonly deadline: bigint;
415
460
  /** EIP-712 signature over the Morpho `Authorization` typed data. */
416
- signature: Hex;
461
+ readonly signature: Hex;
417
462
  }
418
463
  /** Signed and encoded Ecrecover offer-root payload used by Midnight maker flows. */
419
464
  export interface MidnightOfferRootSignatureArgs {
@@ -423,9 +468,11 @@ export interface MidnightOfferRootSignatureArgs {
423
468
  readonly payload: Hex;
424
469
  }
425
470
  export interface PermitAction extends BaseAction<"permit", {
426
- spender: Address;
427
- amount: bigint;
428
- deadline: bigint;
471
+ readonly spender: Address;
472
+ readonly amount: bigint;
473
+ readonly deadline: bigint;
474
+ /** Permit nonce captured by a prepared requirement, when available. */
475
+ readonly nonce?: bigint;
429
476
  }> {
430
477
  }
431
478
  export interface Permit2Action extends BaseAction<"permit2", {
@@ -435,9 +482,17 @@ export interface Permit2Action extends BaseAction<"permit2", {
435
482
  expiration: bigint;
436
483
  }> {
437
484
  }
485
+ /** Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull. */
486
+ export interface Permit2SignatureTransferAction extends BaseAction<"permit2SignatureTransfer", {
487
+ readonly spender: Address;
488
+ readonly amount: bigint;
489
+ readonly nonce: bigint;
490
+ readonly deadline: bigint;
491
+ }> {
492
+ }
438
493
  /**
439
- * Signable Morpho authorization requirement. Emitted by the entity layer when a bundled path
440
- * needs GeneralAdapter1 authorized and the client opts into offchain signatures.
494
+ * Signable Morpho authorization requirement. Its `authorized` operator is route-specific:
495
+ * GeneralAdapter1 for Bundler3 flows or BlueBundlesV1 for direct Blue writes.
441
496
  */
442
497
  export interface AuthorizationAction extends BaseAction<"authorization", {
443
498
  authorized: Address;
@@ -453,18 +508,30 @@ export interface MidnightOfferRootSignatureAction extends BaseAction<"midnightOf
453
508
  }> {
454
509
  }
455
510
  /** Action metadata supported by signature requirements. */
456
- export type SignatureRequirementAction = PermitAction | Permit2Action | AuthorizationAction | MidnightOfferRootSignatureAction;
511
+ export type SignatureRequirementAction = PermitAction | Permit2Action | Permit2SignatureTransferAction | AuthorizationAction | MidnightOfferRootSignatureAction;
457
512
  /** Argument payloads returned by signature requirements. */
458
513
  export type RequirementSignatureArgs = PermitArgs | Permit2Args | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
459
- /** A signed ERC-2612 permit or Permit2 approval requirement. */
460
- export interface PermitRequirementSignature {
461
- args: PermitArgs | Permit2Args;
462
- action: PermitAction | Permit2Action;
463
- }
464
- /** A signed Morpho authorization requirement (consumed via `setAuthorizationWithSig`). */
514
+ /** A signed ERC-2612 permit requirement. */
515
+ export interface Erc2612RequirementSignature {
516
+ readonly args: Readonly<PermitArgs>;
517
+ readonly action: PermitAction;
518
+ }
519
+ /** A signed Permit2 AllowanceTransfer requirement used by Bundler3. */
520
+ export interface Permit2AllowanceRequirementSignature {
521
+ readonly args: Readonly<Permit2Args>;
522
+ readonly action: Permit2Action;
523
+ }
524
+ /** A signed ERC-2612 permit or Permit2 AllowanceTransfer requirement. */
525
+ export type PermitRequirementSignature = Erc2612RequirementSignature | Permit2AllowanceRequirementSignature;
526
+ /** A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts. */
527
+ export interface Permit2SignatureTransferRequirementSignature {
528
+ readonly args: Readonly<PermitArgs>;
529
+ readonly action: Permit2SignatureTransferAction;
530
+ }
531
+ /** A signed Morpho authorization consumed by Bundler3 or a direct BlueBundlesV1 call. */
465
532
  export interface AuthorizationRequirementSignature {
466
- args: AuthorizationSignatureArgs;
467
- action: AuthorizationAction;
533
+ readonly args: AuthorizationSignatureArgs;
534
+ readonly action: AuthorizationAction;
468
535
  }
469
536
  /** A signed Midnight Ecrecover offer-root requirement. */
470
537
  export interface MidnightOfferRootSignature {
@@ -473,13 +540,14 @@ export interface MidnightOfferRootSignature {
473
540
  }
474
541
  /**
475
542
  * The deep-frozen output of `Requirement.sign()`. Discriminated on `action.type`:
476
- * `"permit"` / `"permit2"` carry Bundler3 token-approval args, `"authorization"` carries the
477
- * signed Morpho authorization, and Midnight adds `"midnightOfferRootSignature"`.
543
+ * `"permit"` / `"permit2"` carry token-approval args, `"permit2SignatureTransfer"` carries a
544
+ * bundles SignatureTransfer, `"authorization"` carries the signed Morpho authorization,
545
+ * and Midnight adds `"midnightOfferRootSignature"`.
478
546
  */
479
547
  export type RequirementSignature<TAction extends SignatureRequirementAction | undefined = undefined, TArgs extends RequirementSignatureArgs | undefined = undefined> = TAction extends SignatureRequirementAction ? TArgs extends RequirementSignatureArgs ? {
480
548
  args: TArgs;
481
549
  action: TAction;
482
- } : never : PermitRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
550
+ } : never : PermitRequirementSignature | Permit2SignatureTransferRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
483
551
  type RequirementResult<TSignatureOrAction extends RequirementSignature | SignatureRequirementAction, TArgs extends RequirementSignatureArgs | undefined> = TSignatureOrAction extends SignatureRequirementAction ? RequirementSignature<TSignatureOrAction, Extract<TArgs, RequirementSignatureArgs>> : Extract<TSignatureOrAction, RequirementSignature>;
484
552
  /**
485
553
  * A signable approval / authorization requirement. `sign()` returns the matching
@@ -496,14 +564,18 @@ export interface Requirement<TSignatureOrAction extends RequirementSignature | S
496
564
  }
497
565
  /** Bundler3 token signature requirement. */
498
566
  export type Bundler3TokenSignatureRequirement = Requirement<PermitRequirementSignature>;
567
+ /** ERC-2612 or Permit2 SignatureTransfer requirement consumed by a fixed bundles contract. */
568
+ export type BundlesTokenSignatureRequirement = Requirement<BundlesTokenRequirementSignature>;
499
569
  /** Midnight Ecrecover offer-root signature requirement. */
500
570
  export type MidnightOfferRootRequirement = Requirement<MidnightOfferRootSignatureAction, MidnightOfferRootSignatureArgs>;
501
- /** Permit or Permit2 token signature requirement. */
502
- export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement;
571
+ /** Any token signature requirement supported by an SDK transaction route. */
572
+ export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement | BundlesTokenSignatureRequirement;
503
573
  /** Bundler3 token signature result. */
504
574
  export type Bundler3TokenRequirementSignature = PermitRequirementSignature;
505
- /** Permit or Permit2 token signature result. */
506
- export type TokenRequirementSignature = Bundler3TokenRequirementSignature;
575
+ /** Token signature result consumed by a fixed bundles contract. */
576
+ export type BundlesTokenRequirementSignature = Erc2612RequirementSignature | Permit2SignatureTransferRequirementSignature;
577
+ /** Any token signature result supported by an SDK transaction route. */
578
+ export type TokenRequirementSignature = Bundler3TokenRequirementSignature | BundlesTokenRequirementSignature;
507
579
  /** Any signature result returned by an action-output signature requirement. */
508
580
  export type AnyRequirementSignature = TokenRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
509
581
  /** Any signature requirement returned by an entity action output. */
@@ -541,6 +613,23 @@ export declare function isRequirementSignature(requirement: ActionRequirement |
541
613
  * @returns `true` when `signature.action.type` is `"permit"` or `"permit2"`.
542
614
  */
543
615
  export declare function isPermitSignature(signature: RequirementSignature): signature is PermitRequirementSignature;
616
+ /**
617
+ * Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
618
+ *
619
+ * @param signature - The signed requirement to test.
620
+ * @returns `true` when `signature.action.type` is `"permit2SignatureTransfer"`.
621
+ * @example
622
+ * ```ts
623
+ * import {
624
+ * isPermit2SignatureTransferSignature,
625
+ * type RequirementSignature,
626
+ * } from "@morpho-org/morpho-sdk";
627
+ *
628
+ * const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
629
+ * isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
630
+ * ```
631
+ */
632
+ export declare function isPermit2SignatureTransferSignature(signature: RequirementSignature): signature is Permit2SignatureTransferRequirementSignature;
544
633
  /**
545
634
  * Narrows a {@link RequirementSignature} to a signed Morpho authorization.
546
635
  *
@@ -557,12 +646,14 @@ export declare function isAuthorizationSignature(signature: RequirementSignature
557
646
  export declare function isMidnightOfferRootSignature(signature: RequirementSignature): signature is MidnightOfferRootSignature;
558
647
  /** The typed requirement-signature slots a transaction builder consumes, split from a `buildTx` array. */
559
648
  export interface SelectedRequirementSignatures {
560
- /** The single permit / Permit2 signature, when present. */
561
- permit?: PermitRequirementSignature;
649
+ /** The single ERC-2612 or Permit2 AllowanceTransfer signature, when present. */
650
+ readonly permit?: PermitRequirementSignature;
651
+ /** The single Permit2 SignatureTransfer signature, when present. */
652
+ readonly permit2SignatureTransfer?: Permit2SignatureTransferRequirementSignature;
562
653
  /** The single Morpho authorization signature, when present. */
563
- authorization?: AuthorizationRequirementSignature;
654
+ readonly authorization?: AuthorizationRequirementSignature;
564
655
  /** The single Midnight offer-root signature, when present. */
565
- midnightOfferRoot?: MidnightOfferRootSignature;
656
+ readonly midnightOfferRoot?: MidnightOfferRootSignature;
566
657
  }
567
658
  /**
568
659
  * Splits a `buildTx` signature array into its typed requirement-signature slots, rejecting
@@ -575,10 +666,11 @@ export interface SelectedRequirementSignatures {
575
666
  *
576
667
  * @param signatures - The signatures passed to `buildTx`.
577
668
  * @param accepts - Which signature kinds this operation consumes.
578
- * @param accepts.permit - Whether a permit / Permit2 signature is consumed.
669
+ * @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
670
+ * @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
579
671
  * @param accepts.authorization - Whether a Morpho authorization signature is consumed.
580
672
  * @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
581
- * @returns The single permit and/or authorization signature, when present.
673
+ * @returns The accepted signature in each typed slot, when present.
582
674
  * @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
583
675
  * @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
584
676
  * @example
@@ -592,8 +684,9 @@ export interface SelectedRequirementSignatures {
592
684
  * ```
593
685
  */
594
686
  export declare function selectRequirementSignatures(signatures: readonly RequirementSignature[] | undefined, accepts: {
595
- permit?: boolean;
596
- authorization?: boolean;
597
- midnightOfferRoot?: boolean;
687
+ readonly permit?: boolean;
688
+ readonly permit2SignatureTransfer?: boolean;
689
+ readonly authorization?: boolean;
690
+ readonly midnightOfferRoot?: boolean;
598
691
  }): SelectedRequirementSignatures;
599
692
  export {};