@neutral-trade/sdk 0.4.10 → 0.4.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 +6 -3
- package/dist/index.mjs +3 -1
- package/dist/internal.d.mts +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/{neutral-trade-core-B_KCeEMm.d.mts → neutral-trade-core-7Ob7XfF4.d.mts} +3 -2
- package/dist/{neutral-trade-core-DCc6Dvgi.mjs → neutral-trade-core-x0cLp5YE.mjs} +51 -22
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as UserBundleTempData, B as BundleProgram, C as VaultCategory, D as BundleAccount, E as VaultType, F as getSolanaTokenMint, G as createAllowlistedBundleProgram, H as DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, I as tokens, J as isAllowlistedBundleProgramId, K as createBundleProgramById, L as ALLOWLISTED_BUNDLE_PROGRAM_IDS_BY_CLUSTER, M as SupportedToken, N as Token, O as OracleData, P as getSolanaTokenDecimals, R as BUNDLE_PROGRAM_ID_V2_MAINNET, S as VaultBalanceData, T as VaultRegistryEntry, U as DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, V as BundleProvider, W as assertAllowlistedBundleProgramId, _ as getVaultRegistry, b as vaultsDevnet, f as NeutralTrade, g as getVaultById, h as getVaultByAddress, j as SupportedChain, k as UserBundleAccount, m as getBundleProgramId, p as NeutralTradeConfig, q as getDefaultBundleProgramIdByCluster, t as NeutralTradeCoreContext, v as isValidVaultAddress, w as VaultRegistry, x as UserBalanceResult, y as vaults$1, z as BundleCluster } from "./neutral-trade-core-
|
|
1
|
+
import { A as UserBundleTempData, B as BundleProgram, C as VaultCategory, D as BundleAccount, E as VaultType, F as getSolanaTokenMint, G as createAllowlistedBundleProgram, H as DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, I as tokens, J as isAllowlistedBundleProgramId, K as createBundleProgramById, L as ALLOWLISTED_BUNDLE_PROGRAM_IDS_BY_CLUSTER, M as SupportedToken, N as Token, O as OracleData, P as getSolanaTokenDecimals, R as BUNDLE_PROGRAM_ID_V2_MAINNET, S as VaultBalanceData, T as VaultRegistryEntry, U as DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, V as BundleProvider, W as assertAllowlistedBundleProgramId, _ as getVaultRegistry, b as vaultsDevnet, f as NeutralTrade, g as getVaultById, h as getVaultByAddress, j as SupportedChain, k as UserBundleAccount, m as getBundleProgramId, p as NeutralTradeConfig, q as getDefaultBundleProgramIdByCluster, t as NeutralTradeCoreContext, v as isValidVaultAddress, w as VaultRegistry, x as UserBalanceResult, y as vaults$1, z as BundleCluster } from "./neutral-trade-core-7Ob7XfF4.mjs";
|
|
2
2
|
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
|
|
3
3
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
4
4
|
import BN from "bn.js";
|
|
@@ -186,6 +186,8 @@ declare enum DevnetVaultId {
|
|
|
186
186
|
bundle_1_100000002 = 100000002,
|
|
187
187
|
/** bundle-2 */
|
|
188
188
|
bundle_2_100000003 = 100000003,
|
|
189
|
+
/** bundle-4 */
|
|
190
|
+
bundle_4_100000005 = 100000005,
|
|
189
191
|
}
|
|
190
192
|
//#endregion
|
|
191
193
|
//#region src/utils/amount-raw.d.ts
|
|
@@ -352,7 +354,8 @@ declare function buildBundleRequestWithdrawInstruction({
|
|
|
352
354
|
amountRaw
|
|
353
355
|
}: BuildBundleRequestWithdrawInstructionParams): Promise<TransactionInstruction>;
|
|
354
356
|
/**
|
|
355
|
-
* `
|
|
357
|
+
* `initializeBundleDepositor` on target (when needed) + `requestBundleSwitch`
|
|
358
|
+
* for built-in registry vaults (source → target, same deposit token).
|
|
356
359
|
*/
|
|
357
360
|
declare function buildBundleRequestSwitchInstruction({
|
|
358
361
|
connection,
|
|
@@ -361,7 +364,7 @@ declare function buildBundleRequestSwitchInstruction({
|
|
|
361
364
|
targetVaultId,
|
|
362
365
|
user,
|
|
363
366
|
amountRaw
|
|
364
|
-
}: BuildBundleRequestSwitchInstructionParams): Promise<TransactionInstruction>;
|
|
367
|
+
}: BuildBundleRequestSwitchInstructionParams): Promise<TransactionInstruction[]>;
|
|
365
368
|
//#endregion
|
|
366
369
|
//#region src/utils/pda.d.ts
|
|
367
370
|
declare const SEED_ORACLE: NodeJS.NonSharedUint8Array;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as VaultCategory, B as DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, C as getBundleProgramId, D as isValidVaultAddress, E as getVaultRegistry, F as getSolanaTokenMint, G as isAllowlistedBundleProgramId, H as createAllowlistedBundleProgram, I as tokens, K as createDummyWallet, L as ALLOWLISTED_BUNDLE_PROGRAM_IDS_BY_CLUSTER, M as SupportedChain, N as SupportedToken, O as vaults, P as getSolanaTokenDecimals, R as BUNDLE_PROGRAM_ID_V2_MAINNET, S as parseAmountRawToBigInt, T as getVaultById, U as createBundleProgramById, V as assertAllowlistedBundleProgramId, W as getDefaultBundleProgramIdByCluster, _ as derivePendingAuthPDA, a as buildBundleDepositInstructions, b as getVaultDepositorAddressSync, d as computeRequestWithdrawalSharesFromAmountRaw, f as SEED_ORACLE, g as deriveOraclePDA, h as SEED_USER, i as initNeutralTradeCore, j as VaultType, k as vaultsDevnet, m as SEED_TEMP, n as buildRequestWithdrawInstructionForVaultId, o as buildBundleRequestSwitchInstruction, p as SEED_PENDING_AUTH, s as buildBundleRequestWithdrawInstruction, t as buildDepositInstructionsForVaultId, v as deriveTempDataPDA, w as getVaultByAddress, x as humanFloatToAmountRawString, y as deriveUserPDA, z as DEFAULT_BUNDLE_PROGRAM_ID_DEVNET } from "./neutral-trade-core-
|
|
1
|
+
import { A as VaultCategory, B as DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, C as getBundleProgramId, D as isValidVaultAddress, E as getVaultRegistry, F as getSolanaTokenMint, G as isAllowlistedBundleProgramId, H as createAllowlistedBundleProgram, I as tokens, K as createDummyWallet, L as ALLOWLISTED_BUNDLE_PROGRAM_IDS_BY_CLUSTER, M as SupportedChain, N as SupportedToken, O as vaults, P as getSolanaTokenDecimals, R as BUNDLE_PROGRAM_ID_V2_MAINNET, S as parseAmountRawToBigInt, T as getVaultById, U as createBundleProgramById, V as assertAllowlistedBundleProgramId, W as getDefaultBundleProgramIdByCluster, _ as derivePendingAuthPDA, a as buildBundleDepositInstructions, b as getVaultDepositorAddressSync, d as computeRequestWithdrawalSharesFromAmountRaw, f as SEED_ORACLE, g as deriveOraclePDA, h as SEED_USER, i as initNeutralTradeCore, j as VaultType, k as vaultsDevnet, m as SEED_TEMP, n as buildRequestWithdrawInstructionForVaultId, o as buildBundleRequestSwitchInstruction, p as SEED_PENDING_AUTH, s as buildBundleRequestWithdrawInstruction, t as buildDepositInstructionsForVaultId, v as deriveTempDataPDA, w as getVaultByAddress, x as humanFloatToAmountRawString, y as deriveUserPDA, z as DEFAULT_BUNDLE_PROGRAM_ID_DEVNET } from "./neutral-trade-core-x0cLp5YE.mjs";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
|
|
4
4
|
//#region src/constants/vault-ids.ts
|
|
@@ -183,6 +183,8 @@ let DevnetVaultId = /* @__PURE__ */ function(DevnetVaultId$1) {
|
|
|
183
183
|
DevnetVaultId$1[DevnetVaultId$1["bundle_1_100000002"] = 100000002] = "bundle_1_100000002";
|
|
184
184
|
/** bundle-2 */
|
|
185
185
|
DevnetVaultId$1[DevnetVaultId$1["bundle_2_100000003"] = 100000003] = "bundle_2_100000003";
|
|
186
|
+
/** bundle-4 */
|
|
187
|
+
DevnetVaultId$1[DevnetVaultId$1["bundle_4_100000005"] = 100000005] = "bundle_4_100000005";
|
|
186
188
|
return DevnetVaultId$1;
|
|
187
189
|
}({});
|
|
188
190
|
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as initNeutralTradeCore, c as BuildBundleRequestWithdrawInstructionCoreParams, d as buildBundleRequestWithdrawInstructionWithVault, i as getBundleProgramForVault, l as buildBundleDepositInstructionsWithVault, n as buildDepositInstructionsForVaultId, o as BuildBundleDepositInstructionsCoreParams, r as buildRequestWithdrawInstructionForVaultId, s as BuildBundleRequestSwitchInstructionCoreParams, t as NeutralTradeCoreContext, u as buildBundleRequestSwitchInstructionWithVault } from "./neutral-trade-core-
|
|
1
|
+
import { a as initNeutralTradeCore, c as BuildBundleRequestWithdrawInstructionCoreParams, d as buildBundleRequestWithdrawInstructionWithVault, i as getBundleProgramForVault, l as buildBundleDepositInstructionsWithVault, n as buildDepositInstructionsForVaultId, o as BuildBundleDepositInstructionsCoreParams, r as buildRequestWithdrawInstructionForVaultId, s as BuildBundleRequestSwitchInstructionCoreParams, t as NeutralTradeCoreContext, u as buildBundleRequestSwitchInstructionWithVault } from "./neutral-trade-core-7Ob7XfF4.mjs";
|
|
2
2
|
export { type BuildBundleDepositInstructionsCoreParams, type BuildBundleRequestSwitchInstructionCoreParams, type BuildBundleRequestWithdrawInstructionCoreParams, type NeutralTradeCoreContext, buildBundleDepositInstructionsWithVault, buildBundleRequestSwitchInstructionWithVault, buildBundleRequestWithdrawInstructionWithVault, buildDepositInstructionsForVaultId, buildRequestWithdrawInstructionForVaultId, getBundleProgramForVault, initNeutralTradeCore };
|
package/dist/internal.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { c as buildBundleDepositInstructionsWithVault, i as initNeutralTradeCore, l as buildBundleRequestSwitchInstructionWithVault, n as buildRequestWithdrawInstructionForVaultId, r as getBundleProgramForVault, t as buildDepositInstructionsForVaultId, u as buildBundleRequestWithdrawInstructionWithVault } from "./neutral-trade-core-
|
|
1
|
+
import { c as buildBundleDepositInstructionsWithVault, i as initNeutralTradeCore, l as buildBundleRequestSwitchInstructionWithVault, n as buildRequestWithdrawInstructionForVaultId, r as getBundleProgramForVault, t as buildDepositInstructionsForVaultId, u as buildBundleRequestWithdrawInstructionWithVault } from "./neutral-trade-core-x0cLp5YE.mjs";
|
|
2
2
|
|
|
3
3
|
export { buildBundleDepositInstructionsWithVault, buildBundleRequestSwitchInstructionWithVault, buildBundleRequestWithdrawInstructionWithVault, buildDepositInstructionsForVaultId, buildRequestWithdrawInstructionForVaultId, getBundleProgramForVault, initNeutralTradeCore };
|
|
@@ -4021,7 +4021,8 @@ declare function buildBundleRequestWithdrawInstructionWithVault({
|
|
|
4021
4021
|
amountRaw
|
|
4022
4022
|
}: BuildBundleRequestWithdrawInstructionCoreParams): Promise<TransactionInstruction>;
|
|
4023
4023
|
/**
|
|
4024
|
-
* `
|
|
4024
|
+
* `initializeBundleDepositor` on target (when missing) + `requestBundleSwitch`.
|
|
4025
|
+
* Fetches source bundle, oracle, user bundle, and target bundle internally.
|
|
4025
4026
|
* @internal
|
|
4026
4027
|
*/
|
|
4027
4028
|
declare function buildBundleRequestSwitchInstructionWithVault({
|
|
@@ -4031,7 +4032,7 @@ declare function buildBundleRequestSwitchInstructionWithVault({
|
|
|
4031
4032
|
targetVault,
|
|
4032
4033
|
user,
|
|
4033
4034
|
amountRaw
|
|
4034
|
-
}: BuildBundleRequestSwitchInstructionCoreParams): Promise<TransactionInstruction>;
|
|
4035
|
+
}: BuildBundleRequestSwitchInstructionCoreParams): Promise<TransactionInstruction[]>;
|
|
4035
4036
|
//#endregion
|
|
4036
4037
|
//#region src/neutral-trade-core.d.ts
|
|
4037
4038
|
interface NeutralTradeCoreContext {
|
|
@@ -13037,25 +13037,38 @@ function createBundleProgramById(provider, programId) {
|
|
|
13037
13037
|
|
|
13038
13038
|
//#endregion
|
|
13039
13039
|
//#region src/registry/vaults.devnet.json
|
|
13040
|
-
var vaults_devnet_default = [
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13040
|
+
var vaults_devnet_default = [
|
|
13041
|
+
{
|
|
13042
|
+
"vaultId": 100000002,
|
|
13043
|
+
"name": "bundle-1",
|
|
13044
|
+
"type": "Bundle",
|
|
13045
|
+
"category": "Market Neutral",
|
|
13046
|
+
"vaultAddress": "HXvKAH4QyYMe7MsxC88pb19MhhYCEDHai87E8tZkmXmB",
|
|
13047
|
+
"depositToken": "USDC",
|
|
13048
|
+
"pointsMultiplier": 1,
|
|
13049
|
+
"pointsEnabled": true
|
|
13050
|
+
},
|
|
13051
|
+
{
|
|
13052
|
+
"vaultId": 100000003,
|
|
13053
|
+
"name": "bundle-2",
|
|
13054
|
+
"type": "Bundle",
|
|
13055
|
+
"category": "Market Neutral",
|
|
13056
|
+
"vaultAddress": "6nRRXv7GzreuE1PUgHySf9u6wwzXq61eiQbBpik1fbjy",
|
|
13057
|
+
"depositToken": "USDC",
|
|
13058
|
+
"pointsMultiplier": 1,
|
|
13059
|
+
"pointsEnabled": true
|
|
13060
|
+
},
|
|
13061
|
+
{
|
|
13062
|
+
"vaultId": 100000005,
|
|
13063
|
+
"name": "bundle-4",
|
|
13064
|
+
"type": "Bundle",
|
|
13065
|
+
"category": "Market Neutral",
|
|
13066
|
+
"vaultAddress": "8TqrZmyiWQ3F3WysiBaBQC1Nzj1LDn5AR7JjXBYzFxxQ",
|
|
13067
|
+
"depositToken": "USDC",
|
|
13068
|
+
"pointsMultiplier": 1,
|
|
13069
|
+
"pointsEnabled": true
|
|
13070
|
+
}
|
|
13071
|
+
];
|
|
13059
13072
|
|
|
13060
13073
|
//#endregion
|
|
13061
13074
|
//#region src/registry/vaults.json
|
|
@@ -14309,7 +14322,8 @@ function assertSwitchVaultPair(sourceVault, targetVault, bundleCluster) {
|
|
|
14309
14322
|
if (bundleProgramIdForVault(sourceVault, bundleCluster) !== bundleProgramIdForVault(targetVault, bundleCluster)) throw new Error("Source and target vault must use the same bundle program");
|
|
14310
14323
|
}
|
|
14311
14324
|
/**
|
|
14312
|
-
* `
|
|
14325
|
+
* `initializeBundleDepositor` on target (when missing) + `requestBundleSwitch`.
|
|
14326
|
+
* Fetches source bundle, oracle, user bundle, and target bundle internally.
|
|
14313
14327
|
* @internal
|
|
14314
14328
|
*/
|
|
14315
14329
|
async function buildBundleRequestSwitchInstructionWithVault({ bundleProgram, bundleCluster = "mainnet", sourceVault, targetVault, user, amountRaw }) {
|
|
@@ -14323,6 +14337,7 @@ async function buildBundleRequestSwitchInstructionWithVault({ bundleProgram, bun
|
|
|
14323
14337
|
const userPDA = deriveUserPDA(user, sourceBundlePDA, programPk);
|
|
14324
14338
|
const tempDataPDA = deriveTempDataPDA(sourceBundlePDA, programPk);
|
|
14325
14339
|
const targetUserPDA = deriveUserPDA(user, targetBundlePDA, programPk);
|
|
14340
|
+
const needsTargetInit = !(await bundleProgram.provider.connection.getAccountInfo(targetUserPDA))?.data?.length;
|
|
14326
14341
|
const [sourceBundleAccount, oracleData, userBundle, targetBundleAccount] = await Promise.all([
|
|
14327
14342
|
bundleProgram.account.bundle.fetch(sourceBundlePDA),
|
|
14328
14343
|
bundleProgram.account.oracleData.fetch(oraclePDA),
|
|
@@ -14338,7 +14353,18 @@ async function buildBundleRequestSwitchInstructionWithVault({ bundleProgram, bun
|
|
|
14338
14353
|
totalEquity,
|
|
14339
14354
|
totalShares
|
|
14340
14355
|
});
|
|
14341
|
-
|
|
14356
|
+
const instructions$2 = [];
|
|
14357
|
+
if (needsTargetInit) {
|
|
14358
|
+
const initIx = await bundleProgram.methods.initializeBundleDepositor().accounts({
|
|
14359
|
+
payer: user,
|
|
14360
|
+
authority: user,
|
|
14361
|
+
systemProgram: SystemProgram.programId,
|
|
14362
|
+
bundleAccount: targetBundlePDA,
|
|
14363
|
+
userBundleAccount: targetUserPDA
|
|
14364
|
+
}).instruction();
|
|
14365
|
+
instructions$2.push(initIx);
|
|
14366
|
+
}
|
|
14367
|
+
const switchIx = await bundleProgram.methods.requestBundleSwitch(sharesAmount).accounts({
|
|
14342
14368
|
withdrawalRequest: {
|
|
14343
14369
|
user,
|
|
14344
14370
|
userBundleAccount: userPDA,
|
|
@@ -14352,6 +14378,8 @@ async function buildBundleRequestSwitchInstructionWithVault({ bundleProgram, bun
|
|
|
14352
14378
|
targetBundleAccount: targetBundlePDA,
|
|
14353
14379
|
targetUserBundleAccount: targetUserPDA
|
|
14354
14380
|
}).instruction();
|
|
14381
|
+
instructions$2.push(switchIx);
|
|
14382
|
+
return instructions$2;
|
|
14355
14383
|
}
|
|
14356
14384
|
|
|
14357
14385
|
//#endregion
|
|
@@ -14395,7 +14423,8 @@ async function buildBundleRequestWithdrawInstruction({ connection, bundleCluster
|
|
|
14395
14423
|
});
|
|
14396
14424
|
}
|
|
14397
14425
|
/**
|
|
14398
|
-
* `
|
|
14426
|
+
* `initializeBundleDepositor` on target (when needed) + `requestBundleSwitch`
|
|
14427
|
+
* for built-in registry vaults (source → target, same deposit token).
|
|
14399
14428
|
*/
|
|
14400
14429
|
async function buildBundleRequestSwitchInstruction({ connection, bundleCluster = "mainnet", sourceVaultId, targetVaultId, user, amountRaw }) {
|
|
14401
14430
|
const { vault: sourceVault, programId } = resolveTrustedBundleVault(sourceVaultId, bundleCluster);
|