@voltr/vault-sdk 0.1.6 → 1.0.0

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 CHANGED
@@ -41,10 +41,14 @@ const vaultParams = {
41
41
  config: {
42
42
  maxCap: new BN("1000000000"),
43
43
  startAtTs: new BN(Math.floor(Date.now() / 1000)),
44
+ lockedProfitDegradationDuration: new BN(3600), // 1 hour
44
45
  managerManagementFee: 50, // 0.5%
45
46
  managerPerformanceFee: 1000, // 10%
46
47
  adminManagementFee: 50, // 0.5%
47
48
  adminPerformanceFee: 1000, // 10%
49
+ redemptionFeePercentageBps: 10, // 0.1%
50
+ issuanceFeePercentageBps: 10, // 0.1%
51
+ withdrawalWaitingPeriod: new BN(3600), // 1 hour
48
52
  },
49
53
  name: "My Vault",
50
54
  description: "Example vault",
@@ -116,8 +120,30 @@ const depositIx = await client.createDepositIx(new BN("1000000000"), {
116
120
  assetTokenProgram: tokenProgramPubkey,
117
121
  });
118
122
 
119
- // Withdraw assets
120
- const withdrawIx = await client.createWithdrawIx(new BN("1000000000"), {
123
+ // Request withdraw assets
124
+ const requestWithdrawIx = await client.createRequestWithdrawVaultIx(
125
+ {
126
+ amount: new BN("1000000000"),
127
+ isAmountInLp: false,
128
+ isWithdrawAll: false,
129
+ },
130
+ {
131
+ payer: payerPubkey,
132
+ userAuthority: userPubkey,
133
+ vault: vaultPubkey,
134
+ }
135
+ );
136
+
137
+ // Cancel withdraw request
138
+ const cancelRequestWithdrawIx = await client.createCancelRequestWithdrawVaultIx(
139
+ {
140
+ userAuthority: userPubkey,
141
+ vault: vaultPubkey,
142
+ }
143
+ );
144
+
145
+ // Withdraw from vault
146
+ const withdrawIx = await client.createWithdrawIx({
121
147
  userAuthority: userPubkey,
122
148
  vault: vaultPubkey,
123
149
  vaultAssetMint: mintPubkey,
@@ -127,7 +153,6 @@ const withdrawIx = await client.createWithdrawIx(new BN("1000000000"), {
127
153
  // Direct withdraw from strategy
128
154
  const directWithdrawIx = await client.createDirectWithdrawStrategyIx(
129
155
  {
130
- withdrawAmount: new BN("1000000000"),
131
156
  userArgs: null,
132
157
  },
133
158
  {
@@ -158,8 +183,9 @@ console.log("Strategy Positions:", values.strategies);
158
183
  #### Vault Management
159
184
 
160
185
  - `createInitializeVaultIx(vaultParams, params)`
161
- - `createDepositIx(amount, params)`
162
- - `createWithdrawIx(amount, params)`
186
+ - `createRequestWithdrawVaultIx(requestWithdrawArgs, params)`
187
+ - `createCancelRequestWithdrawVaultIx(params)`
188
+ - `createWithdrawVaultIx(params)`
163
189
 
164
190
  #### Strategy Management
165
191
 
@@ -191,7 +217,8 @@ console.log("Strategy Positions:", values.strategies);
191
217
  #### Calculations
192
218
 
193
219
  - `calculateAssetsForWithdraw(vaultPk, lpAmount)`
194
- - `calculateLpTokensForDeposit(depositAmount, vaultPk)`
220
+ - `calculateLpForWithdraw(vaultPk, assetAmount)`
221
+ - `calculateLpForDeposit(vaultPk, assetAmount)`
195
222
 
196
223
  ## License
197
224
 
package/dist/client.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Program, AnchorProvider, Idl, BN } from "@coral-xyz/anchor";
1
+ import { Program, AnchorProvider, Idl } from "@coral-xyz/anchor";
2
+ import BN from "bn.js";
2
3
  import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
- import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, DirectWithdrawStrategyArgs, WithdrawVaultArgs } from "./types";
4
+ import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, RequestWithdrawVaultArgs } from "./types";
4
5
  declare class AccountUtils {
5
6
  conn: Connection;
6
7
  constructor(conn: Connection);
@@ -111,6 +112,18 @@ export declare class VoltrClient extends AccountUtils {
111
112
  strategyInitReceipt: PublicKey;
112
113
  directWithdrawInitReceipt: PublicKey;
113
114
  };
115
+ /**
116
+ * Finds the request withdraw vault receipt address
117
+ * @param vault - Public key of the vault
118
+ * @param user - Public key of the user
119
+ * @returns The PDA for the request withdraw vault receipt
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const requestWithdrawVaultReceipt = client.findRequestWithdrawVaultReceipt(vaultPubkey, userPubkey);
124
+ * ```
125
+ */
126
+ findRequestWithdrawVaultReceipt(vault: PublicKey, user: PublicKey): PublicKey;
114
127
  /**
115
128
  * Creates an instruction to initialize a new vault
116
129
  *
@@ -118,10 +131,14 @@ export declare class VoltrClient extends AccountUtils {
118
131
  * @param {VaultConfig} vaultParams.config - Vault configuration settings
119
132
  * @param {BN} vaultParams.config.maxCap - Maximum capacity of the vault
120
133
  * @param {BN} vaultParams.config.startAtTs - Vault start timestamp in seconds
134
+ * @param {BN} vaultParams.config.lockedProfitDegradationDuration - Locked profit degradation duration in seconds
121
135
  * @param {number} vaultParams.config.managerManagementFee - Manager's management fee in basis points (e.g., 50 = 0.5%)
122
136
  * @param {number} vaultParams.config.managerPerformanceFee - Manager's performance fee in basis points (e.g., 1000 = 10%)
123
137
  * @param {number} vaultParams.config.adminManagementFee - Admin's management fee in basis points (e.g., 50 = 0.5%)
124
138
  * @param {number} vaultParams.config.adminPerformanceFee - Admin's performance fee in basis points (e.g., 1000 = 10%)
139
+ * @param {number} vaultParams.config.redemptionFee - Redemption fee in basis points (e.g., 10 = 0.1%)
140
+ * @param {number} vaultParams.config.issuanceFee - Issuance fee in basis points (e.g., 10 = 0.1%)
141
+ * @param {BN} vaultParams.config.withdrawalWaitingPeriod - Withdrawal waiting period in seconds
125
142
  * @param {string} vaultParams.name - Name of the vault
126
143
  * @param {string} vaultParams.description - Description of the vault
127
144
  * @param {Object} params - Additional parameters for initializing the vault
@@ -139,6 +156,10 @@ export declare class VoltrClient extends AccountUtils {
139
156
  * config: {
140
157
  * maxCap: new BN('1000000000'),
141
158
  * startAtTs: new BN(Math.floor(Date.now() / 1000)),
159
+ * lockedProfitDegradationDuration: new BN(3600), // 1 hour
160
+ * redemptionFee: 10,
161
+ * issuanceFee: 10,
162
+ * withdrawalWaitingPeriod: new BN(3600), // 1 hour
142
163
  * managerManagementFee: 50, // 0.5%
143
164
  * managerPerformanceFee: 1000, // 10%
144
165
  * adminManagementFee: 50, // 0.5%
@@ -229,29 +250,76 @@ export declare class VoltrClient extends AccountUtils {
229
250
  assetTokenProgram: PublicKey;
230
251
  }): Promise<TransactionInstruction>;
231
252
  /**
232
- * Creates a withdraw instruction for a vault
253
+ * Creates a request withdraw instruction for a vault
233
254
  *
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
238
- * @param {Object} params - Withdraw parameters
255
+ * @param {RequestWithdrawVaultArgs} requestWithdrawArgs - Arguments for withdrawing from the vault
256
+ * @param {BN} requestWithdrawArgs.amount - Amount of LP tokens to withdraw
257
+ * @param {boolean} requestWithdrawArgs.isAmountInLp - Whether the amount is in LP tokens
258
+ * @param {boolean} requestWithdrawArgs.isWithdrawAll - Whether to withdraw all assets
259
+ * @param {Object} params - Request withdraw parameters
260
+ * @param {PublicKey} params.payer - Public key of the payer
239
261
  * @param {PublicKey} params.userAuthority - Public key of the user authority
240
262
  * @param {PublicKey} params.vault - Public key of the vault
241
- * @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
242
- * @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
243
263
  * @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawal
244
264
  *
245
265
  * @throws {Error} If the instruction creation fails
246
266
  *
247
267
  * @example
248
- * const ix = await client.createWithdrawVaultIx(
268
+ * const ix = await client.createRequestWithdrawVaultIx(
249
269
  * {
250
270
  * amount: new BN('1000000000'),
251
271
  * isAmountInLp: true,
252
272
  * isWithdrawAll: false,
253
273
  * },
254
274
  * {
275
+ * payer: payerPubkey,
276
+ * userAuthority: userPubkey,
277
+ * vault: vaultPubkey,
278
+ * }
279
+ * );
280
+ */
281
+ createRequestWithdrawVaultIx({ amount, isAmountInLp, isWithdrawAll }: RequestWithdrawVaultArgs, { payer, userAuthority, vault, }: {
282
+ payer: PublicKey;
283
+ userAuthority: PublicKey;
284
+ vault: PublicKey;
285
+ }): Promise<TransactionInstruction>;
286
+ /**
287
+ * Creates a cancel withdraw instruction for a vault
288
+ *
289
+ * @param {Object} params - Cancel withdraw request parameters
290
+ * @param {PublicKey} params.userAuthority - Public key of the user authority
291
+ * @param {PublicKey} params.vault - Public key of the vault
292
+ * @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawal
293
+ *
294
+ * @throws {Error} If the instruction creation fails
295
+ *
296
+ * @example
297
+ * const ix = await client.createCancelRequestWithdrawVaultIx(
298
+ * {
299
+ * userAuthority: userPubkey,
300
+ * vault: vaultPubkey,
301
+ * }
302
+ * );
303
+ */
304
+ createCancelRequestWithdrawVaultIx({ userAuthority, vault, }: {
305
+ userAuthority: PublicKey;
306
+ vault: PublicKey;
307
+ }): Promise<TransactionInstruction>;
308
+ /**
309
+ * Creates a withdraw instruction for a vault
310
+ *
311
+ * @param {Object} params - Withdraw parameters
312
+ * @param {PublicKey} params.userAuthority - Public key of the user authority
313
+ * @param {PublicKey} params.vault - Public key of the vault
314
+ * @param {PublicKey} params.vaultAssetMint - Public key of the vault asset mint
315
+ * @param {PublicKey} params.assetTokenProgram - Public key of the asset token program
316
+ * @returns {Promise<TransactionInstruction>} Transaction instruction for withdrawal
317
+ *
318
+ * @throws {Error} If the instruction creation fails
319
+ *
320
+ * @example
321
+ * const ix = await client.createWithdrawVaultIx(
322
+ * {
255
323
  * userAuthority: userPubkey,
256
324
  * vault: vaultPubkey,
257
325
  * vaultAssetMint: mintPubkey,
@@ -259,7 +327,7 @@ export declare class VoltrClient extends AccountUtils {
259
327
  * }
260
328
  * );
261
329
  */
262
- createWithdrawVaultIx({ amount, isAmountInLp, isWithdrawAll }: WithdrawVaultArgs, { userAuthority, vault, vaultAssetMint, assetTokenProgram, }: {
330
+ createWithdrawVaultIx({ userAuthority, vault, vaultAssetMint, assetTokenProgram, }: {
263
331
  userAuthority: PublicKey;
264
332
  vault: PublicKey;
265
333
  vaultAssetMint: PublicKey;
@@ -502,10 +570,7 @@ export declare class VoltrClient extends AccountUtils {
502
570
  }): Promise<TransactionInstruction>;
503
571
  /**
504
572
  * Creates an instruction to withdraw assets from a direct withdraw strategy
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
573
+ * @param {Object} directWithdrawArgs - Withdrawal arguments
509
574
  * @param {Buffer | null} [directWithdrawArgs.userArgs] - Optional user arguments for the instruction
510
575
  * @param {Object} params - Parameters for withdrawing assets from direct withdraw strategy
511
576
  * @param {PublicKey} params.user - Public key of the user
@@ -522,9 +587,6 @@ export declare class VoltrClient extends AccountUtils {
522
587
  * ```typescript
523
588
  * const ix = await client.createDirectWithdrawStrategyIx(
524
589
  * {
525
- * amount: new BN('1000000000'),
526
- * isAmountInLp: true,
527
- * isWithdrawAll: false,
528
590
  * userArgs: Buffer.from('...')
529
591
  * },
530
592
  * {
@@ -539,7 +601,9 @@ export declare class VoltrClient extends AccountUtils {
539
601
  * );
540
602
  * ```
541
603
  */
542
- createDirectWithdrawStrategyIx({ amount, isAmountInLp, isWithdrawAll, userArgs, }: DirectWithdrawStrategyArgs, { user, vault, strategy, vaultAssetMint, assetTokenProgram, adaptorProgram, remainingAccounts, }: {
604
+ createDirectWithdrawStrategyIx({ userArgs }: {
605
+ userArgs?: Buffer | null;
606
+ }, { user, vault, strategy, vaultAssetMint, assetTokenProgram, adaptorProgram, remainingAccounts, }: {
543
607
  user: PublicKey;
544
608
  vault: PublicKey;
545
609
  strategy: PublicKey;
@@ -616,10 +680,10 @@ export declare class VoltrClient extends AccountUtils {
616
680
  reserved: number[];
617
681
  }>[]>;
618
682
  getPositionAndTotalValuesForVault(vault: PublicKey): Promise<{
619
- totalValue: any;
683
+ totalValue: number;
620
684
  strategies: {
621
685
  strategyId: string;
622
- amount: any;
686
+ amount: number;
623
687
  }[];
624
688
  }>;
625
689
  /**
@@ -630,16 +694,55 @@ export declare class VoltrClient extends AccountUtils {
630
694
  fetchVaultAccount(vault: PublicKey): Promise<{
631
695
  name: number[];
632
696
  description: number[];
633
- asset: any;
634
- lp: any;
697
+ asset: {
698
+ mint: PublicKey;
699
+ idleAta: PublicKey;
700
+ totalValue: BN;
701
+ idleAtaAuthBump: number;
702
+ reserved: number[];
703
+ };
704
+ lp: {
705
+ mint: PublicKey;
706
+ mintBump: number;
707
+ mintAuthBump: number;
708
+ reserved: number[];
709
+ };
635
710
  manager: PublicKey;
636
711
  admin: PublicKey;
637
- vaultConfiguration: any;
638
- feeConfiguration: any;
639
- feeState: any;
712
+ vaultConfiguration: {
713
+ maxCap: BN;
714
+ startAtTs: BN;
715
+ lockedProfitDegradationDuration: BN;
716
+ withdrawalWaitingPeriod: BN;
717
+ reserved: number[];
718
+ };
719
+ feeConfiguration: {
720
+ managerPerformanceFee: number;
721
+ adminPerformanceFee: number;
722
+ managerManagementFee: number;
723
+ adminManagementFee: number;
724
+ redemptionFee: number;
725
+ issuanceFee: number;
726
+ reserved: number[];
727
+ };
728
+ feeState: {
729
+ accumulatedLpManagerFees: BN;
730
+ accumulatedLpAdminFees: BN;
731
+ accumulatedLpProtocolFees: BN;
732
+ reserved: number[];
733
+ };
734
+ highWaterMark: {
735
+ highestAssetPerLpDecimalBits: BN;
736
+ lastUpdatedTs: BN;
737
+ reserved: number[];
738
+ };
640
739
  lastUpdatedTs: BN;
641
740
  version: number;
642
741
  padding0: number[];
742
+ lockedProfitState: {
743
+ lastUpdatedLockedProfit: BN;
744
+ lastReport: BN;
745
+ };
643
746
  reserved: number[];
644
747
  }>;
645
748
  /**
@@ -684,6 +787,7 @@ export declare class VoltrClient extends AccountUtils {
684
787
  lastUpdatedEpoch: BN;
685
788
  reserved: number[];
686
789
  }>;
790
+ calculateLockedProfit(lastUpdatedLockedProfit: BN, lockedProfitDegradationDuration: BN, currentTime: BN): BN;
687
791
  /**
688
792
  * Calculates the amount of assets that would be received for a given LP token amount
689
793
  *
@@ -703,11 +807,30 @@ export declare class VoltrClient extends AccountUtils {
703
807
  * ```
704
808
  */
705
809
  calculateAssetsForWithdraw(vaultPk: PublicKey, lpAmount: BN): Promise<BN>;
810
+ /**
811
+ * Calculates the amount of LP tokens that would be burned for a given asset amount
812
+ *
813
+ * @param vaultPk - Public key of the vault
814
+ * @param assetAmount - Amount of assets to calculate for
815
+ * @returns Promise resolving to the amount of LP tokens that would be burned
816
+ *
817
+ * @throws {Error} If LP supply or total assets are invalid
818
+ * @throws {Error} If math overflow occurs during calculation
819
+ *
820
+ * @example
821
+ * ```typescript
822
+ * const lpTokensToBurn = await client.calculateLpForWithdraw(
823
+ * vaultPubkey,
824
+ * new BN('1000000000')
825
+ * );
826
+ * ```
827
+ */
828
+ calculateLpForWithdraw(vaultPk: PublicKey, assetAmount: BN): Promise<BN>;
706
829
  /**
707
830
  * Calculates the amount of LP tokens that would be received for a given asset deposit
708
831
  *
709
- * @param depositAmount - Amount of assets to deposit
710
832
  * @param vaultPk - Public key of the vault
833
+ * @param assetAmount - Amount of assets to deposit
711
834
  * @returns Promise resolving to the amount of LP tokens that would be received
712
835
  *
713
836
  * @throws {Error} If math overflow occurs during calculation
@@ -715,11 +838,11 @@ export declare class VoltrClient extends AccountUtils {
715
838
  * @example
716
839
  * ```typescript
717
840
  * const lpTokens = await client.calculateLpTokensForDeposit(
718
- * new BN('1000000000'),
719
841
  * vaultPubkey
842
+ * new BN('1000000000'),
720
843
  * );
721
844
  * ```
722
845
  */
723
- calculateLpTokensForDeposit(depositAmount: BN, vaultPk: PublicKey): Promise<BN>;
846
+ calculateLpForDeposit(vaultPk: PublicKey, assetAmount: BN): Promise<BN>;
724
847
  }
725
848
  export {};