feat: integrate Raydium CPMM trading protocol support

- Add Raydium CPMM constants, instruction builder and pool implementation
- Implement unified buy/sell trading interface and event parsing system
- Update documentation and examples to support new protocol
This commit is contained in:
ysq
2025-07-16 22:54:23 +08:00
parent aef9fe6b14
commit 75a29cd7ee
20 changed files with 1119 additions and 50 deletions
+28
View File
@@ -215,6 +215,34 @@ impl ProtocolParams for BonkParams {
}
}
/// RaydiumCpmm协议特定参数
#[derive(Clone)]
pub struct RaydiumCpmmParams {
pub pool_state: Option<Pubkey>,
pub minimum_amount_out: Option<u64>,
pub auto_handle_wsol: bool,
}
impl RaydiumCpmmParams {
pub fn default() -> Self {
Self {
pool_state: None,
minimum_amount_out: None,
auto_handle_wsol: true,
}
}
}
impl ProtocolParams for RaydiumCpmmParams {
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn clone_box(&self) -> Box<dyn ProtocolParams> {
Box::new(self.clone())
}
}
impl BuyParams {
/// 转换为BuyWithTipParams
pub fn with_tip(self, swqos_clients: Vec<Arc<SwqosClient>>) -> BuyWithTipParams {