189b83e769
* Add more data to reward-estimate response * Fix uptime integer division error * typo * Reify tuple response * Fix uptime calculation * Use lambda and sigma instead of ticked versions for delegator and operator rewards calculation * Changelog
42 lines
1.4 KiB
Rust
42 lines
1.4 KiB
Rust
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use crate::client::ThreadsafeValidatorClient;
|
|
use crate::mix_node::models::EconomicDynamicsStats;
|
|
|
|
pub(crate) async fn retrieve_mixnode_econ_stats(
|
|
client: &ThreadsafeValidatorClient,
|
|
identity: &str,
|
|
) -> Option<EconomicDynamicsStats> {
|
|
let stake_saturation = client
|
|
.0
|
|
.validator_api
|
|
.get_mixnode_stake_saturation(identity)
|
|
.await
|
|
.ok()?;
|
|
|
|
let inclusion_probability = client
|
|
.0
|
|
.validator_api
|
|
.get_mixnode_inclusion_probability(identity)
|
|
.await
|
|
.ok()?;
|
|
|
|
let reward_estimation = client
|
|
.0
|
|
.validator_api
|
|
.get_mixnode_reward_estimation(identity)
|
|
.await
|
|
.ok()?;
|
|
|
|
Some(EconomicDynamicsStats {
|
|
stake_saturation: stake_saturation.saturation,
|
|
active_set_inclusion_probability: inclusion_probability.in_active,
|
|
reserve_set_inclusion_probability: inclusion_probability.in_reserve,
|
|
estimated_total_node_reward: reward_estimation.estimated_total_node_reward,
|
|
estimated_operator_reward: reward_estimation.estimated_operator_reward,
|
|
estimated_delegators_reward: reward_estimation.estimated_delegators_reward,
|
|
current_interval_uptime: reward_estimation.reward_params.node.uptime().u128() as u8,
|
|
})
|
|
}
|