diff --git a/core/resources/i18n/i18n.json b/core/resources/i18n/i18n.json index 3c2de24..8648840 100644 --- a/core/resources/i18n/i18n.json +++ b/core/resources/i18n/i18n.json @@ -3218,6 +3218,8 @@ "Export Wallet Data": "Export Wallet Data", "FIRST": "FIRST", "Faucet": "Faucet", + "Fee Market & Network Pressure": "Fee Market & Network Pressure", + "Fee Market Only": "Fee Market Only", "Fee Rate Estimates": "Fee Rate Estimates", "File Handles": "File Handles", "File contents": "File contents", @@ -3302,6 +3304,7 @@ "NPM Modules for NodeJS": "NPM Modules for NodeJS", "Network": "Network", "Network Difficulty": "Network Difficulty", + "Network Fee Estimator": "Network Fee Estimator", "Network Fees:": "Network Fees:", "Network Interface": "Network Interface", "Network Load:": "Network Load:", diff --git a/core/src/imports.rs b/core/src/imports.rs index 81f65b4..20b8d0e 100644 --- a/core/src/imports.rs +++ b/core/src/imports.rs @@ -87,8 +87,9 @@ pub use crate::primitives::{ pub use crate::result::Result; pub use crate::runtime::{runtime, spawn, spawn_with_result, Payload, Runtime, Service}; pub use crate::settings::{ - KaspadNodeKind, NetworkInterfaceConfig, NetworkInterfaceKind, NodeConnectionConfigKind, - NodeMemoryScale, NodeSettings, RpcConfig, RpcOptions, Settings, UserInterfaceSettings, + EstimatorMode, EstimatorSettings, KaspadNodeKind, NetworkInterfaceConfig, NetworkInterfaceKind, + NodeConnectionConfigKind, NodeMemoryScale, NodeSettings, RpcConfig, RpcOptions, Settings, + UserInterfaceSettings, }; pub use crate::state::State; pub use crate::status::Status; diff --git a/core/src/modules/account_manager/estimator.rs b/core/src/modules/account_manager/estimator.rs index f199c59..f68d265 100644 --- a/core/src/modules/account_manager/estimator.rs +++ b/core/src/modules/account_manager/estimator.rs @@ -104,7 +104,7 @@ impl<'context> Estimator<'context> { let number_of_generated_stages = actual_estimate.number_of_generated_stages; let buckets = if let Some(fees) = core.feerate.as_ref() { - if network_below_capacity { + if network_below_capacity && core.settings.estimator.mode == EstimatorMode::NetworkPressure { [ Some(FeeMode::Low(FeerateBucket::new(1.0,5.0))), Some(FeeMode::Economic(fees.low.value().with_seconds(3.0))), @@ -124,8 +124,8 @@ impl<'context> Estimator<'context> { let fee_mode = self.context.fee_mode; for mode in buckets.into_iter().flatten() { let bucket = mode.bucket(); - let feerate = (bucket.feerate - 1.0).max(0.0); - // let feerate = bucket.feerate; + // let feerate = (bucket.feerate - 1.0).max(0.0); + let feerate = bucket.feerate; // let seconds = if network_below_capacity { // match &mode { @@ -162,8 +162,10 @@ impl<'context> Estimator<'context> { if fee_selection.render(ui, &mut self.context.fee_mode).clicked() { let bucket = self.context.fee_mode.bucket(); - let priority_feerate = (bucket.feerate - 1.0).max(0.0); - let total_fees_sompi = (priority_feerate * actual_estimate.aggregate_mass as f64) as u64; + // let priority_feerate = (bucket.feerate - 1.0).max(0.0); + // let priority_feerate = bucket.feerate; + // let total_fees_sompi = (priority_feerate * actual_estimate.aggregate_mass as f64) as u64; + let total_fees_sompi = (bucket.feerate * actual_estimate.aggregate_mass as f64) as u64; // runtime().toast(UserNotification::success(format!("selection: {:?}", self.context.fee_mode)).short()); let total_fee_kaspa = sompi_to_kaspa(total_fees_sompi); self.context.priority_fees_text = format!("{}", total_fee_kaspa); diff --git a/core/src/modules/account_manager/processor.rs b/core/src/modules/account_manager/processor.rs index a93bc82..43f12c0 100644 --- a/core/src/modules/account_manager/processor.rs +++ b/core/src/modules/account_manager/processor.rs @@ -215,6 +215,7 @@ async fn calculate_fee_rate(network_type : NetworkType, account_id : AccountId, if base_mass == 0 { 1.0 } else { - (priority_fee_sompi as f64 / base_mass as f64) + 1.0 + // (priority_fee_sompi as f64 / base_mass as f64) + 1.0 + priority_fee_sompi as f64 / base_mass as f64 } } \ No newline at end of file diff --git a/core/src/modules/settings/mod.rs b/core/src/modules/settings/mod.rs index 9632070..ae3d6ae 100644 --- a/core/src/modules/settings/mod.rs +++ b/core/src/modules/settings/mod.rs @@ -621,6 +621,21 @@ impl Settings { }); }); + CollapsingHeader::new(i18n("Network Fee Estimator")) + .default_open(false) + .show(ui, |ui| { + ui.vertical(|ui|{ + EstimatorMode::iter().for_each(|kind| { + ui.radio_value(&mut self.settings.estimator.mode, *kind, i18n(kind.describe())); + }); + + if self.settings.estimator.mode != core.settings.estimator.mode { + core.settings.estimator.mode = self.settings.estimator.mode; + core.store_settings(); + } + }); + }); + #[cfg(not(target_arch = "wasm32"))] core.storage.clone().render_settings(core, ui); diff --git a/core/src/settings.rs b/core/src/settings.rs index 273f8f8..1da13ae 100644 --- a/core/src/settings.rs +++ b/core/src/settings.rs @@ -574,6 +574,36 @@ impl DeveloperSettings { } } +#[derive(Describe, Default, Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum EstimatorMode { + #[describe("Fee Market Only")] + FeeMarketOnly, + #[default] + #[describe("Fee Market & Network Pressure")] + NetworkPressure, +} + +#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct EstimatorSettings { + pub mode: EstimatorMode, +} + +impl Default for EstimatorSettings { + fn default() -> Self { + Self { + mode: EstimatorMode::NetworkPressure, + } + } +} + +impl EstimatorSettings { + pub fn track_network_load(&self) -> EstimatorMode { + self.mode + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub struct Settings { @@ -583,6 +613,8 @@ pub struct Settings { pub version: String, pub update: String, pub developer: DeveloperSettings, + #[serde(default)] + pub estimator: EstimatorSettings, pub node: NodeSettings, pub user_interface: UserInterfaceSettings, pub language_code: String, @@ -602,6 +634,7 @@ impl Default for Settings { version: "0.0.0".to_string(), update: crate::app::VERSION.to_string(), developer: DeveloperSettings::default(), + estimator: EstimatorSettings::default(), node: NodeSettings::default(), user_interface: UserInterfaceSettings::default(), language_code: "en".to_string(),