@morpho-org/morpho-sdk 10.3.0 → 10.4.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 (188) hide show
  1. package/README.md +172 -8
  2. package/lib/cjs/actions/midnight/redeem.d.ts +20 -3
  3. package/lib/cjs/actions/midnight/redeem.js +58 -1
  4. package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
  5. package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +41 -0
  6. package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -2
  7. package/lib/cjs/actions/midnight/withdrawCollateral.js +26 -1
  8. package/lib/cjs/helpers/callback.d.ts +3 -2
  9. package/lib/cjs/helpers/callback.js +4 -20
  10. package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
  11. package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.js +30 -0
  12. package/lib/cjs/helpers/parseMidnightMaker.d.ts +21 -0
  13. package/lib/cjs/helpers/parseMidnightMaker.js +41 -1
  14. package/lib/cjs/helpers/validate.d.ts +49 -1
  15. package/lib/cjs/helpers/validate.js +87 -1
  16. package/lib/cjs/helpers/validateMidnightPublication.d.ts +10 -0
  17. package/lib/cjs/helpers/validateMidnightPublication.js +18 -1
  18. package/lib/cjs/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
  19. package/lib/cjs/helpers/validateMidnightTakeableOfferFields.js +85 -0
  20. package/lib/cjs/index.d.ts +2 -2
  21. package/lib/cjs/index.js +23 -1
  22. package/lib/cjs/midnight/utils.d.ts +1 -1
  23. package/lib/cjs/midnight/utils.js +2 -1
  24. package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
  25. package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.js +264 -0
  26. package/lib/cjs/transactionPlan/error.d.ts +27 -0
  27. package/lib/cjs/transactionPlan/error.js +30 -1
  28. package/lib/cjs/transactionPlan/index.d.ts +40 -1
  29. package/lib/cjs/transactionPlan/index.js +46 -5
  30. package/lib/cjs/transactionPlan/midnight/authorization.d.ts +15 -0
  31. package/lib/cjs/transactionPlan/midnight/authorization.js +45 -0
  32. package/lib/cjs/transactionPlan/midnight/cancelOffers.d.ts +80 -0
  33. package/lib/cjs/transactionPlan/midnight/cancelOffers.js +125 -0
  34. package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +104 -0
  35. package/lib/cjs/transactionPlan/midnight/makeBorrow.js +126 -0
  36. package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +140 -0
  37. package/lib/cjs/transactionPlan/midnight/makeLend.js +176 -0
  38. package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +118 -0
  39. package/lib/cjs/transactionPlan/midnight/makeRepay.js +118 -0
  40. package/lib/cjs/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
  41. package/lib/cjs/transactionPlan/midnight/makeWithdraw.js +126 -0
  42. package/lib/cjs/transactionPlan/midnight/makerPublication.d.ts +55 -0
  43. package/lib/cjs/transactionPlan/midnight/makerPublication.js +315 -0
  44. package/lib/cjs/transactionPlan/midnight/market.d.ts +49 -0
  45. package/lib/cjs/transactionPlan/midnight/market.js +120 -0
  46. package/lib/cjs/transactionPlan/midnight/prepare.d.ts +244 -0
  47. package/lib/cjs/transactionPlan/midnight/prepare.js +547 -0
  48. package/lib/cjs/transactionPlan/midnight/publicationState.d.ts +24 -0
  49. package/lib/cjs/transactionPlan/midnight/publicationState.js +50 -0
  50. package/lib/cjs/transactionPlan/midnight/redeem.d.ts +102 -0
  51. package/lib/cjs/transactionPlan/midnight/redeem.js +170 -0
  52. package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
  53. package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.js +51 -0
  54. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
  55. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +328 -0
  56. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
  57. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +199 -0
  58. package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
  59. package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +190 -0
  60. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
  61. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +221 -0
  62. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
  63. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +179 -0
  64. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
  65. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +259 -0
  66. package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +304 -0
  67. package/lib/cjs/transactionPlan/midnight/takeBorrow.js +545 -0
  68. package/lib/cjs/transactionPlan/midnight/takeLend.d.ts +99 -0
  69. package/lib/cjs/transactionPlan/midnight/takeLend.js +263 -0
  70. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
  71. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +440 -0
  72. package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
  73. package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +240 -0
  74. package/lib/cjs/transactionPlan/midnight/validation.d.ts +22 -0
  75. package/lib/cjs/transactionPlan/midnight/validation.js +158 -0
  76. package/lib/cjs/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
  77. package/lib/cjs/transactionPlan/midnight/withdrawCollateral.js +228 -0
  78. package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
  79. package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.js +232 -0
  80. package/lib/cjs/transactionPlan/plan.d.ts +48 -14
  81. package/lib/cjs/transactionPlan/plan.js +103 -18
  82. package/lib/cjs/transactionPlan/requirements.d.ts +7 -4
  83. package/lib/cjs/transactionPlan/requirements.js +2 -2
  84. package/lib/cjs/transactionPlan/serde.d.ts +13 -2
  85. package/lib/cjs/transactionPlan/serde.js +68 -21
  86. package/lib/cjs/transactionPlan/types.d.ts +147 -0
  87. package/lib/cjs/transactionPlan/validateActions.d.ts +3 -1
  88. package/lib/cjs/transactionPlan/validateActions.js +31 -3
  89. package/lib/cjs/transactionPlan/validation.d.ts +1 -1
  90. package/lib/cjs/transactionPlan/validation.js +37 -1
  91. package/lib/cjs/types/error.d.ts +2 -0
  92. package/lib/cjs/types/error.js +2 -0
  93. package/lib/cjs/version.d.ts +1 -1
  94. package/lib/cjs/version.js +1 -1
  95. package/lib/esm/actions/midnight/redeem.d.ts +20 -3
  96. package/lib/esm/actions/midnight/redeem.js +56 -0
  97. package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
  98. package/lib/esm/actions/midnight/supplyCollateralWithNative.js +40 -0
  99. package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -2
  100. package/lib/esm/actions/midnight/withdrawCollateral.js +25 -1
  101. package/lib/esm/helpers/callback.d.ts +3 -2
  102. package/lib/esm/helpers/callback.js +5 -21
  103. package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
  104. package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.js +27 -0
  105. package/lib/esm/helpers/parseMidnightMaker.d.ts +21 -0
  106. package/lib/esm/helpers/parseMidnightMaker.js +40 -1
  107. package/lib/esm/helpers/validate.d.ts +49 -1
  108. package/lib/esm/helpers/validate.js +84 -1
  109. package/lib/esm/helpers/validateMidnightPublication.d.ts +10 -0
  110. package/lib/esm/helpers/validateMidnightPublication.js +16 -0
  111. package/lib/esm/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
  112. package/lib/esm/helpers/validateMidnightTakeableOfferFields.js +81 -0
  113. package/lib/esm/index.d.ts +2 -2
  114. package/lib/esm/index.js +1 -1
  115. package/lib/esm/midnight/utils.d.ts +1 -1
  116. package/lib/esm/midnight/utils.js +1 -1
  117. package/lib/esm/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
  118. package/lib/esm/transactionPlan/blue/withdrawBuyCallback.js +259 -0
  119. package/lib/esm/transactionPlan/error.d.ts +27 -0
  120. package/lib/esm/transactionPlan/error.js +28 -0
  121. package/lib/esm/transactionPlan/index.d.ts +40 -1
  122. package/lib/esm/transactionPlan/index.js +20 -1
  123. package/lib/esm/transactionPlan/midnight/authorization.d.ts +15 -0
  124. package/lib/esm/transactionPlan/midnight/authorization.js +40 -0
  125. package/lib/esm/transactionPlan/midnight/cancelOffers.d.ts +80 -0
  126. package/lib/esm/transactionPlan/midnight/cancelOffers.js +120 -0
  127. package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +104 -0
  128. package/lib/esm/transactionPlan/midnight/makeBorrow.js +123 -0
  129. package/lib/esm/transactionPlan/midnight/makeLend.d.ts +140 -0
  130. package/lib/esm/transactionPlan/midnight/makeLend.js +172 -0
  131. package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +118 -0
  132. package/lib/esm/transactionPlan/midnight/makeRepay.js +115 -0
  133. package/lib/esm/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
  134. package/lib/esm/transactionPlan/midnight/makeWithdraw.js +123 -0
  135. package/lib/esm/transactionPlan/midnight/makerPublication.d.ts +55 -0
  136. package/lib/esm/transactionPlan/midnight/makerPublication.js +310 -0
  137. package/lib/esm/transactionPlan/midnight/market.d.ts +49 -0
  138. package/lib/esm/transactionPlan/midnight/market.js +112 -0
  139. package/lib/esm/transactionPlan/midnight/prepare.d.ts +244 -0
  140. package/lib/esm/transactionPlan/midnight/prepare.js +536 -0
  141. package/lib/esm/transactionPlan/midnight/publicationState.d.ts +24 -0
  142. package/lib/esm/transactionPlan/midnight/publicationState.js +47 -0
  143. package/lib/esm/transactionPlan/midnight/redeem.d.ts +102 -0
  144. package/lib/esm/transactionPlan/midnight/redeem.js +165 -0
  145. package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
  146. package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.js +47 -0
  147. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
  148. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +323 -0
  149. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
  150. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +196 -0
  151. package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
  152. package/lib/esm/transactionPlan/midnight/supplyCollateral.js +185 -0
  153. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
  154. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +216 -0
  155. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
  156. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +176 -0
  157. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
  158. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +254 -0
  159. package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +304 -0
  160. package/lib/esm/transactionPlan/midnight/takeBorrow.js +539 -0
  161. package/lib/esm/transactionPlan/midnight/takeLend.d.ts +99 -0
  162. package/lib/esm/transactionPlan/midnight/takeLend.js +258 -0
  163. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
  164. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +435 -0
  165. package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
  166. package/lib/esm/transactionPlan/midnight/takeWithdraw.js +236 -0
  167. package/lib/esm/transactionPlan/midnight/validation.d.ts +22 -0
  168. package/lib/esm/transactionPlan/midnight/validation.js +151 -0
  169. package/lib/esm/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
  170. package/lib/esm/transactionPlan/midnight/withdrawCollateral.js +223 -0
  171. package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
  172. package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.js +227 -0
  173. package/lib/esm/transactionPlan/plan.d.ts +48 -14
  174. package/lib/esm/transactionPlan/plan.js +99 -14
  175. package/lib/esm/transactionPlan/requirements.d.ts +7 -4
  176. package/lib/esm/transactionPlan/requirements.js +2 -2
  177. package/lib/esm/transactionPlan/serde.d.ts +13 -2
  178. package/lib/esm/transactionPlan/serde.js +49 -2
  179. package/lib/esm/transactionPlan/types.d.ts +147 -0
  180. package/lib/esm/transactionPlan/validateActions.d.ts +3 -1
  181. package/lib/esm/transactionPlan/validateActions.js +31 -3
  182. package/lib/esm/transactionPlan/validation.d.ts +1 -1
  183. package/lib/esm/transactionPlan/validation.js +38 -2
  184. package/lib/esm/types/error.d.ts +2 -0
  185. package/lib/esm/types/error.js +2 -0
  186. package/lib/esm/version.d.ts +1 -1
  187. package/lib/esm/version.js +1 -1
  188. package/package.json +4 -4
