@voltr/vault-sdk 1.0.8 → 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/README.md +1 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +18 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -249,6 +249,7 @@ pendingWithdrawals.forEach((withdrawal, index) => {
|
|
|
249
249
|
- `createCancelRequestWithdrawVaultIx(params)`
|
|
250
250
|
- `createWithdrawVaultIx(params)`
|
|
251
251
|
- `createHarvestFeeIx(params)`
|
|
252
|
+
- `createCreateLpMetadataIx(createLpMetadataArgs, params)`
|
|
252
253
|
|
|
253
254
|
#### Strategy Management
|
|
254
255
|
|
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) {
|
|
@@ -368,12 +368,16 @@ class VoltrClient extends AccountUtils {
|
|
|
368
368
|
* ```
|
|
369
369
|
*/
|
|
370
370
|
async createUpdateVaultIx(vaultConfig, { vault, admin, }) {
|
|
371
|
+
const lpMint = this.findVaultLpMint(vault);
|
|
371
372
|
return await this.vaultProgram.methods
|
|
372
373
|
.updateVault(vaultConfig)
|
|
373
374
|
.accountsPartial({
|
|
374
375
|
admin,
|
|
375
376
|
vault,
|
|
376
377
|
})
|
|
378
|
+
.remainingAccounts([
|
|
379
|
+
{ pubkey: lpMint, isSigner: false, isWritable: false },
|
|
380
|
+
])
|
|
377
381
|
.instruction();
|
|
378
382
|
}
|
|
379
383
|
/**
|
|
@@ -991,7 +995,7 @@ class VoltrClient extends AccountUtils {
|
|
|
991
995
|
* @returns Promise resolving to the vault account data
|
|
992
996
|
*/
|
|
993
997
|
async fetchVaultAccount(vault) {
|
|
994
|
-
return await this.vaultProgram.account.vault.fetch(vault
|
|
998
|
+
return await this.vaultProgram.account.vault.fetch(vault);
|
|
995
999
|
}
|
|
996
1000
|
/**
|
|
997
1001
|
* Fetches a strategy init receipt account's data
|
|
@@ -1004,7 +1008,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1004
1008
|
* ```
|
|
1005
1009
|
*/
|
|
1006
1010
|
async fetchStrategyInitReceiptAccount(strategyInitReceipt) {
|
|
1007
|
-
return await this.vaultProgram.account.strategyInitReceipt.fetch(strategyInitReceipt
|
|
1011
|
+
return await this.vaultProgram.account.strategyInitReceipt.fetch(strategyInitReceipt);
|
|
1008
1012
|
}
|
|
1009
1013
|
/**
|
|
1010
1014
|
* Fetches an adaptor add receipt account's data
|
|
@@ -1017,7 +1021,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1017
1021
|
* ```
|
|
1018
1022
|
*/
|
|
1019
1023
|
async fetchAdaptorAddReceiptAccount(adaptorAddReceipt) {
|
|
1020
|
-
return await this.vaultProgram.account.adaptorAddReceipt.fetch(adaptorAddReceipt
|
|
1024
|
+
return await this.vaultProgram.account.adaptorAddReceipt.fetch(adaptorAddReceipt);
|
|
1021
1025
|
}
|
|
1022
1026
|
/**
|
|
1023
1027
|
* Fetches a request withdraw vault receipt account's data
|
|
@@ -1030,7 +1034,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1030
1034
|
* ```
|
|
1031
1035
|
*/
|
|
1032
1036
|
async fetchRequestWithdrawVaultReceiptAccount(requestWithdrawVaultReceipt) {
|
|
1033
|
-
return await this.vaultProgram.account.requestWithdrawVaultReceipt.fetch(requestWithdrawVaultReceipt
|
|
1037
|
+
return await this.vaultProgram.account.requestWithdrawVaultReceipt.fetch(requestWithdrawVaultReceipt);
|
|
1034
1038
|
}
|
|
1035
1039
|
// --------------------------------------- Helpers
|
|
1036
1040
|
/**
|
|
@@ -1097,7 +1101,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1097
1101
|
async getCurrentAssetPerLpForVault(vault) {
|
|
1098
1102
|
const vaultLpMint = this.findVaultLpMint(vault);
|
|
1099
1103
|
const vaultAccount = await this.fetchVaultAccount(vault);
|
|
1100
|
-
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()));
|
|
1101
1105
|
const unharvestedFeesLp = vaultAccount.feeState.accumulatedLpAdminFees
|
|
1102
1106
|
.add(vaultAccount.feeState.accumulatedLpManagerFees)
|
|
1103
1107
|
.add(vaultAccount.feeState.accumulatedLpProtocolFees);
|
|
@@ -1157,7 +1161,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1157
1161
|
async getPendingWithdrawalForUser(vault, user) {
|
|
1158
1162
|
const [vaultAccount, lp] = await Promise.all([
|
|
1159
1163
|
this.fetchVaultAccount(vault),
|
|
1160
|
-
(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),
|
|
1161
1165
|
]);
|
|
1162
1166
|
const requestWithdrawVaultReceiptAddress = this.findRequestWithdrawVaultReceipt(vault, user);
|
|
1163
1167
|
const receipt = await this.fetchRequestWithdrawVaultReceiptAccount(requestWithdrawVaultReceiptAddress);
|
|
@@ -1177,7 +1181,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1177
1181
|
const [requestWithdrawVaultReceipts, vaultAccount, lp] = await Promise.all([
|
|
1178
1182
|
this.fetchAllRequestWithdrawVaultReceiptsOfVault(vault),
|
|
1179
1183
|
this.fetchVaultAccount(vault),
|
|
1180
|
-
(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),
|
|
1181
1185
|
]);
|
|
1182
1186
|
const lpSupply = new bn_js_1.default(lp.supply.toString());
|
|
1183
1187
|
return Promise.all(requestWithdrawVaultReceipts.map((receipt) => this.processWithdrawalReceipt(receipt, vaultAccount, lpSupply)));
|
|
@@ -1236,7 +1240,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1236
1240
|
try {
|
|
1237
1241
|
const vault = await this.fetchVaultAccount(vaultPk);
|
|
1238
1242
|
const lpMint = this.findVaultLpMint(vaultPk);
|
|
1239
|
-
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);
|
|
1240
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);
|
|
1241
1245
|
return amount;
|
|
1242
1246
|
}
|
|
@@ -1269,7 +1273,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1269
1273
|
const lockedProfit = this.calculateLockedProfit(vault.lockedProfitState.lastUpdatedLockedProfit, vault.vaultConfiguration.lockedProfitDegradationDuration, new bn_js_1.default(Date.now() / 1000));
|
|
1270
1274
|
const totalUnlockedValue = totalValue.sub(lockedProfit);
|
|
1271
1275
|
const lpMint = this.findVaultLpMint(vaultPk);
|
|
1272
|
-
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);
|
|
1273
1277
|
const lpSupply = new bn_js_1.default(lp.supply.toString());
|
|
1274
1278
|
// Validate inputs
|
|
1275
1279
|
if (lpSupply <= new bn_js_1.default(0))
|
|
@@ -1314,7 +1318,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1314
1318
|
const vault = await this.fetchVaultAccount(vaultPk);
|
|
1315
1319
|
const totalValue = vault.asset.totalValue;
|
|
1316
1320
|
const lpMint = this.findVaultLpMint(vaultPk);
|
|
1317
|
-
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);
|
|
1318
1322
|
const lpSupply = new bn_js_1.default(lp.supply.toString());
|
|
1319
1323
|
const unharvestedFeesLp = vault.feeState.accumulatedLpAdminFees
|
|
1320
1324
|
.add(vault.feeState.accumulatedLpManagerFees)
|
|
@@ -1322,7 +1326,7 @@ class VoltrClient extends AccountUtils {
|
|
|
1322
1326
|
const lpSupplyInclFees = lpSupply.add(unharvestedFeesLp);
|
|
1323
1327
|
// If the pool is empty, mint LP tokens 1:1 with deposit
|
|
1324
1328
|
if (lpSupplyInclFees.eq(new bn_js_1.default(0))) {
|
|
1325
|
-
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);
|
|
1326
1330
|
const assetDecimals = assetMint.decimals;
|
|
1327
1331
|
const lpDecimals = lp.decimals;
|
|
1328
1332
|
return assetAmount
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltr/vault-sdk",
|
|
3
|
-
"version": "1.0.
|
|
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.
|
|
39
|
+
"typedoc": "^0.28.0",
|
|
40
40
|
"typedoc-plugin-markdown": "^4.3.3",
|
|
41
41
|
"typescript": "^5.7.2"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|