@neutral-trade/sdk 0.1.16 → 0.1.18

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/index.d.mts CHANGED
@@ -5014,6 +5014,9 @@ interface VaultBalanceData {
5014
5014
  /** Total profit share fee paid by the user */
5015
5015
  feesPaid?: number;
5016
5016
  pendingProfitShareFee?: number;
5017
+ /** Unpaid / accrued fees in deposit token; null if not applicable. Bundle: mgmt+perf estimate; Drift: pending profit share. */
5018
+ pendingFee: number | null;
5019
+ pendingFeeUsd: number | null;
5017
5020
  spotPrice: number;
5018
5021
  /** User's vault shares (raw number, not divided by decimals) */
5019
5022
  vaultShares?: number;
@@ -5066,8 +5069,8 @@ declare function createBundlePrograms(connection: Connection): {
5066
5069
  * These are auto-generated from the vault registry
5067
5070
  */
5068
5071
  declare enum VaultId {
5069
- /** Volatility Alpha */
5070
- volatility_alpha_74 = 74,
5072
+ /** Multi-Asset Volatility Arbitrage */
5073
+ multi_asset_volatility_arbitrage_74 = 74,
5071
5074
  /** Great Debasement */
5072
5075
  great_debasement_73 = 73,
5073
5076
  /** CTA-Adaptive Alpha - Atlas Research */
@@ -5229,7 +5232,7 @@ declare function getBundleProgramId(vault: VaultRegistryEntry): BundleProgramId
5229
5232
  * Uses registry value if present, otherwise defaults to VAULT_PROGRAM_ID
5230
5233
  */
5231
5234
  declare function getDriftProgramId(vault: VaultRegistryEntry): string | undefined;
5232
- declare const vaults: VaultRegistry;
5235
+ declare const vaults$1: VaultRegistry;
5233
5236
  declare function isValidVaultAddress(address: string): boolean;
5234
5237
  declare function getVaultByAddress(address: string): VaultRegistryEntry | undefined;
5235
5238
  declare function getVaultById(vaultId: number): VaultRegistryEntry | undefined;
@@ -5276,6 +5279,24 @@ declare class NeutralTrade {
5276
5279
  }): Promise<UserBalanceResult>;
5277
5280
  }
5278
5281
  //#endregion
5282
+ //#region src/utils/bundle.d.ts
5283
+ /**
5284
+ * Estimated unpaid bundle fees in deposit token (mgmt + performance), matching on-chain `charge_user_fees`.
5285
+ */
5286
+ declare function estimatePendingBundleFeeToken({
5287
+ oracleData,
5288
+ bundleData,
5289
+ userBundle,
5290
+ assetDecimals,
5291
+ nowUnixSeconds
5292
+ }: {
5293
+ oracleData: OracleData;
5294
+ bundleData: BundleAccount;
5295
+ userBundle: UserBundleAccount;
5296
+ assetDecimals: number;
5297
+ nowUnixSeconds?: number;
5298
+ }): number;
5299
+ //#endregion
5279
5300
  //#region src/utils/pda.d.ts
5280
5301
  /**
5281
5302
  * Derive Oracle PDA for Bundle vault
@@ -5291,4 +5312,4 @@ declare function deriveUserPDA(userKey: PublicKey, bundlePDA: PublicKey, program
5291
5312
  */
5292
5313
  declare function getVaultDepositorAddressSync(programId: PublicKey, vault: PublicKey, authority: PublicKey): PublicKey;
5293
5314
  //#endregion
5294
- export { type BundleAccount, BundleProgramId, NeutralTrade, type NeutralTradeConfig, type OracleData, type PointsVaultEntry, SupportedChain, SupportedToken, type Token, type UserBalanceResult, type UserBundleAccount, type UserBundleTempData, type VaultBalanceData, VaultCategory, type VaultRegistryEntry as VaultConfig, type VaultRegistry as VaultConfigRecord, VaultId, VaultType, createBundleProgramV1, createBundleProgramV2, createBundlePrograms, deriveOraclePDA, deriveUserPDA, getBundleProgramId, getDriftProgramId, getPointsVaults, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
5315
+ export { type BundleAccount, BundleProgramId, NeutralTrade, type NeutralTradeConfig, type OracleData, type PointsVaultEntry, SupportedChain, SupportedToken, type Token, type UserBalanceResult, type UserBundleAccount, type UserBundleTempData, type VaultBalanceData, VaultCategory, type VaultRegistryEntry as VaultConfig, type VaultRegistry as VaultConfigRecord, VaultId, VaultType, createBundleProgramV1, createBundleProgramV2, createBundlePrograms, deriveOraclePDA, deriveUserPDA, estimatePendingBundleFeeToken, getBundleProgramId, getDriftProgramId, getPointsVaults, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults$1 as vaults };
package/dist/index.mjs CHANGED
@@ -8148,8 +8148,8 @@ function createBundlePrograms(connection) {
8148
8148
  * These are auto-generated from the vault registry
8149
8149
  */
8150
8150
  let VaultId = /* @__PURE__ */ function(VaultId$1) {
8151
- /** Volatility Alpha */
8152
- VaultId$1[VaultId$1["volatility_alpha_74"] = 74] = "volatility_alpha_74";
8151
+ /** Multi-Asset Volatility Arbitrage */
8152
+ VaultId$1[VaultId$1["multi_asset_volatility_arbitrage_74"] = 74] = "multi_asset_volatility_arbitrage_74";
8153
8153
  /** Great Debasement */
8154
8154
  VaultId$1[VaultId$1["great_debasement_73"] = 73] = "great_debasement_73";
8155
8155
  /** CTA-Adaptive Alpha - Atlas Research */
@@ -8306,7 +8306,7 @@ let VaultId = /* @__PURE__ */ function(VaultId$1) {
8306
8306
  var vaults_default = [
8307
8307
  {
8308
8308
  "vaultId": 74,
8309
- "name": "Volatility Alpha",
8309
+ "name": "Multi-Asset Volatility Arbitrage",
8310
8310
  "type": "Bundle",
8311
8311
  "category": "Market Neutral",
8312
8312
  "vaultAddress": "4QBTzqUbn1crLg2PDUGt8abJfqHjeuZkjNLjCCit69ui",
@@ -9356,6 +9356,43 @@ function getVaultDepositorAddressSync(programId, vault, authority) {
9356
9356
 
9357
9357
  //#endregion
9358
9358
  //#region src/utils/bundle.ts
9359
+ const SECONDS_PER_YEAR = 365n * 24n * 60n * 60n;
9360
+ function bnToBigInt(v) {
9361
+ if (v == null) return 0n;
9362
+ return BigInt(v.toString());
9363
+ }
9364
+ /**
9365
+ * Estimated unpaid bundle fees in deposit token (mgmt + performance), matching on-chain `charge_user_fees`.
9366
+ */
9367
+ function estimatePendingBundleFeeToken({ oracleData, bundleData, userBundle, assetDecimals, nowUnixSeconds = Math.floor(Date.now() / 1e3) }) {
9368
+ const userShares = bnToBigInt(userBundle.shares);
9369
+ if (userShares <= 0n) return 0;
9370
+ const totalShares = bnToBigInt(bundleData.totalShares);
9371
+ const totalAssets = bnToBigInt(oracleData.averageExternalEquity) + bnToBigInt(bundleData.bundleUnderlyingBalance);
9372
+ const extra = bundleData;
9373
+ const assetPrec = extra.assetPrecision != null ? BigInt(extra.assetPrecision.toString()) : BigInt(10 ** assetDecimals);
9374
+ const sharePrice = totalShares > 0n ? totalAssets * assetPrec / totalShares : assetPrec;
9375
+ const managementFeeBps = BigInt(Number(extra.managementFeeBps ?? 0));
9376
+ const performanceFeeBps = BigInt(Number(extra.performanceFee ?? 0));
9377
+ const lastMgmtTs = bnToBigInt(userBundle.lastManagementFeeTimestamp);
9378
+ const nowTs = BigInt(nowUnixSeconds);
9379
+ let managementFeeShares = 0n;
9380
+ if (lastMgmtTs > 0n && managementFeeBps > 0n) {
9381
+ const secondsElapsed = nowTs > lastMgmtTs ? nowTs - lastMgmtTs : 0n;
9382
+ if (secondsElapsed > 0n) managementFeeShares = userShares * secondsElapsed * managementFeeBps / (SECONDS_PER_YEAR * 10000n);
9383
+ }
9384
+ const hwmPerShare = bnToBigInt(userBundle.hwmPerShare);
9385
+ let performanceFeeShares = 0n;
9386
+ if (performanceFeeBps > 0n && sharePrice > 0n) {
9387
+ const hwmValue = hwmPerShare === 0n ? sharePrice : hwmPerShare;
9388
+ if (sharePrice > hwmValue) performanceFeeShares = (sharePrice - hwmValue) * userShares * performanceFeeBps / (sharePrice * 10000n);
9389
+ }
9390
+ const totalFeeShares = managementFeeShares + performanceFeeShares;
9391
+ if (totalFeeShares === 0n) return 0;
9392
+ const feeValueRaw = totalFeeShares * sharePrice / assetPrec;
9393
+ const divisor = 10 ** assetDecimals;
9394
+ return Number(feeValueRaw) / divisor;
9395
+ }
9359
9396
  /**
9360
9397
  * Calculate on-chain PPS for Bundle vault
9361
9398
  * Formula: (Oracle Average External Equity + USDC on Bundle PDA) / Total Shares
@@ -9382,6 +9419,12 @@ function calculateBundleUserBalance({ oracleData, bundleData, userBundle, assetD
9382
9419
  const feesPaid = Number(userBundle.totalFeeCharged.toString()) / divisor;
9383
9420
  const userEarnings = userBalance - netDeposits;
9384
9421
  const highWaterMark = Math.floor(Number(userBundle.hwmPerShare.toString()) * userSharesNum / divisor) / divisor;
9422
+ const pendingFeeToken = estimatePendingBundleFeeToken({
9423
+ oracleData,
9424
+ bundleData,
9425
+ userBundle,
9426
+ assetDecimals
9427
+ });
9385
9428
  return {
9386
9429
  balanceToken: userBalance,
9387
9430
  balanceUsd: userBalance * spotPrice,
@@ -9392,6 +9435,8 @@ function calculateBundleUserBalance({ oracleData, bundleData, userBundle, assetD
9392
9435
  pendingDeposit,
9393
9436
  highWaterMark: highWaterMark + pendingDeposit,
9394
9437
  feesPaid,
9438
+ pendingFee: pendingFeeToken,
9439
+ pendingFeeUsd: pendingFeeToken * spotPrice,
9395
9440
  spotPrice,
9396
9441
  vaultShares: userSharesNum,
9397
9442
  netDeposit: netDeposits,
@@ -9516,7 +9561,7 @@ async function calculateDriftVaultBalance({ vault, vaultDepositor, driftVaultCli
9516
9561
  netDepositToken: netDeposit,
9517
9562
  requestWithdrawToken,
9518
9563
  balanceToken
9519
- }) - pendingProfitShareFee;
9564
+ });
9520
9565
  const totalDeposit = balanceToken + requestWithdrawToken;
9521
9566
  return {
9522
9567
  balanceToken,
@@ -9532,6 +9577,8 @@ async function calculateDriftVaultBalance({ vault, vaultDepositor, driftVaultCli
9532
9577
  feesPaid: profitShareFeePaid,
9533
9578
  highWaterMark,
9534
9579
  pendingProfitShareFee,
9580
+ pendingFee: pendingProfitShareFee,
9581
+ pendingFeeUsd: pendingProfitShareFee * spotPrice,
9535
9582
  asset
9536
9583
  };
9537
9584
  }
@@ -9747,4 +9794,4 @@ var NeutralTrade = class NeutralTrade {
9747
9794
  };
9748
9795
 
9749
9796
  //#endregion
9750
- export { BundleProgramId, NeutralTrade, SupportedChain, SupportedToken, VaultCategory, VaultId, VaultType, createBundleProgramV1, createBundleProgramV2, createBundlePrograms, deriveOraclePDA, deriveUserPDA, getBundleProgramId, getDriftProgramId, getPointsVaults, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
9797
+ export { BundleProgramId, NeutralTrade, SupportedChain, SupportedToken, VaultCategory, VaultId, VaultType, createBundleProgramV1, createBundleProgramV2, createBundlePrograms, deriveOraclePDA, deriveUserPDA, estimatePendingBundleFeeToken, getBundleProgramId, getDriftProgramId, getPointsVaults, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neutral-trade/sdk",
3
3
  "type": "module",
4
- "version": "0.1.16",
4
+ "version": "0.1.18",
5
5
  "description": "SDK for Neutral Trade vaults",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/neutral-trade/sdk#readme",