@morpho-org/morpho-sdk 10.5.0-next.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 (170) hide show
  1. package/README.md +44 -1
  2. package/lib/cjs/abis.d.ts +793 -0
  3. package/lib/cjs/abis.js +811 -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/midnight/supplyCollateralTakeBorrow.js +16 -11
  16. package/lib/cjs/actions/midnight/takeBorrow.js +14 -8
  17. package/lib/cjs/actions/midnight/takeLend.js +15 -9
  18. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +19 -13
  19. package/lib/cjs/actions/midnight/takeWithdraw.js +14 -8
  20. package/lib/cjs/actions/requirements/blue/encodeLeverageAuthorization.d.ts +39 -0
  21. package/lib/cjs/actions/requirements/blue/encodeLeverageAuthorization.js +59 -0
  22. package/lib/cjs/actions/requirements/blue/getLeverageRequirements.d.ts +104 -0
  23. package/lib/cjs/actions/requirements/blue/getLeverageRequirements.js +193 -0
  24. package/lib/cjs/actions/requirements/blue/getLeverageRequirementsApproval.d.ts +45 -0
  25. package/lib/cjs/actions/requirements/blue/getLeverageRequirementsApproval.js +66 -0
  26. package/lib/cjs/actions/requirements/blue/index.d.ts +3 -0
  27. package/lib/cjs/actions/requirements/blue/index.js +17 -0
  28. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -2
  29. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +3 -2
  30. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +11 -6
  31. package/lib/cjs/actions/requirements/getRequirementsApproval.js +29 -5
  32. package/lib/cjs/addresses.d.ts +1 -1
  33. package/lib/cjs/addresses.js +6 -1
  34. package/lib/cjs/blue/addresses.d.ts +1 -1
  35. package/lib/cjs/blue/addresses.js +6 -1
  36. package/lib/cjs/constants.d.ts +1 -1
  37. package/lib/cjs/constants.js +7 -2
  38. package/lib/cjs/entities/blue/blue.d.ts +486 -2
  39. package/lib/cjs/entities/blue/blue.js +529 -34
  40. package/lib/cjs/entities/index.d.ts +1 -1
  41. package/lib/cjs/entities/midnight/midnight.d.ts +6 -0
  42. package/lib/cjs/entities/midnight/midnight.js +21 -2
  43. package/lib/cjs/entities/requirements/assertContractCode.d.ts +0 -23
  44. package/lib/cjs/entities/requirements/assertContractCode.js +3 -28
  45. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +117 -0
  46. package/lib/cjs/entities/vaultV2BlueReallocationData.js +226 -2
  47. package/lib/cjs/helpers/constant.d.ts +41 -0
  48. package/lib/cjs/helpers/constant.js +42 -1
  49. package/lib/cjs/helpers/getZeroExLeverageBundle.d.ts +13 -0
  50. package/lib/cjs/helpers/getZeroExLeverageBundle.js +27 -0
  51. package/lib/cjs/helpers/index.d.ts +4 -1
  52. package/lib/cjs/helpers/index.js +29 -1
  53. package/lib/cjs/helpers/leverage/index.d.ts +1 -0
  54. package/lib/cjs/helpers/leverage/index.js +11 -0
  55. package/lib/cjs/helpers/leverage/limits.d.ts +472 -0
  56. package/lib/cjs/helpers/leverage/limits.js +715 -0
  57. package/lib/cjs/helpers/leverage/positionMarket.d.ts +17 -0
  58. package/lib/cjs/helpers/leverage/positionMarket.js +28 -0
  59. package/lib/cjs/helpers/leverage/reallocations.d.ts +159 -0
  60. package/lib/cjs/helpers/leverage/reallocations.js +276 -0
  61. package/lib/cjs/helpers/validate.d.ts +14 -0
  62. package/lib/cjs/helpers/validate.js +25 -1
  63. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  64. package/lib/cjs/helpers/validateRequirementSpender.js +4 -0
  65. package/lib/cjs/helpers/zeroExQuote.d.ts +250 -0
  66. package/lib/cjs/helpers/zeroExQuote.js +763 -0
  67. package/lib/cjs/index.d.ts +1 -0
  68. package/lib/cjs/index.js +5 -2
  69. package/lib/cjs/reads/assertContractCode.d.ts +25 -0
  70. package/lib/cjs/reads/assertContractCode.js +30 -0
  71. package/lib/cjs/reads/fetchZeroExQuote.d.ts +123 -0
  72. package/lib/cjs/reads/fetchZeroExQuote.js +330 -0
  73. package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +4 -0
  74. package/lib/cjs/transactionPlan/midnight/takeBorrow.js +8 -2
  75. package/lib/cjs/types/action.d.ts +130 -1
  76. package/lib/cjs/types/error.d.ts +84 -0
  77. package/lib/cjs/types/error.js +110 -3
  78. package/lib/cjs/types/index.d.ts +2 -0
  79. package/lib/cjs/types/index.js +2 -0
  80. package/lib/cjs/types/leverageError.d.ts +1552 -0
  81. package/lib/cjs/types/leverageError.js +1711 -0
  82. package/lib/cjs/types/zeroEx.d.ts +171 -0
  83. package/lib/cjs/types/zeroEx.js +2 -0
  84. package/lib/cjs/version.d.ts +1 -1
  85. package/lib/cjs/version.js +1 -1
  86. package/lib/esm/abis.d.ts +793 -0
  87. package/lib/esm/abis.js +809 -0
  88. package/lib/esm/actions/blue/close.d.ts +169 -0
  89. package/lib/esm/actions/blue/close.js +266 -0
  90. package/lib/esm/actions/blue/common.js +3 -3
  91. package/lib/esm/actions/blue/delever.d.ts +156 -0
  92. package/lib/esm/actions/blue/delever.js +219 -0
  93. package/lib/esm/actions/blue/index.d.ts +3 -0
  94. package/lib/esm/actions/blue/index.js +3 -0
  95. package/lib/esm/actions/blue/lever.d.ts +184 -0
  96. package/lib/esm/actions/blue/lever.js +268 -0
  97. package/lib/esm/actions/blue/leverageIntent.d.ts +65 -0
  98. package/lib/esm/actions/blue/leverageIntent.js +96 -0
  99. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +16 -11
  100. package/lib/esm/actions/midnight/takeBorrow.js +14 -8
  101. package/lib/esm/actions/midnight/takeLend.js +15 -9
  102. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +19 -13
  103. package/lib/esm/actions/midnight/takeWithdraw.js +14 -8
  104. package/lib/esm/actions/requirements/blue/encodeLeverageAuthorization.d.ts +39 -0
  105. package/lib/esm/actions/requirements/blue/encodeLeverageAuthorization.js +55 -0
  106. package/lib/esm/actions/requirements/blue/getLeverageRequirements.d.ts +104 -0
  107. package/lib/esm/actions/requirements/blue/getLeverageRequirements.js +189 -0
  108. package/lib/esm/actions/requirements/blue/getLeverageRequirementsApproval.d.ts +45 -0
  109. package/lib/esm/actions/requirements/blue/getLeverageRequirementsApproval.js +62 -0
  110. package/lib/esm/actions/requirements/blue/index.d.ts +3 -0
  111. package/lib/esm/actions/requirements/blue/index.js +3 -0
  112. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -2
  113. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
  114. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +11 -6
  115. package/lib/esm/actions/requirements/getRequirementsApproval.js +29 -5
  116. package/lib/esm/addresses.d.ts +1 -1
  117. package/lib/esm/addresses.js +1 -1
  118. package/lib/esm/blue/addresses.d.ts +1 -1
  119. package/lib/esm/blue/addresses.js +1 -1
  120. package/lib/esm/constants.d.ts +1 -1
  121. package/lib/esm/constants.js +1 -1
  122. package/lib/esm/entities/blue/blue.d.ts +486 -2
  123. package/lib/esm/entities/blue/blue.js +501 -6
  124. package/lib/esm/entities/index.d.ts +1 -1
  125. package/lib/esm/entities/midnight/midnight.d.ts +6 -0
  126. package/lib/esm/entities/midnight/midnight.js +21 -2
  127. package/lib/esm/entities/requirements/assertContractCode.d.ts +0 -23
  128. package/lib/esm/entities/requirements/assertContractCode.js +1 -25
  129. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +117 -0
  130. package/lib/esm/entities/vaultV2BlueReallocationData.js +227 -3
  131. package/lib/esm/helpers/constant.d.ts +41 -0
  132. package/lib/esm/helpers/constant.js +41 -0
  133. package/lib/esm/helpers/getZeroExLeverageBundle.d.ts +13 -0
  134. package/lib/esm/helpers/getZeroExLeverageBundle.js +23 -0
  135. package/lib/esm/helpers/index.d.ts +4 -1
  136. package/lib/esm/helpers/index.js +4 -1
  137. package/lib/esm/helpers/leverage/index.d.ts +1 -0
  138. package/lib/esm/helpers/leverage/index.js +1 -0
  139. package/lib/esm/helpers/leverage/limits.d.ts +472 -0
  140. package/lib/esm/helpers/leverage/limits.js +705 -0
  141. package/lib/esm/helpers/leverage/positionMarket.d.ts +17 -0
  142. package/lib/esm/helpers/leverage/positionMarket.js +24 -0
  143. package/lib/esm/helpers/leverage/reallocations.d.ts +159 -0
  144. package/lib/esm/helpers/leverage/reallocations.js +271 -0
  145. package/lib/esm/helpers/validate.d.ts +14 -0
  146. package/lib/esm/helpers/validate.js +25 -2
  147. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  148. package/lib/esm/helpers/validateRequirementSpender.js +5 -1
  149. package/lib/esm/helpers/zeroExQuote.d.ts +250 -0
  150. package/lib/esm/helpers/zeroExQuote.js +754 -0
  151. package/lib/esm/index.d.ts +1 -0
  152. package/lib/esm/index.js +1 -0
  153. package/lib/esm/reads/assertContractCode.d.ts +25 -0
  154. package/lib/esm/reads/assertContractCode.js +26 -0
  155. package/lib/esm/reads/fetchZeroExQuote.d.ts +123 -0
  156. package/lib/esm/reads/fetchZeroExQuote.js +326 -0
  157. package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +4 -0
  158. package/lib/esm/transactionPlan/midnight/takeBorrow.js +9 -3
  159. package/lib/esm/types/action.d.ts +130 -1
  160. package/lib/esm/types/error.d.ts +84 -0
  161. package/lib/esm/types/error.js +103 -0
  162. package/lib/esm/types/index.d.ts +2 -0
  163. package/lib/esm/types/index.js +2 -0
  164. package/lib/esm/types/leverageError.d.ts +1552 -0
  165. package/lib/esm/types/leverageError.js +1660 -0
  166. package/lib/esm/types/zeroEx.d.ts +171 -0
  167. package/lib/esm/types/zeroEx.js +1 -0
  168. package/lib/esm/version.d.ts +1 -1
  169. package/lib/esm/version.js +1 -1
  170. package/package.json +7 -7
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_LLTV_BUFFER = exports.MAX_REALLOCATION_PENALTY = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.MAX_SLIPPAGE_TOLERANCE = exports.MIDNIGHT_MAX_REFERRAL_FEE_PCT = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = void 0;
3
+ exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.LEVERAGE_CLOSE_INTEREST_BUFFER_FACTOR = exports.LEVERAGE_DEADLINE_WINDOW = exports.LEVERAGE_MAX_ORACLE_DEVIATION = exports.LEVERAGE_MAX_EXECUTION_LOSS = exports.DEFAULT_LLTV_BUFFER = exports.LEVERAGE_MAX_REALLOCATION_PENALTY = exports.MAX_REALLOCATION_PENALTY = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.MAX_SLIPPAGE_TOLERANCE = exports.MIDNIGHT_MAX_REFERRAL_FEE_PCT = exports.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
6
  const viem_1 = require("viem");
