align tables on validator tab with additional values
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
ef81076f71
commit
b9c863e2ea
@ -2,7 +2,7 @@
|
||||
name = "ghost-eye"
|
||||
authors = ["str3tch <stretch@ghostchain.io>"]
|
||||
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
||||
version = "0.3.65"
|
||||
version = "0.3.66"
|
||||
edition = "2021"
|
||||
homepage = "https://git.ghostchain.io/ghostchain"
|
||||
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
||||
|
@ -78,6 +78,8 @@ pub enum Action {
|
||||
NominatorsNumber(u32),
|
||||
Inflation(String),
|
||||
Apy(String),
|
||||
TreasuryApy(String),
|
||||
NextReward(u128),
|
||||
|
||||
GetBlockAuthor(H256, Vec<DigestItem>),
|
||||
SetBlockAuthor(H256, String),
|
||||
|
@ -20,7 +20,6 @@ use crate::{
|
||||
struct Details {
|
||||
incoming_fee: String,
|
||||
outgoing_fee: String,
|
||||
gatekeeper: String,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -58,9 +57,8 @@ impl Component for GatekeeperDetails {
|
||||
},
|
||||
Action::SetGatekeepedNetwork(network) => {
|
||||
self.gatekeeper_details.insert(network.chain_id, Details {
|
||||
incoming_fee: format!("{:.5}%", network.incoming_fee as f64 / 1_000_000_000.0),
|
||||
outgoing_fee: format!("{:.5}%", network.outgoing_fee as f64 / 1_000_000_000.0),
|
||||
gatekeeper: network.gatekeeper,
|
||||
incoming_fee: format!("{:.5}%", network.incoming_fee as f64 / 10_000_000.0),
|
||||
outgoing_fee: format!("{:.5}%", network.outgoing_fee as f64 / 10_000_000.0),
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
@ -100,10 +98,6 @@ impl Component for GatekeeperDetails {
|
||||
Cell::from(Text::from("Outgoing fee".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(current_gatekeeper_details.outgoing_fee).alignment(Alignment::Right)),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Cell::from(Text::from("Gatekeeper".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(current_gatekeeper_details.gatekeeper).alignment(Alignment::Right)),
|
||||
]),
|
||||
],
|
||||
[
|
||||
Constraint::Length(12),
|
||||
|
@ -203,9 +203,8 @@ impl Component for Gatekeepers {
|
||||
let list = List::new(
|
||||
self.gatekeepers
|
||||
.iter()
|
||||
.map(|network| ListItem::new(format!("{} ({}) | {}",
|
||||
.map(|network| ListItem::new(format!("{} (type {})",
|
||||
network.chain_name,
|
||||
network.chain_id,
|
||||
network.chain_type))
|
||||
)
|
||||
)
|
||||
|
@ -287,7 +287,7 @@ impl Component for Validator {
|
||||
|
||||
pub fn validator_layout(area: Rect) -> [Rect; 4] {
|
||||
Layout::vertical([
|
||||
Constraint::Length(19),
|
||||
Constraint::Length(18),
|
||||
Constraint::Fill(1),
|
||||
Constraint::Fill(1),
|
||||
Constraint::Percentage(25),
|
||||
@ -315,7 +315,7 @@ pub fn validator_gatekeeped_networks_layout(area: Rect) -> [Rect; 2] {
|
||||
let [_, _, place] = validator_session_and_listen_layout(area);
|
||||
Layout::horizontal([
|
||||
Constraint::Fill(1),
|
||||
Constraint::Length(57),
|
||||
Constraint::Length(30),
|
||||
]).areas(place)
|
||||
}
|
||||
|
||||
@ -333,6 +333,6 @@ pub fn validator_balance_layout(area: Rect) -> [Rect; 3] {
|
||||
Layout::vertical([
|
||||
Constraint::Length(6),
|
||||
Constraint::Length(6),
|
||||
Constraint::Length(9),
|
||||
Constraint::Fill(1),
|
||||
]).areas(place)
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ pub struct RewardDetails {
|
||||
commission: Option<u32>,
|
||||
nominators_blocked: bool,
|
||||
apy: String,
|
||||
treasury_apy: String,
|
||||
inflation: String,
|
||||
stash: [u8; 32],
|
||||
in_staking_validators: bool,
|
||||
@ -43,6 +44,7 @@ impl RewardDetails {
|
||||
commission: None,
|
||||
nominators_blocked: false,
|
||||
apy: String::from("0.0%"),
|
||||
treasury_apy: String::from("0.0%"),
|
||||
inflation: String::from("0.0%"),
|
||||
stash: [0u8; 32],
|
||||
in_staking_validators: false,
|
||||
@ -110,6 +112,7 @@ impl Component for RewardDetails {
|
||||
}
|
||||
},
|
||||
Action::Apy(apy) => self.apy = apy,
|
||||
Action::TreasuryApy(apy) => self.treasury_apy = apy,
|
||||
Action::Inflation(inflation) => self.inflation = inflation,
|
||||
_ => {}
|
||||
};
|
||||
@ -141,16 +144,20 @@ impl Component for RewardDetails {
|
||||
Cell::from(Text::from(self.comission_to_string()).alignment(Alignment::Right)),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Cell::from(Text::from("Current APY".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from("Validator APY".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(self.apy.clone()).alignment(Alignment::Right)),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Cell::from(Text::from("Treasury APY".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(self.treasury_apy.clone()).alignment(Alignment::Right)),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Cell::from(Text::from("Inflation".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(self.inflation.clone()).alignment(Alignment::Right)),
|
||||
]),
|
||||
],
|
||||
[
|
||||
Constraint::Min(11),
|
||||
Constraint::Min(13),
|
||||
Constraint::Min(0),
|
||||
],
|
||||
)
|
||||
|
@ -20,6 +20,7 @@ pub struct StakingDetails {
|
||||
palette: StylePalette,
|
||||
staked_own: u128,
|
||||
staked_total: u128,
|
||||
next_reward: u128,
|
||||
stash: [u8; 32],
|
||||
reward_destination: RewardDestination,
|
||||
}
|
||||
@ -39,6 +40,7 @@ impl StakingDetails {
|
||||
palette: StylePalette::default(),
|
||||
staked_own: 0,
|
||||
staked_total: 0,
|
||||
next_reward: 0,
|
||||
stash: [0u8; 32],
|
||||
reward_destination: Default::default(),
|
||||
}
|
||||
@ -89,6 +91,7 @@ impl Component for StakingDetails {
|
||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
match action {
|
||||
Action::SetStashAccount(account_id) => self.stash = account_id,
|
||||
Action::NextReward(next_reward) => self.next_reward = next_reward,
|
||||
Action::SetStakingPayee(destination, account_id) if self.stash == account_id =>
|
||||
self.reward_destination = destination,
|
||||
Action::SetStakedRatio(total, own, account_id) if self.stash == account_id => {
|
||||
@ -119,6 +122,10 @@ impl Component for StakingDetails {
|
||||
Cell::from(Text::from("Other stake".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(self.prepare_u128(self.staked_total.saturating_sub(self.staked_own))).alignment(Alignment::Right)),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Cell::from(Text::from("Next reward".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(self.prepare_u128(self.next_reward)).alignment(Alignment::Right)),
|
||||
]),
|
||||
],
|
||||
[
|
||||
Constraint::Min(11),
|
||||
|
@ -197,16 +197,21 @@ pub async fn get_inflation(
|
||||
|
||||
let (inflation, fraction) = super::calculate_for_fraction(total_staked, adjusted_issuance);
|
||||
let current_ratio: f64 = 1.0 + accumulated_commission as f64 / adjusted_issuance as f64;
|
||||
let yearly_current_ratio = current_ratio.powf(365.0) + 1.0;
|
||||
let yearly_current_ratio = current_ratio.powf(365.0) - 1.0;
|
||||
|
||||
let expected_inflation = (inflation.deconstruct() as f64) * yearly_current_ratio / 1_000_000_000.0;
|
||||
let expected_fraction = expected_inflation - (fraction.deconstruct() as f64) / 1_000_000_000.0;
|
||||
let expected_inflation = (inflation.deconstruct() as f64) * yearly_current_ratio / 10_000_000.0;
|
||||
let expected_fraction = (fraction.deconstruct() as f64) * yearly_current_ratio / 10_000_000.0;
|
||||
let expected_reminder = expected_inflation - expected_fraction;
|
||||
|
||||
let inflation_str = format!("{:.4}%", expected_inflation);
|
||||
let fraction_str = format!("{:.4}%", expected_fraction);
|
||||
let treasury_str = format!("{:.4}%", expected_reminder);
|
||||
|
||||
action_tx.send(Action::Inflation(inflation_str))?;
|
||||
action_tx.send(Action::Apy(fraction_str))?;
|
||||
action_tx.send(Action::TreasuryApy(treasury_str))?;
|
||||
action_tx.send(Action::NextReward(accumulated_commission))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user