@morpho-org/morpho-sdk 10.5.0 → 10.6.0-next.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 (192) hide show
  1. package/README.md +44 -1
  2. package/lib/cjs/abis.d.ts +794 -1
  3. package/lib/cjs/abis.js +815 -1
  4. package/lib/cjs/actions/blue/close.d.ts +169 -0
  5. package/lib/cjs/actions/blue/close.js +270 -0
  6. package/lib/cjs/actions/blue/common.js +2 -2
  7. package/lib/cjs/actions/blue/delever.d.ts +156 -0
  8. package/lib/cjs/actions/blue/delever.js +223 -0
  9. package/lib/cjs/actions/blue/index.d.ts +3 -0
  10. package/lib/cjs/actions/blue/index.js +3 -0
  11. package/lib/cjs/actions/blue/lever.d.ts +184 -0
  12. package/lib/cjs/actions/blue/lever.js +272 -0
  13. package/lib/cjs/actions/blue/leverageIntent.d.ts +65 -0
  14. package/lib/cjs/actions/blue/leverageIntent.js +103 -0
  15. package/lib/cjs/actions/requirements/blue/encodeLeverageAuthorization.d.ts +39 -0
  16. package/lib/cjs/actions/requirements/blue/encodeLeverageAuthorization.js +59 -0
  17. package/lib/cjs/actions/requirements/blue/getLeverageRequirements.d.ts +104 -0
  18. package/lib/cjs/actions/requirements/blue/getLeverageRequirements.js +193 -0
  19. package/lib/cjs/actions/requirements/blue/getLeverageRequirementsApproval.d.ts +45 -0
  20. package/lib/cjs/actions/requirements/blue/getLeverageRequirementsApproval.js +66 -0
  21. package/lib/cjs/actions/requirements/blue/index.d.ts +3 -0
  22. package/lib/cjs/actions/requirements/blue/index.js +17 -0
  23. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -2
  24. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +3 -2
  25. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +11 -6
  26. package/lib/cjs/actions/requirements/getRequirementsApproval.js +29 -5
  27. package/lib/cjs/addresses.d.ts +1 -1
  28. package/lib/cjs/addresses.js +6 -1
  29. package/lib/cjs/blue/abis.d.ts +1 -1
  30. package/lib/cjs/blue/abis.js +5 -1
  31. package/lib/cjs/blue/addresses.d.ts +1 -1
  32. package/lib/cjs/blue/addresses.js +6 -1
  33. package/lib/cjs/blue/entities.d.ts +4 -4
  34. package/lib/cjs/blue/entities.js +3 -1
  35. package/lib/cjs/blue/errors.d.ts +2 -2
  36. package/lib/cjs/blue/errors.js +5 -1
  37. package/lib/cjs/blue/fetch.d.ts +2 -2
  38. package/lib/cjs/blue/fetch.js +3 -1
  39. package/lib/cjs/blue/utils.d.ts +1 -1
  40. package/lib/cjs/blue/utils.js +2 -1
  41. package/lib/cjs/constants.d.ts +1 -1
  42. package/lib/cjs/constants.js +6 -2
  43. package/lib/cjs/entities/blue/blue.d.ts +486 -2
  44. package/lib/cjs/entities/blue/blue.js +529 -34
  45. package/lib/cjs/entities/index.d.ts +5 -5
  46. package/lib/cjs/entities/index.js +3 -1
  47. package/lib/cjs/entities/requirements/assertContractCode.d.ts +0 -23
  48. package/lib/cjs/entities/requirements/assertContractCode.js +3 -28
  49. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +34 -8
  50. package/lib/cjs/entities/vaultV2/vaultV2.js +39 -1
  51. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +120 -2
  52. package/lib/cjs/entities/vaultV2BlueReallocationData.js +232 -4
  53. package/lib/cjs/errors.d.ts +4 -4
  54. package/lib/cjs/errors.js +7 -5
  55. package/lib/cjs/fetch.d.ts +2 -2
  56. package/lib/cjs/fetch.js +3 -1
  57. package/lib/cjs/helpers/constant.d.ts +34 -0
  58. package/lib/cjs/helpers/constant.js +35 -1
  59. package/lib/cjs/helpers/deadShares.js +3 -0
  60. package/lib/cjs/helpers/getZeroExLeverageBundle.d.ts +13 -0
  61. package/lib/cjs/helpers/getZeroExLeverageBundle.js +27 -0
  62. package/lib/cjs/helpers/index.d.ts +4 -1
  63. package/lib/cjs/helpers/index.js +28 -1
  64. package/lib/cjs/helpers/leverage/index.d.ts +1 -0
  65. package/lib/cjs/helpers/leverage/index.js +11 -0
  66. package/lib/cjs/helpers/leverage/limits.d.ts +472 -0
  67. package/lib/cjs/helpers/leverage/limits.js +715 -0
  68. package/lib/cjs/helpers/leverage/positionMarket.d.ts +17 -0
  69. package/lib/cjs/helpers/leverage/positionMarket.js +28 -0
  70. package/lib/cjs/helpers/leverage/reallocations.d.ts +159 -0
  71. package/lib/cjs/helpers/leverage/reallocations.js +276 -0
  72. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  73. package/lib/cjs/helpers/validateRequirementSpender.js +4 -0
  74. package/lib/cjs/helpers/zeroExQuote.d.ts +250 -0
  75. package/lib/cjs/helpers/zeroExQuote.js +763 -0
  76. package/lib/cjs/index.d.ts +1 -0
  77. package/lib/cjs/index.js +5 -2
  78. package/lib/cjs/midnight/errors.d.ts +2 -1
  79. package/lib/cjs/midnight/errors.js +5 -4
  80. package/lib/cjs/reads/assertContractCode.d.ts +25 -0
  81. package/lib/cjs/reads/assertContractCode.js +30 -0
  82. package/lib/cjs/reads/fetchZeroExQuote.d.ts +123 -0
  83. package/lib/cjs/reads/fetchZeroExQuote.js +330 -0
  84. package/lib/cjs/types/action.d.ts +130 -1
  85. package/lib/cjs/types/error.d.ts +59 -0
  86. package/lib/cjs/types/error.js +82 -3
  87. package/lib/cjs/types/index.d.ts +2 -0
  88. package/lib/cjs/types/index.js +2 -0
  89. package/lib/cjs/types/leverageError.d.ts +1552 -0
  90. package/lib/cjs/types/leverageError.js +1711 -0
  91. package/lib/cjs/types/zeroEx.d.ts +171 -0
  92. package/lib/cjs/types/zeroEx.js +2 -0
  93. package/lib/cjs/utils.d.ts +2 -2
  94. package/lib/cjs/utils.js +4 -2
  95. package/lib/cjs/version.d.ts +1 -1
  96. package/lib/cjs/version.js +1 -1
  97. package/lib/esm/abis.d.ts +794 -1
  98. package/lib/esm/abis.js +810 -1
  99. package/lib/esm/actions/blue/close.d.ts +169 -0
  100. package/lib/esm/actions/blue/close.js +266 -0
  101. package/lib/esm/actions/blue/common.js +3 -3
  102. package/lib/esm/actions/blue/delever.d.ts +156 -0
  103. package/lib/esm/actions/blue/delever.js +219 -0
  104. package/lib/esm/actions/blue/index.d.ts +3 -0
  105. package/lib/esm/actions/blue/index.js +3 -0
  106. package/lib/esm/actions/blue/lever.d.ts +184 -0
  107. package/lib/esm/actions/blue/lever.js +268 -0
  108. package/lib/esm/actions/blue/leverageIntent.d.ts +65 -0
  109. package/lib/esm/actions/blue/leverageIntent.js +96 -0
  110. package/lib/esm/actions/requirements/blue/encodeLeverageAuthorization.d.ts +39 -0
  111. package/lib/esm/actions/requirements/blue/encodeLeverageAuthorization.js +55 -0
  112. package/lib/esm/actions/requirements/blue/getLeverageRequirements.d.ts +104 -0
  113. package/lib/esm/actions/requirements/blue/getLeverageRequirements.js +189 -0
  114. package/lib/esm/actions/requirements/blue/getLeverageRequirementsApproval.d.ts +45 -0
  115. package/lib/esm/actions/requirements/blue/getLeverageRequirementsApproval.js +62 -0
  116. package/lib/esm/actions/requirements/blue/index.d.ts +3 -0
  117. package/lib/esm/actions/requirements/blue/index.js +3 -0
  118. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -2
  119. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
  120. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +11 -6
  121. package/lib/esm/actions/requirements/getRequirementsApproval.js +29 -5
  122. package/lib/esm/addresses.d.ts +1 -1
  123. package/lib/esm/addresses.js +1 -1
  124. package/lib/esm/blue/abis.d.ts +1 -1
  125. package/lib/esm/blue/abis.js +1 -1
  126. package/lib/esm/blue/addresses.d.ts +1 -1
  127. package/lib/esm/blue/addresses.js +1 -1
  128. package/lib/esm/blue/entities.d.ts +4 -4
  129. package/lib/esm/blue/entities.js +2 -2
  130. package/lib/esm/blue/errors.d.ts +2 -2
  131. package/lib/esm/blue/errors.js +2 -2
  132. package/lib/esm/blue/fetch.d.ts +2 -2
  133. package/lib/esm/blue/fetch.js +2 -2
  134. package/lib/esm/blue/utils.d.ts +1 -1
  135. package/lib/esm/blue/utils.js +1 -1
  136. package/lib/esm/constants.d.ts +1 -1
  137. package/lib/esm/constants.js +1 -1
  138. package/lib/esm/entities/blue/blue.d.ts +486 -2
  139. package/lib/esm/entities/blue/blue.js +501 -6
  140. package/lib/esm/entities/index.d.ts +5 -5
  141. package/lib/esm/entities/index.js +2 -2
  142. package/lib/esm/entities/requirements/assertContractCode.d.ts +0 -23
  143. package/lib/esm/entities/requirements/assertContractCode.js +1 -25
  144. package/lib/esm/entities/vaultV2/vaultV2.d.ts +34 -8
  145. package/lib/esm/entities/vaultV2/vaultV2.js +40 -2
  146. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +120 -2
  147. package/lib/esm/entities/vaultV2BlueReallocationData.js +233 -5
  148. package/lib/esm/errors.d.ts +4 -4
  149. package/lib/esm/errors.js +4 -4
  150. package/lib/esm/fetch.d.ts +2 -2
  151. package/lib/esm/fetch.js +2 -2
  152. package/lib/esm/helpers/constant.d.ts +34 -0
  153. package/lib/esm/helpers/constant.js +34 -0
  154. package/lib/esm/helpers/deadShares.js +4 -1
  155. package/lib/esm/helpers/getZeroExLeverageBundle.d.ts +13 -0
  156. package/lib/esm/helpers/getZeroExLeverageBundle.js +23 -0
  157. package/lib/esm/helpers/index.d.ts +4 -1
  158. package/lib/esm/helpers/index.js +4 -1
  159. package/lib/esm/helpers/leverage/index.d.ts +1 -0
  160. package/lib/esm/helpers/leverage/index.js +1 -0
  161. package/lib/esm/helpers/leverage/limits.d.ts +472 -0
  162. package/lib/esm/helpers/leverage/limits.js +705 -0
  163. package/lib/esm/helpers/leverage/positionMarket.d.ts +17 -0
  164. package/lib/esm/helpers/leverage/positionMarket.js +24 -0
  165. package/lib/esm/helpers/leverage/reallocations.d.ts +159 -0
  166. package/lib/esm/helpers/leverage/reallocations.js +271 -0
  167. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  168. package/lib/esm/helpers/validateRequirementSpender.js +5 -1
  169. package/lib/esm/helpers/zeroExQuote.d.ts +250 -0
  170. package/lib/esm/helpers/zeroExQuote.js +754 -0
  171. package/lib/esm/index.d.ts +1 -0
  172. package/lib/esm/index.js +1 -0
  173. package/lib/esm/midnight/errors.d.ts +2 -1
  174. package/lib/esm/midnight/errors.js +2 -1
  175. package/lib/esm/reads/assertContractCode.d.ts +25 -0
  176. package/lib/esm/reads/assertContractCode.js +26 -0
  177. package/lib/esm/reads/fetchZeroExQuote.d.ts +123 -0
  178. package/lib/esm/reads/fetchZeroExQuote.js +326 -0
  179. package/lib/esm/types/action.d.ts +130 -1
  180. package/lib/esm/types/error.d.ts +59 -0
  181. package/lib/esm/types/error.js +76 -0
  182. package/lib/esm/types/index.d.ts +2 -0
  183. package/lib/esm/types/index.js +2 -0
  184. package/lib/esm/types/leverageError.d.ts +1552 -0
  185. package/lib/esm/types/leverageError.js +1660 -0
  186. package/lib/esm/types/zeroEx.d.ts +171 -0
  187. package/lib/esm/types/zeroEx.js +1 -0
  188. package/lib/esm/utils.d.ts +2 -2
  189. package/lib/esm/utils.js +2 -2
  190. package/lib/esm/version.d.ts +1 -1
  191. package/lib/esm/version.js +1 -1
  192. package/package.json +7 -7