@@ -8,6 +8,13 @@ const viem_1 = require("viem");
8
8
  exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = 604800n;
9
9
  /** Maximum time between now and a Midnight taker-flow deadline, in seconds. */
10
10
  exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = 3600n;
11
+ /**
12
+ * Minimum time between a Midnight borrow's deadline and its market maturity, in seconds (2 hours).
13
+ * Debt still open at maturity becomes liquidatable, so entity and TransactionPlan borrows prepared at
14
+ * or before maturity that could execute closer to it are rejected. Credit covering the target at
15
+ * preparation does not exempt a borrow; sell credit only inside the window with `takeWithdraw`.
16
+ */
17
+ exports.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY = morpho_ts_1.Time.s.from.h(2n);
11
18
  /**
12
19
  * Matches MAX_SLIPPAGE_TOLERANCE, the SDK's other ceiling on a WAD share of user funds; higher fees are rejected as likely unit mistakes.
13
20
  * @internal
@@ -19,8 +26,42 @@ exports.MAX_SLIPPAGE_TOLERANCE = blue_sdk_1.MathLib.WAD / 10n;
19
26
  exports.DEFAULT_MAX_REALLOCATION_PENALTY = 0n;
20
27
  /** Maximum Vault V2 reallocation penalty: 100%. */
