@voltr/vault-sdk 1.0.20 → 1.1.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/dist/client.d.ts CHANGED
@@ -1039,6 +1039,26 @@ export declare class VoltrClient extends AccountUtils {
1039
1039
  vault: PublicKey;
1040
1040
  admin: PublicKey;
1041
1041
  }): Promise<TransactionInstruction>;
1042
+ /**
1043
+ * Creates an instruction to calibrate the high water mark without fee clawback (unsafe)
1044
+ * @param {Object} params - Parameters for calibrating the high water mark
1045
+ * @param {PublicKey} params.vault - Public key of the vault (must be whitelisted)
1046
+ * @param {PublicKey} params.admin - Public key of the admin
1047
+ * @returns {Promise<TransactionInstruction>} Transaction instruction for unsafe calibration
1048
+ * @throws {Error} If instruction creation fails or vault is not whitelisted
1049
+ *
1050
+ * @example
1051
+ * ```typescript
1052
+ * const ix = await client.createCalibrateHighWaterMarkUnsafeIx({
1053
+ * vault: vaultPubkey,
1054
+ * admin: adminPubkey,
1055
+ * });
1056
+ * ```
1057
+ */
1058
+ createCalibrateHighWaterMarkUnsafeIx({ vault, admin, }: {
1059
+ vault: PublicKey;
1060
+ admin: PublicKey;
1061
+ }): Promise<TransactionInstruction>;
1042
1062
  /**
1043
1063
  * Creates an instruction to create LP metadata
1044
1064
  * @param {Object} createLpMetadataArgs - Parameters for creating LP metadata
@@ -1458,12 +1478,12 @@ export declare class VoltrClient extends AccountUtils {
1458
1478
  amountLpEscrowed: number;
1459
1479
  withdrawableFromTs: number;
1460
1480
  }[]>;
1461
- calculateLockedProfit(lastUpdatedLockedProfit: BN, lockedProfitDegradationDuration: BN, currentTime: BN): BN;
1481
+ calculateLockedProfit(lastUpdatedLockedProfit: BN, lastReport: BN, lockedProfitDegradationDuration: BN, currentTime: BN): BN;
1462
1482
  /**
1463
1483
  * Helper to calculate only the pending (unrealised) LP fees based on time elapsed.
1464
1484
  */
1465
1485
  private calculateUnrealisedLpFees;
