@neutral-trade/sdk 0.1.2 → 0.1.4
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 -1
- package/dist/index.d.mts +189 -92
- package/dist/index.mjs +854 -718
- package/package.json +3 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AnchorProvider, IdlAccounts, Program } 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 { z } from "zod";
|
|
5
4
|
import { VaultClient } from "@drift-labs/vaults-sdk";
|
|
5
|
+
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
//#region src/idl/bundle-v1.d.ts
|
|
8
8
|
interface NtbundleV1 {
|
|
@@ -4938,6 +4938,160 @@ declare enum BundleProgramId {
|
|
|
4938
4938
|
V2 = "BUNDeH5A4c47bcEoAjBhN3sCjLgYnRsmt9ibMztqVkC9",
|
|
4939
4939
|
}
|
|
4940
4940
|
//#endregion
|
|
4941
|
+
//#region src/constants/vault-ids.d.ts
|
|
4942
|
+
/**
|
|
4943
|
+
* Vault ID constants for backward compatibility
|
|
4944
|
+
* These are auto-generated from the vault registry
|
|
4945
|
+
*/
|
|
4946
|
+
declare enum VaultId {
|
|
4947
|
+
/** CTA-Adaptive Alpha - Atlas Research */
|
|
4948
|
+
cta_adaptive_alpha_atlas_research_72 = 72,
|
|
4949
|
+
/** Hyperithm Cross-Exchange Arb */
|
|
4950
|
+
hyperithm_cross_exchange_arb_71 = 71,
|
|
4951
|
+
/** Lighter LLP */
|
|
4952
|
+
lighter_llp_70 = 70,
|
|
4953
|
+
/** JLP Delta Neutral - vault-jupiter */
|
|
4954
|
+
jlp_delta_neutral_vault_jupiter_69 = 69,
|
|
4955
|
+
/** SOL Super Staking - Perps */
|
|
4956
|
+
sol_super_staking_perps_68 = 68,
|
|
4957
|
+
/** Aster Funding Arb */
|
|
4958
|
+
aster_funding_arb_67 = 67,
|
|
4959
|
+
/** Moon LP */
|
|
4960
|
+
moon_lp_66 = 66,
|
|
4961
|
+
/** JLP Delta Neutral - Vault-CEX */
|
|
4962
|
+
jlp_delta_neutral_vault_cex_65 = 65,
|
|
4963
|
+
/** JLP Delta Neutral - vip24 */
|
|
4964
|
+
jlp_delta_neutral_vip24_64 = 64,
|
|
4965
|
+
/** JLP Delta Neutral - vip23 */
|
|
4966
|
+
jlp_delta_neutral_vip23_63 = 63,
|
|
4967
|
+
/** JLP Delta Neutral - vip22 */
|
|
4968
|
+
jlp_delta_neutral_vip22_62 = 62,
|
|
4969
|
+
/** USDC Max Yield - Kamino Lending */
|
|
4970
|
+
usdc_max_yield_kamino_lending_61 = 61,
|
|
4971
|
+
/** NT Earn */
|
|
4972
|
+
nt_earn_60 = 60,
|
|
4973
|
+
/** JLP Delta Neutral - Perena */
|
|
4974
|
+
jlp_delta_neutral_perena_59 = 59,
|
|
4975
|
+
/** Memes ETF - Generational Wealth */
|
|
4976
|
+
memes_etf_generational_wealth_58 = 58,
|
|
4977
|
+
/** JLP Delta Neutral - vip21 */
|
|
4978
|
+
jlp_delta_neutral_vip21_57 = 57,
|
|
4979
|
+
/** BTC Dominance */
|
|
4980
|
+
btc_dominance_56 = 56,
|
|
4981
|
+
/** Alt Dominance */
|
|
4982
|
+
alt_dominance_55 = 55,
|
|
4983
|
+
/** HYPE / SOL Pairs Trade */
|
|
4984
|
+
hype_sol_pairs_trade_54 = 54,
|
|
4985
|
+
/** The Big Short */
|
|
4986
|
+
the_big_short_53 = 53,
|
|
4987
|
+
/** CTA Momentum - R* Research */
|
|
4988
|
+
cta_momentum_r_research_52 = 52,
|
|
4989
|
+
/** Term Max */
|
|
4990
|
+
term_max_51 = 51,
|
|
4991
|
+
/** ALP Delta Neutral Forest */
|
|
4992
|
+
alp_delta_neutral_forest_50 = 50,
|
|
4993
|
+
/** ALP Delta Neutral */
|
|
4994
|
+
alp_delta_neutral_49 = 49,
|
|
4995
|
+
/** Hyperliquid Funding Arb */
|
|
4996
|
+
hyperliquid_funding_arb_48 = 48,
|
|
4997
|
+
/** Long BONK, Short PUMP */
|
|
4998
|
+
long_bonk_short_pump_47 = 47,
|
|
4999
|
+
/** Hyper JLP */
|
|
5000
|
+
hyper_jlp_46 = 46,
|
|
5001
|
+
/** FART Dominance - Hot Air Rises */
|
|
5002
|
+
fart_dominance_hot_air_rises_45 = 45,
|
|
5003
|
+
/** BTC Dominance */
|
|
5004
|
+
btc_dominance_44 = 44,
|
|
5005
|
+
/** JLP Delta Neutral - vip team */
|
|
5006
|
+
jlp_delta_neutral_vip_team_43 = 43,
|
|
5007
|
+
/** BTC Savings - Drawdown Protected */
|
|
5008
|
+
btc_savings_drawdown_protected_42 = 42,
|
|
5009
|
+
/** ETH Savings - Drawdown Protected */
|
|
5010
|
+
eth_savings_drawdown_protected_41 = 41,
|
|
5011
|
+
/** SOL Savings - Drawdown Protected */
|
|
5012
|
+
sol_savings_drawdown_protected_40 = 40,
|
|
5013
|
+
/** USDC Savings - Drawdown Protected */
|
|
5014
|
+
usdc_savings_drawdown_protected_39 = 39,
|
|
5015
|
+
/** FUEL Maxi */
|
|
5016
|
+
fuel_maxi_38 = 38,
|
|
5017
|
+
/** Inverse JLP DN - The Big Short */
|
|
5018
|
+
inverse_jlp_dn_the_big_short_37 = 37,
|
|
5019
|
+
/** JLP Delta Neutral - Neutralized JLP */
|
|
5020
|
+
jlp_delta_neutral_neutralized_jlp_36 = 36,
|
|
5021
|
+
/** JLP Delta Neutral - vip20 */
|
|
5022
|
+
jlp_delta_neutral_vip20_35 = 35,
|
|
5023
|
+
/** JLP Delta Neutral - vip19 */
|
|
5024
|
+
jlp_delta_neutral_vip19_34 = 34,
|
|
5025
|
+
/** JLP Delta Neutral - Project Super */
|
|
5026
|
+
jlp_delta_neutral_project_super_33 = 33,
|
|
5027
|
+
/** JLP Delta Neutral - vip pool 1 */
|
|
5028
|
+
jlp_delta_neutral_vip_pool_1_32 = 32,
|
|
5029
|
+
/** JLP Delta Neutral - Drift-5 */
|
|
5030
|
+
jlp_delta_neutral_drift_5_31 = 31,
|
|
5031
|
+
/** Long SOL, Short ETH - Solana Flippening */
|
|
5032
|
+
long_sol_short_eth_solana_flippening_30 = 30,
|
|
5033
|
+
/** JLP Delta Neutral - Drift-4 */
|
|
5034
|
+
jlp_delta_neutral_drift_4_29 = 29,
|
|
5035
|
+
/** JLP Delta Neutral - vip18 */
|
|
5036
|
+
jlp_delta_neutral_vip18_28 = 28,
|
|
5037
|
+
/** JLP Delta Neutral - vip17 */
|
|
5038
|
+
jlp_delta_neutral_vip17_27 = 27,
|
|
5039
|
+
/** BTC Super Staking - tangem */
|
|
5040
|
+
btc_super_staking_tangem_26 = 26,
|
|
5041
|
+
/** JLP Delta Neutral - tangem */
|
|
5042
|
+
jlp_delta_neutral_tangem_25 = 25,
|
|
5043
|
+
/** JLP Delta Neutral - vip16 */
|
|
5044
|
+
jlp_delta_neutral_vip16_24 = 24,
|
|
5045
|
+
/** JLP Delta Neutral - vip15 */
|
|
5046
|
+
jlp_delta_neutral_vip15_23 = 23,
|
|
5047
|
+
/** JLP Delta Neutral - vip14 */
|
|
5048
|
+
jlp_delta_neutral_vip14_22 = 22,
|
|
5049
|
+
/** SOL Momentum - CTA-Marco */
|
|
5050
|
+
sol_momentum_cta_marco_21 = 21,
|
|
5051
|
+
/** JLP Delta Neutral - vip13 */
|
|
5052
|
+
jlp_delta_neutral_vip13_20 = 20,
|
|
5053
|
+
/** JLP Delta Neutral - vip12 */
|
|
5054
|
+
jlp_delta_neutral_vip12_19 = 19,
|
|
5055
|
+
/** JLP Delta Neutral - vip11 */
|
|
5056
|
+
jlp_delta_neutral_vip11_18 = 18,
|
|
5057
|
+
/** USDC Staking - vip10 */
|
|
5058
|
+
usdc_staking_vip10_17 = 17,
|
|
5059
|
+
/** JLP Delta Neutral - Drift-3 */
|
|
5060
|
+
jlp_delta_neutral_drift_3_16 = 16,
|
|
5061
|
+
/** SOL Super Staking - vip8 */
|
|
5062
|
+
sol_super_staking_vip8_15 = 15,
|
|
5063
|
+
/** JLP Delta Neutral - vip7 */
|
|
5064
|
+
jlp_delta_neutral_vip7_14 = 14,
|
|
5065
|
+
/** JLP Delta Neutral - vip6 */
|
|
5066
|
+
jlp_delta_neutral_vip6_13 = 13,
|
|
5067
|
+
/** JLP Delta Neutral - vip5 */
|
|
5068
|
+
jlp_delta_neutral_vip5_12 = 12,
|
|
5069
|
+
/** USDC Basis - Perps Basket */
|
|
5070
|
+
usdc_basis_perps_basket_11 = 11,
|
|
5071
|
+
/** JLP Delta Neutral - vip3 */
|
|
5072
|
+
jlp_delta_neutral_vip3_10 = 10,
|
|
5073
|
+
/** JLP Delta Neutral - vip2 */
|
|
5074
|
+
jlp_delta_neutral_vip2_9 = 9,
|
|
5075
|
+
/** Drift funding arb */
|
|
5076
|
+
drift_funding_arb_8 = 8,
|
|
5077
|
+
/** JLP Traders Print */
|
|
5078
|
+
jlp_traders_print_7 = 7,
|
|
5079
|
+
/** ETH Super Staking */
|
|
5080
|
+
eth_super_staking_6 = 6,
|
|
5081
|
+
/** JLP Delta Neutral - vip1 */
|
|
5082
|
+
jlp_delta_neutral_vip1_5 = 5,
|
|
5083
|
+
/** JLP Delta Neutral - Drift-2 */
|
|
5084
|
+
jlp_delta_neutral_drift_2_4 = 4,
|
|
5085
|
+
/** BTC Super Staking */
|
|
5086
|
+
btc_super_staking_3 = 3,
|
|
5087
|
+
/** JLP Traders Rekt */
|
|
5088
|
+
jlp_traders_rekt_2 = 2,
|
|
5089
|
+
/** SOL Super Staking */
|
|
5090
|
+
sol_super_staking_1 = 1,
|
|
5091
|
+
/** JLP Delta Neutral - vault-1 */
|
|
5092
|
+
jlp_delta_neutral_vault_1_0 = 0,
|
|
5093
|
+
}
|
|
5094
|
+
//#endregion
|
|
4941
5095
|
//#region src/types/tokens.d.ts
|
|
4942
5096
|
declare enum SupportedChain {
|
|
4943
5097
|
Solana = "Solana",
|
|
@@ -4961,105 +5115,37 @@ interface Token {
|
|
|
4961
5115
|
}
|
|
4962
5116
|
declare const tokens: { [name in SupportedToken]: Token };
|
|
4963
5117
|
//#endregion
|
|
5118
|
+
//#region src/types/bundle-types.d.ts
|
|
5119
|
+
type UserBundleAccount = IdlAccounts<NtbundleV1>['userBundleAccount'] | IdlAccounts$1<NtbundleV2>['userBundleAccount'];
|
|
5120
|
+
type OracleData = IdlAccounts<NtbundleV1>['oracleData'] | IdlAccounts$1<NtbundleV2>['oracleData'];
|
|
5121
|
+
type BundleAccount = IdlAccounts<NtbundleV1>['bundle'] | IdlAccounts$1<NtbundleV2>['bundle'];
|
|
5122
|
+
//#endregion
|
|
4964
5123
|
//#region src/types/vault-types.d.ts
|
|
4965
|
-
declare enum VaultId {
|
|
4966
|
-
jlpdnv1 = 0,
|
|
4967
|
-
solnl = 1,
|
|
4968
|
-
rekt = 2,
|
|
4969
|
-
btcnl = 3,
|
|
4970
|
-
jlpdnv2 = 4,
|
|
4971
|
-
vip1 = 5,
|
|
4972
|
-
ethnl = 6,
|
|
4973
|
-
print = 7,
|
|
4974
|
-
solbasisinf = 8,
|
|
4975
|
-
vip2 = 9,
|
|
4976
|
-
vip3 = 10,
|
|
4977
|
-
perpsbasket = 11,
|
|
4978
|
-
vip5 = 12,
|
|
4979
|
-
vip6 = 13,
|
|
4980
|
-
vip7 = 14,
|
|
4981
|
-
vip8 = 15,
|
|
4982
|
-
jlpdnv3 = 16,
|
|
4983
|
-
vip10 = 17,
|
|
4984
|
-
vip11 = 18,
|
|
4985
|
-
vip12 = 19,
|
|
4986
|
-
vip13 = 20,
|
|
4987
|
-
solctamarco = 21,
|
|
4988
|
-
vip14 = 22,
|
|
4989
|
-
vip15 = 23,
|
|
4990
|
-
vip16 = 24,
|
|
4991
|
-
usdctangem = 25,
|
|
4992
|
-
btctangem = 26,
|
|
4993
|
-
vip17 = 27,
|
|
4994
|
-
vip18 = 28,
|
|
4995
|
-
jlpdnv4 = 29,
|
|
4996
|
-
solethflip = 30,
|
|
4997
|
-
jlpdnv5 = 31,
|
|
4998
|
-
vip1ag = 32,
|
|
4999
|
-
usdcsuper = 33,
|
|
5000
|
-
vip19 = 34,
|
|
5001
|
-
vip20 = 35,
|
|
5002
|
-
neutralizedjlp = 36,
|
|
5003
|
-
thebigshort = 37,
|
|
5004
|
-
fuelmaxi = 38,
|
|
5005
|
-
usdcsavings = 39,
|
|
5006
|
-
solsavings = 40,
|
|
5007
|
-
ethsavings = 41,
|
|
5008
|
-
btcsavings = 42,
|
|
5009
|
-
jlpdnteam = 43,
|
|
5010
|
-
btcdom = 44,
|
|
5011
|
-
fartdom = 45,
|
|
5012
|
-
hyperjlp = 46,
|
|
5013
|
-
bonkpump = 47,
|
|
5014
|
-
nmmjlpdn = 57,
|
|
5015
|
-
memesetf = 58,
|
|
5016
|
-
annafromperena = 59,
|
|
5017
|
-
vip22 = 62,
|
|
5018
|
-
vip23 = 63,
|
|
5019
|
-
vip24 = 64,
|
|
5020
|
-
solnlperps = 68,
|
|
5021
|
-
hlbigshort = 53,
|
|
5022
|
-
hlhypesol = 54,
|
|
5023
|
-
hlaltdom = 55,
|
|
5024
|
-
hlbtcdom = 56,
|
|
5025
|
-
kaminolend = 61,
|
|
5026
|
-
hlfundingarb = 48,
|
|
5027
|
-
alpdn = 49,
|
|
5028
|
-
// vip
|
|
5029
|
-
alpdnforest = 50,
|
|
5030
|
-
// vip
|
|
5031
|
-
termmax = 51,
|
|
5032
|
-
ctamomentumrresearch = 52,
|
|
5033
|
-
ntearnusdc = 60,
|
|
5034
|
-
jlpdnbundle = 65,
|
|
5035
|
-
moonlp = 66,
|
|
5036
|
-
asterfundingarb = 67,
|
|
5037
|
-
jlpdnjupiter = 69,
|
|
5038
|
-
lighterllp1 = 70,
|
|
5039
|
-
hyperithm1 = 71,
|
|
5040
|
-
}
|
|
5041
5124
|
declare enum VaultType {
|
|
5042
5125
|
Drift = "Drift",
|
|
5043
5126
|
Bundle = "Bundle",
|
|
5044
5127
|
Hyperliquid = "Hyperliquid",
|
|
5045
5128
|
Kamino = "Kamino",
|
|
5046
5129
|
}
|
|
5047
|
-
|
|
5048
|
-
|
|
5130
|
+
/** Raw vault entry from registry JSON (without program IDs) */
|
|
5131
|
+
interface VaultRegistryEntry {
|
|
5132
|
+
vaultId: number;
|
|
5049
5133
|
name: string;
|
|
5050
5134
|
subname?: string;
|
|
5051
5135
|
type: VaultType;
|
|
5052
5136
|
vaultAddress: string;
|
|
5053
5137
|
depositToken: SupportedToken;
|
|
5054
|
-
|
|
5138
|
+
pfee?: number;
|
|
5139
|
+
}
|
|
5140
|
+
/** Vault config with required program IDs (transformed from registry entry) */
|
|
5141
|
+
interface VaultConfig extends VaultRegistryEntry {
|
|
5142
|
+
/** Required for Drift vaults */
|
|
5055
5143
|
driftProgramId?: string;
|
|
5056
|
-
|
|
5144
|
+
/** Required for Bundle vaults */
|
|
5145
|
+
bundleProgramId?: string;
|
|
5057
5146
|
}
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
type UserBundleAccount = IdlAccounts<NtbundleV1>['userBundleAccount'] | IdlAccounts$1<NtbundleV2>['userBundleAccount'];
|
|
5061
|
-
type OracleData = IdlAccounts<NtbundleV1>['oracleData'] | IdlAccounts$1<NtbundleV2>['oracleData'];
|
|
5062
|
-
type BundleAccount = IdlAccounts<NtbundleV1>['bundle'] | IdlAccounts$1<NtbundleV2>['bundle'];
|
|
5147
|
+
/** Vault registry as a record keyed by vaultId */
|
|
5148
|
+
type VaultConfigRecord = Record<number, VaultConfig>;
|
|
5063
5149
|
//#endregion
|
|
5064
5150
|
//#region src/types/index.d.ts
|
|
5065
5151
|
interface VaultBalanceData {
|
|
@@ -5082,13 +5168,23 @@ interface VaultBalanceData {
|
|
|
5082
5168
|
netDeposit?: number;
|
|
5083
5169
|
asset: SupportedToken;
|
|
5084
5170
|
}
|
|
5085
|
-
type UserBalanceResult = Record<
|
|
5171
|
+
type UserBalanceResult = Record<number, VaultBalanceData | null>;
|
|
5086
5172
|
//#endregion
|
|
5087
5173
|
//#region src/constants/vaults.d.ts
|
|
5088
|
-
|
|
5174
|
+
/**
|
|
5175
|
+
* Get Bundle Program ID for a vault
|
|
5176
|
+
* All bundle vaults use V1 except vaultId 69 and 72 which use V2
|
|
5177
|
+
*/
|
|
5178
|
+
declare function getBundleProgramId(vaultId: number): BundleProgramId;
|
|
5179
|
+
/**
|
|
5180
|
+
* Get Drift Program ID for a vault
|
|
5181
|
+
* All drift vaults use default program ID except vaultId 0
|
|
5182
|
+
*/
|
|
5183
|
+
declare function getDriftProgramPK(vaultId: number): PublicKey;
|
|
5184
|
+
declare const vaults: VaultConfigRecord;
|
|
5089
5185
|
declare function isValidVaultAddress(address: string): boolean;
|
|
5090
5186
|
declare function getVaultByAddress(address: string): VaultConfig | undefined;
|
|
5091
|
-
declare function getVaultById(vaultId:
|
|
5187
|
+
declare function getVaultById(vaultId: number): VaultConfig | undefined;
|
|
5092
5188
|
//#endregion
|
|
5093
5189
|
//#region src/NeutralTrade.d.ts
|
|
5094
5190
|
interface NeutralTradeConfig {
|
|
@@ -5104,7 +5200,7 @@ declare class NeutralTrade {
|
|
|
5104
5200
|
readonly bundleProgramV2: Program$1<NtbundleV2>;
|
|
5105
5201
|
readonly driftVaultClient: VaultClient;
|
|
5106
5202
|
/** Vault configurations (built-in merged with remote if registryUrl was provided) */
|
|
5107
|
-
readonly vaults:
|
|
5203
|
+
readonly vaults: VaultConfigRecord;
|
|
5108
5204
|
/** Price map for deposit tokens */
|
|
5109
5205
|
readonly priceMap: Map<SupportedToken, number>;
|
|
5110
5206
|
private constructor();
|
|
@@ -5116,6 +5212,7 @@ declare class NeutralTrade {
|
|
|
5116
5212
|
static create(config: NeutralTradeConfig): Promise<NeutralTrade>;
|
|
5117
5213
|
/**
|
|
5118
5214
|
* Fetch vault configurations from a remote registry URL
|
|
5215
|
+
* Expects JSON array format and transforms to Record<number, VaultConfig>
|
|
5119
5216
|
* @throws Error if fetch fails or validation fails
|
|
5120
5217
|
*/
|
|
5121
5218
|
private static fetchVaultsFromRegistry;
|
|
@@ -5126,7 +5223,7 @@ declare class NeutralTrade {
|
|
|
5126
5223
|
vaultIds,
|
|
5127
5224
|
userAddress
|
|
5128
5225
|
}: {
|
|
5129
|
-
vaultIds:
|
|
5226
|
+
vaultIds: number[];
|
|
5130
5227
|
userAddress: string;
|
|
5131
5228
|
}): Promise<UserBalanceResult>;
|
|
5132
5229
|
}
|
|
@@ -5146,4 +5243,4 @@ declare function deriveUserPDA(userKey: PublicKey, bundlePDA: PublicKey, program
|
|
|
5146
5243
|
*/
|
|
5147
5244
|
declare function getVaultDepositorAddressSync(programId: PublicKey, vault: PublicKey, authority: PublicKey): PublicKey;
|
|
5148
5245
|
//#endregion
|
|
5149
|
-
export { type BundleAccount, BundleProgramId, NeutralTrade, type NeutralTradeConfig, type OracleData, SupportedChain, SupportedToken, type Token, type UserBalanceResult, type UserBundleAccount, type VaultBalanceData, type VaultConfig, VaultId, VaultType, deriveOraclePDA, deriveUserPDA, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
|
|
5246
|
+
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, getDriftProgramPK, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
|