four-flap-meme-sdk 1.4.89 → 1.4.91

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 (144) hide show
  1. package/README.zh-CN.pdf +0 -0
  2. package/dist/flap/portal-bundle-merkle/create-to-dex.d.ts +1 -1
  3. package/dist/flap/portal-bundle-merkle/create-to-dex.js +51 -13
  4. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  5. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  6. package/dist/utils/holders-maker.d.ts +19 -0
  7. package/dist/utils/holders-maker.js +4 -1
  8. package/package.json +3 -38
  9. package/dist/sol/constants.d.ts +0 -126
  10. package/dist/sol/constants.js +0 -145
  11. package/dist/sol/dex/blockrazor/client.d.ts +0 -51
  12. package/dist/sol/dex/blockrazor/client.js +0 -96
  13. package/dist/sol/dex/blockrazor/constants.d.ts +0 -34
  14. package/dist/sol/dex/blockrazor/constants.js +0 -55
  15. package/dist/sol/dex/blockrazor/geyser.d.ts +0 -128
  16. package/dist/sol/dex/blockrazor/geyser.js +0 -530
  17. package/dist/sol/dex/blockrazor/index.d.ts +0 -18
  18. package/dist/sol/dex/blockrazor/index.js +0 -23
  19. package/dist/sol/dex/blockrazor/send.d.ts +0 -135
  20. package/dist/sol/dex/blockrazor/send.js +0 -254
  21. package/dist/sol/dex/blockrazor/types.d.ts +0 -191
  22. package/dist/sol/dex/blockrazor/types.js +0 -5
  23. package/dist/sol/dex/index.d.ts +0 -10
  24. package/dist/sol/dex/index.js +0 -16
  25. package/dist/sol/dex/jup/client.d.ts +0 -33
  26. package/dist/sol/dex/jup/client.js +0 -110
  27. package/dist/sol/dex/jup/index.d.ts +0 -16
  28. package/dist/sol/dex/jup/index.js +0 -148
  29. package/dist/sol/dex/jup/legacy.d.ts +0 -623
  30. package/dist/sol/dex/jup/legacy.js +0 -416
  31. package/dist/sol/dex/jup/lend.d.ts +0 -640
  32. package/dist/sol/dex/jup/lend.js +0 -603
  33. package/dist/sol/dex/jup/portfolio.d.ts +0 -362
  34. package/dist/sol/dex/jup/portfolio.js +0 -367
  35. package/dist/sol/dex/jup/price.d.ts +0 -173
  36. package/dist/sol/dex/jup/price.js +0 -220
  37. package/dist/sol/dex/jup/recurring.d.ts +0 -437
  38. package/dist/sol/dex/jup/recurring.js +0 -320
  39. package/dist/sol/dex/jup/send.d.ts +0 -282
  40. package/dist/sol/dex/jup/send.js +0 -295
  41. package/dist/sol/dex/jup/studio.d.ts +0 -457
  42. package/dist/sol/dex/jup/studio.js +0 -488
  43. package/dist/sol/dex/jup/tokens.d.ts +0 -767
  44. package/dist/sol/dex/jup/tokens.js +0 -697
  45. package/dist/sol/dex/jup/trigger.d.ts +0 -511
  46. package/dist/sol/dex/jup/trigger.js +0 -397
  47. package/dist/sol/dex/jup/types.d.ts +0 -433
  48. package/dist/sol/dex/jup/types.js +0 -5
  49. package/dist/sol/dex/jup/ultra.d.ts +0 -646
  50. package/dist/sol/dex/jup/ultra.js +0 -853
  51. package/dist/sol/dex/meteora/client.d.ts +0 -76
  52. package/dist/sol/dex/meteora/client.js +0 -219
  53. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  54. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  55. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  56. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  57. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  58. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  59. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  60. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  61. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  62. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  63. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  64. package/dist/sol/dex/meteora/dbc.js +0 -619
  65. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  66. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  67. package/dist/sol/dex/meteora/dlmm.d.ts +0 -157
  68. package/dist/sol/dex/meteora/dlmm.js +0 -671
  69. package/dist/sol/dex/meteora/index.d.ts +0 -25
  70. package/dist/sol/dex/meteora/index.js +0 -65
  71. package/dist/sol/dex/meteora/types.d.ts +0 -787
  72. package/dist/sol/dex/meteora/types.js +0 -110
  73. package/dist/sol/dex/orca/index.d.ts +0 -10
  74. package/dist/sol/dex/orca/index.js +0 -16
  75. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  76. package/dist/sol/dex/orca/orca-bundle.js +0 -173
  77. package/dist/sol/dex/orca/orca.d.ts +0 -65
  78. package/dist/sol/dex/orca/orca.js +0 -474
  79. package/dist/sol/dex/orca/types.d.ts +0 -263
  80. package/dist/sol/dex/orca/types.js +0 -38
  81. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  82. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
  83. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  84. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  85. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  86. package/dist/sol/dex/orca/wavebreak.js +0 -497
  87. package/dist/sol/dex/pump/index.d.ts +0 -9
  88. package/dist/sol/dex/pump/index.js +0 -14
  89. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  90. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  91. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  92. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  93. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  94. package/dist/sol/dex/pump/pump-swap.js +0 -199
  95. package/dist/sol/dex/pump/pump.d.ts +0 -35
  96. package/dist/sol/dex/pump/pump.js +0 -352
  97. package/dist/sol/dex/pump/types.d.ts +0 -215
  98. package/dist/sol/dex/pump/types.js +0 -5
  99. package/dist/sol/dex/raydium/index.d.ts +0 -8
  100. package/dist/sol/dex/raydium/index.js +0 -12
  101. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  102. package/dist/sol/dex/raydium/launchlab.js +0 -210
  103. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  104. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  105. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  106. package/dist/sol/dex/raydium/raydium.js +0 -366
  107. package/dist/sol/dex/raydium/types.d.ts +0 -240
  108. package/dist/sol/dex/raydium/types.js +0 -5
  109. package/dist/sol/index.d.ts +0 -10
  110. package/dist/sol/index.js +0 -16
  111. package/dist/sol/jito/bundle.d.ts +0 -90
  112. package/dist/sol/jito/bundle.js +0 -263
  113. package/dist/sol/jito/index.d.ts +0 -7
  114. package/dist/sol/jito/index.js +0 -7
  115. package/dist/sol/jito/tip.d.ts +0 -51
  116. package/dist/sol/jito/tip.js +0 -83
  117. package/dist/sol/jito/types.d.ts +0 -100
  118. package/dist/sol/jito/types.js +0 -5
  119. package/dist/sol/token/create-complete.d.ts +0 -115
  120. package/dist/sol/token/create-complete.js +0 -235
  121. package/dist/sol/token/create-token.d.ts +0 -57
  122. package/dist/sol/token/create-token.js +0 -230
  123. package/dist/sol/token/index.d.ts +0 -9
  124. package/dist/sol/token/index.js +0 -14
  125. package/dist/sol/token/metadata-upload.d.ts +0 -86
  126. package/dist/sol/token/metadata-upload.js +0 -173
  127. package/dist/sol/token/metadata.d.ts +0 -92
  128. package/dist/sol/token/metadata.js +0 -274
  129. package/dist/sol/token/types.d.ts +0 -153
  130. package/dist/sol/token/types.js +0 -5
  131. package/dist/sol/types.d.ts +0 -176
  132. package/dist/sol/types.js +0 -7
  133. package/dist/sol/utils/balance.d.ts +0 -160
  134. package/dist/sol/utils/balance.js +0 -638
  135. package/dist/sol/utils/connection.d.ts +0 -78
  136. package/dist/sol/utils/connection.js +0 -168
  137. package/dist/sol/utils/index.d.ts +0 -9
  138. package/dist/sol/utils/index.js +0 -9
  139. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  140. package/dist/sol/utils/lp-inspect.js +0 -900
  141. package/dist/sol/utils/transfer.d.ts +0 -125
  142. package/dist/sol/utils/transfer.js +0 -220
  143. package/dist/sol/utils/wallet.d.ts +0 -107
  144. package/dist/sol/utils/wallet.js +0 -210
