@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
package/lib/cjs/abis.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compoundV3MigrationAdapterAbi = exports.compoundV2MigrationAdapterAbi = exports.aaveV3OptimizerMigrationAdapterAbi = exports.aaveV3MigrationAdapterAbi = exports.aaveV2MigrationAdapterAbi = exports.erc20WrapperAdapterAbi = exports.paraswapAdapterAbi = exports.ethereumGeneralAdapter1Abi = exports.generalAdapter1Abi = exports.coreAdapterAbi = exports.bundler3Abi = exports.vaultExitBundlesV1Abi = exports.setterRatifierAbi = exports.midnightSetterRatifierAbi = exports.midnightBundlesAbi = exports.midnightAbi = exports.ecrecoverRatifierAbi = exports.midnightEcrecoverRatifierAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.vaultV1PublicAllocatorAbi = exports.vaultV1AdapterFactoryAbi = exports.vaultV1AdapterAbi = exports.publicAllocatorAbi = exports.preLiquidationFactoryAbi = exports.bluePreLiquidationFactoryAbi = exports.preLiquidationAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.blueAdaptiveCurveIrmAbi = exports.marketParamsAbi = exports.blueMarketParamsAbi = void 0;
4
- exports.blueBundlesV1Abi = void 0;
3
+ exports.compoundV2MigrationAdapterAbi = exports.aaveV3OptimizerMigrationAdapterAbi = exports.aaveV3MigrationAdapterAbi = exports.aaveV2MigrationAdapterAbi = exports.erc20WrapperAdapterAbi = exports.paraswapAdapterAbi = exports.ethereumGeneralAdapter1Abi = exports.generalAdapter1Abi = exports.coreAdapterAbi = exports.bundler3Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.setterRatifierAbi = exports.midnightSetterRatifierAbi = exports.midnightBundlesAbi = exports.midnightAbi = exports.ecrecoverRatifierAbi = exports.midnightEcrecoverRatifierAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.vaultV1PublicAllocatorAbi = exports.vaultV1AdapterFactoryAbi = exports.vaultV1AdapterAbi = exports.publicAllocatorAbi = exports.preLiquidationFactoryAbi = exports.bluePreLiquidationFactoryAbi = exports.preLiquidationAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.blueAdaptiveCurveIrmAbi = exports.marketParamsAbi = exports.blueMarketParamsAbi = void 0;
4
+ exports.blueBundlesV1Abi = exports.compoundV3MigrationAdapterAbi = void 0;
5
5
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
6
6
  Object.defineProperty(exports, "blueMarketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
7
7
  /** @deprecated Use `blueMarketParamsAbi` or the raw `/blue/abis` subpath. */
@@ -215,6 +215,146 @@ exports.vaultExitBundlesV1Abi = [
215
215
  stateMutability: "nonpayable",
216
216
  },
217
217
  ];
