@neutral-trade/sdk 0.1.20 → 0.2.1

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
@@ -4,10 +4,14 @@
4
4
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
5
  [![License][license-src]][license-href]
6
6
 
7
- TypeScript SDK for [Neutral Trade](https://neutral.trade) vaults.
7
+ TypeScript SDK for [Neutral Trade](https://neutral.trade) **Bundle** vaults (on-chain reads, balances, registry).
8
8
 
9
9
  📚 **[Documentation](https://sdk.neutral.trade/)**
10
10
 
11
+ ## Drift vault balances (legacy)
12
+
13
+ This package **does not** depend on `@drift-labs/*`. The public registry may still list historical Drift vault metadata, but **`NeutralTrade.getUserBalanceByVaultIds` only returns Bundle vaults**. Drift depositor balances are outside this package’s scope.
14
+
11
15
  ## Installation
12
16
 
13
17
  ```bash
@@ -24,7 +28,7 @@ pnpm add @neutral-trade/sdk
24
28
  bun add @neutral-trade/sdk
25
29
  ```
26
30
 
27
- All dependencies are bundled with the SDK, so no additional peer dependencies are required.
31
+ Runtime dependencies are declared normally (Anchor, Solana web3, etc.); consumers should not need extra setup for Bundle flows.
28
32
 
29
33
  ## Quick Start
30
34
 
@@ -36,33 +40,28 @@ const sdk = await NeutralTrade.create({
36
40
  rpcUrl: 'YOUR_RPC_URL_HERE'
37
41
  })
38
42
 
39
- // Get user balance for specific vaults
43
+ // Get user balance for Bundle vaults only
40
44
  const balances = await sdk.getUserBalanceByVaultIds({
41
- vaultIds: [VaultId.sol_super_staking_1, VaultId.btc_super_staking_3],
45
+ vaultIds: [VaultId.hyperliquid_funding_arb_48, VaultId.alp_delta_neutral_49],
42
46
  userAddress: 'YOUR_WALLET_ADDRESS'
43
47
  })
44
48
 
45
49
  console.log(balances)
46
50
  ```
47
51
 
48
- ## Available Vaults
52
+ ## Vault registry
49
53
 
50
- The SDK supports both **Drift** and **Bundle** vault types. Use the `VaultId` enum to reference vaults:
54
+ Built-in configs include multiple vault **types** in metadata (`VaultType` may still include `Drift` for historical entries). **Balance queries** in this package apply only to **`VaultType.Bundle`** rows.
51
55
 
52
56
  ```typescript
53
57
  import { VaultId } from '@neutral-trade/sdk'
54
58
 
55
- // Drift Vaults
56
- VaultId.sol_super_staking_1 // SOL Super Staking
57
- VaultId.btc_super_staking_3 // BTC Super Staking
58
- VaultId.jlp_delta_neutral_vault_1_0 // JLP Delta Neutral (vault-1)
59
-
60
- // Bundle Vaults
59
+ // Examples — Bundle vaults (balances supported here)
61
60
  VaultId.hyperliquid_funding_arb_48 // Hyperliquid Funding Arb
62
61
  VaultId.alp_delta_neutral_49 // ALP Delta Neutral
63
62
  ```
64
63
 
65
- See the [documentation](https://sdk.neutral.trade) for the complete list of available vaults.
64
+ See the [documentation](https://sdk.neutral.trade) for the complete list of vault IDs.
66
65
 
67
66
  ## Configuration Registry
68
67
 
package/dist/index.d.mts CHANGED
@@ -1,9 +1,14 @@
1
- import { AnchorProvider, IdlAccounts, Program } from "@coral-xyz/anchor";
1
+ import { AnchorProvider, IdlAccounts, Program, Wallet } from "@coral-xyz/anchor";
2
2
  import { AnchorProvider as AnchorProvider$1, IdlAccounts as IdlAccounts$1, Program as Program$1 } from "@coral-xyz/anchor-32";
3
3
  import { Connection, PublicKey } from "@solana/web3.js";
4
- import { VaultClient } from "@drift-labs/vaults-sdk";
5
4
  import { z } from "zod";
6
5
 
6
+ //#region src/constants/client.d.ts
7
+ declare function createDummyWallet(): Wallet;
8
+ declare function createConnection(rpcUrl: string): Connection;
9
+ declare function createAnchorProviderV29(connection: Connection, wallet?: Wallet): AnchorProvider;
10
+ declare function createAnchorProviderV32(connection: Connection, wallet?: Wallet): AnchorProvider$1;
11
+ //#endregion
7
12
  //#region src/types/tokens.d.ts
8
13
  declare enum SupportedChain {
9
14
  Solana = "Solana",
@@ -5232,11 +5237,6 @@ declare enum VaultId {
5232
5237
  * Uses registry value if present, otherwise defaults to V1
5233
5238
  */
5234
5239
  declare function getBundleProgramId(vault: VaultRegistryEntry): BundleProgramId | undefined;
5235
- /**
5236
- * Get Drift Program ID for a vault config as PublicKey
5237
- * Uses registry value if present, otherwise defaults to VAULT_PROGRAM_ID
5238
- */
5239
- declare function getDriftProgramId(vault: VaultRegistryEntry): string | undefined;
5240
5240
  declare const vaults$1: VaultRegistry;
5241
5241
  declare function isValidVaultAddress(address: string): boolean;
5242
5242
  declare function getVaultByAddress(address: string): VaultRegistryEntry | undefined;
@@ -5254,7 +5254,6 @@ declare class NeutralTrade {
5254
5254
  readonly connection: Connection;
5255
5255
  readonly bundleProgramV1: Program<NtbundleV1>;
5256
5256
  readonly bundleProgramV2: Program$1<NtbundleV2>;
5257
- readonly driftVaultClient: VaultClient;
5258
5257
  /** Vault configurations (built-in merged with remote if registryUrl was provided) */
5259
5258
  readonly vaults: VaultRegistry;
5260
5259
  /** Price map for deposit tokens */
@@ -5262,7 +5261,6 @@ declare class NeutralTrade {
5262
5261
  private constructor();
5263
5262
  /**
5264
5263
  * Create a new NeutralTrade instance
5265
- * This is async because DriftClient needs to subscribe
5266
5264
  * @throws Error if registryUrl is provided but fetch fails or validation fails
5267
5265
  */
5268
5266
  static create(config: NeutralTradeConfig): Promise<NeutralTrade>;
@@ -5273,7 +5271,8 @@ declare class NeutralTrade {
5273
5271
  */
5274
5272
  private static fetchVaultsFromRegistry;
5275
5273
  /**
5276
- * Get user balance for multiple vaults (both Drift and Bundle)
5274
+ * Get user balance for Bundle vaults only.
5275
+ * Drift vault IDs are ignored (no keys in the result).
5277
5276
  */
5278
5277
  getUserBalanceByVaultIds({
5279
5278
  vaultIds,
@@ -5317,4 +5316,4 @@ declare function deriveUserPDA(userKey: PublicKey, bundlePDA: PublicKey, program
5317
5316
  */
5318
5317
  declare function getVaultDepositorAddressSync(programId: PublicKey, vault: PublicKey, authority: PublicKey): PublicKey;
5319
5318
  //#endregion
5320
- 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 };
5319
+ 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, createAnchorProviderV29, createAnchorProviderV32, createBundleProgramV1, createBundleProgramV2, createBundlePrograms, createConnection, createDummyWallet, deriveOraclePDA, deriveUserPDA, estimatePendingBundleFeeToken, getBundleProgramId, getPointsVaults, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults$1 as vaults };
package/dist/index.mjs CHANGED
@@ -1,11 +1,33 @@
1
1
  import { AnchorProvider, Program } from "@coral-xyz/anchor";
2
2
  import { AnchorProvider as AnchorProvider$1, Program as Program$1 } from "@coral-xyz/anchor-32";
3
3
  import { Connection, Keypair, PublicKey } from "@solana/web3.js";
4
- import { IDL, VAULT_PROGRAM_ID, VaultClient } from "@drift-labs/vaults-sdk";
5
4
  import { z } from "zod";
6
- import { BulkAccountLoader, DriftClient, QUOTE_PRECISION, TEN, convertToNumber } from "@drift-labs/sdk";
7
- import { BN } from "bn.js";
8
5
 
6
+ //#region src/constants/addr.ts
7
+ const ZERO_ADDRESS = new PublicKey("11111111111111111111111111111111");
8
+ const WSOL_MINT = new PublicKey("So11111111111111111111111111111111111111112");
9
+
10
+ //#endregion
11
+ //#region src/constants/client.ts
12
+ function createDummyWallet() {
13
+ return {
14
+ publicKey: ZERO_ADDRESS,
15
+ signTransaction: async (tx) => tx,
16
+ signAllTransactions: async (txs) => txs,
17
+ payer: Keypair.generate()
18
+ };
19
+ }
20
+ function createConnection(rpcUrl) {
21
+ return new Connection(rpcUrl, "confirmed");
22
+ }
23
+ function createAnchorProviderV29(connection, wallet) {
24
+ return new AnchorProvider(connection, wallet ?? createDummyWallet(), AnchorProvider.defaultOptions());
25
+ }
26
+ function createAnchorProviderV32(connection, wallet) {
27
+ return new AnchorProvider$1(connection, wallet ?? createDummyWallet(), AnchorProvider$1.defaultOptions());
28
+ }
29
+
30
+ //#endregion
9
31
  //#region src/constants/points-vaults.ts
10
32
  /**
11
33
  * Get vaults that earn points, filtered by pointsEnabled !== false.
@@ -8087,31 +8109,6 @@ var bundle_v2_default = {
8087
8109
  ]
8088
8110
  };
8089
8111
 
8090
- //#endregion
8091
- //#region src/constants/addr.ts
8092
- const ZERO_ADDRESS = new PublicKey("11111111111111111111111111111111");
8093
- const WSOL_MINT = new PublicKey("So11111111111111111111111111111111111111112");
8094
-
8095
- //#endregion
8096
- //#region src/constants/client.ts
8097
- function createDummyWallet() {
8098
- return {
8099
- publicKey: ZERO_ADDRESS,
8100
- signTransaction: async (tx) => tx,
8101
- signAllTransactions: async (txs) => txs,
8102
- payer: Keypair.generate()
8103
- };
8104
- }
8105
- function createConnection(rpcUrl) {
8106
- return new Connection(rpcUrl, "confirmed");
8107
- }
8108
- function createAnchorProviderV29(connection, wallet) {
8109
- return new AnchorProvider(connection, wallet ?? createDummyWallet(), AnchorProvider.defaultOptions());
8110
- }
8111
- function createAnchorProviderV32(connection, wallet) {
8112
- return new AnchorProvider$1(connection, wallet ?? createDummyWallet(), AnchorProvider$1.defaultOptions());
8113
- }
8114
-
8115
8112
  //#endregion
8116
8113
  //#region src/constants/programs.ts
8117
8114
  let BundleProgramId = /* @__PURE__ */ function(BundleProgramId$1) {
@@ -8444,7 +8441,7 @@ var vaults_default = [
8444
8441
  "depositToken": "USDC",
8445
8442
  "pfee": .2,
8446
8443
  "pointsMultiplier": 2,
8447
- "pointsEnabled": true
8444
+ "pointsEnabled": false
8448
8445
  },
8449
8446
  {
8450
8447
  "vaultId": 63,
@@ -8456,7 +8453,7 @@ var vaults_default = [
8456
8453
  "depositToken": "USDC",
8457
8454
  "pfee": .1,
8458
8455
  "pointsMultiplier": 2,
8459
- "pointsEnabled": true
8456
+ "pointsEnabled": false
8460
8457
  },
8461
8458
  {
8462
8459
  "vaultId": 62,
@@ -8468,7 +8465,7 @@ var vaults_default = [
8468
8465
  "depositToken": "USDC",
8469
8466
  "pfee": .2,
8470
8467
  "pointsMultiplier": 2,
8471
- "pointsEnabled": true
8468
+ "pointsEnabled": false
8472
8469
  },
8473
8470
  {
8474
8471
  "vaultId": 61,
@@ -8501,7 +8498,7 @@ var vaults_default = [
8501
8498
  "depositToken": "USDC",
8502
8499
  "pfee": .25,
8503
8500
  "pointsMultiplier": 2,
8504
- "pointsEnabled": true
8501
+ "pointsEnabled": false
8505
8502
  },
8506
8503
  {
8507
8504
  "vaultId": 58,
@@ -8524,7 +8521,7 @@ var vaults_default = [
8524
8521
  "depositToken": "USDC",
8525
8522
  "pfee": .2,
8526
8523
  "pointsMultiplier": 2,
8527
- "pointsEnabled": true
8524
+ "pointsEnabled": false
8528
8525
  },
8529
8526
  {
8530
8527
  "vaultId": 56,
@@ -8631,7 +8628,7 @@ var vaults_default = [
8631
8628
  "depositToken": "USDC",
8632
8629
  "pfee": .15,
8633
8630
  "pointsMultiplier": 2,
8634
- "pointsEnabled": true
8631
+ "pointsEnabled": false
8635
8632
  },
8636
8633
  {
8637
8634
  "vaultId": 45,
@@ -8740,7 +8737,7 @@ var vaults_default = [
8740
8737
  "depositToken": "JLP",
8741
8738
  "pfee": 0,
8742
8739
  "pointsMultiplier": 2,
8743
- "pointsEnabled": true
8740
+ "pointsEnabled": false
8744
8741
  },
8745
8742
  {
8746
8743
  "vaultId": 35,
@@ -8763,7 +8760,7 @@ var vaults_default = [
8763
8760
  "depositToken": "USDC",
8764
8761
  "pfee": .2,
8765
8762
  "pointsMultiplier": 2,
8766
- "pointsEnabled": true
8763
+ "pointsEnabled": false
8767
8764
  },
8768
8765
  {
8769
8766
  "vaultId": 33,
@@ -8775,7 +8772,7 @@ var vaults_default = [
8775
8772
  "depositToken": "USDC",
8776
8773
  "pfee": .25,
8777
8774
  "pointsMultiplier": 2,
8778
- "pointsEnabled": true
8775
+ "pointsEnabled": false
8779
8776
  },
8780
8777
  {
8781
8778
  "vaultId": 32,
@@ -8787,7 +8784,7 @@ var vaults_default = [
8787
8784
  "depositToken": "USDC",
8788
8785
  "pfee": .2,
8789
8786
  "pointsMultiplier": 2,
8790
- "pointsEnabled": true
8787
+ "pointsEnabled": false
8791
8788
  },
8792
8789
  {
8793
8790
  "vaultId": 31,
@@ -8810,7 +8807,7 @@ var vaults_default = [
8810
8807
  "depositToken": "USDC",
8811
8808
  "pfee": .1,
8812
8809
  "pointsMultiplier": 1,
8813
- "pointsEnabled": true
8810
+ "pointsEnabled": false
8814
8811
  },
8815
8812
  {
8816
8813
  "vaultId": 29,
@@ -8822,7 +8819,7 @@ var vaults_default = [
8822
8819
  "depositToken": "USDC",
8823
8820
  "pfee": .25,
8824
8821
  "pointsMultiplier": 2,
8825
- "pointsEnabled": true
8822
+ "pointsEnabled": false
8826
8823
  },
8827
8824
  {
8828
8825
  "vaultId": 28,
@@ -8856,7 +8853,7 @@ var vaults_default = [
8856
8853
  "depositToken": "WBTC",
8857
8854
  "pfee": .2,
8858
8855
  "pointsMultiplier": 1,
8859
- "pointsEnabled": true
8856
+ "pointsEnabled": false
8860
8857
  },
8861
8858
  {
8862
8859
  "vaultId": 25,
@@ -8868,7 +8865,7 @@ var vaults_default = [
8868
8865
  "depositToken": "USDC",
8869
8866
  "pfee": .25,
8870
8867
  "pointsMultiplier": 2,
8871
- "pointsEnabled": true
8868
+ "pointsEnabled": false
8872
8869
  },
8873
8870
  {
8874
8871
  "vaultId": 24,
@@ -8891,7 +8888,7 @@ var vaults_default = [
8891
8888
  "depositToken": "USDC",
8892
8889
  "pfee": .2,
8893
8890
  "pointsMultiplier": 2,
8894
- "pointsEnabled": true
8891
+ "pointsEnabled": false
8895
8892
  },
8896
8893
  {
8897
8894
  "vaultId": 22,
@@ -8969,7 +8966,7 @@ var vaults_default = [
8969
8966
  "depositToken": "USDC",
8970
8967
  "pfee": .25,
8971
8968
  "pointsMultiplier": 2,
8972
- "pointsEnabled": true
8969
+ "pointsEnabled": false
8973
8970
  },
8974
8971
  {
8975
8972
  "vaultId": 15,
@@ -9047,7 +9044,7 @@ var vaults_default = [
9047
9044
  "depositToken": "USDC",
9048
9045
  "pfee": .2,
9049
9046
  "pointsMultiplier": 2,
9050
- "pointsEnabled": true
9047
+ "pointsEnabled": false
9051
9048
  },
9052
9049
  {
9053
9050
  "vaultId": 8,
@@ -9079,7 +9076,7 @@ var vaults_default = [
9079
9076
  "depositToken": "WETH",
9080
9077
  "pfee": .2,
9081
9078
  "pointsMultiplier": 1,
9082
- "pointsEnabled": true
9079
+ "pointsEnabled": false
9083
9080
  },
9084
9081
  {
9085
9082
  "vaultId": 5,
@@ -9102,7 +9099,7 @@ var vaults_default = [
9102
9099
  "depositToken": "USDC",
9103
9100
  "pfee": .25,
9104
9101
  "pointsMultiplier": 2,
9105
- "pointsEnabled": true
9102
+ "pointsEnabled": false
9106
9103
  },
9107
9104
  {
9108
9105
  "vaultId": 3,
@@ -9113,7 +9110,7 @@ var vaults_default = [
9113
9110
  "depositToken": "WBTC",
9114
9111
  "pfee": .2,
9115
9112
  "pointsMultiplier": 1,
9116
- "pointsEnabled": true
9113
+ "pointsEnabled": false
9117
9114
  },
9118
9115
  {
9119
9116
  "vaultId": 2,
@@ -9135,7 +9132,7 @@ var vaults_default = [
9135
9132
  "depositToken": "SOL",
9136
9133
  "pfee": .2,
9137
9134
  "pointsMultiplier": 1,
9138
- "pointsEnabled": true
9135
+ "pointsEnabled": false
9139
9136
  },
9140
9137
  {
9141
9138
  "vaultId": 0,
@@ -9286,6 +9283,7 @@ const VaultRegistryArraySchema = z.array(VaultRegistryEntrySchema).superRefine((
9286
9283
 
9287
9284
  //#endregion
9288
9285
  //#region src/constants/vaults.ts
9286
+ const VAULT_PROGRAM_ID = new PublicKey("vAuLTsyrvSfZRuRB3XgvkPwNGgYSs9YRYymVebLKoxR");
9289
9287
  /**
9290
9288
  * Get Bundle Program ID for a vault config
9291
9289
  * Uses registry value if present, otherwise defaults to V1
@@ -9550,101 +9548,6 @@ async function getBundleBalances({ vaultIds, userAddress, vaults: vaults$1, bund
9550
9548
  return result;
9551
9549
  }
9552
9550
 
9553
- //#endregion
9554
- //#region src/utils/drift.ts
9555
- /**
9556
- * Calculate total earnings for Drift vault
9557
- */
9558
- function getDriftVaultTotalEarning({ netDepositToken, requestWithdrawToken, balanceToken }) {
9559
- const realizedProfit = -Math.min(netDepositToken - requestWithdrawToken, 0);
9560
- const unrealizedProfit = balanceToken - Math.max(netDepositToken - requestWithdrawToken, 0);
9561
- return realizedProfit + unrealizedProfit >= -.01 && realizedProfit + unrealizedProfit <= .01 ? 0 : realizedProfit + unrealizedProfit;
9562
- }
9563
- /**
9564
- * Calculate Drift vault balance from vault and vaultDepositor accounts
9565
- */
9566
- async function calculateDriftVaultBalance({ vault, vaultDepositor, driftVaultClient, profitShareFeePercent = 0, asset = SupportedToken.USDC }) {
9567
- const vaultClient = driftVaultClient;
9568
- const driftClient = vaultClient.driftClient;
9569
- const vaultEquity = await vaultClient.calculateVaultEquity({ vault });
9570
- const spotMarket = driftClient.getSpotMarketAccount(vault.spotMarketIndex);
9571
- if (!spotMarket) throw new Error("Spot market not found");
9572
- const spotPrice = convertToNumber(driftClient.getOracleDataForSpotMarket(vault.spotMarketIndex).price, QUOTE_PRECISION);
9573
- const vaultEquityNum = convertToNumber(vaultEquity, QUOTE_PRECISION);
9574
- const vaultDepositorShare = vaultDepositor.vaultShares.toNumber();
9575
- const activeShares = vaultDepositorShare - vaultDepositor.lastWithdrawRequest.shares.toNumber();
9576
- const balanceUsd = vault.totalShares.toNumber() > 0 ? vaultEquityNum * activeShares / vault.totalShares.toNumber() : 0;
9577
- const balanceToken = spotPrice > 0 ? balanceUsd / spotPrice : 0;
9578
- const spotPrecision = TEN.pow(new BN(spotMarket.decimals));
9579
- const netDeposit = convertToNumber(vaultDepositor.netDeposits, spotPrecision);
9580
- const requestWithdrawToken = convertToNumber(vaultDepositor.lastWithdrawRequest.value, spotPrecision);
9581
- const profitShareFeePaid = convertToNumber(vaultDepositor.profitShareFeePaid, spotPrecision);
9582
- const highWaterMark = netDeposit + convertToNumber(vaultDepositor.cumulativeProfitShareAmount, spotPrecision);
9583
- let pendingProfitShareFee = 0;
9584
- if (balanceToken > highWaterMark) pendingProfitShareFee = (balanceToken - highWaterMark) * profitShareFeePercent / 100;
9585
- const netEarnings = getDriftVaultTotalEarning({
9586
- netDepositToken: netDeposit,
9587
- requestWithdrawToken,
9588
- balanceToken
9589
- });
9590
- const totalDeposit = balanceToken + requestWithdrawToken;
9591
- return {
9592
- balanceToken,
9593
- balanceUsd,
9594
- netEarnings,
9595
- netEarningsUsd: netEarnings * spotPrice,
9596
- totalDepositUsd: totalDeposit * spotPrice,
9597
- totalDeposit,
9598
- requestWithdrawToken,
9599
- spotPrice,
9600
- netDeposit,
9601
- vaultShares: vaultDepositorShare,
9602
- feesPaid: profitShareFeePaid,
9603
- highWaterMark,
9604
- pendingProfitShareFee,
9605
- pendingFee: pendingProfitShareFee,
9606
- pendingFeeUsd: pendingProfitShareFee * spotPrice,
9607
- asset
9608
- };
9609
- }
9610
- async function getDriftBalances({ vaultIds, userAddress, vaults: vaults$1, driftVaultClient }) {
9611
- const result = {};
9612
- const userPublicKey = new PublicKey(userAddress);
9613
- const vaultEntries = vaultIds.map((id) => ({
9614
- vaultId: id,
9615
- config: vaults$1[id]
9616
- })).filter((entry) => entry.config !== void 0);
9617
- if (vaultEntries.length === 0) return result;
9618
- const vaultAddresses = vaultEntries.map(({ config }) => new PublicKey(config.vaultAddress));
9619
- const vaultDepositorPDAs = vaultEntries.map(({ config }) => {
9620
- const vaultPubkey = new PublicKey(config.vaultAddress);
9621
- return getVaultDepositorAddressSync(config.driftProgramId ? new PublicKey(config.driftProgramId) : VAULT_PROGRAM_ID, vaultPubkey, userPublicKey);
9622
- });
9623
- const [vaultsData, vaultDepositors] = await Promise.all([driftVaultClient.program.account.vault.fetchMultiple(vaultAddresses), driftVaultClient.program.account.vaultDepositor.fetchMultiple(vaultDepositorPDAs)]);
9624
- for (let i = 0; i < vaultEntries.length; i++) {
9625
- const { vaultId, config } = vaultEntries[i];
9626
- const vault = vaultsData[i];
9627
- const vaultDepositor = vaultDepositors[i];
9628
- if (!vault || !vaultDepositor) {
9629
- result[vaultId] = null;
9630
- continue;
9631
- }
9632
- try {
9633
- result[vaultId] = await calculateDriftVaultBalance({
9634
- vault,
9635
- vaultDepositor,
9636
- driftVaultClient,
9637
- profitShareFeePercent: (config.pfee ?? 0) * 100,
9638
- asset: config.depositToken
9639
- });
9640
- } catch (e) {
9641
- console.error(`Error calculating balance for drift vault ${vaultId}:`, e);
9642
- result[vaultId] = null;
9643
- }
9644
- }
9645
- return result;
9646
- }
9647
-
9648
9551
  //#endregion
9649
9552
  //#region src/utils/price.ts
9650
9553
  /**
@@ -9694,7 +9597,6 @@ async function fetchPricesFromPyth(tokens$1) {
9694
9597
  }
9695
9598
  /**
9696
9599
  * Initialize price map by fetching from Pyth Network first, then using fallback prices for any missing
9697
- * @param vaults - Vault configurations to determine which tokens need prices
9698
9600
  * @param fallbackPrices - Optional fallback prices to use if Pyth fetch fails or returns incomplete data
9699
9601
  */
9700
9602
  async function initializePrices(fallbackPrices) {
@@ -9717,51 +9619,27 @@ var NeutralTrade = class NeutralTrade {
9717
9619
  connection;
9718
9620
  bundleProgramV1;
9719
9621
  bundleProgramV2;
9720
- driftVaultClient;
9721
9622
  /** Vault configurations (built-in merged with remote if registryUrl was provided) */
9722
9623
  vaults;
9723
9624
  /** Price map for deposit tokens */
9724
9625
  priceMap;
9725
- constructor(connection, bundleProgramV1, bundleProgramV2, driftVaultClient, vaults$1, priceMap) {
9626
+ constructor(connection, bundleProgramV1, bundleProgramV2, vaults$1, priceMap) {
9726
9627
  this.connection = connection;
9727
9628
  this.bundleProgramV1 = bundleProgramV1;
9728
9629
  this.bundleProgramV2 = bundleProgramV2;
9729
- this.driftVaultClient = driftVaultClient;
9730
9630
  this.vaults = vaults$1;
9731
9631
  this.priceMap = priceMap;
9732
9632
  }
9733
9633
  /**
9734
9634
  * Create a new NeutralTrade instance
9735
- * This is async because DriftClient needs to subscribe
9736
9635
  * @throws Error if registryUrl is provided but fetch fails or validation fails
9737
9636
  */
9738
9637
  static async create(config) {
9739
9638
  const connection = createConnection(config.rpcUrl);
9740
- const dummyWallet = createDummyWallet();
9741
9639
  const providerV29 = createAnchorProviderV29(connection);
9742
9640
  const providerV32 = createAnchorProviderV32(connection);
9743
9641
  const bundleProgramV1 = createBundleProgramV1(providerV29);
9744
9642
  const bundleProgramV2 = createBundleProgramV2(providerV32);
9745
- const driftClient = new DriftClient({
9746
- connection,
9747
- wallet: dummyWallet,
9748
- env: "mainnet-beta",
9749
- opts: {
9750
- commitment: "confirmed",
9751
- skipPreflight: false,
9752
- preflightCommitment: "confirmed"
9753
- },
9754
- accountSubscription: {
9755
- type: "polling",
9756
- accountLoader: new BulkAccountLoader(connection, "confirmed", 0)
9757
- }
9758
- });
9759
- await driftClient.subscribe();
9760
- const driftVaultClient = new VaultClient({
9761
- driftClient,
9762
- program: new (await (import("@coral-xyz/anchor"))).Program(IDL, VAULT_PROGRAM_ID, providerV29),
9763
- cliMode: false
9764
- });
9765
9643
  let vaults$1 = { ...vaults };
9766
9644
  if (config.registryUrl) {
9767
9645
  const remoteVaults = await NeutralTrade.fetchVaultsFromRegistry(config.registryUrl);
@@ -9771,7 +9649,7 @@ var NeutralTrade = class NeutralTrade {
9771
9649
  };
9772
9650
  }
9773
9651
  const priceMap = await initializePrices(config.fallbackPrices);
9774
- return new NeutralTrade(connection, bundleProgramV1, bundleProgramV2, driftVaultClient, vaults$1, priceMap);
9652
+ return new NeutralTrade(connection, bundleProgramV1, bundleProgramV2, vaults$1, priceMap);
9775
9653
  }
9776
9654
  /**
9777
9655
  * Fetch vault configurations from a remote registry URL
@@ -9787,36 +9665,25 @@ var NeutralTrade = class NeutralTrade {
9787
9665
  return toVaultRegistry(parseResult.data);
9788
9666
  }
9789
9667
  /**
9790
- * Get user balance for multiple vaults (both Drift and Bundle)
9668
+ * Get user balance for Bundle vaults only.
9669
+ * Drift vault IDs are ignored (no keys in the result).
9791
9670
  */
9792
9671
  async getUserBalanceByVaultIds({ vaultIds, userAddress }) {
9793
- const driftVaultIds = vaultIds.filter((id) => {
9794
- const config = this.vaults[id];
9795
- return config && config.type === VaultType.Drift;
9796
- });
9797
9672
  const bundleVaultIds = vaultIds.filter((id) => {
9798
9673
  const config = this.vaults[id];
9799
9674
  return config && config.type === VaultType.Bundle;
9800
9675
  });
9801
- const [driftResults, bundleResults] = await Promise.all([driftVaultIds.length > 0 ? getDriftBalances({
9802
- vaultIds: driftVaultIds,
9803
- userAddress,
9804
- vaults: this.vaults,
9805
- driftVaultClient: this.driftVaultClient
9806
- }) : {}, bundleVaultIds.length > 0 ? getBundleBalances({
9676
+ if (bundleVaultIds.length === 0) return {};
9677
+ return await getBundleBalances({
9807
9678
  vaultIds: bundleVaultIds,
9808
9679
  userAddress,
9809
9680
  vaults: this.vaults,
9810
9681
  bundleProgramV1: this.bundleProgramV1,
9811
9682
  bundleProgramV2: this.bundleProgramV2,
9812
9683
  priceMap: this.priceMap
9813
- }) : {}]);
9814
- return {
9815
- ...driftResults,
9816
- ...bundleResults
9817
- };
9684
+ });
9818
9685
  }
9819
9686
  };
9820
9687
 
9821
9688
  //#endregion
9822
- export { BundleProgramId, NeutralTrade, SupportedChain, SupportedToken, VaultCategory, VaultId, VaultType, createBundleProgramV1, createBundleProgramV2, createBundlePrograms, deriveOraclePDA, deriveUserPDA, estimatePendingBundleFeeToken, getBundleProgramId, getDriftProgramId, getPointsVaults, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
9689
+ export { BundleProgramId, NeutralTrade, SupportedChain, SupportedToken, VaultCategory, VaultId, VaultType, createAnchorProviderV29, createAnchorProviderV32, createBundleProgramV1, createBundleProgramV2, createBundlePrograms, createConnection, createDummyWallet, deriveOraclePDA, deriveUserPDA, estimatePendingBundleFeeToken, getBundleProgramId, 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.20",
4
+ "version": "0.2.1",
5
5
  "description": "SDK for Neutral Trade vaults",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/neutral-trade/sdk#readme",
@@ -25,8 +25,6 @@
25
25
  "dependencies": {
26
26
  "@coral-xyz/anchor": "0.29.0",
27
27
  "@coral-xyz/anchor-32": "npm:@coral-xyz/anchor@0.32.0",
28
- "@drift-labs/sdk": "2.155.0-beta.5",
29
- "@drift-labs/vaults-sdk": "0.9.264",
30
28
  "@solana/web3.js": "^1.98.4",
31
29
  "@types/bn.js": "^5.2.0",
32
30
  "bn.js": "^5.2.3",
@@ -38,9 +36,9 @@
38
36
  "@antfu/utils": "^9.3.0",
39
37
  "@coral-xyz/anchor": "0.29.0",
40
38
  "@coral-xyz/anchor-32": "npm:@coral-xyz/anchor@0.32.0",
41
- "@drift-labs/sdk": "2.155.0-beta.5",
42
39
  "@solana/web3.js": "^1.98.4",
43
40
  "@types/node": "^25.0.1",
41
+ "baseline-browser-mapping": "^2.10.27",
44
42
  "bumpp": "^10.3.2",
45
43
  "dotenv": "^17.2.3",
46
44
  "eslint": "^9.39.2",
@@ -62,7 +60,7 @@
62
60
  "pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
63
61
  },
64
62
  "lint-staged": {
65
- "*": "eslint --fix"
63
+ "*.{js,cjs,mjs,ts,mts,cts,tsx,jsx}": "eslint --fix"
66
64
  },
67
65
  "scripts": {
68
66
  "generate": "tsx scripts/generate-vault-ids.ts",