@@ -1,76 +0,0 @@
1
- /**
2
- * Meteora SDK 客户端管理器
3
- *
4
- * 统一管理 RPC 连接和 SDK 实例,避免重复实例化
5
- */
6
- import { Connection } from '@solana/web3.js';
7
- import { CpAmm } from '@meteora-ag/cp-amm-sdk';
8
- import { DynamicBondingCurveClient } from '@meteora-ag/dynamic-bonding-curve-sdk';
9
- /**
10
- * 获取连接
11
- * @param connection 可选的自定义连接
12
- * @throws Error 如果没有传入连接且未设置默认连接
13
- */
14
- export declare function getConnection(connection?: Connection): Connection;
15
- /**
16
- * 设置默认连接
17
- * @param connection 新的连接实例
18
- */
19
- export declare function setDefaultConnection(connection: Connection): void;
20
- /**
21
- * 重置默认连接
22
- */
23
- export declare function resetDefaultConnection(): void;
24
- /**
25
- * 获取或创建 DLMM 池实例
26
- * @param poolAddress 池地址
27
- * @param connection 可选连接
28
- * @param forceRefresh 强制刷新缓存
29
- */
30
- export declare function getDlmmPool(poolAddress: string, connection?: Connection, forceRefresh?: boolean): Promise<any>;
31
- /**
32
- * 获取所有 DLMM 池列表
33
- * @param connection 可选连接
34
- */
35
- export declare function getAllDlmmPools(connection?: Connection): Promise<any[]>;
36
- /**
37
- * 清除 DLMM 池缓存
38
- * @param poolAddress 可选,指定池地址;不传则清除全部
39
- */
40
- export declare function clearDlmmCache(poolAddress?: string): void;
41
- /**
42
- * 获取或创建 DBC 客户端
43
- * @param connection 可选连接
44
- */
45
- export declare function getDbcClient(connection?: Connection): DynamicBondingCurveClient;
46
- /**
47
- * 重置 DBC 客户端
48
- */
49
- export declare function resetDbcClient(): void;
50
- /**
51
- * 获取或创建 DAMM v1 池实例
52
- * @param poolAddress 池地址
53
- * @param connection 可选连接
54
- * @param forceRefresh 强制刷新缓存
55
- */
56
- export declare function getDammV1Pool(poolAddress: string, connection?: Connection, forceRefresh?: boolean): Promise<any>;
57
- /**
58
- * 清除 DAMM v1 池缓存
59
- * @param poolAddress 可选,指定池地址;不传则清除全部
60
- */
61
- export declare function clearDammV1Cache(poolAddress?: string): void;
62
- /**
63
- * 获取或创建 DAMM v2 (CpAmm) 客户端
64
- * @param connection 可选连接
65
- */
66
- export declare function getCpAmmClient(connection?: Connection): CpAmm;
67
- /**
68
- * 重置 DAMM v2 客户端
69
- */
70
- export declare function resetCpAmmClient(): void;
71
- /**
72
- * 清除所有 Meteora 缓存
73
- */
74
- export declare function clearAllMeteoraCache(): void;
75
- export declare function setCacheTtl(ttlMs: number): void;
76
- export declare function getCacheTtl(): number;
@@ -1,219 +0,0 @@
1
- /**
2
- * Meteora SDK 客户端管理器
3
- *
4
- * 统一管理 RPC 连接和 SDK 实例,避免重复实例化
5
- */
6
- import { PublicKey } from '@solana/web3.js';
7
- // 不再导入 createConnection,强制使用者传入连接
8
- // SDK 导入 - 使用类型断言绕过 TypeScript 类型检查
9
- import DLMMModule from '@meteora-ag/dlmm';
10
- import AmmImplModule from '@meteora-ag/dynamic-amm-sdk';
11
- import { CpAmm } from '@meteora-ag/cp-amm-sdk';
12
- import { DynamicBondingCurveClient } from '@meteora-ag/dynamic-bonding-curve-sdk';
13
- const DLMM = DLMMModule;
14
- const AmmImpl = AmmImplModule;
15
- // ============================================================================
16
- // 连接管理
17
- // ============================================================================
18
- /** 默认连接实例(必须通过 setDefaultConnection 设置) */
19
- let defaultConnection = null;
20
- /**
21
- * 获取连接
22
- * @param connection 可选的自定义连接
23
- * @throws Error 如果没有传入连接且未设置默认连接
24
- */
25
- export function getConnection(connection) {
26
- if (connection) {
27
- return connection;
28
- }
29
- if (!defaultConnection) {
30
- throw new Error('Connection is required. Either pass a connection parameter or call setDefaultConnection() first with user-configured RPC.');
31
- }
32
- return defaultConnection;
33
- }
34
- /**
35
- * 设置默认连接
36
- * @param connection 新的连接实例
37
- */
38
- export function setDefaultConnection(connection) {
39
- defaultConnection = connection;
40
- }
41
- /**
42
- * 重置默认连接
43
- */
44
- export function resetDefaultConnection() {
45
- defaultConnection = null;
46
- }
47
- // ============================================================================
48
- // DLMM 实例缓存
49
- // ============================================================================
50
- /** DLMM 池实例缓存 */
51
- const dlmmPoolCache = new Map();
52
- /** 缓存过期时间 (毫秒) - 默认 30 秒 */
53
- const CACHE_TTL = 30 * 1000;
54
- /**
55
- * 获取或创建 DLMM 池实例
56
- * @param poolAddress 池地址
57
- * @param connection 可选连接
58
- * @param forceRefresh 强制刷新缓存
59
- */
60
- export async function getDlmmPool(poolAddress, connection, forceRefresh = false) {
61
- const conn = getConnection(connection);
62
- const cacheKey = poolAddress;
63
- // 检查缓存
64
- if (!forceRefresh) {
65
- const cached = dlmmPoolCache.get(cacheKey);
66
- if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
67
- return cached.instance;
68
- }
69
- }
70
- // 创建新实例
71
- const instance = await DLMM.create(conn, new PublicKey(poolAddress));
72
- // 存入缓存
73
- dlmmPoolCache.set(cacheKey, {
74
- instance,
75
- timestamp: Date.now(),
76
- });
77
- return instance;
78
- }
79
- /**
80
- * 获取所有 DLMM 池列表
81
- * @param connection 可选连接
82
- */
83
- export async function getAllDlmmPools(connection) {
84
- const conn = getConnection(connection);
85
- return DLMM.getLbPairs(conn);
86
- }
87
- /**
88
- * 清除 DLMM 池缓存
89
- * @param poolAddress 可选,指定池地址;不传则清除全部
90
- */
91
- export function clearDlmmCache(poolAddress) {
92
- if (poolAddress) {
93
- dlmmPoolCache.delete(poolAddress);
94
- }
95
- else {
96
- dlmmPoolCache.clear();
97
- }
98
- }
99
- // ============================================================================
100
- // DBC 客户端管理
101
- // ============================================================================
102
- /** DBC 客户端实例缓存 */
103
- let dbcClient = null;
104
- let dbcClientConnection = null;
105
- /**
106
- * 获取或创建 DBC 客户端
107
- * @param connection 可选连接
108
- */
109
- export function getDbcClient(connection) {
110
- const conn = getConnection(connection);
111
- // 如果连接相同,复用现有客户端
112
- if (dbcClient && dbcClientConnection === conn) {
113
- return dbcClient;
114
- }
115
- // 创建新客户端
116
- dbcClient = DynamicBondingCurveClient.create(conn, 'confirmed');
117
- dbcClientConnection = conn;
118
- return dbcClient;
119
- }
120
- /**
121
- * 重置 DBC 客户端
122
- */
123
- export function resetDbcClient() {
124
- dbcClient = null;
125
- dbcClientConnection = null;
126
- }
127
- // ============================================================================
128
- // DAMM v1 实例缓存
129
- // ============================================================================
130
- /** DAMM v1 池实例缓存 */
131
- const dammV1PoolCache = new Map();
132
- /**
133
- * 获取或创建 DAMM v1 池实例
134
- * @param poolAddress 池地址
135
- * @param connection 可选连接
136
- * @param forceRefresh 强制刷新缓存
137
- */
138
- export async function getDammV1Pool(poolAddress, connection, forceRefresh = false) {
139
- const conn = getConnection(connection);
140
- const cacheKey = poolAddress;
141
- // 检查缓存
142
- if (!forceRefresh) {
143
- const cached = dammV1PoolCache.get(cacheKey);
144
- if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
145
- return cached.instance;
146
- }
147
- }
148
- // 创建新实例
149
- const instance = await AmmImpl.create(conn, new PublicKey(poolAddress));
150
- // 存入缓存
151
- dammV1PoolCache.set(cacheKey, {
152
- instance,
153
- timestamp: Date.now(),
154
- });
155
- return instance;
156
- }
157
- /**
158
- * 清除 DAMM v1 池缓存
159
- * @param poolAddress 可选,指定池地址;不传则清除全部
160
- */
161
- export function clearDammV1Cache(poolAddress) {
162
- if (poolAddress) {
163
- dammV1PoolCache.delete(poolAddress);
164
- }
165
- else {
166
- dammV1PoolCache.clear();
167
- }
168
- }
169
- // ============================================================================
170
- // DAMM v2 客户端管理
171
- // ============================================================================
172
- /** DAMM v2 客户端实例缓存 */
173
- let cpAmmClient = null;
174
- let cpAmmClientConnection = null;
175
- /**
176
- * 获取或创建 DAMM v2 (CpAmm) 客户端
177
- * @param connection 可选连接
178
- */
179
- export function getCpAmmClient(connection) {
180
- const conn = getConnection(connection);
181
- // 如果连接相同,复用现有客户端
182
- if (cpAmmClient && cpAmmClientConnection === conn) {
183
- return cpAmmClient;
184
- }
185
- // 创建新客户端
186
- cpAmmClient = new CpAmm(conn);
187
- cpAmmClientConnection = conn;
188
- return cpAmmClient;
189
- }
190
- /**
191
- * 重置 DAMM v2 客户端
192
- */
193
- export function resetCpAmmClient() {
194
- cpAmmClient = null;
195
- cpAmmClientConnection = null;
196
- }
197
- // ============================================================================
198
- // 全局缓存管理
199
- // ============================================================================
200
- /**
201
- * 清除所有 Meteora 缓存
202
- */
203
- export function clearAllMeteoraCache() {
204
- clearDlmmCache();
205
- clearDammV1Cache();
206
- resetDbcClient();
207
- resetCpAmmClient();
208
- }
209
- /**
210
- * 设置缓存 TTL (毫秒)
211
- * 注意: 这会影响新创建的缓存项,不会影响已存在的
212
- */
213
- let cacheTtl = CACHE_TTL;
214
- export function setCacheTtl(ttlMs) {
215
- cacheTtl = ttlMs;
216
- }
217
- export function getCacheTtl() {
218
- return cacheTtl;
219
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * Meteora DAMM v1 Bundle 批量交易
3
- *
4
- * 支持 Jito Bundle 的批量买卖
5
- */
6
- import { Connection, Keypair } from '@solana/web3.js';
7
- import BN from 'bn.js';
8
- import type { MeteoraBundleSignedResult } from './types.js';
9
- /**
10
- * DAMM v1 Bundle Swap 参数
11
- */
12
- export interface DammV1BundleSwapParams {
13
- /** 池地址 */
14
- poolAddress: string;
15
- /** 输入代币地址 */
16
- inputMint: string;
17
- /** 输出代币地址 */
18
- outputMint: string;
19
- /** 交易列表 */
20
- trades: {
21
- wallet: Keypair;
22
- amountIn: BN;
23
- minAmountOut?: BN;
24
- }[];
25
- /** 滑点 (bps) */
26
- slippageBps?: number;
27
- /** Jito 小费 */
28
- jitoTipLamports?: number;
29
- }
30
- /**
31
- * 签名 DAMM v1 Bundle 批量买入交易
32
- *
33
- * @param params Bundle 参数
34
- * @param connection 可选连接
35
- */
36
- export declare function signDammV1BundleBuy(params: DammV1BundleSwapParams, connection?: Connection): Promise<MeteoraBundleSignedResult>;
37
- /**
38
- * 签名 DAMM v1 Bundle 批量卖出交易
39
- *
40
- * @param params Bundle 参数
41
- * @param connection 可选连接
42
- */
43
- export declare function signDammV1BundleSell(params: DammV1BundleSwapParams, connection?: Connection): Promise<MeteoraBundleSignedResult>;
44
- /**
45
- * 签名 DAMM v1 Bundle 通用 Swap 交易
46
- *
47
- * @param params Bundle 参数
48
- * @param isBuy 是否买入 (true = 买入, false = 卖出)
49
- * @param connection 可选连接
50
- */
51
- export declare function signDammV1BundleSwap(params: DammV1BundleSwapParams, isBuy: boolean, connection?: Connection): Promise<MeteoraBundleSignedResult>;
52
- /**
53
- * 将 Bundle 结果转换为后端 API 请求格式
54
- */
55
- export declare function toDammV1BundleApiRequest(result: MeteoraBundleSignedResult): {
56
- transactions: string[];
57
- type: string;
58
- poolAddress: string;
59
- tradeCount: number;
60
- jitoTipLamports: number;
61
- };
@@ -1,112 +0,0 @@
1
- /**
2
- * Meteora DAMM v1 Bundle 批量交易
3
- *
4
- * 支持 Jito Bundle 的批量买卖
5
- */
6
- import { PublicKey, } from '@solana/web3.js';
7
- import { getConnection, getDammV1Pool } from './client.js';
8
- import { buildTipInstruction } from '../../jito/tip.js';
9
- // ============================================================================
10
- // Bundle 批量买入
11
- // ============================================================================
12
- /**
13
- * 签名 DAMM v1 Bundle 批量买入交易
14
- *
15
- * @param params Bundle 参数
16
- * @param connection 可选连接
17
- */
18
- export async function signDammV1BundleBuy(params, connection) {
19
- const conn = getConnection(connection);
20
- const pool = await getDammV1Pool(params.poolAddress, connection);
21
- const signedTransactions = [];
22
- for (let i = 0; i < params.trades.length; i++) {
23
- const trade = params.trades[i];
24
- const swapQuote = pool.getSwapQuote(new PublicKey(params.inputMint), trade.amountIn, params.slippageBps || 100);
25
- const minAmountOut = trade.minAmountOut || swapQuote.minSwapOutAmount;
26
- const swapTx = await pool.swap(trade.wallet.publicKey, new PublicKey(params.inputMint), trade.amountIn, minAmountOut);
27
- if (i === params.trades.length - 1 && params.jitoTipLamports) {
28
- const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(params.jitoTipLamports));
29
- swapTx.add(tipIx);
30
- }
31
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
32
- swapTx.recentBlockhash = blockhash;
33
- swapTx.lastValidBlockHeight = lastValidBlockHeight;
34
- swapTx.feePayer = trade.wallet.publicKey;
35
- swapTx.sign(trade.wallet);
36
- signedTransactions.push(swapTx);
37
- }
38
- return {
39
- signedTransactions,
40
- type: 'damm_v1_bundle_buy',
41
- poolAddress: params.poolAddress,
42
- tradeCount: params.trades.length,
43
- jitoTipLamports: params.jitoTipLamports || 0,
44
- };
45
- }
46
- // ============================================================================
47
- // Bundle 批量卖出
48
- // ============================================================================
49
- /**
50
- * 签名 DAMM v1 Bundle 批量卖出交易
51
- *
52
- * @param params Bundle 参数
53
- * @param connection 可选连接
54
- */
55
- export async function signDammV1BundleSell(params, connection) {
56
- const conn = getConnection(connection);
57
- const pool = await getDammV1Pool(params.poolAddress, connection);
58
- const signedTransactions = [];
59
- for (let i = 0; i < params.trades.length; i++) {
60
- const trade = params.trades[i];
61
- const swapQuote = pool.getSwapQuote(new PublicKey(params.inputMint), trade.amountIn, params.slippageBps || 100);
62
- const minAmountOut = trade.minAmountOut || swapQuote.minSwapOutAmount;
63
- const swapTx = await pool.swap(trade.wallet.publicKey, new PublicKey(params.inputMint), trade.amountIn, minAmountOut);
64
- if (i === params.trades.length - 1 && params.jitoTipLamports) {
65
- const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(params.jitoTipLamports));
66
- swapTx.add(tipIx);
67
- }
68
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
69
- swapTx.recentBlockhash = blockhash;
70
- swapTx.lastValidBlockHeight = lastValidBlockHeight;
71
- swapTx.feePayer = trade.wallet.publicKey;
72
- swapTx.sign(trade.wallet);
73
- signedTransactions.push(swapTx);
74
- }
75
- return {
76
- signedTransactions,
77
- type: 'damm_v1_bundle_sell',
78
- poolAddress: params.poolAddress,
79
- tradeCount: params.trades.length,
80
- jitoTipLamports: params.jitoTipLamports || 0,
81
- };
82
- }
83
- // ============================================================================
84
- // Bundle 通用 Swap
85
- // ============================================================================
86
- /**
87
- * 签名 DAMM v1 Bundle 通用 Swap 交易
88
- *
89
- * @param params Bundle 参数
90
- * @param isBuy 是否买入 (true = 买入, false = 卖出)
91
- * @param connection 可选连接
92
- */
93
- export async function signDammV1BundleSwap(params, isBuy, connection) {
94
- if (isBuy) {
95
- return signDammV1BundleBuy(params, connection);
96
- }
97
- else {
98
- return signDammV1BundleSell(params, connection);
99
- }
100
- }
101
- /**
102
- * 将 Bundle 结果转换为后端 API 请求格式
103
- */
104
- export function toDammV1BundleApiRequest(result) {
105
- return {
106
- transactions: result.signedTransactions.map((tx) => tx.serialize().toString('base64')),
107
- type: result.type,
108
- poolAddress: result.poolAddress,
109
- tradeCount: result.tradeCount,
110
- jitoTipLamports: result.jitoTipLamports,
111
- };
112
- }
@@ -1,118 +0,0 @@
1
- /**
2
- * Meteora DAMM v1 (Dynamic AMM) 集成
3
- *
4
- * 基于 https://github.com/MeteoraAg/dynamic-amm-sdk 源码分析
5
- * DAMM v1 是 DBC 迁移后的目标池之一
6
- */
7
- import { Connection, Keypair } from '@solana/web3.js';
8
- import BN from 'bn.js';
9
- import type { DammV1PoolInfo, DammV1SwapParams, MeteoraSignedResult } from './types.js';
10
- /**
11
- * 获取 DAMM v1 池信息
12
- * @param poolAddress 池地址
13
- * @param connection 可选连接
14
- */
15
- export declare function getDammV1PoolInfo(poolAddress: string, connection?: Connection): Promise<DammV1PoolInfo>;
16
- /**
17
- * 签名 DAMM v1 Swap 交易
18
- * @param params Swap 参数
19
- * @param wallet 钱包
20
- * @param connection 可选连接
21
- */
22
- export declare function signDammV1Swap(params: DammV1SwapParams, wallet: Keypair, connection?: Connection): Promise<MeteoraSignedResult>;
23
- /**
24
- * 签名 DAMM v1 添加流动性交易
25
- */
26
- export declare function signDammV1Deposit(poolAddress: string, amountA: BN, amountB: BN, wallet: Keypair, connection?: Connection): Promise<MeteoraSignedResult>;
27
- /**
28
- * 签名 DAMM v1 移除流动性交易
29
- */
30
- export declare function signDammV1Withdraw(poolAddress: string, lpAmount: BN, wallet: Keypair, connection?: Connection): Promise<MeteoraSignedResult>;
31
- /**
32
- * 签名锁定 LP 交易
33
- */
34
- export declare function signDammV1LockLiquidity(poolAddress: string, lpAmount: BN, wallet: Keypair, connection?: Connection): Promise<MeteoraSignedResult>;
35
- /**
36
- * 签名领取锁定 LP 费用交易
37
- */
38
- export declare function signDammV1ClaimLockFee(poolAddress: string, wallet: Keypair, connection?: Connection): Promise<MeteoraSignedResult>;
39
- /**
40
- * 获取 LP Token Mint 地址
41
- */
42
- export declare function getDammV1LpMint(poolAddress: string, connection?: Connection): Promise<string>;
43
- /**
44
- * 获取 LP 供应量
45
- */
46
- export declare function getDammV1LpSupply(poolAddress: string, connection?: Connection): Promise<BN>;
47
- /**
48
- * 获取锁定的 LP 数量
49
- */
50
- export declare function getDammV1LockedLpAmount(poolAddress: string, connection?: Connection): Promise<BN>;
51
- /**
52
- * 签名创建 DAMM v1 池交易
53
- * @param tokenAMint Token A Mint
54
- * @param tokenBMint Token B Mint
55
- * @param tokenAAmount 初始 Token A 数量
56
- * @param tokenBAmount 初始 Token B 数量
57
- * @param wallet 钱包
58
- * @param connection 可选连接
59
- */
60
- export declare function signDammV1CreatePool(tokenAMint: string, tokenBMint: string, tokenAAmount: BN, tokenBAmount: BN, wallet: Keypair, connection?: Connection): Promise<MeteoraSignedResult>;
61
- /**
62
- * 获取 DAMM v1 Swap 报价
63
- * @param poolAddress 池地址
64
- * @param inputMint 输入 Mint
65
- * @param amountIn 输入数量
66
- * @param slippageBps 滑点 (bps)
67
- * @param connection 可选连接
68
- */
69
- export declare function getDammV1SwapQuote(poolAddress: string, inputMint: string, amountIn: BN, slippageBps?: number, connection?: Connection): Promise<{
70
- swapInAmount: string;
71
- swapOutAmount: string;
72
- minSwapOutAmount: string;
73
- priceImpact: string;
74
- fee: string;
75
- }>;
76
- /**
77
- * 获取 DAMM v1 存款报价
78
- * @param poolAddress 池地址
79
- * @param tokenAAmount Token A 数量
80
- * @param tokenBAmount Token B 数量
81
- * @param slippageBps 滑点 (bps)
82
- * @param connection 可选连接
83
- */
84
- export declare function getDammV1DepositQuote(poolAddress: string, tokenAAmount: BN, tokenBAmount: BN, slippageBps?: number, connection?: Connection): Promise<{
85
- tokenAInAmount: string;
86
- tokenBInAmount: string;
87
- poolTokenAmountOut: string;
88
- minPoolTokenAmountOut: string;
89
- }>;
90
- /**
91
- * 获取 DAMM v1 提款报价
92
- * @param poolAddress 池地址
93
- * @param lpAmount LP 数量
94
- * @param slippageBps 滑点 (bps)
95
- * @param connection 可选连接
96
- */
97
- export declare function getDammV1WithdrawQuote(poolAddress: string, lpAmount: BN, slippageBps?: number, connection?: Connection): Promise<{
98
- tokenAOutAmount: string;
99
- tokenBOutAmount: string;
100
- minTokenAOutAmount: string;
101
- minTokenBOutAmount: string;
102
- }>;
103
- /**
104
- * 获取用户的 LP 余额
105
- * @param poolAddress 池地址
106
- * @param userAddress 用户地址
107
- * @param connection 可选连接
108
- */
109
- export declare function getDammV1UserLpBalance(poolAddress: string, userAddress: string, connection?: Connection): Promise<{
110
- balance: string;
111
- lockedBalance: string;
112
- }>;
113
- /**
114
- * 获取池的虚拟价格
115
- * @param poolAddress 池地址
116
- * @param connection 可选连接
117
- */
118
- export declare function getDammV1VirtualPrice(poolAddress: string, connection?: Connection): Promise<number>;