package/lib/esm/abis.js CHANGED
@@ -19,7 +19,7 @@ export const bundlesPermitParameters = {
19
19
  ],
20
20
  };
21
21
  export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
22
- export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
22
+ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
23
23
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
24
24
  preLiquidationAbi as bluePreLiquidationAbi,
25
25
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
@@ -1068,3 +1068,812 @@ export const blueBundlesV1Abi = [
1068
1068
  outputs: [],
1069
1069
  },
1070
1070
  ];
1071
+ /**
1072
+ * Pinned ABI for the ZeroExLeverageBundlesV1 periphery contract: Morpho Blue lever, delever and close in one
1073
+ * transaction, swapping through 0x AllowanceHolder.
1074
+ *
1075
+ * Generated with `forge inspect` from `morpho-org/bundles` commit `3bf53141455051f8fc7a85cd00cc15bd89459238`,
1076
+ * `src/leverage/ZeroExLeverageBundlesV1.sol`: its constructor, getters, Morpho callbacks, three entry points,
1077
+ * `PublicAllocations` struct and custom errors, including those raised by `TokenLib`.
1078
+ *
1079
+ * @see https://github.com/morpho-org/bundles/blob/3bf53141455051f8fc7a85cd00cc15bd89459238/src/leverage/ZeroExLeverageBundlesV1.sol
1080
+ * @example
1081
+ * ```ts
1082
+ * import { zeroExLeverageBundlesV1Abi } from "@morpho-org/morpho-sdk/abis";
1083
+ *
1084
+ * console.log(zeroExLeverageBundlesV1Abi.length);
1085
+ * ```
1086
+ */
1087
+ export const zeroExLeverageBundlesV1Abi = [
1088
+ {
1089
+ type: "constructor",
1090
+ inputs: [
1091
+ {
1092
+ name: "_blue",
1093
+ type: "address",
1094
+ internalType: "address",
1095
+ },
1096
+ {
1097
+ name: "_publicAllocator",
1098
+ type: "address",
1099
+ internalType: "address",
1100
+ },
1101
+ ],
1102
+ stateMutability: "nonpayable",
1103
+ },
1104
+ {
1105
+ type: "error",
1106
+ name: "ApproveReturnedFalse",
1107
+ inputs: [],
1108
+ },
1109
+ {
1110
+ type: "error",
1111
+ name: "DeadlinePassed",
1112
+ inputs: [],
1113
+ },
1114
+ {
1115
+ type: "error",
1116
+ name: "ExcessiveInput",
1117
+ inputs: [],
1118
+ },
1119
+ {
1120
+ type: "error",
1121
+ name: "InconsistentBorrowInput",
1122
+ inputs: [],
1123
+ },
1124
+ {
1125
+ type: "error",
1126
+ name: "InconsistentPenaltyAssets",
1127
+ inputs: [],
1128
+ },
1129
+ {
1130
+ type: "error",
1131
+ name: "InconsistentTokens",
1132
+ inputs: [],
1133
+ },
1134
+ {
1135
+ type: "error",
1136
+ name: "InsufficientOutput",
1137
+ inputs: [],
1138
+ },
1139
+ {
1140
+ type: "error",
1141
+ name: "LtvExceeded",
1142
+ inputs: [],
1143
+ },
1144
+ {
1145
+ type: "error",
1146
+ name: "NoCode",
1147
+ inputs: [],
1148
+ },
1149
+ {
1150
+ type: "error",
1151
+ name: "Reentrancy",
1152
+ inputs: [],
1153
+ },
1154
+ {
1155
+ type: "error",
1156
+ name: "TransferFromReturnedFalse",
1157
+ inputs: [],
1158
+ },
1159
+ {
1160
+ type: "error",
1161
+ name: "TransferReturnedFalse",
1162
+ inputs: [],
1163
+ },
1164
+ {
1165
+ type: "error",
1166
+ name: "UnauthorizedCallback",
1167
+ inputs: [],
1168
+ },
1169
+ {
1170
+ type: "error",
1171
+ name: "ZeroMinCollateralToBuy",
1172
+ inputs: [],
1173
+ },
1174
+ {
1175
+ type: "function",
1176
+ name: "ALLOWANCE_HOLDER",
1177
+ inputs: [],
1178
+ outputs: [
1179
+ {
1180
+ name: "",
1181
+ type: "address",
1182
+ internalType: "address",
1183
+ },
1184
+ ],
1185
+ stateMutability: "view",
1186
+ },
1187
+ {
1188
+ type: "function",
1189
+ name: "BLUE",
1190
+ inputs: [],
1191
+ outputs: [
1192
+ {
1193
+ name: "",
1194
+ type: "address",
1195
+ internalType: "address",
1196
+ },
1197
+ ],
1198
+ stateMutability: "view",
1199
+ },
1200
+ {
1201
+ type: "function",
1202
+ name: "PUBLIC_ALLOCATOR",
1203
+ inputs: [],
1204
+ outputs: [
1205
+ {
1206
+ name: "",
1207
+ type: "address",
1208
+ internalType: "address",
1209
+ },
1210
+ ],
1211
+ stateMutability: "view",
1212
+ },
1213
+ {
1214
+ type: "function",
1215
+ name: "onMorphoFlashLoan",
1216
+ inputs: [
1217
+ {
1218
+ name: "",
1219
+ type: "uint256",
1220
+ internalType: "uint256",
1221
+ },
1222
+ {
1223
+ name: "flashLoanData",
1224
+ type: "bytes",
1225
+ internalType: "bytes",
1226
+ },
1227
+ ],
1228
+ outputs: [],
1229
+ stateMutability: "nonpayable",
1230
+ },
1231
+ {
1232
+ type: "function",
1233
+ name: "onMorphoRepay",
1234
+ inputs: [
1235
+ {
1236
+ name: "assets",
1237
+ type: "uint256",
1238
+ internalType: "uint256",
1239
+ },
1240
+ {
1241
+ name: "repayData",
1242
+ type: "bytes",
1243
+ internalType: "bytes",
1244
+ },
1245
+ ],
1246
+ outputs: [],
1247
+ stateMutability: "nonpayable",
1248
+ },
1249
+ {
1250
+ type: "function",
1251
+ name: "onMorphoSupplyCollateral",
1252
+ inputs: [
1253
+ {
1254
+ name: "",
1255
+ type: "uint256",
1256
+ internalType: "uint256",
1257
+ },
1258
+ {
1259
+ name: "leverData",
1260
+ type: "bytes",
1261
+ internalType: "bytes",
1262
+ },
1263
+ ],
1264
+ outputs: [],
1265
+ stateMutability: "nonpayable",
1266
+ },
1267
+ {
1268
+ type: "function",
1269
+ name: "zeroExLeverageBundlesV1Close",
1270
+ inputs: [
1271
+ {
1272
+ name: "marketParams",
1273
+ type: "tuple",
1274
+ internalType: "struct MarketParams",
1275
+ components: [
1276
+ {
1277
+ name: "loanToken",
1278
+ type: "address",
1279
+ internalType: "address",
1280
+ },
1281
+ {
1282
+ name: "collateralToken",
1283
+ type: "address",
1284
+ internalType: "address",
1285
+ },
1286
+ {
1287
+ name: "oracle",
1288
+ type: "address",
1289
+ internalType: "address",
1290
+ },
1291
+ {
1292
+ name: "irm",
1293
+ type: "address",
1294
+ internalType: "address",
1295
+ },
1296
+ {
1297
+ name: "lltv",
1298
+ type: "uint256",
1299
+ internalType: "uint256",
1300
+ },
1301
+ ],
1302
+ },
1303
+ {
1304
+ name: "maxCollateralIn",
1305
+ type: "uint256",
1306
+ internalType: "uint256",
1307
+ },
1308
+ {
1309
+ name: "minLoanOut",
1310
+ type: "uint256",
1311
+ internalType: "uint256",
1312
+ },
1313
+ {
1314
+ name: "swapData",
1315
+ type: "bytes",
1316
+ internalType: "bytes",
1317
+ },
1318
+ {
1319
+ name: "deadline",
1320
+ type: "uint256",
1321
+ internalType: "uint256",
1322
+ },
1323
+ ],
1324
+ outputs: [],
1325
+ stateMutability: "nonpayable",
1326
+ },
1327
+ {
1328
+ type: "function",
1329
+ name: "zeroExLeverageBundlesV1Delever",
1330
+ inputs: [
1331
+ {
1332
+ name: "marketParams",
1333
+ type: "tuple",
1334
+ internalType: "struct MarketParams",
1335
+ components: [
1336
+ {
1337
+ name: "loanToken",
1338
+ type: "address",
1339
+ internalType: "address",
1340
+ },
1341
+ {
1342
+ name: "collateralToken",
1343
+ type: "address",
1344
+ internalType: "address",
1345
+ },
1346
+ {
1347
+ name: "oracle",
1348
+ type: "address",
1349
+ internalType: "address",
1350
+ },
1351
+ {
1352
+ name: "irm",
1353
+ type: "address",
1354
+ internalType: "address",
1355
+ },
1356
+ {
1357
+ name: "lltv",
1358
+ type: "uint256",
1359
+ internalType: "uint256",
1360
+ },
1361
+ ],
1362
+ },
1363
+ {
1364
+ name: "maxCollateralToSell",
1365
+ type: "uint256",
1366
+ internalType: "uint256",
1367
+ },
1368
+ {
1369
+ name: "minRepayAssets",
1370
+ type: "uint256",
1371
+ internalType: "uint256",
1372
+ },
1373
+ {
1374
+ name: "swapData",
1375
+ type: "bytes",
1376
+ internalType: "bytes",
1377
+ },
1378
+ {
1379
+ name: "maxLtv",
1380
+ type: "uint256",
1381
+ internalType: "uint256",
1382
+ },
1383
+ {
1384
+ name: "deadline",
1385
+ type: "uint256",
1386
+ internalType: "uint256",
1387
+ },
1388
+ ],
1389
+ outputs: [],
1390
+ stateMutability: "nonpayable",
1391
+ },
1392
+ {
1393
+ type: "function",
1394
+ name: "zeroExLeverageBundlesV1Lever",
1395
+ inputs: [
1396
+ {
1397
+ name: "marketParams",
1398
+ type: "tuple",
1399
+ internalType: "struct MarketParams",
1400
+ components: [
1401
+ {
1402
+ name: "loanToken",
1403
+ type: "address",
1404
+ internalType: "address",
1405
+ },
1406
+ {
1407
+ name: "collateralToken",
1408
+ type: "address",
1409
+ internalType: "address",
1410
+ },
1411
+ {
1412
+ name: "oracle",
1413
+ type: "address",
1414
+ internalType: "address",
1415
+ },
1416
+ {
1417
+ name: "irm",
1418
+ type: "address",
1419
+ internalType: "address",
1420
+ },
1421
+ {
1422
+ name: "lltv",
1423
+ type: "uint256",
1424
+ internalType: "uint256",
1425
+ },
1426
+ ],
1427
+ },
1428
+ {
1429
+ name: "collateralAssets",
1430
+ type: "uint256",
1431
+ internalType: "uint256",
1432
+ },
1433
+ {
1434
+ name: "loanAssets",
1435
+ type: "uint256",
1436
+ internalType: "uint256",
1437
+ },
1438
+ {
1439
+ name: "minCollateralToBuy",
1440
+ type: "uint256",
1441
+ internalType: "uint256",
1442
+ },
1443
+ {
1444
+ name: "maxBorrowAssets",
1445
+ type: "uint256",
1446
+ internalType: "uint256",
1447
+ },
1448
+ {
1449
+ name: "swapData",
1450
+ type: "bytes",
1451
+ internalType: "bytes",
1452
+ },
1453
+ {
1454
+ name: "maxLtv",
1455
+ type: "uint256",
1456
+ internalType: "uint256",
1457
+ },
1458
+ {
1459
+ name: "reallocations",
1460
+ type: "tuple[]",
1461
+ internalType: "struct PublicAllocations[]",
1462
+ components: [
1463
+ {
1464
+ name: "vault",
1465
+ type: "address",
1466
+ internalType: "address",
1467
+ },
1468
+ {
1469
+ name: "adapter",
1470
+ type: "address",
1471
+ internalType: "address",
1472
+ },
1473
+ {
1474
+ name: "marketParams",
1475
+ type: "tuple",
1476
+ internalType: "struct MarketParams",
1477
+ components: [
1478
+ {
1479
+ name: "loanToken",
1480
+ type: "address",
1481
+ internalType: "address",
1482
+ },
1483
+ {
1484
+ name: "collateralToken",
1485
+ type: "address",
1486
+ internalType: "address",
1487
+ },
1488
+ {
1489
+ name: "oracle",
1490
+ type: "address",
1491
+ internalType: "address",
1492
+ },
1493
+ {
1494
+ name: "irm",
1495
+ type: "address",
1496
+ internalType: "address",
1497
+ },
1498
+ {
1499
+ name: "lltv",
1500
+ type: "uint256",
1501
+ internalType: "uint256",
1502
+ },
1503
+ ],
1504
+ },
1505
+ {
1506
+ name: "fromIdle",
1507
+ type: "bool",
1508
+ internalType: "bool",
1509
+ },
1510
+ {
1511
+ name: "sourceAdapter",
1512
+ type: "address",
1513
+ internalType: "address",
1514
+ },
1515
+ {
1516
+ name: "sourceMarketParams",
1517
+ type: "tuple",
1518
+ internalType: "struct MarketParams",
1519
+ components: [
1520
+ {
1521
+ name: "loanToken",
1522
+ type: "address",
1523
+ internalType: "address",
1524
+ },
1525
+ {
1526
+ name: "collateralToken",
1527
+ type: "address",
1528
+ internalType: "address",
1529
+ },
1530
+ {
1531
+ name: "oracle",
1532
+ type: "address",
1533
+ internalType: "address",
1534
+ },
1535
+ {
1536
+ name: "irm",
1537
+ type: "address",
1538
+ internalType: "address",
1539
+ },
1540
+ {
1541
+ name: "lltv",
1542
+ type: "uint256",
1543
+ internalType: "uint256",
1544
+ },
1545
+ ],
1546
+ },
1547
+ {
1548
+ name: "assets",
1549
+ type: "uint128",
1550
+ internalType: "uint128",
1551
+ },
1552
+ {
1553
+ name: "penalty",
1554
+ type: "uint64",
1555
+ internalType: "uint64",
1556
+ },
1557
+ ],
1558
+ },
1559
+ {
1560
+ name: "penaltyAssets",
1561
+ type: "uint256",
1562
+ internalType: "uint256",
1563
+ },
1564
+ {
1565
+ name: "deadline",
1566
+ type: "uint256",
1567
+ internalType: "uint256",
1568
+ },
1569
+ {
1570
+ name: "wrappedNative",
1571
+ type: "address",
1572
+ internalType: "address",
1573
+ },
1574
+ ],
1575
+ outputs: [],
1576
+ stateMutability: "payable",
1577
+ },
1578
+ ];
1579
+ /**
1580
+ * Pinned ABI fragment for 0x AllowanceHolder `exec`, the call a 0x allowance-holder quote's `transaction.data` encodes.
1581
+ *
1582
+ * Source: `0xProject/0x-settler` commit `f7340e6237146b2dfd40a40b3efeea527e4eb689`,
1583
+ * `src/allowanceholder/IAllowanceHolder.sol`.
1584
+ *
1585
+ * @see https://github.com/0xProject/0x-settler/blob/f7340e6237146b2dfd40a40b3efeea527e4eb689/src/allowanceholder/IAllowanceHolder.sol
1586
+ * @example
1587
+ * ```ts
1588
+ * import { zeroExAllowanceHolderAbi } from "@morpho-org/morpho-sdk/abis";
1589
+ * import { decodeFunctionData, encodeFunctionData, zeroAddress } from "viem";
1590
+ *
1591
+ * // A 0x allowance-holder quote's `transaction.data` has this shape.
1592
+ * const data = encodeFunctionData({
1593
+ * abi: zeroExAllowanceHolderAbi,
1594
+ * functionName: "exec",
1595
+ * args: [zeroAddress, zeroAddress, 1n, zeroAddress, "0x"],
1596
+ * });
1597
+ * const { args } = decodeFunctionData({ abi: zeroExAllowanceHolderAbi, data });
1598
+ * // args: [operator, token, amount, target, data], here [zeroAddress, zeroAddress, 1n, zeroAddress, "0x"]
1599
+ * ```
1600
+ */
1601
+ export const zeroExAllowanceHolderAbi = [
1602
+ {
1603
+ type: "function",
1604
+ name: "exec",
1605
+ inputs: [
1606
+ { name: "operator", type: "address", internalType: "address" },
1607
+ { name: "token", type: "address", internalType: "address" },
1608
+ { name: "amount", type: "uint256", internalType: "uint256" },
1609
+ { name: "target", type: "address", internalType: "address payable" },
1610
+ { name: "data", type: "bytes", internalType: "bytes" },
1611
+ ],
1612
+ outputs: [{ name: "result", type: "bytes", internalType: "bytes" }],
1613
+ stateMutability: "payable",
1614
+ },
1615
+ ];
1616
+ /**
1617
+ * Pinned ABI fragment for the taker-submitted 0x Settler `execute`, the call AllowanceHolder forwards to Settler.
1618
+ *
1619
+ * Source: `0xProject/0x-settler` commit `f7340e6237146b2dfd40a40b3efeea527e4eb689`,
1620
+ * `src/interfaces/ISettlerTakerSubmitted.sol` and the `AllowedSlippage` struct of `src/interfaces/ISettlerBase.sol`.
1621
+ *
1622
+ * @see https://github.com/0xProject/0x-settler/blob/f7340e6237146b2dfd40a40b3efeea527e4eb689/src/interfaces/ISettlerTakerSubmitted.sol
1623
+ * @example
1624
+ * ```ts
1625
+ * import { zeroExSettlerAbi } from "@morpho-org/morpho-sdk/abis";
1626
+ * import { decodeFunctionData, encodeFunctionData, zeroAddress, zeroHash } from "viem";
1627
+ *
1628
+ * // The `data` argument of AllowanceHolder `exec` carries a Settler call of this shape.
1629
+ * const settlerCalldata = encodeFunctionData({
1630
+ * abi: zeroExSettlerAbi,
1631
+ * functionName: "execute",
1632
+ * args: [{ recipient: zeroAddress, buyToken: zeroAddress, minAmountOut: 1n }, [], zeroHash],
1633
+ * });
1634
+ * const { args } = decodeFunctionData({ abi: zeroExSettlerAbi, data: settlerCalldata });
1635
+ * // args[0]: { recipient, buyToken, minAmountOut }, here minAmountOut === 1n
1636
+ * ```
1637
+ */
1638
+ export const zeroExSettlerAbi = [
1639
+ {
1640
+ type: "function",
1641
+ name: "execute",
1642
+ inputs: [
1643
+ {
1644
+ name: "slippage",
1645
+ type: "tuple",
1646
+ internalType: "struct ISettlerBase.AllowedSlippage",
1647
+ components: [
1648
+ {
1649
+ name: "recipient",
1650
+ type: "address",
1651
+ internalType: "address payable",
1652
+ },
1653
+ {
1654
+ name: "buyToken",
1655
+ type: "address",
1656
+ internalType: "contract IERC20",
1657
+ },
1658
+ { name: "minAmountOut", type: "uint256", internalType: "uint256" },
1659
+ ],
1660
+ },
1661
+ { name: "actions", type: "bytes[]", internalType: "bytes[]" },
1662
+ { name: "", type: "bytes32", internalType: "bytes32" },
1663
+ ],
1664
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1665
+ stateMutability: "payable",
1666
+ },
1667
+ ];
1668
+ /**
1669
+ * Pinned ABI fragments for the 0x Settler entry points ZeroExLeverageBundlesV1 cannot use: `executeWithPermit` and
1670
+ * `executeMetaTxn`. Calldata that decodes as one of them is a decoded inconsistency, which `validateZeroExQuote`
1671
+ * refuses, not an undecodable layer.
1672
+ *
1673
+ * Source: `0xProject/0x-settler` commit `f7340e6237146b2dfd40a40b3efeea527e4eb689`,
1674
+ * `src/interfaces/ISettlerTakerSubmitted.sol` (`executeWithPermit`, implemented at `src/Settler.sol:134`) and
1675
+ * `src/interfaces/ISettlerMetaTxn.sol` (`executeMetaTxn`, implemented at `src/SettlerMetaTxn.sol:155`).
1676
+ *
1677
+ * @see https://github.com/0xProject/0x-settler/blob/f7340e6237146b2dfd40a40b3efeea527e4eb689/src/interfaces/ISettlerMetaTxn.sol
1678
+ * @example
1679
+ * ```ts
1680
+ * import { zeroExSettlerOtherEntryPointsAbi } from "@morpho-org/morpho-sdk/abis";
1681
+ * import { decodeFunctionData, encodeFunctionData, zeroAddress, zeroHash } from "viem";
1682
+ *
1683
+ * const settlerCalldata = encodeFunctionData({
1684
+ * abi: zeroExSettlerOtherEntryPointsAbi,
1685
+ * functionName: "executeWithPermit",
1686
+ * args: [{ recipient: zeroAddress, buyToken: zeroAddress, minAmountOut: 1n }, [], zeroHash, "0x"],
1687
+ * });
1688
+ * const { functionName } = decodeFunctionData({ abi: zeroExSettlerOtherEntryPointsAbi, data: settlerCalldata });
1689
+ * // "executeWithPermit"; calldata for the other entry point decodes as "executeMetaTxn"
1690
+ * ```
1691
+ */
1692
+ export const zeroExSettlerOtherEntryPointsAbi = [
1693
+ {
1694
+ type: "function",
1695
+ name: "executeWithPermit",
1696
+ inputs: [
1697
+ {
1698
+ name: "slippage",
1699
+ type: "tuple",
1700
+ internalType: "struct ISettlerBase.AllowedSlippage",
1701
+ components: [
1702
+ {
1703
+ name: "recipient",
1704
+ type: "address",
1705
+ internalType: "address payable",
1706
+ },
1707
+ {
1708
+ name: "buyToken",
1709
+ type: "address",
1710
+ internalType: "contract IERC20",
1711
+ },
1712
+ { name: "minAmountOut", type: "uint256", internalType: "uint256" },
1713
+ ],
1714
+ },
1715
+ { name: "actions", type: "bytes[]", internalType: "bytes[]" },
1716
+ { name: "", type: "bytes32", internalType: "bytes32" },
1717
+ { name: "permitData", type: "bytes", internalType: "bytes" },
1718
+ ],
1719
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1720
+ stateMutability: "payable",
1721
+ },
1722
+ {
1723
+ type: "function",
1724
+ name: "executeMetaTxn",
1725
+ inputs: [
1726
+ {
1727
+ name: "slippage",
1728
+ type: "tuple",
1729
+ internalType: "struct ISettlerBase.AllowedSlippage",
1730
+ components: [
1731
+ {
1732
+ name: "recipient",
1733
+ type: "address",
1734
+ internalType: "address payable",
1735
+ },
1736
+ {
1737
+ name: "buyToken",
1738
+ type: "address",
1739
+ internalType: "contract IERC20",
1740
+ },
1741
+ { name: "minAmountOut", type: "uint256", internalType: "uint256" },
1742
+ ],
1743
+ },
1744
+ { name: "actions", type: "bytes[]", internalType: "bytes[]" },
1745
+ { name: "", type: "bytes32", internalType: "bytes32" },
1746
+ { name: "msgSender", type: "address", internalType: "address" },
1747
+ { name: "sig", type: "bytes", internalType: "bytes" },
1748
+ ],
1749
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
1750
+ stateMutability: "nonpayable",
1751
+ },
1752
+ ];
1753
+ /**
1754
+ * Pinned ABI fragment for the 0x Settler `SELECT` action, which runs the first of several candidate action lists that
1755
+ * delivers enough. `validateZeroExQuote` decodes it to refuse an RFQ fill in any of its candidates.
1756
+ *
1757
+ * Source: `0xProject/0x-settler` commit `243fb921232caedc27eb84f1f5820e84618dcd8b`, `src/ISettlerActions.sol:274`.
1758
+ *
1759
+ * @see https://github.com/0xProject/0x-settler/blob/243fb921232caedc27eb84f1f5820e84618dcd8b/src/ISettlerActions.sol#L274
1760
+ * @example
1761
+ * ```ts
1762
+ * import { zeroExSettlerSelectAbi } from "@morpho-org/morpho-sdk/abis";
1763
+ * import { decodeFunctionData, encodeFunctionData, zeroAddress } from "viem";
1764
+ *
1765
+ * const action = encodeFunctionData({
1766
+ * abi: zeroExSettlerSelectAbi,
1767
+ * functionName: "SELECT",
1768
+ * args: [500_000n, zeroAddress, [1n], [["0x"]]],
1769
+ * });
1770
+ * const [, , , candidates] = decodeFunctionData({ abi: zeroExSettlerSelectAbi, data: action }).args;
1771
+ * // action starts with "0x42032aef"; candidates is [["0x"]]
1772
+ * ```
1773
+ */
1774
+ export const zeroExSettlerSelectAbi = [
1775
+ {
1776
+ type: "function",
1777
+ name: "SELECT",
1778
+ inputs: [
1779
+ { name: "trialGasLimit", type: "uint256", internalType: "uint256" },
1780
+ { name: "token", type: "address", internalType: "address" },
1781
+ { name: "targets", type: "uint256[]", internalType: "uint256[]" },
1782
+ { name: "candidates", type: "bytes[][]", internalType: "bytes[][]" },
1783
+ ],
1784
+ outputs: [],
1785
+ stateMutability: "nonpayable",
1786
+ },
1787
+ ];
1788
+ /**
1789
+ * Pinned ABI fragments for the 0x Settler `BASIC` and `BASIC_PUSH` actions, opaque calls to a venue.
1790
+ * `validateZeroExQuote` decodes them to scan the inner call's data for a word that looks like a short deadline.
1791
+ *
1792
+ * Source: `0xProject/0x-settler` commit `243fb921232caedc27eb84f1f5820e84618dcd8b`, `src/ISettlerActions.sol:240`
1793
+ * and `:244`.
1794
+ *
1795
+ * @see https://github.com/0xProject/0x-settler/blob/243fb921232caedc27eb84f1f5820e84618dcd8b/src/ISettlerActions.sol#L240
1796
+ * @example
1797
+ * ```ts
1798
+ * import { zeroExSettlerBasicAbi } from "@morpho-org/morpho-sdk/abis";
1799
+ * import { decodeFunctionData, encodeFunctionData, zeroAddress } from "viem";
1800
+ *
1801
+ * const action = encodeFunctionData({
1802
+ * abi: zeroExSettlerBasicAbi,
1803
+ * functionName: "BASIC",
1804
+ * args: [zeroAddress, 10_000n, zeroAddress, 4n, "0x"],
1805
+ * });
1806
+ * const [, , , , data] = decodeFunctionData({ abi: zeroExSettlerBasicAbi, data: action }).args;
1807
+ * // action starts with "0x38c9c147"; data is "0x"
1808
+ * ```
1809
+ */
1810
+ export const zeroExSettlerBasicAbi = [
1811
+ {
1812
+ type: "function",
1813
+ name: "BASIC",
1814
+ inputs: [
1815
+ { name: "sellToken", type: "address", internalType: "address" },
1816
+ { name: "ppm", type: "uint256", internalType: "uint256" },
1817
+ { name: "pool", type: "address", internalType: "address" },
1818
+ { name: "offset", type: "uint256", internalType: "uint256" },
1819
+ { name: "data", type: "bytes", internalType: "bytes" },
1820
+ ],
1821
+ outputs: [],
1822
+ stateMutability: "nonpayable",
1823
+ },
1824
+ {
1825
+ type: "function",
1826
+ name: "BASIC_PUSH",
1827
+ inputs: [
1828
+ { name: "sellToken", type: "address", internalType: "address" },
1829
+ { name: "ppm", type: "uint256", internalType: "uint256" },
1830
+ { name: "pool", type: "address", internalType: "address" },
1831
+ { name: "offset", type: "uint256", internalType: "uint256" },
1832
+ { name: "data", type: "bytes", internalType: "bytes" },
1833
+ ],
1834
+ outputs: [],
1835
+ stateMutability: "nonpayable",
1836
+ },
1837
+ ];
1838
+ /**
1839
+ * Pinned ABI fragment for the 0x Settler deployer and registry: `ownerOf(feature)` returns the current Settler and
1840
+ * reverts while the feature is paused, `prev(feature)` returns the Settler 0x API may still target during a rotation.
1841
+ *
1842
+ * Source: `0xProject/0x-settler` commit `f7340e6237146b2dfd40a40b3efeea527e4eb689`, `src/deployer/IDeployer.sol`,
1843
+ * where `Feature` is a `uint128` user-defined value type.
1844
+ *
1845
+ * @see https://github.com/0xProject/0x-settler/blob/f7340e6237146b2dfd40a40b3efeea527e4eb689/src/deployer/IDeployer.sol
1846
+ * @example
1847
+ * ```ts
1848
+ * import { zeroExSettlerRegistryAbi } from "@morpho-org/morpho-sdk/abis";
1849
+ * import { ZERO_EX_SETTLER_REGISTRY_ADDRESS, ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE } from "@morpho-org/morpho-sdk/addresses";
1850
+ * import { createPublicClient, http } from "viem";
1851
+ * import { readContract } from "viem/actions";
1852
+ * import { mainnet } from "viem/chains";
1853
+ *
1854
+ * const client = createPublicClient({ chain: mainnet, transport: http() }); // use your own RPC URL
1855
+ *
1856
+ * const settler = await readContract(client, {
1857
+ * address: ZERO_EX_SETTLER_REGISTRY_ADDRESS,
1858
+ * abi: zeroExSettlerRegistryAbi,
1859
+ * functionName: "ownerOf",
1860
+ * args: [ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE],
1861
+ * });
1862
+ * ```
1863
+ */
1864
+ export const zeroExSettlerRegistryAbi = [
1865
+ {
1866
+ type: "function",
1867
+ name: "ownerOf",
1868
+ inputs: [{ name: "tokenId", type: "uint256", internalType: "uint256" }],
1869
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1870
+ stateMutability: "view",
1871
+ },
1872
+ {
1873
+ type: "function",
1874
+ name: "prev",
1875
+ inputs: [{ name: "", type: "uint128", internalType: "Feature" }],
1876
+ outputs: [{ name: "", type: "address", internalType: "address" }],
1877
+ stateMutability: "view",
1878
+ },
1879
+ ];