@@ -0,0 +1,244 @@
1
+ import { MarketParams } from "@morpho-org/midnight-sdk";
2
+ import type { Address, Client } from "viem";
3
+ import { parseMidnightCancelAndMake } from "../../actions/midnight/cancelAndMake.js";
4
+ import { type ChainCheck } from "../../actions/requirements/chainCheck.js";
5
+ import type { GetOffersDataParams, MakeLendParams, MakeOffersParams, OffersData, SupplyBlueMakeLendParams, SupplyCollateralMakeBorrowParams } from "../../entities/midnight/types.js";
6
+ import { ExpiredDeadlineError, type Metadata } from "../../types/index.js";
7
+ /** Plain viem client and chain used to prepare maker offers for a TransactionPlan. @internal */
8
+ export type MakerOffersContext = {
9
+ readonly client: Client;
10
+ readonly chainId: number;
11
+ };
12
+ /**
13
+ * Plain viem client context for whole maker constructors: the caller's analytics metadata,
14
+ * optionally the invocation's chain check, run once before the first publication-state read, and
15
+ * optionally an error to throw once the pinned checks pass.
16
+ * @internal
17
+ */
18
+ export type MakerParamsContext = MakerOffersContext & {
19
+ readonly metadata?: Metadata;
20
+ readonly chainCheck?: ChainCheck;
21
+ /** Thrown after the pinned offer-state and deadline checks, before the funding check, the mempool API call, ratification and encoding. */
22
+ readonly rejectAfterPinnedChecks?: ExpiredDeadlineError;
23
+ };
24
+ declare const offersParams: unique symbol;
25
+ declare const preparedMake: unique symbol;
26
+ /**
27
+ * Validates the complete raw publication request before state reads, with the same checks in the
28
+ * same order as the entity maker flows, from a plain viem client.
29
+ * @param params - Maker account, offer tree and optional mempool validation settings.
30
+ * @param context - Plain viem client and the chain the offers are published on.
31
+ * @returns The frozen request that {@link getOffersDataInternal} reads state for.
32
+ * @throws {ChainIdMismatchError} when the client declares another chain than `context.chainId`.
33
+ * @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
34
+ * @throws {MidnightCalldataEncodingError} when `accountAddress` is malformed.
35
+ * @throws {MidnightOfferMakerMismatchError} when an offer names another maker.
36
+ * @throws {MidnightOfferRatifierMismatchError} when an offer names another ratifier than the tree's.
37
+ * @internal
38
+ */
39
+ export declare const parseGetOffersDataParams: (params: GetOffersDataParams, { client, chainId }: MakerOffersContext) => Readonly<{
40
+ tree: import("@morpho-org/midnight-sdk").Tree<"priceV1"> | import("@morpho-org/midnight-sdk").Tree<"rateV1">;
41
+ accountAddress: `0x${string}`;
42
+ ratifier: `0x${string}`;
43
+ ratifierType: "priceV1" | "rateV1";
44
+ validation: false | import("../../entities/index.js").MidnightOfferValidationParams | undefined;
45
+ [offersParams]: true;
46
+ }>;
47
+ /**
48
+ * Reads publication state only from the complete constructed request, using a plain viem client.
49
+ * Pass the caller's `chainCheck` to share one `eth_chainId` read per invocation. With a
50
+ * `bundleDeadline`, the block is pinned first and the deadline is checked against its timestamp
51
+ * before any contract read, and again against the validated state's timestamp after the offer checks.
52
+ * `validateFunding` receives the pinned block number and timestamp and runs after the pinned
53
+ * offer-state checks and before the optional mempool API call.
54
+ * A `rejectAfterPinnedChecks` error is thrown after the pinned offer-state and deadline checks,
55
+ * so no funding check, API call, ratification or encoding runs.
56
+ * @param params - Request built by {@link parseGetOffersDataParams}.
57
+ * @param context - Plain viem client, chain, market-creation clock, optional chain check, bundle deadline, funding check and post-pinned-check error.
58
+ * @returns Offer groups, tree, ratifier and encoded payload ready for publication.
59
+ * @throws {ChainIdMismatchError} when the client's RPC reports another chain.
60
+ * @throws {ExpiredDeadlineError} when `bundleDeadline` is at or before the pinned block timestamp while every offer is live,
61
+ * or `rejectAfterPinnedChecks` is set and the pinned checks pass.
62
+ * @throws {viem.BaseError} when a publication-state read fails.
63
+ * @internal
64
+ */
65
+ export declare const getOffersDataInternal: (params: ReturnType<typeof parseGetOffersDataParams>, { client, chainId, marketCreationTime, chainCheck, bundleDeadline, validateFunding, rejectAfterPinnedChecks, }: MakerOffersContext & {
66
+ readonly marketCreationTime?: "expiry" | "now";
67
+ readonly chainCheck?: ChainCheck;
68
+ readonly bundleDeadline?: bigint;
69
+ readonly validateFunding?: (blockNumber: bigint, timestamp: bigint) => Promise<void>;
70
+ readonly rejectAfterPinnedChecks?: ExpiredDeadlineError;
71
+ }) => Promise<OffersData>;
72
+ /**
73
+ * Constructs the complete lend publication and its loan-token allowance amount from raw params for
74
+ * a TransactionPlan, with the entity `makeLend` checks in the same order, except that malformed
75
+ * cancellations are rejected before any state read.
76
+ * @param params - Maker account, lend-side offer tree, loan token and assets, cancellations and deadline.
77
+ * @param context - Plain viem client, chain, analytics metadata and optional chain check.
78
+ * @returns The parsed bundle action, its publication data, the loan token and the approval amount.
79
+ * @throws {ChainIdMismatchError} when the client declares, or its RPC reports, another chain.
80
+ * @throws {ExpiredDeadlineError} when `deadline` is at or before `now` or the pinned block timestamp.
81
+ * @throws {InvalidBigIntInputError} when `loanAssets` or `reservedLoanAssets` is not a bigint.
82
+ * @throws {NonPositiveInputError} when `loanAssets` is not positive.
83
+ * @throws {MidnightOfferSideMismatchError} when an offer is not lend-side.
84
+ * @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
85
+ * @throws {DuplicateMidnightGroupCancellationError} when a group is cancelled more than once.
86
+ * @throws {MidnightReplacementGroupCancelledError} when a cancelled group is in the new tree.
87
+ * @throws {MidnightOfferMarketLoanTokenMismatchError} when an offer market lends another token.
88
+ * @throws {viem.BaseError} when a publication-state read fails.
89
+ * @internal
90
+ */
91
+ export declare const parseMakeLendParams: (params: MakeLendParams, context: MakerParamsContext) => Promise<Readonly<{
92
+ action: ReturnType<typeof parseMidnightCancelAndMake>;
93
+ data: OffersData;
94
+ loanToken: Address;
95
+ approvalAmount: bigint;
96
+ [preparedMake]: "makeLend";
97
+ }>>;
98
+ /**
99
+ * Constructs the complete reduce-only repayment publication and its loan-token allowance amount
100
+ * from raw params for a TransactionPlan, with the entity `makeRepay` checks in the same order,
101
+ * except that malformed cancellations are rejected before any state read.
102
+ * @param params - Maker account, reduce-only lend-side offer tree, loan token and assets, cancellations and deadline.
103
+ * @param context - Plain viem client, chain, analytics metadata and optional chain check.
104
+ * @returns The parsed bundle action, its publication data, the loan token and the approval amount.
105
+ * @throws {ChainIdMismatchError} when the client declares, or its RPC reports, another chain.
106
+ * @throws {ExpiredDeadlineError} when `deadline` is at or before `now` or the pinned block timestamp.
107
+ * @throws {NonPositiveInputError} when `loanAssets` is not positive.
108
+ * @throws {MidnightOfferNotReduceOnlyError} when an offer is not reduce-only.
109
+ * @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
110
+ * @throws {DuplicateMidnightGroupCancellationError} when a group is cancelled more than once.
111
+ * @throws {MidnightReplacementGroupCancelledError} when a cancelled group is in the new tree.
112
+ * @throws {MidnightOfferMarketLoanTokenMismatchError} when an offer market lends another token.
113
+ * @throws {viem.BaseError} when a publication-state read fails.
114
+ * @internal
115
+ */
116
+ export declare const parseMakeRepayParams: (params: MakeLendParams, context: MakerParamsContext) => Promise<Readonly<{
117
+ action: ReturnType<typeof parseMidnightCancelAndMake>;
118
+ data: OffersData;
119
+ loanToken: Address;
120
+ approvalAmount: bigint;
121
+ [preparedMake]: "makeRepay";
122
+ }>>;
123
+ /**
124
+ * Constructs the complete borrow publication from raw params for a TransactionPlan, with the
125
+ * entity `makeBorrow` checks in the same order, except that malformed cancellations are rejected
126
+ * before any state read.
127
+ * @param params - Maker account, borrow-side offer tree, cancellations, deadline and validation.
128
+ * @param context - Plain viem client, chain, analytics metadata and optional chain check.
129
+ * @returns The parsed bundle action and the publication data it encodes.
130
+ * @throws {ChainIdMismatchError} when the client declares, or its RPC reports, another chain.
131
+ * @throws {ExpiredDeadlineError} when `deadline` is at or before `now` or the pinned block timestamp.
132
+ * @throws {MidnightOfferSideMismatchError} when an offer is not borrow-side.
133
+ * @throws {InvalidTransactionPlanError} when a supplied non-null `cancellations` is not an array or has a non-object entry.
134
+ * @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
135
+ * @throws {DuplicateMidnightGroupCancellationError} when a group is cancelled more than once.
136
+ * @throws {MidnightReplacementGroupCancelledError} when a cancelled group is in the new tree.
137
+ * @throws {viem.BaseError} when a publication-state read fails.
138
+ * @internal
139
+ */
140
+ export declare const parseMakeBorrowParams: (params: MakeOffersParams, context: MakerParamsContext) => Promise<Readonly<{
141
+ action: ReturnType<typeof parseMidnightCancelAndMake>;
142
+ data: OffersData;
143
+ loanToken?: Address;
144
+ approvalAmount: bigint;
145
+ [preparedMake]: "makeBorrow";
146
+ }>>;
147
+ /**
148
+ * Constructs the complete reduce-only credit-exit publication from raw params for a
149
+ * TransactionPlan, with the entity `makeWithdraw` checks in the same order, except that malformed
150
+ * cancellations are rejected before any state read.
151
+ * @param params - Maker account, reduce-only borrow-side offer tree, cancellations and deadline.
152
+ * @param context - Plain viem client, chain, analytics metadata and optional chain check.
153
+ * @returns The parsed bundle action and the publication data it encodes.
154
+ * @throws {ChainIdMismatchError} when the client declares, or its RPC reports, another chain.
155
+ * @throws {ExpiredDeadlineError} when `deadline` is at or before `now` or the pinned block timestamp.
156
+ * @throws {MidnightOfferNotReduceOnlyError} when an offer is not reduce-only.
157
+ * @throws {InvalidTransactionPlanError} when a supplied non-null `cancellations` is not an array or
158
+ * has a non-object entry.
159
+ * @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
160
+ * @throws {DuplicateMidnightGroupCancellationError} when a group is cancelled more than once.
161
+ * @throws {MidnightReplacementGroupCancelledError} when a cancelled group is in the new tree.
162
+ * @throws {viem.BaseError} when a publication-state read fails.
163
+ * @internal
164
+ */
165
+ export declare const parseMakeWithdrawParams: (params: MakeOffersParams, context: MakerParamsContext) => Promise<Readonly<{
166
+ action: ReturnType<typeof parseMidnightCancelAndMake>;
167
+ data: OffersData;
168
+ loanToken?: Address;
169
+ approvalAmount: bigint;
170
+ [preparedMake]: "makeWithdraw";
171
+ }>>;
172
+ /**
173
+ * Constructs the complete collateral-funded borrow publication from raw params for a
174
+ * TransactionPlan, with the entity `supplyCollateralMakeBorrow` checks, except that the market,
175
+ * collateral and native funding checks run before any state read.
176
+ * @param params - Maker account, borrow-side offer tree, collateral supplies, native amount, cancellations and deadline.
177
+ * @param context - Plain viem client, chain, analytics metadata, optional chain check and post-pinned-check error.
178
+ * @returns The parsed bundle action, its publication data and the frozen collateral it supplies.
179
+ * @throws {ChainIdMismatchError} when the client declares, or its RPC reports, another chain.
180
+ * @throws {ExpiredDeadlineError} when `deadline` is at or before `now` or the pinned block timestamp,
181
+ * or `rejectAfterPinnedChecks` is set and the pinned checks pass.
182
+ * @throws {MidnightOfferSideMismatchError} when an offer is not borrow-side.
183
+ * @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
184
+ * @throws {DuplicateMidnightGroupCancellationError} when a group is cancelled more than once.
185
+ * @throws {MidnightReplacementGroupCancelledError} when a cancelled group is in the new tree.
186
+ * @throws {MarketIdMismatchError} when an offer targets another market than the collateral market.
187
+ * @throws {EmptyMidnightCollateralSuppliesError} when collateral supplies are empty.
188
+ * @throws {InvalidBigIntInputError} when a supply index or amount is not a bigint.
189
+ * @throws {UnknownCollateralIndexError} when a supply index is not configured.
190
+ * @throws {viem.BaseError} when a publication-state read fails.
191
+ * @internal
192
+ */
193
+ export declare const parseSupplyCollateralMakeBorrowParams: (params: SupplyCollateralMakeBorrowParams, context: MakerParamsContext) => Promise<Readonly<{
194
+ action: import("../../actions/midnight/cancelAndMake.js").ParsedMidnightCancelAndMake;
195
+ data: OffersData;
196
+ collateral: {
197
+ market: MarketParams;
198
+ supplies: {
199
+ collateralIndex: bigint;
200
+ assets: bigint;
201
+ }[];
202
+ };
203
+ [preparedMake]: "supplyCollateralMakeBorrow";
204
+ }>>;
205
+ /**
206
+ * Constructs the complete Blue-funded lend publication from raw params for a TransactionPlan. The
207
+ * input, tree, cancellation, deadline and binding checks run before the chain check, the
208
+ * publication-state reads and the Blue market read; payload encoding, which also checks market
209
+ * maturity, runs after them. The Blue market is read at the block the publication-state reads are pinned to,
210
+ * after their checks and before the optional mempool API call.
211
+ * @param params - Maker account, lend-side offer tree, Blue market, assets to park, callback salt, cancellations and deadline.
212
+ * @param context - Plain viem client, chain, analytics metadata, optional chain check and post-pinned-check error.
213
+ * @returns The parsed bundle action, its publication data, the loan token, the approval amount and the frozen Blue supply.
214
+ * @throws {ChainIdMismatchError} when the client declares, or its RPC reports, another chain.
215
+ * @throws {InvalidMidnightHexInputError} when `callbackSalt` is not 32-byte hex.
216
+ * @throws {InvalidBigIntInputError} when `assetsToPark` or `blueMarket.lltv` is not a bigint.
217
+ * @throws {NonPositiveInputError} when `assetsToPark` is not positive.
218
+ * @throws {MidnightOfferSideMismatchError} when an offer is not lend-side.
219
+ * @throws {ExpiredDeadlineError} when `deadline` is at or before `now` or the pinned block timestamp,
220
+ * or `rejectAfterPinnedChecks` is set and the pinned offer checks pass, before the Blue market read.
221
+ * @throws {EmptyBlueParkingMarketError} when the Blue market has no supply shares at the pinned block.
222
+ * @throws {ZeroBlueParkingSharesError} when `assetsToPark` buys zero Blue supply shares.
223
+ * @throws {viem.BaseError} when a publication-state or Blue market read fails.
224
+ * @internal
225
+ */
226
+ export declare const parseSupplyBlueMakeLendParams: (params: SupplyBlueMakeLendParams, context: MakerParamsContext) => Promise<Readonly<{
227
+ action: import("../../actions/midnight/cancelAndMake.js").ParsedMidnightCancelAndMake;
228
+ data: OffersData;
229
+ loanToken: `0x${string}`;
230
+ approvalAmount: bigint;
231
+ blueSupply: {
232
+ market: {
233
+ loanToken: `0x${string}`;
234
+ collateralToken: `0x${string}`;
235
+ oracle: `0x${string}`;
236
+ irm: `0x${string}`;
237
+ lltv: bigint;
238
+ };
239
+ assets: bigint;
240
+ callbackSalt: `0x${string}`;
241
+ };
242
+ [preparedMake]: "supplyBlueMakeLend";
243
+ }>>;
244
+ export {};