@neutral-trade/sdk 0.1.5 → 0.1.7

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
@@ -38,7 +38,7 @@ const sdk = await NeutralTrade.create({
38
38
 
39
39
  // Get user balance for specific vaults
40
40
  const balances = await sdk.getUserBalanceByVaultIds({
41
- vaultIds: [VaultId.solnl, VaultId.btcnl],
41
+ vaultIds: [VaultId.sol_super_staking_1, VaultId.btc_super_staking_3],
42
42
  userAddress: 'YOUR_WALLET_ADDRESS'
43
43
  })
44
44
 
@@ -53,17 +53,50 @@ The SDK supports both **Drift** and **Bundle** vault types. Use the `VaultId` en
53
53
  import { VaultId } from '@neutral-trade/sdk'
54
54
 
55
55
  // Drift Vaults
56
- VaultId.solnl // SOL Neutral Long
57
- VaultId.btcnl // BTC Neutral Long
58
- VaultId.jlpdnv1 // JLP DN V1
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
59
 
60
60
  // Bundle Vaults
61
- VaultId.hlfundingarb // HL Funding Arbitrage
62
- VaultId.alpdn // ALP DN
61
+ VaultId.hyperliquid_funding_arb_48 // Hyperliquid Funding Arb
62
+ VaultId.alp_delta_neutral_49 // ALP Delta Neutral
63
63
  ```
64
64
 
65
65
  See the [documentation](https://sdk.neutral.trade) for the complete list of available vaults.
66
66
 
67
+ ## Configuration Registry
68
+
69
+ The SDK includes built-in vault configurations, but you can also fetch the latest configurations from a remote registry. This is useful if you don't upgrade the SDK package frequently.
70
+
71
+ ### Registry URLs
72
+
73
+ - **GitHub Raw**: `https://raw.githubusercontent.com/neutral-trade/sdk/main/src/registry/vaults.json`
74
+ - **jsDelivr CDN**: `https://cdn.jsdelivr.net/gh/neutral-trade/sdk@main/src/registry/vaults.json`
75
+
76
+ ### Usage
77
+
78
+ **Use the registry URL if you don't upgrade the SDK frequently:**
79
+
80
+ ```typescript
81
+ const sdk = await NeutralTrade.create({
82
+ rpcUrl: 'YOUR_RPC_URL_HERE',
83
+ registryUrl: 'https://cdn.jsdelivr.net/gh/neutral-trade/sdk@main/src/registry/vaults.json'
84
+ })
85
+ ```
86
+
87
+ This ensures you always have the latest vault configurations without needing to update the SDK package.
88
+
89
+ **Use built-in configs if you upgrade the SDK regularly:**
90
+
91
+ ```typescript
92
+ const sdk = await NeutralTrade.create({
93
+ rpcUrl: 'YOUR_RPC_URL_HERE'
94
+ // No registryUrl - uses built-in configurations
95
+ })
96
+ ```
97
+
98
+ This is simpler and doesn't require an additional network request at initialization.
99
+
67
100
  ## Examples
68
101
 
69
102
  Check out the [examples](./examples) directory for more usage examples.
package/dist/index.d.mts CHANGED
@@ -5141,15 +5141,8 @@ interface VaultRegistryEntry {
5141
5141
  /** Optional Bundle program ID (only for Bundle vaults with non-default V2 program) */
5142
5142
  bundleProgramId?: string;
5143
5143
  }
5144
- /** Vault config (same as registry entry, program IDs are optional) */
5145
- interface VaultConfig extends VaultRegistryEntry {
5146
- /** Required for Drift vaults */
5147
- driftProgramId: string;
5148
- /** Required for Bundle vaults */
5149
- bundleProgramId: string;
5150
- }
5151
5144
  /** Vault registry as a record keyed by vaultId */
5152
- type VaultConfigRecord = Record<number, VaultConfig>;
5145
+ type VaultRegistry = Record<number, VaultRegistryEntry>;
5153
5146
  //#endregion
5154
5147
  //#region src/types/index.d.ts
5155
5148
  interface VaultBalanceData {
@@ -5179,16 +5172,16 @@ type UserBalanceResult = Record<number, VaultBalanceData | null>;
5179
5172
  * Get Bundle Program ID for a vault config
5180
5173
  * Uses registry value if present, otherwise defaults to V1
5181
5174
  */
5182
- declare function getBundleProgramId(vault: VaultRegistryEntry): BundleProgramId;
5175
+ declare function getBundleProgramId(vault: VaultRegistryEntry): BundleProgramId | undefined;
5183
5176
  /**
5184
5177
  * Get Drift Program ID for a vault config as PublicKey
5185
5178
  * Uses registry value if present, otherwise defaults to VAULT_PROGRAM_ID
5186
5179
  */
5187
- declare function getDriftProgramId(vault: VaultRegistryEntry): string;
5188
- declare const vaults: VaultConfigRecord;
5180
+ declare function getDriftProgramId(vault: VaultRegistryEntry): string | undefined;
5181
+ declare const vaults: VaultRegistry;
5189
5182
  declare function isValidVaultAddress(address: string): boolean;
5190
- declare function getVaultByAddress(address: string): VaultConfig | undefined;
5191
- declare function getVaultById(vaultId: number): VaultConfig | undefined;
5183
+ declare function getVaultByAddress(address: string): VaultRegistryEntry | undefined;
5184
+ declare function getVaultById(vaultId: number): VaultRegistryEntry | undefined;
5192
5185
  //#endregion
5193
5186
  //#region src/NeutralTrade.d.ts
5194
5187
  interface NeutralTradeConfig {
@@ -5204,7 +5197,7 @@ declare class NeutralTrade {
5204
5197
  readonly bundleProgramV2: Program$1<NtbundleV2>;
5205
5198
  readonly driftVaultClient: VaultClient;
5206
5199
  /** Vault configurations (built-in merged with remote if registryUrl was provided) */
5207
- readonly vaults: VaultConfigRecord;
5200
+ readonly vaults: VaultRegistry;
5208
5201
  /** Price map for deposit tokens */
5209
5202
  readonly priceMap: Map<SupportedToken, number>;
5210
5203
  private constructor();
@@ -5247,4 +5240,4 @@ declare function deriveUserPDA(userKey: PublicKey, bundlePDA: PublicKey, program
5247
5240
  */
5248
5241
  declare function getVaultDepositorAddressSync(programId: PublicKey, vault: PublicKey, authority: PublicKey): PublicKey;
5249
5242
  //#endregion
5250
- export { type BundleAccount, BundleProgramId, NeutralTrade, type NeutralTradeConfig, type OracleData, SupportedChain, SupportedToken, type Token, type UserBalanceResult, type UserBundleAccount, type VaultBalanceData, type VaultConfig, type VaultConfigRecord, VaultId, VaultType, deriveOraclePDA, deriveUserPDA, getBundleProgramId, getDriftProgramId, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
5243
+ export { type BundleAccount, BundleProgramId, NeutralTrade, type NeutralTradeConfig, type OracleData, SupportedChain, SupportedToken, type Token, type UserBalanceResult, type UserBundleAccount, type VaultBalanceData, type VaultRegistryEntry as VaultConfig, type VaultRegistry as VaultConfigRecord, VaultId, VaultType, deriveOraclePDA, deriveUserPDA, getBundleProgramId, getDriftProgramId, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
package/dist/index.mjs CHANGED
@@ -8987,6 +8987,7 @@ const VaultRegistryArraySchema = z.array(VaultRegistryEntrySchema).superRefine((
8987
8987
  * Uses registry value if present, otherwise defaults to V1
8988
8988
  */
8989
8989
  function getBundleProgramId(vault) {
8990
+ if (vault.type !== VaultType.Bundle) return;
8990
8991
  if (vault.bundleProgramId) {
8991
8992
  if (Object.values(BundleProgramId).includes(vault.bundleProgramId)) return vault.bundleProgramId;
8992
8993
  }
@@ -8997,6 +8998,7 @@ function getBundleProgramId(vault) {
8997
8998
  * Uses registry value if present, otherwise defaults to VAULT_PROGRAM_ID
8998
8999
  */
8999
9000
  function getDriftProgramId(vault) {
9001
+ if (vault.type !== VaultType.Drift) return;
9000
9002
  if (vault.driftProgramId) return vault.driftProgramId;
9001
9003
  return VAULT_PROGRAM_ID.toBase58();
9002
9004
  }
@@ -9290,7 +9292,7 @@ async function getDriftBalances({ vaultIds, userAddress, vaults: vaults$1, drift
9290
9292
  const vaultAddresses = vaultEntries.map(({ config }) => new PublicKey(config.vaultAddress));
9291
9293
  const vaultDepositorPDAs = vaultEntries.map(({ config }) => {
9292
9294
  const vaultPubkey = new PublicKey(config.vaultAddress);
9293
- return getVaultDepositorAddressSync(new PublicKey(config.driftProgramId), vaultPubkey, userPublicKey);
9295
+ return getVaultDepositorAddressSync(config.driftProgramId ? new PublicKey(config.driftProgramId) : VAULT_PROGRAM_ID, vaultPubkey, userPublicKey);
9294
9296
  });
9295
9297
  const [vaultsData, vaultDepositors] = await Promise.all([driftVaultClient.program.account.vault.fetchMultiple(vaultAddresses), driftVaultClient.program.account.vaultDepositor.fetchMultiple(vaultDepositorPDAs)]);
9296
9298
  for (let i = 0; i < vaultEntries.length; i++) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neutral-trade/sdk",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "description": "SDK for Neutral Trade vaults",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/neutral-trade/sdk#readme",