@morpho-org/morpho-sdk 2.1.1 → 3.0.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/lib/cjs/abis.d.ts +2816 -0
  2. package/lib/cjs/abis.js +1951 -0
  3. package/lib/cjs/actions/index.d.ts +3 -0
  4. package/lib/cjs/actions/marketV1/borrow.js +7 -10
  5. package/lib/cjs/actions/marketV1/buildReallocationActions.d.ts +2 -3
  6. package/lib/cjs/actions/marketV1/buildReallocationActions.js +1 -2
  7. package/lib/cjs/actions/marketV1/repay.d.ts +2 -0
  8. package/lib/cjs/actions/marketV1/repay.js +7 -8
  9. package/lib/cjs/actions/marketV1/repayWithdrawCollateral.d.ts +2 -0
  10. package/lib/cjs/actions/marketV1/repayWithdrawCollateral.js +9 -10
  11. package/lib/cjs/actions/marketV1/supplyCollateral.d.ts +2 -0
  12. package/lib/cjs/actions/marketV1/supplyCollateral.js +11 -12
  13. package/lib/cjs/actions/marketV1/supplyCollateralBorrow.d.ts +2 -0
  14. package/lib/cjs/actions/marketV1/supplyCollateralBorrow.js +13 -14
  15. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -2
  16. package/lib/cjs/actions/requirements/getRequirementsAction.d.ts +1 -1
  17. package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
  18. package/lib/cjs/actions/vaultV1/deposit.d.ts +2 -0
  19. package/lib/cjs/actions/vaultV1/deposit.js +13 -14
  20. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +2 -0
  21. package/lib/cjs/actions/vaultV1/migrateToV2.js +11 -9
  22. package/lib/cjs/actions/vaultV2/deposit.d.ts +2 -0
  23. package/lib/cjs/actions/vaultV2/deposit.js +13 -14
  24. package/lib/cjs/addresses.d.ts +2 -0
  25. package/lib/cjs/addresses.js +18 -0
  26. package/lib/cjs/augment/AccrualPosition.d.ts +9 -0
  27. package/lib/cjs/augment/AccrualPosition.js +8 -0
  28. package/lib/cjs/augment/AccrualVault.d.ts +8 -0
  29. package/lib/cjs/augment/AccrualVault.js +7 -0
  30. package/lib/cjs/augment/Holding.d.ts +8 -0
  31. package/lib/cjs/augment/Holding.js +7 -0
  32. package/lib/cjs/augment/Market.d.ts +8 -0
  33. package/lib/cjs/augment/Market.js +7 -0
  34. package/lib/cjs/augment/MarketParams.d.ts +8 -0
  35. package/lib/cjs/augment/MarketParams.js +7 -0
  36. package/lib/cjs/augment/Position.d.ts +8 -0
  37. package/lib/cjs/augment/Position.js +7 -0
  38. package/lib/cjs/augment/Token.d.ts +8 -0
  39. package/lib/cjs/augment/Token.js +7 -0
  40. package/lib/cjs/augment/User.d.ts +8 -0
  41. package/lib/cjs/augment/User.js +7 -0
  42. package/lib/cjs/augment/Vault.d.ts +8 -0
  43. package/lib/cjs/augment/Vault.js +7 -0
  44. package/lib/cjs/augment/VaultConfig.d.ts +8 -0
  45. package/lib/cjs/augment/VaultConfig.js +7 -0
  46. package/lib/cjs/augment/VaultMarketAllocation.d.ts +8 -0
  47. package/lib/cjs/augment/VaultMarketAllocation.js +7 -0
  48. package/lib/cjs/augment/VaultMarketConfig.d.ts +8 -0
  49. package/lib/cjs/augment/VaultMarketConfig.js +7 -0
  50. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +8 -0
  51. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +8 -0
  52. package/lib/cjs/augment/VaultUser.d.ts +8 -0
  53. package/lib/cjs/augment/VaultUser.js +7 -0
  54. package/lib/cjs/augment.d.ts +14 -0
  55. package/lib/cjs/augment.js +16 -0
  56. package/lib/cjs/bundler/actions.d.ts +555 -0
  57. package/lib/cjs/bundler/actions.js +953 -0
  58. package/lib/cjs/bundler/index.d.ts +2 -0
  59. package/lib/cjs/bundler/index.js +18 -0
  60. package/lib/cjs/bundler/types.d.ts +181 -0
  61. package/lib/cjs/bundler/types.js +2 -0
  62. package/lib/cjs/constants.d.ts +3 -0
  63. package/lib/cjs/constants.js +32 -0
  64. package/lib/cjs/entities/index.d.ts +6 -3
  65. package/lib/cjs/entities/index.js +41 -17
  66. package/lib/cjs/entities/marketV1/marketV1.d.ts +45 -11
  67. package/lib/cjs/entities/marketV1/marketV1.js +27 -12
  68. package/lib/cjs/entities/reallocationData.d.ts +193 -0
  69. package/lib/cjs/entities/reallocationData.js +406 -0
  70. package/lib/cjs/errors.d.ts +2 -0
  71. package/lib/cjs/errors.js +18 -0
  72. package/lib/cjs/fetch.d.ts +1 -0
  73. package/lib/cjs/fetch.js +30 -0
  74. package/lib/cjs/format.d.ts +2 -0
  75. package/lib/cjs/format.js +22 -0
  76. package/lib/cjs/helpers/computeReallocations.d.ts +48 -8
  77. package/lib/cjs/helpers/computeReallocations.js +120 -32
  78. package/lib/cjs/helpers/constant.d.ts +17 -0
  79. package/lib/cjs/helpers/constant.js +30 -1
  80. package/lib/cjs/helpers/index.d.ts +1 -0
  81. package/lib/cjs/helpers/index.js +9 -1
  82. package/lib/cjs/helpers/validate.d.ts +2 -0
  83. package/lib/cjs/helpers/validate.js +14 -2
  84. package/lib/cjs/index.d.ts +0 -1
  85. package/lib/cjs/index.js +0 -1
  86. package/lib/cjs/types/client.d.ts +1 -1
  87. package/lib/cjs/types/error.d.ts +87 -1
  88. package/lib/cjs/types/error.js +119 -1
  89. package/lib/cjs/types/sharedLiquidity.d.ts +43 -3
  90. package/lib/cjs/types.d.ts +3 -0
  91. package/lib/cjs/types.js +17 -0
  92. package/lib/cjs/utils.d.ts +9 -0
  93. package/lib/cjs/utils.js +65 -0
  94. package/lib/esm/abis.d.ts +2816 -0
  95. package/lib/esm/abis.js +1922 -0
  96. package/lib/esm/actions/index.d.ts +3 -0
  97. package/lib/esm/actions/marketV1/borrow.js +2 -5
  98. package/lib/esm/actions/marketV1/buildReallocationActions.d.ts +2 -3
  99. package/lib/esm/actions/marketV1/buildReallocationActions.js +1 -2
  100. package/lib/esm/actions/marketV1/repay.d.ts +2 -0
  101. package/lib/esm/actions/marketV1/repay.js +4 -5
  102. package/lib/esm/actions/marketV1/repayWithdrawCollateral.d.ts +2 -0
  103. package/lib/esm/actions/marketV1/repayWithdrawCollateral.js +4 -5
  104. package/lib/esm/actions/marketV1/supplyCollateral.d.ts +2 -0
  105. package/lib/esm/actions/marketV1/supplyCollateral.js +4 -5
  106. package/lib/esm/actions/marketV1/supplyCollateralBorrow.d.ts +2 -0
  107. package/lib/esm/actions/marketV1/supplyCollateralBorrow.js +4 -5
  108. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +1 -1
  109. package/lib/esm/actions/requirements/getRequirementsAction.d.ts +1 -1
  110. package/lib/esm/actions/requirements/getRequirementsApproval.js +1 -1
  111. package/lib/esm/actions/vaultV1/deposit.d.ts +2 -0
  112. package/lib/esm/actions/vaultV1/deposit.js +3 -4
  113. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +2 -0
  114. package/lib/esm/actions/vaultV1/migrateToV2.js +3 -1
  115. package/lib/esm/actions/vaultV2/deposit.d.ts +2 -0
  116. package/lib/esm/actions/vaultV2/deposit.js +3 -4
  117. package/lib/esm/addresses.d.ts +2 -0
  118. package/lib/esm/addresses.js +1 -0
  119. package/lib/esm/augment/AccrualPosition.d.ts +9 -0
  120. package/lib/esm/augment/AccrualPosition.js +5 -0
  121. package/lib/esm/augment/AccrualVault.d.ts +8 -0
  122. package/lib/esm/augment/AccrualVault.js +4 -0
  123. package/lib/esm/augment/Holding.d.ts +8 -0
  124. package/lib/esm/augment/Holding.js +4 -0
  125. package/lib/esm/augment/Market.d.ts +8 -0
  126. package/lib/esm/augment/Market.js +4 -0
  127. package/lib/esm/augment/MarketParams.d.ts +8 -0
  128. package/lib/esm/augment/MarketParams.js +4 -0
  129. package/lib/esm/augment/Position.d.ts +8 -0
  130. package/lib/esm/augment/Position.js +4 -0
  131. package/lib/esm/augment/Token.d.ts +8 -0
  132. package/lib/esm/augment/Token.js +4 -0
  133. package/lib/esm/augment/User.d.ts +8 -0
  134. package/lib/esm/augment/User.js +4 -0
  135. package/lib/esm/augment/Vault.d.ts +8 -0
  136. package/lib/esm/augment/Vault.js +4 -0
  137. package/lib/esm/augment/VaultConfig.d.ts +8 -0
  138. package/lib/esm/augment/VaultConfig.js +4 -0
  139. package/lib/esm/augment/VaultMarketAllocation.d.ts +8 -0
  140. package/lib/esm/augment/VaultMarketAllocation.js +4 -0
  141. package/lib/esm/augment/VaultMarketConfig.d.ts +8 -0
  142. package/lib/esm/augment/VaultMarketConfig.js +4 -0
  143. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +8 -0
  144. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +5 -0
  145. package/lib/esm/augment/VaultUser.d.ts +8 -0
  146. package/lib/esm/augment/VaultUser.js +4 -0
  147. package/lib/esm/augment.d.ts +14 -0
  148. package/lib/esm/augment.js +14 -0
  149. package/lib/esm/bundler/actions.d.ts +555 -0
  150. package/lib/esm/bundler/actions.js +950 -0
  151. package/lib/esm/bundler/index.d.ts +2 -0
  152. package/lib/esm/bundler/index.js +2 -0
  153. package/lib/esm/bundler/types.d.ts +181 -0
  154. package/lib/esm/bundler/types.js +1 -0
  155. package/lib/esm/constants.d.ts +3 -0
  156. package/lib/esm/constants.js +3 -0
  157. package/lib/esm/entities/index.d.ts +6 -3
  158. package/lib/esm/entities/index.js +5 -3
  159. package/lib/esm/entities/marketV1/marketV1.d.ts +45 -11
  160. package/lib/esm/entities/marketV1/marketV1.js +28 -13
  161. package/lib/esm/entities/reallocationData.d.ts +193 -0
  162. package/lib/esm/entities/reallocationData.js +402 -0
  163. package/lib/esm/errors.d.ts +2 -0
  164. package/lib/esm/errors.js +1 -0
  165. package/lib/esm/fetch.d.ts +1 -0
  166. package/lib/esm/fetch.js +1 -0
  167. package/lib/esm/format.d.ts +2 -0
  168. package/lib/esm/format.js +1 -0
  169. package/lib/esm/helpers/computeReallocations.d.ts +48 -8
  170. package/lib/esm/helpers/computeReallocations.js +119 -31
  171. package/lib/esm/helpers/constant.d.ts +17 -0
  172. package/lib/esm/helpers/constant.js +30 -1
  173. package/lib/esm/helpers/index.d.ts +1 -0
  174. package/lib/esm/helpers/index.js +1 -0
  175. package/lib/esm/helpers/validate.d.ts +2 -0
  176. package/lib/esm/helpers/validate.js +12 -1
  177. package/lib/esm/index.d.ts +0 -1
  178. package/lib/esm/index.js +0 -1
  179. package/lib/esm/types/client.d.ts +1 -1
  180. package/lib/esm/types/error.d.ts +87 -1
  181. package/lib/esm/types/error.js +112 -0
  182. package/lib/esm/types/sharedLiquidity.d.ts +43 -3
  183. package/lib/esm/types.d.ts +3 -0
  184. package/lib/esm/types.js +1 -0
  185. package/lib/esm/utils.d.ts +9 -0
  186. package/lib/esm/utils.js +7 -0
  187. package/package.json +118 -11
  188. package/src/index.ts +0 -1
