Correctly show reward percent changes
This commit is contained in:
parent
49c3f14016
commit
bebfa6e93c
|
@ -800,8 +800,9 @@ pub fn process_get_block(
|
||||||
format!(
|
format!(
|
||||||
"◎{:<19.9} {:>13.9}%",
|
"◎{:<19.9} {:>13.9}%",
|
||||||
lamports_to_sol(reward.post_balance),
|
lamports_to_sol(reward.post_balance),
|
||||||
reward.lamports.abs() as f64
|
(reward.lamports.abs() as f64
|
||||||
/ (reward.post_balance as f64 - reward.lamports as f64)
|
/ (reward.post_balance as f64 - reward.lamports as f64))
|
||||||
|
* 100.0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -1662,13 +1662,13 @@ pub(crate) fn fetch_epoch_rewards(
|
||||||
.find(|reward| reward.pubkey == address.to_string())
|
.find(|reward| reward.pubkey == address.to_string())
|
||||||
{
|
{
|
||||||
if reward.post_balance > reward.lamports.try_into().unwrap_or(0) {
|
if reward.post_balance > reward.lamports.try_into().unwrap_or(0) {
|
||||||
let percent_change = reward.lamports.abs() as f64
|
let rate_change = reward.lamports.abs() as f64
|
||||||
/ (reward.post_balance as f64 - reward.lamports as f64);
|
/ (reward.post_balance as f64 - reward.lamports as f64);
|
||||||
|
|
||||||
let apr = wallclock_epoch_duration.map(|wallclock_epoch_duration| {
|
let apr = wallclock_epoch_duration.map(|wallclock_epoch_duration| {
|
||||||
let wallclock_epochs_per_year =
|
let wallclock_epochs_per_year =
|
||||||
(SECONDS_PER_DAY * 356) as f64 / wallclock_epoch_duration;
|
(SECONDS_PER_DAY * 356) as f64 / wallclock_epoch_duration;
|
||||||
percent_change * wallclock_epochs_per_year
|
rate_change * wallclock_epochs_per_year
|
||||||
});
|
});
|
||||||
|
|
||||||
all_epoch_rewards.push(CliEpochReward {
|
all_epoch_rewards.push(CliEpochReward {
|
||||||
|
@ -1676,8 +1676,8 @@ pub(crate) fn fetch_epoch_rewards(
|
||||||
effective_slot,
|
effective_slot,
|
||||||
amount: reward.lamports.abs() as u64,
|
amount: reward.lamports.abs() as u64,
|
||||||
post_balance: reward.post_balance,
|
post_balance: reward.post_balance,
|
||||||
percent_change,
|
percent_change: rate_change * 100.0,
|
||||||
apr,
|
apr: apr.map(|r| r * 100.0),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue