@continuumdao/ctm-mpc-defi 0.1.4 → 0.2.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 (55) hide show
  1. package/dist/agent/catalog.cjs +878 -141
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.cts +756 -12
  4. package/dist/agent/catalog.d.ts +756 -12
  5. package/dist/agent/catalog.js +829 -142
  6. package/dist/agent/catalog.js.map +1 -1
  7. package/dist/chains/evm/index.cjs +13 -0
  8. package/dist/chains/evm/index.cjs.map +1 -1
  9. package/dist/chains/evm/index.d.cts +3 -1
  10. package/dist/chains/evm/index.d.ts +3 -1
  11. package/dist/chains/evm/index.js +13 -1
  12. package/dist/chains/evm/index.js.map +1 -1
  13. package/dist/index.cjs +825 -141
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +2 -1
  16. package/dist/index.d.ts +2 -1
  17. package/dist/index.js +825 -142
  18. package/dist/index.js.map +1 -1
  19. package/dist/protocols/evm/aave-v4/index.cjs +1987 -0
  20. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -0
  21. package/dist/protocols/evm/aave-v4/index.d.cts +500 -0
  22. package/dist/protocols/evm/aave-v4/index.d.ts +500 -0
  23. package/dist/protocols/evm/aave-v4/index.js +1943 -0
  24. package/dist/protocols/evm/aave-v4/index.js.map +1 -0
  25. package/dist/protocols/evm/ethena/index.cjs +965 -0
  26. package/dist/protocols/evm/ethena/index.cjs.map +1 -0
  27. package/dist/protocols/evm/ethena/index.d.cts +161 -0
  28. package/dist/protocols/evm/ethena/index.d.ts +161 -0
  29. package/dist/protocols/evm/ethena/index.js +943 -0
  30. package/dist/protocols/evm/ethena/index.js.map +1 -0
  31. package/dist/protocols/evm/euler-v2/index.cjs +2263 -0
  32. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -0
  33. package/dist/protocols/evm/euler-v2/index.d.cts +317 -0
  34. package/dist/protocols/evm/euler-v2/index.d.ts +317 -0
  35. package/dist/protocols/evm/euler-v2/index.js +2238 -0
  36. package/dist/protocols/evm/euler-v2/index.js.map +1 -0
  37. package/dist/protocols/evm/lido/index.cjs +834 -0
  38. package/dist/protocols/evm/lido/index.cjs.map +1 -0
  39. package/dist/protocols/evm/lido/index.d.cts +120 -0
  40. package/dist/protocols/evm/lido/index.d.ts +120 -0
  41. package/dist/protocols/evm/lido/index.js +809 -0
  42. package/dist/protocols/evm/lido/index.js.map +1 -0
  43. package/dist/protocols/evm/maple/index.cjs +707 -0
  44. package/dist/protocols/evm/maple/index.cjs.map +1 -0
  45. package/dist/protocols/evm/maple/index.d.cts +109 -0
  46. package/dist/protocols/evm/maple/index.d.ts +109 -0
  47. package/dist/protocols/evm/maple/index.js +693 -0
  48. package/dist/protocols/evm/maple/index.js.map +1 -0
  49. package/dist/protocols/evm/sky/index.cjs +1254 -0
  50. package/dist/protocols/evm/sky/index.cjs.map +1 -0
  51. package/dist/protocols/evm/sky/index.d.cts +218 -0
  52. package/dist/protocols/evm/sky/index.d.ts +218 -0
  53. package/dist/protocols/evm/sky/index.js +1229 -0
  54. package/dist/protocols/evm/sky/index.js.map +1 -0
  55. package/package.json +37 -3