@@ -0,0 +1,555 @@
1
+ import { type InputMarketParams } from "@morpho-org/blue-sdk";
2
+ import { type Address, type Hex } from "viem";
3
+ import type { Action, InputReallocation, Permit2PermitSingle } from "./types.js";
4
+ /**
5
+ * Encoded low-level call consumed by Bundler3's `multicall`.
6
+ */
7
+ export interface BundlerCall {
8
+ /** Contract or account called by Bundler3. */
9
+ readonly to: Address;
10
+ /** ABI-encoded calldata sent to `to`. */
11
+ readonly data: Hex;
12
+ /** Native-token value sent with the call. */
13
+ readonly value: bigint;
14
+ /** Whether Bundler3 should continue when the call reverts. */
15
+ readonly skipRevert: boolean;
16
+ /** Expected callback hash for calls that reenter Bundler3, or zero hash. */
17
+ readonly callbackHash: Hex;
18
+ }
19
+ /**
20
+ * Encodes the Bundler3 action subset used by `morpho-sdk` transaction builders.
21
+ *
22
+ * @remarks
23
+ * The namespace covers only the Bundler3 actions required by `morpho-sdk`.
24
+ * It does not expose operation population or simulation helpers from
25
+ * `@morpho-org/bundler-sdk-viem`.
26
+ */
27
+ export declare namespace BundlerAction {
28
+ /**
29
+ * Encodes a list of Bundler3 actions into a single Bundler3 multicall
30
+ * transaction request.
31
+ *
32
+ * @remarks
33
+ * This is a low-level encoding helper, not a safe bundle constructor. It
34
+ * does not validate that native-token pre-funding is fully consumed or that
35
+ * pre-funding actions are ordered before the value-carrying calls they fund.
36
+ *
37
+ * When custom actions include `nativeTransfer(externalOwner, bundler3,
38
+ * amount)`, no inner Bundler3 call is emitted for that transfer. Consumers
39
+ * must ensure those pre-funding actions precede their downstream consumers
40
+ * and leave no residual pre-funded native token; otherwise `tx.value` can be
41
+ * over-counted or native token can remain stranded on Bundler3. The
42
+ * high-level `morpho-sdk` action builders construct actions in that order,
43
+ * but this invariant is not checked at runtime by `encodeBundle`.
44
+ *
45
+ * @param chainId - Chain where the bundle will execute.
46
+ * @param actions - Ordered Bundler3 actions to encode.
47
+ * @returns Transaction target, calldata, and native value required by the
48
+ * bundle.
49
+ * @throws {BundlerErrors.MissingSignature} when a signature action is unsigned.
50
+ * @throws {BundlerErrors.UnexpectedAction} when an action is unavailable on the chain.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { getChainAddresses } from "@morpho-org/blue-sdk";
55
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
56
+ *
57
+ * const { generalAdapter1 } = getChainAddresses(1).bundler3;
58
+ * const sender = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
59
+ *
60
+ * const tx = BundlerAction.encodeBundle(1, [
61
+ * {
62
+ * type: "nativeTransfer",
63
+ * args: [sender, generalAdapter1, 1_000000000000000000n],
64
+ * },
65
+ * ]);
66
+ * ```
67
+ */
68
+ function encodeBundle(chainId: number, actions: Action[]): {
69
+ to: `0x${string}`;
70
+ value: bigint;
71
+ data: `0x${string}`;
72
+ };
73
+ /**
74
+ * Encodes a single supported Bundler3 action into one or more low-level
75
+ * Bundler3 calls.
76
+ *
77
+ * @param chainId - Chain where the action will execute.
78
+ * @param action - Bundler3 action to encode.
79
+ * @returns Encoded Bundler3 calls.
80
+ * @throws {BundlerErrors.MissingSignature} when a signature action is unsigned.
81
+ * @throws {BundlerErrors.UnexpectedAction} when the action is unavailable on the chain.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
86
+ *
87
+ * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
88
+ *
89
+ * const calls = BundlerAction.encode(1, {
90
+ * type: "wrapNative",
91
+ * args: [1_000000000000000000n, recipient],
92
+ * });
93
+ * ```
94
+ */
95
+ function encode(chainId: number, action: Action): BundlerCall[];
96
+ /**
97
+ * Encodes a native-token transfer for Bundler3 execution.
98
+ *
99
+ * @remarks
100
+ * Transfers to Bundler3 are treated as bundle pre-funding and emit no inner
101
+ * call. Transfers whose `owner` is GeneralAdapter1 are encoded as
102
+ * `GeneralAdapter1.nativeTransfer(recipient, amount)` and always use
103
+ * `skipRevert: false`; the caller-supplied `skipRevert` argument applies
104
+ * only to direct native transfers from other owners.
105
+ *
106
+ * @param chainId - Chain where the action will execute.
107
+ * @param owner - Current native-token owner in the bundle.
108
+ * @param recipient - Native-token recipient.
109
+ * @param amount - Native-token amount in wei.
110
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
111
+ * @returns Encoded Bundler3 calls.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
116
+ *
117
+ * const sender = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
118
+ * const recipient = "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359";
119
+ *
120
+ * const calls = BundlerAction.nativeTransfer(
121
+ * 1,
122
+ * sender,
123
+ * recipient,
124
+ * 1_000000000000000000n,
125
+ * );
126
+ * ```
127
+ */
128
+ function nativeTransfer(chainId: number, owner: Address, recipient: Address, amount: bigint, skipRevert?: boolean): BundlerCall[];
129
+ /**
130
+ * Encodes an ERC20 transfer from the given adapter.
131
+ *
132
+ * @param asset - ERC20 token to transfer.
133
+ * @param recipient - Recipient of the transferred tokens.
134
+ * @param amount - Token amount to transfer.
135
+ * @param adapter - Adapter that currently holds the tokens.
136
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
137
+ * @returns Encoded Bundler3 calls.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * import { getChainAddresses } from "@morpho-org/blue-sdk";
142
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
143
+ *
144
+ * const adapter = getChainAddresses(1).bundler3.generalAdapter1;
145
+ * const asset = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
146
+ * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
147
+ *
148
+ * const calls = BundlerAction.erc20Transfer(
149
+ * asset,
150
+ * recipient,
151
+ * 100n,
152
+ * adapter,
153
+ * );
154
+ * ```
155
+ */
156
+ function erc20Transfer(asset: Address, recipient: Address, amount: bigint, adapter: Address, skipRevert?: boolean): BundlerCall[];
157
+ /**
158
+ * Encodes a GeneralAdapter1 ERC20 `transferFrom`.
159
+ *
160
+ * @param chainId - Chain where the action will execute.
161
+ * @param asset - ERC20 token to transfer.
162
+ * @param amount - Token amount to transfer.
163
+ * @param recipient - Recipient of the transferred tokens.
164
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
165
+ * @returns Encoded Bundler3 calls.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
170
+ *
171
+ * const asset = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
172
+ * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
173
+ *
174
+ * const calls = BundlerAction.erc20TransferFrom(
175
+ * 1,
176
+ * asset,
177
+ * 100n,
178
+ * recipient,
179
+ * );
180
+ * ```
181
+ */
182
+ function erc20TransferFrom(chainId: number, asset: Address, amount: bigint, recipient: Address, skipRevert?: boolean): BundlerCall[];
183
+ /**
184
+ * Encodes an ERC20 permit for GeneralAdapter1 spending.
185
+ *
186
+ * @param chainId - Chain where the action will execute.
187
+ * @param owner - Token owner signing the permit.
188
+ * @param asset - ERC20 token being permitted.
189
+ * @param amount - Allowance amount.
190
+ * @param deadline - Permit deadline timestamp.
191
+ * @param signature - Owner signature.
192
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
193
+ * @returns Encoded Bundler3 calls.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
198
+ *
199
+ * const owner = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
200
+ * const asset = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
201
+ * const signature =
202
+ * "0x111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222221b";
203
+ *
204
+ * const calls = BundlerAction.permit(
205
+ * 1,
206
+ * owner,
207
+ * asset,
208
+ * 100n,
209
+ * 1_900_000_000n,
210
+ * signature,
211
+ * );
212
+ * ```
213
+ */
214
+ function permit(chainId: number, owner: Address, asset: Address, amount: bigint, deadline: bigint, signature: Hex, skipRevert?: boolean): BundlerCall[];
215
+ /**
216
+ * Encodes a Permit2 approval for GeneralAdapter1 spending.
217
+ *
218
+ * @param chainId - Chain where the action will execute.
219
+ * @param owner - Token owner signing the Permit2 payload.
220
+ * @param permitSingle - Permit2 allowance payload.
221
+ * @param signature - Owner signature.
222
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
223
+ * @returns Encoded Bundler3 calls.
224
+ * @throws {BundlerErrors.UnexpectedAction} when Permit2 is unavailable on the chain.
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
229
+ *
230
+ * const owner = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
231
+ * const token = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
232
+ * const signature =
233
+ * "0x111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222221b";
234
+ *
235
+ * const calls = BundlerAction.approve2(
236
+ * 1,
237
+ * owner,
238
+ * {
239
+ * details: {
240
+ * token,
241
+ * amount: 100n,
242
+ * expiration: 1_900_000_000,
243
+ * nonce: 0,
244
+ * },
245
+ * sigDeadline: 1_900_000_000n,
246
+ * },
247
+ * signature,
248
+ * );
249
+ * ```
250
+ */
251
+ function approve2(chainId: number, owner: Address, permitSingle: Permit2PermitSingle, signature: Hex, skipRevert?: boolean): BundlerCall[];
252
+ /**
253
+ * Encodes a GeneralAdapter1 Permit2 transfer.
254
+ *
255
+ * @param chainId - Chain where the action will execute.
256
+ * @param asset - ERC20 token to transfer through Permit2.
257
+ * @param amount - Token amount to transfer.
258
+ * @param recipient - Recipient of the transferred tokens.
259
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
260
+ * @returns Encoded Bundler3 calls.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
265
+ *
266
+ * const asset = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
267
+ * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
268
+ *
269
+ * const calls = BundlerAction.transferFrom2(
270
+ * 1,
271
+ * asset,
272
+ * 100n,
273
+ * recipient,
274
+ * );
275
+ * ```
276
+ */
277
+ function transferFrom2(chainId: number, asset: Address, amount: bigint, recipient: Address, skipRevert?: boolean): BundlerCall[];
278
+ /**
279
+ * Encodes a GeneralAdapter1 ERC4626 deposit.
280
+ *
281
+ * @param chainId - Chain where the action will execute.
282
+ * @param erc4626 - ERC4626 vault address.
283
+ * @param assets - Asset amount to deposit.
284
+ * @param maxSharePrice - Maximum accepted share price in RAY.
285
+ * @param receiver - Recipient of minted vault shares.
286
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
287
+ * @returns Encoded Bundler3 calls.
288
+ *
289
+ * @example
290
+ * ```ts
291
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
292
+ *
293
+ * const vault = "0x186514400e52270cef3D80e1c6F8d10A75d47344";
294
+ * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
295
+ *
296
+ * const calls = BundlerAction.erc4626Deposit(
297
+ * 1,
298
+ * vault,
299
+ * 100n,
300
+ * 1_000000000000000000000000000n,
301
+ * recipient,
302
+ * );
303
+ * ```
304
+ */
305
+ function erc4626Deposit(chainId: number, erc4626: Address, assets: bigint, maxSharePrice: bigint, receiver: Address, skipRevert?: boolean): BundlerCall[];
306
+ /**
307
+ * Encodes a GeneralAdapter1 ERC4626 redeem.
308
+ *
309
+ * @param chainId - Chain where the action will execute.
310
+ * @param erc4626 - ERC4626 vault address.
311
+ * @param shares - Share amount to redeem.
312
+ * @param minSharePrice - Minimum accepted share price in RAY.
313
+ * @param receiver - Recipient of redeemed assets.
314
+ * @param owner - Owner of the shares being redeemed.
315
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
316
+ * @returns Encoded Bundler3 calls.
317
+ *
318
+ * @example
319
+ * ```ts
320
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
321
+ *
322
+ * const vault = "0x186514400e52270cef3D80e1c6F8d10A75d47344";
323
+ * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
324
+ * const owner = recipient;
325
+ *
326
+ * const calls = BundlerAction.erc4626Redeem(
327
+ * 1,
328
+ * vault,
329
+ * 100n,
330
+ * 900000000000000000000000000n,
331
+ * recipient,
332
+ * owner,
333
+ * );
334
+ * ```
335
+ */
336
+ function erc4626Redeem(chainId: number, erc4626: Address, shares: bigint, minSharePrice: bigint, receiver: Address, owner: Address, skipRevert?: boolean): BundlerCall[];
337
+ /**
338
+ * Encodes a GeneralAdapter1 Morpho Blue supply-collateral call.
339
+ *
340
+ * @param chainId - Chain where the action will execute.
341
+ * @param market - Morpho Blue market parameters.
342
+ * @param assets - Collateral asset amount to supply.
343
+ * @param onBehalf - Account receiving the collateral position.
344
+ * @param callbackCalls - Calls executed in Morpho's callback.
345
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
346
+ * @returns Encoded Bundler3 calls.
347
+ *
348
+ * @example
349
+ * ```ts
350
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
351
+ *
352
+ * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
353
+ * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
354
+ * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419";
355
+ * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
356
+ * const onBehalf = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
357
+ * const marketParams = {
358
+ * loanToken,
359
+ * collateralToken,
360
+ * oracle,
361
+ * irm,
362
+ * lltv: 860_000000000000000000n,
363
+ * };
364
+ *
365
+ * const calls = BundlerAction.morphoSupplyCollateral(
366
+ * 1,
367
+ * marketParams,
368
+ * 100n,
369
+ * onBehalf,
370
+ * [],
371
+ * );
372
+ * ```
373
+ */
374
+ function morphoSupplyCollateral(chainId: number, market: InputMarketParams, assets: bigint, onBehalf: Address, callbackCalls: BundlerCall[], skipRevert?: boolean): BundlerCall[];
375
+ /**
376
+ * Encodes a GeneralAdapter1 Morpho Blue borrow call.
377
+ *
378
+ * @param chainId - Chain where the action will execute.
379
+ * @param market - Morpho Blue market parameters.
380
+ * @param assets - Borrow asset amount.
381
+ * @param shares - Borrow share amount.
382
+ * @param slippageAmount - Slippage guard amount.
383
+ * @param receiver - Recipient of borrowed assets.
384
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
385
+ * @returns Encoded Bundler3 calls.
386
+ *
387
+ * @example
388
+ * ```ts
389
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
390
+ *
391
+ * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
392
+ * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
393
+ * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419";
394
+ * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
395
+ * const receiver = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
396
+ * const marketParams = {
397
+ * loanToken,
398
+ * collateralToken,
399
+ * oracle,
400
+ * irm,
401
+ * lltv: 860_000000000000000000n,
402
+ * };
403
+ *
404
+ * const calls = BundlerAction.morphoBorrow(
405
+ * 1,
406
+ * marketParams,
407
+ * 100n,
408
+ * 0n,
409
+ * 1_000000000000000000000000000n,
410
+ * receiver,
411
+ * );
412
+ * ```
413
+ */
414
+ function morphoBorrow(chainId: number, market: InputMarketParams, assets: bigint, shares: bigint, slippageAmount: bigint, receiver: Address, skipRevert?: boolean): BundlerCall[];
415
+ /**
416
+ * Encodes a GeneralAdapter1 Morpho Blue repay call.
417
+ *
418
+ * @param chainId - Chain where the action will execute.
419
+ * @param market - Morpho Blue market parameters.
420
+ * @param assets - Repay asset amount.
421
+ * @param shares - Repay share amount.
422
+ * @param slippageAmount - Slippage guard amount.
423
+ * @param onBehalf - Account whose borrow is repaid.
424
+ * @param callbackCalls - Calls executed in Morpho's callback.
425
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
426
+ * @returns Encoded Bundler3 calls.
427
+ *
428
+ * @example
429
+ * ```ts
430
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
431
+ *
432
+ * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
433
+ * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
434
+ * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419";
435
+ * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
436
+ * const onBehalf = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
437
+ * const marketParams = {
438
+ * loanToken,
439
+ * collateralToken,
440
+ * oracle,
441
+ * irm,
442
+ * lltv: 860_000000000000000000n,
443
+ * };
444
+ *
445
+ * const calls = BundlerAction.morphoRepay(
446
+ * 1,
447
+ * marketParams,
448
+ * 100n,
449
+ * 0n,
450
+ * 1_000000000000000000000000000n,
451
+ * onBehalf,
452
+ * [],
453
+ * );
454
+ * ```
455
+ */
456
+ function morphoRepay(chainId: number, market: InputMarketParams, assets: bigint, shares: bigint, slippageAmount: bigint, onBehalf: Address, callbackCalls: BundlerCall[], skipRevert?: boolean): BundlerCall[];
457
+ /**
458
+ * Encodes a GeneralAdapter1 Morpho Blue withdraw-collateral call.
459
+ *
460
+ * @param chainId - Chain where the action will execute.
461
+ * @param market - Morpho Blue market parameters.
462
+ * @param assets - Collateral asset amount to withdraw.
463
+ * @param receiver - Recipient of withdrawn collateral.
464
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
465
+ * @returns Encoded Bundler3 calls.
466
+ *
467
+ * @example
468
+ * ```ts
469
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
470
+ *
471
+ * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
472
+ * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
473
+ * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419";
474
+ * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
475
+ * const receiver = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
476
+ * const marketParams = {
477
+ * loanToken,
478
+ * collateralToken,
479
+ * oracle,
480
+ * irm,
481
+ * lltv: 860_000000000000000000n,
482
+ * };
483
+ *
484
+ * const calls = BundlerAction.morphoWithdrawCollateral(
485
+ * 1,
486
+ * marketParams,
487
+ * 100n,
488
+ * receiver,
489
+ * );
490
+ * ```
491
+ */
492
+ function morphoWithdrawCollateral(chainId: number, market: InputMarketParams, assets: bigint, receiver: Address, skipRevert?: boolean): BundlerCall[];
493
+ /**
494
+ * Encodes a PublicAllocator reallocation call.
495
+ *
496
+ * @param chainId - Chain where the action will execute.
497
+ * @param vault - Vault to reallocate.
498
+ * @param fee - Public allocator fee.
499
+ * @param withdrawals - Market withdrawals performed before supply.
500
+ * @param supplyMarketParams - Target supply market parameters.
501
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
502
+ * @returns Encoded Bundler3 calls.
503
+ * @throws {BundlerErrors.UnexpectedAction} when the PublicAllocator is unavailable on the chain.
504
+ *
505
+ * @example
506
+ * ```ts
507
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
508
+ *
509
+ * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
510
+ * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
511
+ * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419";
512
+ * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
513
+ * const vault = "0x186514400e52270cef3D80e1c6F8d10A75d47344";
514
+ * const marketParams = {
515
+ * loanToken,
516
+ * collateralToken,
517
+ * oracle,
518
+ * irm,
519
+ * lltv: 860_000000000000000000n,
520
+ * };
521
+ *
522
+ * const calls = BundlerAction.publicAllocatorReallocateTo(
523
+ * 1,
524
+ * vault,
525
+ * 0n,
526
+ * [{ marketParams, amount: 100n }],
527
+ * marketParams,
528
+ * );
529
+ * ```
530
+ */
531
+ function publicAllocatorReallocateTo(chainId: number, vault: Address, fee: bigint, withdrawals: InputReallocation[], supplyMarketParams: InputMarketParams, skipRevert?: boolean): BundlerCall[];
532
+ /**
533
+ * Encodes a GeneralAdapter1 native-token wrap call.
534
+ *
535
+ * @param chainId - Chain where the action will execute.
536
+ * @param amount - Native-token amount to wrap.
537
+ * @param recipient - Recipient of wrapped native tokens.
538
+ * @param skipRevert - Whether Bundler3 should tolerate a revert.
539
+ * @returns Encoded Bundler3 calls.
540
+ *
541
+ * @example
542
+ * ```ts
543
+ * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler";
544
+ *
545
+ * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
546
+ *
547
+ * const calls = BundlerAction.wrapNative(
548
+ * 1,
549
+ * 1_000000000000000000n,
550
+ * recipient,
551
+ * );
552
+ * ```
553
+ */
554
+ function wrapNative(chainId: number, amount: bigint, recipient: Address, skipRevert?: boolean): BundlerCall[];
555
+ }