feat: add Raydium CLMM protocol support, bump version to 0.2.1

This commit is contained in:
ysq
2025-07-19 21:28:01 +08:00
parent 2ddec98805
commit 7942bea571
16 changed files with 413 additions and 41 deletions
+19
View File
@@ -1,6 +1,7 @@
use anyhow::{anyhow, Result};
use solana_sdk::{instruction::Instruction, pubkey::Pubkey, signer::Signer};
use spl_associated_token_account::instruction::create_associated_token_account_idempotent;
use spl_token::instruction::close_account;
use crate::{
constants::pumpswap::{accounts, BUY_DISCRIMINATOR, SELL_DISCRIMINATOR},
@@ -361,6 +362,24 @@ impl PumpSwapInstructionBuilder {
data,
});
let protocol_params = params
.protocol_params
.as_any()
.downcast_ref::<PumpSwapParams>()
.ok_or_else(|| anyhow!("Invalid protocol params for PumpSwap"))?;
if protocol_params.auto_handle_wsol {
instructions.push(
close_account(
&accounts::TOKEN_PROGRAM,
&user_quote_token_account,
&params.payer.pubkey(),
&params.payer.pubkey(),
&[&params.payer.pubkey()],
)
.unwrap(),
);
}
Ok(instructions)
}
}