Update tokenomics
This commit is contained in:
Vendored
+3
-29
@@ -37,9 +37,6 @@ struct ValidatorCacheInner {
|
||||
|
||||
current_mixnode_active_set_size: AtomicUsize,
|
||||
current_gateway_active_set_size: AtomicUsize,
|
||||
|
||||
total_mix_stake: RwLock<Cache<u128>>,
|
||||
total_gateway_stake: RwLock<Cache<u128>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Clone)]
|
||||
@@ -79,30 +76,21 @@ impl<C> ValidatorCacheRefresher<C> {
|
||||
where
|
||||
C: CosmWasmClient + Sync,
|
||||
{
|
||||
let (mixnodes, gateways, total_mix_stake, total_gt_state) = tokio::try_join!(
|
||||
let (mixnodes, gateways) = tokio::try_join!(
|
||||
self.nymd_client.get_mixnodes(),
|
||||
self.nymd_client.get_gateways(),
|
||||
self.nymd_client.get_total_mix_stake(),
|
||||
self.nymd_client.get_total_gateway_stake()
|
||||
)?;
|
||||
|
||||
let state_params = self.nymd_client.get_state_params().await?;
|
||||
|
||||
info!(
|
||||
"Updating validator cache. There are {} mixnodes and {} gateways, total_mix_stake is {}",
|
||||
"Updating validator cache. There are {} mixnodes and {} gateways",
|
||||
mixnodes.len(),
|
||||
gateways.len(),
|
||||
total_mix_stake
|
||||
);
|
||||
|
||||
self.cache
|
||||
.update_cache(
|
||||
mixnodes,
|
||||
gateways,
|
||||
total_mix_stake,
|
||||
total_gt_state,
|
||||
state_params,
|
||||
)
|
||||
.update_cache(mixnodes, gateways, state_params)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
@@ -189,8 +177,6 @@ impl ValidatorCache {
|
||||
&self,
|
||||
mut mixnodes: Vec<MixNodeBond>,
|
||||
mut gateways: Vec<GatewayBond>,
|
||||
total_mix_stake: u128,
|
||||
total_gt_stake: u128,
|
||||
state: StateParams,
|
||||
) {
|
||||
// if our data is valid, it means the active sets are available,
|
||||
@@ -232,16 +218,6 @@ impl ValidatorCache {
|
||||
|
||||
self.inner.mixnodes.write().await.set(mixnodes);
|
||||
self.inner.gateways.write().await.set(gateways);
|
||||
self.inner
|
||||
.total_mix_stake
|
||||
.write()
|
||||
.await
|
||||
.set(total_mix_stake);
|
||||
self.inner
|
||||
.total_gateway_stake
|
||||
.write()
|
||||
.await
|
||||
.set(total_gt_stake);
|
||||
}
|
||||
|
||||
pub async fn mixnodes(&self) -> Cache<Vec<MixNodeBond>> {
|
||||
@@ -327,8 +303,6 @@ impl ValidatorCacheInner {
|
||||
active_gateways_available: AtomicBool::new(false),
|
||||
current_mixnode_active_set_size: Default::default(),
|
||||
current_gateway_active_set_size: Default::default(),
|
||||
total_mix_stake: Default::default(),
|
||||
total_gateway_stake: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,25 +94,18 @@ impl<C> Client<C> {
|
||||
Ok(time)
|
||||
}
|
||||
|
||||
pub(crate) async fn get_total_mix_stake(&self) -> Result<u128, ValidatorClientError>
|
||||
pub(crate) async fn get_reward_pool(&self) -> Result<u128, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync,
|
||||
{
|
||||
Ok(self.0.read().await.get_total_mix_stake().await?)
|
||||
Ok(self.0.read().await.get_reward_pool().await?)
|
||||
}
|
||||
|
||||
pub(crate) async fn get_total_gateway_stake(&self) -> Result<u128, ValidatorClientError>
|
||||
pub(crate) async fn get_circulating_supply(&self) -> Result<u128, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync,
|
||||
{
|
||||
Ok(self.0.read().await.get_total_gateway_stake().await?)
|
||||
}
|
||||
|
||||
pub(crate) async fn get_inflation_pool(&self) -> Result<u128, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync,
|
||||
{
|
||||
Ok(self.0.read().await.get_inflation_pool().await?)
|
||||
Ok(self.0.read().await.get_circulating_supply().await?)
|
||||
}
|
||||
|
||||
pub(crate) async fn get_mixnodes(&self) -> Result<Vec<MixNodeBond>, ValidatorClientError>
|
||||
|
||||
@@ -291,13 +291,13 @@ impl Rewarder {
|
||||
// by people hesitating to delegate to nodes without them and thus those nodes disappearing
|
||||
// from the active set (once introduced)
|
||||
let mixnode_delegators = self.produce_active_mixnode_delegators_map().await?;
|
||||
let total_mix_stake = self.nymd_client.get_total_mix_stake().await?;
|
||||
let inflation_pool = self.nymd_client.get_inflation_pool().await?;
|
||||
let k = self
|
||||
.nymd_client
|
||||
.get_state_params()
|
||||
.await?
|
||||
.mixnode_active_set_size;
|
||||
// TODO: get node saturation
|
||||
let reward_pool = self.nymd_client.get_reward_pool().await?;
|
||||
let circulating_supply = self.nymd_client.get_circulating_supply().await?;
|
||||
let state = self.nymd_client.get_state_params().await?;
|
||||
let k = state.mixnode_active_set_size;
|
||||
let period_reward_pool = (reward_pool / 100) * 2_u128;
|
||||
|
||||
// 1. go through all active mixnodes
|
||||
// 2. filter out nodes that are currently not in the active set (as `mixnode_delegators` was obtained by
|
||||
// querying the validator)
|
||||
@@ -325,11 +325,11 @@ impl Rewarder {
|
||||
if cfg!(feature = "tokenomics") {
|
||||
for mix in eligible_nodes.iter_mut() {
|
||||
mix.params = Some(NodeRewardParams::new(
|
||||
inflation_pool,
|
||||
period_reward_pool,
|
||||
k.into(),
|
||||
total_epoch_uptime,
|
||||
None,
|
||||
total_mix_stake,
|
||||
circulating_supply,
|
||||
mix.uptime.u8().into(),
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user