refactor: rename protocol from RaydiumLaunchpad to Bonk

Comprehensive renaming of RaydiumLaunchpad-related modules, structs, event types and constants to Bonk while maintaining functional logic
This commit is contained in:
ysq
2025-07-10 00:23:29 +08:00
parent c0e02381f8
commit 756ec6e263
25 changed files with 188 additions and 189 deletions
+3 -3
View File
@@ -122,9 +122,9 @@ impl ProtocolParams for PumpSwapParams {
}
}
/// RaydiumLaunchpad协议特定参数
/// Bonk协议特定参数
#[derive(Clone)]
pub struct RaydiumLaunchpadParams {
pub struct BonkParams {
pub virtual_base: Option<u128>,
pub virtual_quote: Option<u128>,
pub real_base_before: Option<u128>,
@@ -132,7 +132,7 @@ pub struct RaydiumLaunchpadParams {
pub auto_handle_wsol: bool,
}
impl ProtocolParams for RaydiumLaunchpadParams {
impl ProtocolParams for BonkParams {
fn as_any(&self) -> &dyn std::any::Any {
self
}
+8 -8
View File
@@ -1,7 +1,7 @@
use anyhow::{anyhow, Result};
use std::sync::Arc;
use crate::trading::protocols::raydium_launchpad::RaydiumLaunchpadInstructionBuilder;
use crate::trading::protocols::bonk::BonkInstructionBuilder;
use super::{
core::{executor::GenericTradeExecutor, traits::TradeExecutor},
@@ -13,7 +13,7 @@ use super::{
pub enum Protocol {
PumpFun,
PumpSwap,
RaydiumLaunchpad,
Bonk,
}
impl std::fmt::Display for Protocol {
@@ -21,7 +21,7 @@ impl std::fmt::Display for Protocol {
match self {
Protocol::PumpFun => write!(f, "PumpFun"),
Protocol::PumpSwap => write!(f, "PumpSwap"),
Protocol::RaydiumLaunchpad => write!(f, "RaydiumLaunchpad"),
Protocol::Bonk => write!(f, "Bonk"),
}
}
}
@@ -33,7 +33,7 @@ impl std::str::FromStr for Protocol {
match s.to_lowercase().as_str() {
"pumpfun" => Ok(Protocol::PumpFun),
"pumpswap" => Ok(Protocol::PumpSwap),
"raydiumlaunchpad" => Ok(Protocol::RaydiumLaunchpad),
"bonk" => Ok(Protocol::Bonk),
_ => Err(anyhow!("Unsupported protocol: {}", s)),
}
}
@@ -54,11 +54,11 @@ impl TradeFactory {
let instruction_builder = Arc::new(PumpSwapInstructionBuilder);
Arc::new(GenericTradeExecutor::new(instruction_builder, "PumpSwap"))
}
Protocol::RaydiumLaunchpad => {
let instruction_builder = Arc::new(RaydiumLaunchpadInstructionBuilder);
Protocol::Bonk => {
let instruction_builder = Arc::new(BonkInstructionBuilder);
Arc::new(GenericTradeExecutor::new(
instruction_builder,
"RaydiumLaunchpad",
"Bonk",
))
}
}
@@ -69,7 +69,7 @@ impl TradeFactory {
vec![
Protocol::PumpFun,
Protocol::PumpSwap,
Protocol::RaydiumLaunchpad,
Protocol::Bonk,
]
}
@@ -3,24 +3,24 @@ use solana_sdk::{instruction::Instruction, pubkey::Pubkey, signer::Signer};
use spl_associated_token_account::instruction::create_associated_token_account_idempotent;
use crate::{
constants::raydium_launchpad::{
constants::bonk::{
accounts, trade::DEFAULT_SLIPPAGE, BUY_EXECT_IN_DISCRIMINATOR, SELL_EXECT_IN_DISCRIMINATOR,
},
raydium_launchpad::{
bonk::{
common::{get_amount_out, get_pool_pda, get_token_balance, get_vault_pda},
pool::Pool,
},
trading::core::{
params::{BuyParams, RaydiumLaunchpadParams, SellParams},
params::{BuyParams, BonkParams, SellParams},
traits::InstructionBuilder,
},
};
/// RaydiumLaunchpad协议的指令构建器
pub struct RaydiumLaunchpadInstructionBuilder;
/// Bonk协议的指令构建器
pub struct BonkInstructionBuilder;
#[async_trait::async_trait]
impl InstructionBuilder for RaydiumLaunchpadInstructionBuilder {
impl InstructionBuilder for BonkInstructionBuilder {
async fn build_buy_instructions(&self, params: &BuyParams) -> Result<Vec<Instruction>> {
if params.amount_sol == 0 {
return Err(anyhow!("Amount cannot be zero"));
@@ -33,7 +33,7 @@ impl InstructionBuilder for RaydiumLaunchpadInstructionBuilder {
}
}
impl RaydiumLaunchpadInstructionBuilder {
impl BonkInstructionBuilder {
/// 使用提供的账户信息构建买入指令
async fn build_buy_instructions_with_accounts(
&self,
@@ -42,8 +42,8 @@ impl RaydiumLaunchpadInstructionBuilder {
let protocol_params = params
.protocol_params
.as_any()
.downcast_ref::<RaydiumLaunchpadParams>()
.ok_or_else(|| anyhow!("Invalid protocol params for RaydiumLaunchpad"))?;
.downcast_ref::<BonkParams>()
.ok_or_else(|| anyhow!("Invalid protocol params for Bonk"))?;
let pool_state = get_pool_pda(&params.mint, &accounts::WSOL_TOKEN_ACCOUNT).unwrap();
@@ -149,7 +149,7 @@ impl RaydiumLaunchpadInstructionBuilder {
solana_sdk::instruction::AccountMeta::new_readonly(accounts::TOKEN_PROGRAM, false), // Base Token Program (readonly)
solana_sdk::instruction::AccountMeta::new_readonly(accounts::TOKEN_PROGRAM, false), // Quote Token Program (readonly)
solana_sdk::instruction::AccountMeta::new_readonly(accounts::EVENT_AUTHORITY, false), // Event Authority (readonly)
solana_sdk::instruction::AccountMeta::new_readonly(accounts::LAUNCHPAD_PROGRAM, false), // Program (readonly)
solana_sdk::instruction::AccountMeta::new_readonly(accounts::BONK, false), // Program (readonly)
];
// 创建指令数据
let mut data = vec![];
@@ -159,7 +159,7 @@ impl RaydiumLaunchpadInstructionBuilder {
data.extend_from_slice(&share_fee_rate.to_le_bytes());
instructions.push(Instruction {
program_id: accounts::LAUNCHPAD_PROGRAM,
program_id: accounts::BONK,
accounts,
data,
});
@@ -263,7 +263,7 @@ impl RaydiumLaunchpadInstructionBuilder {
solana_sdk::instruction::AccountMeta::new_readonly(accounts::TOKEN_PROGRAM, false), // Base Token Program (readonly)
solana_sdk::instruction::AccountMeta::new_readonly(accounts::TOKEN_PROGRAM, false), // Quote Token Program (readonly)
solana_sdk::instruction::AccountMeta::new_readonly(accounts::EVENT_AUTHORITY, false), // Event Authority (readonly)
solana_sdk::instruction::AccountMeta::new_readonly(accounts::LAUNCHPAD_PROGRAM, false), // Program (readonly)
solana_sdk::instruction::AccountMeta::new_readonly(accounts::BONK, false), // Program (readonly)
];
// 创建指令数据
@@ -274,7 +274,7 @@ impl RaydiumLaunchpadInstructionBuilder {
data.extend_from_slice(&share_fee_rate.to_le_bytes());
instructions.push(Instruction {
program_id: accounts::LAUNCHPAD_PROGRAM,
program_id: accounts::BONK,
accounts,
data,
});
+1 -1
View File
@@ -1,3 +1,3 @@
pub mod pumpfun;
pub mod pumpswap;
pub mod raydium_launchpad;
pub mod bonk;