@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
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLeverageRequirements = void 0;
4
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
+ const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
6
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
+ const viem_1 = require("viem");
8
+ const validate_js_1 = require("../../../helpers/validate.js");
9
+ const zeroExQuote_js_1 = require("../../../helpers/zeroExQuote.js");
10
+ const assertContractCode_js_1 = require("../../../reads/assertContractCode.js");
11
+ const index_js_1 = require("../../../types/index.js");
12
+ const validateClientChainId_js_1 = require("../validateClientChainId.js");
13
+ const encodeLeverageAuthorization_js_1 = require("./encodeLeverageAuthorization.js");
14
+ const getLeverageRequirementsApproval_js_1 = require("./getLeverageRequirementsApproval.js");
15
+ const LEVERAGE_OPERATION_TYPES = [
16
+ "lever",
17
+ "delever",
18
+ "close",
19
+ ];
20
+ const LEVER_AMOUNT_FIELDS = [
21
+ "collateralAssets",
22
+ "loanAssets",
23
+ "maxBorrowAssets",
24
+ ];
25
+ const getTokenPulls = (marketParams, operation) => {
26
+ if (operation.type !== "lever") {
27
+ return [];
28
+ }
29
+ (0, validate_js_1.validateUint256Field)("collateralAssets", operation.collateralAssets);
30
+ (0, validate_js_1.validateUint256Field)("loanAssets", operation.loanAssets);
31
+ if ((0, viem_1.isAddressEqual)(marketParams.collateralToken, marketParams.loanToken)) {
32
+ const amount = operation.collateralAssets + operation.loanAssets;
33
+ (0, validate_js_1.validateUint256Field)("amount", amount);
34
+ return [{ token: marketParams.loanToken, amount }];
35
+ }
36
+ return [
37
+ {
38
+ token: marketParams.collateralToken,
39
+ amount: operation.collateralAssets,
40
+ },
41
+ { token: marketParams.loanToken, amount: operation.loanAssets },
42
+ ];
43
+ };
44
+ const needsAuthorization = (operation) => {
45
+ if (operation.type !== "lever") {
46
+ return true;
47
+ }
48
+ (0, validate_js_1.validateUint256Field)("maxBorrowAssets", operation.maxBorrowAssets);
49
+ return operation.maxBorrowAssets > 0n;
50
+ };
51
+ /**
52
+ * Resolves the transactions a user submits before a ZeroExLeverageBundlesV1 action: ERC-20
53
+ * approvals for the tokens it pulls, then the Morpho Blue authorization when its entry point
54
+ * needs one.
55
+ *
56
+ * Reads the user's allowance for each pulled token and `Morpho.isAuthorized(user, bundle)` on the
57
+ * target chain. For the leverage bundle the SDK ships it reads no contract code: `MorphoBlue.lever`, `delever` and
58
+ * `close` check Morpho Blue's code before calling it, and the shipped bundle's code check is waived
59
+ * (`docs/EXCEPTIONS.md`). A bundle registered with `registerCustomAddresses` falls back to the default rules: its code
60
+ * is checked before any read or grant, and its approvals are exact.
61
+ *
62
+ * - **Lever** pulls `collateralAssets` of the collateral token and `loanAssets` of the loan token
63
+ * from the user; when the allowance is short, each gets an unlimited approval (`maxUint256`,
64
+ * capped per token by `MAX_TOKEN_APPROVALS`), as for the other bundles, or an approval of exactly the pulled
65
+ * amount for a bundle the SDK does not ship. It borrows on Blue only
66
+ * when `maxBorrowAssets > 0`, so only then does it need the authorization.
67
+ * - **Delever** and **Close** pull nothing from the user and always withdraw collateral on Blue,
68
+ * so they need the authorization and no approval.
69
+ *
70
+ * The allowance and authorization reads run in parallel, each at the latest block its request sees; they are not
71
+ * pinned to one block, so a block landing between them can mix two states. The result is a snapshot of those
72
+ * reads: a requirement missed that way makes the action revert, and a returned approval still calls `approve` and
73
+ * replaces the allowance, with the zero reset of an approve-once token such as USDT planned from the allowance
74
+ * read. If the allowance or the authorization may have changed before submission, resolve the requirements again.
75
+ *
76
+ * The authorization is global over the user's Blue positions and persists after the action, like
77
+ * the unlimited approvals. The bundle takes no signed authorization, so no signature requirement
78
+ * is returned.
79
+ *
80
+ * @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
81
+ * @param params.chainId - Target chain id.
82
+ * @param params.userAddress - The account that sends the leverage transaction.
83
+ * @param params.marketParams - The market's loan and collateral tokens.
84
+ * @param params.operation - The leverage entry point and, for Lever, its pulled amounts.
85
+ * @returns Deep-frozen transactions in submission order: approvals (each optionally preceded by a
86
+ * reset to zero), then the authorization grant. Empty when nothing is missing.
87
+ * @throws {InvalidLeverageOperationError} when `operation` is missing or not an object, its `type` is
88
+ * not `lever`, `delever` or `close`, a Lever amount is not a bigint, or `userAddress` or a market token is
89
+ * not an address, before any read.
90
+ * @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`, a
91
+ * chain other than `params.chainId`.
92
+ * @throws {LeverageUnsupportedChainError} when the chain has no usable leverage bundle; a chain absent from the
93
+ * address registry reports `noAllowanceHolder`.
94
+ * @throws {MissingContractCodeError} when the chain's leverage bundle is not the one the SDK ships and has no code.
95
+ * @throws {NegativeInputError} when a Lever amount is negative.
96
+ * @throws {InputExceedsMaxError} when a Lever amount exceeds `uint256`; before any read,
97
+ * with `field: "amount"`, when the sum of both amounts on a market whose loan and collateral
98
+ * tokens are equal exceeds `uint256`.
99
+ * @throws {viem.BaseError} when the `eth_chainId` request or an allowance or authorization read
100
+ * fails.
101
+ * @example
102
+ * ```ts
103
+ * import { createPublicClient, http } from "viem";
104
+ * import { base } from "viem/chains";
105
+ * import { getLeverageRequirements } from "@morpho-org/morpho-sdk";
106
+ *
107
+ * const client = createPublicClient({ chain: base, transport: http() });
108
+ * // `leverTx`: the built Lever transaction; its args carry the amounts the Lever signs.
109
+ * const { collateralAssets, loanAssets, maxBorrowAssets } = leverTx.action.args;
110
+ * // None ships yet: register a verified zeroExLeverageBundlesV1 address with `registerCustomAddresses` first,
111
+ * // otherwise it throws `LeverageUnsupportedChainError` with `reason: "noBundle"`.
112
+ * const requirements = await getLeverageRequirements({
113
+ * viemClient: client,
114
+ * chainId: base.id,
115
+ * userAddress,
116
+ * marketParams,
117
+ * // Here collateralAssets is 1_000000000000000000n and loanAssets 0n.
118
+ * operation: { type: "lever", collateralAssets, loanAssets, maxBorrowAssets },
119
+ * });
120
+ * // requirements: [approve(bundle, 1_000000000000000000n), setAuthorization(bundle, true)] when both are
121
+ * // missing: a registered bundle is approved exactly the pull; the bundle morpho-ts ships gets maxUint256.
122
+ * ```
123
+ */
124
+ const getLeverageRequirements = async (params) => {
125
+ const { viemClient, chainId, userAddress, marketParams, operation } = params;
126
+ // A JavaScript caller can pass any shape; only well-formed known entry points may get a grant.
127
+ if (operation == null || typeof operation !== "object") {
128
+ throw new index_js_1.InvalidLeverageOperationError("operation", operation);
129
+ }
130
+ if (!LEVERAGE_OPERATION_TYPES.includes(operation.type)) {
131
+ throw new index_js_1.InvalidLeverageOperationError("type", operation.type);
132
+ }
133
+ if (operation.type === "lever") {
134
+ for (const field of LEVER_AMOUNT_FIELDS) {
135
+ if (typeof operation[field] !== "bigint") {
136
+ throw new index_js_1.InvalidLeverageOperationError(field, operation[field]);
137
+ }
138
+ }
139
+ }
140
+ // A JavaScript caller can pass any value; a malformed address must never reach a read or a grant.
141
+ for (const [field, address] of [
142
+ ["userAddress", userAddress],
143
+ ["marketParams.loanToken", marketParams?.loanToken],
144
+ ["marketParams.collateralToken", marketParams?.collateralToken],
145
+ ]) {
146
+ if (typeof address !== "string" || !(0, viem_1.isAddress)(address, { strict: false })) {
147
+ throw new index_js_1.InvalidLeverageOperationError(field, address);
148
+ }
149
+ }
150
+ (0, validate_js_1.validateChainId)(viemClient.chain?.id, chainId);
151
+ const bundle = (0, zeroExQuote_js_1.getZeroExLeverageBundle)(chainId);
152
+ const pulls = getTokenPulls(marketParams, operation).filter(({ amount }) => amount > 0n);
153
+ const authorize = needsAuthorization(operation);
154
+ await (0, validateClientChainId_js_1.validateClientChainId)(viemClient, chainId);
155
+ const pc = viemClient.extend(viem_1.publicActions);
156
+ if (!(0, morpho_ts_1.isShippedZeroExLeverageBundle)(chainId, bundle)) {
157
+ // The leverage exceptions cover only the shipped bundle: another one is never granted anything without code.
158
+ await (0, assertContractCode_js_1.assertContractCode)(pc, {
159
+ address: bundle,
160
+ chainId,
161
+ role: "bundles.zeroExLeverageBundlesV1",
162
+ });
163
+ }
164
+ const [approvals, isAuthorized] = await Promise.all([
165
+ Promise.all(pulls.map(async ({ token, amount }) => (0, getLeverageRequirementsApproval_js_1.getLeverageRequirementsApproval)({
166
+ chainId,
167
+ token,
168
+ amount,
169
+ allowance: await pc.readContract({
170
+ address: token,
171
+ abi: viem_1.erc20Abi,
172
+ functionName: "allowance",
173
+ args: [userAddress, bundle],
174
+ }),
175
+ }))),
176
+ authorize
177
+ ? pc.readContract({
178
+ address: (0, blue_sdk_1.getChainAddresses)(chainId).blue,
179
+ abi: blue_sdk_viem_1.blueAbi,
180
+ functionName: "isAuthorized",
181
+ args: [userAddress, bundle],
182
+ })
183
+ : true,
184
+ ]);
185
+ if (isAuthorized) {
186
+ return approvals.flat();
187
+ }
188
+ return [
189
+ ...approvals.flat(),
190
+ (0, encodeLeverageAuthorization_js_1.encodeLeverageAuthorization)({ chainId, isAuthorized: true }),
191
+ ];
192
+ };
193
+ exports.getLeverageRequirements = getLeverageRequirements;
@@ -0,0 +1,45 @@
1
+ import type { Address } from "viem";
2
+ import { type ERC20ApprovalAction, type Transaction } from "../../../types/index.js";
3
+ /**
4
+ * Computes the ERC-20 approvals a user gives ZeroExLeverageBundlesV1 so it can pull `amount` of
5
+ * `token`, given the existing allowance.
6
+ *
7
+ * For the leverage bundle the SDK ships (`isShippedZeroExLeverageBundle`), a short allowance is raised to
8
+ * `maxUint256`, capped per token by `MAX_TOKEN_APPROVALS`, like the other bundles' approvals, so one approval per token
9
+ * covers later leverage actions. A bundle registered with `registerCustomAddresses` gets an approval of exactly
10
+ * `amount` instead. For tokens in `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) with a non-zero allowance, a reset to zero
11
+ * precedes it. The spender is always the chain's registered bundle, refused on chains where it cannot run.
12
+ *
13
+ * @param params.chainId - The chain the transaction targets.
14
+ * @param params.token - ERC-20 token the bundle pulls.
15
+ * @param params.amount - Amount the bundle pulls.
16
+ * @param params.allowance - The user's current allowance of `token` for the bundle.
17
+ * @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
18
+ * followed by the unlimited approval, or the exact one for a bundle the SDK does not ship. Empty when
19
+ * `allowance >= amount`.
20
+ * @throws {InvalidLeverageOperationError} when `amount` or `allowance` is not a bigint.
21
+ * @throws {NegativeInputError} when `amount` or `allowance` is negative.
22
+ * @throws {InputExceedsMaxError} when `amount` or `allowance` exceeds `uint256`.
23
+ * @throws {LeverageUnsupportedChainError} when the chain has no usable leverage bundle; a chain absent from the
24
+ * address registry reports `noAllowanceHolder`.
25
+ * @example
26
+ * ```ts
27
+ * import { getLeverageRequirementsApproval } from "@morpho-org/morpho-sdk";
28
+ *
29
+ * // None ships yet: register a verified zeroExLeverageBundlesV1 address with `registerCustomAddresses` first.
30
+ * const txs = getLeverageRequirementsApproval({
31
+ * chainId: 8453,
32
+ * token: USDC,
33
+ * amount: 1_000_000n,
34
+ * allowance: 0n,
35
+ * });
36
+ * // txs: [approve(zeroExLeverageBundlesV1, 1_000_000n)], exactly the pull, for a registered bundle;
37
+ * // the bundle morpho-ts ships gets approve(zeroExLeverageBundlesV1, maxUint256) instead.
38
+ * ```
39
+ */
40
+ export declare const getLeverageRequirementsApproval: (params: {
41
+ readonly chainId: number;
42
+ readonly token: Address;
43
+ readonly amount: bigint;
44
+ readonly allowance: bigint;
45
+ }) => readonly Readonly<Transaction<ERC20ApprovalAction>>[];
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLeverageRequirementsApproval = void 0;
4
+ const validate_js_1 = require("../../../helpers/validate.js");
5
+ const zeroExQuote_js_1 = require("../../../helpers/zeroExQuote.js");
6
+ const index_js_1 = require("../../../types/index.js");
7
+ const getRequirementsApproval_js_1 = require("../getRequirementsApproval.js");
8
+ /**
9
+ * Computes the ERC-20 approvals a user gives ZeroExLeverageBundlesV1 so it can pull `amount` of
10
+ * `token`, given the existing allowance.
11
+ *
12
+ * For the leverage bundle the SDK ships (`isShippedZeroExLeverageBundle`), a short allowance is raised to
13
+ * `maxUint256`, capped per token by `MAX_TOKEN_APPROVALS`, like the other bundles' approvals, so one approval per token
14
+ * covers later leverage actions. A bundle registered with `registerCustomAddresses` gets an approval of exactly
15
+ * `amount` instead. For tokens in `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) with a non-zero allowance, a reset to zero
16
+ * precedes it. The spender is always the chain's registered bundle, refused on chains where it cannot run.
17
+ *
18
+ * @param params.chainId - The chain the transaction targets.
19
+ * @param params.token - ERC-20 token the bundle pulls.
20
+ * @param params.amount - Amount the bundle pulls.
21
+ * @param params.allowance - The user's current allowance of `token` for the bundle.
22
+ * @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
23
+ * followed by the unlimited approval, or the exact one for a bundle the SDK does not ship. Empty when
24
+ * `allowance >= amount`.
25
+ * @throws {InvalidLeverageOperationError} when `amount` or `allowance` is not a bigint.
26
+ * @throws {NegativeInputError} when `amount` or `allowance` is negative.
27
+ * @throws {InputExceedsMaxError} when `amount` or `allowance` exceeds `uint256`.
28
+ * @throws {LeverageUnsupportedChainError} when the chain has no usable leverage bundle; a chain absent from the
29
+ * address registry reports `noAllowanceHolder`.
30
+ * @example
31
+ * ```ts
32
+ * import { getLeverageRequirementsApproval } from "@morpho-org/morpho-sdk";
33
+ *
34
+ * // None ships yet: register a verified zeroExLeverageBundlesV1 address with `registerCustomAddresses` first.
35
+ * const txs = getLeverageRequirementsApproval({
36
+ * chainId: 8453,
37
+ * token: USDC,
38
+ * amount: 1_000_000n,
39
+ * allowance: 0n,
40
+ * });
41
+ * // txs: [approve(zeroExLeverageBundlesV1, 1_000_000n)], exactly the pull, for a registered bundle;
42
+ * // the bundle morpho-ts ships gets approve(zeroExLeverageBundlesV1, maxUint256) instead.
43
+ * ```
44
+ */
45
+ const getLeverageRequirementsApproval = (params) => {
46
+ const { chainId, token, amount, allowance } = params;
47
+ // A JavaScript caller can omit a field; an unknown pull or allowance must never get an approval.
48
+ for (const [field, value] of [
49
+ ["amount", amount],
50
+ ["allowance", allowance],
51
+ ]) {
52
+ if (typeof value !== "bigint") {
53
+ throw new index_js_1.InvalidLeverageOperationError(field, value);
54
+ }
55
+ }
56
+ (0, validate_js_1.validateUint256Field)("amount", amount);
57
+ (0, validate_js_1.validateUint256Field)("allowance", allowance);
58
+ const spender = (0, zeroExQuote_js_1.getZeroExLeverageBundle)(chainId);
59
+ return (0, getRequirementsApproval_js_1.getRequirementsApproval)({
60
+ address: token,
61
+ chainId,
62
+ args: { spendAmount: amount, spender },
63
+ allowances: allowance,
64
+ });
65
+ };
66
+ exports.getLeverageRequirementsApproval = getLeverageRequirementsApproval;
@@ -1 +1,4 @@
1
+ export * from "./encodeLeverageAuthorization.js";
1
2
  export { getBlueAuthorizationRequirement } from "./getBlueAuthorizationRequirement.js";