218
+ /**
219
+ * Pinned ABI for the VaultBundlesV1 entrypoints used by Vault V1 and Vault V2 actions.
220
+ *
221
+ * Sourced from `morpho-org/bundles` commit
222
+ * `f27e7bcf744310303e24faa522b71d702e696686`.
223
+ */
224
+ exports.vaultBundlesV1Abi = [
225
+ { type: "error", name: "AlreadyInitiated", inputs: [] },
226
+ { type: "error", name: "DeadlinePassed", inputs: [] },
227
+ { type: "error", name: "InconsistentAssets", inputs: [] },
228
+ { type: "error", name: "NotExactlyOneZero", inputs: [] },
229
+ { type: "error", name: "PctExceeded", inputs: [] },
230
+ { type: "error", name: "SlippageExceeded", inputs: [] },
231
+ {
232
+ type: "function",
233
+ name: "initiator",
234
+ inputs: [],
235
+ outputs: [{ name: "", type: "address", internalType: "address" }],
236
+ stateMutability: "view",
237
+ },
238
+ {
239
+ type: "function",
240
+ name: "vaultBundlesV1Deposit",
241
+ inputs: [
242
+ { name: "vault", type: "address", internalType: "address" },
243
+ { name: "assets", type: "uint256", internalType: "uint256" },
244
+ {
245
+ name: "maxSharePriceE27",
246
+ type: "uint256",
247
+ internalType: "uint256",
248
+ },
249
+ {
250
+ name: "assetPermit",
251
+ type: "tuple",
252
+ internalType: "struct TokenPermit",
253
+ components: [
254
+ { name: "kind", type: "uint8", internalType: "enum PermitKind" },
255
+ { name: "data", type: "bytes", internalType: "bytes" },
256
+ ],
257
+ },
258
+ {
259
+ name: "referralFeePct",
260
+ type: "uint256",
261
+ internalType: "uint256",
262
+ },
263
+ {
264
+ name: "referralFeeRecipient",
265
+ type: "address",
266
+ internalType: "address",
267
+ },
268
+ { name: "deadline", type: "uint256", internalType: "uint256" },
269
+ ],
270
+ outputs: [],
271
+ stateMutability: "payable",
272
+ },
273
+ {
274
+ type: "function",
275
+ name: "vaultBundlesV1Withdraw",
276
+ inputs: [
277
+ { name: "vault", type: "address", internalType: "address" },
278
+ { name: "assets", type: "uint256", internalType: "uint256" },
279
+ { name: "shares", type: "uint256", internalType: "uint256" },
280
+ {
281
+ name: "sharesPermit",
282
+ type: "tuple",
283
+ internalType: "struct Permit",
284
+ components: [
285
+ { name: "value", type: "uint256", internalType: "uint256" },
286
+ { name: "nonce", type: "uint256", internalType: "uint256" },
287
+ { name: "deadline", type: "uint256", internalType: "uint256" },
288
+ { name: "v", type: "uint8", internalType: "uint8" },
289
+ { name: "r", type: "bytes32", internalType: "bytes32" },
290
+ { name: "s", type: "bytes32", internalType: "bytes32" },
291
+ ],
292
+ },
293
+ {
294
+ name: "referralFeePct",
295
+ type: "uint256",
296
+ internalType: "uint256",
297
+ },
298
+ {
299
+ name: "referralFeeRecipient",
300
+ type: "address",
301
+ internalType: "address",
302
+ },
303
+ { name: "deadline", type: "uint256", internalType: "uint256" },
304
+ ],
305
+ outputs: [],
306
+ stateMutability: "nonpayable",
307
+ },
308
+ {
309
+ type: "function",
310
+ name: "vaultBundlesV1Migrate",
311
+ inputs: [
312
+ { name: "sourceVault", type: "address", internalType: "address" },
313
+ { name: "destVault", type: "address", internalType: "address" },
314
+ {
315
+ name: "assetsWithdrawn",
316
+ type: "uint256",
317
+ internalType: "uint256",
318
+ },
319
+ {
320
+ name: "sharesRedeemed",
321
+ type: "uint256",
322
+ internalType: "uint256",
323
+ },
324
+ {
325
+ name: "destMaxSharePriceE27",
326
+ type: "uint256",
327
+ internalType: "uint256",
328
+ },
329
+ {
330
+ name: "sharesPermit",
331
+ type: "tuple",
332
+ internalType: "struct Permit",
333
+ components: [
334
+ { name: "value", type: "uint256", internalType: "uint256" },
335
+ { name: "nonce", type: "uint256", internalType: "uint256" },
336
+ { name: "deadline", type: "uint256", internalType: "uint256" },
337
+ { name: "v", type: "uint8", internalType: "uint8" },
338
+ { name: "r", type: "bytes32", internalType: "bytes32" },
339
+ { name: "s", type: "bytes32", internalType: "bytes32" },
340
+ ],
341
+ },
342
+ {
343
+ name: "referralFeePct",
344
+ type: "uint256",
345
+ internalType: "uint256",
346
+ },
347
+ {
348
+ name: "referralFeeRecipient",
349
+ type: "address",
350
+ internalType: "address",
351
+ },
352
+ { name: "deadline", type: "uint256", internalType: "uint256" },
353
+ ],
354
+ outputs: [],
355
+ stateMutability: "nonpayable",
356
+ },
357
+ ];
218
358
  /** ABI for the Bundler3 multicall contract. */
