@oydual31/more-vaults-sdk 0.1.2 → 0.1.3
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/react/index.cjs +1108 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +382 -0
- package/dist/react/index.d.ts +382 -0
- package/dist/react/index.js +1097 -0
- package/dist/react/index.js.map +1 -0
- package/dist/userHelpers-CZLB9oQ4.d.cts +286 -0
- package/dist/userHelpers-CZLB9oQ4.d.ts +286 -0
- package/dist/viem/index.d.cts +2 -284
- package/dist/viem/index.d.ts +2 -284
- package/package.json +26 -5
- package/src/react/index.ts +26 -0
- package/src/react/useAsyncRequestStatus.ts +36 -0
- package/src/react/useDepositSimple.ts +76 -0
- package/src/react/useLzFee.ts +27 -0
- package/src/react/useOmniDeposit.ts +97 -0
- package/src/react/useOmniRedeem.ts +96 -0
- package/src/react/useRedeemShares.ts +77 -0
- package/src/react/useSmartDeposit.ts +70 -0
- package/src/react/useUserPosition.ts +29 -0
- package/src/react/useVaultMetadata.ts +29 -0
- package/src/react/useVaultStatus.ts +34 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { Address, WalletClient, PublicClient } from 'viem';
|
|
2
|
+
|
|
3
|
+
type VaultMode = 'local' | 'cross-chain-oracle' | 'cross-chain-async' | 'paused' | 'full';
|
|
4
|
+
interface VaultStatus {
|
|
5
|
+
/** Vault operating mode — determines which SDK flow to use */
|
|
6
|
+
mode: VaultMode;
|
|
7
|
+
/** Which deposit function to call given the current configuration */
|
|
8
|
+
recommendedDepositFlow: 'depositSimple' | 'depositAsync' | 'mintAsync' | 'none';
|
|
9
|
+
/** Which redeem function to call given the current configuration */
|
|
10
|
+
recommendedRedeemFlow: 'redeemShares' | 'redeemAsync' | 'none';
|
|
11
|
+
isHub: boolean;
|
|
12
|
+
isPaused: boolean;
|
|
13
|
+
oracleAccountingEnabled: boolean;
|
|
14
|
+
/** address(0) means CCManager is not set — async flows will fail */
|
|
15
|
+
ccManager: Address;
|
|
16
|
+
/** address(0) means escrow is not configured in the registry */
|
|
17
|
+
escrow: Address;
|
|
18
|
+
withdrawalQueueEnabled: boolean;
|
|
19
|
+
/** Timelock duration in seconds (0 = no timelock) */
|
|
20
|
+
withdrawalTimelockSeconds: bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Remaining deposit capacity in underlying token decimals.
|
|
23
|
+
* `type(uint256).max` = no cap configured (unlimited).
|
|
24
|
+
* `0n` = vault is full — no more deposits accepted.
|
|
25
|
+
* If `depositAccessRestricted = true`, this value is `type(uint256).max` but
|
|
26
|
+
* deposits are still gated by whitelist or other access control.
|
|
27
|
+
*/
|
|
28
|
+
remainingDepositCapacity: bigint;
|
|
29
|
+
/**
|
|
30
|
+
* True when `maxDeposit(address(0))` reverted, indicating the vault uses
|
|
31
|
+
* whitelist or other access control to restrict who can deposit.
|
|
32
|
+
* Deposit flows will succeed only for addresses the vault operator has approved.
|
|
33
|
+
*/
|
|
34
|
+
depositAccessRestricted: boolean;
|
|
35
|
+
underlying: Address;
|
|
36
|
+
totalAssets: bigint;
|
|
37
|
+
totalSupply: bigint;
|
|
38
|
+
/** Vault share token decimals. Use this for display — never hardcode 18. */
|
|
39
|
+
decimals: number;
|
|
40
|
+
/**
|
|
41
|
+
* Price of 1 full share expressed in underlying token units.
|
|
42
|
+
* = convertToAssets(10^decimals). Grows over time as the vault earns yield.
|
|
43
|
+
*/
|
|
44
|
+
sharePrice: bigint;
|
|
45
|
+
/**
|
|
46
|
+
* Underlying token balance held directly on the hub chain.
|
|
47
|
+
* This is the only portion that can be paid out to redeeming users immediately.
|
|
48
|
+
* (= ERC-20.balanceOf(vault) on the hub)
|
|
49
|
+
*/
|
|
50
|
+
hubLiquidBalance: bigint;
|
|
51
|
+
/**
|
|
52
|
+
* Approximate value deployed to spoke chains (totalAssets − hubLiquidBalance).
|
|
53
|
+
* These funds are NOT immediately redeemable — the vault curator must
|
|
54
|
+
* call executeBridging to repatriate them before large redeems can succeed.
|
|
55
|
+
*/
|
|
56
|
+
spokesDeployedBalance: bigint;
|
|
57
|
+
/**
|
|
58
|
+
* Maximum assets that can be redeemed right now without curator intervention.
|
|
59
|
+
* - For hub vaults: equals `hubLiquidBalance` (only what the hub holds).
|
|
60
|
+
* - For local/oracle vaults: equals `totalAssets` (all assets are local).
|
|
61
|
+
* Attempting to redeem more than this will revert (R1) or be auto-refunded (R5).
|
|
62
|
+
*/
|
|
63
|
+
maxImmediateRedeemAssets: bigint;
|
|
64
|
+
/**
|
|
65
|
+
* Human-readable list of configuration problems that would cause transactions
|
|
66
|
+
* to fail. Empty array = vault is ready to use.
|
|
67
|
+
*/
|
|
68
|
+
issues: string[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Read the full configuration and operational status of a vault in a single
|
|
72
|
+
* multicall-friendly batch.
|
|
73
|
+
*
|
|
74
|
+
* Use this to:
|
|
75
|
+
* - Determine which SDK flow to use (`recommendedDepositFlow`)
|
|
76
|
+
* - Show a configuration checklist in an admin dashboard
|
|
77
|
+
* - Surface `issues` to the developer before any transaction
|
|
78
|
+
*
|
|
79
|
+
* @param publicClient Public client for reads
|
|
80
|
+
* @param vault Vault address (diamond proxy)
|
|
81
|
+
* @returns Full vault status snapshot
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const status = await getVaultStatus(publicClient, VAULT)
|
|
86
|
+
* if (status.issues.length) {
|
|
87
|
+
* console.warn('Vault misconfigured:', status.issues)
|
|
88
|
+
* }
|
|
89
|
+
* // Use recommended flow:
|
|
90
|
+
* if (status.recommendedDepositFlow === 'depositAsync') {
|
|
91
|
+
* await depositAsync(walletClient, publicClient, { vault: VAULT, escrow: status.escrow }, ...)
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
declare function getVaultStatus(publicClient: PublicClient, vault: Address): Promise<VaultStatus>;
|
|
96
|
+
/**
|
|
97
|
+
* Ensure the spender has sufficient ERC-20 allowance; approve if not.
|
|
98
|
+
*
|
|
99
|
+
* Checks the current allowance and only sends an approve transaction if
|
|
100
|
+
* the existing allowance is less than the required amount.
|
|
101
|
+
*
|
|
102
|
+
* @param walletClient Wallet client with account attached
|
|
103
|
+
* @param publicClient Public client for reads
|
|
104
|
+
* @param token ERC-20 token address
|
|
105
|
+
* @param spender Address to approve
|
|
106
|
+
* @param amount Minimum required allowance
|
|
107
|
+
*/
|
|
108
|
+
declare function ensureAllowance(walletClient: WalletClient, publicClient: PublicClient, token: Address, spender: Address, amount: bigint): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Quote the LayerZero native fee required for async vault actions.
|
|
111
|
+
*
|
|
112
|
+
* Call this before `depositAsync`, `mintAsync`, or `redeemAsync` to get the
|
|
113
|
+
* exact `lzFee` (msg.value) needed.
|
|
114
|
+
*
|
|
115
|
+
* @param publicClient Public client for reads
|
|
116
|
+
* @param vault Vault address (diamond proxy)
|
|
117
|
+
* @param extraOptions Optional LZ extra options bytes (default 0x)
|
|
118
|
+
* @returns Required native fee in wei
|
|
119
|
+
*/
|
|
120
|
+
declare function quoteLzFee(publicClient: PublicClient, vault: Address, extraOptions?: `0x${string}`): Promise<bigint>;
|
|
121
|
+
/**
|
|
122
|
+
* Check if a vault is operating in async mode (cross-chain hub with oracle OFF).
|
|
123
|
+
*
|
|
124
|
+
* When this returns `true`, deposits and redeems must use the async flows
|
|
125
|
+
* (D4/D5/R5) which go through `initVaultActionRequest`.
|
|
126
|
+
* When `false`, the vault either uses oracle-based accounting (sync) or is
|
|
127
|
+
* a single-chain vault.
|
|
128
|
+
*
|
|
129
|
+
* @param publicClient Public client for reads
|
|
130
|
+
* @param vault Vault address
|
|
131
|
+
* @returns `true` if the vault requires async cross-chain flows
|
|
132
|
+
*/
|
|
133
|
+
declare function isAsyncMode(publicClient: PublicClient, vault: Address): Promise<boolean>;
|
|
134
|
+
/**
|
|
135
|
+
* Poll for async request completion status.
|
|
136
|
+
*
|
|
137
|
+
* After calling an async flow (D4/D5/R5), use this to check whether the
|
|
138
|
+
* LZ callback has resolved and `executeRequest` has been called.
|
|
139
|
+
*
|
|
140
|
+
* @param publicClient Public client for reads
|
|
141
|
+
* @param vault Vault address
|
|
142
|
+
* @param guid Request GUID returned by the async flow
|
|
143
|
+
* @returns Whether the request is fulfilled and the finalization result
|
|
144
|
+
*/
|
|
145
|
+
declare function getAsyncRequestStatus(publicClient: PublicClient, vault: Address, guid: `0x${string}`): Promise<{
|
|
146
|
+
fulfilled: boolean;
|
|
147
|
+
finalized: boolean;
|
|
148
|
+
result: bigint;
|
|
149
|
+
}>;
|
|
150
|
+
|
|
151
|
+
interface UserPosition {
|
|
152
|
+
/** Vault share balance */
|
|
153
|
+
shares: bigint;
|
|
154
|
+
/** convertToAssets(shares) — what they'd get if they redeemed now */
|
|
155
|
+
estimatedAssets: bigint;
|
|
156
|
+
/** Price of 1 full share in underlying (convertToAssets(10n ** decimals)) */
|
|
157
|
+
sharePrice: bigint;
|
|
158
|
+
/** Vault decimals (for display) */
|
|
159
|
+
decimals: number;
|
|
160
|
+
pendingWithdrawal: {
|
|
161
|
+
shares: bigint;
|
|
162
|
+
timelockEndsAt: bigint;
|
|
163
|
+
/** block.timestamp >= timelockEndsAt (or timelockEndsAt === 0n) */
|
|
164
|
+
canRedeemNow: boolean;
|
|
165
|
+
} | null;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Read the user's current position in the vault.
|
|
169
|
+
*
|
|
170
|
+
* @param publicClient Public client for reads
|
|
171
|
+
* @param vault Vault address (diamond proxy)
|
|
172
|
+
* @param user User wallet address
|
|
173
|
+
* @returns Full user position snapshot
|
|
174
|
+
*/
|
|
175
|
+
declare function getUserPosition(publicClient: PublicClient, vault: Address, user: Address): Promise<UserPosition>;
|
|
176
|
+
/**
|
|
177
|
+
* Preview how many shares a given asset amount would mint.
|
|
178
|
+
*
|
|
179
|
+
* @param publicClient Public client for reads
|
|
180
|
+
* @param vault Vault address
|
|
181
|
+
* @param assets Amount of underlying tokens to deposit
|
|
182
|
+
* @returns Estimated shares to be minted
|
|
183
|
+
*/
|
|
184
|
+
declare function previewDeposit(publicClient: PublicClient, vault: Address, assets: bigint): Promise<bigint>;
|
|
185
|
+
/**
|
|
186
|
+
* Preview how many underlying assets a given share amount would redeem.
|
|
187
|
+
*
|
|
188
|
+
* @param publicClient Public client for reads
|
|
189
|
+
* @param vault Vault address
|
|
190
|
+
* @param shares Amount of vault shares to redeem
|
|
191
|
+
* @returns Estimated assets to be returned
|
|
192
|
+
*/
|
|
193
|
+
declare function previewRedeem(publicClient: PublicClient, vault: Address, shares: bigint): Promise<bigint>;
|
|
194
|
+
type DepositBlockReason = 'paused' | 'capacity-full' | 'not-whitelisted' | 'ok';
|
|
195
|
+
interface DepositEligibility {
|
|
196
|
+
allowed: boolean;
|
|
197
|
+
reason: DepositBlockReason;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check whether a user is eligible to deposit into the vault right now.
|
|
201
|
+
*
|
|
202
|
+
* @param publicClient Public client for reads
|
|
203
|
+
* @param vault Vault address
|
|
204
|
+
* @param user User wallet address
|
|
205
|
+
* @returns Eligibility result with reason
|
|
206
|
+
*/
|
|
207
|
+
declare function canDeposit(publicClient: PublicClient, vault: Address, user: Address): Promise<DepositEligibility>;
|
|
208
|
+
interface VaultMetadata {
|
|
209
|
+
name: string;
|
|
210
|
+
symbol: string;
|
|
211
|
+
decimals: number;
|
|
212
|
+
underlying: Address;
|
|
213
|
+
underlyingSymbol: string;
|
|
214
|
+
underlyingDecimals: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Read display metadata for a vault and its underlying token.
|
|
218
|
+
*
|
|
219
|
+
* @param publicClient Public client for reads
|
|
220
|
+
* @param vault Vault address
|
|
221
|
+
* @returns Vault and underlying token metadata
|
|
222
|
+
*/
|
|
223
|
+
declare function getVaultMetadata(publicClient: PublicClient, vault: Address): Promise<VaultMetadata>;
|
|
224
|
+
type AsyncRequestStatus = 'pending' | 'ready-to-execute' | 'completed' | 'refunded';
|
|
225
|
+
interface AsyncRequestStatusInfo {
|
|
226
|
+
status: AsyncRequestStatus;
|
|
227
|
+
/** Human-readable description */
|
|
228
|
+
label: string;
|
|
229
|
+
/** Shares minted or assets returned (0 if still pending) */
|
|
230
|
+
result: bigint;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get the human-readable status of an async cross-chain request.
|
|
234
|
+
*
|
|
235
|
+
* @param publicClient Public client for reads
|
|
236
|
+
* @param vault Vault address
|
|
237
|
+
* @param guid Request GUID returned by depositAsync / mintAsync / redeemAsync
|
|
238
|
+
* @returns Status info with label and result
|
|
239
|
+
*/
|
|
240
|
+
declare function getAsyncRequestStatusLabel(publicClient: PublicClient, vault: Address, guid: `0x${string}`): Promise<AsyncRequestStatusInfo>;
|
|
241
|
+
interface UserBalances {
|
|
242
|
+
/** Vault shares the user holds */
|
|
243
|
+
shareBalance: bigint;
|
|
244
|
+
/** Underlying token balance in wallet (for deposit input) */
|
|
245
|
+
underlyingBalance: bigint;
|
|
246
|
+
/** convertToAssets(shareBalance) — vault position value */
|
|
247
|
+
estimatedAssets: bigint;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Read the user's token balances relevant to a vault.
|
|
251
|
+
*
|
|
252
|
+
* @param publicClient Public client for reads
|
|
253
|
+
* @param vault Vault address
|
|
254
|
+
* @param user User wallet address
|
|
255
|
+
* @returns Share balance, underlying wallet balance, and estimated assets
|
|
256
|
+
*/
|
|
257
|
+
declare function getUserBalances(publicClient: PublicClient, vault: Address, user: Address): Promise<UserBalances>;
|
|
258
|
+
interface MaxWithdrawable {
|
|
259
|
+
/** How many shares can be redeemed right now */
|
|
260
|
+
shares: bigint;
|
|
261
|
+
/** How many underlying assets that corresponds to */
|
|
262
|
+
assets: bigint;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Calculate the maximum amount a user can withdraw from a vault right now.
|
|
266
|
+
*
|
|
267
|
+
* For hub vaults without oracle accounting, this is limited by hub liquidity.
|
|
268
|
+
* For local and oracle vaults, all assets are immediately redeemable.
|
|
269
|
+
*
|
|
270
|
+
* @param publicClient Public client for reads
|
|
271
|
+
* @param vault Vault address
|
|
272
|
+
* @param user User wallet address
|
|
273
|
+
* @returns Maximum withdrawable shares and assets
|
|
274
|
+
*/
|
|
275
|
+
declare function getMaxWithdrawable(publicClient: PublicClient, vault: Address, user: Address): Promise<MaxWithdrawable>;
|
|
276
|
+
type VaultSummary = VaultStatus & VaultMetadata;
|
|
277
|
+
/**
|
|
278
|
+
* Get a combined snapshot of vault status and metadata in one call.
|
|
279
|
+
*
|
|
280
|
+
* @param publicClient Public client for reads
|
|
281
|
+
* @param vault Vault address
|
|
282
|
+
* @returns Merged VaultStatus and VaultMetadata
|
|
283
|
+
*/
|
|
284
|
+
declare function getVaultSummary(publicClient: PublicClient, vault: Address): Promise<VaultSummary>;
|
|
285
|
+
|
|
286
|
+
export { type AsyncRequestStatus as A, type DepositBlockReason as D, type MaxWithdrawable as M, type UserBalances as U, type VaultMetadata as V, type AsyncRequestStatusInfo as a, type DepositEligibility as b, type UserPosition as c, type VaultMode as d, type VaultStatus as e, type VaultSummary as f, canDeposit as g, ensureAllowance as h, getAsyncRequestStatus as i, getAsyncRequestStatusLabel as j, getMaxWithdrawable as k, getUserBalances as l, getUserPosition as m, getVaultMetadata as n, getVaultStatus as o, getVaultSummary as p, isAsyncMode as q, previewDeposit as r, previewRedeem as s, quoteLzFee as t };
|
package/dist/viem/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Hash, Address, WalletClient, PublicClient } from 'viem';
|
|
2
2
|
export { PublicClient as SdkPublicClient } from 'viem';
|
|
3
|
+
export { A as AsyncRequestStatus, a as AsyncRequestStatusInfo, D as DepositBlockReason, b as DepositEligibility, M as MaxWithdrawable, U as UserBalances, c as UserPosition, V as VaultMetadata, d as VaultMode, e as VaultStatus, f as VaultSummary, g as canDeposit, h as ensureAllowance, i as getAsyncRequestStatus, j as getAsyncRequestStatusLabel, k as getMaxWithdrawable, l as getUserBalances, m as getUserPosition, n as getVaultMetadata, o as getVaultStatus, p as getVaultSummary, q as isAsyncMode, r as previewDeposit, s as previewRedeem, t as quoteLzFee } from '../userHelpers-CZLB9oQ4.cjs';
|
|
3
4
|
|
|
4
5
|
/** EVM Chain IDs for chains supported by MoreVaults */
|
|
5
6
|
declare const CHAIN_IDS: {
|
|
@@ -978,154 +979,6 @@ declare function bridgeSharesToHub(walletClient: WalletClient, publicClient: Pub
|
|
|
978
979
|
txHash: Hash;
|
|
979
980
|
}>;
|
|
980
981
|
|
|
981
|
-
type VaultMode = 'local' | 'cross-chain-oracle' | 'cross-chain-async' | 'paused' | 'full';
|
|
982
|
-
interface VaultStatus {
|
|
983
|
-
/** Vault operating mode — determines which SDK flow to use */
|
|
984
|
-
mode: VaultMode;
|
|
985
|
-
/** Which deposit function to call given the current configuration */
|
|
986
|
-
recommendedDepositFlow: 'depositSimple' | 'depositAsync' | 'mintAsync' | 'none';
|
|
987
|
-
/** Which redeem function to call given the current configuration */
|
|
988
|
-
recommendedRedeemFlow: 'redeemShares' | 'redeemAsync' | 'none';
|
|
989
|
-
isHub: boolean;
|
|
990
|
-
isPaused: boolean;
|
|
991
|
-
oracleAccountingEnabled: boolean;
|
|
992
|
-
/** address(0) means CCManager is not set — async flows will fail */
|
|
993
|
-
ccManager: Address;
|
|
994
|
-
/** address(0) means escrow is not configured in the registry */
|
|
995
|
-
escrow: Address;
|
|
996
|
-
withdrawalQueueEnabled: boolean;
|
|
997
|
-
/** Timelock duration in seconds (0 = no timelock) */
|
|
998
|
-
withdrawalTimelockSeconds: bigint;
|
|
999
|
-
/**
|
|
1000
|
-
* Remaining deposit capacity in underlying token decimals.
|
|
1001
|
-
* `type(uint256).max` = no cap configured (unlimited).
|
|
1002
|
-
* `0n` = vault is full — no more deposits accepted.
|
|
1003
|
-
* If `depositAccessRestricted = true`, this value is `type(uint256).max` but
|
|
1004
|
-
* deposits are still gated by whitelist or other access control.
|
|
1005
|
-
*/
|
|
1006
|
-
remainingDepositCapacity: bigint;
|
|
1007
|
-
/**
|
|
1008
|
-
* True when `maxDeposit(address(0))` reverted, indicating the vault uses
|
|
1009
|
-
* whitelist or other access control to restrict who can deposit.
|
|
1010
|
-
* Deposit flows will succeed only for addresses the vault operator has approved.
|
|
1011
|
-
*/
|
|
1012
|
-
depositAccessRestricted: boolean;
|
|
1013
|
-
underlying: Address;
|
|
1014
|
-
totalAssets: bigint;
|
|
1015
|
-
totalSupply: bigint;
|
|
1016
|
-
/** Vault share token decimals. Use this for display — never hardcode 18. */
|
|
1017
|
-
decimals: number;
|
|
1018
|
-
/**
|
|
1019
|
-
* Price of 1 full share expressed in underlying token units.
|
|
1020
|
-
* = convertToAssets(10^decimals). Grows over time as the vault earns yield.
|
|
1021
|
-
*/
|
|
1022
|
-
sharePrice: bigint;
|
|
1023
|
-
/**
|
|
1024
|
-
* Underlying token balance held directly on the hub chain.
|
|
1025
|
-
* This is the only portion that can be paid out to redeeming users immediately.
|
|
1026
|
-
* (= ERC-20.balanceOf(vault) on the hub)
|
|
1027
|
-
*/
|
|
1028
|
-
hubLiquidBalance: bigint;
|
|
1029
|
-
/**
|
|
1030
|
-
* Approximate value deployed to spoke chains (totalAssets − hubLiquidBalance).
|
|
1031
|
-
* These funds are NOT immediately redeemable — the vault curator must
|
|
1032
|
-
* call executeBridging to repatriate them before large redeems can succeed.
|
|
1033
|
-
*/
|
|
1034
|
-
spokesDeployedBalance: bigint;
|
|
1035
|
-
/**
|
|
1036
|
-
* Maximum assets that can be redeemed right now without curator intervention.
|
|
1037
|
-
* - For hub vaults: equals `hubLiquidBalance` (only what the hub holds).
|
|
1038
|
-
* - For local/oracle vaults: equals `totalAssets` (all assets are local).
|
|
1039
|
-
* Attempting to redeem more than this will revert (R1) or be auto-refunded (R5).
|
|
1040
|
-
*/
|
|
1041
|
-
maxImmediateRedeemAssets: bigint;
|
|
1042
|
-
/**
|
|
1043
|
-
* Human-readable list of configuration problems that would cause transactions
|
|
1044
|
-
* to fail. Empty array = vault is ready to use.
|
|
1045
|
-
*/
|
|
1046
|
-
issues: string[];
|
|
1047
|
-
}
|
|
1048
|
-
/**
|
|
1049
|
-
* Read the full configuration and operational status of a vault in a single
|
|
1050
|
-
* multicall-friendly batch.
|
|
1051
|
-
*
|
|
1052
|
-
* Use this to:
|
|
1053
|
-
* - Determine which SDK flow to use (`recommendedDepositFlow`)
|
|
1054
|
-
* - Show a configuration checklist in an admin dashboard
|
|
1055
|
-
* - Surface `issues` to the developer before any transaction
|
|
1056
|
-
*
|
|
1057
|
-
* @param publicClient Public client for reads
|
|
1058
|
-
* @param vault Vault address (diamond proxy)
|
|
1059
|
-
* @returns Full vault status snapshot
|
|
1060
|
-
*
|
|
1061
|
-
* @example
|
|
1062
|
-
* ```ts
|
|
1063
|
-
* const status = await getVaultStatus(publicClient, VAULT)
|
|
1064
|
-
* if (status.issues.length) {
|
|
1065
|
-
* console.warn('Vault misconfigured:', status.issues)
|
|
1066
|
-
* }
|
|
1067
|
-
* // Use recommended flow:
|
|
1068
|
-
* if (status.recommendedDepositFlow === 'depositAsync') {
|
|
1069
|
-
* await depositAsync(walletClient, publicClient, { vault: VAULT, escrow: status.escrow }, ...)
|
|
1070
|
-
* }
|
|
1071
|
-
* ```
|
|
1072
|
-
*/
|
|
1073
|
-
declare function getVaultStatus(publicClient: PublicClient, vault: Address): Promise<VaultStatus>;
|
|
1074
|
-
/**
|
|
1075
|
-
* Ensure the spender has sufficient ERC-20 allowance; approve if not.
|
|
1076
|
-
*
|
|
1077
|
-
* Checks the current allowance and only sends an approve transaction if
|
|
1078
|
-
* the existing allowance is less than the required amount.
|
|
1079
|
-
*
|
|
1080
|
-
* @param walletClient Wallet client with account attached
|
|
1081
|
-
* @param publicClient Public client for reads
|
|
1082
|
-
* @param token ERC-20 token address
|
|
1083
|
-
* @param spender Address to approve
|
|
1084
|
-
* @param amount Minimum required allowance
|
|
1085
|
-
*/
|
|
1086
|
-
declare function ensureAllowance(walletClient: WalletClient, publicClient: PublicClient, token: Address, spender: Address, amount: bigint): Promise<void>;
|
|
1087
|
-
/**
|
|
1088
|
-
* Quote the LayerZero native fee required for async vault actions.
|
|
1089
|
-
*
|
|
1090
|
-
* Call this before `depositAsync`, `mintAsync`, or `redeemAsync` to get the
|
|
1091
|
-
* exact `lzFee` (msg.value) needed.
|
|
1092
|
-
*
|
|
1093
|
-
* @param publicClient Public client for reads
|
|
1094
|
-
* @param vault Vault address (diamond proxy)
|
|
1095
|
-
* @param extraOptions Optional LZ extra options bytes (default 0x)
|
|
1096
|
-
* @returns Required native fee in wei
|
|
1097
|
-
*/
|
|
1098
|
-
declare function quoteLzFee(publicClient: PublicClient, vault: Address, extraOptions?: `0x${string}`): Promise<bigint>;
|
|
1099
|
-
/**
|
|
1100
|
-
* Check if a vault is operating in async mode (cross-chain hub with oracle OFF).
|
|
1101
|
-
*
|
|
1102
|
-
* When this returns `true`, deposits and redeems must use the async flows
|
|
1103
|
-
* (D4/D5/R5) which go through `initVaultActionRequest`.
|
|
1104
|
-
* When `false`, the vault either uses oracle-based accounting (sync) or is
|
|
1105
|
-
* a single-chain vault.
|
|
1106
|
-
*
|
|
1107
|
-
* @param publicClient Public client for reads
|
|
1108
|
-
* @param vault Vault address
|
|
1109
|
-
* @returns `true` if the vault requires async cross-chain flows
|
|
1110
|
-
*/
|
|
1111
|
-
declare function isAsyncMode(publicClient: PublicClient, vault: Address): Promise<boolean>;
|
|
1112
|
-
/**
|
|
1113
|
-
* Poll for async request completion status.
|
|
1114
|
-
*
|
|
1115
|
-
* After calling an async flow (D4/D5/R5), use this to check whether the
|
|
1116
|
-
* LZ callback has resolved and `executeRequest` has been called.
|
|
1117
|
-
*
|
|
1118
|
-
* @param publicClient Public client for reads
|
|
1119
|
-
* @param vault Vault address
|
|
1120
|
-
* @param guid Request GUID returned by the async flow
|
|
1121
|
-
* @returns Whether the request is fulfilled and the finalization result
|
|
1122
|
-
*/
|
|
1123
|
-
declare function getAsyncRequestStatus(publicClient: PublicClient, vault: Address, guid: `0x${string}`): Promise<{
|
|
1124
|
-
fulfilled: boolean;
|
|
1125
|
-
finalized: boolean;
|
|
1126
|
-
result: bigint;
|
|
1127
|
-
}>;
|
|
1128
|
-
|
|
1129
982
|
/**
|
|
1130
983
|
* Pre-flight validation helpers for MoreVaults SDK flows.
|
|
1131
984
|
*
|
|
@@ -1184,141 +1037,6 @@ declare function preflightRedeemLiquidity(publicClient: PublicClient, vault: Add
|
|
|
1184
1037
|
*/
|
|
1185
1038
|
declare function preflightSync(publicClient: PublicClient, vault: Address): Promise<void>;
|
|
1186
1039
|
|
|
1187
|
-
interface UserPosition {
|
|
1188
|
-
/** Vault share balance */
|
|
1189
|
-
shares: bigint;
|
|
1190
|
-
/** convertToAssets(shares) — what they'd get if they redeemed now */
|
|
1191
|
-
estimatedAssets: bigint;
|
|
1192
|
-
/** Price of 1 full share in underlying (convertToAssets(10n ** decimals)) */
|
|
1193
|
-
sharePrice: bigint;
|
|
1194
|
-
/** Vault decimals (for display) */
|
|
1195
|
-
decimals: number;
|
|
1196
|
-
pendingWithdrawal: {
|
|
1197
|
-
shares: bigint;
|
|
1198
|
-
timelockEndsAt: bigint;
|
|
1199
|
-
/** block.timestamp >= timelockEndsAt (or timelockEndsAt === 0n) */
|
|
1200
|
-
canRedeemNow: boolean;
|
|
1201
|
-
} | null;
|
|
1202
|
-
}
|
|
1203
|
-
/**
|
|
1204
|
-
* Read the user's current position in the vault.
|
|
1205
|
-
*
|
|
1206
|
-
* @param publicClient Public client for reads
|
|
1207
|
-
* @param vault Vault address (diamond proxy)
|
|
1208
|
-
* @param user User wallet address
|
|
1209
|
-
* @returns Full user position snapshot
|
|
1210
|
-
*/
|
|
1211
|
-
declare function getUserPosition(publicClient: PublicClient, vault: Address, user: Address): Promise<UserPosition>;
|
|
1212
|
-
/**
|
|
1213
|
-
* Preview how many shares a given asset amount would mint.
|
|
1214
|
-
*
|
|
1215
|
-
* @param publicClient Public client for reads
|
|
1216
|
-
* @param vault Vault address
|
|
1217
|
-
* @param assets Amount of underlying tokens to deposit
|
|
1218
|
-
* @returns Estimated shares to be minted
|
|
1219
|
-
*/
|
|
1220
|
-
declare function previewDeposit(publicClient: PublicClient, vault: Address, assets: bigint): Promise<bigint>;
|
|
1221
|
-
/**
|
|
1222
|
-
* Preview how many underlying assets a given share amount would redeem.
|
|
1223
|
-
*
|
|
1224
|
-
* @param publicClient Public client for reads
|
|
1225
|
-
* @param vault Vault address
|
|
1226
|
-
* @param shares Amount of vault shares to redeem
|
|
1227
|
-
* @returns Estimated assets to be returned
|
|
1228
|
-
*/
|
|
1229
|
-
declare function previewRedeem(publicClient: PublicClient, vault: Address, shares: bigint): Promise<bigint>;
|
|
1230
|
-
type DepositBlockReason = 'paused' | 'capacity-full' | 'not-whitelisted' | 'ok';
|
|
1231
|
-
interface DepositEligibility {
|
|
1232
|
-
allowed: boolean;
|
|
1233
|
-
reason: DepositBlockReason;
|
|
1234
|
-
}
|
|
1235
|
-
/**
|
|
1236
|
-
* Check whether a user is eligible to deposit into the vault right now.
|
|
1237
|
-
*
|
|
1238
|
-
* @param publicClient Public client for reads
|
|
1239
|
-
* @param vault Vault address
|
|
1240
|
-
* @param user User wallet address
|
|
1241
|
-
* @returns Eligibility result with reason
|
|
1242
|
-
*/
|
|
1243
|
-
declare function canDeposit(publicClient: PublicClient, vault: Address, user: Address): Promise<DepositEligibility>;
|
|
1244
|
-
interface VaultMetadata {
|
|
1245
|
-
name: string;
|
|
1246
|
-
symbol: string;
|
|
1247
|
-
decimals: number;
|
|
1248
|
-
underlying: Address;
|
|
1249
|
-
underlyingSymbol: string;
|
|
1250
|
-
underlyingDecimals: number;
|
|
1251
|
-
}
|
|
1252
|
-
/**
|
|
1253
|
-
* Read display metadata for a vault and its underlying token.
|
|
1254
|
-
*
|
|
1255
|
-
* @param publicClient Public client for reads
|
|
1256
|
-
* @param vault Vault address
|
|
1257
|
-
* @returns Vault and underlying token metadata
|
|
1258
|
-
*/
|
|
1259
|
-
declare function getVaultMetadata(publicClient: PublicClient, vault: Address): Promise<VaultMetadata>;
|
|
1260
|
-
type AsyncRequestStatus = 'pending' | 'ready-to-execute' | 'completed' | 'refunded';
|
|
1261
|
-
interface AsyncRequestStatusInfo {
|
|
1262
|
-
status: AsyncRequestStatus;
|
|
1263
|
-
/** Human-readable description */
|
|
1264
|
-
label: string;
|
|
1265
|
-
/** Shares minted or assets returned (0 if still pending) */
|
|
1266
|
-
result: bigint;
|
|
1267
|
-
}
|
|
1268
|
-
/**
|
|
1269
|
-
* Get the human-readable status of an async cross-chain request.
|
|
1270
|
-
*
|
|
1271
|
-
* @param publicClient Public client for reads
|
|
1272
|
-
* @param vault Vault address
|
|
1273
|
-
* @param guid Request GUID returned by depositAsync / mintAsync / redeemAsync
|
|
1274
|
-
* @returns Status info with label and result
|
|
1275
|
-
*/
|
|
1276
|
-
declare function getAsyncRequestStatusLabel(publicClient: PublicClient, vault: Address, guid: `0x${string}`): Promise<AsyncRequestStatusInfo>;
|
|
1277
|
-
interface UserBalances {
|
|
1278
|
-
/** Vault shares the user holds */
|
|
1279
|
-
shareBalance: bigint;
|
|
1280
|
-
/** Underlying token balance in wallet (for deposit input) */
|
|
1281
|
-
underlyingBalance: bigint;
|
|
1282
|
-
/** convertToAssets(shareBalance) — vault position value */
|
|
1283
|
-
estimatedAssets: bigint;
|
|
1284
|
-
}
|
|
1285
|
-
/**
|
|
1286
|
-
* Read the user's token balances relevant to a vault.
|
|
1287
|
-
*
|
|
1288
|
-
* @param publicClient Public client for reads
|
|
1289
|
-
* @param vault Vault address
|
|
1290
|
-
* @param user User wallet address
|
|
1291
|
-
* @returns Share balance, underlying wallet balance, and estimated assets
|
|
1292
|
-
*/
|
|
1293
|
-
declare function getUserBalances(publicClient: PublicClient, vault: Address, user: Address): Promise<UserBalances>;
|
|
1294
|
-
interface MaxWithdrawable {
|
|
1295
|
-
/** How many shares can be redeemed right now */
|
|
1296
|
-
shares: bigint;
|
|
1297
|
-
/** How many underlying assets that corresponds to */
|
|
1298
|
-
assets: bigint;
|
|
1299
|
-
}
|
|
1300
|
-
/**
|
|
1301
|
-
* Calculate the maximum amount a user can withdraw from a vault right now.
|
|
1302
|
-
*
|
|
1303
|
-
* For hub vaults without oracle accounting, this is limited by hub liquidity.
|
|
1304
|
-
* For local and oracle vaults, all assets are immediately redeemable.
|
|
1305
|
-
*
|
|
1306
|
-
* @param publicClient Public client for reads
|
|
1307
|
-
* @param vault Vault address
|
|
1308
|
-
* @param user User wallet address
|
|
1309
|
-
* @returns Maximum withdrawable shares and assets
|
|
1310
|
-
*/
|
|
1311
|
-
declare function getMaxWithdrawable(publicClient: PublicClient, vault: Address, user: Address): Promise<MaxWithdrawable>;
|
|
1312
|
-
type VaultSummary = VaultStatus & VaultMetadata;
|
|
1313
|
-
/**
|
|
1314
|
-
* Get a combined snapshot of vault status and metadata in one call.
|
|
1315
|
-
*
|
|
1316
|
-
* @param publicClient Public client for reads
|
|
1317
|
-
* @param vault Vault address
|
|
1318
|
-
* @returns Merged VaultStatus and VaultMetadata
|
|
1319
|
-
*/
|
|
1320
|
-
declare function getVaultSummary(publicClient: PublicClient, vault: Address): Promise<VaultSummary>;
|
|
1321
|
-
|
|
1322
1040
|
/**
|
|
1323
1041
|
* Cast a wagmi PublicClient to the SDK's expected type.
|
|
1324
1042
|
* Use this in React components to avoid `as any` casts:
|
|
@@ -1333,4 +1051,4 @@ declare function getVaultSummary(publicClient: PublicClient, vault: Address): Pr
|
|
|
1333
1051
|
*/
|
|
1334
1052
|
declare function asSdkClient(client: unknown): PublicClient;
|
|
1335
1053
|
|
|
1336
|
-
export { ActionType, type ActionTypeValue, type AsyncRequestResult,
|
|
1054
|
+
export { ActionType, type ActionTypeValue, type AsyncRequestResult, BRIDGE_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CapacityFullError, type CrossChainRequestInfo, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_EIDS, METADATA_ABI, MissingEscrowAddressError, MoreVaultsError, NotHubVaultError, NotWhitelistedError, OFT_ABI, type RedeemResult, VAULT_ABI, type VaultAddresses, VaultPausedError, WrongChainError, asSdkClient, bridgeSharesToHub, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, getWithdrawalRequest, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSync, quoteDepositFromSpokeFee, redeemAsync, redeemShares, requestRedeem, smartDeposit, withdrawAssets };
|