3
+ export * from "./getLeverageRequirements.js";
4
+ export * from "./getLeverageRequirementsApproval.js";
@@ -1,5 +1,22 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.getBlueAuthorizationRequirement = void 0;
18
+ __exportStar(require("./encodeLeverageAuthorization.js"), exports);
4
19
  var getBlueAuthorizationRequirement_js_1 = require("./getBlueAuthorizationRequirement.js");
5
20
  Object.defineProperty(exports, "getBlueAuthorizationRequirement", { enumerable: true, get: function () { return getBlueAuthorizationRequirement_js_1.getBlueAuthorizationRequirement; } });
21
+ __exportStar(require("./getLeverageRequirements.js"), exports);
22
+ __exportStar(require("./getLeverageRequirementsApproval.js"), exports);
@@ -24,8 +24,8 @@ export declare const parseErc20Approval: (params: EncodeErc20ApprovalParams) =>
24
24
  * @param params - Encoding parameters.
25
25
  * @param params.token - ERC-20 token address to approve.
26
26
  * @param params.spender - Address granted the allowance. Must be Permit2, Midnight,
27
- * MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for
28
- * the chain.
27
+ * MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, BlueBundlesV1, or
28
+ * ZeroExLeverageBundlesV1 for the chain.
29
29
  * @param params.amount - Allowance amount before per-token cap.
