@voltr/vault-sdk 1.0.13 → 1.0.14

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 CHANGED
@@ -64,6 +64,86 @@ const ix = await client.createInitializeVaultIx(vaultParams, {
64
64
  });
65
65
  ```
66
66
 
67
+ ### Update Vault Configuration
68
+
69
+ ```typescript
70
+ import { VaultConfigField } from "@voltr/vault-sdk";
71
+
72
+ // Update max cap
73
+ const maxCapData = client.serializeU64(new BN(20_000_000_000_000));
74
+ const maxCapIx = await client.createUpdateVaultConfigIx(
75
+ VaultConfigField.MaxCap,
76
+ maxCapData,
77
+ {
78
+ vault: vaultPubkey,
79
+ admin: adminPubkey,
80
+ }
81
+ );
82
+
83
+ // Update withdrawal waiting period
84
+ const waitingPeriodData = client.serializeU64(new BN(5_000));
85
+ const waitingPeriodIx = await client.createUpdateVaultConfigIx(
86
+ VaultConfigField.WithdrawalWaitingPeriod,
87
+ waitingPeriodData,
88
+ {
89
+ vault: vaultPubkey,
90
+ admin: adminPubkey,
91
+ }
92
+ );
93
+
94
+ // Update manager management fee (requires LP mint)
95
+ const vaultLpMint = client.findVaultLpMint(vaultPubkey);
96
+ const feeData = client.serializeU16(1000); // 10%
97
+ const feeIx = await client.createUpdateVaultConfigIx(
98
+ VaultConfigField.ManagerManagementFee,
99
+ feeData,
100
+ {
101
+ vault: vaultPubkey,
102
+ admin: adminPubkey,
103
+ vaultLpMint: vaultLpMint,
104
+ }
105
+ );
106
+
107
+ // Update issuance fee
108
+ const issuanceFeeData = client.serializeU16(75); // 0.75%
109
+ const issuanceFeeIx = await client.createUpdateVaultConfigIx(
110
+ VaultConfigField.IssuanceFee,
111
+ issuanceFeeData,
112
+ {
113
+ vault: vaultPubkey,
114
+ admin: adminPubkey,
115
+ }
116
+ );
117
+
118
+ // Update vault manager
119
+ const newManager = new PublicKey("...");
120
+ const managerData = client.serializePubkey(newManager);
121
+ const managerIx = await client.createUpdateVaultConfigIx(
122
+ VaultConfigField.Manager,
123
+ managerData,
124
+ {
125
+ vault: vaultPubkey,
126
+ admin: adminPubkey,
127
+ }
128
+ );
129
+ ```
130
+
131
+ #### Available Vault Config Fields
132
+
133
+ - `VaultConfigField.MaxCap` - Maximum vault capacity (u64)
134
+ - `VaultConfigField.StartAtTs` - Vault start timestamp (u64)
135
+ - `VaultConfigField.LockedProfitDegradationDuration` - Locked profit degradation duration (u64)
136
+ - `VaultConfigField.WithdrawalWaitingPeriod` - Withdrawal waiting period (u64)
137
+ - `VaultConfigField.ManagerPerformanceFee` - Manager performance fee in BPS (u16)
138
+ - `VaultConfigField.AdminPerformanceFee` - Admin performance fee in BPS (u16)
139
+ - `VaultConfigField.ManagerManagementFee` - Manager management fee in BPS (u16, requires LP mint)
140
+ - `VaultConfigField.AdminManagementFee` - Admin management fee in BPS (u16, requires LP mint)
141
+ - `VaultConfigField.RedemptionFee` - Redemption fee in BPS (u16)
142
+ - `VaultConfigField.IssuanceFee` - Issuance fee in BPS (u16)
143
+ - `VaultConfigField.Manager` - Vault manager (PublicKey)
144
+
145
+ > **Note:** When updating `ManagerManagementFee` or `AdminManagementFee`, you must provide the `vaultLpMint` parameter as these operations charge management fees and require reading the LP mint supply.
146
+
67
147
  ### Strategy Management
68
148
 
69
149
  ```typescript
@@ -234,6 +314,67 @@ pendingWithdrawals.forEach((withdrawal, index) => {
234
314
  );
235
315
  }
236
316
  });
