feat: Add address lookup, caching system and Jito GRPC integration

- Implement address lookup tables and multi-level caching

- Add GRPC stream processing and YellowStone connections

- Extend PumpFun functionality including token creation

- Integrate Jito GRPC services (auth, block engine, relayer)

- Optimize log processing and event system
This commit is contained in:
sgxiang
2025-05-29 18:53:58 +08:00
parent f261b8a66d
commit bfe76fcddc
37 changed files with 4168 additions and 694 deletions
+71 -13
View File
@@ -1,36 +1,94 @@
use std::sync::Arc;
use pumpfun_sdk::{common::{logs_events::PumpfunEvent, Cluster, PriorityFee}, grpc::YellowstoneGrpc, ipfs, PumpFun};
use solana_sdk::{commitment_config::CommitmentConfig, native_token::sol_to_lamports, signature::Keypair, signer::Signer};
use pumpfun_sdk::{common::{
logs_events::PumpfunEvent,
logs_subscribe::{stop_subscription, tokens_subscription}, AnyResult
}, grpc::ShredStreamGrpc};
use solana_sdk::{commitment_config::CommitmentConfig, transaction::VersionedTransaction};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// create grpc client
let grpc_url = "http://127.0.0.1:10000";
let client = YellowstoneGrpc::new(grpc_url.to_string());
let grpc = ShredStreamGrpc::new(
"http://127.0.0.1:10800".to_string(),
).await?;
// Define callback function
let callback = |event: PumpfunEvent| {
// TradeInfo 的 sol_amount 不是真实线上消费/获取的数量
// 当 is_buy 为 true 时,sol_amount = max_sol_cost,代表用户愿意支付的最大金额
// 当 is_buy 为 false 时,sol_amount = min_sol_output,代表用户愿意接受的最小金额
//
// timestamp 不是真实交易发生的时间,取的值为当前系统的时间
//
// 无法获取下面4个值
// virtual_sol_reserves: 0,
// virtual_token_reserves: 0,
// real_sol_reserves: 0,
// real_token_reserves: 0,
match event {
PumpfunEvent::NewDevTrade(trade_info) => {
println!("Received new dev trade event: {:?}", trade_info);
},
PumpfunEvent::NewToken(token_info) => {
println!("Received new token event: {:?}", token_info);
},
PumpfunEvent::NewDevTrade(trade_info) => {
println!("Received dev trade event: {:?}", trade_info);
},
PumpfunEvent::NewUserTrade(trade_info) => {
println!("Received new trade event: {:?}", trade_info);
},
PumpfunEvent::NewBotTrade(trade_info) => {
println!("Received new bot trade event: {:?}", trade_info);
}
},
PumpfunEvent::Error(err) => {
println!("Received error: {}", err);
}
}
};
let payer_keypair = Keypair::from_base58_string("your private key");
client.subscribe_pumpfun(callback, Some(payer_keypair.pubkey())).await?;
grpc.shredstream_subscribe(callback, None).await?;
Ok(())
}
async fn test_wss() -> AnyResult<()> {
println!("Starting token subscription\n");
let ws_url = "wss://api.mainnet-beta.solana.com";
// Set commitment
let commitment = CommitmentConfig::confirmed();
// Define callback function
let callback = |event: PumpfunEvent| {
match event {
PumpfunEvent::NewDevTrade(trade_info) => {
println!("Received new dev trade event: {:?}", trade_info);
},
PumpfunEvent::NewToken(token_info) => {
println!("Received new token event: {:?}", token_info);
},
PumpfunEvent::NewUserTrade(trade_info) => {
println!("Received new trade event: {:?}", trade_info);
},
PumpfunEvent::NewBotTrade(trade_info) => {
println!("Received new bot trade event: {:?}", trade_info);
},
PumpfunEvent::Error(err) => {
println!("Received error: {}", err);
}
}
};
// Start subscription
let subscription = tokens_subscription(
ws_url,
commitment,
callback,
None
).await.unwrap();
// Wait for a while to receive events
tokio::time::sleep(tokio::time::Duration::from_secs(60)).await;
// Stop subscription
stop_subscription(subscription).await;
Ok(())
}