origin-morpho-utils 0.1.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ var _chunk35AORYVFcjs = require('./chunk-35AORYVF.cjs');
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ var _chunk37KGZP4Ocjs = require('./chunk-37KGZP4O.cjs');
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+ exports.MORPHO_BLUE_ADDRESSES = _chunk35AORYVFcjs.MORPHO_BLUE_ADDRESSES; exports.computeDepositImpact = _chunk35AORYVFcjs.computeDepositImpact; exports.computeDepositImpactRpc = _chunk35AORYVFcjs.computeDepositImpactRpc; exports.computeWithdrawalImpact = _chunk35AORYVFcjs.computeWithdrawalImpact; exports.computeWithdrawalImpactRpc = _chunk35AORYVFcjs.computeWithdrawalImpactRpc; exports.erc20Abi = _chunk35AORYVFcjs.erc20Abi; exports.estimateMarketApy = _chunk37KGZP4Ocjs.estimateMarketApy; exports.fetchVaultApy = _chunk35AORYVFcjs.fetchVaultApy; exports.fetchVaultApyViem = _chunk35AORYVFcjs.fetchVaultApyViem; exports.fetchVaultMarkets = _chunk35AORYVFcjs.fetchVaultMarkets; exports.fetchVaultMarketsViem = _chunk35AORYVFcjs.fetchVaultMarketsViem; exports.findMaxDeposit = _chunk35AORYVFcjs.findMaxDeposit; exports.findMaxDepositAmount = _chunk35AORYVFcjs.findMaxDepositAmount; exports.findMaxDepositRpc = _chunk35AORYVFcjs.findMaxDepositRpc; exports.findMaxWithdrawal = _chunk35AORYVFcjs.findMaxWithdrawal; exports.findMaxWithdrawalAmount = _chunk35AORYVFcjs.findMaxWithdrawalAmount; exports.findMaxWithdrawalRpc = _chunk35AORYVFcjs.findMaxWithdrawalRpc; exports.getMorphoBlueAddress = _chunk35AORYVFcjs.getMorphoBlueAddress; exports.irmAdaptiveCurveAbi = _chunk35AORYVFcjs.irmAdaptiveCurveAbi; exports.mergeMarketDetails = _chunk37KGZP4Ocjs.mergeMarketDetails; exports.metaMorphoAbi = _chunk35AORYVFcjs.metaMorphoAbi; exports.morphoAbi = _chunk35AORYVFcjs.morphoAbi; exports.simulateDeposit = _chunk37KGZP4Ocjs.simulateDeposit; exports.simulateWithdrawal = _chunk37KGZP4Ocjs.simulateWithdrawal; exports.weightedVaultApy = _chunk37KGZP4Ocjs.weightedVaultApy; exports.weightedVaultApyDetailed = _chunk37KGZP4Ocjs.weightedVaultApyDetailed;
59
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Volumes/origin/morpho-utils/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,+sDAAC","file":"/Volumes/origin/morpho-utils/dist/index.cjs"}
@@ -0,0 +1,314 @@
1
+ import { V as VaultApyResult, a as VaultFetchResult, D as DepositImpactResult, W as WithdrawalImpactResult, M as MarketForApy, F as FindMaxConstraint, b as FindMaxDepositResult, c as FindMaxWithdrawalResult } from './math-ClwpjVti.cjs';
2
+ export { d as FindMaxConstraintState, e as MarketApyDetail, f as MarketApySnapshot, g as MarketImpactDetail, h as VaultApyDetailed, i as estimateMarketApy, m as mergeMarketDetails, s as simulateDeposit, j as simulateWithdrawal, w as weightedVaultApy, k as weightedVaultApyDetailed } from './math-ClwpjVti.cjs';
3
+ import { PublicClient } from 'viem';
4
+
5
+ /**
6
+ * Market data fetching for Morpho Blue / MetaMorpho vaults using viem.
7
+ */
8
+
9
+ /**
10
+ * Fetch all market data for a MetaMorpho vault using viem multicall.
11
+ *
12
+ * Returns market data needed for APY computation and simulation,
13
+ * plus the vault's idle (undeployed) assets.
14
+ */
15
+ declare function fetchVaultMarketsViem(client: PublicClient, vaultAddress: string, morphoAddress: string): Promise<VaultFetchResult>;
16
+ /**
17
+ * Fetch vault markets and compute the weighted APY in one call.
18
+ * Returns null if the vault has no markets yet (not yet deployed).
19
+ * Returns `apy`, `markets`, and `idleAssets` so callers can reuse for simulation.
20
+ */
21
+ declare function fetchVaultApyViem(client: PublicClient, vaultAddress: string, morphoAddress: string, options?: {
22
+ includeMarkets?: boolean;
23
+ }): Promise<VaultApyResult | null>;
24
+
25
+ /**
26
+ * Compute the APY impact of a deposit into a MetaMorpho vault.
27
+ * Makes live on-chain RPC calls via the provided viem PublicClient.
28
+ *
29
+ * @param client viem PublicClient for the target chain
30
+ * @param chainId Chain ID (used to resolve the Morpho Blue singleton address)
31
+ * @param vaultAddress MetaMorpho V1.1 vault address
32
+ * @param depositAmount Deposit size in loan-token base units (e.g. 1e18 for 1 ETH)
33
+ * @param morphoAddress Optional override for the Morpho Blue singleton address
34
+ */
35
+ declare function computeDepositImpact(client: PublicClient, chainId: number, vaultAddress: string, depositAmount: bigint, options?: {
36
+ morphoAddress?: string;
37
+ includeMarkets?: boolean;
38
+ }): Promise<DepositImpactResult>;
39
+
40
+ /**
41
+ * Compute the APY impact of a withdrawal from a MetaMorpho vault.
42
+ * Makes live on-chain RPC calls via the provided viem PublicClient.
43
+ *
44
+ * @param client viem PublicClient for the target chain
45
+ * @param chainId Chain ID (used to resolve the Morpho Blue singleton address)
46
+ * @param vaultAddress MetaMorpho V1.1 vault address
47
+ * @param withdrawAmount Withdrawal size in loan-token base units (e.g. 1e18 for 1 ETH)
48
+ * @param morphoAddress Optional override for the Morpho Blue singleton address
49
+ */
50
+ declare function computeWithdrawalImpact(client: PublicClient, chainId: number, vaultAddress: string, withdrawAmount: bigint, options?: {
51
+ morphoAddress?: string;
52
+ includeMarkets?: boolean;
53
+ }): Promise<WithdrawalImpactResult>;
54
+
55
+ /**
56
+ * Find the maximum deposit amount within an APY impact threshold using binary search.
57
+ *
58
+ * @param markets - Market data from fetchVaultMarkets
59
+ * @param maxAmount - Ceiling amount in base units
60
+ * @param maxImpactBps - Maximum allowed APY impact in basis points (e.g. 50 = 0.5%)
61
+ * @param options.precision - Search granularity in base units. Default: 1 whole token.
62
+ * @param options.includeMarkets - Include per-market details in impact result. Default: false.
63
+ * @param options.constraint - Custom constraint callback. Must be monotonic: if amount X fails, all X+n must also fail.
64
+ */
65
+ declare function findMaxDepositAmount(markets: MarketForApy[], maxAmount: bigint, maxImpactBps: number, options?: {
66
+ precision?: bigint;
67
+ includeMarkets?: boolean;
68
+ constraint?: FindMaxConstraint;
69
+ }): Promise<FindMaxDepositResult>;
70
+ /**
71
+ * Find the maximum withdrawal amount within an APY impact threshold using binary search.
72
+ *
73
+ * @param markets - Market data from fetchVaultMarkets
74
+ * @param idleAssets - Vault idle assets (undeployed)
75
+ * @param maxAmount - Ceiling amount in base units
76
+ * @param maxImpactBps - Maximum allowed APY impact in basis points (e.g. 50 = 0.5%)
77
+ * @param options.precision - Search granularity in base units. Default: 1 whole token.
78
+ * @param options.includeMarkets - Include per-market details in impact result. Default: false.
79
+ * @param options.constraint - Custom constraint callback. Must be monotonic: if amount X fails, all X+n must also fail.
80
+ */
81
+ declare function findMaxWithdrawalAmount(markets: MarketForApy[], idleAssets: bigint, maxAmount: bigint, maxImpactBps: number, options?: {
82
+ precision?: bigint;
83
+ includeMarkets?: boolean;
84
+ constraint?: FindMaxConstraint;
85
+ }): Promise<FindMaxWithdrawalResult>;
86
+
87
+ declare function findMaxDeposit(client: PublicClient, chainId: number, vaultAddress: string, maxAmount: bigint, maxImpactBps: number, options?: {
88
+ precision?: bigint;
89
+ morphoAddress?: string;
90
+ includeMarkets?: boolean;
91
+ constraint?: FindMaxConstraint;
92
+ }): Promise<FindMaxDepositResult>;
93
+ declare function findMaxWithdrawal(client: PublicClient, chainId: number, vaultAddress: string, maxAmount: bigint, maxImpactBps: number, options?: {
94
+ precision?: bigint;
95
+ morphoAddress?: string;
96
+ includeMarkets?: boolean;
97
+ constraint?: FindMaxConstraint;
98
+ }): Promise<FindMaxWithdrawalResult>;
99
+
100
+ declare function fetchVaultMarkets(rpcUrl: string, chainId: number, vaultAddress: string, morphoAddress: string): Promise<VaultFetchResult>;
101
+ declare function fetchVaultApy(rpcUrl: string, chainId: number, vaultAddress: string, options?: {
102
+ morphoAddress?: string;
103
+ includeMarkets?: boolean;
104
+ }): Promise<VaultApyResult | null>;
105
+ declare function computeDepositImpactRpc(rpcUrl: string, chainId: number, vaultAddress: string, depositAmount: bigint, options?: {
106
+ morphoAddress?: string;
107
+ includeMarkets?: boolean;
108
+ }): Promise<DepositImpactResult>;
109
+ declare function computeWithdrawalImpactRpc(rpcUrl: string, chainId: number, vaultAddress: string, withdrawAmount: bigint, options?: {
110
+ morphoAddress?: string;
111
+ includeMarkets?: boolean;
112
+ }): Promise<WithdrawalImpactResult>;
113
+ declare function findMaxDepositRpc(rpcUrl: string, chainId: number, vaultAddress: string, maxAmount: bigint, maxImpactBps: number, options?: {
114
+ precision?: bigint;
115
+ morphoAddress?: string;
116
+ includeMarkets?: boolean;
117
+ constraint?: FindMaxConstraint;
118
+ }): Promise<FindMaxDepositResult>;
119
+ declare function findMaxWithdrawalRpc(rpcUrl: string, chainId: number, vaultAddress: string, maxAmount: bigint, maxImpactBps: number, options?: {
120
+ precision?: bigint;
121
+ morphoAddress?: string;
122
+ includeMarkets?: boolean;
123
+ constraint?: FindMaxConstraint;
124
+ }): Promise<FindMaxWithdrawalResult>;
125
+
126
+ /** Well-known Morpho Blue singleton addresses per chain. */
127
+ declare const MORPHO_BLUE_ADDRESSES: Record<number, `0x${string}`>;
128
+ /** Look up Morpho Blue singleton address by chain ID. Throws if unknown. */
129
+ declare function getMorphoBlueAddress(chainId: number): `0x${string}`;
130
+
131
+ /** Minimal Morpho Blue ABI — only view functions used by fetchVaultMarketsViem. */
132
+ declare const morphoAbi: readonly [{
133
+ readonly inputs: readonly [{
134
+ readonly name: "id";
135
+ readonly type: "bytes32";
136
+ }];
137
+ readonly name: "market";
138
+ readonly outputs: readonly [{
139
+ readonly name: "totalSupplyAssets";
140
+ readonly type: "uint128";
141
+ }, {
142
+ readonly name: "totalSupplyShares";
143
+ readonly type: "uint128";
144
+ }, {
145
+ readonly name: "totalBorrowAssets";
146
+ readonly type: "uint128";
147
+ }, {
148
+ readonly name: "totalBorrowShares";
149
+ readonly type: "uint128";
150
+ }, {
151
+ readonly name: "lastUpdate";
152
+ readonly type: "uint128";
153
+ }, {
154
+ readonly name: "fee";
155
+ readonly type: "uint128";
156
+ }];
157
+ readonly stateMutability: "view";
158
+ readonly type: "function";
159
+ }, {
160
+ readonly inputs: readonly [{
161
+ readonly name: "id";
162
+ readonly type: "bytes32";
163
+ }, {
164
+ readonly name: "user";
165
+ readonly type: "address";
166
+ }];
167
+ readonly name: "position";
168
+ readonly outputs: readonly [{
169
+ readonly name: "supplyShares";
170
+ readonly type: "uint256";
171
+ }, {
172
+ readonly name: "borrowShares";
173
+ readonly type: "uint128";
174
+ }, {
175
+ readonly name: "collateral";
176
+ readonly type: "uint128";
177
+ }];
178
+ readonly stateMutability: "view";
179
+ readonly type: "function";
180
+ }, {
181
+ readonly inputs: readonly [{
182
+ readonly name: "id";
183
+ readonly type: "bytes32";
184
+ }];
185
+ readonly name: "idToMarketParams";
186
+ readonly outputs: readonly [{
187
+ readonly name: "loanToken";
188
+ readonly type: "address";
189
+ }, {
190
+ readonly name: "collateralToken";
191
+ readonly type: "address";
192
+ }, {
193
+ readonly name: "oracle";
194
+ readonly type: "address";
195
+ }, {
196
+ readonly name: "irm";
197
+ readonly type: "address";
198
+ }, {
199
+ readonly name: "lltv";
200
+ readonly type: "uint256";
201
+ }];
202
+ readonly stateMutability: "view";
203
+ readonly type: "function";
204
+ }];
205
+
206
+ /** Minimal MetaMorpho (ERC4626 vault) ABI — only view functions used by fetchVaultMarketsViem. */
207
+ declare const metaMorphoAbi: readonly [{
208
+ readonly inputs: readonly [];
209
+ readonly name: "supplyQueueLength";
210
+ readonly outputs: readonly [{
211
+ readonly name: "";
212
+ readonly type: "uint256";
213
+ }];
214
+ readonly stateMutability: "view";
215
+ readonly type: "function";
216
+ }, {
217
+ readonly inputs: readonly [];
218
+ readonly name: "withdrawQueueLength";
219
+ readonly outputs: readonly [{
220
+ readonly name: "";
221
+ readonly type: "uint256";
222
+ }];
223
+ readonly stateMutability: "view";
224
+ readonly type: "function";
225
+ }, {
226
+ readonly inputs: readonly [];
227
+ readonly name: "totalAssets";
228
+ readonly outputs: readonly [{
229
+ readonly name: "totalManagedAssets";
230
+ readonly type: "uint256";
231
+ }];
232
+ readonly stateMutability: "view";
233
+ readonly type: "function";
234
+ }, {
235
+ readonly inputs: readonly [{
236
+ readonly name: "";
237
+ readonly type: "uint256";
238
+ }];
239
+ readonly name: "supplyQueue";
240
+ readonly outputs: readonly [{
241
+ readonly name: "";
242
+ readonly type: "bytes32";
243
+ }];
244
+ readonly stateMutability: "view";
245
+ readonly type: "function";
246
+ }, {
247
+ readonly inputs: readonly [{
248
+ readonly name: "";
249
+ readonly type: "uint256";
250
+ }];
251
+ readonly name: "withdrawQueue";
252
+ readonly outputs: readonly [{
253
+ readonly name: "";
254
+ readonly type: "bytes32";
255
+ }];
256
+ readonly stateMutability: "view";
257
+ readonly type: "function";
258
+ }, {
259
+ readonly inputs: readonly [{
260
+ readonly name: "";
261
+ readonly type: "bytes32";
262
+ }];
263
+ readonly name: "config";
264
+ readonly outputs: readonly [{
265
+ readonly name: "cap";
266
+ readonly type: "uint184";
267
+ }, {
268
+ readonly name: "enabled";
269
+ readonly type: "bool";
270
+ }, {
271
+ readonly name: "removableAt";
272
+ readonly type: "uint64";
273
+ }];
274
+ readonly stateMutability: "view";
275
+ readonly type: "function";
276
+ }];
277
+
278
+ /** Minimal IRM Adaptive Curve ABI — rateAtTarget only. */
279
+ declare const irmAdaptiveCurveAbi: readonly [{
280
+ readonly inputs: readonly [{
281
+ readonly name: "id";
282
+ readonly type: "bytes32";
283
+ }];
284
+ readonly name: "rateAtTarget";
285
+ readonly outputs: readonly [{
286
+ readonly name: "";
287
+ readonly type: "int256";
288
+ }];
289
+ readonly stateMutability: "view";
290
+ readonly type: "function";
291
+ }];
292
+
293
+ /** Minimal ERC20 ABI — decimals + symbol. */
294
+ declare const erc20Abi: readonly [{
295
+ readonly inputs: readonly [];
296
+ readonly name: "decimals";
297
+ readonly outputs: readonly [{
298
+ readonly name: "";
299
+ readonly type: "uint8";
300
+ }];
301
+ readonly stateMutability: "view";
302
+ readonly type: "function";
303
+ }, {
304
+ readonly inputs: readonly [];
305
+ readonly name: "symbol";
306
+ readonly outputs: readonly [{
307
+ readonly name: "";
308
+ readonly type: "string";
309
+ }];
310
+ readonly stateMutability: "view";
311
+ readonly type: "function";
312
+ }];
313
+
314
+ export { DepositImpactResult, FindMaxConstraint, FindMaxDepositResult, FindMaxWithdrawalResult, MORPHO_BLUE_ADDRESSES, MarketForApy, VaultApyResult, VaultFetchResult, WithdrawalImpactResult, computeDepositImpact, computeDepositImpactRpc, computeWithdrawalImpact, computeWithdrawalImpactRpc, erc20Abi, fetchVaultApy, fetchVaultApyViem, fetchVaultMarkets, fetchVaultMarketsViem, findMaxDeposit, findMaxDepositAmount, findMaxDepositRpc, findMaxWithdrawal, findMaxWithdrawalAmount, findMaxWithdrawalRpc, getMorphoBlueAddress, irmAdaptiveCurveAbi, metaMorphoAbi, morphoAbi };
@@ -0,0 +1,314 @@
1
+ import { V as VaultApyResult, a as VaultFetchResult, D as DepositImpactResult, W as WithdrawalImpactResult, M as MarketForApy, F as FindMaxConstraint, b as FindMaxDepositResult, c as FindMaxWithdrawalResult } from './math-ClwpjVti.js';
2
+ export { d as FindMaxConstraintState, e as MarketApyDetail, f as MarketApySnapshot, g as MarketImpactDetail, h as VaultApyDetailed, i as estimateMarketApy, m as mergeMarketDetails, s as simulateDeposit, j as simulateWithdrawal, w as weightedVaultApy, k as weightedVaultApyDetailed } from './math-ClwpjVti.js';
3
+ import { PublicClient } from 'viem';
4
+
5
+ /**
6
+ * Market data fetching for Morpho Blue / MetaMorpho vaults using viem.
7
+ */
8
+
9
+ /**
10
+ * Fetch all market data for a MetaMorpho vault using viem multicall.
11
+ *
12
+ * Returns market data needed for APY computation and simulation,
13
+ * plus the vault's idle (undeployed) assets.
14
+ */
15
+ declare function fetchVaultMarketsViem(client: PublicClient, vaultAddress: string, morphoAddress: string): Promise<VaultFetchResult>;
16
+ /**
17
+ * Fetch vault markets and compute the weighted APY in one call.
18
+ * Returns null if the vault has no markets yet (not yet deployed).
19
+ * Returns `apy`, `markets`, and `idleAssets` so callers can reuse for simulation.
20
+ */
21
+ declare function fetchVaultApyViem(client: PublicClient, vaultAddress: string, morphoAddress: string, options?: {
22
+ includeMarkets?: boolean;
23
+ }): Promise<VaultApyResult | null>;
24
+
25
+ /**
26
+ * Compute the APY impact of a deposit into a MetaMorpho vault.
27
+ * Makes live on-chain RPC calls via the provided viem PublicClient.
28
+ *
29
+ * @param client viem PublicClient for the target chain
30
+ * @param chainId Chain ID (used to resolve the Morpho Blue singleton address)
31
+ * @param vaultAddress MetaMorpho V1.1 vault address
32
+ * @param depositAmount Deposit size in loan-token base units (e.g. 1e18 for 1 ETH)
33
+ * @param morphoAddress Optional override for the Morpho Blue singleton address
34
+ */
35
+ declare function computeDepositImpact(client: PublicClient, chainId: number, vaultAddress: string, depositAmount: bigint, options?: {
36
+ morphoAddress?: string;
37
+ includeMarkets?: boolean;
38
+ }): Promise<DepositImpactResult>;
39
+
40
+ /**
41
+ * Compute the APY impact of a withdrawal from a MetaMorpho vault.
42
+ * Makes live on-chain RPC calls via the provided viem PublicClient.
43
+ *
44
+ * @param client viem PublicClient for the target chain
45
+ * @param chainId Chain ID (used to resolve the Morpho Blue singleton address)
46
+ * @param vaultAddress MetaMorpho V1.1 vault address
47
+ * @param withdrawAmount Withdrawal size in loan-token base units (e.g. 1e18 for 1 ETH)
48
+ * @param morphoAddress Optional override for the Morpho Blue singleton address
49
+ */
50
+ declare function computeWithdrawalImpact(client: PublicClient, chainId: number, vaultAddress: string, withdrawAmount: bigint, options?: {
51
+ morphoAddress?: string;
52
+ includeMarkets?: boolean;
53
+ }): Promise<WithdrawalImpactResult>;
54
+
55
+ /**
56
+ * Find the maximum deposit amount within an APY impact threshold using binary search.
57
+ *
58
+ * @param markets - Market data from fetchVaultMarkets
59
+ * @param maxAmount - Ceiling amount in base units
60
+ * @param maxImpactBps - Maximum allowed APY impact in basis points (e.g. 50 = 0.5%)
61
+ * @param options.precision - Search granularity in base units. Default: 1 whole token.
62
+ * @param options.includeMarkets - Include per-market details in impact result. Default: false.
63
+ * @param options.constraint - Custom constraint callback. Must be monotonic: if amount X fails, all X+n must also fail.
64
+ */
65
+ declare function findMaxDepositAmount(markets: MarketForApy[], maxAmount: bigint, maxImpactBps: number, options?: {
66
+ precision?: bigint;
67
+ includeMarkets?: boolean;
68
+ constraint?: FindMaxConstraint;
69
+ }): Promise<FindMaxDepositResult>;
70
+ /**
71
+ * Find the maximum withdrawal amount within an APY impact threshold using binary search.
72
+ *
73
+ * @param markets - Market data from fetchVaultMarkets
74
+ * @param idleAssets - Vault idle assets (undeployed)
75
+ * @param maxAmount - Ceiling amount in base units
76
+ * @param maxImpactBps - Maximum allowed APY impact in basis points (e.g. 50 = 0.5%)
77
+ * @param options.precision - Search granularity in base units. Default: 1 whole token.
78
+ * @param options.includeMarkets - Include per-market details in impact result. Default: false.
79
+ * @param options.constraint - Custom constraint callback. Must be monotonic: if amount X fails, all X+n must also fail.
80
+ */
81
+ declare function findMaxWithdrawalAmount(markets: MarketForApy[], idleAssets: bigint, maxAmount: bigint, maxImpactBps: number, options?: {
82
+ precision?: bigint;
83
+ includeMarkets?: boolean;
84
+ constraint?: FindMaxConstraint;
85
+ }): Promise<FindMaxWithdrawalResult>;
86
+
87
+ declare function findMaxDeposit(client: PublicClient, chainId: number, vaultAddress: string, maxAmount: bigint, maxImpactBps: number, options?: {
88
+ precision?: bigint;
89
+ morphoAddress?: string;
90
+ includeMarkets?: boolean;
91
+ constraint?: FindMaxConstraint;
92
+ }): Promise<FindMaxDepositResult>;
93
+ declare function findMaxWithdrawal(client: PublicClient, chainId: number, vaultAddress: string, maxAmount: bigint, maxImpactBps: number, options?: {
94
+ precision?: bigint;
95
+ morphoAddress?: string;
96
+ includeMarkets?: boolean;
97
+ constraint?: FindMaxConstraint;
98
+ }): Promise<FindMaxWithdrawalResult>;
99
+
100
+ declare function fetchVaultMarkets(rpcUrl: string, chainId: number, vaultAddress: string, morphoAddress: string): Promise<VaultFetchResult>;
101
+ declare function fetchVaultApy(rpcUrl: string, chainId: number, vaultAddress: string, options?: {
102
+ morphoAddress?: string;
103
+ includeMarkets?: boolean;
104
+ }): Promise<VaultApyResult | null>;
105
+ declare function computeDepositImpactRpc(rpcUrl: string, chainId: number, vaultAddress: string, depositAmount: bigint, options?: {
106
+ morphoAddress?: string;
107
+ includeMarkets?: boolean;
108
+ }): Promise<DepositImpactResult>;
109
+ declare function computeWithdrawalImpactRpc(rpcUrl: string, chainId: number, vaultAddress: string, withdrawAmount: bigint, options?: {
110
+ morphoAddress?: string;
111
+ includeMarkets?: boolean;
112
+ }): Promise<WithdrawalImpactResult>;
113
+ declare function findMaxDepositRpc(rpcUrl: string, chainId: number, vaultAddress: string, maxAmount: bigint, maxImpactBps: number, options?: {
114
+ precision?: bigint;
115
+ morphoAddress?: string;
116
+ includeMarkets?: boolean;
117
+ constraint?: FindMaxConstraint;
118
+ }): Promise<FindMaxDepositResult>;
119
+ declare function findMaxWithdrawalRpc(rpcUrl: string, chainId: number, vaultAddress: string, maxAmount: bigint, maxImpactBps: number, options?: {
120
+ precision?: bigint;
121
+ morphoAddress?: string;
122
+ includeMarkets?: boolean;
123
+ constraint?: FindMaxConstraint;
124
+ }): Promise<FindMaxWithdrawalResult>;
125
+
126
+ /** Well-known Morpho Blue singleton addresses per chain. */
127
+ declare const MORPHO_BLUE_ADDRESSES: Record<number, `0x${string}`>;
128
+ /** Look up Morpho Blue singleton address by chain ID. Throws if unknown. */
129
+ declare function getMorphoBlueAddress(chainId: number): `0x${string}`;
130
+
131
+ /** Minimal Morpho Blue ABI — only view functions used by fetchVaultMarketsViem. */
132
+ declare const morphoAbi: readonly [{
133
+ readonly inputs: readonly [{
134
+ readonly name: "id";
135
+ readonly type: "bytes32";
136
+ }];
137
+ readonly name: "market";
138
+ readonly outputs: readonly [{
139
+ readonly name: "totalSupplyAssets";
140
+ readonly type: "uint128";
141
+ }, {
142
+ readonly name: "totalSupplyShares";
143
+ readonly type: "uint128";
144
+ }, {
145
+ readonly name: "totalBorrowAssets";
146
+ readonly type: "uint128";
147
+ }, {
148
+ readonly name: "totalBorrowShares";
149
+ readonly type: "uint128";
150
+ }, {
151
+ readonly name: "lastUpdate";
152
+ readonly type: "uint128";
153
+ }, {
154
+ readonly name: "fee";
155
+ readonly type: "uint128";
156
+ }];
157
+ readonly stateMutability: "view";
158
+ readonly type: "function";
159
+ }, {
160
+ readonly inputs: readonly [{
161
+ readonly name: "id";
162
+ readonly type: "bytes32";
163
+ }, {
164
+ readonly name: "user";
165
+ readonly type: "address";
166
+ }];
167
+ readonly name: "position";
168
+ readonly outputs: readonly [{
169
+ readonly name: "supplyShares";
170
+ readonly type: "uint256";
171
+ }, {
172
+ readonly name: "borrowShares";
173
+ readonly type: "uint128";
174
+ }, {
175
+ readonly name: "collateral";
176
+ readonly type: "uint128";
177
+ }];
178
+ readonly stateMutability: "view";
179
+ readonly type: "function";
180
+ }, {
181
+ readonly inputs: readonly [{
182
+ readonly name: "id";
183
+ readonly type: "bytes32";
184
+ }];
185
+ readonly name: "idToMarketParams";
186
+ readonly outputs: readonly [{
187
+ readonly name: "loanToken";
188
+ readonly type: "address";
189
+ }, {
190
+ readonly name: "collateralToken";
191
+ readonly type: "address";
192
+ }, {
193
+ readonly name: "oracle";
194
+ readonly type: "address";
195
+ }, {
196
+ readonly name: "irm";
197
+ readonly type: "address";
198
+ }, {
199
+ readonly name: "lltv";
200
+ readonly type: "uint256";
201
+ }];
202
+ readonly stateMutability: "view";
203
+ readonly type: "function";
204
+ }];
205
+
206
+ /** Minimal MetaMorpho (ERC4626 vault) ABI — only view functions used by fetchVaultMarketsViem. */
207
+ declare const metaMorphoAbi: readonly [{
208
+ readonly inputs: readonly [];
209
+ readonly name: "supplyQueueLength";
210
+ readonly outputs: readonly [{
211
+ readonly name: "";
212
+ readonly type: "uint256";
213
+ }];
214
+ readonly stateMutability: "view";
215
+ readonly type: "function";
216
+ }, {
217
+ readonly inputs: readonly [];
218
+ readonly name: "withdrawQueueLength";
219
+ readonly outputs: readonly [{
220
+ readonly name: "";
221
+ readonly type: "uint256";
222
+ }];
223
+ readonly stateMutability: "view";
224
+ readonly type: "function";
225
+ }, {
226
+ readonly inputs: readonly [];
227
+ readonly name: "totalAssets";
228
+ readonly outputs: readonly [{
229
+ readonly name: "totalManagedAssets";
230
+ readonly type: "uint256";
231
+ }];
232
+ readonly stateMutability: "view";
233
+ readonly type: "function";
234
+ }, {
235
+ readonly inputs: readonly [{
236
+ readonly name: "";
237
+ readonly type: "uint256";
238
+ }];
239
+ readonly name: "supplyQueue";
240
+ readonly outputs: readonly [{
241
+ readonly name: "";
242
+ readonly type: "bytes32";
243
+ }];
244
+ readonly stateMutability: "view";
245
+ readonly type: "function";
246
+ }, {
247
+ readonly inputs: readonly [{
248
+ readonly name: "";
249
+ readonly type: "uint256";
250
+ }];
251
+ readonly name: "withdrawQueue";
252
+ readonly outputs: readonly [{
253
+ readonly name: "";
254
+ readonly type: "bytes32";
255
+ }];
256
+ readonly stateMutability: "view";
257
+ readonly type: "function";
258
+ }, {
259
+ readonly inputs: readonly [{
260
+ readonly name: "";
261
+ readonly type: "bytes32";
262
+ }];
263
+ readonly name: "config";
264
+ readonly outputs: readonly [{
265
+ readonly name: "cap";
266
+ readonly type: "uint184";
267
+ }, {
268
+ readonly name: "enabled";
269
+ readonly type: "bool";
270
+ }, {
271
+ readonly name: "removableAt";
272
+ readonly type: "uint64";
273
+ }];
274
+ readonly stateMutability: "view";
275
+ readonly type: "function";
276
+ }];
277
+
278
+ /** Minimal IRM Adaptive Curve ABI — rateAtTarget only. */
279
+ declare const irmAdaptiveCurveAbi: readonly [{
280
+ readonly inputs: readonly [{
281
+ readonly name: "id";
282
+ readonly type: "bytes32";
283
+ }];
284
+ readonly name: "rateAtTarget";
285
+ readonly outputs: readonly [{
286
+ readonly name: "";
287
+ readonly type: "int256";
288
+ }];
289
+ readonly stateMutability: "view";
290
+ readonly type: "function";
291
+ }];
292
+
293
+ /** Minimal ERC20 ABI — decimals + symbol. */
294
+ declare const erc20Abi: readonly [{
295
+ readonly inputs: readonly [];
296
+ readonly name: "decimals";
297
+ readonly outputs: readonly [{
298
+ readonly name: "";
299
+ readonly type: "uint8";
300
+ }];
301
+ readonly stateMutability: "view";
302
+ readonly type: "function";
303
+ }, {
304
+ readonly inputs: readonly [];
305
+ readonly name: "symbol";
306
+ readonly outputs: readonly [{
307
+ readonly name: "";
308
+ readonly type: "string";
309
+ }];
310
+ readonly stateMutability: "view";
311
+ readonly type: "function";
312
+ }];
313
+
314
+ export { DepositImpactResult, FindMaxConstraint, FindMaxDepositResult, FindMaxWithdrawalResult, MORPHO_BLUE_ADDRESSES, MarketForApy, VaultApyResult, VaultFetchResult, WithdrawalImpactResult, computeDepositImpact, computeDepositImpactRpc, computeWithdrawalImpact, computeWithdrawalImpactRpc, erc20Abi, fetchVaultApy, fetchVaultApyViem, fetchVaultMarkets, fetchVaultMarketsViem, findMaxDeposit, findMaxDepositAmount, findMaxDepositRpc, findMaxWithdrawal, findMaxWithdrawalAmount, findMaxWithdrawalRpc, getMorphoBlueAddress, irmAdaptiveCurveAbi, metaMorphoAbi, morphoAbi };