@voltr/vault-sdk 0.1.5 → 0.1.6
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 +20 -9
- package/dist/client.js +21 -10
- package/dist/idl/voltr_vault.json +16 -0
- package/dist/types/vault.d.ts +6 -2
- package/dist/types/voltr_vault.d.ts +16 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Program, AnchorProvider, Idl, BN } from "@coral-xyz/anchor";
|
|
2
2
|
import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
-
import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, DirectWithdrawStrategyArgs } from "./types";
|
|
3
|
+
import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, DirectWithdrawStrategyArgs, WithdrawVaultArgs } from "./types";
|
|
4
4
|
declare class AccountUtils {
|
|
5
5
|
conn: Connection;
|
|
6
6
|
constructor(conn: Connection);
|
|
@@ -231,7 +231,10 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
231
231
|
/**
|
|
232
232
|
* Creates a withdraw instruction for a vault
|
|
233
233
|
*
|
|
234
|
-
* @param
|
|
234
|
+
* @param {WithdrawVaultArgs} obj - Arguments for withdrawing from the vault
|
|
235
|
+
* @param {BN} obj.amount - Amount of LP tokens to withdraw
|
|
236
|
+
* @param {boolean} obj.isAmountInLp - Whether the amount is in LP tokens
|
|
237
|
+
* @param {boolean} obj.isWithdrawAll - Whether to withdraw all assets
|
|
235
238
|
* @param {Object} params - Withdraw parameters
|
|
236
239
|
* @param {PublicKey} params.userAuthority - Public key of the user authority
|
|
237
240
|
* @param {PublicKey} params.vault - Public key of the vault
|
|
@@ -243,7 +246,11 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
243
246
|
*
|
|
244
247
|
* @example
|
|
245
248
|
* const ix = await client.createWithdrawVaultIx(
|
|
246
|
-
*
|
|
249
|
+
* {
|
|
250
|
+
* amount: new BN('1000000000'),
|
|
251
|
+
* isAmountInLp: true,
|
|
252
|
+
* isWithdrawAll: false,
|
|
253
|
+
* },
|
|
247
254
|
* {
|
|
248
255
|
* userAuthority: userPubkey,
|
|
249
256
|
* vault: vaultPubkey,
|
|
@@ -252,7 +259,7 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
252
259
|
* }
|
|
253
260
|
* );
|
|
254
261
|
*/
|
|
255
|
-
createWithdrawVaultIx(amount:
|
|
262
|
+
createWithdrawVaultIx({ amount, isAmountInLp, isWithdrawAll }: WithdrawVaultArgs, { userAuthority, vault, vaultAssetMint, assetTokenProgram, }: {
|
|
256
263
|
userAuthority: PublicKey;
|
|
257
264
|
vault: PublicKey;
|
|
258
265
|
vaultAssetMint: PublicKey;
|
|
@@ -495,9 +502,11 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
495
502
|
}): Promise<TransactionInstruction>;
|
|
496
503
|
/**
|
|
497
504
|
* Creates an instruction to withdraw assets from a direct withdraw strategy
|
|
498
|
-
* @param {DirectWithdrawStrategyArgs}
|
|
499
|
-
* @param {BN}
|
|
500
|
-
* @param {
|
|
505
|
+
* @param {DirectWithdrawStrategyArgs} directWithdrawArgs - Withdrawal arguments
|
|
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
|
|
509
|
+
* @param {Buffer | null} [directWithdrawArgs.userArgs] - Optional user arguments for the instruction
|
|
501
510
|
* @param {Object} params - Parameters for withdrawing assets from direct withdraw strategy
|
|
502
511
|
* @param {PublicKey} params.user - Public key of the user
|
|
503
512
|
* @param {PublicKey} params.vault - Public key of the vault
|
|
@@ -513,7 +522,9 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
513
522
|
* ```typescript
|
|
514
523
|
* const ix = await client.createDirectWithdrawStrategyIx(
|
|
515
524
|
* {
|
|
516
|
-
*
|
|
525
|
+
* amount: new BN('1000000000'),
|
|
526
|
+
* isAmountInLp: true,
|
|
527
|
+
* isWithdrawAll: false,
|
|
517
528
|
* userArgs: Buffer.from('...')
|
|
518
529
|
* },
|
|
519
530
|
* {
|
|
@@ -528,7 +539,7 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
528
539
|
* );
|
|
529
540
|
* ```
|
|
530
541
|
*/
|
|
531
|
-
createDirectWithdrawStrategyIx({
|
|
542
|
+
createDirectWithdrawStrategyIx({ amount, isAmountInLp, isWithdrawAll, userArgs, }: DirectWithdrawStrategyArgs, { user, vault, strategy, vaultAssetMint, assetTokenProgram, adaptorProgram, remainingAccounts, }: {
|
|
532
543
|
user: PublicKey;
|
|
533
544
|
vault: PublicKey;
|
|
534
545
|
strategy: PublicKey;
|
package/dist/client.js
CHANGED
|
@@ -367,7 +367,10 @@ class VoltrClient extends AccountUtils {
|
|
|
367
367
|
/**
|
|
368
368
|
* Creates a withdraw instruction for a vault
|
|
369
369
|
*
|
|
370
|
-
* @param
|
|
370
|
+
* @param {WithdrawVaultArgs} obj - Arguments for withdrawing from the vault
|
|
371
|
+
* @param {BN} obj.amount - Amount of LP tokens to withdraw
|
|
372
|
+
* @param {boolean} obj.isAmountInLp - Whether the amount is in LP tokens
|
|
373
|
+
* @param {boolean} obj.isWithdrawAll - Whether to withdraw all assets
|
|
371
374
|
* @param {Object} params - Withdraw parameters
|
|
372
375
|
* @param {PublicKey} params.userAuthority - Public key of the user authority
|
|
373
376
|
* @param {PublicKey} params.vault - Public key of the vault
|
|
@@ -379,7 +382,11 @@ class VoltrClient extends AccountUtils {
|
|
|
379
382
|
*
|
|
380
383
|
* @example
|
|
381
384
|
* const ix = await client.createWithdrawVaultIx(
|
|
382
|
-
*
|
|
385
|
+
* {
|
|
386
|
+
* amount: new BN('1000000000'),
|
|
387
|
+
* isAmountInLp: true,
|
|
388
|
+
* isWithdrawAll: false,
|
|
389
|
+
* },
|
|
383
390
|
* {
|
|
384
391
|
* userAuthority: userPubkey,
|
|
385
392
|
* vault: vaultPubkey,
|
|
@@ -388,9 +395,9 @@ class VoltrClient extends AccountUtils {
|
|
|
388
395
|
* }
|
|
389
396
|
* );
|
|
390
397
|
*/
|
|
391
|
-
async createWithdrawVaultIx(amount, { userAuthority, vault, vaultAssetMint, assetTokenProgram, }) {
|
|
398
|
+
async createWithdrawVaultIx({ amount, isAmountInLp, isWithdrawAll }, { userAuthority, vault, vaultAssetMint, assetTokenProgram, }) {
|
|
392
399
|
return await this.vaultProgram.methods
|
|
393
|
-
.withdrawVault(amount)
|
|
400
|
+
.withdrawVault(amount, isAmountInLp, isWithdrawAll)
|
|
394
401
|
.accounts({
|
|
395
402
|
userTransferAuthority: userAuthority,
|
|
396
403
|
vault,
|
|
@@ -655,9 +662,11 @@ class VoltrClient extends AccountUtils {
|
|
|
655
662
|
}
|
|
656
663
|
/**
|
|
657
664
|
* Creates an instruction to withdraw assets from a direct withdraw strategy
|
|
658
|
-
* @param {DirectWithdrawStrategyArgs}
|
|
659
|
-
* @param {BN}
|
|
660
|
-
* @param {
|
|
665
|
+
* @param {DirectWithdrawStrategyArgs} directWithdrawArgs - Withdrawal arguments
|
|
666
|
+
* @param {BN} directWithdrawArgs.amount - Amount of assets to withdraw
|
|
667
|
+
* @param {boolean} directWithdrawArgs.isAmountInLp - Whether the amount is in LP tokens
|
|
668
|
+
* @param {boolean} directWithdrawArgs.isWithdrawAll - Whether to withdraw all assets
|
|
669
|
+
* @param {Buffer | null} [directWithdrawArgs.userArgs] - Optional user arguments for the instruction
|
|
661
670
|
* @param {Object} params - Parameters for withdrawing assets from direct withdraw strategy
|
|
662
671
|
* @param {PublicKey} params.user - Public key of the user
|
|
663
672
|
* @param {PublicKey} params.vault - Public key of the vault
|
|
@@ -673,7 +682,9 @@ class VoltrClient extends AccountUtils {
|
|
|
673
682
|
* ```typescript
|
|
674
683
|
* const ix = await client.createDirectWithdrawStrategyIx(
|
|
675
684
|
* {
|
|
676
|
-
*
|
|
685
|
+
* amount: new BN('1000000000'),
|
|
686
|
+
* isAmountInLp: true,
|
|
687
|
+
* isWithdrawAll: false,
|
|
677
688
|
* userArgs: Buffer.from('...')
|
|
678
689
|
* },
|
|
679
690
|
* {
|
|
@@ -688,9 +699,9 @@ class VoltrClient extends AccountUtils {
|
|
|
688
699
|
* );
|
|
689
700
|
* ```
|
|
690
701
|
*/
|
|
691
|
-
async createDirectWithdrawStrategyIx({
|
|
702
|
+
async createDirectWithdrawStrategyIx({ amount, isAmountInLp, isWithdrawAll, userArgs = null, }, { user, vault, strategy, vaultAssetMint, assetTokenProgram, adaptorProgram = constants_1.DEFAULT_ADAPTOR_PROGRAM_ID, remainingAccounts, }) {
|
|
692
703
|
return await this.vaultProgram.methods
|
|
693
|
-
.directWithdrawStrategy(
|
|
704
|
+
.directWithdrawStrategy(amount, isAmountInLp, isWithdrawAll, userArgs)
|
|
694
705
|
.accounts({
|
|
695
706
|
userTransferAuthority: user,
|
|
696
707
|
strategy,
|
|
@@ -1280,6 +1280,14 @@
|
|
|
1280
1280
|
"name": "amount",
|
|
1281
1281
|
"type": "u64"
|
|
1282
1282
|
},
|
|
1283
|
+
{
|
|
1284
|
+
"name": "is_amount_in_lp",
|
|
1285
|
+
"type": "bool"
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
"name": "is_withdraw_all",
|
|
1289
|
+
"type": "bool"
|
|
1290
|
+
},
|
|
1283
1291
|
{
|
|
1284
1292
|
"name": "user_args",
|
|
1285
1293
|
"type": {
|
|
@@ -2797,6 +2805,14 @@
|
|
|
2797
2805
|
{
|
|
2798
2806
|
"name": "amount",
|
|
2799
2807
|
"type": "u64"
|
|
2808
|
+
},
|
|
2809
|
+
{
|
|
2810
|
+
"name": "amount_in_lp",
|
|
2811
|
+
"type": "bool"
|
|
2812
|
+
},
|
|
2813
|
+
{
|
|
2814
|
+
"name": "withdraw_all",
|
|
2815
|
+
"type": "bool"
|
|
2800
2816
|
}
|
|
2801
2817
|
]
|
|
2802
2818
|
}
|
package/dist/types/vault.d.ts
CHANGED
|
@@ -25,7 +25,11 @@ export interface WithdrawStrategyArgs extends InitializeStrategyArgs {
|
|
|
25
25
|
export interface InitializeDirectWithdrawStrategyArgs extends InitializeStrategyArgs {
|
|
26
26
|
allowUserArgs?: boolean;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
29
|
-
|
|
28
|
+
export interface WithdrawVaultArgs {
|
|
29
|
+
amount: BN;
|
|
30
|
+
isAmountInLp: boolean;
|
|
31
|
+
isWithdrawAll: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface DirectWithdrawStrategyArgs extends WithdrawVaultArgs {
|
|
30
34
|
userArgs?: Buffer | null;
|
|
31
35
|
}
|
|
@@ -1286,6 +1286,14 @@ export type VoltrVault = {
|
|
|
1286
1286
|
"name": "amount";
|
|
1287
1287
|
"type": "u64";
|
|
1288
1288
|
},
|
|
1289
|
+
{
|
|
1290
|
+
"name": "isAmountInLp";
|
|
1291
|
+
"type": "bool";
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
"name": "isWithdrawAll";
|
|
1295
|
+
"type": "bool";
|
|
1296
|
+
},
|
|
1289
1297
|
{
|
|
1290
1298
|
"name": "userArgs";
|
|
1291
1299
|
"type": {
|
|
@@ -2803,6 +2811,14 @@ export type VoltrVault = {
|
|
|
2803
2811
|
{
|
|
2804
2812
|
"name": "amount";
|
|
2805
2813
|
"type": "u64";
|
|
2814
|
+
},
|
|
2815
|
+
{
|
|
2816
|
+
"name": "amountInLp";
|
|
2817
|
+
"type": "bool";
|
|
2818
|
+
},
|
|
2819
|
+
{
|
|
2820
|
+
"name": "withdrawAll";
|
|
2821
|
+
"type": "bool";
|
|
2806
2822
|
}
|
|
2807
2823
|
];
|
|
2808
2824
|
}
|