@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 +178 -0
- package/dist/client.d.ts +563 -0
- package/dist/client.js +729 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +14 -0
- package/dist/idl/voltr_vault.json +3101 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +18 -0
- package/dist/types/vault.d.ts +24 -0
- package/dist/types/vault.js +2 -0
- package/dist/types/voltr_vault.d.ts +3107 -0
- package/dist/types/voltr_vault.js +2 -0
- package/package.json +40 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import { Program, AnchorProvider, Idl, BN } from "@coral-xyz/anchor";
|
|
2
|
+
import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
+
import { VaultParams, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs } from "./types";
|
|
4
|
+
declare class AccountUtils {
|
|
5
|
+
conn: Connection;
|
|
6
|
+
constructor(conn: Connection);
|
|
7
|
+
/**
|
|
8
|
+
* Gets the balance of a Solana account
|
|
9
|
+
* @param publicKey - Public key to check balance for
|
|
10
|
+
* @returns Promise resolving to the account balance in lamports
|
|
11
|
+
* @throws {Error} If fetching balance fails
|
|
12
|
+
*/
|
|
13
|
+
getBalance(publicKey: PublicKey): Promise<number>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Main client for interacting with the Voltr protocol
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* The VoltrClient provides methods for initializing and managing vaults,
|
|
20
|
+
* handling strategies, and performing deposits/withdrawals. It requires
|
|
21
|
+
* a Solana connection and optionally accepts a wallet for signing transactions.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { VoltrClient } from '@voltr/sdk';
|
|
26
|
+
* import { Connection } from '@solana/web3.js';
|
|
27
|
+
*
|
|
28
|
+
* const connection = new Connection('https://api.mainnet-beta.solana.com');
|
|
29
|
+
* const client = new VoltrClient(connection);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class VoltrClient extends AccountUtils {
|
|
33
|
+
provider: AnchorProvider;
|
|
34
|
+
vaultProgram: Program<VoltrVault>;
|
|
35
|
+
vaultIdl: Idl;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new VoltrClient instance
|
|
38
|
+
* @param conn - Solana connection instance
|
|
39
|
+
* @param wallet - Optional keypair for signing transactions
|
|
40
|
+
*/
|
|
41
|
+
constructor(conn: Connection, wallet?: Keypair);
|
|
42
|
+
private setProvider;
|
|
43
|
+
private setPrograms;
|
|
44
|
+
/**
|
|
45
|
+
* Finds the vault LP mint address for a given vault
|
|
46
|
+
* @param vault - Public key of the vault
|
|
47
|
+
* @returns The PDA for the vault's LP mint
|
|
48
|
+
*/
|
|
49
|
+
findVaultLpMint(vault: PublicKey): PublicKey;
|
|
50
|
+
/**
|
|
51
|
+
* Finds the vault's asset idle authority address
|
|
52
|
+
* @param vault - Public key of the vault
|
|
53
|
+
* @returns The PDA for the vault's asset idle authority
|
|
54
|
+
*/
|
|
55
|
+
findVaultAssetIdleAuth(vault: PublicKey): PublicKey;
|
|
56
|
+
/**
|
|
57
|
+
* Finds the vault's LP fee authority address
|
|
58
|
+
* @param vault - Public key of the vault
|
|
59
|
+
* @returns The PDA for the vault's LP fee authority
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const feeAuth = client.findVaultLpFeeAuth(vaultPubkey);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
findVaultLpFeeAuth(vault: PublicKey): PublicKey;
|
|
67
|
+
/**
|
|
68
|
+
* Finds all vault-related addresses
|
|
69
|
+
* @param vault - Public key of the vault
|
|
70
|
+
* @returns Object containing all vault-related PDAs
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const addresses = client.findVaultAddresses(vaultPubkey);
|
|
75
|
+
* console.log(addresses.vaultLpMint.toBase58());
|
|
76
|
+
* console.log(addresses.vaultAssetIdleAuth.toBase58());
|
|
77
|
+
* console.log(addresses.vaultLpFeeAuth.toBase58());
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
findVaultAddresses(vault: PublicKey): {
|
|
81
|
+
vaultLpMint: PublicKey;
|
|
82
|
+
vaultAssetIdleAuth: PublicKey;
|
|
83
|
+
vaultLpFeeAuth: PublicKey;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Finds the vault strategy auth address
|
|
87
|
+
* @param vault - Public key of the vault
|
|
88
|
+
* @param strategy - Public key of the strategy
|
|
89
|
+
* @returns The PDA for the vault strategy auth
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const vaultStrategyAuth = client.findVaultStrategyAuth(vaultPubkey, strategyPubkey);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
findVaultStrategyAuth(vault: PublicKey, strategy: PublicKey): PublicKey;
|
|
97
|
+
/**
|
|
98
|
+
* Finds the strategy init receipt address
|
|
99
|
+
* @param vault - Public key of the vault
|
|
100
|
+
* @param strategy - Public key of the strategy
|
|
101
|
+
* @returns The PDA for the strategy init receipt
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const strategyInitReceipt = client.findStrategyInitReceipt(vaultPubkey, strategyPubkey);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
findStrategyInitReceipt(vault: PublicKey, strategy: PublicKey): PublicKey;
|
|
109
|
+
/**
|
|
110
|
+
* Creates an instruction to initialize a new vault
|
|
111
|
+
*
|
|
112
|
+
* @param {VaultParams} vaultParams - Configuration parameters for the vault
|
|
113
|
+
* @param {VaultConfig} vaultParams.config - Vault configuration settings
|
|
114
|
+
* @param {BN} vaultParams.config.maxCap - Maximum capacity of the vault
|
|
115
|
+
* @param {BN} vaultParams.config.startAtTs - Vault start timestamp in seconds
|
|
116
|
+
* @param {number} vaultParams.config.managerManagementFee - Manager's management fee in basis points (e.g., 50 = 0.5%)
|
|
117
|
+
* @param {number} vaultParams.config.managerPerformanceFee - Manager's performance fee in basis points (e.g., 1000 = 10%)
|
|
118
|
+
* @param {number} vaultParams.config.adminManagementFee - Admin's management fee in basis points (e.g., 50 = 0.5%)
|
|
119
|
+
* @param {number} vaultParams.config.adminPerformanceFee - Admin's performance fee in basis points (e.g., 1000 = 10%)
|
|
120
|
+
* @param {string} vaultParams.name - Name of the vault
|
|
121
|
+
* @param {string} vaultParams.description - Description of the vault
|
|
122
|
+
* @param {Object} params - Additional parameters for initializing the vault
|
|
123
|
+
* @param {Keypair} params.vault - Keypair for the new vault
|
|
124
|
+
* @param {PublicKey} params.vaultAssetMint - Public key of the vault's asset mint
|
|
125
|
+
* @param {PublicKey} params.admin - Public key of the vault admin
|
|
126
|
+
* @param {PublicKey} params.manager - Public key of the vault manager
|
|
127
|
+
* @param {PublicKey} params.payer - Public key of the fee payer
|
|
128
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for initializing the vault
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const ix = await client.createInitializeVaultIx(
|
|
133
|
+
* {
|
|
134
|
+
* config: {
|
|
135
|
+
* maxCap: new BN('1000000000'),
|
|
136
|
+
* startAtTs: new BN(Math.floor(Date.now() / 1000)),
|
|
137
|
+
* managerManagementFee: 50, // 0.5%
|
|
138
|
+
* managerPerformanceFee: 1000, // 10%
|
|
139
|
+
* adminManagementFee: 50, // 0.5%
|
|
140
|
+
* adminPerformanceFee: 1000, // 10%
|
|
141
|
+
* },
|
|
142
|
+
* name: "My Vault",
|
|
143
|
+
* description: "Example vault"
|
|
144
|
+
* },
|
|
145
|
+
* {
|
|
146
|
+
* vault: vaultKeypair,
|
|
147
|
+
* vaultAssetMint: new PublicKey('...'),
|
|
148
|
+
* admin: adminPubkey,
|
|
149
|
+
* manager: managerPubkey,
|
|
150
|
+
* payer: payerPubkey
|
|
151
|
+
* }
|
|
152
|
+
* );
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
createInitializeVaultIx(vaultParams: VaultParams, { vault, vaultAssetMint, admin, manager, payer, }: {
|
|
156
|
+
vault: Keypair;
|
|
157
|
+
vaultAssetMint: PublicKey;
|
|
158
|
+
admin: PublicKey;
|
|
159
|
+
manager: PublicKey;
|
|
160
|
+
payer: PublicKey;
|
|
161
|
+
}): Promise<TransactionInstruction>;
|
|
162
|
+
/**
|
|
163
|
+
* Creates a deposit instruction
|
|
164
|
+
*
|
|
165
|
+
* @param {BN} amount - Amount of tokens to deposit
|
|
166
|
+
* @param {Object} params - Deposit parameters
|
|
167
|
+
* @param {PublicKey} params.userAuthority - Public key of the user's transfer authority
|
|
168
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
169
|
+
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
170
|
+
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
171
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for depositing tokens
|
|
172
|
+
* @throws {Error} If instruction creation fails
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const ix = await client.createDepositIx(
|
|
177
|
+
* new BN('1000000000'),
|
|
178
|
+
* {
|
|
179
|
+
* userAuthority: userPubkey,
|
|
180
|
+
* vault: vaultPubkey,
|
|
181
|
+
* vaultAssetMint: mintPubkey,
|
|
182
|
+
* assetTokenProgram: tokenProgramPubkey
|
|
183
|
+
* }
|
|
184
|
+
* );
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
createDepositIx(amount: BN, { userAuthority, vault, vaultAssetMint, assetTokenProgram, }: {
|
|
188
|
+
userAuthority: PublicKey;
|
|
189
|
+
vault: PublicKey;
|
|
190
|
+
vaultAssetMint: PublicKey;
|
|
191
|
+
assetTokenProgram: PublicKey;
|
|
192
|
+
}): Promise<TransactionInstruction>;
|
|
193
|
+
/**
|
|
194
|
+
* Creates a withdraw instruction
|
|
195
|
+
*
|
|
196
|
+
* @param amount - Amount of LP tokens to withdraw
|
|
197
|
+
* @param {Object} params - Withdraw parameters
|
|
198
|
+
* @param {PublicKey} params.userAuthority - Public key of the user authority
|
|
199
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
200
|
+
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
201
|
+
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
202
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawal
|
|
203
|
+
*
|
|
204
|
+
* @throws {Error} If the instruction creation fails
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* const ix = await client.createWithdrawIx(
|
|
208
|
+
* new BN('1000000000'),
|
|
209
|
+
* {
|
|
210
|
+
* userAuthority: userPubkey,
|
|
211
|
+
* vault: vaultPubkey,
|
|
212
|
+
* vaultAssetMint: mintPubkey,
|
|
213
|
+
* assetTokenProgram: tokenProgramPubkey
|
|
214
|
+
* }
|
|
215
|
+
* );
|
|
216
|
+
*/
|
|
217
|
+
createWithdrawIx(amount: BN, { userAuthority, vault, vaultAssetMint, assetTokenProgram, }: {
|
|
218
|
+
userAuthority: PublicKey;
|
|
219
|
+
vault: PublicKey;
|
|
220
|
+
vaultAssetMint: PublicKey;
|
|
221
|
+
assetTokenProgram: PublicKey;
|
|
222
|
+
}): Promise<TransactionInstruction>;
|
|
223
|
+
/**
|
|
224
|
+
* Creates an instruction to add an adaptor to a vault
|
|
225
|
+
* @param {Object} params - Parameters for adding adaptor to vault
|
|
226
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
227
|
+
* @param {PublicKey} params.payer - Public key of the payer
|
|
228
|
+
* @param {PublicKey} params.adaptorProgram - Public key of the adaptor program
|
|
229
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for adding adaptor to vault
|
|
230
|
+
*
|
|
231
|
+
* @throws {Error} If the instruction creation fails
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const ix = await client.createAddAdaptorIx({
|
|
236
|
+
* vault: vaultPubkey,
|
|
237
|
+
* payer: payerPubkey,
|
|
238
|
+
* adaptorProgram: adaptorProgramPubkey
|
|
239
|
+
* });
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
createAddAdaptorIx({ vault, payer, adaptorProgram, }: {
|
|
243
|
+
vault: PublicKey;
|
|
244
|
+
payer: PublicKey;
|
|
245
|
+
adaptorProgram?: PublicKey;
|
|
246
|
+
}): Promise<TransactionInstruction>;
|
|
247
|
+
/**
|
|
248
|
+
* Creates an instruction to initialize a strategy to a vault
|
|
249
|
+
* @param {InitializeStrategyArgs} initArgs - Arguments for strategy initialization
|
|
250
|
+
* @param {Buffer | null} [initArgs.instructionDiscriminator] - Optional discriminator for the instruction
|
|
251
|
+
* @param {Buffer | null} [initArgs.additionalArgs] - Optional additional arguments for the instruction
|
|
252
|
+
* @param {Object} params - Parameters for initializing strategy to vault
|
|
253
|
+
* @param {PublicKey} params.payer - Public key of the payer
|
|
254
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
255
|
+
* @param {PublicKey} params.manager - Public key of the manager
|
|
256
|
+
* @param {PublicKey} params.strategy - Public key of the strategy
|
|
257
|
+
* @param {PublicKey} params.adaptorProgram - Public key of the adaptor program
|
|
258
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for initializing strategy to vault
|
|
259
|
+
* @throws {Error} If the instruction creation fails
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const ix = await client.createInitializeStrategyIx(
|
|
264
|
+
* {
|
|
265
|
+
* instructionDiscriminator: Buffer.from('...'), // optional
|
|
266
|
+
* additionalArgs: Buffer.from('...') // optional
|
|
267
|
+
* },
|
|
268
|
+
* {
|
|
269
|
+
* payer: payerPubkey,
|
|
270
|
+
* vault: vaultPubkey,
|
|
271
|
+
* manager: managerPubkey,
|
|
272
|
+
* strategy: strategyPubkey,
|
|
273
|
+
* adaptorProgram: adaptorProgramPubkey
|
|
274
|
+
* }
|
|
275
|
+
* );
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
createInitializeStrategyIx({ instructionDiscriminator, additionalArgs, }: InitializeStrategyArgs, { payer, vault, manager, strategy, adaptorProgram, }: {
|
|
279
|
+
payer: PublicKey;
|
|
280
|
+
vault: PublicKey;
|
|
281
|
+
manager: PublicKey;
|
|
282
|
+
strategy: PublicKey;
|
|
283
|
+
adaptorProgram?: PublicKey;
|
|
284
|
+
}): Promise<TransactionInstruction>;
|
|
285
|
+
/**
|
|
286
|
+
* Creates an instruction to deposit assets into a strategy
|
|
287
|
+
*
|
|
288
|
+
* @param {Object} depositArgs - Deposit arguments
|
|
289
|
+
* @param {BN} depositArgs.depositAmount - Amount of assets to deposit
|
|
290
|
+
* @param {Buffer | null} [depositArgs.instructionDiscriminator] - Optional discriminator for the instruction
|
|
291
|
+
* @param {Buffer | null} [depositArgs.additionalArgs] - Optional additional arguments for the instruction
|
|
292
|
+
* @param {Object} params - Strategy deposit parameters
|
|
293
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
294
|
+
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
295
|
+
* @param {PublicKey} params.strategy - Public key of the strategy
|
|
296
|
+
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
297
|
+
* @param {PublicKey} params.adaptorProgram - Public key of the adaptor program
|
|
298
|
+
* @param {Array<{ pubkey: PublicKey, isSigner: boolean, isWritable: boolean }>} params.remainingAccounts - Remaining accounts for the instruction
|
|
299
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for depositing assets into strategy
|
|
300
|
+
* @throws {Error} If the instruction creation fails
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const ix = await client.createDepositStrategyIx(
|
|
305
|
+
* {
|
|
306
|
+
* depositAmount: new BN('1000000000'),
|
|
307
|
+
* instructionDiscriminator: Buffer.from('...'),
|
|
308
|
+
* additionalArgs: Buffer.from('...')
|
|
309
|
+
* },
|
|
310
|
+
* {
|
|
311
|
+
* vault: vaultPubkey,
|
|
312
|
+
* vaultAssetMint: mintPubkey,
|
|
313
|
+
* strategy: strategyPubkey,
|
|
314
|
+
* assetTokenProgram: tokenProgramPubkey,
|
|
315
|
+
* adaptorProgram: adaptorProgramPubkey,
|
|
316
|
+
* remainingAccounts: []
|
|
317
|
+
* }
|
|
318
|
+
* );
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
createDepositStrategyIx({ depositAmount, instructionDiscriminator, additionalArgs, }: DepositStrategyArgs, { vault, vaultAssetMint, strategy, assetTokenProgram, adaptorProgram, remainingAccounts, }: {
|
|
322
|
+
vault: PublicKey;
|
|
323
|
+
vaultAssetMint: PublicKey;
|
|
324
|
+
strategy: PublicKey;
|
|
325
|
+
assetTokenProgram: PublicKey;
|
|
326
|
+
adaptorProgram?: PublicKey;
|
|
327
|
+
remainingAccounts: Array<{
|
|
328
|
+
pubkey: PublicKey;
|
|
329
|
+
isSigner: boolean;
|
|
330
|
+
isWritable: boolean;
|
|
331
|
+
}>;
|
|
332
|
+
}): Promise<TransactionInstruction>;
|
|
333
|
+
/**
|
|
334
|
+
* Creates an instruction to withdraw assets from a strategy
|
|
335
|
+
*
|
|
336
|
+
* @param {Object} withdrawArgs - Withdrawal arguments
|
|
337
|
+
* @param {BN} withdrawArgs.withdrawAmount - Amount of assets to withdraw
|
|
338
|
+
* @param {Buffer | null} [withdrawArgs.instructionDiscriminator] - Optional discriminator for the instruction
|
|
339
|
+
* @param {Buffer | null} [withdrawArgs.additionalArgs] - Optional additional arguments for the instruction
|
|
340
|
+
* @param {Object} params - Strategy withdrawal parameters
|
|
341
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
342
|
+
* @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
|
|
343
|
+
* @param {PublicKey} params.strategy - Public key of the strategy
|
|
344
|
+
* @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
|
|
345
|
+
* @param {PublicKey} params.adaptorProgram - Public key of the adaptor program
|
|
346
|
+
* @param {Array<{ pubkey: PublicKey, isSigner: boolean, isWritable: boolean }>} params.remainingAccounts - Remaining accounts for the instruction
|
|
347
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawing assets from strategy
|
|
348
|
+
* @throws {Error} If the instruction creation fails
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```typescript
|
|
352
|
+
* const ix = await client.createWithdrawStrategyIx(
|
|
353
|
+
* {
|
|
354
|
+
* withdrawAmount: new BN('1000000000'),
|
|
355
|
+
* instructionDiscriminator: Buffer.from('...'),
|
|
356
|
+
* additionalArgs: Buffer.from('...')
|
|
357
|
+
* },
|
|
358
|
+
* {
|
|
359
|
+
* vault: vaultPubkey,
|
|
360
|
+
* vaultAssetMint: mintPubkey,
|
|
361
|
+
* strategy: strategyPubkey,
|
|
362
|
+
* assetTokenProgram: tokenProgramPubkey,
|
|
363
|
+
* adaptorProgram: adaptorProgramPubkey,
|
|
364
|
+
* remainingAccounts: []
|
|
365
|
+
* }
|
|
366
|
+
* );
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
createWithdrawStrategyIx({ withdrawAmount, instructionDiscriminator, additionalArgs, }: WithdrawStrategyArgs, { vault, vaultAssetMint, strategy, assetTokenProgram, adaptorProgram, remainingAccounts, }: {
|
|
370
|
+
vault: PublicKey;
|
|
371
|
+
vaultAssetMint: PublicKey;
|
|
372
|
+
strategy: PublicKey;
|
|
373
|
+
assetTokenProgram: PublicKey;
|
|
374
|
+
adaptorProgram?: PublicKey;
|
|
375
|
+
remainingAccounts: Array<{
|
|
376
|
+
pubkey: PublicKey;
|
|
377
|
+
isSigner: boolean;
|
|
378
|
+
isWritable: boolean;
|
|
379
|
+
}>;
|
|
380
|
+
}): Promise<TransactionInstruction>;
|
|
381
|
+
/**
|
|
382
|
+
* Creates an instruction to remove a strategy from a vault
|
|
383
|
+
* @param {Object} params - Parameters for removing strategy
|
|
384
|
+
* @param {PublicKey} params.vault - Public key of the vault
|
|
385
|
+
* @param {PublicKey} params.adaptorProgram - Public key of the adaptor program
|
|
386
|
+
* @returns {Promise<TransactionInstruction>} Transaction instruction for removing strategy from vault
|
|
387
|
+
* @throws {Error} If instruction creation fails
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* const ix = await client.createRemoveStrategyIx({
|
|
392
|
+
* vault: vaultPubkey,
|
|
393
|
+
* adaptorProgram: adaptorProgramPubkey
|
|
394
|
+
* });
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
createRemoveStrategyIx({ vault, adaptorProgram, }: {
|
|
398
|
+
vault: PublicKey;
|
|
399
|
+
adaptorProgram?: PublicKey;
|
|
400
|
+
}): Promise<TransactionInstruction>;
|
|
401
|
+
/**
|
|
402
|
+
* Fetches all strategy init receipt accounts
|
|
403
|
+
* @returns Promise resolving to an array of strategy init receipt accounts
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* const strategyInitReceiptAccounts = await client.fetchAllStrategyInitReceiptAccounts();
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
fetchAllStrategyInitReceiptAccounts(): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
411
|
+
vault: PublicKey;
|
|
412
|
+
strategy: PublicKey;
|
|
413
|
+
positionValue: BN;
|
|
414
|
+
lastUpdatedTs: BN;
|
|
415
|
+
version: number;
|
|
416
|
+
bump: number;
|
|
417
|
+
vaultStrategyAuthBump: number;
|
|
418
|
+
padding0: number[];
|
|
419
|
+
reserved: number[];
|
|
420
|
+
}>[]>;
|
|
421
|
+
/**
|
|
422
|
+
* Fetches all strategy init receipt accounts of a vault
|
|
423
|
+
* @param vault - Public key of the vault
|
|
424
|
+
* @returns Promise resolving to an array of strategy init receipt accounts
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```typescript
|
|
428
|
+
* const strategyInitReceiptAccounts = await client.fetchAllStrategyInitReceiptAccountsOfVault(vaultPubkey);
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
fetchAllStrategyInitReceiptAccountsOfVault(vault: PublicKey): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
432
|
+
vault: PublicKey;
|
|
433
|
+
strategy: PublicKey;
|
|
434
|
+
positionValue: BN;
|
|
435
|
+
lastUpdatedTs: BN;
|
|
436
|
+
version: number;
|
|
437
|
+
bump: number;
|
|
438
|
+
vaultStrategyAuthBump: number;
|
|
439
|
+
padding0: number[];
|
|
440
|
+
reserved: number[];
|
|
441
|
+
}>[]>;
|
|
442
|
+
/**
|
|
443
|
+
* Fetches all adaptor add receipt accounts of a vault
|
|
444
|
+
* @param vault - Public key of the vault
|
|
445
|
+
* @returns Promise resolving to an array of adaptor add receipt accounts
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* const adaptorAddReceiptAccounts = await client.fetchAllAdaptorAddReceiptAccountsOfVault(vaultPubkey);
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
fetchAllAdaptorAddReceiptAccountsOfVault(vault: PublicKey): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
453
|
+
vault: PublicKey;
|
|
454
|
+
adaptorProgram: PublicKey;
|
|
455
|
+
version: number;
|
|
456
|
+
bump: number;
|
|
457
|
+
padding0: number[];
|
|
458
|
+
reserved: number[];
|
|
459
|
+
}>[]>;
|
|
460
|
+
getPositionAndTotalValuesForVault(vault: PublicKey): Promise<{
|
|
461
|
+
totalValue: any;
|
|
462
|
+
strategies: {
|
|
463
|
+
strategyId: string;
|
|
464
|
+
amount: any;
|
|
465
|
+
}[];
|
|
466
|
+
}>;
|
|
467
|
+
/**
|
|
468
|
+
* Fetches a vault account's data
|
|
469
|
+
* @param vault - Public key of the vault
|
|
470
|
+
* @returns Promise resolving to the vault account data
|
|
471
|
+
*/
|
|
472
|
+
fetchVaultAccount(vault: PublicKey): Promise<{
|
|
473
|
+
name: number[];
|
|
474
|
+
description: number[];
|
|
475
|
+
asset: any;
|
|
476
|
+
lp: any;
|
|
477
|
+
manager: PublicKey;
|
|
478
|
+
admin: PublicKey;
|
|
479
|
+
vaultConfiguration: any;
|
|
480
|
+
feeConfiguration: any;
|
|
481
|
+
lastUpdatedTs: BN;
|
|
482
|
+
version: number;
|
|
483
|
+
padding0: number[];
|
|
484
|
+
reserved: number[];
|
|
485
|
+
}>;
|
|
486
|
+
/**
|
|
487
|
+
* Fetches a strategy init receipt account's data
|
|
488
|
+
* @param strategyInitReceipt - Public key of the strategy init receipt account
|
|
489
|
+
* @returns Promise resolving to the strategy init receipt account data
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* const strategyInitReceiptAccount = await client.fetchStrategyInitReceiptAccount(strategyInitReceiptPubkey);
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
fetchStrategyInitReceiptAccount(strategyInitReceipt: PublicKey): Promise<{
|
|
497
|
+
vault: PublicKey;
|
|
498
|
+
strategy: PublicKey;
|
|
499
|
+
positionValue: BN;
|
|
500
|
+
lastUpdatedTs: BN;
|
|
501
|
+
version: number;
|
|
502
|
+
bump: number;
|
|
503
|
+
vaultStrategyAuthBump: number;
|
|
504
|
+
padding0: number[];
|
|
505
|
+
reserved: number[];
|
|
506
|
+
}>;
|
|
507
|
+
/**
|
|
508
|
+
* Fetches an adaptor add receipt account's data
|
|
509
|
+
* @param adaptorAddReceipt - Public key of the adaptor add receipt account
|
|
510
|
+
* @returns Promise resolving to the adaptor add receipt account data
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```typescript
|
|
514
|
+
* const adaptorAddReceiptAccount = await client.fetchAdaptorAddReceiptAccount(adaptorAddReceiptPubkey);
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
fetchAdaptorAddReceiptAccount(adaptorAddReceipt: PublicKey): Promise<{
|
|
518
|
+
vault: PublicKey;
|
|
519
|
+
adaptorProgram: PublicKey;
|
|
520
|
+
version: number;
|
|
521
|
+
bump: number;
|
|
522
|
+
padding0: number[];
|
|
523
|
+
reserved: number[];
|
|
524
|
+
}>;
|
|
525
|
+
/**
|
|
526
|
+
* Calculates the amount of assets that would be received for a given LP token amount
|
|
527
|
+
*
|
|
528
|
+
* @param vaultPk - Public key of the vault
|
|
529
|
+
* @param lpAmount - Amount of LP tokens to calculate for
|
|
530
|
+
* @returns Promise resolving to the amount of assets that would be received
|
|
531
|
+
*
|
|
532
|
+
* @throws {Error} If LP supply or total assets are invalid
|
|
533
|
+
* @throws {Error} If math overflow occurs during calculation
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```typescript
|
|
537
|
+
* const assetsToReceive = await client.calculateAssetsForWithdraw(
|
|
538
|
+
* vaultPubkey,
|
|
539
|
+
* new BN('1000000000')
|
|
540
|
+
* );
|
|
541
|
+
* ```
|
|
542
|
+
*/
|
|
543
|
+
calculateAssetsForWithdraw(vaultPk: PublicKey, lpAmount: BN): Promise<BN>;
|
|
544
|
+
/**
|
|
545
|
+
* Calculates the amount of LP tokens that would be received for a given asset deposit
|
|
546
|
+
*
|
|
547
|
+
* @param depositAmount - Amount of assets to deposit
|
|
548
|
+
* @param vaultPk - Public key of the vault
|
|
549
|
+
* @returns Promise resolving to the amount of LP tokens that would be received
|
|
550
|
+
*
|
|
551
|
+
* @throws {Error} If math overflow occurs during calculation
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* const lpTokens = await client.calculateLpTokensForDeposit(
|
|
556
|
+
* new BN('1000000000'),
|
|
557
|
+
* vaultPubkey
|
|
558
|
+
* );
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
calculateLpTokensForDeposit(depositAmount: BN, vaultPk: PublicKey): Promise<BN>;
|
|
562
|
+
}
|
|
563
|
+
export {};
|