docs: README 中英文更新 - Cashback 章节与大纲、示例与表格同步
- 大纲增加 Cashback 支持(PumpFun/PumpSwap)入口 - 新增 Cashback 说明:交易侧无需改代码,事件解析可获返现字段 - 英文:Method 1 增加 with_wsol_ata_config 可选示例 - 中文:创建客户端拆为方式一/方式二,表格增加 shared_infrastructure,特性增加共享基础设施 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -51,6 +51,7 @@
|
|||||||
- [🔧 Middleware System](#-middleware-system)
|
- [🔧 Middleware System](#-middleware-system)
|
||||||
- [🔍 Address Lookup Tables](#-address-lookup-tables)
|
- [🔍 Address Lookup Tables](#-address-lookup-tables)
|
||||||
- [🔍 Nonce Cache](#-nonce-cache)
|
- [🔍 Nonce Cache](#-nonce-cache)
|
||||||
|
- [💰 Cashback Support (PumpFun / PumpSwap)](#-cashback-support-pumpfun--pumpswap)
|
||||||
- [🛡️ MEV Protection Services](#️-mev-protection-services)
|
- [🛡️ MEV Protection Services](#️-mev-protection-services)
|
||||||
- [📁 Project Structure](#-project-structure)
|
- [📁 Project Structure](#-project-structure)
|
||||||
- [📄 License](#-license)
|
- [📄 License](#-license)
|
||||||
@@ -122,6 +123,10 @@ let swqos_configs: Vec<SwqosConfig> = vec.
|
Use Durable Nonce to implement transaction replay protection and optimize transaction processing. For detailed information, see the [Durable Nonce Guide](docs/NONCE_CACHE.md).
|
||||||
|
|
||||||
|
## 💰 Cashback Support (PumpFun / PumpSwap)
|
||||||
|
|
||||||
|
PumpFun and PumpSwap support **cashback** for eligible tokens: part of the trading fee can be returned to the user. When you use this SDK to execute `buy` or `sell`, the transaction is submitted as usual; if the token has cashback enabled, the protocol will credit cashback according to its rules.
|
||||||
|
|
||||||
|
- **Trading**: No change to your code—use `TradeBuyParams` / `TradeSellParams` as normal. Cashback is handled on-chain.
|
||||||
|
- **Event parsing**: If you consume chain events (e.g. via [sol-parser-sdk](https://github.com/0xfnzero/sol-parser-sdk)), trade events can expose cashback-related fields (e.g. `cashback_fee_basis_points`, `cashback`, `is_cashback_enabled`) so your strategy or analytics can be cashback-aware.
|
||||||
|
|
||||||
## 🛡️ MEV Protection Services
|
## 🛡️ MEV Protection Services
|
||||||
|
|
||||||
You can apply for a key through the official website: [Community Website](https://fnzero.dev/swqos)
|
You can apply for a key through the official website: [Community Website](https://fnzero.dev/swqos)
|
||||||
|
|||||||
+30
-14
@@ -51,6 +51,7 @@
|
|||||||
- [🔧 中间件系统说明](#-中间件系统说明)
|
- [🔧 中间件系统说明](#-中间件系统说明)
|
||||||
- [🔍 地址查找表](#-地址查找表)
|
- [🔍 地址查找表](#-地址查找表)
|
||||||
- [🔍 Nonce 缓存](#-nonce-缓存)
|
- [🔍 Nonce 缓存](#-nonce-缓存)
|
||||||
|
- [💰 Cashback 支持(PumpFun / PumpSwap)](#-cashback-支持pumpfun--pumpswap)
|
||||||
- [🛡️ MEV 保护服务](#️-mev-保护服务)
|
- [🛡️ MEV 保护服务](#️-mev-保护服务)
|
||||||
- [📁 项目结构](#-项目结构)
|
- [📁 项目结构](#-项目结构)
|
||||||
- [📄 许可证](#-许可证)
|
- [📄 许可证](#-许可证)
|
||||||
@@ -71,6 +72,7 @@
|
|||||||
8. **并发交易**: 同时使用多个 MEV 服务发送交易,最快的成功,其他失败
|
8. **并发交易**: 同时使用多个 MEV 服务发送交易,最快的成功,其他失败
|
||||||
9. **统一交易接口**: 使用统一的交易协议枚举进行交易操作
|
9. **统一交易接口**: 使用统一的交易协议枚举进行交易操作
|
||||||
10. **中间件系统**: 支持自定义指令中间件,可在交易执行前对指令进行修改、添加或移除
|
10. **中间件系统**: 支持自定义指令中间件,可在交易执行前对指令进行修改、添加或移除
|
||||||
|
11. **共享基础设施**: 多钱包可共享同一套 RPC 与 SWQOS 客户端,降低资源占用
|
||||||
|
|
||||||
## 📦 安装
|
## 📦 安装
|
||||||
|
|
||||||
@@ -103,40 +105,46 @@ sol-trade-sdk = "3.4.0"
|
|||||||
|
|
||||||
#### 1. 创建 TradingClient 实例
|
#### 1. 创建 TradingClient 实例
|
||||||
|
|
||||||
可以参考 [示例:创建 TradingClient 实例](examples/trading_client/src/main.rs)。
|
可参考 [示例:创建 TradingClient 实例](examples/trading_client/src/main.rs)。
|
||||||
|
|
||||||
|
**方式一:简单创建(单钱包)**
|
||||||
```rust
|
```rust
|
||||||
// 钱包
|
// 钱包
|
||||||
let payer = Keypair::from_base58_string("use_your_payer_keypair_here");
|
let payer = Keypair::from_base58_string("use_your_payer_keypair_here");
|
||||||
// RPC 地址
|
// RPC 地址
|
||||||
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
||||||
let commitment = CommitmentConfig::processed();
|
let commitment = CommitmentConfig::processed();
|
||||||
// 可以配置多个SWQOS服务
|
// 可配置多个 SWQOS 服务
|
||||||
let swqos_configs: Vec<SwqosConfig> = vec![
|
let swqos_configs: Vec<SwqosConfig> = vec![
|
||||||
SwqosConfig::Default(rpc_url.clone()),
|
SwqosConfig::Default(rpc_url.clone()),
|
||||||
SwqosConfig::Jito("your uuid".to_string(), SwqosRegion::Frankfurt, None),
|
SwqosConfig::Jito("your uuid".to_string(), SwqosRegion::Frankfurt, None),
|
||||||
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt, None),
|
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt, None),
|
||||||
SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt, None),
|
|
||||||
SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt, None),
|
|
||||||
SwqosConfig::FlashBlock("your api_token".to_string(), SwqosRegion::Frankfurt, None),
|
|
||||||
SwqosConfig::Node1("your api_token".to_string(), SwqosRegion::Frankfurt, None),
|
|
||||||
SwqosConfig::BlockRazor("your api_token".to_string(), SwqosRegion::Frankfurt, None),
|
|
||||||
SwqosConfig::Astralane("your api_token".to_string(), SwqosRegion::Frankfurt, None),
|
|
||||||
];
|
];
|
||||||
// 创建 TradeConfig 实例
|
// 创建 TradeConfig 实例
|
||||||
let trade_config = TradeConfig::new(rpc_url, swqos_configs, commitment);
|
let trade_config = TradeConfig::new(rpc_url, swqos_configs, commitment);
|
||||||
|
|
||||||
// 可选:自定义 WSOL ATA 和 Seed 优化设置
|
// 可选:自定义 WSOL ATA 与 Seed 优化
|
||||||
// let trade_config = TradeConfig::new(rpc_url, swqos_configs, commitment)
|
// let trade_config = TradeConfig::new(rpc_url, swqos_configs, commitment)
|
||||||
// .with_wsol_ata_config(
|
// .with_wsol_ata_config(true, true); // create_wsol_ata_on_startup, use_seed_optimize
|
||||||
// true, // create_wsol_ata_on_startup: 启动时检查并创建 WSOL ATA(默认: true)
|
|
||||||
// true // use_seed_optimize: 全局启用所有 ATA 操作的 seed 优化(默认: true)
|
|
||||||
// );
|
|
||||||
|
|
||||||
// 创建 TradingClient 客户端
|
// 创建 TradingClient
|
||||||
let client = TradingClient::new(Arc::new(payer), trade_config).await;
|
let client = TradingClient::new(Arc::new(payer), trade_config).await;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**方式二:共享基础设施(多钱包)**
|
||||||
|
|
||||||
|
多钱包场景下可先创建一份基础设施,再复用到多个钱包。参见 [示例:共享基础设施](examples/shared_infrastructure/src/main.rs)。
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// 创建一次基础设施(开销较大)
|
||||||
|
let infra_config = InfrastructureConfig::new(rpc_url, swqos_configs, commitment);
|
||||||
|
let infrastructure = Arc::new(TradingInfrastructure::new(infra_config).await);
|
||||||
|
|
||||||
|
// 基于同一基础设施创建多个客户端(开销小)
|
||||||
|
let client1 = TradingClient::from_infrastructure(Arc::new(payer1), infrastructure.clone(), true);
|
||||||
|
let client2 = TradingClient::from_infrastructure(Arc::new(payer2), infrastructure.clone(), true);
|
||||||
|
```
|
||||||
|
|
||||||
#### 2. 配置 Gas Fee 策略
|
#### 2. 配置 Gas Fee 策略
|
||||||
|
|
||||||
有关 Gas Fee 策略的详细信息,请参阅 [Gas Fee 策略参考手册](docs/GAS_FEE_STRATEGY_CN.md)。
|
有关 Gas Fee 策略的详细信息,请参阅 [Gas Fee 策略参考手册](docs/GAS_FEE_STRATEGY_CN.md)。
|
||||||
@@ -198,6 +206,7 @@ client.buy(buy_params).await?;
|
|||||||
| 描述 | 运行命令 | 源码路径 |
|
| 描述 | 运行命令 | 源码路径 |
|
||||||
|------|---------|----------|
|
|------|---------|----------|
|
||||||
| 创建和配置 TradingClient 实例 | `cargo run --package trading_client` | [examples/trading_client](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/trading_client/src/main.rs) |
|
| 创建和配置 TradingClient 实例 | `cargo run --package trading_client` | [examples/trading_client](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/trading_client/src/main.rs) |
|
||||||
|
| 多钱包共享基础设施 | `cargo run --package shared_infrastructure` | [examples/shared_infrastructure](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/shared_infrastructure/src/main.rs) |
|
||||||
| PumpFun 代币狙击交易 | `cargo run --package pumpfun_sniper_trading` | [examples/pumpfun_sniper_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpfun_sniper_trading/src/main.rs) |
|
| PumpFun 代币狙击交易 | `cargo run --package pumpfun_sniper_trading` | [examples/pumpfun_sniper_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpfun_sniper_trading/src/main.rs) |
|
||||||
| PumpFun 代币跟单交易 | `cargo run --package pumpfun_copy_trading` | [examples/pumpfun_copy_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpfun_copy_trading/src/main.rs) |
|
| PumpFun 代币跟单交易 | `cargo run --package pumpfun_copy_trading` | [examples/pumpfun_copy_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpfun_copy_trading/src/main.rs) |
|
||||||
| PumpSwap 交易操作 | `cargo run --package pumpswap_trading` | [examples/pumpswap_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpswap_trading/src/main.rs) |
|
| PumpSwap 交易操作 | `cargo run --package pumpswap_trading` | [examples/pumpswap_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpswap_trading/src/main.rs) |
|
||||||
@@ -268,6 +277,13 @@ let middleware_manager = MiddlewareManager::new()
|
|||||||
|
|
||||||
使用 Durable Nonce 来实现交易重放保护和优化交易处理。详细信息请参阅 [Nonce 使用指南](docs/NONCE_CACHE_CN.md)。
|
使用 Durable Nonce 来实现交易重放保护和优化交易处理。详细信息请参阅 [Nonce 使用指南](docs/NONCE_CACHE_CN.md)。
|
||||||
|
|
||||||
|
## 💰 Cashback 支持(PumpFun / PumpSwap)
|
||||||
|
|
||||||
|
PumpFun 与 PumpSwap 支持**返现(Cashback)**:部分手续费可返还给用户。使用本 SDK 执行 `buy` / `sell` 时,按正常方式提交交易即可;若代币已开启返现,协议会按规则自动结算返现。
|
||||||
|
|
||||||
|
- **交易侧**:无需改代码,照常使用 `TradeBuyParams` / `TradeSellParams`,返现由链上处理。
|
||||||
|
- **事件解析**:若通过事件驱动(如 [sol-parser-sdk](https://github.com/0xfnzero/sol-parser-sdk))消费链上事件,可获取返现相关字段(如 `cashback_fee_basis_points`、`cashback`、`is_cashback_enabled`),便于策略或统计与返现逻辑结合。
|
||||||
|
|
||||||
## 🛡️ MEV 保护服务
|
## 🛡️ MEV 保护服务
|
||||||
|
|
||||||
可以通过官网申请密钥:[社区官网](https://fnzero.dev/swqos)
|
可以通过官网申请密钥:[社区官网](https://fnzero.dev/swqos)
|
||||||
|
|||||||
Reference in New Issue
Block a user