@morpho-org/morpho-sdk 5.4.1 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +23 -7
  2. package/lib/cjs/abis.d.ts +314 -1
  3. package/lib/cjs/abis.js +169 -1
  4. package/lib/cjs/actions/blue/borrow.d.ts +21 -15
  5. package/lib/cjs/actions/blue/borrow.js +25 -18
  6. package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +1 -1
  7. package/lib/cjs/actions/blue/buildAssetFundingActions.js +1 -1
  8. package/lib/cjs/actions/blue/buildReallocationActions.d.ts +62 -19
  9. package/lib/cjs/actions/blue/buildReallocationActions.js +123 -27
  10. package/lib/cjs/actions/blue/refinance.d.ts +14 -7
  11. package/lib/cjs/actions/blue/refinance.js +18 -10
  12. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +28 -19
  13. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +39 -23
  14. package/lib/cjs/actions/blue/withdraw.d.ts +20 -13
  15. package/lib/cjs/actions/blue/withdraw.js +23 -18
  16. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  17. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +9 -2
  18. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
  19. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +131 -0
  20. package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
  21. package/lib/cjs/actions/requirements/encode/index.js +1 -0
  22. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
  23. package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -3
  24. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
  25. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +91 -0
  26. package/lib/cjs/actions/signatures/index.d.ts +1 -0
  27. package/lib/cjs/actions/signatures/index.js +1 -0
  28. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +54 -0
  29. package/lib/cjs/actions/vaultV1/inKindRedeem.js +96 -0
  30. package/lib/cjs/actions/vaultV1/index.d.ts +1 -0
  31. package/lib/cjs/actions/vaultV1/index.js +1 -0
  32. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +56 -0
  33. package/lib/cjs/actions/vaultV2/inKindRedeem.js +97 -0
  34. package/lib/cjs/actions/vaultV2/index.d.ts +1 -0
  35. package/lib/cjs/actions/vaultV2/index.js +1 -0
  36. package/lib/cjs/bundler/actions.d.ts +118 -2
  37. package/lib/cjs/bundler/actions.js +212 -6
  38. package/lib/cjs/bundler/types.d.ts +20 -0
  39. package/lib/cjs/constants.d.ts +1 -1
  40. package/lib/cjs/constants.js +3 -1
  41. package/lib/cjs/entities/blue/blue.d.ts +365 -76
  42. package/lib/cjs/entities/blue/blue.js +285 -52
  43. package/lib/cjs/entities/index.d.ts +2 -1
  44. package/lib/cjs/entities/index.js +6 -3
  45. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +82 -4
  46. package/lib/cjs/entities/vaultV1/vaultV1.js +164 -0
  47. package/lib/cjs/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
  48. package/lib/cjs/entities/{reallocationData.js → vaultV1ReallocationData.js} +30 -18
  49. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +89 -3
  50. package/lib/cjs/entities/vaultV2/vaultV2.js +181 -0
  51. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +511 -0
  52. package/lib/cjs/entities/vaultV2BlueReallocationData.js +1311 -0
  53. package/lib/{esm/helpers/computeReallocations.d.ts → cjs/helpers/computeVaultV1Reallocations.d.ts} +14 -8
  54. package/lib/cjs/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +27 -13
  55. package/lib/cjs/helpers/constant.d.ts +5 -3
  56. package/lib/cjs/helpers/constant.js +6 -4
  57. package/lib/cjs/helpers/index.d.ts +3 -2
  58. package/lib/cjs/helpers/index.js +8 -3
  59. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
  60. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +73 -0
  61. package/lib/cjs/helpers/validate.d.ts +31 -15
  62. package/lib/cjs/helpers/validate.js +140 -27
  63. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  64. package/lib/cjs/helpers/validateRequirementSpender.js +2 -1
  65. package/lib/cjs/types/action.d.ts +33 -1
  66. package/lib/cjs/types/error.d.ts +363 -5
  67. package/lib/cjs/types/error.js +455 -6
  68. package/lib/cjs/types/sharedLiquidity.d.ts +72 -8
  69. package/lib/cjs/utils.d.ts +2 -2
  70. package/lib/cjs/utils.js +6 -4
  71. package/lib/esm/abis.d.ts +314 -1
  72. package/lib/esm/abis.js +167 -1
  73. package/lib/esm/actions/blue/borrow.d.ts +21 -15
  74. package/lib/esm/actions/blue/borrow.js +26 -19
  75. package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +1 -1
  76. package/lib/esm/actions/blue/buildAssetFundingActions.js +1 -1
  77. package/lib/esm/actions/blue/buildReallocationActions.d.ts +62 -19
  78. package/lib/esm/actions/blue/buildReallocationActions.js +119 -25
  79. package/lib/esm/actions/blue/refinance.d.ts +14 -7
  80. package/lib/esm/actions/blue/refinance.js +19 -11
  81. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +28 -19
  82. package/lib/esm/actions/blue/supplyCollateralBorrow.js +40 -24
  83. package/lib/esm/actions/blue/withdraw.d.ts +20 -13
  84. package/lib/esm/actions/blue/withdraw.js +24 -19
  85. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  86. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -2
  87. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
  88. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +127 -0
  89. package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
  90. package/lib/esm/actions/requirements/encode/index.js +1 -0
  91. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
  92. package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -3
  93. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
  94. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +87 -0
  95. package/lib/esm/actions/signatures/index.d.ts +1 -0
  96. package/lib/esm/actions/signatures/index.js +1 -0
  97. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +54 -0
  98. package/lib/esm/actions/vaultV1/inKindRedeem.js +92 -0
  99. package/lib/esm/actions/vaultV1/index.d.ts +1 -0
  100. package/lib/esm/actions/vaultV1/index.js +1 -0
  101. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +56 -0
  102. package/lib/esm/actions/vaultV2/inKindRedeem.js +93 -0
  103. package/lib/esm/actions/vaultV2/index.d.ts +1 -0
  104. package/lib/esm/actions/vaultV2/index.js +1 -0
  105. package/lib/esm/bundler/actions.d.ts +118 -2
  106. package/lib/esm/bundler/actions.js +215 -9
  107. package/lib/esm/bundler/types.d.ts +20 -0
  108. package/lib/esm/constants.d.ts +1 -1
  109. package/lib/esm/constants.js +1 -1
  110. package/lib/esm/entities/blue/blue.d.ts +362 -73
  111. package/lib/esm/entities/blue/blue.js +288 -55
  112. package/lib/esm/entities/index.d.ts +2 -1
  113. package/lib/esm/entities/index.js +2 -1
  114. package/lib/esm/entities/vaultV1/vaultV1.d.ts +80 -2
  115. package/lib/esm/entities/vaultV1/vaultV1.js +170 -6
  116. package/lib/esm/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
  117. package/lib/esm/entities/{reallocationData.js → vaultV1ReallocationData.js} +33 -16
  118. package/lib/esm/entities/vaultV2/vaultV2.d.ts +88 -2
  119. package/lib/esm/entities/vaultV2/vaultV2.js +187 -6
  120. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +511 -0
  121. package/lib/esm/entities/vaultV2BlueReallocationData.js +1307 -0
  122. package/lib/{cjs/helpers/computeReallocations.d.ts → esm/helpers/computeVaultV1Reallocations.d.ts} +14 -8
  123. package/lib/esm/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +25 -11
  124. package/lib/esm/helpers/constant.d.ts +5 -3
  125. package/lib/esm/helpers/constant.js +5 -3
  126. package/lib/esm/helpers/index.d.ts +3 -2
  127. package/lib/esm/helpers/index.js +3 -2
  128. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
  129. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +70 -0
  130. package/lib/esm/helpers/validate.d.ts +31 -15
  131. package/lib/esm/helpers/validate.js +141 -30
  132. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  133. package/lib/esm/helpers/validateRequirementSpender.js +2 -1
  134. package/lib/esm/types/action.d.ts +33 -1
  135. package/lib/esm/types/error.d.ts +363 -5
  136. package/lib/esm/types/error.js +428 -4
  137. package/lib/esm/types/sharedLiquidity.d.ts +72 -8
  138. package/lib/esm/utils.d.ts +2 -2
  139. package/lib/esm/utils.js +2 -2
  140. package/package.json +9 -11
