@voltr/vault-sdk 1.0.9 → 1.0.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Program, AnchorProvider, Idl } from "@coral-xyz/anchor";
2
2
  import BN from "bn.js";
3
- import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
+ import { ConfirmOptions, Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
4
4
  import { VaultParams, VaultConfig, VoltrVault, InitializeStrategyArgs, DepositStrategyArgs, WithdrawStrategyArgs, InitializeDirectWithdrawStrategyArgs, RequestWithdrawVaultArgs } from "./types";
5
5
  declare class AccountUtils {
6
6
  conn: Connection;
@@ -39,7 +39,7 @@ export declare class VoltrClient extends AccountUtils {
39
39
  * @param conn - Solana connection instance
40
40
  * @param wallet - Optional keypair for signing transactions
41
41
  */
42
- constructor(conn: Connection, wallet?: Keypair);
42
+ constructor(conn: Connection, wallet?: Keypair, opts?: ConfirmOptions);
43
43
  private setProvider;
44
44
  private setPrograms;
45
45
  /**
package/dist/client.js CHANGED
@@ -105,13 +105,13 @@ class VoltrClient extends AccountUtils {
105
105
  * @param conn - Solana connection instance
106
106
  * @param wallet - Optional keypair for signing transactions
107
107
  */
108
- constructor(conn, wallet) {
108
+ constructor(conn, wallet, opts) {
109
109
  super(conn);
110
110
  // Initialize programs
111
111
  this.setProvider(wallet);
112
112
  this.setPrograms(vaultIdl);
113
113
  }
114
- setProvider(wallet) {
114
+ setProvider(wallet, opts) {
115
115
  /// we are creating instructions with this client without signing
116
116
  let kp;
117
117
  if (!wallet) {
@@ -127,7 +127,7 @@ class VoltrClient extends AccountUtils {
127
127
  else {
128
128
  kp = wallet;
129
129
  }
130
- this.provider = new anchor_1.AnchorProvider(this.conn, new CustomWallet(kp), anchor_1.AnchorProvider.defaultOptions());
130
+ this.provider = new anchor_1.AnchorProvider(this.conn, new CustomWallet(kp), opts ?? anchor_1.AnchorProvider.defaultOptions());
131
131
  (0, anchor_1.setProvider)(this.provider);
132
132
  }
133
133
  setPrograms(vaultIdl) {
@@ -995,7 +995,7 @@ class VoltrClient extends AccountUtils {
995
995
  * @returns Promise resolving to the vault account data
996
996
  */
997
997
  async fetchVaultAccount(vault) {
998
- return await this.vaultProgram.account.vault.fetch(vault, "confirmed");
998
+ return await this.vaultProgram.account.vault.fetch(vault);
999
999
  }
1000
1000
  /**
1001
1001
  * Fetches a strategy init receipt account's data
@@ -1008,7 +1008,7 @@ class VoltrClient extends AccountUtils {
1008
1008
  * ```
1009
1009
  */
1010
1010
  async fetchStrategyInitReceiptAccount(strategyInitReceipt) {
1011
- return await this.vaultProgram.account.strategyInitReceipt.fetch(strategyInitReceipt, "confirmed");
1011
+ return await this.vaultProgram.account.strategyInitReceipt.fetch(strategyInitReceipt);
1012
1012
  }
1013
1013
  /**
1014
1014
  * Fetches an adaptor add receipt account's data
@@ -1021,7 +1021,7 @@ class VoltrClient extends AccountUtils {
1021
1021
  * ```
1022
1022
  */
1023
1023
  async fetchAdaptorAddReceiptAccount(adaptorAddReceipt) {
1024
- return await this.vaultProgram.account.adaptorAddReceipt.fetch(adaptorAddReceipt, "confirmed");
1024
+ return await this.vaultProgram.account.adaptorAddReceipt.fetch(adaptorAddReceipt);
1025
1025
  }
1026
1026
  /**
1027
1027
  * Fetches a request withdraw vault receipt account's data
@@ -1034,7 +1034,7 @@ class VoltrClient extends AccountUtils {
1034
1034
  * ```
1035
1035
  */
1036
1036
  async fetchRequestWithdrawVaultReceiptAccount(requestWithdrawVaultReceipt) {
1037
- return await this.vaultProgram.account.requestWithdrawVaultReceipt.fetch(requestWithdrawVaultReceipt, "confirmed");
1037
+ return await this.vaultProgram.account.requestWithdrawVaultReceipt.fetch(requestWithdrawVaultReceipt);
1038
1038
  }
1039
1039
  // --------------------------------------- Helpers
1040
1040
  /**
@@ -1101,7 +1101,7 @@ class VoltrClient extends AccountUtils {
1101
1101
  async getCurrentAssetPerLpForVault(vault) {
1102
1102
  const vaultLpMint = this.findVaultLpMint(vault);
1103
1103
  const vaultAccount = await this.fetchVaultAccount(vault);
1104
- const lpSupply = await (0, spl_token_1.getMint)(this.conn, vaultLpMint).then((lp) => new bn_js_1.default(lp.supply.toString()));
1104
+ const lpSupply = await (0, spl_token_1.getMint)(this.conn, vaultLpMint, this.provider.opts.commitment).then((lp) => new bn_js_1.default(lp.supply.toString()));
1105
1105
  const unharvestedFeesLp = vaultAccount.feeState.accumulatedLpAdminFees
1106
1106
  .add(vaultAccount.feeState.accumulatedLpManagerFees)
1107
1107
  .add(vaultAccount.feeState.accumulatedLpProtocolFees);
@@ -1161,7 +1161,7 @@ class VoltrClient extends AccountUtils {
1161
1161
  async getPendingWithdrawalForUser(vault, user) {
1162
1162
  const [vaultAccount, lp] = await Promise.all([
1163
1163
  this.fetchVaultAccount(vault),
1164
- (0, spl_token_1.getMint)(this.conn, this.findVaultLpMint(vault)),
1164
+ (0, spl_token_1.getMint)(this.conn, this.findVaultLpMint(vault), this.provider.opts.commitment),
1165
1165
  ]);
1166
1166
  const requestWithdrawVaultReceiptAddress = this.findRequestWithdrawVaultReceipt(vault, user);
1167
1167
  const receipt = await this.fetchRequestWithdrawVaultReceiptAccount(requestWithdrawVaultReceiptAddress);
@@ -1181,7 +1181,7 @@ class VoltrClient extends AccountUtils {
1181
1181
  const [requestWithdrawVaultReceipts, vaultAccount, lp] = await Promise.all([
1182
1182
  this.fetchAllRequestWithdrawVaultReceiptsOfVault(vault),
1183
1183
  this.fetchVaultAccount(vault),
1184
- (0, spl_token_1.getMint)(this.conn, this.findVaultLpMint(vault)),
1184
+ (0, spl_token_1.getMint)(this.conn, this.findVaultLpMint(vault), this.provider.opts.commitment),
1185
1185
  ]);
1186
1186
  const lpSupply = new bn_js_1.default(lp.supply.toString());
1187
1187
  return Promise.all(requestWithdrawVaultReceipts.map((receipt) => this.processWithdrawalReceipt(receipt, vaultAccount, lpSupply)));
@@ -1240,7 +1240,7 @@ class VoltrClient extends AccountUtils {
1240
1240
  try {
1241
1241
  const vault = await this.fetchVaultAccount(vaultPk);
1242
1242
  const lpMint = this.findVaultLpMint(vaultPk);
1243
- const lp = await (0, spl_token_1.getMint)(this.conn, lpMint);
1243
+ const lp = await (0, spl_token_1.getMint)(this.conn, lpMint, this.provider.opts.commitment);
1244
1244
  const amount = this.calculateAssetsForWithdrawHelper(vault.asset.totalValue, vault.lockedProfitState.lastUpdatedLockedProfit, vault.vaultConfiguration.lockedProfitDegradationDuration, vault.feeState.accumulatedLpAdminFees, vault.feeState.accumulatedLpManagerFees, vault.feeState.accumulatedLpProtocolFees, vault.feeConfiguration.redemptionFee, new bn_js_1.default(lp.supply.toString()), lpAmount);
1245
1245
  return amount;
1246
1246
  }
@@ -1273,7 +1273,7 @@ class VoltrClient extends AccountUtils {
1273
1273
  const lockedProfit = this.calculateLockedProfit(vault.lockedProfitState.lastUpdatedLockedProfit, vault.vaultConfiguration.lockedProfitDegradationDuration, new bn_js_1.default(Date.now() / 1000));
1274
1274
  const totalUnlockedValue = totalValue.sub(lockedProfit);
1275
1275
  const lpMint = this.findVaultLpMint(vaultPk);
1276
- const lp = await (0, spl_token_1.getMint)(this.conn, lpMint);
1276
+ const lp = await (0, spl_token_1.getMint)(this.conn, lpMint, this.provider.opts.commitment);
1277
1277
  const lpSupply = new bn_js_1.default(lp.supply.toString());
1278
1278
  // Validate inputs
1279
1279
  if (lpSupply <= new bn_js_1.default(0))
@@ -1318,7 +1318,7 @@ class VoltrClient extends AccountUtils {
1318
1318
  const vault = await this.fetchVaultAccount(vaultPk);
1319
1319
  const totalValue = vault.asset.totalValue;
1320
1320
  const lpMint = this.findVaultLpMint(vaultPk);
1321
- const lp = await (0, spl_token_1.getMint)(this.conn, lpMint);
1321
+ const lp = await (0, spl_token_1.getMint)(this.conn, lpMint, this.provider.opts.commitment);
1322
1322
  const lpSupply = new bn_js_1.default(lp.supply.toString());
1323
1323
  const unharvestedFeesLp = vault.feeState.accumulatedLpAdminFees
1324
1324
  .add(vault.feeState.accumulatedLpManagerFees)
@@ -1326,7 +1326,7 @@ class VoltrClient extends AccountUtils {
1326
1326
  const lpSupplyInclFees = lpSupply.add(unharvestedFeesLp);
1327
1327
  // If the pool is empty, mint LP tokens 1:1 with deposit
1328
1328
  if (lpSupplyInclFees.eq(new bn_js_1.default(0))) {
1329
- const assetMint = await (0, spl_token_1.getMint)(this.conn, vault.asset.mint);
1329
+ const assetMint = await (0, spl_token_1.getMint)(this.conn, vault.asset.mint, this.provider.opts.commitment);
1330
1330
  const assetDecimals = assetMint.decimals;
1331
1331
  const lpDecimals = lp.decimals;
1332
1332
  return assetAmount
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltr/vault-sdk",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "SDK for interacting with Voltr Protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,8 +36,8 @@
36
36
  "@types/bn.js": "^5.1.6",
37
37
  "@types/node": "^22.10.2",
38
38
  "gh-pages": "^6.2.0",
39
- "typedoc": "^0.27.5",
39
+ "typedoc": "^0.28.0",
40
40
  "typedoc-plugin-markdown": "^4.3.3",
41
41
  "typescript": "^5.7.2"
42
42
  }
43
- }
43
+ }