317
+
318
+ // Get pending withdrawal for a specific user
319
+ const userWithdrawal = await client.getPendingWithdrawalForUser(
320
+ vaultPubkey,
321
+ userPubkey
322
+ );
323
+ console.log(`User withdrawal amount: ${userWithdrawal.amountAssetToWithdrawEffective}`);
324
+ ```
325
+
326
+ ### Fee Management
327
+
328
+ ```typescript
329
+ // Calibrate high water mark (admin only)
330
+ const calibrateIx = await client.createCalibrateHighWaterMarkIx({
331
+ vault: vaultPubkey,
332
+ admin: adminPubkey,
333
+ });
334
+
335
+ // Get current high water mark
336
+ const highWaterMark = await client.getHighWaterMarkForVault(vaultPubkey);
337
+ console.log(`Highest asset per LP: ${highWaterMark.highestAssetPerLp}`);
338
+ console.log(
339
+ `Last updated: ${new Date(highWaterMark.lastUpdatedTs * 1000).toLocaleString()}`
340
+ );
341
+
342
+ // Get current asset per LP
343
+ const currentAssetPerLp =
344
+ await client.getCurrentAssetPerLpForVault(vaultPubkey);
345
+ console.log(`Current asset per LP: ${currentAssetPerLp}`);
346
+
347
+ // Harvest accumulated fees
348
+ const harvestIx = await client.createHarvestFeeIx({
349
+ harvester: harvesterPubkey,
350
+ vaultManager: managerPubkey,
351
+ vaultAdmin: adminPubkey,
352
+ protocolAdmin: protocolAdminPubkey,
353
+ vault: vaultPubkey,
354
+ });
355
+
356
+ // Get accumulated fees
357
+ const adminFees = await client.getAccumulatedAdminFeesForVault(vaultPubkey);
358
+ const managerFees = await client.getAccumulatedManagerFeesForVault(vaultPubkey);
359
+ console.log(`Admin fees: ${adminFees.toString()}`);
360
+ console.log(`Manager fees: ${managerFees.toString()}`);
361
+ ```
362
+
363
+ ## Helper Methods
364
+
365
+ ### Serialization Helpers
366
+
367
+ The SDK provides helper methods to serialize values for vault configuration updates:
368
+
369
+ ```typescript
370
+ // Serialize u64 values (for amounts, timestamps, etc.)
371
+ const u64Data = client.serializeU64(new BN(20_000_000_000_000));
372
+
373
+ // Serialize u16 values (for fee percentages in basis points)
374
+ const u16Data = client.serializeU16(1000); // 10%
375
+
376
+ // Serialize PublicKey values (for manager updates)
377
+ const pubkeyData = client.serializePubkey(new PublicKey("..."));
237
378
  ```
238
379
 
239
380
  ## API Reference
@@ -242,61 +383,71 @@ pendingWithdrawals.forEach((withdrawal, index) => {
242
383
 
243
384
  #### Vault Management
244
385
 
245
- - `createInitializeVaultIx(vaultParams, params)`
246
- - `createUpdateVaultIx(vaultConfig, params)`
247
- - `createDepositVaultIx(amount, params)`
248
- - `createRequestWithdrawVaultIx(requestWithdrawArgs, params)`
249
- - `createCancelRequestWithdrawVaultIx(params)`
250
- - `createWithdrawVaultIx(params)`
251
- - `createHarvestFeeIx(params)`
252
- - `createCreateLpMetadataIx(createLpMetadataArgs, params)`
386
+ - `createInitializeVaultIx(vaultParams, params)` - Initialize a new vault
387
+ - `createUpdateVaultIx(vaultConfig, params)` - **Deprecated:** Update vault (use `createUpdateVaultConfigIx` instead)
388
+ - `createUpdateVaultConfigIx(field, data, params)` - Update a specific vault configuration field
389
+ - `createDepositVaultIx(amount, params)` - Deposit assets into vault
390
+ - `createRequestWithdrawVaultIx(requestWithdrawArgs, params)` - Request withdrawal from vault
391
+ - `createCancelRequestWithdrawVaultIx(params)` - Cancel a pending withdrawal request
392
+ - `createWithdrawVaultIx(params)` - Execute a withdrawal from vault
393
+ - `createHarvestFeeIx(params)` - Harvest accumulated fees
394
+ - `createCalibrateHighWaterMarkIx(params)` - Calibrate the high water mark
395
+ - `createCreateLpMetadataIx(createLpMetadataArgs, params)` - Create LP token metadata
253
396
 
254
397
  #### Strategy Management
255
398
 
256
- - `createAddAdaptorIx(params)`
257
- - `createInitializeStrategyIx(initArgs, params)`
258
- - `createDepositStrategyIx(depositArgs, params)`
259
- - `createWithdrawStrategyIx(withdrawArgs, params)`
260
- - `createInitializeDirectWithdrawStrategyIx(initArgs, params)`
261
- - `createDirectWithdrawStrategyIx(withdrawArgs, params)`
262
- - `createCloseStrategyIx(params)`
263
- - `createRemoveAdaptorIx(params)`
399
+ - `createAddAdaptorIx(params)` - Add an adaptor to a vault
400
+ - `createInitializeStrategyIx(initArgs, params)` - Initialize a new strategy
401
+ - `createDepositStrategyIx(depositArgs, params)` - Deposit assets into a strategy
402
+ - `createWithdrawStrategyIx(withdrawArgs, params)` - Withdraw assets from a strategy
403
+ - `createInitializeDirectWithdrawStrategyIx(initArgs, params)` - Initialize direct withdraw for a strategy
404
+ - `createDirectWithdrawStrategyIx(withdrawArgs, params)` - Execute direct withdrawal from a strategy
405
+ - `createCloseStrategyIx(params)` - Close a strategy
406
+ - `createRemoveAdaptorIx(params)` - Remove an adaptor from a vault
264
407
 
265
408
  #### Account Data
266
409
 
267
- - `fetchVaultAccount(vault)`
268
- - `fetchStrategyInitReceiptAccount(strategyInitReceipt)`
269
- - `fetchAdaptorAddReceiptAccount(adaptorAddReceipt)`
270
- - `fetchRequestWithdrawVaultReceiptAccount(requestWithdrawVaultReceipt)`
271
- - `fetchAllStrategyInitReceiptAccounts()`
272
- - `fetchAllStrategyInitReceiptAccountsOfVault(vault)`
273
- - `fetchAllAdaptorAddReceiptAccountsOfVault(vault)`
274
- - `fetchAllRequestWithdrawVaultReceiptsOfVault(vault)`
275
- - `getPositionAndTotalValuesForVault(vault)`
276
- - `getAccumulatedAdminFeesForVault(vault)`
277
- - `getAccumulatedManagerFeesForVault(vault)`
278
- - `getPendingWithdrawalForUser(vault, user)`
279
- - `getAllPendingWithdrawalsForVault(vault)`
280
- - `getCurrentAssetPerLpForVault(vault)`
281
- - `getHighWaterMarkForVault(vault)`
410
+ - `fetchVaultAccount(vault)` - Fetch vault account data
411
+ - `fetchStrategyInitReceiptAccount(strategyInitReceipt)` - Fetch strategy initialization receipt
412
+ - `fetchAdaptorAddReceiptAccount(adaptorAddReceipt)` - Fetch adaptor add receipt
413
+ - `fetchRequestWithdrawVaultReceiptAccount(requestWithdrawVaultReceipt)` - Fetch withdrawal request receipt
414
+ - `fetchAllStrategyInitReceiptAccounts()` - Fetch all strategy receipts
415
+ - `fetchAllStrategyInitReceiptAccountsOfVault(vault)` - Fetch all strategy receipts for a vault
416
+ - `fetchAllAdaptorAddReceiptAccountsOfVault(vault)` - Fetch all adaptor receipts for a vault
417
+ - `fetchAllRequestWithdrawVaultReceiptsOfVault(vault)` - Fetch all withdrawal requests for a vault
418
+ - `getPositionAndTotalValuesForVault(vault)` - Get position values and total vault value
419
+ - `getAccumulatedAdminFeesForVault(vault)` - Get accumulated admin fees
420
+ - `getAccumulatedManagerFeesForVault(vault)` - Get accumulated manager fees
421
+ - `getPendingWithdrawalForUser(vault, user)` - Get pending withdrawal for a specific user
422
+ - `getAllPendingWithdrawalsForVault(vault)` - Get all pending withdrawals for a vault
423
+ - `getCurrentAssetPerLpForVault(vault)` - Get current asset per LP ratio
424
+ - `getHighWaterMarkForVault(vault)` - Get high water mark information
282
425
 
283
426
  #### PDA Finding
284
427
 
285
- - `findVaultLpMint(vault)`
286
- - `findVaultAssetIdleAuth(vault)`
287
- - `findVaultAddresses(vault)`
288
- - `findVaultStrategyAuth(vault, strategy)`
289
- - `findStrategyInitReceipt(vault, strategy)`
290
- - `findDirectWithdrawInitReceipt(vault, strategy)`
291
- - `findVaultStrategyAddresses(vault, strategy)`
292
- - `findRequestWithdrawVaultReceipt(vault, user)`
428
+ - `findVaultLpMint(vault)` - Find vault LP mint address
429
+ - `findVaultAssetIdleAuth(vault)` - Find vault asset idle authority
430
+ - `findVaultAddresses(vault)` - Find all vault-related addresses
431
+ - `findVaultStrategyAuth(vault, strategy)` - Find vault strategy authority
432
+ - `findStrategyInitReceipt(vault, strategy)` - Find strategy initialization receipt
433
+ - `findDirectWithdrawInitReceipt(vault, strategy)` - Find direct withdraw receipt
434
+ - `findVaultStrategyAddresses(vault, strategy)` - Find all strategy-related addresses
435
+ - `findRequestWithdrawVaultReceipt(vault, user)` - Find withdrawal request receipt
436
+ - `findLpMetadataAccount(vault)` - Find LP metadata account
293
437
 
294
438
  #### Calculations
295
439
 
296
- - `calculateAssetsForWithdraw(vaultPk, lpAmount)`
297
- - `calculateLpForWithdraw(vaultPk, assetAmount)`
298
- - `calculateLpForDeposit(vaultPk, assetAmount)`
440
+ - `calculateAssetsForWithdraw(vaultPk, lpAmount)` - Calculate asset amount for LP tokens
441
+ - `calculateLpForWithdraw(vaultPk, assetAmount)` - Calculate LP tokens needed for asset amount
442
+ - `calculateLpForDeposit(vaultPk, assetAmount)` - Calculate LP tokens received for deposit
443
+
444
+ #### Helper Methods
445
+
446
+ - `serializeU64(value)` - Serialize a u64 value to Buffer
447
+ - `serializeU16(value)` - Serialize a u16 value to Buffer
448
+ - `serializePubkey(pubkey)` - Serialize a PublicKey to Buffer
449
+ - `getBalance(publicKey)` - Get account balance in lamports
299
450
 
300
451
  ## License
301
452
 
302
- [MIT](https://choosealicense.com/licenses/mit/)
453
+ [MIT](https://choosealicense.com/licenses/mit/)
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Program, AnchorProvider, Idl } from "@coral-xyz/anchor";
2
2
  import BN from "bn.js";
3
3
  import { ConfirmOptions, Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
4
- import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, RequestWithdrawVaultArgs } from "./types";
4
+ import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, RequestWithdrawVaultArgs, VaultConfigField } from "./types";
5
5
  declare class AccountUtils {
6
6
  conn: Connection;
7
7
  constructor(conn: Connection);
@@ -198,6 +198,10 @@ export declare class VoltrClient extends AccountUtils {
198
198
  }): Promise<TransactionInstruction>;
199
199
  /**
200
200
  * Creates an instruction to update a vault
201
+ *
202
+ * @deprecated Since version 1.0.14. Use `createUpdateVaultConfigIx` instead for more granular configuration updates.
203
+ * This method will be removed in a future version.
204
+ *
201
205
  * @param {VaultConfig} vaultConfig - Configuration parameters for the vault
202
206
  * @param {BN} vaultConfig.maxCap - Maximum capacity of the vault
203
207
  * @param {BN} vaultConfig.startAtTs - Vault start timestamp in seconds
@@ -212,6 +216,7 @@ export declare class VoltrClient extends AccountUtils {
212
216
  *
213
217
  * @example
214
218
  * ```typescript
