solana-meme-sdk 1.0.0
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.md +160 -0
- package/dist/batch-executor/accounts.d.ts +141 -0
- package/dist/batch-executor/accounts.d.ts.map +1 -0
- package/dist/batch-executor/accounts.js +98 -0
- package/dist/batch-executor/accounts.js.map +1 -0
- package/dist/batch-executor/batch-executor.d.ts +27 -0
- package/dist/batch-executor/batch-executor.d.ts.map +1 -0
- package/dist/batch-executor/batch-executor.js +286 -0
- package/dist/batch-executor/batch-executor.js.map +1 -0
- package/dist/batch-executor/index.d.ts +4 -0
- package/dist/batch-executor/index.d.ts.map +1 -0
- package/dist/batch-executor/index.js +6 -0
- package/dist/batch-executor/index.js.map +1 -0
- package/dist/batch-executor/types.d.ts +87 -0
- package/dist/batch-executor/types.d.ts.map +1 -0
- package/dist/batch-executor/types.js +42 -0
- package/dist/batch-executor/types.js.map +1 -0
- package/dist/constants.d.ts +151 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +189 -0
- package/dist/constants.js.map +1 -0
- package/dist/dex/blockrazor/client.d.ts +52 -0
- package/dist/dex/blockrazor/client.d.ts.map +1 -0
- package/dist/dex/blockrazor/client.js +97 -0
- package/dist/dex/blockrazor/client.js.map +1 -0
- package/dist/dex/blockrazor/constants.d.ts +35 -0
- package/dist/dex/blockrazor/constants.d.ts.map +1 -0
- package/dist/dex/blockrazor/constants.js +56 -0
- package/dist/dex/blockrazor/constants.js.map +1 -0
- package/dist/dex/blockrazor/geyser.d.ts +129 -0
- package/dist/dex/blockrazor/geyser.d.ts.map +1 -0
- package/dist/dex/blockrazor/geyser.js +531 -0
- package/dist/dex/blockrazor/geyser.js.map +1 -0
- package/dist/dex/blockrazor/index.d.ts +19 -0
- package/dist/dex/blockrazor/index.d.ts.map +1 -0
- package/dist/dex/blockrazor/index.js +24 -0
- package/dist/dex/blockrazor/index.js.map +1 -0
- package/dist/dex/blockrazor/send.d.ts +136 -0
- package/dist/dex/blockrazor/send.d.ts.map +1 -0
- package/dist/dex/blockrazor/send.js +255 -0
- package/dist/dex/blockrazor/send.js.map +1 -0
- package/dist/dex/blockrazor/types.d.ts +192 -0
- package/dist/dex/blockrazor/types.d.ts.map +1 -0
- package/dist/dex/blockrazor/types.js +6 -0
- package/dist/dex/blockrazor/types.js.map +1 -0
- package/dist/dex/index.d.ts +11 -0
- package/dist/dex/index.d.ts.map +1 -0
- package/dist/dex/index.js +17 -0
- package/dist/dex/index.js.map +1 -0
- package/dist/dex/jup/client.d.ts +34 -0
- package/dist/dex/jup/client.d.ts.map +1 -0
- package/dist/dex/jup/client.js +111 -0
- package/dist/dex/jup/client.js.map +1 -0
- package/dist/dex/jup/index.d.ts +17 -0
- package/dist/dex/jup/index.d.ts.map +1 -0
- package/dist/dex/jup/index.js +149 -0
- package/dist/dex/jup/index.js.map +1 -0
- package/dist/dex/jup/legacy.d.ts +624 -0
- package/dist/dex/jup/legacy.d.ts.map +1 -0
- package/dist/dex/jup/legacy.js +417 -0
- package/dist/dex/jup/legacy.js.map +1 -0
- package/dist/dex/jup/lend.d.ts +641 -0
- package/dist/dex/jup/lend.d.ts.map +1 -0
- package/dist/dex/jup/lend.js +604 -0
- package/dist/dex/jup/lend.js.map +1 -0
- package/dist/dex/jup/portfolio.d.ts +363 -0
- package/dist/dex/jup/portfolio.d.ts.map +1 -0
- package/dist/dex/jup/portfolio.js +368 -0
- package/dist/dex/jup/portfolio.js.map +1 -0
- package/dist/dex/jup/price.d.ts +174 -0
- package/dist/dex/jup/price.d.ts.map +1 -0
- package/dist/dex/jup/price.js +226 -0
- package/dist/dex/jup/price.js.map +1 -0
- package/dist/dex/jup/recurring.d.ts +438 -0
- package/dist/dex/jup/recurring.d.ts.map +1 -0
- package/dist/dex/jup/recurring.js +321 -0
- package/dist/dex/jup/recurring.js.map +1 -0
- package/dist/dex/jup/send.d.ts +283 -0
- package/dist/dex/jup/send.d.ts.map +1 -0
- package/dist/dex/jup/send.js +296 -0
- package/dist/dex/jup/send.js.map +1 -0
- package/dist/dex/jup/studio.d.ts +458 -0
- package/dist/dex/jup/studio.d.ts.map +1 -0
- package/dist/dex/jup/studio.js +489 -0
- package/dist/dex/jup/studio.js.map +1 -0
- package/dist/dex/jup/tokens.d.ts +768 -0
- package/dist/dex/jup/tokens.d.ts.map +1 -0
- package/dist/dex/jup/tokens.js +698 -0
- package/dist/dex/jup/tokens.js.map +1 -0
- package/dist/dex/jup/trigger.d.ts +512 -0
- package/dist/dex/jup/trigger.d.ts.map +1 -0
- package/dist/dex/jup/trigger.js +398 -0
- package/dist/dex/jup/trigger.js.map +1 -0
- package/dist/dex/jup/types.d.ts +434 -0
- package/dist/dex/jup/types.d.ts.map +1 -0
- package/dist/dex/jup/types.js +6 -0
- package/dist/dex/jup/types.js.map +1 -0
- package/dist/dex/jup/ultra.d.ts +647 -0
- package/dist/dex/jup/ultra.d.ts.map +1 -0
- package/dist/dex/jup/ultra.js +854 -0
- package/dist/dex/jup/ultra.js.map +1 -0
- package/dist/dex/meteora/client.d.ts +77 -0
- package/dist/dex/meteora/client.d.ts.map +1 -0
- package/dist/dex/meteora/client.js +220 -0
- package/dist/dex/meteora/client.js.map +1 -0
- package/dist/dex/meteora/damm-v1-bundle.d.ts +62 -0
- package/dist/dex/meteora/damm-v1-bundle.d.ts.map +1 -0
- package/dist/dex/meteora/damm-v1-bundle.js +113 -0
- package/dist/dex/meteora/damm-v1-bundle.js.map +1 -0
- package/dist/dex/meteora/damm-v1.d.ts +119 -0
- package/dist/dex/meteora/damm-v1.d.ts.map +1 -0
- package/dist/dex/meteora/damm-v1.js +316 -0
- package/dist/dex/meteora/damm-v1.js.map +1 -0
- package/dist/dex/meteora/damm-v2-bundle.d.ts +83 -0
- package/dist/dex/meteora/damm-v2-bundle.d.ts.map +1 -0
- package/dist/dex/meteora/damm-v2-bundle.js +243 -0
- package/dist/dex/meteora/damm-v2-bundle.js.map +1 -0
- package/dist/dex/meteora/damm-v2.d.ts +173 -0
- package/dist/dex/meteora/damm-v2.d.ts.map +1 -0
- package/dist/dex/meteora/damm-v2.js +633 -0
- package/dist/dex/meteora/damm-v2.js.map +1 -0
- package/dist/dex/meteora/dbc-bundle.d.ts +124 -0
- package/dist/dex/meteora/dbc-bundle.d.ts.map +1 -0
- package/dist/dex/meteora/dbc-bundle.js +305 -0
- package/dist/dex/meteora/dbc-bundle.js.map +1 -0
- package/dist/dex/meteora/dbc.d.ts +193 -0
- package/dist/dex/meteora/dbc.d.ts.map +1 -0
- package/dist/dex/meteora/dbc.js +620 -0
- package/dist/dex/meteora/dbc.js.map +1 -0
- package/dist/dex/meteora/dlmm-bundle.d.ts +40 -0
- package/dist/dex/meteora/dlmm-bundle.d.ts.map +1 -0
- package/dist/dex/meteora/dlmm-bundle.js +190 -0
- package/dist/dex/meteora/dlmm-bundle.js.map +1 -0
- package/dist/dex/meteora/dlmm.d.ts +158 -0
- package/dist/dex/meteora/dlmm.d.ts.map +1 -0
- package/dist/dex/meteora/dlmm.js +672 -0
- package/dist/dex/meteora/dlmm.js.map +1 -0
- package/dist/dex/meteora/index.d.ts +26 -0
- package/dist/dex/meteora/index.d.ts.map +1 -0
- package/dist/dex/meteora/index.js +66 -0
- package/dist/dex/meteora/index.js.map +1 -0
- package/dist/dex/meteora/types.d.ts +788 -0
- package/dist/dex/meteora/types.d.ts.map +1 -0
- package/dist/dex/meteora/types.js +111 -0
- package/dist/dex/meteora/types.js.map +1 -0
- package/dist/dex/orca/index.d.ts +11 -0
- package/dist/dex/orca/index.d.ts.map +1 -0
- package/dist/dex/orca/index.js +17 -0
- package/dist/dex/orca/index.js.map +1 -0
- package/dist/dex/orca/orca-bundle.d.ts +42 -0
- package/dist/dex/orca/orca-bundle.d.ts.map +1 -0
- package/dist/dex/orca/orca-bundle.js +174 -0
- package/dist/dex/orca/orca-bundle.js.map +1 -0
- package/dist/dex/orca/orca.d.ts +66 -0
- package/dist/dex/orca/orca.d.ts.map +1 -0
- package/dist/dex/orca/orca.js +475 -0
- package/dist/dex/orca/orca.js.map +1 -0
- package/dist/dex/orca/types.d.ts +264 -0
- package/dist/dex/orca/types.d.ts.map +1 -0
- package/dist/dex/orca/types.js +39 -0
- package/dist/dex/orca/types.js.map +1 -0
- package/dist/dex/orca/wavebreak-bundle.d.ts +35 -0
- package/dist/dex/orca/wavebreak-bundle.d.ts.map +1 -0
- package/dist/dex/orca/wavebreak-bundle.js +199 -0
- package/dist/dex/orca/wavebreak-bundle.js.map +1 -0
- package/dist/dex/orca/wavebreak-types.d.ts +228 -0
- package/dist/dex/orca/wavebreak-types.d.ts.map +1 -0
- package/dist/dex/orca/wavebreak-types.js +24 -0
- package/dist/dex/orca/wavebreak-types.js.map +1 -0
- package/dist/dex/orca/wavebreak.d.ts +79 -0
- package/dist/dex/orca/wavebreak.d.ts.map +1 -0
- package/dist/dex/orca/wavebreak.js +498 -0
- package/dist/dex/orca/wavebreak.js.map +1 -0
- package/dist/dex/pump/index.d.ts +10 -0
- package/dist/dex/pump/index.d.ts.map +1 -0
- package/dist/dex/pump/index.js +15 -0
- package/dist/dex/pump/index.js.map +1 -0
- package/dist/dex/pump/pump-bundle.d.ts +93 -0
- package/dist/dex/pump/pump-bundle.d.ts.map +1 -0
- package/dist/dex/pump/pump-bundle.js +384 -0
- package/dist/dex/pump/pump-bundle.js.map +1 -0
- package/dist/dex/pump/pump-swap-bundle.d.ts +104 -0
- package/dist/dex/pump/pump-swap-bundle.d.ts.map +1 -0
- package/dist/dex/pump/pump-swap-bundle.js +381 -0
- package/dist/dex/pump/pump-swap-bundle.js.map +1 -0
- package/dist/dex/pump/pump-swap.d.ts +47 -0
- package/dist/dex/pump/pump-swap.d.ts.map +1 -0
- package/dist/dex/pump/pump-swap.js +200 -0
- package/dist/dex/pump/pump-swap.js.map +1 -0
- package/dist/dex/pump/pump.d.ts +36 -0
- package/dist/dex/pump/pump.d.ts.map +1 -0
- package/dist/dex/pump/pump.js +353 -0
- package/dist/dex/pump/pump.js.map +1 -0
- package/dist/dex/pump/types.d.ts +216 -0
- package/dist/dex/pump/types.d.ts.map +1 -0
- package/dist/dex/pump/types.js +6 -0
- package/dist/dex/pump/types.js.map +1 -0
- package/dist/dex/raydium/index.d.ts +9 -0
- package/dist/dex/raydium/index.d.ts.map +1 -0
- package/dist/dex/raydium/index.js +13 -0
- package/dist/dex/raydium/index.js.map +1 -0
- package/dist/dex/raydium/launchlab.d.ts +69 -0
- package/dist/dex/raydium/launchlab.d.ts.map +1 -0
- package/dist/dex/raydium/launchlab.js +211 -0
- package/dist/dex/raydium/launchlab.js.map +1 -0
- package/dist/dex/raydium/raydium-bundle.d.ts +65 -0
- package/dist/dex/raydium/raydium-bundle.d.ts.map +1 -0
- package/dist/dex/raydium/raydium-bundle.js +325 -0
- package/dist/dex/raydium/raydium-bundle.js.map +1 -0
- package/dist/dex/raydium/raydium.d.ts +41 -0
- package/dist/dex/raydium/raydium.d.ts.map +1 -0
- package/dist/dex/raydium/raydium.js +367 -0
- package/dist/dex/raydium/raydium.js.map +1 -0
- package/dist/dex/raydium/types.d.ts +241 -0
- package/dist/dex/raydium/types.d.ts.map +1 -0
- package/dist/dex/raydium/types.js +6 -0
- package/dist/dex/raydium/types.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/jito/bundle.d.ts +91 -0
- package/dist/jito/bundle.d.ts.map +1 -0
- package/dist/jito/bundle.js +267 -0
- package/dist/jito/bundle.js.map +1 -0
- package/dist/jito/index.d.ts +8 -0
- package/dist/jito/index.d.ts.map +1 -0
- package/dist/jito/index.js +8 -0
- package/dist/jito/index.js.map +1 -0
- package/dist/jito/tip.d.ts +52 -0
- package/dist/jito/tip.d.ts.map +1 -0
- package/dist/jito/tip.js +84 -0
- package/dist/jito/tip.js.map +1 -0
- package/dist/jito/types.d.ts +101 -0
- package/dist/jito/types.d.ts.map +1 -0
- package/dist/jito/types.js +6 -0
- package/dist/jito/types.js.map +1 -0
- package/dist/nozomi/client.d.ts +64 -0
- package/dist/nozomi/client.d.ts.map +1 -0
- package/dist/nozomi/client.js +228 -0
- package/dist/nozomi/client.js.map +1 -0
- package/dist/nozomi/index.d.ts +9 -0
- package/dist/nozomi/index.d.ts.map +1 -0
- package/dist/nozomi/index.js +9 -0
- package/dist/nozomi/index.js.map +1 -0
- package/dist/nozomi/tip.d.ts +51 -0
- package/dist/nozomi/tip.d.ts.map +1 -0
- package/dist/nozomi/tip.js +81 -0
- package/dist/nozomi/tip.js.map +1 -0
- package/dist/nozomi/types.d.ts +97 -0
- package/dist/nozomi/types.d.ts.map +1 -0
- package/dist/nozomi/types.js +6 -0
- package/dist/nozomi/types.js.map +1 -0
- package/dist/token/create-complete.d.ts +116 -0
- package/dist/token/create-complete.d.ts.map +1 -0
- package/dist/token/create-complete.js +236 -0
- package/dist/token/create-complete.js.map +1 -0
- package/dist/token/create-token.d.ts +58 -0
- package/dist/token/create-token.d.ts.map +1 -0
- package/dist/token/create-token.js +231 -0
- package/dist/token/create-token.js.map +1 -0
- package/dist/token/index.d.ts +10 -0
- package/dist/token/index.d.ts.map +1 -0
- package/dist/token/index.js +15 -0
- package/dist/token/index.js.map +1 -0
- package/dist/token/metadata-upload.d.ts +87 -0
- package/dist/token/metadata-upload.d.ts.map +1 -0
- package/dist/token/metadata-upload.js +176 -0
- package/dist/token/metadata-upload.js.map +1 -0
- package/dist/token/metadata.d.ts +93 -0
- package/dist/token/metadata.d.ts.map +1 -0
- package/dist/token/metadata.js +275 -0
- package/dist/token/metadata.js.map +1 -0
- package/dist/token/types.d.ts +154 -0
- package/dist/token/types.d.ts.map +1 -0
- package/dist/token/types.js +6 -0
- package/dist/token/types.js.map +1 -0
- package/dist/types.d.ts +177 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/alt.d.ts +58 -0
- package/dist/utils/alt.d.ts.map +1 -0
- package/dist/utils/alt.js +125 -0
- package/dist/utils/alt.js.map +1 -0
- package/dist/utils/balance.d.ts +161 -0
- package/dist/utils/balance.d.ts.map +1 -0
- package/dist/utils/balance.js +639 -0
- package/dist/utils/balance.js.map +1 -0
- package/dist/utils/batch-swap.d.ts +52 -0
- package/dist/utils/batch-swap.d.ts.map +1 -0
- package/dist/utils/batch-swap.js +286 -0
- package/dist/utils/batch-swap.js.map +1 -0
- package/dist/utils/batch-types.d.ts +90 -0
- package/dist/utils/batch-types.d.ts.map +1 -0
- package/dist/utils/batch-types.js +7 -0
- package/dist/utils/batch-types.js.map +1 -0
- package/dist/utils/connection.d.ts +79 -0
- package/dist/utils/connection.d.ts.map +1 -0
- package/dist/utils/connection.js +169 -0
- package/dist/utils/connection.js.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +14 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lp-inspect.d.ts +81 -0
- package/dist/utils/lp-inspect.d.ts.map +1 -0
- package/dist/utils/lp-inspect.js +265 -0
- package/dist/utils/lp-inspect.js.map +1 -0
- package/dist/utils/transfer.d.ts +197 -0
- package/dist/utils/transfer.d.ts.map +1 -0
- package/dist/utils/transfer.js +308 -0
- package/dist/utils/transfer.js.map +1 -0
- package/dist/utils/wallet.d.ts +108 -0
- package/dist/utils/wallet.d.ts.map +1 -0
- package/dist/utils/wallet.js +211 -0
- package/dist/utils/wallet.js.map +1 -0
- package/package.json +92 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solana SDK 入口
|
|
3
|
+
* @module sol
|
|
4
|
+
*/
|
|
5
|
+
// 类型导出
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
// 常量导出
|
|
8
|
+
export * from './constants.js';
|
|
9
|
+
// 工具函数导出
|
|
10
|
+
export * from './utils/index.js';
|
|
11
|
+
// Jito Bundle 导出
|
|
12
|
+
export * from './jito/index.js';
|
|
13
|
+
// Nozomi 交易加速导出
|
|
14
|
+
export * from './nozomi/index.js';
|
|
15
|
+
// Token 创建导出
|
|
16
|
+
export * from './token/index.js';
|
|
17
|
+
// DEX 导出(Pump, Raydium, Orca, Meteora)
|
|
18
|
+
export * from './dex/index.js';
|
|
19
|
+
// Batch Executor (批量交易执行器)
|
|
20
|
+
export * from './batch-executor/index.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO;AACP,cAAc,YAAY,CAAC;AAE3B,OAAO;AACP,cAAc,gBAAgB,CAAC;AAE/B,SAAS;AACT,cAAc,kBAAkB,CAAC;AAEjC,iBAAiB;AACjB,cAAc,iBAAiB,CAAC;AAEhC,gBAAgB;AAChB,cAAc,mBAAmB,CAAC;AAElC,aAAa;AACb,cAAc,kBAAkB,CAAC;AAEjC,uCAAuC;AACvC,cAAc,gBAAgB,CAAC;AAE/B,2BAA2B;AAC3B,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jito Bundle 构建和签名
|
|
3
|
+
* SDK 只负责构建和签名,提交到后端服务器广播
|
|
4
|
+
* @module sol/jito/bundle
|
|
5
|
+
*/
|
|
6
|
+
import { Connection, Keypair, Transaction, TransactionInstruction } from '@solana/web3.js';
|
|
7
|
+
import type { SerializedTransaction, SignedBundleData, TransactionBuildOptions } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Bundle 构建器
|
|
10
|
+
* 用于构建、签名 Jito Bundle,然后提交到后端
|
|
11
|
+
*/
|
|
12
|
+
export declare class BundleBuilder {
|
|
13
|
+
private connection;
|
|
14
|
+
private transactions;
|
|
15
|
+
private signers;
|
|
16
|
+
private tipAccount;
|
|
17
|
+
private tipLamports;
|
|
18
|
+
constructor(connection: Connection, options?: {
|
|
19
|
+
tipAccount?: string;
|
|
20
|
+
tipLamports?: bigint;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* 添加交易
|
|
24
|
+
* @param transaction 交易
|
|
25
|
+
* @param signers 签名者列表
|
|
26
|
+
*/
|
|
27
|
+
addTransaction(transaction: Transaction, signers: Keypair[]): this;
|
|
28
|
+
/**
|
|
29
|
+
* 添加多个交易
|
|
30
|
+
* @param items 交易和签名者列表
|
|
31
|
+
*/
|
|
32
|
+
addTransactions(items: Array<{
|
|
33
|
+
transaction: Transaction;
|
|
34
|
+
signers: Keypair[];
|
|
35
|
+
}>): this;
|
|
36
|
+
/**
|
|
37
|
+
* 设置 Tip
|
|
38
|
+
* @param lamports Tip 金额
|
|
39
|
+
* @param account Tip 账户
|
|
40
|
+
*/
|
|
41
|
+
setTip(lamports: bigint, account?: string): this;
|
|
42
|
+
/**
|
|
43
|
+
* 获取交易数量
|
|
44
|
+
*/
|
|
45
|
+
getTransactionCount(): number;
|
|
46
|
+
/**
|
|
47
|
+
* 清空所有交易
|
|
48
|
+
*/
|
|
49
|
+
clear(): this;
|
|
50
|
+
/**
|
|
51
|
+
* 构建并签名 Bundle
|
|
52
|
+
* @param feePayer 手续费支付者
|
|
53
|
+
* @returns 签名后的 Bundle 数据,用于提交到后端
|
|
54
|
+
*/
|
|
55
|
+
buildAndSign(feePayer: Keypair): Promise<SignedBundleData>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 构建单个交易并签名(用于简单场景)
|
|
59
|
+
* @param connection Solana 连接
|
|
60
|
+
* @param instructions 指令列表
|
|
61
|
+
* @param signers 签名者列表(第一个为 feePayer)
|
|
62
|
+
* @param options 选项
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildAndSignTransaction(connection: Connection, instructions: TransactionInstruction[], signers: Keypair[], options?: TransactionBuildOptions): Promise<SerializedTransaction>;
|
|
65
|
+
/**
|
|
66
|
+
* 构建批量交易并签名(每个钱包一笔交易)
|
|
67
|
+
* @param connection Solana 连接
|
|
68
|
+
* @param walletInstructions 每个钱包的指令
|
|
69
|
+
* @param options 选项
|
|
70
|
+
*/
|
|
71
|
+
export declare function buildAndSignBatchTransactions(connection: Connection, walletInstructions: Array<{
|
|
72
|
+
wallet: Keypair;
|
|
73
|
+
instructions: TransactionInstruction[];
|
|
74
|
+
}>, options?: TransactionBuildOptions & {
|
|
75
|
+
/** 统一的 feePayer,如果不指定则每个钱包自己付费 */
|
|
76
|
+
feePayer?: Keypair;
|
|
77
|
+
}): Promise<SignedBundleData>;
|
|
78
|
+
/**
|
|
79
|
+
* 将 SignedBundleData 转换为后端 API 需要的格式
|
|
80
|
+
* @param bundleData 签名后的 Bundle 数据
|
|
81
|
+
*/
|
|
82
|
+
export declare function toBundleRequest(bundleData: SignedBundleData): {
|
|
83
|
+
transactions: string[];
|
|
84
|
+
signatures: string[];
|
|
85
|
+
tipAccount: string;
|
|
86
|
+
tipLamports: string;
|
|
87
|
+
recentBlockhash: string;
|
|
88
|
+
lastValidBlockHeight: number;
|
|
89
|
+
timestamp: number;
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/jito/bundle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,EACV,OAAO,EAEP,WAAW,EAGX,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAS;gBAG1B,UAAU,EAAE,UAAU,EACtB,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M,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,CAUA"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jito Bundle 构建和签名
|
|
3
|
+
* SDK 只负责构建和签名,提交到后端服务器广播
|
|
4
|
+
* @module sol/jito/bundle
|
|
5
|
+
*/
|
|
6
|
+
import { Transaction, ComputeBudgetProgram, } from '@solana/web3.js';
|
|
7
|
+
import { TX_CONFIG } from '../constants.js';
|
|
8
|
+
import { buildTipInstruction, getRandomTipAccount, calculateRecommendedTip } from './tip.js';
|
|
9
|
+
/**
|
|
10
|
+
* Bundle 构建器
|
|
11
|
+
* 用于构建、签名 Jito Bundle,然后提交到后端
|
|
12
|
+
*/
|
|
13
|
+
export class BundleBuilder {
|
|
14
|
+
connection;
|
|
15
|
+
transactions = [];
|
|
16
|
+
signers = [];
|
|
17
|
+
tipAccount;
|
|
18
|
+
tipLamports;
|
|
19
|
+
constructor(connection, options) {
|
|
20
|
+
this.connection = connection;
|
|
21
|
+
this.tipAccount = options?.tipAccount || getRandomTipAccount();
|
|
22
|
+
this.tipLamports = options?.tipLamports || BigInt(TX_CONFIG.COMPUTE_UNIT_PRICE);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 添加交易
|
|
26
|
+
* @param transaction 交易
|
|
27
|
+
* @param signers 签名者列表
|
|
28
|
+
*/
|
|
29
|
+
addTransaction(transaction, signers) {
|
|
30
|
+
this.transactions.push(transaction);
|
|
31
|
+
this.signers.push(signers);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 添加多个交易
|
|
36
|
+
* @param items 交易和签名者列表
|
|
37
|
+
*/
|
|
38
|
+
addTransactions(items) {
|
|
39
|
+
for (const item of items) {
|
|
40
|
+
this.addTransaction(item.transaction, item.signers);
|
|
41
|
+
}
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 设置 Tip
|
|
46
|
+
* @param lamports Tip 金额
|
|
47
|
+
* @param account Tip 账户
|
|
48
|
+
*/
|
|
49
|
+
setTip(lamports, account) {
|
|
50
|
+
this.tipLamports = lamports;
|
|
51
|
+
if (account) {
|
|
52
|
+
this.tipAccount = account;
|
|
53
|
+
}
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 获取交易数量
|
|
58
|
+
*/
|
|
59
|
+
getTransactionCount() {
|
|
60
|
+
return this.transactions.length;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 清空所有交易
|
|
64
|
+
*/
|
|
65
|
+
clear() {
|
|
66
|
+
this.transactions = [];
|
|
67
|
+
this.signers = [];
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 构建并签名 Bundle
|
|
72
|
+
* @param feePayer 手续费支付者
|
|
73
|
+
* @returns 签名后的 Bundle 数据,用于提交到后端
|
|
74
|
+
*/
|
|
75
|
+
async buildAndSign(feePayer) {
|
|
76
|
+
if (this.transactions.length === 0) {
|
|
77
|
+
throw new Error('No transactions to bundle');
|
|
78
|
+
}
|
|
79
|
+
// 获取最新 blockhash
|
|
80
|
+
const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash('finalized');
|
|
81
|
+
const serializedTransactions = [];
|
|
82
|
+
const allSignatures = [];
|
|
83
|
+
// 处理每个交易
|
|
84
|
+
for (let i = 0; i < this.transactions.length; i++) {
|
|
85
|
+
const tx = this.transactions[i];
|
|
86
|
+
const txSigners = this.signers[i];
|
|
87
|
+
// 设置 blockhash 和 feePayer
|
|
88
|
+
tx.recentBlockhash = blockhash;
|
|
89
|
+
tx.feePayer = feePayer.publicKey;
|
|
90
|
+
// 签名
|
|
91
|
+
const allTxSigners = [feePayer, ...txSigners.filter(s => !s.publicKey.equals(feePayer.publicKey))];
|
|
92
|
+
tx.sign(...allTxSigners);
|
|
93
|
+
// 序列化
|
|
94
|
+
const serialized = tx.serialize();
|
|
95
|
+
const signature = tx.signature?.toString('base64') || '';
|
|
96
|
+
serializedTransactions.push({
|
|
97
|
+
data: Buffer.from(serialized).toString('base64'),
|
|
98
|
+
isVersioned: false,
|
|
99
|
+
signature,
|
|
100
|
+
});
|
|
101
|
+
if (tx.signature) {
|
|
102
|
+
allSignatures.push(Buffer.from(tx.signature).toString('base64'));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 创建 Tip 交易(最后一笔)
|
|
106
|
+
const tipTx = new Transaction().add(buildTipInstruction(feePayer.publicKey, this.tipLamports, this.tipAccount));
|
|
107
|
+
tipTx.recentBlockhash = blockhash;
|
|
108
|
+
tipTx.feePayer = feePayer.publicKey;
|
|
109
|
+
tipTx.sign(feePayer);
|
|
110
|
+
const tipSerialized = tipTx.serialize();
|
|
111
|
+
serializedTransactions.push({
|
|
112
|
+
data: Buffer.from(tipSerialized).toString('base64'),
|
|
113
|
+
isVersioned: false,
|
|
114
|
+
signature: tipTx.signature ? Buffer.from(tipTx.signature).toString('base64') : '',
|
|
115
|
+
});
|
|
116
|
+
if (tipTx.signature) {
|
|
117
|
+
allSignatures.push(Buffer.from(tipTx.signature).toString('base64'));
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
transactions: serializedTransactions,
|
|
121
|
+
signatures: allSignatures,
|
|
122
|
+
tip: {
|
|
123
|
+
account: this.tipAccount,
|
|
124
|
+
lamports: this.tipLamports,
|
|
125
|
+
},
|
|
126
|
+
recentBlockhash: blockhash,
|
|
127
|
+
lastValidBlockHeight,
|
|
128
|
+
createdAt: Date.now(),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 构建单个交易并签名(用于简单场景)
|
|
134
|
+
* @param connection Solana 连接
|
|
135
|
+
* @param instructions 指令列表
|
|
136
|
+
* @param signers 签名者列表(第一个为 feePayer)
|
|
137
|
+
* @param options 选项
|
|
138
|
+
*/
|
|
139
|
+
export async function buildAndSignTransaction(connection, instructions, signers, options) {
|
|
140
|
+
if (signers.length === 0) {
|
|
141
|
+
throw new Error('At least one signer (feePayer) is required');
|
|
142
|
+
}
|
|
143
|
+
const feePayer = signers[0];
|
|
144
|
+
const { blockhash } = await connection.getLatestBlockhash('finalized');
|
|
145
|
+
const transaction = new Transaction();
|
|
146
|
+
// 添加计算预算指令(如果指定)
|
|
147
|
+
if (options?.computeUnitLimit) {
|
|
148
|
+
transaction.add(ComputeBudgetProgram.setComputeUnitLimit({
|
|
149
|
+
units: options.computeUnitLimit,
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
if (options?.computeUnitPrice) {
|
|
153
|
+
transaction.add(ComputeBudgetProgram.setComputeUnitPrice({
|
|
154
|
+
microLamports: options.computeUnitPrice,
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
// 添加业务指令
|
|
158
|
+
transaction.add(...instructions);
|
|
159
|
+
// 添加 Tip 指令(如果需要)
|
|
160
|
+
if (options?.addTip) {
|
|
161
|
+
const tipLamports = options.tipLamports || calculateRecommendedTip(1);
|
|
162
|
+
transaction.add(buildTipInstruction(feePayer.publicKey, tipLamports, options.tipAccount));
|
|
163
|
+
}
|
|
164
|
+
transaction.recentBlockhash = blockhash;
|
|
165
|
+
transaction.feePayer = feePayer.publicKey;
|
|
166
|
+
transaction.sign(...signers);
|
|
167
|
+
const serialized = transaction.serialize();
|
|
168
|
+
return {
|
|
169
|
+
data: Buffer.from(serialized).toString('base64'),
|
|
170
|
+
isVersioned: false,
|
|
171
|
+
signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : undefined,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 构建批量交易并签名(每个钱包一笔交易)
|
|
176
|
+
* @param connection Solana 连接
|
|
177
|
+
* @param walletInstructions 每个钱包的指令
|
|
178
|
+
* @param options 选项
|
|
179
|
+
*/
|
|
180
|
+
export async function buildAndSignBatchTransactions(connection, walletInstructions, options) {
|
|
181
|
+
if (walletInstructions.length === 0) {
|
|
182
|
+
throw new Error('No transactions to build');
|
|
183
|
+
}
|
|
184
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('finalized');
|
|
185
|
+
const serializedTransactions = [];
|
|
186
|
+
const allSignatures = [];
|
|
187
|
+
// 确定 tip 支付者
|
|
188
|
+
const tipPayer = options?.feePayer || walletInstructions[0].wallet;
|
|
189
|
+
const tipAccount = options?.tipAccount || getRandomTipAccount();
|
|
190
|
+
const tipLamports = options?.tipLamports || calculateRecommendedTip(walletInstructions.length);
|
|
191
|
+
// 构建每个交易
|
|
192
|
+
for (const { wallet, instructions } of walletInstructions) {
|
|
193
|
+
const transaction = new Transaction();
|
|
194
|
+
// 添加计算预算
|
|
195
|
+
if (options?.computeUnitLimit) {
|
|
196
|
+
transaction.add(ComputeBudgetProgram.setComputeUnitLimit({
|
|
197
|
+
units: options.computeUnitLimit,
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
if (options?.computeUnitPrice) {
|
|
201
|
+
transaction.add(ComputeBudgetProgram.setComputeUnitPrice({
|
|
202
|
+
microLamports: options.computeUnitPrice,
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
// 添加业务指令
|
|
206
|
+
transaction.add(...instructions);
|
|
207
|
+
// 设置 blockhash 和 feePayer
|
|
208
|
+
transaction.recentBlockhash = blockhash;
|
|
209
|
+
transaction.feePayer = options?.feePayer?.publicKey || wallet.publicKey;
|
|
210
|
+
// 签名
|
|
211
|
+
const signers = options?.feePayer
|
|
212
|
+
? [options.feePayer, wallet].filter((s, i, arr) => arr.findIndex(x => x.publicKey.equals(s.publicKey)) === i)
|
|
213
|
+
: [wallet];
|
|
214
|
+
transaction.sign(...signers);
|
|
215
|
+
const serialized = transaction.serialize();
|
|
216
|
+
serializedTransactions.push({
|
|
217
|
+
data: Buffer.from(serialized).toString('base64'),
|
|
218
|
+
isVersioned: false,
|
|
219
|
+
signature: transaction.signature ? Buffer.from(transaction.signature).toString('base64') : undefined,
|
|
220
|
+
});
|
|
221
|
+
if (transaction.signature) {
|
|
222
|
+
allSignatures.push(Buffer.from(transaction.signature).toString('base64'));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// 添加 Tip 交易
|
|
226
|
+
if (options?.addTip !== false) {
|
|
227
|
+
const tipTx = new Transaction().add(buildTipInstruction(tipPayer.publicKey, tipLamports, tipAccount));
|
|
228
|
+
tipTx.recentBlockhash = blockhash;
|
|
229
|
+
tipTx.feePayer = tipPayer.publicKey;
|
|
230
|
+
tipTx.sign(tipPayer);
|
|
231
|
+
serializedTransactions.push({
|
|
232
|
+
data: Buffer.from(tipTx.serialize()).toString('base64'),
|
|
233
|
+
isVersioned: false,
|
|
234
|
+
signature: tipTx.signature ? Buffer.from(tipTx.signature).toString('base64') : undefined,
|
|
235
|
+
});
|
|
236
|
+
if (tipTx.signature) {
|
|
237
|
+
allSignatures.push(Buffer.from(tipTx.signature).toString('base64'));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
transactions: serializedTransactions,
|
|
242
|
+
signatures: allSignatures,
|
|
243
|
+
tip: {
|
|
244
|
+
account: tipAccount,
|
|
245
|
+
lamports: tipLamports,
|
|
246
|
+
},
|
|
247
|
+
recentBlockhash: blockhash,
|
|
248
|
+
lastValidBlockHeight,
|
|
249
|
+
createdAt: Date.now(),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* 将 SignedBundleData 转换为后端 API 需要的格式
|
|
254
|
+
* @param bundleData 签名后的 Bundle 数据
|
|
255
|
+
*/
|
|
256
|
+
export function toBundleRequest(bundleData) {
|
|
257
|
+
return {
|
|
258
|
+
transactions: bundleData.transactions.map(tx => tx.data),
|
|
259
|
+
signatures: bundleData.signatures,
|
|
260
|
+
tipAccount: bundleData.tip.account,
|
|
261
|
+
tipLamports: bundleData.tip.lamports.toString(),
|
|
262
|
+
recentBlockhash: bundleData.recentBlockhash,
|
|
263
|
+
lastValidBlockHeight: bundleData.lastValidBlockHeight,
|
|
264
|
+
timestamp: bundleData.createdAt,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/jito/bundle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,WAAW,EAIX,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAO7F;;;GAGG;AACH,MAAM,OAAO,aAAa;IAChB,UAAU,CAAa;IACvB,YAAY,GAAkB,EAAE,CAAC;IACjC,OAAO,GAAgB,EAAE,CAAC;IAC1B,UAAU,CAAS;IACnB,WAAW,CAAS;IAE5B,YACE,UAAsB,EACtB,OAGC;QAED,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,CAAC;QAC/D,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAClF,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,WAAwB,EAAE,OAAkB;QACzD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,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C,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,OAAO;QAClC,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE;QAC/C,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,oBAAoB,EAAE,UAAU,CAAC,oBAAoB;QACrD,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jito/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jito/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jito Tip 相关功能
|
|
3
|
+
* @module sol/jito/tip
|
|
4
|
+
*/
|
|
5
|
+
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
6
|
+
/**
|
|
7
|
+
* 随机选择一个 Tip 账户
|
|
8
|
+
* @returns Tip 账户地址
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRandomTipAccount(): string;
|
|
11
|
+
/**
|
|
12
|
+
* 获取所有 Tip 账户
|
|
13
|
+
* @returns Tip 账户列表
|
|
14
|
+
*/
|
|
15
|
+
export declare function getAllTipAccounts(): string[];
|
|
16
|
+
/**
|
|
17
|
+
* 验证是否是有效的 Tip 账户
|
|
18
|
+
* @param address 地址
|
|
19
|
+
*/
|
|
20
|
+
export declare function isValidTipAccount(address: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 构建 Tip 指令
|
|
23
|
+
* @param fromPubkey 付款者公钥
|
|
24
|
+
* @param tipLamports Tip 金额(lamports)
|
|
25
|
+
* @param tipAccount 可选:指定 Tip 账户,默认随机选择
|
|
26
|
+
* @returns TransactionInstruction
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildTipInstruction(fromPubkey: PublicKey, tipLamports?: bigint, tipAccount?: string): TransactionInstruction;
|
|
29
|
+
/**
|
|
30
|
+
* 计算推荐的 Tip 金额
|
|
31
|
+
* 根据交易数量和优先级计算
|
|
32
|
+
* @param txCount 交易数量
|
|
33
|
+
* @param priority 优先级 (1-10,10 最高)
|
|
34
|
+
* @returns 推荐的 Tip 金额(lamports)
|
|
35
|
+
*/
|
|
36
|
+
export declare function calculateRecommendedTip(txCount?: number, priority?: number): bigint;
|
|
37
|
+
/**
|
|
38
|
+
* Tip 金额预设
|
|
39
|
+
*/
|
|
40
|
+
export declare const TIP_PRESETS: {
|
|
41
|
+
/** 最低 tip (0.00001 SOL) */
|
|
42
|
+
readonly LOW: bigint;
|
|
43
|
+
/** 标准 tip (0.0001 SOL) */
|
|
44
|
+
readonly STANDARD: bigint;
|
|
45
|
+
/** 中等 tip (0.0005 SOL) */
|
|
46
|
+
readonly MEDIUM: bigint;
|
|
47
|
+
/** 高 tip (0.001 SOL) */
|
|
48
|
+
readonly HIGH: bigint;
|
|
49
|
+
/** 紧急 tip (0.005 SOL) */
|
|
50
|
+
readonly URGENT: bigint;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=tip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tip.d.ts","sourceRoot":"","sources":["../../src/jito/tip.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,SAAS,EAET,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAGzB;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAI5C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAE5C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,SAAS,EACrB,WAAW,GAAE,MAAiD,EAC9D,UAAU,CAAC,EAAE,MAAM,GAClB,sBAAsB,CAaxB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,MAAU,EACnB,QAAQ,GAAE,MAAU,GACnB,MAAM,CAgBR;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB,2BAA2B;;IAE3B,0BAA0B;;IAE1B,0BAA0B;;IAE1B,wBAAwB;;IAExB,yBAAyB;;CAEjB,CAAC"}
|
package/dist/jito/tip.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jito Tip 相关功能
|
|
3
|
+
* @module sol/jito/tip
|
|
4
|
+
*/
|
|
5
|
+
import { PublicKey, SystemProgram, } from '@solana/web3.js';
|
|
6
|
+
import { JITO_CONFIG } from '../constants.js';
|
|
7
|
+
/**
|
|
8
|
+
* 随机选择一个 Tip 账户
|
|
9
|
+
* @returns Tip 账户地址
|
|
10
|
+
*/
|
|
11
|
+
export function getRandomTipAccount() {
|
|
12
|
+
const accounts = JITO_CONFIG.TIP_ACCOUNTS;
|
|
13
|
+
const index = Math.floor(Math.random() * accounts.length);
|
|
14
|
+
return accounts[index];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 获取所有 Tip 账户
|
|
18
|
+
* @returns Tip 账户列表
|
|
19
|
+
*/
|
|
20
|
+
export function getAllTipAccounts() {
|
|
21
|
+
return [...JITO_CONFIG.TIP_ACCOUNTS];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 验证是否是有效的 Tip 账户
|
|
25
|
+
* @param address 地址
|
|
26
|
+
*/
|
|
27
|
+
export function isValidTipAccount(address) {
|
|
28
|
+
return JITO_CONFIG.TIP_ACCOUNTS.includes(address);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 构建 Tip 指令
|
|
32
|
+
* @param fromPubkey 付款者公钥
|
|
33
|
+
* @param tipLamports Tip 金额(lamports)
|
|
34
|
+
* @param tipAccount 可选:指定 Tip 账户,默认随机选择
|
|
35
|
+
* @returns TransactionInstruction
|
|
36
|
+
*/
|
|
37
|
+
export function buildTipInstruction(fromPubkey, tipLamports = BigInt(JITO_CONFIG.DEFAULT_TIP_LAMPORTS), tipAccount) {
|
|
38
|
+
const tipAccountAddress = tipAccount || getRandomTipAccount();
|
|
39
|
+
// 确保 tip 金额不低于最小值
|
|
40
|
+
const finalTip = tipLamports < BigInt(JITO_CONFIG.MIN_TIP_LAMPORTS)
|
|
41
|
+
? BigInt(JITO_CONFIG.MIN_TIP_LAMPORTS)
|
|
42
|
+
: tipLamports;
|
|
43
|
+
return SystemProgram.transfer({
|
|
44
|
+
fromPubkey,
|
|
45
|
+
toPubkey: new PublicKey(tipAccountAddress),
|
|
46
|
+
lamports: finalTip,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 计算推荐的 Tip 金额
|
|
51
|
+
* 根据交易数量和优先级计算
|
|
52
|
+
* @param txCount 交易数量
|
|
53
|
+
* @param priority 优先级 (1-10,10 最高)
|
|
54
|
+
* @returns 推荐的 Tip 金额(lamports)
|
|
55
|
+
*/
|
|
56
|
+
export function calculateRecommendedTip(txCount = 1, priority = 5) {
|
|
57
|
+
// 基础 tip
|
|
58
|
+
const baseTip = BigInt(JITO_CONFIG.DEFAULT_TIP_LAMPORTS);
|
|
59
|
+
// 根据交易数量增加
|
|
60
|
+
const txMultiplier = BigInt(Math.max(1, txCount));
|
|
61
|
+
// 根据优先级增加(1-10 映射到 0.5x - 2x)
|
|
62
|
+
const priorityMultiplier = 0.5 + (priority / 10) * 1.5;
|
|
63
|
+
const tip = BigInt(Math.floor(Number(baseTip * txMultiplier) * priorityMultiplier));
|
|
64
|
+
// 确保不低于最小值
|
|
65
|
+
return tip < BigInt(JITO_CONFIG.MIN_TIP_LAMPORTS)
|
|
66
|
+
? BigInt(JITO_CONFIG.MIN_TIP_LAMPORTS)
|
|
67
|
+
: tip;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Tip 金额预设
|
|
71
|
+
*/
|
|
72
|
+
export const TIP_PRESETS = {
|
|
73
|
+
/** 最低 tip (0.00001 SOL) */
|
|
74
|
+
LOW: BigInt(10_000),
|
|
75
|
+
/** 标准 tip (0.0001 SOL) */
|
|
76
|
+
STANDARD: BigInt(100_000),
|
|
77
|
+
/** 中等 tip (0.0005 SOL) */
|
|
78
|
+
MEDIUM: BigInt(500_000),
|
|
79
|
+
/** 高 tip (0.001 SOL) */
|
|
80
|
+
HIGH: BigInt(1_000_000),
|
|
81
|
+
/** 紧急 tip (0.005 SOL) */
|
|
82
|
+
URGENT: BigInt(5_000_000),
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=tip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tip.js","sourceRoot":"","sources":["../../src/jito/tip.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,SAAS,EACT,aAAa,GAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAC;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,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