four-flap-meme-sdk 1.3.85 → 1.3.86

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.
Files changed (104) hide show
  1. package/dist/clients/blockrazor.js +0 -1
  2. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  3. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.js +0 -1
  6. package/package.json +4 -39
  7. package/dist/sol/constants.d.ts +0 -136
  8. package/dist/sol/constants.js +0 -156
  9. package/dist/sol/dex/index.d.ts +0 -8
  10. package/dist/sol/dex/index.js +0 -12
  11. package/dist/sol/dex/meteora/client.d.ts +0 -75
  12. package/dist/sol/dex/meteora/client.js +0 -218
  13. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  14. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  15. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  16. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  17. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  18. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  19. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  20. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  21. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  22. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  23. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  24. package/dist/sol/dex/meteora/dbc.js +0 -619
  25. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  26. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  27. package/dist/sol/dex/meteora/dlmm.d.ts +0 -146
  28. package/dist/sol/dex/meteora/dlmm.js +0 -593
  29. package/dist/sol/dex/meteora/index.d.ts +0 -25
  30. package/dist/sol/dex/meteora/index.js +0 -65
  31. package/dist/sol/dex/meteora/types.d.ts +0 -787
  32. package/dist/sol/dex/meteora/types.js +0 -110
  33. package/dist/sol/dex/orca/index.d.ts +0 -10
  34. package/dist/sol/dex/orca/index.js +0 -16
  35. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  36. package/dist/sol/dex/orca/orca-bundle.js +0 -140
  37. package/dist/sol/dex/orca/orca.d.ts +0 -65
  38. package/dist/sol/dex/orca/orca.js +0 -426
  39. package/dist/sol/dex/orca/types.d.ts +0 -263
  40. package/dist/sol/dex/orca/types.js +0 -38
  41. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  42. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -189
  43. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  44. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  45. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  46. package/dist/sol/dex/orca/wavebreak.js +0 -469
  47. package/dist/sol/dex/pump/index.d.ts +0 -9
  48. package/dist/sol/dex/pump/index.js +0 -14
  49. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  50. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  51. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  52. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  53. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  54. package/dist/sol/dex/pump/pump-swap.js +0 -199
  55. package/dist/sol/dex/pump/pump.d.ts +0 -35
  56. package/dist/sol/dex/pump/pump.js +0 -352
  57. package/dist/sol/dex/pump/types.d.ts +0 -215
  58. package/dist/sol/dex/pump/types.js +0 -5
  59. package/dist/sol/dex/raydium/index.d.ts +0 -8
  60. package/dist/sol/dex/raydium/index.js +0 -12
  61. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  62. package/dist/sol/dex/raydium/launchlab.js +0 -210
  63. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  64. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  65. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  66. package/dist/sol/dex/raydium/raydium.js +0 -366
  67. package/dist/sol/dex/raydium/types.d.ts +0 -240
  68. package/dist/sol/dex/raydium/types.js +0 -5
  69. package/dist/sol/index.d.ts +0 -10
  70. package/dist/sol/index.js +0 -16
  71. package/dist/sol/jito/bundle.d.ts +0 -90
  72. package/dist/sol/jito/bundle.js +0 -263
  73. package/dist/sol/jito/index.d.ts +0 -7
  74. package/dist/sol/jito/index.js +0 -7
  75. package/dist/sol/jito/tip.d.ts +0 -51
  76. package/dist/sol/jito/tip.js +0 -83
  77. package/dist/sol/jito/types.d.ts +0 -100
  78. package/dist/sol/jito/types.js +0 -5
  79. package/dist/sol/token/create-complete.d.ts +0 -115
  80. package/dist/sol/token/create-complete.js +0 -235
  81. package/dist/sol/token/create-token.d.ts +0 -57
  82. package/dist/sol/token/create-token.js +0 -230
  83. package/dist/sol/token/index.d.ts +0 -9
  84. package/dist/sol/token/index.js +0 -14
  85. package/dist/sol/token/metadata-upload.d.ts +0 -86
  86. package/dist/sol/token/metadata-upload.js +0 -173
  87. package/dist/sol/token/metadata.d.ts +0 -92
  88. package/dist/sol/token/metadata.js +0 -274
  89. package/dist/sol/token/types.d.ts +0 -153
  90. package/dist/sol/token/types.js +0 -5
  91. package/dist/sol/types.d.ts +0 -176
  92. package/dist/sol/types.js +0 -7
  93. package/dist/sol/utils/balance.d.ts +0 -160
  94. package/dist/sol/utils/balance.js +0 -638
  95. package/dist/sol/utils/connection.d.ts +0 -69
  96. package/dist/sol/utils/connection.js +0 -156
  97. package/dist/sol/utils/index.d.ts +0 -9
  98. package/dist/sol/utils/index.js +0 -9
  99. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  100. package/dist/sol/utils/lp-inspect.js +0 -515
  101. package/dist/sol/utils/transfer.d.ts +0 -125
  102. package/dist/sol/utils/transfer.js +0 -220
  103. package/dist/sol/utils/wallet.d.ts +0 -107
  104. package/dist/sol/utils/wallet.js +0 -210