1466
- calculateAssetsForWithdrawHelper(vaultTotalValue: BN, vaultLastUpdatedLockedProfit: BN, vaultLockedProfitDegradationDuration: BN, vaultAccumulatedLpAdminFees: BN, vaultAccumulatedLpManagerFees: BN, vaultAccumulatedLpProtocolFees: BN, vaultRedemptionFeeBps: number, vaultManagementFeeBps: number, vaultLastManagementFeeUpdateTs: BN, lpSupply: BN, lpAmount: BN, deadWeight?: BN): BN;
1486
+ calculateAssetsForWithdrawHelper(vaultTotalValue: BN, vaultLastUpdatedLockedProfit: BN, vaultLastReport: BN, vaultLockedProfitDegradationDuration: BN, vaultAccumulatedLpAdminFees: BN, vaultAccumulatedLpManagerFees: BN, vaultAccumulatedLpProtocolFees: BN, vaultRedemptionFeeBps: number, vaultManagementFeeBps: number, vaultLastManagementFeeUpdateTs: BN, lpSupply: BN, lpAmount: BN, deadWeight?: BN): BN;
1467
1487
  /**
1468
1488
  * Calculates the amount of assets that would be received for a given LP token amount
1469
1489
  *
package/dist/client.js CHANGED
@@ -1313,6 +1313,31 @@ class VoltrClient extends AccountUtils {
1313
1313
  })
1314
1314
  .instruction();
1315
1315
  }
1316
+ /**
1317
+ * Creates an instruction to calibrate the high water mark without fee clawback (unsafe)
1318
+ * @param {Object} params - Parameters for calibrating the high water mark
1319
+ * @param {PublicKey} params.vault - Public key of the vault (must be whitelisted)
1320
+ * @param {PublicKey} params.admin - Public key of the admin
1321
+ * @returns {Promise<TransactionInstruction>} Transaction instruction for unsafe calibration
1322
+ * @throws {Error} If instruction creation fails or vault is not whitelisted
1323
+ *
1324
+ * @example
1325
+ * ```typescript
1326
+ * const ix = await client.createCalibrateHighWaterMarkUnsafeIx({
1327
+ * vault: vaultPubkey,
1328
+ * admin: adminPubkey,
1329
+ * });
1330
+ * ```
1331
+ */
1332
+ async createCalibrateHighWaterMarkUnsafeIx({ vault, admin, }) {
1333
+ return await this.vaultProgram.methods
1334
+ .calibrateHighWaterMarkUnsafe()
1335
+ .accountsPartial({
1336
+ vault,
1337
+ admin,
1338
+ })
1339
+ .instruction();
1340
+ }
1316
1341
  /**
1317
1342
  * Creates an instruction to create LP metadata
1318
1343
  * @param {Object} createLpMetadataArgs - Parameters for creating LP metadata
@@ -1672,7 +1697,7 @@ class VoltrClient extends AccountUtils {
1672
1697
  const amountAssetToWithdrawDecimal = (0, decimals_1.convertDecimalBitsToDecimal)(receipt.account.amountAssetToWithdrawDecimalBits);
1673
1698
  const amountAssetToWithdrawAtRequest = amountAssetToWithdrawDecimal.toNumber();
1674
1699
  const amountLpEscrowed = receipt.account.amountLpEscrowed;
1675
- const amountAssetToWithdrawAtPresent = this.calculateAssetsForWithdrawHelper(vaultAccount.asset.totalValue, vaultAccount.lockedProfitState.lastUpdatedLockedProfit, vaultAccount.vaultConfiguration.lockedProfitDegradationDuration, vaultAccount.feeState.accumulatedLpAdminFees, vaultAccount.feeState.accumulatedLpManagerFees, vaultAccount.feeState.accumulatedLpProtocolFees, vaultAccount.feeConfiguration.redemptionFee, vaultAccount.feeConfiguration.managerManagementFee +
1700
+ const amountAssetToWithdrawAtPresent = this.calculateAssetsForWithdrawHelper(vaultAccount.asset.totalValue, vaultAccount.lockedProfitState.lastUpdatedLockedProfit, vaultAccount.lockedProfitState.lastReport, vaultAccount.vaultConfiguration.lockedProfitDegradationDuration, vaultAccount.feeState.accumulatedLpAdminFees, vaultAccount.feeState.accumulatedLpManagerFees, vaultAccount.feeState.accumulatedLpProtocolFees, vaultAccount.feeConfiguration.redemptionFee, vaultAccount.feeConfiguration.managerManagementFee +
1676
1701
  vaultAccount.feeConfiguration.adminManagementFee +
1677
1702
  vaultAccount.feeConfiguration.protocolManagementFee, vaultAccount.feeUpdate.lastManagementFeeUpdateTs, lpSupply, amountLpEscrowed, vaultAccount.deadWeight).toNumber();
1678
1703
  // Cap the withdrawal amount to the initial request amount
@@ -1725,17 +1750,15 @@ class VoltrClient extends AccountUtils {
1725
1750
  const lpSupply = new bn_js_1.default(lp.supply.toString());
1726
1751
  return Promise.all(requestWithdrawVaultReceipts.map((receipt) => this.processWithdrawalReceipt(receipt, vaultAccount, lpSupply)));
1727
1752
  }
1728
- calculateLockedProfit(lastUpdatedLockedProfit, lockedProfitDegradationDuration, currentTime) {
1753
+ calculateLockedProfit(lastUpdatedLockedProfit, lastReport, lockedProfitDegradationDuration, currentTime) {
1729
1754
  if (lockedProfitDegradationDuration.eq(new bn_js_1.default(0)))
1730
1755
  return new bn_js_1.default(0);
1731
- const duration = currentTime.sub(lastUpdatedLockedProfit);
1732
- const lockedProfit = lastUpdatedLockedProfit
1733
- .mul(lockedProfitDegradationDuration.sub(duration))
1734
- .div(lockedProfitDegradationDuration);
1756
+ const duration = currentTime.sub(lastReport);
1735
1757
  if (duration.gt(lockedProfitDegradationDuration))
1736
1758
  return new bn_js_1.default(0);
1737
- else
1738
- return lockedProfit;
1759
+ return lastUpdatedLockedProfit
1760
+ .mul(lockedProfitDegradationDuration.sub(duration))
1761
+ .div(lockedProfitDegradationDuration);
1739
1762
  }
1740
1763
  /**
1741
1764
  * Helper to calculate only the pending (unrealised) LP fees based on time elapsed.
@@ -1767,12 +1790,12 @@ class VoltrClient extends AccountUtils {
1767
1790
  .div(lpDenominator);
1768
1791
  return pendingLpToMint;
1769
1792
  }
1770
- calculateAssetsForWithdrawHelper(vaultTotalValue, vaultLastUpdatedLockedProfit, vaultLockedProfitDegradationDuration, vaultAccumulatedLpAdminFees, vaultAccumulatedLpManagerFees, vaultAccumulatedLpProtocolFees, vaultRedemptionFeeBps, vaultManagementFeeBps, vaultLastManagementFeeUpdateTs, lpSupply, lpAmount, deadWeight = new bn_js_1.default(0)) {
1793
+ calculateAssetsForWithdrawHelper(vaultTotalValue, vaultLastUpdatedLockedProfit, vaultLastReport, vaultLockedProfitDegradationDuration, vaultAccumulatedLpAdminFees, vaultAccumulatedLpManagerFees, vaultAccumulatedLpProtocolFees, vaultRedemptionFeeBps, vaultManagementFeeBps, vaultLastManagementFeeUpdateTs, lpSupply, lpAmount, deadWeight = new bn_js_1.default(0)) {
1771
1794
  if (lpSupply <= new bn_js_1.default(0))
1772
1795
  throw new Error("Invalid LP supply");
1773
1796
  if (vaultTotalValue <= new bn_js_1.default(0))
1774
1797
  throw new Error("Invalid total assets");
1775
- const lockedProfit = this.calculateLockedProfit(vaultLastUpdatedLockedProfit, vaultLockedProfitDegradationDuration, new bn_js_1.default(Date.now() / 1000));
1798
+ const lockedProfit = this.calculateLockedProfit(vaultLastUpdatedLockedProfit, vaultLastReport, vaultLockedProfitDegradationDuration, new bn_js_1.default(Math.floor(Date.now() / 1000)));
1776
1799
  const totalUnlockedValue = vaultTotalValue.sub(lockedProfit);
1777
1800
  const unharvestedFeesLp = vaultAccumulatedLpAdminFees
1778
1801
  .add(vaultAccumulatedLpManagerFees)
@@ -1814,7 +1837,7 @@ class VoltrClient extends AccountUtils {
1814
1837
  const vault = await this.fetchVaultAccount(vaultPk);
1815
1838
  const lpMint = this.findVaultLpMint(vaultPk);
1816
1839
  const lp = await (0, spl_token_1.getMint)(this.conn, lpMint, this.provider.opts.commitment);
1817
- 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, vault.feeConfiguration.managerManagementFee +
1840
+ const amount = this.calculateAssetsForWithdrawHelper(vault.asset.totalValue, vault.lockedProfitState.lastUpdatedLockedProfit, vault.lockedProfitState.lastReport, vault.vaultConfiguration.lockedProfitDegradationDuration, vault.feeState.accumulatedLpAdminFees, vault.feeState.accumulatedLpManagerFees, vault.feeState.accumulatedLpProtocolFees, vault.feeConfiguration.redemptionFee, vault.feeConfiguration.managerManagementFee +
1818
1841
  vault.feeConfiguration.adminManagementFee +
1819
1842
  vault.feeConfiguration.protocolManagementFee, vault.feeUpdate.lastManagementFeeUpdateTs, new bn_js_1.default(lp.supply.toString()), lpAmount, vault.deadWeight);
1820
1843
  return amount;
@@ -1845,7 +1868,7 @@ class VoltrClient extends AccountUtils {
1845
1868
  try {
1846
1869
  const vault = await this.fetchVaultAccount(vaultPk);
1847
1870
  const totalValue = vault.asset.totalValue;
1848
- const lockedProfit = this.calculateLockedProfit(vault.lockedProfitState.lastUpdatedLockedProfit, vault.vaultConfiguration.lockedProfitDegradationDuration, new bn_js_1.default(Date.now() / 1000));
1871
+ const lockedProfit = this.calculateLockedProfit(vault.lockedProfitState.lastUpdatedLockedProfit, vault.lockedProfitState.lastReport, vault.vaultConfiguration.lockedProfitDegradationDuration, new bn_js_1.default(Math.floor(Date.now() / 1000)));
1849
1872
  const totalUnlockedValue = totalValue.sub(lockedProfit);
1850
1873
  const lpMint = this.findVaultLpMint(vaultPk);
1851
1874
  const lp = await (0, spl_token_1.getMint)(this.conn, lpMint, this.provider.opts.commitment);
@@ -315,6 +315,83 @@
315
315
  ],
316
316
  "args": []
317
317
  },
318
+ {
319
+ "name": "calibrate_high_water_mark_unsafe",
320
+ "discriminator": [
321
+ 162,
322
+ 16,
323
+ 96,
324
+ 202,
325
+ 178,
326
+ 8,
327
+ 187,
328
+ 235
329
+ ],
330
+ "accounts": [
331
+ {
332
+ "name": "admin",
333
+ "signer": true,
334
+ "relations": [
335
+ "vault"
336
+ ]
337
+ },
338
+ {
339
+ "name": "protocol",
340
+ "pda": {
341
+ "seeds": [
342
+ {
343
+ "kind": "const",
344
+ "value": [
345
+ 112,
346
+ 114,
347
+ 111,
348
+ 116,
349
+ 111,
350
+ 99,
351
+ 111,
352
+ 108
353
+ ]
354
+ }
355
+ ]
356
+ }
357
+ },
358
+ {
359
+ "name": "vault",
360
+ "writable": true
361
+ },
362
+ {
363
+ "name": "vault_lp_mint",
364
+ "writable": true,
365
+ "pda": {
366
+ "seeds": [
367
+ {
368
+ "kind": "const",
369
+ "value": [
370
+ 118,
371
+ 97,
372
+ 117,
373
+ 108,
374
+ 116,
375
+ 95,
376
+ 108,
377
+ 112,
378
+ 95,
379
+ 109,
380
+ 105,
381
+ 110,
382
+ 116
383
+ ]
384
+ },
385
+ {
386
+ "kind": "account",
387
+ "path": "vault"
388
+ }
389
+ ]
390
+ }
391
+ }
392
+ ],
393
+ "args": []
394
+ },
318
395
  {
319
396
  "name": "cancel_request_withdraw_vault",
320
397
  "discriminator": [
@@ -6185,6 +6262,19 @@
6185
6262
  155
6186
6263
  ]
6187
6264
  },
6265
+ {
6266
+ "name": "CalibrateHighWaterMarkUnsafeEvent",
6267
+ "discriminator": [
6268
+ 205,
6269
+ 76,
6270
+ 169,
6271
+ 255,
6272
+ 37,
6273
+ 228,
6274
+ 65,
6275
+ 130
6276
+ ]
6277
+ },
6188
6278
  {
6189
6279
  "name": "CancelRequestWithdrawVaultEvent",
6190
6280
  "discriminator": [
@@ -6724,6 +6814,42 @@
6724
6814
  ]
6725
6815
  }
6726
6816
  },
6817
+ {
6818
+ "name": "CalibrateHighWaterMarkUnsafeEvent",
6819
+ "type": {
6820
+ "kind": "struct",
6821
+ "fields": [
6822
+ {
6823
+ "name": "admin",
6824
+ "type": "pubkey"
6825
+ },
6826
+ {
6827
+ "name": "vault",
6828
+ "type": "pubkey"
6829
+ },
6830
+ {
6831
+ "name": "vault_asset_total_value",
6832
+ "type": "u64"
6833
+ },
6834
+ {
6835
+ "name": "vault_lp_supply_incl_fees",
6836
+ "type": "u64"
6837
+ },
6838
+ {
6839
+ "name": "vault_highest_asset_per_lp_decimal_bits_before",
6840
+ "type": "u128"
6841
+ },
6842
+ {
6843
+ "name": "vault_highest_asset_per_lp_decimal_bits_after",
6844
+ "type": "u128"
6845
+ },
6846
+ {
6847
+ "name": "calibrated_ts",
6848
+ "type": "u64"
6849
+ }
6850
+ ]
6851
+ }
6852
+ },
6727
6853
  {
6728
6854
  "name": "CancelRequestWithdrawVaultEvent",
6729
6855
  "type": {
@@ -321,6 +321,83 @@ export type VoltrVault = {
321
321
  ];
322
322
  "args": [];
323
323
  },
324
+ {
325
+ "name": "calibrateHighWaterMarkUnsafe";
326
+ "discriminator": [
327
+ 162,
328
+ 16,
329
+ 96,
330
+ 202,
331
+ 178,
332
+ 8,
333
+ 187,
334
+ 235
335
+ ];
336
+ "accounts": [
337
+ {
338
+ "name": "admin";
339
+ "signer": true;
340
+ "relations": [
341
+ "vault"
342
+ ];
343
+ },
344
+ {
345
+ "name": "protocol";
346
+ "pda": {
347
+ "seeds": [
348
+ {
349
+ "kind": "const";
350
+ "value": [
351
+ 112,
352
+ 114,
353
+ 111,
354
+ 116,
355
+ 111,
356
+ 99,
357
+ 111,
358
+ 108
359
+ ];
360
+ }
361
+ ];
362
+ };
363
+ },
364
+ {
365
+ "name": "vault";
366
+ "writable": true;
367
+ },
368
+ {
369
+ "name": "vaultLpMint";
370
+ "writable": true;
371
+ "pda": {
372
+ "seeds": [
373
+ {
374
+ "kind": "const";
375
+ "value": [
376
+ 118,
377
+ 97,
378
+ 117,
379
+ 108,
380
+ 116,
381
+ 95,
382
+ 108,
383
+ 112,
384
+ 95,
385
+ 109,
386
+ 105,
387
+ 110,
388
+ 116
389
+ ];
390
+ },
391
+ {
392
+ "kind": "account";
393
+ "path": "vault";
394
+ }
395
+ ];
396
+ };
397
+ }
398
+ ];
399
+ "args": [];
400
+ },
324
401
  {
325
402
  "name": "cancelRequestWithdrawVault";
326
403
  "discriminator": [
@@ -6191,6 +6268,19 @@ export type VoltrVault = {
6191
6268
  155
6192
6269
  ];
6193
6270
  },
6271
+ {
6272
+ "name": "calibrateHighWaterMarkUnsafeEvent";
6273
+ "discriminator": [
6274
+ 205,
6275
+ 76,
6276
+ 169,
6277
+ 255,
6278
+ 37,
6279
+ 228,
6280
+ 65,
6281
+ 130
6282
+ ];
6283
+ },
6194
6284
  {
6195
6285
  "name": "cancelRequestWithdrawVaultEvent";
6196
6286
  "discriminator": [
@@ -6730,6 +6820,42 @@ export type VoltrVault = {
6730
6820
  ];
6731
6821
  };
6732
6822
  },
6823
+ {
6824
+ "name": "calibrateHighWaterMarkUnsafeEvent";
6825
+ "type": {
6826
+ "kind": "struct";
6827
+ "fields": [
6828
+ {
6829
+ "name": "admin";
6830
+ "type": "pubkey";
6831
+ },
6832
+ {
6833
+ "name": "vault";
6834
+ "type": "pubkey";
6835
+ },
6836
+ {
6837
+ "name": "vaultAssetTotalValue";
6838
+ "type": "u64";
6839
+ },
6840
+ {
6841
+ "name": "vaultLpSupplyInclFees";
6842
+ "type": "u64";
6843
+ },
6844
+ {
6845
+ "name": "vaultHighestAssetPerLpDecimalBitsBefore";
6846
+ "type": "u128";
6847
+ },
6848
+ {
6849
+ "name": "vaultHighestAssetPerLpDecimalBitsAfter";
6850
+ "type": "u128";
6851
+ },
6852
+ {
6853
+ "name": "calibratedTs";
6854
+ "type": "u64";
6855
+ }
6856
+ ];
6857
+ };
6858
+ },
6733
6859
  {
6734
6860
  "name": "cancelRequestWithdrawVaultEvent";
6735
6861
  "type": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltr/vault-sdk",
3
- "version": "1.0.20",
3
+ "version": "1.1.0",
4
4
  "description": "SDK for interacting with Voltr Protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",