@@ -1,6 +1,6 @@
1
- import { getChainAddresses, } from "@morpho-org/blue-sdk";
2
- import { blueAbi, erc2612Abi, permit2Abi, publicAllocatorAbi, } from "@morpho-org/blue-sdk-viem";
3
- import { encodeAbiParameters, encodeFunctionData, isAddressEqual, keccak256, parseSignature, serializeSignature, zeroHash, } from "viem";
1
+ import { getChainAddresses, VaultV2BluePublicAllocatorConfigUtils, } from "@morpho-org/blue-sdk";
2
+ import { blueAbi, erc2612Abi, permit2Abi, vaultV1PublicAllocatorAbi, vaultV2BluePublicAllocatorAbi, } from "@morpho-org/blue-sdk-viem";
3
+ import { encodeAbiParameters, encodeFunctionData, erc20Abi, isAddressEqual, keccak256, parseSignature, serializeSignature, zeroHash, } from "viem";
4
4
  import { bundler3Abi, coreAdapterAbi, generalAdapter1Abi } from "../abis.js";
5
5
  import { BundlerErrors } from "../types/error.js";
6
6
  const reenterAbiInputs = bundler3Abi.find((item) => item.type === "function" && item.name === "reenter").inputs;
@@ -41,8 +41,7 @@ const consumeCallValue = (state, call) => {
41
41
  *
42
42
  * @remarks
43
43
  * The namespace covers only the Bundler3 actions required by `morpho-sdk`.
44
- * It does not expose operation population or simulation helpers from
45
- * `@morpho-org/bundler-sdk-viem`.
44
+ * It does not expose operation population or broad simulation helpers.
46
45
  */
47
46
  export var BundlerAction;
48
47
  (function (BundlerAction) {
@@ -194,6 +193,12 @@ export var BundlerAction;
194
193
  case "reallocateTo": {
195
194
  return BundlerAction.publicAllocatorReallocateTo(chainId, ...args);
196
195
  }
196
+ case "vaultV2BluePublicAllocatorReallocate": {
197
+ return BundlerAction.vaultV2BluePublicAllocatorReallocate(chainId, ...args);
198
+ }
199
+ case "vaultV2BluePublicAllocatorAllocateFromIdle": {
200
+ return BundlerAction.vaultV2BluePublicAllocatorAllocateFromIdle(chainId, ...args);
201
+ }
197
202
  case "wrapNative": {
198
203
  return BundlerAction.wrapNative(chainId, ...args);
199
204
  }
@@ -1096,15 +1101,15 @@ export var BundlerAction;
1096
1101
  */
1097
1102
  // biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
1098
1103
  function publicAllocatorReallocateTo(chainId, vault, fee, withdrawals, supplyMarketParams, skipRevert = false) {
1099
- const { publicAllocator } = getChainAddresses(chainId);
1100
- if (publicAllocator == null) {
1104
+ const { vaultV1PublicAllocator } = getChainAddresses(chainId);
1105
+ if (vaultV1PublicAllocator == null) {
1101
1106
  throw new BundlerErrors.UnexpectedAction("reallocateTo", chainId);
1102
1107
  }
1103
1108
  return [
1104
1109
  {
1105
- to: publicAllocator,
1110
+ to: vaultV1PublicAllocator,
1106
1111
  data: encodeFunctionData({
1107
- abi: publicAllocatorAbi,
1112
+ abi: vaultV1PublicAllocatorAbi,
1108
1113
  functionName: "reallocateTo",
1109
1114
  args: [vault, withdrawals, supplyMarketParams],
1110
1115
  }),
@@ -1115,6 +1120,207 @@ export var BundlerAction;
1115
1120
  ];
1116
1121
  }
1117
1122
  BundlerAction.publicAllocatorReallocateTo = publicAllocatorReallocateTo;
1123
+ /**
1124
+ * Encodes a Vault V2 Blue Public Allocator market-to-market reallocation.
1125
+ *
1126
+ * @remarks Bundler3 must already hold the computed penalty assets. The
1127
+ * high-level Blue builders add the corresponding GeneralAdapter1 transfer.
1128
+ *
1129
+ * @param chainId - Chain whose canonical Blue Public Allocator is called.
1130
+ * @param vault - Vault whose liquidity is reallocated.
1131
+ * @param deallocateAdapter - Vault V2 adapter supplying the source market.
1132
+ * @param deallocateMarket - Source Morpho Blue market parameters.
1133
+ * @param allocateAdapter - Vault V2 adapter supplying the target market.
1134
+ * @param allocateMarket - Target Morpho Blue market parameters.
1135
+ * @param assets - Assets to reallocate, bounded by `uint128` by the high-level action.
1136
+ * @param penalty - Vault-configured proportional penalty, scaled by WAD.
1137
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
1138
+ * @returns A zero reset and exact approval when needed, then the allocator call.
1139
+ * @throws {BundlerErrors.UnexpectedAction} when the chain has no Blue Public Allocator deployment.
1140
+ * @throws {BundlerErrors.SkippableAllocatorPenalty} when `skipRevert` is true and a token approval is required.
1141
+ * @example
1142
+ * ```ts
1143
+ * import { ChainId, type InputMarketParams } from "@morpho-org/blue-sdk";
1144
+ * import {
1145
+ * BundlerAction,
1146
+ * type BundlerCall,
1147
+ * } from "@morpho-org/morpho-sdk/bundler";
1148
+ * import type { Address } from "viem";
1149
+ *
1150
+ * const keyrockUsdcVault =
1151
+ * "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145" satisfies Address;
1152
+ * const sourceAdapterFixture =
1153
+ * "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" satisfies Address;
1154
+ * const targetAdapterFixture =
1155
+ * "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" satisfies Address;
1156
+ * const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" satisfies Address;
1157
+ * const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" satisfies Address;
1158
+ * const wbtc = "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" satisfies Address;
1159
+ * const ethUsdOracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" satisfies Address;
1160
+ * const adaptiveCurveIrm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" satisfies Address;
1161
+ * const sourceMarket = {
1162
+ * loanToken: usdc,
1163
+ * collateralToken: weth,
1164
+ * oracle: ethUsdOracle,
1165
+ * irm: adaptiveCurveIrm,
1166
+ * lltv: 860_000_000_000_000_000n,
1167
+ * } satisfies InputMarketParams;
1168
+ * const targetMarket = {
1169
+ * ...sourceMarket,
1170
+ * collateralToken: wbtc,
1171
+ * } satisfies InputMarketParams;
1172
+ *
1173
+ * const calls: BundlerCall[] = BundlerAction.vaultV2BluePublicAllocatorReallocate(
1174
+ * ChainId.EthMainnet,
1175
+ * keyrockUsdcVault,
1176
+ * sourceAdapterFixture,
1177
+ * sourceMarket,
1178
+ * targetAdapterFixture,
1179
+ * targetMarket,
1180
+ * 1_000_000n,
1181
+ * 1_000_000_000_000_000n,
1182
+ * );
1183
+ * // Bundler3 resets and approves 1_000 USDC units, then calls `reallocate` with zero native value.
1184
+ * ```
1185
+ */
1186
+ // biome-ignore lint/complexity/useMaxParams: mirrors the protocol call
1187
+ function vaultV2BluePublicAllocatorReallocate(chainId, vault, deallocateAdapter, deallocateMarket, allocateAdapter, allocateMarket, assets, penalty, skipRevert = false) {
1188
+ const { vaultV2BluePublicAllocator: allocator } = getChainAddresses(chainId);
1189
+ if (allocator == null) {
1190
+ throw new BundlerErrors.UnexpectedAction("vaultV2BluePublicAllocatorReallocate", chainId);
1191
+ }
1192
+ const calls = [];
1193
+ const penaltyAssets = VaultV2BluePublicAllocatorConfigUtils.getPenaltyAssets({ penalty }, assets);
1194
+ if (skipRevert && penaltyAssets > 0n) {
1195
+ throw new BundlerErrors.SkippableAllocatorPenalty(penaltyAssets);
1196
+ }
1197
+ if (penaltyAssets > 0n) {
1198
+ for (const amount of [0n, penaltyAssets])
1199
+ calls.push({
1200
+ to: allocateMarket.loanToken,
1201
+ data: encodeFunctionData({
1202
+ abi: erc20Abi,
1203
+ functionName: "approve",
1204
+ args: [allocator, amount],
1205
+ }),
1206
+ value: 0n,
1207
+ skipRevert,
1208
+ callbackHash: zeroHash,
1209
+ });
1210
+ }
1211
+ calls.push({
1212
+ to: allocator,
1213
+ data: encodeFunctionData({
1214
+ abi: vaultV2BluePublicAllocatorAbi,
1215
+ functionName: "reallocate",
1216
+ args: [
1217
+ vault,
1218
+ deallocateAdapter,
1219
+ deallocateMarket,
1220
+ allocateAdapter,
1221
+ allocateMarket,
1222
+ assets,
1223
+ penalty,
1224
+ ],
1225
+ }),
1226
+ value: 0n,
1227
+ skipRevert,
1228
+ callbackHash: zeroHash,
1229
+ });
1230
+ return calls;
1231
+ }
1232
+ BundlerAction.vaultV2BluePublicAllocatorReallocate = vaultV2BluePublicAllocatorReallocate;
1233
+ /**
1234
+ * Encodes a Vault V2 Blue Public Allocator allocation from vault idle liquidity.
1235
+ *
1236
+ * @remarks Bundler3 must already hold the computed penalty assets. The
1237
+ * high-level Blue builders add the corresponding GeneralAdapter1 transfer.
1238
+ *
1239
+ * @param chainId - Chain whose canonical Blue Public Allocator is called.
1240
+ * @param vault - Vault whose idle liquidity is allocated.
1241
+ * @param adapter - Vault V2 adapter supplying the target market.
1242
+ * @param market - Target Morpho Blue market parameters.
1243
+ * @param assets - Assets to allocate, bounded by `uint128` by the high-level action.
1244
+ * @param penalty - Vault-configured proportional penalty, scaled by WAD.
1245
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
1246
+ * @returns A zero reset and exact approval when needed, then the allocator call.
1247
+ * @throws {BundlerErrors.UnexpectedAction} when the chain has no Blue Public Allocator deployment.
1248
+ * @throws {BundlerErrors.SkippableAllocatorPenalty} when `skipRevert` is true and a token approval is required.
1249
+ * @example
1250
+ * ```ts
1251
+ * import { ChainId, type InputMarketParams } from "@morpho-org/blue-sdk";
1252
+ * import {
1253
+ * BundlerAction,
1254
+ * type BundlerCall,
1255
+ * } from "@morpho-org/morpho-sdk/bundler";
1256
+ * import type { Address } from "viem";
1257
+ *
1258
+ * const keyrockUsdcVault =
1259
+ * "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145" satisfies Address;
1260
+ * const targetAdapterFixture =
1261
+ * "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" satisfies Address;
1262
+ * const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" satisfies Address;
1263
+ * const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" satisfies Address;
1264
+ * const ethUsdOracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" satisfies Address;
1265
+ * const adaptiveCurveIrm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" satisfies Address;
1266
+ * const targetMarket = {
1267
+ * loanToken: usdc,
1268
+ * collateralToken: weth,
1269
+ * oracle: ethUsdOracle,
1270
+ * irm: adaptiveCurveIrm,
1271
+ * lltv: 860_000_000_000_000_000n,
1272
+ * } satisfies InputMarketParams;
1273
+ *
1274
+ * const calls: BundlerCall[] = BundlerAction.vaultV2BluePublicAllocatorAllocateFromIdle(
1275
+ * ChainId.EthMainnet,
1276
+ * keyrockUsdcVault,
1277
+ * targetAdapterFixture,
1278
+ * targetMarket,
1279
+ * 1_000_000n,
1280
+ * 1_000_000_000_000_000n,
1281
+ * );
1282
+ * // Bundler3 resets and approves 1_000 USDC units, then calls `allocateFromIdle` with zero native value.
1283
+ * ```
1284
+ */
1285
+ // biome-ignore lint/complexity/useMaxParams: mirrors the protocol call
1286
+ function vaultV2BluePublicAllocatorAllocateFromIdle(chainId, vault, adapter, market, assets, penalty, skipRevert = false) {
1287
+ const { vaultV2BluePublicAllocator: allocator } = getChainAddresses(chainId);
1288
+ if (allocator == null) {
1289
+ throw new BundlerErrors.UnexpectedAction("vaultV2BluePublicAllocatorAllocateFromIdle", chainId);
1290
+ }
1291
+ const calls = [];
1292
+ const penaltyAssets = VaultV2BluePublicAllocatorConfigUtils.getPenaltyAssets({ penalty }, assets);
1293
+ if (skipRevert && penaltyAssets > 0n) {
1294
+ throw new BundlerErrors.SkippableAllocatorPenalty(penaltyAssets);
1295
+ }
1296
+ if (penaltyAssets > 0n) {
1297
+ for (const amount of [0n, penaltyAssets])
1298
+ calls.push({
1299
+ to: market.loanToken,
1300
+ data: encodeFunctionData({
1301
+ abi: erc20Abi,
1302
+ functionName: "approve",
1303
+ args: [allocator, amount],
1304
+ }),
1305
+ value: 0n,
1306
+ skipRevert,
1307
+ callbackHash: zeroHash,
1308
+ });
1309
+ }
1310
+ calls.push({
1311
+ to: allocator,
1312
+ data: encodeFunctionData({
1313
+ abi: vaultV2BluePublicAllocatorAbi,
1314
+ functionName: "allocateFromIdle",
1315
+ args: [vault, adapter, market, assets, penalty],
1316
+ }),
1317
+ value: 0n,
1318
+ skipRevert,
1319
+ callbackHash: zeroHash,
1320
+ });
1321
+ return calls;
1322
+ }
1323
+ BundlerAction.vaultV2BluePublicAllocatorAllocateFromIdle = vaultV2BluePublicAllocatorAllocateFromIdle;
1118
1324
  /**
1119
1325
  * Encodes a GeneralAdapter1 native-token wrap call.
1120
1326
  *
@@ -180,6 +180,26 @@ export interface ActionArgs {
180
180
  supplyMarket: InputMarketParams,
181
181
  skipRevert?: boolean
182
182
  ];
183
+ /** Vault V2 Blue Public Allocator market-to-market reallocation with a WAD-scaled penalty. */
184
+ readonly vaultV2BluePublicAllocatorReallocate: [
185
+ vault: Address,
186
+ deallocateAdapter: Address,
187
+ deallocateMarket: InputMarketParams,
188
+ allocateAdapter: Address,
189
+ allocateMarket: InputMarketParams,
190
+ assets: bigint,
191
+ penalty: bigint,
192
+ skipRevert?: boolean
193
+ ];
194
+ /** Vault V2 Blue Public Allocator idle-to-market allocation with a WAD-scaled penalty. */
195
+ readonly vaultV2BluePublicAllocatorAllocateFromIdle: [
196
+ vault: Address,
197
+ adapter: Address,
198
+ market: InputMarketParams,
199
+ assets: bigint,
200
+ penalty: bigint,
201
+ skipRevert?: boolean
202
+ ];
183
203
  /** GeneralAdapter1 native wrap of `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
184
204
  readonly wrapNative: [
185
205
  amount: bigint,
@@ -1,4 +1,4 @@
1
1
  export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, isMarketId, LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType, } from "@morpho-org/blue-sdk";
2
2
  export { CBP, COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH, MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE, MAX_SETTLEMENT_FEES, MAX_TICK, OFFER_TYPEHASH, PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS, } from "@morpho-org/midnight-sdk";
3
3
  export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, CDN_BASE_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, OPTIMIZERS_API_BASE_URL, OPTIMIZERS_BASE_URL, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
4
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
4
+ export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
@@ -1,4 +1,4 @@
1
1
  export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, isMarketId, LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType, } from "@morpho-org/blue-sdk";
2
2
  export { CBP, COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH, MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE, MAX_SETTLEMENT_FEES, MAX_TICK, OFFER_TYPEHASH, PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS, } from "@morpho-org/midnight-sdk";
3
3
  export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, CDN_BASE_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, OPTIMIZERS_API_BASE_URL, OPTIMIZERS_BASE_URL, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
4
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
4
+ export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";