@voltr/vault-sdk 0.2.0 → 1.0.1
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/README.md +97 -9
- package/dist/client.d.ts +193 -39
- package/dist/client.js +254 -54
- package/dist/constants.d.ts +6 -2
- package/dist/constants.js +8 -3
- package/dist/decimals.d.ts +3 -0
- package/dist/decimals.js +10 -0
- package/dist/idl/voltr_vault.json +772 -63
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/vault.d.ts +4 -4
- package/dist/types/voltr_vault.d.ts +771 -62
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -41,10 +41,14 @@ const vaultParams = {
|
|
|
41
41
|
config: {
|
|
42
42
|
maxCap: new BN("1000000000"),
|
|
43
43
|
startAtTs: new BN(Math.floor(Date.now() / 1000)),
|
|
44
|
+
lockedProfitDegradationDuration: new BN(3600), // 1 hour
|
|
44
45
|
managerManagementFee: 50, // 0.5%
|
|
45
46
|
managerPerformanceFee: 1000, // 10%
|
|
46
47
|
adminManagementFee: 50, // 0.5%
|
|
47
48
|
adminPerformanceFee: 1000, // 10%
|
|
49
|
+
redemptionFee: 10, // 0.1%
|
|
50
|
+
issuanceFee: 10, // 0.1%
|
|
51
|
+
withdrawalWaitingPeriod: new BN(3600), // 1 hour
|
|
48
52
|
},
|
|
49
53
|
name: "My Vault",
|
|
50
54
|
description: "Example vault",
|
|
@@ -109,16 +113,38 @@ const initDirectWithdrawIx =
|
|
|
109
113
|
|
|
110
114
|
```typescript
|
|
111
115
|
// Deposit assets
|
|
112
|
-
const depositIx = await client.
|
|
113
|
-
|
|
116
|
+
const depositIx = await client.createDepositVaultIx(new BN("1000000000"), {
|
|
117
|
+
userTransferAuthority: userPubkey,
|
|
114
118
|
vault: vaultPubkey,
|
|
115
119
|
vaultAssetMint: mintPubkey,
|
|
116
120
|
assetTokenProgram: tokenProgramPubkey,
|
|
117
121
|
});
|
|
118
122
|
|
|
119
|
-
//
|
|
120
|
-
const
|
|
121
|
-
|
|
123
|
+
// Request withdraw assets
|
|
124
|
+
const requestWithdrawIx = await client.createRequestWithdrawVaultIx(
|
|
125
|
+
{
|
|
126
|
+
amount: new BN("1000000000"),
|
|
127
|
+
isAmountInLp: false,
|
|
128
|
+
isWithdrawAll: false,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
payer: payerPubkey,
|
|
132
|
+
userTransferAuthority: userPubkey,
|
|
133
|
+
vault: vaultPubkey,
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Cancel withdraw request
|
|
138
|
+
const cancelRequestWithdrawIx = await client.createCancelRequestWithdrawVaultIx(
|
|
139
|
+
{
|
|
140
|
+
userTransferAuthority: userPubkey,
|
|
141
|
+
vault: vaultPubkey,
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// Withdraw from vault
|
|
146
|
+
const withdrawIx = await client.createWithdrawVaultIx({
|
|
147
|
+
userTransferAuthority: userPubkey,
|
|
122
148
|
vault: vaultPubkey,
|
|
123
149
|
vaultAssetMint: mintPubkey,
|
|
124
150
|
assetTokenProgram: tokenProgramPubkey,
|
|
@@ -127,7 +153,6 @@ const withdrawIx = await client.createWithdrawIx(new BN("1000000000"), {
|
|
|
127
153
|
// Direct withdraw from strategy
|
|
128
154
|
const directWithdrawIx = await client.createDirectWithdrawStrategyIx(
|
|
129
155
|
{
|
|
130
|
-
withdrawAmount: new BN("1000000000"),
|
|
131
156
|
userArgs: null,
|
|
132
157
|
},
|
|
133
158
|
{
|
|
@@ -151,6 +176,66 @@ console.log(`Total Value: ${values.totalValue}`);
|
|
|
151
176
|
console.log("Strategy Positions:", values.strategies);
|
|
152
177
|
```
|
|
153
178
|
|
|
179
|
+
### Asset Calculation Utilities
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// Calculate the amount of assets that would be received for a given LP token amount
|
|
183
|
+
const assetsToReceive = await client.calculateAssetsForWithdraw(
|
|
184
|
+
vaultPubkey,
|
|
185
|
+
new BN("1000000000")
|
|
186
|
+
);
|
|
187
|
+
console.log(`Assets to receive: ${assetsToReceive.toString()}`);
|
|
188
|
+
|
|
189
|
+
// Calculate the amount of LP tokens needed to withdraw a specific asset amount
|
|
190
|
+
const lpTokensRequired = await client.calculateLpForWithdraw(
|
|
191
|
+
vaultPubkey,
|
|
192
|
+
new BN("1000000000")
|
|
193
|
+
);
|
|
194
|
+
console.log(`LP tokens required: ${lpTokensRequired.toString()}`);
|
|
195
|
+
|
|
196
|
+
// Calculate the amount of LP tokens that would be received for a deposit
|
|
197
|
+
const lpTokensToReceive = await client.calculateLpForDeposit(
|
|
198
|
+
vaultPubkey,
|
|
199
|
+
new BN("1000000000")
|
|
200
|
+
);
|
|
201
|
+
console.log(`LP tokens to receive: ${lpTokensToReceive.toString()}`);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Querying Pending Withdrawals
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
// Get all pending withdrawals for a vault
|
|
208
|
+
const pendingWithdrawals = await client.getAllPendingWithdrawalsForVault(
|
|
209
|
+
vaultPubkey
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
// Process the pending withdrawals
|
|
213
|
+
pendingWithdrawals.forEach((withdrawal, index) => {
|
|
214
|
+
console.log(`Withdrawal ${index + 1}:`);
|
|
215
|
+
console.log(` Asset amount: ${withdrawal.amountAssetToWithdraw}`);
|
|
216
|
+
|
|
217
|
+
// Check if withdrawal is available yet
|
|
218
|
+
const withdrawableTimestamp = withdrawal.withdrawableFromTs.toNumber();
|
|
219
|
+
const currentTime = Math.floor(Date.now() / 1000);
|
|
220
|
+
const isWithdrawable = currentTime >= withdrawableTimestamp;
|
|
221
|
+
|
|
222
|
+
console.log(
|
|
223
|
+
` Withdrawable from: ${new Date(
|
|
224
|
+
withdrawableTimestamp * 1000
|
|
225
|
+
).toLocaleString()}`
|
|
226
|
+
);
|
|
227
|
+
console.log(` Status: ${isWithdrawable ? "Available now" : "Pending"}`);
|
|
228
|
+
if (!isWithdrawable) {
|
|
229
|
+
const timeRemaining = Math.max(0, withdrawableTimestamp - currentTime);
|
|
230
|
+
console.log(
|
|
231
|
+
` Time remaining: ${Math.floor(timeRemaining / 3600)}h ${Math.floor(
|
|
232
|
+
(timeRemaining % 3600) / 60
|
|
233
|
+
)}m`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
154
239
|
## API Reference
|
|
155
240
|
|
|
156
241
|
### VoltrClient Methods
|
|
@@ -158,8 +243,10 @@ console.log("Strategy Positions:", values.strategies);
|
|
|
158
243
|
#### Vault Management
|
|
159
244
|
|
|
160
245
|
- `createInitializeVaultIx(vaultParams, params)`
|
|
161
|
-
- `
|
|
162
|
-
- `
|
|
246
|
+
- `createUpdateVaultIx(vaultConfig, params)`
|
|
247
|
+
- `createRequestWithdrawVaultIx(requestWithdrawArgs, params)`
|
|
248
|
+
- `createCancelRequestWithdrawVaultIx(params)`
|
|
249
|
+
- `createWithdrawVaultIx(params)`
|
|
163
250
|
|
|
164
251
|
#### Strategy Management
|
|
165
252
|
|
|
@@ -191,7 +278,8 @@ console.log("Strategy Positions:", values.strategies);
|
|
|
191
278
|
#### Calculations
|
|
192
279
|
|
|
193
280
|
- `calculateAssetsForWithdraw(vaultPk, lpAmount)`
|
|
194
|
-
- `
|
|
281
|
+
- `calculateLpForWithdraw(vaultPk, assetAmount)`
|
|
282
|
+
- `calculateLpForDeposit(vaultPk, assetAmount)`
|
|
195
283
|
|
|
196
284
|
## License
|
|
197
285
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Program, AnchorProvider, Idl
|
|
1
|
+
import { Program, AnchorProvider, Idl } from "@coral-xyz/anchor";
|
|
2
|
+
import BN from "bn.js";
|
|
2
3
|
import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
-
import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs,
|
|
4
|
+
import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, RequestWithdrawVaultArgs } from "./types";
|
|
4
5
|
declare class AccountUtils {
|
|
5
6
|
conn: Connection;
|
|
6
7
|
constructor(conn: Connection);
|
|
@@ -111,6 +112,18 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
111
112
|
strategyInitReceipt: PublicKey;
|
|
112
113
|
directWithdrawInitReceipt: PublicKey;
|
|
113
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Finds the request withdraw vault receipt address
|
|
117
|
+
* @param vault - Public key of the vault
|
|
118
|
+
* @param user - Public key of the user
|
|
119
|
+
* @returns The PDA for the request withdraw vault receipt
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* const requestWithdrawVaultReceipt = client.findRequestWithdrawVaultReceipt(vaultPubkey, userPubkey);
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
findRequestWithdrawVaultReceipt(vault: PublicKey, user: PublicKey): PublicKey;
|
|
114
127
|
/**
|
|
115
128
|
* Creates an instruction to initialize a new vault
|
|
116
129
|
*
|
|
@@ -118,10 +131,14 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
118
131
|
* @param {VaultConfig} vaultParams.config - Vault configuration settings
|
|
119
132
|
* @param {BN} vaultParams.config.maxCap - Maximum capacity of the vault
|
|
120
133
|
* @param {BN} vaultParams.config.startAtTs - Vault start timestamp in seconds
|
|
134
|
+
* @param {BN} vaultParams.config.lockedProfitDegradationDuration - Locked profit degradation duration in seconds
|
|
121
135
|
* @param {number} vaultParams.config.managerManagementFee - Manager's management fee in basis points (e.g., 50 = 0.5%)
|
|
122
136
|
* @param {number} vaultParams.config.managerPerformanceFee - Manager's performance fee in basis points (e.g., 1000 = 10%)
|
|
123
137
|
* @param {number} vaultParams.config.adminManagementFee - Admin's management fee in basis points (e.g., 50 = 0.5%)
|
|
124
138
|
* @param {number} vaultParams.config.adminPerformanceFee - Admin's performance fee in basis points (e.g., 1000 = 10%)
|
|
139
|
+
* @param {number} vaultParams.config.redemptionFee - Redemption fee in basis points (e.g., 10 = 0.1%)
|
|
140
|
+
* @param {number} vaultParams.config.issuanceFee - Issuance fee in basis points (e.g., 10 = 0.1%)
|
|
141
|
+
* @param {BN} vaultParams.config.withdrawalWaitingPeriod - Withdrawal waiting period in seconds
|
|
125
142
|
* @param {string} vaultParams.name - Name of the vault
|
|
126
143
|
* @param {string} vaultParams.description - Description of the vault
|
|
127
144
|
* @param {Object} params - Additional parameters for initializing the vault
|
|
@@ -139,6 +156,10 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
139
156
|
* config: {
|
|
140
157
|
* maxCap: new BN('1000000000'),
|
|
141
158
|
* startAtTs: new BN(Math.floor(Date.now() / 1000)),
|
|
159
|
+
* lockedProfitDegradationDuration: new BN(3600), // 1 hour
|
|
160
|
+
* redemptionFee: 10,
|
|
161
|
+
* issuanceFee: 10,
|
|
162
|
+
* withdrawalWaitingPeriod: new BN(3600), // 1 hour
|
|
142
163
|
* managerManagementFee: 50, // 0.5%
|
|
143
164
|
* managerPerformanceFee: 1000, // 10%
|
|
144
165
|
* adminManagementFee: 50, // 0.5%
|
|
@@ -202,7 +223,7 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
202
223
|
*
|
|
203
224
|
* @param {BN} amount - Amount of tokens to deposit
|
|
204
225
|
* @param {Object} params - Deposit parameters
|
|
205
|
-
* @param {PublicKey} params.
|
|
226
|
+
* @param {PublicKey} params.userTransferAuthority - Public key of the user's transfer authority
|
|
206
227
|
* @param {PublicKey} params.vault - Public key of the vault
|
|
207
228
|
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
208
229
|
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
@@ -214,7 +235,7 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
214
235
|
* const ix = await client.createDepositVaultIx(
|
|
215
236
|
* new BN('1000000000'),
|
|
216
237
|
* {
|
|
217
|
-
*
|
|
238
|
+
* userTransferAuthority: userPubkey,
|
|
218
239
|
* vault: vaultPubkey,
|
|
219
240
|
* vaultAssetMint: mintPubkey,
|
|
220
241
|
* assetTokenProgram: tokenProgramPubkey
|
|
@@ -222,45 +243,92 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
222
243
|
* );
|
|
223
244
|
* ```
|
|
224
245
|
*/
|
|
225
|
-
createDepositVaultIx(amount: BN, {
|
|
226
|
-
|
|
246
|
+
createDepositVaultIx(amount: BN, { userTransferAuthority, vault, vaultAssetMint, assetTokenProgram, }: {
|
|
247
|
+
userTransferAuthority: PublicKey;
|
|
227
248
|
vault: PublicKey;
|
|
228
249
|
vaultAssetMint: PublicKey;
|
|
229
250
|
assetTokenProgram: PublicKey;
|
|
230
251
|
}): Promise<TransactionInstruction>;
|
|
231
252
|
/**
|
|
232
|
-
* Creates a withdraw instruction for a vault
|
|
253
|
+
* Creates a request withdraw instruction for a vault
|
|
233
254
|
*
|
|
234
|
-
* @param {
|
|
235
|
-
* @param {BN}
|
|
236
|
-
* @param {boolean}
|
|
237
|
-
* @param {boolean}
|
|
238
|
-
* @param {Object} params -
|
|
239
|
-
* @param {PublicKey} params.
|
|
255
|
+
* @param {RequestWithdrawVaultArgs} requestWithdrawArgs - Arguments for withdrawing from the vault
|
|
256
|
+
* @param {BN} requestWithdrawArgs.amount - Amount of LP tokens to withdraw
|
|
257
|
+
* @param {boolean} requestWithdrawArgs.isAmountInLp - Whether the amount is in LP tokens
|
|
258
|
+
* @param {boolean} requestWithdrawArgs.isWithdrawAll - Whether to withdraw all assets
|
|
259
|
+
* @param {Object} params - Request withdraw parameters
|
|
260
|
+
* @param {PublicKey} params.payer - Public key of the payer
|
|
261
|
+
* @param {PublicKey} params.userTransferAuthority - Public key of the user authority
|
|
240
262
|
* @param {PublicKey} params.vault - Public key of the vault
|
|
241
|
-
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
242
|
-
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
243
263
|
* @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawal
|
|
244
264
|
*
|
|
245
265
|
* @throws {Error} If the instruction creation fails
|
|
246
266
|
*
|
|
247
267
|
* @example
|
|
248
|
-
* const ix = await client.
|
|
268
|
+
* const ix = await client.createRequestWithdrawVaultIx(
|
|
249
269
|
* {
|
|
250
270
|
* amount: new BN('1000000000'),
|
|
251
271
|
* isAmountInLp: true,
|
|
252
272
|
* isWithdrawAll: false,
|
|
253
273
|
* },
|
|
254
274
|
* {
|
|
255
|
-
*
|
|
275
|
+
* payer: payerPubkey,
|
|
276
|
+
* userTransferAuthority: userPubkey,
|
|
277
|
+
* vault: vaultPubkey,
|
|
278
|
+
* }
|
|
279
|
+
* );
|
|
280
|
+
*/
|
|
281
|
+
createRequestWithdrawVaultIx({ amount, isAmountInLp, isWithdrawAll }: RequestWithdrawVaultArgs, { payer, userTransferAuthority, vault, }: {
|
|
282
|
+
payer: PublicKey;
|
|
283
|
+
userTransferAuthority: PublicKey;
|
|
284
|
+
vault: PublicKey;
|
|
285
|
+
}): Promise<TransactionInstruction>;
|
|
286
|
+
/**
|
|
287
|
+
* Creates a cancel withdraw instruction for a vault
|
|
288
|
+
*
|
|
289
|
+
* @param {Object} params - Cancel withdraw request parameters
|
|
290
|
+
* @param {PublicKey} params.userTransferAuthority - Public key of the user authority
|
|
291
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
292
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawal
|
|
293
|
+
*
|
|
294
|
+
* @throws {Error} If the instruction creation fails
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* const ix = await client.createCancelRequestWithdrawVaultIx(
|
|
298
|
+
* {
|
|
299
|
+
* userTransferAuthority: userPubkey,
|
|
300
|
+
* vault: vaultPubkey,
|
|
301
|
+
* }
|
|
302
|
+
* );
|
|
303
|
+
*/
|
|
304
|
+
createCancelRequestWithdrawVaultIx({ userTransferAuthority, vault, }: {
|
|
305
|
+
userTransferAuthority: PublicKey;
|
|
306
|
+
vault: PublicKey;
|
|
307
|
+
}): Promise<TransactionInstruction>;
|
|
308
|
+
/**
|
|
309
|
+
* Creates a withdraw instruction for a vault
|
|
310
|
+
*
|
|
311
|
+
* @param {Object} params - Withdraw parameters
|
|
312
|
+
* @param {PublicKey} params.userTransferAuthority - Public key of the user authority
|
|
313
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
314
|
+
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
315
|
+
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
316
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawal
|
|
317
|
+
*
|
|
318
|
+
* @throws {Error} If the instruction creation fails
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* const ix = await client.createWithdrawVaultIx(
|
|
322
|
+
* {
|
|
323
|
+
* userTransferAuthority: userPubkey,
|
|
256
324
|
* vault: vaultPubkey,
|
|
257
325
|
* vaultAssetMint: mintPubkey,
|
|
258
326
|
* assetTokenProgram: tokenProgramPubkey
|
|
259
327
|
* }
|
|
260
328
|
* );
|
|
261
329
|
*/
|
|
262
|
-
createWithdrawVaultIx({
|
|
263
|
-
|
|
330
|
+
createWithdrawVaultIx({ userTransferAuthority, vault, vaultAssetMint, assetTokenProgram, }: {
|
|
331
|
+
userTransferAuthority: PublicKey;
|
|
264
332
|
vault: PublicKey;
|
|
265
333
|
vaultAssetMint: PublicKey;
|
|
266
334
|
assetTokenProgram: PublicKey;
|
|
@@ -502,10 +570,7 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
502
570
|
}): Promise<TransactionInstruction>;
|
|
503
571
|
/**
|
|
504
572
|
* Creates an instruction to withdraw assets from a direct withdraw strategy
|
|
505
|
-
* @param {
|
|
506
|
-
* @param {BN} directWithdrawArgs.amount - Amount of assets to withdraw
|
|
507
|
-
* @param {boolean} directWithdrawArgs.isAmountInLp - Whether the amount is in LP tokens
|
|
508
|
-
* @param {boolean} directWithdrawArgs.isWithdrawAll - Whether to withdraw all assets
|
|
573
|
+
* @param {Object} directWithdrawArgs - Withdrawal arguments
|
|
509
574
|
* @param {Buffer | null} [directWithdrawArgs.userArgs] - Optional user arguments for the instruction
|
|
510
575
|
* @param {Object} params - Parameters for withdrawing assets from direct withdraw strategy
|
|
511
576
|
* @param {PublicKey} params.user - Public key of the user
|
|
@@ -522,9 +587,6 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
522
587
|
* ```typescript
|
|
523
588
|
* const ix = await client.createDirectWithdrawStrategyIx(
|
|
524
589
|
* {
|
|
525
|
-
* amount: new BN('1000000000'),
|
|
526
|
-
* isAmountInLp: true,
|
|
527
|
-
* isWithdrawAll: false,
|
|
528
590
|
* userArgs: Buffer.from('...')
|
|
529
591
|
* },
|
|
530
592
|
* {
|
|
@@ -539,7 +601,9 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
539
601
|
* );
|
|
540
602
|
* ```
|
|
541
603
|
*/
|
|
542
|
-
createDirectWithdrawStrategyIx({
|
|
604
|
+
createDirectWithdrawStrategyIx({ userArgs }: {
|
|
605
|
+
userArgs?: Buffer | null;
|
|
606
|
+
}, { user, vault, strategy, vaultAssetMint, assetTokenProgram, adaptorProgram, remainingAccounts, }: {
|
|
543
607
|
user: PublicKey;
|
|
544
608
|
vault: PublicKey;
|
|
545
609
|
strategy: PublicKey;
|
|
@@ -595,6 +659,25 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
595
659
|
padding0: number[];
|
|
596
660
|
reserved: number[];
|
|
597
661
|
}>[]>;
|
|
662
|
+
/**
|
|
663
|
+
* Fetches all request withdraw vault receipt accounts of a vault
|
|
664
|
+
* @param vault - Public key of the vault
|
|
665
|
+
* @returns Promise resolving to an array of request withdraw vault receipt accounts
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* ```typescript
|
|
669
|
+
* const requestWithdrawVaultReceiptAccounts = await client.fetchAllRequestWithdrawVaultReceiptsOfVault(vaultPubkey);
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
672
|
+
fetchAllRequestWithdrawVaultReceiptsOfVault(vault: PublicKey): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
673
|
+
vault: PublicKey;
|
|
674
|
+
user: PublicKey;
|
|
675
|
+
amountLpEscrowed: BN;
|
|
676
|
+
amountAssetToWithdrawDecimalBits: BN;
|
|
677
|
+
withdrawableFromTs: BN;
|
|
678
|
+
bump: number;
|
|
679
|
+
version: number;
|
|
680
|
+
}>[]>;
|
|
598
681
|
/**
|
|
599
682
|
* Fetches all adaptor add receipt accounts of a vault
|
|
600
683
|
* @param vault - Public key of the vault
|
|
@@ -616,10 +699,10 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
616
699
|
reserved: number[];
|
|
617
700
|
}>[]>;
|
|
618
701
|
getPositionAndTotalValuesForVault(vault: PublicKey): Promise<{
|
|
619
|
-
totalValue:
|
|
702
|
+
totalValue: number;
|
|
620
703
|
strategies: {
|
|
621
704
|
strategyId: string;
|
|
622
|
-
amount:
|
|
705
|
+
amount: number;
|
|
623
706
|
}[];
|
|
624
707
|
}>;
|
|
625
708
|
/**
|
|
@@ -630,18 +713,55 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
630
713
|
fetchVaultAccount(vault: PublicKey): Promise<{
|
|
631
714
|
name: number[];
|
|
632
715
|
description: number[];
|
|
633
|
-
asset:
|
|
634
|
-
|
|
716
|
+
asset: {
|
|
717
|
+
mint: PublicKey;
|
|
718
|
+
idleAta: PublicKey;
|
|
719
|
+
totalValue: BN;
|
|
720
|
+
idleAtaAuthBump: number;
|
|
721
|
+
reserved: number[];
|
|
722
|
+
};
|
|
723
|
+
lp: {
|
|
724
|
+
mint: PublicKey;
|
|
725
|
+
mintBump: number;
|
|
726
|
+
mintAuthBump: number;
|
|
727
|
+
reserved: number[];
|
|
728
|
+
};
|
|
635
729
|
manager: PublicKey;
|
|
636
730
|
admin: PublicKey;
|
|
637
|
-
vaultConfiguration:
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
731
|
+
vaultConfiguration: {
|
|
732
|
+
maxCap: BN;
|
|
733
|
+
startAtTs: BN;
|
|
734
|
+
lockedProfitDegradationDuration: BN;
|
|
735
|
+
withdrawalWaitingPeriod: BN;
|
|
736
|
+
reserved: number[];
|
|
737
|
+
};
|
|
738
|
+
feeConfiguration: {
|
|
739
|
+
managerPerformanceFee: number;
|
|
740
|
+
adminPerformanceFee: number;
|
|
741
|
+
managerManagementFee: number;
|
|
742
|
+
adminManagementFee: number;
|
|
743
|
+
redemptionFee: number;
|
|
744
|
+
issuanceFee: number;
|
|
745
|
+
reserved: number[];
|
|
746
|
+
};
|
|
747
|
+
feeState: {
|
|
748
|
+
accumulatedLpManagerFees: BN;
|
|
749
|
+
accumulatedLpAdminFees: BN;
|
|
750
|
+
accumulatedLpProtocolFees: BN;
|
|
751
|
+
reserved: number[];
|
|
752
|
+
};
|
|
753
|
+
highWaterMark: {
|
|
754
|
+
highestAssetPerLpDecimalBits: BN;
|
|
755
|
+
lastUpdatedTs: BN;
|
|
756
|
+
reserved: number[];
|
|
757
|
+
};
|
|
641
758
|
lastUpdatedTs: BN;
|
|
642
759
|
version: number;
|
|
643
760
|
padding0: number[];
|
|
644
|
-
lockedProfitState:
|
|
761
|
+
lockedProfitState: {
|
|
762
|
+
lastUpdatedLockedProfit: BN;
|
|
763
|
+
lastReport: BN;
|
|
764
|
+
};
|
|
645
765
|
reserved: number[];
|
|
646
766
|
}>;
|
|
647
767
|
/**
|
|
@@ -686,6 +806,21 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
686
806
|
lastUpdatedEpoch: BN;
|
|
687
807
|
reserved: number[];
|
|
688
808
|
}>;
|
|
809
|
+
/**
|
|
810
|
+
* Fetches all pending withdrawals for a vault
|
|
811
|
+
* @param vault - Public key of the vault
|
|
812
|
+
* @returns Promise resolving to an array of pending withdrawals
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* ```typescript
|
|
816
|
+
* const pendingWithdrawals = await client.getAllPendingWithdrawalsForVault(vaultPubkey);
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
819
|
+
getAllPendingWithdrawalsForVault(vault: PublicKey): Promise<{
|
|
820
|
+
amountAssetToWithdraw: number;
|
|
821
|
+
withdrawableFromTs: BN;
|
|
822
|
+
}[]>;
|
|
823
|
+
calculateLockedProfit(lastUpdatedLockedProfit: BN, lockedProfitDegradationDuration: BN, currentTime: BN): BN;
|
|
689
824
|
/**
|
|
690
825
|
* Calculates the amount of assets that would be received for a given LP token amount
|
|
691
826
|
*
|
|
@@ -705,11 +840,30 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
705
840
|
* ```
|
|
706
841
|
*/
|
|
707
842
|
calculateAssetsForWithdraw(vaultPk: PublicKey, lpAmount: BN): Promise<BN>;
|
|
843
|
+
/**
|
|
844
|
+
* Calculates the amount of LP tokens that would be burned for a given asset amount
|
|
845
|
+
*
|
|
846
|
+
* @param vaultPk - Public key of the vault
|
|
847
|
+
* @param assetAmount - Amount of assets to calculate for
|
|
848
|
+
* @returns Promise resolving to the amount of LP tokens that would be burned
|
|
849
|
+
*
|
|
850
|
+
* @throws {Error} If LP supply or total assets are invalid
|
|
851
|
+
* @throws {Error} If math overflow occurs during calculation
|
|
852
|
+
*
|
|
853
|
+
* @example
|
|
854
|
+
* ```typescript
|
|
855
|
+
* const lpTokensToBurn = await client.calculateLpForWithdraw(
|
|
856
|
+
* vaultPubkey,
|
|
857
|
+
* new BN('1000000000')
|
|
858
|
+
* );
|
|
859
|
+
* ```
|
|
860
|
+
*/
|
|
861
|
+
calculateLpForWithdraw(vaultPk: PublicKey, assetAmount: BN): Promise<BN>;
|
|
708
862
|
/**
|
|
709
863
|
* Calculates the amount of LP tokens that would be received for a given asset deposit
|
|
710
864
|
*
|
|
711
|
-
* @param depositAmount - Amount of assets to deposit
|
|
712
865
|
* @param vaultPk - Public key of the vault
|
|
866
|
+
* @param assetAmount - Amount of assets to deposit
|
|
713
867
|
* @returns Promise resolving to the amount of LP tokens that would be received
|
|
714
868
|
*
|
|
715
869
|
* @throws {Error} If math overflow occurs during calculation
|
|
@@ -717,11 +871,11 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
717
871
|
* @example
|
|
718
872
|
* ```typescript
|
|
719
873
|
* const lpTokens = await client.calculateLpTokensForDeposit(
|
|
720
|
-
* new BN('1000000000'),
|
|
721
874
|
* vaultPubkey
|
|
875
|
+
* new BN('1000000000'),
|
|
722
876
|
* );
|
|
723
877
|
* ```
|
|
724
878
|
*/
|
|
725
|
-
|
|
879
|
+
calculateLpForDeposit(vaultPk: PublicKey, assetAmount: BN): Promise<BN>;
|
|
726
880
|
}
|
|
727
881
|
export {};
|