30
30
  * @param params.chainId - The chain the transaction targets (used to resolve supported spenders and the per-token cap).
31
31
  * @returns A deep-frozen `Transaction<ERC20ApprovalAction>` with the capped approval amount.
@@ -24,6 +24,7 @@ const parseErc20Approval = (params) => {
24
24
  "vaultExitBundlesV1",
25
25
  "vaultBundlesV1",
26
26
  "blueBundlesV1",
27
+ "zeroExLeverageBundlesV1",
27
28
  ],
28
29
  });
29
30
  return {
@@ -41,8 +42,8 @@ exports.parseErc20Approval = parseErc20Approval;
41
42
  * @param params - Encoding parameters.
42
43
  * @param params.token - ERC-20 token address to approve.
43
44
  * @param params.spender - Address granted the allowance. Must be Permit2, Midnight,
44
- * MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for
45
- * the chain.
45
+ * MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, BlueBundlesV1, or
46
+ * ZeroExLeverageBundlesV1 for the chain.
46
47
  * @param params.amount - Allowance amount before per-token cap.
47
48
  * @param params.chainId - The chain the transaction targets (used to resolve supported spenders and the per-token cap).
48
49
  * @returns A deep-frozen `Transaction<ERC20ApprovalAction>` with the capped approval amount.
@@ -1,5 +1,5 @@
1
- import type { Address } from "@morpho-org/blue-sdk";
2
- import type { ERC20ApprovalAction, Transaction } from "../../types/index.js";
1
+ import { type Address } from "@morpho-org/blue-sdk";
2
+ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js";
3
3
  import { type Erc20ApprovalInput } from "./encode/encodeErc20Approval.js";
4
4
  /** Complete raw approval requirement invocation. @internal */
5
5
  interface RequirementsApprovalParams {
@@ -25,11 +25,12 @@ export declare const parseRequirementsApproval: (params: RequirementsApprovalPar
25
25
  * allowance.
26
26
  *
27
27
  * The operation constructor validates the spender before constructing approval inputs. Supported
28
- * spenders are the chain's Permit2, Midnight, MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, and BlueBundlesV1
29
- * addresses when configured.
28
+ * spenders are the chain's Permit2, Midnight, MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, BlueBundlesV1, and
29
+ * ZeroExLeverageBundlesV1 addresses when configured.
30
30
  *
31
31
  * When `allowances < spendAmount`, requests an approval for `maxUint256`, capped per token by
32
- * `MAX_TOKEN_APPROVALS`. For tokens in `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) with a non-zero
32
+ * `MAX_TOKEN_APPROVALS`. A ZeroExLeverageBundlesV1 the SDK does not ship, one registered with
33
+ * `registerCustomAddresses`, falls back to the default rule and is approved exactly `spendAmount`. For tokens in `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) with a non-zero
33
34
  * allowance, prepends an `approve(spender, 0)` reset before re-approving. No approval is emitted
34
35
  * when `allowances >= spendAmount`.
35
36
  *
@@ -38,12 +39,16 @@ export declare const parseRequirementsApproval: (params: RequirementsApprovalPar
38
39
  * and token approval caps.
39
40
  * @param params.args.spendAmount - The amount the bundle will actually pull.
40
41
  * @param params.args.spender - Address that will be granted the approval. Must be Permit2,
41
- * Midnight, MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for `chainId`.
42
+ * Midnight, MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, BlueBundlesV1, or
43
+ * ZeroExLeverageBundlesV1 for `chainId`.
42
44
  * @param params.allowances - The user's current allowance of `address` for `spender`.
43
45
  * @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
44
46
  * followed by the new approval. Empty when `allowances >= spendAmount`.
45
47
  * @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
46
48
  * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a supported SDK spender for `chainId`.
49
+ * @throws {InvalidBigIntInputError} when an exact approval is due and `spendAmount` is not a bigint.
50
+ * @throws {NegativeInputError} when an exact approval is due and `spendAmount` is negative.
51
+ * @throws {InputExceedsMaxError} when an exact approval is due and `spendAmount` exceeds `uint256`.
47
52
  * @example
48
53
  * ```ts
49
54
  * import { getRequirementsApproval } from "@morpho-org/morpho-sdk";
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getParsedRequirementsApproval = exports.getRequirementsApproval = exports.parseRequirementsApproval = void 0;
4
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
+ const viem_1 = require("viem");
4
7
  const tokenApproval_js_1 = require("../../helpers/tokenApproval.js");
8
+ const validate_js_1 = require("../../helpers/validate.js");
9
+ const index_js_1 = require("../../types/index.js");
5
10
  const encodeErc20Approval_js_1 = require("./encode/encodeErc20Approval.js");
6
11
  const requirementsApprovalInput = Symbol("RequirementsApprovalInput");
7
12
  /** Owns no-op and token/spender error precedence for direct callers. @internal */
@@ -22,11 +27,25 @@ const parseRequirementsApproval = (params) => {
22
27
  allowance: input.allowances,
23
28
  spendAmount: input.args.spendAmount,
24
29
  });
30
+ const leverageBundle = amounts.length > 0 && (0, blue_sdk_1.isZeroExLeverageChain)(input.chainId)
31
+ ? (0, blue_sdk_1.getChainAddresses)(input.chainId).bundles?.zeroExLeverageBundlesV1
32
+ : undefined;
33
+ // The unlimited-approval exception covers only the leverage bundle the SDK ships.
34
+ const exact = leverageBundle != null &&
35
+ (0, viem_1.isAddressEqual)(input.args.spender, leverageBundle) &&
36
+ !(0, morpho_ts_1.isShippedZeroExLeverageBundle)(input.chainId, input.args.spender);
37
+ if (exact) {
38
+ // The exact approval is spendAmount itself, so it must be a uint256 the token can hold, not a capped maximum.
39
+ if (typeof input.args.spendAmount !== "bigint") {
40
+ throw new index_js_1.InvalidBigIntInputError("spendAmount", input.args.spendAmount);
41
+ }
42
+ (0, validate_js_1.validateUint256Field)("spendAmount", input.args.spendAmount);
43
+ }
25
44
  const approvals = amounts.map((amount) => (0, encodeErc20Approval_js_1.parseErc20Approval)({
26
45
  token: input.address,
27
46
  spender: input.args.spender,
28
47
  chainId: input.chainId,
29
- amount,
48
+ amount: exact && amount !== 0n ? input.args.spendAmount : amount,
30
49
  }));
31
50
  return {
32
51
  ...input,
@@ -41,11 +60,12 @@ exports.parseRequirementsApproval = parseRequirementsApproval;
41
60
  * allowance.
42
61
  *
43
62
  * The operation constructor validates the spender before constructing approval inputs. Supported
44
- * spenders are the chain's Permit2, Midnight, MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, and BlueBundlesV1
45
- * addresses when configured.
63
+ * spenders are the chain's Permit2, Midnight, MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, BlueBundlesV1, and
64
+ * ZeroExLeverageBundlesV1 addresses when configured.
46
65
  *
47
66
  * When `allowances < spendAmount`, requests an approval for `maxUint256`, capped per token by
48
- * `MAX_TOKEN_APPROVALS`. For tokens in `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) with a non-zero
67
+ * `MAX_TOKEN_APPROVALS`. A ZeroExLeverageBundlesV1 the SDK does not ship, one registered with
68
+ * `registerCustomAddresses`, falls back to the default rule and is approved exactly `spendAmount`. For tokens in `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) with a non-zero
49
69
  * allowance, prepends an `approve(spender, 0)` reset before re-approving. No approval is emitted
50
70
  * when `allowances >= spendAmount`.
51
71
  *
@@ -54,12 +74,16 @@ exports.parseRequirementsApproval = parseRequirementsApproval;
54
74
  * and token approval caps.
55
75
  * @param params.args.spendAmount - The amount the bundle will actually pull.
56
76
  * @param params.args.spender - Address that will be granted the approval. Must be Permit2,
57
- * Midnight, MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for `chainId`.
77
+ * Midnight, MidnightBundlesV2, VaultExitBundlesV1, VaultBundlesV1, BlueBundlesV1, or
78
+ * ZeroExLeverageBundlesV1 for `chainId`.
58
79
  * @param params.allowances - The user's current allowance of `address` for `spender`.
59
80
  * @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
60
81
  * followed by the new approval. Empty when `allowances >= spendAmount`.
61
82
  * @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
62
83
  * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a supported SDK spender for `chainId`.
84
+ * @throws {InvalidBigIntInputError} when an exact approval is due and `spendAmount` is not a bigint.
85
+ * @throws {NegativeInputError} when an exact approval is due and `spendAmount` is negative.
86
+ * @throws {InputExceedsMaxError} when an exact approval is due and `spendAmount` exceeds `uint256`.
63
87
  * @example
64
88
  * ```ts
65
89
  * import { getRequirementsApproval } from "@morpho-org/morpho-sdk";
@@ -1,2 +1,2 @@
1
1
  export type { AddressLabel, AddressRegistry, ChainAddresses, ChainDeployments, DeploymentRegistry, } from "@morpho-org/blue-sdk";
2
- export { addresses, addressesRegistry, convexWrapperTokens, deployments, erc20WrapperTokens, getChainAddress, getChainAddresses, getPermissionedCoinbaseTokens, getUnwrappedToken, NATIVE_ADDRESS, permissionedBackedTokens, permissionedCoinbaseTokens, permissionedWrapperTokens, registerCustomAddresses, unwrappedTokensMapping, } from "@morpho-org/blue-sdk";
2
+ export { addresses, addressesRegistry, convexWrapperTokens, deployments, erc20WrapperTokens, getChainAddress, getChainAddresses, getPermissionedCoinbaseTokens, getUnwrappedToken, isZeroExLeverageChain as isBlueZeroExLeverageChain, NATIVE_ADDRESS, permissionedBackedTokens, permissionedCoinbaseTokens, permissionedWrapperTokens, registerCustomAddresses, unwrappedTokensMapping, ZERO_EX_ALLOWANCE_HOLDER_ADDRESS, ZERO_EX_ALLOWANCE_HOLDER_CHAIN_IDS, ZERO_EX_SETTLER_REGISTRY_ADDRESS, ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE, } from "@morpho-org/blue-sdk";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unwrappedTokensMapping = exports.registerCustomAddresses = exports.permissionedWrapperTokens = exports.permissionedCoinbaseTokens = exports.permissionedBackedTokens = exports.NATIVE_ADDRESS = exports.getUnwrappedToken = exports.getPermissionedCoinbaseTokens = exports.getChainAddresses = exports.getChainAddress = exports.erc20WrapperTokens = exports.deployments = exports.convexWrapperTokens = exports.addressesRegistry = exports.addresses = void 0;
3
+ exports.ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE = exports.ZERO_EX_SETTLER_REGISTRY_ADDRESS = exports.ZERO_EX_ALLOWANCE_HOLDER_CHAIN_IDS = exports.ZERO_EX_ALLOWANCE_HOLDER_ADDRESS = exports.unwrappedTokensMapping = exports.registerCustomAddresses = exports.permissionedWrapperTokens = exports.permissionedCoinbaseTokens = exports.permissionedBackedTokens = exports.NATIVE_ADDRESS = exports.isBlueZeroExLeverageChain = exports.getUnwrappedToken = exports.getPermissionedCoinbaseTokens = exports.getChainAddresses = exports.getChainAddress = exports.erc20WrapperTokens = exports.deployments = exports.convexWrapperTokens = exports.addressesRegistry = exports.addresses = void 0;
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "addresses", { enumerable: true, get: function () { return blue_sdk_1.addresses; } });
6
6
  Object.defineProperty(exports, "addressesRegistry", { enumerable: true, get: function () { return blue_sdk_1.addressesRegistry; } });
@@ -11,9 +11,14 @@ Object.defineProperty(exports, "getChainAddress", { enumerable: true, get: funct
11
11
  Object.defineProperty(exports, "getChainAddresses", { enumerable: true, get: function () { return blue_sdk_1.getChainAddresses; } });
12
12
  Object.defineProperty(exports, "getPermissionedCoinbaseTokens", { enumerable: true, get: function () { return blue_sdk_1.getPermissionedCoinbaseTokens; } });
13
13
  Object.defineProperty(exports, "getUnwrappedToken", { enumerable: true, get: function () { return blue_sdk_1.getUnwrappedToken; } });
14
+ Object.defineProperty(exports, "isBlueZeroExLeverageChain", { enumerable: true, get: function () { return blue_sdk_1.isZeroExLeverageChain; } });
14
15
  Object.defineProperty(exports, "NATIVE_ADDRESS", { enumerable: true, get: function () { return blue_sdk_1.NATIVE_ADDRESS; } });
15
16
  Object.defineProperty(exports, "permissionedBackedTokens", { enumerable: true, get: function () { return blue_sdk_1.permissionedBackedTokens; } });
16
17
  Object.defineProperty(exports, "permissionedCoinbaseTokens", { enumerable: true, get: function () { return blue_sdk_1.permissionedCoinbaseTokens; } });
17
18
  Object.defineProperty(exports, "permissionedWrapperTokens", { enumerable: true, get: function () { return blue_sdk_1.permissionedWrapperTokens; } });
18
19
  Object.defineProperty(exports, "registerCustomAddresses", { enumerable: true, get: function () { return blue_sdk_1.registerCustomAddresses; } });
19
20
  Object.defineProperty(exports, "unwrappedTokensMapping", { enumerable: true, get: function () { return blue_sdk_1.unwrappedTokensMapping; } });
21
+ Object.defineProperty(exports, "ZERO_EX_ALLOWANCE_HOLDER_ADDRESS", { enumerable: true, get: function () { return blue_sdk_1.ZERO_EX_ALLOWANCE_HOLDER_ADDRESS; } });
22
+ Object.defineProperty(exports, "ZERO_EX_ALLOWANCE_HOLDER_CHAIN_IDS", { enumerable: true, get: function () { return blue_sdk_1.ZERO_EX_ALLOWANCE_HOLDER_CHAIN_IDS; } });
23
+ Object.defineProperty(exports, "ZERO_EX_SETTLER_REGISTRY_ADDRESS", { enumerable: true, get: function () { return blue_sdk_1.ZERO_EX_SETTLER_REGISTRY_ADDRESS; } });
24
+ Object.defineProperty(exports, "ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE", { enumerable: true, get: function () { return blue_sdk_1.ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE; } });
@@ -1,5 +1,5 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
2
+ export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  preLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.marketParamsAbi = void 0;
3
+ exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.midnightAdapterRateRatifierV1Abi = exports.midnightAdapterPriceRatifierV1Abi = exports.midnightAdapterFactoryAbi = exports.midnightAdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.marketParamsAbi = void 0;
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "marketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
6
6
  var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
@@ -13,6 +13,10 @@ Object.defineProperty(exports, "erc3643IdentityRegistryAbi", { enumerable: true,
13
13
  Object.defineProperty(exports, "erc5267Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc5267Abi; } });
14
14
  Object.defineProperty(exports, "metaMorphoAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoAbi; } });
15
15
  Object.defineProperty(exports, "metaMorphoFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoFactoryAbi; } });
16
+ Object.defineProperty(exports, "midnightAdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterAbi; } });
17
+ Object.defineProperty(exports, "midnightAdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterFactoryAbi; } });
18
+ Object.defineProperty(exports, "midnightAdapterPriceRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterPriceRatifierV1Abi; } });
19
+ Object.defineProperty(exports, "midnightAdapterRateRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterRateRatifierV1Abi; } });
16
20
  Object.defineProperty(exports, "morphoMarketV1AdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterAbi; } });
17
21
  Object.defineProperty(exports, "morphoMarketV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterFactoryAbi; } });
18
22
  Object.defineProperty(exports, "morphoMarketV1AdapterV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterV2Abi; } });
@@ -1,2 +1,2 @@
1
1
  export type { AddressLabel, AddressRegistry, ChainAddresses, ChainDeployments, DeploymentRegistry, } from "@morpho-org/blue-sdk";
2
- export { addresses, addressesRegistry, convexWrapperTokens, deployments, erc20WrapperTokens, getChainAddress, getChainAddresses, getPermissionedCoinbaseTokens, getUnwrappedToken, NATIVE_ADDRESS, permissionedBackedTokens, permissionedCoinbaseTokens, permissionedWrapperTokens, registerCustomAddresses, unwrappedTokensMapping, } from "@morpho-org/blue-sdk";
2
+ export { addresses, addressesRegistry, convexWrapperTokens, deployments, erc20WrapperTokens, getChainAddress, getChainAddresses, getPermissionedCoinbaseTokens, getUnwrappedToken, isZeroExLeverageChain, NATIVE_ADDRESS, permissionedBackedTokens, permissionedCoinbaseTokens, permissionedWrapperTokens, registerCustomAddresses, unwrappedTokensMapping, ZERO_EX_ALLOWANCE_HOLDER_ADDRESS, ZERO_EX_ALLOWANCE_HOLDER_CHAIN_IDS, ZERO_EX_SETTLER_REGISTRY_ADDRESS, ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE, } from "@morpho-org/blue-sdk";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unwrappedTokensMapping = exports.registerCustomAddresses = exports.permissionedWrapperTokens = exports.permissionedCoinbaseTokens = exports.permissionedBackedTokens = exports.NATIVE_ADDRESS = exports.getUnwrappedToken = exports.getPermissionedCoinbaseTokens = exports.getChainAddresses = exports.getChainAddress = exports.erc20WrapperTokens = exports.deployments = exports.convexWrapperTokens = exports.addressesRegistry = exports.addresses = void 0;
3
+ exports.ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE = exports.ZERO_EX_SETTLER_REGISTRY_ADDRESS = exports.ZERO_EX_ALLOWANCE_HOLDER_CHAIN_IDS = exports.ZERO_EX_ALLOWANCE_HOLDER_ADDRESS = exports.unwrappedTokensMapping = exports.registerCustomAddresses = exports.permissionedWrapperTokens = exports.permissionedCoinbaseTokens = exports.permissionedBackedTokens = exports.NATIVE_ADDRESS = exports.isZeroExLeverageChain = exports.getUnwrappedToken = exports.getPermissionedCoinbaseTokens = exports.getChainAddresses = exports.getChainAddress = exports.erc20WrapperTokens = exports.deployments = exports.convexWrapperTokens = exports.addressesRegistry = exports.addresses = void 0;
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "addresses", { enumerable: true, get: function () { return blue_sdk_1.addresses; } });
6
6
  Object.defineProperty(exports, "addressesRegistry", { enumerable: true, get: function () { return blue_sdk_1.addressesRegistry; } });
@@ -11,9 +11,14 @@ Object.defineProperty(exports, "getChainAddress", { enumerable: true, get: funct
11
11
  Object.defineProperty(exports, "getChainAddresses", { enumerable: true, get: function () { return blue_sdk_1.getChainAddresses; } });
12
12
  Object.defineProperty(exports, "getPermissionedCoinbaseTokens", { enumerable: true, get: function () { return blue_sdk_1.getPermissionedCoinbaseTokens; } });
13
13
  Object.defineProperty(exports, "getUnwrappedToken", { enumerable: true, get: function () { return blue_sdk_1.getUnwrappedToken; } });
14
+ Object.defineProperty(exports, "isZeroExLeverageChain", { enumerable: true, get: function () { return blue_sdk_1.isZeroExLeverageChain; } });
14
15
  Object.defineProperty(exports, "NATIVE_ADDRESS", { enumerable: true, get: function () { return blue_sdk_1.NATIVE_ADDRESS; } });
15
16
  Object.defineProperty(exports, "permissionedBackedTokens", { enumerable: true, get: function () { return blue_sdk_1.permissionedBackedTokens; } });
16
17
  Object.defineProperty(exports, "permissionedCoinbaseTokens", { enumerable: true, get: function () { return blue_sdk_1.permissionedCoinbaseTokens; } });
17
18
  Object.defineProperty(exports, "permissionedWrapperTokens", { enumerable: true, get: function () { return blue_sdk_1.permissionedWrapperTokens; } });
18
19
  Object.defineProperty(exports, "registerCustomAddresses", { enumerable: true, get: function () { return blue_sdk_1.registerCustomAddresses; } });
19
20
  Object.defineProperty(exports, "unwrappedTokensMapping", { enumerable: true, get: function () { return blue_sdk_1.unwrappedTokensMapping; } });
21
+ Object.defineProperty(exports, "ZERO_EX_ALLOWANCE_HOLDER_ADDRESS", { enumerable: true, get: function () { return blue_sdk_1.ZERO_EX_ALLOWANCE_HOLDER_ADDRESS; } });
22
+ Object.defineProperty(exports, "ZERO_EX_ALLOWANCE_HOLDER_CHAIN_IDS", { enumerable: true, get: function () { return blue_sdk_1.ZERO_EX_ALLOWANCE_HOLDER_CHAIN_IDS; } });
23
+ Object.defineProperty(exports, "ZERO_EX_SETTLER_REGISTRY_ADDRESS", { enumerable: true, get: function () { return blue_sdk_1.ZERO_EX_SETTLER_REGISTRY_ADDRESS; } });
24
+ Object.defineProperty(exports, "ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE", { enumerable: true, get: function () { return blue_sdk_1.ZERO_EX_TAKER_SUBMITTED_SETTLER_FEATURE; } });
@@ -1,10 +1,10 @@
1
- export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
1
+ export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MidnightAdapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  IPreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
6
- export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
5
+ IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MidnightAdapter, IVaultV2MidnightAdapterAccrualMarket, IVaultV2MidnightAdapterCollateralParams, IVaultV2MidnightAdapterMarket, IVaultV2MidnightAdapterMarketData, IVaultV2MidnightAdapterMarketState, IVaultV2MidnightAdapterMidnightMarket, IVaultV2MidnightAdapterPosition, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultV2MidnightAdapterAccrualMarket, VaultV2MidnightAdapterMarketData, } from "@morpho-org/blue-sdk";
6
+ export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
7
7
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
8
8
  PreLiquidationParams,
9
9
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
10
- PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
10
+ PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";