@voltr/vault-sdk 1.0.6 → 1.0.8
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 +1 -0
- package/dist/client.d.ts +72 -0
- package/dist/client.js +80 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -1
- package/dist/idl/voltr_vault.json +1268 -47
- package/dist/types/voltr_vault.d.ts +1268 -47
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -258,6 +258,7 @@ pendingWithdrawals.forEach((withdrawal, index) => {
|
|
|
258
258
|
- `createWithdrawStrategyIx(withdrawArgs, params)`
|
|
259
259
|
- `createInitializeDirectWithdrawStrategyIx(initArgs, params)`
|
|
260
260
|
- `createDirectWithdrawStrategyIx(withdrawArgs, params)`
|
|
261
|
+
- `createCloseStrategyIx(params)`
|
|
261
262
|
- `createRemoveAdaptorIx(params)`
|
|
262
263
|
|
|
263
264
|
#### Account Data
|
package/dist/client.d.ts
CHANGED
|
@@ -124,6 +124,17 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
124
124
|
* ```
|
|
125
125
|
*/
|
|
126
126
|
findRequestWithdrawVaultReceipt(vault: PublicKey, user: PublicKey): PublicKey;
|
|
127
|
+
/**
|
|
128
|
+
* Finds the LP metadata account for a given vault
|
|
129
|
+
* @param vault - Public key of the vault
|
|
130
|
+
* @returns The PDA for the LP metadata account
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const lpMetadataAccount = client.findLpMetadataAccount(vaultPubkey);
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
findLpMetadataAccount(vault: PublicKey): PublicKey;
|
|
127
138
|
/**
|
|
128
139
|
* Creates an instruction to initialize a new vault
|
|
129
140
|
*
|
|
@@ -645,6 +656,63 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
645
656
|
protocolAdmin: PublicKey;
|
|
646
657
|
vault: PublicKey;
|
|
647
658
|
}): Promise<TransactionInstruction>;
|
|
659
|
+
/**
|
|
660
|
+
* Creates an instruction to close a strategy
|
|
661
|
+
* @param {Object} params - Parameters for closing strategy
|
|
662
|
+
* @param {PublicKey} params.payer - Public key of the payer
|
|
663
|
+
* @param {PublicKey} params.manager - Public key of the manager
|
|
664
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
665
|
+
* @param {PublicKey} params.strategy - Public key of the strategy
|
|
666
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for closing strategy
|
|
667
|
+
* @throws {Error} If instruction creation fails
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* ```typescript
|
|
671
|
+
* const ix = await client.createCloseStrategyIx({
|
|
672
|
+
* payer: payerPubkey,
|
|
673
|
+
* manager: managerPubkey,
|
|
674
|
+
* vault: vaultPubkey,
|
|
675
|
+
* strategy: strategyPubkey,
|
|
676
|
+
* });
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
679
|
+
createCloseStrategyIx({ payer, manager, vault, strategy, }: {
|
|
680
|
+
payer: PublicKey;
|
|
681
|
+
manager: PublicKey;
|
|
682
|
+
vault: PublicKey;
|
|
683
|
+
strategy: PublicKey;
|
|
684
|
+
}): Promise<TransactionInstruction>;
|
|
685
|
+
/**
|
|
686
|
+
* Creates an instruction to create LP metadata
|
|
687
|
+
* @param {Object} createLpMetadataArgs - Parameters for creating LP metadata
|
|
688
|
+
* @param {string} createLpMetadataArgs.name - Name of the LP
|
|
689
|
+
* @param {string} createLpMetadataArgs.symbol - Symbol of the LP
|
|
690
|
+
* @param {string} createLpMetadataArgs.uri - URI of the LP metadata
|
|
691
|
+
* @param {Object} params - Parameters for creating LP metadata
|
|
692
|
+
* @param {PublicKey} params.payer - Public key of the payer
|
|
693
|
+
* @param {PublicKey} params.admin - Public key of the admin
|
|
694
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
695
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for creating LP metadata
|
|
696
|
+
* @throws {Error} If instruction creation fails
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* ```typescript
|
|
700
|
+
* const ix = await client.createCreateLpMetadataIx({
|
|
701
|
+
* name: "My LP",
|
|
702
|
+
* symbol: "MYLP",
|
|
703
|
+
* uri: "https://mylp.com/metadata",
|
|
704
|
+
* });
|
|
705
|
+
* ```
|
|
706
|
+
*/
|
|
707
|
+
createCreateLpMetadataIx({ name, symbol, uri, }: {
|
|
708
|
+
name: string;
|
|
709
|
+
symbol: string;
|
|
710
|
+
uri: string;
|
|
711
|
+
}, { payer, admin, vault, }: {
|
|
712
|
+
payer: PublicKey;
|
|
713
|
+
admin: PublicKey;
|
|
714
|
+
vault: PublicKey;
|
|
715
|
+
}): Promise<TransactionInstruction>;
|
|
648
716
|
/**
|
|
649
717
|
* Fetches all strategy init receipt accounts
|
|
650
718
|
* @returns Promise resolving to an array of strategy init receipt accounts
|
|
@@ -765,6 +833,10 @@ export declare class VoltrClient extends AccountUtils {
|
|
|
765
833
|
issuanceFee: number;
|
|
766
834
|
reserved: number[];
|
|
767
835
|
};
|
|
836
|
+
feeUpdate: {
|
|
837
|
+
lastPerformanceFeeUpdateTs: BN;
|
|
838
|
+
lastManagementFeeUpdateTs: BN;
|
|
839
|
+
};
|
|
768
840
|
feeState: {
|
|
769
841
|
accumulatedLpManagerFees: BN;
|
|
770
842
|
accumulatedLpAdminFees: BN;
|
package/dist/client.js
CHANGED
|
@@ -247,6 +247,21 @@ class VoltrClient extends AccountUtils {
|
|
|
247
247
|
const [requestWithdrawVaultReceipt] = web3_js_1.PublicKey.findProgramAddressSync([constants_1.SEEDS.REQUEST_WITHDRAW_VAULT_RECEIPT, vault.toBuffer(), user.toBuffer()], this.vaultProgram.programId);
|
|
248
248
|
return requestWithdrawVaultReceipt;
|
|
249
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Finds the LP metadata account for a given vault
|
|
252
|
+
* @param vault - Public key of the vault
|
|
253
|
+
* @returns The PDA for the LP metadata account
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const lpMetadataAccount = client.findLpMetadataAccount(vaultPubkey);
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
findLpMetadataAccount(vault) {
|
|
261
|
+
const lpMint = this.findVaultLpMint(vault);
|
|
262
|
+
const [lpMetadataAccount] = web3_js_1.PublicKey.findProgramAddressSync([constants_1.SEEDS.METADATA, constants_1.METADATA_PROGRAM_ID.toBuffer(), lpMint.toBuffer()], constants_1.METADATA_PROGRAM_ID);
|
|
263
|
+
return lpMetadataAccount;
|
|
264
|
+
}
|
|
250
265
|
// --------------------------------------- Vault Instructions
|
|
251
266
|
/**
|
|
252
267
|
* Creates an instruction to initialize a new vault
|
|
@@ -831,6 +846,71 @@ class VoltrClient extends AccountUtils {
|
|
|
831
846
|
})
|
|
832
847
|
.instruction();
|
|
833
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Creates an instruction to close a strategy
|
|
851
|
+
* @param {Object} params - Parameters for closing strategy
|
|
852
|
+
* @param {PublicKey} params.payer - Public key of the payer
|
|
853
|
+
* @param {PublicKey} params.manager - Public key of the manager
|
|
854
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
855
|
+
* @param {PublicKey} params.strategy - Public key of the strategy
|
|
856
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for closing strategy
|
|
857
|
+
* @throws {Error} If instruction creation fails
|
|
858
|
+
*
|
|
859
|
+
* @example
|
|
860
|
+
* ```typescript
|
|
861
|
+
* const ix = await client.createCloseStrategyIx({
|
|
862
|
+
* payer: payerPubkey,
|
|
863
|
+
* manager: managerPubkey,
|
|
864
|
+
* vault: vaultPubkey,
|
|
865
|
+
* strategy: strategyPubkey,
|
|
866
|
+
* });
|
|
867
|
+
* ```
|
|
868
|
+
*/
|
|
869
|
+
async createCloseStrategyIx({ payer, manager, vault, strategy, }) {
|
|
870
|
+
return await this.vaultProgram.methods
|
|
871
|
+
.closeStrategy()
|
|
872
|
+
.accounts({
|
|
873
|
+
payer,
|
|
874
|
+
manager,
|
|
875
|
+
vault,
|
|
876
|
+
strategy,
|
|
877
|
+
})
|
|
878
|
+
.instruction();
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Creates an instruction to create LP metadata
|
|
882
|
+
* @param {Object} createLpMetadataArgs - Parameters for creating LP metadata
|
|
883
|
+
* @param {string} createLpMetadataArgs.name - Name of the LP
|
|
884
|
+
* @param {string} createLpMetadataArgs.symbol - Symbol of the LP
|
|
885
|
+
* @param {string} createLpMetadataArgs.uri - URI of the LP metadata
|
|
886
|
+
* @param {Object} params - Parameters for creating LP metadata
|
|
887
|
+
* @param {PublicKey} params.payer - Public key of the payer
|
|
888
|
+
* @param {PublicKey} params.admin - Public key of the admin
|
|
889
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
890
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for creating LP metadata
|
|
891
|
+
* @throws {Error} If instruction creation fails
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```typescript
|
|
895
|
+
* const ix = await client.createCreateLpMetadataIx({
|
|
896
|
+
* name: "My LP",
|
|
897
|
+
* symbol: "MYLP",
|
|
898
|
+
* uri: "https://mylp.com/metadata",
|
|
899
|
+
* });
|
|
900
|
+
* ```
|
|
901
|
+
*/
|
|
902
|
+
async createCreateLpMetadataIx({ name, symbol, uri, }, { payer, admin, vault, }) {
|
|
903
|
+
const metadataAccount = this.findLpMetadataAccount(vault);
|
|
904
|
+
return await this.vaultProgram.methods
|
|
905
|
+
.createLpMetadata(name, symbol, uri)
|
|
906
|
+
.accountsPartial({
|
|
907
|
+
payer,
|
|
908
|
+
vault,
|
|
909
|
+
admin,
|
|
910
|
+
metadataAccount,
|
|
911
|
+
})
|
|
912
|
+
.instruction();
|
|
913
|
+
}
|
|
834
914
|
// --------------------------------------- Account Fetching All
|
|
835
915
|
/**
|
|
836
916
|
* Fetches all strategy init receipt accounts
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { PublicKey } from "@solana/web3.js";
|
|
|
2
2
|
export declare const VAULT_PROGRAM_ID: PublicKey;
|
|
3
3
|
export declare const LENDING_ADAPTOR_PROGRAM_ID: PublicKey;
|
|
4
4
|
export declare const DRIFT_ADAPTOR_PROGRAM_ID: PublicKey;
|
|
5
|
+
export declare const METADATA_PROGRAM_ID: PublicKey;
|
|
5
6
|
export declare const SEEDS: {
|
|
6
7
|
PROTOCOL: Buffer<ArrayBuffer>;
|
|
7
8
|
VAULT_LP_MINT: Buffer<ArrayBuffer>;
|
|
@@ -14,4 +15,5 @@ export declare const SEEDS: {
|
|
|
14
15
|
DIRECT_WITHDRAW_INIT_RECEIPT_SEED: Buffer<ArrayBuffer>;
|
|
15
16
|
REQUEST_WITHDRAW_VAULT_RECEIPT: Buffer<ArrayBuffer>;
|
|
16
17
|
STRATEGY: Buffer<ArrayBuffer>;
|
|
18
|
+
METADATA: Buffer<ArrayBuffer>;
|
|
17
19
|
};
|
package/dist/constants.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SEEDS = exports.DRIFT_ADAPTOR_PROGRAM_ID = exports.LENDING_ADAPTOR_PROGRAM_ID = exports.VAULT_PROGRAM_ID = void 0;
|
|
3
|
+
exports.SEEDS = exports.METADATA_PROGRAM_ID = exports.DRIFT_ADAPTOR_PROGRAM_ID = exports.LENDING_ADAPTOR_PROGRAM_ID = exports.VAULT_PROGRAM_ID = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
exports.VAULT_PROGRAM_ID = new web3_js_1.PublicKey("vVoLTRjQmtFpiYoegx285Ze4gsLJ8ZxgFKVcuvmG1a8");
|
|
6
6
|
exports.LENDING_ADAPTOR_PROGRAM_ID = new web3_js_1.PublicKey("aVoLTRCRt3NnnchvLYH6rMYehJHwM5m45RmLBZq7PGz");
|
|
7
7
|
exports.DRIFT_ADAPTOR_PROGRAM_ID = new web3_js_1.PublicKey("EBN93eXs5fHGBABuajQqdsKRkCgaqtJa8vEFD6vKXiP");
|
|
8
|
+
exports.METADATA_PROGRAM_ID = new web3_js_1.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
8
9
|
exports.SEEDS = {
|
|
9
10
|
PROTOCOL: Buffer.from("protocol"),
|
|
10
11
|
VAULT_LP_MINT: Buffer.from("vault_lp_mint"),
|
|
@@ -18,4 +19,5 @@ exports.SEEDS = {
|
|
|
18
19
|
REQUEST_WITHDRAW_VAULT_RECEIPT: Buffer.from("request_withdraw_vault_receipt"),
|
|
19
20
|
// TODO: Remove this
|
|
20
21
|
STRATEGY: Buffer.from("strategy"),
|
|
22
|
+
METADATA: Buffer.from("metadata"),
|
|
21
23
|
};
|