four-flap-meme-sdk 1.7.3 → 1.7.5

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.
@@ -0,0 +1,103 @@
1
+ /**
2
+ * X-Layer Bundle 发币 + 内盘买到外盘
3
+ *
4
+ * 功能:在一个 Type 4 交易中完成:
5
+ * 1. 发币(创建新代币)
6
+ * 2. 多个钱包在 Bonding Curve(内盘)买入代币
7
+ * 3. 买到毕业(代币上 DEX)
8
+ * 4. 多个钱包在 PotatoSwap(外盘)继续买入
9
+ *
10
+ * ✅ 与 BSC 链 create-to-dex.ts 功能对齐
11
+ * ✅ 使用 Type 4 交易(EIP-7702),所有操作原子化
12
+ */
13
+ /** 用户类型 */
14
+ export type UserType = 'v0' | 'v1' | 'normal';
15
+ /** 代币信息 */
16
+ export interface CreateTokenInfo {
17
+ name: string;
18
+ symbol: string;
19
+ meta: string;
20
+ }
21
+ /** 内盘买入钱包配置 */
22
+ export interface CurveBuyerConfig {
23
+ privateKey: string;
24
+ /** 买入金额(OKB),为空则自动分配 */
25
+ buyAmount?: string;
26
+ }
27
+ /** 外盘买入钱包配置 */
28
+ export interface DexBuyerConfig {
29
+ privateKey: string;
30
+ /** 买入金额(OKB),为空则自动分配 */
31
+ buyAmount?: string;
32
+ }
33
+ /** 发币 + 一键到外盘参数 */
34
+ export interface CreateToDexParams {
35
+ /** RPC URL */
36
+ rpcUrl: string;
37
+ /** Gas Price (可选) */
38
+ gasPrice?: bigint;
39
+ /** 用户类型(影响利润率) */
40
+ userType?: UserType;
41
+ /** Dev 钱包私钥(发币者) */
42
+ devPrivateKey: string;
43
+ /** 代币信息 */
44
+ tokenInfo: CreateTokenInfo;
45
+ /** 预计算的代币地址 */
46
+ tokenAddress: string;
47
+ /** 内盘买入钱包 */
48
+ curveBuyers: CurveBuyerConfig[];
49
+ /** 内盘总买入金额(OKB) */
50
+ curveTotalBuyAmount: string;
51
+ /** 是否启用外盘买入 */
52
+ enableDexBuy?: boolean;
53
+ /** 外盘买入钱包(与内盘钱包可相同或不同) */
54
+ dexBuyers?: DexBuyerConfig[];
55
+ /** 外盘总买入金额(OKB) */
56
+ dexTotalBuyAmount?: string;
57
+ /** 外盘池类型(V2 或 V3),默认 V2 */
58
+ dexPoolType?: 'v2' | 'v3';
59
+ /** V3 费率(100/500/2500/10000),默认 2500 */
60
+ v3Fee?: number;
61
+ /** 发币扩展参数 */
62
+ dexThresh?: number;
63
+ migratorType?: number;
64
+ taxRate?: number;
65
+ salt?: string;
66
+ /** V4 参数 */
67
+ dexId?: number;
68
+ lpFeeProfile?: number;
69
+ extensionID?: string;
70
+ extensionData?: string;
71
+ }
72
+ /** 签名结果 */
73
+ export interface CreateToDexSignedResult {
74
+ /** 签名后的 Type 4 交易 */
75
+ signedTx: string;
76
+ /** 交易哈希 */
77
+ txHash: string;
78
+ /** Sponsor 地址 */
79
+ sponsorAddress: string;
80
+ /** 代币地址 */
81
+ tokenAddress: string;
82
+ /** 元数据 */
83
+ metadata: {
84
+ curveBuyerCount: number;
85
+ curveTotalBuy: string;
86
+ enableDexBuy: boolean;
87
+ dexBuyerCount: number;
88
+ dexTotalBuy: string;
89
+ profitAmount: string;
90
+ };
91
+ /** 时间戳 */
92
+ timestamp: number;
93
+ }
94
+ /**
95
+ * 发币 + 一键买到外盘(Type 4 原子交易)
96
+ *
97
+ * 交易顺序:
98
+ * 1. Dev 发币(创建代币)
99
+ * 2. 内盘买入(多个钱包在 Bonding Curve 买入,买到毕业)
100
+ * 3. 外盘买入(多个钱包在 PotatoSwap 买入)
101
+ * 4. 利润转账
102
+ */
103
+ export declare function signCreateToDex(params: CreateToDexParams): Promise<CreateToDexSignedResult>;
@@ -0,0 +1,348 @@
1
+ /**
2
+ * X-Layer Bundle 发币 + 内盘买到外盘
3
+ *
4
+ * 功能:在一个 Type 4 交易中完成:
5
+ * 1. 发币(创建新代币)
6
+ * 2. 多个钱包在 Bonding Curve(内盘)买入代币
7
+ * 3. 买到毕业(代币上 DEX)
8
+ * 4. 多个钱包在 PotatoSwap(外盘)继续买入
9
+ *
10
+ * ✅ 与 BSC 链 create-to-dex.ts 功能对齐
11
+ * ✅ 使用 Type 4 交易(EIP-7702),所有操作原子化
12
+ */
13
+ import { ethers, Wallet, JsonRpcProvider, Interface } from 'ethers';
14
+ import { XLAYER_CHAIN_ID, EXECUTOR_ADDRESS, EXECUTOR_ABI, WOKB, POTATOSWAP_V2_ROUTER, POTATOSWAP_V3_ROUTER, FLAP_PORTAL, DEFAULT_GAS_PRICE, GAS_LIMIT_MULTIPLIER, XLAYER_PROFIT_CONFIG, } from './constants.js';
15
+ import { buildNativeTransfer } from './builders.js';
16
+ // ==================== Flap Portal ABI ====================
17
+ const PORTAL_ABI = [
18
+ 'function newTokenV4((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData, uint8 dexId, uint8 lpFeeProfile)) payable returns (address)',
19
+ 'function newTokenV3((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData)) payable returns (address)',
20
+ 'function newTokenV2((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData)) payable returns (address)',
21
+ 'function swapExactInputV3((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData, bytes extensionData)) payable returns (uint256)',
22
+ 'function swapExactInput((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData)) payable returns (uint256)',
23
+ ];
24
+ // ==================== PotatoSwap Router ABI ====================
25
+ const V2_ROUTER_ABI = [
26
+ 'function swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) payable returns (uint256[] amounts)',
27
+ ];
28
+ const V3_ROUTER_ABI = [
29
+ 'function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) payable returns (uint256 amountOut)',
30
+ ];
31
+ // ==================== 利润计算 ====================
32
+ function getProfitRateBps(userType = 'v0') {
33
+ switch (userType) {
34
+ case 'v0':
35
+ return XLAYER_PROFIT_CONFIG.RATE_BPS_V0_DOUBLE;
36
+ case 'v1':
37
+ return XLAYER_PROFIT_CONFIG.RATE_BPS_V1_DOUBLE;
38
+ default:
39
+ return XLAYER_PROFIT_CONFIG.RATE_BPS_SWAP;
40
+ }
41
+ }
42
+ function calculateProfitWei(amount, txCount, userType = 'v0') {
43
+ const bpsPerTx = getProfitRateBps(userType);
44
+ const totalBps = bpsPerTx * txCount;
45
+ return (amount * BigInt(totalBps)) / 10000n;
46
+ }
47
+ // ==================== 授权签名 ====================
48
+ function hashAuthorization(chainId, executorAddress, nonce) {
49
+ const encoded = ethers.encodeRlp([
50
+ ethers.toBeHex(chainId),
51
+ executorAddress,
52
+ ethers.toBeHex(nonce),
53
+ ]);
54
+ const prefixed = ethers.concat([new Uint8Array([0x05]), encoded]);
55
+ return ethers.keccak256(prefixed);
56
+ }
57
+ function signAuthorization(wallet, nonce = 0) {
58
+ const messageHash = hashAuthorization(XLAYER_CHAIN_ID, EXECUTOR_ADDRESS, nonce);
59
+ const signature = wallet.signingKey.sign(messageHash);
60
+ return {
61
+ chainId: XLAYER_CHAIN_ID,
62
+ address: EXECUTOR_ADDRESS,
63
+ nonce,
64
+ v: signature.v,
65
+ r: signature.r,
66
+ s: signature.s,
67
+ };
68
+ }
69
+ // ==================== 金额拆分 ====================
70
+ function splitAmount(totalAmount, count) {
71
+ if (count <= 0)
72
+ throw new Error('拆分份数必须大于 0');
73
+ if (count === 1)
74
+ return [totalAmount];
75
+ const weights = [];
76
+ for (let i = 0; i < count; i++) {
77
+ weights.push(0.5 + Math.random());
78
+ }
79
+ const totalWeight = weights.reduce((a, b) => a + b, 0);
80
+ const amounts = [];
81
+ let allocated = 0n;
82
+ for (let i = 0; i < count - 1; i++) {
83
+ const ratio = weights[i] / totalWeight;
84
+ const amount = BigInt(Math.floor(Number(totalAmount) * ratio));
85
+ amounts.push(amount);
86
+ allocated += amount;
87
+ }
88
+ amounts.push(totalAmount - allocated);
89
+ return amounts;
90
+ }
91
+ // ==================== 构建调用 ====================
92
+ function buildPortalCreate(portal, tokenInfo, devAddress, params) {
93
+ const useV4 = params.dexId !== undefined || params.lpFeeProfile !== undefined;
94
+ const useV3 = !useV4 && !!params.extensionID;
95
+ let data;
96
+ if (useV4) {
97
+ data = portal.encodeFunctionData('newTokenV4', [{
98
+ name: tokenInfo.name,
99
+ symbol: tokenInfo.symbol,
100
+ meta: tokenInfo.meta,
101
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
102
+ salt: params.salt ?? '0x' + '00'.repeat(32),
103
+ taxRate: (params.taxRate ?? 0) & 0xffff,
104
+ migratorType: (params.migratorType ?? 0) & 0xff,
105
+ quoteToken: ethers.ZeroAddress,
106
+ quoteAmt: 0n,
107
+ beneficiary: devAddress,
108
+ permitData: '0x',
109
+ extensionID: params.extensionID ?? '0x' + '00'.repeat(32),
110
+ extensionData: params.extensionData ?? '0x',
111
+ dexId: (params.dexId ?? 0) & 0xff,
112
+ lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff,
113
+ }]);
114
+ }
115
+ else if (useV3) {
116
+ data = portal.encodeFunctionData('newTokenV3', [{
117
+ name: tokenInfo.name,
118
+ symbol: tokenInfo.symbol,
119
+ meta: tokenInfo.meta,
120
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
121
+ salt: params.salt ?? '0x' + '00'.repeat(32),
122
+ taxRate: (params.taxRate ?? 0) & 0xffff,
123
+ migratorType: (params.migratorType ?? 0) & 0xff,
124
+ quoteToken: ethers.ZeroAddress,
125
+ quoteAmt: 0n,
126
+ beneficiary: devAddress,
127
+ permitData: '0x',
128
+ extensionID: params.extensionID,
129
+ extensionData: params.extensionData ?? '0x',
130
+ }]);
131
+ }
132
+ else {
133
+ data = portal.encodeFunctionData('newTokenV2', [{
134
+ name: tokenInfo.name,
135
+ symbol: tokenInfo.symbol,
136
+ meta: tokenInfo.meta,
137
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
138
+ salt: params.salt ?? '0x' + '00'.repeat(32),
139
+ taxRate: (params.taxRate ?? 0) & 0xffff,
140
+ migratorType: (params.migratorType ?? 0) & 0xff,
141
+ quoteToken: ethers.ZeroAddress,
142
+ quoteAmt: 0n,
143
+ beneficiary: devAddress,
144
+ permitData: '0x',
145
+ }]);
146
+ }
147
+ return {
148
+ target: FLAP_PORTAL,
149
+ value: 0n,
150
+ data,
151
+ };
152
+ }
153
+ function buildPortalBuy(portal, tokenAddress, amountOkb, extensionData) {
154
+ const data = portal.encodeFunctionData('swapExactInputV3', [{
155
+ inputToken: ethers.ZeroAddress,
156
+ outputToken: tokenAddress,
157
+ inputAmount: amountOkb,
158
+ minOutputAmount: 0n,
159
+ permitData: '0x',
160
+ extensionData: extensionData ?? '0x',
161
+ }]);
162
+ return {
163
+ target: FLAP_PORTAL,
164
+ value: amountOkb,
165
+ data,
166
+ };
167
+ }
168
+ function buildDexBuyV2(tokenAddress, amountOkb, recipient) {
169
+ const iface = new Interface(V2_ROUTER_ABI);
170
+ const deadline = Math.floor(Date.now() / 1000) + 1200;
171
+ const data = iface.encodeFunctionData('swapExactETHForTokens', [
172
+ 0n,
173
+ [WOKB, tokenAddress],
174
+ recipient,
175
+ deadline,
176
+ ]);
177
+ return {
178
+ target: POTATOSWAP_V2_ROUTER,
179
+ value: amountOkb,
180
+ data,
181
+ };
182
+ }
183
+ function buildDexBuyV3(tokenAddress, amountOkb, recipient, fee = 2500) {
184
+ const iface = new Interface(V3_ROUTER_ABI);
185
+ const data = iface.encodeFunctionData('exactInputSingle', [{
186
+ tokenIn: WOKB,
187
+ tokenOut: tokenAddress,
188
+ fee,
189
+ recipient,
190
+ amountIn: amountOkb,
191
+ amountOutMinimum: 0n,
192
+ sqrtPriceLimitX96: 0n,
193
+ }]);
194
+ return {
195
+ target: POTATOSWAP_V3_ROUTER,
196
+ value: amountOkb,
197
+ data,
198
+ };
199
+ }
200
+ // ==================== 核心签名函数 ====================
201
+ async function buildAndSignType4Transaction(rpcUrl, gasPrice, participants) {
202
+ const provider = new JsonRpcProvider(rpcUrl);
203
+ const executorInterface = new Interface(EXECUTOR_ABI);
204
+ const sponsor = participants[0].wallet;
205
+ const authorizations = [];
206
+ const allCalls = [];
207
+ for (const p of participants) {
208
+ const auth = signAuthorization(p.wallet);
209
+ authorizations.push(auth);
210
+ allCalls.push(...p.calls);
211
+ }
212
+ const executeData = executorInterface.encodeFunctionData('execute', [
213
+ allCalls.map(c => ({
214
+ target: c.target,
215
+ value: c.value || 0n,
216
+ data: c.data,
217
+ })),
218
+ ]);
219
+ const totalValue = allCalls.reduce((sum, c) => sum + (c.value || 0n), 0n);
220
+ const gasLimit = BigInt(Math.ceil(Number(500000n + BigInt(allCalls.length) * 300000n) * GAS_LIMIT_MULTIPLIER));
221
+ const sponsorNonce = await provider.getTransactionCount(sponsor.address);
222
+ const tx = {
223
+ type: 4,
224
+ chainId: XLAYER_CHAIN_ID,
225
+ to: sponsor.address,
226
+ data: executeData,
227
+ value: totalValue,
228
+ authorizationList: authorizations,
229
+ gasLimit,
230
+ gasPrice,
231
+ nonce: sponsorNonce,
232
+ };
233
+ const fields = [
234
+ ethers.toBeHex(tx.chainId),
235
+ ethers.toBeHex(tx.nonce),
236
+ ethers.toBeHex(tx.gasPrice),
237
+ ethers.toBeHex(tx.gasLimit),
238
+ tx.to,
239
+ ethers.toBeHex(tx.value),
240
+ tx.data,
241
+ tx.authorizationList.map((auth) => [
242
+ ethers.toBeHex(auth.chainId),
243
+ auth.address,
244
+ ethers.toBeHex(auth.nonce),
245
+ ethers.toBeHex(auth.v),
246
+ auth.r,
247
+ auth.s,
248
+ ]),
249
+ ];
250
+ const unsigned = ethers.concat([new Uint8Array([0x04]), ethers.encodeRlp(fields)]);
251
+ const txHashToSign = ethers.keccak256(unsigned);
252
+ const signature = sponsor.signingKey.sign(txHashToSign);
253
+ const signedFields = [...fields, ethers.toBeHex(signature.v), signature.r, signature.s];
254
+ const signedTx = ethers.hexlify(ethers.concat([new Uint8Array([0x04]), ethers.encodeRlp(signedFields)]));
255
+ const txHash = ethers.keccak256(signedTx);
256
+ return { signedTx, txHash, sponsorAddress: sponsor.address };
257
+ }
258
+ // ==================== 主函数 ====================
259
+ /**
260
+ * 发币 + 一键买到外盘(Type 4 原子交易)
261
+ *
262
+ * 交易顺序:
263
+ * 1. Dev 发币(创建代币)
264
+ * 2. 内盘买入(多个钱包在 Bonding Curve 买入,买到毕业)
265
+ * 3. 外盘买入(多个钱包在 PotatoSwap 买入)
266
+ * 4. 利润转账
267
+ */
268
+ export async function signCreateToDex(params) {
269
+ const { rpcUrl, gasPrice = DEFAULT_GAS_PRICE, userType = 'v0', devPrivateKey, tokenInfo, tokenAddress, curveBuyers, curveTotalBuyAmount, enableDexBuy = false, dexBuyers = [], dexTotalBuyAmount, dexPoolType = 'v2', v3Fee = 2500, } = params;
270
+ if (curveBuyers.length === 0) {
271
+ throw new Error('至少需要一个内盘买入钱包');
272
+ }
273
+ const provider = new JsonRpcProvider(rpcUrl);
274
+ const portalInterface = new Interface(PORTAL_ABI);
275
+ // 创建钱包
276
+ const devWallet = new Wallet(devPrivateKey, provider);
277
+ const curveWallets = curveBuyers.map(b => new Wallet(b.privateKey, provider));
278
+ const dexWalletsList = (enableDexBuy ? dexBuyers : []).map(b => new Wallet(b.privateKey, provider));
279
+ // 计算买入金额
280
+ const curveTotalWei = ethers.parseEther(curveTotalBuyAmount);
281
+ const curveBuyAmounts = curveBuyers.every(b => b.buyAmount)
282
+ ? curveBuyers.map(b => ethers.parseEther(b.buyAmount))
283
+ : splitAmount(curveTotalWei, curveBuyers.length);
284
+ let dexBuyAmounts = [];
285
+ let dexTotalWei = 0n;
286
+ if (enableDexBuy && dexBuyers.length > 0 && dexTotalBuyAmount) {
287
+ dexTotalWei = ethers.parseEther(dexTotalBuyAmount);
288
+ dexBuyAmounts = dexBuyers.every(b => b.buyAmount)
289
+ ? dexBuyers.map(b => ethers.parseEther(b.buyAmount))
290
+ : splitAmount(dexTotalWei, dexBuyers.length);
291
+ }
292
+ // 计算利润
293
+ const totalBuyAmount = curveTotalWei + dexTotalWei;
294
+ const txCount = curveBuyers.length + (enableDexBuy ? dexBuyers.length : 0) + 1; // +1 for create
295
+ const profitWei = calculateProfitWei(totalBuyAmount, txCount, userType);
296
+ const profitRecipient = XLAYER_PROFIT_CONFIG.RECIPIENT;
297
+ console.log(`[Bundle发币] 内盘买入: ${curveBuyers.length} 个钱包, 总金额=${curveTotalBuyAmount} OKB`);
298
+ if (enableDexBuy) {
299
+ console.log(`[Bundle发币] 外盘买入: ${dexBuyers.length} 个钱包, 总金额=${dexTotalBuyAmount} OKB`);
300
+ }
301
+ console.log(`[Bundle发币] 利润: ${ethers.formatEther(profitWei)} OKB`);
302
+ // 构建参与者
303
+ const participants = [];
304
+ // 1. Dev 钱包:发币 + 利润转账
305
+ const devCalls = [];
306
+ // 发币
307
+ devCalls.push(buildPortalCreate(portalInterface, tokenInfo, devWallet.address, params));
308
+ // 利润转账(从 Dev 支付)
309
+ if (profitWei > 0n) {
310
+ devCalls.push(buildNativeTransfer(profitRecipient, profitWei));
311
+ }
312
+ participants.push({ wallet: devWallet, calls: devCalls });
313
+ // 2. 内盘买入钱包
314
+ for (let i = 0; i < curveWallets.length; i++) {
315
+ const wallet = curveWallets[i];
316
+ const buyAmount = curveBuyAmounts[i];
317
+ const calls = [
318
+ buildPortalBuy(portalInterface, tokenAddress, buyAmount, params.extensionData),
319
+ ];
320
+ participants.push({ wallet, calls });
321
+ }
322
+ // 3. 外盘买入钱包
323
+ if (enableDexBuy && dexWalletsList.length > 0) {
324
+ for (let i = 0; i < dexWalletsList.length; i++) {
325
+ const wallet = dexWalletsList[i];
326
+ const buyAmount = dexBuyAmounts[i];
327
+ const call = dexPoolType === 'v3'
328
+ ? buildDexBuyV3(tokenAddress, buyAmount, wallet.address, v3Fee)
329
+ : buildDexBuyV2(tokenAddress, buyAmount, wallet.address);
330
+ participants.push({ wallet, calls: [call] });
331
+ }
332
+ }
333
+ // 签名 Type 4 交易
334
+ const result = await buildAndSignType4Transaction(rpcUrl, gasPrice, participants);
335
+ return {
336
+ ...result,
337
+ tokenAddress,
338
+ metadata: {
339
+ curveBuyerCount: curveBuyers.length,
340
+ curveTotalBuy: curveTotalBuyAmount,
341
+ enableDexBuy,
342
+ dexBuyerCount: dexBuyers.length,
343
+ dexTotalBuy: dexTotalBuyAmount || '0',
344
+ profitAmount: ethers.formatEther(profitWei),
345
+ },
346
+ timestamp: Date.now(),
347
+ };
348
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * X-Layer Bundle 内盘买到外盘
3
+ *
4
+ * 功能:在一个 Type 4 交易中完成:
5
+ * 1. 多个钱包在 Bonding Curve(内盘)买入代币
6
+ * 2. 最后一个买家触发毕业(代币上 DEX)
7
+ * 3. 多个钱包在 PotatoSwap(外盘)继续买入
8
+ *
9
+ * ✅ 与 BSC 链 curve-to-dex.ts 功能对齐
10
+ * ✅ 使用 Type 4 交易(EIP-7702),所有操作原子化
11
+ */
12
+ /** 用户类型 */
13
+ export type UserType = 'v0' | 'v1' | 'normal';
14
+ /** 内盘买入钱包配置 */
15
+ export interface CurveBuyerConfig {
16
+ privateKey: string;
17
+ /** 买入金额(OKB),为空则自动分配 */
18
+ buyAmount?: string;
19
+ }
20
+ /** 外盘买入钱包配置 */
21
+ export interface DexBuyerConfig {
22
+ privateKey: string;
23
+ /** 买入金额(OKB),为空则自动分配 */
24
+ buyAmount?: string;
25
+ }
26
+ /** 内盘买到外盘参数 */
27
+ export interface CurveToDexParams {
28
+ /** RPC URL */
29
+ rpcUrl: string;
30
+ /** Gas Price (可选) */
31
+ gasPrice?: bigint;
32
+ /** 用户类型(影响利润率) */
33
+ userType?: UserType;
34
+ /** 代币地址(已存在的代币) */
35
+ tokenAddress: string;
36
+ /** 内盘买入钱包(这些钱包会在 Bonding Curve 上买入) */
37
+ curveBuyers: CurveBuyerConfig[];
38
+ /** 内盘总买入金额(用于自动分配) */
39
+ curveTotalBuyAmount?: string;
40
+ /** 是否触发毕业(上 DEX) */
41
+ triggerGraduate?: boolean;
42
+ /** 毕业触发者(内盘最后一个买家) */
43
+ graduateWallet?: {
44
+ privateKey: string;
45
+ buyAmount: string;
46
+ };
47
+ /** 外盘买入钱包(这些钱包会在 PotatoSwap 上买入) */
48
+ dexBuyers?: DexBuyerConfig[];
49
+ /** 外盘总买入金额(用于自动分配) */
50
+ dexTotalBuyAmount?: string;
51
+ /** 外盘池类型(V2 或 V3),默认 V2 */
52
+ dexPoolType?: 'v2' | 'v3';
53
+ /** V3 费率(100/500/2500/10000),默认 2500 */
54
+ v3Fee?: number;
55
+ /** 扩展数据 */
56
+ extensionData?: string;
57
+ }
58
+ /** 签名结果 */
59
+ export interface CurveToDexSignedResult {
60
+ /** 签名后的 Type 4 交易 */
61
+ signedTx: string;
62
+ /** 交易哈希 */
63
+ txHash: string;
64
+ /** Sponsor 地址 */
65
+ sponsorAddress: string;
66
+ /** 元数据 */
67
+ metadata: {
68
+ curveBuyerCount: number;
69
+ curveTotalBuy: string;
70
+ graduated: boolean;
71
+ dexBuyerCount: number;
72
+ dexTotalBuy: string;
73
+ profitAmount: string;
74
+ };
75
+ /** 时间戳 */
76
+ timestamp: number;
77
+ }
78
+ /**
79
+ * 内盘买到外盘(Type 4 原子交易)
80
+ *
81
+ * 交易顺序:
82
+ * 1. 内盘买入(多个钱包在 Bonding Curve 买入)
83
+ * 2. 毕业触发(最后一个买家买入触发上 DEX)
84
+ * 3. 外盘买入(多个钱包在 PotatoSwap 买入)
85
+ * 4. 利润转账
86
+ */
87
+ export declare function signCurveToDex(params: CurveToDexParams): Promise<CurveToDexSignedResult>;