@@ -0,0 +1,317 @@
1
+ import { d as ProtocolModule } from '../../../types-Ce2qNHai.cjs';
2
+ import { Address } from 'viem';
3
+ import { K as KeyGenSubsetForPermit } from '../../../keygen-CfNp8yKJ.cjs';
4
+
5
+ /** Stay below on-chain max borrow LTV when computing per-round headroom (basis points). */
6
+ declare const EULER_SAME_ASSET_BORROW_PROTOCOL_HEADROOM_BPS = 50n;
7
+ /** Extra allowance on total collateral deposits: `total * (1 + bps/10000)` plus one wei. */
8
+ declare const EULER_SAME_ASSET_BORROW_APPROVAL_BUFFER_BPS = 100n;
9
+ declare const EULER_SAME_ASSET_BORROW_MAX_ROUNDS = 48;
10
+ /** Stop iterating when current LTV is within this many bps of target (0.15%). */
11
+ declare const EULER_SAME_ASSET_BORROW_RATIO_STOP_EPS_BPS = 15n;
12
+ declare function eulerBorrowAndCollateralSameAsset(row: {
13
+ collateralAssetAddressLower?: string | null | undefined;
14
+ borrowAssetAddressLower?: string | null | undefined;
15
+ }): boolean;
16
+ /**
17
+ * Plan iterative borrow → re-deposit rounds so final debt/collateral (UoA) approaches `targetLtvBps`,
18
+ * without exceeding a capped max LTV (vault max minus protocol headroom). Same borrow/collateral asset only.
19
+ */
20
+ declare function planSameAssetLeveragedBorrows(args: {
21
+ initialCollateralWei: bigint;
22
+ oneBorrowUnitUoAWei: bigint;
23
+ borrowDecimals: number;
24
+ targetLtvBps: number;
25
+ maxLtvBps: number;
26
+ maxNewBorrowWei: bigint;
27
+ }): {
28
+ borrowWeis: readonly bigint[];
29
+ totalBorrowWei: bigint;
30
+ projectedFinalLtvBps: bigint;
31
+ } | null;
32
+ /** Total ERC-20 allowance target for collateral vault: deposits plus buffer. */
33
+ declare function eulerSameAssetTotalCollateralPullWei(args: {
34
+ initialCollateralWei: bigint;
35
+ loopBorrowWeis: readonly bigint[];
36
+ }): bigint;
37
+ declare function eulerSameAssetApproveAmountWithBuffer(args: {
38
+ totalPullWei: bigint;
39
+ }): bigint;
40
+
41
+ /**
42
+ * Maximum collateral underlying (asset wei) safely withdrawable for a borrow position’s collateral eVault,
43
+ * matching how the app submits `EVC.batch` → `withdraw(assets, receiver, owner=subAccount)`.
44
+ *
45
+ * Prefer ERC-4626 `maxWithdraw` when non-zero (no controller shortcut). Otherwise simulate via RPC.
46
+ */
47
+ declare function fetchEulerBorrowCollateralMaxWithdrawAssetsWei(args: {
48
+ rpcUrl: string;
49
+ chainId: number;
50
+ evc: Address;
51
+ collateralVault: Address;
52
+ subAccount: Address;
53
+ /** Address that submits the multisign tx (must match multisign executor / receiver). */
54
+ caller: Address;
55
+ }): Promise<bigint>;
56
+
57
+ declare const EULER_V2_VAULT_WITHDRAW_FALLBACK_GAS = 900000n;
58
+ type ChainRow$5 = {
59
+ legacy?: boolean;
60
+ gasLimit?: number;
61
+ gasMultiplier?: number;
62
+ gasPrice?: number;
63
+ baseFee?: number;
64
+ priorityFee?: number;
65
+ baseFeeMultiplier?: number;
66
+ };
67
+ declare function fetchEulerVaultUnderlyingMeta(args: {
68
+ rpcUrl: string;
69
+ chainId: number;
70
+ evault: Address;
71
+ }): Promise<{
72
+ asset: Address;
73
+ decimals: number;
74
+ }>;
75
+ /**
76
+ * Some RPCs/indexers report too-low underlying `decimals` (~15) for WETH-class assets, inflating formatted amounts ~1000×.
77
+ * Prefer wrapped-gas alias match, then Euler ETH-style vault labels, then raw chain `decimals`.
78
+ */
79
+ declare function clampEulerUnderlyingDecimalsForEulerUi(args: {
80
+ fetchedDecimals: number;
81
+ underlyingAssetLower: string;
82
+ marketName: string;
83
+ underlyingSymbol: string;
84
+ wrappedGasAliasesLower: ReadonlySet<string>;
85
+ }): number;
86
+ declare function fetchEulerVaultAssetDecimals(args: {
87
+ rpcUrl: string;
88
+ chainId: number;
89
+ evault: Address;
90
+ }): Promise<number>;
91
+ /** Max underlying assets redeemable via `withdraw` for `owner` (ERC-4626 `maxWithdraw`). */
92
+ declare function fetchEulerVaultMaxWithdrawWei(args: {
93
+ rpcUrl: string;
94
+ chainId: number;
95
+ evault: Address;
96
+ owner: Address;
97
+ }): Promise<bigint>;
98
+ /** Use for LEND/EARN redeem UX + validation: merges ERC-4626 `maxWithdraw` with withdraw simulation when it is pessimistically zero. */
99
+ declare function fetchEulerLendEarnVaultEffectiveMaxWithdrawWei(args: {
100
+ rpcUrl: string;
101
+ chainId: number;
102
+ evault: Address;
103
+ vaultShareOwner: Address;
104
+ /** Must match multisign redeem `receiver` and `executor` (key Ethereum address). */
105
+ txSender: Address;
106
+ }): Promise<bigint>;
107
+ /**
108
+ * Single ERC-4626 `withdraw(assets, receiver, owner)` on an Euler isolated eVault — no unwrap batch.
109
+ */
110
+ declare function buildEvmMultisignBodyEulerV2VaultWithdraw(args: {
111
+ keyGen: KeyGenSubsetForPermit;
112
+ chainId: number;
113
+ rpcUrl: string;
114
+ chainDetail: ChainRow$5;
115
+ useCustomGas: boolean;
116
+ customGasChainDetails?: Record<string, unknown> | null;
117
+ evault: Address;
118
+ /** Underlying asset amount (human decimal string); capped by `fetchEulerLendEarnVaultEffectiveMaxWithdrawWei`. */
119
+ amountHuman: string;
120
+ /** Receiver of underlying (usually the key address). */
121
+ owner: Address;
122
+ /** Address whose eVault shares are redeemed (ERC-4626 `owner`); defaults to `owner` when omitted. */
123
+ vaultShareOwner?: Address;
124
+ executorAddress: Address;
125
+ purposeText: string;
126
+ vaultMarketLabel: string;
127
+ }): Promise<{
128
+ bodyForSign: Record<string, unknown>;
129
+ messageToSign: string;
130
+ }>;
131
+
132
+ /** Conservative fallback when `estimateGas` fails on Euler eVault `deposit`. */
133
+ declare const EULER_V2_ISOLATED_VAULT_DEPOSIT_FALLBACK_GAS = 950000n;
134
+ type ChainRow$4 = {
135
+ legacy?: boolean;
136
+ gasLimit?: number;
137
+ gasMultiplier?: number;
138
+ gasPrice?: number;
139
+ baseFee?: number;
140
+ priorityFee?: number;
141
+ baseFeeMultiplier?: number;
142
+ };
143
+ /**
144
+ * Euler v2 isolated lending: wrap native → WETH when needed, `approve(eVault, amount)` if required,
145
+ * then `eVault.deposit(assets, receiver)` (ERC-4626).
146
+ */
147
+ declare function buildEvmMultisignBodyEulerV2IsolatedLendDepositBatch(args: {
148
+ keyGen: KeyGenSubsetForPermit;
149
+ chainId: number;
150
+ rpcUrl: string;
151
+ chainDetail: ChainRow$4;
152
+ useCustomGas: boolean;
153
+ customGasChainDetails?: Record<string, unknown> | null;
154
+ /** Euler eVault (checksummed). */
155
+ evault: Address;
156
+ /** Underlying ERC-20 passed to `deposit` (WETH when user chose native gas token row). */
157
+ underlying: Address;
158
+ isNativeIn: boolean;
159
+ nativeWrapped: Address;
160
+ amountHuman: string;
161
+ receiver: Address;
162
+ executorAddress: Address;
163
+ purposeText: string;
164
+ vaultMarketLabel: string;
165
+ }): Promise<{
166
+ bodyForSign: Record<string, unknown>;
167
+ messageToSign: string;
168
+ }>;
169
+
170
+ type ChainRow$3 = {
171
+ legacy?: boolean;
172
+ gasLimit?: number;
173
+ gasMultiplier?: number;
174
+ gasPrice?: number;
175
+ baseFee?: number;
176
+ priorityFee?: number;
177
+ baseFeeMultiplier?: number;
178
+ };
179
+ /**
180
+ * Collateral deposit + enable collateral + enable borrow controller + borrow, batched on EVC (after wrap/approve).
181
+ * When {@link args.redepositBorrowedToCollateral} is true (borrow asset === collateral asset), each borrow is followed
182
+ * by a collateral deposit of the same size inside the same EVC batch (leverage loop).
183
+ */
184
+ declare function buildEvmMultisignBodyEulerV2IsolatedBorrowBatch(args: {
185
+ keyGen: KeyGenSubsetForPermit;
186
+ chainId: number;
187
+ rpcUrl: string;
188
+ chainDetail: ChainRow$3;
189
+ useCustomGas: boolean;
190
+ customGasChainDetails?: Record<string, unknown> | null;
191
+ evc: Address;
192
+ borrowVault: Address;
193
+ collateralVault: Address;
194
+ collateralUnderlying: Address;
195
+ borrowUnderlying: Address;
196
+ isNativeCollateralIn: boolean;
197
+ nativeWrapped: Address;
198
+ collateralAmountHuman: string;
199
+ borrowAmountHuman: string;
200
+ /** Each round: `borrow(amount)` then optional `deposit(amount)` when redepositing. */
201
+ loopBorrowWeis: readonly bigint[];
202
+ redepositBorrowedToCollateral: boolean;
203
+ receiver: Address;
204
+ executorAddress: Address;
205
+ purposeText: string;
206
+ vaultMarketLabel: string;
207
+ }): Promise<{
208
+ bodyForSign: Record<string, unknown>;
209
+ messageToSign: string;
210
+ }>;
211
+
212
+ type ChainRow$2 = {
213
+ legacy?: boolean;
214
+ gasLimit?: number;
215
+ gasMultiplier?: number;
216
+ gasPrice?: number;
217
+ baseFee?: number;
218
+ priorityFee?: number;
219
+ baseFeeMultiplier?: number;
220
+ };
221
+ /**
222
+ * ERC-20 approve (if needed) + EVC batch with liability vault `repay` for `subAccount`’s debt.
223
+ */
224
+ declare function buildEvmMultisignBodyEulerV2BorrowRepayBatch(args: {
225
+ keyGen: KeyGenSubsetForPermit;
226
+ chainId: number;
227
+ rpcUrl: string;
228
+ chainDetail: ChainRow$2;
229
+ useCustomGas: boolean;
230
+ customGasChainDetails?: Record<string, unknown> | null;
231
+ evc: Address;
232
+ borrowVault: Address;
233
+ borrowUnderlying: Address;
234
+ subAccount: Address;
235
+ /** Human decimal string; full repay when `repayAll` or amount ≥ on-chain debt. */
236
+ amountHuman: string;
237
+ /** When true, encodes `repay(type(uint256).max, receiver)`. */
238
+ repayAll: boolean;
239
+ executorAddress: Address;
240
+ purposeText: string;
241
+ vaultMarketLabel: string;
242
+ }): Promise<{
243
+ bodyForSign: Record<string, unknown>;
244
+ messageToSign: string;
245
+ }>;
246
+
247
+ type ChainRow$1 = {
248
+ legacy?: boolean;
249
+ gasLimit?: number;
250
+ gasMultiplier?: number;
251
+ gasPrice?: number;
252
+ baseFee?: number;
253
+ priorityFee?: number;
254
+ baseFeeMultiplier?: number;
255
+ };
256
+ /**
257
+ * ERC-20 approve (if needed) + EVC batch: collateral eVault `deposit(assets, receiver=subAccount)` on behalf of the sub-account.
258
+ * Uses the key EOA as token source (`executor` approves the collateral vault).
259
+ */
260
+ declare function buildEvmMultisignBodyEulerV2BorrowCollateralDepositBatch(args: {
261
+ keyGen: KeyGenSubsetForPermit;
262
+ chainId: number;
263
+ rpcUrl: string;
264
+ chainDetail: ChainRow$1;
265
+ useCustomGas: boolean;
266
+ customGasChainDetails?: Record<string, unknown> | null;
267
+ evc: Address;
268
+ collateralVault: Address;
269
+ collateralUnderlying: Address;
270
+ subAccount: Address;
271
+ amountHuman: string;
272
+ executorAddress: Address;
273
+ purposeText: string;
274
+ vaultMarketLabel: string;
275
+ }): Promise<{
276
+ bodyForSign: Record<string, unknown>;
277
+ messageToSign: string;
278
+ }>;
279
+
280
+ type ChainRow = {
281
+ legacy?: boolean;
282
+ gasLimit?: number;
283
+ gasMultiplier?: number;
284
+ gasPrice?: number;
285
+ baseFee?: number;
286
+ priorityFee?: number;
287
+ baseFeeMultiplier?: number;
288
+ };
289
+ /**
290
+ * EVC batch: collateral eVault `withdraw(assets, receiver, owner=subAccount)` on behalf of the sub-account.
291
+ * Amount is capped by `fetchEulerBorrowCollateralMaxWithdrawAssetsWei` (ERC-4626 `maxWithdraw` is 0 while EVC controls the account).
292
+ */
293
+ declare function buildEvmMultisignBodyEulerV2BorrowCollateralWithdrawBatch(args: {
294
+ keyGen: KeyGenSubsetForPermit;
295
+ chainId: number;
296
+ rpcUrl: string;
297
+ chainDetail: ChainRow;
298
+ useCustomGas: boolean;
299
+ customGasChainDetails?: Record<string, unknown> | null;
300
+ evc: Address;
301
+ collateralVault: Address;
302
+ subAccount: Address;
303
+ /** Receives underlying collateral tokens (typically the key EOA). */
304
+ receiver: Address;
305
+ amountHuman: string;
306
+ executorAddress: Address;
307
+ purposeText: string;
308
+ vaultMarketLabel: string;
309
+ }): Promise<{
310
+ bodyForSign: Record<string, unknown>;
311
+ messageToSign: string;
312
+ }>;
313
+
314
+ declare const EULER_V2_PROTOCOL_ID = "euler-v2";
315
+ declare const eulerV2ProtocolModule: ProtocolModule;
316
+
317
+ export { EULER_SAME_ASSET_BORROW_APPROVAL_BUFFER_BPS, EULER_SAME_ASSET_BORROW_MAX_ROUNDS, EULER_SAME_ASSET_BORROW_PROTOCOL_HEADROOM_BPS, EULER_SAME_ASSET_BORROW_RATIO_STOP_EPS_BPS, EULER_V2_ISOLATED_VAULT_DEPOSIT_FALLBACK_GAS, EULER_V2_PROTOCOL_ID, EULER_V2_VAULT_WITHDRAW_FALLBACK_GAS, buildEvmMultisignBodyEulerV2BorrowCollateralDepositBatch, buildEvmMultisignBodyEulerV2BorrowCollateralWithdrawBatch, buildEvmMultisignBodyEulerV2BorrowRepayBatch, buildEvmMultisignBodyEulerV2IsolatedBorrowBatch, buildEvmMultisignBodyEulerV2IsolatedLendDepositBatch, buildEvmMultisignBodyEulerV2VaultWithdraw, clampEulerUnderlyingDecimalsForEulerUi, eulerBorrowAndCollateralSameAsset, eulerSameAssetApproveAmountWithBuffer, eulerSameAssetTotalCollateralPullWei, eulerV2ProtocolModule, fetchEulerBorrowCollateralMaxWithdrawAssetsWei, fetchEulerLendEarnVaultEffectiveMaxWithdrawWei, fetchEulerVaultAssetDecimals, fetchEulerVaultMaxWithdrawWei, fetchEulerVaultUnderlyingMeta, planSameAssetLeveragedBorrows };
@@ -0,0 +1,317 @@
1
+ import { d as ProtocolModule } from '../../../types-Ce2qNHai.js';
2
+ import { Address } from 'viem';
3
+ import { K as KeyGenSubsetForPermit } from '../../../keygen-DsINazx8.js';
4
+
5
+ /** Stay below on-chain max borrow LTV when computing per-round headroom (basis points). */
6
+ declare const EULER_SAME_ASSET_BORROW_PROTOCOL_HEADROOM_BPS = 50n;
7
+ /** Extra allowance on total collateral deposits: `total * (1 + bps/10000)` plus one wei. */
8
+ declare const EULER_SAME_ASSET_BORROW_APPROVAL_BUFFER_BPS = 100n;
9
+ declare const EULER_SAME_ASSET_BORROW_MAX_ROUNDS = 48;
10
+ /** Stop iterating when current LTV is within this many bps of target (0.15%). */
11
+ declare const EULER_SAME_ASSET_BORROW_RATIO_STOP_EPS_BPS = 15n;
12
+ declare function eulerBorrowAndCollateralSameAsset(row: {
13
+ collateralAssetAddressLower?: string | null | undefined;
14
+ borrowAssetAddressLower?: string | null | undefined;
15
+ }): boolean;
16
+ /**
17
+ * Plan iterative borrow → re-deposit rounds so final debt/collateral (UoA) approaches `targetLtvBps`,
18
+ * without exceeding a capped max LTV (vault max minus protocol headroom). Same borrow/collateral asset only.
19
+ */
20
+ declare function planSameAssetLeveragedBorrows(args: {
21
+ initialCollateralWei: bigint;
22
+ oneBorrowUnitUoAWei: bigint;
23
+ borrowDecimals: number;
24
+ targetLtvBps: number;
25
+ maxLtvBps: number;
26
+ maxNewBorrowWei: bigint;
27
+ }): {
28
+ borrowWeis: readonly bigint[];
29
+ totalBorrowWei: bigint;
30
+ projectedFinalLtvBps: bigint;
31
+ } | null;
32
+ /** Total ERC-20 allowance target for collateral vault: deposits plus buffer. */
33
+ declare function eulerSameAssetTotalCollateralPullWei(args: {
34
+ initialCollateralWei: bigint;
35
+ loopBorrowWeis: readonly bigint[];
36
+ }): bigint;
37
+ declare function eulerSameAssetApproveAmountWithBuffer(args: {
38
+ totalPullWei: bigint;
39
+ }): bigint;
40
+
41
+ /**
42
+ * Maximum collateral underlying (asset wei) safely withdrawable for a borrow position’s collateral eVault,
43
+ * matching how the app submits `EVC.batch` → `withdraw(assets, receiver, owner=subAccount)`.
44
+ *
45
+ * Prefer ERC-4626 `maxWithdraw` when non-zero (no controller shortcut). Otherwise simulate via RPC.
46
+ */
47
+ declare function fetchEulerBorrowCollateralMaxWithdrawAssetsWei(args: {
48
+ rpcUrl: string;
49
+ chainId: number;
50
+ evc: Address;
51
+ collateralVault: Address;
52
+ subAccount: Address;
53
+ /** Address that submits the multisign tx (must match multisign executor / receiver). */
54
+ caller: Address;
55
+ }): Promise<bigint>;
56
+
57
+ declare const EULER_V2_VAULT_WITHDRAW_FALLBACK_GAS = 900000n;
58
+ type ChainRow$5 = {
59
+ legacy?: boolean;
60
+ gasLimit?: number;
61
+ gasMultiplier?: number;
62
+ gasPrice?: number;
63
+ baseFee?: number;
64
+ priorityFee?: number;
65
+ baseFeeMultiplier?: number;
66
+ };
67
+ declare function fetchEulerVaultUnderlyingMeta(args: {
68
+ rpcUrl: string;
69
+ chainId: number;
70
+ evault: Address;
71
+ }): Promise<{
72
+ asset: Address;
73
+ decimals: number;
74
+ }>;
75
+ /**
76
+ * Some RPCs/indexers report too-low underlying `decimals` (~15) for WETH-class assets, inflating formatted amounts ~1000×.
77
+ * Prefer wrapped-gas alias match, then Euler ETH-style vault labels, then raw chain `decimals`.
78
+ */
79
+ declare function clampEulerUnderlyingDecimalsForEulerUi(args: {
80
+ fetchedDecimals: number;
81
+ underlyingAssetLower: string;
82
+ marketName: string;
83
+ underlyingSymbol: string;
84
+ wrappedGasAliasesLower: ReadonlySet<string>;
85
+ }): number;
86
+ declare function fetchEulerVaultAssetDecimals(args: {
87
+ rpcUrl: string;
88
+ chainId: number;
89
+ evault: Address;
90
+ }): Promise<number>;
91
+ /** Max underlying assets redeemable via `withdraw` for `owner` (ERC-4626 `maxWithdraw`). */
92
+ declare function fetchEulerVaultMaxWithdrawWei(args: {
93
+ rpcUrl: string;
94
+ chainId: number;
95
+ evault: Address;
96
+ owner: Address;
97
+ }): Promise<bigint>;
98
+ /** Use for LEND/EARN redeem UX + validation: merges ERC-4626 `maxWithdraw` with withdraw simulation when it is pessimistically zero. */
99
+ declare function fetchEulerLendEarnVaultEffectiveMaxWithdrawWei(args: {
100
+ rpcUrl: string;
101
+ chainId: number;
102
+ evault: Address;
103
+ vaultShareOwner: Address;
104
+ /** Must match multisign redeem `receiver` and `executor` (key Ethereum address). */
105
+ txSender: Address;
106
+ }): Promise<bigint>;
107
+ /**
108
+ * Single ERC-4626 `withdraw(assets, receiver, owner)` on an Euler isolated eVault — no unwrap batch.
109
+ */
110
+ declare function buildEvmMultisignBodyEulerV2VaultWithdraw(args: {
111
+ keyGen: KeyGenSubsetForPermit;
112
+ chainId: number;
113
+ rpcUrl: string;
114
+ chainDetail: ChainRow$5;
115
+ useCustomGas: boolean;
116
+ customGasChainDetails?: Record<string, unknown> | null;
117
+ evault: Address;
118
+ /** Underlying asset amount (human decimal string); capped by `fetchEulerLendEarnVaultEffectiveMaxWithdrawWei`. */
119
+ amountHuman: string;
120
+ /** Receiver of underlying (usually the key address). */
121
+ owner: Address;
122
+ /** Address whose eVault shares are redeemed (ERC-4626 `owner`); defaults to `owner` when omitted. */
123
+ vaultShareOwner?: Address;
124
+ executorAddress: Address;
125
+ purposeText: string;
126
+ vaultMarketLabel: string;
127
+ }): Promise<{
128
+ bodyForSign: Record<string, unknown>;
129
+ messageToSign: string;
130
+ }>;
131
+
132
+ /** Conservative fallback when `estimateGas` fails on Euler eVault `deposit`. */
133
+ declare const EULER_V2_ISOLATED_VAULT_DEPOSIT_FALLBACK_GAS = 950000n;
134
+ type ChainRow$4 = {
135
+ legacy?: boolean;
136
+ gasLimit?: number;
137
+ gasMultiplier?: number;
138
+ gasPrice?: number;
139
+ baseFee?: number;
140
+ priorityFee?: number;
141
+ baseFeeMultiplier?: number;
142
+ };
143
+ /**
144
+ * Euler v2 isolated lending: wrap native → WETH when needed, `approve(eVault, amount)` if required,
145
+ * then `eVault.deposit(assets, receiver)` (ERC-4626).
146
+ */
147
+ declare function buildEvmMultisignBodyEulerV2IsolatedLendDepositBatch(args: {
148
+ keyGen: KeyGenSubsetForPermit;
149
+ chainId: number;
150
+ rpcUrl: string;
151
+ chainDetail: ChainRow$4;
152
+ useCustomGas: boolean;
153
+ customGasChainDetails?: Record<string, unknown> | null;
154
+ /** Euler eVault (checksummed). */
155
+ evault: Address;
156
+ /** Underlying ERC-20 passed to `deposit` (WETH when user chose native gas token row). */
157
+ underlying: Address;
158
+ isNativeIn: boolean;
159
+ nativeWrapped: Address;
160
+ amountHuman: string;
161
+ receiver: Address;
162
+ executorAddress: Address;
163
+ purposeText: string;
164
+ vaultMarketLabel: string;
165
+ }): Promise<{
166
+ bodyForSign: Record<string, unknown>;
167
+ messageToSign: string;
168
+ }>;
169
+
170
+ type ChainRow$3 = {
171
+ legacy?: boolean;
172
+ gasLimit?: number;
173
+ gasMultiplier?: number;
174
+ gasPrice?: number;
175
+ baseFee?: number;
176
+ priorityFee?: number;
177
+ baseFeeMultiplier?: number;
178
+ };
179
+ /**
180
+ * Collateral deposit + enable collateral + enable borrow controller + borrow, batched on EVC (after wrap/approve).
181
+ * When {@link args.redepositBorrowedToCollateral} is true (borrow asset === collateral asset), each borrow is followed
182
+ * by a collateral deposit of the same size inside the same EVC batch (leverage loop).
183
+ */
184
+ declare function buildEvmMultisignBodyEulerV2IsolatedBorrowBatch(args: {
185
+ keyGen: KeyGenSubsetForPermit;
186
+ chainId: number;
187
+ rpcUrl: string;
188
+ chainDetail: ChainRow$3;
189
+ useCustomGas: boolean;
190
+ customGasChainDetails?: Record<string, unknown> | null;
191
+ evc: Address;
192
+ borrowVault: Address;
193
+ collateralVault: Address;
194
+ collateralUnderlying: Address;
195
+ borrowUnderlying: Address;
196
+ isNativeCollateralIn: boolean;
197
+ nativeWrapped: Address;
198
+ collateralAmountHuman: string;
199
+ borrowAmountHuman: string;
200
+ /** Each round: `borrow(amount)` then optional `deposit(amount)` when redepositing. */
201
+ loopBorrowWeis: readonly bigint[];
202
+ redepositBorrowedToCollateral: boolean;
203
+ receiver: Address;
204
+ executorAddress: Address;
205
+ purposeText: string;
206
+ vaultMarketLabel: string;
207
+ }): Promise<{
208
+ bodyForSign: Record<string, unknown>;
209
+ messageToSign: string;
210
+ }>;
211
+
212
+ type ChainRow$2 = {
213
+ legacy?: boolean;
214
+ gasLimit?: number;
215
+ gasMultiplier?: number;
216
+ gasPrice?: number;
217
+ baseFee?: number;
218
+ priorityFee?: number;
219
+ baseFeeMultiplier?: number;
220
+ };
221
+ /**
222
+ * ERC-20 approve (if needed) + EVC batch with liability vault `repay` for `subAccount`’s debt.
223
+ */
224
+ declare function buildEvmMultisignBodyEulerV2BorrowRepayBatch(args: {
225
+ keyGen: KeyGenSubsetForPermit;
226
+ chainId: number;
227
+ rpcUrl: string;
228
+ chainDetail: ChainRow$2;
229
+ useCustomGas: boolean;
230
+ customGasChainDetails?: Record<string, unknown> | null;
231
+ evc: Address;
232
+ borrowVault: Address;
233
+ borrowUnderlying: Address;
234
+ subAccount: Address;
235
+ /** Human decimal string; full repay when `repayAll` or amount ≥ on-chain debt. */
236
+ amountHuman: string;
237
+ /** When true, encodes `repay(type(uint256).max, receiver)`. */
238
+ repayAll: boolean;
239
+ executorAddress: Address;
240
+ purposeText: string;
241
+ vaultMarketLabel: string;
242
+ }): Promise<{
243
+ bodyForSign: Record<string, unknown>;
244
+ messageToSign: string;
245
+ }>;
246
+
247
+ type ChainRow$1 = {
248
+ legacy?: boolean;
249
+ gasLimit?: number;
250
+ gasMultiplier?: number;
251
+ gasPrice?: number;
252
+ baseFee?: number;
253
+ priorityFee?: number;
254
+ baseFeeMultiplier?: number;
255
+ };
256
+ /**
257
+ * ERC-20 approve (if needed) + EVC batch: collateral eVault `deposit(assets, receiver=subAccount)` on behalf of the sub-account.
258
+ * Uses the key EOA as token source (`executor` approves the collateral vault).
259
+ */
260
+ declare function buildEvmMultisignBodyEulerV2BorrowCollateralDepositBatch(args: {
261
+ keyGen: KeyGenSubsetForPermit;
262
+ chainId: number;
263
+ rpcUrl: string;
264
+ chainDetail: ChainRow$1;
265
+ useCustomGas: boolean;
266
+ customGasChainDetails?: Record<string, unknown> | null;
267
+ evc: Address;
268
+ collateralVault: Address;
269
+ collateralUnderlying: Address;
270
+ subAccount: Address;
271
+ amountHuman: string;
272
+ executorAddress: Address;
273
+ purposeText: string;
274
+ vaultMarketLabel: string;
275
+ }): Promise<{
276
+ bodyForSign: Record<string, unknown>;
277
+ messageToSign: string;
278
+ }>;
279
+
280
+ type ChainRow = {
281
+ legacy?: boolean;
282
+ gasLimit?: number;
283
+ gasMultiplier?: number;
284
+ gasPrice?: number;
285
+ baseFee?: number;
286
+ priorityFee?: number;
287
+ baseFeeMultiplier?: number;
288
+ };
289
+ /**
290
+ * EVC batch: collateral eVault `withdraw(assets, receiver, owner=subAccount)` on behalf of the sub-account.
291
+ * Amount is capped by `fetchEulerBorrowCollateralMaxWithdrawAssetsWei` (ERC-4626 `maxWithdraw` is 0 while EVC controls the account).
292
+ */
293
+ declare function buildEvmMultisignBodyEulerV2BorrowCollateralWithdrawBatch(args: {
294
+ keyGen: KeyGenSubsetForPermit;
295
+ chainId: number;
296
+ rpcUrl: string;
297
+ chainDetail: ChainRow;
298
+ useCustomGas: boolean;
299
+ customGasChainDetails?: Record<string, unknown> | null;
300
+ evc: Address;
301
+ collateralVault: Address;
302
+ subAccount: Address;
303
+ /** Receives underlying collateral tokens (typically the key EOA). */
304
+ receiver: Address;
305
+ amountHuman: string;
306
+ executorAddress: Address;
307
+ purposeText: string;
308
+ vaultMarketLabel: string;
309
+ }): Promise<{
310
+ bodyForSign: Record<string, unknown>;
311
+ messageToSign: string;
312
+ }>;
313
+
314
+ declare const EULER_V2_PROTOCOL_ID = "euler-v2";
315
+ declare const eulerV2ProtocolModule: ProtocolModule;
316
+
317
+ export { EULER_SAME_ASSET_BORROW_APPROVAL_BUFFER_BPS, EULER_SAME_ASSET_BORROW_MAX_ROUNDS, EULER_SAME_ASSET_BORROW_PROTOCOL_HEADROOM_BPS, EULER_SAME_ASSET_BORROW_RATIO_STOP_EPS_BPS, EULER_V2_ISOLATED_VAULT_DEPOSIT_FALLBACK_GAS, EULER_V2_PROTOCOL_ID, EULER_V2_VAULT_WITHDRAW_FALLBACK_GAS, buildEvmMultisignBodyEulerV2BorrowCollateralDepositBatch, buildEvmMultisignBodyEulerV2BorrowCollateralWithdrawBatch, buildEvmMultisignBodyEulerV2BorrowRepayBatch, buildEvmMultisignBodyEulerV2IsolatedBorrowBatch, buildEvmMultisignBodyEulerV2IsolatedLendDepositBatch, buildEvmMultisignBodyEulerV2VaultWithdraw, clampEulerUnderlyingDecimalsForEulerUi, eulerBorrowAndCollateralSameAsset, eulerSameAssetApproveAmountWithBuffer, eulerSameAssetTotalCollateralPullWei, eulerV2ProtocolModule, fetchEulerBorrowCollateralMaxWithdrawAssetsWei, fetchEulerLendEarnVaultEffectiveMaxWithdrawWei, fetchEulerVaultAssetDecimals, fetchEulerVaultMaxWithdrawWei, fetchEulerVaultUnderlyingMeta, planSameAssetLeveragedBorrows };