@voltr/vault-sdk 0.1.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 ADDED
@@ -0,0 +1,178 @@
1
+ # Voltr SDK
2
+
3
+ A TypeScript SDK for interacting with the Voltr protocol on Solana.
4
+
5
+ ## Features
6
+
7
+ - Complete TypeScript support with type definitions
8
+ - Comprehensive vault management functionality
9
+ - Strategy handling and execution
10
+ - Asset deposit and withdrawal operations
11
+ - PDA (Program Derived Address) utilities
12
+ - Account data fetching and parsing
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @voltr/vault-sdk
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import { Connection } from "@solana/web3.js";
24
+ import { VoltrClient } from "@voltr/vault-sdk";
25
+
26
+ // Initialize client
27
+ const connection = new Connection("https://api.mainnet-beta.solana.com");
28
+ const client = new VoltrClient(connection);
29
+ ```
30
+
31
+ ## Usage Examples
32
+
33
+ ### Initialize a New Vault
34
+
35
+ ```typescript
36
+ import { BN } from "@coral-xyz/anchor";
37
+ import { Keypair, PublicKey } from "@solana/web3.js";
38
+
39
+ // Create vault initialization parameters
40
+ const vaultParams = {
41
+ config: {
42
+ maxCap: new BN("1000000000"),
43
+ startAtTs: new BN(Math.floor(Date.now() / 1000)),
44
+ managerManagementFee: 50, // 0.5%
45
+ managerPerformanceFee: 1000, // 10%
46
+ adminManagementFee: 50, // 0.5%
47
+ adminPerformanceFee: 1000, // 10%
48
+ },
49
+ name: "My Vault",
50
+ description: "Example vault",
51
+ };
52
+
53
+ // Create initialization instruction
54
+ const ix = await client.createInitializeVaultIx(vaultParams, {
55
+ vault: vaultKeypair,
56
+ vaultAssetMint: new PublicKey("..."),
57
+ admin: adminPubkey,
58
+ manager: managerPubkey,
59
+ payer: payerPubkey,
60
+ });
61
+ ```
62
+
63
+ ### Deposit Assets
64
+
65
+ ```typescript
66
+ const depositIx = await client.createDepositIx(new BN("1000000000"), {
67
+ userAuthority: userPubkey,
68
+ vault: vaultPubkey,
69
+ vaultAssetMint: mintPubkey,
70
+ assetTokenProgram: tokenProgramPubkey,
71
+ });
72
+ ```
73
+
74
+ ### Withdraw Assets
75
+
76
+ ```typescript
77
+ const withdrawIx = await client.createWithdrawIx(new BN("1000000000"), {
78
+ userAuthority: userPubkey,
79
+ vault: vaultPubkey,
80
+ vaultAssetMint: mintPubkey,
81
+ assetTokenProgram: tokenProgramPubkey,
82
+ });
83
+ ```
84
+
85
+ ### Strategy Management
86
+
87
+ ```typescript
88
+ // Add an adaptor to a vault
89
+ const addAdaptorIx = await client.createAddAdaptorIx({
90
+ vault: vaultPubkey,
91
+ payer: payerPubkey,
92
+ adaptorProgram: adaptorProgramPubkey,
93
+ });
94
+
95
+ // Initialize a strategy
96
+ const initStrategyIx = await client.createInitializeStrategyIx(
97
+ {
98
+ instructionDiscriminator: null,
99
+ additionalArgs: null,
100
+ },
101
+ {
102
+ payer: payerPubkey,
103
+ vault: vaultPubkey,
104
+ manager: managerPubkey,
105
+ strategy: strategyPubkey,
106
+ adaptorProgram: adaptorProgramPubkey,
107
+ }
108
+ );
109
+
110
+ // Deposit into a strategy
111
+ const depositStrategyIx = await client.createDepositStrategyIx(
112
+ {
113
+ depositAmount: new BN("1000000000"),
114
+ instructionDiscriminator: null,
115
+ additionalArgs: null,
116
+ },
117
+ {
118
+ vault: vaultPubkey,
119
+ vaultAssetMint: mintPubkey,
120
+ strategy: strategyPubkey,
121
+ assetTokenProgram: tokenProgramPubkey,
122
+ adaptorProgram: adaptorProgramPubkey,
123
+ remainingAccounts: [],
124
+ }
125
+ );
126
+ ```
127
+
128
+ ## API Reference
129
+
130
+ ### VoltrClient
131
+
132
+ The main client class for interacting with the Voltr protocol.
133
+
134
+ #### Constructor
135
+
136
+ ```typescript
137
+ constructor(conn: Connection, wallet?: Keypair)
138
+ ```
139
+
140
+ #### Vault Management Methods
141
+
142
+ - `createInitializeVaultIx(vaultParams: VaultParams, params: InitializeParams)`
143
+ - `createDepositIx(amount: BN, params: DepositParams)`
144
+ - `createWithdrawIx(amount: BN, params: WithdrawParams)`
145
+
146
+ #### Strategy Management Methods
147
+
148
+ - `createAddAdaptorIx(params: AddAdaptorParams)`
149
+ - `createInitializeStrategyIx(initArgs: InitializeStrategyArgs, params: InitStrategyParams)`
150
+ - `createDepositStrategyIx(depositArgs: depositStrategyArgs, params: DepositStrategyParams)`
151
+ - `createWithdrawStrategyIx(withdrawArgs: withdrawStrategyArgs, params: WithdrawStrategyParams)`
152
+ - `createRemoveStrategyIx(params: RemoveStrategyParams)`
153
+
154
+ #### Account Fetching Methods
155
+
156
+ - `fetchVaultAccount(vault: PublicKey)`
157
+ - `fetchAllStrategyInitReceiptAccounts()`
158
+ - `fetchAllStrategyInitReceiptAccountsOfVault(vault: PublicKey)`
159
+ - `fetchAllAdaptorAddReceiptAccountsOfVault(vault: PublicKey)`
160
+ - `getPositionAndTotalValuesForVault(vault: PublicKey)`
161
+
162
+ #### PDA Finding Methods
163
+
164
+ - `findVaultLpMint(vault: PublicKey)`
165
+ - `findVaultAssetIdleAuth(vault: PublicKey)`
166
+ - `findVaultLpFeeAuth(vault: PublicKey)`
167
+ - `findVaultAddresses(vault: PublicKey)`
168
+ - `findVaultStrategyAuth(vault: PublicKey, strategy: PublicKey)`
169
+ - `findStrategyInitReceipt(vault: PublicKey, strategy: PublicKey)`
170
+
171
+ #### Calculation Methods
172
+
173
+ - `calculateAssetsForWithdraw(vaultPk: PublicKey, lpAmount: BN)`
174
+ - `calculateLpTokensForDeposit(depositAmount: BN, vaultPk: PublicKey)`
175
+
176
+ ## License
177
+
178
+ [MIT](https://choosealicense.com/licenses/mit/)