219
359
  exports.bundler3Abi = [
220
360
  {
@@ -1,84 +1,85 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
2
  import type { Address } from "viem";
3
- import { type AuthorizationRequirementSignature, type BlueBorrowAction, type BlueReallocationPlan, type Metadata, type Transaction } from "../../types/index.js";
3
+ import type { AuthorizationRequirementSignature, BlueBorrowAction, Metadata, Transaction, VaultV2BlueReallocation } from "../../types/index.js";
4
4
  /** Parameters for {@link blueBorrow}. */
5
5
  export interface BlueBorrowParams {
6
- market: {
6
+ /** Chain and scoped Morpho Blue market. */
7
+ readonly market: {
7
8
  readonly chainId: number;
8
9
  readonly marketParams: MarketParams;
9
10
  };
10
- args: {
11
- /** Amount of loan asset to borrow. */
12
- amount: bigint;
13
- /** Address that receives the borrowed assets. */
14
- receiver: Address;
15
- /** Minimum borrow share price (in ray). Protects against share price manipulation. */
16
- minSharePrice: bigint;
17
- /**
18
- * Homogeneous Vault V1 or Vault V2 reallocations to execute before borrowing.
19
- * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2 for new integrations.
20
- */
21
- reallocations?: BlueReallocationPlan;
22
- /**
23
- * Optional signed Morpho authorization. When provided, a `setAuthorizationWithSig` call is
24
- * prepended to the bundle so GeneralAdapter1 is authorized in-bundle instead of via a
25
- * standalone `setAuthorization` transaction.
26
- */
27
- authorizationSignature?: AuthorizationRequirementSignature;
11
+ /** Direct BlueBundlesV1 borrow arguments. */
12
+ readonly args: {
13
+ /** User whose debt position is increased. */
14
+ readonly userAddress: Address;
15
+ /** Gross loan assets borrowed before penalties and referral fees. */
16
+ readonly borrowAssets: bigint;
17
+ /** Maximum post-operation LTV enforced by BlueBundlesV1. */
18
+ readonly maxLtv: bigint;
19
+ /** Optional validated Vault V2 BluePublicAllocator reallocations. */
20
+ readonly reallocations?: Iterable<VaultV2BlueReallocation>;
21
+ /** Final call deadline in Unix seconds. */
22
+ readonly deadline: bigint;
23
+ /** Optional WAD-scaled referral fee, strictly below 100%. */
24
+ readonly referralFeePct?: bigint;
25
+ /** Recipient required when `referralFeePct` is positive. */
26
+ readonly referralFeeRecipient?: Address;
27
+ /** Optional Morpho authorization signature for BlueBundlesV1. */
28
+ readonly authorizationSignature?: AuthorizationRequirementSignature;
28
29
  };
29
- metadata?: Metadata;
30
+ /** Optional transaction metadata suffix. */
31
+ readonly metadata?: Metadata;
30
32
  }
31
33
  /**
32
- * Prepares a borrow transaction for a Morpho Blue market.
34
+ * Encodes a pure borrow through BlueBundlesV1.
33
35
  *
34
- * Routed through bundler3 via `morphoBorrow`. The bundler uses the transaction initiator as
35
- * `onBehalf`. Uses `minSharePrice` to protect against share price manipulation between
36
- * transaction construction and execution.
36
+ * Delegates to {@link blueSupplyCollateralBorrow} with a zero collateral leg. Vault V2 allocator
37
+ * penalties and referral fees reduce the assets received, and no Bundler3 action is encoded.
37
38
  *
38
- * A `reallocations` plan contains either PublicAllocator V1 entries or Vault V2
39
- * BluePublicAllocator entries, never both. The calls run before the borrow.
40
- * V1 fees accumulate in `tx.value`; V2 penalties are paid in the target loan
41
- * token and donated directly to each vault.
42
- *
43
- * @param params.market.chainId - The chain the market lives on.
44
- * @param params.market.marketParams - Market params (loanToken, collateralToken, oracle, irm, lltv).
45
- * @param params.args.amount - Loan asset amount to borrow, in the loan token's smallest unit.
46
- * @param params.args.receiver - Address that receives the borrowed assets.
47
- * @param params.args.minSharePrice - Minimum borrow share price (in ray). Slippage protection.
48
- * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
49
- * execute before borrowing. Vault V1 inputs are deprecated; use Vault V2 for new integrations.
50
- * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
51
- * a `setAuthorizationWithSig` call is prepended to the bundle.
52
- * @param params.metadata - Optional analytics metadata attached to the bundle.
53
- * @returns A deep-frozen `Transaction<BlueBorrowAction>` with `to`, `value`, `data`, and the
54
- * typed `action` discriminator the simulation layer consumes.
55
- * @throws {NonPositiveInputError} when `amount <= 0n` or any reallocation withdrawal amount
56
- * is non-positive.
57
- * @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
58
- * @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
59
- * @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
60
- * @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
61
- * @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
62
- * @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
63
- * @throws {NegativeInputError} when `minSharePrice < 0n`, a V1 fee, or a V2 penalty is negative.
64
- * @throws {EmptyReallocationWithdrawalsError} when any `reallocation.withdrawals` is empty.
65
- * @throws {ReallocationWithdrawalOnTargetMarketError} when any reallocation withdrawal references
66
- * the target market.
67
- * @throws {UnsortedReallocationWithdrawalsError} when reallocation withdrawals are not strictly
68
- * sorted by market id.
39
+ * @param params - Borrow encoding parameters.
40
+ * @param params.market.chainId - Chain containing BlueBundlesV1.
41
+ * @param params.market.marketParams - Scoped Morpho Blue market parameters.
42
+ * @param params.args.userAddress - User whose debt position is increased.
43
+ * @param params.args.borrowAssets - Gross loan assets borrowed.
44
+ * @param params.args.maxLtv - Maximum post-operation LTV.
45
+ * @param params.args.reallocations - Vault V2 reallocations executed before borrowing.
46
+ * @param params.args.deadline - Final call deadline in Unix seconds.
47
+ * @param params.args.referralFeePct - Optional WAD-scaled referral fee.
48
+ * @param params.args.referralFeeRecipient - Recipient required for a positive fee.
49
+ * @param params.args.authorizationSignature - Optional Blue authorization signature.
50
+ * @param params.metadata - Optional transaction metadata.
51
+ * @returns A deep-frozen `Readonly<Transaction<BlueBorrowAction>>` whose calldata invokes the
52
+ * combined BlueBundlesV1 entrypoint with a zero collateral leg.
53
+ * @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
54
+ * @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
55
+ * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
56
+ * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
57
+ * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
58
+ * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
59
+ * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
60
+ * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
61
+ * @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
62
+ * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
63
+ * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
64
+ * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
65
+ * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
69
66
  * @example
70
67
  * ```ts
68
+ * import { markets } from "@morpho-org/morpho-test";
71
69
  * import { blueBorrow } from "@morpho-org/morpho-sdk";
70
+ * import { zeroAddress } from "viem";
71
+ * import { mainnet } from "viem/chains";
72
72
  *
73
73
  * const tx = blueBorrow({
74
- * market: { chainId: 1, marketParams },
74
+ * market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
75
75
  * args: {
76
- * amount: 1_000_000n,
77
- * receiver: borrower,
78
- * minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinBorrowSharePrice` from market state + slippage tolerance
76
+ * userAddress: zeroAddress,
77
+ * borrowAssets: 1_000_000n,
78
+ * maxLtv: 850000000000000000n,
79
+ * deadline: 1_900_000_000n,
79
80
  * },
80
81
  * });
81
82
  * // tx satisfies Readonly<Transaction<BlueBorrowAction>>
82
83
  * ```
83
84
  */
84
- export declare const blueBorrow: ({ market: { chainId, marketParams }, args: { amount, receiver, minSharePrice, reallocations, authorizationSignature, }, metadata, }: BlueBorrowParams) => Readonly<Transaction<BlueBorrowAction>>;
85
+ export declare const blueBorrow: (params: BlueBorrowParams) => Readonly<Transaction<BlueBorrowAction>>;
@@ -2,102 +2,70 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.blueBorrow = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
- const index_js_1 = require("../../bundler/index.js");
6
- const index_js_2 = require("../../helpers/index.js");
7
- const index_js_3 = require("../../types/index.js");
8
- const getBlueAuthorizationAction_js_1 = require("../signatures/getBlueAuthorizationAction.js");
9
- const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
5
+ const supplyCollateralBorrow_js_1 = require("./supplyCollateralBorrow.js");
10
6
  /**
11
- * Prepares a borrow transaction for a Morpho Blue market.
7
+ * Encodes a pure borrow through BlueBundlesV1.
12
8
  *
13
- * Routed through bundler3 via `morphoBorrow`. The bundler uses the transaction initiator as
14
- * `onBehalf`. Uses `minSharePrice` to protect against share price manipulation between
15
- * transaction construction and execution.
9
+ * Delegates to {@link blueSupplyCollateralBorrow} with a zero collateral leg. Vault V2 allocator
10
+ * penalties and referral fees reduce the assets received, and no Bundler3 action is encoded.
16
11
  *
17
- * A `reallocations` plan contains either PublicAllocator V1 entries or Vault V2
18
- * BluePublicAllocator entries, never both. The calls run before the borrow.
19
- * V1 fees accumulate in `tx.value`; V2 penalties are paid in the target loan
20
- * token and donated directly to each vault.
21
- *
22
- * @param params.market.chainId - The chain the market lives on.
23
- * @param params.market.marketParams - Market params (loanToken, collateralToken, oracle, irm, lltv).
24
- * @param params.args.amount - Loan asset amount to borrow, in the loan token's smallest unit.
25
- * @param params.args.receiver - Address that receives the borrowed assets.
26
- * @param params.args.minSharePrice - Minimum borrow share price (in ray). Slippage protection.
27
- * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
28
- * execute before borrowing. Vault V1 inputs are deprecated; use Vault V2 for new integrations.
29
- * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
30
- * a `setAuthorizationWithSig` call is prepended to the bundle.
31
- * @param params.metadata - Optional analytics metadata attached to the bundle.
32
- * @returns A deep-frozen `Transaction<BlueBorrowAction>` with `to`, `value`, `data`, and the
33
- * typed `action` discriminator the simulation layer consumes.
34
- * @throws {NonPositiveInputError} when `amount <= 0n` or any reallocation withdrawal amount
35
- * is non-positive.
36
- * @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
37
- * @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
38
- * @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
39
- * @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
40
- * @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
41
- * @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
42
- * @throws {NegativeInputError} when `minSharePrice < 0n`, a V1 fee, or a V2 penalty is negative.
43
- * @throws {EmptyReallocationWithdrawalsError} when any `reallocation.withdrawals` is empty.
44
- * @throws {ReallocationWithdrawalOnTargetMarketError} when any reallocation withdrawal references
45
- * the target market.
46
- * @throws {UnsortedReallocationWithdrawalsError} when reallocation withdrawals are not strictly
47
- * sorted by market id.
12
+ * @param params - Borrow encoding parameters.
13
+ * @param params.market.chainId - Chain containing BlueBundlesV1.
14
+ * @param params.market.marketParams - Scoped Morpho Blue market parameters.
15
+ * @param params.args.userAddress - User whose debt position is increased.
16
+ * @param params.args.borrowAssets - Gross loan assets borrowed.
17
+ * @param params.args.maxLtv - Maximum post-operation LTV.
18
+ * @param params.args.reallocations - Vault V2 reallocations executed before borrowing.
19
+ * @param params.args.deadline - Final call deadline in Unix seconds.
20
+ * @param params.args.referralFeePct - Optional WAD-scaled referral fee.
21
+ * @param params.args.referralFeeRecipient - Recipient required for a positive fee.
22
+ * @param params.args.authorizationSignature - Optional Blue authorization signature.
23
+ * @param params.metadata - Optional transaction metadata.
24
+ * @returns A deep-frozen `Readonly<Transaction<BlueBorrowAction>>` whose calldata invokes the
25
+ * combined BlueBundlesV1 entrypoint with a zero collateral leg.
26
+ * @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
27
+ * @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
28
+ * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
29
+ * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
30
+ * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
31
+ * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
32
+ * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
33
+ * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
34
+ * @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
35
+ * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
36
+ * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
37
+ * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
38
+ * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
48
39
  * @example
49
40
  * ```ts
41
+ * import { markets } from "@morpho-org/morpho-test";
50
42
  * import { blueBorrow } from "@morpho-org/morpho-sdk";
43
+ * import { zeroAddress } from "viem";
44
+ * import { mainnet } from "viem/chains";
51
45
  *
52
46
  * const tx = blueBorrow({
53
- * market: { chainId: 1, marketParams },
47
+ * market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
54
48
  * args: {
55
- * amount: 1_000_000n,
56
- * receiver: borrower,
57
- * minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinBorrowSharePrice` from market state + slippage tolerance
49
+ * userAddress: zeroAddress,
50
+ * borrowAssets: 1_000_000n,
51
+ * maxLtv: 850000000000000000n,
52
+ * deadline: 1_900_000_000n,
58
53
  * },
59
54
  * });
60
55
  * // tx satisfies Readonly<Transaction<BlueBorrowAction>>
61
56
  * ```
62
57
  */
63
- const blueBorrow = ({ market: { chainId, marketParams }, args: { amount, receiver, minSharePrice, reallocations, authorizationSignature, }, metadata, }) => {
64
- if (amount <= 0n) {
65
- throw new index_js_3.NonPositiveInputError("amount", amount);
66
- }
67
- if (minSharePrice < 0n) {
68
- throw new index_js_3.NegativeInputError("minSharePrice", minSharePrice);
69
- }
70
- const actions = [];
71
- if (authorizationSignature) {
72
- actions.push((0, getBlueAuthorizationAction_js_1.getBlueAuthorizationAction)(chainId, authorizationSignature));
73
- }
74
- const { actions: reallocationActions, fee: reallocationFee, penaltyAssets: reallocationPenaltyAssets, } = (0, buildReallocationActions_js_1.buildBlueReallocationActions)({
75
- chainId,
76
- reallocations,
77
- targetMarketParams: marketParams,
78
- });
79
- actions.push(...reallocationActions);
80
- actions.push({
81
- type: "morphoBorrow",
82
- args: [marketParams, amount, 0n, minSharePrice, receiver, false],
58
+ const blueBorrow = (params) => {
59
+ const transaction = (0, supplyCollateralBorrow_js_1.blueSupplyCollateralBorrow)({
60
+ ...params,
61
+ args: {
62
+ ...params.args,
63
+ collateralAssets: 0n,
64
+ },
83
65
  });
84
- let tx = index_js_1.BundlerAction.encodeBundle(chainId, actions);
85
- if (metadata) {
86
- tx = (0, index_js_2.addTransactionMetadata)(tx, metadata);
87
- }
88
66
  return (0, morpho_ts_1.deepFreeze)({
89
- ...tx,
90
- action: {
91
- type: "blueBorrow",
92
- args: {
93
- market: marketParams.id,
94
- amount,
95
- receiver,
96
- minSharePrice,
97
- reallocationFee,
98
- reallocationPenaltyAssets,
99
- },
100
- },
67
+ ...transaction,
68
+ action: { ...transaction.action, type: "blueBorrow" },
101
69
  });
102
70
  };
103
71
  exports.blueBorrow = blueBorrow;
@@ -0,0 +1,86 @@
1
+ import { MarketParams } from "@morpho-org/blue-sdk";
2
+ import { type Address, type Hex } from "viem";
3
+ import { type AuthorizationRequirementSignature, type BaseAction, type BundlesTokenRequirementSignature, type Metadata, type RequirementSignature, type Transaction, type VaultV2BlueReallocation } from "../../types/index.js";
4
+ import { type BundlesTokenPermit } from "../bundles/index.js";
5
+ /** @internal */
6
+ export interface BlueBundlesV1CommonParams {
7
+ chainId: number;
8
+ userAddress: Address;
9
+ deadline: bigint;
10
+ referralFeePct?: bigint;
11
+ referralFeeRecipient?: Address;
12
+ metadata?: Metadata;
13
+ }
14
+ /** @internal */
15
+ export interface NormalizedBlueBundlesV1CommonParams {
16
+ referralFeePct: bigint;
17
+ referralFeeRecipient: Address;
18
+ }
19
+ type BlueBundlesV1TokenPermit = BundlesTokenPermit;
20
+ interface BlueBundlesV1SignedAuthorization {
21
+ signature: {
22
+ v: number;
23
+ r: Hex;
24
+ s: Hex;
25
+ };
26
+ nonce: bigint;
27
+ deadline: bigint;
28
+ }
29
+ /** @internal */
30
+ export declare const normalizeBlueBundlesV1CommonParams: (params: BlueBundlesV1CommonParams) => NormalizedBlueBundlesV1CommonParams;
31
+ /** @internal */
32
+ export declare const validateBlueBundlesV1NativeFunding: (params: {
33
+ chainId: number;
34
+ token: Address;
35
+ fundedAmount: bigint;
36
+ nativeAmount?: bigint;
37
+ requirementSignature?: BundlesTokenRequirementSignature;
38
+ }) => bigint;
39
+ /** @internal */
40
+ export declare const getBlueBundlesV1TokenPermit: (params: {
41
+ chainId: number;
42
+ userAddress: Address;
43
+ token: Address;
44
+ amount: bigint;
45
+ requirementSignature?: BundlesTokenRequirementSignature;
46
+ }) => BlueBundlesV1TokenPermit;
47
+ /** @internal */
48
+ export declare const getBlueBundlesV1SignedAuthorization: (params: {
49
+ chainId: number;
50
+ userAddress: Address;
51
+ authorizationSignature?: AuthorizationRequirementSignature;
52
+ }) => BlueBundlesV1SignedAuthorization;
53
+ /** @internal */
54
+ export declare const getBlueBundlesV1PublicAllocations: (reallocations: readonly VaultV2BlueReallocation[], targetMarketParams: MarketParams) => {
55
+ vault: `0x${string}`;
56
+ adapter: `0x${string}`;
57
+ marketParams: MarketParams;
58
+ fromIdle: boolean;
59
+ sourceAdapter: `0x${string}`;
60
+ sourceMarketParams: MarketParams;
61
+ assets: bigint;
62
+ penalty: bigint;
63
+ }[];
64
+ /** @internal */
65
+ export declare const getBlueBundlesV1PenaltyAssets: (reallocations: readonly {
66
+ assets: bigint;
67
+ penalty: bigint;
68
+ }[]) => bigint;
69
+ /** @internal */
70
+ export declare const getBlueBundlesV1ReferralFeeAssets: (assets: bigint, referralFeePct: bigint) => bigint;
71
+ /** @internal */
72
+ export declare const selectBlueBundlesV1RequirementSignatures: (signatures: readonly RequirementSignature[] | undefined, accepts: {
73
+ token?: boolean;
74
+ authorization?: boolean;
75
+ }) => {
76
+ token?: BundlesTokenRequirementSignature;
77
+ authorization?: AuthorizationRequirementSignature;
78
+ };
79
+ /** @internal */
80
+ export declare const finalizeBlueBundlesV1Transaction: <TAction extends BaseAction>(params: {
81
+ common: BlueBundlesV1CommonParams;
82
+ value: bigint;
83
+ data: Hex;
84
+ action: TAction;
85
+ }) => Readonly<Transaction<TAction>>;
86
+ export {};