@neutral-trade/sdk 0.2.8 → 0.2.11
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 +32 -9
- package/dist/index.mjs +82 -14
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3030,10 +3030,12 @@ declare function createBundleProgramById(provider: AnchorProvider, programId: st
|
|
|
3030
3030
|
//#endregion
|
|
3031
3031
|
//#region src/constants/vault-ids.d.ts
|
|
3032
3032
|
/**
|
|
3033
|
-
* Vault ID constants
|
|
3034
|
-
*
|
|
3033
|
+
* Vault ID constants (VaultId)
|
|
3034
|
+
* Auto-generated from the vault registry JSON.
|
|
3035
3035
|
*/
|
|
3036
3036
|
declare enum VaultId {
|
|
3037
|
+
/** Velox-Cross-USDC-Bundle */
|
|
3038
|
+
velox_cross_usdc_bundle_78 = 78,
|
|
3037
3039
|
/** Hyperithm-CTA-USDC-Bundle */
|
|
3038
3040
|
hyperithm_cta_usdc_bundle_77 = 77,
|
|
3039
3041
|
/** Master Bundle */
|
|
@@ -3192,6 +3194,16 @@ declare enum VaultId {
|
|
|
3192
3194
|
jlp_delta_neutral_vault_1_0 = 0,
|
|
3193
3195
|
}
|
|
3194
3196
|
//#endregion
|
|
3197
|
+
//#region src/constants/vault-ids.devnet.d.ts
|
|
3198
|
+
/**
|
|
3199
|
+
* Vault ID constants (DevnetVaultId)
|
|
3200
|
+
* Auto-generated from the vault registry JSON.
|
|
3201
|
+
*/
|
|
3202
|
+
declare enum DevnetVaultId {
|
|
3203
|
+
/** Dev1 */
|
|
3204
|
+
dev1_100000001 = 100000001,
|
|
3205
|
+
}
|
|
3206
|
+
//#endregion
|
|
3195
3207
|
//#region src/types/tokens.d.ts
|
|
3196
3208
|
declare enum SupportedChain {
|
|
3197
3209
|
Solana = "Solana",
|
|
@@ -3214,6 +3226,13 @@ interface Token {
|
|
|
3214
3226
|
} | null };
|
|
3215
3227
|
}
|
|
3216
3228
|
declare const tokens: { [name in SupportedToken]: Token };
|
|
3229
|
+
/**
|
|
3230
|
+
* Solana mint address for a supported token, keyed by bundle cluster.
|
|
3231
|
+
* Devnet USDC uses the team mock mint; other tokens use mainnet table until devnet overrides exist.
|
|
3232
|
+
*/
|
|
3233
|
+
declare function getSolanaTokenMint(token: SupportedToken, cluster?: BundleCluster): string;
|
|
3234
|
+
/** SPL decimals for `token` (same on mainnet vs devnet for current overrides). */
|
|
3235
|
+
declare function getSolanaTokenDecimals(token: SupportedToken): number;
|
|
3217
3236
|
//#endregion
|
|
3218
3237
|
//#region src/types/bundle-types.d.ts
|
|
3219
3238
|
type UserBundleAccount = IdlAccounts<Ntbundle>['userBundleAccount'];
|
|
@@ -3293,17 +3312,21 @@ type UserBalanceResult = Record<number, VaultBalanceData | null>;
|
|
|
3293
3312
|
* Uses registry value if present, otherwise falls back to cluster default.
|
|
3294
3313
|
*/
|
|
3295
3314
|
declare function getBundleProgramId(vault: VaultRegistryEntry, cluster?: BundleCluster): string | undefined;
|
|
3315
|
+
/** Mainnet registry (default; backward compatible). */
|
|
3296
3316
|
declare const vaults: VaultRegistry;
|
|
3297
|
-
|
|
3298
|
-
declare
|
|
3299
|
-
declare function
|
|
3317
|
+
/** Devnet-only vault registry (fixtures / local testing). */
|
|
3318
|
+
declare const vaultsDevnet: VaultRegistry;
|
|
3319
|
+
declare function getVaultRegistry(cluster: BundleCluster): VaultRegistry;
|
|
3320
|
+
declare function isValidVaultAddress(address: string, cluster?: BundleCluster): boolean;
|
|
3321
|
+
declare function getVaultByAddress(address: string, cluster?: BundleCluster): VaultRegistryEntry | undefined;
|
|
3322
|
+
declare function getVaultById(vaultId: number, cluster?: BundleCluster): VaultRegistryEntry | undefined;
|
|
3300
3323
|
//#endregion
|
|
3301
3324
|
//#region src/NeutralTrade.d.ts
|
|
3302
3325
|
interface NeutralTradeConfig {
|
|
3303
3326
|
rpcUrl: string;
|
|
3304
3327
|
/** Bundle program cluster selector. Defaults to 'mainnet'. */
|
|
3305
3328
|
bundleCluster?: BundleCluster;
|
|
3306
|
-
/** If true, include built-in vault registry
|
|
3329
|
+
/** If true, include built-in vault registry for `bundleCluster` (mainnet vs devnet fixtures). Defaults to true. */
|
|
3307
3330
|
includeBuiltInVaults?: boolean;
|
|
3308
3331
|
/** Optional local registry entries. Applied after built-in configs and before registryUrl (if provided). */
|
|
3309
3332
|
registry?: VaultRegistryEntry[];
|
|
@@ -3322,14 +3345,14 @@ declare class NeutralTrade {
|
|
|
3322
3345
|
readonly connection: Connection;
|
|
3323
3346
|
readonly bundlePrograms: Record<string, Program<Ntbundle>>;
|
|
3324
3347
|
readonly bundleCluster: BundleCluster;
|
|
3325
|
-
/** Vault configurations after merge order: built-in < local registry < registryUrl */
|
|
3348
|
+
/** Vault configurations after merge order: built-in (cluster-specific) < local registry < registryUrl */
|
|
3326
3349
|
readonly vaults: VaultRegistry;
|
|
3327
3350
|
/** Price map for deposit tokens */
|
|
3328
3351
|
readonly priceMap: Map<SupportedToken, number>;
|
|
3329
3352
|
protected constructor(connection: Connection, bundlePrograms: Record<string, Program<Ntbundle>>, bundleCluster: BundleCluster, vaults: VaultRegistry, priceMap: Map<SupportedToken, number>);
|
|
3330
3353
|
/**
|
|
3331
3354
|
* Create a new NeutralTrade instance
|
|
3332
|
-
* Merge order: built-in (when allowed) < local registry < registryUrl
|
|
3355
|
+
* Merge order: built-in catalog for `bundleCluster` (when allowed) < local registry < registryUrl
|
|
3333
3356
|
* @throws Error if registry or registryUrl validation fails (or fetch fails for registryUrl)
|
|
3334
3357
|
*/
|
|
3335
3358
|
protected static initCore(config: NeutralTradeConfig): Promise<NeutralTradeCoreContext>;
|
|
@@ -3447,4 +3470,4 @@ declare function derivePendingAuthPDA(bundlePDA: PublicKey, programId: PublicKey
|
|
|
3447
3470
|
*/
|
|
3448
3471
|
declare function getVaultDepositorAddressSync(programId: PublicKey, vault: PublicKey, authority: PublicKey): PublicKey;
|
|
3449
3472
|
//#endregion
|
|
3450
|
-
export { BUNDLE_PROGRAM_ID_V2_MAINNET, type BundleAccount, type BundleCluster, type BundleProgram, type BundleProvider, DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, NeutralTrade, type NeutralTradeConfig, type NeutralTradeCoreContext, type OracleData, SEED_ORACLE, SEED_PENDING_AUTH, SEED_TEMP, SEED_USER, SupportedChain, SupportedToken, type Token, type UserBalanceResult, type UserBundleAccount, type UserBundleTempData, type VaultBalanceData, VaultCategory, type VaultRegistryEntry as VaultConfig, type VaultRegistry as VaultConfigRecord, VaultId, VaultType, buildBundleDepositInstructions, buildBundleRequestWithdrawInstruction, createBundleProgramById, createDummyWallet, deriveOraclePDA, derivePendingAuthPDA, deriveTempDataPDA, deriveUserPDA, getBundleProgramId, getDefaultBundleProgramIdByCluster, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
|
|
3473
|
+
export { BUNDLE_PROGRAM_ID_V2_MAINNET, type BundleAccount, type BundleCluster, type BundleProgram, type BundleProvider, DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, DevnetVaultId, NeutralTrade, type NeutralTradeConfig, type NeutralTradeCoreContext, type OracleData, SEED_ORACLE, SEED_PENDING_AUTH, SEED_TEMP, SEED_USER, SupportedChain, SupportedToken, type Token, type UserBalanceResult, type UserBundleAccount, type UserBundleTempData, type VaultBalanceData, VaultCategory, type VaultRegistryEntry as VaultConfig, type VaultRegistry as VaultConfigRecord, VaultId, VaultType, buildBundleDepositInstructions, buildBundleRequestWithdrawInstruction, createBundleProgramById, createDummyWallet, deriveOraclePDA, derivePendingAuthPDA, deriveTempDataPDA, deriveUserPDA, getBundleProgramId, getDefaultBundleProgramIdByCluster, getSolanaTokenDecimals, getSolanaTokenMint, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, getVaultRegistry, isValidVaultAddress, tokens, vaults, vaultsDevnet };
|
package/dist/index.mjs
CHANGED
|
@@ -11613,10 +11613,12 @@ function createBundleProgramById(provider, programId) {
|
|
|
11613
11613
|
//#endregion
|
|
11614
11614
|
//#region src/constants/vault-ids.ts
|
|
11615
11615
|
/**
|
|
11616
|
-
* Vault ID constants
|
|
11617
|
-
*
|
|
11616
|
+
* Vault ID constants (VaultId)
|
|
11617
|
+
* Auto-generated from the vault registry JSON.
|
|
11618
11618
|
*/
|
|
11619
11619
|
let VaultId = /* @__PURE__ */ function(VaultId$1) {
|
|
11620
|
+
/** Velox-Cross-USDC-Bundle */
|
|
11621
|
+
VaultId$1[VaultId$1["velox_cross_usdc_bundle_78"] = 78] = "velox_cross_usdc_bundle_78";
|
|
11620
11622
|
/** Hyperithm-CTA-USDC-Bundle */
|
|
11621
11623
|
VaultId$1[VaultId$1["hyperithm_cta_usdc_bundle_77"] = 77] = "hyperithm_cta_usdc_bundle_77";
|
|
11622
11624
|
/** Master Bundle */
|
|
@@ -11776,9 +11778,45 @@ let VaultId = /* @__PURE__ */ function(VaultId$1) {
|
|
|
11776
11778
|
return VaultId$1;
|
|
11777
11779
|
}({});
|
|
11778
11780
|
|
|
11781
|
+
//#endregion
|
|
11782
|
+
//#region src/constants/vault-ids.devnet.ts
|
|
11783
|
+
/**
|
|
11784
|
+
* Vault ID constants (DevnetVaultId)
|
|
11785
|
+
* Auto-generated from the vault registry JSON.
|
|
11786
|
+
*/
|
|
11787
|
+
let DevnetVaultId = /* @__PURE__ */ function(DevnetVaultId$1) {
|
|
11788
|
+
/** Dev1 */
|
|
11789
|
+
DevnetVaultId$1[DevnetVaultId$1["dev1_100000001"] = 100000001] = "dev1_100000001";
|
|
11790
|
+
return DevnetVaultId$1;
|
|
11791
|
+
}({});
|
|
11792
|
+
|
|
11793
|
+
//#endregion
|
|
11794
|
+
//#region src/registry/vaults.devnet.json
|
|
11795
|
+
var vaults_devnet_default = [{
|
|
11796
|
+
"vaultId": 100000001,
|
|
11797
|
+
"name": "Dev1",
|
|
11798
|
+
"type": "Bundle",
|
|
11799
|
+
"category": "Market Neutral",
|
|
11800
|
+
"vaultAddress": "EUs1XqK5Fr7DXxS5NTy2yYd3jehfYFJ4WYefesDf6iy3",
|
|
11801
|
+
"depositToken": "USDC",
|
|
11802
|
+
"bundleProgramId": "7trSyt7d1ZRnvfGh9JaQZwZMWtfAXMvMwN3UxgMzVFbv",
|
|
11803
|
+
"pointsMultiplier": 1,
|
|
11804
|
+
"pointsEnabled": false
|
|
11805
|
+
}];
|
|
11806
|
+
|
|
11779
11807
|
//#endregion
|
|
11780
11808
|
//#region src/registry/vaults.json
|
|
11781
11809
|
var vaults_default = [
|
|
11810
|
+
{
|
|
11811
|
+
"vaultId": 78,
|
|
11812
|
+
"name": "Velox-Cross-USDC-Bundle",
|
|
11813
|
+
"type": "Bundle",
|
|
11814
|
+
"category": "Market Neutral",
|
|
11815
|
+
"vaultAddress": "De47QBuMP7xukYBek5r4ScZF4HEk1kHW34ymKASz3DLt",
|
|
11816
|
+
"depositToken": "USDC",
|
|
11817
|
+
"pointsMultiplier": 1,
|
|
11818
|
+
"pointsEnabled": true
|
|
11819
|
+
},
|
|
11782
11820
|
{
|
|
11783
11821
|
"vaultId": 77,
|
|
11784
11822
|
"name": "Hyperithm-CTA-USDC-Bundle",
|
|
@@ -12716,6 +12754,27 @@ const tokens = {
|
|
|
12716
12754
|
}
|
|
12717
12755
|
}
|
|
12718
12756
|
};
|
|
12757
|
+
/** Devnet SPL mint overrides (`depositToken` still uses `SupportedToken`). */
|
|
12758
|
+
const SOLANA_MINT_OVERRIDES_DEVNET = { [SupportedToken.USDC]: "6a8hWCCa2QDQTqzLUapZwZtgHTox8BsgataN6JVLwdo7" };
|
|
12759
|
+
/**
|
|
12760
|
+
* Solana mint address for a supported token, keyed by bundle cluster.
|
|
12761
|
+
* Devnet USDC uses the team mock mint; other tokens use mainnet table until devnet overrides exist.
|
|
12762
|
+
*/
|
|
12763
|
+
function getSolanaTokenMint(token, cluster = "mainnet") {
|
|
12764
|
+
const row = tokens[token].onChain[SupportedChain.Solana];
|
|
12765
|
+
if (!row) throw new Error(`No Solana mint configured for ${token}`);
|
|
12766
|
+
if (cluster === "devnet") {
|
|
12767
|
+
const override = SOLANA_MINT_OVERRIDES_DEVNET[token];
|
|
12768
|
+
if (override) return override;
|
|
12769
|
+
}
|
|
12770
|
+
return row.address;
|
|
12771
|
+
}
|
|
12772
|
+
/** SPL decimals for `token` (same on mainnet vs devnet for current overrides). */
|
|
12773
|
+
function getSolanaTokenDecimals(token) {
|
|
12774
|
+
const row = tokens[token].onChain[SupportedChain.Solana];
|
|
12775
|
+
if (!row) throw new Error(`No Solana decimals configured for ${token}`);
|
|
12776
|
+
return row.decimals;
|
|
12777
|
+
}
|
|
12719
12778
|
|
|
12720
12779
|
//#endregion
|
|
12721
12780
|
//#region src/types/vault-types.ts
|
|
@@ -12803,16 +12862,25 @@ function toVaultConfig(entry) {
|
|
|
12803
12862
|
function toVaultRegistry(entries) {
|
|
12804
12863
|
return Object.fromEntries(entries.map((entry) => [entry.vaultId, toVaultConfig(entry)]));
|
|
12805
12864
|
}
|
|
12806
|
-
const
|
|
12807
|
-
const
|
|
12808
|
-
|
|
12809
|
-
|
|
12865
|
+
const parsedVaultsMainnet = VaultRegistryArraySchema.parse(vaults_default);
|
|
12866
|
+
const parsedVaultsDevnet = VaultRegistryArraySchema.parse(vaults_devnet_default);
|
|
12867
|
+
const vaultsMainnetRegistry = toVaultRegistry(parsedVaultsMainnet);
|
|
12868
|
+
const vaultsDevnetRegistry = toVaultRegistry(parsedVaultsDevnet);
|
|
12869
|
+
/** Mainnet registry (default; backward compatible). */
|
|
12870
|
+
const vaults = vaultsMainnetRegistry;
|
|
12871
|
+
/** Devnet-only vault registry (fixtures / local testing). */
|
|
12872
|
+
const vaultsDevnet = vaultsDevnetRegistry;
|
|
12873
|
+
function getVaultRegistry(cluster) {
|
|
12874
|
+
return cluster === "devnet" ? vaultsDevnetRegistry : vaultsMainnetRegistry;
|
|
12875
|
+
}
|
|
12876
|
+
function isValidVaultAddress(address$2, cluster = "mainnet") {
|
|
12877
|
+
return Object.values(getVaultRegistry(cluster)).map((vault) => vault.vaultAddress).includes(address$2);
|
|
12810
12878
|
}
|
|
12811
|
-
function getVaultByAddress(address$2) {
|
|
12812
|
-
return Object.values(
|
|
12879
|
+
function getVaultByAddress(address$2, cluster = "mainnet") {
|
|
12880
|
+
return Object.values(getVaultRegistry(cluster)).find((v) => v.vaultAddress === address$2);
|
|
12813
12881
|
}
|
|
12814
|
-
function getVaultById(vaultId) {
|
|
12815
|
-
return
|
|
12882
|
+
function getVaultById(vaultId, cluster = "mainnet") {
|
|
12883
|
+
return getVaultRegistry(cluster)[vaultId];
|
|
12816
12884
|
}
|
|
12817
12885
|
|
|
12818
12886
|
//#endregion
|
|
@@ -13192,7 +13260,7 @@ var NeutralTrade = class NeutralTrade {
|
|
|
13192
13260
|
connection;
|
|
13193
13261
|
bundlePrograms;
|
|
13194
13262
|
bundleCluster;
|
|
13195
|
-
/** Vault configurations after merge order: built-in < local registry < registryUrl */
|
|
13263
|
+
/** Vault configurations after merge order: built-in (cluster-specific) < local registry < registryUrl */
|
|
13196
13264
|
vaults;
|
|
13197
13265
|
/** Price map for deposit tokens */
|
|
13198
13266
|
priceMap;
|
|
@@ -13205,14 +13273,14 @@ var NeutralTrade = class NeutralTrade {
|
|
|
13205
13273
|
}
|
|
13206
13274
|
/**
|
|
13207
13275
|
* Create a new NeutralTrade instance
|
|
13208
|
-
* Merge order: built-in (when allowed) < local registry < registryUrl
|
|
13276
|
+
* Merge order: built-in catalog for `bundleCluster` (when allowed) < local registry < registryUrl
|
|
13209
13277
|
* @throws Error if registry or registryUrl validation fails (or fetch fails for registryUrl)
|
|
13210
13278
|
*/
|
|
13211
13279
|
static async initCore(config) {
|
|
13212
13280
|
const connection = createConnection(config.rpcUrl);
|
|
13213
13281
|
const provider = createAnchorProvider(connection);
|
|
13214
13282
|
const cluster = config.bundleCluster ?? "mainnet";
|
|
13215
|
-
let vaults$1 = config.includeBuiltInVaults !== false ? { ...
|
|
13283
|
+
let vaults$1 = config.includeBuiltInVaults !== false ? { ...getVaultRegistry(cluster) } : {};
|
|
13216
13284
|
if (config.registry) {
|
|
13217
13285
|
const localVaults = NeutralTrade.parseVaultRegistryEntries(config.registry, "registry");
|
|
13218
13286
|
vaults$1 = {
|
|
@@ -13320,4 +13388,4 @@ var NeutralTrade = class NeutralTrade {
|
|
|
13320
13388
|
};
|
|
13321
13389
|
|
|
13322
13390
|
//#endregion
|
|
13323
|
-
export { BUNDLE_PROGRAM_ID_V2_MAINNET, DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, NeutralTrade, SEED_ORACLE, SEED_PENDING_AUTH, SEED_TEMP, SEED_USER, SupportedChain, SupportedToken, VaultCategory, VaultId, VaultType, buildBundleDepositInstructions, buildBundleRequestWithdrawInstruction, createBundleProgramById, createDummyWallet, deriveOraclePDA, derivePendingAuthPDA, deriveTempDataPDA, deriveUserPDA, getBundleProgramId, getDefaultBundleProgramIdByCluster, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, isValidVaultAddress, tokens, vaults };
|
|
13391
|
+
export { BUNDLE_PROGRAM_ID_V2_MAINNET, DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, DevnetVaultId, NeutralTrade, SEED_ORACLE, SEED_PENDING_AUTH, SEED_TEMP, SEED_USER, SupportedChain, SupportedToken, VaultCategory, VaultId, VaultType, buildBundleDepositInstructions, buildBundleRequestWithdrawInstruction, createBundleProgramById, createDummyWallet, deriveOraclePDA, derivePendingAuthPDA, deriveTempDataPDA, deriveUserPDA, getBundleProgramId, getDefaultBundleProgramIdByCluster, getSolanaTokenDecimals, getSolanaTokenMint, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, getVaultRegistry, isValidVaultAddress, tokens, vaults, vaultsDevnet };
|