four-flap-meme-sdk 1.3.91 → 1.3.93

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 (127) hide show
  1. package/dist/clients/blockrazor.js +0 -1
  2. package/dist/contracts/tm-bundle-merkle/config.d.ts +5 -0
  3. package/dist/contracts/tm-bundle-merkle/config.js +10 -0
  4. package/dist/contracts/tm-bundle-merkle/core.js +92 -24
  5. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +103 -54
  6. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +0 -1
  7. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +36 -6
  8. package/dist/contracts/tm-bundle-merkle/swap.d.ts +0 -3
  9. package/dist/contracts/tm-bundle-merkle/swap.js +59 -6
  10. package/dist/flap/portal-bundle-merkle/config.d.ts +8 -0
  11. package/dist/flap/portal-bundle-merkle/config.js +17 -0
  12. package/dist/flap/portal-bundle-merkle/core.js +120 -68
  13. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  14. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  15. package/dist/flap/portal-bundle-merkle/pancake-proxy.js +136 -78
  16. package/dist/flap/portal-bundle-merkle/swap-buy-first.d.ts +0 -2
  17. package/dist/flap/portal-bundle-merkle/swap-buy-first.js +49 -30
  18. package/dist/flap/portal-bundle-merkle/swap.d.ts +0 -2
  19. package/dist/flap/portal-bundle-merkle/swap.js +75 -47
  20. package/dist/flap/portal-bundle-merkle/types.d.ts +1 -0
  21. package/dist/index.d.ts +1 -2
  22. package/dist/index.js +0 -1
  23. package/dist/pancake/bundle-buy-first.d.ts +1 -1
  24. package/dist/pancake/bundle-buy-first.js +49 -17
  25. package/dist/pancake/bundle-swap.d.ts +1 -4
  26. package/dist/pancake/bundle-swap.js +98 -33
  27. package/dist/utils/erc20.d.ts +108 -2
  28. package/dist/utils/erc20.js +65 -17
  29. package/package.json +4 -39
  30. package/dist/sol/constants.d.ts +0 -126
  31. package/dist/sol/constants.js +0 -145
  32. package/dist/sol/dex/index.d.ts +0 -8
  33. package/dist/sol/dex/index.js +0 -12
  34. package/dist/sol/dex/meteora/client.d.ts +0 -76
  35. package/dist/sol/dex/meteora/client.js +0 -219
  36. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  37. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  38. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  39. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  40. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  41. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  42. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  43. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  44. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  45. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  46. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  47. package/dist/sol/dex/meteora/dbc.js +0 -619
  48. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  49. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  50. package/dist/sol/dex/meteora/dlmm.d.ts +0 -146
  51. package/dist/sol/dex/meteora/dlmm.js +0 -593
  52. package/dist/sol/dex/meteora/index.d.ts +0 -25
  53. package/dist/sol/dex/meteora/index.js +0 -65
  54. package/dist/sol/dex/meteora/types.d.ts +0 -787
  55. package/dist/sol/dex/meteora/types.js +0 -110
  56. package/dist/sol/dex/orca/index.d.ts +0 -10
  57. package/dist/sol/dex/orca/index.js +0 -16
  58. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  59. package/dist/sol/dex/orca/orca-bundle.js +0 -173
  60. package/dist/sol/dex/orca/orca.d.ts +0 -65
  61. package/dist/sol/dex/orca/orca.js +0 -474
  62. package/dist/sol/dex/orca/types.d.ts +0 -263
  63. package/dist/sol/dex/orca/types.js +0 -38
  64. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  65. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
  66. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  67. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  68. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  69. package/dist/sol/dex/orca/wavebreak.js +0 -497
  70. package/dist/sol/dex/pump/index.d.ts +0 -9
  71. package/dist/sol/dex/pump/index.js +0 -14
  72. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  73. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  74. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  75. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  76. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  77. package/dist/sol/dex/pump/pump-swap.js +0 -199
  78. package/dist/sol/dex/pump/pump.d.ts +0 -35
  79. package/dist/sol/dex/pump/pump.js +0 -352
  80. package/dist/sol/dex/pump/types.d.ts +0 -215
  81. package/dist/sol/dex/pump/types.js +0 -5
  82. package/dist/sol/dex/raydium/index.d.ts +0 -8
  83. package/dist/sol/dex/raydium/index.js +0 -12
  84. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  85. package/dist/sol/dex/raydium/launchlab.js +0 -210
  86. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  87. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  88. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  89. package/dist/sol/dex/raydium/raydium.js +0 -366
  90. package/dist/sol/dex/raydium/types.d.ts +0 -240
  91. package/dist/sol/dex/raydium/types.js +0 -5
  92. package/dist/sol/index.d.ts +0 -10
  93. package/dist/sol/index.js +0 -16
  94. package/dist/sol/jito/bundle.d.ts +0 -90
  95. package/dist/sol/jito/bundle.js +0 -263
  96. package/dist/sol/jito/index.d.ts +0 -7
  97. package/dist/sol/jito/index.js +0 -7
  98. package/dist/sol/jito/tip.d.ts +0 -51
  99. package/dist/sol/jito/tip.js +0 -83
  100. package/dist/sol/jito/types.d.ts +0 -100
  101. package/dist/sol/jito/types.js +0 -5
  102. package/dist/sol/token/create-complete.d.ts +0 -115
  103. package/dist/sol/token/create-complete.js +0 -235
  104. package/dist/sol/token/create-token.d.ts +0 -57
  105. package/dist/sol/token/create-token.js +0 -230
  106. package/dist/sol/token/index.d.ts +0 -9
  107. package/dist/sol/token/index.js +0 -14
  108. package/dist/sol/token/metadata-upload.d.ts +0 -86
  109. package/dist/sol/token/metadata-upload.js +0 -173
  110. package/dist/sol/token/metadata.d.ts +0 -92
  111. package/dist/sol/token/metadata.js +0 -274
  112. package/dist/sol/token/types.d.ts +0 -153
  113. package/dist/sol/token/types.js +0 -5
  114. package/dist/sol/types.d.ts +0 -176
  115. package/dist/sol/types.js +0 -7
  116. package/dist/sol/utils/balance.d.ts +0 -160
  117. package/dist/sol/utils/balance.js +0 -638
  118. package/dist/sol/utils/connection.d.ts +0 -78
  119. package/dist/sol/utils/connection.js +0 -168
  120. package/dist/sol/utils/index.d.ts +0 -9
  121. package/dist/sol/utils/index.js +0 -9
  122. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  123. package/dist/sol/utils/lp-inspect.js +0 -529
  124. package/dist/sol/utils/transfer.d.ts +0 -125
  125. package/dist/sol/utils/transfer.js +0 -220
  126. package/dist/sol/utils/wallet.d.ts +0 -107
  127. 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,173 +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
