four-flap-meme-sdk 1.5.10 → 1.5.12
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/README.zh-CN.pdf +0 -0
- package/dist/contracts/tm-bundle-merkle/submit.js +58 -0
- package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
- package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
- package/dist/flap/portal-bundle-merkle/private.js +8 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +4 -2
- package/dist/xlayer/constants.d.ts +2 -0
- package/dist/xlayer/constants.js +2 -0
- package/package.json +5 -44
- package/dist/sol/constants.d.ts +0 -150
- package/dist/sol/constants.js +0 -188
- package/dist/sol/dex/blockrazor/client.d.ts +0 -51
- package/dist/sol/dex/blockrazor/client.js +0 -96
- package/dist/sol/dex/blockrazor/constants.d.ts +0 -34
- package/dist/sol/dex/blockrazor/constants.js +0 -55
- package/dist/sol/dex/blockrazor/geyser.d.ts +0 -128
- package/dist/sol/dex/blockrazor/geyser.js +0 -530
- package/dist/sol/dex/blockrazor/index.d.ts +0 -18
- package/dist/sol/dex/blockrazor/index.js +0 -23
- package/dist/sol/dex/blockrazor/send.d.ts +0 -135
- package/dist/sol/dex/blockrazor/send.js +0 -254
- package/dist/sol/dex/blockrazor/types.d.ts +0 -191
- package/dist/sol/dex/blockrazor/types.js +0 -5
- package/dist/sol/dex/index.d.ts +0 -10
- package/dist/sol/dex/index.js +0 -16
- package/dist/sol/dex/jup/client.d.ts +0 -33
- package/dist/sol/dex/jup/client.js +0 -110
- package/dist/sol/dex/jup/index.d.ts +0 -16
- package/dist/sol/dex/jup/index.js +0 -148
- package/dist/sol/dex/jup/legacy.d.ts +0 -623
- package/dist/sol/dex/jup/legacy.js +0 -416
- package/dist/sol/dex/jup/lend.d.ts +0 -640
- package/dist/sol/dex/jup/lend.js +0 -603
- package/dist/sol/dex/jup/portfolio.d.ts +0 -362
- package/dist/sol/dex/jup/portfolio.js +0 -367
- package/dist/sol/dex/jup/price.d.ts +0 -173
- package/dist/sol/dex/jup/price.js +0 -220
- package/dist/sol/dex/jup/recurring.d.ts +0 -437
- package/dist/sol/dex/jup/recurring.js +0 -320
- package/dist/sol/dex/jup/send.d.ts +0 -282
- package/dist/sol/dex/jup/send.js +0 -295
- package/dist/sol/dex/jup/studio.d.ts +0 -457
- package/dist/sol/dex/jup/studio.js +0 -488
- package/dist/sol/dex/jup/tokens.d.ts +0 -767
- package/dist/sol/dex/jup/tokens.js +0 -697
- package/dist/sol/dex/jup/trigger.d.ts +0 -511
- package/dist/sol/dex/jup/trigger.js +0 -397
- package/dist/sol/dex/jup/types.d.ts +0 -433
- package/dist/sol/dex/jup/types.js +0 -5
- package/dist/sol/dex/jup/ultra.d.ts +0 -646
- package/dist/sol/dex/jup/ultra.js +0 -853
- 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 -11
- package/dist/sol/index.js +0 -18
- 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/nozomi/client.d.ts +0 -63
- package/dist/sol/nozomi/client.js +0 -222
- package/dist/sol/nozomi/index.d.ts +0 -8
- package/dist/sol/nozomi/index.js +0 -8
- package/dist/sol/nozomi/tip.d.ts +0 -50
- package/dist/sol/nozomi/tip.js +0 -80
- package/dist/sol/nozomi/types.d.ts +0 -96
- package/dist/sol/nozomi/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 -196
- package/dist/sol/utils/transfer.js +0 -307
- package/dist/sol/utils/wallet.d.ts +0 -107
- package/dist/sol/utils/wallet.js +0 -210
package/README.zh-CN.pdf
ADDED
|
Binary file
|
|
@@ -250,6 +250,30 @@ export async function submitMultipleBundlesToBlockRazorParallel(bundles, config)
|
|
|
250
250
|
const promises = bundles.map(signedTransactions => submitBundleToBlockRazor(signedTransactions, config));
|
|
251
251
|
return await Promise.all(promises);
|
|
252
252
|
}
|
|
253
|
+
function shouldTreatBroadcastErrorAsMaybeSent(msg) {
|
|
254
|
+
const m = String(msg || '').toLowerCase();
|
|
255
|
+
// 常见:交易已被节点接收/已在 mempool/已上链,但节点返回报错
|
|
256
|
+
return (m.includes('already known') ||
|
|
257
|
+
m.includes('known transaction') ||
|
|
258
|
+
m.includes('nonce too low') ||
|
|
259
|
+
m.includes('nonce has already been used') ||
|
|
260
|
+
m.includes('nonce expired') ||
|
|
261
|
+
m.includes('replacement transaction underpriced'));
|
|
262
|
+
}
|
|
263
|
+
async function recoverTxHashIfAlreadySeen(provider, signedTx, errorMessage) {
|
|
264
|
+
if (!shouldTreatBroadcastErrorAsMaybeSent(errorMessage))
|
|
265
|
+
return undefined;
|
|
266
|
+
try {
|
|
267
|
+
const hash = ethers.keccak256(signedTx);
|
|
268
|
+
if (!hash)
|
|
269
|
+
return undefined;
|
|
270
|
+
const tx = await provider.getTransaction(hash);
|
|
271
|
+
return tx ? hash : undefined;
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
253
277
|
/**
|
|
254
278
|
* 并行广播到 RPC(用于不支持 Bundle 的链,如 Monad)
|
|
255
279
|
*
|
|
@@ -333,6 +357,17 @@ export async function submitDirectToRpc(signedTransactions, config) {
|
|
|
333
357
|
catch (error) {
|
|
334
358
|
const errorMessage = error?.message || String(error);
|
|
335
359
|
console.error(`❌ [${chainName}] 交易 ${i + 1}/${totalTransactions} 广播失败:`, errorMessage);
|
|
360
|
+
// ✅ 兼容:nonce too low / already known 等情况下,交易可能已经被接收
|
|
361
|
+
const recovered = await recoverTxHashIfAlreadySeen(provider, signedTx, errorMessage);
|
|
362
|
+
if (recovered) {
|
|
363
|
+
if (config.waitForConfirmation) {
|
|
364
|
+
try {
|
|
365
|
+
await provider.waitForTransaction(recovered, 1, config.confirmationTimeout ?? 30000);
|
|
366
|
+
}
|
|
367
|
+
catch { }
|
|
368
|
+
}
|
|
369
|
+
return { index: i, success: true, txHash: recovered, error: errorMessage };
|
|
370
|
+
}
|
|
336
371
|
return {
|
|
337
372
|
index: i,
|
|
338
373
|
success: false,
|
|
@@ -431,6 +466,29 @@ export async function submitDirectToRpcSequential(signedTransactions, config) {
|
|
|
431
466
|
}
|
|
432
467
|
catch (error) {
|
|
433
468
|
const errorMessage = error?.message || String(error);
|
|
469
|
+
// ✅ 兼容:nonce too low / already known 等情况下,交易可能已经被接收
|
|
470
|
+
const recovered = await recoverTxHashIfAlreadySeen(provider, signedTx, errorMessage);
|
|
471
|
+
if (recovered) {
|
|
472
|
+
// 顺序模式依赖确认:尽量等待一下
|
|
473
|
+
try {
|
|
474
|
+
const receipt = await provider.waitForTransaction(recovered, 1, confirmationTimeout);
|
|
475
|
+
if (receipt && receipt.status === 1) {
|
|
476
|
+
results.push({ index: i, success: true, txHash: recovered, error: errorMessage });
|
|
477
|
+
txHashes.push(recovered);
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
const errorMsg = `交易执行失败(status=${receipt?.status})`;
|
|
481
|
+
results.push({ index: i, success: false, txHash: recovered, error: `${errorMessage} | ${errorMsg}` });
|
|
482
|
+
errors.push(`交易 ${i + 1}: ${errorMessage} | ${errorMsg}`);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
catch {
|
|
486
|
+
// 等待超时也先认为“已广播”,交给上层自行确认
|
|
487
|
+
results.push({ index: i, success: true, txHash: recovered, error: errorMessage });
|
|
488
|
+
txHashes.push(recovered);
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
434
492
|
results.push({
|
|
435
493
|
index: i,
|
|
436
494
|
success: false,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECDH + AES-GCM 加密工具(浏览器兼容)
|
|
3
|
+
* 用于将签名交易用服务器公钥加密
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 用服务器公钥加密签名交易(ECDH + AES-GCM)
|
|
7
|
+
*
|
|
8
|
+
* @param signedTransactions 签名后的交易数组
|
|
9
|
+
* @param publicKeyBase64 服务器提供的公钥(Base64 格式)
|
|
10
|
+
* @returns JSON 字符串 {e: 临时公钥, i: IV, d: 密文}
|
|
11
|
+
*/
|
|
12
|
+
export declare function encryptWithPublicKey(signedTransactions: string[], publicKeyBase64: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* 验证公钥格式(Base64)
|
|
15
|
+
*/
|
|
16
|
+
export declare function validatePublicKey(publicKeyBase64: string): boolean;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECDH + AES-GCM 加密工具(浏览器兼容)
|
|
3
|
+
* 用于将签名交易用服务器公钥加密
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 获取全局 crypto 对象(最简单直接的方式)
|
|
7
|
+
*/
|
|
8
|
+
function getCryptoAPI() {
|
|
9
|
+
// 尝试所有可能的全局对象,优先浏览器环境
|
|
10
|
+
const cryptoObj = (typeof window !== 'undefined' && window.crypto) ||
|
|
11
|
+
(typeof self !== 'undefined' && self.crypto) ||
|
|
12
|
+
(typeof global !== 'undefined' && global.crypto) ||
|
|
13
|
+
(typeof globalThis !== 'undefined' && globalThis.crypto);
|
|
14
|
+
if (!cryptoObj) {
|
|
15
|
+
const env = typeof window !== 'undefined' ? 'Browser' : 'Node.js';
|
|
16
|
+
const protocol = typeof location !== 'undefined' ? location.protocol : 'unknown';
|
|
17
|
+
throw new Error(`❌ Crypto API 不可用。环境: ${env}, 协议: ${protocol}. ` +
|
|
18
|
+
'请确保在 HTTPS 或 localhost 下运行');
|
|
19
|
+
}
|
|
20
|
+
return cryptoObj;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 获取 SubtleCrypto(用于加密操作)
|
|
24
|
+
*/
|
|
25
|
+
function getSubtleCrypto() {
|
|
26
|
+
const crypto = getCryptoAPI();
|
|
27
|
+
if (!crypto.subtle) {
|
|
28
|
+
const protocol = typeof location !== 'undefined' ? location.protocol : 'unknown';
|
|
29
|
+
const hostname = typeof location !== 'undefined' ? location.hostname : 'unknown';
|
|
30
|
+
throw new Error(`❌ SubtleCrypto API 不可用。协议: ${protocol}, 主机: ${hostname}. ` +
|
|
31
|
+
'请确保:1) 使用 HTTPS (或 localhost);2) 浏览器支持 Web Crypto API;' +
|
|
32
|
+
'3) 不在无痕/隐私浏览模式下');
|
|
33
|
+
}
|
|
34
|
+
return crypto.subtle;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Base64 转 ArrayBuffer(优先使用浏览器 API)
|
|
38
|
+
*/
|
|
39
|
+
function base64ToArrayBuffer(base64) {
|
|
40
|
+
// 浏览器环境(优先)
|
|
41
|
+
if (typeof atob !== 'undefined') {
|
|
42
|
+
const binaryString = atob(base64);
|
|
43
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
44
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
45
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
46
|
+
}
|
|
47
|
+
return bytes.buffer;
|
|
48
|
+
}
|
|
49
|
+
// Node.js 环境(fallback)
|
|
50
|
+
if (typeof Buffer !== 'undefined') {
|
|
51
|
+
return Buffer.from(base64, 'base64').buffer;
|
|
52
|
+
}
|
|
53
|
+
throw new Error('❌ Base64 解码不可用');
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* ArrayBuffer 转 Base64(优先使用浏览器 API)
|
|
57
|
+
*/
|
|
58
|
+
function arrayBufferToBase64(buffer) {
|
|
59
|
+
// 浏览器环境(优先)
|
|
60
|
+
if (typeof btoa !== 'undefined') {
|
|
61
|
+
const bytes = new Uint8Array(buffer);
|
|
62
|
+
let binary = '';
|
|
63
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
64
|
+
binary += String.fromCharCode(bytes[i]);
|
|
65
|
+
}
|
|
66
|
+
return btoa(binary);
|
|
67
|
+
}
|
|
68
|
+
// Node.js 环境(fallback)
|
|
69
|
+
if (typeof Buffer !== 'undefined') {
|
|
70
|
+
return Buffer.from(buffer).toString('base64');
|
|
71
|
+
}
|
|
72
|
+
throw new Error('❌ Base64 编码不可用');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 生成随机 Hex 字符串
|
|
76
|
+
*/
|
|
77
|
+
function randomHex(length) {
|
|
78
|
+
const crypto = getCryptoAPI();
|
|
79
|
+
const array = new Uint8Array(length);
|
|
80
|
+
crypto.getRandomValues(array);
|
|
81
|
+
return Array.from(array)
|
|
82
|
+
.map(b => b.toString(16).padStart(2, '0'))
|
|
83
|
+
.join('');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 用服务器公钥加密签名交易(ECDH + AES-GCM)
|
|
87
|
+
*
|
|
88
|
+
* @param signedTransactions 签名后的交易数组
|
|
89
|
+
* @param publicKeyBase64 服务器提供的公钥(Base64 格式)
|
|
90
|
+
* @returns JSON 字符串 {e: 临时公钥, i: IV, d: 密文}
|
|
91
|
+
*/
|
|
92
|
+
export async function encryptWithPublicKey(signedTransactions, publicKeyBase64) {
|
|
93
|
+
try {
|
|
94
|
+
// 0. 获取 SubtleCrypto 和 Crypto API
|
|
95
|
+
const subtle = getSubtleCrypto();
|
|
96
|
+
const crypto = getCryptoAPI();
|
|
97
|
+
// 1. 准备数据
|
|
98
|
+
const payload = {
|
|
99
|
+
signedTransactions,
|
|
100
|
+
timestamp: Date.now(),
|
|
101
|
+
nonce: randomHex(8)
|
|
102
|
+
};
|
|
103
|
+
const plaintext = JSON.stringify(payload);
|
|
104
|
+
// 2. 生成临时 ECDH 密钥对
|
|
105
|
+
const ephemeralKeyPair = await subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, true, ['deriveKey']);
|
|
106
|
+
// 3. 导入服务器公钥
|
|
107
|
+
const publicKeyBuffer = base64ToArrayBuffer(publicKeyBase64);
|
|
108
|
+
const publicKey = await subtle.importKey('raw', publicKeyBuffer, { name: 'ECDH', namedCurve: 'P-256' }, false, []);
|
|
109
|
+
// 4. 派生共享密钥(AES-256)
|
|
110
|
+
const sharedKey = await subtle.deriveKey({ name: 'ECDH', public: publicKey }, ephemeralKeyPair.privateKey, { name: 'AES-GCM', length: 256 }, false, ['encrypt']);
|
|
111
|
+
// 5. AES-GCM 加密
|
|
112
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
113
|
+
const encrypted = await subtle.encrypt({ name: 'AES-GCM', iv }, sharedKey, new TextEncoder().encode(plaintext));
|
|
114
|
+
// 6. 导出临时公钥
|
|
115
|
+
const ephemeralPublicKeyRaw = await subtle.exportKey('raw', ephemeralKeyPair.publicKey);
|
|
116
|
+
// 7. 返回加密包(JSON 格式)
|
|
117
|
+
return JSON.stringify({
|
|
118
|
+
e: arrayBufferToBase64(ephemeralPublicKeyRaw), // 临时公钥
|
|
119
|
+
i: arrayBufferToBase64(iv.buffer), // IV
|
|
120
|
+
d: arrayBufferToBase64(encrypted) // 密文
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
throw new Error(`加密失败: ${error?.message || String(error)}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 验证公钥格式(Base64)
|
|
129
|
+
*/
|
|
130
|
+
export function validatePublicKey(publicKeyBase64) {
|
|
131
|
+
try {
|
|
132
|
+
if (!publicKeyBase64)
|
|
133
|
+
return false;
|
|
134
|
+
// Base64 字符集验证
|
|
135
|
+
if (!/^[A-Za-z0-9+/=]+$/.test(publicKeyBase64))
|
|
136
|
+
return false;
|
|
137
|
+
// ECDH P-256 公钥固定长度 65 字节(未压缩)
|
|
138
|
+
// Base64 编码后约 88 字符
|
|
139
|
+
if (publicKeyBase64.length < 80 || publicKeyBase64.length > 100)
|
|
140
|
+
return false;
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -22,7 +22,8 @@ export async function flapPrivateBuyMerkle(params) {
|
|
|
22
22
|
// ✅ 并行获取 gasPrice、nonce 和构建未签名交易
|
|
23
23
|
const [gasPrice, currentNonce, unsigned] = await Promise.all([
|
|
24
24
|
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
25
|
-
|
|
25
|
+
// ✅ 使用 pending nonce,避免 xLayer 等链上“已有 pending 交易”导致 nonce too low
|
|
26
|
+
provider.getTransactionCount(wallet.address, 'pending'),
|
|
26
27
|
portal.swapExactInput.populateTransaction({
|
|
27
28
|
inputToken: ZERO_ADDRESS,
|
|
28
29
|
outputToken: tokenAddress,
|
|
@@ -101,7 +102,8 @@ export async function flapPrivateSellMerkle(params) {
|
|
|
101
102
|
// ✅ 并行获取 gasPrice、nonce、报价和构建未签名交易
|
|
102
103
|
const [gasPrice, currentNonce, { quotedOutput }, unsigned] = await Promise.all([
|
|
103
104
|
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
104
|
-
|
|
105
|
+
// ✅ 使用 pending nonce,避免 xLayer 等链上“已有 pending 交易”导致 nonce too low
|
|
106
|
+
provider.getTransactionCount(wallet.address, 'pending'),
|
|
105
107
|
resolveSingleSellOutputs(portal, tokenAddress, amountWei, minOutputAmount),
|
|
106
108
|
portal.swapExactInput.populateTransaction({
|
|
107
109
|
inputToken: tokenAddress,
|
|
@@ -198,7 +200,8 @@ export async function flapBatchPrivateBuyMerkle(params) {
|
|
|
198
200
|
// ✅ 并行获取 gasPrice、所有 nonces 和构建未签名交易
|
|
199
201
|
const [gasPrice, initialNonces, unsignedList] = await Promise.all([
|
|
200
202
|
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
201
|
-
|
|
203
|
+
// ✅ 使用 pending nonce,避免 xLayer 等链上“已有 pending 交易”导致 nonce too low
|
|
204
|
+
Promise.all(wallets.map(w => provider.getTransactionCount(w.address, 'pending'))),
|
|
202
205
|
Promise.all(portals.map((portal, i) => portal.swapExactInput.populateTransaction({
|
|
203
206
|
inputToken: ZERO_ADDRESS,
|
|
204
207
|
outputToken: tokenAddress,
|
|
@@ -287,7 +290,8 @@ export async function flapBatchPrivateSellMerkle(params) {
|
|
|
287
290
|
// ✅ 并行获取 gasPrice、所有 nonces、所有报价和构建未签名交易
|
|
288
291
|
const [gasPrice, initialNonces, quotedOutputs, unsignedList] = await Promise.all([
|
|
289
292
|
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
290
|
-
|
|
293
|
+
// ✅ 使用 pending nonce,避免 xLayer 等链上“已有 pending 交易”导致 nonce too low
|
|
294
|
+
Promise.all(wallets.map(w => provider.getTransactionCount(w.address, 'pending'))),
|
|
291
295
|
Promise.all(amountsWei.map(amount => portal.quoteExactInput.staticCall({
|
|
292
296
|
inputToken: tokenAddress,
|
|
293
297
|
outputToken: ZERO_ADDRESS,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * as Abis from './abis/index.js';
|
|
2
|
-
export * as Sol from './sol/index.js';
|
|
3
2
|
export { ERC20_ABI, ERC20_BALANCE_ABI, ERC20_ALLOWANCE_ABI, MULTICALL3_ABI, V2_ROUTER_ABI, V2_ROUTER_QUOTE_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, V3_QUOTER_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, V3_POOL_ABI, FLAP_PORTAL_ABI, TM2_ABI, HELPER3_ABI, } from './abis/common.js';
|
|
4
3
|
export { ADDRESSES, CHAIN, BLOCKRAZOR_BUILDER_EOA as BUILDER_EOA, ZERO_ADDRESS as COMMON_ZERO_ADDRESS, DEFAULT_DEADLINE_MINUTES, V3_FEE_TIERS as COMMON_V3_FEE_TIERS, } from './utils/constants.js';
|
|
5
4
|
export { isExclusiveOnChain, isExclusiveOffChain } from './utils/mpcExclusive.js';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// 公共 ABI(统一管理)
|
|
3
3
|
// ============================================================================
|
|
4
4
|
export * as Abis from './abis/index.js';
|
|
5
|
-
export * as Sol from './sol/index.js';
|
|
5
|
+
// export * as Sol from './sol/index.js';
|
|
6
6
|
export { ERC20_ABI, ERC20_BALANCE_ABI, ERC20_ALLOWANCE_ABI, MULTICALL3_ABI, V2_ROUTER_ABI, V2_ROUTER_QUOTE_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, V3_QUOTER_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, V3_POOL_ABI, FLAP_PORTAL_ABI, TM2_ABI, HELPER3_ABI, } from './abis/common.js';
|
|
7
7
|
// ============================================================================
|
|
8
8
|
// 公共常量(统一管理)
|
|
@@ -89,6 +89,7 @@ export declare const ADDRESSES: {
|
|
|
89
89
|
readonly PotatoSwapV3Factory: "0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5";
|
|
90
90
|
readonly USDT: "0x1e4a5963abfd975d8c9021ce480b42188849d41d";
|
|
91
91
|
readonly USDC: "0x74b7f16337b8972027f6196a17a631ac6de26d22";
|
|
92
|
+
readonly USDT0: "0x779ded0c9e1022225f8e0630b35a9b54be713736";
|
|
92
93
|
};
|
|
93
94
|
readonly MORPH: {
|
|
94
95
|
readonly FlapPortal: "0x6aB823408672c0Db1DE1a18F1750d62E5F995A58";
|
package/dist/utils/constants.js
CHANGED
|
@@ -94,8 +94,10 @@ export const ADDRESSES = {
|
|
|
94
94
|
PotatoSwapV3Router: '0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41', // V3 Router
|
|
95
95
|
PotatoSwapV3Factory: '0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5', // V3 Factory
|
|
96
96
|
// 稳定币
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
// 注意:Flap xLayer 发币/内盘计价支持的是 USD₮0(USDT0),不是原生桥接 USDT/USDC
|
|
98
|
+
USDT: '0x1e4a5963abfd975d8c9021ce480b42188849d41d', // 6位精度(不一定被 Flap 内盘支持)
|
|
99
|
+
USDC: '0x74b7f16337b8972027f6196a17a631ac6de26d22', // 6位精度(不一定被 Flap 内盘支持)
|
|
100
|
+
USDT0: '0x779ded0c9e1022225f8e0630b35a9b54be713736', // 6位精度(USD₮0)
|
|
99
101
|
},
|
|
100
102
|
MORPH: {
|
|
101
103
|
// Flap Portal
|
|
@@ -38,6 +38,8 @@ export declare const POTATOSWAP_V3_FACTORY = "0xa1415fAe79c4B196d087F02b8aD5a622
|
|
|
38
38
|
export declare const USDT = "0x1e4a5963abfd975d8c9021ce480b42188849d41d";
|
|
39
39
|
/** USDC (6位精度) */
|
|
40
40
|
export declare const USDC = "0x74b7f16337b8972027f6196a17a631ac6de26d22";
|
|
41
|
+
/** USD₮0 / USDT0 (6位精度) - Flap xLayer 支持的稳定币计价 */
|
|
42
|
+
export declare const USDT0 = "0x779ded0c9e1022225f8e0630b35a9b54be713736";
|
|
41
43
|
/** 零地址(表示原生代币 OKB) */
|
|
42
44
|
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
43
45
|
/** 默认 Gas Price 兜底值(0.1 gwei) */
|
package/dist/xlayer/constants.js
CHANGED
|
@@ -53,6 +53,8 @@ export const POTATOSWAP_V3_FACTORY = '0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5
|
|
|
53
53
|
export const USDT = '0x1e4a5963abfd975d8c9021ce480b42188849d41d';
|
|
54
54
|
/** USDC (6位精度) */
|
|
55
55
|
export const USDC = '0x74b7f16337b8972027f6196a17a631ac6de26d22';
|
|
56
|
+
/** USD₮0 / USDT0 (6位精度) - Flap xLayer 支持的稳定币计价 */
|
|
57
|
+
export const USDT0 = '0x779ded0c9e1022225f8e0630b35a9b54be713736';
|
|
56
58
|
// ============================================================================
|
|
57
59
|
// 零地址
|
|
58
60
|
// ============================================================================
|
package/package.json
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "four-flap-meme-sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.12",
|
|
4
4
|
"description": "SDK for Flap bonding curve and four.meme TokenManager",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"default": "./dist/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./sol": {
|
|
15
|
-
"types": "./dist/sol/index.d.ts",
|
|
16
|
-
"import": "./dist/sol/index.js",
|
|
17
|
-
"default": "./dist/sol/index.js"
|
|
18
|
-
},
|
|
19
|
-
"./sol/*": {
|
|
20
|
-
"types": "./dist/sol/*.d.ts",
|
|
21
|
-
"import": "./dist/sol/*.js",
|
|
22
|
-
"default": "./dist/sol/*.js"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
8
|
"files": [
|
|
26
9
|
"dist",
|
|
27
10
|
"src/abis/*.json"
|
|
@@ -46,33 +29,11 @@
|
|
|
46
29
|
"node": ">=18"
|
|
47
30
|
},
|
|
48
31
|
"dependencies": {
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"@metaplex-foundation/umi-web3js-adapters": "^1.4.1",
|
|
53
|
-
"@meteora-ag/cp-amm-sdk": "^1.2.6",
|
|
54
|
-
"@meteora-ag/dlmm": "^1.9.0",
|
|
55
|
-
"@meteora-ag/dynamic-amm-sdk": "^1.4.1",
|
|
56
|
-
"@meteora-ag/dynamic-bonding-curve-sdk": "^1.4.9",
|
|
57
|
-
"@orca-so/common-sdk": "^0.7.0",
|
|
58
|
-
"@orca-so/whirlpools-sdk": "^0.17.4",
|
|
59
|
-
"@pump-fun/pump-sdk": "^1.24.0",
|
|
60
|
-
"@pump-fun/pump-swap-sdk": "^1.11.0",
|
|
61
|
-
"@raydium-io/raydium-sdk-v2": "^0.2.31-alpha",
|
|
62
|
-
"@solana/spl-token": "0.4.14",
|
|
63
|
-
"@solana/web3.js": "1.98.4",
|
|
64
|
-
"axios": "^1.13.2",
|
|
65
|
-
"ethers": "^6.16.0",
|
|
66
|
-
"pinata": "^2.5.1",
|
|
67
|
-
"tweetnacl": "^1.0.3"
|
|
68
|
-
},
|
|
69
|
-
"optionalDependencies": {
|
|
70
|
-
"@orca-so/wavebreak": "^1.1.7"
|
|
32
|
+
"axios": "^1.12.2",
|
|
33
|
+
"ethers": "^6.11.0",
|
|
34
|
+
"pinata": "^1.10.1"
|
|
71
35
|
},
|
|
72
36
|
"devDependencies": {
|
|
73
|
-
"
|
|
74
|
-
"@types/bs58": "^4.0.4",
|
|
75
|
-
"decimal.js": "^10.6.0",
|
|
76
|
-
"typescript": "^5.9.3"
|
|
37
|
+
"typescript": "^5.6.3"
|
|
77
38
|
}
|
|
78
39
|
}
|
package/dist/sol/constants.d.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Solana SDK 常量配置
|
|
3
|
-
* @module sol/constants
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Nozomi 配置
|
|
7
|
-
* Temporal Nozomi 交易加速服务
|
|
8
|
-
*/
|
|
9
|
-
export declare const NOZOMI_CONFIG: {
|
|
10
|
-
/** Tip 账户列表(随机选择一个) */
|
|
11
|
-
readonly TIP_ACCOUNTS: readonly ["TEMPaMeCRFAS9EKF53Jd6KpHxgL47uWLcpFArU1Fanq", "noz3jAjPiHuBPqiSPkkugaJDkJscPuRhYnSpbi8UvC4", "noz3str9KXfpKknefHji8L1mPgimezaiUyCHYMDv1GE", "noz6uoYCDijhu1V7cutCpwxNiSovEwLdRHPwmgCGDNo", "noz9EPNcT7WH6Sou3sr3GGjHQYVkN3DNirpbvDkv9YJ", "nozc5yT15LazbLTFVZzoNZCwjh3yUtW86LoUyqsBu4L", "nozFrhfnNGoyqwVuwPAW4aaGqempx4PU6g6D9CJMv7Z", "nozievPk7HyK1Rqy1MPJwVQ7qQg2QoJGyP71oeDwbsu", "noznbgwYnBLDHu8wcQVCEw6kDrXkPdKkydGJGNXGvL7", "nozNVWs5N8mgzuD3qigrCG2UoKxZttxzZ85pvAQVrbP", "nozpEGbwx4BcGp6pvEdAh1JoC2CQGZdU6HbNP1v2p6P", "nozrhjhkCr3zXT3BiT4WCodYCUFeQvcdUkM7MqhKqge", "nozrwQtWhEdrA6W8dkbt9gnUaMs52PdAv5byipnadq3", "nozUacTVWub3cL4mJmGCYjKZTnE9RbdY5AP46iQgbPJ", "nozWCyTPppJjRuw2fpzDhhWbW355fzosWSzrrMYB1Qk", "nozWNju6dY353eMkMqURqwQEoM3SFgEKC6psLCSfUne", "nozxNBgWohjR75vdspfxR5H9ceC7XXH99xpxhVGt3Bb"];
|
|
12
|
-
/** 最小 Tip(lamports)- 0.001 SOL */
|
|
13
|
-
readonly MIN_TIP_LAMPORTS: 1000000;
|
|
14
|
-
/** 默认 Tip(lamports)- 0.001 SOL */
|
|
15
|
-
readonly DEFAULT_TIP_LAMPORTS: 1000000;
|
|
16
|
-
/** 建议的 Priority Fee(microlamports) */
|
|
17
|
-
readonly RECOMMENDED_PRIORITY_FEE: 1000000;
|
|
18
|
-
/** 区域端点 */
|
|
19
|
-
readonly REGIONS: {
|
|
20
|
-
readonly auto: "nozomi.temporal.xyz";
|
|
21
|
-
readonly pit: "pit1.nozomi.temporal.xyz";
|
|
22
|
-
readonly tyo: "tyo1.nozomi.temporal.xyz";
|
|
23
|
-
readonly sgp: "sgp1.nozomi.temporal.xyz";
|
|
24
|
-
readonly ewr: "ewr1.nozomi.temporal.xyz";
|
|
25
|
-
readonly ams: "ams1.nozomi.temporal.xyz";
|
|
26
|
-
readonly fra: "fra2.nozomi.temporal.xyz";
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Jito 配置
|
|
31
|
-
*
|
|
32
|
-
* 注意:BLOCK_ENGINE_URL 需要由前端传入,不在 SDK 中写死
|
|
33
|
-
*/
|
|
34
|
-
export declare const JITO_CONFIG: {
|
|
35
|
-
/** Tip 账户列表(随机选择一个)- 这些是 Jito 官方账户,固定不变 */
|
|
36
|
-
readonly TIP_ACCOUNTS: readonly ["96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5", "HFqU5x63VTqvQss8hp11i4bVmkzdNaVB6PYjYgNd4W5U", "Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY", "ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49", "DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh", "ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt", "DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL", "3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT"];
|
|
37
|
-
/** 最小 Tip(lamports) */
|
|
38
|
-
readonly MIN_TIP_LAMPORTS: 1000;
|
|
39
|
-
/** 默认 Tip(lamports)- 0.00001 SOL */
|
|
40
|
-
readonly DEFAULT_TIP_LAMPORTS: 10000;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Solana 系统程序地址
|
|
44
|
-
*/
|
|
45
|
-
export declare const SYSTEM_PROGRAMS: {
|
|
46
|
-
/** Token Program */
|
|
47
|
-
readonly TOKEN_PROGRAM: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
48
|
-
/** Token-2022 Program */
|
|
49
|
-
readonly TOKEN_2022_PROGRAM: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
50
|
-
/** Associated Token Account Program */
|
|
51
|
-
readonly ATA_PROGRAM: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
52
|
-
/** Metaplex Token Metadata Program */
|
|
53
|
-
readonly METADATA_PROGRAM: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
|
|
54
|
-
/** System Program */
|
|
55
|
-
readonly SYSTEM_PROGRAM: "11111111111111111111111111111111";
|
|
56
|
-
/** Rent Sysvar */
|
|
57
|
-
readonly RENT_SYSVAR: "SysvarRent111111111111111111111111111111111";
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Pump.fun 程序地址
|
|
61
|
-
*/
|
|
62
|
-
export declare const PUMP_PROGRAMS: {
|
|
63
|
-
/** Pump Program ID */
|
|
64
|
-
readonly PUMP_PROGRAM: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
|
|
65
|
-
/** Pump Swap Program ID */
|
|
66
|
-
readonly PUMP_SWAP_PROGRAM: "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";
|
|
67
|
-
/** Global Config */
|
|
68
|
-
readonly GLOBAL_CONFIG: "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf";
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Raydium 程序地址
|
|
72
|
-
*/
|
|
73
|
-
export declare const RAYDIUM_PROGRAMS: {
|
|
74
|
-
/** AMM Program ID */
|
|
75
|
-
readonly AMM_PROGRAM: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8";
|
|
76
|
-
/** CLMM Program ID */
|
|
77
|
-
readonly CLMM_PROGRAM: "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK";
|
|
78
|
-
/** LaunchLab Program ID */
|
|
79
|
-
readonly LAUNCHLAB_PROGRAM: "LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj";
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Orca 程序地址
|
|
83
|
-
*/
|
|
84
|
-
export declare const ORCA_PROGRAMS: {
|
|
85
|
-
/** Whirlpool Program ID */
|
|
86
|
-
readonly WHIRLPOOL_PROGRAM: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Meteora 程序地址
|
|
90
|
-
*/
|
|
91
|
-
export declare const METEORA_PROGRAMS: {
|
|
92
|
-
/** DLMM Program ID */
|
|
93
|
-
readonly DLMM_PROGRAM: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
|
|
94
|
-
/** DAMM v2 Program ID */
|
|
95
|
-
readonly DAMM_V2_PROGRAM: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
|
|
96
|
-
/** DBC Program ID */
|
|
97
|
-
readonly DBC_PROGRAM: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN";
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* 常用代币地址
|
|
101
|
-
*/
|
|
102
|
-
export declare const TOKENS: {
|
|
103
|
-
/** Wrapped SOL */
|
|
104
|
-
readonly SOL: "So11111111111111111111111111111111111111112";
|
|
105
|
-
/** USDC */
|
|
106
|
-
readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
107
|
-
/** USDT */
|
|
108
|
-
readonly USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* 交易默认配置
|
|
112
|
-
*/
|
|
113
|
-
export declare const TX_CONFIG: {
|
|
114
|
-
/** 默认滑点 1% */
|
|
115
|
-
readonly DEFAULT_SLIPPAGE: 1;
|
|
116
|
-
/** 最大滑点 50% */
|
|
117
|
-
readonly MAX_SLIPPAGE: 50;
|
|
118
|
-
/** 计算单元限制 */
|
|
119
|
-
readonly COMPUTE_UNIT_LIMIT: 200000;
|
|
120
|
-
/** 计算单元价格(microlamports) */
|
|
121
|
-
readonly COMPUTE_UNIT_PRICE: 50000;
|
|
122
|
-
/** 确认超时(毫秒) */
|
|
123
|
-
readonly CONFIRMATION_TIMEOUT: 60000;
|
|
124
|
-
/** 默认 commitment */
|
|
125
|
-
readonly DEFAULT_COMMITMENT: "confirmed";
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* 账户大小(用于计算租金)
|
|
129
|
-
*/
|
|
130
|
-
export declare const ACCOUNT_SIZE: {
|
|
131
|
-
/** Mint 账户大小 */
|
|
132
|
-
readonly MINT: 82;
|
|
133
|
-
/** Token 账户大小 */
|
|
134
|
-
readonly TOKEN_ACCOUNT: 165;
|
|
135
|
-
/** Metadata 账户大小(近似值) */
|
|
136
|
-
readonly METADATA: 679;
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* SOL 单位换算
|
|
140
|
-
*/
|
|
141
|
-
export declare const SOL_DECIMALS = 9;
|
|
142
|
-
export declare const LAMPORTS_PER_SOL = 1000000000;
|
|
143
|
-
/**
|
|
144
|
-
* 将 SOL 转换为 lamports
|
|
145
|
-
*/
|
|
146
|
-
export declare function solToLamports(sol: number): bigint;
|
|
147
|
-
/**
|
|
148
|
-
* 将 lamports 转换为 SOL
|
|
149
|
-
*/
|
|
150
|
-
export declare function lamportsToSol(lamports: bigint): number;
|