@@ -1,110 +0,0 @@
1
- /**
2
- * Meteora 通用类型定义
3
- */
4
- /**
5
- * DBC 迁移费用选项
6
- */
7
- export var DbcMigrationFeeOption;
8
- (function (DbcMigrationFeeOption) {
9
- DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps25"] = 0] = "FixedBps25";
10
- DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps30"] = 1] = "FixedBps30";
11
- DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps100"] = 2] = "FixedBps100";
12
- DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps200"] = 3] = "FixedBps200";
13
- DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps400"] = 4] = "FixedBps400";
14
- DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps600"] = 5] = "FixedBps600";
15
- DbcMigrationFeeOption[DbcMigrationFeeOption["Customizable"] = 6] = "Customizable";
16
- })(DbcMigrationFeeOption || (DbcMigrationFeeOption = {}));
17
- /**
18
- * DBC 激活类型
19
- */
20
- export var DbcActivationType;
21
- (function (DbcActivationType) {
22
- DbcActivationType[DbcActivationType["Slot"] = 0] = "Slot";
23
- DbcActivationType[DbcActivationType["Timestamp"] = 1] = "Timestamp";
24
- })(DbcActivationType || (DbcActivationType = {}));
25
- /**
26
- * DBC 代币类型
27
- */
28
- export var DbcTokenType;
29
- (function (DbcTokenType) {
30
- DbcTokenType[DbcTokenType["Token"] = 0] = "Token";
31
- DbcTokenType[DbcTokenType["Token2022"] = 1] = "Token2022";
32
- })(DbcTokenType || (DbcTokenType = {}));
33
- /**
34
- * DBC 迁移目标
35
- */
36
- export var DbcMigrationOption;
37
- (function (DbcMigrationOption) {
38
- DbcMigrationOption[DbcMigrationOption["DammV1"] = 0] = "DammV1";
39
- DbcMigrationOption[DbcMigrationOption["DammV2"] = 1] = "DammV2";
40
- })(DbcMigrationOption || (DbcMigrationOption = {}));
41
- // ============================================================================
42
- // DBC 扩展类型
43
- // ============================================================================
44
- /**
45
- * DBC 费用模式
46
- */
47
- export var DbcBaseFeeMode;
48
- (function (DbcBaseFeeMode) {
49
- DbcBaseFeeMode[DbcBaseFeeMode["FeeSchedulerLinear"] = 0] = "FeeSchedulerLinear";
50
- DbcBaseFeeMode[DbcBaseFeeMode["FeeSchedulerExponential"] = 1] = "FeeSchedulerExponential";
51
- DbcBaseFeeMode[DbcBaseFeeMode["RateLimiter"] = 2] = "RateLimiter";
52
- })(DbcBaseFeeMode || (DbcBaseFeeMode = {}));
53
- /**
54
- * DBC 费用收取模式
55
- */
56
- export var DbcCollectFeeMode;
57
- (function (DbcCollectFeeMode) {
58
- DbcCollectFeeMode[DbcCollectFeeMode["QuoteToken"] = 0] = "QuoteToken";
59
- DbcCollectFeeMode[DbcCollectFeeMode["OutputToken"] = 1] = "OutputToken";
60
- })(DbcCollectFeeMode || (DbcCollectFeeMode = {}));
61
- /**
62
- * DBC 代币更新权限
63
- */
64
- export var DbcTokenUpdateAuthority;
65
- (function (DbcTokenUpdateAuthority) {
66
- DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["CreatorUpdateAuthority"] = 0] = "CreatorUpdateAuthority";
67
- DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["Immutable"] = 1] = "Immutable";
68
- DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["PartnerUpdateAuthority"] = 2] = "PartnerUpdateAuthority";
69
- DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["CreatorUpdateAndMintAuthority"] = 3] = "CreatorUpdateAndMintAuthority";
70
- DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["PartnerUpdateAndMintAuthority"] = 4] = "PartnerUpdateAndMintAuthority";
71
- })(DbcTokenUpdateAuthority || (DbcTokenUpdateAuthority = {}));
72
- // ============================================================================
73
- // 常量
74
- // ============================================================================
75
- /**
76
- * Meteora Program IDs
77
- */
78
- export const METEORA_PROGRAM_IDS = {
79
- /** DLMM Program */
80
- DLMM: 'LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo',
81
- /** Dynamic Bonding Curve Program */
82
- DBC: 'dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN',
83
- /** DAMM v1 Program */
84
- DAMM_V1: 'Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB',
85
- /** DAMM v2 (CP-AMM) Program */
86
- DAMM_V2: 'cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG',
87
- };
88
- /**
89
- * DBC DAMM V1 迁移费用配置地址
90
- */
91
- export const DBC_DAMM_V1_MIGRATION_FEE_ADDRESS = {
92
- [DbcMigrationFeeOption.FixedBps25]: '8f848CEy8eY6PhJ3VcemtBDzPPSD4Vq7aJczLZ3o8MmX',
93
- [DbcMigrationFeeOption.FixedBps30]: 'HBxB8Lf14Yj8pqeJ8C4qDb5ryHL7xwpuykz31BLNYr7S',
94
- [DbcMigrationFeeOption.FixedBps100]: '7v5vBdUQHTNeqk1HnduiXcgbvCyVEZ612HLmYkQoAkik',
95
- [DbcMigrationFeeOption.FixedBps200]: 'EkvP7d5yKxovj884d2DwmBQbrHUWRLGK6bympzrkXGja',
96
- [DbcMigrationFeeOption.FixedBps400]: '9EZYAJrcqNWNQzP2trzZesP7XKMHA1jEomHzbRsdX8R2',
97
- [DbcMigrationFeeOption.FixedBps600]: '8cdKo87jZU2R12KY1BUjjRPwyjgdNjLGqSGQyrDshhud',
98
- };
99
- /**
100
- * DBC DAMM V2 迁移费用配置地址
101
- */
102
- export const DBC_DAMM_V2_MIGRATION_FEE_ADDRESS = {
103
- [DbcMigrationFeeOption.FixedBps25]: '7F6dnUcRuyM2TwR8myT1dYypFXpPSxqwKNSFNkxyNESd',
104
- [DbcMigrationFeeOption.FixedBps30]: '2nHK1kju6XjphBLbNxpM5XRGFj7p9U8vvNzyZiha1z6k',
105
- [DbcMigrationFeeOption.FixedBps100]: 'Hv8Lmzmnju6m7kcokVKvwqz7QPmdX9XfKjJsXz8RXcjp',
106
- [DbcMigrationFeeOption.FixedBps200]: '2c4cYd4reUYVRAB9kUUkrq55VPyy2FNQ3FDL4o12JXmq',
107
- [DbcMigrationFeeOption.FixedBps400]: 'AkmQWebAwFvWk55wBoCr5D62C6VVDTzi84NJuD9H7cFD',
108
- [DbcMigrationFeeOption.FixedBps600]: 'DbCRBj8McvPYHJG1ukj8RE15h2dCNUdTAESG49XpQ44u',
109
- [DbcMigrationFeeOption.Customizable]: 'A8gMrEPJkacWkcb3DGwtJwTe16HktSEfvwtuDh2MCtck',
110
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * Orca 模块导出
3
- * 包含 Whirlpool (流动性池) 和 Wavebreak (代币发射平台)
4
- */
5
- export * from './types.js';
6
- export { createOrcaContext, createOrcaClient, getOrcaPoolInfo, findOrcaPool, signOrcaSwap, signOrcaAddLiquidity, signOrcaRemoveLiquidity, signOrcaCreatePool, signOrcaCollectFees, getOrcaPositionInfo, getFullRangeTickIndices, getTickIndicesFromPriceRange, } from './orca.js';
7
- export { signOrcaBundleBuy, signOrcaBundleSell, signOrcaBundleSwap, toOrcaBundleApiRequest, batchGetOrcaPoolInfo, } from './orca-bundle.js';
8
- export * from './wavebreak-types.js';
9
- export { getWavebreakBondingCurveAddress, getWavebreakBondingCurveAddressSync, getWavebreakQuoteVaultAddressSync, getWavebreakLpEscrowAddressSync, getWavebreakBondingCurveInfo, getWavebreakBuyQuote, getWavebreakSellQuote, signWavebreakBuy, signWavebreakSell, signWavebreakCreateLaunch, buildWavebreakBuyInstruction, buildWavebreakSellInstruction, buildWavebreakCreateLaunchInstruction, toWavebreakApiRequest, } from './wavebreak.js';
10
- export { signWavebreakBundleBuy, signWavebreakBundleSell, signWavebreakBundleCreateAndBuy, toWavebreakBundleApiRequest, } from './wavebreak-bundle.js';
@@ -1,16 +0,0 @@
1
- /**
2
- * Orca 模块导出
3
- * 包含 Whirlpool (流动性池) 和 Wavebreak (代币发射平台)
4
- */
5
- // ===== Whirlpool 类型 =====
6
- export * from './types.js';
7
- // ===== Whirlpool 核心功能 =====
8
- export { createOrcaContext, createOrcaClient, getOrcaPoolInfo, findOrcaPool, signOrcaSwap, signOrcaAddLiquidity, signOrcaRemoveLiquidity, signOrcaCreatePool, signOrcaCollectFees, getOrcaPositionInfo, getFullRangeTickIndices, getTickIndicesFromPriceRange, } from './orca.js';
9
- // ===== Whirlpool Bundle 批量交易 =====
10
- export { signOrcaBundleBuy, signOrcaBundleSell, signOrcaBundleSwap, toOrcaBundleApiRequest, batchGetOrcaPoolInfo, } from './orca-bundle.js';
11
- // ===== Wavebreak 类型 =====
12
- export * from './wavebreak-types.js';
13
- // ===== Wavebreak 核心功能 =====
14
- export { getWavebreakBondingCurveAddress, getWavebreakBondingCurveAddressSync, getWavebreakQuoteVaultAddressSync, getWavebreakLpEscrowAddressSync, getWavebreakBondingCurveInfo, getWavebreakBuyQuote, getWavebreakSellQuote, signWavebreakBuy, signWavebreakSell, signWavebreakCreateLaunch, buildWavebreakBuyInstruction, buildWavebreakSellInstruction, buildWavebreakCreateLaunchInstruction, toWavebreakApiRequest, } from './wavebreak.js';
15
- // ===== Wavebreak Bundle 批量交易 =====
16
- export { signWavebreakBundleBuy, signWavebreakBundleSell, signWavebreakBundleCreateAndBuy, toWavebreakBundleApiRequest, } from './wavebreak-bundle.js';
@@ -1,41 +0,0 @@
1
- /**
2
- * Orca Whirlpool Jito Bundle 批量交易
3
- * 支持批量买卖的原子性交易
4
- */
5
- import { Connection } from '@solana/web3.js';
6
- import type { OrcaBundleSwapParams, OrcaBundleSignedResult } from './types.js';
7
- /**
8
- * 签名 Orca Bundle 批量买入交易
9
- * 多个钱包同时买入同一个代币
10
- */
11
- export declare function signOrcaBundleBuy(params: OrcaBundleSwapParams, connection?: Connection): Promise<OrcaBundleSignedResult>;
12
- /**
13
- * 签名 Orca Bundle 批量卖出交易
14
- * 多个钱包同时卖出同一个代币
15
- */
16
- export declare function signOrcaBundleSell(params: OrcaBundleSwapParams, connection?: Connection): Promise<OrcaBundleSignedResult>;
17
- /**
18
- * 签名 Orca Bundle 批量 Swap 交易 (通用)
19
- * 支持买入和卖出
20
- */
21
- export declare function signOrcaBundleSwap(params: OrcaBundleSwapParams, connection?: Connection): Promise<OrcaBundleSignedResult>;
22
- /**
23
- * 将 Orca Bundle 结果转换为后端 API 请求格式
24
- */
25
- export declare function toOrcaBundleApiRequest(result: OrcaBundleSignedResult): {
26
- transactions: string[];
27
- metadata: {
28
- type: string;
29
- poolAddress: string;
30
- tradeCount: number;
31
- jitoTipLamports: number;
32
- };
33
- };
34
- /**
35
- * 批量获取多个池的信息
36
- */
37
- export declare function batchGetOrcaPoolInfo(poolAddresses: string[], connection?: Connection): Promise<Map<string, {
38
- tokenMintA: string;
39
- tokenMintB: string;
40
- tickSpacing: number;
41
- }>>;
@@ -1,140 +0,0 @@
1
- /**
2
- * Orca Whirlpool Jito Bundle 批量交易
3
- * 支持批量买卖的原子性交易
4
- */
5
- import { PublicKey, Keypair, Transaction, ComputeBudgetProgram, } from '@solana/web3.js';
6
- import { WhirlpoolContext, buildWhirlpoolClient, ORCA_WHIRLPOOL_PROGRAM_ID, swapQuoteByInputToken, TokenExtensionUtil, } from '@orca-so/whirlpools-sdk';
7
- import { Percentage } from '@orca-so/common-sdk';
8
- import { Wallet } from '@coral-xyz/anchor';
9
- import { createConnection } from '../../utils/connection.js';
10
- import { buildTipInstruction, getRandomTipAccount } from '../../jito/tip.js';
11
- /**
12
- * 默认 Jito 小费 (0.001 SOL)
13
- */
14
- const DEFAULT_JITO_TIP_LAMPORTS = 1000000;
15
- /**
16
- * 签名 Orca Bundle 批量买入交易
17
- * 多个钱包同时买入同一个代币
18
- */
19
- export async function signOrcaBundleBuy(params, connection) {
20
- return signOrcaBundleSwap(params, connection);
21
- }
22
- /**
23
- * 签名 Orca Bundle 批量卖出交易
24
- * 多个钱包同时卖出同一个代币
25
- */
26
- export async function signOrcaBundleSell(params, connection) {
27
- return signOrcaBundleSwap(params, connection);
28
- }
29
- /**
30
- * 签名 Orca Bundle 批量 Swap 交易 (通用)
31
- * 支持买入和卖出
32
- */
33
- export async function signOrcaBundleSwap(params, connection) {
34
- const conn = connection || createConnection();
35
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
36
- const signedTransactions = [];
37
- const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
38
- // 预加载池信息 (只加载一次)
39
- const firstWallet = params.trades[0].wallet;
40
- const ctx = WhirlpoolContext.from(conn, new Wallet(firstWallet));
41
- const client = buildWhirlpoolClient(ctx);
42
- const pool = await client.getPool(params.poolAddress);
43
- const tokenInfoA = pool.getTokenAInfo();
44
- const tokenInfoB = pool.getTokenBInfo();
45
- // 获取 token extension context
46
- const tokenExtensionCtx = await TokenExtensionUtil.buildTokenExtensionContextForPool(ctx.fetcher, tokenInfoA.mint, tokenInfoB.mint);
47
- // 为每个交易创建签名
48
- for (let i = 0; i < params.trades.length; i++) {
49
- const trade = params.trades[i];
50
- const isLastTrade = i === params.trades.length - 1;
51
- // 创建该钱包的 context
52
- const walletCtx = WhirlpoolContext.from(conn, new Wallet(trade.wallet));
53
- const walletClient = buildWhirlpoolClient(walletCtx);
54
- const walletPool = await walletClient.getPool(params.poolAddress);
55
- // 获取报价
56
- const slippage = Percentage.fromFraction(100, 10000); // 1% 滑点
57
- const quote = await swapQuoteByInputToken(walletPool, new PublicKey(params.inputMint), trade.amountIn, slippage, ORCA_WHIRLPOOL_PROGRAM_ID, walletCtx.fetcher);
58
- // 构建交易
59
- const tx = new Transaction();
60
- // 添加计算预算指令
61
- tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 400000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
62
- // 获取 swap 交易
63
- const swapTxBuilder = await walletPool.swap(quote, trade.wallet.publicKey);
64
- const swapTx = await swapTxBuilder.build();
65
- // 提取指令
66
- if ('instructions' in swapTx.transaction) {
67
- const swapTransaction = swapTx.transaction;
68
- tx.add(...swapTransaction.instructions);
69
- }
70
- else {
71
- throw new Error('VersionedTransaction not supported in bundle mode');
72
- }
73
- // 最后一笔交易添加 Jito 小费
74
- if (isLastTrade) {
75
- const tipAccount = getRandomTipAccount();
76
- const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
77
- tx.add(tipIx);
78
- }
79
- // 设置交易参数
80
- tx.recentBlockhash = blockhash;
81
- tx.lastValidBlockHeight = lastValidBlockHeight;
82
- tx.feePayer = trade.wallet.publicKey;
83
- // 签名
84
- tx.sign(trade.wallet, ...swapTx.signers);
85
- signedTransactions.push(tx);
86
- }
87
- return {
88
- signedTransactions,
89
- type: 'bundleSwap',
90
- poolAddress: params.poolAddress,
91
- tradeCount: params.trades.length,
92
- jitoTipLamports,
93
- };
94
- }
95
- /**
96
- * 将 Orca Bundle 结果转换为后端 API 请求格式
97
- */
98
- export function toOrcaBundleApiRequest(result) {
99
- const transactions = result.signedTransactions.map(tx => {
100
- if (tx instanceof Transaction) {
101
- return Buffer.from(tx.serialize()).toString('base64');
102
- }
103
- // VersionedTransaction
104
- return Buffer.from(tx.serialize()).toString('base64');
105
- });
106
- return {
107
- transactions,
108
- metadata: {
109
- type: result.type,
110
- poolAddress: result.poolAddress,
111
- tradeCount: result.tradeCount,
112
- jitoTipLamports: result.jitoTipLamports,
113
- },
114
- };
115
- }
116
- /**
117
- * 批量获取多个池的信息
118
- */
119
- export async function batchGetOrcaPoolInfo(poolAddresses, connection) {
120
- const conn = connection || createConnection();
121
- const result = new Map();
122
- // 创建一个临时钱包用于查询
123
- const tempWallet = Keypair.generate();
124
- const ctx = WhirlpoolContext.from(conn, new Wallet(tempWallet));
125
- const client = buildWhirlpoolClient(ctx);
126
- // 批量获取池信息
127
- const pools = await client.getPools(poolAddresses);
128
- for (const pool of pools) {
129
- const address = pool.getAddress().toBase58();
130
- const tokenInfoA = pool.getTokenAInfo();
131
- const tokenInfoB = pool.getTokenBInfo();
132
- const data = pool.getData();
133
- result.set(address, {
134
- tokenMintA: tokenInfoA.mint.toBase58(),
135
- tokenMintB: tokenInfoB.mint.toBase58(),
136
- tickSpacing: data.tickSpacing,
137
- });
138
- }
139
- return result;
140
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * Orca Whirlpool 核心功能
3
- * 提供 Swap、LP 添加/移除等功能
4
- *
5
- * 基于 @orca-so/whirlpools-sdk (Legacy SDK)
6
- * 文档: https://dev.orca.so/SDKs/Overview
7
- */
8
- import { Connection, Keypair } from '@solana/web3.js';
9
- import { WhirlpoolContext, type WhirlpoolClient } from '@orca-so/whirlpools-sdk';
10
- import type { OrcaPoolInfo, OrcaSwapParams, OrcaAddLiquidityParams, OrcaRemoveLiquidityParams, OrcaPositionInfo, OrcaCreatePoolParams, OrcaSignedResult } from './types.js';
11
- /**
12
- * 创建 Orca Whirlpool Context
13
- */
14
- export declare function createOrcaContext(connection?: Connection, wallet?: Keypair): Promise<WhirlpoolContext>;
15
- /**
16
- * 创建 Orca Whirlpool Client
17
- */
18
- export declare function createOrcaClient(connection?: Connection, wallet?: Keypair): Promise<WhirlpoolClient>;
19
- /**
20
- * 获取 Orca Whirlpool 池信息
21
- */
22
- export declare function getOrcaPoolInfo(poolAddress: string, connection?: Connection): Promise<OrcaPoolInfo>;
23
- /**
24
- * 查找 Orca Whirlpool 池
25
- */
26
- export declare function findOrcaPool(tokenMintA: string, tokenMintB: string, tickSpacing?: number, connection?: Connection): Promise<string | null>;
27
- /**
28
- * 签名 Orca Swap 交易
29
- * 使用 Whirlpool 的高级 swap 接口
30
- */
31
- export declare function signOrcaSwap(params: OrcaSwapParams, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
32
- /**
33
- * 签名 Orca 添加流动性交易
34
- */
35
- export declare function signOrcaAddLiquidity(params: OrcaAddLiquidityParams, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
36
- /**
37
- * 签名 Orca 移除流动性交易
38
- */
39
- export declare function signOrcaRemoveLiquidity(params: OrcaRemoveLiquidityParams, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
40
- /**
41
- * 签名创建 Orca Whirlpool 池交易
42
- */
43
- export declare function signOrcaCreatePool(params: OrcaCreatePoolParams, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
44
- /**
45
- * 签名收集费用交易
46
- */
47
- export declare function signOrcaCollectFees(positionAddress: string, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
48
- /**
49
- * 获取 Position 信息
50
- */
51
- export declare function getOrcaPositionInfo(positionAddress: string, connection?: Connection): Promise<OrcaPositionInfo>;
52
- /**
53
- * 计算全范围流动性的 tick 范围
54
- */
55
- export declare function getFullRangeTickIndices(tickSpacing: number): {
56
- tickLower: number;
57
- tickUpper: number;
58
- };
59
- /**
60
- * 根据价格范围计算 tick 范围
61
- */
62
- export declare function getTickIndicesFromPriceRange(priceLower: number, priceUpper: number, decimalsA: number, decimalsB: number, tickSpacing: number): {
63
- tickLower: number;
64
- tickUpper: number;
65
- };