- /**
9
- * 从 Keypair 创建 Wallet 适配器(兼容浏览器环境)
10
- */
11
- function createWalletFromKeypair(keypair) {
12
- return {
13
- publicKey: keypair.publicKey,
14
- signTransaction: async (tx) => {
15
- if (tx instanceof Transaction) {
16
- tx.partialSign(keypair);
17
- }
18
- else {
19
- tx.sign([keypair]);
20
- }
21
- return tx;
22
- },
23
- signAllTransactions: async (txs) => {
24
- for (const tx of txs) {
25
- if (tx instanceof Transaction) {
26
- tx.partialSign(keypair);
27
- }
28
- else {
29
- tx.sign([keypair]);
30
- }
31
- }
32
- return txs;
33
- },
34
- };
35
- }
36
- // 不再导入 createConnection,强制使用者传入连接
37
- import { buildTipInstruction, getRandomTipAccount } from '../../jito/tip.js';
38
- /**
39
- * 默认 Jito 小费 (0.001 SOL)
40
- */
41
- const DEFAULT_JITO_TIP_LAMPORTS = 1000000;
42
- /**
43
- * 签名 Orca Bundle 批量买入交易
44
- * 多个钱包同时买入同一个代币
45
- */
46
- export async function signOrcaBundleBuy(params, connection) {
47
- return signOrcaBundleSwap(params, connection);
48
- }
49
- /**
50
- * 签名 Orca Bundle 批量卖出交易
51
- * 多个钱包同时卖出同一个代币
52
- */
53
- export async function signOrcaBundleSell(params, connection) {
54
- return signOrcaBundleSwap(params, connection);
55
- }
56
- /**
57
- * 签名 Orca Bundle 批量 Swap 交易 (通用)
58
- * 支持买入和卖出
59
- */
60
- export async function signOrcaBundleSwap(params, connection) {
61
- if (!connection) {
62
- throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
63
- }
64
- const conn = connection;
65
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
66
- const signedTransactions = [];
67
- const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
68
- // 预加载池信息 (只加载一次)
69
- const firstWallet = params.trades[0].wallet;
70
- const ctx = WhirlpoolContext.from(conn, createWalletFromKeypair(firstWallet));
71
- const client = buildWhirlpoolClient(ctx);
72
- const pool = await client.getPool(params.poolAddress);
73
- const tokenInfoA = pool.getTokenAInfo();
74
- const tokenInfoB = pool.getTokenBInfo();
75
- // 获取 token extension context
76
- const tokenExtensionCtx = await TokenExtensionUtil.buildTokenExtensionContextForPool(ctx.fetcher, tokenInfoA.mint, tokenInfoB.mint);
77
- // 为每个交易创建签名
78
- for (let i = 0; i < params.trades.length; i++) {
79
- const trade = params.trades[i];
80
- const isLastTrade = i === params.trades.length - 1;
81
- // 创建该钱包的 context
82
- const walletCtx = WhirlpoolContext.from(conn, createWalletFromKeypair(trade.wallet));
83
- const walletClient = buildWhirlpoolClient(walletCtx);
84
- const walletPool = await walletClient.getPool(params.poolAddress);
85
- // 获取报价
86
- const slippage = Percentage.fromFraction(100, 10000); // 1% 滑点
87
- const quote = await swapQuoteByInputToken(walletPool, new PublicKey(params.inputMint), trade.amountIn, slippage, ORCA_WHIRLPOOL_PROGRAM_ID, walletCtx.fetcher);
88
- // 构建交易
89
- const tx = new Transaction();
90
- // 添加计算预算指令
91
- tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 400000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
92
- // 获取 swap 交易
93
- const swapTxBuilder = await walletPool.swap(quote, trade.wallet.publicKey);
94
- const swapTx = await swapTxBuilder.build();
95
- // 提取指令
96
- if ('instructions' in swapTx.transaction) {
97
- const swapTransaction = swapTx.transaction;
98
- tx.add(...swapTransaction.instructions);
99
- }
100
- else {
101
- throw new Error('VersionedTransaction not supported in bundle mode');
102
- }
103
- // 最后一笔交易添加 Jito 小费
104
- if (isLastTrade) {
105
- const tipAccount = getRandomTipAccount();
106
- const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
107
- tx.add(tipIx);
108
- }
109
- // 设置交易参数
110
- tx.recentBlockhash = blockhash;
111
- tx.lastValidBlockHeight = lastValidBlockHeight;
112
- tx.feePayer = trade.wallet.publicKey;
113
- // 签名
114
- tx.sign(trade.wallet, ...swapTx.signers);
115
- signedTransactions.push(tx);
116
- }
117
- return {
118
- signedTransactions,
119
- type: 'bundleSwap',
120
- poolAddress: params.poolAddress,
121
- tradeCount: params.trades.length,
122
- jitoTipLamports,
123
- };
124
- }
125
- /**
126
- * 将 Orca Bundle 结果转换为后端 API 请求格式
127
- */
128
- export function toOrcaBundleApiRequest(result) {
129
- const transactions = result.signedTransactions.map(tx => {
130
- if (tx instanceof Transaction) {
131
- return Buffer.from(tx.serialize()).toString('base64');
132
- }
133
- // VersionedTransaction
134
- return Buffer.from(tx.serialize()).toString('base64');
135
- });
136
- return {
137
- transactions,
138
- metadata: {
139
- type: result.type,
140
- poolAddress: result.poolAddress,
141
- tradeCount: result.tradeCount,
142
- jitoTipLamports: result.jitoTipLamports,
143
- },
144
- };
145
- }
146
- /**
147
- * 批量获取多个池的信息
148
- */
149
- export async function batchGetOrcaPoolInfo(poolAddresses, connection) {
150
- if (!connection) {
151
- throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
152
- }
153
- const conn = connection;
154
- const result = new Map();
155
- // 创建一个临时钱包用于查询
156
- const tempWallet = Keypair.generate();
157
- const ctx = WhirlpoolContext.from(conn, createWalletFromKeypair(tempWallet));
158
- const client = buildWhirlpoolClient(ctx);
159
- // 批量获取池信息
160
- const pools = await client.getPools(poolAddresses);
161
- for (const pool of pools) {
162
- const address = pool.getAddress().toBase58();
163
- const tokenInfoA = pool.getTokenAInfo();
164
- const tokenInfoB = pool.getTokenBInfo();
165
- const data = pool.getData();
166
- result.set(address, {
167
- tokenMintA: tokenInfoA.mint.toBase58(),
168
- tokenMintB: tokenInfoB.mint.toBase58(),
169
- tickSpacing: data.tickSpacing,
170
- });
171
- }
172
- return result;
173
- }
@@ -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
- };