@stablechain/sdk 0.1.0 → 1.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.
- package/dist/index.cjs +577 -333
- package/dist/index.d.cts +190 -8
- package/dist/index.d.ts +190 -8
- package/dist/index.js +586 -342
- package/package.json +12 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Account, Transport, WalletClient, Address, BaseError } from 'viem';
|
|
2
2
|
|
|
3
|
+
interface EarnConfig {
|
|
4
|
+
/** MetaMorpho V2 vault address */
|
|
5
|
+
vault: string;
|
|
6
|
+
}
|
|
3
7
|
interface StableConfig {
|
|
4
8
|
/** Target network — defaults to Network.Mainnet */
|
|
5
9
|
network?: Network;
|
|
@@ -11,6 +15,8 @@ interface StableConfig {
|
|
|
11
15
|
transport?: Transport;
|
|
12
16
|
/** Pre-configured viem WalletClient — takes precedence over account/transport. */
|
|
13
17
|
walletClient?: WalletClient;
|
|
18
|
+
/** Earn (Morpho V2 vault) configuration — required to use stable.earn.* methods. */
|
|
19
|
+
earn?: EarnConfig;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* Unified result for transfer, bridge, and swap.
|
|
@@ -82,9 +88,6 @@ declare enum Network {
|
|
|
82
88
|
interface BridgeQuote {
|
|
83
89
|
/** Estimated output amount on the destination chain */
|
|
84
90
|
toAmount?: number;
|
|
85
|
-
/** LayerZero native fee — only present for USDT0→USDT0 routes */
|
|
86
|
-
nativeFee?: bigint;
|
|
87
|
-
lzTokenFee?: bigint;
|
|
88
91
|
}
|
|
89
92
|
interface BridgeParams {
|
|
90
93
|
fromChain: Chain;
|
|
@@ -98,9 +101,149 @@ interface BridgeParams {
|
|
|
98
101
|
fromDecimals?: number;
|
|
99
102
|
/** Recipient address — defaults to the signer */
|
|
100
103
|
recipient?: string;
|
|
101
|
-
/** Pre-fetched quote from quoteBridge() — skips the
|
|
104
|
+
/** Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to bridge() */
|
|
102
105
|
quote?: BridgeQuote;
|
|
103
106
|
}
|
|
107
|
+
interface EarnDepositParams {
|
|
108
|
+
/** Amount of underlying assets to deposit (human-readable) */
|
|
109
|
+
amount: number;
|
|
110
|
+
/** Vault address — overrides the vault set in StableConfig. Required when using bulkDeposit across multiple vaults. */
|
|
111
|
+
vault?: string;
|
|
112
|
+
/** Underlying asset decimals — fetched on-chain if omitted */
|
|
113
|
+
tokenDecimals?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Slippage tolerance as a decimal (e.g. 0.003 = 0.3%).
|
|
116
|
+
* Defaults to Morpho's built-in default (0.03%).
|
|
117
|
+
*/
|
|
118
|
+
slippageTolerance?: number;
|
|
119
|
+
/** Deduplication key: if an operation with this key is already in flight, the same Promise is returned. */
|
|
120
|
+
idempotencyKey?: string;
|
|
121
|
+
}
|
|
122
|
+
interface EarnWithdrawParams {
|
|
123
|
+
/** Amount of underlying assets to withdraw (human-readable) */
|
|
124
|
+
amount: number;
|
|
125
|
+
/** Underlying asset decimals — fetched on-chain if omitted */
|
|
126
|
+
tokenDecimals?: number;
|
|
127
|
+
/** Deduplication key */
|
|
128
|
+
idempotencyKey?: string;
|
|
129
|
+
}
|
|
130
|
+
interface EarnRedeemParams {
|
|
131
|
+
/** Number of vault shares to redeem (human-readable, uses vault's share decimals) */
|
|
132
|
+
shares: number;
|
|
133
|
+
/** Vault share decimals — fetched on-chain if omitted */
|
|
134
|
+
shareDecimals?: number;
|
|
135
|
+
/** Deduplication key */
|
|
136
|
+
idempotencyKey?: string;
|
|
137
|
+
}
|
|
138
|
+
interface EarnResult {
|
|
139
|
+
txHash: string;
|
|
140
|
+
idempotencyKey?: string;
|
|
141
|
+
}
|
|
142
|
+
type BulkEarnResultItem = {
|
|
143
|
+
status: "fulfilled";
|
|
144
|
+
txHash: string;
|
|
145
|
+
vault?: string;
|
|
146
|
+
idempotencyKey?: string;
|
|
147
|
+
} | {
|
|
148
|
+
status: "rejected";
|
|
149
|
+
error: string;
|
|
150
|
+
vault?: string;
|
|
151
|
+
idempotencyKey?: string;
|
|
152
|
+
};
|
|
153
|
+
interface BulkEarnResult {
|
|
154
|
+
results: BulkEarnResultItem[];
|
|
155
|
+
/** Number of deposits that succeeded */
|
|
156
|
+
succeeded: number;
|
|
157
|
+
/** Number of deposits that failed */
|
|
158
|
+
failed: number;
|
|
159
|
+
idempotencyKey?: string;
|
|
160
|
+
}
|
|
161
|
+
interface BulkDepositOptions {
|
|
162
|
+
/** Batch-level deduplication key — if this batch is already in flight, the same Promise is returned. */
|
|
163
|
+
idempotencyKey?: string;
|
|
164
|
+
/**
|
|
165
|
+
* When true, the batch halts on the first failure and rejects.
|
|
166
|
+
* When false (default), all deposits are attempted and partial results are returned.
|
|
167
|
+
*/
|
|
168
|
+
stopOnError?: boolean;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A single adapter position to forcibly deallocate before a force withdraw/redeem.
|
|
172
|
+
* `amount` is in underlying asset units (human-readable).
|
|
173
|
+
* `marketParams` is required only for Morpho Blue market adapters; omit for vault adapters.
|
|
174
|
+
*/
|
|
175
|
+
interface ForceDeallocation {
|
|
176
|
+
adapter: string;
|
|
177
|
+
amount: number;
|
|
178
|
+
marketParams?: {
|
|
179
|
+
loanToken: string;
|
|
180
|
+
collateralToken: string;
|
|
181
|
+
oracle: string;
|
|
182
|
+
irm: string;
|
|
183
|
+
/** LLTV scaled by WAD (1e18) */
|
|
184
|
+
lltv: bigint;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
interface ForceWithdrawParams {
|
|
188
|
+
/** Amount of underlying assets to withdraw (human-readable) */
|
|
189
|
+
amount: number;
|
|
190
|
+
/** Underlying asset decimals — fetched on-chain if omitted */
|
|
191
|
+
tokenDecimals?: number;
|
|
192
|
+
/** Adapter positions to deallocate before the withdrawal */
|
|
193
|
+
deallocations: ForceDeallocation[];
|
|
194
|
+
/** Deduplication key */
|
|
195
|
+
idempotencyKey?: string;
|
|
196
|
+
}
|
|
197
|
+
interface ForceRedeemParams {
|
|
198
|
+
/** Number of vault shares to redeem (human-readable) */
|
|
199
|
+
shares: number;
|
|
200
|
+
/** Vault share decimals — fetched on-chain if omitted */
|
|
201
|
+
shareDecimals?: number;
|
|
202
|
+
/** Underlying asset decimals for deallocation amounts — fetched on-chain if omitted */
|
|
203
|
+
tokenDecimals?: number;
|
|
204
|
+
/** Adapter positions to deallocate before the redemption */
|
|
205
|
+
deallocations: ForceDeallocation[];
|
|
206
|
+
/** Deduplication key */
|
|
207
|
+
idempotencyKey?: string;
|
|
208
|
+
}
|
|
209
|
+
interface VaultPosition {
|
|
210
|
+
/** Raw vault share balance */
|
|
211
|
+
shares: bigint;
|
|
212
|
+
/** Human-readable share balance (shares formatted by shareDecimals) */
|
|
213
|
+
sharesFormatted: number;
|
|
214
|
+
/** Vault share token decimals */
|
|
215
|
+
shareDecimals: number;
|
|
216
|
+
/** Asset value of shares (human-readable) */
|
|
217
|
+
assets: number;
|
|
218
|
+
/** Underlying asset decimals */
|
|
219
|
+
tokenDecimals: number;
|
|
220
|
+
/** Underlying asset contract address */
|
|
221
|
+
assetAddress: string;
|
|
222
|
+
}
|
|
223
|
+
interface YieldPreview {
|
|
224
|
+
/** Expected yield over the period, in asset units (human-readable) */
|
|
225
|
+
projectedYield: number;
|
|
226
|
+
/** Annual percentage yield as a decimal (e.g. 0.05 = 5%) */
|
|
227
|
+
apy: number;
|
|
228
|
+
horizonDays: number;
|
|
229
|
+
}
|
|
230
|
+
interface WithdrawStatus {
|
|
231
|
+
/** True when the full amount can be withdrawn from idle vault liquidity immediately */
|
|
232
|
+
isInstant: boolean;
|
|
233
|
+
/** Instantly available liquidity in asset units (human-readable) */
|
|
234
|
+
availableLiquidity: number;
|
|
235
|
+
tokenDecimals: number;
|
|
236
|
+
}
|
|
237
|
+
interface StableReaderConfig {
|
|
238
|
+
/** Target network — defaults to Network.Mainnet */
|
|
239
|
+
network?: Network;
|
|
240
|
+
/** Optional RPC override */
|
|
241
|
+
rpc?: string;
|
|
242
|
+
/** Earn configuration — required for reader.earn.* methods */
|
|
243
|
+
earn?: EarnConfig;
|
|
244
|
+
/** Address of the user whose position to read */
|
|
245
|
+
address: string;
|
|
246
|
+
}
|
|
104
247
|
|
|
105
248
|
interface StableClient {
|
|
106
249
|
transfer(params: TransferParams): Promise<OperationResult>;
|
|
@@ -108,8 +251,33 @@ interface StableClient {
|
|
|
108
251
|
bridge(params: BridgeParams): Promise<OperationResult>;
|
|
109
252
|
quoteSwap(params: SwapParams): Promise<SwapQuote>;
|
|
110
253
|
swap(params: SwapParams): Promise<OperationResult>;
|
|
254
|
+
earn: {
|
|
255
|
+
deposit(params: EarnDepositParams): Promise<EarnResult>;
|
|
256
|
+
bulkDeposit(items: EarnDepositParams[], options?: BulkDepositOptions): Promise<BulkEarnResult>;
|
|
257
|
+
withdraw(params: EarnWithdrawParams): Promise<EarnResult>;
|
|
258
|
+
redeem(params: EarnRedeemParams): Promise<EarnResult>;
|
|
259
|
+
forceWithdraw(params: ForceWithdrawParams): Promise<EarnResult>;
|
|
260
|
+
forceRedeem(params: ForceRedeemParams): Promise<EarnResult>;
|
|
261
|
+
};
|
|
111
262
|
}
|
|
112
|
-
|
|
263
|
+
interface StableReader {
|
|
264
|
+
earn: {
|
|
265
|
+
/** Current vault position (shares + asset value) for the configured user address. */
|
|
266
|
+
position(): Promise<VaultPosition>;
|
|
267
|
+
/** Projected yield over a given horizon, using Morpho's live net APY. */
|
|
268
|
+
preview(params: {
|
|
269
|
+
amount: number;
|
|
270
|
+
horizonDays: number;
|
|
271
|
+
}): Promise<YieldPreview>;
|
|
272
|
+
/** Whether a given withdrawal amount can be fulfilled instantly from idle liquidity. */
|
|
273
|
+
withdrawability(params: {
|
|
274
|
+
amount: number;
|
|
275
|
+
tokenDecimals?: number;
|
|
276
|
+
}): Promise<WithdrawStatus>;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, }: StableConfig): StableClient;
|
|
280
|
+
declare function createStableReader(config: StableReaderConfig): StableReader;
|
|
113
281
|
|
|
114
282
|
interface ChainConfig {
|
|
115
283
|
id: number;
|
|
@@ -120,6 +288,9 @@ interface ChainConfig {
|
|
|
120
288
|
}
|
|
121
289
|
declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
|
|
122
290
|
|
|
291
|
+
declare const STABLE_USDT_ADDRESS: Address;
|
|
292
|
+
declare const STABLE_VAULT_ADDRESS: Address;
|
|
293
|
+
|
|
123
294
|
declare class StableError extends BaseError {
|
|
124
295
|
}
|
|
125
296
|
declare class StableValidationError extends StableError {
|
|
@@ -130,12 +301,12 @@ declare class StableValidationError extends StableError {
|
|
|
130
301
|
});
|
|
131
302
|
}
|
|
132
303
|
declare class StableQuoteError extends StableError {
|
|
133
|
-
provider:
|
|
304
|
+
provider: string;
|
|
134
305
|
httpStatus?: number;
|
|
135
306
|
providerCode?: string;
|
|
136
307
|
body?: unknown;
|
|
137
308
|
constructor(args: {
|
|
138
|
-
provider:
|
|
309
|
+
provider: string;
|
|
139
310
|
shortMessage: string;
|
|
140
311
|
httpStatus?: number;
|
|
141
312
|
providerCode?: string;
|
|
@@ -165,5 +336,16 @@ declare class StableNetworkError extends StableError {
|
|
|
165
336
|
cause?: Error;
|
|
166
337
|
});
|
|
167
338
|
}
|
|
339
|
+
declare class StableBulkError extends StableError {
|
|
340
|
+
results: BulkEarnResultItem[];
|
|
341
|
+
succeeded: number;
|
|
342
|
+
failed: number;
|
|
343
|
+
constructor(args: {
|
|
344
|
+
shortMessage: string;
|
|
345
|
+
results: BulkEarnResultItem[];
|
|
346
|
+
succeeded: number;
|
|
347
|
+
failed: number;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
168
350
|
|
|
169
|
-
export { type BridgeParams, type BridgeQuote, CHAIN_CONFIGS, Chain, type ChainConfig, Network, type OperationResult, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, createStable };
|
|
351
|
+
export { type BridgeParams, type BridgeQuote, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type WithdrawStatus, type YieldPreview, createStable, createStableReader };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Account, Transport, WalletClient, Address, BaseError } from 'viem';
|
|
2
2
|
|
|
3
|
+
interface EarnConfig {
|
|
4
|
+
/** MetaMorpho V2 vault address */
|
|
5
|
+
vault: string;
|
|
6
|
+
}
|
|
3
7
|
interface StableConfig {
|
|
4
8
|
/** Target network — defaults to Network.Mainnet */
|
|
5
9
|
network?: Network;
|
|
@@ -11,6 +15,8 @@ interface StableConfig {
|
|
|
11
15
|
transport?: Transport;
|
|
12
16
|
/** Pre-configured viem WalletClient — takes precedence over account/transport. */
|
|
13
17
|
walletClient?: WalletClient;
|
|
18
|
+
/** Earn (Morpho V2 vault) configuration — required to use stable.earn.* methods. */
|
|
19
|
+
earn?: EarnConfig;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* Unified result for transfer, bridge, and swap.
|
|
@@ -82,9 +88,6 @@ declare enum Network {
|
|
|
82
88
|
interface BridgeQuote {
|
|
83
89
|
/** Estimated output amount on the destination chain */
|
|
84
90
|
toAmount?: number;
|
|
85
|
-
/** LayerZero native fee — only present for USDT0→USDT0 routes */
|
|
86
|
-
nativeFee?: bigint;
|
|
87
|
-
lzTokenFee?: bigint;
|
|
88
91
|
}
|
|
89
92
|
interface BridgeParams {
|
|
90
93
|
fromChain: Chain;
|
|
@@ -98,9 +101,149 @@ interface BridgeParams {
|
|
|
98
101
|
fromDecimals?: number;
|
|
99
102
|
/** Recipient address — defaults to the signer */
|
|
100
103
|
recipient?: string;
|
|
101
|
-
/** Pre-fetched quote from quoteBridge() — skips the
|
|
104
|
+
/** Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to bridge() */
|
|
102
105
|
quote?: BridgeQuote;
|
|
103
106
|
}
|
|
107
|
+
interface EarnDepositParams {
|
|
108
|
+
/** Amount of underlying assets to deposit (human-readable) */
|
|
109
|
+
amount: number;
|
|
110
|
+
/** Vault address — overrides the vault set in StableConfig. Required when using bulkDeposit across multiple vaults. */
|
|
111
|
+
vault?: string;
|
|
112
|
+
/** Underlying asset decimals — fetched on-chain if omitted */
|
|
113
|
+
tokenDecimals?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Slippage tolerance as a decimal (e.g. 0.003 = 0.3%).
|
|
116
|
+
* Defaults to Morpho's built-in default (0.03%).
|
|
117
|
+
*/
|
|
118
|
+
slippageTolerance?: number;
|
|
119
|
+
/** Deduplication key: if an operation with this key is already in flight, the same Promise is returned. */
|
|
120
|
+
idempotencyKey?: string;
|
|
121
|
+
}
|
|
122
|
+
interface EarnWithdrawParams {
|
|
123
|
+
/** Amount of underlying assets to withdraw (human-readable) */
|
|
124
|
+
amount: number;
|
|
125
|
+
/** Underlying asset decimals — fetched on-chain if omitted */
|
|
126
|
+
tokenDecimals?: number;
|
|
127
|
+
/** Deduplication key */
|
|
128
|
+
idempotencyKey?: string;
|
|
129
|
+
}
|
|
130
|
+
interface EarnRedeemParams {
|
|
131
|
+
/** Number of vault shares to redeem (human-readable, uses vault's share decimals) */
|
|
132
|
+
shares: number;
|
|
133
|
+
/** Vault share decimals — fetched on-chain if omitted */
|
|
134
|
+
shareDecimals?: number;
|
|
135
|
+
/** Deduplication key */
|
|
136
|
+
idempotencyKey?: string;
|
|
137
|
+
}
|
|
138
|
+
interface EarnResult {
|
|
139
|
+
txHash: string;
|
|
140
|
+
idempotencyKey?: string;
|
|
141
|
+
}
|
|
142
|
+
type BulkEarnResultItem = {
|
|
143
|
+
status: "fulfilled";
|
|
144
|
+
txHash: string;
|
|
145
|
+
vault?: string;
|
|
146
|
+
idempotencyKey?: string;
|
|
147
|
+
} | {
|
|
148
|
+
status: "rejected";
|
|
149
|
+
error: string;
|
|
150
|
+
vault?: string;
|
|
151
|
+
idempotencyKey?: string;
|
|
152
|
+
};
|
|
153
|
+
interface BulkEarnResult {
|
|
154
|
+
results: BulkEarnResultItem[];
|
|
155
|
+
/** Number of deposits that succeeded */
|
|
156
|
+
succeeded: number;
|
|
157
|
+
/** Number of deposits that failed */
|
|
158
|
+
failed: number;
|
|
159
|
+
idempotencyKey?: string;
|
|
160
|
+
}
|
|
161
|
+
interface BulkDepositOptions {
|
|
162
|
+
/** Batch-level deduplication key — if this batch is already in flight, the same Promise is returned. */
|
|
163
|
+
idempotencyKey?: string;
|
|
164
|
+
/**
|
|
165
|
+
* When true, the batch halts on the first failure and rejects.
|
|
166
|
+
* When false (default), all deposits are attempted and partial results are returned.
|
|
167
|
+
*/
|
|
168
|
+
stopOnError?: boolean;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A single adapter position to forcibly deallocate before a force withdraw/redeem.
|
|
172
|
+
* `amount` is in underlying asset units (human-readable).
|
|
173
|
+
* `marketParams` is required only for Morpho Blue market adapters; omit for vault adapters.
|
|
174
|
+
*/
|
|
175
|
+
interface ForceDeallocation {
|
|
176
|
+
adapter: string;
|
|
177
|
+
amount: number;
|
|
178
|
+
marketParams?: {
|
|
179
|
+
loanToken: string;
|
|
180
|
+
collateralToken: string;
|
|
181
|
+
oracle: string;
|
|
182
|
+
irm: string;
|
|
183
|
+
/** LLTV scaled by WAD (1e18) */
|
|
184
|
+
lltv: bigint;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
interface ForceWithdrawParams {
|
|
188
|
+
/** Amount of underlying assets to withdraw (human-readable) */
|
|
189
|
+
amount: number;
|
|
190
|
+
/** Underlying asset decimals — fetched on-chain if omitted */
|
|
191
|
+
tokenDecimals?: number;
|
|
192
|
+
/** Adapter positions to deallocate before the withdrawal */
|
|
193
|
+
deallocations: ForceDeallocation[];
|
|
194
|
+
/** Deduplication key */
|
|
195
|
+
idempotencyKey?: string;
|
|
196
|
+
}
|
|
197
|
+
interface ForceRedeemParams {
|
|
198
|
+
/** Number of vault shares to redeem (human-readable) */
|
|
199
|
+
shares: number;
|
|
200
|
+
/** Vault share decimals — fetched on-chain if omitted */
|
|
201
|
+
shareDecimals?: number;
|
|
202
|
+
/** Underlying asset decimals for deallocation amounts — fetched on-chain if omitted */
|
|
203
|
+
tokenDecimals?: number;
|
|
204
|
+
/** Adapter positions to deallocate before the redemption */
|
|
205
|
+
deallocations: ForceDeallocation[];
|
|
206
|
+
/** Deduplication key */
|
|
207
|
+
idempotencyKey?: string;
|
|
208
|
+
}
|
|
209
|
+
interface VaultPosition {
|
|
210
|
+
/** Raw vault share balance */
|
|
211
|
+
shares: bigint;
|
|
212
|
+
/** Human-readable share balance (shares formatted by shareDecimals) */
|
|
213
|
+
sharesFormatted: number;
|
|
214
|
+
/** Vault share token decimals */
|
|
215
|
+
shareDecimals: number;
|
|
216
|
+
/** Asset value of shares (human-readable) */
|
|
217
|
+
assets: number;
|
|
218
|
+
/** Underlying asset decimals */
|
|
219
|
+
tokenDecimals: number;
|
|
220
|
+
/** Underlying asset contract address */
|
|
221
|
+
assetAddress: string;
|
|
222
|
+
}
|
|
223
|
+
interface YieldPreview {
|
|
224
|
+
/** Expected yield over the period, in asset units (human-readable) */
|
|
225
|
+
projectedYield: number;
|
|
226
|
+
/** Annual percentage yield as a decimal (e.g. 0.05 = 5%) */
|
|
227
|
+
apy: number;
|
|
228
|
+
horizonDays: number;
|
|
229
|
+
}
|
|
230
|
+
interface WithdrawStatus {
|
|
231
|
+
/** True when the full amount can be withdrawn from idle vault liquidity immediately */
|
|
232
|
+
isInstant: boolean;
|
|
233
|
+
/** Instantly available liquidity in asset units (human-readable) */
|
|
234
|
+
availableLiquidity: number;
|
|
235
|
+
tokenDecimals: number;
|
|
236
|
+
}
|
|
237
|
+
interface StableReaderConfig {
|
|
238
|
+
/** Target network — defaults to Network.Mainnet */
|
|
239
|
+
network?: Network;
|
|
240
|
+
/** Optional RPC override */
|
|
241
|
+
rpc?: string;
|
|
242
|
+
/** Earn configuration — required for reader.earn.* methods */
|
|
243
|
+
earn?: EarnConfig;
|
|
244
|
+
/** Address of the user whose position to read */
|
|
245
|
+
address: string;
|
|
246
|
+
}
|
|
104
247
|
|
|
105
248
|
interface StableClient {
|
|
106
249
|
transfer(params: TransferParams): Promise<OperationResult>;
|
|
@@ -108,8 +251,33 @@ interface StableClient {
|
|
|
108
251
|
bridge(params: BridgeParams): Promise<OperationResult>;
|
|
109
252
|
quoteSwap(params: SwapParams): Promise<SwapQuote>;
|
|
110
253
|
swap(params: SwapParams): Promise<OperationResult>;
|
|
254
|
+
earn: {
|
|
255
|
+
deposit(params: EarnDepositParams): Promise<EarnResult>;
|
|
256
|
+
bulkDeposit(items: EarnDepositParams[], options?: BulkDepositOptions): Promise<BulkEarnResult>;
|
|
257
|
+
withdraw(params: EarnWithdrawParams): Promise<EarnResult>;
|
|
258
|
+
redeem(params: EarnRedeemParams): Promise<EarnResult>;
|
|
259
|
+
forceWithdraw(params: ForceWithdrawParams): Promise<EarnResult>;
|
|
260
|
+
forceRedeem(params: ForceRedeemParams): Promise<EarnResult>;
|
|
261
|
+
};
|
|
111
262
|
}
|
|
112
|
-
|
|
263
|
+
interface StableReader {
|
|
264
|
+
earn: {
|
|
265
|
+
/** Current vault position (shares + asset value) for the configured user address. */
|
|
266
|
+
position(): Promise<VaultPosition>;
|
|
267
|
+
/** Projected yield over a given horizon, using Morpho's live net APY. */
|
|
268
|
+
preview(params: {
|
|
269
|
+
amount: number;
|
|
270
|
+
horizonDays: number;
|
|
271
|
+
}): Promise<YieldPreview>;
|
|
272
|
+
/** Whether a given withdrawal amount can be fulfilled instantly from idle liquidity. */
|
|
273
|
+
withdrawability(params: {
|
|
274
|
+
amount: number;
|
|
275
|
+
tokenDecimals?: number;
|
|
276
|
+
}): Promise<WithdrawStatus>;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, }: StableConfig): StableClient;
|
|
280
|
+
declare function createStableReader(config: StableReaderConfig): StableReader;
|
|
113
281
|
|
|
114
282
|
interface ChainConfig {
|
|
115
283
|
id: number;
|
|
@@ -120,6 +288,9 @@ interface ChainConfig {
|
|
|
120
288
|
}
|
|
121
289
|
declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
|
|
122
290
|
|
|
291
|
+
declare const STABLE_USDT_ADDRESS: Address;
|
|
292
|
+
declare const STABLE_VAULT_ADDRESS: Address;
|
|
293
|
+
|
|
123
294
|
declare class StableError extends BaseError {
|
|
124
295
|
}
|
|
125
296
|
declare class StableValidationError extends StableError {
|
|
@@ -130,12 +301,12 @@ declare class StableValidationError extends StableError {
|
|
|
130
301
|
});
|
|
131
302
|
}
|
|
132
303
|
declare class StableQuoteError extends StableError {
|
|
133
|
-
provider:
|
|
304
|
+
provider: string;
|
|
134
305
|
httpStatus?: number;
|
|
135
306
|
providerCode?: string;
|
|
136
307
|
body?: unknown;
|
|
137
308
|
constructor(args: {
|
|
138
|
-
provider:
|
|
309
|
+
provider: string;
|
|
139
310
|
shortMessage: string;
|
|
140
311
|
httpStatus?: number;
|
|
141
312
|
providerCode?: string;
|
|
@@ -165,5 +336,16 @@ declare class StableNetworkError extends StableError {
|
|
|
165
336
|
cause?: Error;
|
|
166
337
|
});
|
|
167
338
|
}
|
|
339
|
+
declare class StableBulkError extends StableError {
|
|
340
|
+
results: BulkEarnResultItem[];
|
|
341
|
+
succeeded: number;
|
|
342
|
+
failed: number;
|
|
343
|
+
constructor(args: {
|
|
344
|
+
shortMessage: string;
|
|
345
|
+
results: BulkEarnResultItem[];
|
|
346
|
+
succeeded: number;
|
|
347
|
+
failed: number;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
168
350
|
|
|
169
|
-
export { type BridgeParams, type BridgeQuote, CHAIN_CONFIGS, Chain, type ChainConfig, Network, type OperationResult, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, createStable };
|
|
351
|
+
export { type BridgeParams, type BridgeQuote, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type WithdrawStatus, type YieldPreview, createStable, createStableReader };
|