diff --git a/common/commands/src/validator/mixnet/operators/mixnode/settings/mod.rs b/common/commands/src/validator/mixnet/operators/mixnode/settings/mod.rs index 9d0c018cf94..4ab2a0a4ffc 100644 --- a/common/commands/src/validator/mixnet/operators/mixnode/settings/mod.rs +++ b/common/commands/src/validator/mixnet/operators/mixnode/settings/mod.rs @@ -4,6 +4,7 @@ use clap::{Args, Subcommand}; pub mod update_config; +pub mod update_cost_params; pub mod vesting_update_config; #[derive(Debug, Args)] @@ -20,7 +21,5 @@ pub enum MixnetOperatorsMixnodeSettingsCommands { /// Update mixnode configuration for a mixnode bonded with locked tokens VestingUpdateConfig(vesting_update_config::Args), /// Update mixnode cost parameters - UpdateCostParameters, - /// Update mixnode cost parameters for a mixnode bonded with locked tokens - VestingUpdateCostParameters, + UpdateCostParameters(update_cost_params::Args), } diff --git a/common/commands/src/validator/mixnet/operators/mixnode/settings/update_cost_params.rs b/common/commands/src/validator/mixnet/operators/mixnode/settings/update_cost_params.rs new file mode 100644 index 00000000000..0616a81d332 --- /dev/null +++ b/common/commands/src/validator/mixnet/operators/mixnode/settings/update_cost_params.rs @@ -0,0 +1,48 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use crate::context::SigningClient; +use clap::Parser; +use cosmwasm_std::Uint128; +use log::info; +use nym_mixnet_contract_common::{MixNodeCostParams, Percent}; +use nym_validator_client::nyxd::contract_traits::MixnetSigningClient; +use nym_validator_client::nyxd::CosmWasmCoin; + +#[derive(Debug, Parser)] +pub struct Args { + #[clap( + long, + help = "input your profit margin as follows; (so it would be 10, rather than 0.1)" + )] + pub profit_margin_percent: Option, + + #[clap( + long, + help = "operating cost in current DENOMINATION (so it would be 'unym', rather than 'nym')" + )] + pub interval_operating_cost: Option, +} + +pub async fn update_cost_params(args: Args, client: SigningClient) { + let denom = client.current_chain_details().mix_denom.base.as_str(); + + let cost_params = MixNodeCostParams { + profit_margin_percent: Percent::from_percentage_value( + args.profit_margin_percent.unwrap_or(10) as u64, + ) + .unwrap(), + interval_operating_cost: CosmWasmCoin { + denom: denom.into(), + amount: Uint128::new(args.interval_operating_cost.unwrap_or(40_000_000)), + }, + }; + + info!("Starting mixnode params updating!"); + let res = client + .update_mixnode_cost_params(cost_params, None) + .await + .expect("failed to update cost params"); + + info!("Cost params result: {:?}", res) +} diff --git a/tools/nym-cli/src/validator/mixnet/operators/mixnodes/settings/mod.rs b/tools/nym-cli/src/validator/mixnet/operators/mixnodes/settings/mod.rs index 77b12e2cc4e..a5d5c028838 100644 --- a/tools/nym-cli/src/validator/mixnet/operators/mixnodes/settings/mod.rs +++ b/tools/nym-cli/src/validator/mixnet/operators/mixnodes/settings/mod.rs @@ -13,6 +13,9 @@ pub(crate) async fn execute( nym_cli_commands::validator::mixnet::operators::mixnode::settings::MixnetOperatorsMixnodeSettingsCommands::UpdateConfig(args) => { nym_cli_commands::validator::mixnet::operators::mixnode::settings::update_config::update_config(args, create_signing_client(global_args, network_details)?).await } + nym_cli_commands::validator::mixnet::operators::mixnode::settings::MixnetOperatorsMixnodeSettingsCommands::UpdateCostParameters(args) => { + nym_cli_commands::validator::mixnet::operators::mixnode::settings::update_cost_params::update_cost_params(args, create_signing_client(global_args, network_details)?).await + } _ => unreachable!(), } Ok(())