diff --git a/common/mixnet-contract/src/lib.rs b/common/mixnet-contract/src/lib.rs index 785497197b..6779514b29 100644 --- a/common/mixnet-contract/src/lib.rs +++ b/common/mixnet-contract/src/lib.rs @@ -13,3 +13,5 @@ pub use gateway::{Gateway, GatewayBond, GatewayOwnershipResponse, PagedGatewayRe pub use mixnode::{Layer, MixNode, MixNodeBond, MixOwnershipResponse, PagedMixnodeResponse}; pub use msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; pub use types::{IdentityKey, IdentityKeyRef, LayerDistribution, SphinxKey, StateParams}; + +pub use types::default_delegation_reward; diff --git a/common/mixnet-contract/src/types.rs b/common/mixnet-contract/src/types.rs index 9d0404daf0..8a202fde61 100644 --- a/common/mixnet-contract/src/types.rs +++ b/common/mixnet-contract/src/types.rs @@ -26,6 +26,10 @@ impl LayerDistribution { } } +pub fn default_delegation_reward() -> Decimal { + Decimal::percent(110) +} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct StateParams { pub epoch_length: u32, // length of an epoch, expressed in hours @@ -34,7 +38,9 @@ pub struct StateParams { pub minimum_gateway_bond: Uint128, // minimum amount a gateway must bond to get into the system pub mixnode_bond_reward_rate: Decimal, // annual reward rate, expressed as a decimal like 1.25 pub gateway_bond_reward_rate: Decimal, // annual reward rate, expressed as a decimal like 1.25 + #[serde(default = "default_delegation_reward")] pub mixnode_delegation_reward_rate: Decimal, // annual reward rate, expressed as a decimal like 1.25 + #[serde(default = "default_delegation_reward")] pub gateway_delegation_reward_rate: Decimal, // annual reward rate, expressed as a decimal like 1.25 pub mixnode_active_set_size: u32, } diff --git a/contracts/mixnet/src/contract.rs b/contracts/mixnet/src/contract.rs index 5487ea451e..9dd24a7eb6 100644 --- a/contracts/mixnet/src/contract.rs +++ b/contracts/mixnet/src/contract.rs @@ -3,7 +3,7 @@ use crate::helpers::calculate_epoch_reward_rate; use crate::state::State; -use crate::storage::{config, layer_distribution}; +use crate::storage::{config, config_read, layer_distribution}; use crate::{error::ContractError, queries, transactions}; use config::defaults::NETWORK_MONITOR_ADDRESS; use cosmwasm_std::{ @@ -181,7 +181,9 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result Result { +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let state = config_read(deps.storage).load().unwrap(); + config(deps.storage).save(&state)?; Ok(Default::default()) } diff --git a/contracts/mixnet/src/state.rs b/contracts/mixnet/src/state.rs index c537366f07..d4f0034ff6 100644 --- a/contracts/mixnet/src/state.rs +++ b/contracts/mixnet/src/state.rs @@ -6,6 +6,8 @@ use mixnet_contract::StateParams; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use mixnet_contract::default_delegation_reward; + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct State { pub owner: Addr, // only the owner account can update state @@ -15,6 +17,8 @@ pub struct State { // helper values to avoid having to recalculate them on every single payment operation pub mixnode_epoch_bond_reward: Decimal, // reward per epoch expressed as a decimal like 0.05 pub gateway_epoch_bond_reward: Decimal, // reward per epoch expressed as a decimal like 0.05 + #[serde(default = "default_delegation_reward")] pub mixnode_epoch_delegation_reward: Decimal, // reward per epoch expressed as a decimal like 0.05 + #[serde(default = "default_delegation_reward")] pub gateway_epoch_delegation_reward: Decimal, // reward per epoch expressed as a decimal like 0.05 }