21
28
  exports.MAX_REALLOCATION_PENALTY = blue_sdk_1.MathLib.WAD;
29
+ /**
30
+ * Maximum penalty rate a ZeroExLeverageBundlesV1 Lever accepts per public-allocator reallocation:
31
+ * 1%, WAD-scaled. Fixed; no caller option.
32
+ */
33
+ exports.LEVERAGE_MAX_REALLOCATION_PENALTY = blue_sdk_1.MathLib.WAD / 100n;
22
34
  /** Default LLTV buffer: 0.5% below LLTV. Prevents instant liquidation on new positions. */
23
35
  exports.DEFAULT_LLTV_BUFFER = blue_sdk_1.MathLib.WAD / 200n;
36
+ /**
37
+ * SDK slippage ceiling per leverage action, WAD-scaled: `MAX_SLIPPAGE_TOLERANCE` (10%) for every action, the
38
+ * ceiling `fetchZeroExQuote` enforces, so the fetch and the builders cannot drift apart. Not configurable.
39
+ */
40
+ exports.LEVERAGE_MAX_EXECUTION_LOSS = Object.freeze({
41
+ lever: exports.MAX_SLIPPAGE_TOLERANCE,
42
+ delever: exports.MAX_SLIPPAGE_TOLERANCE,
43
+ close: exports.MAX_SLIPPAGE_TOLERANCE,
44
+ });
45
+ /**
46
+ * Largest amount a Lever's worst swap price (`maxSwapIn` per `minCollateralToBuy`) may be above the market's oracle
47
+ * price, WAD-scaled: 15%. Exactly 15% is accepted, and a price below the oracle, which favours the user, is never
48
+ * refused. Delever and Close are not checked. The worst price uses `maxSwapIn`, which already includes the caller's
49
+ * slippage, so the room left for a gap between 0x's price and the oracle is about 15% minus that slippage (5% at the
50
+ * 10% ceiling).
51
+ * Not configurable.
52
+ */
53
+ exports.LEVERAGE_MAX_ORACLE_DEVIATION = (blue_sdk_1.MathLib.WAD * 15n) / 100n;
54
+ /** Leverage deadline window after the data block, in seconds (1 hour). */
55
+ exports.LEVERAGE_DEADLINE_WINDOW = 3600n;
56
+ /**
57
+ * Margin applied to the interest a Close's debt may accrue before its deadline: the buffer is the debt accrued for
58
+ * the one-hour deadline window at 4× the data block's borrow rate. The factor matches the AdaptiveCurveIrm curve
59
+ * steepness (`AdaptiveCurveIrmLib.CURVE_STEEPNESS` in blue-sdk), the most utilization can raise the rate over its
60
+ * rate at target, while that rate at target itself drifts by well under 1% in an hour (`ADJUSTMENT_SPEED` is 50 per
61
+ * year). It does not cover a rate that rises more than 4×, such as one quoted below target that jumps to full
62
+ * utilization; the Close then reverts instead of overpaying. Fixed; no caller option.
63
+ */
64
+ exports.LEVERAGE_CLOSE_INTEREST_BUFFER_FACTOR = 4n;
24
65
  /**
25
66
  * Forward interest-accrual window, in seconds (2 hours), reserved in target-market
26
67
  * cap checks (BluePublicAllocator max-in, Vault V2 absolute and relative caps) when
@@ -0,0 +1,13 @@
1
+ import { type Address } from "viem";
2
+ /**
3
+ * Returns the ZeroExLeverageBundlesV1 address registered for `chainId`, whether or not the bundle
4
+ * can run there.
5
+ *
6
+ * @param chainId - Target chain id.
7
+ * @returns The registered ZeroExLeverageBundlesV1 address.
8
+ * @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
9
+ * @throws {LeverageUnsupportedChainError} with reason `noBundle` when no bundle, the zero address or a value that
10
+ * is not an address is registered.
11
+ * @internal
12
+ */
13
+ export declare const getRegisteredZeroExLeverageBundle: (chainId: number) => Address;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRegisteredZeroExLeverageBundle = void 0;
4
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
+ const viem_1 = require("viem");
6
+ const index_js_1 = require("../types/index.js");
7
+ /**
8
+ * Returns the ZeroExLeverageBundlesV1 address registered for `chainId`, whether or not the bundle
9
+ * can run there.
10
+ *
11
+ * @param chainId - Target chain id.
12
+ * @returns The registered ZeroExLeverageBundlesV1 address.
13
+ * @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
14
+ * @throws {LeverageUnsupportedChainError} with reason `noBundle` when no bundle, the zero address or a value that
15
+ * is not an address is registered.
16
+ * @internal
17
+ */
18
+ const getRegisteredZeroExLeverageBundle = (chainId) => {
19
+ const bundle = (0, blue_sdk_1.getChainAddresses)(chainId).bundles?.zeroExLeverageBundlesV1;
20
+ if (typeof bundle !== "string" ||
21
+ !(0, viem_1.isAddress)(bundle, { strict: false }) ||
22
+ (0, viem_1.isAddressEqual)(bundle, viem_1.zeroAddress)) {
23
+ throw new index_js_1.LeverageUnsupportedChainError({ chainId, reason: "noBundle" });
24
+ }
25
+ return bundle;
26
+ };
27
+ exports.getRegisteredZeroExLeverageBundle = getRegisteredZeroExLeverageBundle;
@@ -1,6 +1,8 @@
1
1
  export { getMidnightBlueBuyCallbackAddress, getMidnightBlueBuyCallbackData, } from "./callback.js";
