feat: upgrade to v2.0.0 with major dependency updates

- Upgrade Solana dependencies from 2.3.x to 3.0.0 series
  - Upgrade solana-streamer-sdk from 0.4.13 to 0.5.0
  - Upgrade yellowstone-grpc from 8.0.0 to 9.0.0
  - Add new SPL token utility modules (spl_token.rs, spl_token_2022.rs,
  spl_associated_token_account.rs)
  - Remove deprecated gRPC protocol definitions (protos/ directory)
  - Remove event_subscription example and update all example dependencies
  - Update README documentation to reflect v2.0.0 changes
  - Refactor imports to use new dependency structure across examples

  BREAKING CHANGES:
  - Solana SDK upgraded to 3.0.0 with API changes
  - Removed gRPC protocol definitions
  - Updated import paths for SPL token operations
This commit is contained in:
ysq
2025-09-27 14:24:41 +08:00
parent e75b0c9480
commit a7f673b43d
70 changed files with 502 additions and 3001 deletions
+4 -2
View File
@@ -5,7 +5,9 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-address-lookup-table-interface = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
anyhow = "1.0.94"
+20 -25
View File
@@ -1,3 +1,23 @@
use sol_trade_sdk::common::address_lookup_cache::AddressLookupTableCache;
use sol_trade_sdk::common::SolanaRpcClient;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::{
common::AnyResult,
swqos::SwqosConfig,
trading::{core::params::PumpFunParams, factory::DexType},
SolanaTrade,
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Keypair;
use solana_streamer_sdk::match_event;
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
use solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::parser::PUMPFUN_PROGRAM_ID;
use solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::streaming::yellowstone_grpc::{AccountFilter, TransactionFilter};
use solana_streamer_sdk::streaming::YellowstoneGrpc;
use std::{
str::FromStr,
sync::{
@@ -6,31 +26,6 @@ use std::{
},
};
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::parser::PUMPFUN_PROGRAM_ID;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use sol_trade_sdk::solana_streamer_sdk::streaming::yellowstone_grpc::{
AccountFilter, TransactionFilter,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::YellowstoneGrpc;
use sol_trade_sdk::{
common::address_lookup_cache::AddressLookupTableCache,
solana_streamer_sdk::streaming::event_parser::common::EventType,
};
use sol_trade_sdk::{
common::AnyResult,
swqos::SwqosConfig,
trading::{core::params::PumpFunParams, factory::DexType},
SolanaTrade,
};
use sol_trade_sdk::{
common::SolanaRpcClient,
solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter,
};
use sol_trade_sdk::{common::TradeConfig, solana_streamer_sdk::match_event};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
// Global static flag to ensure transaction is executed only once
static ALREADY_EXECUTED: AtomicBool = AtomicBool::new(false);
+3 -2
View File
@@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
+12 -12
View File
@@ -3,25 +3,25 @@ use std::sync::{
Arc,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::EventType;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::bonk::parser::BONK_PROGRAM_ID;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::bonk::BonkTradeEvent;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use sol_trade_sdk::solana_streamer_sdk::streaming::yellowstone_grpc::{
AccountFilter, TransactionFilter,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::YellowstoneGrpc;
use sol_trade_sdk::common::spl_associated_token_account::get_associated_token_address;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::{
common::AnyResult,
swqos::SwqosConfig,
trading::{core::params::BonkParams, factory::DexType},
SolanaTrade,
};
use sol_trade_sdk::{common::TradeConfig, solana_streamer_sdk::match_event};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::signer::Signer;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use spl_associated_token_account::get_associated_token_address;
use solana_streamer_sdk::match_event;
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
use solana_streamer_sdk::streaming::event_parser::protocols::bonk::parser::BONK_PROGRAM_ID;
use solana_streamer_sdk::streaming::event_parser::protocols::bonk::BonkTradeEvent;
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::streaming::yellowstone_grpc::{AccountFilter, TransactionFilter};
use solana_streamer_sdk::streaming::YellowstoneGrpc;
// Global static flag to ensure transaction is executed only once
static ALREADY_EXECUTED: AtomicBool = AtomicBool::new(false);
+3 -2
View File
@@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
+8 -7
View File
@@ -1,18 +1,19 @@
use sol_trade_sdk::common::spl_associated_token_account::get_associated_token_address;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::EventType;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::bonk::BonkTradeEvent;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use sol_trade_sdk::solana_streamer_sdk::{match_event, streaming::ShredStreamGrpc};
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
use solana_streamer_sdk::streaming::event_parser::protocols::bonk::BonkTradeEvent;
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::{match_event, streaming::ShredStreamGrpc};
use sol_trade_sdk::{
common::AnyResult,
swqos::SwqosConfig,
trading::{core::params::BonkParams, factory::DexType},
SolanaTrade,
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::signer::Signer;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use spl_associated_token_account::get_associated_token_address;
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
+3 -3
View File
@@ -5,8 +5,8 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
solana-system-interface = "2.0.0"
tokio = { version = "1", features = ["full"] }
clap = { version = "4.0", features = ["derive"] }
spl-token = "8.0.0"
spl-associated-token-account = "7.0.0"
+28 -22
View File
@@ -1,8 +1,14 @@
use clap::Parser;
use sol_trade_sdk::{
common::{
fast_fn::get_associated_token_address_with_program_id_fast_use_seed, AnyResult, TradeConfig,
fast_fn::get_associated_token_address_with_program_id_fast_use_seed,
spl_associated_token_account::{
create_associated_token_account_idempotent, get_associated_token_address,
},
spl_token::{self, close_account},
AnyResult, TradeConfig,
},
constants::WSOL_TOKEN_ACCOUNT,
swqos::SwqosConfig,
trading::{
core::params::{
@@ -12,10 +18,15 @@ use sol_trade_sdk::{
},
SolanaTrade, TradeBuyParams, TradeSellParams, TradeTokenType,
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::{
commitment_config::CommitmentConfig, native_token::sol_str_to_lamports, pubkey::Pubkey,
signature::Keypair, signer::Signer,
message::{AccountMeta, Instruction},
native_token::sol_str_to_lamports,
pubkey::Pubkey,
signature::Keypair,
signer::Signer,
};
use solana_system_interface::instruction::transfer;
use std::sync::{Arc, LazyLock};
use std::{
io::{self, Write},
@@ -1238,7 +1249,7 @@ async fn handle_close_wsol() -> Result<(), Box<dyn std::error::Error>> {
match initialize_real_client().await {
Ok(client) => {
// Check WSOL balance first
let wsol_mint = spl_token::native_mint::id();
let wsol_mint = WSOL_TOKEN_ACCOUNT;
match client.get_payer_token_balance(&wsol_mint).await {
Ok(wsol_balance) => {
if wsol_balance == 0 {
@@ -1332,29 +1343,27 @@ async fn wrap_sol_real(
let wsol_mint = "So11111111111111111111111111111111111111112".parse().unwrap();
let instructions = vec![
// Create associated token account for WSOL
spl_associated_token_account::instruction::create_associated_token_account_idempotent(
create_associated_token_account_idempotent(
&client.get_payer_pubkey(),
&client.get_payer_pubkey(),
&wsol_mint,
&spl_token::ID,
),
// Transfer SOL to WSOL account
solana_sdk::system_instruction::transfer(
transfer(
&client.get_payer_pubkey(),
&spl_associated_token_account::get_associated_token_address(
&client.get_payer_pubkey(),
&wsol_mint,
),
&get_associated_token_address(&client.get_payer_pubkey(), &wsol_mint),
amount_lamports,
),
// Sync native (convert SOL to WSOL tokens)
spl_token::instruction::sync_native(
&spl_token::ID,
&spl_associated_token_account::get_associated_token_address(
&client.get_payer_pubkey(),
&wsol_mint,
),
)?,
Instruction {
program_id: sol_trade_sdk::constants::TOKEN_PROGRAM,
accounts: vec![AccountMeta::new(
get_associated_token_address(&client.get_payer_pubkey(), &wsol_mint),
false,
)],
data: vec![17],
},
];
// Build and send transaction
@@ -1375,10 +1384,7 @@ async fn close_wsol_real(client: &SolanaTrade) -> Result<(), Box<dyn std::error:
use solana_sdk::transaction::Transaction;
let wsol_mint = "So11111111111111111111111111111111111111112".parse().unwrap();
let wsol_account = spl_associated_token_account::get_associated_token_address(
&client.get_payer_pubkey(),
&wsol_mint,
);
let wsol_account = get_associated_token_address(&client.get_payer_pubkey(), &wsol_mint);
// Check if WSOL account exists
let account_info = client.rpc.get_account(&wsol_account).await;
@@ -1387,7 +1393,7 @@ async fn close_wsol_real(client: &SolanaTrade) -> Result<(), Box<dyn std::error:
}
// Close WSOL account instruction
let close_instruction = spl_token::instruction::close_account(
let close_instruction = close_account(
&spl_token::ID,
&wsol_account,
&client.get_payer_pubkey(),
-8
View File
@@ -1,8 +0,0 @@
[package]
name = "event_subscription"
version = "0.1.0"
edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
tokio = { version = "1", features = ["full"] }
-182
View File
@@ -1,182 +0,0 @@
use sol_trade_sdk::solana_streamer_sdk::{
match_event,
streaming::{
event_parser::{
common::{filter::EventTypeFilter, EventType},
protocols::{
bonk::{parser::BONK_PROGRAM_ID, BonkPoolCreateEvent, BonkTradeEvent},
pumpfun::{parser::PUMPFUN_PROGRAM_ID, PumpFunCreateTokenEvent, PumpFunTradeEvent},
pumpswap::{
parser::PUMPSWAP_PROGRAM_ID, PumpSwapBuyEvent, PumpSwapCreatePoolEvent,
PumpSwapDepositEvent, PumpSwapSellEvent, PumpSwapWithdrawEvent,
},
raydium_amm_v4::parser::RAYDIUM_AMM_V4_PROGRAM_ID,
raydium_clmm::parser::RAYDIUM_CLMM_PROGRAM_ID,
raydium_cpmm::{parser::RAYDIUM_CPMM_PROGRAM_ID, RaydiumCpmmSwapEvent},
},
Protocol, UnifiedEvent,
},
yellowstone_grpc::{AccountFilter, TransactionFilter},
ShredStreamGrpc, YellowstoneGrpc,
},
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("This example demonstrates how to subscribe to events using Yellowstone gRPC and ShredStream.");
println!("You can choose which example to run by uncommenting the relevant function call.");
// Uncomment one of these to run the example:
test_grpc().await?; // Use public Yellowstone gRPC endpoint
// test_shreds().await?; // Use local ShredStream endpoint
Ok(())
}
/// Subscribe to events using Yellowstone gRPC
async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
println!("Subscribing to GRPC events...");
// Initialize gRPC client with public endpoint
let grpc = YellowstoneGrpc::new(
"https://solana-yellowstone-grpc.publicnode.com:443".to_string(),
None, // No auth token needed
)?;
let callback = create_event_callback();
// Define protocols to monitor
let protocols =
vec![Protocol::PumpFun, Protocol::PumpSwap, Protocol::Bonk, Protocol::RaydiumCpmm];
// Define program IDs to monitor
let account_include = vec![
PUMPFUN_PROGRAM_ID.to_string(), // Listen to pumpfun program ID
PUMPSWAP_PROGRAM_ID.to_string(), // Listen to pumpswap program ID
BONK_PROGRAM_ID.to_string(), // Listen to bonk program ID
RAYDIUM_CPMM_PROGRAM_ID.to_string(), // Listen to raydium_cpmm program ID
RAYDIUM_CLMM_PROGRAM_ID.to_string(), // Listen to raydium_clmm program ID
RAYDIUM_AMM_V4_PROGRAM_ID.to_string(), // Listen to raydium_amm_v4 program ID
];
let account_exclude = vec![];
let account_required = vec![];
// Configure transaction filter
let transaction_filter = TransactionFilter {
account_include: account_include.clone(),
account_exclude,
account_required,
};
// Configure account filter for program-owned accounts
let account_filter =
AccountFilter { account: vec![], owner: account_include.clone(), filters: vec![] };
// Configure event type filter (all events)
let event_type_filter = None;
// For specific events only:
// let event_type_filter =
// EventTypeFilter { include: vec![EventType::PumpSwapBuy, EventType::PumpSwapSell] };
println!("Starting to listen for events, press Ctrl+C to stop...");
// Start subscription
grpc.subscribe_events_immediate(
protocols,
None,
vec![transaction_filter],
vec![account_filter],
event_type_filter,
None,
callback,
)
.await?;
// Wait for termination signal
tokio::signal::ctrl_c().await?;
Ok(())
}
/// Subscribe to events using ShredStream
async fn test_shreds() -> Result<(), Box<dyn std::error::Error>> {
println!("Subscribing to ShredStream events...");
// Initialize ShredStream client with local endpoint
let shred_stream = ShredStreamGrpc::new("http://127.0.0.1:10800".to_string()).await?;
let callback = create_event_callback();
// Define protocols to monitor
let protocols = vec![Protocol::PumpFun, Protocol::PumpSwap, Protocol::Bonk];
// Configure event type filter (all events)
let event_type_filter = None;
// For specific events only:
// let event_type_filter =
// EventTypeFilter { include: vec![EventType::PumpSwapBuy, EventType::PumpSwapSell] };
println!("Starting to listen for events, press Ctrl+C to stop...");
// Start subscription
shred_stream
.shredstream_subscribe(
protocols,
None, // No slot range specified
event_type_filter,
callback,
)
.await?;
// Wait for termination signal
tokio::signal::ctrl_c().await?;
Ok(())
}
/// Create an event callback function that handles different types of events
fn create_event_callback() -> impl Fn(Box<dyn UnifiedEvent>) {
|event: Box<dyn UnifiedEvent>| {
// Process events using match_event! macro
match_event!(event, {
// Bonk protocol events
BonkPoolCreateEvent => |e: BonkPoolCreateEvent| {
println!("BonkPoolCreateEvent: {:?}", e.base_mint_param.symbol);
},
BonkTradeEvent => |e: BonkTradeEvent| {
println!("BonkTradeEvent: {:?}", e);
},
// PumpFun protocol events
PumpFunTradeEvent => |e: PumpFunTradeEvent| {
println!("PumpFunTradeEvent: {:?}", e);
},
PumpFunCreateTokenEvent => |e: PumpFunCreateTokenEvent| {
println!("PumpFunCreateTokenEvent: {:?}", e);
},
// PumpSwap protocol events
PumpSwapBuyEvent => |e: PumpSwapBuyEvent| {
println!("Buy event: {:?}", e);
},
PumpSwapSellEvent => |e: PumpSwapSellEvent| {
println!("Sell event: {:?}", e);
},
PumpSwapCreatePoolEvent => |e: PumpSwapCreatePoolEvent| {
println!("CreatePool event: {:?}", e);
},
PumpSwapDepositEvent => |e: PumpSwapDepositEvent| {
println!("Deposit event: {:?}", e);
},
PumpSwapWithdrawEvent => |e: PumpSwapWithdrawEvent| {
println!("Withdraw event: {:?}", e);
},
// Raydium protocol events
RaydiumCpmmSwapEvent => |e: RaydiumCpmmSwapEvent| {
println!("RaydiumCpmmSwapEvent: {:?}", e);
},
// For more events and documentation, please refer to https://github.com/0xfnzero/solana-streamer
});
}
}
+3 -1
View File
@@ -5,6 +5,8 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
anyhow = "1.0.79"
+2 -4
View File
@@ -8,10 +8,8 @@ use sol_trade_sdk::{
},
SolanaTrade, TradeTokenType,
};
use solana_sdk::{
commitment_config::CommitmentConfig, instruction::Instruction, pubkey::Pubkey,
signature::Keypair,
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::{instruction::Instruction, pubkey::Pubkey, signature::Keypair};
use std::{str::FromStr, sync::Arc};
#[tokio::main]
+3 -1
View File
@@ -5,7 +5,9 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
spl-associated-token-account = "7.0.0"
tokio = { version = "1", features = ["full"] }
anyhow = "1.0.94"
+13 -16
View File
@@ -3,28 +3,25 @@ use std::sync::{
Arc,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::EventType;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use sol_trade_sdk::solana_streamer_sdk::streaming::yellowstone_grpc::{
AccountFilter, TransactionFilter,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::YellowstoneGrpc;
use sol_trade_sdk::{
common::nonce_cache::NonceCache,
solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::parser::PUMPFUN_PROGRAM_ID,
};
use sol_trade_sdk::common::nonce_cache::NonceCache;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::TradeTokenType;
use sol_trade_sdk::{
common::AnyResult,
swqos::SwqosConfig,
trading::{core::params::PumpFunParams, factory::DexType},
SolanaTrade,
};
use sol_trade_sdk::{common::TradeConfig, solana_streamer_sdk::match_event};
use sol_trade_sdk::{
solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter, TradeTokenType,
};
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_streamer_sdk::match_event;
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
use solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::parser::PUMPFUN_PROGRAM_ID;
use solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::streaming::yellowstone_grpc::{AccountFilter, TransactionFilter};
use solana_streamer_sdk::streaming::YellowstoneGrpc;
// Global static flag to ensure transaction is executed only once
static ALREADY_EXECUTED: AtomicBool = AtomicBool::new(false);
+3 -2
View File
@@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
+13 -13
View File
@@ -3,27 +3,27 @@ use std::sync::{
Arc,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::EventType;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::parser::PUMPFUN_PROGRAM_ID;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use sol_trade_sdk::solana_streamer_sdk::streaming::yellowstone_grpc::{
AccountFilter, TransactionFilter,
use sol_trade_sdk::common::{
spl_associated_token_account::get_associated_token_address, TradeConfig,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::YellowstoneGrpc;
use sol_trade_sdk::TradeTokenType;
use sol_trade_sdk::{
common::AnyResult,
swqos::SwqosConfig,
trading::{core::params::PumpFunParams, factory::DexType},
SolanaTrade,
};
use sol_trade_sdk::{common::TradeConfig, solana_streamer_sdk::match_event};
use sol_trade_sdk::{
solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter, TradeTokenType,
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::signer::Signer;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use spl_associated_token_account::get_associated_token_address;
use solana_streamer_sdk::match_event;
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
use solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::parser::PUMPFUN_PROGRAM_ID;
use solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::streaming::yellowstone_grpc::{AccountFilter, TransactionFilter};
use solana_streamer_sdk::streaming::YellowstoneGrpc;
// Global static flag to ensure transaction is executed only once
static ALREADY_EXECUTED: AtomicBool = AtomicBool::new(false);
+3 -2
View File
@@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
+8 -8
View File
@@ -1,9 +1,5 @@
use sol_trade_sdk::common::spl_associated_token_account::get_associated_token_address;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::EventType;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use sol_trade_sdk::solana_streamer_sdk::{match_event, streaming::ShredStreamGrpc};
use sol_trade_sdk::TradeTokenType;
use sol_trade_sdk::{
common::AnyResult,
@@ -11,10 +7,14 @@ use sol_trade_sdk::{
trading::{core::params::PumpFunParams, factory::DexType},
SolanaTrade,
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::signer::Signer;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use spl_associated_token_account::get_associated_token_address;
use std::mem::take;
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
use solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::{match_event, streaming::ShredStreamGrpc};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
+3 -4
View File
@@ -5,8 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
spl-token= "8.0.0"
spl-token-2022 = { version = "8.0.0", features = ["no-entrypoint"] }
+7 -4
View File
@@ -1,12 +1,15 @@
use sol_trade_sdk::{
common::{AnyResult, TradeConfig},
common::{
spl_associated_token_account::get_associated_token_address_with_program_id, AnyResult,
TradeConfig,
},
swqos::SwqosConfig,
trading::{core::params::PumpSwapParams, factory::DexType},
SolanaTrade, TradeTokenType,
};
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::{pubkey::Pubkey, signer::Signer};
use spl_associated_token_account::get_associated_token_address_with_program_id;
use std::{str::FromStr, sync::Arc};
#[tokio::main]
@@ -47,7 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rpc = client.rpc.clone();
let payer = client.payer.pubkey();
let program_id = spl_token_2022::ID;
let program_id = sol_trade_sdk::constants::TOKEN_PROGRAM_2022;
let account = get_associated_token_address_with_program_id(&payer, &mint_pubkey, &program_id);
let balance = rpc.get_token_account_balance(&account).await?;
let amount_token = balance.amount.parse::<u64>().unwrap();
+3 -2
View File
@@ -5,7 +5,8 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
spl-token-2022 = { version = "8.0.0", features = ["no-entrypoint"] }
+21 -30
View File
@@ -1,40 +1,31 @@
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::yellowstone_grpc::{
AccountFilter, TransactionFilter,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::YellowstoneGrpc;
use sol_trade_sdk::solana_streamer_sdk::{
match_event, streaming::event_parser::protocols::pumpswap::parser::PUMPSWAP_PROGRAM_ID,
};
use sol_trade_sdk::common::spl_associated_token_account::get_associated_token_address_with_program_id;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::TradeTokenType;
use sol_trade_sdk::{
common::AnyResult,
swqos::SwqosConfig,
trading::{core::params::PumpSwapParams, factory::DexType},
SolanaTrade,
};
use sol_trade_sdk::{
common::TradeConfig,
solana_streamer_sdk::streaming::event_parser::{
common::EventType, protocols::pumpswap::PumpSwapSellEvent,
},
};
use sol_trade_sdk::{
instruction::utils::pumpswap::accounts,
solana_streamer_sdk::streaming::event_parser::{
common::filter::EventTypeFilter, protocols::pumpswap::PumpSwapBuyEvent,
},
};
use sol_trade_sdk::{
solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent},
TradeTokenType,
};
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::{pubkey::Pubkey, signer::Signer};
use spl_associated_token_account::get_associated_token_address_with_program_id;
use solana_streamer_sdk::streaming::event_parser::{
common::filter::EventTypeFilter, protocols::pumpswap::PumpSwapBuyEvent,
};
use solana_streamer_sdk::streaming::event_parser::{
common::EventType, protocols::pumpswap::PumpSwapSellEvent,
};
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::streaming::yellowstone_grpc::{AccountFilter, TransactionFilter};
use solana_streamer_sdk::streaming::YellowstoneGrpc;
use solana_streamer_sdk::{
match_event, streaming::event_parser::protocols::pumpswap::parser::PUMPSWAP_PROGRAM_ID,
};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
// Global static flag to ensure transaction is executed only once
static ALREADY_EXECUTED: AtomicBool = AtomicBool::new(false);
+3 -2
View File
@@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
+20 -17
View File
@@ -1,26 +1,29 @@
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use sol_trade_sdk::{common::TradeConfig, instruction::utils::raydium_amm_v4::{accounts, fetch_amm_info}, solana_streamer_sdk::{match_event, streaming::event_parser::protocols::raydium_amm_v4::RaydiumAmmV4SwapEvent}, trading::common::get_multi_token_balances, TradeTokenType};
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::EventType;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::raydium_amm_v4::parser::RAYDIUM_AMM_V4_PROGRAM_ID;
use sol_trade_sdk::{solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent}};
use sol_trade_sdk::solana_streamer_sdk::streaming::yellowstone_grpc::{
AccountFilter, TransactionFilter,
};
use sol_trade_sdk::solana_streamer_sdk::streaming::YellowstoneGrpc;
use sol_trade_sdk::{
common::AnyResult,
common::TradeConfig, instruction::utils::raydium_amm_v4::fetch_amm_info,
trading::common::get_multi_token_balances, TradeTokenType,
};
use sol_trade_sdk::{
common::{spl_associated_token_account::get_associated_token_address, AnyResult},
swqos::SwqosConfig,
trading::{core::params::RaydiumAmmV4Params, factory::DexType},
SolanaTrade,
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::signer::Signer;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use spl_associated_token_account::get_associated_token_address;
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
use solana_streamer_sdk::streaming::event_parser::protocols::raydium_amm_v4::parser::RAYDIUM_AMM_V4_PROGRAM_ID;
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::streaming::yellowstone_grpc::{AccountFilter, TransactionFilter};
use solana_streamer_sdk::streaming::YellowstoneGrpc;
use solana_streamer_sdk::{
match_event, streaming::event_parser::protocols::raydium_amm_v4::RaydiumAmmV4SwapEvent,
};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
// Global static flag to ensure transaction is executed only once
static ALREADY_EXECUTED: AtomicBool = AtomicBool::new(false);
+3 -2
View File
@@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
+19 -29
View File
@@ -1,37 +1,27 @@
use sol_trade_sdk::common::spl_associated_token_account::get_associated_token_address;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT;
use sol_trade_sdk::trading::core::params::RaydiumCpmmParams;
use sol_trade_sdk::trading::factory::DexType;
use sol_trade_sdk::TradeTokenType;
use sol_trade_sdk::{common::AnyResult, swqos::SwqosConfig, SolanaTrade};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::signer::Signer;
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
use solana_streamer_sdk::streaming::event_parser::protocols::raydium_cpmm::parser::RAYDIUM_CPMM_PROGRAM_ID;
use solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent};
use solana_streamer_sdk::streaming::yellowstone_grpc::{AccountFilter, TransactionFilter};
use solana_streamer_sdk::streaming::YellowstoneGrpc;
use solana_streamer_sdk::{
match_event, streaming::event_parser::protocols::raydium_cpmm::RaydiumCpmmSwapEvent,
};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use sol_trade_sdk::solana_streamer_sdk::{
match_event, streaming::event_parser::protocols::raydium_cpmm::RaydiumCpmmSwapEvent,
};
use sol_trade_sdk::{common::AnyResult, swqos::SwqosConfig, SolanaTrade};
use sol_trade_sdk::{
common::TradeConfig,
solana_streamer_sdk::streaming::yellowstone_grpc::{AccountFilter, TransactionFilter},
};
use sol_trade_sdk::{
constants::WSOL_TOKEN_ACCOUNT,
solana_streamer_sdk::streaming::event_parser::{Protocol, UnifiedEvent},
};
use sol_trade_sdk::{
instruction::utils::raydium_cpmm::accounts,
solana_streamer_sdk::streaming::event_parser::protocols::raydium_cpmm::parser::RAYDIUM_CPMM_PROGRAM_ID,
};
use sol_trade_sdk::{
solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter,
trading::factory::DexType,
};
use sol_trade_sdk::{
solana_streamer_sdk::streaming::event_parser::common::EventType,
trading::core::params::RaydiumCpmmParams,
};
use sol_trade_sdk::{solana_streamer_sdk::streaming::YellowstoneGrpc, TradeTokenType};
use solana_sdk::signer::Signer;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use spl_associated_token_account::get_associated_token_address;
// Global static flag to ensure transaction is executed only once
static ALREADY_EXECUTED: AtomicBool = AtomicBool::new(false);
+4 -5
View File
@@ -5,8 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
spl-associated-token-account = "7.0.0"
tokio = { version = "1", features = ["full"] }
spl-token= "8.0.0"
spl-token-2022 = { version = "8.0.0", features = ["no-entrypoint"] }
solana-streamer-sdk = "0.5.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
+3 -2
View File
@@ -6,7 +6,8 @@ use sol_trade_sdk::{
trading::{core::params::PumpSwapParams, factory::DexType},
SolanaTrade, TradeTokenType,
};
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::{pubkey::Pubkey, signer::Signer};
use std::{str::FromStr, sync::Arc};
@@ -50,7 +51,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rpc = client.rpc.clone();
let payer = client.payer.pubkey();
let program_id = spl_token::ID;
let program_id = sol_trade_sdk::constants::TOKEN_PROGRAM;
// ❗️❗️❗️❗️ Must use the 'use seed' method to get the ATA account, otherwise the transaction will fail
let account = get_associated_token_address_with_program_id_fast_use_seed(
&payer,
+2 -1
View File
@@ -5,5 +5,6 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
+2 -1
View File
@@ -3,7 +3,8 @@ use sol_trade_sdk::{
swqos::{SwqosConfig, SwqosRegion},
SolanaTrade,
};
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use std::sync::Arc;
#[tokio::main]
+2 -1
View File
@@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
sol-trade-sdk = { path = "../.." }
solana-sdk = "2.3.0"
solana-sdk = "3.0.0"
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
anyhow = "1.0"
+2 -1
View File
@@ -1,5 +1,6 @@
use sol_trade_sdk::{common::TradeConfig, swqos::SwqosConfig, SolanaTrade};
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use std::sync::Arc;
#[tokio::main]