@neutral-trade/sdk 0.4.8 → 0.4.10
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 +31 -4
- package/dist/index.mjs +10 -4
- package/dist/internal.d.mts +2 -2
- package/dist/internal.mjs +2 -2
- package/dist/{neutral-trade-core-BGjOiCsY.d.mts → neutral-trade-core-B_KCeEMm.d.mts} +613 -2
- package/dist/{neutral-trade-core-B8iDgu5K.mjs → neutral-trade-core-DCc6Dvgi.mjs} +1459 -252
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
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-B_KCeEMm.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";
|
|
@@ -182,8 +182,10 @@ declare enum VaultId {
|
|
|
182
182
|
* Auto-generated from the vault registry JSON.
|
|
183
183
|
*/
|
|
184
184
|
declare enum DevnetVaultId {
|
|
185
|
-
/**
|
|
186
|
-
|
|
185
|
+
/** bundle-1 */
|
|
186
|
+
bundle_1_100000002 = 100000002,
|
|
187
|
+
/** bundle-2 */
|
|
188
|
+
bundle_2_100000003 = 100000003,
|
|
187
189
|
}
|
|
188
190
|
//#endregion
|
|
189
191
|
//#region src/utils/amount-raw.d.ts
|
|
@@ -280,6 +282,11 @@ declare function computeDepositFeePreview(grossAmount: number, depositFeeDecimal
|
|
|
280
282
|
feeAmount: number;
|
|
281
283
|
netAmount: number;
|
|
282
284
|
};
|
|
285
|
+
/** Same linear preview as deposit: fee = gross × rate, net = gross − fee. */
|
|
286
|
+
declare function computeWithdrawFeePreview(grossAmount: number, withdrawalFeeDecimal: number): {
|
|
287
|
+
feeAmount: number;
|
|
288
|
+
netAmount: number;
|
|
289
|
+
};
|
|
283
290
|
//#endregion
|
|
284
291
|
//#region src/utils/request-withdraw-shares.d.ts
|
|
285
292
|
/**
|
|
@@ -315,6 +322,15 @@ interface BuildBundleRequestWithdrawInstructionParams {
|
|
|
315
322
|
/** Smallest token units (decimal string) to request withdrawing. */
|
|
316
323
|
amountRaw: string;
|
|
317
324
|
}
|
|
325
|
+
interface BuildBundleRequestSwitchInstructionParams {
|
|
326
|
+
connection: Connection;
|
|
327
|
+
bundleCluster?: BundleCluster;
|
|
328
|
+
sourceVaultId: number;
|
|
329
|
+
targetVaultId: number;
|
|
330
|
+
user: PublicKey;
|
|
331
|
+
/** Smallest token units (decimal string) to switch out of the source vault. */
|
|
332
|
+
amountRaw: string;
|
|
333
|
+
}
|
|
318
334
|
/**
|
|
319
335
|
* `initializeBundleDepositor` (when needed) + `requestDeposit` for a built-in registry vault.
|
|
320
336
|
*/
|
|
@@ -335,6 +351,17 @@ declare function buildBundleRequestWithdrawInstruction({
|
|
|
335
351
|
user,
|
|
336
352
|
amountRaw
|
|
337
353
|
}: BuildBundleRequestWithdrawInstructionParams): Promise<TransactionInstruction>;
|
|
354
|
+
/**
|
|
355
|
+
* `requestBundleSwitch` for built-in registry vaults (source → target, same deposit token).
|
|
356
|
+
*/
|
|
357
|
+
declare function buildBundleRequestSwitchInstruction({
|
|
358
|
+
connection,
|
|
359
|
+
bundleCluster,
|
|
360
|
+
sourceVaultId,
|
|
361
|
+
targetVaultId,
|
|
362
|
+
user,
|
|
363
|
+
amountRaw
|
|
364
|
+
}: BuildBundleRequestSwitchInstructionParams): Promise<TransactionInstruction>;
|
|
338
365
|
//#endregion
|
|
339
366
|
//#region src/utils/pda.d.ts
|
|
340
367
|
declare const SEED_ORACLE: NodeJS.NonSharedUint8Array;
|
|
@@ -363,4 +390,4 @@ declare function derivePendingAuthPDA(bundlePDA: PublicKey, programId: PublicKey
|
|
|
363
390
|
*/
|
|
364
391
|
declare function getVaultDepositorAddressSync(programId: PublicKey, vault: PublicKey, authority: PublicKey): PublicKey;
|
|
365
392
|
//#endregion
|
|
366
|
-
export { ALLOWLISTED_BUNDLE_PROGRAM_IDS_BY_CLUSTER, BUNDLE_PROGRAM_ID_V2_MAINNET, type BuildBundleDepositInstructionsParams, type BuildBundleRequestWithdrawInstructionParams, type BundleAccount, type BundleCluster, type BundleProgram, type BundleProvider, DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, DevnetVaultId, type EffectiveFeeBps, type EffectiveVaultFeeDecimals, FEE_OVERRIDE, 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 UserFeeOverrideFields, type VaultBalanceData, VaultCategory, VaultId, type VaultRegistry, type VaultRegistryEntry, VaultType, assertAllowlistedBundleProgramId, bpsToFeeDecimal, bpsToPercentLabel, buildBundleDepositInstructions, buildBundleRequestWithdrawInstruction, buildFeeOverrideMask, computeDepositFeePreview, computeRequestWithdrawalSharesFromAmountRaw, createAllowlistedBundleProgram, createBundleProgramById, createDummyWallet, deriveOraclePDA, derivePendingAuthPDA, deriveTempDataPDA, deriveUserPDA, effectiveFeeBpsToDecimals, estimatePendingBundleFeeToken, feeDecimalToBps, formatFeeOverrideFlags, getBundleProgramId, getDefaultBundleProgramIdByCluster, getSolanaTokenDecimals, getSolanaTokenMint, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, getVaultRegistry, hasAnyFeeOverride, hasCustomFeeRate, hasFeeOverrideFlag, humanFloatToAmountRawString, isAllowlistedBundleProgramId, isValidVaultAddress, parseAmountRawToBigInt, readUserFeeOverrideFields, resolveEffectiveFeeBps, resolveEffectiveFeeBpsFromDefaults, resolveEffectiveVaultFees, tokens, vaultFeeDecimalsToBps, vaults$1 as vaults, vaultsDevnet };
|
|
393
|
+
export { ALLOWLISTED_BUNDLE_PROGRAM_IDS_BY_CLUSTER, BUNDLE_PROGRAM_ID_V2_MAINNET, type BuildBundleDepositInstructionsParams, type BuildBundleRequestSwitchInstructionParams, type BuildBundleRequestWithdrawInstructionParams, type BundleAccount, type BundleCluster, type BundleProgram, type BundleProvider, DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, DevnetVaultId, type EffectiveFeeBps, type EffectiveVaultFeeDecimals, FEE_OVERRIDE, 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 UserFeeOverrideFields, type VaultBalanceData, VaultCategory, VaultId, type VaultRegistry, type VaultRegistryEntry, VaultType, assertAllowlistedBundleProgramId, bpsToFeeDecimal, bpsToPercentLabel, buildBundleDepositInstructions, buildBundleRequestSwitchInstruction, buildBundleRequestWithdrawInstruction, buildFeeOverrideMask, computeDepositFeePreview, computeRequestWithdrawalSharesFromAmountRaw, computeWithdrawFeePreview, createAllowlistedBundleProgram, createBundleProgramById, createDummyWallet, deriveOraclePDA, derivePendingAuthPDA, deriveTempDataPDA, deriveUserPDA, effectiveFeeBpsToDecimals, estimatePendingBundleFeeToken, feeDecimalToBps, formatFeeOverrideFlags, getBundleProgramId, getDefaultBundleProgramIdByCluster, getSolanaTokenDecimals, getSolanaTokenMint, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, getVaultRegistry, hasAnyFeeOverride, hasCustomFeeRate, hasFeeOverrideFlag, humanFloatToAmountRawString, isAllowlistedBundleProgramId, isValidVaultAddress, parseAmountRawToBigInt, readUserFeeOverrideFields, resolveEffectiveFeeBps, resolveEffectiveFeeBpsFromDefaults, resolveEffectiveVaultFees, tokens, vaultFeeDecimalsToBps, vaults$1 as vaults, vaultsDevnet };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
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-DCc6Dvgi.mjs";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
|
|
4
4
|
//#region src/constants/vault-ids.ts
|
|
@@ -179,8 +179,10 @@ let VaultId = /* @__PURE__ */ function(VaultId$1) {
|
|
|
179
179
|
* Auto-generated from the vault registry JSON.
|
|
180
180
|
*/
|
|
181
181
|
let DevnetVaultId = /* @__PURE__ */ function(DevnetVaultId$1) {
|
|
182
|
-
/**
|
|
183
|
-
DevnetVaultId$1[DevnetVaultId$1["
|
|
182
|
+
/** bundle-1 */
|
|
183
|
+
DevnetVaultId$1[DevnetVaultId$1["bundle_1_100000002"] = 100000002] = "bundle_1_100000002";
|
|
184
|
+
/** bundle-2 */
|
|
185
|
+
DevnetVaultId$1[DevnetVaultId$1["bundle_2_100000003"] = 100000003] = "bundle_2_100000003";
|
|
184
186
|
return DevnetVaultId$1;
|
|
185
187
|
}({});
|
|
186
188
|
|
|
@@ -308,6 +310,10 @@ function computeDepositFeePreview(grossAmount, depositFeeDecimal) {
|
|
|
308
310
|
netAmount: grossAmount - feeAmount
|
|
309
311
|
};
|
|
310
312
|
}
|
|
313
|
+
/** Same linear preview as deposit: fee = gross × rate, net = gross − fee. */
|
|
314
|
+
function computeWithdrawFeePreview(grossAmount, withdrawalFeeDecimal) {
|
|
315
|
+
return computeDepositFeePreview(grossAmount, withdrawalFeeDecimal);
|
|
316
|
+
}
|
|
311
317
|
|
|
312
318
|
//#endregion
|
|
313
319
|
//#region src/utils/bundle.ts
|
|
@@ -532,4 +538,4 @@ var NeutralTrade = class NeutralTrade {
|
|
|
532
538
|
};
|
|
533
539
|
|
|
534
540
|
//#endregion
|
|
535
|
-
export { ALLOWLISTED_BUNDLE_PROGRAM_IDS_BY_CLUSTER, BUNDLE_PROGRAM_ID_V2_MAINNET, DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, DevnetVaultId, FEE_OVERRIDE, NeutralTrade, SEED_ORACLE, SEED_PENDING_AUTH, SEED_TEMP, SEED_USER, SupportedChain, SupportedToken, VaultCategory, VaultId, VaultType, assertAllowlistedBundleProgramId, bpsToFeeDecimal, bpsToPercentLabel, buildBundleDepositInstructions, buildBundleRequestWithdrawInstruction, buildFeeOverrideMask, computeDepositFeePreview, computeRequestWithdrawalSharesFromAmountRaw, createAllowlistedBundleProgram, createBundleProgramById, createDummyWallet, deriveOraclePDA, derivePendingAuthPDA, deriveTempDataPDA, deriveUserPDA, effectiveFeeBpsToDecimals, estimatePendingBundleFeeToken, feeDecimalToBps, formatFeeOverrideFlags, getBundleProgramId, getDefaultBundleProgramIdByCluster, getSolanaTokenDecimals, getSolanaTokenMint, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, getVaultRegistry, hasAnyFeeOverride, hasCustomFeeRate, hasFeeOverrideFlag, humanFloatToAmountRawString, isAllowlistedBundleProgramId, isValidVaultAddress, parseAmountRawToBigInt, readUserFeeOverrideFields, resolveEffectiveFeeBps, resolveEffectiveFeeBpsFromDefaults, resolveEffectiveVaultFees, tokens, vaultFeeDecimalsToBps, vaults, vaultsDevnet };
|
|
541
|
+
export { ALLOWLISTED_BUNDLE_PROGRAM_IDS_BY_CLUSTER, BUNDLE_PROGRAM_ID_V2_MAINNET, DEFAULT_BUNDLE_PROGRAM_ID_DEVNET, DEFAULT_BUNDLE_PROGRAM_ID_MAINNET, DevnetVaultId, FEE_OVERRIDE, NeutralTrade, SEED_ORACLE, SEED_PENDING_AUTH, SEED_TEMP, SEED_USER, SupportedChain, SupportedToken, VaultCategory, VaultId, VaultType, assertAllowlistedBundleProgramId, bpsToFeeDecimal, bpsToPercentLabel, buildBundleDepositInstructions, buildBundleRequestSwitchInstruction, buildBundleRequestWithdrawInstruction, buildFeeOverrideMask, computeDepositFeePreview, computeRequestWithdrawalSharesFromAmountRaw, computeWithdrawFeePreview, createAllowlistedBundleProgram, createBundleProgramById, createDummyWallet, deriveOraclePDA, derivePendingAuthPDA, deriveTempDataPDA, deriveUserPDA, effectiveFeeBpsToDecimals, estimatePendingBundleFeeToken, feeDecimalToBps, formatFeeOverrideFlags, getBundleProgramId, getDefaultBundleProgramIdByCluster, getSolanaTokenDecimals, getSolanaTokenMint, getVaultByAddress, getVaultById, getVaultDepositorAddressSync, getVaultRegistry, hasAnyFeeOverride, hasCustomFeeRate, hasFeeOverrideFlag, humanFloatToAmountRawString, isAllowlistedBundleProgramId, isValidVaultAddress, parseAmountRawToBigInt, readUserFeeOverrideFields, resolveEffectiveFeeBps, resolveEffectiveFeeBpsFromDefaults, resolveEffectiveVaultFees, tokens, vaultFeeDecimalsToBps, vaults, vaultsDevnet };
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as initNeutralTradeCore, c as
|
|
2
|
-
export { type BuildBundleDepositInstructionsCoreParams, type BuildBundleRequestWithdrawInstructionCoreParams, type NeutralTradeCoreContext, buildBundleDepositInstructionsWithVault, buildBundleRequestWithdrawInstructionWithVault, buildDepositInstructionsForVaultId, buildRequestWithdrawInstructionForVaultId, getBundleProgramForVault, initNeutralTradeCore };
|
|
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-B_KCeEMm.mjs";
|
|
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
|
|
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-DCc6Dvgi.mjs";
|
|
2
2
|
|
|
3
|
-
export { buildBundleDepositInstructionsWithVault, buildBundleRequestWithdrawInstructionWithVault, buildDepositInstructionsForVaultId, buildRequestWithdrawInstructionForVaultId, getBundleProgramForVault, initNeutralTradeCore };
|
|
3
|
+
export { buildBundleDepositInstructionsWithVault, buildBundleRequestSwitchInstructionWithVault, buildBundleRequestWithdrawInstructionWithVault, buildDepositInstructionsForVaultId, buildRequestWithdrawInstructionForVaultId, getBundleProgramForVault, initNeutralTradeCore };
|