feat: major gas fee strategy and documentation overhaul

- feat(gas): add comprehensive gas fee strategy management system
  * Implement GasFeeStrategyType with Default/LowTipHighCuPrice/HighTipLowCuPrice strategies
  * Add dynamic gas fee configuration per SWQOS service and trade type
  * Integrate arc-swap for thread-safe strategy updates

- docs: restructure documentation with dedicated guides
  * Add ADDRESS_LOOKUP_TABLE.md/CN.md for lookup table configuration
  * Add NONCE_CACHE.md/CN.md for nonce management documentation
  * Add TRADING_PARAMETERS.md/CN.md for comprehensive parameter guides
  * Simplify main README.md with focused overview

- refactor: update all examples with new gas fee strategy integration
  * Modernize 14 trading examples with consistent parameter handling
  * Improve error handling and configuration management
  * Enhance parallel trading implementation
This commit is contained in:
ysq
2025-09-19 00:49:45 +08:00
parent fad343ffbf
commit 006686e8a3
45 changed files with 2133 additions and 1681 deletions
-105
View File
@@ -1,7 +1,5 @@
pub mod calc;
pub mod price;
use crate::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use crate::trading;
use crate::SolanaTrade;
use solana_sdk::pubkey::Pubkey;
@@ -57,107 +55,4 @@ impl SolanaTrade {
pub async fn close_token_account(&self, mint: &Pubkey) -> Result<(), anyhow::Error> {
trading::common::utils::close_token_account(&self.rpc, self.payer.as_ref(), mint).await
}
// -------------------------------- PumpFun --------------------------------
#[deprecated(since = "0.6.7", note = "This function is deprecated and will be removed in a future version")]
#[inline]
pub fn get_pumpfun_token_buy_price(&self, amount: u64, trade_info: &PumpFunTradeEvent) -> u64 {
crate::instruction::utils::pumpfun::get_buy_price(amount, trade_info)
}
#[deprecated(since = "0.6.7", note = "This function is deprecated and will be removed in a future version")]
#[inline]
pub async fn get_pumpfun_token_current_price(
&self,
mint: &Pubkey,
) -> Result<f64, anyhow::Error> {
let (bonding_curve, _) =
crate::instruction::utils::pumpfun::fetch_bonding_curve_account(&self.rpc, mint)
.await?;
let virtual_sol_reserves = bonding_curve.virtual_sol_reserves;
let virtual_token_reserves = bonding_curve.virtual_token_reserves;
Ok(price::pumpfun::price_token_in_sol(virtual_sol_reserves, virtual_token_reserves))
}
#[deprecated(since = "0.6.7", note = "This function is deprecated and will be removed in a future version")]
#[inline]
pub async fn get_pumpfun_token_real_sol_reserves(
&self,
mint: &Pubkey,
) -> Result<u64, anyhow::Error> {
let (bonding_curve, _) =
crate::instruction::utils::pumpfun::fetch_bonding_curve_account(&self.rpc, mint)
.await?;
let actual_sol_reserves = bonding_curve.real_sol_reserves;
Ok(actual_sol_reserves)
}
#[deprecated(since = "0.6.7", note = "This function is deprecated and will be removed in a future version")]
#[inline]
pub async fn get_pumpfun_token_creator(&self, mint: &Pubkey) -> Result<Pubkey, anyhow::Error> {
let (bonding_curve, _) =
crate::instruction::utils::pumpfun::fetch_bonding_curve_account(&self.rpc, mint)
.await?;
let creator = bonding_curve.creator;
Ok(creator)
}
// -------------------------------- PumpSwap --------------------------------
#[deprecated(since = "0.6.7", note = "This function is deprecated and will be removed in a future version")]
#[inline]
pub async fn get_pumpswap_token_current_price(
&self,
pool_address: &Pubkey,
) -> Result<f64, anyhow::Error> {
let pool = crate::instruction::utils::pumpswap::fetch_pool(&self.rpc, pool_address).await?;
let (base_amount, quote_amount) =
crate::instruction::utils::pumpswap::get_token_balances(&pool, &self.rpc).await?;
// Calculate price using constant product formula (x * y = k)
// Price = quote_amount / base_amount
if base_amount == 0 {
return Err(anyhow::anyhow!("Base amount is zero, cannot calculate price"));
}
let price = quote_amount as f64 / base_amount as f64;
Ok(price)
}
#[deprecated(since = "0.6.7", note = "This function is deprecated and will be removed in a future version")]
#[inline]
pub async fn get_pumpswap_token_real_sol_reserves(
&self,
pool_address: &Pubkey,
) -> Result<u64, anyhow::Error> {
let pool = crate::instruction::utils::pumpswap::fetch_pool(&self.rpc, pool_address).await?;
let (_, quote_amount) =
crate::instruction::utils::pumpswap::get_token_balances(&pool, &self.rpc).await?;
Ok(quote_amount)
}
#[deprecated(since = "0.6.7", note = "This function is deprecated and will be removed in a future version")]
#[inline]
pub async fn get_pumpswap_payer_token_balance(
&self,
pool_address: &Pubkey,
) -> Result<u64, anyhow::Error> {
let pool = crate::instruction::utils::pumpswap::fetch_pool(&self.rpc, pool_address).await?;
let (base_amount, _) =
crate::instruction::utils::pumpswap::get_token_balances(&pool, &self.rpc).await?;
Ok(base_amount)
}
}