use std::str::FromStr;
use std::sync::Arc;
use clap::ArgMatches;
use solana_clap_utils::keypair::DefaultSigner;
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use crate::check_and_update_err;
use crate::command::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult};
use crate::contract::instructions::update_config_protocol_fee_rate::new_update_config_protocol_fee_rate;
use crate::math::fee::ui_fee_to_lamport;
use crate::utils::send::send_tx;
pub fn parse_update_config_protocol_fee_rate<'a>(matches: &'a ArgMatches, default_signer: &DefaultSigner, wallet_manager: &mut Option<Arc<RemoteWalletManager>>) -> Result<CliCommandInfo<'a>, CliError> {
let clmm_config = matches.value_of("clmm_config");
let new_protocol_fee_rate = matches.value_of("new_protocol_fee_rate");
Ok(CliCommandInfo {
command: CliCommand::PairConfigProtocolFeeRateUpdate {
clmm_config: Pubkey::from_str(clmm_config.unwrap()).unwrap(),
new_protocol_fee_rate: ui_fee_to_lamport(new_protocol_fee_rate.unwrap().parse::<f64>().unwrap()) as u16,
},
signers: vec![check_and_update_err!(default_signer.signer_from_path(matches, wallet_manager), CliError::RpcRequestError("owner key is invalid".to_string()))?],
})
}
pub fn process_update_config_protocol_fee_rate(
rpc_client: &RpcClient,
config: &CliConfig,
clmm_config: &Pubkey,
new_protocol_fee_rate: &u16,
) -> ProcessResult {
let ixs = [new_update_config_protocol_fee_rate(clmm_config, new_protocol_fee_rate, config.pubkey().unwrap())];
let res = send_tx(rpc_client, config, &ixs)?;
Ok("signers : ".to_owned() + res.to_string().as_str())
}