aftermath-ts-sdk 1.3.23-perps.34 → 1.3.23-perps.36
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/general/types/generalTypes.d.ts +4 -0
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetuals.d.ts +177 -262
- package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetuals.js +185 -256
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +178 -34
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsAccount.js +183 -39
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +116 -140
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.js +125 -159
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +241 -5
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsVault.d.ts +273 -19
- package/dist/packages/perpetuals/perpetualsVault.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsVault.js +289 -78
- package/package.json +1 -1
|
@@ -3,36 +3,65 @@ import { AftermathApi } from "../../general/providers";
|
|
|
3
3
|
import { Caller } from "../../general/utils/caller";
|
|
4
4
|
import { Balance, CallerConfig, PerpetualsMarketId, PerpetualsVaultObject, SuiAddress, ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse, PerpetualsVaultWithdrawRequest, ApiPerpetualsVaultPreviewCreateWithdrawRequestResponse, ApiPerpetualsVaultPreviewDepositResponse, ApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse, ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse, ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse, ApiTransactionResponse, PerpetualsPartialVaultCap, ApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse, ApiPerpetualsVaultsWithdrawRequestsResponse, ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse, ApiPerpetualsVaultProcessForceWithdrawRequestTxResponse, PerpetualsAccountObject } from "../../types";
|
|
5
5
|
import { PerpetualsAccount } from "./perpetualsAccount";
|
|
6
|
+
/**
|
|
7
|
+
* High-level wrapper around a single Perpetuals vault.
|
|
8
|
+
*
|
|
9
|
+
* A vault is a managed perpetuals account that accepts user deposits (LP),
|
|
10
|
+
* trades across up to a bounded set of markets, and supports withdrawals via
|
|
11
|
+
* a request flow.
|
|
12
|
+
*
|
|
13
|
+
* This class provides:
|
|
14
|
+
*
|
|
15
|
+
* - Transaction builders for:
|
|
16
|
+
* - User actions (deposit, create/cancel withdraw request, update slippage)
|
|
17
|
+
* - Force-withdraw processing (close positions and settle a request)
|
|
18
|
+
* - Owner admin actions (update params, process requests, withdraw fees/collateral)
|
|
19
|
+
* - Read helpers for:
|
|
20
|
+
* - Vault withdraw requests
|
|
21
|
+
* - LP token pricing
|
|
22
|
+
* - Accessing the vault’s underlying perpetuals account
|
|
23
|
+
* - Static validation helpers for LP coin metadata (name/symbol constraints)
|
|
24
|
+
* - A small calculation helper for withdraw-request slippage
|
|
25
|
+
*
|
|
26
|
+
* Typical usage:
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* const perps = afSdk.Perpetuals();
|
|
30
|
+
* const { vaults } = await perps.getAllVaults();
|
|
31
|
+
* const vault = vaults[0];
|
|
32
|
+
*
|
|
33
|
+
* const { tx } = await vault.getDepositTx({
|
|
34
|
+
* walletAddress: "0x...",
|
|
35
|
+
* depositAmount: BigInt("1000000000"),
|
|
36
|
+
* minLpAmountOut: 0n,
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
6
40
|
export declare class PerpetualsVault extends Caller {
|
|
7
41
|
readonly vaultObject: PerpetualsVaultObject;
|
|
8
42
|
readonly Provider?: AftermathApi | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Vault-level protocol limits and UI-friendly constraints.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* These are SDK constants (not fetched from chain). They should match the
|
|
48
|
+
* on-chain / backend limits enforced by the vault module.
|
|
49
|
+
*/
|
|
9
50
|
static readonly constants: {
|
|
10
51
|
/**
|
|
11
52
|
* Maximum lock period in milliseconds.
|
|
12
53
|
*/
|
|
13
54
|
maxLockPeriodMs: number;
|
|
14
|
-
/**
|
|
15
|
-
* Minimum lock period in milliseconds.
|
|
16
|
-
*/
|
|
17
|
-
minLockPeriodMs: number;
|
|
18
55
|
/**
|
|
19
56
|
* Maximum period for force withdraw delay in milliseconds.
|
|
20
57
|
*/
|
|
21
58
|
maxForceWithdrawDelayMs: number;
|
|
22
59
|
/**
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
minForceWithdrawDelayMs: number;
|
|
26
|
-
/**
|
|
27
|
-
* Minimum vault fee.
|
|
28
|
-
*/
|
|
29
|
-
minPerformanceFeePercentage: number;
|
|
30
|
-
/**
|
|
31
|
-
* Maximum vault fee.
|
|
60
|
+
* Maximum vault fee (performance fee).
|
|
32
61
|
*/
|
|
33
62
|
maxPerformanceFeePercentage: number;
|
|
34
63
|
/**
|
|
35
|
-
* Minimum USD value required for
|
|
64
|
+
* Minimum USD value required for user deposits.
|
|
36
65
|
*/
|
|
37
66
|
minDepositUsd: number;
|
|
38
67
|
/**
|
|
@@ -40,15 +69,37 @@ export declare class PerpetualsVault extends Caller {
|
|
|
40
69
|
*/
|
|
41
70
|
minOwnerLockUsd: number;
|
|
42
71
|
/**
|
|
43
|
-
* The maximum number of distinct `ClearingHouse
|
|
72
|
+
* The maximum number of distinct markets (`ClearingHouse`s) the vault can trade.
|
|
44
73
|
*/
|
|
45
74
|
maxMarketsInVault: number;
|
|
46
75
|
/**
|
|
47
|
-
* The maximum number of pending orders allowed for a single position in the
|
|
76
|
+
* The maximum number of pending orders allowed for a single position in the vault.
|
|
48
77
|
*/
|
|
49
78
|
maxPendingOrdersPerPosition: number;
|
|
50
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Create a new {@link PerpetualsVault} wrapper.
|
|
82
|
+
*
|
|
83
|
+
* @param vaultObject - Raw on-chain vault object snapshot.
|
|
84
|
+
* @param config - Optional {@link CallerConfig} (network, auth, base URL).
|
|
85
|
+
* @param Provider - Optional shared {@link AftermathApi} provider. When provided,
|
|
86
|
+
* transaction builders will serialize {@link Transaction}s into `txKind`.
|
|
87
|
+
*/
|
|
51
88
|
constructor(vaultObject: PerpetualsVaultObject, config?: CallerConfig, Provider?: AftermathApi | undefined);
|
|
89
|
+
/**
|
|
90
|
+
* Build a `process-force-withdraw-request` transaction.
|
|
91
|
+
*
|
|
92
|
+
* Force-withdraw is a mechanism that closes required positions and processes
|
|
93
|
+
* a withdraw request after a delay window (see vault params).
|
|
94
|
+
*
|
|
95
|
+
* @param inputs.walletAddress - User wallet that owns the withdraw request.
|
|
96
|
+
* @param inputs.sizesToClose - Mapping of marketId -> size (base units) to close.
|
|
97
|
+
* @param inputs.recipientAddress - Optional recipient of the withdrawn collateral.
|
|
98
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
99
|
+
*
|
|
100
|
+
* @returns Transaction response containing `tx` (and any additional outputs
|
|
101
|
+
* provided by the backend response type).
|
|
102
|
+
*/
|
|
52
103
|
getProcessForceWithdrawRequestTx(inputs: {
|
|
53
104
|
walletAddress: SuiAddress;
|
|
54
105
|
sizesToClose: Record<PerpetualsMarketId, Balance>;
|
|
@@ -57,36 +108,93 @@ export declare class PerpetualsVault extends Caller {
|
|
|
57
108
|
}): Promise<Omit<ApiPerpetualsVaultProcessForceWithdrawRequestTxResponse, "txKind"> & {
|
|
58
109
|
tx: Transaction;
|
|
59
110
|
}>;
|
|
111
|
+
/**
|
|
112
|
+
* Build an `update-withdraw-request-slippage` transaction.
|
|
113
|
+
*
|
|
114
|
+
* This updates the user's minimum acceptable collateral output amount
|
|
115
|
+
* for an existing withdraw request.
|
|
116
|
+
*
|
|
117
|
+
* @param inputs.minCollateralAmountOut - New minimum collateral amount out.
|
|
118
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
119
|
+
*
|
|
120
|
+
* @returns Transaction response containing `tx`.
|
|
121
|
+
*/
|
|
60
122
|
getUpdateWithdrawRequestSlippageTx(inputs: {
|
|
61
123
|
minCollateralAmountOut: Balance;
|
|
62
124
|
tx?: Transaction;
|
|
63
125
|
}): Promise<Omit<ApiTransactionResponse, "txKind"> & {
|
|
64
126
|
tx: Transaction;
|
|
65
127
|
}>;
|
|
128
|
+
/**
|
|
129
|
+
* Build an owner transaction to update the vault's force withdraw delay.
|
|
130
|
+
*
|
|
131
|
+
* @param inputs.forceWithdrawDelayMs - New delay (ms). Should be <= {@link constants.maxForceWithdrawDelayMs}.
|
|
132
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
133
|
+
*
|
|
134
|
+
* @returns Transaction response containing `tx`.
|
|
135
|
+
*/
|
|
66
136
|
getOwnerUpdateForceWithdrawDelayTx(inputs: {
|
|
67
137
|
forceWithdrawDelayMs: bigint;
|
|
68
138
|
tx?: Transaction;
|
|
69
139
|
}): Promise<Omit<ApiTransactionResponse, "txKind"> & {
|
|
70
140
|
tx: Transaction;
|
|
71
141
|
}>;
|
|
142
|
+
/**
|
|
143
|
+
* Build an owner transaction to update the vault's lock period.
|
|
144
|
+
*
|
|
145
|
+
* @param inputs.lockPeriodMs - New lock period (ms). Should be <= {@link constants.maxLockPeriodMs}.
|
|
146
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
147
|
+
*
|
|
148
|
+
* @returns Transaction response containing `tx`.
|
|
149
|
+
*/
|
|
72
150
|
getOwnerUpdateLockPeriodTx(inputs: {
|
|
73
151
|
lockPeriodMs: bigint;
|
|
74
152
|
tx?: Transaction;
|
|
75
153
|
}): Promise<Omit<ApiTransactionResponse, "txKind"> & {
|
|
76
154
|
tx: Transaction;
|
|
77
155
|
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Build an owner transaction to update the vault performance fee.
|
|
158
|
+
*
|
|
159
|
+
* @param inputs.performanceFeePercentage - New fee as a fraction (e.g. `0.2` = 20%).
|
|
160
|
+
* Should be <= {@link constants.maxPerformanceFeePercentage}.
|
|
161
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
162
|
+
*
|
|
163
|
+
* @returns Transaction response containing `tx`.
|
|
164
|
+
*/
|
|
78
165
|
getOwnerUpdatePerformanceFeeTx(inputs: {
|
|
79
166
|
performanceFeePercentage: number;
|
|
80
167
|
tx?: Transaction;
|
|
81
168
|
}): Promise<Omit<ApiTransactionResponse, "txKind"> & {
|
|
82
169
|
tx: Transaction;
|
|
83
170
|
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Build an owner transaction to process one or more users' withdraw requests.
|
|
173
|
+
*
|
|
174
|
+
* This is the normal (non-force) processing path for withdrawals. The owner
|
|
175
|
+
* batches users and settles their requests in a single transaction.
|
|
176
|
+
*
|
|
177
|
+
* @param inputs.userAddresses - Users whose requests should be processed.
|
|
178
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
179
|
+
*
|
|
180
|
+
* @returns Transaction response containing `tx`.
|
|
181
|
+
*/
|
|
84
182
|
getOwnerProcessWithdrawRequestsTx(inputs: {
|
|
85
183
|
userAddresses: SuiAddress[];
|
|
86
184
|
tx?: Transaction;
|
|
87
185
|
}): Promise<Omit<ApiTransactionResponse, "txKind"> & {
|
|
88
186
|
tx: Transaction;
|
|
89
187
|
}>;
|
|
188
|
+
/**
|
|
189
|
+
* Build an owner transaction to withdraw accrued performance fees.
|
|
190
|
+
*
|
|
191
|
+
* @param inputs.withdrawAmount - Amount of collateral to withdraw as fees.
|
|
192
|
+
* @param inputs.recipientAddress - Optional recipient address for the withdrawn fees.
|
|
193
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
194
|
+
*
|
|
195
|
+
* @returns Response containing `tx` and any extra outputs described by
|
|
196
|
+
* {@link ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse}.
|
|
197
|
+
*/
|
|
90
198
|
getOwnerWithdrawPerformanceFeesTx(inputs: {
|
|
91
199
|
withdrawAmount: Balance;
|
|
92
200
|
recipientAddress?: SuiAddress;
|
|
@@ -94,6 +202,17 @@ export declare class PerpetualsVault extends Caller {
|
|
|
94
202
|
}): Promise<Omit<ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse, "txKind"> & {
|
|
95
203
|
tx: Transaction;
|
|
96
204
|
}>;
|
|
205
|
+
/**
|
|
206
|
+
* Build an owner transaction to withdraw vault collateral by redeeming LP.
|
|
207
|
+
*
|
|
208
|
+
* @param inputs.lpWithdrawAmount - Amount of LP to redeem.
|
|
209
|
+
* @param inputs.minCollateralAmountOut - Minimum collateral out to protect from slippage.
|
|
210
|
+
* @param inputs.recipientAddress - Optional recipient address for withdrawn collateral.
|
|
211
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
212
|
+
*
|
|
213
|
+
* @returns Response containing `tx` and any extra outputs described by
|
|
214
|
+
* {@link ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse}.
|
|
215
|
+
*/
|
|
97
216
|
getOwnerWithdrawCollateralTx(inputs: {
|
|
98
217
|
lpWithdrawAmount: Balance;
|
|
99
218
|
minCollateralAmountOut: Balance;
|
|
@@ -102,6 +221,19 @@ export declare class PerpetualsVault extends Caller {
|
|
|
102
221
|
}): Promise<Omit<ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse, "txKind"> & {
|
|
103
222
|
tx: Transaction;
|
|
104
223
|
}>;
|
|
224
|
+
/**
|
|
225
|
+
* Build a user transaction to create a vault withdraw request.
|
|
226
|
+
*
|
|
227
|
+
* Withdrawals are request-based: the user specifies how much LP to redeem
|
|
228
|
+
* and a minimum collateral output amount.
|
|
229
|
+
*
|
|
230
|
+
* @param inputs.walletAddress - Wallet creating the request.
|
|
231
|
+
* @param inputs.lpWithdrawAmount - Amount of LP to withdraw.
|
|
232
|
+
* @param inputs.minCollateralAmountOut - Minimum collateral out (slippage guard).
|
|
233
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
234
|
+
*
|
|
235
|
+
* @returns Transaction response containing `tx`.
|
|
236
|
+
*/
|
|
105
237
|
getCreateWithdrawRequestTx(inputs: {
|
|
106
238
|
walletAddress: SuiAddress;
|
|
107
239
|
lpWithdrawAmount: Balance;
|
|
@@ -110,12 +242,45 @@ export declare class PerpetualsVault extends Caller {
|
|
|
110
242
|
}): Promise<Omit<ApiTransactionResponse, "txKind"> & {
|
|
111
243
|
tx: Transaction;
|
|
112
244
|
}>;
|
|
245
|
+
/**
|
|
246
|
+
* Build a user transaction to cancel an existing vault withdraw request.
|
|
247
|
+
*
|
|
248
|
+
* @param inputs.walletAddress - Wallet canceling the request.
|
|
249
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
250
|
+
*
|
|
251
|
+
* @returns Transaction response containing `tx`.
|
|
252
|
+
*/
|
|
113
253
|
getCancelWithdrawRequestTx(inputs: {
|
|
114
254
|
walletAddress: SuiAddress;
|
|
115
255
|
tx?: Transaction;
|
|
116
256
|
}): Promise<Omit<ApiTransactionResponse, "txKind"> & {
|
|
117
257
|
tx: Transaction;
|
|
118
258
|
}>;
|
|
259
|
+
/**
|
|
260
|
+
* Build a user transaction to deposit collateral into the vault in exchange for LP.
|
|
261
|
+
*
|
|
262
|
+
* You can specify the deposit as:
|
|
263
|
+
* - `depositAmount` (wallet pays directly), OR
|
|
264
|
+
* - `depositCoinArg` (use an existing transaction argument)
|
|
265
|
+
*
|
|
266
|
+
* @param inputs.walletAddress - Depositor wallet.
|
|
267
|
+
* @param inputs.minLpAmountOut - Minimum LP out (slippage guard).
|
|
268
|
+
* @param inputs.isSponsoredTx - Whether the tx is sponsored (gas paid by another party).
|
|
269
|
+
* @param inputs.depositAmount - Amount of collateral to deposit (mutually exclusive with `depositCoinArg`).
|
|
270
|
+
* @param inputs.depositCoinArg - Transaction argument referencing collateral coin.
|
|
271
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
272
|
+
*
|
|
273
|
+
* @returns Transaction response containing `tx`.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* const { txKind } = await vault.getDepositTx({
|
|
278
|
+
* walletAddress: "0x...",
|
|
279
|
+
* depositAmount: 1_000_000_000n,
|
|
280
|
+
* minLpAmountOut: 0n,
|
|
281
|
+
* });
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
119
284
|
getDepositTx(inputs: {
|
|
120
285
|
walletAddress: SuiAddress;
|
|
121
286
|
minLpAmountOut: Balance;
|
|
@@ -128,29 +293,101 @@ export declare class PerpetualsVault extends Caller {
|
|
|
128
293
|
})): Promise<Omit<ApiTransactionResponse, "txKind"> & {
|
|
129
294
|
tx: Transaction;
|
|
130
295
|
}>;
|
|
296
|
+
/**
|
|
297
|
+
* Fetch all withdraw requests for this vault.
|
|
298
|
+
*
|
|
299
|
+
* @returns {@link ApiPerpetualsVaultsWithdrawRequestsResponse} containing requests
|
|
300
|
+
* scoped to `this.vaultObject.objectId`.
|
|
301
|
+
*
|
|
302
|
+
* @remarks
|
|
303
|
+
* This currently calls the `vaults/withdraw-requests` endpoint with a single vault ID.
|
|
304
|
+
* This may be moved to {@link Perpetuals} as a shared helper.
|
|
305
|
+
*/
|
|
131
306
|
getAllWithdrawRequests(): Promise<ApiPerpetualsVaultsWithdrawRequestsResponse>;
|
|
307
|
+
/**
|
|
308
|
+
* Preview the results of an owner processing one or more withdraw requests.
|
|
309
|
+
*
|
|
310
|
+
* @param inputs.userAddresses - Users to process.
|
|
311
|
+
* @returns Preview response with expected effects.
|
|
312
|
+
*/
|
|
132
313
|
getPreviewOwnerProcessWithdrawRequests(inputs: {
|
|
133
314
|
userAddresses: SuiAddress[];
|
|
134
315
|
}): Promise<ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse>;
|
|
316
|
+
/**
|
|
317
|
+
* Preview the amount available for the owner to withdraw as performance fees.
|
|
318
|
+
*
|
|
319
|
+
* @returns Preview response including withdrawable fees and related metadata.
|
|
320
|
+
*/
|
|
135
321
|
getPreviewOwnerWithdrawPerformanceFees(): Promise<ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse>;
|
|
322
|
+
/**
|
|
323
|
+
* Preview an owner collateral withdrawal (LP redemption).
|
|
324
|
+
*
|
|
325
|
+
* @param inputs.lpWithdrawAmount - LP amount to redeem.
|
|
326
|
+
* @returns Preview response including estimated collateral out.
|
|
327
|
+
*/
|
|
136
328
|
getPreviewOwnerWithdrawCollateral(inputs: {
|
|
137
329
|
lpWithdrawAmount: Balance;
|
|
138
330
|
}): Promise<ApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse>;
|
|
331
|
+
/**
|
|
332
|
+
* Preview creating a withdraw request.
|
|
333
|
+
*
|
|
334
|
+
* @param inputs.walletAddress - Requesting wallet.
|
|
335
|
+
* @param inputs.lpWithdrawAmount - LP amount to withdraw.
|
|
336
|
+
* @returns Preview response including estimated collateral out and constraints.
|
|
337
|
+
*/
|
|
139
338
|
getPreviewCreateWithdrawRequest(inputs: {
|
|
140
339
|
walletAddress: SuiAddress;
|
|
141
340
|
lpWithdrawAmount: Balance;
|
|
142
341
|
}): Promise<ApiPerpetualsVaultPreviewCreateWithdrawRequestResponse>;
|
|
342
|
+
/**
|
|
343
|
+
* Preview depositing into the vault.
|
|
344
|
+
*
|
|
345
|
+
* @param inputs.depositAmount - Deposit amount in collateral coin units.
|
|
346
|
+
* @returns Preview response including estimated LP out.
|
|
347
|
+
*/
|
|
143
348
|
getPreviewDeposit(inputs: {
|
|
144
349
|
depositAmount: Balance;
|
|
145
350
|
}): Promise<ApiPerpetualsVaultPreviewDepositResponse>;
|
|
351
|
+
/**
|
|
352
|
+
* Preview processing a force withdraw request for a user.
|
|
353
|
+
*
|
|
354
|
+
* This is useful to determine what positions/sizes must be closed or what
|
|
355
|
+
* the expected outputs are prior to building the actual transaction.
|
|
356
|
+
*
|
|
357
|
+
* @param inputs.walletAddress - User wallet with a pending force-withdraw.
|
|
358
|
+
* @returns Preview response describing expected processing effects.
|
|
359
|
+
*/
|
|
146
360
|
getPreviewProcessForceWithdrawRequest(inputs: {
|
|
147
361
|
walletAddress: SuiAddress;
|
|
148
362
|
}): Promise<ApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse>;
|
|
363
|
+
/**
|
|
364
|
+
* Fetch the current LP coin price for this vault (in collateral units).
|
|
365
|
+
*
|
|
366
|
+
* Internally calls {@link Perpetuals.getLpCoinPrices} and returns the first price.
|
|
367
|
+
*
|
|
368
|
+
* @returns LP coin price as a `number`.
|
|
369
|
+
*/
|
|
149
370
|
getLpCoinPrice(): Promise<number>;
|
|
371
|
+
/**
|
|
372
|
+
* Build a lightweight “cap-like” object for the vault’s underlying account.
|
|
373
|
+
*
|
|
374
|
+
* @returns {@link PerpetualsPartialVaultCap} suitable for account fetch helpers
|
|
375
|
+
* such as {@link Perpetuals.getAccount}.
|
|
376
|
+
*/
|
|
150
377
|
partialVaultCap(): PerpetualsPartialVaultCap;
|
|
378
|
+
/**
|
|
379
|
+
* Fetch the underlying perpetuals account object for this vault.
|
|
380
|
+
*
|
|
381
|
+
* @returns `{ account }` where `account` is the on-chain {@link PerpetualsAccountObject}.
|
|
382
|
+
*/
|
|
151
383
|
getAccountObject(): Promise<{
|
|
152
384
|
account: PerpetualsAccountObject;
|
|
153
385
|
}>;
|
|
386
|
+
/**
|
|
387
|
+
* Fetch a {@link PerpetualsAccount} wrapper for the vault’s underlying account.
|
|
388
|
+
*
|
|
389
|
+
* @returns `{ account }` where `account` is a high-level {@link PerpetualsAccount}.
|
|
390
|
+
*/
|
|
154
391
|
getAccount(): Promise<{
|
|
155
392
|
account: PerpetualsAccount;
|
|
156
393
|
}>;
|
|
@@ -158,16 +395,33 @@ export declare class PerpetualsVault extends Caller {
|
|
|
158
395
|
* Checks if a string is a valid LP coin name.
|
|
159
396
|
*
|
|
160
397
|
* @param value - The string to check.
|
|
161
|
-
* @returns `true` if `value`
|
|
398
|
+
* @returns `true` if `value` can be used as a valid LP coin name, otherwise `false`.
|
|
399
|
+
*
|
|
400
|
+
* @remarks
|
|
401
|
+
* Current rule: ASCII-only. This aligns with many on-chain metadata constraints.
|
|
162
402
|
*/
|
|
163
403
|
static isValidLpCoinName: (value: string) => boolean;
|
|
164
404
|
/**
|
|
165
|
-
* Checks if a string is a valid LP coin type.
|
|
405
|
+
* Checks if a string is a valid LP coin type symbol.
|
|
166
406
|
*
|
|
167
407
|
* @param value - The string to check.
|
|
168
|
-
* @returns `true` if `value`
|
|
408
|
+
* @returns `true` if `value` can be used as a valid LP coin type symbol, otherwise `false`.
|
|
409
|
+
*
|
|
410
|
+
* @remarks
|
|
411
|
+
* Current rule: uppercase A–Z plus underscore.
|
|
169
412
|
*/
|
|
170
413
|
static isValidLpCoinTypeSymbol: (value: string) => boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Compute the implied slippage tolerance for a withdraw request.
|
|
416
|
+
*
|
|
417
|
+
* Defined as:
|
|
418
|
+
* ```text
|
|
419
|
+
* (lpAmountInUsd - minCollateralAmountOutUsd) / lpAmountInUsd
|
|
420
|
+
* ```
|
|
421
|
+
*
|
|
422
|
+
* @param inputs.withdrawRequest - Withdraw request to analyze.
|
|
423
|
+
* @returns Slippage fraction (0..1). Returns `0` if `lpAmountInUsd` is missing/zero.
|
|
424
|
+
*/
|
|
171
425
|
static calcWithdrawRequestSlippage: (inputs: {
|
|
172
426
|
withdrawRequest: PerpetualsVaultWithdrawRequest;
|
|
173
427
|
}) => number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpetualsVault.d.ts","sourceRoot":"","sources":["../../../src/packages/perpetuals/perpetualsVault.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EACX,yBAAyB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC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