four-flap-meme-sdk 1.4.20 → 1.4.21
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/flap/portal-bundle-merkle/encryption.d.ts +16 -0
- package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +3 -38
- package/dist/sol/constants.d.ts +0 -126
- package/dist/sol/constants.js +0 -145
- package/dist/sol/dex/index.d.ts +0 -8
- package/dist/sol/dex/index.js +0 -12
- package/dist/sol/dex/meteora/client.d.ts +0 -76
- package/dist/sol/dex/meteora/client.js +0 -219
- package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
- package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
- package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
- package/dist/sol/dex/meteora/damm-v1.js +0 -315
- package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
- package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
- package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
- package/dist/sol/dex/meteora/damm-v2.js +0 -632
- package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
- package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
- package/dist/sol/dex/meteora/dbc.d.ts +0 -192
- package/dist/sol/dex/meteora/dbc.js +0 -619
- package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
- package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
- package/dist/sol/dex/meteora/dlmm.d.ts +0 -157
- package/dist/sol/dex/meteora/dlmm.js +0 -671
- package/dist/sol/dex/meteora/index.d.ts +0 -25
- package/dist/sol/dex/meteora/index.js +0 -65
- package/dist/sol/dex/meteora/types.d.ts +0 -787
- package/dist/sol/dex/meteora/types.js +0 -110
- package/dist/sol/dex/orca/index.d.ts +0 -10
- package/dist/sol/dex/orca/index.js +0 -16
- package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
- package/dist/sol/dex/orca/orca-bundle.js +0 -173
- package/dist/sol/dex/orca/orca.d.ts +0 -65
- package/dist/sol/dex/orca/orca.js +0 -474
- package/dist/sol/dex/orca/types.d.ts +0 -263
- package/dist/sol/dex/orca/types.js +0 -38
- package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
- package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
- package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
- package/dist/sol/dex/orca/wavebreak-types.js +0 -23
- package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
- package/dist/sol/dex/orca/wavebreak.js +0 -497
- package/dist/sol/dex/pump/index.d.ts +0 -9
- package/dist/sol/dex/pump/index.js +0 -14
- package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
- package/dist/sol/dex/pump/pump-bundle.js +0 -383
- package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
- package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
- package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
- package/dist/sol/dex/pump/pump-swap.js +0 -199
- package/dist/sol/dex/pump/pump.d.ts +0 -35
- package/dist/sol/dex/pump/pump.js +0 -352
- package/dist/sol/dex/pump/types.d.ts +0 -215
- package/dist/sol/dex/pump/types.js +0 -5
- package/dist/sol/dex/raydium/index.d.ts +0 -8
- package/dist/sol/dex/raydium/index.js +0 -12
- package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
- package/dist/sol/dex/raydium/launchlab.js +0 -210
- package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
- package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
- package/dist/sol/dex/raydium/raydium.d.ts +0 -40
- package/dist/sol/dex/raydium/raydium.js +0 -366
- package/dist/sol/dex/raydium/types.d.ts +0 -240
- package/dist/sol/dex/raydium/types.js +0 -5
- package/dist/sol/index.d.ts +0 -10
- package/dist/sol/index.js +0 -16
- package/dist/sol/jito/bundle.d.ts +0 -90
- package/dist/sol/jito/bundle.js +0 -263
- package/dist/sol/jito/index.d.ts +0 -7
- package/dist/sol/jito/index.js +0 -7
- package/dist/sol/jito/tip.d.ts +0 -51
- package/dist/sol/jito/tip.js +0 -83
- package/dist/sol/jito/types.d.ts +0 -100
- package/dist/sol/jito/types.js +0 -5
- package/dist/sol/token/create-complete.d.ts +0 -115
- package/dist/sol/token/create-complete.js +0 -235
- package/dist/sol/token/create-token.d.ts +0 -57
- package/dist/sol/token/create-token.js +0 -230
- package/dist/sol/token/index.d.ts +0 -9
- package/dist/sol/token/index.js +0 -14
- package/dist/sol/token/metadata-upload.d.ts +0 -86
- package/dist/sol/token/metadata-upload.js +0 -173
- package/dist/sol/token/metadata.d.ts +0 -92
- package/dist/sol/token/metadata.js +0 -274
- package/dist/sol/token/types.d.ts +0 -153
- package/dist/sol/token/types.js +0 -5
- package/dist/sol/types.d.ts +0 -176
- package/dist/sol/types.js +0 -7
- package/dist/sol/utils/balance.d.ts +0 -160
- package/dist/sol/utils/balance.js +0 -638
- package/dist/sol/utils/connection.d.ts +0 -78
- package/dist/sol/utils/connection.js +0 -168
- package/dist/sol/utils/index.d.ts +0 -9
- package/dist/sol/utils/index.js +0 -9
- package/dist/sol/utils/lp-inspect.d.ts +0 -129
- package/dist/sol/utils/lp-inspect.js +0 -900
- package/dist/sol/utils/transfer.d.ts +0 -125
- package/dist/sol/utils/transfer.js +0 -220
- package/dist/sol/utils/wallet.d.ts +0 -107
- package/dist/sol/utils/wallet.js +0 -210
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orca Whirlpool 类型定义
|
|
3
|
-
*/
|
|
4
|
-
import type { Keypair, Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
5
|
-
import type BN from 'bn.js';
|
|
6
|
-
/**
|
|
7
|
-
* Orca Whirlpool 池信息
|
|
8
|
-
*/
|
|
9
|
-
export interface OrcaPoolInfo {
|
|
10
|
-
/** 池地址 */
|
|
11
|
-
poolAddress: string;
|
|
12
|
-
/** Token A 地址 */
|
|
13
|
-
tokenMintA: string;
|
|
14
|
-
/** Token B 地址 */
|
|
15
|
-
tokenMintB: string;
|
|
16
|
-
/** Token A 符号 */
|
|
17
|
-
tokenSymbolA?: string;
|
|
18
|
-
/** Token B 符号 */
|
|
19
|
-
tokenSymbolB?: string;
|
|
20
|
-
/** Token A 小数位数 */
|
|
21
|
-
tokenDecimalsA: number;
|
|
22
|
-
/** Token B 小数位数 */
|
|
23
|
-
tokenDecimalsB: number;
|
|
24
|
-
/** Token A 金库地址 */
|
|
25
|
-
tokenVaultA: string;
|
|
26
|
-
/** Token B 金库地址 */
|
|
27
|
-
tokenVaultB: string;
|
|
28
|
-
/** 当前价格 (Token B / Token A) */
|
|
29
|
-
price: number;
|
|
30
|
-
/** 当前 sqrt 价格 */
|
|
31
|
-
sqrtPrice: string;
|
|
32
|
-
/** 当前 tick */
|
|
33
|
-
currentTick: number;
|
|
34
|
-
/** Tick 间距 */
|
|
35
|
-
tickSpacing: number;
|
|
36
|
-
/** 费率 (bps) */
|
|
37
|
-
feeRate: number;
|
|
38
|
-
/** 协议费率 (bps) */
|
|
39
|
-
protocolFeeRate: number;
|
|
40
|
-
/** 流动性 */
|
|
41
|
-
liquidity: string;
|
|
42
|
-
/** 费用增长 A */
|
|
43
|
-
feeGrowthGlobalA: string;
|
|
44
|
-
/** 费用增长 B */
|
|
45
|
-
feeGrowthGlobalB: string;
|
|
46
|
-
/** 奖励信息 */
|
|
47
|
-
rewardInfos: OrcaRewardInfo[];
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Orca 奖励信息
|
|
51
|
-
*/
|
|
52
|
-
export interface OrcaRewardInfo {
|
|
53
|
-
/** 奖励代币地址 */
|
|
54
|
-
mint: string;
|
|
55
|
-
/** 奖励金库地址 */
|
|
56
|
-
vault: string;
|
|
57
|
-
/** 每秒排放量 */
|
|
58
|
-
emissionsPerSecond: string;
|
|
59
|
-
/** 增长全局 */
|
|
60
|
-
growthGlobal: string;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Orca Swap 参数
|
|
64
|
-
*/
|
|
65
|
-
export interface OrcaSwapParams {
|
|
66
|
-
/** 池地址 */
|
|
67
|
-
poolAddress: string;
|
|
68
|
-
/** 输入代币地址 */
|
|
69
|
-
inputMint: string;
|
|
70
|
-
/** 输出代币地址 */
|
|
71
|
-
outputMint: string;
|
|
72
|
-
/** 输入金额 (lamports) */
|
|
73
|
-
amountIn: BN;
|
|
74
|
-
/** 最小输出金额 (lamports) */
|
|
75
|
-
minAmountOut: BN;
|
|
76
|
-
/** 滑点 (bps, 如 100 = 1%) */
|
|
77
|
-
slippageBps?: number;
|
|
78
|
-
/** 是否精确输入 */
|
|
79
|
-
exactInput?: boolean;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Orca Swap 报价
|
|
83
|
-
*/
|
|
84
|
-
export interface OrcaSwapQuote {
|
|
85
|
-
/** 输入金额 */
|
|
86
|
-
amountIn: BN;
|
|
87
|
-
/** 预估输出金额 */
|
|
88
|
-
estimatedAmountOut: BN;
|
|
89
|
-
/** 最小输出金额 (考虑滑点) */
|
|
90
|
-
minAmountOut: BN;
|
|
91
|
-
/** 费用金额 */
|
|
92
|
-
feeAmount: BN;
|
|
93
|
-
/** 价格影响 (百分比) */
|
|
94
|
-
priceImpact: number;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Orca 添加流动性参数
|
|
98
|
-
*/
|
|
99
|
-
export interface OrcaAddLiquidityParams {
|
|
100
|
-
/** 池地址 */
|
|
101
|
-
poolAddress: string;
|
|
102
|
-
/** 下限 tick */
|
|
103
|
-
tickLower: number;
|
|
104
|
-
/** 上限 tick */
|
|
105
|
-
tickUpper: number;
|
|
106
|
-
/** Token A 金额 */
|
|
107
|
-
tokenAmountA: BN;
|
|
108
|
-
/** Token B 金额 */
|
|
109
|
-
tokenAmountB: BN;
|
|
110
|
-
/** 滑点 (bps) */
|
|
111
|
-
slippageBps?: number;
|
|
112
|
-
/** 是否创建新 position */
|
|
113
|
-
createNewPosition?: boolean;
|
|
114
|
-
/** 已有 position 地址 (如果不创建新的) */
|
|
115
|
-
positionAddress?: string;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Orca 移除流动性参数
|
|
119
|
-
*/
|
|
120
|
-
export interface OrcaRemoveLiquidityParams {
|
|
121
|
-
/** Position 地址 */
|
|
122
|
-
positionAddress: string;
|
|
123
|
-
/** 流动性金额 (如果不指定,移除全部) */
|
|
124
|
-
liquidityAmount?: BN;
|
|
125
|
-
/** 最小 Token A 输出 */
|
|
126
|
-
minTokenAmountA?: BN;
|
|
127
|
-
/** 最小 Token B 输出 */
|
|
128
|
-
minTokenAmountB?: BN;
|
|
129
|
-
/** 滑点 (bps) */
|
|
130
|
-
slippageBps?: number;
|
|
131
|
-
/** 是否关闭 position */
|
|
132
|
-
closePosition?: boolean;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Orca Position 信息
|
|
136
|
-
*/
|
|
137
|
-
export interface OrcaPositionInfo {
|
|
138
|
-
/** Position 地址 */
|
|
139
|
-
positionAddress: string;
|
|
140
|
-
/** Position Mint 地址 */
|
|
141
|
-
positionMint: string;
|
|
142
|
-
/** 池地址 */
|
|
143
|
-
poolAddress: string;
|
|
144
|
-
/** 下限 tick */
|
|
145
|
-
tickLower: number;
|
|
146
|
-
/** 上限 tick */
|
|
147
|
-
tickUpper: number;
|
|
148
|
-
/** 流动性 */
|
|
149
|
-
liquidity: string;
|
|
150
|
-
/** 费用 A 应收 */
|
|
151
|
-
feeOwedA: string;
|
|
152
|
-
/** 费用 B 应收 */
|
|
153
|
-
feeOwedB: string;
|
|
154
|
-
/** 奖励应收 */
|
|
155
|
-
rewardOwed: string[];
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Orca 创建池参数
|
|
159
|
-
*/
|
|
160
|
-
export interface OrcaCreatePoolParams {
|
|
161
|
-
/** Whirlpools Config 地址 */
|
|
162
|
-
whirlpoolsConfig: string;
|
|
163
|
-
/** Token A 地址 */
|
|
164
|
-
tokenMintA: string;
|
|
165
|
-
/** Token B 地址 */
|
|
166
|
-
tokenMintB: string;
|
|
167
|
-
/** 初始价格 (Token B / Token A) */
|
|
168
|
-
initialPrice: number;
|
|
169
|
-
/** Tick 间距 (决定费率) */
|
|
170
|
-
tickSpacing?: number;
|
|
171
|
-
/** 资金提供者 (默认为签名者) */
|
|
172
|
-
funder?: string;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Orca Bundle Swap 参数 (批量交易)
|
|
176
|
-
*/
|
|
177
|
-
export interface OrcaBundleSwapParams {
|
|
178
|
-
/** 池地址 */
|
|
179
|
-
poolAddress: string;
|
|
180
|
-
/** 输入代币地址 */
|
|
181
|
-
inputMint: string;
|
|
182
|
-
/** 输出代币地址 */
|
|
183
|
-
outputMint: string;
|
|
184
|
-
/** 交易列表 */
|
|
185
|
-
trades: {
|
|
186
|
-
/** 钱包 */
|
|
187
|
-
wallet: Keypair;
|
|
188
|
-
/** 输入金额 */
|
|
189
|
-
amountIn: BN;
|
|
190
|
-
/** 最小输出金额 */
|
|
191
|
-
minAmountOut: BN;
|
|
192
|
-
}[];
|
|
193
|
-
/** Jito 小费 (lamports) */
|
|
194
|
-
jitoTipLamports?: number;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Orca 签名结果
|
|
198
|
-
*/
|
|
199
|
-
export interface OrcaSignedResult {
|
|
200
|
-
/** 签名后的交易 */
|
|
201
|
-
signedTransaction: Transaction | VersionedTransaction;
|
|
202
|
-
/** 交易类型 */
|
|
203
|
-
type: 'swap' | 'addLiquidity' | 'removeLiquidity' | 'createPool' | 'collectFees';
|
|
204
|
-
/** 池地址 */
|
|
205
|
-
poolAddress: string;
|
|
206
|
-
/** 额外信息 */
|
|
207
|
-
metadata?: {
|
|
208
|
-
positionMint?: string;
|
|
209
|
-
positionAddress?: string;
|
|
210
|
-
estimatedAmountOut?: string;
|
|
211
|
-
liquidityAmount?: string;
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Orca Bundle 签名结果
|
|
216
|
-
*/
|
|
217
|
-
export interface OrcaBundleSignedResult {
|
|
218
|
-
/** 签名后的交易列表 */
|
|
219
|
-
signedTransactions: (Transaction | VersionedTransaction)[];
|
|
220
|
-
/** Bundle 类型 */
|
|
221
|
-
type: 'bundleSwap';
|
|
222
|
-
/** 池地址 */
|
|
223
|
-
poolAddress: string;
|
|
224
|
-
/** 交易数量 */
|
|
225
|
-
tradeCount: number;
|
|
226
|
-
/** Jito 小费 */
|
|
227
|
-
jitoTipLamports: number;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Whirlpool 费率等级
|
|
231
|
-
* tickSpacing 决定费率
|
|
232
|
-
*/
|
|
233
|
-
export declare const WHIRLPOOL_TICK_SPACING: {
|
|
234
|
-
/** 0.01% 费率 */
|
|
235
|
-
readonly TICK_SPACING_1: 1;
|
|
236
|
-
/** 0.02% 费率 */
|
|
237
|
-
readonly TICK_SPACING_2: 2;
|
|
238
|
-
/** 0.04% 费率 */
|
|
239
|
-
readonly TICK_SPACING_4: 4;
|
|
240
|
-
/** 0.08% 费率 */
|
|
241
|
-
readonly TICK_SPACING_8: 8;
|
|
242
|
-
/** 0.16% 费率 */
|
|
243
|
-
readonly TICK_SPACING_16: 16;
|
|
244
|
-
/** 0.30% 费率 */
|
|
245
|
-
readonly TICK_SPACING_64: 64;
|
|
246
|
-
/** 1.00% 费率 */
|
|
247
|
-
readonly TICK_SPACING_128: 128;
|
|
248
|
-
/** 2.00% 费率 */
|
|
249
|
-
readonly TICK_SPACING_256: 256;
|
|
250
|
-
};
|
|
251
|
-
/**
|
|
252
|
-
* Orca Whirlpools Config 地址
|
|
253
|
-
*/
|
|
254
|
-
export declare const ORCA_WHIRLPOOL_CONFIG: {
|
|
255
|
-
/** Mainnet Whirlpools Config */
|
|
256
|
-
readonly MAINNET: "FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR";
|
|
257
|
-
/** Devnet Whirlpools Config */
|
|
258
|
-
readonly DEVNET: "FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR";
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* Orca Whirlpool Program ID
|
|
262
|
-
*/
|
|
263
|
-
export declare const ORCA_WHIRLPOOL_PROGRAM_ID = "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orca Whirlpool 类型定义
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Whirlpool 费率等级
|
|
6
|
-
* tickSpacing 决定费率
|
|
7
|
-
*/
|
|
8
|
-
export const WHIRLPOOL_TICK_SPACING = {
|
|
9
|
-
/** 0.01% 费率 */
|
|
10
|
-
TICK_SPACING_1: 1,
|
|
11
|
-
/** 0.02% 费率 */
|
|
12
|
-
TICK_SPACING_2: 2,
|
|
13
|
-
/** 0.04% 费率 */
|
|
14
|
-
TICK_SPACING_4: 4,
|
|
15
|
-
/** 0.08% 费率 */
|
|
16
|
-
TICK_SPACING_8: 8,
|
|
17
|
-
/** 0.16% 费率 */
|
|
18
|
-
TICK_SPACING_16: 16,
|
|
19
|
-
/** 0.30% 费率 */
|
|
20
|
-
TICK_SPACING_64: 64,
|
|
21
|
-
/** 1.00% 费率 */
|
|
22
|
-
TICK_SPACING_128: 128,
|
|
23
|
-
/** 2.00% 费率 */
|
|
24
|
-
TICK_SPACING_256: 256,
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Orca Whirlpools Config 地址
|
|
28
|
-
*/
|
|
29
|
-
export const ORCA_WHIRLPOOL_CONFIG = {
|
|
30
|
-
/** Mainnet Whirlpools Config */
|
|
31
|
-
MAINNET: 'FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR',
|
|
32
|
-
/** Devnet Whirlpools Config */
|
|
33
|
-
DEVNET: 'FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR',
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Orca Whirlpool Program ID
|
|
37
|
-
*/
|
|
38
|
-
export const ORCA_WHIRLPOOL_PROGRAM_ID = 'whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orca Wavebreak Jito Bundle 批量交易
|
|
3
|
-
* 支持批量买卖的原子性交易
|
|
4
|
-
*/
|
|
5
|
-
import { Connection, Keypair } from '@solana/web3.js';
|
|
6
|
-
import type { WavebreakBundleBuyParams, WavebreakBundleSellParams, WavebreakBundleCreateAndBuyParams, WavebreakBundleSignedResult } from './wavebreak-types.js';
|
|
7
|
-
/**
|
|
8
|
-
* 签名 Wavebreak Bundle 批量买入交易
|
|
9
|
-
*/
|
|
10
|
-
export declare function signWavebreakBundleBuy(params: WavebreakBundleBuyParams, connection?: Connection): Promise<WavebreakBundleSignedResult>;
|
|
11
|
-
/**
|
|
12
|
-
* 签名 Wavebreak Bundle 批量卖出交易
|
|
13
|
-
*/
|
|
14
|
-
export declare function signWavebreakBundleSell(params: WavebreakBundleSellParams, connection?: Connection): Promise<WavebreakBundleSignedResult>;
|
|
15
|
-
/**
|
|
16
|
-
* 签名 Wavebreak Bundle 创建并买入交易
|
|
17
|
-
* 第一笔交易创建代币,后续交易批量买入
|
|
18
|
-
*/
|
|
19
|
-
export declare function signWavebreakBundleCreateAndBuy(params: WavebreakBundleCreateAndBuyParams, connection?: Connection): Promise<WavebreakBundleSignedResult & {
|
|
20
|
-
baseMintKeypair: Keypair;
|
|
21
|
-
}>;
|
|
22
|
-
/**
|
|
23
|
-
* 将 Wavebreak Bundle 结果转换为后端 API 请求格式
|
|
24
|
-
*/
|
|
25
|
-
export declare function toWavebreakBundleApiRequest(result: WavebreakBundleSignedResult): {
|
|
26
|
-
transactions: string[];
|
|
27
|
-
metadata: {
|
|
28
|
-
type: string;
|
|
29
|
-
bondingCurveAddress: string;
|
|
30
|
-
baseMint?: string;
|
|
31
|
-
tradeCount: number;
|
|
32
|
-
jitoTipLamports: number;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orca Wavebreak Jito Bundle 批量交易
|
|
3
|
-
* 支持批量买卖的原子性交易
|
|
4
|
-
*/
|
|
5
|
-
import { PublicKey, Keypair, Transaction, ComputeBudgetProgram, } from '@solana/web3.js';
|
|
6
|
-
// 不再导入 createConnection,强制使用者传入连接
|
|
7
|
-
import { buildTipInstruction, getRandomTipAccount } from '../../jito/tip.js';
|
|
8
|
-
import { buildWavebreakBuyInstruction, buildWavebreakSellInstruction, buildWavebreakCreateLaunchInstruction, getWavebreakBondingCurveInfo, } from './wavebreak.js';
|
|
9
|
-
import { WAVEBREAK_CONSTANTS } from './wavebreak-types.js';
|
|
10
|
-
/**
|
|
11
|
-
* 默认 Jito 小费 (0.001 SOL)
|
|
12
|
-
*/
|
|
13
|
-
const DEFAULT_JITO_TIP_LAMPORTS = 1000000;
|
|
14
|
-
/**
|
|
15
|
-
* 签名 Wavebreak Bundle 批量买入交易
|
|
16
|
-
*/
|
|
17
|
-
export async function signWavebreakBundleBuy(params, connection) {
|
|
18
|
-
if (!connection) {
|
|
19
|
-
throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
|
|
20
|
-
}
|
|
21
|
-
const conn = connection;
|
|
22
|
-
const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
|
|
23
|
-
// 获取 Bonding Curve 信息
|
|
24
|
-
const info = await getWavebreakBondingCurveInfo(params.bondingCurveOrMint, conn);
|
|
25
|
-
if (!info) {
|
|
26
|
-
throw new Error('Bonding Curve 不存在');
|
|
27
|
-
}
|
|
28
|
-
const signedTransactions = [];
|
|
29
|
-
const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
|
|
30
|
-
const slippageBps = params.slippageBps || 100;
|
|
31
|
-
for (let i = 0; i < params.trades.length; i++) {
|
|
32
|
-
const trade = params.trades[i];
|
|
33
|
-
const isLastTrade = i === params.trades.length - 1;
|
|
34
|
-
const tx = new Transaction();
|
|
35
|
-
// 添加计算预算
|
|
36
|
-
tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
|
|
37
|
-
// 添加买入指令
|
|
38
|
-
const buyIx = await buildWavebreakBuyInstruction({
|
|
39
|
-
bondingCurveOrMint: info.bondingCurveAddress,
|
|
40
|
-
amountIn: trade.amountIn,
|
|
41
|
-
allowPartialFill: true,
|
|
42
|
-
slippageBps,
|
|
43
|
-
}, trade.wallet.publicKey, conn);
|
|
44
|
-
tx.add(buyIx);
|
|
45
|
-
// 最后一笔交易添加 Jito 小费
|
|
46
|
-
if (isLastTrade) {
|
|
47
|
-
const tipAccount = getRandomTipAccount();
|
|
48
|
-
const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
|
|
49
|
-
tx.add(tipIx);
|
|
50
|
-
}
|
|
51
|
-
// 设置交易参数
|
|
52
|
-
tx.recentBlockhash = blockhash;
|
|
53
|
-
tx.lastValidBlockHeight = lastValidBlockHeight;
|
|
54
|
-
tx.feePayer = trade.wallet.publicKey;
|
|
55
|
-
// 签名
|
|
56
|
-
tx.sign(trade.wallet);
|
|
57
|
-
signedTransactions.push(tx);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
signedTransactions,
|
|
61
|
-
type: 'bundleBuy',
|
|
62
|
-
bondingCurveAddress: info.bondingCurveAddress,
|
|
63
|
-
baseMint: info.baseMint,
|
|
64
|
-
tradeCount: params.trades.length,
|
|
65
|
-
jitoTipLamports,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 签名 Wavebreak Bundle 批量卖出交易
|
|
70
|
-
*/
|
|
71
|
-
export async function signWavebreakBundleSell(params, connection) {
|
|
72
|
-
if (!connection) {
|
|
73
|
-
throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
|
|
74
|
-
}
|
|
75
|
-
const conn = connection;
|
|
76
|
-
const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
|
|
77
|
-
const info = await getWavebreakBondingCurveInfo(params.bondingCurveOrMint, conn);
|
|
78
|
-
if (!info) {
|
|
79
|
-
throw new Error('Bonding Curve 不存在');
|
|
80
|
-
}
|
|
81
|
-
const signedTransactions = [];
|
|
82
|
-
const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
|
|
83
|
-
const slippageBps = params.slippageBps || 100;
|
|
84
|
-
for (let i = 0; i < params.trades.length; i++) {
|
|
85
|
-
const trade = params.trades[i];
|
|
86
|
-
const isLastTrade = i === params.trades.length - 1;
|
|
87
|
-
const tx = new Transaction();
|
|
88
|
-
tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
|
|
89
|
-
const sellIx = await buildWavebreakSellInstruction({
|
|
90
|
-
bondingCurveOrMint: info.bondingCurveAddress,
|
|
91
|
-
amountIn: trade.amountIn,
|
|
92
|
-
allowPartialFill: true,
|
|
93
|
-
slippageBps,
|
|
94
|
-
}, trade.wallet.publicKey, conn);
|
|
95
|
-
tx.add(sellIx);
|
|
96
|
-
if (isLastTrade) {
|
|
97
|
-
const tipAccount = getRandomTipAccount();
|
|
98
|
-
const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
|
|
99
|
-
tx.add(tipIx);
|
|
100
|
-
}
|
|
101
|
-
tx.recentBlockhash = blockhash;
|
|
102
|
-
tx.lastValidBlockHeight = lastValidBlockHeight;
|
|
103
|
-
tx.feePayer = trade.wallet.publicKey;
|
|
104
|
-
tx.sign(trade.wallet);
|
|
105
|
-
signedTransactions.push(tx);
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
signedTransactions,
|
|
109
|
-
type: 'bundleSell',
|
|
110
|
-
bondingCurveAddress: info.bondingCurveAddress,
|
|
111
|
-
baseMint: info.baseMint,
|
|
112
|
-
tradeCount: params.trades.length,
|
|
113
|
-
jitoTipLamports,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* 签名 Wavebreak Bundle 创建并买入交易
|
|
118
|
-
* 第一笔交易创建代币,后续交易批量买入
|
|
119
|
-
*/
|
|
120
|
-
export async function signWavebreakBundleCreateAndBuy(params, connection) {
|
|
121
|
-
if (!connection) {
|
|
122
|
-
throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
|
|
123
|
-
}
|
|
124
|
-
const conn = connection;
|
|
125
|
-
const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
|
|
126
|
-
const signedTransactions = [];
|
|
127
|
-
const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
|
|
128
|
-
const slippageBps = params.slippageBps || 100;
|
|
129
|
-
// 生成新的 Mint Keypair
|
|
130
|
-
const baseMintKeypair = Keypair.generate();
|
|
131
|
-
// 计算 Bonding Curve 地址
|
|
132
|
-
const [bondingCurve] = PublicKey.findProgramAddressSync([Buffer.from('bonding_curve'), baseMintKeypair.publicKey.toBuffer()], new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID));
|
|
133
|
-
// ===== 第一笔交易:创建代币发射 =====
|
|
134
|
-
const createTx = new Transaction();
|
|
135
|
-
createTx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 500000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
|
|
136
|
-
const createIx = await buildWavebreakCreateLaunchInstruction(params.createParams, params.creator.publicKey, baseMintKeypair, conn);
|
|
137
|
-
createTx.add(createIx);
|
|
138
|
-
// 如果创建者也要买入,在创建交易中添加买入指令
|
|
139
|
-
// 这样可以减少一笔交易
|
|
140
|
-
createTx.recentBlockhash = blockhash;
|
|
141
|
-
createTx.lastValidBlockHeight = lastValidBlockHeight;
|
|
142
|
-
createTx.feePayer = params.creator.publicKey;
|
|
143
|
-
createTx.sign(params.creator, baseMintKeypair);
|
|
144
|
-
signedTransactions.push(createTx);
|
|
145
|
-
// ===== 后续交易:批量买入 =====
|
|
146
|
-
const totalTrades = params.buyTrades.length;
|
|
147
|
-
for (let i = 0; i < totalTrades; i++) {
|
|
148
|
-
const trade = params.buyTrades[i];
|
|
149
|
-
const isLastTrade = i === totalTrades - 1;
|
|
150
|
-
const buyTx = new Transaction();
|
|
151
|
-
buyTx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
|
|
152
|
-
const buyIx = await buildWavebreakBuyInstruction({
|
|
153
|
-
bondingCurveOrMint: bondingCurve.toBase58(),
|
|
154
|
-
amountIn: trade.amountIn,
|
|
155
|
-
allowPartialFill: true,
|
|
156
|
-
slippageBps,
|
|
157
|
-
}, trade.wallet.publicKey, conn);
|
|
158
|
-
buyTx.add(buyIx);
|
|
159
|
-
// 最后一笔交易添加 Jito 小费
|
|
160
|
-
if (isLastTrade) {
|
|
161
|
-
const tipAccount = getRandomTipAccount();
|
|
162
|
-
const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
|
|
163
|
-
buyTx.add(tipIx);
|
|
164
|
-
}
|
|
165
|
-
buyTx.recentBlockhash = blockhash;
|
|
166
|
-
buyTx.lastValidBlockHeight = lastValidBlockHeight;
|
|
167
|
-
buyTx.feePayer = trade.wallet.publicKey;
|
|
168
|
-
buyTx.sign(trade.wallet);
|
|
169
|
-
signedTransactions.push(buyTx);
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
signedTransactions,
|
|
173
|
-
type: 'bundleCreateAndBuy',
|
|
174
|
-
bondingCurveAddress: bondingCurve.toBase58(),
|
|
175
|
-
baseMint: baseMintKeypair.publicKey.toBase58(),
|
|
176
|
-
tradeCount: totalTrades + 1, // 包括创建交易
|
|
177
|
-
jitoTipLamports,
|
|
178
|
-
baseMintKeypair,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* 将 Wavebreak Bundle 结果转换为后端 API 请求格式
|
|
183
|
-
*/
|
|
184
|
-
export function toWavebreakBundleApiRequest(result) {
|
|
185
|
-
const transactions = result.signedTransactions.map(tx => {
|
|
186
|
-
return Buffer.from(tx.serialize()).toString('base64');
|
|
187
|
-
});
|
|
188
|
-
return {
|
|
189
|
-
transactions,
|
|
190
|
-
metadata: {
|
|
191
|
-
type: result.type,
|
|
192
|
-
bondingCurveAddress: result.bondingCurveAddress,
|
|
193
|
-
baseMint: result.baseMint,
|
|
194
|
-
tradeCount: result.tradeCount,
|
|
195
|
-
jitoTipLamports: result.jitoTipLamports,
|
|
196
|
-
},
|
|
197
|
-
};
|
|
198
|
-
}
|