@voltr/vault-sdk 1.0.17 → 1.0.19
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/client.d.ts +78 -48
- package/dist/client.js +77 -56
- package/dist/idl/voltr_vault.json +830 -71
- package/dist/types/vault.d.ts +3 -1
- package/dist/types/vault.js +2 -0
- package/dist/types/voltr_vault.d.ts +830 -71
- package/package.json +2 -4
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,
|
|
4
|
+
import { VaultParams, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, RequestWithdrawVaultArgs, VaultConfigField } from "./types";
|
|
5
5
|
declare class AccountUtils {
|
|
6
6
|
conn: Connection;
|
|
7
7
|
constructor(conn: Connection);
|
|
@@ -196,53 +196,6 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
196
196
|
manager: PublicKey;
|
|
197
197
|
payer: PublicKey;
|
|
198
198
|
}): Promise<TransactionInstruction>;
|
|
199
|
-
/**
|
|
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
|
-
*
|
|
205
|
-
* @param {VaultConfig} vaultConfig - Configuration parameters for the vault
|
|
206
|
-
* @param {BN} vaultConfig.maxCap - Maximum capacity of the vault
|
|
207
|
-
* @param {BN} vaultConfig.startAtTs - Vault start timestamp in seconds
|
|
208
|
-
* @param {number} vaultConfig.managerManagementFee - Manager's management fee in basis points (e.g., 50 = 0.5%)
|
|
209
|
-
* @param {number} vaultConfig.managerPerformanceFee - Manager's performance fee in basis points (e.g., 1000 = 10%)
|
|
210
|
-
* @param {number} vaultConfig.adminManagementFee - Admin's management fee in basis points (e.g., 50 = 0.5%)
|
|
211
|
-
* @param {number} vaultConfig.adminPerformanceFee - Admin's performance fee in basis points (e.g., 1000 = 10%)
|
|
212
|
-
* @param {Object} params - Parameters for updating the vault
|
|
213
|
-
* @param {PublicKey} params.vault - Public key of the vault
|
|
214
|
-
* @param {PublicKey} params.admin - Public key of the vault admin
|
|
215
|
-
* @returns Transaction instruction for updating the vault
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* ```typescript
|
|
219
|
-
* // DEPRECATED - Use createUpdateVaultConfigIx instead
|
|
220
|
-
* const ix = await client.createUpdateVaultIx(
|
|
221
|
-
* {
|
|
222
|
-
* maxCap: new BN('1000000000'),
|
|
223
|
-
* startAtTs: new BN(Math.floor(Date.now() / 1000)),
|
|
224
|
-
* managerManagementFee: 50,
|
|
225
|
-
* managerPerformanceFee: 1000,
|
|
226
|
-
* adminManagementFee: 50,
|
|
227
|
-
* adminPerformanceFee: 1000,
|
|
228
|
-
* },
|
|
229
|
-
* { vault: vaultPubkey, admin: adminPubkey }
|
|
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
|
-
* );
|
|
240
|
-
* ```
|
|
241
|
-
*/
|
|
242
|
-
createUpdateVaultIx(vaultConfig: VaultConfig, { vault, admin, }: {
|
|
243
|
-
vault: PublicKey;
|
|
244
|
-
admin: PublicKey;
|
|
245
|
-
}): Promise<TransactionInstruction>;
|
|
246
199
|
/**
|
|
247
200
|
* Creates an instruction to update a specific vault configuration field
|
|
248
201
|
*
|
|
@@ -310,6 +263,27 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
310
263
|
admin: PublicKey;
|
|
311
264
|
vaultLpMint?: PublicKey;
|
|
312
265
|
}): Promise<TransactionInstruction>;
|
|
266
|
+
/**
|
|
267
|
+
* Creates an instruction for the pending admin to accept the vault admin role
|
|
268
|
+
*
|
|
269
|
+
* @param {Object} params - Parameters for accepting vault admin
|
|
270
|
+
* @param {PublicKey} params.pendingAdmin - Public key of the pending admin (must be signer)
|
|
271
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
272
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for accepting vault admin
|
|
273
|
+
* @throws {Error} If instruction creation fails
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const ix = await client.createAcceptVaultAdminIx({
|
|
278
|
+
* pendingAdmin: pendingAdminPubkey,
|
|
279
|
+
* vault: vaultPubkey,
|
|
280
|
+
* });
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
createAcceptVaultAdminIx({ pendingAdmin, vault, }: {
|
|
284
|
+
pendingAdmin: PublicKey;
|
|
285
|
+
vault: PublicKey;
|
|
286
|
+
}): Promise<TransactionInstruction>;
|
|
313
287
|
/**
|
|
314
288
|
* Creates a deposit instruction for a vault
|
|
315
289
|
*
|
|
@@ -708,6 +682,57 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
708
682
|
isWritable: boolean;
|
|
709
683
|
}>;
|
|
710
684
|
}): Promise<TransactionInstruction>;
|
|
685
|
+
/**
|
|
686
|
+
* Creates an instruction to withdraw assets from a strategy via direct withdrawal with tolerance
|
|
687
|
+
* @param {Object} args - Arguments for the withdrawal
|
|
688
|
+
* @param {Buffer | null} args.userArgs - Optional user arguments
|
|
689
|
+
* @param {BN} args.tolerance - Tolerance amount for the withdrawal
|
|
690
|
+
* @param {Object} params - Parameters for withdrawing assets from direct withdraw strategy
|
|
691
|
+
* @param {PublicKey} params.user - Public key of the user
|
|
692
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
693
|
+
* @param {PublicKey} params.strategy - Public key of the strategy
|
|
694
|
+
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
695
|
+
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
696
|
+
* @param {PublicKey} params.adaptorProgram - Public key of the adaptor program
|
|
697
|
+
* @param {Array<{ pubkey: PublicKey, isSigner: boolean, isWritable: boolean }>} params.remainingAccounts - Remaining accounts for the instruction
|
|
698
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawing assets from direct withdraw strategy with tolerance
|
|
699
|
+
* @throws {Error} If instruction creation fails
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```typescript
|
|
703
|
+
* const ix = await client.createDirectWithdrawStrategyWithToleranceIx(
|
|
704
|
+
* {
|
|
705
|
+
* userArgs: Buffer.from('...'),
|
|
706
|
+
* tolerance: new BN(1)
|
|
707
|
+
* },
|
|
708
|
+
* {
|
|
709
|
+
* user: userPubkey,
|
|
710
|
+
* vault: vaultPubkey,
|
|
711
|
+
* strategy: strategyPubkey,
|
|
712
|
+
* vaultAssetMint: mintPubkey,
|
|
713
|
+
* assetTokenProgram: tokenProgramPubkey,
|
|
714
|
+
* adaptorProgram: adaptorProgramPubkey,
|
|
715
|
+
* remainingAccounts: []
|
|
716
|
+
* }
|
|
717
|
+
* );
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
720
|
+
createDirectWithdrawStrategyWithToleranceIx({ userArgs, tolerance }: {
|
|
721
|
+
userArgs?: Buffer | null;
|
|
722
|
+
tolerance: BN;
|
|
723
|
+
}, { user, vault, strategy, vaultAssetMint, assetTokenProgram, adaptorProgram, remainingAccounts, }: {
|
|
724
|
+
user: PublicKey;
|
|
725
|
+
vault: PublicKey;
|
|
726
|
+
strategy: PublicKey;
|
|
727
|
+
vaultAssetMint: PublicKey;
|
|
728
|
+
assetTokenProgram: PublicKey;
|
|
729
|
+
adaptorProgram?: PublicKey;
|
|
730
|
+
remainingAccounts: Array<{
|
|
731
|
+
pubkey: PublicKey;
|
|
732
|
+
isSigner: boolean;
|
|
733
|
+
isWritable: boolean;
|
|
734
|
+
}>;
|
|
735
|
+
}): Promise<TransactionInstruction>;
|
|
711
736
|
/**
|
|
712
737
|
* Creates an instruction to harvest fees from a vault
|
|
713
738
|
* @param {Object} params - Parameters for harvesting fees
|
|
@@ -916,6 +941,7 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
916
941
|
mintAuthBump: number;
|
|
917
942
|
reserved: number[];
|
|
918
943
|
};
|
|
944
|
+
pendingAdmin: PublicKey;
|
|
919
945
|
manager: PublicKey;
|
|
920
946
|
admin: PublicKey;
|
|
921
947
|
vaultConfiguration: {
|
|
@@ -923,6 +949,7 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
923
949
|
startAtTs: BN;
|
|
924
950
|
lockedProfitDegradationDuration: BN;
|
|
925
951
|
withdrawalWaitingPeriod: BN;
|
|
952
|
+
disabledOperations: number;
|
|
926
953
|
reserved: number[];
|
|
927
954
|
};
|
|
928
955
|
feeConfiguration: {
|
|
@@ -932,6 +959,8 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
932
959
|
adminManagementFee: number;
|
|
933
960
|
redemptionFee: number;
|
|
934
961
|
issuanceFee: number;
|
|
962
|
+
protocolPerformanceFee: number;
|
|
963
|
+
protocolManagementFee: number;
|
|
935
964
|
reserved: number[];
|
|
936
965
|
};
|
|
937
966
|
feeUpdate: {
|
|
@@ -944,6 +973,7 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
944
973
|
accumulatedLpProtocolFees: BN;
|
|
945
974
|
reserved: number[];
|
|
946
975
|
};
|
|
976
|
+
deadWeight: BN;
|
|
947
977
|
highWaterMark: {
|
|
948
978
|
highestAssetPerLpDecimalBits: BN;
|
|
949
979
|
lastUpdatedTs: BN;
|
package/dist/client.js
CHANGED
|
@@ -339,62 +339,6 @@ class VoltrClient extends AccountUtils {
|
|
|
339
339
|
})
|
|
340
340
|
.instruction();
|
|
341
341
|
}
|
|
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
|
-
*
|
|
348
|
-
* @param {VaultConfig} vaultConfig - Configuration parameters for the vault
|
|
349
|
-
* @param {BN} vaultConfig.maxCap - Maximum capacity of the vault
|
|
350
|
-
* @param {BN} vaultConfig.startAtTs - Vault start timestamp in seconds
|
|
351
|
-
* @param {number} vaultConfig.managerManagementFee - Manager's management fee in basis points (e.g., 50 = 0.5%)
|
|
352
|
-
* @param {number} vaultConfig.managerPerformanceFee - Manager's performance fee in basis points (e.g., 1000 = 10%)
|
|
353
|
-
* @param {number} vaultConfig.adminManagementFee - Admin's management fee in basis points (e.g., 50 = 0.5%)
|
|
354
|
-
* @param {number} vaultConfig.adminPerformanceFee - Admin's performance fee in basis points (e.g., 1000 = 10%)
|
|
355
|
-
* @param {Object} params - Parameters for updating the vault
|
|
356
|
-
* @param {PublicKey} params.vault - Public key of the vault
|
|
357
|
-
* @param {PublicKey} params.admin - Public key of the vault admin
|
|
358
|
-
* @returns Transaction instruction for updating the vault
|
|
359
|
-
*
|
|
360
|
-
* @example
|
|
361
|
-
* ```typescript
|
|
362
|
-
* // DEPRECATED - Use createUpdateVaultConfigIx instead
|
|
363
|
-
* const ix = await client.createUpdateVaultIx(
|
|
364
|
-
* {
|
|
365
|
-
* maxCap: new BN('1000000000'),
|
|
366
|
-
* startAtTs: new BN(Math.floor(Date.now() / 1000)),
|
|
367
|
-
* managerManagementFee: 50,
|
|
368
|
-
* managerPerformanceFee: 1000,
|
|
369
|
-
* adminManagementFee: 50,
|
|
370
|
-
* adminPerformanceFee: 1000,
|
|
371
|
-
* },
|
|
372
|
-
* { vault: vaultPubkey, admin: adminPubkey }
|
|
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
|
-
* );
|
|
383
|
-
* ```
|
|
384
|
-
*/
|
|
385
|
-
async createUpdateVaultIx(vaultConfig, { vault, admin, }) {
|
|
386
|
-
const lpMint = this.findVaultLpMint(vault);
|
|
387
|
-
return await this.vaultProgram.methods
|
|
388
|
-
.updateVault(vaultConfig)
|
|
389
|
-
.accountsPartial({
|
|
390
|
-
admin,
|
|
391
|
-
vault,
|
|
392
|
-
})
|
|
393
|
-
.remainingAccounts([
|
|
394
|
-
{ pubkey: lpMint, isSigner: false, isWritable: false },
|
|
395
|
-
])
|
|
396
|
-
.instruction();
|
|
397
|
-
}
|
|
398
342
|
/**
|
|
399
343
|
* Creates an instruction to update a specific vault configuration field
|
|
400
344
|
*
|
|
@@ -489,6 +433,8 @@ class VoltrClient extends AccountUtils {
|
|
|
489
433
|
[types_1.VaultConfigField.RedemptionFee]: { redemptionFee: {} },
|
|
490
434
|
[types_1.VaultConfigField.IssuanceFee]: { issuanceFee: {} },
|
|
491
435
|
[types_1.VaultConfigField.Manager]: { manager: {} },
|
|
436
|
+
[types_1.VaultConfigField.PendingAdmin]: { pendingAdmin: {} },
|
|
437
|
+
[types_1.VaultConfigField.DisabledOperations]: { disabledOperations: {} },
|
|
492
438
|
};
|
|
493
439
|
const fieldVariant = fieldToVariant[field];
|
|
494
440
|
if (!fieldVariant) {
|
|
@@ -503,6 +449,32 @@ class VoltrClient extends AccountUtils {
|
|
|
503
449
|
.remainingAccounts(remainingAccounts)
|
|
504
450
|
.instruction();
|
|
505
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Creates an instruction for the pending admin to accept the vault admin role
|
|
454
|
+
*
|
|
455
|
+
* @param {Object} params - Parameters for accepting vault admin
|
|
456
|
+
* @param {PublicKey} params.pendingAdmin - Public key of the pending admin (must be signer)
|
|
457
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
458
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for accepting vault admin
|
|
459
|
+
* @throws {Error} If instruction creation fails
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```typescript
|
|
463
|
+
* const ix = await client.createAcceptVaultAdminIx({
|
|
464
|
+
* pendingAdmin: pendingAdminPubkey,
|
|
465
|
+
* vault: vaultPubkey,
|
|
466
|
+
* });
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
async createAcceptVaultAdminIx({ pendingAdmin, vault, }) {
|
|
470
|
+
return await this.vaultProgram.methods
|
|
471
|
+
.acceptVaultAdmin()
|
|
472
|
+
.accountsStrict({
|
|
473
|
+
pendingAdmin,
|
|
474
|
+
vault,
|
|
475
|
+
})
|
|
476
|
+
.instruction();
|
|
477
|
+
}
|
|
506
478
|
/**
|
|
507
479
|
* Creates a deposit instruction for a vault
|
|
508
480
|
*
|
|
@@ -939,6 +911,55 @@ class VoltrClient extends AccountUtils {
|
|
|
939
911
|
.remainingAccounts(remainingAccounts)
|
|
940
912
|
.instruction();
|
|
941
913
|
}
|
|
914
|
+
/**
|
|
915
|
+
* Creates an instruction to withdraw assets from a strategy via direct withdrawal with tolerance
|
|
916
|
+
* @param {Object} args - Arguments for the withdrawal
|
|
917
|
+
* @param {Buffer | null} args.userArgs - Optional user arguments
|
|
918
|
+
* @param {BN} args.tolerance - Tolerance amount for the withdrawal
|
|
919
|
+
* @param {Object} params - Parameters for withdrawing assets from direct withdraw strategy
|
|
920
|
+
* @param {PublicKey} params.user - Public key of the user
|
|
921
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
922
|
+
* @param {PublicKey} params.strategy - Public key of the strategy
|
|
923
|
+
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
924
|
+
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
925
|
+
* @param {PublicKey} params.adaptorProgram - Public key of the adaptor program
|
|
926
|
+
* @param {Array<{ pubkey: PublicKey, isSigner: boolean, isWritable: boolean }>} params.remainingAccounts - Remaining accounts for the instruction
|
|
927
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawing assets from direct withdraw strategy with tolerance
|
|
928
|
+
* @throws {Error} If instruction creation fails
|
|
929
|
+
*
|
|
930
|
+
* @example
|
|
931
|
+
* ```typescript
|
|
932
|
+
* const ix = await client.createDirectWithdrawStrategyWithToleranceIx(
|
|
933
|
+
* {
|
|
934
|
+
* userArgs: Buffer.from('...'),
|
|
935
|
+
* tolerance: new BN(1)
|
|
936
|
+
* },
|
|
937
|
+
* {
|
|
938
|
+
* user: userPubkey,
|
|
939
|
+
* vault: vaultPubkey,
|
|
940
|
+
* strategy: strategyPubkey,
|
|
941
|
+
* vaultAssetMint: mintPubkey,
|
|
942
|
+
* assetTokenProgram: tokenProgramPubkey,
|
|
943
|
+
* adaptorProgram: adaptorProgramPubkey,
|
|
944
|
+
* remainingAccounts: []
|
|
945
|
+
* }
|
|
946
|
+
* );
|
|
947
|
+
* ```
|
|
948
|
+
*/
|
|
949
|
+
async createDirectWithdrawStrategyWithToleranceIx({ userArgs = null, tolerance }, { user, vault, strategy, vaultAssetMint, assetTokenProgram, adaptorProgram = constants_1.LENDING_ADAPTOR_PROGRAM_ID, remainingAccounts, }) {
|
|
950
|
+
return await this.vaultProgram.methods
|
|
951
|
+
.directWithdrawStrategyWithTolerance(userArgs, tolerance)
|
|
952
|
+
.accounts({
|
|
953
|
+
userTransferAuthority: user,
|
|
954
|
+
strategy,
|
|
955
|
+
adaptorProgram,
|
|
956
|
+
vault,
|
|
957
|
+
vaultAssetMint,
|
|
958
|
+
assetTokenProgram,
|
|
959
|
+
})
|
|
960
|
+
.remainingAccounts(remainingAccounts)
|
|
961
|
+
.instruction();
|
|
962
|
+
}
|
|
942
963
|
/**
|
|
943
964
|
* Creates an instruction to harvest fees from a vault
|
|
944
965
|
* @param {Object} params - Parameters for harvesting fees
|