219
+ * // DEPRECATED - Use createUpdateVaultConfigIx instead
215
220
  * const ix = await client.createUpdateVaultIx(
216
221
  * {
217
222
  * maxCap: new BN('1000000000'),
@@ -223,12 +228,88 @@ export declare class VoltrClient extends AccountUtils {
223
228
  * },
224
229
  * { vault: vaultPubkey, admin: adminPubkey }
225
230
  * );
231
+ *
232
+ * // NEW WAY - Update individual fields:
233
+ * const newMaxCap = new BN('1000000000');
234
+ * const data = newMaxCap.toArrayLike(Buffer, 'le', 8);
235
+ * const ix = await client.createUpdateVaultConfigIx(
236
+ * VaultConfigField.MaxCap,
237
+ * data,
238
+ * { vault: vaultPubkey, admin: adminPubkey }
239
+ * );
226
240
  * ```
227
241
  */
228
242
  createUpdateVaultIx(vaultConfig: VaultConfig, { vault, admin, }: {
229
243
  vault: PublicKey;
230
244
  admin: PublicKey;
231
245
  }): Promise<TransactionInstruction>;
246
+ /**
247
+ * Creates an instruction to update a specific vault configuration field
248
+ *
249
+ * @param {VaultConfigField} field - The configuration field to update
250
+ * @param {Buffer} data - The serialized data for the new value
251
+ * @param {Object} params - Parameters for updating the vault config
252
+ * @param {PublicKey} params.vault - Public key of the vault
253
+ * @param {PublicKey} params.admin - Public key of the vault admin
254
+ * @param {PublicKey} [params.vaultLpMint] - Required when updating management fees
255
+ * @returns {Promise<TransactionInstruction>} Transaction instruction for updating the vault config
256
+ *
257
+ * @throws {Error} If the field requires LP mint but it's not provided
258
+ *
259
+ * @example Update max cap
260
+ * ```typescript
261
+ * const newMaxCap = new BN(20_000_000_000_000);
262
+ * const data = newMaxCap.toArrayLike(Buffer, "le", 8);
263
+ *
264
+ * const ix = await client.createUpdateVaultConfigIx(
265
+ * VaultConfigField.MaxCap,
266
+ * data,
267
+ * {
268
+ * vault: vaultPubkey,
269
+ * admin: adminPubkey
270
+ * }
271
+ * );
272
+ * ```
273
+ *
274
+ * @example Update manager management fee (requires LP mint)
275
+ * ```typescript
276
+ * const newManagerManagementFee = 1000; // 10%
277
+ * const data = Buffer.alloc(2);
278
+ * data.writeUInt16LE(newManagerManagementFee, 0);
279
+ *
280
+ * const vaultLpMint = client.findVaultLpMint(vaultPubkey);
281
+ *
282
+ * const ix = await client.createUpdateVaultConfigIx(
283
+ * VaultConfigField.ManagerManagementFee,
284
+ * data,
285
+ * {
286
+ * vault: vaultPubkey,
287
+ * admin: adminPubkey,
288
+ * vaultLpMint: vaultLpMint
289
+ * }
290
+ * );
291
+ * ```
292
+ *
293
+ * @example Update manager (requires Pubkey)
294
+ * ```typescript
295
+ * const newManager = new PublicKey('...');
296
+ * const data = newManager.toBuffer();
297
+ *
298
+ * const ix = await client.createUpdateVaultConfigIx(
299
+ * VaultConfigField.Manager,
300
+ * data,
301
+ * {
302
+ * vault: vaultPubkey,
303
+ * admin: adminPubkey
304
+ * }
305
+ * );
306
+ * ```
307
+ */
308
+ createUpdateVaultConfigIx(field: VaultConfigField, data: Buffer, { vault, admin, vaultLpMint, }: {
309
+ vault: PublicKey;
310
+ admin: PublicKey;
311
+ vaultLpMint?: PublicKey;
312
+ }): Promise<TransactionInstruction>;
232
313
  /**
233
314
  * Creates a deposit instruction for a vault
234
315
  *
package/dist/client.js CHANGED
@@ -42,6 +42,7 @@ const bn_js_1 = __importDefault(require("bn.js"));
42
42
  const web3_js_1 = require("@solana/web3.js");
43
43
  const spl_token_1 = require("@solana/spl-token");
44
44
  const constants_1 = require("./constants");
45
+ const types_1 = require("./types");
45
46
  // Import IDL files
46
47
  const vaultIdl = __importStar(require("./idl/voltr_vault.json"));
47
48
  const decimals_1 = require("./decimals");
@@ -340,6 +341,10 @@ class VoltrClient extends AccountUtils {
340
341
  }
341
342
  /**
342
343
  * Creates an instruction to update a vault
344
+ *
345
+ * @deprecated Since version 1.0.14. Use `createUpdateVaultConfigIx` instead for more granular configuration updates.
346
+ * This method will be removed in a future version.
347
+ *
343
348
  * @param {VaultConfig} vaultConfig - Configuration parameters for the vault
344
349
  * @param {BN} vaultConfig.maxCap - Maximum capacity of the vault
345
350
  * @param {BN} vaultConfig.startAtTs - Vault start timestamp in seconds
@@ -354,6 +359,7 @@ class VoltrClient extends AccountUtils {
354
359
  *
355
360
  * @example
356
361
  * ```typescript
362
+ * // DEPRECATED - Use createUpdateVaultConfigIx instead
357
363
  * const ix = await client.createUpdateVaultIx(
358
364
  * {
359
365
  * maxCap: new BN('1000000000'),
@@ -365,6 +371,15 @@ class VoltrClient extends AccountUtils {
365
371
  * },
366
372
  * { vault: vaultPubkey, admin: adminPubkey }
367
373
  * );
374
+ *
375
+ * // NEW WAY - Update individual fields:
376
+ * const newMaxCap = new BN('1000000000');
377
+ * const data = newMaxCap.toArrayLike(Buffer, 'le', 8);
378
+ * const ix = await client.createUpdateVaultConfigIx(
379
+ * VaultConfigField.MaxCap,
380
+ * data,
381
+ * { vault: vaultPubkey, admin: adminPubkey }
382
+ * );
368
383
  * ```
369
384
  */
370
385
  async createUpdateVaultIx(vaultConfig, { vault, admin, }) {
@@ -380,6 +395,114 @@ class VoltrClient extends AccountUtils {
380
395
  ])
381
396
  .instruction();
382
397
  }
398
+ /**
399
+ * Creates an instruction to update a specific vault configuration field
400
+ *
401
+ * @param {VaultConfigField} field - The configuration field to update
402
+ * @param {Buffer} data - The serialized data for the new value
403
+ * @param {Object} params - Parameters for updating the vault config
404
+ * @param {PublicKey} params.vault - Public key of the vault
405
+ * @param {PublicKey} params.admin - Public key of the vault admin
406
+ * @param {PublicKey} [params.vaultLpMint] - Required when updating management fees
407
+ * @returns {Promise<TransactionInstruction>} Transaction instruction for updating the vault config
408
+ *
409
+ * @throws {Error} If the field requires LP mint but it's not provided
410
+ *
411
+ * @example Update max cap
412
+ * ```typescript
413
+ * const newMaxCap = new BN(20_000_000_000_000);
414
+ * const data = newMaxCap.toArrayLike(Buffer, "le", 8);
415
+ *
416
+ * const ix = await client.createUpdateVaultConfigIx(
417
+ * VaultConfigField.MaxCap,
418
+ * data,
419
+ * {
420
+ * vault: vaultPubkey,
421
+ * admin: adminPubkey
422
+ * }
423
+ * );
424
+ * ```
425
+ *
426
+ * @example Update manager management fee (requires LP mint)
427
+ * ```typescript
428
+ * const newManagerManagementFee = 1000; // 10%
429
+ * const data = Buffer.alloc(2);
430
+ * data.writeUInt16LE(newManagerManagementFee, 0);
431
+ *
432
+ * const vaultLpMint = client.findVaultLpMint(vaultPubkey);
433
+ *
434
+ * const ix = await client.createUpdateVaultConfigIx(
435
+ * VaultConfigField.ManagerManagementFee,
436
+ * data,
437
+ * {
438
+ * vault: vaultPubkey,
439
+ * admin: adminPubkey,
440
+ * vaultLpMint: vaultLpMint
441
+ * }
442
+ * );
443
+ * ```
444
+ *
445
+ * @example Update manager (requires Pubkey)
446
+ * ```typescript
447
+ * const newManager = new PublicKey('...');
448
+ * const data = newManager.toBuffer();
449
+ *
450
+ * const ix = await client.createUpdateVaultConfigIx(
451
+ * VaultConfigField.Manager,
452
+ * data,
453
+ * {
454
+ * vault: vaultPubkey,
455
+ * admin: adminPubkey
456
+ * }
457
+ * );
458
+ * ```
459
+ */
460
+ async createUpdateVaultConfigIx(field, data, { vault, admin, vaultLpMint, }) {
461
+ // Check if LP mint is required for this field
462
+ const requiresLpMint = field === types_1.VaultConfigField.ManagerManagementFee ||
463
+ field === types_1.VaultConfigField.AdminManagementFee;
464
+ if (requiresLpMint && !vaultLpMint) {
465
+ throw new Error(`LP mint is required when updating ${field}. Please provide vaultLpMint parameter.`);
466
+ }
467
+ // Build remaining accounts array
468
+ const remainingAccounts = [];
469
+ if (requiresLpMint && vaultLpMint) {
470
+ remainingAccounts.push({
471
+ pubkey: vaultLpMint,
472
+ isSigner: false,
473
+ isWritable: false,
474
+ });
475
+ }
476
+ const fieldToVariant = {
477
+ [types_1.VaultConfigField.MaxCap]: { maxCap: {} },
478
+ [types_1.VaultConfigField.StartAtTs]: { startAtTs: {} },
479
+ [types_1.VaultConfigField.LockedProfitDegradationDuration]: {
480
+ lockedProfitDegradationDuration: {},
481
+ },
482
+ [types_1.VaultConfigField.WithdrawalWaitingPeriod]: {
483
+ withdrawalWaitingPeriod: {},
484
+ },
485
+ [types_1.VaultConfigField.ManagerPerformanceFee]: { managerPerformanceFee: {} },
486
+ [types_1.VaultConfigField.AdminPerformanceFee]: { adminPerformanceFee: {} },
487
+ [types_1.VaultConfigField.ManagerManagementFee]: { managerManagementFee: {} },
488
+ [types_1.VaultConfigField.AdminManagementFee]: { adminManagementFee: {} },
489
+ [types_1.VaultConfigField.RedemptionFee]: { redemptionFee: {} },
490
+ [types_1.VaultConfigField.IssuanceFee]: { issuanceFee: {} },
491
+ [types_1.VaultConfigField.Manager]: { manager: {} },
492
+ };
493
+ const fieldVariant = fieldToVariant[field];
494
+ if (!fieldVariant) {
495
+ throw new Error(`Unknown vault config field: ${field}`);
496
+ }
497
+ return await this.vaultProgram.methods
498
+ .updateVaultConfig(fieldVariant, data)
499
+ .accountsPartial({
500
+ admin,
501
+ vault,
502
+ })
503
+ .remainingAccounts(remainingAccounts)
504
+ .instruction();
505
+ }
383
506
  /**
384
507
  * Creates a deposit instruction for a vault
385
508
  *
@@ -2,7 +2,7 @@
2
2
  "address": "vVoLTRjQmtFpiYoegx285Ze4gsLJ8ZxgFKVcuvmG1a8",
3
3
  "metadata": {
4
4
  "name": "voltr_vault",
5
- "version": "0.1.0",
5
+ "version": "0.2.0",
6
6
  "spec": "0.1.0",
7
7
  "description": "Created with Anchor"
8
8
  },
@@ -3274,6 +3274,70 @@
3274
3274
  }
3275
3275
  ]
3276
3276
  },
3277
+ {
3278
+ "name": "update_vault_config",
3279
+ "discriminator": [
3280
+ 122,
3281
+ 3,
3282
+ 21,
3283
+ 222,
3284
+ 158,
3285
+ 255,
3286
+ 238,
3287
+ 157
3288
+ ],
3289
+ "accounts": [
3290
+ {
3291
+ "name": "admin",
3292
+ "signer": true,
3293
+ "relations": [
3294
+ "vault"
3295
+ ]
3296
+ },
3297
+ {
3298
+ "name": "protocol",
3299
+ "pda": {
3300
+ "seeds": [
3301
+ {
3302
+ "kind": "const",
3303
+ "value": [
3304
+ 112,
3305
+ 114,
3306
+ 111,
3307
+ 116,
3308
+ 111,
3309
+ 99,
3310
+ 111,
3311
+ 108
3312
+ ]
3313
+ }
3314
+ ]
3315
+ }
3316
+ },
3317
+ {
3318
+ "name": "vault",
3319
+ "writable": true
3320
+ },
3321
+ {
3322
+ "name": "rent",
3323
+ "address": "SysvarRent111111111111111111111111111111111"
3324
+ }
3325
+ ],
3326
+ "args": [
3327
+ {
3328
+ "name": "field",
3329
+ "type": {
3330
+ "defined": {
3331
+ "name": "VaultConfigField"
3332
+ }
3333
+ }
3334
+ },
3335
+ {
3336
+ "name": "data",
3337
+ "type": "bytes"
3338
+ }
3339
+ ]
3340
+ },
3277
3341
  {
3278
3342
  "name": "withdraw_strategy",
3279
3343
  "discriminator": [
@@ -4291,6 +4355,19 @@
4291
4355
  237
4292
4356
  ]
4293
4357
  },
4358
+ {
4359
+ "name": "UpdateVaultConfigEvent",
4360
+ "discriminator": [
4361
+ 61,
4362
+ 92,
4363
+ 206,
4364
+ 151,
4365
+ 162,
4366
+ 40,
4367
+ 237,
4368
+ 103
4369
+ ]
4370
+ },
4294
4371
  {
4295
4372
  "name": "UpdateVaultEvent",
4296
4373
  "discriminator": [
@@ -4401,6 +4478,11 @@
4401
4478
  "code": 6013,
4402
4479
  "name": "InvalidInput",
4403
4480
  "msg": "Invalid input."
4481
+ },
4482
+ {
4483
+ "code": 6014,
4484
+ "name": "DivisionByZero",
4485
+ "msg": "Division by zero."
4404
4486
  }
4405
4487
  ],
4406
4488
  "types": [
@@ -5656,6 +5738,38 @@
5656
5738
  ]
5657
5739
  }
5658
5740
  },
5741
+ {
5742
+ "name": "UpdateVaultConfigEvent",
5743
+ "type": {
5744
+ "kind": "struct",
5745
+ "fields": [
5746
+ {
5747
+ "name": "admin",
5748
+ "type": "pubkey"
5749
+ },
5750
+ {
5751
+ "name": "vault",
5752
+ "type": "pubkey"
5753
+ },
5754
+ {
5755
+ "name": "field",
5756
+ "type": "string"
5757
+ },
5758
+ {
5759
+ "name": "old_value",
5760
+ "type": "string"
5761
+ },
5762
+ {
5763
+ "name": "new_value",
5764
+ "type": "string"
5765
+ },
5766
+ {
5767
+ "name": "updated_ts",
5768
+ "type": "u64"
5769
+ }
5770
+ ]
5771
+ }
5772
+ },
5659
5773
  {
5660
5774
  "name": "UpdateVaultEvent",
5661
5775
  "type": {
@@ -5981,6 +6095,47 @@
5981
6095
  ]
5982
6096
  }
5983
6097
  },
6098
+ {
6099
+ "name": "VaultConfigField",
6100
+ "type": {
6101
+ "kind": "enum",
6102
+ "variants": [
6103
+ {
6104
+ "name": "MaxCap"
6105
+ },
6106
+ {
6107
+ "name": "StartAtTs"
6108
+ },
6109
+ {
6110
+ "name": "LockedProfitDegradationDuration"
6111
+ },
6112
+ {
6113
+ "name": "WithdrawalWaitingPeriod"
6114
+ },
6115
+ {
6116
+ "name": "ManagerPerformanceFee"
6117
+ },
6118
+ {
6119
+ "name": "AdminPerformanceFee"
6120
+ },
6121
+ {
6122
+ "name": "ManagerManagementFee"
6123
+ },
6124
+ {
6125
+ "name": "AdminManagementFee"
6126
+ },
6127
+ {
6128
+ "name": "RedemptionFee"
6129
+ },
6130
+ {
6131
+ "name": "IssuanceFee"
6132
+ },
6133
+ {
6134
+ "name": "Manager"
6135
+ }
6136
+ ]
6137
+ }
6138
+ },
5984
6139
  {
5985
6140
  "name": "VaultConfiguration",
5986
6141
  "serialization": "bytemuckunsafe",
@@ -34,3 +34,16 @@ export interface RequestWithdrawVaultArgs {
34
34
  isAmountInLp: boolean;
35
35
  isWithdrawAll: boolean;
36
36
  }
37
+ export declare enum VaultConfigField {
38
+ MaxCap = "maxCap",
39
+ StartAtTs = "startAtTs",
40
+ LockedProfitDegradationDuration = "lockedProfitDegradationDuration",
41
+ WithdrawalWaitingPeriod = "withdrawalWaitingPeriod",
42
+ ManagerPerformanceFee = "managerPerformanceFee",
43
+ AdminPerformanceFee = "adminPerformanceFee",
44
+ ManagerManagementFee = "managerManagementFee",
45
+ AdminManagementFee = "adminManagementFee",
46
+ RedemptionFee = "redemptionFee",
47
+ IssuanceFee = "issuanceFee",
48
+ Manager = "manager"
49
+ }
@@ -1,2 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultConfigField = void 0;
4
+ var VaultConfigField;
5
+ (function (VaultConfigField) {
6
+ VaultConfigField["MaxCap"] = "maxCap";
7
+ VaultConfigField["StartAtTs"] = "startAtTs";
8
+ VaultConfigField["LockedProfitDegradationDuration"] = "lockedProfitDegradationDuration";
9
+ VaultConfigField["WithdrawalWaitingPeriod"] = "withdrawalWaitingPeriod";
10
+ VaultConfigField["ManagerPerformanceFee"] = "managerPerformanceFee";
11
+ VaultConfigField["AdminPerformanceFee"] = "adminPerformanceFee";
12
+ VaultConfigField["ManagerManagementFee"] = "managerManagementFee";
13
+ VaultConfigField["AdminManagementFee"] = "adminManagementFee";
14
+ VaultConfigField["RedemptionFee"] = "redemptionFee";
15
+ VaultConfigField["IssuanceFee"] = "issuanceFee";
16
+ VaultConfigField["Manager"] = "manager";
17
+ })(VaultConfigField || (exports.VaultConfigField = VaultConfigField = {}));
@@ -8,7 +8,7 @@ export type VoltrVault = {
8
8
  "address": "vVoLTRjQmtFpiYoegx285Ze4gsLJ8ZxgFKVcuvmG1a8";
9
9
  "metadata": {
10
10
  "name": "voltrVault";
11
- "version": "0.1.0";
11
+ "version": "0.2.0";
12
12
  "spec": "0.1.0";
13
13
  "description": "Created with Anchor";
14
14
  };
@@ -3280,6 +3280,70 @@ export type VoltrVault = {
3280
3280
  }
3281
3281
  ];
3282
3282
  },
3283
+ {
3284
+ "name": "updateVaultConfig";
3285
+ "discriminator": [
3286
+ 122,
3287
+ 3,
3288
+ 21,
3289
+ 222,
3290
+ 158,
3291
+ 255,
3292
+ 238,
3293
+ 157
3294
+ ];
3295
+ "accounts": [
3296
+ {
3297
+ "name": "admin";
3298
+ "signer": true;
3299
+ "relations": [
3300
+ "vault"
3301
+ ];
3302
+ },
3303
+ {
3304
+ "name": "protocol";
3305
+ "pda": {
3306
+ "seeds": [
3307
+ {
3308
+ "kind": "const";
3309
+ "value": [
3310
+ 112,
3311
+ 114,
3312
+ 111,
3313
+ 116,
3314
+ 111,
3315
+ 99,
3316
+ 111,
3317
+ 108
3318
+ ];
3319
+ }
3320
+ ];
3321
+ };
3322
+ },
3323
+ {
3324
+ "name": "vault";
3325
+ "writable": true;
3326
+ },
3327
+ {
3328
+ "name": "rent";
3329
+ "address": "SysvarRent111111111111111111111111111111111";
3330
+ }
3331
+ ];
3332
+ "args": [
3333
+ {
3334
+ "name": "field";
3335
+ "type": {
3336
+ "defined": {
3337
+ "name": "vaultConfigField";
3338
+ };
3339
+ };
3340
+ },
3341
+ {
3342
+ "name": "data";
3343
+ "type": "bytes";
3344
+ }
3345
+ ];
3346
+ },
3283
3347
  {
3284
3348
  "name": "withdrawStrategy";
3285
3349
  "discriminator": [
@@ -4297,6 +4361,19 @@ export type VoltrVault = {
4297
4361
  237
4298
4362
  ];
4299
4363
  },
4364
+ {
4365
+ "name": "updateVaultConfigEvent";
4366
+ "discriminator": [
4367
+ 61,
4368
+ 92,
4369
+ 206,
4370
+ 151,
4371
+ 162,
4372
+ 40,
4373
+ 237,
4374
+ 103
4375
+ ];
4376
+ },
4300
4377
  {
4301
4378
  "name": "updateVaultEvent";
4302
4379
  "discriminator": [
@@ -4407,6 +4484,11 @@ export type VoltrVault = {
4407
4484
  "code": 6013;
4408
4485
  "name": "invalidInput";
4409
4486
  "msg": "Invalid input.";
4487
+ },
4488
+ {
4489
+ "code": 6014;
4490
+ "name": "divisionByZero";
4491
+ "msg": "Division by zero.";
4410
4492
  }
4411
4493
  ];
4412
4494
  "types": [
@@ -5662,6 +5744,38 @@ export type VoltrVault = {
5662
5744
  ];
5663
5745
  };
5664
5746
  },
5747
+ {
5748
+ "name": "updateVaultConfigEvent";
5749
+ "type": {
5750
+ "kind": "struct";
5751
+ "fields": [
5752
+ {
5753
+ "name": "admin";
5754
+ "type": "pubkey";
5755
+ },
5756
+ {
5757
+ "name": "vault";
5758
+ "type": "pubkey";
5759
+ },
5760
+ {
5761
+ "name": "field";
5762
+ "type": "string";
5763
+ },
5764
+ {
5765
+ "name": "oldValue";
5766
+ "type": "string";
5767
+ },
5768
+ {
5769
+ "name": "newValue";
5770
+ "type": "string";
5771
+ },
5772
+ {
5773
+ "name": "updatedTs";
5774
+ "type": "u64";
5775
+ }
5776
+ ];
5777
+ };
5778
+ },
5665
5779
  {
5666
5780
  "name": "updateVaultEvent";
5667
5781
  "type": {
@@ -5987,6 +6101,47 @@ export type VoltrVault = {
5987
6101
  ];
5988
6102
  };
5989
6103
  },
6104
+ {
6105
+ "name": "vaultConfigField";
6106
+ "type": {
6107
+ "kind": "enum";
6108
+ "variants": [
6109
+ {
6110
+ "name": "maxCap";
6111
+ },
6112
+ {
6113
+ "name": "startAtTs";
6114
+ },
6115
+ {
6116
+ "name": "lockedProfitDegradationDuration";
6117
+ },
6118
+ {
6119
+ "name": "withdrawalWaitingPeriod";
6120
+ },
6121
+ {
6122
+ "name": "managerPerformanceFee";
6123
+ },
6124
+ {
6125
+ "name": "adminPerformanceFee";
6126
+ },
6127
+ {
6128
+ "name": "managerManagementFee";
6129
+ },
6130
+ {
6131
+ "name": "adminManagementFee";
6132
+ },
6133
+ {
6134
+ "name": "redemptionFee";
6135
+ },
6136
+ {
6137
+ "name": "issuanceFee";
6138
+ },
6139
+ {
6140
+ "name": "manager";
6141
+ }
6142
+ ];
6143
+ };
6144
+ },
5990
6145
  {
5991
6146
  "name": "vaultConfiguration";
5992
6147
  "serialization": "bytemuckunsafe";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltr/vault-sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "SDK for interacting with Voltr Protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",