2
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, VAULT_DEPOSIT_MAX_DEADLINE_SECONDS, } from "./constant.js";
2
+ export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, LEVERAGE_CLOSE_INTEREST_BUFFER_FACTOR, LEVERAGE_DEADLINE_WINDOW, LEVERAGE_MAX_EXECUTION_LOSS, LEVERAGE_MAX_ORACLE_DEVIATION, LEVERAGE_MAX_REALLOCATION_PENALTY, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, VAULT_DEPOSIT_MAX_DEADLINE_SECONDS, } from "./constant.js";
3
3
  export { validateBlueMarketDeadShares, validateVaultV1DeadShares, validateVaultV2DeadShares, } from "./deadShares.js";
4
+ export * from "./leverage/index.js";
5
+ export { computeLeveragePenaltyAssets, type LeverageAllocatorState, type LeverageReallocation, validateLeverageReallocations, } from "./leverage/reallocations.js";
4
6
  export { addTransactionMetadata } from "./metadata.js";
5
7
  export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./previewVaultV2ForceWithdraw.js";
6
8
  export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./previewVaultV2InKindRedeem.js";
@@ -11,3 +13,4 @@ export { getMidnightMaxSafeDebt, validateAccrualPosition, validateChainId, valid
11
13
  export { validateOfferSides } from "./validateOfferSides.js";
12
14
  export { type RequirementSpenderKey, validateRequirementSpender, } from "./validateRequirementSpender.js";
13
15
  export { computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawPlan, } from "./vaultV2ForceWithdrawPlan.js";
16
+ export { getZeroExSwapRoute, validateZeroExQuote, type ZeroExSwapRoute, } from "./zeroExQuote.js";
@@ -1,6 +1,21 @@
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
- exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightNativeAmount = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.getMidnightMaxSafeDebt = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateVaultV2DeadShares = exports.validateVaultV1DeadShares = exports.validateBlueMarketDeadShares = exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.APPROVE_ONLY_ONCE_TOKENS = exports.getMidnightBlueBuyCallbackData = exports.getMidnightBlueBuyCallbackAddress = void 0;
17
+ exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightNativeAmount = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.getMidnightMaxSafeDebt = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateLeverageReallocations = exports.computeLeveragePenaltyAssets = exports.validateVaultV2DeadShares = exports.validateVaultV1DeadShares = exports.validateBlueMarketDeadShares = exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.LEVERAGE_MAX_REALLOCATION_PENALTY = exports.LEVERAGE_MAX_ORACLE_DEVIATION = exports.LEVERAGE_MAX_EXECUTION_LOSS = exports.LEVERAGE_DEADLINE_WINDOW = exports.LEVERAGE_CLOSE_INTEREST_BUFFER_FACTOR = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.APPROVE_ONLY_ONCE_TOKENS = exports.getMidnightBlueBuyCallbackData = exports.getMidnightBlueBuyCallbackAddress = void 0;
18
+ exports.validateZeroExQuote = exports.getZeroExSwapRoute = exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = void 0;
4
19
  var callback_js_1 = require("./callback.js");
5
20
  Object.defineProperty(exports, "getMidnightBlueBuyCallbackAddress", { enumerable: true, get: function () { return callback_js_1.getMidnightBlueBuyCallbackAddress; } });
6
21
  Object.defineProperty(exports, "getMidnightBlueBuyCallbackData", { enumerable: true, get: function () { return callback_js_1.getMidnightBlueBuyCallbackData; } });
@@ -12,10 +27,16 @@ Object.defineProperty(exports, "DEFAULT_LLTV_BUFFER", { enumerable: true, get: f
12
27
  Object.defineProperty(exports, "DEFAULT_MAX_REALLOCATION_PENALTY", { enumerable: true, get: function () { return constant_js_1.DEFAULT_MAX_REALLOCATION_PENALTY; } });
13
28
  Object.defineProperty(exports, "DEFAULT_SUPPLY_TARGET_UTILIZATION", { enumerable: true, get: function () { return constant_js_1.DEFAULT_SUPPLY_TARGET_UTILIZATION; } });
14
29
  Object.defineProperty(exports, "DEFAULT_WITHDRAWAL_TARGET_UTILIZATION", { enumerable: true, get: function () { return constant_js_1.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION; } });
30
+ Object.defineProperty(exports, "LEVERAGE_CLOSE_INTEREST_BUFFER_FACTOR", { enumerable: true, get: function () { return constant_js_1.LEVERAGE_CLOSE_INTEREST_BUFFER_FACTOR; } });
31
+ Object.defineProperty(exports, "LEVERAGE_DEADLINE_WINDOW", { enumerable: true, get: function () { return constant_js_1.LEVERAGE_DEADLINE_WINDOW; } });
32
+ Object.defineProperty(exports, "LEVERAGE_MAX_EXECUTION_LOSS", { enumerable: true, get: function () { return constant_js_1.LEVERAGE_MAX_EXECUTION_LOSS; } });
33
+ Object.defineProperty(exports, "LEVERAGE_MAX_ORACLE_DEVIATION", { enumerable: true, get: function () { return constant_js_1.LEVERAGE_MAX_ORACLE_DEVIATION; } });
34
+ Object.defineProperty(exports, "LEVERAGE_MAX_REALLOCATION_PENALTY", { enumerable: true, get: function () { return constant_js_1.LEVERAGE_MAX_REALLOCATION_PENALTY; } });
15
35
  Object.defineProperty(exports, "MAX_ABSOLUTE_SHARE_PRICE", { enumerable: true, get: function () { return constant_js_1.MAX_ABSOLUTE_SHARE_PRICE; } });
16
36
  Object.defineProperty(exports, "MAX_REALLOCATION_PENALTY", { enumerable: true, get: function () { return constant_js_1.MAX_REALLOCATION_PENALTY; } });
17
37
  Object.defineProperty(exports, "MAX_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return constant_js_1.MAX_SLIPPAGE_TOLERANCE; } });
18
38
  Object.defineProperty(exports, "MAX_TOKEN_APPROVALS", { enumerable: true, get: function () { return constant_js_1.MAX_TOKEN_APPROVALS; } });
39
+ Object.defineProperty(exports, "MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY", { enumerable: true, get: function () { return constant_js_1.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY; } });
19
40
  Object.defineProperty(exports, "MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS", { enumerable: true, get: function () { return constant_js_1.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS; } });
20
41
  Object.defineProperty(exports, "MIN_DEAD_SHARES", { enumerable: true, get: function () { return constant_js_1.MIN_DEAD_SHARES; } });
21
42
  Object.defineProperty(exports, "MIN_VAULT_V2_DEAD_ASSETS", { enumerable: true, get: function () { return constant_js_1.MIN_VAULT_V2_DEAD_ASSETS; } });
@@ -24,6 +45,10 @@ var deadShares_js_1 = require("./deadShares.js");
24
45
  Object.defineProperty(exports, "validateBlueMarketDeadShares", { enumerable: true, get: function () { return deadShares_js_1.validateBlueMarketDeadShares; } });
25
46
  Object.defineProperty(exports, "validateVaultV1DeadShares", { enumerable: true, get: function () { return deadShares_js_1.validateVaultV1DeadShares; } });
26
47
  Object.defineProperty(exports, "validateVaultV2DeadShares", { enumerable: true, get: function () { return deadShares_js_1.validateVaultV2DeadShares; } });
48
+ __exportStar(require("./leverage/index.js"), exports);
49
+ var reallocations_js_1 = require("./leverage/reallocations.js");
50
+ Object.defineProperty(exports, "computeLeveragePenaltyAssets", { enumerable: true, get: function () { return reallocations_js_1.computeLeveragePenaltyAssets; } });
51
+ Object.defineProperty(exports, "validateLeverageReallocations", { enumerable: true, get: function () { return reallocations_js_1.validateLeverageReallocations; } });
27
52
  var metadata_js_1 = require("./metadata.js");
28
53
  Object.defineProperty(exports, "addTransactionMetadata", { enumerable: true, get: function () { return metadata_js_1.addTransactionMetadata; } });
29
54
  var previewVaultV2ForceWithdraw_js_1 = require("./previewVaultV2ForceWithdraw.js");
@@ -63,3 +88,6 @@ Object.defineProperty(exports, "computeVaultV2ForceWithdrawMinSharesBurnt", { en
63
88
  Object.defineProperty(exports, "computeVaultV2ForceWithdrawPlan", { enumerable: true, get: function () { return vaultV2ForceWithdrawPlan_js_1.computeVaultV2ForceWithdrawPlan; } });
64
89
  Object.defineProperty(exports, "computeVaultV2ForceWithdrawSharesBurnt", { enumerable: true, get: function () { return vaultV2ForceWithdrawPlan_js_1.computeVaultV2ForceWithdrawSharesBurnt; } });
65
90
  Object.defineProperty(exports, "resolveVaultV2ForceWithdrawEligibility", { enumerable: true, get: function () { return vaultV2ForceWithdrawPlan_js_1.resolveVaultV2ForceWithdrawEligibility; } });
91
+ var zeroExQuote_js_1 = require("./zeroExQuote.js");
92
+ Object.defineProperty(exports, "getZeroExSwapRoute", { enumerable: true, get: function () { return zeroExQuote_js_1.getZeroExSwapRoute; } });
93
+ Object.defineProperty(exports, "validateZeroExQuote", { enumerable: true, get: function () { return zeroExQuote_js_1.validateZeroExQuote; } });
@@ -0,0 +1 @@
1
+ export { type CloseLimits, type CloseLimitsParams, computeCloseInterestBuffer, computeCloseLimits, computeDeleverLimits, computeLeverageOracleDeviation, computeLeverLimits, type DeleverLimits, type DeleverLimitsParams, type LeverageActionOracleDeviation, type LeverageLimitsData, type LeverageLimitsInput, type LeverageOperation, type LeverageOracleDeviation, type LeverageOracleDeviationParams, type LeverageQuoteAmounts, type LeverLimits, type LeverLimitsParams, leverageDeadline, validateLeverageInputs, } from "./limits.js";
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateLeverageInputs = exports.leverageDeadline = exports.computeLeverLimits = exports.computeLeverageOracleDeviation = exports.computeDeleverLimits = exports.computeCloseLimits = exports.computeCloseInterestBuffer = void 0;
4
+ var limits_js_1 = require("./limits.js");
5
+ Object.defineProperty(exports, "computeCloseInterestBuffer", { enumerable: true, get: function () { return limits_js_1.computeCloseInterestBuffer; } });
6
+ Object.defineProperty(exports, "computeCloseLimits", { enumerable: true, get: function () { return limits_js_1.computeCloseLimits; } });
7
+ Object.defineProperty(exports, "computeDeleverLimits", { enumerable: true, get: function () { return limits_js_1.computeDeleverLimits; } });
8
+ Object.defineProperty(exports, "computeLeverageOracleDeviation", { enumerable: true, get: function () { return limits_js_1.computeLeverageOracleDeviation; } });
9
+ Object.defineProperty(exports, "computeLeverLimits", { enumerable: true, get: function () { return limits_js_1.computeLeverLimits; } });
10
+ Object.defineProperty(exports, "leverageDeadline", { enumerable: true, get: function () { return limits_js_1.leverageDeadline; } });
11
+ Object.defineProperty(exports, "validateLeverageInputs", { enumerable: true, get: function () { return limits_js_1.validateLeverageInputs; } });